Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
Kiet Lam | 842dad0 | 2014-02-18 18:44:02 -0800 | [diff] [blame] | 2 | * Copyright (c) 2012-2014 The Linux Foundation. All rights reserved. |
| 3 | * |
| 4 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 5 | * |
| 6 | * |
| 7 | * Permission to use, copy, modify, and/or distribute this software for |
| 8 | * any purpose with or without fee is hereby granted, provided that the |
| 9 | * above copyright notice and this permission notice appear in all |
| 10 | * copies. |
| 11 | * |
| 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 13 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 14 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 15 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 16 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 17 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 18 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 19 | * PERFORMANCE OF THIS SOFTWARE. |
| 20 | */ |
| 21 | |
| 22 | /* |
Kiet Lam | aa8e15a | 2014-02-11 23:30:06 -0800 | [diff] [blame] | 23 | * Copyright (c) 2012-2014 Qualcomm Atheros, Inc. |
| 24 | * All Rights Reserved. |
| 25 | * Qualcomm Atheros Confidential and Proprietary. |
Kiet Lam | 842dad0 | 2014-02-18 18:44:02 -0800 | [diff] [blame] | 26 | * |
Gopichand Nakkala | 92f07d8 | 2013-01-08 21:16:34 -0800 | [diff] [blame] | 27 | */ |
Kiet Lam | 842dad0 | 2014-02-18 18:44:02 -0800 | [diff] [blame] | 28 | |
| 29 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 30 | /*======================================================================== |
| 31 | |
| 32 | \file wlan_hdd_main.c |
| 33 | |
| 34 | \brief WLAN Host Device Driver implementation |
| 35 | |
| 36 | Copyright 2008 (c) Qualcomm, Incorporated. All Rights Reserved. |
| 37 | |
| 38 | Qualcomm Confidential and Proprietary. |
| 39 | |
| 40 | ========================================================================*/ |
| 41 | |
| 42 | /**========================================================================= |
| 43 | |
| 44 | EDIT HISTORY FOR FILE |
| 45 | |
| 46 | |
| 47 | This section contains comments describing changes made to the module. |
| 48 | Notice that changes are listed in reverse chronological order. |
| 49 | |
| 50 | |
| 51 | $Header:$ $DateTime: $ $Author: $ |
| 52 | |
| 53 | |
| 54 | when who what, where, why |
| 55 | -------- --- -------------------------------------------------------- |
| 56 | 04/5/09 Shailender Created module. |
| 57 | 02/24/10 Sudhir.S.Kohalli Added to support param for SoftAP module |
| 58 | 06/03/10 js - Added support to hostapd driven deauth/disassoc/mic failure |
| 59 | ==========================================================================*/ |
| 60 | |
| 61 | /*-------------------------------------------------------------------------- |
| 62 | Include Files |
| 63 | ------------------------------------------------------------------------*/ |
| 64 | //#include <wlan_qct_driver.h> |
| 65 | #include <wlan_hdd_includes.h> |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 66 | #include <vos_api.h> |
| 67 | #include <vos_sched.h> |
| 68 | #include <vos_power.h> |
| 69 | #include <linux/etherdevice.h> |
| 70 | #include <linux/firmware.h> |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 71 | #ifdef ANI_BUS_TYPE_PLATFORM |
| 72 | #include <linux/wcnss_wlan.h> |
| 73 | #endif //ANI_BUS_TYPE_PLATFORM |
| 74 | #ifdef ANI_BUS_TYPE_PCI |
| 75 | #include "wcnss_wlan.h" |
| 76 | #endif /* ANI_BUS_TYPE_PCI */ |
| 77 | #include <wlan_hdd_tx_rx.h> |
| 78 | #include <palTimer.h> |
| 79 | #include <wniApi.h> |
| 80 | #include <wlan_nlink_srv.h> |
| 81 | #include <wlan_btc_svc.h> |
| 82 | #include <wlan_hdd_cfg.h> |
| 83 | #include <wlan_ptt_sock_svc.h> |
Vinay Krishna Eranna | d938c42 | 2014-03-10 17:14:21 +0530 | [diff] [blame] | 84 | #include <wlan_logging_sock_svc.h> |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 85 | #include <wlan_hdd_wowl.h> |
| 86 | #include <wlan_hdd_misc.h> |
| 87 | #include <wlan_hdd_wext.h> |
| 88 | #ifdef WLAN_BTAMP_FEATURE |
| 89 | #include <bap_hdd_main.h> |
| 90 | #include <bapInternal.h> |
| 91 | #endif // WLAN_BTAMP_FEATURE |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 92 | #include "wlan_hdd_trace.h" |
| 93 | #include "vos_types.h" |
| 94 | #include "vos_trace.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 95 | #include <linux/wireless.h> |
| 96 | #include <net/cfg80211.h> |
Vinay Krishna Eranna | d9cbdb3 | 2014-01-16 12:59:10 +0530 | [diff] [blame] | 97 | #include <linux/inetdevice.h> |
| 98 | #include <net/addrconf.h> |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 99 | #include "wlan_hdd_cfg80211.h" |
| 100 | #include "wlan_hdd_p2p.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 101 | #include <linux/rtnetlink.h> |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 102 | int wlan_hdd_ftm_start(hdd_context_t *pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 103 | #include "sapApi.h" |
| 104 | #include <linux/semaphore.h> |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 105 | #include <linux/ctype.h> |
Arun Kumar Khandavalli | 74fe303 | 2014-03-17 20:35:34 +0530 | [diff] [blame] | 106 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)) |
| 107 | #include <soc/qcom/subsystem_restart.h> |
| 108 | #else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 109 | #include <mach/subsystem_restart.h> |
Arun Kumar Khandavalli | 74fe303 | 2014-03-17 20:35:34 +0530 | [diff] [blame] | 110 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 111 | #include <wlan_hdd_hostapd.h> |
| 112 | #include <wlan_hdd_softap_tx_rx.h> |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 113 | #include "cfgApi.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 114 | #include "wlan_hdd_dev_pwr.h" |
| 115 | #ifdef WLAN_BTAMP_FEATURE |
| 116 | #include "bap_hdd_misc.h" |
| 117 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 118 | #include "wlan_qct_pal_trace.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 119 | #include "qwlan_version.h" |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 120 | #include "wlan_qct_wda.h" |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 121 | #ifdef FEATURE_WLAN_TDLS |
| 122 | #include "wlan_hdd_tdls.h" |
| 123 | #endif |
Yue Ma | 0d4891e | 2013-08-06 17:01:45 -0700 | [diff] [blame] | 124 | #include "wlan_hdd_debugfs.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 125 | |
| 126 | #ifdef MODULE |
| 127 | #define WLAN_MODULE_NAME module_name(THIS_MODULE) |
| 128 | #else |
| 129 | #define WLAN_MODULE_NAME "wlan" |
| 130 | #endif |
| 131 | |
| 132 | #ifdef TIMER_MANAGER |
| 133 | #define TIMER_MANAGER_STR " +TIMER_MANAGER" |
| 134 | #else |
| 135 | #define TIMER_MANAGER_STR "" |
| 136 | #endif |
| 137 | |
| 138 | #ifdef MEMORY_DEBUG |
| 139 | #define MEMORY_DEBUG_STR " +MEMORY_DEBUG" |
| 140 | #else |
| 141 | #define MEMORY_DEBUG_STR "" |
| 142 | #endif |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 143 | #define MAX_WAIT_FOR_ROC_COMPLETION 3 |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 144 | /* the Android framework expects this param even though we don't use it */ |
| 145 | #define BUF_LEN 20 |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 146 | static char fwpath_buffer[BUF_LEN]; |
| 147 | static struct kparam_string fwpath = { |
| 148 | .string = fwpath_buffer, |
| 149 | .maxlen = BUF_LEN, |
| 150 | }; |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 151 | |
| 152 | static char *country_code; |
| 153 | static int enable_11d = -1; |
| 154 | static int enable_dfs_chan_scan = -1; |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 155 | static int gbcnMissRate = -1; |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 156 | |
Madan Mohan Koyyalamudi | 05f313c | 2012-09-18 19:19:15 -0700 | [diff] [blame] | 157 | #ifndef MODULE |
Madan Mohan Koyyalamudi | dfd6aa8 | 2012-10-18 20:18:43 -0700 | [diff] [blame] | 158 | static int wlan_hdd_inited; |
Madan Mohan Koyyalamudi | 05f313c | 2012-09-18 19:19:15 -0700 | [diff] [blame] | 159 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 160 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 161 | /* |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 162 | * spinlock for synchronizing asynchronous request/response |
| 163 | * (full description of use in wlan_hdd_main.h) |
| 164 | */ |
| 165 | DEFINE_SPINLOCK(hdd_context_lock); |
| 166 | |
| 167 | /* |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 168 | * The rate at which the driver sends RESTART event to supplicant |
| 169 | * once the function 'vos_wlanRestart()' is called |
| 170 | * |
| 171 | */ |
| 172 | #define WLAN_HDD_RESTART_RETRY_DELAY_MS 5000 /* 5 second */ |
| 173 | #define WLAN_HDD_RESTART_RETRY_MAX_CNT 5 /* 5 retries */ |
Varun Reddy Yeturu | 6d99ac8 | 2013-05-08 14:15:35 -0700 | [diff] [blame] | 174 | |
| 175 | /* |
| 176 | * Size of Driver command strings from upper layer |
| 177 | */ |
| 178 | #define SIZE_OF_SETROAMMODE 11 /* size of SETROAMMODE */ |
| 179 | #define SIZE_OF_GETROAMMODE 11 /* size of GETROAMMODE */ |
| 180 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 181 | #if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD) |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 182 | #define TID_MIN_VALUE 0 |
| 183 | #define TID_MAX_VALUE 15 |
| 184 | static VOS_STATUS hdd_get_tsm_stats(hdd_adapter_t *pAdapter, const tANI_U8 tid, |
| 185 | tAniTrafStrmMetrics* pTsmMetrics); |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 186 | static VOS_STATUS hdd_parse_ese_beacon_req(tANI_U8 *pValue, |
| 187 | tCsrEseBeaconReq *pEseBcnReq); |
| 188 | #endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */ |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 189 | |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 190 | static VOS_STATUS wlan_hdd_init_channels_for_cc(hdd_context_t *pHddCtx); |
Atul Mittal | 1d72242 | 2014-03-19 11:15:07 +0530 | [diff] [blame] | 191 | /* |
| 192 | * Maximum buffer size used for returning the data back to user space |
| 193 | */ |
| 194 | #define WLAN_MAX_BUF_SIZE 1024 |
| 195 | #define WLAN_PRIV_DATA_MAX_LEN 8192 |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 196 | /* |
| 197 | * Driver miracast parameters 0-Disabled |
| 198 | * 1-Source, 2-Sink |
| 199 | */ |
| 200 | #define WLAN_HDD_DRIVER_MIRACAST_CFG_MIN_VAL 0 |
| 201 | #define WLAN_HDD_DRIVER_MIRACAST_CFG_MAX_VAL 2 |
| 202 | |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 203 | //wait time for beacon miss rate. |
| 204 | #define BCN_MISS_RATE_TIME 500 |
| 205 | |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 206 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 207 | static struct wake_lock wlan_wake_lock; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 208 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 209 | /* set when SSR is needed after unload */ |
Madan Mohan Koyyalamudi | b5da533 | 2012-10-15 17:23:21 -0700 | [diff] [blame] | 210 | static e_hdd_ssr_required isSsrRequired = HDD_SSR_NOT_REQUIRED; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 211 | |
| 212 | //internal function declaration |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 213 | static VOS_STATUS wlan_hdd_framework_restart(hdd_context_t *pHddCtx); |
| 214 | static void wlan_hdd_restart_init(hdd_context_t *pHddCtx); |
| 215 | static void wlan_hdd_restart_deinit(hdd_context_t *pHddCtx); |
| 216 | void wlan_hdd_restart_timer_cb(v_PVOID_t usrDataForCallback); |
Sameer Thalappil | 45931fb | 2013-02-01 11:18:05 -0800 | [diff] [blame] | 217 | void hdd_set_wlan_suspend_mode(bool suspend); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 218 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 219 | v_U16_t hdd_select_queue(struct net_device *dev, |
| 220 | struct sk_buff *skb); |
| 221 | |
| 222 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 223 | static void hdd_set_multicast_list(struct net_device *dev); |
| 224 | #endif |
| 225 | |
| 226 | void hdd_wlan_initial_scan(hdd_adapter_t *pAdapter); |
| 227 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 228 | #if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR) |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 229 | void hdd_getBand_helper(hdd_context_t *pHddCtx, int *pBand); |
| 230 | static VOS_STATUS hdd_parse_channellist(tANI_U8 *pValue, tANI_U8 *pChannelList, tANI_U8 *pNumChannels); |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 231 | static VOS_STATUS hdd_parse_send_action_frame_data(tANI_U8 *pValue, tANI_U8 *pTargetApBssid, |
| 232 | tANI_U8 *pChannel, tANI_U8 *pDwellTime, |
| 233 | tANI_U8 **pBuf, tANI_U8 *pBufLen); |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 234 | static VOS_STATUS hdd_parse_reassoc_command_data(tANI_U8 *pValue, |
| 235 | tANI_U8 *pTargetApBssid, |
| 236 | tANI_U8 *pChannel); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 237 | #endif |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 238 | #if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD) |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 239 | VOS_STATUS hdd_parse_get_cckm_ie(tANI_U8 *pValue, tANI_U8 **pCckmIe, tANI_U8 *pCckmIeLen); |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 240 | #endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */ |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 241 | |
Mihir Shete | e1093ba | 2014-01-21 20:13:32 +0530 | [diff] [blame] | 242 | static VOS_STATUS wlan_hdd_init_channels(hdd_context_t *pHddCtx); |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 243 | const char * hdd_device_modetoString(v_U8_t device_mode) |
| 244 | { |
| 245 | switch(device_mode) |
| 246 | { |
| 247 | CASE_RETURN_STRING( WLAN_HDD_INFRA_STATION ); |
| 248 | CASE_RETURN_STRING( WLAN_HDD_SOFTAP ); |
| 249 | CASE_RETURN_STRING( WLAN_HDD_P2P_CLIENT ); |
| 250 | CASE_RETURN_STRING( WLAN_HDD_P2P_GO ); |
| 251 | CASE_RETURN_STRING( WLAN_HDD_MONITOR); |
| 252 | CASE_RETURN_STRING( WLAN_HDD_FTM ); |
| 253 | CASE_RETURN_STRING( WLAN_HDD_IBSS ); |
| 254 | CASE_RETURN_STRING( WLAN_HDD_P2P_DEVICE ); |
| 255 | default: |
| 256 | return "device_mode Unknown"; |
| 257 | } |
| 258 | } |
Mihir Shete | e1093ba | 2014-01-21 20:13:32 +0530 | [diff] [blame] | 259 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 260 | static int hdd_netdev_notifier_call(struct notifier_block * nb, |
| 261 | unsigned long state, |
| 262 | void *ndev) |
| 263 | { |
| 264 | struct net_device *dev = ndev; |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 265 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 27cee45 | 2013-03-27 11:10:24 -0700 | [diff] [blame] | 266 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 267 | #ifdef WLAN_BTAMP_FEATURE |
| 268 | VOS_STATUS status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 269 | #endif |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 270 | long result; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 271 | |
| 272 | //Make sure that this callback corresponds to our device. |
Jeff Johnson | 27cee45 | 2013-03-27 11:10:24 -0700 | [diff] [blame] | 273 | if ((strncmp(dev->name, "wlan", 4)) && |
Amar Singhal | 4c723bd | 2013-03-25 18:14:15 -0700 | [diff] [blame] | 274 | (strncmp(dev->name, "p2p", 3))) |
| 275 | return NOTIFY_DONE; |
| 276 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 277 | if (!dev->ieee80211_ptr) |
Jeff Johnson | 27cee45 | 2013-03-27 11:10:24 -0700 | [diff] [blame] | 278 | return NOTIFY_DONE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 279 | |
Jeff Johnson | 27cee45 | 2013-03-27 11:10:24 -0700 | [diff] [blame] | 280 | if (NULL == pAdapter) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 281 | { |
Jeff Johnson | a8a1a48 | 2012-12-12 16:49:33 -0800 | [diff] [blame] | 282 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: HDD Adapter Null Pointer", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 283 | VOS_ASSERT(0); |
| 284 | return NOTIFY_DONE; |
| 285 | } |
| 286 | |
Jeff Johnson | 27cee45 | 2013-03-27 11:10:24 -0700 | [diff] [blame] | 287 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 288 | if (NULL == pHddCtx) |
| 289 | { |
| 290 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: HDD Context Null Pointer", __func__); |
| 291 | VOS_ASSERT(0); |
| 292 | return NOTIFY_DONE; |
| 293 | } |
Sameer Thalappil | 1406797 | 2014-01-23 14:54:54 -0800 | [diff] [blame] | 294 | if (pHddCtx->isLogpInProgress) |
| 295 | return NOTIFY_DONE; |
| 296 | |
Jeff Johnson | 27cee45 | 2013-03-27 11:10:24 -0700 | [diff] [blame] | 297 | |
| 298 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s New Net Device State = %lu", |
| 299 | __func__, dev->name, state); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 300 | |
| 301 | switch (state) { |
| 302 | case NETDEV_REGISTER: |
| 303 | break; |
| 304 | |
| 305 | case NETDEV_UNREGISTER: |
| 306 | break; |
| 307 | |
| 308 | case NETDEV_UP: |
| 309 | break; |
| 310 | |
| 311 | case NETDEV_DOWN: |
| 312 | break; |
| 313 | |
| 314 | case NETDEV_CHANGE: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 315 | if(TRUE == pAdapter->isLinkUpSvcNeeded) |
| 316 | complete(&pAdapter->linkup_event_var); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 317 | break; |
| 318 | |
| 319 | case NETDEV_GOING_DOWN: |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 320 | result = wlan_hdd_scan_abort(pAdapter); |
Girish Gowli | 4bf7a63 | 2014-06-12 13:42:11 +0530 | [diff] [blame] | 321 | if (result < 0) |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 322 | { |
| 323 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 324 | "%s: Timeout occurred while waiting for abortscan %ld", |
| 325 | __func__, result); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 326 | } |
| 327 | else |
| 328 | { |
| 329 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 330 | "%s: Scan Abort Successful" , __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 331 | } |
| 332 | #ifdef WLAN_BTAMP_FEATURE |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 333 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"%s: disabling AMP", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 334 | status = WLANBAP_StopAmp(); |
| 335 | if(VOS_STATUS_SUCCESS != status ) |
| 336 | { |
| 337 | pHddCtx->isAmpAllowed = VOS_TRUE; |
| 338 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 339 | "%s: Failed to stop AMP", __func__); |
| 340 | } |
| 341 | else |
| 342 | { |
| 343 | //a state m/c implementation in PAL is TBD to avoid this delay |
| 344 | msleep(500); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 345 | if ( pHddCtx->isAmpAllowed ) |
| 346 | { |
| 347 | WLANBAP_DeregisterFromHCI(); |
| 348 | pHddCtx->isAmpAllowed = VOS_FALSE; |
| 349 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 350 | } |
| 351 | #endif //WLAN_BTAMP_FEATURE |
| 352 | break; |
| 353 | |
| 354 | default: |
| 355 | break; |
| 356 | } |
| 357 | |
| 358 | return NOTIFY_DONE; |
| 359 | } |
| 360 | |
| 361 | struct notifier_block hdd_netdev_notifier = { |
| 362 | .notifier_call = hdd_netdev_notifier_call, |
| 363 | }; |
| 364 | |
| 365 | /*--------------------------------------------------------------------------- |
| 366 | * Function definitions |
| 367 | *-------------------------------------------------------------------------*/ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 368 | void hdd_unregister_mcast_bcast_filter(hdd_context_t *pHddCtx); |
| 369 | void hdd_register_mcast_bcast_filter(hdd_context_t *pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 370 | //variable to hold the insmod parameters |
Madan Mohan Koyyalamudi | dfd6aa8 | 2012-10-18 20:18:43 -0700 | [diff] [blame] | 371 | static int con_mode; |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 372 | #ifndef MODULE |
| 373 | /* current con_mode - used only for statically linked driver |
| 374 | * con_mode is changed by userspace to indicate a mode change which will |
| 375 | * result in calling the module exit and init functions. The module |
| 376 | * exit function will clean up based on the value of con_mode prior to it |
| 377 | * being changed by userspace. So curr_con_mode records the current con_mode |
| 378 | * for exit when con_mode becomes the next mode for init |
| 379 | */ |
Madan Mohan Koyyalamudi | dfd6aa8 | 2012-10-18 20:18:43 -0700 | [diff] [blame] | 380 | static int curr_con_mode; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 381 | #endif |
| 382 | |
Varun Reddy Yeturu | 587e680 | 2013-01-24 12:21:41 -0800 | [diff] [blame] | 383 | /**--------------------------------------------------------------------------- |
| 384 | |
| 385 | \brief hdd_vos_trace_enable() - Configure initial VOS Trace enable |
| 386 | |
| 387 | Called immediately after the cfg.ini is read in order to configure |
| 388 | the desired trace levels. |
| 389 | |
| 390 | \param - moduleId - module whose trace level is being configured |
| 391 | \param - bitmask - bitmask of log levels to be enabled |
| 392 | |
| 393 | \return - void |
| 394 | |
| 395 | --------------------------------------------------------------------------*/ |
| 396 | static void hdd_vos_trace_enable(VOS_MODULE_ID moduleId, v_U32_t bitmask) |
| 397 | { |
| 398 | wpt_tracelevel level; |
| 399 | |
| 400 | /* if the bitmask is the default value, then a bitmask was not |
| 401 | specified in cfg.ini, so leave the logging level alone (it |
| 402 | will remain at the "compiled in" default value) */ |
| 403 | if (CFG_VOS_TRACE_ENABLE_DEFAULT == bitmask) |
| 404 | { |
| 405 | return; |
| 406 | } |
| 407 | |
| 408 | /* a mask was specified. start by disabling all logging */ |
| 409 | vos_trace_setValue(moduleId, VOS_TRACE_LEVEL_NONE, 0); |
| 410 | |
| 411 | /* now cycle through the bitmask until all "set" bits are serviced */ |
| 412 | level = VOS_TRACE_LEVEL_FATAL; |
| 413 | while (0 != bitmask) |
| 414 | { |
| 415 | if (bitmask & 1) |
| 416 | { |
| 417 | vos_trace_setValue(moduleId, level, 1); |
| 418 | } |
| 419 | level++; |
| 420 | bitmask >>= 1; |
| 421 | } |
| 422 | } |
| 423 | |
| 424 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 425 | /**--------------------------------------------------------------------------- |
| 426 | |
| 427 | \brief hdd_wdi_trace_enable() - Configure initial WDI Trace enable |
| 428 | |
| 429 | Called immediately after the cfg.ini is read in order to configure |
| 430 | the desired trace levels in the WDI. |
| 431 | |
| 432 | \param - moduleId - module whose trace level is being configured |
| 433 | \param - bitmask - bitmask of log levels to be enabled |
| 434 | |
| 435 | \return - void |
| 436 | |
| 437 | --------------------------------------------------------------------------*/ |
| 438 | static void hdd_wdi_trace_enable(wpt_moduleid moduleId, v_U32_t bitmask) |
| 439 | { |
| 440 | wpt_tracelevel level; |
| 441 | |
| 442 | /* if the bitmask is the default value, then a bitmask was not |
| 443 | specified in cfg.ini, so leave the logging level alone (it |
| 444 | will remain at the "compiled in" default value) */ |
| 445 | if (CFG_WDI_TRACE_ENABLE_DEFAULT == bitmask) |
| 446 | { |
| 447 | return; |
| 448 | } |
| 449 | |
| 450 | /* a mask was specified. start by disabling all logging */ |
| 451 | wpalTraceSetLevel(moduleId, eWLAN_PAL_TRACE_LEVEL_NONE, 0); |
| 452 | |
| 453 | /* now cycle through the bitmask until all "set" bits are serviced */ |
| 454 | level = eWLAN_PAL_TRACE_LEVEL_FATAL; |
| 455 | while (0 != bitmask) |
| 456 | { |
| 457 | if (bitmask & 1) |
| 458 | { |
| 459 | wpalTraceSetLevel(moduleId, level, 1); |
| 460 | } |
| 461 | level++; |
| 462 | bitmask >>= 1; |
| 463 | } |
| 464 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 465 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 466 | /* |
| 467 | * FUNCTION: wlan_hdd_validate_context |
| 468 | * This function is used to check the HDD context |
| 469 | */ |
| 470 | int wlan_hdd_validate_context(hdd_context_t *pHddCtx) |
| 471 | { |
| 472 | ENTER(); |
| 473 | |
| 474 | if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini) |
| 475 | { |
| 476 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 477 | "%s: HDD context is Null", __func__); |
| 478 | return -ENODEV; |
| 479 | } |
| 480 | |
| 481 | if (pHddCtx->isLogpInProgress) |
| 482 | { |
| 483 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 484 | "%s: LOGP in Progress. Ignore!!!", __func__); |
| 485 | return -EAGAIN; |
| 486 | } |
| 487 | |
Mihir Shete | 1815629 | 2014-03-11 15:38:30 +0530 | [diff] [blame] | 488 | if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx)) |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 489 | { |
| 490 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 491 | "%s: Unloading/Loading in Progress. Ignore!!!", __func__); |
| 492 | return -EAGAIN; |
| 493 | } |
| 494 | return 0; |
| 495 | } |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 496 | #ifdef CONFIG_ENABLE_LINUX_REG |
| 497 | void hdd_checkandupdate_phymode( hdd_context_t *pHddCtx) |
| 498 | { |
| 499 | hdd_adapter_t *pAdapter = NULL; |
| 500 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 501 | eCsrPhyMode phyMode; |
| 502 | hdd_config_t *cfg_param = NULL; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 503 | |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 504 | if (NULL == pHddCtx) |
| 505 | { |
| 506 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 507 | "HDD Context is null !!"); |
| 508 | return ; |
| 509 | } |
| 510 | |
| 511 | pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 512 | if (NULL == pAdapter) |
| 513 | { |
| 514 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 515 | "pAdapter is null !!"); |
| 516 | return ; |
| 517 | } |
| 518 | |
| 519 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 520 | if (NULL == pHddStaCtx) |
| 521 | { |
| 522 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 523 | "pHddStaCtx is null !!"); |
| 524 | return ; |
| 525 | } |
| 526 | |
| 527 | cfg_param = pHddCtx->cfg_ini; |
| 528 | if (NULL == cfg_param) |
| 529 | { |
| 530 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 531 | "cfg_params not available !!"); |
| 532 | return ; |
| 533 | } |
| 534 | |
| 535 | phyMode = sme_GetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter)); |
| 536 | |
| 537 | if (!pHddCtx->isVHT80Allowed) |
| 538 | { |
| 539 | if ((eCSR_DOT11_MODE_AUTO == phyMode) || |
| 540 | (eCSR_DOT11_MODE_11ac == phyMode) || |
| 541 | (eCSR_DOT11_MODE_11ac_ONLY == phyMode)) |
| 542 | { |
| 543 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 544 | "Setting phymode to 11n!!"); |
| 545 | sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_DOT11_MODE_11n); |
| 546 | } |
| 547 | } |
| 548 | else |
| 549 | { |
| 550 | /*New country Supports 11ac as well resetting value back from .ini*/ |
| 551 | sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 552 | hdd_cfg_xlate_to_csr_phy_mode(cfg_param->dot11Mode)); |
| 553 | return ; |
| 554 | } |
| 555 | |
| 556 | if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) && |
| 557 | ((eCSR_CFG_DOT11_MODE_11AC_ONLY == pHddStaCtx->conn_info.dot11Mode) || |
| 558 | (eCSR_CFG_DOT11_MODE_11AC == pHddStaCtx->conn_info.dot11Mode))) |
| 559 | { |
| 560 | VOS_STATUS vosStatus; |
| 561 | |
| 562 | // need to issue a disconnect to CSR. |
| 563 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 564 | vosStatus = sme_RoamDisconnect(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 565 | pAdapter->sessionId, |
| 566 | eCSR_DISCONNECT_REASON_UNSPECIFIED ); |
| 567 | |
| 568 | if (VOS_STATUS_SUCCESS == vosStatus) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 569 | { |
| 570 | long ret; |
| 571 | |
| 572 | ret = wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var, |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 573 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 574 | if (0 >= ret) |
| 575 | hddLog(LOGE, FL("failure waiting for disconnect_comp_var %ld"), |
| 576 | ret); |
| 577 | } |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 578 | |
| 579 | } |
| 580 | } |
| 581 | #else |
Gopichand Nakkala | dacbcb5 | 2013-04-18 16:41:54 +0530 | [diff] [blame] | 582 | void hdd_checkandupdate_phymode( hdd_adapter_t *pAdapter, char *country_code) |
| 583 | { |
| 584 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 585 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 586 | hdd_config_t *cfg_param; |
| 587 | eCsrPhyMode phyMode; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 588 | long ret; |
Gopichand Nakkala | dacbcb5 | 2013-04-18 16:41:54 +0530 | [diff] [blame] | 589 | |
| 590 | if (NULL == pHddCtx) |
| 591 | { |
| 592 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 593 | "HDD Context is null !!"); |
| 594 | return ; |
| 595 | } |
| 596 | |
| 597 | cfg_param = pHddCtx->cfg_ini; |
| 598 | |
| 599 | if (NULL == cfg_param) |
| 600 | { |
| 601 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 602 | "cfg_params not available !!"); |
| 603 | return ; |
| 604 | } |
| 605 | |
| 606 | phyMode = sme_GetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter)); |
| 607 | |
| 608 | if (NULL != strstr(cfg_param->listOfNon11acCountryCode, country_code)) |
| 609 | { |
| 610 | if ((eCSR_DOT11_MODE_AUTO == phyMode) || |
| 611 | (eCSR_DOT11_MODE_11ac == phyMode) || |
| 612 | (eCSR_DOT11_MODE_11ac_ONLY == phyMode)) |
| 613 | { |
| 614 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 615 | "Setting phymode to 11n!!"); |
| 616 | sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_DOT11_MODE_11n); |
| 617 | } |
| 618 | } |
| 619 | else |
| 620 | { |
| 621 | /*New country Supports 11ac as well resetting value back from .ini*/ |
| 622 | sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 623 | hdd_cfg_xlate_to_csr_phy_mode(cfg_param->dot11Mode)); |
| 624 | return ; |
| 625 | } |
| 626 | |
| 627 | if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) && |
| 628 | ((eCSR_CFG_DOT11_MODE_11AC_ONLY == pHddStaCtx->conn_info.dot11Mode) || |
| 629 | (eCSR_CFG_DOT11_MODE_11AC == pHddStaCtx->conn_info.dot11Mode))) |
| 630 | { |
| 631 | VOS_STATUS vosStatus; |
| 632 | |
| 633 | // need to issue a disconnect to CSR. |
| 634 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 635 | vosStatus = sme_RoamDisconnect(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 636 | pAdapter->sessionId, |
| 637 | eCSR_DISCONNECT_REASON_UNSPECIFIED ); |
| 638 | |
| 639 | if (VOS_STATUS_SUCCESS == vosStatus) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 640 | { |
| 641 | ret = wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var, |
Gopichand Nakkala | dacbcb5 | 2013-04-18 16:41:54 +0530 | [diff] [blame] | 642 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 643 | if (ret <= 0) |
| 644 | { |
| 645 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 646 | "wait on disconnect_comp_var is failed %ld", ret); |
| 647 | } |
| 648 | } |
Gopichand Nakkala | dacbcb5 | 2013-04-18 16:41:54 +0530 | [diff] [blame] | 649 | |
| 650 | } |
| 651 | } |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 652 | #endif //CONFIG_ENABLE_LINUX_REG |
Gopichand Nakkala | dacbcb5 | 2013-04-18 16:41:54 +0530 | [diff] [blame] | 653 | |
Tushnim Bhattacharyya | 9cdf608 | 2013-04-21 16:33:30 -0700 | [diff] [blame] | 654 | void hdd_checkandupdate_dfssetting( hdd_adapter_t *pAdapter, char *country_code) |
| 655 | { |
| 656 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 657 | hdd_config_t *cfg_param; |
| 658 | |
| 659 | if (NULL == pHddCtx) |
| 660 | { |
| 661 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 662 | "HDD Context is null !!"); |
| 663 | return ; |
| 664 | } |
| 665 | |
| 666 | cfg_param = pHddCtx->cfg_ini; |
| 667 | |
| 668 | if (NULL == cfg_param) |
| 669 | { |
| 670 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 671 | "cfg_params not available !!"); |
| 672 | return ; |
| 673 | } |
| 674 | |
| 675 | if (NULL != strstr(cfg_param->listOfNonDfsCountryCode, country_code)) |
| 676 | { |
| 677 | /*New country doesn't support DFS */ |
| 678 | sme_UpdateDfsSetting(WLAN_HDD_GET_HAL_CTX(pAdapter), 0); |
| 679 | } |
| 680 | else |
| 681 | { |
| 682 | /*New country Supports DFS as well resetting value back from .ini*/ |
| 683 | sme_UpdateDfsSetting(WLAN_HDD_GET_HAL_CTX(pAdapter), cfg_param->enableDFSChnlScan); |
| 684 | } |
| 685 | |
| 686 | } |
| 687 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 688 | #ifdef FEATURE_WLAN_BATCH_SCAN |
| 689 | |
| 690 | /**--------------------------------------------------------------------------- |
| 691 | |
| 692 | \brief hdd_extract_assigned_int_from_str() - Extracts assigned integer from |
| 693 | input string |
| 694 | |
| 695 | This function extracts assigned integer from string in below format: |
| 696 | "STRING=10" : extracts integer 10 from this string |
| 697 | |
| 698 | \param - pInPtr Pointer to input string |
| 699 | \param - base Base for string to int conversion(10 for decimal 16 for hex) |
| 700 | \param - pOutPtr Pointer to variable in which extracted integer needs to be |
| 701 | assigned |
| 702 | \param - pLastArg to tell whether it is last arguement in input string or |
| 703 | not |
| 704 | |
| 705 | \return - NULL for failure cases |
| 706 | pointer to next arguement in input string for success cases |
| 707 | --------------------------------------------------------------------------*/ |
| 708 | static tANI_U8 * |
| 709 | hdd_extract_assigned_int_from_str |
| 710 | ( |
| 711 | tANI_U8 *pInPtr, |
| 712 | tANI_U8 base, |
| 713 | tANI_U32 *pOutPtr, |
| 714 | tANI_U8 *pLastArg |
| 715 | ) |
| 716 | { |
| 717 | int tempInt; |
| 718 | int v = 0; |
| 719 | char buf[32]; |
| 720 | int val = 0; |
| 721 | *pLastArg = FALSE; |
| 722 | |
| 723 | pInPtr = strnchr(pInPtr, strlen(pInPtr), EQUALS_TO_ASCII_VALUE); |
| 724 | if (NULL == pInPtr) |
| 725 | { |
| 726 | return NULL; |
| 727 | } |
| 728 | |
| 729 | pInPtr++; |
| 730 | |
| 731 | while ((SPACE_ASCII_VALUE == *pInPtr) && ('\0' != *pInPtr)) pInPtr++; |
| 732 | |
| 733 | val = sscanf(pInPtr, "%32s ", buf); |
| 734 | if (val < 0 && val > strlen(pInPtr)) |
| 735 | { |
| 736 | return NULL; |
| 737 | } |
| 738 | pInPtr += val; |
| 739 | v = kstrtos32(buf, base, &tempInt); |
| 740 | if (v < 0) |
| 741 | { |
| 742 | return NULL; |
| 743 | } |
Rajeev Kumar | 4d93d84 | 2014-01-02 18:31:21 -0800 | [diff] [blame] | 744 | if (tempInt < 0) |
| 745 | { |
| 746 | tempInt = 0; |
| 747 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 748 | *pOutPtr = tempInt; |
| 749 | |
| 750 | pInPtr = strnchr(pInPtr, strlen(pInPtr), SPACE_ASCII_VALUE); |
| 751 | if (NULL == pInPtr) |
| 752 | { |
| 753 | *pLastArg = TRUE; |
| 754 | return NULL; |
| 755 | } |
| 756 | while ((SPACE_ASCII_VALUE == *pInPtr) && ('\0' != *pInPtr)) pInPtr++; |
| 757 | |
| 758 | return pInPtr; |
| 759 | } |
| 760 | |
| 761 | /**--------------------------------------------------------------------------- |
| 762 | |
| 763 | \brief hdd_extract_assigned_char_from_str() - Extracts assigned char from |
| 764 | input string |
| 765 | |
| 766 | This function extracts assigned character from string in below format: |
| 767 | "STRING=A" : extracts char 'A' from this string |
| 768 | |
| 769 | \param - pInPtr Pointer to input string |
| 770 | \param - pOutPtr Pointer to variable in which extracted char needs to be |
| 771 | assigned |
| 772 | \param - pLastArg to tell whether it is last arguement in input string or |
| 773 | not |
| 774 | |
| 775 | \return - NULL for failure cases |
| 776 | pointer to next arguement in input string for success cases |
| 777 | --------------------------------------------------------------------------*/ |
| 778 | static tANI_U8 * |
| 779 | hdd_extract_assigned_char_from_str |
| 780 | ( |
| 781 | tANI_U8 *pInPtr, |
| 782 | tANI_U8 *pOutPtr, |
| 783 | tANI_U8 *pLastArg |
| 784 | ) |
| 785 | { |
| 786 | *pLastArg = FALSE; |
| 787 | |
| 788 | pInPtr = strnchr(pInPtr, strlen(pInPtr), EQUALS_TO_ASCII_VALUE); |
| 789 | if (NULL == pInPtr) |
| 790 | { |
| 791 | return NULL; |
| 792 | } |
| 793 | |
| 794 | pInPtr++; |
| 795 | |
| 796 | while ((SPACE_ASCII_VALUE == *pInPtr) && ('\0' != *pInPtr)) pInPtr++; |
| 797 | |
| 798 | *pOutPtr = *pInPtr; |
| 799 | |
| 800 | pInPtr = strnchr(pInPtr, strlen(pInPtr), SPACE_ASCII_VALUE); |
| 801 | if (NULL == pInPtr) |
| 802 | { |
| 803 | *pLastArg = TRUE; |
| 804 | return NULL; |
| 805 | } |
| 806 | while ((SPACE_ASCII_VALUE == *pInPtr) && ('\0' != *pInPtr)) pInPtr++; |
| 807 | |
| 808 | return pInPtr; |
| 809 | } |
| 810 | |
| 811 | |
| 812 | /**--------------------------------------------------------------------------- |
| 813 | |
| 814 | \brief hdd_parse_set_batchscan_command () - HDD parse set batch scan command |
| 815 | |
| 816 | This function parses set batch scan command in below format: |
| 817 | WLS_BATCHING_SET <space> followed by below arguements |
| 818 | "SCANFREQ=XX" : Optional defaults to 30 sec |
| 819 | "MSCAN=XX" : Required number of scans to attempt to batch |
| 820 | "BESTN=XX" : Best Network (RSSI) defaults to 16 |
| 821 | "CHANNEL=<X,Y>" : optional defaults to all channels, can list 'A'or` B. |
| 822 | A. implies only 5 GHz , B. implies only 2.4GHz |
| 823 | "RTT=X" : optional defaults to 0 |
| 824 | returns the MIN of MSCAN or the max # of scans firmware can cache or -1 on |
| 825 | error |
| 826 | |
| 827 | For example input commands: |
| 828 | 1) WLS_BATCHING_SET SCANFREQ=60 MSCAN=10 BESTN=20 CHANNEL=A RTT=0 -> This is |
| 829 | translated into set batch scan with following parameters: |
| 830 | a) Frequence 60 seconds |
| 831 | b) Batch 10 scans together |
| 832 | c) Best RSSI to be 20 |
| 833 | d) 5GHz band only |
| 834 | e) RTT is equal to 0 |
| 835 | |
| 836 | \param - pValue Pointer to input channel list |
| 837 | \param - pHddSetBatchScanReq Pointer to HDD batch scan request structure |
| 838 | |
| 839 | \return - 0 for success non-zero for failure |
| 840 | |
| 841 | --------------------------------------------------------------------------*/ |
| 842 | static int |
| 843 | hdd_parse_set_batchscan_command |
| 844 | ( |
| 845 | tANI_U8 *pValue, |
| 846 | tSirSetBatchScanReq *pHddSetBatchScanReq |
| 847 | ) |
| 848 | { |
| 849 | tANI_U8 *inPtr = pValue; |
| 850 | tANI_U8 val = 0; |
| 851 | tANI_U8 lastArg = 0; |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 852 | tANI_U32 nScanFreq; |
| 853 | tANI_U32 nMscan; |
| 854 | tANI_U32 nBestN; |
| 855 | tANI_U8 ucRfBand; |
| 856 | tANI_U32 nRtt; |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 857 | tANI_U32 temp; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 858 | |
| 859 | /*initialize default values*/ |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 860 | nScanFreq = HDD_SET_BATCH_SCAN_DEFAULT_FREQ; |
| 861 | ucRfBand = HDD_SET_BATCH_SCAN_DEFAULT_BAND; |
| 862 | nRtt = 0; |
| 863 | nBestN = HDD_SET_BATCH_SCAN_BEST_NETWORK; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 864 | |
| 865 | /*go to space after WLS_BATCHING_SET command*/ |
| 866 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 867 | /*no argument after the command*/ |
| 868 | if (NULL == inPtr) |
| 869 | { |
| 870 | return -EINVAL; |
| 871 | } |
| 872 | |
| 873 | /*no space after the command*/ |
| 874 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 875 | { |
| 876 | return -EINVAL; |
| 877 | } |
| 878 | |
| 879 | /*removing empty spaces*/ |
| 880 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
| 881 | |
| 882 | /*no argument followed by spaces*/ |
| 883 | if ('\0' == *inPtr) |
| 884 | { |
| 885 | return -EINVAL; |
| 886 | } |
| 887 | |
| 888 | /*check and parse SCANFREQ*/ |
| 889 | if ((strncmp(inPtr, "SCANFREQ", 8) == 0)) |
| 890 | { |
| 891 | inPtr = hdd_extract_assigned_int_from_str(inPtr, 10, |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 892 | &temp, &lastArg); |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 893 | |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 894 | if (0 != temp) |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 895 | { |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 896 | nScanFreq = temp; |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 897 | } |
| 898 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 899 | if ( (NULL == inPtr) || (TRUE == lastArg)) |
| 900 | { |
| 901 | return -EINVAL; |
| 902 | } |
| 903 | } |
| 904 | |
| 905 | /*check and parse MSCAN*/ |
| 906 | if ((strncmp(inPtr, "MSCAN", 5) == 0)) |
| 907 | { |
| 908 | inPtr = hdd_extract_assigned_int_from_str(inPtr, 10, |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 909 | &nMscan, &lastArg); |
| 910 | |
| 911 | if (0 == nMscan) |
| 912 | { |
| 913 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 914 | "invalid MSCAN=%d", nMscan); |
| 915 | return -EINVAL; |
| 916 | } |
| 917 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 918 | if (TRUE == lastArg) |
| 919 | { |
| 920 | goto done; |
| 921 | } |
| 922 | else if (NULL == inPtr) |
| 923 | { |
| 924 | return -EINVAL; |
| 925 | } |
| 926 | } |
| 927 | else |
| 928 | { |
| 929 | return -EINVAL; |
| 930 | } |
| 931 | |
| 932 | /*check and parse BESTN*/ |
| 933 | if ((strncmp(inPtr, "BESTN", 5) == 0)) |
| 934 | { |
| 935 | inPtr = hdd_extract_assigned_int_from_str(inPtr, 10, |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 936 | &temp, &lastArg); |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 937 | |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 938 | if (0 != temp) |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 939 | { |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 940 | nBestN = temp; |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 941 | } |
| 942 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 943 | if (TRUE == lastArg) |
| 944 | { |
| 945 | goto done; |
| 946 | } |
| 947 | else if (NULL == inPtr) |
| 948 | { |
| 949 | return -EINVAL; |
| 950 | } |
| 951 | } |
| 952 | |
| 953 | /*check and parse CHANNEL*/ |
| 954 | if ((strncmp(inPtr, "CHANNEL", 7) == 0)) |
| 955 | { |
| 956 | inPtr = hdd_extract_assigned_char_from_str(inPtr, &val, &lastArg); |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 957 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 958 | if (('A' == val) || ('a' == val)) |
| 959 | { |
c_hpothu | ebf8973 | 2014-02-25 13:00:24 +0530 | [diff] [blame] | 960 | ucRfBand = HDD_SET_BATCH_SCAN_5GHz_BAND_ONLY; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 961 | } |
| 962 | else if (('B' == val) || ('b' == val)) |
| 963 | { |
c_hpothu | ebf8973 | 2014-02-25 13:00:24 +0530 | [diff] [blame] | 964 | ucRfBand = HDD_SET_BATCH_SCAN_24GHz_BAND_ONLY; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 965 | } |
| 966 | else |
| 967 | { |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 968 | ucRfBand = HDD_SET_BATCH_SCAN_DEFAULT_BAND; |
| 969 | } |
| 970 | |
| 971 | if (TRUE == lastArg) |
| 972 | { |
| 973 | goto done; |
| 974 | } |
| 975 | else if (NULL == inPtr) |
| 976 | { |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 977 | return -EINVAL; |
| 978 | } |
| 979 | } |
| 980 | |
| 981 | /*check and parse RTT*/ |
| 982 | if ((strncmp(inPtr, "RTT", 3) == 0)) |
| 983 | { |
| 984 | inPtr = hdd_extract_assigned_int_from_str(inPtr, 10, |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 985 | &nRtt, &lastArg); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 986 | if (TRUE == lastArg) |
| 987 | { |
| 988 | goto done; |
| 989 | } |
| 990 | if (NULL == inPtr) |
| 991 | { |
| 992 | return -EINVAL; |
| 993 | } |
| 994 | } |
| 995 | |
| 996 | |
| 997 | done: |
| 998 | |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 999 | pHddSetBatchScanReq->scanFrequency = nScanFreq; |
| 1000 | pHddSetBatchScanReq->numberOfScansToBatch = nMscan; |
| 1001 | pHddSetBatchScanReq->bestNetwork = nBestN; |
| 1002 | pHddSetBatchScanReq->rfBand = ucRfBand; |
| 1003 | pHddSetBatchScanReq->rtt = nRtt; |
| 1004 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1005 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1006 | "Received WLS_BATCHING_SET with SCANFREQ=%d " |
| 1007 | "MSCAN=%d BESTN=%d CHANNEL=%d RTT=%d", |
| 1008 | pHddSetBatchScanReq->scanFrequency, |
| 1009 | pHddSetBatchScanReq->numberOfScansToBatch, |
| 1010 | pHddSetBatchScanReq->bestNetwork, |
| 1011 | pHddSetBatchScanReq->rfBand, |
| 1012 | pHddSetBatchScanReq->rtt); |
| 1013 | |
| 1014 | return 0; |
| 1015 | }/*End of hdd_parse_set_batchscan_command*/ |
| 1016 | |
| 1017 | /**--------------------------------------------------------------------------- |
| 1018 | |
| 1019 | \brief hdd_set_batch_scan_req_callback () - This function is called after |
| 1020 | receiving set batch scan response from FW and it saves set batch scan |
| 1021 | response data FW to HDD context and sets the completion event on |
| 1022 | which hdd_ioctl is waiting |
| 1023 | |
| 1024 | \param - callbackContext Pointer to HDD adapter |
| 1025 | \param - pRsp Pointer to set batch scan response data received from FW |
| 1026 | |
| 1027 | \return - nothing |
| 1028 | |
| 1029 | --------------------------------------------------------------------------*/ |
| 1030 | static void hdd_set_batch_scan_req_callback |
| 1031 | ( |
| 1032 | void *callbackContext, |
| 1033 | tSirSetBatchScanRsp *pRsp |
| 1034 | ) |
| 1035 | { |
| 1036 | hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext; |
| 1037 | tSirSetBatchScanRsp *pHddSetBatchScanRsp; |
| 1038 | |
| 1039 | /*sanity check*/ |
| 1040 | if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) |
| 1041 | { |
| 1042 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1043 | "%s: Invalid pAdapter magic", __func__); |
| 1044 | VOS_ASSERT(0); |
| 1045 | return; |
| 1046 | } |
| 1047 | pHddSetBatchScanRsp = &pAdapter->hddSetBatchScanRsp; |
| 1048 | |
| 1049 | /*save set batch scan response*/ |
| 1050 | pHddSetBatchScanRsp->nScansToBatch = pRsp->nScansToBatch; |
| 1051 | |
| 1052 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
| 1053 | "Received set batch scan rsp from FW with nScansToBatch=%d", |
| 1054 | pHddSetBatchScanRsp->nScansToBatch); |
| 1055 | |
| 1056 | pAdapter->hdd_wait_for_set_batch_scan_rsp = FALSE; |
| 1057 | complete(&pAdapter->hdd_set_batch_scan_req_var); |
| 1058 | |
| 1059 | return; |
| 1060 | }/*End of hdd_set_batch_scan_req_callback*/ |
| 1061 | |
| 1062 | |
| 1063 | /**--------------------------------------------------------------------------- |
| 1064 | |
| 1065 | \brief hdd_populate_batch_scan_rsp_queue () - This function stores AP meta |
| 1066 | info in hdd batch scan response queue |
| 1067 | |
| 1068 | \param - pAdapter Pointer to hdd adapter |
| 1069 | \param - pAPMetaInfo Pointer to access point meta info |
| 1070 | \param - scanId scan ID of batch scan response |
| 1071 | \param - isLastAp tells whether AP is last AP in batch scan response or not |
| 1072 | |
| 1073 | \return - nothing |
| 1074 | |
| 1075 | --------------------------------------------------------------------------*/ |
| 1076 | static void hdd_populate_batch_scan_rsp_queue( hdd_adapter_t* pAdapter, |
| 1077 | tpSirBatchScanNetworkInfo pApMetaInfo, tANI_U32 scanId, v_BOOL_t isLastAp) |
| 1078 | { |
| 1079 | tHddBatchScanRsp *pHead; |
| 1080 | tHddBatchScanRsp *pNode; |
| 1081 | tHddBatchScanRsp *pPrev; |
| 1082 | tHddBatchScanRsp *pTemp; |
| 1083 | tANI_U8 ssidLen; |
| 1084 | |
| 1085 | /*head of hdd batch scan response queue*/ |
| 1086 | pHead = pAdapter->pBatchScanRsp; |
| 1087 | |
| 1088 | pNode = (tHddBatchScanRsp *)vos_mem_malloc(sizeof(tHddBatchScanRsp)); |
| 1089 | if (NULL == pNode) |
| 1090 | { |
| 1091 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1092 | "%s: Could not allocate memory", __func__); |
| 1093 | VOS_ASSERT(0); |
| 1094 | return; |
| 1095 | } |
| 1096 | |
| 1097 | vos_mem_copy(pNode->ApInfo.bssid, pApMetaInfo->bssid, |
| 1098 | sizeof(pNode->ApInfo.bssid)); |
| 1099 | ssidLen = strlen(pApMetaInfo->ssid); |
| 1100 | if (SIR_MAX_SSID_SIZE < ssidLen) |
| 1101 | { |
| 1102 | /*invalid scan result*/ |
| 1103 | vos_mem_free(pNode); |
| 1104 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1105 | "%s: Invalid AP meta info ssidlen %d", __func__, ssidLen); |
| 1106 | return; |
| 1107 | } |
| 1108 | vos_mem_copy(pNode->ApInfo.ssid, pApMetaInfo->ssid, ssidLen); |
| 1109 | /*null terminate ssid*/ |
| 1110 | pNode->ApInfo.ssid[ssidLen] = '\0'; |
| 1111 | pNode->ApInfo.ch = pApMetaInfo->ch; |
| 1112 | pNode->ApInfo.rssi = pApMetaInfo->rssi; |
| 1113 | pNode->ApInfo.age = pApMetaInfo->timestamp; |
| 1114 | pNode->ApInfo.batchId = scanId; |
| 1115 | pNode->ApInfo.isLastAp = isLastAp; |
| 1116 | |
| 1117 | pNode->pNext = NULL; |
| 1118 | if (NULL == pHead) |
| 1119 | { |
| 1120 | pAdapter->pBatchScanRsp = pNode; |
| 1121 | } |
| 1122 | else |
| 1123 | { |
| 1124 | pTemp = pHead; |
| 1125 | while (NULL != pTemp) |
| 1126 | { |
| 1127 | pPrev = pTemp; |
| 1128 | pTemp = pTemp->pNext; |
| 1129 | } |
| 1130 | pPrev->pNext = pNode; |
| 1131 | } |
| 1132 | |
| 1133 | return; |
| 1134 | }/*End of hdd_populate_batch_scan_rsp_queue*/ |
| 1135 | |
| 1136 | /**--------------------------------------------------------------------------- |
| 1137 | |
| 1138 | \brief hdd_batch_scan_result_ind_callback () - This function is called after |
| 1139 | receiving batch scan response indication from FW. It saves get batch scan |
| 1140 | response data in HDD batch scan response queue. This callback sets the |
| 1141 | completion event on which hdd_ioctl is waiting only after getting complete |
| 1142 | batch scan response data from FW |
| 1143 | |
| 1144 | \param - callbackContext Pointer to HDD adapter |
| 1145 | \param - pRsp Pointer to get batch scan response data received from FW |
| 1146 | |
| 1147 | \return - nothing |
| 1148 | |
| 1149 | --------------------------------------------------------------------------*/ |
| 1150 | static void hdd_batch_scan_result_ind_callback |
| 1151 | ( |
| 1152 | void *callbackContext, |
| 1153 | void *pRsp |
| 1154 | ) |
| 1155 | { |
| 1156 | v_BOOL_t isLastAp; |
| 1157 | tANI_U32 numApMetaInfo; |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1158 | tANI_U32 numNetworkInScanList; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1159 | tANI_U32 numberScanList; |
| 1160 | tANI_U32 nextScanListOffset; |
| 1161 | tANI_U32 nextApMetaInfoOffset; |
| 1162 | hdd_adapter_t* pAdapter; |
| 1163 | tpSirBatchScanList pScanList; |
| 1164 | tpSirBatchScanNetworkInfo pApMetaInfo; |
| 1165 | tpSirBatchScanResultIndParam pBatchScanRsp;/*batch scan rsp data from FW*/ |
| 1166 | tSirSetBatchScanReq *pReq; |
| 1167 | |
| 1168 | pAdapter = (hdd_adapter_t *)callbackContext; |
| 1169 | /*sanity check*/ |
Rajeev Kumar | 5286bb9 | 2013-12-05 11:52:10 -0800 | [diff] [blame] | 1170 | if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)) |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1171 | { |
| 1172 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1173 | "%s: Invalid pAdapter magic", __func__); |
| 1174 | VOS_ASSERT(0); |
| 1175 | return; |
| 1176 | } |
| 1177 | |
| 1178 | /*initialize locals*/ |
| 1179 | pReq = &pAdapter->hddSetBatchScanReq; |
| 1180 | pBatchScanRsp = (tpSirBatchScanResultIndParam)pRsp; |
| 1181 | isLastAp = FALSE; |
| 1182 | numApMetaInfo = 0; |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1183 | numNetworkInScanList = 0; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1184 | numberScanList = 0; |
| 1185 | nextScanListOffset = 0; |
| 1186 | nextApMetaInfoOffset = 0; |
| 1187 | pScanList = NULL; |
| 1188 | pApMetaInfo = NULL; |
| 1189 | |
| 1190 | if ((NULL == pBatchScanRsp) || (NULL == pReq)) |
| 1191 | { |
| 1192 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1193 | "%s: pBatchScanRsp is %p pReq %p", __func__, pBatchScanRsp, pReq); |
| 1194 | isLastAp = TRUE; |
| 1195 | goto done; |
| 1196 | } |
| 1197 | |
| 1198 | pAdapter->numScanList = numberScanList = pBatchScanRsp->numScanLists; |
| 1199 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1200 | "Batch scan rsp: numberScalList %d", numberScanList); |
| 1201 | |
| 1202 | if ((!numberScanList) || (numberScanList > pReq->numberOfScansToBatch)) |
| 1203 | { |
| 1204 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1205 | "%s: numberScanList %d", __func__, numberScanList); |
| 1206 | isLastAp = TRUE; |
| 1207 | goto done; |
| 1208 | } |
| 1209 | |
| 1210 | while (numberScanList) |
| 1211 | { |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1212 | pScanList = (tpSirBatchScanList)((tANI_U8 *)pBatchScanRsp->scanResults + |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1213 | nextScanListOffset); |
| 1214 | if (NULL == pScanList) |
| 1215 | { |
| 1216 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1217 | "%s: pScanList is %p", __func__, pScanList); |
| 1218 | isLastAp = TRUE; |
| 1219 | goto done; |
| 1220 | } |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1221 | numNetworkInScanList = numApMetaInfo = pScanList->numNetworksInScanList; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1222 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1223 | "Batch scan rsp: numApMetaInfo %d scanId %d", |
| 1224 | numApMetaInfo, pScanList->scanId); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1225 | |
| 1226 | if ((!numApMetaInfo) || (numApMetaInfo > pReq->bestNetwork)) |
| 1227 | { |
| 1228 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1229 | "%s: numApMetaInfo %d", __func__, numApMetaInfo); |
| 1230 | isLastAp = TRUE; |
| 1231 | goto done; |
| 1232 | } |
| 1233 | |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1234 | /*Initialize next AP meta info offset for next scan list*/ |
| 1235 | nextApMetaInfoOffset = 0; |
| 1236 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1237 | while (numApMetaInfo) |
| 1238 | { |
| 1239 | pApMetaInfo = (tpSirBatchScanNetworkInfo)(pScanList->scanList + |
| 1240 | nextApMetaInfoOffset); |
| 1241 | if (NULL == pApMetaInfo) |
| 1242 | { |
| 1243 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1244 | "%s: pApMetaInfo is %p", __func__, pApMetaInfo); |
| 1245 | isLastAp = TRUE; |
| 1246 | goto done; |
| 1247 | } |
| 1248 | /*calculate AP age*/ |
| 1249 | pApMetaInfo->timestamp = |
| 1250 | pBatchScanRsp->timestamp - pApMetaInfo->timestamp; |
| 1251 | |
| 1252 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
Arif Hussain | a7c8e41 | 2013-11-20 11:06:42 -0800 | [diff] [blame] | 1253 | "%s: bssId "MAC_ADDRESS_STR |
| 1254 | " ch %d rssi %d timestamp %d", __func__, |
| 1255 | MAC_ADDR_ARRAY(pApMetaInfo->bssid), |
| 1256 | pApMetaInfo->ch, pApMetaInfo->rssi, |
| 1257 | pApMetaInfo->timestamp); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1258 | |
| 1259 | /*mark last AP in batch scan response*/ |
| 1260 | if ((TRUE == pBatchScanRsp->isLastResult) && |
| 1261 | (1 == numberScanList) && (1 == numApMetaInfo)) |
| 1262 | { |
| 1263 | isLastAp = TRUE; |
| 1264 | } |
| 1265 | |
| 1266 | mutex_lock(&pAdapter->hdd_batch_scan_lock); |
| 1267 | /*store batch scan repsonse in hdd queue*/ |
| 1268 | hdd_populate_batch_scan_rsp_queue(pAdapter, pApMetaInfo, |
| 1269 | pScanList->scanId, isLastAp); |
| 1270 | mutex_unlock(&pAdapter->hdd_batch_scan_lock); |
| 1271 | |
| 1272 | nextApMetaInfoOffset += sizeof(tSirBatchScanNetworkInfo); |
| 1273 | numApMetaInfo--; |
| 1274 | } |
| 1275 | |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1276 | nextScanListOffset += ((sizeof(tSirBatchScanList) - sizeof(tANI_U8)) |
| 1277 | + (sizeof(tSirBatchScanNetworkInfo) |
| 1278 | * numNetworkInScanList)); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1279 | numberScanList--; |
| 1280 | } |
| 1281 | |
| 1282 | done: |
| 1283 | |
| 1284 | /*notify hdd_ioctl only if complete batch scan rsp is received and it was |
| 1285 | requested from hdd_ioctl*/ |
| 1286 | if ((TRUE == pAdapter->hdd_wait_for_get_batch_scan_rsp) && |
| 1287 | (TRUE == isLastAp)) |
| 1288 | { |
| 1289 | pAdapter->hdd_wait_for_get_batch_scan_rsp = FALSE; |
| 1290 | complete(&pAdapter->hdd_get_batch_scan_req_var); |
| 1291 | } |
| 1292 | |
| 1293 | return; |
| 1294 | }/*End of hdd_batch_scan_result_ind_callback*/ |
| 1295 | |
| 1296 | /**--------------------------------------------------------------------------- |
| 1297 | |
| 1298 | \brief hdd_format_batch_scan_rsp () - This function formats batch scan |
| 1299 | response as per batch scan FR request format by putting proper markers |
| 1300 | |
| 1301 | \param - pDest pointer to destination buffer |
| 1302 | \param - cur_len current length |
| 1303 | \param - tot_len total remaining size which can be written to user space |
| 1304 | \param - pApMetaInfo Pointer to get batch scan response AP meta info |
| 1305 | \param - pAdapter Pointer to HDD adapter |
| 1306 | |
| 1307 | \return - ret no of characters written |
| 1308 | |
| 1309 | --------------------------------------------------------------------------*/ |
| 1310 | static tANI_U32 |
| 1311 | hdd_format_batch_scan_rsp |
| 1312 | ( |
| 1313 | tANI_U8 *pDest, |
| 1314 | tANI_U32 cur_len, |
| 1315 | tANI_U32 tot_len, |
| 1316 | tHddBatchScanRsp *pApMetaInfo, |
| 1317 | hdd_adapter_t* pAdapter |
| 1318 | ) |
| 1319 | { |
| 1320 | tANI_U32 ret = 0; |
| 1321 | tANI_U32 rem_len = 0; |
| 1322 | tANI_U8 temp_len = 0; |
| 1323 | tANI_U8 temp_total_len = 0; |
| 1324 | tANI_U8 temp[HDD_BATCH_SCAN_AP_META_INFO_SIZE]; |
| 1325 | tANI_U8 *pTemp = temp; |
| 1326 | |
| 1327 | /*Batch scan reponse needs to be returned to user space in |
| 1328 | following format: |
| 1329 | "scancount=X\n" where X is the number of scans in current batch |
| 1330 | batch |
| 1331 | "trunc\n" optional present if current scan truncated |
| 1332 | "bssid=XX:XX:XX:XX:XX:XX\n" |
| 1333 | "ssid=XXXX\n" |
| 1334 | "freq=X\n" frequency in Mhz |
| 1335 | "level=XX\n" |
| 1336 | "age=X\n" ms |
| 1337 | "dist=X\n" cm (-1 if not available) |
| 1338 | "errror=X\n" (-1if not available) |
| 1339 | "====\n" (end of ap marker) |
| 1340 | "####\n" (end of scan marker) |
| 1341 | "----\n" (end of results)*/ |
| 1342 | /*send scan result in above format to user space based on |
| 1343 | available length*/ |
| 1344 | /*The GET response may have more data than the driver can return in its |
| 1345 | buffer. In that case the buffer should be filled to the nearest complete |
| 1346 | scan, ending with "%%%%".Subsequent callsshould return the remaining data |
| 1347 | starting with the next scan (optional .trunc\n., .apcount=X\n., etc). |
| 1348 | The final buffer should end with "----\n"*/ |
| 1349 | |
| 1350 | /*sanity*/ |
| 1351 | if (cur_len > tot_len) |
| 1352 | { |
| 1353 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1354 | "%s: invaid cur_len %d tot_len %d", __func__, cur_len, tot_len); |
| 1355 | return 0; |
| 1356 | } |
| 1357 | else |
| 1358 | { |
| 1359 | rem_len = (tot_len - cur_len); |
| 1360 | } |
| 1361 | |
| 1362 | /*end scan marker*/ |
| 1363 | if (pApMetaInfo->ApInfo.batchId != pAdapter->prev_batch_id) |
| 1364 | { |
| 1365 | temp_len = snprintf(pTemp, sizeof(temp), "####\n"); |
| 1366 | pTemp += temp_len; |
| 1367 | temp_total_len += temp_len; |
| 1368 | } |
| 1369 | |
| 1370 | /*bssid*/ |
| 1371 | temp_len = snprintf(pTemp, sizeof(temp), |
| 1372 | "bssid=0x%x:0x%x:0x%x:0x%x:0x%x:0x%x\n", |
| 1373 | pApMetaInfo->ApInfo.bssid[0], pApMetaInfo->ApInfo.bssid[1], |
| 1374 | pApMetaInfo->ApInfo.bssid[2], pApMetaInfo->ApInfo.bssid[3], |
| 1375 | pApMetaInfo->ApInfo.bssid[4], pApMetaInfo->ApInfo.bssid[5]); |
| 1376 | pTemp += temp_len; |
| 1377 | temp_total_len += temp_len; |
| 1378 | |
| 1379 | /*ssid*/ |
| 1380 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "ssid=%s\n", |
| 1381 | pApMetaInfo->ApInfo.ssid); |
| 1382 | pTemp += temp_len; |
| 1383 | temp_total_len += temp_len; |
| 1384 | |
| 1385 | /*freq*/ |
| 1386 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "freq=%d\n", |
Rajeev Kumar | c40f751 | 2013-11-04 14:13:23 -0800 | [diff] [blame] | 1387 | sme_ChnToFreq(pApMetaInfo->ApInfo.ch)); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1388 | pTemp += temp_len; |
| 1389 | temp_total_len += temp_len; |
| 1390 | |
| 1391 | /*level*/ |
| 1392 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "level=%d\n", |
| 1393 | pApMetaInfo->ApInfo.rssi); |
| 1394 | pTemp += temp_len; |
| 1395 | temp_total_len += temp_len; |
| 1396 | |
| 1397 | /*age*/ |
Jeff Johnson | 0279779 | 2013-10-26 19:17:13 -0700 | [diff] [blame] | 1398 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "age=%d\n", |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1399 | pApMetaInfo->ApInfo.age); |
| 1400 | pTemp += temp_len; |
| 1401 | temp_total_len += temp_len; |
| 1402 | |
| 1403 | /*dist*/ |
| 1404 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "dist=-1\n"); |
| 1405 | pTemp += temp_len; |
| 1406 | temp_total_len += temp_len; |
| 1407 | |
| 1408 | /*error*/ |
| 1409 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "error=-1\n"); |
| 1410 | pTemp += temp_len; |
| 1411 | temp_total_len += temp_len; |
| 1412 | |
| 1413 | /*end AP marker*/ |
| 1414 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "====\n"); |
| 1415 | pTemp += temp_len; |
| 1416 | temp_total_len += temp_len; |
| 1417 | |
| 1418 | /*last AP in batch scan response*/ |
| 1419 | if(TRUE == pApMetaInfo->ApInfo.isLastAp) |
| 1420 | { |
| 1421 | /*end scan marker*/ |
| 1422 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "####\n"); |
| 1423 | pTemp += temp_len; |
| 1424 | temp_total_len += temp_len; |
| 1425 | |
| 1426 | /*end batch scan result marker*/ |
| 1427 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "----\n"); |
| 1428 | pTemp += temp_len; |
| 1429 | temp_total_len += temp_len; |
Kiet Lam | aa8e15a | 2014-02-11 23:30:06 -0800 | [diff] [blame] | 1430 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1431 | } |
| 1432 | |
| 1433 | if (temp_total_len < rem_len) |
| 1434 | { |
| 1435 | ret = temp_total_len + 1; |
| 1436 | strlcpy(pDest, temp, ret); |
| 1437 | pAdapter->isTruncated = FALSE; |
| 1438 | } |
| 1439 | else |
| 1440 | { |
| 1441 | pAdapter->isTruncated = TRUE; |
| 1442 | if (rem_len >= strlen("%%%%")) |
| 1443 | { |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 1444 | ret = snprintf(pDest, sizeof(temp), "%%%%"); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1445 | } |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 1446 | else |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1447 | { |
| 1448 | ret = 0; |
| 1449 | } |
| 1450 | } |
| 1451 | |
| 1452 | return ret; |
| 1453 | |
| 1454 | }/*End of hdd_format_batch_scan_rsp*/ |
| 1455 | |
| 1456 | /**--------------------------------------------------------------------------- |
| 1457 | |
| 1458 | \brief hdd_populate_user_batch_scan_rsp() - This function populates user data |
| 1459 | buffer starting with head of hdd batch scan response queue |
| 1460 | |
| 1461 | \param - pAdapter Pointer to HDD adapter |
| 1462 | \param - pDest Pointer to user data buffer |
| 1463 | \param - cur_len current offset in user buffer |
| 1464 | \param - rem_len remaining no of bytes in user buffer |
| 1465 | |
| 1466 | \return - number of bytes written in user buffer |
| 1467 | |
| 1468 | --------------------------------------------------------------------------*/ |
| 1469 | |
| 1470 | tANI_U32 hdd_populate_user_batch_scan_rsp |
| 1471 | ( |
| 1472 | hdd_adapter_t* pAdapter, |
| 1473 | tANI_U8 *pDest, |
| 1474 | tANI_U32 cur_len, |
| 1475 | tANI_U32 rem_len |
| 1476 | ) |
| 1477 | { |
| 1478 | tHddBatchScanRsp *pHead; |
| 1479 | tHddBatchScanRsp *pPrev; |
| 1480 | tANI_U32 len; |
| 1481 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1482 | pAdapter->isTruncated = FALSE; |
| 1483 | |
| 1484 | /*head of hdd batch scan response queue*/ |
| 1485 | pHead = pAdapter->pBatchScanRsp; |
| 1486 | while (pHead) |
| 1487 | { |
| 1488 | len = hdd_format_batch_scan_rsp(pDest, cur_len, rem_len, pHead, |
| 1489 | pAdapter); |
| 1490 | pDest += len; |
Rajeev Kumar | 292d2bb | 2013-10-23 15:01:44 -0700 | [diff] [blame] | 1491 | pDest--; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1492 | cur_len += len; |
| 1493 | if(TRUE == pAdapter->isTruncated) |
| 1494 | { |
| 1495 | /*result is truncated return rest of scan rsp in next req*/ |
| 1496 | cur_len = rem_len; |
| 1497 | break; |
| 1498 | } |
| 1499 | pPrev = pHead; |
| 1500 | pHead = pHead->pNext; |
| 1501 | pAdapter->pBatchScanRsp = pHead; |
Rajeev Kumar | be17d8b | 2014-01-10 15:39:45 -0800 | [diff] [blame] | 1502 | if (TRUE == pPrev->ApInfo.isLastAp) |
| 1503 | { |
| 1504 | pAdapter->prev_batch_id = 0; |
| 1505 | } |
| 1506 | else |
| 1507 | { |
| 1508 | pAdapter->prev_batch_id = pPrev->ApInfo.batchId; |
| 1509 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1510 | vos_mem_free(pPrev); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 1511 | pPrev = NULL; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1512 | } |
| 1513 | |
| 1514 | return cur_len; |
| 1515 | }/*End of hdd_populate_user_batch_scan_rsp*/ |
| 1516 | |
| 1517 | /**--------------------------------------------------------------------------- |
| 1518 | |
| 1519 | \brief hdd_return_batch_scan_rsp_to_user () - This function returns batch |
| 1520 | scan response data from HDD queue to user space |
| 1521 | It does following in detail: |
| 1522 | a) if HDD has enough data in its queue then it 1st copies data to user |
| 1523 | space and then send get batch scan indication message to FW. In this |
| 1524 | case it does not wait on any event and batch scan response data will |
| 1525 | be populated in HDD response queue in MC thread context after receiving |
| 1526 | indication from FW |
| 1527 | b) else send get batch scan indication message to FW and wait on an event |
| 1528 | which will be set once HDD receives complete batch scan response from |
| 1529 | FW and then this function returns batch scan response to user space |
| 1530 | |
| 1531 | \param - pAdapter Pointer to HDD adapter |
| 1532 | \param - pPrivData Pointer to priv_data |
| 1533 | |
| 1534 | \return - 0 for success -EFAULT for failure |
| 1535 | |
| 1536 | --------------------------------------------------------------------------*/ |
| 1537 | |
| 1538 | int hdd_return_batch_scan_rsp_to_user |
| 1539 | ( |
| 1540 | hdd_adapter_t* pAdapter, |
| 1541 | hdd_priv_data_t *pPrivData, |
| 1542 | tANI_U8 *command |
| 1543 | ) |
| 1544 | { |
| 1545 | tANI_U8 *pDest; |
| 1546 | tANI_U32 count = 0; |
| 1547 | tANI_U32 len = 0; |
| 1548 | tANI_U32 cur_len = 0; |
| 1549 | tANI_U32 rem_len = 0; |
| 1550 | eHalStatus halStatus; |
| 1551 | unsigned long rc; |
| 1552 | tSirTriggerBatchScanResultInd *pReq; |
| 1553 | |
| 1554 | pReq = &pAdapter->hddTriggerBatchScanResultInd; |
| 1555 | pReq->param = 0;/*batch scan client*/ |
| 1556 | pDest = (tANI_U8 *)(command + pPrivData->used_len); |
| 1557 | pAdapter->hdd_wait_for_get_batch_scan_rsp = FALSE; |
| 1558 | |
| 1559 | cur_len = pPrivData->used_len; |
| 1560 | if (pPrivData->total_len > pPrivData->used_len) |
| 1561 | { |
| 1562 | rem_len = pPrivData->total_len - pPrivData->used_len; |
| 1563 | } |
| 1564 | else |
| 1565 | { |
| 1566 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1567 | "%s: Invalid user data buffer total_len %d used_len %d", |
| 1568 | __func__, pPrivData->total_len, pPrivData->used_len); |
| 1569 | return -EFAULT; |
| 1570 | } |
| 1571 | |
| 1572 | mutex_lock(&pAdapter->hdd_batch_scan_lock); |
| 1573 | len = hdd_populate_user_batch_scan_rsp(pAdapter, pDest, |
| 1574 | cur_len, rem_len); |
| 1575 | mutex_unlock(&pAdapter->hdd_batch_scan_lock); |
| 1576 | |
| 1577 | /*enough scan result available in cache to return to user space or |
| 1578 | scan result needs to be fetched 1st from fw and then return*/ |
Rajeev Kumar | 99db626 | 2013-11-11 15:23:36 -0800 | [diff] [blame] | 1579 | if (len == cur_len) |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1580 | { |
| 1581 | pAdapter->hdd_wait_for_get_batch_scan_rsp = TRUE; |
| 1582 | halStatus = sme_TriggerBatchScanResultInd( |
| 1583 | WLAN_HDD_GET_HAL_CTX(pAdapter), pReq, |
| 1584 | pAdapter->sessionId, hdd_batch_scan_result_ind_callback, |
| 1585 | pAdapter); |
| 1586 | if ( eHAL_STATUS_SUCCESS == halStatus ) |
| 1587 | { |
| 1588 | if (TRUE == pAdapter->hdd_wait_for_get_batch_scan_rsp) |
| 1589 | { |
| 1590 | INIT_COMPLETION(pAdapter->hdd_get_batch_scan_req_var); |
| 1591 | rc = wait_for_completion_timeout( |
| 1592 | &pAdapter->hdd_get_batch_scan_req_var, |
| 1593 | msecs_to_jiffies(HDD_GET_BATCH_SCAN_RSP_TIME_OUT)); |
| 1594 | if (0 == rc) |
| 1595 | { |
| 1596 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1597 | "%s: Timeout waiting to fetch batch scan rsp from fw", |
| 1598 | __func__); |
| 1599 | return -EFAULT; |
| 1600 | } |
| 1601 | } |
| 1602 | |
| 1603 | len = snprintf(pDest, HDD_BATCH_SCAN_AP_META_INFO_SIZE, |
Jeff Johnson | 0279779 | 2013-10-26 19:17:13 -0700 | [diff] [blame] | 1604 | "scancount=%u\n", pAdapter->numScanList); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1605 | pDest += len; |
| 1606 | cur_len += len; |
| 1607 | |
| 1608 | mutex_lock(&pAdapter->hdd_batch_scan_lock); |
| 1609 | len = hdd_populate_user_batch_scan_rsp(pAdapter, pDest, |
| 1610 | cur_len, rem_len); |
| 1611 | mutex_unlock(&pAdapter->hdd_batch_scan_lock); |
| 1612 | |
| 1613 | count = 0; |
| 1614 | len = (len - pPrivData->used_len); |
| 1615 | pDest = (command + pPrivData->used_len); |
| 1616 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Rajeev Kumar | 99db626 | 2013-11-11 15:23:36 -0800 | [diff] [blame] | 1617 | "NEW BATCH SCAN RESULT:"); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1618 | while(count < len) |
| 1619 | { |
| 1620 | printk("%c", *(pDest + count)); |
| 1621 | count++; |
| 1622 | } |
| 1623 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1624 | "%s: copy %d data to user buffer", __func__, len); |
| 1625 | if (copy_to_user(pPrivData->buf, pDest, len)) |
| 1626 | { |
| 1627 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1628 | "%s: failed to copy data to user buffer", __func__); |
| 1629 | return -EFAULT; |
| 1630 | } |
| 1631 | } |
| 1632 | else |
| 1633 | { |
| 1634 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1635 | "sme_GetBatchScanScan returned failure halStatus %d", |
| 1636 | halStatus); |
| 1637 | return -EINVAL; |
| 1638 | } |
| 1639 | } |
| 1640 | else |
| 1641 | { |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1642 | count = 0; |
| 1643 | len = (len - pPrivData->used_len); |
| 1644 | pDest = (command + pPrivData->used_len); |
| 1645 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Rajeev Kumar | 99db626 | 2013-11-11 15:23:36 -0800 | [diff] [blame] | 1646 | "REMAINING TRUNCATED BATCH SCAN RESULT:"); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1647 | while(count < len) |
| 1648 | { |
| 1649 | printk("%c", *(pDest + count)); |
| 1650 | count++; |
| 1651 | } |
Rajeev Kumar | 99db626 | 2013-11-11 15:23:36 -0800 | [diff] [blame] | 1652 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1653 | "%s: copy %d data to user buffer", __func__, len); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1654 | if (copy_to_user(pPrivData->buf, pDest, len)) |
| 1655 | { |
| 1656 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1657 | "%s: failed to copy data to user buffer", __func__); |
| 1658 | return -EFAULT; |
| 1659 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1660 | } |
| 1661 | |
| 1662 | return 0; |
| 1663 | } /*End of hdd_return_batch_scan_rsp_to_user*/ |
| 1664 | |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 1665 | |
| 1666 | /**--------------------------------------------------------------------------- |
| 1667 | |
| 1668 | \brief hdd_handle_batch_scan_ioctl () - This function handles WLS_BATCHING |
| 1669 | IOCTLs from user space. Following BATCH SCAN DEV IOCTs are handled: |
| 1670 | WLS_BATCHING VERSION |
| 1671 | WLS_BATCHING SET |
| 1672 | WLS_BATCHING GET |
| 1673 | WLS_BATCHING STOP |
| 1674 | |
| 1675 | \param - pAdapter Pointer to HDD adapter |
| 1676 | \param - pPrivdata Pointer to priv_data |
| 1677 | \param - command Pointer to command |
| 1678 | |
| 1679 | \return - 0 for success -EFAULT for failure |
| 1680 | |
| 1681 | --------------------------------------------------------------------------*/ |
| 1682 | |
| 1683 | int hdd_handle_batch_scan_ioctl |
| 1684 | ( |
| 1685 | hdd_adapter_t *pAdapter, |
| 1686 | hdd_priv_data_t *pPrivdata, |
| 1687 | tANI_U8 *command |
| 1688 | ) |
| 1689 | { |
| 1690 | int ret = 0; |
Yue Ma | e36e355 | 2014-03-05 17:06:20 -0800 | [diff] [blame] | 1691 | hdd_context_t *pHddCtx; |
| 1692 | |
| 1693 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 1694 | ret = wlan_hdd_validate_context(pHddCtx); |
| 1695 | if (ret) |
| 1696 | { |
| 1697 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1698 | "%s: HDD context is not valid!", __func__); |
| 1699 | goto exit; |
| 1700 | } |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 1701 | |
| 1702 | if (strncmp(command, "WLS_BATCHING VERSION", 20) == 0) |
| 1703 | { |
| 1704 | char extra[32]; |
| 1705 | tANI_U8 len = 0; |
| 1706 | tANI_U8 version = HDD_BATCH_SCAN_VERSION; |
| 1707 | |
| 1708 | if (FALSE == sme_IsFeatureSupportedByFW(BATCH_SCAN)) |
| 1709 | { |
| 1710 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1711 | "%s: Batch scan feature is not supported by FW", __func__); |
| 1712 | ret = -EINVAL; |
| 1713 | goto exit; |
| 1714 | } |
| 1715 | |
| 1716 | len = scnprintf(extra, sizeof(extra), "WLS_BATCHING_VERSION %d", |
| 1717 | version); |
| 1718 | if (copy_to_user(pPrivdata->buf, &extra, len + 1)) |
| 1719 | { |
| 1720 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1721 | "%s: failed to copy data to user buffer", __func__); |
| 1722 | ret = -EFAULT; |
| 1723 | goto exit; |
| 1724 | } |
| 1725 | ret = HDD_BATCH_SCAN_VERSION; |
| 1726 | } |
| 1727 | else if (strncmp(command, "WLS_BATCHING SET", 16) == 0) |
| 1728 | { |
| 1729 | int status; |
| 1730 | tANI_U8 *value = (command + 16); |
| 1731 | eHalStatus halStatus; |
| 1732 | unsigned long rc; |
| 1733 | tSirSetBatchScanReq *pReq = &pAdapter->hddSetBatchScanReq; |
| 1734 | tSirSetBatchScanRsp *pRsp = &pAdapter->hddSetBatchScanRsp; |
| 1735 | |
| 1736 | if (FALSE == sme_IsFeatureSupportedByFW(BATCH_SCAN)) |
| 1737 | { |
| 1738 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1739 | "%s: Batch scan feature is not supported by FW", __func__); |
| 1740 | ret = -EINVAL; |
| 1741 | goto exit; |
| 1742 | } |
| 1743 | |
| 1744 | if ((WLAN_HDD_INFRA_STATION != pAdapter->device_mode) && |
| 1745 | (WLAN_HDD_P2P_CLIENT != pAdapter->device_mode) && |
| 1746 | (WLAN_HDD_P2P_GO != pAdapter->device_mode) && |
| 1747 | (WLAN_HDD_P2P_DEVICE != pAdapter->device_mode)) |
| 1748 | { |
| 1749 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 1750 | "Received WLS_BATCHING SET command in invalid mode %s (%d) " |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 1751 | "WLS_BATCHING_SET is only allowed in infra STA/P2P client mode", |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 1752 | hdd_device_modetoString(pAdapter->device_mode), |
| 1753 | pAdapter->device_mode); |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 1754 | ret = -EINVAL; |
| 1755 | goto exit; |
| 1756 | } |
| 1757 | |
| 1758 | status = hdd_parse_set_batchscan_command(value, pReq); |
| 1759 | if (status) |
| 1760 | { |
| 1761 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1762 | "Invalid WLS_BATCHING SET command"); |
| 1763 | ret = -EINVAL; |
| 1764 | goto exit; |
| 1765 | } |
| 1766 | |
| 1767 | |
| 1768 | pAdapter->hdd_wait_for_set_batch_scan_rsp = TRUE; |
| 1769 | halStatus = sme_SetBatchScanReq(WLAN_HDD_GET_HAL_CTX(pAdapter), pReq, |
| 1770 | pAdapter->sessionId, hdd_set_batch_scan_req_callback, |
| 1771 | pAdapter); |
| 1772 | |
| 1773 | if ( eHAL_STATUS_SUCCESS == halStatus ) |
| 1774 | { |
Mahesh A Saptasagar | 5f56817 | 2014-05-14 17:02:33 +0530 | [diff] [blame] | 1775 | char extra[32]; |
| 1776 | tANI_U8 len = 0; |
| 1777 | tANI_U8 mScan = 0; |
| 1778 | |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 1779 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 1780 | "sme_SetBatchScanReq returned success halStatus %d", |
| 1781 | halStatus); |
| 1782 | if (TRUE == pAdapter->hdd_wait_for_set_batch_scan_rsp) |
| 1783 | { |
| 1784 | INIT_COMPLETION(pAdapter->hdd_set_batch_scan_req_var); |
| 1785 | rc = wait_for_completion_timeout( |
| 1786 | &pAdapter->hdd_set_batch_scan_req_var, |
| 1787 | msecs_to_jiffies(HDD_SET_BATCH_SCAN_REQ_TIME_OUT)); |
| 1788 | if (0 == rc) |
| 1789 | { |
| 1790 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1791 | "%s: Timeout waiting for set batch scan to complete", |
| 1792 | __func__); |
| 1793 | ret = -EINVAL; |
| 1794 | goto exit; |
| 1795 | } |
| 1796 | } |
| 1797 | if ( !pRsp->nScansToBatch ) |
| 1798 | { |
| 1799 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1800 | "%s: Received set batch scan failure response from FW", |
| 1801 | __func__); |
| 1802 | ret = -EINVAL; |
| 1803 | goto exit; |
| 1804 | } |
| 1805 | /*As per the Batch Scan Framework API we should return the MIN of |
| 1806 | either MSCAN or the max # of scans firmware can cache*/ |
Mahesh A Saptasagar | 5f56817 | 2014-05-14 17:02:33 +0530 | [diff] [blame] | 1807 | mScan = MIN(pReq->numberOfScansToBatch , pRsp->nScansToBatch); |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 1808 | |
| 1809 | pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STARTED; |
| 1810 | |
| 1811 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1812 | "%s: request MSCAN %d response MSCAN %d ret %d", |
Mahesh A Saptasagar | 5f56817 | 2014-05-14 17:02:33 +0530 | [diff] [blame] | 1813 | __func__, pReq->numberOfScansToBatch, pRsp->nScansToBatch, mScan); |
| 1814 | len = scnprintf(extra, sizeof(extra), "%d", mScan); |
| 1815 | if (copy_to_user(pPrivdata->buf, &extra, len + 1)) |
| 1816 | { |
| 1817 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1818 | "%s: failed to copy MSCAN value to user buffer", __func__); |
| 1819 | ret = -EFAULT; |
| 1820 | goto exit; |
| 1821 | } |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 1822 | } |
| 1823 | else |
| 1824 | { |
| 1825 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1826 | "sme_SetBatchScanReq returned failure halStatus %d", |
| 1827 | halStatus); |
| 1828 | ret = -EINVAL; |
| 1829 | goto exit; |
| 1830 | } |
| 1831 | } |
| 1832 | else if (strncmp(command, "WLS_BATCHING STOP", 17) == 0) |
| 1833 | { |
| 1834 | eHalStatus halStatus; |
| 1835 | tSirStopBatchScanInd *pInd = &pAdapter->hddStopBatchScanInd; |
| 1836 | pInd->param = 0; |
| 1837 | |
| 1838 | if (FALSE == sme_IsFeatureSupportedByFW(BATCH_SCAN)) |
| 1839 | { |
| 1840 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1841 | "%s: Batch scan feature is not supported by FW", __func__); |
| 1842 | ret = -EINVAL; |
| 1843 | goto exit; |
| 1844 | } |
| 1845 | |
| 1846 | if (eHDD_BATCH_SCAN_STATE_STARTED != pAdapter->batchScanState) |
| 1847 | { |
| 1848 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1849 | "Batch scan is not yet enabled batch scan state %d", |
| 1850 | pAdapter->batchScanState); |
| 1851 | ret = -EINVAL; |
| 1852 | goto exit; |
| 1853 | } |
| 1854 | |
Kiet Lam | aa8e15a | 2014-02-11 23:30:06 -0800 | [diff] [blame] | 1855 | mutex_lock(&pAdapter->hdd_batch_scan_lock); |
| 1856 | hdd_deinit_batch_scan(pAdapter); |
| 1857 | mutex_unlock(&pAdapter->hdd_batch_scan_lock); |
| 1858 | |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 1859 | pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STOPPED; |
| 1860 | |
| 1861 | halStatus = sme_StopBatchScanInd(WLAN_HDD_GET_HAL_CTX(pAdapter), pInd, |
| 1862 | pAdapter->sessionId); |
| 1863 | if ( eHAL_STATUS_SUCCESS == halStatus ) |
| 1864 | { |
| 1865 | ret = 0; |
| 1866 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 1867 | "sme_StopBatchScanInd returned success halStatus %d", |
| 1868 | halStatus); |
| 1869 | } |
| 1870 | else |
| 1871 | { |
| 1872 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1873 | "sme_StopBatchScanInd returned failure halStatus %d", |
| 1874 | halStatus); |
| 1875 | ret = -EINVAL; |
| 1876 | goto exit; |
| 1877 | } |
| 1878 | } |
| 1879 | else if (strncmp(command, "WLS_BATCHING GET", 16) == 0) |
| 1880 | { |
| 1881 | tANI_U32 remain_len; |
| 1882 | |
| 1883 | if (FALSE == sme_IsFeatureSupportedByFW(BATCH_SCAN)) |
| 1884 | { |
| 1885 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1886 | "%s: Batch scan feature is not supported by FW", __func__); |
| 1887 | ret = -EINVAL; |
| 1888 | goto exit; |
| 1889 | } |
| 1890 | |
| 1891 | if (eHDD_BATCH_SCAN_STATE_STARTED != pAdapter->batchScanState) |
| 1892 | { |
| 1893 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1894 | "Batch scan is not yet enabled could not return results" |
| 1895 | "Batch Scan state %d", |
| 1896 | pAdapter->batchScanState); |
| 1897 | ret = -EINVAL; |
| 1898 | goto exit; |
| 1899 | } |
| 1900 | |
| 1901 | pPrivdata->used_len = 16; |
| 1902 | remain_len = pPrivdata->total_len - pPrivdata->used_len; |
| 1903 | if (remain_len < pPrivdata->total_len) |
| 1904 | { |
| 1905 | /*Clear previous batch scan response data if any*/ |
| 1906 | vos_mem_zero((tANI_U8 *)(command + pPrivdata->used_len), remain_len); |
| 1907 | } |
| 1908 | else |
| 1909 | { |
| 1910 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1911 | "Invalid total length from user space can't fetch batch" |
| 1912 | " scan response total_len %d used_len %d remain len %d", |
| 1913 | pPrivdata->total_len, pPrivdata->used_len, remain_len); |
| 1914 | ret = -EINVAL; |
| 1915 | goto exit; |
| 1916 | } |
| 1917 | ret = hdd_return_batch_scan_rsp_to_user(pAdapter, pPrivdata, command); |
| 1918 | } |
| 1919 | |
| 1920 | exit: |
| 1921 | |
| 1922 | return ret; |
| 1923 | } |
| 1924 | |
| 1925 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1926 | #endif/*End of FEATURE_WLAN_BATCH_SCAN*/ |
| 1927 | |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 1928 | static void getBcnMissRateCB(VOS_STATUS status, int bcnMissRate, void *data) |
| 1929 | { |
c_hpothu | 39eb1e3 | 2014-06-26 16:31:50 +0530 | [diff] [blame^] | 1930 | bcnMissRateContext_t *pCBCtx; |
| 1931 | |
| 1932 | if (NULL == data) |
| 1933 | { |
| 1934 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("argument data is NULL")); |
| 1935 | return; |
| 1936 | } |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 1937 | |
| 1938 | /* there is a race condition that exists between this callback |
| 1939 | function and the caller since the caller could time out either |
| 1940 | before or while this code is executing. we use a spinlock to |
| 1941 | serialize these actions */ |
| 1942 | spin_lock(&hdd_context_lock); |
| 1943 | |
c_hpothu | 39eb1e3 | 2014-06-26 16:31:50 +0530 | [diff] [blame^] | 1944 | pCBCtx = (bcnMissRateContext_t *)data; |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 1945 | gbcnMissRate = -1; |
| 1946 | |
c_hpothu | 39eb1e3 | 2014-06-26 16:31:50 +0530 | [diff] [blame^] | 1947 | if (pCBCtx->magic != BCN_MISS_RATE_CONTEXT_MAGIC) |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 1948 | { |
| 1949 | hddLog(VOS_TRACE_LEVEL_ERROR, |
c_hpothu | 39eb1e3 | 2014-06-26 16:31:50 +0530 | [diff] [blame^] | 1950 | FL("invalid context magic: %08x"), pCBCtx->magic); |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 1951 | spin_unlock(&hdd_context_lock); |
| 1952 | return ; |
| 1953 | } |
| 1954 | |
| 1955 | if (VOS_STATUS_SUCCESS == status) |
| 1956 | { |
c_hpothu | 39eb1e3 | 2014-06-26 16:31:50 +0530 | [diff] [blame^] | 1957 | gbcnMissRate = bcnMissRate; |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 1958 | } |
c_hpothu | 39eb1e3 | 2014-06-26 16:31:50 +0530 | [diff] [blame^] | 1959 | else |
| 1960 | { |
| 1961 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("failed to get bcnMissRate")); |
| 1962 | } |
| 1963 | |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 1964 | complete(&(pCBCtx->completion)); |
| 1965 | spin_unlock(&hdd_context_lock); |
| 1966 | |
| 1967 | return; |
| 1968 | } |
| 1969 | |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 1970 | static int hdd_get_dwell_time(hdd_config_t *pCfg, tANI_U8 *command, char *extra, tANI_U8 n, tANI_U8 *len) |
| 1971 | { |
| 1972 | int ret = 0; |
| 1973 | |
| 1974 | if (!pCfg || !command || !extra || !len) |
| 1975 | { |
| 1976 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1977 | "%s: argument passsed for GETDWELLTIME is incorrect", __func__); |
| 1978 | ret = -EINVAL; |
| 1979 | return ret; |
| 1980 | } |
| 1981 | |
| 1982 | if (strncmp(command, "GETDWELLTIME ACTIVE MAX", 23) == 0) |
| 1983 | { |
| 1984 | *len = scnprintf(extra, n, "GETDWELLTIME ACTIVE MAX %u\n", |
| 1985 | (int)pCfg->nActiveMaxChnTime); |
| 1986 | return ret; |
| 1987 | } |
| 1988 | else if (strncmp(command, "GETDWELLTIME ACTIVE MIN", 23) == 0) |
| 1989 | { |
| 1990 | *len = scnprintf(extra, n, "GETDWELLTIME ACTIVE MIN %u\n", |
| 1991 | (int)pCfg->nActiveMinChnTime); |
| 1992 | return ret; |
| 1993 | } |
| 1994 | else if (strncmp(command, "GETDWELLTIME PASSIVE MAX", 24) == 0) |
| 1995 | { |
| 1996 | *len = scnprintf(extra, n, "GETDWELLTIME PASSIVE MAX %u\n", |
| 1997 | (int)pCfg->nPassiveMaxChnTime); |
| 1998 | return ret; |
| 1999 | } |
| 2000 | else if (strncmp(command, "GETDWELLTIME PASSIVE MIN", 24) == 0) |
| 2001 | { |
| 2002 | *len = scnprintf(extra, n, "GETDWELLTIME PASSIVE MIN %u\n", |
| 2003 | (int)pCfg->nPassiveMinChnTime); |
| 2004 | return ret; |
| 2005 | } |
| 2006 | else |
| 2007 | { |
| 2008 | ret = -EINVAL; |
| 2009 | } |
| 2010 | |
| 2011 | return ret; |
| 2012 | } |
| 2013 | |
| 2014 | static int hdd_set_dwell_time(hdd_adapter_t *pAdapter, tANI_U8 *command) |
| 2015 | { |
| 2016 | hdd_config_t *pCfg; |
| 2017 | tANI_U8 *value = command; |
| 2018 | int val = 0, ret = 0, temp = 0; |
| 2019 | |
| 2020 | if (!pAdapter || !command || !(pCfg = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini)) |
| 2021 | { |
| 2022 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2023 | "%s: argument passed for SETDWELLTIME is incorrect", __func__); |
| 2024 | ret = -EINVAL; |
| 2025 | return ret; |
| 2026 | } |
| 2027 | |
| 2028 | if (strncmp(command, "SETDWELLTIME ACTIVE MAX", 23) == 0 ) |
| 2029 | { |
| 2030 | value = value + 24; |
| 2031 | temp = kstrtou32(value, 10, &val); |
| 2032 | if (temp != 0 || val < CFG_ACTIVE_MAX_CHANNEL_TIME_MIN || |
| 2033 | val > CFG_ACTIVE_MAX_CHANNEL_TIME_MAX ) |
| 2034 | { |
| 2035 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2036 | "%s: argument passed for SETDWELLTIME ACTIVE MAX is incorrect", __func__); |
| 2037 | ret = -EFAULT; |
| 2038 | return ret; |
| 2039 | } |
| 2040 | pCfg->nActiveMaxChnTime = val; |
| 2041 | } |
| 2042 | else if (strncmp(command, "SETDWELLTIME ACTIVE MIN", 23) == 0) |
| 2043 | { |
| 2044 | value = value + 24; |
| 2045 | temp = kstrtou32(value, 10, &val); |
| 2046 | if (temp !=0 || val < CFG_ACTIVE_MIN_CHANNEL_TIME_MIN || |
| 2047 | val > CFG_ACTIVE_MIN_CHANNEL_TIME_MAX ) |
| 2048 | { |
| 2049 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2050 | "%s: argument passsed for SETDWELLTIME ACTIVE MIN is incorrect", __func__); |
| 2051 | ret = -EFAULT; |
| 2052 | return ret; |
| 2053 | } |
| 2054 | pCfg->nActiveMinChnTime = val; |
| 2055 | } |
| 2056 | else if (strncmp(command, "SETDWELLTIME PASSIVE MAX", 24) == 0) |
| 2057 | { |
| 2058 | value = value + 25; |
| 2059 | temp = kstrtou32(value, 10, &val); |
| 2060 | if (temp != 0 || val < CFG_PASSIVE_MAX_CHANNEL_TIME_MIN || |
| 2061 | val > CFG_PASSIVE_MAX_CHANNEL_TIME_MAX ) |
| 2062 | { |
| 2063 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2064 | "%s: argument passed for SETDWELLTIME PASSIVE MAX is incorrect", __func__); |
| 2065 | ret = -EFAULT; |
| 2066 | return ret; |
| 2067 | } |
| 2068 | pCfg->nPassiveMaxChnTime = val; |
| 2069 | } |
| 2070 | else if (strncmp(command, "SETDWELLTIME PASSIVE MIN", 24) == 0) |
| 2071 | { |
| 2072 | value = value + 25; |
| 2073 | temp = kstrtou32(value, 10, &val); |
| 2074 | if (temp != 0 || val < CFG_PASSIVE_MIN_CHANNEL_TIME_MIN || |
| 2075 | val > CFG_PASSIVE_MIN_CHANNEL_TIME_MAX ) |
| 2076 | { |
| 2077 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2078 | "%s: argument passed for SETDWELLTIME PASSIVE MIN is incorrect", __func__); |
| 2079 | ret = -EFAULT; |
| 2080 | return ret; |
| 2081 | } |
| 2082 | pCfg->nPassiveMinChnTime = val; |
| 2083 | } |
| 2084 | else |
| 2085 | { |
| 2086 | ret = -EINVAL; |
| 2087 | } |
| 2088 | |
| 2089 | return ret; |
| 2090 | } |
| 2091 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2092 | static int hdd_driver_command(hdd_adapter_t *pAdapter, |
| 2093 | hdd_priv_data_t *ppriv_data) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2094 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2095 | hdd_priv_data_t priv_data; |
| 2096 | tANI_U8 *command = NULL; |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2097 | int ret = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2098 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2099 | /* |
| 2100 | * Note that valid pointers are provided by caller |
| 2101 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2102 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2103 | /* copy to local struct to avoid numerous changes to legacy code */ |
| 2104 | priv_data = *ppriv_data; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2105 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2106 | if (priv_data.total_len <= 0 || |
| 2107 | priv_data.total_len > WLAN_PRIV_DATA_MAX_LEN) |
Sameer Thalappil | 8ef3a0e | 2013-04-05 14:36:04 -0700 | [diff] [blame] | 2108 | { |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2109 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 2110 | "%s:invalid priv_data.total_len(%d)!!!", __func__, |
| 2111 | priv_data.total_len); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 2112 | ret = -EINVAL; |
| 2113 | goto exit; |
| 2114 | } |
| 2115 | |
| 2116 | /* Allocate +1 for '\0' */ |
| 2117 | command = kmalloc(priv_data.total_len + 1, GFP_KERNEL); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2118 | if (!command) |
| 2119 | { |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2120 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2121 | "%s: failed to allocate memory", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2122 | ret = -ENOMEM; |
| 2123 | goto exit; |
| 2124 | } |
| 2125 | |
| 2126 | if (copy_from_user(command, priv_data.buf, priv_data.total_len)) |
| 2127 | { |
| 2128 | ret = -EFAULT; |
| 2129 | goto exit; |
| 2130 | } |
| 2131 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2132 | /* Make sure the command is NUL-terminated */ |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 2133 | command[priv_data.total_len] = '\0'; |
| 2134 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2135 | /* at one time the following block of code was conditional. braces |
| 2136 | * have been retained to avoid re-indenting the legacy code |
| 2137 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2138 | { |
| 2139 | hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx; |
| 2140 | |
| 2141 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | f9bdd4e | 2012-10-30 18:05:03 -0700 | [diff] [blame] | 2142 | "%s: Received %s cmd from Wi-Fi GUI***", __func__, command); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2143 | |
| 2144 | if (strncmp(command, "P2P_DEV_ADDR", 12) == 0 ) |
| 2145 | { |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2146 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2147 | TRACE_CODE_HDD_P2P_DEV_ADDR_IOCTL, |
| 2148 | pAdapter->sessionId, (unsigned) |
| 2149 | (*(pHddCtx->p2pDeviceAddress.bytes+2)<<24 | |
| 2150 | *(pHddCtx->p2pDeviceAddress.bytes+3)<<16 | |
| 2151 | *(pHddCtx->p2pDeviceAddress.bytes+4)<<8 | |
| 2152 | *(pHddCtx->p2pDeviceAddress.bytes+5)))); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2153 | if (copy_to_user(priv_data.buf, pHddCtx->p2pDeviceAddress.bytes, |
| 2154 | sizeof(tSirMacAddr))) |
| 2155 | { |
| 2156 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2157 | "%s: failed to copy data to user buffer", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2158 | ret = -EFAULT; |
| 2159 | } |
| 2160 | } |
Amar Singhal | 0974e40 | 2013-02-12 14:27:46 -0800 | [diff] [blame] | 2161 | else if(strncmp(command, "SETBAND", 7) == 0) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2162 | { |
Amar Singhal | 0974e40 | 2013-02-12 14:27:46 -0800 | [diff] [blame] | 2163 | tANI_U8 *ptr = command ; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2164 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2165 | /* Change band request received */ |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2166 | |
| 2167 | /* First 8 bytes will have "SETBAND " and |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2168 | * 9 byte will have band setting value */ |
Madan Mohan Koyyalamudi | 8bdd311 | 2012-09-24 13:55:14 -0700 | [diff] [blame] | 2169 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Amar Singhal | 0974e40 | 2013-02-12 14:27:46 -0800 | [diff] [blame] | 2170 | "%s: SetBandCommand Info comm %s UL %d, TL %d", __func__, command, priv_data.used_len, priv_data.total_len); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2171 | /* Change band request received */ |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2172 | ret = hdd_setBand_helper(pAdapter->dev, ptr); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 2173 | if(ret != 0) |
| 2174 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2175 | "%s: failed to set band ret=%d", __func__, ret); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2176 | } |
Kiet Lam | f040f47 | 2013-11-20 21:15:23 +0530 | [diff] [blame] | 2177 | else if(strncmp(command, "SETWMMPS", 8) == 0) |
| 2178 | { |
| 2179 | tANI_U8 *ptr = command; |
| 2180 | ret = hdd_wmmps_helper(pAdapter, ptr); |
| 2181 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2182 | else if ( strncasecmp(command, "COUNTRY", 7) == 0 ) |
| 2183 | { |
| 2184 | char *country_code; |
| 2185 | |
| 2186 | country_code = command + 8; |
Tushnim Bhattacharyya | 9cdf608 | 2013-04-21 16:33:30 -0700 | [diff] [blame] | 2187 | |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 2188 | INIT_COMPLETION(pAdapter->change_country_code); |
Tushnim Bhattacharyya | 9cdf608 | 2013-04-21 16:33:30 -0700 | [diff] [blame] | 2189 | hdd_checkandupdate_dfssetting(pAdapter, country_code); |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 2190 | #ifndef CONFIG_ENABLE_LINUX_REG |
Gopichand Nakkala | dacbcb5 | 2013-04-18 16:41:54 +0530 | [diff] [blame] | 2191 | hdd_checkandupdate_phymode(pAdapter, country_code); |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 2192 | #endif |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 2193 | ret = (int)sme_ChangeCountryCode(pHddCtx->hHal, |
| 2194 | (void *)(tSmeChangeCountryCallback) |
| 2195 | wlan_hdd_change_country_code_callback, |
Abhishek Singh | a306a44 | 2013-11-07 18:39:01 +0530 | [diff] [blame] | 2196 | country_code, pAdapter, pHddCtx->pvosContext, eSIR_TRUE, eSIR_TRUE); |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 2197 | if (eHAL_STATUS_SUCCESS == ret) |
| 2198 | { |
| 2199 | ret = wait_for_completion_interruptible_timeout( |
| 2200 | &pAdapter->change_country_code, |
| 2201 | msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY)); |
| 2202 | if (0 >= ret) |
| 2203 | { |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2204 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: SME while setting country code timed out %d", |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 2205 | __func__, ret); |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 2206 | } |
| 2207 | } |
| 2208 | else |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2209 | { |
| 2210 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2211 | "%s: SME Change Country code fail ret=%d", __func__, ret); |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 2212 | ret = -EINVAL; |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2213 | } |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 2214 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 2215 | } |
| 2216 | /* |
| 2217 | command should be a string having format |
| 2218 | SET_SAP_CHANNEL_LIST <num of channels> <the channels seperated by spaces> |
| 2219 | */ |
Amar Singhal | 0974e40 | 2013-02-12 14:27:46 -0800 | [diff] [blame] | 2220 | else if(strncmp(command, "SET_SAP_CHANNEL_LIST", 20) == 0) |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 2221 | { |
Amar Singhal | 0974e40 | 2013-02-12 14:27:46 -0800 | [diff] [blame] | 2222 | tANI_U8 *ptr = command; |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 2223 | |
| 2224 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 2225 | " Received Command to Set Preferred Channels for SAP in %s", __func__); |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 2226 | |
Mahesh Kumar Kalikot Veetil | 2aad8d8 | 2013-02-07 12:31:28 -0800 | [diff] [blame] | 2227 | ret = sapSetPreferredChannel(ptr); |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2228 | } |
Sameer Thalappil | 45931fb | 2013-02-01 11:18:05 -0800 | [diff] [blame] | 2229 | else if(strncmp(command, "SETSUSPENDMODE", 14) == 0) |
| 2230 | { |
| 2231 | int suspend = 0; |
| 2232 | tANI_U8 *ptr = (tANI_U8*)command + 15; |
| 2233 | |
| 2234 | suspend = *ptr - '0'; |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2235 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2236 | TRACE_CODE_HDD_SETSUSPENDMODE_IOCTL, |
| 2237 | pAdapter->sessionId, suspend)); |
Sameer Thalappil | 45931fb | 2013-02-01 11:18:05 -0800 | [diff] [blame] | 2238 | hdd_set_wlan_suspend_mode(suspend); |
| 2239 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2240 | #ifdef WLAN_FEATURE_NEIGHBOR_ROAMING |
| 2241 | else if (strncmp(command, "SETROAMTRIGGER", 14) == 0) |
| 2242 | { |
| 2243 | tANI_U8 *value = command; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2244 | tANI_S8 rssi = 0; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2245 | tANI_U8 lookUpThreshold = CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_DEFAULT; |
| 2246 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 2247 | |
| 2248 | /* Move pointer to ahead of SETROAMTRIGGER<delimiter> */ |
| 2249 | value = value + 15; |
| 2250 | |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2251 | /* Convert the value from ascii to integer */ |
| 2252 | ret = kstrtos8(value, 10, &rssi); |
| 2253 | if (ret < 0) |
| 2254 | { |
| 2255 | /* If the input value is greater than max value of datatype, then also |
| 2256 | kstrtou8 fails */ |
| 2257 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2258 | "%s: kstrtou8 failed Input value may be out of range[%d - %d]", |
Srinivas Girigowda | fa7157d | 2013-10-31 10:14:22 -0700 | [diff] [blame] | 2259 | __func__, |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2260 | CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MIN, |
| 2261 | CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MAX); |
| 2262 | ret = -EINVAL; |
| 2263 | goto exit; |
| 2264 | } |
| 2265 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2266 | lookUpThreshold = abs(rssi); |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2267 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2268 | if ((lookUpThreshold < CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MIN) || |
| 2269 | (lookUpThreshold > CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MAX)) |
| 2270 | { |
| 2271 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2272 | "Neighbor lookup threshold value %d is out of range" |
| 2273 | " (Min: %d Max: %d)", lookUpThreshold, |
| 2274 | CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MIN, |
| 2275 | CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MAX); |
| 2276 | ret = -EINVAL; |
| 2277 | goto exit; |
| 2278 | } |
| 2279 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2280 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2281 | TRACE_CODE_HDD_SETROAMTRIGGER_IOCTL, |
| 2282 | pAdapter->sessionId, lookUpThreshold)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2283 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2284 | "%s: Received Command to Set Roam trigger" |
| 2285 | " (Neighbor lookup threshold) = %d", __func__, lookUpThreshold); |
| 2286 | |
| 2287 | pHddCtx->cfg_ini->nNeighborLookupRssiThreshold = lookUpThreshold; |
| 2288 | status = sme_setNeighborLookupRssiThreshold((tHalHandle)(pHddCtx->hHal), lookUpThreshold); |
| 2289 | if (eHAL_STATUS_SUCCESS != status) |
| 2290 | { |
| 2291 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2292 | "%s: Failed to set roam trigger, try again", __func__); |
| 2293 | ret = -EPERM; |
| 2294 | goto exit; |
| 2295 | } |
| 2296 | |
| 2297 | /* Set Reassoc threshold to (lookup rssi threshold + 5 dBm) */ |
mukul sharma | d6e1fdd | 2014-06-23 19:19:09 +0530 | [diff] [blame] | 2298 | pHddCtx->cfg_ini->nNeighborReassocRssiThreshold = lookUpThreshold + 5; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2299 | sme_setNeighborReassocRssiThreshold((tHalHandle)(pHddCtx->hHal), lookUpThreshold + 5); |
| 2300 | } |
| 2301 | else if (strncmp(command, "GETROAMTRIGGER", 14) == 0) |
| 2302 | { |
| 2303 | tANI_U8 lookUpThreshold = sme_getNeighborLookupRssiThreshold((tHalHandle)(pHddCtx->hHal)); |
| 2304 | int rssi = (-1) * lookUpThreshold; |
| 2305 | char extra[32]; |
| 2306 | tANI_U8 len = 0; |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2307 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2308 | TRACE_CODE_HDD_GETROAMTRIGGER_IOCTL, |
| 2309 | pAdapter->sessionId, lookUpThreshold)); |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2310 | len = scnprintf(extra, sizeof(extra), "%s %d", command, rssi); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2311 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2312 | { |
| 2313 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2314 | "%s: failed to copy data to user buffer", __func__); |
| 2315 | ret = -EFAULT; |
| 2316 | goto exit; |
| 2317 | } |
| 2318 | } |
| 2319 | else if (strncmp(command, "SETROAMSCANPERIOD", 17) == 0) |
| 2320 | { |
| 2321 | tANI_U8 *value = command; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2322 | tANI_U8 roamScanPeriod = 0; |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2323 | tANI_U16 neighborEmptyScanRefreshPeriod = CFG_EMPTY_SCAN_REFRESH_PERIOD_DEFAULT; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2324 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2325 | /* input refresh period is in terms of seconds */ |
| 2326 | /* Move pointer to ahead of SETROAMSCANPERIOD<delimiter> */ |
| 2327 | value = value + 18; |
| 2328 | /* Convert the value from ascii to integer */ |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2329 | ret = kstrtou8(value, 10, &roamScanPeriod); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2330 | if (ret < 0) |
| 2331 | { |
| 2332 | /* If the input value is greater than max value of datatype, then also |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2333 | kstrtou8 fails */ |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2334 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2335 | "%s: kstrtou8 failed Input value may be out of range[%d - %d]", |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2336 | __func__, |
Srinivas Girigowda | b8edd1e | 2013-03-19 11:42:08 -0700 | [diff] [blame] | 2337 | (CFG_EMPTY_SCAN_REFRESH_PERIOD_MIN/1000), |
| 2338 | (CFG_EMPTY_SCAN_REFRESH_PERIOD_MAX/1000)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2339 | ret = -EINVAL; |
| 2340 | goto exit; |
| 2341 | } |
| 2342 | |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2343 | if ((roamScanPeriod < (CFG_EMPTY_SCAN_REFRESH_PERIOD_MIN/1000)) || |
| 2344 | (roamScanPeriod > (CFG_EMPTY_SCAN_REFRESH_PERIOD_MAX/1000))) |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2345 | { |
| 2346 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2347 | "Roam scan period value %d is out of range" |
| 2348 | " (Min: %d Max: %d)", roamScanPeriod, |
Srinivas Girigowda | b8edd1e | 2013-03-19 11:42:08 -0700 | [diff] [blame] | 2349 | (CFG_EMPTY_SCAN_REFRESH_PERIOD_MIN/1000), |
| 2350 | (CFG_EMPTY_SCAN_REFRESH_PERIOD_MAX/1000)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2351 | ret = -EINVAL; |
| 2352 | goto exit; |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2353 | } |
| 2354 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2355 | TRACE_CODE_HDD_SETROAMSCANPERIOD_IOCTL, |
| 2356 | pAdapter->sessionId, roamScanPeriod)); |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2357 | neighborEmptyScanRefreshPeriod = roamScanPeriod * 1000; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2358 | |
| 2359 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2360 | "%s: Received Command to Set roam scan period" |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2361 | " (Empty Scan refresh period) = %d", __func__, roamScanPeriod); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2362 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2363 | pHddCtx->cfg_ini->nEmptyScanRefreshPeriod = neighborEmptyScanRefreshPeriod; |
| 2364 | sme_UpdateEmptyScanRefreshPeriod((tHalHandle)(pHddCtx->hHal), neighborEmptyScanRefreshPeriod); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2365 | } |
| 2366 | else if (strncmp(command, "GETROAMSCANPERIOD", 17) == 0) |
| 2367 | { |
| 2368 | tANI_U16 nEmptyScanRefreshPeriod = sme_getEmptyScanRefreshPeriod((tHalHandle)(pHddCtx->hHal)); |
| 2369 | char extra[32]; |
| 2370 | tANI_U8 len = 0; |
| 2371 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2372 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2373 | TRACE_CODE_HDD_GETROAMSCANPERIOD_IOCTL, |
| 2374 | pAdapter->sessionId, nEmptyScanRefreshPeriod)); |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2375 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 2376 | "GETROAMSCANPERIOD", (nEmptyScanRefreshPeriod/1000)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2377 | /* Returned value is in units of seconds */ |
| 2378 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2379 | { |
| 2380 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2381 | "%s: failed to copy data to user buffer", __func__); |
| 2382 | ret = -EFAULT; |
| 2383 | goto exit; |
| 2384 | } |
| 2385 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2386 | else if (strncmp(command, "SETROAMSCANREFRESHPERIOD", 24) == 0) |
| 2387 | { |
| 2388 | tANI_U8 *value = command; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2389 | tANI_U8 roamScanRefreshPeriod = 0; |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2390 | tANI_U16 neighborScanRefreshPeriod = CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_DEFAULT; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2391 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2392 | /* input refresh period is in terms of seconds */ |
| 2393 | /* Move pointer to ahead of SETROAMSCANREFRESHPERIOD<delimiter> */ |
| 2394 | value = value + 25; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2395 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2396 | /* Convert the value from ascii to integer */ |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2397 | ret = kstrtou8(value, 10, &roamScanRefreshPeriod); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2398 | if (ret < 0) |
| 2399 | { |
| 2400 | /* If the input value is greater than max value of datatype, then also |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2401 | kstrtou8 fails */ |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2402 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2403 | "%s: kstrtou8 failed Input value may be out of range[%d - %d]", |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2404 | __func__, |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2405 | (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MIN/1000), |
| 2406 | (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MAX/1000)); |
| 2407 | ret = -EINVAL; |
| 2408 | goto exit; |
| 2409 | } |
| 2410 | |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2411 | if ((roamScanRefreshPeriod < (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MIN/1000)) || |
| 2412 | (roamScanRefreshPeriod > (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MAX/1000))) |
| 2413 | { |
| 2414 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2415 | "Neighbor scan results refresh period value %d is out of range" |
| 2416 | " (Min: %d Max: %d)", roamScanRefreshPeriod, |
| 2417 | (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MIN/1000), |
| 2418 | (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MAX/1000)); |
| 2419 | ret = -EINVAL; |
| 2420 | goto exit; |
| 2421 | } |
| 2422 | neighborScanRefreshPeriod = roamScanRefreshPeriod * 1000; |
| 2423 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2424 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2425 | "%s: Received Command to Set roam scan refresh period" |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2426 | " (Scan refresh period) = %d", __func__, roamScanRefreshPeriod); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2427 | |
| 2428 | pHddCtx->cfg_ini->nNeighborResultsRefreshPeriod = neighborScanRefreshPeriod; |
| 2429 | sme_setNeighborScanRefreshPeriod((tHalHandle)(pHddCtx->hHal), neighborScanRefreshPeriod); |
| 2430 | } |
| 2431 | else if (strncmp(command, "GETROAMSCANREFRESHPERIOD", 24) == 0) |
| 2432 | { |
| 2433 | tANI_U16 value = sme_getNeighborScanRefreshPeriod((tHalHandle)(pHddCtx->hHal)); |
| 2434 | char extra[32]; |
| 2435 | tANI_U8 len = 0; |
| 2436 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2437 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 2438 | "GETROAMSCANREFRESHPERIOD", (value/1000)); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2439 | /* Returned value is in units of seconds */ |
| 2440 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2441 | { |
| 2442 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2443 | "%s: failed to copy data to user buffer", __func__); |
| 2444 | ret = -EFAULT; |
| 2445 | goto exit; |
| 2446 | } |
| 2447 | } |
Varun Reddy Yeturu | 6d99ac8 | 2013-05-08 14:15:35 -0700 | [diff] [blame] | 2448 | #ifdef FEATURE_WLAN_LFR |
| 2449 | /* SETROAMMODE */ |
| 2450 | else if (strncmp(command, "SETROAMMODE", SIZE_OF_SETROAMMODE) == 0) |
| 2451 | { |
| 2452 | tANI_U8 *value = command; |
| 2453 | tANI_BOOLEAN roamMode = CFG_LFR_FEATURE_ENABLED_DEFAULT; |
| 2454 | |
| 2455 | /* Move pointer to ahead of SETROAMMODE<delimiter> */ |
| 2456 | value = value + SIZE_OF_SETROAMMODE + 1; |
| 2457 | |
| 2458 | /* Convert the value from ascii to integer */ |
| 2459 | ret = kstrtou8(value, SIZE_OF_SETROAMMODE, &roamMode); |
| 2460 | if (ret < 0) |
| 2461 | { |
| 2462 | /* If the input value is greater than max value of datatype, then also |
| 2463 | kstrtou8 fails */ |
| 2464 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2465 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 2466 | CFG_LFR_FEATURE_ENABLED_MIN, |
| 2467 | CFG_LFR_FEATURE_ENABLED_MAX); |
| 2468 | ret = -EINVAL; |
| 2469 | goto exit; |
| 2470 | } |
| 2471 | if ((roamMode < CFG_LFR_FEATURE_ENABLED_MIN) || |
| 2472 | (roamMode > CFG_LFR_FEATURE_ENABLED_MAX)) |
| 2473 | { |
| 2474 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2475 | "Roam Mode value %d is out of range" |
| 2476 | " (Min: %d Max: %d)", roamMode, |
| 2477 | CFG_LFR_FEATURE_ENABLED_MIN, |
| 2478 | CFG_LFR_FEATURE_ENABLED_MAX); |
| 2479 | ret = -EINVAL; |
| 2480 | goto exit; |
| 2481 | } |
| 2482 | |
| 2483 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2484 | "%s: Received Command to Set Roam Mode = %d", __func__, roamMode); |
| 2485 | /* |
| 2486 | * Note that |
| 2487 | * SETROAMMODE 0 is to enable LFR while |
| 2488 | * SETROAMMODE 1 is to disable LFR, but |
| 2489 | * NotifyIsFastRoamIniFeatureEnabled 0/1 is to enable/disable. |
| 2490 | * So, we have to invert the value to call sme_UpdateIsFastRoamIniFeatureEnabled. |
| 2491 | */ |
| 2492 | if (CFG_LFR_FEATURE_ENABLED_MIN == roamMode) |
| 2493 | roamMode = CFG_LFR_FEATURE_ENABLED_MAX; /* Roam enable */ |
| 2494 | else |
| 2495 | roamMode = CFG_LFR_FEATURE_ENABLED_MIN; /* Roam disable */ |
| 2496 | |
| 2497 | pHddCtx->cfg_ini->isFastRoamIniFeatureEnabled = roamMode; |
| 2498 | sme_UpdateIsFastRoamIniFeatureEnabled((tHalHandle)(pHddCtx->hHal), roamMode); |
| 2499 | } |
| 2500 | /* GETROAMMODE */ |
| 2501 | else if (strncmp(priv_data.buf, "GETROAMMODE", SIZE_OF_GETROAMMODE) == 0) |
| 2502 | { |
| 2503 | tANI_BOOLEAN roamMode = sme_getIsLfrFeatureEnabled((tHalHandle)(pHddCtx->hHal)); |
| 2504 | char extra[32]; |
| 2505 | tANI_U8 len = 0; |
| 2506 | |
| 2507 | /* |
| 2508 | * roamMode value shall be inverted because the sementics is different. |
| 2509 | */ |
| 2510 | if (CFG_LFR_FEATURE_ENABLED_MIN == roamMode) |
| 2511 | roamMode = CFG_LFR_FEATURE_ENABLED_MAX; |
| 2512 | else |
| 2513 | roamMode = CFG_LFR_FEATURE_ENABLED_MIN; |
| 2514 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2515 | len = scnprintf(extra, sizeof(extra), "%s %d", command, roamMode); |
Varun Reddy Yeturu | 6d99ac8 | 2013-05-08 14:15:35 -0700 | [diff] [blame] | 2516 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2517 | { |
| 2518 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2519 | "%s: failed to copy data to user buffer", __func__); |
| 2520 | ret = -EFAULT; |
| 2521 | goto exit; |
| 2522 | } |
| 2523 | } |
| 2524 | #endif |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2525 | #endif |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2526 | #if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR) |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2527 | else if (strncmp(command, "SETROAMDELTA", 12) == 0) |
| 2528 | { |
| 2529 | tANI_U8 *value = command; |
| 2530 | tANI_U8 roamRssiDiff = CFG_ROAM_RSSI_DIFF_DEFAULT; |
| 2531 | |
| 2532 | /* Move pointer to ahead of SETROAMDELTA<delimiter> */ |
| 2533 | value = value + 13; |
| 2534 | /* Convert the value from ascii to integer */ |
| 2535 | ret = kstrtou8(value, 10, &roamRssiDiff); |
| 2536 | if (ret < 0) |
| 2537 | { |
| 2538 | /* If the input value is greater than max value of datatype, then also |
| 2539 | kstrtou8 fails */ |
| 2540 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2541 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 2542 | CFG_ROAM_RSSI_DIFF_MIN, |
| 2543 | CFG_ROAM_RSSI_DIFF_MAX); |
| 2544 | ret = -EINVAL; |
| 2545 | goto exit; |
| 2546 | } |
| 2547 | |
| 2548 | if ((roamRssiDiff < CFG_ROAM_RSSI_DIFF_MIN) || |
| 2549 | (roamRssiDiff > CFG_ROAM_RSSI_DIFF_MAX)) |
| 2550 | { |
| 2551 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2552 | "Roam rssi diff value %d is out of range" |
| 2553 | " (Min: %d Max: %d)", roamRssiDiff, |
| 2554 | CFG_ROAM_RSSI_DIFF_MIN, |
| 2555 | CFG_ROAM_RSSI_DIFF_MAX); |
| 2556 | ret = -EINVAL; |
| 2557 | goto exit; |
| 2558 | } |
| 2559 | |
| 2560 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2561 | "%s: Received Command to Set roam rssi diff = %d", __func__, roamRssiDiff); |
| 2562 | |
| 2563 | pHddCtx->cfg_ini->RoamRssiDiff = roamRssiDiff; |
| 2564 | sme_UpdateRoamRssiDiff((tHalHandle)(pHddCtx->hHal), roamRssiDiff); |
| 2565 | } |
| 2566 | else if (strncmp(priv_data.buf, "GETROAMDELTA", 12) == 0) |
| 2567 | { |
| 2568 | tANI_U8 roamRssiDiff = sme_getRoamRssiDiff((tHalHandle)(pHddCtx->hHal)); |
| 2569 | char extra[32]; |
| 2570 | tANI_U8 len = 0; |
| 2571 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2572 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2573 | TRACE_CODE_HDD_GETROAMDELTA_IOCTL, |
| 2574 | pAdapter->sessionId, roamRssiDiff)); |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2575 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 2576 | command, roamRssiDiff); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2577 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2578 | { |
| 2579 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2580 | "%s: failed to copy data to user buffer", __func__); |
| 2581 | ret = -EFAULT; |
| 2582 | goto exit; |
| 2583 | } |
| 2584 | } |
| 2585 | #endif |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2586 | #if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR) |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2587 | else if (strncmp(command, "GETBAND", 7) == 0) |
| 2588 | { |
| 2589 | int band = -1; |
| 2590 | char extra[32]; |
| 2591 | tANI_U8 len = 0; |
| 2592 | hdd_getBand_helper(pHddCtx, &band); |
| 2593 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2594 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2595 | TRACE_CODE_HDD_GETBAND_IOCTL, |
| 2596 | pAdapter->sessionId, band)); |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2597 | len = scnprintf(extra, sizeof(extra), "%s %d", command, band); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2598 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2599 | { |
| 2600 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2601 | "%s: failed to copy data to user buffer", __func__); |
| 2602 | ret = -EFAULT; |
| 2603 | goto exit; |
| 2604 | } |
| 2605 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2606 | else if (strncmp(command, "SETROAMSCANCHANNELS", 19) == 0) |
| 2607 | { |
| 2608 | tANI_U8 *value = command; |
| 2609 | tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0}; |
| 2610 | tANI_U8 numChannels = 0; |
| 2611 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 2612 | |
| 2613 | status = hdd_parse_channellist(value, ChannelList, &numChannels); |
| 2614 | if (eHAL_STATUS_SUCCESS != status) |
| 2615 | { |
| 2616 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2617 | "%s: Failed to parse channel list information", __func__); |
| 2618 | ret = -EINVAL; |
| 2619 | goto exit; |
| 2620 | } |
| 2621 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2622 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2623 | TRACE_CODE_HDD_SETROAMSCANCHANNELS_IOCTL, |
| 2624 | pAdapter->sessionId, numChannels)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2625 | if (numChannels > WNI_CFG_VALID_CHANNEL_LIST_LEN) |
| 2626 | { |
| 2627 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2628 | "%s: number of channels (%d) supported exceeded max (%d)", __func__, |
| 2629 | numChannels, WNI_CFG_VALID_CHANNEL_LIST_LEN); |
| 2630 | ret = -EINVAL; |
| 2631 | goto exit; |
| 2632 | } |
| 2633 | status = sme_ChangeRoamScanChannelList((tHalHandle)(pHddCtx->hHal), ChannelList, |
| 2634 | numChannels); |
| 2635 | if (eHAL_STATUS_SUCCESS != status) |
| 2636 | { |
| 2637 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2638 | "%s: Failed to update channel list information", __func__); |
| 2639 | ret = -EINVAL; |
| 2640 | goto exit; |
| 2641 | } |
| 2642 | } |
| 2643 | else if (strncmp(command, "GETROAMSCANCHANNELS", 19) == 0) |
| 2644 | { |
| 2645 | tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0}; |
| 2646 | tANI_U8 numChannels = 0; |
Jeff Johnson | 51b6778 | 2013-04-05 12:35:41 -0700 | [diff] [blame] | 2647 | tANI_U8 j = 0; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2648 | char extra[128] = {0}; |
Jeff Johnson | 51b6778 | 2013-04-05 12:35:41 -0700 | [diff] [blame] | 2649 | int len; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2650 | |
| 2651 | if (eHAL_STATUS_SUCCESS != sme_getRoamScanChannelList( (tHalHandle)(pHddCtx->hHal), |
| 2652 | ChannelList, &numChannels )) |
| 2653 | { |
| 2654 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 2655 | "%s: failed to get roam scan channel list", __func__); |
| 2656 | ret = -EFAULT; |
| 2657 | goto exit; |
| 2658 | } |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2659 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2660 | TRACE_CODE_HDD_GETROAMSCANCHANNELS_IOCTL, |
| 2661 | pAdapter->sessionId, numChannels)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2662 | /* output channel list is of the format |
| 2663 | [Number of roam scan channels][Channel1][Channel2]... */ |
| 2664 | /* copy the number of channels in the 0th index */ |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2665 | len = scnprintf(extra, sizeof(extra), "%s %d", command, numChannels); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2666 | for (j = 0; (j < numChannels); j++) |
| 2667 | { |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2668 | len += scnprintf(extra + len, sizeof(extra) - len, " %d", |
| 2669 | ChannelList[j]); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2670 | } |
| 2671 | |
| 2672 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2673 | { |
| 2674 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2675 | "%s: failed to copy data to user buffer", __func__); |
| 2676 | ret = -EFAULT; |
| 2677 | goto exit; |
| 2678 | } |
| 2679 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2680 | else if (strncmp(command, "GETCCXMODE", 10) == 0) |
| 2681 | { |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2682 | tANI_BOOLEAN eseMode = sme_getIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal)); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2683 | char extra[32]; |
| 2684 | tANI_U8 len = 0; |
| 2685 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2686 | /* Check if the features OKC/ESE/11R are supported simultaneously, |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 2687 | then this operation is not permitted (return FAILURE) */ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2688 | if (eseMode && |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 2689 | hdd_is_okc_mode_enabled(pHddCtx) && |
| 2690 | sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal))) |
| 2691 | { |
| 2692 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2693 | "%s: OKC/ESE/11R are supported simultaneously" |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 2694 | " hence this operation is not permitted!", __func__); |
| 2695 | ret = -EPERM; |
| 2696 | goto exit; |
| 2697 | } |
| 2698 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2699 | len = scnprintf(extra, sizeof(extra), "%s %d", |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2700 | "GETCCXMODE", eseMode); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2701 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2702 | { |
| 2703 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2704 | "%s: failed to copy data to user buffer", __func__); |
| 2705 | ret = -EFAULT; |
| 2706 | goto exit; |
| 2707 | } |
| 2708 | } |
| 2709 | else if (strncmp(command, "GETOKCMODE", 10) == 0) |
| 2710 | { |
| 2711 | tANI_BOOLEAN okcMode = hdd_is_okc_mode_enabled(pHddCtx); |
| 2712 | char extra[32]; |
| 2713 | tANI_U8 len = 0; |
| 2714 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2715 | /* Check if the features OKC/ESE/11R are supported simultaneously, |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 2716 | then this operation is not permitted (return FAILURE) */ |
| 2717 | if (okcMode && |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2718 | sme_getIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal)) && |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 2719 | sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal))) |
| 2720 | { |
| 2721 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2722 | "%s: OKC/ESE/11R are supported simultaneously" |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 2723 | " hence this operation is not permitted!", __func__); |
| 2724 | ret = -EPERM; |
| 2725 | goto exit; |
| 2726 | } |
| 2727 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2728 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 2729 | "GETOKCMODE", okcMode); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2730 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2731 | { |
| 2732 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2733 | "%s: failed to copy data to user buffer", __func__); |
| 2734 | ret = -EFAULT; |
| 2735 | goto exit; |
| 2736 | } |
| 2737 | } |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2738 | else if (strncmp(command, "GETFASTROAM", 11) == 0) |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2739 | { |
| 2740 | tANI_BOOLEAN lfrMode = sme_getIsLfrFeatureEnabled((tHalHandle)(pHddCtx->hHal)); |
| 2741 | char extra[32]; |
| 2742 | tANI_U8 len = 0; |
| 2743 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2744 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 2745 | "GETFASTROAM", lfrMode); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2746 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2747 | { |
| 2748 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2749 | "%s: failed to copy data to user buffer", __func__); |
| 2750 | ret = -EFAULT; |
| 2751 | goto exit; |
| 2752 | } |
| 2753 | } |
| 2754 | else if (strncmp(command, "GETFASTTRANSITION", 17) == 0) |
| 2755 | { |
| 2756 | tANI_BOOLEAN ft = sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal)); |
| 2757 | char extra[32]; |
| 2758 | tANI_U8 len = 0; |
| 2759 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2760 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 2761 | "GETFASTTRANSITION", ft); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2762 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2763 | { |
| 2764 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2765 | "%s: failed to copy data to user buffer", __func__); |
| 2766 | ret = -EFAULT; |
| 2767 | goto exit; |
| 2768 | } |
| 2769 | } |
| 2770 | else if (strncmp(command, "SETROAMSCANCHANNELMINTIME", 25) == 0) |
| 2771 | { |
| 2772 | tANI_U8 *value = command; |
| 2773 | tANI_U8 minTime = CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_DEFAULT; |
| 2774 | |
| 2775 | /* Move pointer to ahead of SETROAMSCANCHANNELMINTIME<delimiter> */ |
| 2776 | value = value + 26; |
| 2777 | /* Convert the value from ascii to integer */ |
| 2778 | ret = kstrtou8(value, 10, &minTime); |
| 2779 | if (ret < 0) |
| 2780 | { |
| 2781 | /* If the input value is greater than max value of datatype, then also |
| 2782 | kstrtou8 fails */ |
| 2783 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2784 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 2785 | CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MIN, |
| 2786 | CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MAX); |
| 2787 | ret = -EINVAL; |
| 2788 | goto exit; |
| 2789 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2790 | if ((minTime < CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MIN) || |
| 2791 | (minTime > CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MAX)) |
| 2792 | { |
| 2793 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2794 | "scan min channel time value %d is out of range" |
| 2795 | " (Min: %d Max: %d)", minTime, |
| 2796 | CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MIN, |
| 2797 | CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MAX); |
| 2798 | ret = -EINVAL; |
| 2799 | goto exit; |
| 2800 | } |
| 2801 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2802 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2803 | TRACE_CODE_HDD_SETROAMSCANCHANNELMINTIME_IOCTL, |
| 2804 | pAdapter->sessionId, minTime)); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2805 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2806 | "%s: Received Command to change channel min time = %d", __func__, minTime); |
| 2807 | |
| 2808 | pHddCtx->cfg_ini->nNeighborScanMinChanTime = minTime; |
| 2809 | sme_setNeighborScanMinChanTime((tHalHandle)(pHddCtx->hHal), minTime); |
| 2810 | } |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 2811 | else if (strncmp(command, "SENDACTIONFRAME", 15) == 0) |
| 2812 | { |
| 2813 | tANI_U8 *value = command; |
| 2814 | tANI_U8 channel = 0; |
| 2815 | tANI_U8 dwellTime = 0; |
| 2816 | tANI_U8 bufLen = 0; |
| 2817 | tANI_U8 *buf = NULL; |
| 2818 | tSirMacAddr targetApBssid; |
| 2819 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 2820 | struct ieee80211_channel chan; |
| 2821 | tANI_U8 finalLen = 0; |
| 2822 | tANI_U8 *finalBuf = NULL; |
| 2823 | tANI_U8 temp = 0; |
| 2824 | u64 cookie; |
| 2825 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 2826 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 2827 | |
| 2828 | /* if not associated, no need to send action frame */ |
| 2829 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 2830 | { |
| 2831 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__); |
| 2832 | ret = -EINVAL; |
| 2833 | goto exit; |
| 2834 | } |
| 2835 | |
| 2836 | status = hdd_parse_send_action_frame_data(value, targetApBssid, &channel, |
| 2837 | &dwellTime, &buf, &bufLen); |
| 2838 | if (eHAL_STATUS_SUCCESS != status) |
| 2839 | { |
| 2840 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2841 | "%s: Failed to parse send action frame data", __func__); |
| 2842 | ret = -EINVAL; |
| 2843 | goto exit; |
| 2844 | } |
| 2845 | |
| 2846 | /* if the target bssid is different from currently associated AP, |
| 2847 | then no need to send action frame */ |
| 2848 | if (VOS_TRUE != vos_mem_compare(targetApBssid, |
| 2849 | pHddStaCtx->conn_info.bssId, sizeof(tSirMacAddr))) |
| 2850 | { |
| 2851 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:STA is not associated to this AP!",__func__); |
| 2852 | ret = -EINVAL; |
Jeff Johnson | 11c3315 | 2013-04-16 17:52:40 -0700 | [diff] [blame] | 2853 | vos_mem_free(buf); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 2854 | buf = NULL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 2855 | goto exit; |
| 2856 | } |
| 2857 | |
| 2858 | /* if the channel number is different from operating channel then |
| 2859 | no need to send action frame */ |
| 2860 | if (channel != pHddStaCtx->conn_info.operationChannel) |
| 2861 | { |
| 2862 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2863 | "%s: channel(%d) is different from operating channel(%d)", |
| 2864 | __func__, channel, pHddStaCtx->conn_info.operationChannel); |
| 2865 | ret = -EINVAL; |
Jeff Johnson | 11c3315 | 2013-04-16 17:52:40 -0700 | [diff] [blame] | 2866 | vos_mem_free(buf); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 2867 | buf = NULL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 2868 | goto exit; |
| 2869 | } |
| 2870 | chan.center_freq = sme_ChnToFreq(channel); |
| 2871 | |
| 2872 | finalLen = bufLen + 24; |
| 2873 | finalBuf = vos_mem_malloc(finalLen); |
| 2874 | if (NULL == finalBuf) |
| 2875 | { |
| 2876 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:memory allocation failed",__func__); |
| 2877 | ret = -ENOMEM; |
Jeff Johnson | 11c3315 | 2013-04-16 17:52:40 -0700 | [diff] [blame] | 2878 | vos_mem_free(buf); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 2879 | buf = NULL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 2880 | goto exit; |
| 2881 | } |
| 2882 | vos_mem_zero(finalBuf, finalLen); |
| 2883 | |
| 2884 | /* Fill subtype */ |
| 2885 | temp = SIR_MAC_MGMT_ACTION << 4; |
| 2886 | vos_mem_copy(finalBuf + 0, &temp, sizeof(temp)); |
| 2887 | |
| 2888 | /* Fill type */ |
| 2889 | temp = SIR_MAC_MGMT_FRAME; |
| 2890 | vos_mem_copy(finalBuf + 2, &temp, sizeof(temp)); |
| 2891 | |
| 2892 | /* Fill destination address (bssid of the AP) */ |
| 2893 | vos_mem_copy(finalBuf + 4, targetApBssid, sizeof(targetApBssid)); |
| 2894 | |
Srinivas Girigowda | b27c019 | 2013-06-03 10:19:56 -0700 | [diff] [blame] | 2895 | /* Fill source address (STA mac address) */ |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 2896 | vos_mem_copy(finalBuf + 10, pAdapter->macAddressCurrent.bytes, sizeof(pAdapter->macAddressCurrent.bytes)); |
| 2897 | |
Srinivas Girigowda | b27c019 | 2013-06-03 10:19:56 -0700 | [diff] [blame] | 2898 | /* Fill BSSID (AP mac address) */ |
| 2899 | vos_mem_copy(finalBuf + 16, targetApBssid, sizeof(targetApBssid)); |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 2900 | |
| 2901 | /* Fill received buffer from 24th address */ |
| 2902 | vos_mem_copy(finalBuf + 24, buf, bufLen); |
| 2903 | |
Jeff Johnson | 11c3315 | 2013-04-16 17:52:40 -0700 | [diff] [blame] | 2904 | /* done with the parsed buffer */ |
| 2905 | vos_mem_free(buf); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 2906 | buf = NULL; |
Jeff Johnson | 11c3315 | 2013-04-16 17:52:40 -0700 | [diff] [blame] | 2907 | |
DARAM SUDHA | 39eede6 | 2014-02-12 11:16:40 +0530 | [diff] [blame] | 2908 | wlan_hdd_mgmt_tx( NULL, |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 2909 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 2910 | &(pAdapter->wdev), |
| 2911 | #else |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2912 | pAdapter->dev, |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 2913 | #endif |
| 2914 | &chan, 0, |
| 2915 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)) |
| 2916 | NL80211_CHAN_HT20, 1, |
| 2917 | #endif |
| 2918 | dwellTime, finalBuf, finalLen, 1, |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 2919 | 1, &cookie ); |
| 2920 | vos_mem_free(finalBuf); |
| 2921 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2922 | else if (strncmp(command, "GETROAMSCANCHANNELMINTIME", 25) == 0) |
| 2923 | { |
| 2924 | tANI_U16 val = sme_getNeighborScanMinChanTime((tHalHandle)(pHddCtx->hHal)); |
| 2925 | char extra[32]; |
| 2926 | tANI_U8 len = 0; |
| 2927 | |
| 2928 | /* value is interms of msec */ |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2929 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 2930 | "GETROAMSCANCHANNELMINTIME", val); |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2931 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2932 | TRACE_CODE_HDD_GETROAMSCANCHANNELMINTIME_IOCTL, |
| 2933 | pAdapter->sessionId, val)); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2934 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2935 | { |
| 2936 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2937 | "%s: failed to copy data to user buffer", __func__); |
| 2938 | ret = -EFAULT; |
| 2939 | goto exit; |
| 2940 | } |
| 2941 | } |
| 2942 | else if (strncmp(command, "SETSCANCHANNELTIME", 18) == 0) |
| 2943 | { |
| 2944 | tANI_U8 *value = command; |
Varun Reddy Yeturu | 3885a66 | 2013-06-19 07:10:37 -0700 | [diff] [blame] | 2945 | tANI_U16 maxTime = CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_DEFAULT; |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2946 | |
| 2947 | /* Move pointer to ahead of SETSCANCHANNELTIME<delimiter> */ |
| 2948 | value = value + 19; |
| 2949 | /* Convert the value from ascii to integer */ |
Varun Reddy Yeturu | 3885a66 | 2013-06-19 07:10:37 -0700 | [diff] [blame] | 2950 | ret = kstrtou16(value, 10, &maxTime); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2951 | if (ret < 0) |
| 2952 | { |
| 2953 | /* If the input value is greater than max value of datatype, then also |
Varun Reddy Yeturu | 3885a66 | 2013-06-19 07:10:37 -0700 | [diff] [blame] | 2954 | kstrtou16 fails */ |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2955 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Varun Reddy Yeturu | 3885a66 | 2013-06-19 07:10:37 -0700 | [diff] [blame] | 2956 | "%s: kstrtou16 failed range [%d - %d]", __func__, |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2957 | CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MIN, |
| 2958 | CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MAX); |
| 2959 | ret = -EINVAL; |
| 2960 | goto exit; |
| 2961 | } |
| 2962 | |
| 2963 | if ((maxTime < CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MIN) || |
| 2964 | (maxTime > CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MAX)) |
| 2965 | { |
| 2966 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2967 | "lfr mode value %d is out of range" |
| 2968 | " (Min: %d Max: %d)", maxTime, |
| 2969 | CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MIN, |
| 2970 | CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MAX); |
| 2971 | ret = -EINVAL; |
| 2972 | goto exit; |
| 2973 | } |
| 2974 | |
| 2975 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2976 | "%s: Received Command to change channel max time = %d", __func__, maxTime); |
| 2977 | |
| 2978 | pHddCtx->cfg_ini->nNeighborScanMaxChanTime = maxTime; |
| 2979 | sme_setNeighborScanMaxChanTime((tHalHandle)(pHddCtx->hHal), maxTime); |
| 2980 | } |
| 2981 | else if (strncmp(command, "GETSCANCHANNELTIME", 18) == 0) |
| 2982 | { |
| 2983 | tANI_U16 val = sme_getNeighborScanMaxChanTime((tHalHandle)(pHddCtx->hHal)); |
| 2984 | char extra[32]; |
| 2985 | tANI_U8 len = 0; |
| 2986 | |
| 2987 | /* value is interms of msec */ |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2988 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 2989 | "GETSCANCHANNELTIME", val); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2990 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2991 | { |
| 2992 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2993 | "%s: failed to copy data to user buffer", __func__); |
| 2994 | ret = -EFAULT; |
| 2995 | goto exit; |
| 2996 | } |
| 2997 | } |
| 2998 | else if (strncmp(command, "SETSCANHOMETIME", 15) == 0) |
| 2999 | { |
| 3000 | tANI_U8 *value = command; |
| 3001 | tANI_U16 val = CFG_NEIGHBOR_SCAN_TIMER_PERIOD_DEFAULT; |
| 3002 | |
| 3003 | /* Move pointer to ahead of SETSCANHOMETIME<delimiter> */ |
| 3004 | value = value + 16; |
| 3005 | /* Convert the value from ascii to integer */ |
| 3006 | ret = kstrtou16(value, 10, &val); |
| 3007 | if (ret < 0) |
| 3008 | { |
| 3009 | /* If the input value is greater than max value of datatype, then also |
| 3010 | kstrtou16 fails */ |
| 3011 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3012 | "%s: kstrtou16 failed range [%d - %d]", __func__, |
| 3013 | CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MIN, |
| 3014 | CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MAX); |
| 3015 | ret = -EINVAL; |
| 3016 | goto exit; |
| 3017 | } |
| 3018 | |
| 3019 | if ((val < CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MIN) || |
| 3020 | (val > CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MAX)) |
| 3021 | { |
| 3022 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3023 | "scan home time value %d is out of range" |
| 3024 | " (Min: %d Max: %d)", val, |
| 3025 | CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MIN, |
| 3026 | CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MAX); |
| 3027 | ret = -EINVAL; |
| 3028 | goto exit; |
| 3029 | } |
| 3030 | |
| 3031 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3032 | "%s: Received Command to change scan home time = %d", __func__, val); |
| 3033 | |
| 3034 | pHddCtx->cfg_ini->nNeighborScanPeriod = val; |
| 3035 | sme_setNeighborScanPeriod((tHalHandle)(pHddCtx->hHal), val); |
| 3036 | } |
| 3037 | else if (strncmp(command, "GETSCANHOMETIME", 15) == 0) |
| 3038 | { |
| 3039 | tANI_U16 val = sme_getNeighborScanPeriod((tHalHandle)(pHddCtx->hHal)); |
| 3040 | char extra[32]; |
| 3041 | tANI_U8 len = 0; |
| 3042 | |
| 3043 | /* value is interms of msec */ |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3044 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3045 | "GETSCANHOMETIME", val); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3046 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 3047 | { |
| 3048 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3049 | "%s: failed to copy data to user buffer", __func__); |
| 3050 | ret = -EFAULT; |
| 3051 | goto exit; |
| 3052 | } |
| 3053 | } |
| 3054 | else if (strncmp(command, "SETROAMINTRABAND", 16) == 0) |
| 3055 | { |
| 3056 | tANI_U8 *value = command; |
| 3057 | tANI_U8 val = CFG_ROAM_INTRA_BAND_DEFAULT; |
| 3058 | |
| 3059 | /* Move pointer to ahead of SETROAMINTRABAND<delimiter> */ |
| 3060 | value = value + 17; |
| 3061 | /* Convert the value from ascii to integer */ |
| 3062 | ret = kstrtou8(value, 10, &val); |
| 3063 | if (ret < 0) |
| 3064 | { |
| 3065 | /* If the input value is greater than max value of datatype, then also |
| 3066 | kstrtou8 fails */ |
| 3067 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3068 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3069 | CFG_ROAM_INTRA_BAND_MIN, |
| 3070 | CFG_ROAM_INTRA_BAND_MAX); |
| 3071 | ret = -EINVAL; |
| 3072 | goto exit; |
| 3073 | } |
| 3074 | |
| 3075 | if ((val < CFG_ROAM_INTRA_BAND_MIN) || |
| 3076 | (val > CFG_ROAM_INTRA_BAND_MAX)) |
| 3077 | { |
| 3078 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3079 | "intra band mode value %d is out of range" |
| 3080 | " (Min: %d Max: %d)", val, |
| 3081 | CFG_ROAM_INTRA_BAND_MIN, |
| 3082 | CFG_ROAM_INTRA_BAND_MAX); |
| 3083 | ret = -EINVAL; |
| 3084 | goto exit; |
| 3085 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3086 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3087 | "%s: Received Command to change intra band = %d", __func__, val); |
| 3088 | |
| 3089 | pHddCtx->cfg_ini->nRoamIntraBand = val; |
| 3090 | sme_setRoamIntraBand((tHalHandle)(pHddCtx->hHal), val); |
| 3091 | } |
| 3092 | else if (strncmp(command, "GETROAMINTRABAND", 16) == 0) |
| 3093 | { |
| 3094 | tANI_U16 val = sme_getRoamIntraBand((tHalHandle)(pHddCtx->hHal)); |
| 3095 | char extra[32]; |
| 3096 | tANI_U8 len = 0; |
| 3097 | |
| 3098 | /* value is interms of msec */ |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3099 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3100 | "GETROAMINTRABAND", val); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3101 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 3102 | { |
| 3103 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3104 | "%s: failed to copy data to user buffer", __func__); |
| 3105 | ret = -EFAULT; |
| 3106 | goto exit; |
| 3107 | } |
| 3108 | } |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3109 | else if (strncmp(command, "SETSCANNPROBES", 14) == 0) |
| 3110 | { |
| 3111 | tANI_U8 *value = command; |
| 3112 | tANI_U8 nProbes = CFG_ROAM_SCAN_N_PROBES_DEFAULT; |
| 3113 | |
| 3114 | /* Move pointer to ahead of SETSCANNPROBES<delimiter> */ |
| 3115 | value = value + 15; |
| 3116 | /* Convert the value from ascii to integer */ |
| 3117 | ret = kstrtou8(value, 10, &nProbes); |
| 3118 | if (ret < 0) |
| 3119 | { |
| 3120 | /* If the input value is greater than max value of datatype, then also |
| 3121 | kstrtou8 fails */ |
| 3122 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3123 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3124 | CFG_ROAM_SCAN_N_PROBES_MIN, |
| 3125 | CFG_ROAM_SCAN_N_PROBES_MAX); |
| 3126 | ret = -EINVAL; |
| 3127 | goto exit; |
| 3128 | } |
| 3129 | |
| 3130 | if ((nProbes < CFG_ROAM_SCAN_N_PROBES_MIN) || |
| 3131 | (nProbes > CFG_ROAM_SCAN_N_PROBES_MAX)) |
| 3132 | { |
| 3133 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3134 | "NProbes value %d is out of range" |
| 3135 | " (Min: %d Max: %d)", nProbes, |
| 3136 | CFG_ROAM_SCAN_N_PROBES_MIN, |
| 3137 | CFG_ROAM_SCAN_N_PROBES_MAX); |
| 3138 | ret = -EINVAL; |
| 3139 | goto exit; |
| 3140 | } |
| 3141 | |
| 3142 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3143 | "%s: Received Command to Set nProbes = %d", __func__, nProbes); |
| 3144 | |
| 3145 | pHddCtx->cfg_ini->nProbes = nProbes; |
| 3146 | sme_UpdateRoamScanNProbes((tHalHandle)(pHddCtx->hHal), nProbes); |
| 3147 | } |
| 3148 | else if (strncmp(priv_data.buf, "GETSCANNPROBES", 14) == 0) |
| 3149 | { |
| 3150 | tANI_U8 val = sme_getRoamScanNProbes((tHalHandle)(pHddCtx->hHal)); |
| 3151 | char extra[32]; |
| 3152 | tANI_U8 len = 0; |
| 3153 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3154 | len = scnprintf(extra, sizeof(extra), "%s %d", command, val); |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3155 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 3156 | { |
| 3157 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3158 | "%s: failed to copy data to user buffer", __func__); |
| 3159 | ret = -EFAULT; |
| 3160 | goto exit; |
| 3161 | } |
| 3162 | } |
| 3163 | else if (strncmp(command, "SETSCANHOMEAWAYTIME", 19) == 0) |
| 3164 | { |
| 3165 | tANI_U8 *value = command; |
| 3166 | tANI_U16 homeAwayTime = CFG_ROAM_SCAN_HOME_AWAY_TIME_DEFAULT; |
| 3167 | |
| 3168 | /* Move pointer to ahead of SETSCANHOMEAWAYTIME<delimiter> */ |
| 3169 | /* input value is in units of msec */ |
| 3170 | value = value + 20; |
| 3171 | /* Convert the value from ascii to integer */ |
| 3172 | ret = kstrtou16(value, 10, &homeAwayTime); |
| 3173 | if (ret < 0) |
| 3174 | { |
| 3175 | /* If the input value is greater than max value of datatype, then also |
| 3176 | kstrtou8 fails */ |
| 3177 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3178 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3179 | CFG_ROAM_SCAN_HOME_AWAY_TIME_MIN, |
| 3180 | CFG_ROAM_SCAN_HOME_AWAY_TIME_MAX); |
| 3181 | ret = -EINVAL; |
| 3182 | goto exit; |
| 3183 | } |
| 3184 | |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3185 | if ((homeAwayTime < CFG_ROAM_SCAN_HOME_AWAY_TIME_MIN) || |
| 3186 | (homeAwayTime > CFG_ROAM_SCAN_HOME_AWAY_TIME_MAX)) |
| 3187 | { |
| 3188 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3189 | "homeAwayTime value %d is out of range" |
| 3190 | " (Min: %d Max: %d)", homeAwayTime, |
| 3191 | CFG_ROAM_SCAN_HOME_AWAY_TIME_MIN, |
| 3192 | CFG_ROAM_SCAN_HOME_AWAY_TIME_MAX); |
| 3193 | ret = -EINVAL; |
| 3194 | goto exit; |
| 3195 | } |
| 3196 | |
| 3197 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3198 | "%s: Received Command to Set scan away time = %d", __func__, homeAwayTime); |
Srinivas Girigowda | 6cf0b82 | 2013-06-27 14:00:20 -0700 | [diff] [blame] | 3199 | if (pHddCtx->cfg_ini->nRoamScanHomeAwayTime != homeAwayTime) |
| 3200 | { |
| 3201 | pHddCtx->cfg_ini->nRoamScanHomeAwayTime = homeAwayTime; |
| 3202 | sme_UpdateRoamScanHomeAwayTime((tHalHandle)(pHddCtx->hHal), homeAwayTime, eANI_BOOLEAN_TRUE); |
| 3203 | } |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3204 | } |
| 3205 | else if (strncmp(priv_data.buf, "GETSCANHOMEAWAYTIME", 19) == 0) |
| 3206 | { |
| 3207 | tANI_U16 val = sme_getRoamScanHomeAwayTime((tHalHandle)(pHddCtx->hHal)); |
| 3208 | char extra[32]; |
| 3209 | tANI_U8 len = 0; |
| 3210 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3211 | len = scnprintf(extra, sizeof(extra), "%s %d", command, val); |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3212 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 3213 | { |
| 3214 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3215 | "%s: failed to copy data to user buffer", __func__); |
| 3216 | ret = -EFAULT; |
| 3217 | goto exit; |
| 3218 | } |
| 3219 | } |
| 3220 | else if (strncmp(command, "REASSOC", 7) == 0) |
| 3221 | { |
| 3222 | tANI_U8 *value = command; |
| 3223 | tANI_U8 channel = 0; |
| 3224 | tSirMacAddr targetApBssid; |
| 3225 | eHalStatus status = eHAL_STATUS_SUCCESS; |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 3226 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 3227 | tCsrHandoffRequest handoffInfo; |
| 3228 | #endif |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3229 | hdd_station_ctx_t *pHddStaCtx = NULL; |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3230 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3231 | |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3232 | /* if not associated, no need to proceed with reassoc */ |
| 3233 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 3234 | { |
| 3235 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__); |
| 3236 | ret = -EINVAL; |
| 3237 | goto exit; |
| 3238 | } |
| 3239 | |
| 3240 | status = hdd_parse_reassoc_command_data(value, targetApBssid, &channel); |
| 3241 | if (eHAL_STATUS_SUCCESS != status) |
| 3242 | { |
| 3243 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3244 | "%s: Failed to parse reassoc command data", __func__); |
| 3245 | ret = -EINVAL; |
| 3246 | goto exit; |
| 3247 | } |
| 3248 | |
| 3249 | /* if the target bssid is same as currently associated AP, |
| 3250 | then no need to proceed with reassoc */ |
| 3251 | if (VOS_TRUE == vos_mem_compare(targetApBssid, |
| 3252 | pHddStaCtx->conn_info.bssId, sizeof(tSirMacAddr))) |
| 3253 | { |
| 3254 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Reassoc BSSID is same as currently associated AP bssid",__func__); |
| 3255 | ret = -EINVAL; |
| 3256 | goto exit; |
| 3257 | } |
| 3258 | |
| 3259 | /* Check channel number is a valid channel number */ |
| 3260 | if(VOS_STATUS_SUCCESS != |
| 3261 | wlan_hdd_validate_operation_channel(pAdapter, channel)) |
| 3262 | { |
| 3263 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 3264 | "%s: Invalid Channel [%d]", __func__, channel); |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3265 | return -EINVAL; |
| 3266 | } |
| 3267 | |
| 3268 | /* Proceed with reassoc */ |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 3269 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 3270 | handoffInfo.channel = channel; |
| 3271 | vos_mem_copy(handoffInfo.bssid, targetApBssid, sizeof(tSirMacAddr)); |
| 3272 | sme_HandoffRequest(pHddCtx->hHal, &handoffInfo); |
| 3273 | #endif |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3274 | } |
Srinivas Girigowda | ad34ca9 | 2013-10-22 10:54:29 -0700 | [diff] [blame] | 3275 | else if (strncmp(command, "SETWESMODE", 10) == 0) |
| 3276 | { |
| 3277 | tANI_U8 *value = command; |
| 3278 | tANI_BOOLEAN wesMode = CFG_ENABLE_WES_MODE_NAME_DEFAULT; |
| 3279 | |
| 3280 | /* Move pointer to ahead of SETWESMODE<delimiter> */ |
| 3281 | value = value + 11; |
| 3282 | /* Convert the value from ascii to integer */ |
| 3283 | ret = kstrtou8(value, 10, &wesMode); |
| 3284 | if (ret < 0) |
| 3285 | { |
| 3286 | /* If the input value is greater than max value of datatype, then also |
| 3287 | kstrtou8 fails */ |
| 3288 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3289 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3290 | CFG_ENABLE_WES_MODE_NAME_MIN, |
| 3291 | CFG_ENABLE_WES_MODE_NAME_MAX); |
| 3292 | ret = -EINVAL; |
| 3293 | goto exit; |
| 3294 | } |
| 3295 | |
| 3296 | if ((wesMode < CFG_ENABLE_WES_MODE_NAME_MIN) || |
| 3297 | (wesMode > CFG_ENABLE_WES_MODE_NAME_MAX)) |
| 3298 | { |
| 3299 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3300 | "WES Mode value %d is out of range" |
| 3301 | " (Min: %d Max: %d)", wesMode, |
| 3302 | CFG_ENABLE_WES_MODE_NAME_MIN, |
| 3303 | CFG_ENABLE_WES_MODE_NAME_MAX); |
| 3304 | ret = -EINVAL; |
| 3305 | goto exit; |
| 3306 | } |
| 3307 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3308 | "%s: Received Command to Set WES Mode rssi diff = %d", __func__, wesMode); |
| 3309 | |
| 3310 | pHddCtx->cfg_ini->isWESModeEnabled = wesMode; |
| 3311 | sme_UpdateWESMode((tHalHandle)(pHddCtx->hHal), wesMode); |
| 3312 | } |
| 3313 | else if (strncmp(priv_data.buf, "GETWESMODE", 10) == 0) |
| 3314 | { |
| 3315 | tANI_BOOLEAN wesMode = sme_GetWESMode((tHalHandle)(pHddCtx->hHal)); |
| 3316 | char extra[32]; |
| 3317 | tANI_U8 len = 0; |
| 3318 | |
Arif Hussain | 826d941 | 2013-11-12 16:44:54 -0800 | [diff] [blame] | 3319 | len = scnprintf(extra, sizeof(extra), "%s %d", command, wesMode); |
Srinivas Girigowda | ad34ca9 | 2013-10-22 10:54:29 -0700 | [diff] [blame] | 3320 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 3321 | { |
| 3322 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3323 | "%s: failed to copy data to user buffer", __func__); |
| 3324 | ret = -EFAULT; |
| 3325 | goto exit; |
| 3326 | } |
| 3327 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3328 | #endif /* WLAN_FEATURE_VOWIFI_11R || FEATURE_WLAN_ESE || FEATURE_WLAN_LFR */ |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3329 | #ifdef FEATURE_WLAN_LFR |
| 3330 | else if (strncmp(command, "SETFASTROAM", 11) == 0) |
| 3331 | { |
| 3332 | tANI_U8 *value = command; |
| 3333 | tANI_U8 lfrMode = CFG_LFR_FEATURE_ENABLED_DEFAULT; |
| 3334 | |
| 3335 | /* Move pointer to ahead of SETFASTROAM<delimiter> */ |
| 3336 | value = value + 12; |
| 3337 | /* Convert the value from ascii to integer */ |
| 3338 | ret = kstrtou8(value, 10, &lfrMode); |
| 3339 | if (ret < 0) |
| 3340 | { |
| 3341 | /* If the input value is greater than max value of datatype, then also |
| 3342 | kstrtou8 fails */ |
| 3343 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3344 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3345 | CFG_LFR_FEATURE_ENABLED_MIN, |
| 3346 | CFG_LFR_FEATURE_ENABLED_MAX); |
| 3347 | ret = -EINVAL; |
| 3348 | goto exit; |
| 3349 | } |
| 3350 | |
| 3351 | if ((lfrMode < CFG_LFR_FEATURE_ENABLED_MIN) || |
| 3352 | (lfrMode > CFG_LFR_FEATURE_ENABLED_MAX)) |
| 3353 | { |
| 3354 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3355 | "lfr mode value %d is out of range" |
| 3356 | " (Min: %d Max: %d)", lfrMode, |
| 3357 | CFG_LFR_FEATURE_ENABLED_MIN, |
| 3358 | CFG_LFR_FEATURE_ENABLED_MAX); |
| 3359 | ret = -EINVAL; |
| 3360 | goto exit; |
| 3361 | } |
| 3362 | |
| 3363 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3364 | "%s: Received Command to change lfr mode = %d", __func__, lfrMode); |
| 3365 | |
| 3366 | pHddCtx->cfg_ini->isFastRoamIniFeatureEnabled = lfrMode; |
| 3367 | sme_UpdateIsFastRoamIniFeatureEnabled((tHalHandle)(pHddCtx->hHal), lfrMode); |
| 3368 | } |
| 3369 | #endif |
| 3370 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 3371 | else if (strncmp(command, "SETFASTTRANSITION", 17) == 0) |
| 3372 | { |
| 3373 | tANI_U8 *value = command; |
| 3374 | tANI_U8 ft = CFG_FAST_TRANSITION_ENABLED_NAME_DEFAULT; |
| 3375 | |
| 3376 | /* Move pointer to ahead of SETFASTROAM<delimiter> */ |
| 3377 | value = value + 18; |
| 3378 | /* Convert the value from ascii to integer */ |
| 3379 | ret = kstrtou8(value, 10, &ft); |
| 3380 | if (ret < 0) |
| 3381 | { |
| 3382 | /* If the input value is greater than max value of datatype, then also |
| 3383 | kstrtou8 fails */ |
| 3384 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3385 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3386 | CFG_FAST_TRANSITION_ENABLED_NAME_MIN, |
| 3387 | CFG_FAST_TRANSITION_ENABLED_NAME_MAX); |
| 3388 | ret = -EINVAL; |
| 3389 | goto exit; |
| 3390 | } |
| 3391 | |
| 3392 | if ((ft < CFG_FAST_TRANSITION_ENABLED_NAME_MIN) || |
| 3393 | (ft > CFG_FAST_TRANSITION_ENABLED_NAME_MAX)) |
| 3394 | { |
| 3395 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3396 | "ft mode value %d is out of range" |
| 3397 | " (Min: %d Max: %d)", ft, |
| 3398 | CFG_FAST_TRANSITION_ENABLED_NAME_MIN, |
| 3399 | CFG_FAST_TRANSITION_ENABLED_NAME_MAX); |
| 3400 | ret = -EINVAL; |
| 3401 | goto exit; |
| 3402 | } |
| 3403 | |
| 3404 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3405 | "%s: Received Command to change ft mode = %d", __func__, ft); |
| 3406 | |
| 3407 | pHddCtx->cfg_ini->isFastTransitionEnabled = ft; |
| 3408 | sme_UpdateFastTransitionEnabled((tHalHandle)(pHddCtx->hHal), ft); |
| 3409 | } |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 3410 | |
| 3411 | else if (strncmp(command, "FASTREASSOC", 11) == 0) |
| 3412 | { |
| 3413 | tANI_U8 *value = command; |
| 3414 | tSirMacAddr targetApBssid; |
| 3415 | tANI_U8 trigger = 0; |
| 3416 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 3417 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 3418 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3419 | |
| 3420 | /* if not associated, no need to proceed with reassoc */ |
| 3421 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 3422 | { |
| 3423 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__); |
| 3424 | ret = -EINVAL; |
| 3425 | goto exit; |
| 3426 | } |
| 3427 | |
| 3428 | status = hdd_parse_reassoc_command_data(value, targetApBssid, &trigger); |
| 3429 | if (eHAL_STATUS_SUCCESS != status) |
| 3430 | { |
| 3431 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3432 | "%s: Failed to parse reassoc command data", __func__); |
| 3433 | ret = -EINVAL; |
| 3434 | goto exit; |
| 3435 | } |
| 3436 | |
| 3437 | /* if the target bssid is same as currently associated AP, |
| 3438 | then no need to proceed with reassoc */ |
| 3439 | if (VOS_TRUE == vos_mem_compare(targetApBssid, |
| 3440 | pHddStaCtx->conn_info.bssId, sizeof(tSirMacAddr))) |
| 3441 | { |
| 3442 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3443 | "%s:11r Reassoc BSSID is same as currently associated AP bssid", |
| 3444 | __func__); |
| 3445 | ret = -EINVAL; |
| 3446 | goto exit; |
| 3447 | } |
| 3448 | |
| 3449 | /* Proceed with scan/roam */ |
| 3450 | smeIssueFastRoamNeighborAPEvent(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 3451 | &targetApBssid[0], |
| 3452 | (tSmeFastRoamTrigger)(trigger)); |
| 3453 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3454 | #endif |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3455 | #ifdef FEATURE_WLAN_ESE |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3456 | else if (strncmp(command, "SETCCXMODE", 10) == 0) |
| 3457 | { |
| 3458 | tANI_U8 *value = command; |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3459 | tANI_U8 eseMode = CFG_ESE_FEATURE_ENABLED_DEFAULT; |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3460 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3461 | /* Check if the features OKC/ESE/11R are supported simultaneously, |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 3462 | then this operation is not permitted (return FAILURE) */ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3463 | if (sme_getIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal)) && |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 3464 | hdd_is_okc_mode_enabled(pHddCtx) && |
| 3465 | sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal))) |
| 3466 | { |
| 3467 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3468 | "%s: OKC/ESE/11R are supported simultaneously" |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 3469 | " hence this operation is not permitted!", __func__); |
| 3470 | ret = -EPERM; |
| 3471 | goto exit; |
| 3472 | } |
| 3473 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3474 | /* Move pointer to ahead of SETCCXMODE<delimiter> */ |
| 3475 | value = value + 11; |
| 3476 | /* Convert the value from ascii to integer */ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3477 | ret = kstrtou8(value, 10, &eseMode); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3478 | if (ret < 0) |
| 3479 | { |
| 3480 | /* If the input value is greater than max value of datatype, then also |
| 3481 | kstrtou8 fails */ |
| 3482 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3483 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3484 | CFG_ESE_FEATURE_ENABLED_MIN, |
| 3485 | CFG_ESE_FEATURE_ENABLED_MAX); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3486 | ret = -EINVAL; |
| 3487 | goto exit; |
| 3488 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3489 | if ((eseMode < CFG_ESE_FEATURE_ENABLED_MIN) || |
| 3490 | (eseMode > CFG_ESE_FEATURE_ENABLED_MAX)) |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3491 | { |
| 3492 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3493 | "Ese mode value %d is out of range" |
| 3494 | " (Min: %d Max: %d)", eseMode, |
| 3495 | CFG_ESE_FEATURE_ENABLED_MIN, |
| 3496 | CFG_ESE_FEATURE_ENABLED_MAX); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3497 | ret = -EINVAL; |
| 3498 | goto exit; |
| 3499 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3500 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3501 | "%s: Received Command to change ese mode = %d", __func__, eseMode); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3502 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3503 | pHddCtx->cfg_ini->isEseIniFeatureEnabled = eseMode; |
| 3504 | sme_UpdateIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal), eseMode); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3505 | } |
| 3506 | #endif |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 3507 | else if (strncmp(command, "SETROAMSCANCONTROL", 18) == 0) |
| 3508 | { |
| 3509 | tANI_U8 *value = command; |
| 3510 | tANI_BOOLEAN roamScanControl = 0; |
| 3511 | |
| 3512 | /* Move pointer to ahead of SETROAMSCANCONTROL<delimiter> */ |
| 3513 | value = value + 19; |
| 3514 | /* Convert the value from ascii to integer */ |
| 3515 | ret = kstrtou8(value, 10, &roamScanControl); |
| 3516 | if (ret < 0) |
| 3517 | { |
| 3518 | /* If the input value is greater than max value of datatype, then also |
| 3519 | kstrtou8 fails */ |
| 3520 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3521 | "%s: kstrtou8 failed ", __func__); |
| 3522 | ret = -EINVAL; |
| 3523 | goto exit; |
| 3524 | } |
| 3525 | |
| 3526 | if (0 != roamScanControl) |
| 3527 | { |
| 3528 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3529 | "roam scan control invalid value = %d", |
| 3530 | roamScanControl); |
| 3531 | ret = -EINVAL; |
| 3532 | goto exit; |
| 3533 | } |
| 3534 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3535 | "%s: Received Command to Set roam scan control = %d", __func__, roamScanControl); |
| 3536 | |
| 3537 | sme_SetRoamScanControl((tHalHandle)(pHddCtx->hHal), roamScanControl); |
| 3538 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3539 | #ifdef FEATURE_WLAN_OKC |
| 3540 | else if (strncmp(command, "SETOKCMODE", 10) == 0) |
| 3541 | { |
| 3542 | tANI_U8 *value = command; |
| 3543 | tANI_U8 okcMode = CFG_OKC_FEATURE_ENABLED_DEFAULT; |
| 3544 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3545 | /* Check if the features OKC/ESE/11R are supported simultaneously, |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 3546 | then this operation is not permitted (return FAILURE) */ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3547 | if (sme_getIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal)) && |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 3548 | hdd_is_okc_mode_enabled(pHddCtx) && |
| 3549 | sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal))) |
| 3550 | { |
| 3551 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3552 | "%s: OKC/ESE/11R are supported simultaneously" |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 3553 | " hence this operation is not permitted!", __func__); |
| 3554 | ret = -EPERM; |
| 3555 | goto exit; |
| 3556 | } |
| 3557 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3558 | /* Move pointer to ahead of SETOKCMODE<delimiter> */ |
| 3559 | value = value + 11; |
| 3560 | /* Convert the value from ascii to integer */ |
| 3561 | ret = kstrtou8(value, 10, &okcMode); |
| 3562 | if (ret < 0) |
| 3563 | { |
| 3564 | /* If the input value is greater than max value of datatype, then also |
| 3565 | kstrtou8 fails */ |
| 3566 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3567 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3568 | CFG_OKC_FEATURE_ENABLED_MIN, |
| 3569 | CFG_OKC_FEATURE_ENABLED_MAX); |
| 3570 | ret = -EINVAL; |
| 3571 | goto exit; |
| 3572 | } |
| 3573 | |
| 3574 | if ((okcMode < CFG_OKC_FEATURE_ENABLED_MIN) || |
| 3575 | (okcMode > CFG_OKC_FEATURE_ENABLED_MAX)) |
| 3576 | { |
| 3577 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3578 | "Okc mode value %d is out of range" |
| 3579 | " (Min: %d Max: %d)", okcMode, |
| 3580 | CFG_OKC_FEATURE_ENABLED_MIN, |
| 3581 | CFG_OKC_FEATURE_ENABLED_MAX); |
| 3582 | ret = -EINVAL; |
| 3583 | goto exit; |
| 3584 | } |
| 3585 | |
| 3586 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3587 | "%s: Received Command to change okc mode = %d", __func__, okcMode); |
| 3588 | |
| 3589 | pHddCtx->cfg_ini->isOkcIniFeatureEnabled = okcMode; |
| 3590 | } |
Srinivas Girigowda | ad34ca9 | 2013-10-22 10:54:29 -0700 | [diff] [blame] | 3591 | #endif /* FEATURE_WLAN_OKC */ |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 3592 | else if (strncmp(priv_data.buf, "GETROAMSCANCONTROL", 18) == 0) |
| 3593 | { |
| 3594 | tANI_BOOLEAN roamScanControl = sme_GetRoamScanControl((tHalHandle)(pHddCtx->hHal)); |
| 3595 | char extra[32]; |
| 3596 | tANI_U8 len = 0; |
| 3597 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3598 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3599 | command, roamScanControl); |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 3600 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 3601 | { |
| 3602 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3603 | "%s: failed to copy data to user buffer", __func__); |
| 3604 | ret = -EFAULT; |
| 3605 | goto exit; |
| 3606 | } |
| 3607 | } |
Gopichand Nakkala | 227c7f3 | 2013-06-26 22:44:57 +0530 | [diff] [blame] | 3608 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 3609 | else if (strncmp(command, "ENABLE_PKTFILTER_IPV6", 21) == 0) |
| 3610 | { |
| 3611 | tANI_U8 filterType = 0; |
| 3612 | tANI_U8 *value = command; |
| 3613 | |
| 3614 | /* Move pointer to ahead of ENABLE_PKTFILTER_IPV6<delimiter> */ |
| 3615 | value = value + 22; |
| 3616 | |
| 3617 | /* Convert the value from ascii to integer */ |
| 3618 | ret = kstrtou8(value, 10, &filterType); |
| 3619 | if (ret < 0) |
| 3620 | { |
| 3621 | /* If the input value is greater than max value of datatype, |
| 3622 | * then also kstrtou8 fails |
| 3623 | */ |
| 3624 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3625 | "%s: kstrtou8 failed range ", __func__); |
| 3626 | ret = -EINVAL; |
| 3627 | goto exit; |
| 3628 | } |
| 3629 | |
| 3630 | if (filterType != 0 && filterType != 1) |
| 3631 | { |
| 3632 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3633 | "%s: Accepted Values are 0 and 1 ", __func__); |
| 3634 | ret = -EINVAL; |
| 3635 | goto exit; |
| 3636 | } |
| 3637 | wlan_hdd_setIPv6Filter(WLAN_HDD_GET_CTX(pAdapter), filterType, |
| 3638 | pAdapter->sessionId); |
| 3639 | } |
| 3640 | #endif |
Sundaresan Ramachandran | 76e48e8 | 2013-07-15 13:07:17 +0530 | [diff] [blame] | 3641 | else if (strncmp(command, "BTCOEXMODE", 10) == 0 ) |
| 3642 | { |
Kiet Lam | 94fd292 | 2014-06-18 19:12:43 -0700 | [diff] [blame] | 3643 | char *bcMode; |
| 3644 | bcMode = command + 11; |
| 3645 | if ('1' == *bcMode) |
Sundaresan Ramachandran | 76e48e8 | 2013-07-15 13:07:17 +0530 | [diff] [blame] | 3646 | { |
c_hpothu | 9b781ba | 2013-12-30 20:57:45 +0530 | [diff] [blame] | 3647 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Kiet Lam | 94fd292 | 2014-06-18 19:12:43 -0700 | [diff] [blame] | 3648 | FL("BTCOEXMODE %d"), *bcMode); |
c_hpothu | 9b781ba | 2013-12-30 20:57:45 +0530 | [diff] [blame] | 3649 | |
| 3650 | pHddCtx->btCoexModeSet = TRUE; |
Sundaresan Ramachandran | 76e48e8 | 2013-07-15 13:07:17 +0530 | [diff] [blame] | 3651 | } |
Kiet Lam | 94fd292 | 2014-06-18 19:12:43 -0700 | [diff] [blame] | 3652 | else if ('2' == *bcMode) |
Sundaresan Ramachandran | 76e48e8 | 2013-07-15 13:07:17 +0530 | [diff] [blame] | 3653 | { |
c_hpothu | 9b781ba | 2013-12-30 20:57:45 +0530 | [diff] [blame] | 3654 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Kiet Lam | 94fd292 | 2014-06-18 19:12:43 -0700 | [diff] [blame] | 3655 | FL("BTCOEXMODE %d"), *bcMode); |
c_hpothu | 9b781ba | 2013-12-30 20:57:45 +0530 | [diff] [blame] | 3656 | |
| 3657 | pHddCtx->btCoexModeSet = FALSE; |
Sundaresan Ramachandran | 76e48e8 | 2013-07-15 13:07:17 +0530 | [diff] [blame] | 3658 | } |
| 3659 | } |
Jeff Johnson | f54df2c | 2013-07-24 11:43:39 -0700 | [diff] [blame] | 3660 | else if (strncmp(command, "SCAN-ACTIVE", 11) == 0) |
| 3661 | { |
c_hpothu | dbefd3e | 2014-04-28 15:59:47 +0530 | [diff] [blame] | 3662 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3663 | FL("making default scan to ACTIVE")); |
| 3664 | pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN; |
Jeff Johnson | f54df2c | 2013-07-24 11:43:39 -0700 | [diff] [blame] | 3665 | } |
| 3666 | else if (strncmp(command, "SCAN-PASSIVE", 12) == 0) |
| 3667 | { |
c_hpothu | dbefd3e | 2014-04-28 15:59:47 +0530 | [diff] [blame] | 3668 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3669 | FL("making default scan to PASSIVE")); |
| 3670 | pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN; |
Jeff Johnson | f54df2c | 2013-07-24 11:43:39 -0700 | [diff] [blame] | 3671 | } |
Hanumantha Reddy Pothula | 212243c | 2013-08-01 17:28:31 +0530 | [diff] [blame] | 3672 | else if (strncmp(command, "GETDWELLTIME", 12) == 0) |
| 3673 | { |
| 3674 | hdd_config_t *pCfg = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini; |
| 3675 | char extra[32]; |
| 3676 | tANI_U8 len = 0; |
| 3677 | |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 3678 | memset(extra, 0, sizeof(extra)); |
| 3679 | ret = hdd_get_dwell_time(pCfg, command, extra, sizeof(extra), &len); |
| 3680 | if (ret != 0 || copy_to_user(priv_data.buf, &extra, len + 1)) |
Hanumantha Reddy Pothula | 212243c | 2013-08-01 17:28:31 +0530 | [diff] [blame] | 3681 | { |
| 3682 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3683 | "%s: failed to copy data to user buffer", __func__); |
| 3684 | ret = -EFAULT; |
| 3685 | goto exit; |
| 3686 | } |
| 3687 | ret = len; |
| 3688 | } |
| 3689 | else if (strncmp(command, "SETDWELLTIME", 12) == 0) |
| 3690 | { |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 3691 | ret = hdd_set_dwell_time(pAdapter, command); |
Hanumantha Reddy Pothula | 212243c | 2013-08-01 17:28:31 +0530 | [diff] [blame] | 3692 | } |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 3693 | else if ( strncasecmp(command, "MIRACAST", 8) == 0 ) |
| 3694 | { |
| 3695 | tANI_U8 filterType = 0; |
| 3696 | tANI_U8 *value; |
| 3697 | value = command + 9; |
| 3698 | |
| 3699 | /* Convert the value from ascii to integer */ |
| 3700 | ret = kstrtou8(value, 10, &filterType); |
| 3701 | if (ret < 0) |
| 3702 | { |
| 3703 | /* If the input value is greater than max value of datatype, |
| 3704 | * then also kstrtou8 fails |
| 3705 | */ |
| 3706 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3707 | "%s: kstrtou8 failed range ", __func__); |
| 3708 | ret = -EINVAL; |
| 3709 | goto exit; |
| 3710 | } |
| 3711 | if ((filterType < WLAN_HDD_DRIVER_MIRACAST_CFG_MIN_VAL ) || |
| 3712 | (filterType > WLAN_HDD_DRIVER_MIRACAST_CFG_MAX_VAL)) |
| 3713 | { |
| 3714 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3715 | "%s: Accepted Values are 0 to 2. 0-Disabled, 1-Source," |
| 3716 | " 2-Sink ", __func__); |
| 3717 | ret = -EINVAL; |
| 3718 | goto exit; |
| 3719 | } |
| 3720 | //Filtertype value should be either 0-Disabled, 1-Source, 2-sink |
| 3721 | pHddCtx->drvr_miracast = filterType; |
| 3722 | hdd_tx_rx_pkt_cnt_stat_timer_handler(pHddCtx); |
| 3723 | } |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 3724 | else if (strncmp(command, "SETMCRATE", 9) == 0) |
| 3725 | { |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 3726 | tANI_U8 *value = command; |
| 3727 | int targetRate; |
Leo Chang | 1f98cbd | 2013-10-17 15:03:52 -0700 | [diff] [blame] | 3728 | tSirRateUpdateInd *rateUpdate; |
| 3729 | eHalStatus status; |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 3730 | |
| 3731 | /* Only valid for SAP mode */ |
| 3732 | if (WLAN_HDD_SOFTAP != pAdapter->device_mode) |
| 3733 | { |
| 3734 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3735 | "%s: SAP mode is not running", __func__); |
| 3736 | ret = -EFAULT; |
| 3737 | goto exit; |
| 3738 | } |
| 3739 | |
| 3740 | /* Move pointer to ahead of SETMCRATE<delimiter> */ |
| 3741 | /* input value is in units of hundred kbps */ |
| 3742 | value = value + 10; |
| 3743 | /* Convert the value from ascii to integer, decimal base */ |
| 3744 | ret = kstrtouint(value, 10, &targetRate); |
| 3745 | |
Leo Chang | 1f98cbd | 2013-10-17 15:03:52 -0700 | [diff] [blame] | 3746 | rateUpdate = (tSirRateUpdateInd *)vos_mem_malloc(sizeof(tSirRateUpdateInd)); |
| 3747 | if (NULL == rateUpdate) |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 3748 | { |
Leo Chang | 1f98cbd | 2013-10-17 15:03:52 -0700 | [diff] [blame] | 3749 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3750 | "%s: SETMCRATE indication alloc fail", __func__); |
| 3751 | ret = -EFAULT; |
| 3752 | goto exit; |
| 3753 | } |
| 3754 | vos_mem_zero(rateUpdate, sizeof(tSirRateUpdateInd )); |
| 3755 | |
| 3756 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3757 | "MC Target rate %d", targetRate); |
| 3758 | /* Ignore unicast */ |
| 3759 | rateUpdate->ucastDataRate = -1; |
| 3760 | rateUpdate->mcastDataRate24GHz = targetRate; |
| 3761 | rateUpdate->mcastDataRate5GHz = targetRate; |
| 3762 | rateUpdate->mcastDataRate24GHzTxFlag = 0; |
| 3763 | rateUpdate->mcastDataRate5GHzTxFlag = 0; |
| 3764 | status = sme_SendRateUpdateInd(pHddCtx->hHal, rateUpdate); |
| 3765 | if (eHAL_STATUS_SUCCESS != status) |
| 3766 | { |
| 3767 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3768 | "%s: SET_MC_RATE failed", __func__); |
| 3769 | vos_mem_free(rateUpdate); |
| 3770 | ret = -EFAULT; |
| 3771 | goto exit; |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 3772 | } |
| 3773 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 3774 | #ifdef FEATURE_WLAN_BATCH_SCAN |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 3775 | else if (strncmp(command, "WLS_BATCHING", 12) == 0) |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 3776 | { |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 3777 | ret = hdd_handle_batch_scan_ioctl(pAdapter, &priv_data, command); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 3778 | } |
| 3779 | #endif |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3780 | #if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD) |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 3781 | else if (strncmp(command, "SETCCXROAMSCANCHANNELS", 22) == 0) |
| 3782 | { |
| 3783 | tANI_U8 *value = command; |
| 3784 | tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0}; |
| 3785 | tANI_U8 numChannels = 0; |
| 3786 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 3787 | |
| 3788 | status = hdd_parse_channellist(value, ChannelList, &numChannels); |
| 3789 | if (eHAL_STATUS_SUCCESS != status) |
| 3790 | { |
| 3791 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3792 | "%s: Failed to parse channel list information", __func__); |
| 3793 | ret = -EINVAL; |
| 3794 | goto exit; |
| 3795 | } |
| 3796 | |
| 3797 | if (numChannels > WNI_CFG_VALID_CHANNEL_LIST_LEN) |
| 3798 | { |
| 3799 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3800 | "%s: number of channels (%d) supported exceeded max (%d)", __func__, |
| 3801 | numChannels, WNI_CFG_VALID_CHANNEL_LIST_LEN); |
| 3802 | ret = -EINVAL; |
| 3803 | goto exit; |
| 3804 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3805 | status = sme_SetEseRoamScanChannelList((tHalHandle)(pHddCtx->hHal), |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 3806 | ChannelList, |
| 3807 | numChannels); |
| 3808 | if (eHAL_STATUS_SUCCESS != status) |
| 3809 | { |
| 3810 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3811 | "%s: Failed to update channel list information", __func__); |
| 3812 | ret = -EINVAL; |
| 3813 | goto exit; |
| 3814 | } |
| 3815 | } |
| 3816 | else if (strncmp(command, "GETTSMSTATS", 11) == 0) |
| 3817 | { |
| 3818 | tANI_U8 *value = command; |
| 3819 | char extra[128] = {0}; |
| 3820 | int len = 0; |
| 3821 | tANI_U8 tid = 0; |
| 3822 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 3823 | tAniTrafStrmMetrics tsmMetrics; |
| 3824 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3825 | |
| 3826 | /* if not associated, return error */ |
| 3827 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 3828 | { |
| 3829 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:Not associated!",__func__); |
| 3830 | ret = -EINVAL; |
| 3831 | goto exit; |
| 3832 | } |
| 3833 | |
| 3834 | /* Move pointer to ahead of GETTSMSTATS<delimiter> */ |
| 3835 | value = value + 12; |
| 3836 | /* Convert the value from ascii to integer */ |
| 3837 | ret = kstrtou8(value, 10, &tid); |
| 3838 | if (ret < 0) |
| 3839 | { |
| 3840 | /* If the input value is greater than max value of datatype, then also |
| 3841 | kstrtou8 fails */ |
| 3842 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3843 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3844 | TID_MIN_VALUE, |
| 3845 | TID_MAX_VALUE); |
| 3846 | ret = -EINVAL; |
| 3847 | goto exit; |
| 3848 | } |
| 3849 | |
| 3850 | if ((tid < TID_MIN_VALUE) || (tid > TID_MAX_VALUE)) |
| 3851 | { |
| 3852 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3853 | "tid value %d is out of range" |
| 3854 | " (Min: %d Max: %d)", tid, |
| 3855 | TID_MIN_VALUE, |
| 3856 | TID_MAX_VALUE); |
| 3857 | ret = -EINVAL; |
| 3858 | goto exit; |
| 3859 | } |
| 3860 | |
| 3861 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3862 | "%s: Received Command to get tsm stats tid = %d", __func__, tid); |
| 3863 | |
| 3864 | if (VOS_STATUS_SUCCESS != hdd_get_tsm_stats(pAdapter, tid, &tsmMetrics)) |
| 3865 | { |
| 3866 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3867 | "%s: failed to get tsm stats", __func__); |
| 3868 | ret = -EFAULT; |
| 3869 | goto exit; |
| 3870 | } |
| 3871 | |
| 3872 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3873 | "UplinkPktQueueDly(%d)\n" |
| 3874 | "UplinkPktQueueDlyHist[0](%d)\n" |
| 3875 | "UplinkPktQueueDlyHist[1](%d)\n" |
| 3876 | "UplinkPktQueueDlyHist[2](%d)\n" |
| 3877 | "UplinkPktQueueDlyHist[3](%d)\n" |
Arun Kumar Khandavalli | e876821 | 2014-02-17 16:43:34 +0530 | [diff] [blame] | 3878 | "UplinkPktTxDly(%u)\n" |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 3879 | "UplinkPktLoss(%d)\n" |
| 3880 | "UplinkPktCount(%d)\n" |
| 3881 | "RoamingCount(%d)\n" |
| 3882 | "RoamingDly(%d)", tsmMetrics.UplinkPktQueueDly, |
| 3883 | tsmMetrics.UplinkPktQueueDlyHist[0], |
| 3884 | tsmMetrics.UplinkPktQueueDlyHist[1], |
| 3885 | tsmMetrics.UplinkPktQueueDlyHist[2], |
| 3886 | tsmMetrics.UplinkPktQueueDlyHist[3], |
| 3887 | tsmMetrics.UplinkPktTxDly, tsmMetrics.UplinkPktLoss, |
| 3888 | tsmMetrics.UplinkPktCount, tsmMetrics.RoamingCount, tsmMetrics.RoamingDly); |
| 3889 | |
| 3890 | /* Output TSM stats is of the format |
| 3891 | GETTSMSTATS [PktQueueDly] [PktQueueDlyHist[0]]:[PktQueueDlyHist[1]] ...[RoamingDly] |
| 3892 | eg., GETTSMSTATS 10 1:0:0:161 20 1 17 8 39800 */ |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 3893 | len = scnprintf(extra, sizeof(extra), "%s %d %d:%d:%d:%d %u %d %d %d %d", command, |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 3894 | tsmMetrics.UplinkPktQueueDly, tsmMetrics.UplinkPktQueueDlyHist[0], |
| 3895 | tsmMetrics.UplinkPktQueueDlyHist[1], tsmMetrics.UplinkPktQueueDlyHist[2], |
| 3896 | tsmMetrics.UplinkPktQueueDlyHist[3], tsmMetrics.UplinkPktTxDly, |
| 3897 | tsmMetrics.UplinkPktLoss, tsmMetrics.UplinkPktCount, tsmMetrics.RoamingCount, |
| 3898 | tsmMetrics.RoamingDly); |
| 3899 | |
| 3900 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 3901 | { |
| 3902 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3903 | "%s: failed to copy data to user buffer", __func__); |
| 3904 | ret = -EFAULT; |
| 3905 | goto exit; |
| 3906 | } |
| 3907 | } |
| 3908 | else if (strncmp(command, "SETCCKMIE", 9) == 0) |
| 3909 | { |
| 3910 | tANI_U8 *value = command; |
| 3911 | tANI_U8 *cckmIe = NULL; |
| 3912 | tANI_U8 cckmIeLen = 0; |
| 3913 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 3914 | |
| 3915 | status = hdd_parse_get_cckm_ie(value, &cckmIe, &cckmIeLen); |
| 3916 | if (eHAL_STATUS_SUCCESS != status) |
| 3917 | { |
| 3918 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3919 | "%s: Failed to parse cckm ie data", __func__); |
| 3920 | ret = -EINVAL; |
| 3921 | goto exit; |
| 3922 | } |
| 3923 | |
| 3924 | if (cckmIeLen > DOT11F_IE_RSN_MAX_LEN) |
| 3925 | { |
| 3926 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3927 | "%s: CCKM Ie input length is more than max[%d]", __func__, |
| 3928 | DOT11F_IE_RSN_MAX_LEN); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 3929 | vos_mem_free(cckmIe); |
| 3930 | cckmIe = NULL; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 3931 | ret = -EINVAL; |
| 3932 | goto exit; |
| 3933 | } |
| 3934 | sme_SetCCKMIe((tHalHandle)(pHddCtx->hHal), pAdapter->sessionId, cckmIe, cckmIeLen); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 3935 | vos_mem_free(cckmIe); |
| 3936 | cckmIe = NULL; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 3937 | } |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 3938 | else if (strncmp(command, "CCXBEACONREQ", 12) == 0) |
| 3939 | { |
| 3940 | tANI_U8 *value = command; |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3941 | tCsrEseBeaconReq eseBcnReq; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 3942 | eHalStatus status = eHAL_STATUS_SUCCESS; |
Srinivas Girigowda | 0c6d7fe | 2014-05-28 18:18:10 -0700 | [diff] [blame] | 3943 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3944 | status = hdd_parse_ese_beacon_req(value, &eseBcnReq); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 3945 | if (eHAL_STATUS_SUCCESS != status) |
| 3946 | { |
| 3947 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3948 | "%s: Failed to parse ese beacon req", __func__); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 3949 | ret = -EINVAL; |
| 3950 | goto exit; |
| 3951 | } |
Srinivas Girigowda | 0c6d7fe | 2014-05-28 18:18:10 -0700 | [diff] [blame] | 3952 | if (!hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) { |
| 3953 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Not associated")); |
| 3954 | hdd_indicateEseBcnReportNoResults (pAdapter, |
| 3955 | eseBcnReq.bcnReq[0].measurementToken, |
| 3956 | 0x02, //BIT(1) set for measurement done |
| 3957 | 0); // no BSS |
| 3958 | goto exit; |
| 3959 | } |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 3960 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3961 | status = sme_SetEseBeaconRequest((tHalHandle)(pHddCtx->hHal), pAdapter->sessionId, &eseBcnReq); |
| 3962 | if (eHAL_STATUS_SUCCESS != status) |
| 3963 | { |
| 3964 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3965 | "%s: sme_SetEseBeaconRequest failed (%d)", __func__, status); |
| 3966 | ret = -EINVAL; |
| 3967 | goto exit; |
| 3968 | } |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 3969 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3970 | #endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */ |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 3971 | else if (strncmp(command, "GETBCNMISSRATE", 14) == 0) |
| 3972 | { |
| 3973 | eHalStatus status; |
| 3974 | char buf[32], len; |
| 3975 | long waitRet; |
| 3976 | bcnMissRateContext_t getBcnMissRateCtx; |
| 3977 | |
| 3978 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3979 | |
| 3980 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 3981 | { |
| 3982 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 3983 | FL("GETBCNMISSRATE: STA is not in connected state")); |
| 3984 | ret = -1; |
| 3985 | goto exit; |
| 3986 | } |
| 3987 | |
| 3988 | init_completion(&(getBcnMissRateCtx.completion)); |
| 3989 | getBcnMissRateCtx.magic = BCN_MISS_RATE_CONTEXT_MAGIC; |
| 3990 | |
| 3991 | status = sme_getBcnMissRate((tHalHandle)(pHddCtx->hHal), |
| 3992 | pAdapter->sessionId, |
| 3993 | (void *)getBcnMissRateCB, |
| 3994 | (void *)(&getBcnMissRateCtx)); |
| 3995 | if( eHAL_STATUS_SUCCESS != status) |
| 3996 | { |
| 3997 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 3998 | FL("GETBCNMISSRATE: fail to post WDA cmd")); |
| 3999 | ret = -EINVAL; |
| 4000 | goto exit; |
| 4001 | } |
| 4002 | |
| 4003 | waitRet = wait_for_completion_interruptible_timeout |
| 4004 | (&getBcnMissRateCtx.completion, BCN_MISS_RATE_TIME); |
| 4005 | if(waitRet <= 0) |
| 4006 | { |
| 4007 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4008 | FL("failed to wait on bcnMissRateComp %d"), ret); |
| 4009 | |
| 4010 | //Make magic number to zero so that callback is not called. |
| 4011 | spin_lock(&hdd_context_lock); |
| 4012 | getBcnMissRateCtx.magic = 0x0; |
| 4013 | spin_unlock(&hdd_context_lock); |
| 4014 | ret = -EINVAL; |
| 4015 | goto exit; |
| 4016 | } |
| 4017 | |
| 4018 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4019 | FL("GETBCNMISSRATE: bcnMissRate: %d"), gbcnMissRate); |
| 4020 | |
| 4021 | len = snprintf(buf, sizeof(buf), "GETBCNMISSRATE %d", gbcnMissRate); |
| 4022 | if (copy_to_user(priv_data.buf, &buf, len + 1)) |
| 4023 | { |
| 4024 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4025 | "%s: failed to copy data to user buffer", __func__); |
| 4026 | ret = -EFAULT; |
| 4027 | goto exit; |
| 4028 | } |
| 4029 | ret = len; |
| 4030 | } |
Madan Mohan Koyyalamudi | f9bdd4e | 2012-10-30 18:05:03 -0700 | [diff] [blame] | 4031 | else { |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 4032 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 4033 | TRACE_CODE_HDD_UNSUPPORTED_IOCTL, |
| 4034 | pAdapter->sessionId, 0)); |
Madan Mohan Koyyalamudi | f9bdd4e | 2012-10-30 18:05:03 -0700 | [diff] [blame] | 4035 | hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s", |
| 4036 | __func__, command); |
| 4037 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4038 | } |
| 4039 | exit: |
| 4040 | if (command) |
| 4041 | { |
| 4042 | kfree(command); |
| 4043 | } |
| 4044 | return ret; |
| 4045 | } |
| 4046 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 4047 | #ifdef CONFIG_COMPAT |
| 4048 | static int hdd_driver_compat_ioctl(hdd_adapter_t *pAdapter, struct ifreq *ifr) |
| 4049 | { |
| 4050 | struct { |
| 4051 | compat_uptr_t buf; |
| 4052 | int used_len; |
| 4053 | int total_len; |
| 4054 | } compat_priv_data; |
| 4055 | hdd_priv_data_t priv_data; |
| 4056 | int ret = 0; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4057 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 4058 | /* |
| 4059 | * Note that pAdapter and ifr have already been verified by caller, |
| 4060 | * and HDD context has also been validated |
| 4061 | */ |
| 4062 | if (copy_from_user(&compat_priv_data, ifr->ifr_data, |
| 4063 | sizeof(compat_priv_data))) { |
| 4064 | ret = -EFAULT; |
| 4065 | goto exit; |
| 4066 | } |
| 4067 | priv_data.buf = compat_ptr(compat_priv_data.buf); |
| 4068 | priv_data.used_len = compat_priv_data.used_len; |
| 4069 | priv_data.total_len = compat_priv_data.total_len; |
| 4070 | ret = hdd_driver_command(pAdapter, &priv_data); |
| 4071 | exit: |
| 4072 | return ret; |
| 4073 | } |
| 4074 | #else /* CONFIG_COMPAT */ |
| 4075 | static int hdd_driver_compat_ioctl(hdd_adapter_t *pAdapter, struct ifreq *ifr) |
| 4076 | { |
| 4077 | /* will never be invoked */ |
| 4078 | return 0; |
| 4079 | } |
| 4080 | #endif /* CONFIG_COMPAT */ |
| 4081 | |
| 4082 | static int hdd_driver_ioctl(hdd_adapter_t *pAdapter, struct ifreq *ifr) |
| 4083 | { |
| 4084 | hdd_priv_data_t priv_data; |
| 4085 | int ret = 0; |
| 4086 | |
| 4087 | /* |
| 4088 | * Note that pAdapter and ifr have already been verified by caller, |
| 4089 | * and HDD context has also been validated |
| 4090 | */ |
| 4091 | if (copy_from_user(&priv_data, ifr->ifr_data, sizeof(priv_data))) { |
| 4092 | ret = -EFAULT; |
| 4093 | } else { |
| 4094 | ret = hdd_driver_command(pAdapter, &priv_data); |
| 4095 | } |
| 4096 | return ret; |
| 4097 | } |
| 4098 | |
| 4099 | int hdd_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) |
| 4100 | { |
| 4101 | hdd_adapter_t *pAdapter; |
| 4102 | hdd_context_t *pHddCtx; |
| 4103 | int ret; |
| 4104 | |
| 4105 | pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 4106 | if (NULL == pAdapter) { |
| 4107 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 4108 | "%s: HDD adapter context is Null", __func__); |
| 4109 | ret = -ENODEV; |
| 4110 | goto exit; |
| 4111 | } |
| 4112 | if (dev != pAdapter->dev) { |
| 4113 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 4114 | "%s: HDD adapter/dev inconsistency", __func__); |
| 4115 | ret = -ENODEV; |
| 4116 | goto exit; |
| 4117 | } |
| 4118 | |
| 4119 | if ((!ifr) || (!ifr->ifr_data)) { |
| 4120 | ret = -EINVAL; |
| 4121 | goto exit; |
| 4122 | } |
| 4123 | |
| 4124 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 4125 | ret = wlan_hdd_validate_context(pHddCtx); |
| 4126 | if (ret) { |
| 4127 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4128 | "%s: invalid context", __func__); |
| 4129 | ret = -EBUSY; |
| 4130 | goto exit; |
| 4131 | } |
| 4132 | |
| 4133 | switch (cmd) { |
| 4134 | case (SIOCDEVPRIVATE + 1): |
| 4135 | if (is_compat_task()) |
| 4136 | ret = hdd_driver_compat_ioctl(pAdapter, ifr); |
| 4137 | else |
| 4138 | ret = hdd_driver_ioctl(pAdapter, ifr); |
| 4139 | break; |
| 4140 | default: |
| 4141 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unknown ioctl %d", |
| 4142 | __func__, cmd); |
| 4143 | ret = -EINVAL; |
| 4144 | break; |
| 4145 | } |
| 4146 | exit: |
| 4147 | return ret; |
| 4148 | } |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4149 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4150 | #if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4151 | /**--------------------------------------------------------------------------- |
| 4152 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4153 | \brief hdd_parse_ese_beacon_req() - Parse ese beacon request |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4154 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4155 | This function parses the ese beacon request passed in the format |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4156 | CCXBEACONREQ<space><Number of fields><space><Measurement token> |
| 4157 | <space>Channel 1<space>Scan Mode <space>Meas Duration<space>Channel N |
| 4158 | <space>Scan Mode N<space>Meas Duration N |
| 4159 | if the Number of bcn req fields (N) does not match with the actual number of fields passed |
| 4160 | then take N. |
| 4161 | <Meas Token><Channel><Scan Mode> and <Meas Duration> are treated as one pair |
| 4162 | For example, CCXBEACONREQ 2 1 1 1 30 2 44 0 40. |
| 4163 | This function does not take care of removing duplicate channels from the list |
| 4164 | |
| 4165 | \param - pValue Pointer to data |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4166 | \param - pEseBcnReq output pointer to store parsed ie information |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4167 | |
| 4168 | \return - 0 for success non-zero for failure |
| 4169 | |
| 4170 | --------------------------------------------------------------------------*/ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4171 | static VOS_STATUS hdd_parse_ese_beacon_req(tANI_U8 *pValue, |
| 4172 | tCsrEseBeaconReq *pEseBcnReq) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4173 | { |
| 4174 | tANI_U8 *inPtr = pValue; |
| 4175 | int tempInt = 0; |
| 4176 | int j = 0, i = 0, v = 0; |
| 4177 | char buf[32]; |
| 4178 | |
| 4179 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 4180 | /*no argument after the command*/ |
| 4181 | if (NULL == inPtr) |
| 4182 | { |
| 4183 | return -EINVAL; |
| 4184 | } |
| 4185 | /*no space after the command*/ |
| 4186 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 4187 | { |
| 4188 | return -EINVAL; |
| 4189 | } |
| 4190 | |
| 4191 | /*removing empty spaces*/ |
| 4192 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
| 4193 | |
| 4194 | /*no argument followed by spaces*/ |
| 4195 | if ('\0' == *inPtr) return -EINVAL; |
| 4196 | |
| 4197 | /*getting the first argument ie measurement token*/ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 4198 | v = sscanf(inPtr, "%31s ", buf); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4199 | if (1 != v) return -EINVAL; |
| 4200 | |
| 4201 | v = kstrtos32(buf, 10, &tempInt); |
| 4202 | if ( v < 0) return -EINVAL; |
| 4203 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4204 | pEseBcnReq->numBcnReqIe = tempInt; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4205 | |
| 4206 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4207 | "Number of Bcn Req Ie fields(%d)", pEseBcnReq->numBcnReqIe); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4208 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4209 | for (j = 0; j < (pEseBcnReq->numBcnReqIe); j++) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4210 | { |
| 4211 | for (i = 0; i < 4; i++) |
| 4212 | { |
| 4213 | /*inPtr pointing to the beginning of first space after number of ie fields*/ |
| 4214 | inPtr = strpbrk( inPtr, " " ); |
| 4215 | /*no ie data after the number of ie fields argument*/ |
| 4216 | if (NULL == inPtr) return -EINVAL; |
| 4217 | |
| 4218 | /*removing empty space*/ |
| 4219 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
| 4220 | |
| 4221 | /*no ie data after the number of ie fields argument and spaces*/ |
| 4222 | if ( '\0' == *inPtr ) return -EINVAL; |
| 4223 | |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 4224 | v = sscanf(inPtr, "%31s ", buf); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4225 | if (1 != v) return -EINVAL; |
| 4226 | |
| 4227 | v = kstrtos32(buf, 10, &tempInt); |
| 4228 | if (v < 0) return -EINVAL; |
| 4229 | |
| 4230 | switch (i) |
| 4231 | { |
| 4232 | case 0: /* Measurement token */ |
| 4233 | if (tempInt <= 0) |
| 4234 | { |
| 4235 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4236 | "Invalid Measurement Token(%d)", tempInt); |
| 4237 | return -EINVAL; |
| 4238 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4239 | pEseBcnReq->bcnReq[j].measurementToken = tempInt; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4240 | break; |
| 4241 | |
| 4242 | case 1: /* Channel number */ |
| 4243 | if ((tempInt <= 0) || |
| 4244 | (tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX)) |
| 4245 | { |
| 4246 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4247 | "Invalid Channel Number(%d)", tempInt); |
| 4248 | return -EINVAL; |
| 4249 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4250 | pEseBcnReq->bcnReq[j].channel = tempInt; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4251 | break; |
| 4252 | |
| 4253 | case 2: /* Scan mode */ |
Varun Reddy Yeturu | 0b18d5a | 2013-12-04 11:42:23 -0800 | [diff] [blame] | 4254 | if ((tempInt < eSIR_PASSIVE_SCAN) || (tempInt > eSIR_BEACON_TABLE)) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4255 | { |
| 4256 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4257 | "Invalid Scan Mode(%d) Expected{0|1|2}", tempInt); |
| 4258 | return -EINVAL; |
| 4259 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4260 | pEseBcnReq->bcnReq[j].scanMode= tempInt; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4261 | break; |
| 4262 | |
| 4263 | case 3: /* Measurement duration */ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4264 | if (((tempInt <= 0) && (pEseBcnReq->bcnReq[j].scanMode != eSIR_BEACON_TABLE)) || |
| 4265 | ((tempInt < 0) && (pEseBcnReq->bcnReq[j].scanMode == eSIR_BEACON_TABLE))) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4266 | { |
| 4267 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4268 | "Invalid Measurement Duration(%d)", tempInt); |
| 4269 | return -EINVAL; |
| 4270 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4271 | pEseBcnReq->bcnReq[j].measurementDuration = tempInt; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4272 | break; |
| 4273 | } |
| 4274 | } |
| 4275 | } |
| 4276 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4277 | for (j = 0; j < pEseBcnReq->numBcnReqIe; j++) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4278 | { |
| 4279 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Arun Kumar Khandavalli | e876821 | 2014-02-17 16:43:34 +0530 | [diff] [blame] | 4280 | "Index(%d) Measurement Token(%u)Channel(%u) Scan Mode(%u) Measurement Duration(%u)\n", |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4281 | j, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4282 | pEseBcnReq->bcnReq[j].measurementToken, |
| 4283 | pEseBcnReq->bcnReq[j].channel, |
| 4284 | pEseBcnReq->bcnReq[j].scanMode, |
| 4285 | pEseBcnReq->bcnReq[j].measurementDuration); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4286 | } |
| 4287 | |
| 4288 | return VOS_STATUS_SUCCESS; |
| 4289 | } |
| 4290 | |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4291 | static void hdd_GetTsmStatsCB( tAniTrafStrmMetrics tsmMetrics, const tANI_U32 staId, void *pContext ) |
| 4292 | { |
| 4293 | struct statsContext *pStatsContext = NULL; |
| 4294 | hdd_adapter_t *pAdapter = NULL; |
| 4295 | |
| 4296 | if (NULL == pContext) |
| 4297 | { |
| 4298 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4299 | "%s: Bad param, pContext [%p]", |
| 4300 | __func__, pContext); |
| 4301 | return; |
| 4302 | } |
| 4303 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 4304 | /* there is a race condition that exists between this callback |
| 4305 | function and the caller since the caller could time out either |
| 4306 | before or while this code is executing. we use a spinlock to |
| 4307 | serialize these actions */ |
| 4308 | spin_lock(&hdd_context_lock); |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4309 | |
| 4310 | pStatsContext = pContext; |
| 4311 | pAdapter = pStatsContext->pAdapter; |
| 4312 | if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic)) |
| 4313 | { |
| 4314 | /* the caller presumably timed out so there is nothing we can do */ |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 4315 | spin_unlock(&hdd_context_lock); |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4316 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 4317 | "%s: Invalid context, pAdapter [%p] magic [%08x]", |
| 4318 | __func__, pAdapter, pStatsContext->magic); |
| 4319 | return; |
| 4320 | } |
| 4321 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 4322 | /* context is valid so caller is still waiting */ |
| 4323 | |
| 4324 | /* paranoia: invalidate the magic */ |
| 4325 | pStatsContext->magic = 0; |
| 4326 | |
| 4327 | /* copy over the tsm stats */ |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4328 | pAdapter->tsmStats.UplinkPktQueueDly = tsmMetrics.UplinkPktQueueDly; |
| 4329 | vos_mem_copy(pAdapter->tsmStats.UplinkPktQueueDlyHist, |
| 4330 | tsmMetrics.UplinkPktQueueDlyHist, |
| 4331 | sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist)/ |
| 4332 | sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist[0])); |
| 4333 | pAdapter->tsmStats.UplinkPktTxDly = tsmMetrics.UplinkPktTxDly; |
| 4334 | pAdapter->tsmStats.UplinkPktLoss = tsmMetrics.UplinkPktLoss; |
| 4335 | pAdapter->tsmStats.UplinkPktCount = tsmMetrics.UplinkPktCount; |
| 4336 | pAdapter->tsmStats.RoamingCount = tsmMetrics.RoamingCount; |
| 4337 | pAdapter->tsmStats.RoamingDly = tsmMetrics.RoamingDly; |
| 4338 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 4339 | /* notify the caller */ |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4340 | complete(&pStatsContext->completion); |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 4341 | |
| 4342 | /* serialization is complete */ |
| 4343 | spin_unlock(&hdd_context_lock); |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4344 | } |
| 4345 | |
| 4346 | |
| 4347 | |
| 4348 | static VOS_STATUS hdd_get_tsm_stats(hdd_adapter_t *pAdapter, const tANI_U8 tid, |
| 4349 | tAniTrafStrmMetrics* pTsmMetrics) |
| 4350 | { |
| 4351 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 4352 | eHalStatus hstatus; |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 4353 | VOS_STATUS vstatus = VOS_STATUS_SUCCESS; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4354 | long lrc; |
| 4355 | struct statsContext context; |
| 4356 | hdd_context_t *pHddCtx = NULL; |
| 4357 | |
| 4358 | if (NULL == pAdapter) |
| 4359 | { |
| 4360 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: pAdapter is NULL", __func__); |
| 4361 | return VOS_STATUS_E_FAULT; |
| 4362 | } |
| 4363 | |
| 4364 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 4365 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 4366 | |
| 4367 | /* we are connected prepare our callback context */ |
| 4368 | init_completion(&context.completion); |
| 4369 | context.pAdapter = pAdapter; |
| 4370 | context.magic = STATS_CONTEXT_MAGIC; |
| 4371 | |
| 4372 | /* query tsm stats */ |
| 4373 | hstatus = sme_GetTsmStats(pHddCtx->hHal, hdd_GetTsmStatsCB, |
| 4374 | pHddStaCtx->conn_info.staId[ 0 ], |
| 4375 | pHddStaCtx->conn_info.bssId, |
| 4376 | &context, pHddCtx->pvosContext, tid); |
| 4377 | |
| 4378 | if (eHAL_STATUS_SUCCESS != hstatus) |
| 4379 | { |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 4380 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unable to retrieve statistics", |
| 4381 | __func__); |
| 4382 | vstatus = VOS_STATUS_E_FAULT; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4383 | } |
| 4384 | else |
| 4385 | { |
| 4386 | /* request was sent -- wait for the response */ |
| 4387 | lrc = wait_for_completion_interruptible_timeout(&context.completion, |
| 4388 | msecs_to_jiffies(WLAN_WAIT_TIME_STATS)); |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4389 | if (lrc <= 0) |
| 4390 | { |
| 4391 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4392 | "%s: SME %s while retrieving statistics", |
| 4393 | __func__, (0 == lrc) ? "timeout" : "interrupt"); |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 4394 | vstatus = VOS_STATUS_E_TIMEOUT; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4395 | } |
| 4396 | } |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4397 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 4398 | /* either we never sent a request, we sent a request and received a |
| 4399 | response or we sent a request and timed out. if we never sent a |
| 4400 | request or if we sent a request and got a response, we want to |
| 4401 | clear the magic out of paranoia. if we timed out there is a |
| 4402 | race condition such that the callback function could be |
| 4403 | executing at the same time we are. of primary concern is if the |
| 4404 | callback function had already verified the "magic" but had not |
| 4405 | yet set the completion variable when a timeout occurred. we |
| 4406 | serialize these activities by invalidating the magic while |
| 4407 | holding a shared spinlock which will cause us to block if the |
| 4408 | callback is currently executing */ |
| 4409 | spin_lock(&hdd_context_lock); |
| 4410 | context.magic = 0; |
| 4411 | spin_unlock(&hdd_context_lock); |
| 4412 | |
| 4413 | if (VOS_STATUS_SUCCESS == vstatus) |
| 4414 | { |
| 4415 | pTsmMetrics->UplinkPktQueueDly = pAdapter->tsmStats.UplinkPktQueueDly; |
| 4416 | vos_mem_copy(pTsmMetrics->UplinkPktQueueDlyHist, |
| 4417 | pAdapter->tsmStats.UplinkPktQueueDlyHist, |
| 4418 | sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist)/ |
| 4419 | sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist[0])); |
| 4420 | pTsmMetrics->UplinkPktTxDly = pAdapter->tsmStats.UplinkPktTxDly; |
| 4421 | pTsmMetrics->UplinkPktLoss = pAdapter->tsmStats.UplinkPktLoss; |
| 4422 | pTsmMetrics->UplinkPktCount = pAdapter->tsmStats.UplinkPktCount; |
| 4423 | pTsmMetrics->RoamingCount = pAdapter->tsmStats.RoamingCount; |
| 4424 | pTsmMetrics->RoamingDly = pAdapter->tsmStats.RoamingDly; |
| 4425 | } |
| 4426 | return vstatus; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4427 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4428 | #endif /*FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */ |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4429 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4430 | #if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR) |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4431 | void hdd_getBand_helper(hdd_context_t *pHddCtx, int *pBand) |
| 4432 | { |
| 4433 | eCsrBand band = -1; |
| 4434 | sme_GetFreqBand((tHalHandle)(pHddCtx->hHal), &band); |
| 4435 | switch (band) |
| 4436 | { |
| 4437 | case eCSR_BAND_ALL: |
| 4438 | *pBand = WLAN_HDD_UI_BAND_AUTO; |
| 4439 | break; |
| 4440 | |
| 4441 | case eCSR_BAND_24: |
| 4442 | *pBand = WLAN_HDD_UI_BAND_2_4_GHZ; |
| 4443 | break; |
| 4444 | |
| 4445 | case eCSR_BAND_5G: |
| 4446 | *pBand = WLAN_HDD_UI_BAND_5_GHZ; |
| 4447 | break; |
| 4448 | |
| 4449 | default: |
| 4450 | hddLog( VOS_TRACE_LEVEL_WARN, "%s: Invalid Band %d", __func__, band); |
| 4451 | *pBand = -1; |
| 4452 | break; |
| 4453 | } |
| 4454 | } |
| 4455 | |
| 4456 | /**--------------------------------------------------------------------------- |
| 4457 | |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4458 | \brief hdd_parse_send_action_frame_data() - HDD Parse send action frame data |
| 4459 | |
| 4460 | This function parses the send action frame data passed in the format |
| 4461 | SENDACTIONFRAME<space><bssid><space><channel><space><dwelltime><space><data> |
| 4462 | |
Srinivas Girigowda | 5607685 | 2013-08-20 14:00:50 -0700 | [diff] [blame] | 4463 | \param - pValue Pointer to input data |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4464 | \param - pTargetApBssid Pointer to target Ap bssid |
| 4465 | \param - pChannel Pointer to the Target AP channel |
| 4466 | \param - pDwellTime Pointer to the time to stay off-channel after transmitting action frame |
| 4467 | \param - pBuf Pointer to data |
| 4468 | \param - pBufLen Pointer to data length |
| 4469 | |
| 4470 | \return - 0 for success non-zero for failure |
| 4471 | |
| 4472 | --------------------------------------------------------------------------*/ |
| 4473 | VOS_STATUS hdd_parse_send_action_frame_data(tANI_U8 *pValue, tANI_U8 *pTargetApBssid, tANI_U8 *pChannel, |
| 4474 | tANI_U8 *pDwellTime, tANI_U8 **pBuf, tANI_U8 *pBufLen) |
| 4475 | { |
| 4476 | tANI_U8 *inPtr = pValue; |
| 4477 | tANI_U8 *dataEnd; |
| 4478 | int tempInt; |
| 4479 | int j = 0; |
| 4480 | int i = 0; |
| 4481 | int v = 0; |
| 4482 | tANI_U8 tempBuf[32]; |
| 4483 | tANI_U8 tempByte = 0; |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 4484 | /* 12 hexa decimal digits, 5 ':' and '\0' */ |
| 4485 | tANI_U8 macAddress[18]; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4486 | |
| 4487 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 4488 | /*no argument after the command*/ |
| 4489 | if (NULL == inPtr) |
| 4490 | { |
| 4491 | return -EINVAL; |
| 4492 | } |
| 4493 | |
| 4494 | /*no space after the command*/ |
| 4495 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 4496 | { |
| 4497 | return -EINVAL; |
| 4498 | } |
| 4499 | |
| 4500 | /*removing empty spaces*/ |
| 4501 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 4502 | |
| 4503 | /*no argument followed by spaces*/ |
| 4504 | if ('\0' == *inPtr) |
| 4505 | { |
| 4506 | return -EINVAL; |
| 4507 | } |
| 4508 | |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4509 | v = sscanf(inPtr, "%17s", macAddress); |
| 4510 | if (!((1 == v) && hdd_is_valid_mac_address(macAddress))) |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4511 | { |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4512 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4513 | "Invalid MAC address or All hex inputs are not read (%d)", v); |
| 4514 | return -EINVAL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4515 | } |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4516 | |
| 4517 | pTargetApBssid[0] = hdd_parse_hex(macAddress[0]) << 4 | hdd_parse_hex(macAddress[1]); |
| 4518 | pTargetApBssid[1] = hdd_parse_hex(macAddress[3]) << 4 | hdd_parse_hex(macAddress[4]); |
| 4519 | pTargetApBssid[2] = hdd_parse_hex(macAddress[6]) << 4 | hdd_parse_hex(macAddress[7]); |
| 4520 | pTargetApBssid[3] = hdd_parse_hex(macAddress[9]) << 4 | hdd_parse_hex(macAddress[10]); |
| 4521 | pTargetApBssid[4] = hdd_parse_hex(macAddress[12]) << 4 | hdd_parse_hex(macAddress[13]); |
| 4522 | pTargetApBssid[5] = hdd_parse_hex(macAddress[15]) << 4 | hdd_parse_hex(macAddress[16]); |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4523 | |
| 4524 | /* point to the next argument */ |
| 4525 | inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE); |
| 4526 | /*no argument after the command*/ |
| 4527 | if (NULL == inPtr) return -EINVAL; |
| 4528 | |
| 4529 | /*removing empty spaces*/ |
| 4530 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 4531 | |
| 4532 | /*no argument followed by spaces*/ |
| 4533 | if ('\0' == *inPtr) |
| 4534 | { |
| 4535 | return -EINVAL; |
| 4536 | } |
| 4537 | |
| 4538 | /*getting the next argument ie the channel number */ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 4539 | v = sscanf(inPtr, "%31s ", tempBuf); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4540 | if (1 != v) return -EINVAL; |
| 4541 | |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4542 | v = kstrtos32(tempBuf, 10, &tempInt); |
Agarwal Ashish | 353b3a8 | 2014-04-08 14:55:11 +0530 | [diff] [blame] | 4543 | if ( v < 0 || tempInt <= 0 || tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX ) |
Kiet Lam | be150c2 | 2013-11-21 16:30:32 +0530 | [diff] [blame] | 4544 | return -EINVAL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4545 | |
| 4546 | *pChannel = tempInt; |
| 4547 | |
| 4548 | /* point to the next argument */ |
| 4549 | inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE); |
| 4550 | /*no argument after the command*/ |
| 4551 | if (NULL == inPtr) return -EINVAL; |
| 4552 | /*removing empty spaces*/ |
| 4553 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 4554 | |
| 4555 | /*no argument followed by spaces*/ |
| 4556 | if ('\0' == *inPtr) |
| 4557 | { |
| 4558 | return -EINVAL; |
| 4559 | } |
| 4560 | |
| 4561 | /*getting the next argument ie the dwell time */ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 4562 | v = sscanf(inPtr, "%31s ", tempBuf); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4563 | if (1 != v) return -EINVAL; |
| 4564 | |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4565 | v = kstrtos32(tempBuf, 10, &tempInt); |
Srinivas Girigowda | 5a6e067 | 2014-01-09 14:42:57 -0800 | [diff] [blame] | 4566 | if ( v < 0 || tempInt < 0) return -EINVAL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4567 | |
| 4568 | *pDwellTime = tempInt; |
| 4569 | |
| 4570 | /* point to the next argument */ |
| 4571 | inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE); |
| 4572 | /*no argument after the command*/ |
| 4573 | if (NULL == inPtr) return -EINVAL; |
| 4574 | /*removing empty spaces*/ |
| 4575 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 4576 | |
| 4577 | /*no argument followed by spaces*/ |
| 4578 | if ('\0' == *inPtr) |
| 4579 | { |
| 4580 | return -EINVAL; |
| 4581 | } |
| 4582 | |
| 4583 | /* find the length of data */ |
| 4584 | dataEnd = inPtr; |
| 4585 | while(('\0' != *dataEnd) ) |
| 4586 | { |
| 4587 | dataEnd++; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4588 | } |
Kiet Lam | be150c2 | 2013-11-21 16:30:32 +0530 | [diff] [blame] | 4589 | *pBufLen = dataEnd - inPtr ; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4590 | if ( *pBufLen <= 0) return -EINVAL; |
| 4591 | |
Srinivas Girigowda | b5ae85d | 2013-06-03 10:51:45 -0700 | [diff] [blame] | 4592 | /* Allocate the number of bytes based on the number of input characters |
| 4593 | whether it is even or odd. |
| 4594 | if the number of input characters are even, then we need N/2 byte. |
| 4595 | if the number of input characters are odd, then we need do (N+1)/2 to |
| 4596 | compensate rounding off. |
| 4597 | For example, if N = 18, then (18 + 1)/2 = 9 bytes are enough. |
| 4598 | If N = 19, then we need 10 bytes, hence (19 + 1)/2 = 10 bytes */ |
| 4599 | *pBuf = vos_mem_malloc((*pBufLen + 1)/2); |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4600 | if (NULL == *pBuf) |
| 4601 | { |
| 4602 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 4603 | "%s: vos_mem_alloc failed ", __func__); |
| 4604 | return -EINVAL; |
| 4605 | } |
| 4606 | |
| 4607 | /* the buffer received from the upper layer is character buffer, |
| 4608 | we need to prepare the buffer taking 2 characters in to a U8 hex decimal number |
| 4609 | for example 7f0000f0...form a buffer to contain 7f in 0th location, 00 in 1st |
| 4610 | and f0 in 3rd location */ |
| 4611 | for (i = 0, j = 0; j < *pBufLen; j += 2) |
| 4612 | { |
Kiet Lam | be150c2 | 2013-11-21 16:30:32 +0530 | [diff] [blame] | 4613 | if( j+1 == *pBufLen) |
| 4614 | { |
| 4615 | tempByte = hdd_parse_hex(inPtr[j]); |
| 4616 | } |
| 4617 | else |
| 4618 | { |
| 4619 | tempByte = (hdd_parse_hex(inPtr[j]) << 4) | (hdd_parse_hex(inPtr[j + 1])); |
| 4620 | } |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4621 | (*pBuf)[i++] = tempByte; |
| 4622 | } |
| 4623 | *pBufLen = i; |
| 4624 | return VOS_STATUS_SUCCESS; |
| 4625 | } |
| 4626 | |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4627 | /**--------------------------------------------------------------------------- |
| 4628 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4629 | \brief hdd_parse_channellist() - HDD Parse channel list |
| 4630 | |
| 4631 | This function parses the channel list passed in the format |
| 4632 | SETROAMSCANCHANNELS<space><Number of channels><space>Channel 1<space>Channel 2<space>Channel N |
Srinivas Girigowda | cf9a9b4 | 2013-03-21 11:55:24 -0700 | [diff] [blame] | 4633 | if the Number of channels (N) does not match with the actual number of channels passed |
| 4634 | then take the minimum of N and count of (Ch1, Ch2, ...Ch M) |
| 4635 | For example, if SETROAMSCANCHANNELS 3 36 40 44 48, only 36, 40 and 44 shall be taken. |
| 4636 | If SETROAMSCANCHANNELS 5 36 40 44 48, ignore 5 and take 36, 40, 44 and 48. |
| 4637 | This function does not take care of removing duplicate channels from the list |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4638 | |
| 4639 | \param - pValue Pointer to input channel list |
| 4640 | \param - ChannelList Pointer to local output array to record channel list |
| 4641 | \param - pNumChannels Pointer to number of roam scan channels |
| 4642 | |
| 4643 | \return - 0 for success non-zero for failure |
| 4644 | |
| 4645 | --------------------------------------------------------------------------*/ |
| 4646 | VOS_STATUS hdd_parse_channellist(tANI_U8 *pValue, tANI_U8 *pChannelList, tANI_U8 *pNumChannels) |
| 4647 | { |
| 4648 | tANI_U8 *inPtr = pValue; |
| 4649 | int tempInt; |
| 4650 | int j = 0; |
| 4651 | int v = 0; |
| 4652 | char buf[32]; |
| 4653 | |
| 4654 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 4655 | /*no argument after the command*/ |
| 4656 | if (NULL == inPtr) |
| 4657 | { |
| 4658 | return -EINVAL; |
| 4659 | } |
| 4660 | |
| 4661 | /*no space after the command*/ |
| 4662 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 4663 | { |
| 4664 | return -EINVAL; |
| 4665 | } |
| 4666 | |
| 4667 | /*removing empty spaces*/ |
Jeff Johnson | a1f9afb | 2013-04-03 09:13:31 -0700 | [diff] [blame] | 4668 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4669 | |
| 4670 | /*no argument followed by spaces*/ |
| 4671 | if ('\0' == *inPtr) |
| 4672 | { |
| 4673 | return -EINVAL; |
| 4674 | } |
| 4675 | |
| 4676 | /*getting the first argument ie the number of channels*/ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 4677 | v = sscanf(inPtr, "%31s ", buf); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4678 | if (1 != v) return -EINVAL; |
| 4679 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4680 | v = kstrtos32(buf, 10, &tempInt); |
Jeff Johnson | a1f9afb | 2013-04-03 09:13:31 -0700 | [diff] [blame] | 4681 | if ((v < 0) || |
| 4682 | (tempInt <= 0) || |
| 4683 | (tempInt > WNI_CFG_VALID_CHANNEL_LIST_LEN)) |
| 4684 | { |
| 4685 | return -EINVAL; |
| 4686 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4687 | |
| 4688 | *pNumChannels = tempInt; |
| 4689 | |
| 4690 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
| 4691 | "Number of channels are: %d", *pNumChannels); |
| 4692 | |
| 4693 | for (j = 0; j < (*pNumChannels); j++) |
| 4694 | { |
| 4695 | /*inPtr pointing to the beginning of first space after number of channels*/ |
| 4696 | inPtr = strpbrk( inPtr, " " ); |
| 4697 | /*no channel list after the number of channels argument*/ |
| 4698 | if (NULL == inPtr) |
| 4699 | { |
Srinivas Girigowda | cf9a9b4 | 2013-03-21 11:55:24 -0700 | [diff] [blame] | 4700 | if (0 != j) |
| 4701 | { |
| 4702 | *pNumChannels = j; |
| 4703 | return VOS_STATUS_SUCCESS; |
| 4704 | } |
| 4705 | else |
| 4706 | { |
| 4707 | return -EINVAL; |
| 4708 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4709 | } |
| 4710 | |
| 4711 | /*removing empty space*/ |
Jeff Johnson | a1f9afb | 2013-04-03 09:13:31 -0700 | [diff] [blame] | 4712 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4713 | |
| 4714 | /*no channel list after the number of channels argument and spaces*/ |
| 4715 | if ( '\0' == *inPtr ) |
| 4716 | { |
Srinivas Girigowda | cf9a9b4 | 2013-03-21 11:55:24 -0700 | [diff] [blame] | 4717 | if (0 != j) |
| 4718 | { |
| 4719 | *pNumChannels = j; |
| 4720 | return VOS_STATUS_SUCCESS; |
| 4721 | } |
| 4722 | else |
| 4723 | { |
| 4724 | return -EINVAL; |
| 4725 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4726 | } |
| 4727 | |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 4728 | v = sscanf(inPtr, "%31s ", buf); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4729 | if (1 != v) return -EINVAL; |
| 4730 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4731 | v = kstrtos32(buf, 10, &tempInt); |
Jeff Johnson | a1f9afb | 2013-04-03 09:13:31 -0700 | [diff] [blame] | 4732 | if ((v < 0) || |
| 4733 | (tempInt <= 0) || |
| 4734 | (tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX)) |
| 4735 | { |
| 4736 | return -EINVAL; |
| 4737 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4738 | pChannelList[j] = tempInt; |
| 4739 | |
| 4740 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
| 4741 | "Channel %d added to preferred channel list", |
| 4742 | pChannelList[j] ); |
| 4743 | } |
| 4744 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4745 | return VOS_STATUS_SUCCESS; |
| 4746 | } |
| 4747 | |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 4748 | |
| 4749 | /**--------------------------------------------------------------------------- |
| 4750 | |
| 4751 | \brief hdd_parse_reassoc_command_data() - HDD Parse reassoc command data |
| 4752 | |
| 4753 | This function parses the reasoc command data passed in the format |
| 4754 | REASSOC<space><bssid><space><channel> |
| 4755 | |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4756 | \param - pValue Pointer to input data (its a NUL terminated string) |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 4757 | \param - pTargetApBssid Pointer to target Ap bssid |
| 4758 | \param - pChannel Pointer to the Target AP channel |
| 4759 | |
| 4760 | \return - 0 for success non-zero for failure |
| 4761 | |
| 4762 | --------------------------------------------------------------------------*/ |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4763 | VOS_STATUS hdd_parse_reassoc_command_data(tANI_U8 *pValue, |
| 4764 | tANI_U8 *pTargetApBssid, tANI_U8 *pChannel) |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 4765 | { |
| 4766 | tANI_U8 *inPtr = pValue; |
| 4767 | int tempInt; |
| 4768 | int v = 0; |
| 4769 | tANI_U8 tempBuf[32]; |
Kiet Lam | aa8e15a | 2014-02-11 23:30:06 -0800 | [diff] [blame] | 4770 | /* 12 hexa decimal digits, 5 ':' and '\0' */ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 4771 | tANI_U8 macAddress[18]; |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 4772 | |
| 4773 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 4774 | /*no argument after the command*/ |
| 4775 | if (NULL == inPtr) |
| 4776 | { |
| 4777 | return -EINVAL; |
| 4778 | } |
| 4779 | |
| 4780 | /*no space after the command*/ |
| 4781 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 4782 | { |
| 4783 | return -EINVAL; |
| 4784 | } |
| 4785 | |
| 4786 | /*removing empty spaces*/ |
| 4787 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 4788 | |
| 4789 | /*no argument followed by spaces*/ |
| 4790 | if ('\0' == *inPtr) |
| 4791 | { |
| 4792 | return -EINVAL; |
| 4793 | } |
| 4794 | |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4795 | v = sscanf(inPtr, "%17s", macAddress); |
| 4796 | if (!((1 == v) && hdd_is_valid_mac_address(macAddress))) |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 4797 | { |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4798 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4799 | "Invalid MAC address or All hex inputs are not read (%d)", v); |
| 4800 | return -EINVAL; |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 4801 | } |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4802 | |
| 4803 | pTargetApBssid[0] = hdd_parse_hex(macAddress[0]) << 4 | hdd_parse_hex(macAddress[1]); |
| 4804 | pTargetApBssid[1] = hdd_parse_hex(macAddress[3]) << 4 | hdd_parse_hex(macAddress[4]); |
| 4805 | pTargetApBssid[2] = hdd_parse_hex(macAddress[6]) << 4 | hdd_parse_hex(macAddress[7]); |
| 4806 | pTargetApBssid[3] = hdd_parse_hex(macAddress[9]) << 4 | hdd_parse_hex(macAddress[10]); |
| 4807 | pTargetApBssid[4] = hdd_parse_hex(macAddress[12]) << 4 | hdd_parse_hex(macAddress[13]); |
| 4808 | pTargetApBssid[5] = hdd_parse_hex(macAddress[15]) << 4 | hdd_parse_hex(macAddress[16]); |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 4809 | |
| 4810 | /* point to the next argument */ |
| 4811 | inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE); |
| 4812 | /*no argument after the command*/ |
| 4813 | if (NULL == inPtr) return -EINVAL; |
| 4814 | |
| 4815 | /*removing empty spaces*/ |
| 4816 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 4817 | |
| 4818 | /*no argument followed by spaces*/ |
| 4819 | if ('\0' == *inPtr) |
| 4820 | { |
| 4821 | return -EINVAL; |
| 4822 | } |
| 4823 | |
| 4824 | /*getting the next argument ie the channel number */ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 4825 | v = sscanf(inPtr, "%31s ", tempBuf); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4826 | if (1 != v) return -EINVAL; |
| 4827 | |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 4828 | v = kstrtos32(tempBuf, 10, &tempInt); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4829 | if ((v < 0) || |
| 4830 | (tempInt <= 0) || |
| 4831 | (tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX)) |
| 4832 | { |
| 4833 | return -EINVAL; |
| 4834 | } |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 4835 | |
| 4836 | *pChannel = tempInt; |
| 4837 | return VOS_STATUS_SUCCESS; |
| 4838 | } |
| 4839 | |
| 4840 | #endif |
| 4841 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4842 | #if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD) |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4843 | /**--------------------------------------------------------------------------- |
| 4844 | |
| 4845 | \brief hdd_parse_get_cckm_ie() - HDD Parse and fetch the CCKM IE |
| 4846 | |
| 4847 | This function parses the SETCCKM IE command |
| 4848 | SETCCKMIE<space><ie data> |
| 4849 | |
| 4850 | \param - pValue Pointer to input data |
| 4851 | \param - pCckmIe Pointer to output cckm Ie |
| 4852 | \param - pCckmIeLen Pointer to output cckm ie length |
| 4853 | |
| 4854 | \return - 0 for success non-zero for failure |
| 4855 | |
| 4856 | --------------------------------------------------------------------------*/ |
| 4857 | VOS_STATUS hdd_parse_get_cckm_ie(tANI_U8 *pValue, tANI_U8 **pCckmIe, |
| 4858 | tANI_U8 *pCckmIeLen) |
| 4859 | { |
| 4860 | tANI_U8 *inPtr = pValue; |
| 4861 | tANI_U8 *dataEnd; |
| 4862 | int j = 0; |
| 4863 | int i = 0; |
| 4864 | tANI_U8 tempByte = 0; |
| 4865 | |
| 4866 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 4867 | /*no argument after the command*/ |
| 4868 | if (NULL == inPtr) |
| 4869 | { |
| 4870 | return -EINVAL; |
| 4871 | } |
| 4872 | |
| 4873 | /*no space after the command*/ |
| 4874 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 4875 | { |
| 4876 | return -EINVAL; |
| 4877 | } |
| 4878 | |
| 4879 | /*removing empty spaces*/ |
| 4880 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 4881 | |
| 4882 | /*no argument followed by spaces*/ |
| 4883 | if ('\0' == *inPtr) |
| 4884 | { |
| 4885 | return -EINVAL; |
| 4886 | } |
| 4887 | |
| 4888 | /* find the length of data */ |
| 4889 | dataEnd = inPtr; |
| 4890 | while(('\0' != *dataEnd) ) |
| 4891 | { |
| 4892 | dataEnd++; |
| 4893 | ++(*pCckmIeLen); |
| 4894 | } |
| 4895 | if ( *pCckmIeLen <= 0) return -EINVAL; |
| 4896 | |
| 4897 | /* Allocate the number of bytes based on the number of input characters |
| 4898 | whether it is even or odd. |
| 4899 | if the number of input characters are even, then we need N/2 byte. |
| 4900 | if the number of input characters are odd, then we need do (N+1)/2 to |
| 4901 | compensate rounding off. |
| 4902 | For example, if N = 18, then (18 + 1)/2 = 9 bytes are enough. |
| 4903 | If N = 19, then we need 10 bytes, hence (19 + 1)/2 = 10 bytes */ |
| 4904 | *pCckmIe = vos_mem_malloc((*pCckmIeLen + 1)/2); |
| 4905 | if (NULL == *pCckmIe) |
| 4906 | { |
| 4907 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 4908 | "%s: vos_mem_alloc failed ", __func__); |
| 4909 | return -EINVAL; |
| 4910 | } |
| 4911 | vos_mem_zero(*pCckmIe, (*pCckmIeLen + 1)/2); |
| 4912 | /* the buffer received from the upper layer is character buffer, |
| 4913 | we need to prepare the buffer taking 2 characters in to a U8 hex decimal number |
| 4914 | for example 7f0000f0...form a buffer to contain 7f in 0th location, 00 in 1st |
| 4915 | and f0 in 3rd location */ |
| 4916 | for (i = 0, j = 0; j < *pCckmIeLen; j += 2) |
| 4917 | { |
| 4918 | tempByte = (hdd_parse_hex(inPtr[j]) << 4) | (hdd_parse_hex(inPtr[j + 1])); |
| 4919 | (*pCckmIe)[i++] = tempByte; |
| 4920 | } |
| 4921 | *pCckmIeLen = i; |
| 4922 | |
| 4923 | return VOS_STATUS_SUCCESS; |
| 4924 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4925 | #endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */ |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4926 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4927 | /**--------------------------------------------------------------------------- |
| 4928 | |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4929 | \brief hdd_is_valid_mac_address() - Validate MAC address |
| 4930 | |
| 4931 | This function validates whether the given MAC address is valid or not |
| 4932 | Expected MAC address is of the format XX:XX:XX:XX:XX:XX |
| 4933 | where X is the hexa decimal digit character and separated by ':' |
| 4934 | This algorithm works even if MAC address is not separated by ':' |
| 4935 | |
| 4936 | This code checks given input string mac contains exactly 12 hexadecimal digits. |
| 4937 | and a separator colon : appears in the input string only after |
| 4938 | an even number of hex digits. |
| 4939 | |
| 4940 | \param - pMacAddr pointer to the input MAC address |
| 4941 | \return - 1 for valid and 0 for invalid |
| 4942 | |
| 4943 | --------------------------------------------------------------------------*/ |
| 4944 | |
| 4945 | v_BOOL_t hdd_is_valid_mac_address(const tANI_U8 *pMacAddr) |
| 4946 | { |
| 4947 | int xdigit = 0; |
| 4948 | int separator = 0; |
| 4949 | while (*pMacAddr) |
| 4950 | { |
| 4951 | if (isxdigit(*pMacAddr)) |
| 4952 | { |
| 4953 | xdigit++; |
| 4954 | } |
| 4955 | else if (':' == *pMacAddr) |
| 4956 | { |
| 4957 | if (0 == xdigit || ((xdigit / 2) - 1) != separator) |
| 4958 | break; |
| 4959 | |
| 4960 | ++separator; |
| 4961 | } |
| 4962 | else |
| 4963 | { |
| 4964 | separator = -1; |
| 4965 | /* Invalid MAC found */ |
| 4966 | return 0; |
| 4967 | } |
| 4968 | ++pMacAddr; |
| 4969 | } |
| 4970 | return (xdigit == 12 && (separator == 5 || separator == 0)); |
| 4971 | } |
| 4972 | |
| 4973 | /**--------------------------------------------------------------------------- |
| 4974 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4975 | \brief hdd_open() - HDD Open function |
| 4976 | |
| 4977 | This is called in response to ifconfig up |
| 4978 | |
| 4979 | \param - dev Pointer to net_device structure |
| 4980 | |
| 4981 | \return - 0 for success non-zero for failure |
| 4982 | |
| 4983 | --------------------------------------------------------------------------*/ |
| 4984 | int hdd_open (struct net_device *dev) |
| 4985 | { |
| 4986 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 4987 | hdd_context_t *pHddCtx; |
| 4988 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 4989 | VOS_STATUS status; |
| 4990 | v_BOOL_t in_standby = TRUE; |
| 4991 | |
| 4992 | if (NULL == pAdapter) |
| 4993 | { |
| 4994 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Agarwal Ashish | 971c288 | 2013-10-30 20:11:12 +0530 | [diff] [blame] | 4995 | "%s: pAdapter is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4996 | return -ENODEV; |
| 4997 | } |
| 4998 | |
| 4999 | pHddCtx = (hdd_context_t*)pAdapter->pHddCtx; |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 5000 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_OPEN_REQUEST, |
| 5001 | pAdapter->sessionId, pAdapter->device_mode)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5002 | if (NULL == pHddCtx) |
| 5003 | { |
| 5004 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 5005 | "%s: HDD context is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5006 | return -ENODEV; |
| 5007 | } |
| 5008 | |
| 5009 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 5010 | while ( (NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status) ) |
| 5011 | { |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 5012 | if (test_bit(DEVICE_IFACE_OPENED, &pAdapterNode->pAdapter->event_flags)) |
| 5013 | { |
| 5014 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: chip already out of standby", |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 5015 | __func__); |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 5016 | in_standby = FALSE; |
| 5017 | break; |
| 5018 | } |
| 5019 | else |
| 5020 | { |
| 5021 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 5022 | pAdapterNode = pNext; |
| 5023 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5024 | } |
| 5025 | |
| 5026 | if (TRUE == in_standby) |
| 5027 | { |
| 5028 | if (VOS_STATUS_SUCCESS != wlan_hdd_exit_lowpower(pHddCtx, pAdapter)) |
| 5029 | { |
| 5030 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failed to bring " |
| 5031 | "wlan out of power save", __func__); |
| 5032 | return -EINVAL; |
| 5033 | } |
| 5034 | } |
| 5035 | |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 5036 | set_bit(DEVICE_IFACE_OPENED, &pAdapter->event_flags); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5037 | if (hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) |
| 5038 | { |
| 5039 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 5040 | "%s: Enabling Tx Queues", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5041 | /* Enable TX queues only when we are connected */ |
| 5042 | netif_tx_start_all_queues(dev); |
| 5043 | } |
| 5044 | |
| 5045 | return 0; |
| 5046 | } |
| 5047 | |
| 5048 | int hdd_mon_open (struct net_device *dev) |
| 5049 | { |
| 5050 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5051 | |
| 5052 | if(pAdapter == NULL) { |
| 5053 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 5054 | "%s: HDD adapter context is Null", __func__); |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 5055 | return -EINVAL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5056 | } |
| 5057 | |
| 5058 | netif_start_queue(dev); |
| 5059 | |
| 5060 | return 0; |
| 5061 | } |
| 5062 | /**--------------------------------------------------------------------------- |
| 5063 | |
| 5064 | \brief hdd_stop() - HDD stop function |
| 5065 | |
| 5066 | This is called in response to ifconfig down |
| 5067 | |
| 5068 | \param - dev Pointer to net_device structure |
| 5069 | |
| 5070 | \return - 0 for success non-zero for failure |
| 5071 | |
| 5072 | --------------------------------------------------------------------------*/ |
| 5073 | |
| 5074 | int hdd_stop (struct net_device *dev) |
| 5075 | { |
| 5076 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5077 | hdd_context_t *pHddCtx; |
| 5078 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 5079 | VOS_STATUS status; |
| 5080 | v_BOOL_t enter_standby = TRUE; |
| 5081 | |
| 5082 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5083 | if (NULL == pAdapter) |
| 5084 | { |
| 5085 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Agarwal Ashish | 971c288 | 2013-10-30 20:11:12 +0530 | [diff] [blame] | 5086 | "%s: pAdapter is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5087 | return -ENODEV; |
| 5088 | } |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 5089 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_OPEN_REQUEST, |
| 5090 | pAdapter->sessionId, pAdapter->device_mode)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5091 | pHddCtx = (hdd_context_t*)pAdapter->pHddCtx; |
| 5092 | if (NULL == pHddCtx) |
| 5093 | { |
| 5094 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 5095 | "%s: HDD context is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5096 | return -ENODEV; |
| 5097 | } |
| 5098 | |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 5099 | /* Nothing to be done if the interface is not opened */ |
| 5100 | if (VOS_FALSE == test_bit(DEVICE_IFACE_OPENED, &pAdapter->event_flags)) |
| 5101 | { |
| 5102 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5103 | "%s: NETDEV Interface is not OPENED", __func__); |
| 5104 | return -ENODEV; |
| 5105 | } |
| 5106 | |
| 5107 | /* Make sure the interface is marked as closed */ |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 5108 | clear_bit(DEVICE_IFACE_OPENED, &pAdapter->event_flags); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5109 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disabling OS Tx queues", __func__); |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 5110 | |
| 5111 | /* Disable TX on the interface, after this hard_start_xmit() will not |
| 5112 | * be called on that interface |
| 5113 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5114 | netif_tx_disable(pAdapter->dev); |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 5115 | |
| 5116 | /* Mark the interface status as "down" for outside world */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5117 | netif_carrier_off(pAdapter->dev); |
| 5118 | |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 5119 | /* The interface is marked as down for outside world (aka kernel) |
| 5120 | * But the driver is pretty much alive inside. The driver needs to |
| 5121 | * tear down the existing connection on the netdev (session) |
| 5122 | * cleanup the data pipes and wait until the control plane is stabilized |
| 5123 | * for this interface. The call also needs to wait until the above |
| 5124 | * mentioned actions are completed before returning to the caller. |
| 5125 | * Notice that the hdd_stop_adapter is requested not to close the session |
| 5126 | * That is intentional to be able to scan if it is a STA/P2P interface |
| 5127 | */ |
| 5128 | hdd_stop_adapter(pHddCtx, pAdapter, VOS_FALSE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5129 | |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 5130 | /* DeInit the adapter. This ensures datapath cleanup as well */ |
| 5131 | hdd_deinit_adapter(pHddCtx, pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5132 | /* SoftAP ifaces should never go in power save mode |
| 5133 | making sure same here. */ |
| 5134 | if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode ) |
| 5135 | || (WLAN_HDD_MONITOR == pAdapter->device_mode ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5136 | || (WLAN_HDD_P2P_GO == pAdapter->device_mode ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5137 | ) |
| 5138 | { |
| 5139 | /* SoftAP mode, so return from here */ |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 5140 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5141 | "%s: In SAP MODE", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5142 | EXIT(); |
| 5143 | return 0; |
| 5144 | } |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 5145 | /* Find if any iface is up. If any iface is up then can't put device to |
| 5146 | * sleep/power save mode |
| 5147 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5148 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 5149 | while ( (NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status) ) |
| 5150 | { |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 5151 | if (test_bit(DEVICE_IFACE_OPENED, &pAdapterNode->pAdapter->event_flags)) |
| 5152 | { |
| 5153 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Still other ifaces are up cannot " |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 5154 | "put device to sleep", __func__); |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 5155 | enter_standby = FALSE; |
| 5156 | break; |
| 5157 | } |
| 5158 | else |
| 5159 | { |
| 5160 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 5161 | pAdapterNode = pNext; |
| 5162 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5163 | } |
| 5164 | |
| 5165 | if (TRUE == enter_standby) |
| 5166 | { |
| 5167 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: All Interfaces are Down " |
| 5168 | "entering standby", __func__); |
| 5169 | if (VOS_STATUS_SUCCESS != wlan_hdd_enter_lowpower(pHddCtx)) |
| 5170 | { |
| 5171 | /*log and return success*/ |
| 5172 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failed to put " |
| 5173 | "wlan in power save", __func__); |
| 5174 | } |
| 5175 | } |
| 5176 | |
| 5177 | EXIT(); |
| 5178 | return 0; |
| 5179 | } |
| 5180 | |
| 5181 | /**--------------------------------------------------------------------------- |
| 5182 | |
| 5183 | \brief hdd_uninit() - HDD uninit function |
| 5184 | |
| 5185 | This is called during the netdev unregister to uninitialize all data |
| 5186 | associated with the device |
| 5187 | |
| 5188 | \param - dev Pointer to net_device structure |
| 5189 | |
| 5190 | \return - void |
| 5191 | |
| 5192 | --------------------------------------------------------------------------*/ |
| 5193 | static void hdd_uninit (struct net_device *dev) |
| 5194 | { |
| 5195 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5196 | |
| 5197 | ENTER(); |
| 5198 | |
| 5199 | do |
| 5200 | { |
| 5201 | if (NULL == pAdapter) |
| 5202 | { |
| 5203 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 5204 | "%s: NULL pAdapter", __func__); |
| 5205 | break; |
| 5206 | } |
| 5207 | |
| 5208 | if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) |
| 5209 | { |
| 5210 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 5211 | "%s: Invalid magic", __func__); |
| 5212 | break; |
| 5213 | } |
| 5214 | |
| 5215 | if (NULL == pAdapter->pHddCtx) |
| 5216 | { |
| 5217 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 5218 | "%s: NULL pHddCtx", __func__); |
| 5219 | break; |
| 5220 | } |
| 5221 | |
| 5222 | if (dev != pAdapter->dev) |
| 5223 | { |
| 5224 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 5225 | "%s: Invalid device reference", __func__); |
| 5226 | /* we haven't validated all cases so let this go for now */ |
| 5227 | } |
| 5228 | |
| 5229 | hdd_deinit_adapter(pAdapter->pHddCtx, pAdapter); |
| 5230 | |
| 5231 | /* after uninit our adapter structure will no longer be valid */ |
| 5232 | pAdapter->dev = NULL; |
| 5233 | pAdapter->magic = 0; |
| 5234 | } while (0); |
| 5235 | |
| 5236 | EXIT(); |
| 5237 | } |
| 5238 | |
| 5239 | /**--------------------------------------------------------------------------- |
| 5240 | |
| 5241 | \brief hdd_release_firmware() - |
| 5242 | |
| 5243 | This function calls the release firmware API to free the firmware buffer. |
| 5244 | |
| 5245 | \param - pFileName Pointer to the File Name. |
| 5246 | pCtx - Pointer to the adapter . |
| 5247 | |
| 5248 | |
| 5249 | \return - 0 for success, non zero for failure |
| 5250 | |
| 5251 | --------------------------------------------------------------------------*/ |
| 5252 | |
| 5253 | VOS_STATUS hdd_release_firmware(char *pFileName,v_VOID_t *pCtx) |
| 5254 | { |
| 5255 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 5256 | hdd_context_t *pHddCtx = (hdd_context_t*)pCtx; |
| 5257 | ENTER(); |
| 5258 | |
| 5259 | |
| 5260 | if (!strcmp(WLAN_FW_FILE, pFileName)) { |
| 5261 | |
| 5262 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"%s: Loaded firmware file is %s",__func__,pFileName); |
| 5263 | |
| 5264 | if(pHddCtx->fw) { |
| 5265 | release_firmware(pHddCtx->fw); |
| 5266 | pHddCtx->fw = NULL; |
| 5267 | } |
| 5268 | else |
| 5269 | status = VOS_STATUS_E_FAILURE; |
| 5270 | } |
| 5271 | else if (!strcmp(WLAN_NV_FILE,pFileName)) { |
| 5272 | if(pHddCtx->nv) { |
| 5273 | release_firmware(pHddCtx->nv); |
| 5274 | pHddCtx->nv = NULL; |
| 5275 | } |
| 5276 | else |
| 5277 | status = VOS_STATUS_E_FAILURE; |
| 5278 | |
| 5279 | } |
| 5280 | |
| 5281 | EXIT(); |
| 5282 | return status; |
| 5283 | } |
| 5284 | |
| 5285 | /**--------------------------------------------------------------------------- |
| 5286 | |
| 5287 | \brief hdd_request_firmware() - |
| 5288 | |
| 5289 | This function reads the firmware file using the request firmware |
| 5290 | API and returns the the firmware data and the firmware file size. |
| 5291 | |
| 5292 | \param - pfileName - Pointer to the file name. |
| 5293 | - pCtx - Pointer to the adapter . |
| 5294 | - ppfw_data - Pointer to the pointer of the firmware data. |
| 5295 | - pSize - Pointer to the file size. |
| 5296 | |
| 5297 | \return - VOS_STATUS_SUCCESS for success, VOS_STATUS_E_FAILURE for failure |
| 5298 | |
| 5299 | --------------------------------------------------------------------------*/ |
| 5300 | |
| 5301 | |
| 5302 | VOS_STATUS hdd_request_firmware(char *pfileName,v_VOID_t *pCtx,v_VOID_t **ppfw_data, v_SIZE_t *pSize) |
| 5303 | { |
| 5304 | int status; |
| 5305 | VOS_STATUS retval = VOS_STATUS_SUCCESS; |
| 5306 | hdd_context_t *pHddCtx = (hdd_context_t*)pCtx; |
| 5307 | ENTER(); |
| 5308 | |
| 5309 | if( (!strcmp(WLAN_FW_FILE, pfileName)) ) { |
| 5310 | |
| 5311 | status = request_firmware(&pHddCtx->fw, pfileName, pHddCtx->parent_dev); |
| 5312 | |
| 5313 | if(status || !pHddCtx->fw || !pHddCtx->fw->data) { |
| 5314 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Firmware %s download failed", |
| 5315 | __func__, pfileName); |
| 5316 | retval = VOS_STATUS_E_FAILURE; |
| 5317 | } |
| 5318 | |
| 5319 | else { |
| 5320 | *ppfw_data = (v_VOID_t *)pHddCtx->fw->data; |
| 5321 | *pSize = pHddCtx->fw->size; |
| 5322 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Firmware size = %d", |
| 5323 | __func__, *pSize); |
| 5324 | } |
| 5325 | } |
| 5326 | else if(!strcmp(WLAN_NV_FILE, pfileName)) { |
| 5327 | |
| 5328 | status = request_firmware(&pHddCtx->nv, pfileName, pHddCtx->parent_dev); |
| 5329 | |
| 5330 | if(status || !pHddCtx->nv || !pHddCtx->nv->data) { |
| 5331 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: nv %s download failed", |
| 5332 | __func__, pfileName); |
| 5333 | retval = VOS_STATUS_E_FAILURE; |
| 5334 | } |
| 5335 | |
| 5336 | else { |
| 5337 | *ppfw_data = (v_VOID_t *)pHddCtx->nv->data; |
| 5338 | *pSize = pHddCtx->nv->size; |
| 5339 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: nv file size = %d", |
| 5340 | __func__, *pSize); |
| 5341 | } |
| 5342 | } |
| 5343 | |
| 5344 | EXIT(); |
| 5345 | return retval; |
| 5346 | } |
| 5347 | /**--------------------------------------------------------------------------- |
| 5348 | \brief hdd_full_pwr_cbk() - HDD full power callbackfunction |
| 5349 | |
| 5350 | This is the function invoked by SME to inform the result of a full power |
| 5351 | request issued by HDD |
| 5352 | |
| 5353 | \param - callbackcontext - Pointer to cookie |
| 5354 | status - result of request |
| 5355 | |
| 5356 | \return - None |
| 5357 | |
| 5358 | --------------------------------------------------------------------------*/ |
| 5359 | void hdd_full_pwr_cbk(void *callbackContext, eHalStatus status) |
| 5360 | { |
| 5361 | hdd_context_t *pHddCtx = (hdd_context_t*)callbackContext; |
| 5362 | |
Madan Mohan Koyyalamudi | 8bdd311 | 2012-09-24 13:55:14 -0700 | [diff] [blame] | 5363 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"HDD full Power callback status = %d", status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5364 | if(&pHddCtx->full_pwr_comp_var) |
| 5365 | { |
| 5366 | complete(&pHddCtx->full_pwr_comp_var); |
| 5367 | } |
| 5368 | } |
| 5369 | |
| 5370 | /**--------------------------------------------------------------------------- |
| 5371 | |
| 5372 | \brief hdd_req_bmps_cbk() - HDD Request BMPS callback function |
| 5373 | |
| 5374 | This is the function invoked by SME to inform the result of BMPS |
| 5375 | request issued by HDD |
| 5376 | |
| 5377 | \param - callbackcontext - Pointer to cookie |
| 5378 | status - result of request |
| 5379 | |
| 5380 | \return - None |
| 5381 | |
| 5382 | --------------------------------------------------------------------------*/ |
| 5383 | void hdd_req_bmps_cbk(void *callbackContext, eHalStatus status) |
| 5384 | { |
| 5385 | |
| 5386 | struct completion *completion_var = (struct completion*) callbackContext; |
| 5387 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 5388 | hddLog(VOS_TRACE_LEVEL_ERROR, "HDD BMPS request Callback, status = %d", status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5389 | if(completion_var != NULL) |
| 5390 | { |
| 5391 | complete(completion_var); |
| 5392 | } |
| 5393 | } |
| 5394 | |
| 5395 | /**--------------------------------------------------------------------------- |
| 5396 | |
| 5397 | \brief hdd_get_cfg_file_size() - |
| 5398 | |
| 5399 | This function reads the configuration file using the request firmware |
| 5400 | API and returns the configuration file size. |
| 5401 | |
| 5402 | \param - pCtx - Pointer to the adapter . |
| 5403 | - pFileName - Pointer to the file name. |
| 5404 | - pBufSize - Pointer to the buffer size. |
| 5405 | |
| 5406 | \return - 0 for success, non zero for failure |
| 5407 | |
| 5408 | --------------------------------------------------------------------------*/ |
| 5409 | |
| 5410 | VOS_STATUS hdd_get_cfg_file_size(v_VOID_t *pCtx, char *pFileName, v_SIZE_t *pBufSize) |
| 5411 | { |
| 5412 | int status; |
| 5413 | hdd_context_t *pHddCtx = (hdd_context_t*)pCtx; |
| 5414 | |
| 5415 | ENTER(); |
| 5416 | |
| 5417 | status = request_firmware(&pHddCtx->fw, pFileName, pHddCtx->parent_dev); |
| 5418 | |
| 5419 | if(status || !pHddCtx->fw || !pHddCtx->fw->data) { |
| 5420 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: CFG download failed",__func__); |
| 5421 | status = VOS_STATUS_E_FAILURE; |
| 5422 | } |
| 5423 | else { |
| 5424 | *pBufSize = pHddCtx->fw->size; |
| 5425 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: CFG size = %d", __func__, *pBufSize); |
| 5426 | release_firmware(pHddCtx->fw); |
| 5427 | pHddCtx->fw = NULL; |
| 5428 | } |
| 5429 | |
| 5430 | EXIT(); |
| 5431 | return VOS_STATUS_SUCCESS; |
| 5432 | } |
| 5433 | |
| 5434 | /**--------------------------------------------------------------------------- |
| 5435 | |
| 5436 | \brief hdd_read_cfg_file() - |
| 5437 | |
| 5438 | This function reads the configuration file using the request firmware |
| 5439 | API and returns the cfg data and the buffer size of the configuration file. |
| 5440 | |
| 5441 | \param - pCtx - Pointer to the adapter . |
| 5442 | - pFileName - Pointer to the file name. |
| 5443 | - pBuffer - Pointer to the data buffer. |
| 5444 | - pBufSize - Pointer to the buffer size. |
| 5445 | |
| 5446 | \return - 0 for success, non zero for failure |
| 5447 | |
| 5448 | --------------------------------------------------------------------------*/ |
| 5449 | |
| 5450 | VOS_STATUS hdd_read_cfg_file(v_VOID_t *pCtx, char *pFileName, |
| 5451 | v_VOID_t *pBuffer, v_SIZE_t *pBufSize) |
| 5452 | { |
| 5453 | int status; |
| 5454 | hdd_context_t *pHddCtx = (hdd_context_t*)pCtx; |
| 5455 | |
| 5456 | ENTER(); |
| 5457 | |
| 5458 | status = request_firmware(&pHddCtx->fw, pFileName, pHddCtx->parent_dev); |
| 5459 | |
| 5460 | if(status || !pHddCtx->fw || !pHddCtx->fw->data) { |
| 5461 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: CFG download failed",__func__); |
| 5462 | return VOS_STATUS_E_FAILURE; |
| 5463 | } |
| 5464 | else { |
| 5465 | if(*pBufSize != pHddCtx->fw->size) { |
| 5466 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Caller sets invalid CFG " |
| 5467 | "file size", __func__); |
| 5468 | release_firmware(pHddCtx->fw); |
| 5469 | pHddCtx->fw = NULL; |
| 5470 | return VOS_STATUS_E_FAILURE; |
| 5471 | } |
| 5472 | else { |
| 5473 | if(pBuffer) { |
| 5474 | vos_mem_copy(pBuffer,pHddCtx->fw->data,*pBufSize); |
| 5475 | } |
| 5476 | release_firmware(pHddCtx->fw); |
| 5477 | pHddCtx->fw = NULL; |
| 5478 | } |
| 5479 | } |
| 5480 | |
| 5481 | EXIT(); |
| 5482 | |
| 5483 | return VOS_STATUS_SUCCESS; |
| 5484 | } |
| 5485 | |
| 5486 | /**--------------------------------------------------------------------------- |
| 5487 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5488 | \brief hdd_set_mac_address() - |
| 5489 | |
| 5490 | This function sets the user specified mac address using |
| 5491 | the command ifconfig wlanX hw ether <mac adress>. |
| 5492 | |
| 5493 | \param - dev - Pointer to the net device. |
| 5494 | - addr - Pointer to the sockaddr. |
| 5495 | \return - 0 for success, non zero for failure |
| 5496 | |
| 5497 | --------------------------------------------------------------------------*/ |
| 5498 | |
| 5499 | static int hdd_set_mac_address(struct net_device *dev, void *addr) |
| 5500 | { |
| 5501 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5502 | struct sockaddr *psta_mac_addr = addr; |
| 5503 | eHalStatus halStatus = eHAL_STATUS_SUCCESS; |
| 5504 | |
| 5505 | ENTER(); |
| 5506 | |
| 5507 | memcpy(&pAdapter->macAddressCurrent, psta_mac_addr->sa_data, ETH_ALEN); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5508 | memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN); |
| 5509 | |
| 5510 | EXIT(); |
| 5511 | return halStatus; |
| 5512 | } |
| 5513 | |
| 5514 | tANI_U8* wlan_hdd_get_intf_addr(hdd_context_t* pHddCtx) |
| 5515 | { |
| 5516 | int i; |
| 5517 | for ( i = 0; i < VOS_MAX_CONCURRENCY_PERSONA; i++) |
| 5518 | { |
Abhishek Singh | eb18378 | 2014-02-06 13:37:21 +0530 | [diff] [blame] | 5519 | if( 0 == ((pHddCtx->cfg_ini->intfAddrMask) & (1 << i)) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5520 | break; |
| 5521 | } |
| 5522 | |
| 5523 | if( VOS_MAX_CONCURRENCY_PERSONA == i) |
| 5524 | return NULL; |
| 5525 | |
| 5526 | pHddCtx->cfg_ini->intfAddrMask |= (1 << i); |
| 5527 | return &pHddCtx->cfg_ini->intfMacAddr[i].bytes[0]; |
| 5528 | } |
| 5529 | |
| 5530 | void wlan_hdd_release_intf_addr(hdd_context_t* pHddCtx, tANI_U8* releaseAddr) |
| 5531 | { |
| 5532 | int i; |
| 5533 | for ( i = 0; i < VOS_MAX_CONCURRENCY_PERSONA; i++) |
| 5534 | { |
| 5535 | if ( !memcmp(releaseAddr, &pHddCtx->cfg_ini->intfMacAddr[i].bytes[0], 6) ) |
| 5536 | { |
| 5537 | pHddCtx->cfg_ini->intfAddrMask &= ~(1 << i); |
| 5538 | break; |
| 5539 | } |
| 5540 | } |
| 5541 | return; |
| 5542 | } |
| 5543 | |
| 5544 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)) |
| 5545 | static struct net_device_ops wlan_drv_ops = { |
| 5546 | .ndo_open = hdd_open, |
| 5547 | .ndo_stop = hdd_stop, |
| 5548 | .ndo_uninit = hdd_uninit, |
| 5549 | .ndo_start_xmit = hdd_hard_start_xmit, |
| 5550 | .ndo_tx_timeout = hdd_tx_timeout, |
| 5551 | .ndo_get_stats = hdd_stats, |
| 5552 | .ndo_do_ioctl = hdd_ioctl, |
| 5553 | .ndo_set_mac_address = hdd_set_mac_address, |
| 5554 | .ndo_select_queue = hdd_select_queue, |
| 5555 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 5556 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(3,1,0)) |
| 5557 | .ndo_set_rx_mode = hdd_set_multicast_list, |
| 5558 | #else |
| 5559 | .ndo_set_multicast_list = hdd_set_multicast_list, |
| 5560 | #endif //LINUX_VERSION_CODE |
| 5561 | #endif |
| 5562 | }; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5563 | static struct net_device_ops wlan_mon_drv_ops = { |
| 5564 | .ndo_open = hdd_mon_open, |
| 5565 | .ndo_stop = hdd_stop, |
| 5566 | .ndo_uninit = hdd_uninit, |
| 5567 | .ndo_start_xmit = hdd_mon_hard_start_xmit, |
| 5568 | .ndo_tx_timeout = hdd_tx_timeout, |
| 5569 | .ndo_get_stats = hdd_stats, |
| 5570 | .ndo_do_ioctl = hdd_ioctl, |
| 5571 | .ndo_set_mac_address = hdd_set_mac_address, |
| 5572 | }; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5573 | |
| 5574 | #endif |
| 5575 | |
| 5576 | void hdd_set_station_ops( struct net_device *pWlanDev ) |
| 5577 | { |
| 5578 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5579 | pWlanDev->netdev_ops = &wlan_drv_ops; |
| 5580 | #else |
| 5581 | pWlanDev->open = hdd_open; |
| 5582 | pWlanDev->stop = hdd_stop; |
| 5583 | pWlanDev->uninit = hdd_uninit; |
| 5584 | pWlanDev->hard_start_xmit = NULL; |
| 5585 | pWlanDev->tx_timeout = hdd_tx_timeout; |
| 5586 | pWlanDev->get_stats = hdd_stats; |
| 5587 | pWlanDev->do_ioctl = hdd_ioctl; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5588 | pWlanDev->set_mac_address = hdd_set_mac_address; |
| 5589 | #endif |
| 5590 | } |
| 5591 | |
Jeff Johnson | eed415b | 2013-01-18 16:11:20 -0800 | [diff] [blame] | 5592 | static hdd_adapter_t* hdd_alloc_station_adapter( hdd_context_t *pHddCtx, tSirMacAddr macAddr, const char* name ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5593 | { |
| 5594 | struct net_device *pWlanDev = NULL; |
| 5595 | hdd_adapter_t *pAdapter = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5596 | /* |
| 5597 | * cfg80211 initialization and registration.... |
| 5598 | */ |
| 5599 | pWlanDev = alloc_netdev_mq(sizeof( hdd_adapter_t ), name, ether_setup, NUM_TX_QUEUES); |
| 5600 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5601 | if(pWlanDev != NULL) |
| 5602 | { |
| 5603 | |
| 5604 | //Save the pointer to the net_device in the HDD adapter |
| 5605 | pAdapter = (hdd_adapter_t*) netdev_priv( pWlanDev ); |
| 5606 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5607 | vos_mem_zero( pAdapter, sizeof( hdd_adapter_t ) ); |
| 5608 | |
| 5609 | pAdapter->dev = pWlanDev; |
| 5610 | pAdapter->pHddCtx = pHddCtx; |
| 5611 | pAdapter->magic = WLAN_HDD_ADAPTER_MAGIC; |
| 5612 | |
| 5613 | init_completion(&pAdapter->session_open_comp_var); |
| 5614 | init_completion(&pAdapter->session_close_comp_var); |
| 5615 | init_completion(&pAdapter->disconnect_comp_var); |
| 5616 | init_completion(&pAdapter->linkup_event_var); |
| 5617 | init_completion(&pAdapter->cancel_rem_on_chan_var); |
| 5618 | init_completion(&pAdapter->rem_on_chan_ready_event); |
Vinay Krishna Eranna | f0e523b | 2014-03-01 21:00:16 +0530 | [diff] [blame] | 5619 | init_completion(&pAdapter->pno_comp_var); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5620 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 5621 | init_completion(&pAdapter->offchannel_tx_event); |
| 5622 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5623 | init_completion(&pAdapter->tx_action_cnf_event); |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 5624 | #ifdef FEATURE_WLAN_TDLS |
| 5625 | init_completion(&pAdapter->tdls_add_station_comp); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 5626 | init_completion(&pAdapter->tdls_del_station_comp); |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 5627 | init_completion(&pAdapter->tdls_mgmt_comp); |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 5628 | init_completion(&pAdapter->tdls_link_establish_req_comp); |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 5629 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5630 | init_completion(&pHddCtx->mc_sus_event_var); |
| 5631 | init_completion(&pHddCtx->tx_sus_event_var); |
Gopichand Nakkala | 0562141 | 2013-06-19 19:37:38 +0530 | [diff] [blame] | 5632 | init_completion(&pHddCtx->rx_sus_event_var); |
Jeff Johnson | 9efb9aa | 2013-03-15 13:59:27 -0700 | [diff] [blame] | 5633 | init_completion(&pAdapter->ula_complete); |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 5634 | init_completion(&pAdapter->change_country_code); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5635 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 5636 | #ifdef FEATURE_WLAN_BATCH_SCAN |
| 5637 | init_completion(&pAdapter->hdd_set_batch_scan_req_var); |
| 5638 | init_completion(&pAdapter->hdd_get_batch_scan_req_var); |
| 5639 | pAdapter->pBatchScanRsp = NULL; |
| 5640 | pAdapter->numScanList = 0; |
Rajeev Kumar | 20140c1 | 2013-10-21 19:39:02 -0700 | [diff] [blame] | 5641 | pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STOPPED; |
Kiet Lam | aa8e15a | 2014-02-11 23:30:06 -0800 | [diff] [blame] | 5642 | pAdapter->prev_batch_id = 0; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 5643 | mutex_init(&pAdapter->hdd_batch_scan_lock); |
| 5644 | #endif |
| 5645 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5646 | pAdapter->isLinkUpSvcNeeded = FALSE; |
| 5647 | pAdapter->higherDtimTransition = eANI_BOOLEAN_TRUE; |
| 5648 | //Init the net_device structure |
| 5649 | strlcpy(pWlanDev->name, name, IFNAMSIZ); |
| 5650 | |
| 5651 | vos_mem_copy(pWlanDev->dev_addr, (void *)macAddr, sizeof(tSirMacAddr)); |
| 5652 | vos_mem_copy( pAdapter->macAddressCurrent.bytes, macAddr, sizeof(tSirMacAddr)); |
| 5653 | pWlanDev->watchdog_timeo = HDD_TX_TIMEOUT; |
| 5654 | pWlanDev->hard_header_len += LIBRA_HW_NEEDED_HEADROOM; |
| 5655 | |
| 5656 | hdd_set_station_ops( pAdapter->dev ); |
| 5657 | |
| 5658 | pWlanDev->destructor = free_netdev; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5659 | pWlanDev->ieee80211_ptr = &pAdapter->wdev ; |
| 5660 | pAdapter->wdev.wiphy = pHddCtx->wiphy; |
| 5661 | pAdapter->wdev.netdev = pWlanDev; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5662 | /* set pWlanDev's parent to underlying device */ |
| 5663 | SET_NETDEV_DEV(pWlanDev, pHddCtx->parent_dev); |
Kumar Anand | 82c009f | 2014-05-29 00:29:42 -0700 | [diff] [blame] | 5664 | |
| 5665 | hdd_wmm_init( pAdapter ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5666 | } |
| 5667 | |
| 5668 | return pAdapter; |
| 5669 | } |
| 5670 | |
| 5671 | VOS_STATUS hdd_register_interface( hdd_adapter_t *pAdapter, tANI_U8 rtnl_lock_held ) |
| 5672 | { |
| 5673 | struct net_device *pWlanDev = pAdapter->dev; |
| 5674 | //hdd_station_ctx_t *pHddStaCtx = &pAdapter->sessionCtx.station; |
| 5675 | //hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
| 5676 | //eHalStatus halStatus = eHAL_STATUS_SUCCESS; |
| 5677 | |
| 5678 | if( rtnl_lock_held ) |
| 5679 | { |
Madan Mohan Koyyalamudi | d8ac866 | 2012-11-06 19:04:56 -0800 | [diff] [blame] | 5680 | if (strnchr(pWlanDev->name, strlen(pWlanDev->name), '%')) { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5681 | if( dev_alloc_name(pWlanDev, pWlanDev->name) < 0 ) |
| 5682 | { |
| 5683 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s:Failed:dev_alloc_name",__func__); |
| 5684 | return VOS_STATUS_E_FAILURE; |
| 5685 | } |
| 5686 | } |
| 5687 | if (register_netdevice(pWlanDev)) |
| 5688 | { |
| 5689 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s:Failed:register_netdev",__func__); |
| 5690 | return VOS_STATUS_E_FAILURE; |
| 5691 | } |
| 5692 | } |
| 5693 | else |
| 5694 | { |
| 5695 | if(register_netdev(pWlanDev)) |
| 5696 | { |
| 5697 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failed:register_netdev",__func__); |
| 5698 | return VOS_STATUS_E_FAILURE; |
| 5699 | } |
| 5700 | } |
| 5701 | set_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags); |
| 5702 | |
| 5703 | return VOS_STATUS_SUCCESS; |
| 5704 | } |
| 5705 | |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 5706 | static eHalStatus hdd_smeCloseSessionCallback(void *pContext) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5707 | { |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 5708 | hdd_adapter_t *pAdapter = pContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5709 | |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 5710 | if (NULL == pAdapter) |
| 5711 | { |
| 5712 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: NULL pAdapter", __func__); |
| 5713 | return eHAL_STATUS_INVALID_PARAMETER; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5714 | } |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 5715 | |
| 5716 | if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) |
| 5717 | { |
| 5718 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Invalid magic", __func__); |
| 5719 | return eHAL_STATUS_NOT_INITIALIZED; |
| 5720 | } |
| 5721 | |
| 5722 | clear_bit(SME_SESSION_OPENED, &pAdapter->event_flags); |
| 5723 | |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 5724 | #ifndef WLAN_OPEN_SOURCE |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 5725 | /* need to make sure all of our scheduled work has completed. |
| 5726 | * This callback is called from MC thread context, so it is safe to |
| 5727 | * to call below flush workqueue API from here. |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 5728 | * |
| 5729 | * Even though this is called from MC thread context, if there is a faulty |
| 5730 | * work item in the system, that can hang this call forever. So flushing |
| 5731 | * this global work queue is not safe; and now we make sure that |
| 5732 | * individual work queues are stopped correctly. But the cancel work queue |
| 5733 | * is a GPL only API, so the proprietary version of the driver would still |
| 5734 | * rely on the global work queue flush. |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 5735 | */ |
| 5736 | flush_scheduled_work(); |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 5737 | #endif |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 5738 | |
| 5739 | /* We can be blocked while waiting for scheduled work to be |
| 5740 | * flushed, and the adapter structure can potentially be freed, in |
| 5741 | * which case the magic will have been reset. So make sure the |
| 5742 | * magic is still good, and hence the adapter structure is still |
| 5743 | * valid, before signaling completion */ |
| 5744 | if (WLAN_HDD_ADAPTER_MAGIC == pAdapter->magic) |
| 5745 | { |
| 5746 | complete(&pAdapter->session_close_comp_var); |
| 5747 | } |
| 5748 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5749 | return eHAL_STATUS_SUCCESS; |
| 5750 | } |
| 5751 | |
| 5752 | VOS_STATUS hdd_init_station_mode( hdd_adapter_t *pAdapter ) |
| 5753 | { |
| 5754 | struct net_device *pWlanDev = pAdapter->dev; |
| 5755 | hdd_station_ctx_t *pHddStaCtx = &pAdapter->sessionCtx.station; |
| 5756 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
| 5757 | eHalStatus halStatus = eHAL_STATUS_SUCCESS; |
| 5758 | VOS_STATUS status = VOS_STATUS_E_FAILURE; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 5759 | long rc = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5760 | |
| 5761 | INIT_COMPLETION(pAdapter->session_open_comp_var); |
Kiran Kumar Lokere | 0ad5cd3 | 2013-06-25 11:26:22 -0700 | [diff] [blame] | 5762 | sme_SetCurrDeviceMode(pHddCtx->hHal, pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5763 | //Open a SME session for future operation |
| 5764 | halStatus = sme_OpenSession( pHddCtx->hHal, hdd_smeRoamCallback, pAdapter, |
Kiran Kumar Lokere | 0ad5cd3 | 2013-06-25 11:26:22 -0700 | [diff] [blame] | 5765 | (tANI_U8 *)&pAdapter->macAddressCurrent, &pAdapter->sessionId); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5766 | if ( !HAL_STATUS_SUCCESS( halStatus ) ) |
| 5767 | { |
| 5768 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 5769 | "sme_OpenSession() failed with status code %08d [x%08x]", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5770 | halStatus, halStatus ); |
| 5771 | status = VOS_STATUS_E_FAILURE; |
| 5772 | goto error_sme_open; |
| 5773 | } |
| 5774 | |
| 5775 | //Block on a completion variable. Can't wait forever though. |
Vinay Krishna Eranna | 0fe2e7c | 2014-04-09 21:32:08 +0530 | [diff] [blame] | 5776 | rc = wait_for_completion_timeout( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5777 | &pAdapter->session_open_comp_var, |
| 5778 | msecs_to_jiffies(WLAN_WAIT_TIME_SESSIONOPENCLOSE)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 5779 | if (rc <= 0) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5780 | { |
| 5781 | hddLog(VOS_TRACE_LEVEL_FATAL, |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 5782 | "Session is not opened within timeout period code %ld", rc ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5783 | status = VOS_STATUS_E_FAILURE; |
| 5784 | goto error_sme_open; |
| 5785 | } |
| 5786 | |
| 5787 | // Register wireless extensions |
| 5788 | if( eHAL_STATUS_SUCCESS != (halStatus = hdd_register_wext(pWlanDev))) |
| 5789 | { |
| 5790 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 5791 | "hdd_register_wext() failed with status code %08d [x%08x]", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5792 | halStatus, halStatus ); |
| 5793 | status = VOS_STATUS_E_FAILURE; |
| 5794 | goto error_register_wext; |
| 5795 | } |
| 5796 | //Safe to register the hard_start_xmit function again |
| 5797 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)) |
| 5798 | wlan_drv_ops.ndo_start_xmit = hdd_hard_start_xmit; |
| 5799 | #else |
| 5800 | pWlanDev->hard_start_xmit = hdd_hard_start_xmit; |
| 5801 | #endif |
| 5802 | |
| 5803 | //Set the Connection State to Not Connected |
Abhishek Singh | f4669da | 2014-05-26 15:07:49 +0530 | [diff] [blame] | 5804 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 5805 | "%s: Set HDD connState to eConnectionState_NotConnected", |
| 5806 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5807 | pHddStaCtx->conn_info.connState = eConnectionState_NotConnected; |
| 5808 | |
| 5809 | //Set the default operation channel |
| 5810 | pHddStaCtx->conn_info.operationChannel = pHddCtx->cfg_ini->OperatingChannel; |
| 5811 | |
| 5812 | /* Make the default Auth Type as OPEN*/ |
| 5813 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 5814 | |
| 5815 | if( VOS_STATUS_SUCCESS != ( status = hdd_init_tx_rx( pAdapter ) ) ) |
| 5816 | { |
| 5817 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 5818 | "hdd_init_tx_rx() failed with status code %08d [x%08x]", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5819 | status, status ); |
| 5820 | goto error_init_txrx; |
| 5821 | } |
| 5822 | |
| 5823 | set_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags); |
| 5824 | |
| 5825 | if( VOS_STATUS_SUCCESS != ( status = hdd_wmm_adapter_init( pAdapter ) ) ) |
| 5826 | { |
| 5827 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 5828 | "hdd_wmm_adapter_init() failed with status code %08d [x%08x]", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5829 | status, status ); |
| 5830 | goto error_wmm_init; |
| 5831 | } |
| 5832 | |
| 5833 | set_bit(WMM_INIT_DONE, &pAdapter->event_flags); |
| 5834 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 5835 | #ifdef FEATURE_WLAN_TDLS |
| 5836 | if(0 != wlan_hdd_tdls_init(pAdapter)) |
| 5837 | { |
| 5838 | status = VOS_STATUS_E_FAILURE; |
| 5839 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wlan_hdd_tdls_init failed",__func__); |
| 5840 | goto error_tdls_init; |
| 5841 | } |
| 5842 | set_bit(TDLS_INIT_DONE, &pAdapter->event_flags); |
| 5843 | #endif |
| 5844 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5845 | return VOS_STATUS_SUCCESS; |
| 5846 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 5847 | #ifdef FEATURE_WLAN_TDLS |
| 5848 | error_tdls_init: |
| 5849 | clear_bit(WMM_INIT_DONE, &pAdapter->event_flags); |
| 5850 | hdd_wmm_adapter_close(pAdapter); |
| 5851 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5852 | error_wmm_init: |
| 5853 | clear_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags); |
| 5854 | hdd_deinit_tx_rx(pAdapter); |
| 5855 | error_init_txrx: |
| 5856 | hdd_UnregisterWext(pWlanDev); |
| 5857 | error_register_wext: |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 5858 | if (test_bit(SME_SESSION_OPENED, &pAdapter->event_flags)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5859 | { |
| 5860 | INIT_COMPLETION(pAdapter->session_close_comp_var); |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 5861 | if (eHAL_STATUS_SUCCESS == sme_CloseSession(pHddCtx->hHal, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5862 | pAdapter->sessionId, |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 5863 | hdd_smeCloseSessionCallback, pAdapter)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5864 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 5865 | unsigned long rc; |
| 5866 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5867 | //Block on a completion variable. Can't wait forever though. |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 5868 | rc = wait_for_completion_timeout( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5869 | &pAdapter->session_close_comp_var, |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 5870 | msecs_to_jiffies(WLAN_WAIT_TIME_SESSIONOPENCLOSE)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 5871 | if (rc <= 0) |
| 5872 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5873 | FL("Session is not opened within timeout period code %ld"), rc); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5874 | } |
| 5875 | } |
| 5876 | error_sme_open: |
| 5877 | return status; |
| 5878 | } |
| 5879 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5880 | void hdd_cleanup_actionframe( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter ) |
| 5881 | { |
| 5882 | hdd_cfg80211_state_t *cfgState; |
| 5883 | |
| 5884 | cfgState = WLAN_HDD_GET_CFG_STATE_PTR( pAdapter ); |
| 5885 | |
| 5886 | if( NULL != cfgState->buf ) |
| 5887 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 5888 | long rc; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5889 | INIT_COMPLETION(pAdapter->tx_action_cnf_event); |
| 5890 | rc = wait_for_completion_interruptible_timeout( |
| 5891 | &pAdapter->tx_action_cnf_event, |
| 5892 | msecs_to_jiffies(ACTION_FRAME_TX_TIMEOUT)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 5893 | if (rc <= 0) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5894 | { |
Sudhir Sattayappa Kohalli | 8ee532d | 2013-02-15 13:16:26 -0800 | [diff] [blame] | 5895 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 5896 | "%s ERROR: HDD Wait for Action Confirmation Failed!! %ld" |
| 5897 | , __func__, rc); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5898 | } |
| 5899 | } |
| 5900 | return; |
| 5901 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5902 | |
| 5903 | void hdd_deinit_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter ) |
| 5904 | { |
| 5905 | ENTER(); |
| 5906 | switch ( pAdapter->device_mode ) |
| 5907 | { |
| 5908 | case WLAN_HDD_INFRA_STATION: |
| 5909 | case WLAN_HDD_P2P_CLIENT: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5910 | case WLAN_HDD_P2P_DEVICE: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5911 | { |
| 5912 | if(test_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags)) |
| 5913 | { |
| 5914 | hdd_deinit_tx_rx( pAdapter ); |
| 5915 | clear_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags); |
| 5916 | } |
| 5917 | |
| 5918 | if(test_bit(WMM_INIT_DONE, &pAdapter->event_flags)) |
| 5919 | { |
| 5920 | hdd_wmm_adapter_close( pAdapter ); |
| 5921 | clear_bit(WMM_INIT_DONE, &pAdapter->event_flags); |
| 5922 | } |
| 5923 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5924 | hdd_cleanup_actionframe(pHddCtx, pAdapter); |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 5925 | #ifdef FEATURE_WLAN_TDLS |
| 5926 | if(test_bit(TDLS_INIT_DONE, &pAdapter->event_flags)) |
| 5927 | { |
| 5928 | wlan_hdd_tdls_exit(pAdapter); |
| 5929 | clear_bit(TDLS_INIT_DONE, &pAdapter->event_flags); |
| 5930 | } |
| 5931 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5932 | |
| 5933 | break; |
| 5934 | } |
| 5935 | |
| 5936 | case WLAN_HDD_SOFTAP: |
| 5937 | case WLAN_HDD_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5938 | { |
Madan Mohan Koyyalamudi | 8c6dec8 | 2013-09-26 15:56:13 +0530 | [diff] [blame] | 5939 | |
| 5940 | if (test_bit(WMM_INIT_DONE, &pAdapter->event_flags)) |
| 5941 | { |
| 5942 | hdd_wmm_adapter_close( pAdapter ); |
| 5943 | clear_bit(WMM_INIT_DONE, &pAdapter->event_flags); |
| 5944 | } |
| 5945 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5946 | hdd_cleanup_actionframe(pHddCtx, pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5947 | |
| 5948 | hdd_unregister_hostapd(pAdapter); |
| 5949 | hdd_set_conparam( 0 ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5950 | wlan_hdd_set_monitor_tx_adapter( WLAN_HDD_GET_CTX(pAdapter), NULL ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5951 | break; |
| 5952 | } |
| 5953 | |
| 5954 | case WLAN_HDD_MONITOR: |
| 5955 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5956 | hdd_adapter_t* pAdapterforTx = pAdapter->sessionCtx.monitor.pAdapterForTx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5957 | if(test_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags)) |
| 5958 | { |
| 5959 | hdd_deinit_tx_rx( pAdapter ); |
| 5960 | clear_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags); |
| 5961 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5962 | if(NULL != pAdapterforTx) |
| 5963 | { |
| 5964 | hdd_cleanup_actionframe(pHddCtx, pAdapterforTx); |
| 5965 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5966 | break; |
| 5967 | } |
| 5968 | |
| 5969 | |
| 5970 | default: |
| 5971 | break; |
| 5972 | } |
| 5973 | |
| 5974 | EXIT(); |
| 5975 | } |
| 5976 | |
| 5977 | void hdd_cleanup_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter, tANI_U8 rtnl_held ) |
| 5978 | { |
Mingcheng Zhu | 87f22fc | 2014-01-30 19:23:32 -0800 | [diff] [blame] | 5979 | struct net_device *pWlanDev = NULL; |
Srinivas, Dasari | 693dfc5 | 2013-12-27 17:29:09 +0530 | [diff] [blame] | 5980 | |
| 5981 | ENTER(); |
| 5982 | if (NULL == pAdapter) |
| 5983 | { |
| 5984 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5985 | "%s: HDD adapter is Null", __func__); |
| 5986 | return; |
| 5987 | } |
| 5988 | |
| 5989 | pWlanDev = pAdapter->dev; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5990 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 5991 | #ifdef FEATURE_WLAN_BATCH_SCAN |
Srinivas, Dasari | 693dfc5 | 2013-12-27 17:29:09 +0530 | [diff] [blame] | 5992 | if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
| 5993 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 5994 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Srinivas, Dasari | 693dfc5 | 2013-12-27 17:29:09 +0530 | [diff] [blame] | 5995 | || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE) |
| 5996 | ) |
| 5997 | { |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 5998 | if (pAdapter) |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 5999 | { |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 6000 | if (eHDD_BATCH_SCAN_STATE_STARTED == pAdapter->batchScanState) |
| 6001 | { |
| 6002 | hdd_deinit_batch_scan(pAdapter); |
| 6003 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 6004 | } |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 6005 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 6006 | #endif |
| 6007 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6008 | if(test_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags)) { |
| 6009 | if( rtnl_held ) |
| 6010 | { |
| 6011 | unregister_netdevice(pWlanDev); |
| 6012 | } |
| 6013 | else |
| 6014 | { |
| 6015 | unregister_netdev(pWlanDev); |
| 6016 | } |
| 6017 | // note that the pAdapter is no longer valid at this point |
| 6018 | // since the memory has been reclaimed |
| 6019 | } |
| 6020 | |
Srinivas, Dasari | 693dfc5 | 2013-12-27 17:29:09 +0530 | [diff] [blame] | 6021 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6022 | } |
| 6023 | |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 6024 | void hdd_set_pwrparams(hdd_context_t *pHddCtx) |
| 6025 | { |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 6026 | VOS_STATUS status; |
| 6027 | hdd_adapter_t *pAdapter = NULL; |
| 6028 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 6029 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 6030 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 6031 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 6032 | /*loop through all adapters.*/ |
| 6033 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 6034 | { |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 6035 | pAdapter = pAdapterNode->pAdapter; |
| 6036 | if ( (WLAN_HDD_INFRA_STATION != pAdapter->device_mode) |
| 6037 | && (WLAN_HDD_P2P_CLIENT != pAdapter->device_mode) ) |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 6038 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 6039 | { // we skip this registration for modes other than STA and P2P client modes. |
| 6040 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 6041 | pAdapterNode = pNext; |
| 6042 | continue; |
| 6043 | } |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 6044 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 6045 | //Apply Dynamic DTIM For P2P |
| 6046 | //Only if ignoreDynamicDtimInP2pMode is not set in ini |
| 6047 | if ((pHddCtx->cfg_ini->enableDynamicDTIM || |
| 6048 | pHddCtx->cfg_ini->enableModulatedDTIM) && |
| 6049 | ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
| 6050 | ((WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) && |
| 6051 | !(pHddCtx->cfg_ini->ignoreDynamicDtimInP2pMode))) && |
| 6052 | (eANI_BOOLEAN_TRUE == pAdapter->higherDtimTransition) && |
| 6053 | (eConnectionState_Associated == |
| 6054 | (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) && |
| 6055 | (pHddCtx->cfg_ini->fIsBmpsEnabled)) |
| 6056 | { |
| 6057 | tSirSetPowerParamsReq powerRequest = { 0 }; |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 6058 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 6059 | powerRequest.uIgnoreDTIM = 1; |
| 6060 | powerRequest.uMaxLIModulatedDTIM = pHddCtx->cfg_ini->fMaxLIModulatedDTIM; |
| 6061 | |
| 6062 | if (pHddCtx->cfg_ini->enableModulatedDTIM) |
| 6063 | { |
| 6064 | powerRequest.uDTIMPeriod = pHddCtx->cfg_ini->enableModulatedDTIM; |
| 6065 | powerRequest.uListenInterval = pHddCtx->hdd_actual_LI_value; |
| 6066 | } |
| 6067 | else |
| 6068 | { |
| 6069 | powerRequest.uListenInterval = pHddCtx->cfg_ini->enableDynamicDTIM; |
| 6070 | } |
| 6071 | |
| 6072 | /* Update ignoreDTIM and ListedInterval in CFG to remain at the DTIM |
| 6073 | * specified during Enter/Exit BMPS when LCD off*/ |
| 6074 | ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IGNORE_DTIM, powerRequest.uIgnoreDTIM, |
| 6075 | NULL, eANI_BOOLEAN_FALSE); |
| 6076 | ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_LISTEN_INTERVAL, powerRequest.uListenInterval, |
| 6077 | NULL, eANI_BOOLEAN_FALSE); |
| 6078 | |
| 6079 | /* switch to the DTIM specified in cfg.ini */ |
| 6080 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 6081 | "Switch to DTIM %d", powerRequest.uListenInterval); |
| 6082 | sme_SetPowerParams( pHddCtx->hHal, &powerRequest, TRUE); |
| 6083 | break; |
| 6084 | |
| 6085 | } |
| 6086 | |
| 6087 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 6088 | pAdapterNode = pNext; |
| 6089 | } |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 6090 | } |
| 6091 | |
| 6092 | void hdd_reset_pwrparams(hdd_context_t *pHddCtx) |
| 6093 | { |
| 6094 | /*Switch back to DTIM 1*/ |
| 6095 | tSirSetPowerParamsReq powerRequest = { 0 }; |
| 6096 | |
| 6097 | powerRequest.uIgnoreDTIM = pHddCtx->hdd_actual_ignore_DTIM_value; |
| 6098 | powerRequest.uListenInterval = pHddCtx->hdd_actual_LI_value; |
Yue Ma | c24062f | 2013-05-13 17:01:29 -0700 | [diff] [blame] | 6099 | powerRequest.uMaxLIModulatedDTIM = pHddCtx->cfg_ini->fMaxLIModulatedDTIM; |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 6100 | |
| 6101 | /* Update ignoreDTIM and ListedInterval in CFG with default values */ |
| 6102 | ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IGNORE_DTIM, powerRequest.uIgnoreDTIM, |
| 6103 | NULL, eANI_BOOLEAN_FALSE); |
| 6104 | ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_LISTEN_INTERVAL, powerRequest.uListenInterval, |
| 6105 | NULL, eANI_BOOLEAN_FALSE); |
| 6106 | |
| 6107 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 6108 | "Switch to DTIM%d",powerRequest.uListenInterval); |
| 6109 | sme_SetPowerParams( pHddCtx->hHal, &powerRequest, TRUE); |
| 6110 | |
| 6111 | } |
| 6112 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6113 | VOS_STATUS hdd_enable_bmps_imps(hdd_context_t *pHddCtx) |
| 6114 | { |
| 6115 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 6116 | |
| 6117 | if(pHddCtx->cfg_ini->fIsBmpsEnabled) |
| 6118 | { |
| 6119 | sme_EnablePowerSave(pHddCtx->hHal, ePMC_BEACON_MODE_POWER_SAVE); |
| 6120 | } |
| 6121 | |
| 6122 | if(pHddCtx->cfg_ini->fIsAutoBmpsTimerEnabled) |
| 6123 | { |
| 6124 | sme_StartAutoBmpsTimer(pHddCtx->hHal); |
| 6125 | } |
| 6126 | |
| 6127 | if (pHddCtx->cfg_ini->fIsImpsEnabled) |
| 6128 | { |
| 6129 | sme_EnablePowerSave (pHddCtx->hHal, ePMC_IDLE_MODE_POWER_SAVE); |
| 6130 | } |
| 6131 | |
| 6132 | return status; |
| 6133 | } |
| 6134 | |
| 6135 | VOS_STATUS hdd_disable_bmps_imps(hdd_context_t *pHddCtx, tANI_U8 session_type) |
| 6136 | { |
| 6137 | hdd_adapter_t *pAdapter = NULL; |
| 6138 | eHalStatus halStatus; |
| 6139 | VOS_STATUS status = VOS_STATUS_E_INVAL; |
| 6140 | v_BOOL_t disableBmps = FALSE; |
| 6141 | v_BOOL_t disableImps = FALSE; |
| 6142 | |
| 6143 | switch(session_type) |
| 6144 | { |
| 6145 | case WLAN_HDD_INFRA_STATION: |
| 6146 | case WLAN_HDD_SOFTAP: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6147 | case WLAN_HDD_P2P_CLIENT: |
| 6148 | case WLAN_HDD_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6149 | //Exit BMPS -> Is Sta/P2P Client is already connected |
| 6150 | pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 6151 | if((NULL != pAdapter)&& |
| 6152 | hdd_connIsConnected( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) |
| 6153 | { |
| 6154 | disableBmps = TRUE; |
| 6155 | } |
| 6156 | |
| 6157 | pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT); |
| 6158 | if((NULL != pAdapter)&& |
| 6159 | hdd_connIsConnected( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) |
| 6160 | { |
| 6161 | disableBmps = TRUE; |
| 6162 | } |
| 6163 | |
| 6164 | //Exit both Bmps and Imps incase of Go/SAP Mode |
| 6165 | if((WLAN_HDD_SOFTAP == session_type) || |
| 6166 | (WLAN_HDD_P2P_GO == session_type)) |
| 6167 | { |
| 6168 | disableBmps = TRUE; |
| 6169 | disableImps = TRUE; |
| 6170 | } |
| 6171 | |
| 6172 | if(TRUE == disableImps) |
| 6173 | { |
| 6174 | if (pHddCtx->cfg_ini->fIsImpsEnabled) |
| 6175 | { |
| 6176 | sme_DisablePowerSave (pHddCtx->hHal, ePMC_IDLE_MODE_POWER_SAVE); |
| 6177 | } |
| 6178 | } |
| 6179 | |
| 6180 | if(TRUE == disableBmps) |
| 6181 | { |
| 6182 | if(pHddCtx->cfg_ini->fIsBmpsEnabled) |
| 6183 | { |
| 6184 | halStatus = sme_DisablePowerSave(pHddCtx->hHal, ePMC_BEACON_MODE_POWER_SAVE); |
| 6185 | |
| 6186 | if(eHAL_STATUS_SUCCESS != halStatus) |
| 6187 | { |
| 6188 | status = VOS_STATUS_E_FAILURE; |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6189 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Fail to Disable Power Save", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6190 | VOS_ASSERT(0); |
| 6191 | return status; |
| 6192 | } |
| 6193 | } |
| 6194 | |
| 6195 | if(pHddCtx->cfg_ini->fIsAutoBmpsTimerEnabled) |
| 6196 | { |
| 6197 | halStatus = sme_StopAutoBmpsTimer(pHddCtx->hHal); |
| 6198 | |
| 6199 | if(eHAL_STATUS_SUCCESS != halStatus) |
| 6200 | { |
| 6201 | status = VOS_STATUS_E_FAILURE; |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6202 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Fail to Stop Auto Bmps Timer", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6203 | VOS_ASSERT(0); |
| 6204 | return status; |
| 6205 | } |
| 6206 | } |
| 6207 | } |
| 6208 | |
| 6209 | if((TRUE == disableBmps) || |
| 6210 | (TRUE == disableImps)) |
| 6211 | { |
| 6212 | /* Now, get the chip into Full Power now */ |
| 6213 | INIT_COMPLETION(pHddCtx->full_pwr_comp_var); |
| 6214 | halStatus = sme_RequestFullPower(pHddCtx->hHal, hdd_full_pwr_cbk, |
| 6215 | pHddCtx, eSME_FULL_PWR_NEEDED_BY_HDD); |
| 6216 | |
| 6217 | if(halStatus != eHAL_STATUS_SUCCESS) |
| 6218 | { |
| 6219 | if(halStatus == eHAL_STATUS_PMC_PENDING) |
| 6220 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6221 | long ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6222 | //Block on a completion variable. Can't wait forever though |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6223 | ret = wait_for_completion_interruptible_timeout( |
| 6224 | &pHddCtx->full_pwr_comp_var, |
| 6225 | msecs_to_jiffies(1000)); |
| 6226 | if (ret <= 0) |
| 6227 | { |
| 6228 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6229 | "%s: wait on full_pwr_comp_var failed %ld", |
| 6230 | __func__, ret); |
| 6231 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6232 | } |
| 6233 | else |
| 6234 | { |
| 6235 | status = VOS_STATUS_E_FAILURE; |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6236 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Request for Full Power failed", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6237 | VOS_ASSERT(0); |
| 6238 | return status; |
| 6239 | } |
| 6240 | } |
| 6241 | |
| 6242 | status = VOS_STATUS_SUCCESS; |
| 6243 | } |
| 6244 | |
| 6245 | break; |
| 6246 | } |
| 6247 | return status; |
| 6248 | } |
| 6249 | |
| 6250 | hdd_adapter_t* hdd_open_adapter( hdd_context_t *pHddCtx, tANI_U8 session_type, |
Jeff Johnson | eed415b | 2013-01-18 16:11:20 -0800 | [diff] [blame] | 6251 | const char *iface_name, tSirMacAddr macAddr, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6252 | tANI_U8 rtnl_held ) |
| 6253 | { |
| 6254 | hdd_adapter_t *pAdapter = NULL; |
| 6255 | hdd_adapter_list_node_t *pHddAdapterNode = NULL; |
| 6256 | VOS_STATUS status = VOS_STATUS_E_FAILURE; |
| 6257 | VOS_STATUS exitbmpsStatus; |
| 6258 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6259 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s iface =%s type = %d",__func__,iface_name,session_type); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6260 | |
Nirav Shah | 436658f | 2014-02-28 17:05:45 +0530 | [diff] [blame] | 6261 | if(macAddr == NULL) |
| 6262 | { |
| 6263 | /* Not received valid macAddr */ |
| 6264 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6265 | "%s:Unable to add virtual intf: Not able to get" |
| 6266 | "valid mac address",__func__); |
| 6267 | return NULL; |
| 6268 | } |
| 6269 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6270 | //Disable BMPS incase of Concurrency |
| 6271 | exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx, session_type); |
| 6272 | |
| 6273 | if(VOS_STATUS_E_FAILURE == exitbmpsStatus) |
| 6274 | { |
| 6275 | //Fail to Exit BMPS |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6276 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Fail to Exit BMPS", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6277 | VOS_ASSERT(0); |
| 6278 | return NULL; |
| 6279 | } |
| 6280 | |
| 6281 | switch(session_type) |
| 6282 | { |
| 6283 | case WLAN_HDD_INFRA_STATION: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6284 | case WLAN_HDD_P2P_CLIENT: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6285 | case WLAN_HDD_P2P_DEVICE: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6286 | { |
| 6287 | pAdapter = hdd_alloc_station_adapter( pHddCtx, macAddr, iface_name ); |
| 6288 | |
| 6289 | if( NULL == pAdapter ) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6290 | { |
| 6291 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 6292 | FL("failed to allocate adapter for session %d"), session_type); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6293 | return NULL; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6294 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6295 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 6296 | #ifdef FEATURE_WLAN_TDLS |
| 6297 | /* A Mutex Lock is introduced while changing/initializing the mode to |
| 6298 | * protect the concurrent access for the Adapters by TDLS module. |
| 6299 | */ |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 6300 | mutex_lock(&pHddCtx->tdls_lock); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 6301 | #endif |
| 6302 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6303 | pAdapter->wdev.iftype = (session_type == WLAN_HDD_P2P_CLIENT) ? |
| 6304 | NL80211_IFTYPE_P2P_CLIENT: |
| 6305 | NL80211_IFTYPE_STATION; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6306 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6307 | pAdapter->device_mode = session_type; |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 6308 | #ifdef FEATURE_WLAN_TDLS |
| 6309 | mutex_unlock(&pHddCtx->tdls_lock); |
| 6310 | #endif |
Sunil Dutt | 66485cb | 2013-12-19 19:05:03 +0530 | [diff] [blame] | 6311 | |
| 6312 | status = hdd_init_station_mode( pAdapter ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6313 | if( VOS_STATUS_SUCCESS != status ) |
| 6314 | goto err_free_netdev; |
| 6315 | |
| 6316 | status = hdd_register_interface( pAdapter, rtnl_held ); |
| 6317 | if( VOS_STATUS_SUCCESS != status ) |
| 6318 | { |
| 6319 | hdd_deinit_adapter(pHddCtx, pAdapter); |
| 6320 | goto err_free_netdev; |
| 6321 | } |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 6322 | |
Vinay Krishna Eranna | 4d055d4 | 2013-12-17 17:02:01 +0530 | [diff] [blame] | 6323 | // Workqueue which gets scheduled in IPv4 notification callback. |
| 6324 | INIT_WORK(&pAdapter->ipv4NotifierWorkQueue, hdd_ipv4_notifier_work_queue); |
| 6325 | |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 6326 | #ifdef WLAN_NS_OFFLOAD |
| 6327 | // Workqueue which gets scheduled in IPv6 notification callback. |
| 6328 | INIT_WORK(&pAdapter->ipv6NotifierWorkQueue, hdd_ipv6_notifier_work_queue); |
| 6329 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6330 | //Stop the Interface TX queue. |
| 6331 | netif_tx_disable(pAdapter->dev); |
| 6332 | //netif_tx_disable(pWlanDev); |
| 6333 | netif_carrier_off(pAdapter->dev); |
| 6334 | |
| 6335 | break; |
| 6336 | } |
| 6337 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6338 | case WLAN_HDD_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6339 | case WLAN_HDD_SOFTAP: |
| 6340 | { |
| 6341 | pAdapter = hdd_wlan_create_ap_dev( pHddCtx, macAddr, (tANI_U8 *)iface_name ); |
| 6342 | if( NULL == pAdapter ) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6343 | { |
| 6344 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 6345 | FL("failed to allocate adapter for session %d"), session_type); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6346 | return NULL; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6347 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6348 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6349 | pAdapter->wdev.iftype = (session_type == WLAN_HDD_SOFTAP) ? |
| 6350 | NL80211_IFTYPE_AP: |
| 6351 | NL80211_IFTYPE_P2P_GO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6352 | pAdapter->device_mode = session_type; |
| 6353 | |
| 6354 | status = hdd_init_ap_mode(pAdapter); |
| 6355 | if( VOS_STATUS_SUCCESS != status ) |
| 6356 | goto err_free_netdev; |
| 6357 | |
| 6358 | status = hdd_register_hostapd( pAdapter, rtnl_held ); |
| 6359 | if( VOS_STATUS_SUCCESS != status ) |
| 6360 | { |
| 6361 | hdd_deinit_adapter(pHddCtx, pAdapter); |
| 6362 | goto err_free_netdev; |
| 6363 | } |
| 6364 | |
| 6365 | netif_tx_disable(pAdapter->dev); |
| 6366 | netif_carrier_off(pAdapter->dev); |
| 6367 | |
| 6368 | hdd_set_conparam( 1 ); |
| 6369 | break; |
| 6370 | } |
| 6371 | case WLAN_HDD_MONITOR: |
| 6372 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6373 | pAdapter = hdd_alloc_station_adapter( pHddCtx, macAddr, iface_name ); |
| 6374 | if( NULL == pAdapter ) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6375 | { |
| 6376 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 6377 | FL("failed to allocate adapter for session %d"), session_type); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6378 | return NULL; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6379 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6380 | |
| 6381 | pAdapter->wdev.iftype = NL80211_IFTYPE_MONITOR; |
| 6382 | pAdapter->device_mode = session_type; |
| 6383 | status = hdd_register_interface( pAdapter, rtnl_held ); |
| 6384 | #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29) |
| 6385 | pAdapter->dev->netdev_ops = &wlan_mon_drv_ops; |
| 6386 | #else |
| 6387 | pAdapter->dev->open = hdd_mon_open; |
| 6388 | pAdapter->dev->hard_start_xmit = hdd_mon_hard_start_xmit; |
| 6389 | #endif |
| 6390 | hdd_init_tx_rx( pAdapter ); |
| 6391 | set_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags); |
| 6392 | //Set adapter to be used for data tx. It will use either GO or softap. |
| 6393 | pAdapter->sessionCtx.monitor.pAdapterForTx = |
| 6394 | hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_SOFTAP); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6395 | if (NULL == pAdapter->sessionCtx.monitor.pAdapterForTx) |
| 6396 | { |
| 6397 | pAdapter->sessionCtx.monitor.pAdapterForTx = |
| 6398 | hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_P2P_GO); |
| 6399 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6400 | /* This workqueue will be used to transmit management packet over |
| 6401 | * monitor interface. */ |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 6402 | if (NULL == pAdapter->sessionCtx.monitor.pAdapterForTx) { |
| 6403 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s:Failed:hdd_get_adapter",__func__); |
| 6404 | return NULL; |
| 6405 | } |
Madan Mohan Koyyalamudi | 9f40ceb | 2012-10-18 19:22:56 -0700 | [diff] [blame] | 6406 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6407 | INIT_WORK(&pAdapter->sessionCtx.monitor.pAdapterForTx->monTxWorkQueue, |
| 6408 | hdd_mon_tx_work_queue); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6409 | } |
| 6410 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6411 | case WLAN_HDD_FTM: |
| 6412 | { |
| 6413 | pAdapter = hdd_alloc_station_adapter( pHddCtx, macAddr, iface_name ); |
| 6414 | |
| 6415 | if( NULL == pAdapter ) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6416 | { |
| 6417 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 6418 | FL("failed to allocate adapter for session %d"), session_type); |
| 6419 | return NULL; |
| 6420 | } |
| 6421 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6422 | /* Assign NL80211_IFTYPE_STATION as interface type to resolve Kernel Warning |
| 6423 | * message while loading driver in FTM mode. */ |
| 6424 | pAdapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 6425 | pAdapter->device_mode = session_type; |
| 6426 | status = hdd_register_interface( pAdapter, rtnl_held ); |
Madan Mohan Koyyalamudi | f89ac9f | 2013-09-19 16:58:12 +0530 | [diff] [blame] | 6427 | |
| 6428 | hdd_init_tx_rx( pAdapter ); |
| 6429 | |
| 6430 | //Stop the Interface TX queue. |
| 6431 | netif_tx_disable(pAdapter->dev); |
| 6432 | netif_carrier_off(pAdapter->dev); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6433 | } |
| 6434 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6435 | default: |
| 6436 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6437 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s Invalid session type %d", |
| 6438 | __func__, session_type); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6439 | VOS_ASSERT(0); |
| 6440 | return NULL; |
| 6441 | } |
| 6442 | } |
| 6443 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6444 | if( VOS_STATUS_SUCCESS == status ) |
| 6445 | { |
| 6446 | //Add it to the hdd's session list. |
| 6447 | pHddAdapterNode = vos_mem_malloc( sizeof( hdd_adapter_list_node_t ) ); |
| 6448 | if( NULL == pHddAdapterNode ) |
| 6449 | { |
| 6450 | status = VOS_STATUS_E_NOMEM; |
| 6451 | } |
| 6452 | else |
| 6453 | { |
| 6454 | pHddAdapterNode->pAdapter = pAdapter; |
| 6455 | status = hdd_add_adapter_back ( pHddCtx, |
| 6456 | pHddAdapterNode ); |
| 6457 | } |
| 6458 | } |
| 6459 | |
| 6460 | if( VOS_STATUS_SUCCESS != status ) |
| 6461 | { |
| 6462 | if( NULL != pAdapter ) |
| 6463 | { |
| 6464 | hdd_cleanup_adapter( pHddCtx, pAdapter, rtnl_held ); |
| 6465 | pAdapter = NULL; |
| 6466 | } |
| 6467 | if( NULL != pHddAdapterNode ) |
| 6468 | { |
| 6469 | vos_mem_free( pHddAdapterNode ); |
| 6470 | } |
| 6471 | |
| 6472 | goto resume_bmps; |
| 6473 | } |
| 6474 | |
| 6475 | if(VOS_STATUS_SUCCESS == status) |
| 6476 | { |
| 6477 | wlan_hdd_set_concurrency_mode(pHddCtx, session_type); |
| 6478 | |
Madan Mohan Koyyalamudi | 96dd30d | 2012-10-05 17:24:51 -0700 | [diff] [blame] | 6479 | //Initialize the WoWL service |
| 6480 | if(!hdd_init_wowl(pAdapter)) |
| 6481 | { |
| 6482 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hdd_init_wowl failed",__func__); |
| 6483 | goto err_free_netdev; |
| 6484 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6485 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6486 | return pAdapter; |
| 6487 | |
| 6488 | err_free_netdev: |
| 6489 | free_netdev(pAdapter->dev); |
| 6490 | wlan_hdd_release_intf_addr( pHddCtx, |
| 6491 | pAdapter->macAddressCurrent.bytes ); |
| 6492 | |
| 6493 | resume_bmps: |
| 6494 | //If bmps disabled enable it |
| 6495 | if(VOS_STATUS_SUCCESS == exitbmpsStatus) |
| 6496 | { |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 6497 | if (pHddCtx->hdd_wlan_suspended) |
| 6498 | { |
| 6499 | hdd_set_pwrparams(pHddCtx); |
| 6500 | } |
| 6501 | hdd_enable_bmps_imps(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6502 | } |
| 6503 | return NULL; |
| 6504 | } |
| 6505 | |
| 6506 | VOS_STATUS hdd_close_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter, |
| 6507 | tANI_U8 rtnl_held ) |
| 6508 | { |
| 6509 | hdd_adapter_list_node_t *pAdapterNode, *pCurrent, *pNext; |
| 6510 | VOS_STATUS status; |
| 6511 | |
| 6512 | status = hdd_get_front_adapter ( pHddCtx, &pCurrent ); |
| 6513 | if( VOS_STATUS_SUCCESS != status ) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6514 | { |
| 6515 | hddLog(VOS_TRACE_LEVEL_WARN,"%s: adapter list empty %d", |
| 6516 | __func__, status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6517 | return status; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6518 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6519 | |
| 6520 | while ( pCurrent->pAdapter != pAdapter ) |
| 6521 | { |
| 6522 | status = hdd_get_next_adapter ( pHddCtx, pCurrent, &pNext ); |
| 6523 | if( VOS_STATUS_SUCCESS != status ) |
| 6524 | break; |
| 6525 | |
| 6526 | pCurrent = pNext; |
| 6527 | } |
| 6528 | pAdapterNode = pCurrent; |
| 6529 | if( VOS_STATUS_SUCCESS == status ) |
| 6530 | { |
| 6531 | wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode); |
| 6532 | hdd_cleanup_adapter( pHddCtx, pAdapterNode->pAdapter, rtnl_held ); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 6533 | |
| 6534 | #ifdef FEATURE_WLAN_TDLS |
| 6535 | |
| 6536 | /* A Mutex Lock is introduced while changing/initializing the mode to |
| 6537 | * protect the concurrent access for the Adapters by TDLS module. |
| 6538 | */ |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 6539 | mutex_lock(&pHddCtx->tdls_lock); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 6540 | #endif |
| 6541 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6542 | hdd_remove_adapter( pHddCtx, pAdapterNode ); |
| 6543 | vos_mem_free( pAdapterNode ); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 6544 | pAdapterNode = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6545 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 6546 | #ifdef FEATURE_WLAN_TDLS |
| 6547 | mutex_unlock(&pHddCtx->tdls_lock); |
| 6548 | #endif |
| 6549 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6550 | |
| 6551 | /* If there is a single session of STA/P2P client, re-enable BMPS */ |
| 6552 | if ((!vos_concurrent_sessions_running()) && |
| 6553 | ((pHddCtx->no_of_sessions[VOS_STA_MODE] >= 1) || |
| 6554 | (pHddCtx->no_of_sessions[VOS_P2P_CLIENT_MODE] >= 1))) |
| 6555 | { |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 6556 | if (pHddCtx->hdd_wlan_suspended) |
| 6557 | { |
| 6558 | hdd_set_pwrparams(pHddCtx); |
| 6559 | } |
| 6560 | hdd_enable_bmps_imps(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6561 | } |
| 6562 | |
| 6563 | return VOS_STATUS_SUCCESS; |
| 6564 | } |
| 6565 | |
| 6566 | return VOS_STATUS_E_FAILURE; |
| 6567 | } |
| 6568 | |
| 6569 | VOS_STATUS hdd_close_all_adapters( hdd_context_t *pHddCtx ) |
| 6570 | { |
| 6571 | hdd_adapter_list_node_t *pHddAdapterNode; |
| 6572 | VOS_STATUS status; |
| 6573 | |
| 6574 | ENTER(); |
| 6575 | |
| 6576 | do |
| 6577 | { |
| 6578 | status = hdd_remove_front_adapter( pHddCtx, &pHddAdapterNode ); |
| 6579 | if( pHddAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 6580 | { |
| 6581 | hdd_cleanup_adapter( pHddCtx, pHddAdapterNode->pAdapter, FALSE ); |
| 6582 | vos_mem_free( pHddAdapterNode ); |
| 6583 | } |
| 6584 | }while( NULL != pHddAdapterNode && VOS_STATUS_E_EMPTY != status ); |
| 6585 | |
| 6586 | EXIT(); |
| 6587 | |
| 6588 | return VOS_STATUS_SUCCESS; |
| 6589 | } |
| 6590 | |
| 6591 | void wlan_hdd_reset_prob_rspies(hdd_adapter_t* pHostapdAdapter) |
| 6592 | { |
| 6593 | v_U8_t addIE[1] = {0}; |
| 6594 | |
| 6595 | if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 6596 | WNI_CFG_PROBE_RSP_ADDNIE_DATA1,(tANI_U8*)addIE, 0, NULL, |
| 6597 | eANI_BOOLEAN_FALSE) ) |
| 6598 | { |
| 6599 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6600 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6601 | } |
| 6602 | |
| 6603 | if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 6604 | WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL, |
| 6605 | eANI_BOOLEAN_FALSE) ) |
| 6606 | { |
| 6607 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6608 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6609 | } |
| 6610 | |
| 6611 | if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 6612 | WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL, |
| 6613 | eANI_BOOLEAN_FALSE) ) |
| 6614 | { |
| 6615 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6616 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6617 | } |
| 6618 | } |
| 6619 | |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 6620 | VOS_STATUS hdd_stop_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter, |
| 6621 | const v_BOOL_t bCloseSession ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6622 | { |
| 6623 | eHalStatus halStatus = eHAL_STATUS_SUCCESS; |
| 6624 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 6625 | union iwreq_data wrqu; |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 6626 | v_U8_t retry = 0; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6627 | long ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6628 | |
| 6629 | ENTER(); |
| 6630 | |
| 6631 | switch(pAdapter->device_mode) |
| 6632 | { |
| 6633 | case WLAN_HDD_INFRA_STATION: |
| 6634 | case WLAN_HDD_P2P_CLIENT: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6635 | case WLAN_HDD_P2P_DEVICE: |
Vinay Krishna Eranna | b09d3e7 | 2014-03-26 21:23:55 +0530 | [diff] [blame] | 6636 | { |
| 6637 | hdd_station_ctx_t *pstation = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 6638 | if( hdd_connIsConnected(pstation) || |
| 6639 | (pstation->conn_info.connState == eConnectionState_Connecting) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6640 | { |
| 6641 | if (pWextState->roamProfile.BSSType == eCSR_BSS_TYPE_START_IBSS) |
| 6642 | halStatus = sme_RoamDisconnect(pHddCtx->hHal, |
| 6643 | pAdapter->sessionId, |
| 6644 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
| 6645 | else |
| 6646 | halStatus = sme_RoamDisconnect(pHddCtx->hHal, |
| 6647 | pAdapter->sessionId, |
| 6648 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
| 6649 | //success implies disconnect command got queued up successfully |
| 6650 | if(halStatus == eHAL_STATUS_SUCCESS) |
| 6651 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6652 | ret = wait_for_completion_interruptible_timeout( |
| 6653 | &pAdapter->disconnect_comp_var, |
| 6654 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 6655 | if (ret <= 0) |
| 6656 | { |
| 6657 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6658 | "%s: wait on disconnect_comp_var failed %ld", |
| 6659 | __func__, ret); |
| 6660 | } |
| 6661 | } |
| 6662 | else |
| 6663 | { |
| 6664 | hddLog(LOGE, "%s: failed to post disconnect event to SME", |
| 6665 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6666 | } |
| 6667 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 6668 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 6669 | memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN); |
| 6670 | wireless_send_event(pAdapter->dev, SIOCGIWAP, &wrqu, NULL); |
| 6671 | } |
Vinay Krishna Eranna | b09d3e7 | 2014-03-26 21:23:55 +0530 | [diff] [blame] | 6672 | else if(pstation->conn_info.connState == |
| 6673 | eConnectionState_Disconnecting) |
| 6674 | { |
| 6675 | ret = wait_for_completion_interruptible_timeout( |
| 6676 | &pAdapter->disconnect_comp_var, |
| 6677 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 6678 | if (ret <= 0) |
| 6679 | { |
| 6680 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6681 | FL("wait on disconnect_comp_var failed %ld"), ret); |
| 6682 | } |
| 6683 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6684 | else |
| 6685 | { |
Srinivas, Dasari | 138af4f | 2014-02-07 11:13:45 +0530 | [diff] [blame] | 6686 | hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId, |
| 6687 | eCSR_SCAN_ABORT_DEFAULT); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6688 | } |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 6689 | if (pAdapter->device_mode != WLAN_HDD_INFRA_STATION) |
| 6690 | { |
| 6691 | while (pAdapter->is_roc_inprogress) |
| 6692 | { |
| 6693 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6694 | "%s: ROC in progress for session %d!!!", |
| 6695 | __func__, pAdapter->sessionId); |
| 6696 | // waiting for ROC to expire |
| 6697 | msleep(500); |
| 6698 | /* In GO present case , if retry exceeds 3, |
| 6699 | it means something went wrong. */ |
| 6700 | if ( retry++ > MAX_WAIT_FOR_ROC_COMPLETION ) |
| 6701 | { |
| 6702 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6703 | "%s: ROC completion is not received.!!!", __func__); |
| 6704 | sme_CancelRemainOnChannel(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 6705 | pAdapter->sessionId); |
| 6706 | wait_for_completion_interruptible_timeout( |
| 6707 | &pAdapter->cancel_rem_on_chan_var, |
| 6708 | msecs_to_jiffies(WAIT_CANCEL_REM_CHAN)); |
| 6709 | break; |
| 6710 | } |
| 6711 | } |
| 6712 | } |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 6713 | #ifdef WLAN_NS_OFFLOAD |
Vinay Krishna Eranna | 941360f | 2014-01-16 15:38:22 +0530 | [diff] [blame] | 6714 | #ifdef WLAN_OPEN_SOURCE |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 6715 | cancel_work_sync(&pAdapter->ipv6NotifierWorkQueue); |
| 6716 | #endif |
Vinay Krishna Eranna | 941360f | 2014-01-16 15:38:22 +0530 | [diff] [blame] | 6717 | if (pAdapter->ipv6_notifier_registered) |
| 6718 | { |
| 6719 | hddLog(LOG1, FL("Unregistered IPv6 notifier")); |
| 6720 | unregister_inet6addr_notifier(&pAdapter->ipv6_notifier); |
| 6721 | pAdapter->ipv6_notifier_registered = false; |
| 6722 | } |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 6723 | #endif |
Vinay Krishna Eranna | d9cbdb3 | 2014-01-16 12:59:10 +0530 | [diff] [blame] | 6724 | if (pAdapter->ipv4_notifier_registered) |
| 6725 | { |
| 6726 | hddLog(LOG1, FL("Unregistered IPv4 notifier")); |
| 6727 | unregister_inetaddr_notifier(&pAdapter->ipv4_notifier); |
| 6728 | pAdapter->ipv4_notifier_registered = false; |
| 6729 | } |
Vinay Krishna Eranna | 4d055d4 | 2013-12-17 17:02:01 +0530 | [diff] [blame] | 6730 | #ifdef WLAN_OPEN_SOURCE |
| 6731 | cancel_work_sync(&pAdapter->ipv4NotifierWorkQueue); |
| 6732 | #endif |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 6733 | /* It is possible that the caller of this function does not |
| 6734 | * wish to close the session |
| 6735 | */ |
| 6736 | if (VOS_TRUE == bCloseSession && |
| 6737 | test_bit(SME_SESSION_OPENED, &pAdapter->event_flags)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6738 | { |
| 6739 | INIT_COMPLETION(pAdapter->session_close_comp_var); |
| 6740 | if (eHAL_STATUS_SUCCESS == |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 6741 | sme_CloseSession(pHddCtx->hHal, pAdapter->sessionId, |
| 6742 | hdd_smeCloseSessionCallback, pAdapter)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6743 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6744 | unsigned long ret; |
| 6745 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6746 | //Block on a completion variable. Can't wait forever though. |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6747 | ret = wait_for_completion_timeout( |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 6748 | &pAdapter->session_close_comp_var, |
| 6749 | msecs_to_jiffies(WLAN_WAIT_TIME_SESSIONOPENCLOSE)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6750 | if ( 0 >= ret) |
| 6751 | { |
| 6752 | hddLog(LOGE, "%s: failure waiting for session_close_comp_var %ld", |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 6753 | __func__, ret); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6754 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6755 | } |
| 6756 | } |
Vinay Krishna Eranna | b09d3e7 | 2014-03-26 21:23:55 +0530 | [diff] [blame] | 6757 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6758 | break; |
| 6759 | |
| 6760 | case WLAN_HDD_SOFTAP: |
| 6761 | case WLAN_HDD_P2P_GO: |
| 6762 | //Any softap specific cleanup here... |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 6763 | if (pAdapter->device_mode == WLAN_HDD_P2P_GO) { |
| 6764 | while (pAdapter->is_roc_inprogress) { |
| 6765 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6766 | "%s: ROC in progress for session %d!!!", |
| 6767 | __func__, pAdapter->sessionId); |
| 6768 | msleep(500); |
| 6769 | if ( retry++ > MAX_WAIT_FOR_ROC_COMPLETION ) { |
| 6770 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6771 | "%s: ROC completion is not received.!!!", __func__); |
| 6772 | WLANSAP_CancelRemainOnChannel( |
| 6773 | (WLAN_HDD_GET_CTX(pAdapter))->pvosContext); |
| 6774 | wait_for_completion_interruptible_timeout( |
| 6775 | &pAdapter->cancel_rem_on_chan_var, |
| 6776 | msecs_to_jiffies(WAIT_CANCEL_REM_CHAN)); |
| 6777 | break; |
| 6778 | } |
| 6779 | } |
| 6780 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6781 | mutex_lock(&pHddCtx->sap_lock); |
| 6782 | if (test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags)) |
| 6783 | { |
| 6784 | VOS_STATUS status; |
| 6785 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 6786 | |
| 6787 | //Stop Bss. |
| 6788 | status = WLANSAP_StopBss(pHddCtx->pvosContext); |
| 6789 | if (VOS_IS_STATUS_SUCCESS(status)) |
| 6790 | { |
| 6791 | hdd_hostapd_state_t *pHostapdState = |
| 6792 | WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 6793 | |
| 6794 | status = vos_wait_single_event(&pHostapdState->vosEvent, 10000); |
| 6795 | |
| 6796 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 6797 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6798 | hddLog(LOGE, "%s: failure waiting for WLANSAP_StopBss %d", |
| 6799 | __func__, status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6800 | } |
| 6801 | } |
| 6802 | else |
| 6803 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 6804 | hddLog(LOGE, "%s: failure in WLANSAP_StopBss", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6805 | } |
| 6806 | clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags); |
| 6807 | |
| 6808 | if (eHAL_STATUS_FAILURE == |
| 6809 | ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, |
| 6810 | 0, NULL, eANI_BOOLEAN_FALSE)) |
| 6811 | { |
| 6812 | hddLog(LOGE, |
| 6813 | "%s: Failed to set WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 6814 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6815 | } |
| 6816 | |
| 6817 | if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal, |
| 6818 | WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL, |
| 6819 | eANI_BOOLEAN_FALSE) ) |
| 6820 | { |
| 6821 | hddLog(LOGE, |
| 6822 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM"); |
| 6823 | } |
| 6824 | |
| 6825 | // Reset WNI_CFG_PROBE_RSP Flags |
| 6826 | wlan_hdd_reset_prob_rspies(pAdapter); |
| 6827 | kfree(pAdapter->sessionCtx.ap.beacon); |
| 6828 | pAdapter->sessionCtx.ap.beacon = NULL; |
| 6829 | } |
| 6830 | mutex_unlock(&pHddCtx->sap_lock); |
| 6831 | break; |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 6832 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6833 | case WLAN_HDD_MONITOR: |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 6834 | #ifdef WLAN_OPEN_SOURCE |
| 6835 | cancel_work_sync(&pAdapter->sessionCtx.monitor.pAdapterForTx->monTxWorkQueue); |
| 6836 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6837 | break; |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 6838 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6839 | default: |
| 6840 | break; |
| 6841 | } |
| 6842 | |
| 6843 | EXIT(); |
| 6844 | return VOS_STATUS_SUCCESS; |
| 6845 | } |
| 6846 | |
| 6847 | VOS_STATUS hdd_stop_all_adapters( hdd_context_t *pHddCtx ) |
| 6848 | { |
| 6849 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 6850 | VOS_STATUS status; |
| 6851 | hdd_adapter_t *pAdapter; |
| 6852 | |
| 6853 | ENTER(); |
| 6854 | |
| 6855 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 6856 | |
| 6857 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 6858 | { |
| 6859 | pAdapter = pAdapterNode->pAdapter; |
| 6860 | netif_tx_disable(pAdapter->dev); |
| 6861 | netif_carrier_off(pAdapter->dev); |
| 6862 | |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 6863 | hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6864 | |
| 6865 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 6866 | pAdapterNode = pNext; |
| 6867 | } |
| 6868 | |
| 6869 | EXIT(); |
| 6870 | |
| 6871 | return VOS_STATUS_SUCCESS; |
| 6872 | } |
| 6873 | |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 6874 | |
| 6875 | #ifdef FEATURE_WLAN_BATCH_SCAN |
| 6876 | /**--------------------------------------------------------------------------- |
| 6877 | |
| 6878 | \brief hdd_deinit_batch_scan () - This function cleans up batch scan data |
| 6879 | structures |
| 6880 | |
| 6881 | \param - pAdapter Pointer to HDD adapter |
| 6882 | |
| 6883 | \return - None |
| 6884 | |
| 6885 | --------------------------------------------------------------------------*/ |
| 6886 | void hdd_deinit_batch_scan(hdd_adapter_t *pAdapter) |
| 6887 | { |
| 6888 | tHddBatchScanRsp *pNode; |
| 6889 | tHddBatchScanRsp *pPrev; |
| 6890 | |
Siddharth Bhal | b3e9b79 | 2014-02-24 15:14:16 +0530 | [diff] [blame] | 6891 | if (NULL == pAdapter) |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 6892 | { |
Siddharth Bhal | b3e9b79 | 2014-02-24 15:14:16 +0530 | [diff] [blame] | 6893 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6894 | "%s: Adapter context is Null", __func__); |
| 6895 | return; |
| 6896 | } |
| 6897 | |
| 6898 | pNode = pAdapter->pBatchScanRsp; |
| 6899 | while (pNode) |
| 6900 | { |
| 6901 | pPrev = pNode; |
| 6902 | pNode = pNode->pNext; |
| 6903 | vos_mem_free((v_VOID_t * )pPrev); |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 6904 | } |
| 6905 | |
| 6906 | pAdapter->pBatchScanRsp = NULL; |
| 6907 | pAdapter->numScanList = 0; |
| 6908 | pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STOPPED; |
| 6909 | pAdapter->prev_batch_id = 0; |
| 6910 | |
| 6911 | return; |
| 6912 | } |
| 6913 | #endif |
| 6914 | |
| 6915 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6916 | VOS_STATUS hdd_reset_all_adapters( hdd_context_t *pHddCtx ) |
| 6917 | { |
| 6918 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 6919 | VOS_STATUS status; |
| 6920 | hdd_adapter_t *pAdapter; |
| 6921 | |
| 6922 | ENTER(); |
| 6923 | |
| 6924 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 6925 | |
| 6926 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 6927 | { |
| 6928 | pAdapter = pAdapterNode->pAdapter; |
| 6929 | netif_tx_disable(pAdapter->dev); |
| 6930 | netif_carrier_off(pAdapter->dev); |
| 6931 | |
Srinivas Girigowda | 66c05eb | 2013-07-14 13:06:01 -0700 | [diff] [blame] | 6932 | pAdapter->sessionCtx.station.hdd_ReassocScenario = VOS_FALSE; |
| 6933 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6934 | hdd_deinit_tx_rx(pAdapter); |
Madan Mohan Koyyalamudi | 8c6dec8 | 2013-09-26 15:56:13 +0530 | [diff] [blame] | 6935 | if (test_bit(WMM_INIT_DONE, &pAdapter->event_flags)) |
| 6936 | { |
| 6937 | hdd_wmm_adapter_close( pAdapter ); |
| 6938 | clear_bit(WMM_INIT_DONE, &pAdapter->event_flags); |
| 6939 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6940 | |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 6941 | #ifdef FEATURE_WLAN_BATCH_SCAN |
| 6942 | if (eHDD_BATCH_SCAN_STATE_STARTED == pAdapter->batchScanState) |
| 6943 | { |
| 6944 | hdd_deinit_batch_scan(pAdapter); |
| 6945 | } |
| 6946 | #endif |
| 6947 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6948 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 6949 | pAdapterNode = pNext; |
| 6950 | } |
| 6951 | |
| 6952 | EXIT(); |
| 6953 | |
| 6954 | return VOS_STATUS_SUCCESS; |
| 6955 | } |
| 6956 | |
| 6957 | VOS_STATUS hdd_start_all_adapters( hdd_context_t *pHddCtx ) |
| 6958 | { |
| 6959 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 6960 | VOS_STATUS status; |
| 6961 | hdd_adapter_t *pAdapter; |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 6962 | eConnectionState connState; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6963 | |
| 6964 | ENTER(); |
| 6965 | |
| 6966 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 6967 | |
| 6968 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 6969 | { |
| 6970 | pAdapter = pAdapterNode->pAdapter; |
| 6971 | |
Kumar Anand | 82c009f | 2014-05-29 00:29:42 -0700 | [diff] [blame] | 6972 | hdd_wmm_init( pAdapter ); |
| 6973 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6974 | switch(pAdapter->device_mode) |
| 6975 | { |
| 6976 | case WLAN_HDD_INFRA_STATION: |
| 6977 | case WLAN_HDD_P2P_CLIENT: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6978 | case WLAN_HDD_P2P_DEVICE: |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 6979 | |
| 6980 | connState = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState; |
| 6981 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6982 | hdd_init_station_mode(pAdapter); |
| 6983 | /* Open the gates for HDD to receive Wext commands */ |
| 6984 | pAdapter->isLinkUpSvcNeeded = FALSE; |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 6985 | pHddCtx->scan_info.mScanPending = FALSE; |
| 6986 | pHddCtx->scan_info.waitScanResult = FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6987 | |
| 6988 | //Trigger the initial scan |
| 6989 | hdd_wlan_initial_scan(pAdapter); |
| 6990 | |
| 6991 | //Indicate disconnect event to supplicant if associated previously |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 6992 | if (eConnectionState_Associated == connState || |
| 6993 | eConnectionState_IbssConnected == connState ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6994 | { |
| 6995 | union iwreq_data wrqu; |
| 6996 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 6997 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 6998 | memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN); |
| 6999 | wireless_send_event(pAdapter->dev, SIOCGIWAP, &wrqu, NULL); |
Srinivas Girigowda | 66c05eb | 2013-07-14 13:06:01 -0700 | [diff] [blame] | 7000 | pAdapter->sessionCtx.station.hdd_ReassocScenario = VOS_FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7001 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7002 | /* indicate disconnected event to nl80211 */ |
| 7003 | cfg80211_disconnected(pAdapter->dev, WLAN_REASON_UNSPECIFIED, |
| 7004 | NULL, 0, GFP_KERNEL); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7005 | } |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 7006 | else if (eConnectionState_Connecting == connState) |
| 7007 | { |
| 7008 | /* |
| 7009 | * Indicate connect failure to supplicant if we were in the |
| 7010 | * process of connecting |
| 7011 | */ |
| 7012 | cfg80211_connect_result(pAdapter->dev, NULL, |
| 7013 | NULL, 0, NULL, 0, |
| 7014 | WLAN_STATUS_ASSOC_DENIED_UNSPEC, |
| 7015 | GFP_KERNEL); |
| 7016 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7017 | break; |
| 7018 | |
| 7019 | case WLAN_HDD_SOFTAP: |
| 7020 | /* softAP can handle SSR */ |
| 7021 | break; |
| 7022 | |
| 7023 | case WLAN_HDD_P2P_GO: |
Sameer Thalappil | edf0d79 | 2013-08-09 14:31:03 -0700 | [diff] [blame] | 7024 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s [SSR] send stop ap to supplicant", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7025 | __func__); |
Sameer Thalappil | edf0d79 | 2013-08-09 14:31:03 -0700 | [diff] [blame] | 7026 | cfg80211_ap_stopped(pAdapter->dev, GFP_KERNEL); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7027 | break; |
| 7028 | |
| 7029 | case WLAN_HDD_MONITOR: |
| 7030 | /* monitor interface start */ |
| 7031 | break; |
| 7032 | default: |
| 7033 | break; |
| 7034 | } |
| 7035 | |
| 7036 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7037 | pAdapterNode = pNext; |
| 7038 | } |
| 7039 | |
| 7040 | EXIT(); |
| 7041 | |
| 7042 | return VOS_STATUS_SUCCESS; |
| 7043 | } |
| 7044 | |
| 7045 | VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx ) |
| 7046 | { |
| 7047 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7048 | hdd_adapter_t *pAdapter; |
| 7049 | VOS_STATUS status; |
| 7050 | v_U32_t roamId; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7051 | long ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7052 | |
| 7053 | ENTER(); |
| 7054 | |
| 7055 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7056 | |
| 7057 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7058 | { |
| 7059 | pAdapter = pAdapterNode->pAdapter; |
| 7060 | |
| 7061 | if( (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
| 7062 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ) |
| 7063 | { |
| 7064 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 7065 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 7066 | |
Abhishek Singh | f4669da | 2014-05-26 15:07:49 +0530 | [diff] [blame] | 7067 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 7068 | "%s: Set HDD connState to eConnectionState_NotConnected", |
| 7069 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7070 | pHddStaCtx->conn_info.connState = eConnectionState_NotConnected; |
| 7071 | init_completion(&pAdapter->disconnect_comp_var); |
| 7072 | sme_RoamDisconnect(pHddCtx->hHal, pAdapter->sessionId, |
| 7073 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
| 7074 | |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7075 | ret = wait_for_completion_interruptible_timeout( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7076 | &pAdapter->disconnect_comp_var, |
| 7077 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7078 | if (0 >= ret) |
| 7079 | hddLog(LOGE, "%s: failure waiting for disconnect_comp_var %ld", |
| 7080 | __func__, ret); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7081 | |
| 7082 | pWextState->roamProfile.csrPersona = pAdapter->device_mode; |
| 7083 | pHddCtx->isAmpAllowed = VOS_FALSE; |
| 7084 | sme_RoamConnect(pHddCtx->hHal, |
| 7085 | pAdapter->sessionId, &(pWextState->roamProfile), |
| 7086 | &roamId); |
| 7087 | } |
| 7088 | |
| 7089 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7090 | pAdapterNode = pNext; |
| 7091 | } |
| 7092 | |
| 7093 | EXIT(); |
| 7094 | |
| 7095 | return VOS_STATUS_SUCCESS; |
| 7096 | } |
| 7097 | |
Sudhir Sattayappa Kohalli | 90e4c75 | 2013-03-21 14:25:04 -0700 | [diff] [blame] | 7098 | void hdd_dump_concurrency_info(hdd_context_t *pHddCtx) |
| 7099 | { |
| 7100 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7101 | VOS_STATUS status; |
| 7102 | hdd_adapter_t *pAdapter; |
| 7103 | hdd_station_ctx_t *pHddStaCtx; |
| 7104 | hdd_ap_ctx_t *pHddApCtx; |
| 7105 | hdd_hostapd_state_t * pHostapdState; |
| 7106 | tCsrBssid staBssid = { 0 }, p2pBssid = { 0 }, apBssid = { 0 }; |
| 7107 | v_U8_t staChannel = 0, p2pChannel = 0, apChannel = 0; |
| 7108 | const char *p2pMode = "DEV"; |
| 7109 | const char *ccMode = "Standalone"; |
| 7110 | int n; |
| 7111 | |
| 7112 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7113 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7114 | { |
| 7115 | pAdapter = pAdapterNode->pAdapter; |
| 7116 | switch (pAdapter->device_mode) { |
| 7117 | case WLAN_HDD_INFRA_STATION: |
| 7118 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 7119 | if (eConnectionState_Associated == pHddStaCtx->conn_info.connState) { |
| 7120 | staChannel = pHddStaCtx->conn_info.operationChannel; |
| 7121 | memcpy(staBssid, pHddStaCtx->conn_info.bssId, sizeof(staBssid)); |
| 7122 | } |
| 7123 | break; |
| 7124 | case WLAN_HDD_P2P_CLIENT: |
| 7125 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 7126 | if (eConnectionState_Associated == pHddStaCtx->conn_info.connState) { |
| 7127 | p2pChannel = pHddStaCtx->conn_info.operationChannel; |
| 7128 | memcpy(p2pBssid, pHddStaCtx->conn_info.bssId, sizeof(p2pBssid)); |
| 7129 | p2pMode = "CLI"; |
| 7130 | } |
| 7131 | break; |
| 7132 | case WLAN_HDD_P2P_GO: |
| 7133 | pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
| 7134 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 7135 | if (pHostapdState->bssState == BSS_START && pHostapdState->vosStatus==VOS_STATUS_SUCCESS) { |
| 7136 | p2pChannel = pHddApCtx->operatingChannel; |
| 7137 | memcpy(p2pBssid, pAdapter->macAddressCurrent.bytes, sizeof(p2pBssid)); |
| 7138 | } |
| 7139 | p2pMode = "GO"; |
| 7140 | break; |
| 7141 | case WLAN_HDD_SOFTAP: |
| 7142 | pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
| 7143 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 7144 | if (pHostapdState->bssState == BSS_START && pHostapdState->vosStatus==VOS_STATUS_SUCCESS) { |
| 7145 | apChannel = pHddApCtx->operatingChannel; |
| 7146 | memcpy(apBssid, pAdapter->macAddressCurrent.bytes, sizeof(apBssid)); |
| 7147 | } |
| 7148 | break; |
| 7149 | default: |
| 7150 | break; |
| 7151 | } |
| 7152 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7153 | pAdapterNode = pNext; |
| 7154 | } |
| 7155 | if (staChannel > 0 && (apChannel > 0 || p2pChannel > 0)) { |
| 7156 | ccMode = (p2pChannel==staChannel||apChannel==staChannel) ? "SCC" : "MCC"; |
| 7157 | } |
| 7158 | n = pr_info("wlan(%d) " MAC_ADDRESS_STR " %s", |
| 7159 | staChannel, MAC_ADDR_ARRAY(staBssid), ccMode); |
| 7160 | if (p2pChannel > 0) { |
| 7161 | n += pr_info("p2p-%s(%d) " MAC_ADDRESS_STR, |
| 7162 | p2pMode, p2pChannel, MAC_ADDR_ARRAY(p2pBssid)); |
| 7163 | } |
| 7164 | if (apChannel > 0) { |
| 7165 | n += pr_info("AP(%d) " MAC_ADDRESS_STR, |
| 7166 | apChannel, MAC_ADDR_ARRAY(apBssid)); |
| 7167 | } |
| 7168 | |
| 7169 | if (p2pChannel > 0 && apChannel > 0) { |
| 7170 | hddLog(VOS_TRACE_LEVEL_ERROR, "Error concurrent SAP %d and P2P %d which is not support", apChannel, p2pChannel); |
| 7171 | } |
| 7172 | } |
| 7173 | |
Madan Mohan Koyyalamudi | b5da533 | 2012-10-15 17:23:21 -0700 | [diff] [blame] | 7174 | bool hdd_is_ssr_required( void) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7175 | { |
Madan Mohan Koyyalamudi | b5da533 | 2012-10-15 17:23:21 -0700 | [diff] [blame] | 7176 | return (isSsrRequired == HDD_SSR_REQUIRED); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7177 | } |
| 7178 | |
Madan Mohan Koyyalamudi | b5da533 | 2012-10-15 17:23:21 -0700 | [diff] [blame] | 7179 | /* Once SSR is disabled then it cannot be set. */ |
| 7180 | void hdd_set_ssr_required( e_hdd_ssr_required value) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7181 | { |
Madan Mohan Koyyalamudi | b5da533 | 2012-10-15 17:23:21 -0700 | [diff] [blame] | 7182 | if (HDD_SSR_DISABLED == isSsrRequired) |
| 7183 | return; |
| 7184 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7185 | isSsrRequired = value; |
| 7186 | } |
| 7187 | |
| 7188 | VOS_STATUS hdd_get_front_adapter( hdd_context_t *pHddCtx, |
| 7189 | hdd_adapter_list_node_t** ppAdapterNode) |
| 7190 | { |
| 7191 | VOS_STATUS status; |
| 7192 | spin_lock(&pHddCtx->hddAdapters.lock); |
| 7193 | status = hdd_list_peek_front ( &pHddCtx->hddAdapters, |
| 7194 | (hdd_list_node_t**) ppAdapterNode ); |
| 7195 | spin_unlock(&pHddCtx->hddAdapters.lock); |
| 7196 | return status; |
| 7197 | } |
| 7198 | |
| 7199 | VOS_STATUS hdd_get_next_adapter( hdd_context_t *pHddCtx, |
| 7200 | hdd_adapter_list_node_t* pAdapterNode, |
| 7201 | hdd_adapter_list_node_t** pNextAdapterNode) |
| 7202 | { |
| 7203 | VOS_STATUS status; |
| 7204 | spin_lock(&pHddCtx->hddAdapters.lock); |
| 7205 | status = hdd_list_peek_next ( &pHddCtx->hddAdapters, |
| 7206 | (hdd_list_node_t*) pAdapterNode, |
| 7207 | (hdd_list_node_t**)pNextAdapterNode ); |
| 7208 | |
| 7209 | spin_unlock(&pHddCtx->hddAdapters.lock); |
| 7210 | return status; |
| 7211 | } |
| 7212 | |
| 7213 | VOS_STATUS hdd_remove_adapter( hdd_context_t *pHddCtx, |
| 7214 | hdd_adapter_list_node_t* pAdapterNode) |
| 7215 | { |
| 7216 | VOS_STATUS status; |
| 7217 | spin_lock(&pHddCtx->hddAdapters.lock); |
| 7218 | status = hdd_list_remove_node ( &pHddCtx->hddAdapters, |
| 7219 | &pAdapterNode->node ); |
| 7220 | spin_unlock(&pHddCtx->hddAdapters.lock); |
| 7221 | return status; |
| 7222 | } |
| 7223 | |
| 7224 | VOS_STATUS hdd_remove_front_adapter( hdd_context_t *pHddCtx, |
| 7225 | hdd_adapter_list_node_t** ppAdapterNode) |
| 7226 | { |
| 7227 | VOS_STATUS status; |
| 7228 | spin_lock(&pHddCtx->hddAdapters.lock); |
| 7229 | status = hdd_list_remove_front( &pHddCtx->hddAdapters, |
| 7230 | (hdd_list_node_t**) ppAdapterNode ); |
| 7231 | spin_unlock(&pHddCtx->hddAdapters.lock); |
| 7232 | return status; |
| 7233 | } |
| 7234 | |
| 7235 | VOS_STATUS hdd_add_adapter_back( hdd_context_t *pHddCtx, |
| 7236 | hdd_adapter_list_node_t* pAdapterNode) |
| 7237 | { |
| 7238 | VOS_STATUS status; |
| 7239 | spin_lock(&pHddCtx->hddAdapters.lock); |
| 7240 | status = hdd_list_insert_back ( &pHddCtx->hddAdapters, |
| 7241 | (hdd_list_node_t*) pAdapterNode ); |
| 7242 | spin_unlock(&pHddCtx->hddAdapters.lock); |
| 7243 | return status; |
| 7244 | } |
| 7245 | |
| 7246 | VOS_STATUS hdd_add_adapter_front( hdd_context_t *pHddCtx, |
| 7247 | hdd_adapter_list_node_t* pAdapterNode) |
| 7248 | { |
| 7249 | VOS_STATUS status; |
| 7250 | spin_lock(&pHddCtx->hddAdapters.lock); |
| 7251 | status = hdd_list_insert_front ( &pHddCtx->hddAdapters, |
| 7252 | (hdd_list_node_t*) pAdapterNode ); |
| 7253 | spin_unlock(&pHddCtx->hddAdapters.lock); |
| 7254 | return status; |
| 7255 | } |
| 7256 | |
| 7257 | hdd_adapter_t * hdd_get_adapter_by_macaddr( hdd_context_t *pHddCtx, |
| 7258 | tSirMacAddr macAddr ) |
| 7259 | { |
| 7260 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7261 | hdd_adapter_t *pAdapter; |
| 7262 | VOS_STATUS status; |
| 7263 | |
| 7264 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7265 | |
| 7266 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7267 | { |
| 7268 | pAdapter = pAdapterNode->pAdapter; |
| 7269 | |
| 7270 | if( pAdapter && vos_mem_compare( pAdapter->macAddressCurrent.bytes, |
| 7271 | macAddr, sizeof(tSirMacAddr) ) ) |
| 7272 | { |
| 7273 | return pAdapter; |
| 7274 | } |
| 7275 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7276 | pAdapterNode = pNext; |
| 7277 | } |
| 7278 | |
| 7279 | return NULL; |
| 7280 | |
| 7281 | } |
| 7282 | |
| 7283 | hdd_adapter_t * hdd_get_adapter_by_name( hdd_context_t *pHddCtx, tANI_U8 *name ) |
| 7284 | { |
| 7285 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7286 | hdd_adapter_t *pAdapter; |
| 7287 | VOS_STATUS status; |
| 7288 | |
| 7289 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7290 | |
| 7291 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7292 | { |
| 7293 | pAdapter = pAdapterNode->pAdapter; |
| 7294 | |
| 7295 | if( pAdapter && !strncmp( pAdapter->dev->name, (const char *)name, |
| 7296 | IFNAMSIZ ) ) |
| 7297 | { |
| 7298 | return pAdapter; |
| 7299 | } |
| 7300 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7301 | pAdapterNode = pNext; |
| 7302 | } |
| 7303 | |
| 7304 | return NULL; |
| 7305 | |
| 7306 | } |
| 7307 | |
| 7308 | hdd_adapter_t * hdd_get_adapter( hdd_context_t *pHddCtx, device_mode_t mode ) |
| 7309 | { |
| 7310 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7311 | hdd_adapter_t *pAdapter; |
| 7312 | VOS_STATUS status; |
| 7313 | |
| 7314 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7315 | |
| 7316 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7317 | { |
| 7318 | pAdapter = pAdapterNode->pAdapter; |
| 7319 | |
| 7320 | if( pAdapter && (mode == pAdapter->device_mode) ) |
| 7321 | { |
| 7322 | return pAdapter; |
| 7323 | } |
| 7324 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7325 | pAdapterNode = pNext; |
| 7326 | } |
| 7327 | |
| 7328 | return NULL; |
| 7329 | |
| 7330 | } |
| 7331 | |
| 7332 | //Remove this function later |
| 7333 | hdd_adapter_t * hdd_get_mon_adapter( hdd_context_t *pHddCtx ) |
| 7334 | { |
| 7335 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7336 | hdd_adapter_t *pAdapter; |
| 7337 | VOS_STATUS status; |
| 7338 | |
| 7339 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7340 | |
| 7341 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7342 | { |
| 7343 | pAdapter = pAdapterNode->pAdapter; |
| 7344 | |
| 7345 | if( pAdapter && WLAN_HDD_MONITOR == pAdapter->device_mode ) |
| 7346 | { |
| 7347 | return pAdapter; |
| 7348 | } |
| 7349 | |
| 7350 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7351 | pAdapterNode = pNext; |
| 7352 | } |
| 7353 | |
| 7354 | return NULL; |
| 7355 | |
| 7356 | } |
| 7357 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7358 | /**--------------------------------------------------------------------------- |
| 7359 | |
| 7360 | \brief hdd_set_monitor_tx_adapter() - |
| 7361 | |
| 7362 | This API initializes the adapter to be used while transmitting on monitor |
| 7363 | adapter. |
| 7364 | |
| 7365 | \param - pHddCtx - Pointer to the HDD context. |
| 7366 | pAdapter - Adapter that will used for TX. This can be NULL. |
| 7367 | \return - None. |
| 7368 | --------------------------------------------------------------------------*/ |
| 7369 | void wlan_hdd_set_monitor_tx_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter ) |
| 7370 | { |
| 7371 | hdd_adapter_t *pMonAdapter; |
| 7372 | |
| 7373 | pMonAdapter = hdd_get_adapter( pHddCtx, WLAN_HDD_MONITOR ); |
| 7374 | |
| 7375 | if( NULL != pMonAdapter ) |
| 7376 | { |
| 7377 | pMonAdapter->sessionCtx.monitor.pAdapterForTx = pAdapter; |
| 7378 | } |
| 7379 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7380 | /**--------------------------------------------------------------------------- |
| 7381 | |
| 7382 | \brief hdd_select_queue() - |
| 7383 | |
| 7384 | This API returns the operating channel of the requested device mode |
| 7385 | |
| 7386 | \param - pHddCtx - Pointer to the HDD context. |
| 7387 | - mode - Device mode for which operating channel is required |
| 7388 | suported modes - WLAN_HDD_INFRA_STATION, WLAN_HDD_P2P_CLIENT |
| 7389 | WLAN_HDD_SOFTAP, WLAN_HDD_P2P_GO. |
| 7390 | \return - channel number. "0" id the requested device is not found OR it is not connected. |
| 7391 | --------------------------------------------------------------------------*/ |
| 7392 | v_U8_t hdd_get_operating_channel( hdd_context_t *pHddCtx, device_mode_t mode ) |
| 7393 | { |
| 7394 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7395 | VOS_STATUS status; |
| 7396 | hdd_adapter_t *pAdapter; |
| 7397 | v_U8_t operatingChannel = 0; |
| 7398 | |
| 7399 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7400 | |
| 7401 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7402 | { |
| 7403 | pAdapter = pAdapterNode->pAdapter; |
| 7404 | |
| 7405 | if( mode == pAdapter->device_mode ) |
| 7406 | { |
| 7407 | switch(pAdapter->device_mode) |
| 7408 | { |
| 7409 | case WLAN_HDD_INFRA_STATION: |
| 7410 | case WLAN_HDD_P2P_CLIENT: |
| 7411 | if( hdd_connIsConnected( WLAN_HDD_GET_STATION_CTX_PTR( pAdapter )) ) |
| 7412 | operatingChannel = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.operationChannel; |
| 7413 | break; |
| 7414 | case WLAN_HDD_SOFTAP: |
| 7415 | case WLAN_HDD_P2P_GO: |
| 7416 | /*softap connection info */ |
| 7417 | if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags)) |
| 7418 | operatingChannel = (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->operatingChannel; |
| 7419 | break; |
| 7420 | default: |
| 7421 | break; |
| 7422 | } |
| 7423 | |
| 7424 | break; //Found the device of interest. break the loop |
| 7425 | } |
| 7426 | |
| 7427 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7428 | pAdapterNode = pNext; |
| 7429 | } |
| 7430 | return operatingChannel; |
| 7431 | } |
| 7432 | |
| 7433 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 7434 | /**--------------------------------------------------------------------------- |
| 7435 | |
| 7436 | \brief hdd_set_multicast_list() - |
| 7437 | |
| 7438 | This used to set the multicast address list. |
| 7439 | |
| 7440 | \param - dev - Pointer to the WLAN device. |
| 7441 | - skb - Pointer to OS packet (sk_buff). |
| 7442 | \return - success/fail |
| 7443 | |
| 7444 | --------------------------------------------------------------------------*/ |
| 7445 | static void hdd_set_multicast_list(struct net_device *dev) |
| 7446 | { |
| 7447 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7448 | int mc_count; |
| 7449 | int i = 0; |
| 7450 | struct netdev_hw_addr *ha; |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 7451 | |
| 7452 | if (NULL == pAdapter) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7453 | { |
| 7454 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 7455 | "%s: Adapter context is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7456 | return; |
| 7457 | } |
| 7458 | |
| 7459 | if (dev->flags & IFF_ALLMULTI) |
| 7460 | { |
| 7461 | hddLog(VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7462 | "%s: allow all multicast frames", __func__); |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 7463 | pAdapter->mc_addr_list.mc_cnt = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7464 | } |
| 7465 | else |
| 7466 | { |
| 7467 | mc_count = netdev_mc_count(dev); |
| 7468 | hddLog(VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7469 | "%s: mc_count = %u", __func__, mc_count); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7470 | if (mc_count > WLAN_HDD_MAX_MC_ADDR_LIST) |
| 7471 | { |
| 7472 | hddLog(VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7473 | "%s: No free filter available; allow all multicast frames", __func__); |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 7474 | pAdapter->mc_addr_list.mc_cnt = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7475 | return; |
| 7476 | } |
| 7477 | |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 7478 | pAdapter->mc_addr_list.mc_cnt = mc_count; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7479 | |
| 7480 | netdev_for_each_mc_addr(ha, dev) { |
| 7481 | if (i == mc_count) |
| 7482 | break; |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 7483 | memset(&(pAdapter->mc_addr_list.addr[i][0]), 0, ETH_ALEN); |
| 7484 | memcpy(&(pAdapter->mc_addr_list.addr[i][0]), ha->addr, ETH_ALEN); |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 7485 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: mlist[%d] = "MAC_ADDRESS_STR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7486 | __func__, i, |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 7487 | MAC_ADDR_ARRAY(pAdapter->mc_addr_list.addr[i])); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7488 | i++; |
| 7489 | } |
| 7490 | } |
| 7491 | return; |
| 7492 | } |
| 7493 | #endif |
| 7494 | |
| 7495 | /**--------------------------------------------------------------------------- |
| 7496 | |
| 7497 | \brief hdd_select_queue() - |
| 7498 | |
| 7499 | This function is registered with the Linux OS for network |
| 7500 | core to decide which queue to use first. |
| 7501 | |
| 7502 | \param - dev - Pointer to the WLAN device. |
| 7503 | - skb - Pointer to OS packet (sk_buff). |
| 7504 | \return - ac, Queue Index/access category corresponding to UP in IP header |
| 7505 | |
| 7506 | --------------------------------------------------------------------------*/ |
| 7507 | v_U16_t hdd_select_queue(struct net_device *dev, |
| 7508 | struct sk_buff *skb) |
| 7509 | { |
| 7510 | return hdd_wmm_select_queue(dev, skb); |
| 7511 | } |
| 7512 | |
| 7513 | |
| 7514 | /**--------------------------------------------------------------------------- |
| 7515 | |
| 7516 | \brief hdd_wlan_initial_scan() - |
| 7517 | |
| 7518 | This function triggers the initial scan |
| 7519 | |
| 7520 | \param - pAdapter - Pointer to the HDD adapter. |
| 7521 | |
| 7522 | --------------------------------------------------------------------------*/ |
| 7523 | void hdd_wlan_initial_scan(hdd_adapter_t *pAdapter) |
| 7524 | { |
| 7525 | tCsrScanRequest scanReq; |
| 7526 | tCsrChannelInfo channelInfo; |
| 7527 | eHalStatus halStatus; |
Jeff Johnson | 0279779 | 2013-10-26 19:17:13 -0700 | [diff] [blame] | 7528 | tANI_U32 scanId; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7529 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 7530 | |
| 7531 | vos_mem_zero(&scanReq, sizeof(tCsrScanRequest)); |
| 7532 | vos_mem_set(&scanReq.bssid, sizeof(tCsrBssid), 0xff); |
| 7533 | scanReq.BSSType = eCSR_BSS_TYPE_ANY; |
| 7534 | |
| 7535 | if(sme_Is11dSupported(pHddCtx->hHal)) |
| 7536 | { |
| 7537 | halStatus = sme_ScanGetBaseChannels( pHddCtx->hHal, &channelInfo ); |
| 7538 | if ( HAL_STATUS_SUCCESS( halStatus ) ) |
| 7539 | { |
| 7540 | scanReq.ChannelInfo.ChannelList = vos_mem_malloc(channelInfo.numOfChannels); |
| 7541 | if( !scanReq.ChannelInfo.ChannelList ) |
| 7542 | { |
| 7543 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s kmalloc failed", __func__); |
| 7544 | vos_mem_free(channelInfo.ChannelList); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 7545 | channelInfo.ChannelList = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7546 | return; |
| 7547 | } |
| 7548 | vos_mem_copy(scanReq.ChannelInfo.ChannelList, channelInfo.ChannelList, |
| 7549 | channelInfo.numOfChannels); |
| 7550 | scanReq.ChannelInfo.numOfChannels = channelInfo.numOfChannels; |
| 7551 | vos_mem_free(channelInfo.ChannelList); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 7552 | channelInfo.ChannelList = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7553 | } |
| 7554 | |
| 7555 | scanReq.scanType = eSIR_PASSIVE_SCAN; |
| 7556 | scanReq.requestType = eCSR_SCAN_REQUEST_11D_SCAN; |
| 7557 | scanReq.maxChnTime = pHddCtx->cfg_ini->nPassiveMaxChnTime; |
| 7558 | scanReq.minChnTime = pHddCtx->cfg_ini->nPassiveMinChnTime; |
| 7559 | } |
| 7560 | else |
| 7561 | { |
| 7562 | scanReq.scanType = eSIR_ACTIVE_SCAN; |
| 7563 | scanReq.requestType = eCSR_SCAN_REQUEST_FULL_SCAN; |
| 7564 | scanReq.maxChnTime = pHddCtx->cfg_ini->nActiveMaxChnTime; |
| 7565 | scanReq.minChnTime = pHddCtx->cfg_ini->nActiveMinChnTime; |
| 7566 | } |
| 7567 | |
| 7568 | halStatus = sme_ScanRequest(pHddCtx->hHal, pAdapter->sessionId, &scanReq, &scanId, NULL, NULL); |
| 7569 | if ( !HAL_STATUS_SUCCESS( halStatus ) ) |
| 7570 | { |
| 7571 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_ScanRequest failed status code %d", |
| 7572 | __func__, halStatus ); |
| 7573 | } |
| 7574 | |
| 7575 | if(sme_Is11dSupported(pHddCtx->hHal)) |
| 7576 | vos_mem_free(scanReq.ChannelInfo.ChannelList); |
| 7577 | } |
| 7578 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7579 | /**--------------------------------------------------------------------------- |
| 7580 | |
| 7581 | \brief hdd_full_power_callback() - HDD full power callback function |
| 7582 | |
| 7583 | This is the function invoked by SME to inform the result of a full power |
| 7584 | request issued by HDD |
| 7585 | |
| 7586 | \param - callbackcontext - Pointer to cookie |
| 7587 | \param - status - result of request |
| 7588 | |
| 7589 | \return - None |
| 7590 | |
| 7591 | --------------------------------------------------------------------------*/ |
| 7592 | static void hdd_full_power_callback(void *callbackContext, eHalStatus status) |
| 7593 | { |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 7594 | struct statsContext *pContext = callbackContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7595 | |
| 7596 | hddLog(VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 7597 | "%s: context = %p, status = %d", __func__, pContext, status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7598 | |
| 7599 | if (NULL == callbackContext) |
| 7600 | { |
| 7601 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 7602 | "%s: Bad param, context [%p]", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7603 | __func__, callbackContext); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7604 | return; |
| 7605 | } |
| 7606 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 7607 | /* there is a race condition that exists between this callback |
| 7608 | function and the caller since the caller could time out either |
| 7609 | before or while this code is executing. we use a spinlock to |
| 7610 | serialize these actions */ |
| 7611 | spin_lock(&hdd_context_lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7612 | |
| 7613 | if (POWER_CONTEXT_MAGIC != pContext->magic) |
| 7614 | { |
| 7615 | /* the caller presumably timed out so there is nothing we can do */ |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 7616 | spin_unlock(&hdd_context_lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7617 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 7618 | "%s: Invalid context, magic [%08x]", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7619 | __func__, pContext->magic); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7620 | return; |
| 7621 | } |
| 7622 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 7623 | /* context is valid so caller is still waiting */ |
| 7624 | |
| 7625 | /* paranoia: invalidate the magic */ |
| 7626 | pContext->magic = 0; |
| 7627 | |
| 7628 | /* notify the caller */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7629 | complete(&pContext->completion); |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 7630 | |
| 7631 | /* serialization is complete */ |
| 7632 | spin_unlock(&hdd_context_lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7633 | } |
| 7634 | |
| 7635 | /**--------------------------------------------------------------------------- |
| 7636 | |
| 7637 | \brief hdd_wlan_exit() - HDD WLAN exit function |
| 7638 | |
| 7639 | This is the driver exit point (invoked during rmmod) |
| 7640 | |
| 7641 | \param - pHddCtx - Pointer to the HDD Context |
| 7642 | |
| 7643 | \return - None |
| 7644 | |
| 7645 | --------------------------------------------------------------------------*/ |
| 7646 | void hdd_wlan_exit(hdd_context_t *pHddCtx) |
| 7647 | { |
| 7648 | eHalStatus halStatus; |
| 7649 | v_CONTEXT_t pVosContext = pHddCtx->pvosContext; |
| 7650 | VOS_STATUS vosStatus; |
Gopichand Nakkala | 66923aa | 2013-03-06 23:17:24 +0530 | [diff] [blame] | 7651 | struct wiphy *wiphy = pHddCtx->wiphy; |
Mingcheng Zhu | 87f22fc | 2014-01-30 19:23:32 -0800 | [diff] [blame] | 7652 | hdd_adapter_t* pAdapter = NULL; |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 7653 | struct statsContext powerContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7654 | long lrc; |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 7655 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7656 | |
| 7657 | ENTER(); |
| 7658 | |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 7659 | if (VOS_FTM_MODE != hdd_get_conparam()) |
| 7660 | { |
| 7661 | // Unloading, restart logic is no more required. |
| 7662 | wlan_hdd_restart_deinit(pHddCtx); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7663 | |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 7664 | vosStatus = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7665 | while (NULL != pAdapterNode && VOS_STATUS_E_EMPTY != vosStatus) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7666 | { |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 7667 | pAdapter = pAdapterNode->pAdapter; |
| 7668 | if (NULL != pAdapter) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7669 | { |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 7670 | if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode || |
| 7671 | WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) |
| 7672 | { |
| 7673 | wlan_hdd_cfg80211_deregister_frames(pAdapter); |
| 7674 | hdd_UnregisterWext(pAdapter->dev); |
| 7675 | } |
| 7676 | // Cancel any outstanding scan requests. We are about to close all |
| 7677 | // of our adapters, but an adapter structure is what SME passes back |
| 7678 | // to our callback function. Hence if there are any outstanding scan |
| 7679 | // requests then there is a race condition between when the adapter |
| 7680 | // is closed and when the callback is invoked.We try to resolve that |
| 7681 | // race condition here by canceling any outstanding scans before we |
| 7682 | // close the adapters. |
| 7683 | // Note that the scans may be cancelled in an asynchronous manner, |
| 7684 | // so ideally there needs to be some kind of synchronization. Rather |
| 7685 | // than introduce a new synchronization here, we will utilize the |
| 7686 | // fact that we are about to Request Full Power, and since that is |
| 7687 | // synchronized, the expectation is that by the time Request Full |
| 7688 | // Power has completed all scans will be cancelled. |
| 7689 | if (pHddCtx->scan_info.mScanPending) |
| 7690 | { |
| 7691 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 7692 | FL("abort scan mode: %d sessionId: %d"), |
| 7693 | pAdapter->device_mode, |
| 7694 | pAdapter->sessionId); |
| 7695 | hdd_abort_mac_scan(pHddCtx, |
| 7696 | pAdapter->sessionId, |
| 7697 | eCSR_SCAN_ABORT_DEFAULT); |
| 7698 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7699 | } |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 7700 | vosStatus = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7701 | pAdapterNode = pNext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7702 | } |
| 7703 | } |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 7704 | else |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 7705 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7706 | hddLog(VOS_TRACE_LEVEL_INFO,"%s: FTM MODE",__func__); |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 7707 | wlan_hdd_ftm_close(pHddCtx); |
| 7708 | goto free_hdd_ctx; |
| 7709 | } |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7710 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7711 | /* DeRegister with platform driver as client for Suspend/Resume */ |
| 7712 | vosStatus = hddDeregisterPmOps(pHddCtx); |
| 7713 | if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) ) |
| 7714 | { |
| 7715 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddDeregisterPmOps failed",__func__); |
| 7716 | VOS_ASSERT(0); |
| 7717 | } |
| 7718 | |
| 7719 | vosStatus = hddDevTmUnregisterNotifyCallback(pHddCtx); |
| 7720 | if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) ) |
| 7721 | { |
| 7722 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddDevTmUnregisterNotifyCallback failed",__func__); |
| 7723 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7724 | |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 7725 | //Stop the traffic monitor timer |
| 7726 | if ( VOS_TIMER_STATE_RUNNING == |
| 7727 | vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)) |
| 7728 | { |
| 7729 | vos_timer_stop(&pHddCtx->tx_rx_trafficTmr); |
| 7730 | } |
| 7731 | |
| 7732 | // Destroy the traffic monitor timer |
| 7733 | if (!VOS_IS_STATUS_SUCCESS(vos_timer_destroy( |
| 7734 | &pHddCtx->tx_rx_trafficTmr))) |
| 7735 | { |
| 7736 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 7737 | "%s: Cannot deallocate Traffic monitor timer", __func__); |
| 7738 | } |
| 7739 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7740 | //Disable IMPS/BMPS as we do not want the device to enter any power |
| 7741 | //save mode during shutdown |
| 7742 | sme_DisablePowerSave(pHddCtx->hHal, ePMC_IDLE_MODE_POWER_SAVE); |
| 7743 | sme_DisablePowerSave(pHddCtx->hHal, ePMC_BEACON_MODE_POWER_SAVE); |
| 7744 | sme_DisablePowerSave(pHddCtx->hHal, ePMC_UAPSD_MODE_POWER_SAVE); |
| 7745 | |
| 7746 | //Ensure that device is in full power as we will touch H/W during vos_Stop |
| 7747 | init_completion(&powerContext.completion); |
| 7748 | powerContext.magic = POWER_CONTEXT_MAGIC; |
| 7749 | |
| 7750 | halStatus = sme_RequestFullPower(pHddCtx->hHal, hdd_full_power_callback, |
| 7751 | &powerContext, eSME_FULL_PWR_NEEDED_BY_HDD); |
| 7752 | |
| 7753 | if (eHAL_STATUS_SUCCESS != halStatus) |
| 7754 | { |
| 7755 | if (eHAL_STATUS_PMC_PENDING == halStatus) |
| 7756 | { |
| 7757 | /* request was sent -- wait for the response */ |
| 7758 | lrc = wait_for_completion_interruptible_timeout( |
| 7759 | &powerContext.completion, |
| 7760 | msecs_to_jiffies(WLAN_WAIT_TIME_POWER)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7761 | if (lrc <= 0) |
| 7762 | { |
| 7763 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s while requesting full power", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7764 | __func__, (0 == lrc) ? "timeout" : "interrupt"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7765 | } |
| 7766 | } |
| 7767 | else |
| 7768 | { |
| 7769 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 7770 | "%s: Request for Full Power failed, status %d", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7771 | __func__, halStatus); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7772 | /* continue -- need to clean up as much as possible */ |
| 7773 | } |
| 7774 | } |
| 7775 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 7776 | /* either we never sent a request, we sent a request and received a |
| 7777 | response or we sent a request and timed out. if we never sent a |
| 7778 | request or if we sent a request and got a response, we want to |
| 7779 | clear the magic out of paranoia. if we timed out there is a |
| 7780 | race condition such that the callback function could be |
| 7781 | executing at the same time we are. of primary concern is if the |
| 7782 | callback function had already verified the "magic" but had not |
| 7783 | yet set the completion variable when a timeout occurred. we |
| 7784 | serialize these activities by invalidating the magic while |
| 7785 | holding a shared spinlock which will cause us to block if the |
| 7786 | callback is currently executing */ |
| 7787 | spin_lock(&hdd_context_lock); |
| 7788 | powerContext.magic = 0; |
| 7789 | spin_unlock(&hdd_context_lock); |
| 7790 | |
Yue Ma | 0d4891e | 2013-08-06 17:01:45 -0700 | [diff] [blame] | 7791 | hdd_debugfs_exit(pHddCtx); |
| 7792 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7793 | // Unregister the Net Device Notifier |
| 7794 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 7795 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7796 | hdd_stop_all_adapters( pHddCtx ); |
| 7797 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7798 | #ifdef WLAN_BTAMP_FEATURE |
| 7799 | vosStatus = WLANBAP_Stop(pVosContext); |
| 7800 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) |
| 7801 | { |
| 7802 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 7803 | "%s: Failed to stop BAP",__func__); |
| 7804 | } |
| 7805 | #endif //WLAN_BTAMP_FEATURE |
| 7806 | |
| 7807 | //Stop all the modules |
| 7808 | vosStatus = vos_stop( pVosContext ); |
| 7809 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) |
| 7810 | { |
| 7811 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7812 | "%s: Failed to stop VOSS",__func__); |
| 7813 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) ); |
| 7814 | } |
| 7815 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7816 | //Assert Deep sleep signal now to put Libra HW in lowest power state |
| 7817 | vosStatus = vos_chipAssertDeepSleep( NULL, NULL, NULL ); |
| 7818 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) ); |
| 7819 | |
| 7820 | //Vote off any PMIC voltage supplies |
| 7821 | vos_chipPowerDown(NULL, NULL, NULL); |
| 7822 | |
| 7823 | vos_chipVoteOffXOBuffer(NULL, NULL, NULL); |
| 7824 | |
Leo Chang | 59cdc7e | 2013-07-10 10:08:21 -0700 | [diff] [blame] | 7825 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7826 | //This requires pMac access, Call this before vos_close(). |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7827 | hdd_unregister_mcast_bcast_filter(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7828 | |
| 7829 | //Close the scheduler before calling vos_close to make sure no thread is |
| 7830 | // scheduled after the each module close is called i.e after all the data |
| 7831 | // structures are freed. |
| 7832 | vosStatus = vos_sched_close( pVosContext ); |
| 7833 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) { |
| 7834 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, |
| 7835 | "%s: Failed to close VOSS Scheduler",__func__); |
| 7836 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) ); |
| 7837 | } |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 7838 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7839 | #ifdef WLAN_FEATURE_HOLD_RX_WAKELOCK |
| 7840 | /* Destroy the wake lock */ |
| 7841 | wake_lock_destroy(&pHddCtx->rx_wake_lock); |
| 7842 | #endif |
Madan Mohan Koyyalamudi | 69fc3ad | 2012-11-28 16:04:56 -0800 | [diff] [blame] | 7843 | /* Destroy the wake lock */ |
| 7844 | wake_lock_destroy(&pHddCtx->sap_wake_lock); |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 7845 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7846 | |
Mihir Shete | 7a24b5f | 2013-12-21 12:18:31 +0530 | [diff] [blame] | 7847 | #ifdef CONFIG_ENABLE_LINUX_REG |
| 7848 | vosStatus = vos_nv_close(); |
| 7849 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) |
| 7850 | { |
| 7851 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 7852 | "%s: Failed to close NV", __func__); |
| 7853 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) ); |
| 7854 | } |
| 7855 | #endif |
| 7856 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7857 | //Close VOSS |
| 7858 | //This frees pMac(HAL) context. There should not be any call that requires pMac access after this. |
| 7859 | vos_close(pVosContext); |
| 7860 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7861 | //Close Watchdog |
| 7862 | if(pHddCtx->cfg_ini->fIsLogpEnabled) |
| 7863 | vos_watchdog_close(pVosContext); |
| 7864 | |
Gopichand Nakkala | a035848 | 2013-06-12 17:05:47 +0530 | [diff] [blame] | 7865 | //Clean up HDD Nlink Service |
| 7866 | send_btc_nlink_msg(WLAN_MODULE_DOWN_IND, 0); |
Leo Chang | 59cdc7e | 2013-07-10 10:08:21 -0700 | [diff] [blame] | 7867 | #ifdef WLAN_KD_READY_NOTIFIER |
| 7868 | nl_srv_exit(pHddCtx->ptt_pid); |
| 7869 | #else |
Gopichand Nakkala | a035848 | 2013-06-12 17:05:47 +0530 | [diff] [blame] | 7870 | nl_srv_exit(); |
Leo Chang | 59cdc7e | 2013-07-10 10:08:21 -0700 | [diff] [blame] | 7871 | #endif /* WLAN_KD_READY_NOTIFIER */ |
Gopichand Nakkala | a035848 | 2013-06-12 17:05:47 +0530 | [diff] [blame] | 7872 | |
Vinay Krishna Eranna | d938c42 | 2014-03-10 17:14:21 +0530 | [diff] [blame] | 7873 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 7874 | if (pHddCtx->cfg_ini->wlanLoggingEnable) |
Vinay Krishna Eranna | d938c42 | 2014-03-10 17:14:21 +0530 | [diff] [blame] | 7875 | { |
| 7876 | wlan_logging_sock_deactivate_svc(); |
| 7877 | } |
| 7878 | #endif |
| 7879 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7880 | /* Cancel the vote for XO Core ON. |
| 7881 | * This is done here to ensure there is no race condition since MC, TX and WD threads have |
| 7882 | * exited at this point |
| 7883 | */ |
| 7884 | hddLog(VOS_TRACE_LEVEL_WARN, "In module exit: Cancel the vote for XO Core ON" |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 7885 | " when WLAN is turned OFF"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7886 | if (vos_chipVoteXOCore(NULL, NULL, NULL, VOS_FALSE) != VOS_STATUS_SUCCESS) |
| 7887 | { |
| 7888 | hddLog(VOS_TRACE_LEVEL_ERROR, "Could not cancel the vote for XO Core ON." |
| 7889 | " Not returning failure." |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 7890 | " Power consumed will be high"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7891 | } |
| 7892 | |
| 7893 | hdd_close_all_adapters( pHddCtx ); |
| 7894 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7895 | /* free the power on lock from platform driver */ |
| 7896 | if (free_riva_power_on_lock("wlan")) |
| 7897 | { |
| 7898 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to free power on lock", |
| 7899 | __func__); |
| 7900 | } |
| 7901 | |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 7902 | free_hdd_ctx: |
c_hpothu | 78c7b60 | 2014-05-17 17:35:49 +0530 | [diff] [blame] | 7903 | |
| 7904 | //Free up dynamically allocated members inside HDD Adapter |
| 7905 | if (pHddCtx->cfg_ini) |
| 7906 | { |
| 7907 | kfree(pHddCtx->cfg_ini); |
| 7908 | pHddCtx->cfg_ini= NULL; |
| 7909 | } |
| 7910 | |
Leo Chang | f04ddad | 2013-09-18 13:46:38 -0700 | [diff] [blame] | 7911 | /* FTM mode, WIPHY did not registered |
| 7912 | If un-register here, system crash will happen */ |
| 7913 | if (VOS_FTM_MODE != hdd_get_conparam()) |
| 7914 | { |
| 7915 | wiphy_unregister(wiphy) ; |
| 7916 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7917 | wiphy_free(wiphy) ; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7918 | if (hdd_is_ssr_required()) |
| 7919 | { |
| 7920 | /* WDI timeout had happened during unload, so SSR is needed here */ |
Madan Mohan Koyyalamudi | 3246f5b | 2012-10-15 15:40:02 -0700 | [diff] [blame] | 7921 | subsystem_restart("wcnss"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7922 | msleep(5000); |
| 7923 | } |
| 7924 | hdd_set_ssr_required (VOS_FALSE); |
| 7925 | } |
| 7926 | |
| 7927 | |
| 7928 | /**--------------------------------------------------------------------------- |
| 7929 | |
| 7930 | \brief hdd_update_config_from_nv() - Function to update the contents of |
| 7931 | the running configuration with parameters taken from NV storage |
| 7932 | |
| 7933 | \param - pHddCtx - Pointer to the HDD global context |
| 7934 | |
| 7935 | \return - VOS_STATUS_SUCCESS if successful |
| 7936 | |
| 7937 | --------------------------------------------------------------------------*/ |
| 7938 | static VOS_STATUS hdd_update_config_from_nv(hdd_context_t* pHddCtx) |
| 7939 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7940 | v_BOOL_t itemIsValid = VOS_FALSE; |
| 7941 | VOS_STATUS status; |
| 7942 | v_MACADDR_t macFromNV[VOS_MAX_CONCURRENCY_PERSONA]; |
| 7943 | v_U8_t macLoop; |
| 7944 | |
| 7945 | /*If the NV is valid then get the macaddress from nv else get it from qcom_cfg.ini*/ |
| 7946 | status = vos_nv_getValidity(VNV_FIELD_IMAGE, &itemIsValid); |
| 7947 | if(status != VOS_STATUS_SUCCESS) |
| 7948 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 7949 | hddLog(VOS_TRACE_LEVEL_ERROR," vos_nv_getValidity() failed"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7950 | return VOS_STATUS_E_FAILURE; |
| 7951 | } |
| 7952 | |
| 7953 | if (itemIsValid == VOS_TRUE) |
| 7954 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 7955 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH," Reading the Macaddress from NV"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7956 | status = vos_nv_readMultiMacAddress((v_U8_t *)&macFromNV[0].bytes[0], |
| 7957 | VOS_MAX_CONCURRENCY_PERSONA); |
| 7958 | if(status != VOS_STATUS_SUCCESS) |
| 7959 | { |
| 7960 | /* Get MAC from NV fail, not update CFG info |
| 7961 | * INI MAC value will be used for MAC setting */ |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 7962 | hddLog(VOS_TRACE_LEVEL_ERROR," vos_nv_readMacAddress() failed"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7963 | return VOS_STATUS_E_FAILURE; |
| 7964 | } |
| 7965 | |
| 7966 | /* If first MAC is not valid, treat all others are not valid |
| 7967 | * Then all MACs will be got from ini file */ |
| 7968 | if(vos_is_macaddr_zero(&macFromNV[0])) |
| 7969 | { |
| 7970 | /* MAC address in NV file is not configured yet */ |
| 7971 | hddLog(VOS_TRACE_LEVEL_WARN, "Invalid MAC in NV file"); |
| 7972 | return VOS_STATUS_E_INVAL; |
| 7973 | } |
| 7974 | |
| 7975 | /* Get MAC address from NV, update CFG info */ |
| 7976 | for(macLoop = 0; macLoop < VOS_MAX_CONCURRENCY_PERSONA; macLoop++) |
| 7977 | { |
| 7978 | if(vos_is_macaddr_zero(&macFromNV[macLoop])) |
| 7979 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7980 | hddLog(VOS_TRACE_LEVEL_ERROR,"not valid MAC from NV for %d", macLoop); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7981 | /* This MAC is not valid, skip it |
| 7982 | * This MAC will be got from ini file */ |
| 7983 | } |
| 7984 | else |
| 7985 | { |
| 7986 | vos_mem_copy((v_U8_t *)&pHddCtx->cfg_ini->intfMacAddr[macLoop].bytes[0], |
| 7987 | (v_U8_t *)&macFromNV[macLoop].bytes[0], |
| 7988 | VOS_MAC_ADDR_SIZE); |
| 7989 | } |
| 7990 | } |
| 7991 | } |
| 7992 | else |
| 7993 | { |
| 7994 | hddLog(VOS_TRACE_LEVEL_ERROR, "NV ITEM, MAC Not valid"); |
| 7995 | return VOS_STATUS_E_FAILURE; |
| 7996 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7997 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7998 | |
| 7999 | return VOS_STATUS_SUCCESS; |
| 8000 | } |
| 8001 | |
| 8002 | /**--------------------------------------------------------------------------- |
| 8003 | |
| 8004 | \brief hdd_post_voss_start_config() - HDD post voss start config helper |
| 8005 | |
| 8006 | \param - pAdapter - Pointer to the HDD |
| 8007 | |
| 8008 | \return - None |
| 8009 | |
| 8010 | --------------------------------------------------------------------------*/ |
| 8011 | VOS_STATUS hdd_post_voss_start_config(hdd_context_t* pHddCtx) |
| 8012 | { |
| 8013 | eHalStatus halStatus; |
| 8014 | v_U32_t listenInterval; |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 8015 | tANI_U32 ignoreDtim; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8016 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8017 | |
| 8018 | // Send ready indication to the HDD. This will kick off the MAC |
| 8019 | // into a 'running' state and should kick off an initial scan. |
| 8020 | halStatus = sme_HDDReadyInd( pHddCtx->hHal ); |
| 8021 | if ( !HAL_STATUS_SUCCESS( halStatus ) ) |
| 8022 | { |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 8023 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: sme_HDDReadyInd() failed with status " |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8024 | "code %08d [x%08x]",__func__, halStatus, halStatus ); |
| 8025 | return VOS_STATUS_E_FAILURE; |
| 8026 | } |
| 8027 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 8028 | // Set default LI and ignoreDtim into HDD context, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8029 | // otherwise under some race condition, HDD will set 0 LI value into RIVA, |
| 8030 | // And RIVA will crash |
| 8031 | wlan_cfgGetInt(pHddCtx->hHal, WNI_CFG_LISTEN_INTERVAL, &listenInterval); |
| 8032 | pHddCtx->hdd_actual_LI_value = listenInterval; |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 8033 | wlan_cfgGetInt(pHddCtx->hHal, WNI_CFG_IGNORE_DTIM, &ignoreDtim); |
| 8034 | pHddCtx->hdd_actual_ignore_DTIM_value = ignoreDtim; |
| 8035 | |
| 8036 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8037 | return VOS_STATUS_SUCCESS; |
| 8038 | } |
| 8039 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8040 | /* wake lock APIs for HDD */ |
| 8041 | void hdd_prevent_suspend(void) |
| 8042 | { |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 8043 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8044 | wake_lock(&wlan_wake_lock); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8045 | #else |
| 8046 | wcnss_prevent_suspend(); |
| 8047 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8048 | } |
| 8049 | |
| 8050 | void hdd_allow_suspend(void) |
| 8051 | { |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 8052 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8053 | wake_unlock(&wlan_wake_lock); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8054 | #else |
| 8055 | wcnss_allow_suspend(); |
| 8056 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8057 | } |
| 8058 | |
Mahesh A Saptasagar | b9c5040 | 2014-01-16 15:49:22 +0530 | [diff] [blame] | 8059 | void hdd_prevent_suspend_timeout(v_U32_t timeout) |
Madan Mohan Koyyalamudi | 10d83a9 | 2012-09-28 15:47:05 -0700 | [diff] [blame] | 8060 | { |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 8061 | #ifdef WLAN_OPEN_SOURCE |
Amar Singhal | 6144c00 | 2013-05-03 16:11:42 -0700 | [diff] [blame] | 8062 | wake_lock_timeout(&wlan_wake_lock, msecs_to_jiffies(timeout)); |
Madan Mohan Koyyalamudi | 10d83a9 | 2012-09-28 15:47:05 -0700 | [diff] [blame] | 8063 | #else |
| 8064 | /* Do nothing as there is no API in wcnss for timeout*/ |
| 8065 | #endif |
| 8066 | } |
| 8067 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8068 | /**--------------------------------------------------------------------------- |
| 8069 | |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8070 | \brief hdd_exchange_version_and_caps() - HDD function to exchange version and capability |
| 8071 | information between Host and Riva |
| 8072 | |
| 8073 | This function gets reported version of FW |
| 8074 | It also finds the version of Riva headers used to compile the host |
| 8075 | It compares the above two and prints a warning if they are different |
| 8076 | It gets the SW and HW version string |
| 8077 | Finally, it exchanges capabilities between host and Riva i.e. host and riva exchange a msg |
| 8078 | indicating the features they support through a bitmap |
| 8079 | |
| 8080 | \param - pHddCtx - Pointer to HDD context |
| 8081 | |
| 8082 | \return - void |
| 8083 | |
| 8084 | --------------------------------------------------------------------------*/ |
| 8085 | |
| 8086 | void hdd_exchange_version_and_caps(hdd_context_t *pHddCtx) |
| 8087 | { |
| 8088 | |
| 8089 | tSirVersionType versionCompiled; |
| 8090 | tSirVersionType versionReported; |
| 8091 | tSirVersionString versionString; |
| 8092 | tANI_U8 fwFeatCapsMsgSupported = 0; |
| 8093 | VOS_STATUS vstatus; |
| 8094 | |
Mingcheng Zhu | 87f22fc | 2014-01-30 19:23:32 -0800 | [diff] [blame] | 8095 | memset(&versionCompiled, 0, sizeof(versionCompiled)); |
| 8096 | memset(&versionReported, 0, sizeof(versionReported)); |
| 8097 | |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8098 | /* retrieve and display WCNSS version information */ |
| 8099 | do { |
| 8100 | |
| 8101 | vstatus = sme_GetWcnssWlanCompiledVersion(pHddCtx->hHal, |
| 8102 | &versionCompiled); |
| 8103 | if (!VOS_IS_STATUS_SUCCESS(vstatus)) |
| 8104 | { |
| 8105 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 8106 | "%s: unable to retrieve WCNSS WLAN compiled version", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 8107 | __func__); |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8108 | break; |
| 8109 | } |
| 8110 | |
| 8111 | vstatus = sme_GetWcnssWlanReportedVersion(pHddCtx->hHal, |
| 8112 | &versionReported); |
| 8113 | if (!VOS_IS_STATUS_SUCCESS(vstatus)) |
| 8114 | { |
| 8115 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 8116 | "%s: unable to retrieve WCNSS WLAN reported version", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 8117 | __func__); |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8118 | break; |
| 8119 | } |
| 8120 | |
| 8121 | if ((versionCompiled.major != versionReported.major) || |
| 8122 | (versionCompiled.minor != versionReported.minor) || |
| 8123 | (versionCompiled.version != versionReported.version) || |
| 8124 | (versionCompiled.revision != versionReported.revision)) |
| 8125 | { |
| 8126 | pr_err("%s: WCNSS WLAN Version %u.%u.%u.%u, " |
| 8127 | "Host expected %u.%u.%u.%u\n", |
| 8128 | WLAN_MODULE_NAME, |
| 8129 | (int)versionReported.major, |
| 8130 | (int)versionReported.minor, |
| 8131 | (int)versionReported.version, |
| 8132 | (int)versionReported.revision, |
| 8133 | (int)versionCompiled.major, |
| 8134 | (int)versionCompiled.minor, |
| 8135 | (int)versionCompiled.version, |
| 8136 | (int)versionCompiled.revision); |
| 8137 | } |
| 8138 | else |
| 8139 | { |
| 8140 | pr_info("%s: WCNSS WLAN version %u.%u.%u.%u\n", |
| 8141 | WLAN_MODULE_NAME, |
| 8142 | (int)versionReported.major, |
| 8143 | (int)versionReported.minor, |
| 8144 | (int)versionReported.version, |
| 8145 | (int)versionReported.revision); |
| 8146 | } |
| 8147 | |
| 8148 | vstatus = sme_GetWcnssSoftwareVersion(pHddCtx->hHal, |
| 8149 | versionString, |
| 8150 | sizeof(versionString)); |
| 8151 | if (!VOS_IS_STATUS_SUCCESS(vstatus)) |
| 8152 | { |
| 8153 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 8154 | "%s: unable to retrieve WCNSS software version string", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 8155 | __func__); |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8156 | break; |
| 8157 | } |
| 8158 | |
| 8159 | pr_info("%s: WCNSS software version %s\n", |
| 8160 | WLAN_MODULE_NAME, versionString); |
| 8161 | |
| 8162 | vstatus = sme_GetWcnssHardwareVersion(pHddCtx->hHal, |
| 8163 | versionString, |
| 8164 | sizeof(versionString)); |
| 8165 | if (!VOS_IS_STATUS_SUCCESS(vstatus)) |
| 8166 | { |
| 8167 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 8168 | "%s: unable to retrieve WCNSS hardware version string", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 8169 | __func__); |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8170 | break; |
| 8171 | } |
| 8172 | |
| 8173 | pr_info("%s: WCNSS hardware version %s\n", |
| 8174 | WLAN_MODULE_NAME, versionString); |
| 8175 | |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 8176 | /* 1.Check if FW version is greater than 0.1.1.0. Only then send host-FW capability exchange message |
| 8177 | 2.Host-FW capability exchange message is only present on riva 1.1 so |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8178 | send the message only if it the riva is 1.1 |
| 8179 | minor numbers for different riva branches: |
| 8180 | 0 -> (1.0)Mainline Build |
| 8181 | 1 -> (1.1)Mainline Build |
| 8182 | 2->(1.04) Stability Build |
| 8183 | */ |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 8184 | if (((versionReported.major>0) || (versionReported.minor>1) || |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8185 | ((versionReported.minor>=1) && (versionReported.version>=1))) |
| 8186 | && ((versionReported.major == 1) && (versionReported.minor >= 1))) |
| 8187 | fwFeatCapsMsgSupported = 1; |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 8188 | |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8189 | if (fwFeatCapsMsgSupported) |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 8190 | { |
| 8191 | #ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE |
| 8192 | if(!pHddCtx->cfg_ini->fEnableActiveModeOffload) |
| 8193 | sme_disableFeatureCapablity(WLANACTIVE_OFFLOAD); |
| 8194 | #endif |
Ravi Joshi | d2ca7c4 | 2013-07-23 08:37:49 -0700 | [diff] [blame] | 8195 | /* Indicate if IBSS heartbeat monitoring needs to be offloaded */ |
| 8196 | if (!pHddCtx->cfg_ini->enableIbssHeartBeatOffload) |
| 8197 | { |
| 8198 | sme_disableFeatureCapablity(IBSS_HEARTBEAT_OFFLOAD); |
| 8199 | } |
| 8200 | |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8201 | sme_featureCapsExchange(pHddCtx->hHal); |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 8202 | } |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8203 | |
| 8204 | } while (0); |
| 8205 | |
| 8206 | } |
| 8207 | |
| 8208 | /**--------------------------------------------------------------------------- |
| 8209 | |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 8210 | \brief hdd_is_5g_supported() - HDD function to know if hardware supports 5GHz |
| 8211 | |
| 8212 | \param - pHddCtx - Pointer to the hdd context |
| 8213 | |
| 8214 | \return - true if hardware supports 5GHz |
| 8215 | |
| 8216 | --------------------------------------------------------------------------*/ |
Vinay Krishna Eranna | facf5e2 | 2014-02-24 13:16:25 +0530 | [diff] [blame] | 8217 | boolean hdd_is_5g_supported(hdd_context_t * pHddCtx) |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 8218 | { |
| 8219 | /* If wcnss_wlan_iris_xo_mode() returns WCNSS_XO_48MHZ(1); |
| 8220 | * then hardware support 5Ghz. |
| 8221 | */ |
| 8222 | if (WCNSS_XO_48MHZ == wcnss_wlan_iris_xo_mode()) |
| 8223 | { |
Agarwal Ashish | 971c288 | 2013-10-30 20:11:12 +0530 | [diff] [blame] | 8224 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Hardware supports 5Ghz", __func__); |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 8225 | return true; |
| 8226 | } |
| 8227 | else |
| 8228 | { |
Agarwal Ashish | 971c288 | 2013-10-30 20:11:12 +0530 | [diff] [blame] | 8229 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Hardware doesn't supports 5Ghz", |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 8230 | __func__); |
| 8231 | return false; |
| 8232 | } |
| 8233 | } |
| 8234 | |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 8235 | /**--------------------------------------------------------------------------- |
| 8236 | |
| 8237 | \brief hdd_generate_iface_mac_addr_auto() - HDD Mac Interface Auto |
| 8238 | generate function |
| 8239 | |
| 8240 | This is generate the random mac address for WLAN interface |
| 8241 | |
| 8242 | \param - pHddCtx - Pointer to HDD context |
| 8243 | idx - Start interface index to get auto |
| 8244 | generated mac addr. |
| 8245 | mac_addr - Mac address |
| 8246 | |
| 8247 | \return - 0 for success, < 0 for failure |
| 8248 | |
| 8249 | --------------------------------------------------------------------------*/ |
| 8250 | |
| 8251 | static int hdd_generate_iface_mac_addr_auto(hdd_context_t *pHddCtx, |
| 8252 | int idx, v_MACADDR_t mac_addr) |
| 8253 | { |
| 8254 | int i; |
| 8255 | unsigned int serialno; |
| 8256 | serialno = wcnss_get_serial_number(); |
| 8257 | |
| 8258 | if (0 != serialno) |
| 8259 | { |
| 8260 | /* MAC address has 3 bytes of OUI so we have a maximum of 3 |
| 8261 | bytes of the serial number that can be used to generate |
| 8262 | the other 3 bytes of the MAC address. Mask off all but |
| 8263 | the lower 3 bytes (this will also make sure we don't |
| 8264 | overflow in the next step) */ |
| 8265 | serialno &= 0x00FFFFFF; |
| 8266 | |
| 8267 | /* we need a unique address for each session */ |
| 8268 | serialno *= VOS_MAX_CONCURRENCY_PERSONA; |
| 8269 | |
| 8270 | /* autogen other Mac addresses */ |
| 8271 | for (i = idx; i < VOS_MAX_CONCURRENCY_PERSONA; i++) |
| 8272 | { |
| 8273 | /* start with the entire default address */ |
| 8274 | pHddCtx->cfg_ini->intfMacAddr[i] = mac_addr; |
| 8275 | /* then replace the lower 3 bytes */ |
| 8276 | pHddCtx->cfg_ini->intfMacAddr[i].bytes[3] = (serialno >> 16) & 0xFF; |
| 8277 | pHddCtx->cfg_ini->intfMacAddr[i].bytes[4] = (serialno >> 8) & 0xFF; |
| 8278 | pHddCtx->cfg_ini->intfMacAddr[i].bytes[5] = serialno & 0xFF; |
| 8279 | |
| 8280 | serialno++; |
| 8281 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8282 | "%s: Derived Mac Addr: " |
| 8283 | MAC_ADDRESS_STR, __func__, |
| 8284 | MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[i].bytes)); |
| 8285 | } |
| 8286 | |
| 8287 | } |
| 8288 | else |
| 8289 | { |
| 8290 | hddLog(LOGE, FL("Failed to Get Serial NO")); |
| 8291 | return -1; |
| 8292 | } |
| 8293 | return 0; |
| 8294 | } |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 8295 | |
| 8296 | /**--------------------------------------------------------------------------- |
| 8297 | |
Mihir Shete | fc7ff5b | 2014-01-27 11:30:05 +0530 | [diff] [blame] | 8298 | \brief hdd_11d_scan_done - callback to be executed when 11d scan is |
| 8299 | completed to flush out the scan results |
| 8300 | |
| 8301 | 11d scan is done during driver load and is a passive scan on all |
| 8302 | channels supported by the device, 11d scans may find some APs on |
| 8303 | frequencies which are forbidden to be used in the regulatory domain |
| 8304 | the device is operating in. If these APs are notified to the supplicant |
| 8305 | it may try to connect to these APs, thus flush out all the scan results |
| 8306 | which are present in SME after 11d scan is done. |
| 8307 | |
| 8308 | \return - eHalStatus |
| 8309 | |
| 8310 | --------------------------------------------------------------------------*/ |
| 8311 | static eHalStatus hdd_11d_scan_done(tHalHandle halHandle, void *pContext, |
| 8312 | tANI_U32 scanId, eCsrScanStatus status) |
| 8313 | { |
| 8314 | ENTER(); |
| 8315 | |
| 8316 | sme_ScanFlushResult(halHandle, 0); |
| 8317 | |
| 8318 | EXIT(); |
| 8319 | |
| 8320 | return eHAL_STATUS_SUCCESS; |
| 8321 | } |
| 8322 | |
| 8323 | /**--------------------------------------------------------------------------- |
| 8324 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8325 | \brief hdd_wlan_startup() - HDD init function |
| 8326 | |
| 8327 | This is the driver startup code executed once a WLAN device has been detected |
| 8328 | |
| 8329 | \param - dev - Pointer to the underlying device |
| 8330 | |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 8331 | \return - 0 for success, < 0 for failure |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8332 | |
| 8333 | --------------------------------------------------------------------------*/ |
| 8334 | |
| 8335 | int hdd_wlan_startup(struct device *dev ) |
| 8336 | { |
| 8337 | VOS_STATUS status; |
| 8338 | hdd_adapter_t *pAdapter = NULL; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8339 | hdd_adapter_t *pP2pAdapter = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8340 | hdd_context_t *pHddCtx = NULL; |
| 8341 | v_CONTEXT_t pVosContext= NULL; |
| 8342 | #ifdef WLAN_BTAMP_FEATURE |
| 8343 | VOS_STATUS vStatus = VOS_STATUS_SUCCESS; |
| 8344 | WLANBAP_ConfigType btAmpConfig; |
| 8345 | hdd_config_t *pConfig; |
| 8346 | #endif |
| 8347 | int ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8348 | struct wiphy *wiphy; |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 8349 | v_MACADDR_t mac_addr; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8350 | |
| 8351 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8352 | /* |
| 8353 | * cfg80211: wiphy allocation |
| 8354 | */ |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 8355 | wiphy = wlan_hdd_cfg80211_wiphy_alloc(sizeof(hdd_context_t)) ; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8356 | |
| 8357 | if(wiphy == NULL) |
| 8358 | { |
| 8359 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: cfg80211 init failed", __func__); |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 8360 | return -EIO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8361 | } |
| 8362 | |
| 8363 | pHddCtx = wiphy_priv(wiphy); |
| 8364 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8365 | //Initialize the adapter context to zeros. |
| 8366 | vos_mem_zero(pHddCtx, sizeof( hdd_context_t )); |
| 8367 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8368 | pHddCtx->wiphy = wiphy; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8369 | hdd_prevent_suspend(); |
Mihir Shete | 1815629 | 2014-03-11 15:38:30 +0530 | [diff] [blame] | 8370 | pHddCtx->isLoadUnloadInProgress = WLAN_HDD_LOAD_IN_PROGRESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8371 | |
| 8372 | vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, TRUE); |
| 8373 | |
| 8374 | /*Get vos context here bcoz vos_open requires it*/ |
| 8375 | pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL); |
| 8376 | |
Madan Mohan Koyyalamudi | 0b78e15 | 2012-11-28 15:46:51 -0800 | [diff] [blame] | 8377 | if(pVosContext == NULL) |
| 8378 | { |
| 8379 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Failed vos_get_global_context",__func__); |
| 8380 | goto err_free_hdd_context; |
| 8381 | } |
| 8382 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8383 | //Save the Global VOSS context in adapter context for future. |
| 8384 | pHddCtx->pvosContext = pVosContext; |
| 8385 | |
| 8386 | //Save the adapter context in global context for future. |
| 8387 | ((VosContextType*)(pVosContext))->pHDDContext = (v_VOID_t*)pHddCtx; |
| 8388 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8389 | pHddCtx->parent_dev = dev; |
| 8390 | |
| 8391 | init_completion(&pHddCtx->full_pwr_comp_var); |
| 8392 | init_completion(&pHddCtx->standby_comp_var); |
| 8393 | init_completion(&pHddCtx->req_bmps_comp_var); |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 8394 | init_completion(&pHddCtx->scan_info.scan_req_completion_event); |
Madan Mohan Koyyalamudi | f4e8100 | 2012-11-13 10:46:38 -0800 | [diff] [blame] | 8395 | init_completion(&pHddCtx->scan_info.abortscan_event_var); |
Kiet Lam | 46b8e4e | 2013-11-06 21:49:53 +0530 | [diff] [blame] | 8396 | init_completion(&pHddCtx->wiphy_channel_update_event); |
Arun Kumar Khandavalli | e0b046d | 2014-03-01 21:54:25 +0530 | [diff] [blame] | 8397 | init_completion(&pHddCtx->ssr_comp_var); |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 8398 | |
| 8399 | #ifdef CONFIG_ENABLE_LINUX_REG |
Amar Singhal | fddc28c | 2013-09-05 13:03:40 -0700 | [diff] [blame] | 8400 | init_completion(&pHddCtx->linux_reg_req); |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 8401 | #else |
| 8402 | init_completion(&pHddCtx->driver_crda_req); |
| 8403 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8404 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 8405 | spin_lock_init(&pHddCtx->schedScan_lock); |
| 8406 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8407 | hdd_list_init( &pHddCtx->hddAdapters, MAX_NUMBER_OF_ADAPTERS ); |
| 8408 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 8409 | #ifdef FEATURE_WLAN_TDLS |
| 8410 | /* tdls_lock is initialized before an hdd_open_adapter ( which is |
| 8411 | * invoked by other instances also) to protect the concurrent |
| 8412 | * access for the Adapters by TDLS module. |
| 8413 | */ |
| 8414 | mutex_init(&pHddCtx->tdls_lock); |
| 8415 | #endif |
| 8416 | |
Kiet Lam | 46b8e4e | 2013-11-06 21:49:53 +0530 | [diff] [blame] | 8417 | pHddCtx->nEnableStrictRegulatoryForFCC = TRUE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8418 | // Load all config first as TL config is needed during vos_open |
| 8419 | pHddCtx->cfg_ini = (hdd_config_t*) kmalloc(sizeof(hdd_config_t), GFP_KERNEL); |
| 8420 | if(pHddCtx->cfg_ini == NULL) |
| 8421 | { |
| 8422 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Failed kmalloc hdd_config_t",__func__); |
| 8423 | goto err_free_hdd_context; |
| 8424 | } |
| 8425 | |
| 8426 | vos_mem_zero(pHddCtx->cfg_ini, sizeof( hdd_config_t )); |
| 8427 | |
| 8428 | // Read and parse the qcom_cfg.ini file |
| 8429 | status = hdd_parse_config_ini( pHddCtx ); |
| 8430 | if ( VOS_STATUS_SUCCESS != status ) |
| 8431 | { |
| 8432 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: error parsing %s", |
| 8433 | __func__, WLAN_INI_FILE); |
| 8434 | goto err_config; |
| 8435 | } |
Arif Hussain | d521891 | 2013-12-05 01:10:55 -0800 | [diff] [blame] | 8436 | #ifdef MEMORY_DEBUG |
| 8437 | if (pHddCtx->cfg_ini->IsMemoryDebugSupportEnabled) |
| 8438 | vos_mem_init(); |
| 8439 | |
| 8440 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: gEnableMemoryDebug=%d", |
| 8441 | __func__, pHddCtx->cfg_ini->IsMemoryDebugSupportEnabled); |
| 8442 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8443 | |
Gopichand Nakkala | b8f0f1a | 2013-05-23 18:19:48 +0530 | [diff] [blame] | 8444 | /* INI has been read, initialise the configuredMcastBcastFilter with |
| 8445 | * INI value as this will serve as the default value |
| 8446 | */ |
| 8447 | pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting; |
| 8448 | hddLog(VOS_TRACE_LEVEL_INFO, "Setting configuredMcastBcastFilter: %d", |
| 8449 | pHddCtx->cfg_ini->mcastBcastFilterSetting); |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 8450 | |
| 8451 | if (false == hdd_is_5g_supported(pHddCtx)) |
| 8452 | { |
| 8453 | //5Ghz is not supported. |
| 8454 | if (1 != pHddCtx->cfg_ini->nBandCapability) |
| 8455 | { |
| 8456 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 8457 | "%s: Setting pHddCtx->cfg_ini->nBandCapability = 1", __func__); |
| 8458 | pHddCtx->cfg_ini->nBandCapability = 1; |
| 8459 | } |
| 8460 | } |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 8461 | |
| 8462 | /* If SNR Monitoring is enabled, FW has to parse all beacons |
| 8463 | * for calcaluting and storing the average SNR, so set Nth beacon |
| 8464 | * filter to 1 to enable FW to parse all the beaocons |
| 8465 | */ |
| 8466 | if (1 == pHddCtx->cfg_ini->fEnableSNRMonitoring) |
| 8467 | { |
| 8468 | /* The log level is deliberately set to WARN as overriding |
| 8469 | * nthBeaconFilter to 1 will increase power cosumption and this |
| 8470 | * might just prove helpful to detect the power issue. |
| 8471 | */ |
| 8472 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 8473 | "%s: Setting pHddCtx->cfg_ini->nthBeaconFilter = 1", __func__); |
| 8474 | pHddCtx->cfg_ini->nthBeaconFilter = 1; |
| 8475 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8476 | /* |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 8477 | * cfg80211: Initialization ... |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8478 | */ |
Manjunathappa Prakash | eec4ddf | 2014-01-13 18:23:51 -0800 | [diff] [blame] | 8479 | if (VOS_FTM_MODE != hdd_get_conparam()) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8480 | { |
Manjunathappa Prakash | eec4ddf | 2014-01-13 18:23:51 -0800 | [diff] [blame] | 8481 | if (0 < wlan_hdd_cfg80211_init(dev, wiphy, pHddCtx->cfg_ini)) |
| 8482 | { |
| 8483 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 8484 | "%s: wlan_hdd_cfg80211_init return failure", __func__); |
| 8485 | goto err_config; |
| 8486 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8487 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8488 | |
Varun Reddy Yeturu | 587e680 | 2013-01-24 12:21:41 -0800 | [diff] [blame] | 8489 | // Update VOS trace levels based upon the cfg.ini |
| 8490 | hdd_vos_trace_enable(VOS_MODULE_ID_BAP, |
| 8491 | pHddCtx->cfg_ini->vosTraceEnableBAP); |
| 8492 | hdd_vos_trace_enable(VOS_MODULE_ID_TL, |
| 8493 | pHddCtx->cfg_ini->vosTraceEnableTL); |
| 8494 | hdd_vos_trace_enable(VOS_MODULE_ID_WDI, |
| 8495 | pHddCtx->cfg_ini->vosTraceEnableWDI); |
| 8496 | hdd_vos_trace_enable(VOS_MODULE_ID_HDD, |
| 8497 | pHddCtx->cfg_ini->vosTraceEnableHDD); |
| 8498 | hdd_vos_trace_enable(VOS_MODULE_ID_SME, |
| 8499 | pHddCtx->cfg_ini->vosTraceEnableSME); |
| 8500 | hdd_vos_trace_enable(VOS_MODULE_ID_PE, |
| 8501 | pHddCtx->cfg_ini->vosTraceEnablePE); |
Katya Nigam | 70d6833 | 2013-09-16 16:49:45 +0530 | [diff] [blame] | 8502 | hdd_vos_trace_enable(VOS_MODULE_ID_PMC, |
| 8503 | pHddCtx->cfg_ini->vosTraceEnablePMC); |
Varun Reddy Yeturu | 587e680 | 2013-01-24 12:21:41 -0800 | [diff] [blame] | 8504 | hdd_vos_trace_enable(VOS_MODULE_ID_WDA, |
| 8505 | pHddCtx->cfg_ini->vosTraceEnableWDA); |
| 8506 | hdd_vos_trace_enable(VOS_MODULE_ID_SYS, |
| 8507 | pHddCtx->cfg_ini->vosTraceEnableSYS); |
| 8508 | hdd_vos_trace_enable(VOS_MODULE_ID_VOSS, |
| 8509 | pHddCtx->cfg_ini->vosTraceEnableVOSS); |
Varun Reddy Yeturu | 587e680 | 2013-01-24 12:21:41 -0800 | [diff] [blame] | 8510 | hdd_vos_trace_enable(VOS_MODULE_ID_SAP, |
| 8511 | pHddCtx->cfg_ini->vosTraceEnableSAP); |
| 8512 | hdd_vos_trace_enable(VOS_MODULE_ID_HDD_SOFTAP, |
| 8513 | pHddCtx->cfg_ini->vosTraceEnableHDDSAP); |
Varun Reddy Yeturu | 587e680 | 2013-01-24 12:21:41 -0800 | [diff] [blame] | 8514 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8515 | // Update WDI trace levels based upon the cfg.ini |
| 8516 | hdd_wdi_trace_enable(eWLAN_MODULE_DAL, |
| 8517 | pHddCtx->cfg_ini->wdiTraceEnableDAL); |
| 8518 | hdd_wdi_trace_enable(eWLAN_MODULE_DAL_CTRL, |
| 8519 | pHddCtx->cfg_ini->wdiTraceEnableCTL); |
| 8520 | hdd_wdi_trace_enable(eWLAN_MODULE_DAL_DATA, |
| 8521 | pHddCtx->cfg_ini->wdiTraceEnableDAT); |
| 8522 | hdd_wdi_trace_enable(eWLAN_MODULE_PAL, |
| 8523 | pHddCtx->cfg_ini->wdiTraceEnablePAL); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8524 | |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 8525 | if (VOS_FTM_MODE == hdd_get_conparam()) |
| 8526 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8527 | if ( VOS_STATUS_SUCCESS != wlan_hdd_ftm_open(pHddCtx) ) |
| 8528 | { |
| 8529 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: wlan_hdd_ftm_open Failed",__func__); |
| 8530 | goto err_free_hdd_context; |
| 8531 | } |
| 8532 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: FTM driver loaded success fully",__func__); |
c_hpothu | 2de0ef6 | 2014-04-15 16:16:15 +0530 | [diff] [blame] | 8533 | |
| 8534 | vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, FALSE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8535 | return VOS_STATUS_SUCCESS; |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 8536 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8537 | |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 8538 | //Open watchdog module |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8539 | if(pHddCtx->cfg_ini->fIsLogpEnabled) |
| 8540 | { |
| 8541 | status = vos_watchdog_open(pVosContext, |
| 8542 | &((VosContextType*)pVosContext)->vosWatchdog, sizeof(VosWatchdogContext)); |
| 8543 | |
| 8544 | if(!VOS_IS_STATUS_SUCCESS( status )) |
| 8545 | { |
| 8546 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: vos_watchdog_open failed",__func__); |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 8547 | goto err_wdclose; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8548 | } |
| 8549 | } |
| 8550 | |
| 8551 | pHddCtx->isLogpInProgress = FALSE; |
| 8552 | vos_set_logp_in_progress(VOS_MODULE_ID_VOSS, FALSE); |
| 8553 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8554 | status = vos_chipVoteOnXOBuffer(NULL, NULL, NULL); |
| 8555 | if(!VOS_IS_STATUS_SUCCESS(status)) |
| 8556 | { |
| 8557 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Failed to configure 19.2 MHz Clock", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8558 | goto err_wdclose; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8559 | } |
| 8560 | |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 8561 | #ifdef CONFIG_ENABLE_LINUX_REG |
Amar Singhal | 0a40223 | 2013-10-11 20:57:16 -0700 | [diff] [blame] | 8562 | /* initialize the NV module. This is required so that |
| 8563 | we can initialize the channel information in wiphy |
| 8564 | from the NV.bin data. The channel information in |
| 8565 | wiphy needs to be initialized before wiphy registration */ |
| 8566 | |
| 8567 | status = vos_nv_open(); |
| 8568 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 8569 | { |
| 8570 | /* NV module cannot be initialized */ |
| 8571 | hddLog( VOS_TRACE_LEVEL_FATAL, |
| 8572 | "%s: vos_nv_open failed", __func__); |
| 8573 | goto err_clkvote; |
| 8574 | } |
| 8575 | |
| 8576 | status = vos_init_wiphy_from_nv_bin(); |
| 8577 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 8578 | { |
| 8579 | /* NV module cannot be initialized */ |
| 8580 | hddLog( VOS_TRACE_LEVEL_FATAL, |
| 8581 | "%s: vos_init_wiphy failed", __func__); |
| 8582 | goto err_vos_nv_close; |
| 8583 | } |
| 8584 | |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 8585 | #endif |
| 8586 | |
Arun Kumar Khandavalli | ebb1948 | 2014-03-25 13:56:53 +0530 | [diff] [blame] | 8587 | status = vos_open( &pVosContext, pHddCtx->parent_dev); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8588 | if ( !VOS_IS_STATUS_SUCCESS( status )) |
| 8589 | { |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 8590 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: vos_open failed", __func__); |
Mihir Shete | e1093ba | 2014-01-21 20:13:32 +0530 | [diff] [blame] | 8591 | goto err_vos_nv_close; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8592 | } |
| 8593 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8594 | pHddCtx->hHal = (tHalHandle)vos_get_context( VOS_MODULE_ID_SME, pVosContext ); |
| 8595 | |
| 8596 | if ( NULL == pHddCtx->hHal ) |
| 8597 | { |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 8598 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: HAL context is null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8599 | goto err_vosclose; |
| 8600 | } |
| 8601 | |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 8602 | status = vos_preStart( pHddCtx->pvosContext ); |
| 8603 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 8604 | { |
| 8605 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: vos_preStart failed", __func__); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 8606 | goto err_vosclose; |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 8607 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8608 | |
Arif Hussain | eaf6860 | 2013-12-30 23:10:44 -0800 | [diff] [blame] | 8609 | if (0 == enable_dfs_chan_scan || 1 == enable_dfs_chan_scan) |
| 8610 | { |
| 8611 | pHddCtx->cfg_ini->enableDFSChnlScan = enable_dfs_chan_scan; |
| 8612 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: module enable_dfs_chan_scan set to %d", |
| 8613 | __func__, enable_dfs_chan_scan); |
| 8614 | } |
| 8615 | if (0 == enable_11d || 1 == enable_11d) |
| 8616 | { |
| 8617 | pHddCtx->cfg_ini->Is11dSupportEnabled = enable_11d; |
| 8618 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: module enable_11d set to %d", |
| 8619 | __func__, enable_11d); |
| 8620 | } |
| 8621 | |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 8622 | /* Note that the vos_preStart() sequence triggers the cfg download. |
| 8623 | The cfg download must occur before we update the SME config |
| 8624 | since the SME config operation must access the cfg database */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8625 | status = hdd_set_sme_config( pHddCtx ); |
| 8626 | |
| 8627 | if ( VOS_STATUS_SUCCESS != status ) |
| 8628 | { |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 8629 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Failed hdd_set_sme_config", __func__); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 8630 | goto err_vosclose; |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 8631 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8632 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8633 | /* In the integrated architecture we update the configuration from |
| 8634 | the INI file and from NV before vOSS has been started so that |
| 8635 | the final contents are available to send down to the cCPU */ |
| 8636 | |
| 8637 | // Apply the cfg.ini to cfg.dat |
| 8638 | if (FALSE == hdd_update_config_dat(pHddCtx)) |
| 8639 | { |
| 8640 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: config update failed",__func__ ); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 8641 | goto err_vosclose; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8642 | } |
| 8643 | |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 8644 | // Get mac addr from platform driver |
| 8645 | ret = wcnss_get_wlan_mac_address((char*)&mac_addr.bytes); |
| 8646 | |
| 8647 | if ((0 == ret) && (!vos_is_macaddr_zero(&mac_addr))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8648 | { |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 8649 | /* Store the mac addr for first interface */ |
| 8650 | pHddCtx->cfg_ini->intfMacAddr[0] = mac_addr; |
| 8651 | |
| 8652 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8653 | "%s: WLAN Mac Addr: " |
| 8654 | MAC_ADDRESS_STR, __func__, |
| 8655 | MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[0].bytes)); |
| 8656 | |
| 8657 | /* Here, passing Arg2 as 1 because we do not want to change the |
| 8658 | last 3 bytes (means non OUI bytes) of first interface mac |
| 8659 | addr. |
| 8660 | */ |
| 8661 | if (0 != hdd_generate_iface_mac_addr_auto(pHddCtx, 1, mac_addr)) |
| 8662 | { |
| 8663 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8664 | "%s: Failed to generate wlan interface mac addr " |
| 8665 | "using MAC from ini file ", __func__); |
| 8666 | } |
| 8667 | } |
| 8668 | else if (VOS_STATUS_SUCCESS != hdd_update_config_from_nv(pHddCtx)) |
| 8669 | { |
| 8670 | // Apply the NV to cfg.dat |
| 8671 | /* Prima Update MAC address only at here */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8672 | #ifdef WLAN_AUTOGEN_MACADDR_FEATURE |
| 8673 | /* There was not a valid set of MAC Addresses in NV. See if the |
| 8674 | default addresses were modified by the cfg.ini settings. If so, |
| 8675 | we'll use them, but if not, we'll autogenerate a set of MAC |
| 8676 | addresses based upon the device serial number */ |
| 8677 | |
| 8678 | static const v_MACADDR_t default_address = |
| 8679 | {{0x00, 0x0A, 0xF5, 0x89, 0x89, 0xFF}}; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8680 | |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 8681 | if (0 == memcmp(&default_address, &pHddCtx->cfg_ini->intfMacAddr[0], |
| 8682 | sizeof(default_address))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8683 | { |
| 8684 | /* cfg.ini has the default address, invoke autogen logic */ |
| 8685 | |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 8686 | /* Here, passing Arg2 as 0 because we want to change the |
| 8687 | last 3 bytes (means non OUI bytes) of all the interfaces |
| 8688 | mac addr. |
| 8689 | */ |
| 8690 | if (0 != hdd_generate_iface_mac_addr_auto(pHddCtx, 0, |
| 8691 | default_address)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8692 | { |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 8693 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8694 | "%s: Failed to generate wlan interface mac addr " |
| 8695 | "using MAC from ini file " MAC_ADDRESS_STR, __func__, |
| 8696 | MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[0].bytes)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8697 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8698 | } |
| 8699 | else |
| 8700 | #endif //WLAN_AUTOGEN_MACADDR_FEATURE |
| 8701 | { |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 8702 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8703 | "%s: Invalid MAC address in NV, using MAC from ini file " |
| 8704 | MAC_ADDRESS_STR, __func__, |
| 8705 | MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[0].bytes)); |
| 8706 | } |
| 8707 | } |
| 8708 | { |
| 8709 | eHalStatus halStatus; |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 8710 | |
| 8711 | /* Set the MAC Address Currently this is used by HAL to |
| 8712 | * add self sta. Remove this once self sta is added as |
| 8713 | * part of session open. |
| 8714 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8715 | halStatus = cfgSetStr( pHddCtx->hHal, WNI_CFG_STA_ID, |
| 8716 | (v_U8_t *)&pHddCtx->cfg_ini->intfMacAddr[0], |
| 8717 | sizeof( pHddCtx->cfg_ini->intfMacAddr[0]) ); |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 8718 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8719 | if (!HAL_STATUS_SUCCESS( halStatus )) |
| 8720 | { |
| 8721 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failed to set MAC Address. " |
| 8722 | "HALStatus is %08d [x%08x]",__func__, halStatus, halStatus ); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 8723 | goto err_vosclose; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8724 | } |
| 8725 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8726 | |
| 8727 | /*Start VOSS which starts up the SME/MAC/HAL modules and everything else |
| 8728 | Note: Firmware image will be read and downloaded inside vos_start API */ |
| 8729 | status = vos_start( pHddCtx->pvosContext ); |
| 8730 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 8731 | { |
| 8732 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: vos_start failed",__func__); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 8733 | goto err_vosclose; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8734 | } |
| 8735 | |
Leo Chang | 6cec3e2 | 2014-01-21 15:33:49 -0800 | [diff] [blame] | 8736 | #ifdef FEATURE_WLAN_CH_AVOID |
| 8737 | /* Plug in avoid channel notification callback |
| 8738 | * This should happen before ADD_SELF_STA |
| 8739 | * FW will send first IND with ADD_SELF_STA REQ from host */ |
Pradeep Reddy POTTETI | 5c2e16d | 2014-06-27 16:47:38 +0530 | [diff] [blame] | 8740 | |
| 8741 | /* check the Channel Avoidance is enabled */ |
| 8742 | if (TRUE == pHddCtx->cfg_ini->fenableCHAvoidance) |
| 8743 | { |
| 8744 | sme_AddChAvoidCallback(pHddCtx->hHal, |
| 8745 | hdd_hostapd_ch_avoid_cb); |
| 8746 | } |
Leo Chang | 6cec3e2 | 2014-01-21 15:33:49 -0800 | [diff] [blame] | 8747 | #endif /* FEATURE_WLAN_CH_AVOID */ |
| 8748 | |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8749 | /* Exchange capability info between Host and FW and also get versioning info from FW */ |
| 8750 | hdd_exchange_version_and_caps(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8751 | |
Agarwal Ashish | ad9281b | 2014-06-10 14:57:30 +0530 | [diff] [blame] | 8752 | #ifdef CONFIG_ENABLE_LINUX_REG |
| 8753 | status = wlan_hdd_init_channels(pHddCtx); |
| 8754 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 8755 | { |
| 8756 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: wlan_hdd_init_channels failed", |
| 8757 | __func__); |
| 8758 | goto err_vosstop; |
| 8759 | } |
| 8760 | #endif |
| 8761 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8762 | status = hdd_post_voss_start_config( pHddCtx ); |
| 8763 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 8764 | { |
| 8765 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hdd_post_voss_start_config failed", |
| 8766 | __func__); |
| 8767 | goto err_vosstop; |
| 8768 | } |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 8769 | |
| 8770 | #ifndef CONFIG_ENABLE_LINUX_REG |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 8771 | wlan_hdd_cfg80211_update_reg_info( wiphy ); |
| 8772 | |
| 8773 | /* registration of wiphy dev with cfg80211 */ |
| 8774 | if (0 > wlan_hdd_cfg80211_register(wiphy)) |
| 8775 | { |
| 8776 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__); |
| 8777 | goto err_vosstop; |
| 8778 | } |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 8779 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8780 | |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 8781 | #ifdef CONFIG_ENABLE_LINUX_REG |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 8782 | /* registration of wiphy dev with cfg80211 */ |
| 8783 | if (0 > wlan_hdd_cfg80211_register(wiphy)) |
| 8784 | { |
| 8785 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__); |
| 8786 | goto err_vosstop; |
| 8787 | } |
| 8788 | |
| 8789 | status = wlan_hdd_init_channels_for_cc(pHddCtx); |
| 8790 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 8791 | { |
| 8792 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: wlan_hdd_init_channels_for_cc failed", |
| 8793 | __func__); |
| 8794 | goto err_unregister_wiphy; |
| 8795 | } |
| 8796 | #endif |
| 8797 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8798 | if (VOS_STA_SAP_MODE == hdd_get_conparam()) |
| 8799 | { |
| 8800 | pAdapter = hdd_open_adapter( pHddCtx, WLAN_HDD_SOFTAP, "softap.%d", |
| 8801 | wlan_hdd_get_intf_addr(pHddCtx), FALSE ); |
| 8802 | } |
| 8803 | else |
| 8804 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8805 | pAdapter = hdd_open_adapter( pHddCtx, WLAN_HDD_INFRA_STATION, "wlan%d", |
| 8806 | wlan_hdd_get_intf_addr(pHddCtx), FALSE ); |
| 8807 | if (pAdapter != NULL) |
| 8808 | { |
kai | dde6998 | 2014-06-18 13:23:21 +0800 | [diff] [blame] | 8809 | if (pHddCtx->cfg_ini->isP2pDeviceAddrAdministrated && !(pHddCtx->cfg_ini->intfMacAddr[0].bytes[0] &= 0x02)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8810 | { |
Gopichand Nakkala | 49f96f6 | 2013-02-06 14:38:17 +0530 | [diff] [blame] | 8811 | vos_mem_copy( pHddCtx->p2pDeviceAddress.bytes, |
| 8812 | pHddCtx->cfg_ini->intfMacAddr[0].bytes, |
| 8813 | sizeof(tSirMacAddr)); |
Madan Mohan Koyyalamudi | edfc1b7 | 2012-10-18 20:25:55 -0700 | [diff] [blame] | 8814 | |
Gopichand Nakkala | 49f96f6 | 2013-02-06 14:38:17 +0530 | [diff] [blame] | 8815 | /* Generate the P2P Device Address. This consists of the device's |
| 8816 | * primary MAC address with the locally administered bit set. |
| 8817 | */ |
| 8818 | pHddCtx->p2pDeviceAddress.bytes[0] |= 0x02; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8819 | } |
| 8820 | else |
| 8821 | { |
Gopichand Nakkala | 49f96f6 | 2013-02-06 14:38:17 +0530 | [diff] [blame] | 8822 | tANI_U8* p2p_dev_addr = wlan_hdd_get_intf_addr(pHddCtx); |
| 8823 | if (p2p_dev_addr != NULL) |
| 8824 | { |
| 8825 | vos_mem_copy(&pHddCtx->p2pDeviceAddress.bytes[0], |
| 8826 | p2p_dev_addr, VOS_MAC_ADDR_SIZE); |
| 8827 | } |
| 8828 | else |
| 8829 | { |
| 8830 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 8831 | "%s: Failed to allocate mac_address for p2p_device", |
| 8832 | __func__); |
| 8833 | goto err_close_adapter; |
| 8834 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8835 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8836 | |
| 8837 | pP2pAdapter = hdd_open_adapter( pHddCtx, WLAN_HDD_P2P_DEVICE, "p2p%d", |
| 8838 | &pHddCtx->p2pDeviceAddress.bytes[0], FALSE ); |
| 8839 | if ( NULL == pP2pAdapter ) |
| 8840 | { |
| 8841 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 8842 | "%s: Failed to do hdd_open_adapter for P2P Device Interface", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 8843 | __func__); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8844 | goto err_close_adapter; |
| 8845 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8846 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8847 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8848 | |
| 8849 | if( pAdapter == NULL ) |
| 8850 | { |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 8851 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: hdd_open_adapter failed", __func__); |
| 8852 | goto err_close_adapter; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8853 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8854 | |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 8855 | if (country_code) |
| 8856 | { |
| 8857 | eHalStatus ret; |
Arif Hussain | cb60708 | 2013-12-20 11:57:42 -0800 | [diff] [blame] | 8858 | INIT_COMPLETION(pAdapter->change_country_code); |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 8859 | hdd_checkandupdate_dfssetting(pAdapter, country_code); |
| 8860 | #ifndef CONFIG_ENABLE_LINUX_REG |
| 8861 | hdd_checkandupdate_phymode(pAdapter, country_code); |
| 8862 | #endif |
Arif Hussain | eaf6860 | 2013-12-30 23:10:44 -0800 | [diff] [blame] | 8863 | ret = sme_ChangeCountryCode(pHddCtx->hHal, |
| 8864 | (void *)(tSmeChangeCountryCallback) |
| 8865 | wlan_hdd_change_country_code_callback, |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 8866 | country_code, |
| 8867 | pAdapter, pHddCtx->pvosContext, |
Abhishek Singh | a306a44 | 2013-11-07 18:39:01 +0530 | [diff] [blame] | 8868 | eSIR_TRUE, eSIR_TRUE); |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 8869 | if (eHAL_STATUS_SUCCESS == ret) |
| 8870 | { |
Arif Hussain | cb60708 | 2013-12-20 11:57:42 -0800 | [diff] [blame] | 8871 | ret = wait_for_completion_interruptible_timeout( |
| 8872 | &pAdapter->change_country_code, |
| 8873 | msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY)); |
| 8874 | |
| 8875 | if (0 >= ret) |
| 8876 | { |
| 8877 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 8878 | "%s: SME while setting country code timed out", __func__); |
| 8879 | } |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 8880 | } |
| 8881 | else |
| 8882 | { |
Arif Hussain | cb60708 | 2013-12-20 11:57:42 -0800 | [diff] [blame] | 8883 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 8884 | "%s: SME Change Country code from module param fail ret=%d", |
| 8885 | __func__, ret); |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 8886 | } |
| 8887 | } |
| 8888 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8889 | #ifdef WLAN_BTAMP_FEATURE |
| 8890 | vStatus = WLANBAP_Open(pVosContext); |
| 8891 | if(!VOS_IS_STATUS_SUCCESS(vStatus)) |
| 8892 | { |
| 8893 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 8894 | "%s: Failed to open BAP",__func__); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8895 | goto err_close_adapter; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8896 | } |
| 8897 | |
| 8898 | vStatus = BSL_Init(pVosContext); |
| 8899 | if(!VOS_IS_STATUS_SUCCESS(vStatus)) |
| 8900 | { |
| 8901 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 8902 | "%s: Failed to Init BSL",__func__); |
| 8903 | goto err_bap_close; |
| 8904 | } |
| 8905 | vStatus = WLANBAP_Start(pVosContext); |
| 8906 | if (!VOS_IS_STATUS_SUCCESS(vStatus)) |
| 8907 | { |
| 8908 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 8909 | "%s: Failed to start TL",__func__); |
| 8910 | goto err_bap_close; |
| 8911 | } |
| 8912 | |
| 8913 | pConfig = pHddCtx->cfg_ini; |
| 8914 | btAmpConfig.ucPreferredChannel = pConfig->preferredChannel; |
| 8915 | status = WLANBAP_SetConfig(&btAmpConfig); |
| 8916 | |
| 8917 | #endif //WLAN_BTAMP_FEATURE |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8918 | |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 8919 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 8920 | if(!(IS_ROAM_SCAN_OFFLOAD_FEATURE_ENABLE)) |
| 8921 | { |
| 8922 | hddLog(VOS_TRACE_LEVEL_DEBUG,"%s: ROAM_SCAN_OFFLOAD Feature not supported",__func__); |
| 8923 | pHddCtx->cfg_ini->isRoamOffloadScanEnabled = 0; |
| 8924 | sme_UpdateRoamScanOffloadEnabled((tHalHandle)(pHddCtx->hHal), |
| 8925 | pHddCtx->cfg_ini->isRoamOffloadScanEnabled); |
| 8926 | } |
| 8927 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8928 | |
Mihir Shete | fc7ff5b | 2014-01-27 11:30:05 +0530 | [diff] [blame] | 8929 | sme_Register11dScanDoneCallback(pHddCtx->hHal, hdd_11d_scan_done); |
| 8930 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8931 | /* Register with platform driver as client for Suspend/Resume */ |
| 8932 | status = hddRegisterPmOps(pHddCtx); |
| 8933 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 8934 | { |
| 8935 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddRegisterPmOps failed",__func__); |
| 8936 | #ifdef WLAN_BTAMP_FEATURE |
| 8937 | goto err_bap_stop; |
| 8938 | #else |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8939 | goto err_close_adapter; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8940 | #endif //WLAN_BTAMP_FEATURE |
| 8941 | } |
| 8942 | |
Yue Ma | 0d4891e | 2013-08-06 17:01:45 -0700 | [diff] [blame] | 8943 | /* Open debugfs interface */ |
| 8944 | if (VOS_STATUS_SUCCESS != hdd_debugfs_init(pAdapter)) |
| 8945 | { |
| 8946 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 8947 | "%s: hdd_debugfs_init failed!", __func__); |
Yue Ma | 0d4891e | 2013-08-06 17:01:45 -0700 | [diff] [blame] | 8948 | } |
| 8949 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8950 | /* Register TM level change handler function to the platform */ |
| 8951 | status = hddDevTmRegisterNotifyCallback(pHddCtx); |
| 8952 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 8953 | { |
| 8954 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddDevTmRegisterNotifyCallback failed",__func__); |
| 8955 | goto err_unregister_pmops; |
| 8956 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8957 | |
| 8958 | /* register for riva power on lock to platform driver */ |
| 8959 | if (req_riva_power_on_lock("wlan")) |
| 8960 | { |
| 8961 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: req riva power on lock failed", |
| 8962 | __func__); |
| 8963 | goto err_unregister_pmops; |
| 8964 | } |
| 8965 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8966 | // register net device notifier for device change notification |
| 8967 | ret = register_netdevice_notifier(&hdd_netdev_notifier); |
| 8968 | |
| 8969 | if(ret < 0) |
| 8970 | { |
| 8971 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: register_netdevice_notifier failed",__func__); |
| 8972 | goto err_free_power_on_lock; |
| 8973 | } |
| 8974 | |
| 8975 | //Initialize the nlink service |
| 8976 | if(nl_srv_init() != 0) |
| 8977 | { |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 8978 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: nl_srv_init failed", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8979 | goto err_reg_netdev; |
| 8980 | } |
| 8981 | |
Leo Chang | 4ce1cc5 | 2013-10-21 18:27:15 -0700 | [diff] [blame] | 8982 | #ifdef WLAN_KD_READY_NOTIFIER |
| 8983 | pHddCtx->kd_nl_init = 1; |
| 8984 | #endif /* WLAN_KD_READY_NOTIFIER */ |
| 8985 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8986 | //Initialize the BTC service |
| 8987 | if(btc_activate_service(pHddCtx) != 0) |
| 8988 | { |
| 8989 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: btc_activate_service failed",__func__); |
| 8990 | goto err_nl_srv; |
| 8991 | } |
| 8992 | |
| 8993 | #ifdef PTT_SOCK_SVC_ENABLE |
| 8994 | //Initialize the PTT service |
| 8995 | if(ptt_sock_activate_svc(pHddCtx) != 0) |
| 8996 | { |
| 8997 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: ptt_sock_activate_svc failed",__func__); |
| 8998 | goto err_nl_srv; |
| 8999 | } |
| 9000 | #endif |
| 9001 | |
Vinay Krishna Eranna | d938c42 | 2014-03-10 17:14:21 +0530 | [diff] [blame] | 9002 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 9003 | if(pHddCtx->cfg_ini && pHddCtx->cfg_ini->wlanLoggingEnable) |
| 9004 | { |
| 9005 | if(wlan_logging_sock_activate_svc( |
| 9006 | pHddCtx->cfg_ini->wlanLoggingFEToConsole, |
| 9007 | pHddCtx->cfg_ini->wlanLoggingNumBuf)) |
| 9008 | { |
| 9009 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wlan_logging_sock_activate_svc" |
| 9010 | " failed", __func__); |
| 9011 | goto err_nl_srv; |
| 9012 | } |
| 9013 | } |
| 9014 | #endif |
| 9015 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9016 | hdd_register_mcast_bcast_filter(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9017 | if (VOS_STA_SAP_MODE != hdd_get_conparam()) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9018 | { |
Madan Mohan Koyyalamudi | c537df2 | 2012-10-22 15:07:08 -0700 | [diff] [blame] | 9019 | /* Action frame registered in one adapter which will |
| 9020 | * applicable to all interfaces |
| 9021 | */ |
Agarwal Ashish | 8fa0e9a | 2014-05-23 00:40:12 +0530 | [diff] [blame] | 9022 | wlan_hdd_cfg80211_register_frames(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9023 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9024 | |
| 9025 | mutex_init(&pHddCtx->sap_lock); |
| 9026 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9027 | |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 9028 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9029 | #ifdef WLAN_FEATURE_HOLD_RX_WAKELOCK |
| 9030 | /* Initialize the wake lcok */ |
| 9031 | wake_lock_init(&pHddCtx->rx_wake_lock, |
| 9032 | WAKE_LOCK_SUSPEND, |
| 9033 | "qcom_rx_wakelock"); |
| 9034 | #endif |
Madan Mohan Koyyalamudi | 69fc3ad | 2012-11-28 16:04:56 -0800 | [diff] [blame] | 9035 | /* Initialize the wake lcok */ |
| 9036 | wake_lock_init(&pHddCtx->sap_wake_lock, |
| 9037 | WAKE_LOCK_SUSPEND, |
| 9038 | "qcom_sap_wakelock"); |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 9039 | #endif |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9040 | |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 9041 | vos_event_init(&pHddCtx->scan_info.scan_finished_event); |
| 9042 | pHddCtx->scan_info.scan_pending_option = WEXT_SCAN_PENDING_GIVEUP; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9043 | |
Katya Nigam | 5c306ea | 2014-06-19 15:39:54 +0530 | [diff] [blame] | 9044 | pHddCtx->isLoadUnloadInProgress = WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9045 | vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, FALSE); |
| 9046 | hdd_allow_suspend(); |
Katya Nigam | 5c306ea | 2014-06-19 15:39:54 +0530 | [diff] [blame] | 9047 | |
| 9048 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 9049 | /*SME must send channel update configuration to RIVA*/ |
| 9050 | sme_UpdateChannelConfig(pHddCtx->hHal); |
| 9051 | #endif |
| 9052 | |
Abhishek Singh | a306a44 | 2013-11-07 18:39:01 +0530 | [diff] [blame] | 9053 | #ifndef CONFIG_ENABLE_LINUX_REG |
| 9054 | /*updating wiphy so that regulatory user hints can be processed*/ |
| 9055 | if (wiphy) |
| 9056 | { |
| 9057 | regulatory_hint(wiphy, "00"); |
| 9058 | } |
| 9059 | #endif |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9060 | // Initialize the restart logic |
| 9061 | wlan_hdd_restart_init(pHddCtx); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 9062 | |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 9063 | //Register the traffic monitor timer now |
| 9064 | if ( pHddCtx->cfg_ini->dynSplitscan) |
| 9065 | { |
| 9066 | vos_timer_init(&pHddCtx->tx_rx_trafficTmr, |
| 9067 | VOS_TIMER_TYPE_SW, |
| 9068 | hdd_tx_rx_pkt_cnt_stat_timer_handler, |
| 9069 | (void *)pHddCtx); |
| 9070 | } |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 9071 | #ifdef WLAN_FEATURE_EXTSCAN |
| 9072 | sme_EXTScanRegisterCallback(pHddCtx->hHal, |
| 9073 | wlan_hdd_cfg80211_extscan_callback, |
| 9074 | pHddCtx); |
| 9075 | #endif /* WLAN_FEATURE_EXTSCAN */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9076 | goto success; |
| 9077 | |
| 9078 | err_nl_srv: |
Leo Chang | 59cdc7e | 2013-07-10 10:08:21 -0700 | [diff] [blame] | 9079 | #ifdef WLAN_KD_READY_NOTIFIER |
| 9080 | nl_srv_exit(pHddCtx->ptt_pid); |
| 9081 | #else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9082 | nl_srv_exit(); |
Leo Chang | 59cdc7e | 2013-07-10 10:08:21 -0700 | [diff] [blame] | 9083 | #endif /* WLAN_KD_READY_NOTIFIER */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9084 | err_reg_netdev: |
| 9085 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 9086 | |
| 9087 | err_free_power_on_lock: |
| 9088 | free_riva_power_on_lock("wlan"); |
| 9089 | |
| 9090 | err_unregister_pmops: |
| 9091 | hddDevTmUnregisterNotifyCallback(pHddCtx); |
| 9092 | hddDeregisterPmOps(pHddCtx); |
| 9093 | |
Yue Ma | 0d4891e | 2013-08-06 17:01:45 -0700 | [diff] [blame] | 9094 | hdd_debugfs_exit(pHddCtx); |
| 9095 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9096 | #ifdef WLAN_BTAMP_FEATURE |
| 9097 | err_bap_stop: |
| 9098 | WLANBAP_Stop(pVosContext); |
| 9099 | #endif |
| 9100 | |
| 9101 | #ifdef WLAN_BTAMP_FEATURE |
| 9102 | err_bap_close: |
| 9103 | WLANBAP_Close(pVosContext); |
| 9104 | #endif |
| 9105 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9106 | err_close_adapter: |
| 9107 | hdd_close_all_adapters( pHddCtx ); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 9108 | err_unregister_wiphy: |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 9109 | wiphy_unregister(wiphy) ; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9110 | err_vosstop: |
| 9111 | vos_stop(pVosContext); |
| 9112 | |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 9113 | err_vosclose: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9114 | status = vos_sched_close( pVosContext ); |
| 9115 | if (!VOS_IS_STATUS_SUCCESS(status)) { |
| 9116 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, |
| 9117 | "%s: Failed to close VOSS Scheduler", __func__); |
| 9118 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( status ) ); |
| 9119 | } |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 9120 | vos_close(pVosContext ); |
| 9121 | |
Amar Singhal | 0a40223 | 2013-10-11 20:57:16 -0700 | [diff] [blame] | 9122 | err_vos_nv_close: |
| 9123 | |
c_hpothu | e6a3628 | 2014-03-19 12:27:38 +0530 | [diff] [blame] | 9124 | #ifdef CONFIG_ENABLE_LINUX_REG |
Amar Singhal | 0a40223 | 2013-10-11 20:57:16 -0700 | [diff] [blame] | 9125 | vos_nv_close(); |
| 9126 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9127 | err_clkvote: |
c_hpothu | 70f8d81 | 2014-03-22 22:59:23 +0530 | [diff] [blame] | 9128 | #endif |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 9129 | vos_chipVoteOffXOBuffer(NULL, NULL, NULL); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9130 | |
| 9131 | err_wdclose: |
| 9132 | if(pHddCtx->cfg_ini->fIsLogpEnabled) |
| 9133 | vos_watchdog_close(pVosContext); |
| 9134 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9135 | err_config: |
| 9136 | kfree(pHddCtx->cfg_ini); |
| 9137 | pHddCtx->cfg_ini= NULL; |
| 9138 | |
| 9139 | err_free_hdd_context: |
| 9140 | hdd_allow_suspend(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9141 | wiphy_free(wiphy) ; |
| 9142 | //kfree(wdev) ; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9143 | VOS_BUG(1); |
| 9144 | |
Madan Mohan Koyyalamudi | d57ae63 | 2012-11-06 18:42:48 -0800 | [diff] [blame] | 9145 | if (hdd_is_ssr_required()) |
| 9146 | { |
| 9147 | /* WDI timeout had happened during load, so SSR is needed here */ |
| 9148 | subsystem_restart("wcnss"); |
| 9149 | msleep(5000); |
| 9150 | } |
| 9151 | hdd_set_ssr_required (VOS_FALSE); |
| 9152 | |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 9153 | return -EIO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9154 | |
| 9155 | success: |
| 9156 | EXIT(); |
| 9157 | return 0; |
| 9158 | } |
| 9159 | |
| 9160 | /**--------------------------------------------------------------------------- |
| 9161 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 9162 | \brief hdd_driver_init() - Core Driver Init Function |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9163 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 9164 | This is the driver entry point - called in different timeline depending |
| 9165 | on whether the driver is statically or dynamically linked |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9166 | |
| 9167 | \param - None |
| 9168 | |
| 9169 | \return - 0 for success, non zero for failure |
| 9170 | |
| 9171 | --------------------------------------------------------------------------*/ |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 9172 | static int hdd_driver_init( void) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9173 | { |
| 9174 | VOS_STATUS status; |
| 9175 | v_CONTEXT_t pVosContext = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9176 | struct device *dev = NULL; |
| 9177 | int ret_status = 0; |
Sameer Thalappil | f58d7ec | 2013-04-25 20:17:12 -0700 | [diff] [blame] | 9178 | #ifdef HAVE_WCNSS_CAL_DOWNLOAD |
| 9179 | int max_retries = 0; |
| 9180 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9181 | |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 9182 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 9183 | wlan_logging_sock_init_svc(); |
| 9184 | #endif |
| 9185 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9186 | ENTER(); |
| 9187 | |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 9188 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9189 | wake_lock_init(&wlan_wake_lock, WAKE_LOCK_SUSPEND, "wlan"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9190 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9191 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 9192 | hddTraceInit(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9193 | pr_info("%s: loading driver v%s\n", WLAN_MODULE_NAME, |
| 9194 | QWLAN_VERSIONSTR TIMER_MANAGER_STR MEMORY_DEBUG_STR); |
| 9195 | |
| 9196 | //Power Up Libra WLAN card first if not already powered up |
| 9197 | status = vos_chipPowerUp(NULL,NULL,NULL); |
| 9198 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 9199 | { |
| 9200 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Libra WLAN not Powered Up. " |
| 9201 | "exiting", __func__); |
madan mohan koyyalamudi | 8c96ce1 | 2013-07-10 19:14:39 +0530 | [diff] [blame] | 9202 | #ifdef WLAN_OPEN_SOURCE |
| 9203 | wake_lock_destroy(&wlan_wake_lock); |
| 9204 | #endif |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 9205 | |
| 9206 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 9207 | wlan_logging_sock_deinit_svc(); |
| 9208 | #endif |
| 9209 | |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 9210 | return -EIO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9211 | } |
| 9212 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9213 | #ifdef ANI_BUS_TYPE_PCI |
| 9214 | |
| 9215 | dev = wcnss_wlan_get_device(); |
| 9216 | |
| 9217 | #endif // ANI_BUS_TYPE_PCI |
| 9218 | |
| 9219 | #ifdef ANI_BUS_TYPE_PLATFORM |
Sameer Thalappil | f58d7ec | 2013-04-25 20:17:12 -0700 | [diff] [blame] | 9220 | |
| 9221 | #ifdef HAVE_WCNSS_CAL_DOWNLOAD |
| 9222 | /* wait until WCNSS driver downloads NV */ |
| 9223 | while (!wcnss_device_ready() && 5 >= ++max_retries) { |
| 9224 | msleep(1000); |
| 9225 | } |
| 9226 | if (max_retries >= 5) { |
| 9227 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: WCNSS driver not ready", __func__); |
madan mohan koyyalamudi | 8c96ce1 | 2013-07-10 19:14:39 +0530 | [diff] [blame] | 9228 | #ifdef WLAN_OPEN_SOURCE |
| 9229 | wake_lock_destroy(&wlan_wake_lock); |
| 9230 | #endif |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 9231 | |
| 9232 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 9233 | wlan_logging_sock_deinit_svc(); |
| 9234 | #endif |
| 9235 | |
Sameer Thalappil | f58d7ec | 2013-04-25 20:17:12 -0700 | [diff] [blame] | 9236 | return -ENODEV; |
| 9237 | } |
| 9238 | #endif |
| 9239 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9240 | dev = wcnss_wlan_get_device(); |
| 9241 | #endif // ANI_BUS_TYPE_PLATFORM |
| 9242 | |
| 9243 | |
| 9244 | do { |
| 9245 | if (NULL == dev) { |
| 9246 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: WLAN device not found!!",__func__); |
| 9247 | ret_status = -1; |
| 9248 | break; |
| 9249 | } |
| 9250 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9251 | #ifdef TIMER_MANAGER |
| 9252 | vos_timer_manager_init(); |
| 9253 | #endif |
| 9254 | |
| 9255 | /* Preopen VOSS so that it is ready to start at least SAL */ |
| 9256 | status = vos_preOpen(&pVosContext); |
| 9257 | |
| 9258 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 9259 | { |
| 9260 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Failed to preOpen VOSS", __func__); |
| 9261 | ret_status = -1; |
| 9262 | break; |
| 9263 | } |
| 9264 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 9265 | #ifndef MODULE |
| 9266 | /* For statically linked driver, call hdd_set_conparam to update curr_con_mode |
| 9267 | */ |
| 9268 | hdd_set_conparam((v_UINT_t)con_mode); |
| 9269 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9270 | |
| 9271 | // Call our main init function |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 9272 | if (hdd_wlan_startup(dev)) |
| 9273 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9274 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: WLAN Driver Initialization failed", |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 9275 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9276 | vos_preClose( &pVosContext ); |
| 9277 | ret_status = -1; |
| 9278 | break; |
| 9279 | } |
| 9280 | |
| 9281 | /* Cancel the vote for XO Core ON |
| 9282 | * This is done here for safety purposes in case we re-initialize without turning |
| 9283 | * it OFF in any error scenario. |
| 9284 | */ |
Madan Mohan Koyyalamudi | 8b7f1e6 | 2012-10-05 14:56:51 -0700 | [diff] [blame] | 9285 | hddLog(VOS_TRACE_LEVEL_INFO, "In module init: Ensure Force XO Core is OFF" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9286 | " when WLAN is turned ON so Core toggles" |
Madan Mohan Koyyalamudi | 8b7f1e6 | 2012-10-05 14:56:51 -0700 | [diff] [blame] | 9287 | " unless we enter PSD"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9288 | if (vos_chipVoteXOCore(NULL, NULL, NULL, VOS_FALSE) != VOS_STATUS_SUCCESS) |
| 9289 | { |
| 9290 | hddLog(VOS_TRACE_LEVEL_ERROR, "Could not cancel XO Core ON vote. Not returning failure." |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 9291 | " Power consumed will be high"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9292 | } |
| 9293 | } while (0); |
| 9294 | |
| 9295 | if (0 != ret_status) |
| 9296 | { |
| 9297 | //Assert Deep sleep signal now to put Libra HW in lowest power state |
| 9298 | status = vos_chipAssertDeepSleep( NULL, NULL, NULL ); |
| 9299 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( status) ); |
| 9300 | |
| 9301 | //Vote off any PMIC voltage supplies |
| 9302 | vos_chipPowerDown(NULL, NULL, NULL); |
| 9303 | #ifdef TIMER_MANAGER |
| 9304 | vos_timer_exit(); |
| 9305 | #endif |
| 9306 | #ifdef MEMORY_DEBUG |
| 9307 | vos_mem_exit(); |
| 9308 | #endif |
| 9309 | |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 9310 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9311 | wake_lock_destroy(&wlan_wake_lock); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9312 | #endif |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 9313 | |
| 9314 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 9315 | wlan_logging_sock_deinit_svc(); |
| 9316 | #endif |
| 9317 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9318 | pr_err("%s: driver load failure\n", WLAN_MODULE_NAME); |
| 9319 | } |
| 9320 | else |
| 9321 | { |
| 9322 | //Send WLAN UP indication to Nlink Service |
| 9323 | send_btc_nlink_msg(WLAN_MODULE_UP_IND, 0); |
| 9324 | |
| 9325 | pr_info("%s: driver loaded\n", WLAN_MODULE_NAME); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9326 | } |
| 9327 | |
| 9328 | EXIT(); |
| 9329 | |
| 9330 | return ret_status; |
| 9331 | } |
| 9332 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 9333 | /**--------------------------------------------------------------------------- |
| 9334 | |
| 9335 | \brief hdd_module_init() - Init Function |
| 9336 | |
| 9337 | This is the driver entry point (invoked when module is loaded using insmod) |
| 9338 | |
| 9339 | \param - None |
| 9340 | |
| 9341 | \return - 0 for success, non zero for failure |
| 9342 | |
| 9343 | --------------------------------------------------------------------------*/ |
| 9344 | #ifdef MODULE |
| 9345 | static int __init hdd_module_init ( void) |
| 9346 | { |
| 9347 | return hdd_driver_init(); |
| 9348 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 9349 | #else /* #ifdef MODULE */ |
| 9350 | static int __init hdd_module_init ( void) |
| 9351 | { |
| 9352 | /* Driver initialization is delayed to fwpath_changed_handler */ |
| 9353 | return 0; |
| 9354 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 9355 | #endif /* #ifdef MODULE */ |
| 9356 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9357 | |
| 9358 | /**--------------------------------------------------------------------------- |
| 9359 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 9360 | \brief hdd_driver_exit() - Exit function |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9361 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 9362 | This is the driver exit point (invoked when module is unloaded using rmmod |
| 9363 | or con_mode was changed by userspace) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9364 | |
| 9365 | \param - None |
| 9366 | |
| 9367 | \return - None |
| 9368 | |
| 9369 | --------------------------------------------------------------------------*/ |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 9370 | static void hdd_driver_exit(void) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9371 | { |
| 9372 | hdd_context_t *pHddCtx = NULL; |
| 9373 | v_CONTEXT_t pVosContext = NULL; |
Agarwal Ashish | 5e41479 | 2014-06-08 15:25:23 +0530 | [diff] [blame] | 9374 | v_REGDOMAIN_t regId; |
Arun Kumar Khandavalli | e0b046d | 2014-03-01 21:54:25 +0530 | [diff] [blame] | 9375 | unsigned long rc = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9376 | |
| 9377 | pr_info("%s: unloading driver v%s\n", WLAN_MODULE_NAME, QWLAN_VERSIONSTR); |
| 9378 | |
| 9379 | //Get the global vos context |
| 9380 | pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL); |
| 9381 | |
| 9382 | if(!pVosContext) |
| 9383 | { |
| 9384 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Global VOS context is Null", __func__); |
| 9385 | goto done; |
| 9386 | } |
| 9387 | |
| 9388 | //Get the HDD context. |
| 9389 | pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext ); |
| 9390 | |
| 9391 | if(!pHddCtx) |
| 9392 | { |
| 9393 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: module exit called before probe",__func__); |
| 9394 | } |
| 9395 | else |
| 9396 | { |
Arun Kumar Khandavalli | e0b046d | 2014-03-01 21:54:25 +0530 | [diff] [blame] | 9397 | INIT_COMPLETION(pHddCtx->ssr_comp_var); |
| 9398 | |
| 9399 | if (pHddCtx->isLogpInProgress) |
| 9400 | { |
Sameer Thalappil | 451ebb9 | 2013-06-28 15:49:58 -0700 | [diff] [blame] | 9401 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Arun Kumar Khandavalli | e0b046d | 2014-03-01 21:54:25 +0530 | [diff] [blame] | 9402 | "%s:SSR in Progress; block rmmod !!!", __func__); |
| 9403 | rc = wait_for_completion_timeout(&pHddCtx->ssr_comp_var, |
| 9404 | msecs_to_jiffies(30000)); |
| 9405 | if(!rc) |
| 9406 | { |
| 9407 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 9408 | "%s:SSR timedout, fatal error", __func__); |
| 9409 | VOS_BUG(0); |
Sameer Thalappil | 451ebb9 | 2013-06-28 15:49:58 -0700 | [diff] [blame] | 9410 | } |
Arun Kumar Khandavalli | e0b046d | 2014-03-01 21:54:25 +0530 | [diff] [blame] | 9411 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9412 | |
Mihir Shete | 1815629 | 2014-03-11 15:38:30 +0530 | [diff] [blame] | 9413 | pHddCtx->isLoadUnloadInProgress = WLAN_HDD_UNLOAD_IN_PROGRESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9414 | vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, TRUE); |
| 9415 | |
Agarwal Ashish | 5e41479 | 2014-06-08 15:25:23 +0530 | [diff] [blame] | 9416 | if (eANI_BOOLEAN_TRUE == sme_Is11dCountrycode(pHddCtx->hHal) && |
| 9417 | pHddCtx->cfg_ini->fSupplicantCountryCodeHasPriority ) |
| 9418 | { |
| 9419 | vos_nv_getRegDomainFromCountryCode(®Id , "00", COUNTRY_USER); |
| 9420 | } |
| 9421 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9422 | //Do all the cleanup before deregistering the driver |
| 9423 | hdd_wlan_exit(pHddCtx); |
| 9424 | } |
| 9425 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9426 | vos_preClose( &pVosContext ); |
| 9427 | |
| 9428 | #ifdef TIMER_MANAGER |
| 9429 | vos_timer_exit(); |
| 9430 | #endif |
| 9431 | #ifdef MEMORY_DEBUG |
| 9432 | vos_mem_exit(); |
| 9433 | #endif |
| 9434 | |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 9435 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 9436 | wlan_logging_sock_deinit_svc(); |
| 9437 | #endif |
| 9438 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9439 | done: |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 9440 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9441 | wake_lock_destroy(&wlan_wake_lock); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9442 | #endif |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 9443 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9444 | pr_info("%s: driver unloaded\n", WLAN_MODULE_NAME); |
| 9445 | } |
| 9446 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 9447 | /**--------------------------------------------------------------------------- |
| 9448 | |
| 9449 | \brief hdd_module_exit() - Exit function |
| 9450 | |
| 9451 | This is the driver exit point (invoked when module is unloaded using rmmod) |
| 9452 | |
| 9453 | \param - None |
| 9454 | |
| 9455 | \return - None |
| 9456 | |
| 9457 | --------------------------------------------------------------------------*/ |
| 9458 | static void __exit hdd_module_exit(void) |
| 9459 | { |
| 9460 | hdd_driver_exit(); |
| 9461 | } |
| 9462 | |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 9463 | #ifdef MODULE |
| 9464 | static int fwpath_changed_handler(const char *kmessage, |
| 9465 | struct kernel_param *kp) |
| 9466 | { |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 9467 | return param_set_copystring(kmessage, kp); |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 9468 | } |
| 9469 | |
| 9470 | static int con_mode_handler(const char *kmessage, |
| 9471 | struct kernel_param *kp) |
| 9472 | { |
Madan Mohan Koyyalamudi | f2f8d8b | 2012-10-11 17:06:59 -0700 | [diff] [blame] | 9473 | return param_set_int(kmessage, kp); |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 9474 | } |
| 9475 | #else /* #ifdef MODULE */ |
| 9476 | /**--------------------------------------------------------------------------- |
| 9477 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 9478 | \brief kickstart_driver |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 9479 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 9480 | This is the driver entry point |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 9481 | - delayed driver initialization when driver is statically linked |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 9482 | - invoked when module parameter fwpath is modified from userspace to signal |
| 9483 | initializing the WLAN driver or when con_mode is modified from userspace |
| 9484 | to signal a switch in operating mode |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 9485 | |
| 9486 | \return - 0 for success, non zero for failure |
| 9487 | |
| 9488 | --------------------------------------------------------------------------*/ |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 9489 | static int kickstart_driver(void) |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 9490 | { |
Madan Mohan Koyyalamudi | 62e6005 | 2012-10-05 14:27:22 -0700 | [diff] [blame] | 9491 | int ret_status; |
| 9492 | |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 9493 | if (!wlan_hdd_inited) { |
Madan Mohan Koyyalamudi | 62e6005 | 2012-10-05 14:27:22 -0700 | [diff] [blame] | 9494 | ret_status = hdd_driver_init(); |
| 9495 | wlan_hdd_inited = ret_status ? 0 : 1; |
| 9496 | return ret_status; |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 9497 | } |
| 9498 | |
| 9499 | hdd_driver_exit(); |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 9500 | |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 9501 | msleep(200); |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 9502 | |
Madan Mohan Koyyalamudi | 62e6005 | 2012-10-05 14:27:22 -0700 | [diff] [blame] | 9503 | ret_status = hdd_driver_init(); |
| 9504 | wlan_hdd_inited = ret_status ? 0 : 1; |
| 9505 | return ret_status; |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 9506 | } |
| 9507 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9508 | /**--------------------------------------------------------------------------- |
| 9509 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 9510 | \brief fwpath_changed_handler() - Handler Function |
| 9511 | |
| 9512 | Handle changes to the fwpath parameter |
| 9513 | |
| 9514 | \return - 0 for success, non zero for failure |
| 9515 | |
| 9516 | --------------------------------------------------------------------------*/ |
| 9517 | static int fwpath_changed_handler(const char *kmessage, |
| 9518 | struct kernel_param *kp) |
| 9519 | { |
| 9520 | int ret; |
| 9521 | |
| 9522 | ret = param_set_copystring(kmessage, kp); |
| 9523 | if (0 == ret) |
| 9524 | ret = kickstart_driver(); |
| 9525 | return ret; |
| 9526 | } |
| 9527 | |
| 9528 | /**--------------------------------------------------------------------------- |
| 9529 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 9530 | \brief con_mode_handler() - |
| 9531 | |
| 9532 | Handler function for module param con_mode when it is changed by userspace |
| 9533 | Dynamically linked - do nothing |
| 9534 | Statically linked - exit and init driver, as in rmmod and insmod |
| 9535 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 9536 | \param - |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 9537 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 9538 | \return - |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 9539 | |
| 9540 | --------------------------------------------------------------------------*/ |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 9541 | static int con_mode_handler(const char *kmessage, struct kernel_param *kp) |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 9542 | { |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 9543 | int ret; |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 9544 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 9545 | ret = param_set_int(kmessage, kp); |
| 9546 | if (0 == ret) |
| 9547 | ret = kickstart_driver(); |
| 9548 | return ret; |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 9549 | } |
| 9550 | #endif /* #ifdef MODULE */ |
| 9551 | |
| 9552 | /**--------------------------------------------------------------------------- |
| 9553 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9554 | \brief hdd_get_conparam() - |
| 9555 | |
| 9556 | This is the driver exit point (invoked when module is unloaded using rmmod) |
| 9557 | |
| 9558 | \param - None |
| 9559 | |
| 9560 | \return - tVOS_CON_MODE |
| 9561 | |
| 9562 | --------------------------------------------------------------------------*/ |
| 9563 | tVOS_CON_MODE hdd_get_conparam ( void ) |
| 9564 | { |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 9565 | #ifdef MODULE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9566 | return (tVOS_CON_MODE)con_mode; |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 9567 | #else |
| 9568 | return (tVOS_CON_MODE)curr_con_mode; |
| 9569 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9570 | } |
| 9571 | void hdd_set_conparam ( v_UINT_t newParam ) |
| 9572 | { |
| 9573 | con_mode = newParam; |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 9574 | #ifndef MODULE |
| 9575 | curr_con_mode = con_mode; |
| 9576 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9577 | } |
| 9578 | /**--------------------------------------------------------------------------- |
| 9579 | |
| 9580 | \brief hdd_softap_sta_deauth() - function |
| 9581 | |
| 9582 | This to take counter measure to handle deauth req from HDD |
| 9583 | |
| 9584 | \param - pAdapter - Pointer to the HDD |
| 9585 | |
| 9586 | \param - enable - boolean value |
| 9587 | |
| 9588 | \return - None |
| 9589 | |
| 9590 | --------------------------------------------------------------------------*/ |
| 9591 | |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 9592 | VOS_STATUS hdd_softap_sta_deauth(hdd_adapter_t *pAdapter, v_U8_t *pDestMacAddress) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9593 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9594 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 9595 | VOS_STATUS vosStatus = VOS_STATUS_E_FAULT; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9596 | |
| 9597 | ENTER(); |
| 9598 | |
Rajesh Chauhan | 18488fc | 2013-08-22 10:15:03 -0700 | [diff] [blame] | 9599 | hddLog(LOG1, "hdd_softap_sta_deauth:(%p, false)", |
| 9600 | (WLAN_HDD_GET_CTX(pAdapter))->pvosContext); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9601 | |
| 9602 | //Ignore request to deauth bcmc station |
| 9603 | if( pDestMacAddress[0] & 0x1 ) |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 9604 | return vosStatus; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9605 | |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 9606 | vosStatus = WLANSAP_DeauthSta(pVosContext,pDestMacAddress); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9607 | |
| 9608 | EXIT(); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 9609 | return vosStatus; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9610 | } |
| 9611 | |
| 9612 | /**--------------------------------------------------------------------------- |
| 9613 | |
| 9614 | \brief hdd_softap_sta_disassoc() - function |
| 9615 | |
| 9616 | This to take counter measure to handle deauth req from HDD |
| 9617 | |
| 9618 | \param - pAdapter - Pointer to the HDD |
| 9619 | |
| 9620 | \param - enable - boolean value |
| 9621 | |
| 9622 | \return - None |
| 9623 | |
| 9624 | --------------------------------------------------------------------------*/ |
| 9625 | |
| 9626 | void hdd_softap_sta_disassoc(hdd_adapter_t *pAdapter,v_U8_t *pDestMacAddress) |
| 9627 | { |
| 9628 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
| 9629 | |
| 9630 | ENTER(); |
| 9631 | |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 9632 | hddLog( LOGE, "hdd_softap_sta_disassoc:(%p, false)", (WLAN_HDD_GET_CTX(pAdapter))->pvosContext); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9633 | |
| 9634 | //Ignore request to disassoc bcmc station |
| 9635 | if( pDestMacAddress[0] & 0x1 ) |
| 9636 | return; |
| 9637 | |
| 9638 | WLANSAP_DisassocSta(pVosContext,pDestMacAddress); |
| 9639 | } |
| 9640 | |
| 9641 | void hdd_softap_tkip_mic_fail_counter_measure(hdd_adapter_t *pAdapter,v_BOOL_t enable) |
| 9642 | { |
| 9643 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
| 9644 | |
| 9645 | ENTER(); |
| 9646 | |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 9647 | hddLog( LOGE, "hdd_softap_tkip_mic_fail_counter_measure:(%p, false)", (WLAN_HDD_GET_CTX(pAdapter))->pvosContext); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9648 | |
| 9649 | WLANSAP_SetCounterMeasure(pVosContext, (v_BOOL_t)enable); |
| 9650 | } |
| 9651 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9652 | /**--------------------------------------------------------------------------- |
| 9653 | * |
| 9654 | * \brief hdd_get__concurrency_mode() - |
| 9655 | * |
| 9656 | * |
| 9657 | * \param - None |
| 9658 | * |
| 9659 | * \return - CONCURRENCY MODE |
| 9660 | * |
| 9661 | * --------------------------------------------------------------------------*/ |
| 9662 | tVOS_CONCURRENCY_MODE hdd_get_concurrency_mode ( void ) |
| 9663 | { |
| 9664 | v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL ); |
| 9665 | hdd_context_t *pHddCtx; |
| 9666 | |
| 9667 | if (NULL != pVosContext) |
| 9668 | { |
| 9669 | pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext); |
| 9670 | if (NULL != pHddCtx) |
| 9671 | { |
| 9672 | return (tVOS_CONCURRENCY_MODE)pHddCtx->concurrency_mode; |
| 9673 | } |
| 9674 | } |
| 9675 | |
| 9676 | /* we are in an invalid state :( */ |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 9677 | hddLog(LOGE, "%s: Invalid context", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9678 | return VOS_STA; |
| 9679 | } |
| 9680 | |
| 9681 | /* Decide whether to allow/not the apps power collapse. |
| 9682 | * Allow apps power collapse if we are in connected state. |
| 9683 | * if not, allow only if we are in IMPS */ |
| 9684 | v_BOOL_t hdd_is_apps_power_collapse_allowed(hdd_context_t* pHddCtx) |
| 9685 | { |
| 9686 | tPmcState pmcState = pmcGetPmcState(pHddCtx->hHal); |
Srikant Kuppa | fef66a7 | 2013-01-30 17:32:44 -0800 | [diff] [blame] | 9687 | tANI_BOOLEAN scanRspPending = csrNeighborRoamScanRspPending(pHddCtx->hHal); |
Srinivas Girigowda | a553c46 | 2013-03-07 19:42:52 -0800 | [diff] [blame] | 9688 | tANI_BOOLEAN inMiddleOfRoaming = csrNeighborMiddleOfRoaming(pHddCtx->hHal); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9689 | hdd_config_t *pConfig = pHddCtx->cfg_ini; |
| 9690 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 9691 | hdd_adapter_t *pAdapter = NULL; |
| 9692 | VOS_STATUS status; |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 9693 | tVOS_CONCURRENCY_MODE concurrent_state = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9694 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9695 | if (VOS_STA_SAP_MODE == hdd_get_conparam()) |
| 9696 | return TRUE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9697 | |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 9698 | concurrent_state = hdd_get_concurrency_mode(); |
| 9699 | |
| 9700 | #ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE |
| 9701 | if(((concurrent_state == (VOS_STA | VOS_P2P_CLIENT)) || |
| 9702 | (concurrent_state == (VOS_STA | VOS_P2P_GO))) && |
| 9703 | (IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)) |
| 9704 | return TRUE; |
| 9705 | #endif |
| 9706 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9707 | /*loop through all adapters. TBD fix for Concurrency */ |
| 9708 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 9709 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 9710 | { |
| 9711 | pAdapter = pAdapterNode->pAdapter; |
| 9712 | if ( (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) |
| 9713 | || (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ) |
| 9714 | { |
Srikant Kuppa | fef66a7 | 2013-01-30 17:32:44 -0800 | [diff] [blame] | 9715 | if (((pConfig->fIsImpsEnabled || pConfig->fIsBmpsEnabled) |
c_hpothu | 4e8faac | 2014-05-16 17:38:44 +0530 | [diff] [blame] | 9716 | && (pmcState != IMPS && pmcState != BMPS && pmcState != UAPSD |
Srikant Kuppa | fef66a7 | 2013-01-30 17:32:44 -0800 | [diff] [blame] | 9717 | && pmcState != STOPPED && pmcState != STANDBY)) || |
Srinivas Girigowda | a553c46 | 2013-03-07 19:42:52 -0800 | [diff] [blame] | 9718 | (eANI_BOOLEAN_TRUE == scanRspPending) || |
| 9719 | (eANI_BOOLEAN_TRUE == inMiddleOfRoaming)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9720 | { |
Srikant Kuppa | fef66a7 | 2013-01-30 17:32:44 -0800 | [diff] [blame] | 9721 | hddLog( LOGE, "%s: do not allow APPS power collapse-" |
Srinivas Girigowda | a553c46 | 2013-03-07 19:42:52 -0800 | [diff] [blame] | 9722 | "pmcState = %d scanRspPending = %d inMiddleOfRoaming = %d", |
| 9723 | __func__, pmcState, scanRspPending, inMiddleOfRoaming ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9724 | return FALSE; |
| 9725 | } |
| 9726 | } |
| 9727 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 9728 | pAdapterNode = pNext; |
| 9729 | } |
| 9730 | return TRUE; |
| 9731 | } |
| 9732 | |
Madan Mohan Koyyalamudi | c72a4d6 | 2012-11-08 14:59:34 -0800 | [diff] [blame] | 9733 | /* Decides whether to send suspend notification to Riva |
| 9734 | * if any adapter is in BMPS; then it is required */ |
| 9735 | v_BOOL_t hdd_is_suspend_notify_allowed(hdd_context_t* pHddCtx) |
| 9736 | { |
| 9737 | tPmcState pmcState = pmcGetPmcState(pHddCtx->hHal); |
| 9738 | hdd_config_t *pConfig = pHddCtx->cfg_ini; |
| 9739 | |
| 9740 | if (pConfig->fIsBmpsEnabled && (pmcState == BMPS)) |
| 9741 | { |
| 9742 | return TRUE; |
| 9743 | } |
| 9744 | return FALSE; |
| 9745 | } |
| 9746 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9747 | void wlan_hdd_set_concurrency_mode(hdd_context_t *pHddCtx, tVOS_CON_MODE mode) |
| 9748 | { |
| 9749 | switch(mode) |
| 9750 | { |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 9751 | case VOS_STA_MODE: |
| 9752 | case VOS_P2P_CLIENT_MODE: |
| 9753 | case VOS_P2P_GO_MODE: |
| 9754 | case VOS_STA_SAP_MODE: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9755 | pHddCtx->concurrency_mode |= (1 << mode); |
| 9756 | pHddCtx->no_of_sessions[mode]++; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9757 | break; |
| 9758 | default: |
| 9759 | break; |
| 9760 | |
| 9761 | } |
| 9762 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: concurrency_mode = 0x%x NumberofSessions for mode %d = %d", |
| 9763 | __func__,pHddCtx->concurrency_mode,mode,pHddCtx->no_of_sessions[mode]); |
| 9764 | } |
| 9765 | |
| 9766 | |
| 9767 | void wlan_hdd_clear_concurrency_mode(hdd_context_t *pHddCtx, tVOS_CON_MODE mode) |
| 9768 | { |
| 9769 | switch(mode) |
| 9770 | { |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 9771 | case VOS_STA_MODE: |
| 9772 | case VOS_P2P_CLIENT_MODE: |
| 9773 | case VOS_P2P_GO_MODE: |
| 9774 | case VOS_STA_SAP_MODE: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9775 | pHddCtx->no_of_sessions[mode]--; |
| 9776 | if (!(pHddCtx->no_of_sessions[mode])) |
| 9777 | pHddCtx->concurrency_mode &= (~(1 << mode)); |
| 9778 | break; |
| 9779 | default: |
| 9780 | break; |
| 9781 | } |
| 9782 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: concurrency_mode = 0x%x NumberofSessions for mode %d = %d", |
| 9783 | __func__,pHddCtx->concurrency_mode,mode,pHddCtx->no_of_sessions[mode]); |
| 9784 | } |
| 9785 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9786 | /**--------------------------------------------------------------------------- |
| 9787 | * |
| 9788 | * \brief wlan_hdd_restart_init |
| 9789 | * |
| 9790 | * This function initalizes restart timer/flag. An internal function. |
| 9791 | * |
| 9792 | * \param - pHddCtx |
| 9793 | * |
| 9794 | * \return - None |
| 9795 | * |
| 9796 | * --------------------------------------------------------------------------*/ |
| 9797 | |
| 9798 | static void wlan_hdd_restart_init(hdd_context_t *pHddCtx) |
| 9799 | { |
| 9800 | /* Initialize */ |
| 9801 | pHddCtx->hdd_restart_retries = 0; |
| 9802 | atomic_set(&pHddCtx->isRestartInProgress, 0); |
| 9803 | vos_timer_init(&pHddCtx->hdd_restart_timer, |
| 9804 | VOS_TIMER_TYPE_SW, |
| 9805 | wlan_hdd_restart_timer_cb, |
| 9806 | pHddCtx); |
| 9807 | } |
| 9808 | /**--------------------------------------------------------------------------- |
| 9809 | * |
| 9810 | * \brief wlan_hdd_restart_deinit |
| 9811 | * |
| 9812 | * This function cleans up the resources used. An internal function. |
| 9813 | * |
| 9814 | * \param - pHddCtx |
| 9815 | * |
| 9816 | * \return - None |
| 9817 | * |
| 9818 | * --------------------------------------------------------------------------*/ |
| 9819 | |
| 9820 | static void wlan_hdd_restart_deinit(hdd_context_t* pHddCtx) |
| 9821 | { |
| 9822 | |
| 9823 | VOS_STATUS vos_status; |
| 9824 | /* Block any further calls */ |
| 9825 | atomic_set(&pHddCtx->isRestartInProgress, 1); |
| 9826 | /* Cleanup */ |
| 9827 | vos_status = vos_timer_stop( &pHddCtx->hdd_restart_timer ); |
| 9828 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 9829 | hddLog(LOGE, FL("Failed to stop HDD restart timer")); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9830 | vos_status = vos_timer_destroy(&pHddCtx->hdd_restart_timer); |
| 9831 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 9832 | hddLog(LOGE, FL("Failed to destroy HDD restart timer")); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9833 | |
| 9834 | } |
| 9835 | |
| 9836 | /**--------------------------------------------------------------------------- |
| 9837 | * |
| 9838 | * \brief wlan_hdd_framework_restart |
| 9839 | * |
| 9840 | * This function uses a cfg80211 API to start a framework initiated WLAN |
| 9841 | * driver module unload/load. |
| 9842 | * |
| 9843 | * Also this API keep retrying (WLAN_HDD_RESTART_RETRY_MAX_CNT). |
| 9844 | * |
| 9845 | * |
| 9846 | * \param - pHddCtx |
| 9847 | * |
| 9848 | * \return - VOS_STATUS_SUCCESS: Success |
| 9849 | * VOS_STATUS_E_EMPTY: Adapter is Empty |
| 9850 | * VOS_STATUS_E_NOMEM: No memory |
| 9851 | |
| 9852 | * --------------------------------------------------------------------------*/ |
| 9853 | |
| 9854 | static VOS_STATUS wlan_hdd_framework_restart(hdd_context_t *pHddCtx) |
| 9855 | { |
| 9856 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 9857 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
Madan Mohan Koyyalamudi | fc19e44 | 2013-05-09 18:24:08 -0700 | [diff] [blame] | 9858 | int len = (sizeof (struct ieee80211_mgmt)); |
| 9859 | struct ieee80211_mgmt *mgmt = NULL; |
| 9860 | |
| 9861 | /* Prepare the DEAUTH managment frame with reason code */ |
| 9862 | mgmt = kzalloc(len, GFP_KERNEL); |
| 9863 | if(mgmt == NULL) |
| 9864 | { |
| 9865 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 9866 | "%s: memory allocation failed (%d bytes)", __func__, len); |
| 9867 | return VOS_STATUS_E_NOMEM; |
| 9868 | } |
| 9869 | mgmt->u.deauth.reason_code = WLAN_REASON_DISASSOC_LOW_ACK; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9870 | |
| 9871 | /* Iterate over all adapters/devices */ |
| 9872 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 9873 | do |
| 9874 | { |
| 9875 | if( (status == VOS_STATUS_SUCCESS) && |
| 9876 | pAdapterNode && |
| 9877 | pAdapterNode->pAdapter) |
| 9878 | { |
| 9879 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 9880 | "restarting the driver(intf:\'%s\' mode:%d :try %d)", |
| 9881 | pAdapterNode->pAdapter->dev->name, |
| 9882 | pAdapterNode->pAdapter->device_mode, |
| 9883 | pHddCtx->hdd_restart_retries + 1); |
Madan Mohan Koyyalamudi | fc19e44 | 2013-05-09 18:24:08 -0700 | [diff] [blame] | 9884 | /* |
| 9885 | * CFG80211 event to restart the driver |
| 9886 | * |
| 9887 | * 'cfg80211_send_unprot_deauth' sends a |
| 9888 | * NL80211_CMD_UNPROT_DEAUTHENTICATE event to supplicant at any state |
| 9889 | * of SME(Linux Kernel) state machine. |
| 9890 | * |
| 9891 | * Reason code WLAN_REASON_DISASSOC_LOW_ACK is currently used to restart |
| 9892 | * the driver. |
| 9893 | * |
| 9894 | */ |
| 9895 | |
| 9896 | cfg80211_send_unprot_deauth(pAdapterNode->pAdapter->dev, (u_int8_t*)mgmt, len ); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9897 | } |
| 9898 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 9899 | pAdapterNode = pNext; |
| 9900 | } while((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status)); |
| 9901 | |
Madan Mohan Koyyalamudi | fc19e44 | 2013-05-09 18:24:08 -0700 | [diff] [blame] | 9902 | |
| 9903 | /* Free the allocated management frame */ |
| 9904 | kfree(mgmt); |
| 9905 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9906 | /* Retry until we unload or reach max count */ |
| 9907 | if(++pHddCtx->hdd_restart_retries < WLAN_HDD_RESTART_RETRY_MAX_CNT) |
| 9908 | vos_timer_start(&pHddCtx->hdd_restart_timer, WLAN_HDD_RESTART_RETRY_DELAY_MS); |
| 9909 | |
| 9910 | return status; |
| 9911 | |
| 9912 | } |
| 9913 | /**--------------------------------------------------------------------------- |
| 9914 | * |
| 9915 | * \brief wlan_hdd_restart_timer_cb |
| 9916 | * |
| 9917 | * Restart timer callback. An internal function. |
| 9918 | * |
| 9919 | * \param - User data: |
| 9920 | * |
| 9921 | * \return - None |
| 9922 | * |
| 9923 | * --------------------------------------------------------------------------*/ |
| 9924 | |
| 9925 | void wlan_hdd_restart_timer_cb(v_PVOID_t usrDataForCallback) |
| 9926 | { |
| 9927 | hdd_context_t *pHddCtx = usrDataForCallback; |
| 9928 | wlan_hdd_framework_restart(pHddCtx); |
| 9929 | return; |
| 9930 | |
| 9931 | } |
| 9932 | |
| 9933 | |
| 9934 | /**--------------------------------------------------------------------------- |
| 9935 | * |
| 9936 | * \brief wlan_hdd_restart_driver |
| 9937 | * |
| 9938 | * This function sends an event to supplicant to restart the WLAN driver. |
| 9939 | * |
| 9940 | * This function is called from vos_wlanRestart. |
| 9941 | * |
| 9942 | * \param - pHddCtx |
| 9943 | * |
| 9944 | * \return - VOS_STATUS_SUCCESS: Success |
| 9945 | * VOS_STATUS_E_EMPTY: Adapter is Empty |
| 9946 | * VOS_STATUS_E_ALREADY: Request already in progress |
| 9947 | |
| 9948 | * --------------------------------------------------------------------------*/ |
| 9949 | VOS_STATUS wlan_hdd_restart_driver(hdd_context_t *pHddCtx) |
| 9950 | { |
| 9951 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 9952 | |
| 9953 | /* A tight check to make sure reentrancy */ |
| 9954 | if(atomic_xchg(&pHddCtx->isRestartInProgress, 1)) |
| 9955 | { |
Mihir Shete | fd52865 | 2014-06-23 19:07:50 +0530 | [diff] [blame] | 9956 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9957 | "%s: WLAN restart is already in progress", __func__); |
| 9958 | |
| 9959 | return VOS_STATUS_E_ALREADY; |
| 9960 | } |
Sameer Thalappil | 0c164f5 | 2013-03-28 15:27:56 -0700 | [diff] [blame] | 9961 | /* Send reset FIQ to WCNSS to invoke SSR. */ |
Madan Mohan Koyyalamudi | e388b34 | 2012-11-08 15:03:16 -0800 | [diff] [blame] | 9962 | #ifdef HAVE_WCNSS_RESET_INTR |
Madan Mohan Koyyalamudi | bb8f017 | 2012-09-28 15:36:06 -0700 | [diff] [blame] | 9963 | wcnss_reset_intr(); |
| 9964 | #endif |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 9965 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9966 | return status; |
| 9967 | } |
| 9968 | |
Mihir Shete | e1093ba | 2014-01-21 20:13:32 +0530 | [diff] [blame] | 9969 | /**--------------------------------------------------------------------------- |
| 9970 | * |
| 9971 | * \brief wlan_hdd_init_channels |
| 9972 | * |
| 9973 | * This function is used to initialize the channel list in CSR |
| 9974 | * |
| 9975 | * This function is called from hdd_wlan_startup |
| 9976 | * |
| 9977 | * \param - pHddCtx: HDD context |
| 9978 | * |
| 9979 | * \return - VOS_STATUS_SUCCESS: Success |
| 9980 | * VOS_STATUS_E_FAULT: Failure reported by SME |
| 9981 | |
| 9982 | * --------------------------------------------------------------------------*/ |
| 9983 | static VOS_STATUS wlan_hdd_init_channels(hdd_context_t *pHddCtx) |
| 9984 | { |
| 9985 | eHalStatus status; |
| 9986 | |
| 9987 | status = sme_InitChannels(pHddCtx->hHal); |
| 9988 | if (HAL_STATUS_SUCCESS(status)) |
| 9989 | { |
| 9990 | return VOS_STATUS_SUCCESS; |
| 9991 | } |
| 9992 | else |
| 9993 | { |
| 9994 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Channel initialization failed(%d)", |
| 9995 | __func__, status); |
| 9996 | return VOS_STATUS_E_FAULT; |
| 9997 | } |
| 9998 | } |
| 9999 | |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 10000 | static VOS_STATUS wlan_hdd_init_channels_for_cc(hdd_context_t *pHddCtx) |
| 10001 | { |
| 10002 | eHalStatus status; |
| 10003 | |
| 10004 | status = sme_InitChannelsForCC(pHddCtx->hHal); |
| 10005 | if (HAL_STATUS_SUCCESS(status)) |
| 10006 | { |
| 10007 | return VOS_STATUS_SUCCESS; |
| 10008 | } |
| 10009 | else |
| 10010 | { |
| 10011 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Issue reg hint failed(%d)", |
| 10012 | __func__, status); |
| 10013 | return VOS_STATUS_E_FAULT; |
| 10014 | } |
| 10015 | } |
Sudhir Sattayappa Kohalli | b1d8c3a | 2013-06-18 14:47:20 -0700 | [diff] [blame] | 10016 | /* |
| 10017 | * API to find if there is any STA or P2P-Client is connected |
| 10018 | */ |
| 10019 | VOS_STATUS hdd_issta_p2p_clientconnected(hdd_context_t *pHddCtx) |
| 10020 | { |
| 10021 | return sme_isSta_p2p_clientConnected(pHddCtx->hHal); |
| 10022 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10023 | |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 10024 | int wlan_hdd_scan_abort(hdd_adapter_t *pAdapter) |
| 10025 | { |
| 10026 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 10027 | hdd_scaninfo_t *pScanInfo = NULL; |
Girish Gowli | 4bf7a63 | 2014-06-12 13:42:11 +0530 | [diff] [blame] | 10028 | long status = 0; |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 10029 | |
| 10030 | pScanInfo = &pHddCtx->scan_info; |
| 10031 | if (pScanInfo->mScanPending) |
| 10032 | { |
| 10033 | INIT_COMPLETION(pScanInfo->abortscan_event_var); |
| 10034 | hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId, |
| 10035 | eCSR_SCAN_ABORT_DEFAULT); |
| 10036 | |
| 10037 | status = wait_for_completion_interruptible_timeout( |
| 10038 | &pScanInfo->abortscan_event_var, |
| 10039 | msecs_to_jiffies(5000)); |
Girish Gowli | 4bf7a63 | 2014-06-12 13:42:11 +0530 | [diff] [blame] | 10040 | if (0 >= status) |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 10041 | { |
| 10042 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Girish Gowli | 4bf7a63 | 2014-06-12 13:42:11 +0530 | [diff] [blame] | 10043 | "%s: Timeout or Interrupt occurred while waiting for abort" |
| 10044 | "scan, status- %ld", __func__, status); |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 10045 | return -ETIMEDOUT; |
| 10046 | } |
| 10047 | } |
Girish Gowli | 4bf7a63 | 2014-06-12 13:42:11 +0530 | [diff] [blame] | 10048 | return 0; |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 10049 | } |
| 10050 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10051 | //Register the module init/exit functions |
| 10052 | module_init(hdd_module_init); |
| 10053 | module_exit(hdd_module_exit); |
| 10054 | |
| 10055 | MODULE_LICENSE("Dual BSD/GPL"); |
| 10056 | MODULE_AUTHOR("Qualcomm Atheros, Inc."); |
| 10057 | MODULE_DESCRIPTION("WLAN HOST DEVICE DRIVER"); |
| 10058 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 10059 | module_param_call(con_mode, con_mode_handler, param_get_int, &con_mode, |
| 10060 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 10061 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 10062 | module_param_call(fwpath, fwpath_changed_handler, param_get_string, &fwpath, |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 10063 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 10064 | |
| 10065 | module_param(enable_dfs_chan_scan, int, |
| 10066 | S_IRUSR | S_IRGRP | S_IROTH); |
| 10067 | |
| 10068 | module_param(enable_11d, int, |
| 10069 | S_IRUSR | S_IRGRP | S_IROTH); |
| 10070 | |
| 10071 | module_param(country_code, charp, |
| 10072 | S_IRUSR | S_IRGRP | S_IROTH); |