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 | { |
| 1930 | bcnMissRateContext_t *pCBCtx = (bcnMissRateContext_t *)data; |
| 1931 | |
| 1932 | /* there is a race condition that exists between this callback |
| 1933 | function and the caller since the caller could time out either |
| 1934 | before or while this code is executing. we use a spinlock to |
| 1935 | serialize these actions */ |
| 1936 | spin_lock(&hdd_context_lock); |
| 1937 | |
| 1938 | gbcnMissRate = -1; |
| 1939 | |
| 1940 | if(pCBCtx->magic != BCN_MISS_RATE_CONTEXT_MAGIC || NULL == data) |
| 1941 | { |
| 1942 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1943 | FL("invalid context magic: %08x data: %p"), pCBCtx->magic, data ); |
| 1944 | spin_unlock(&hdd_context_lock); |
| 1945 | return ; |
| 1946 | } |
| 1947 | |
| 1948 | if (VOS_STATUS_SUCCESS == status) |
| 1949 | { |
| 1950 | gbcnMissRate = bcnMissRate; |
| 1951 | } |
| 1952 | complete(&(pCBCtx->completion)); |
| 1953 | spin_unlock(&hdd_context_lock); |
| 1954 | |
| 1955 | return; |
| 1956 | } |
| 1957 | |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 1958 | static int hdd_get_dwell_time(hdd_config_t *pCfg, tANI_U8 *command, char *extra, tANI_U8 n, tANI_U8 *len) |
| 1959 | { |
| 1960 | int ret = 0; |
| 1961 | |
| 1962 | if (!pCfg || !command || !extra || !len) |
| 1963 | { |
| 1964 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1965 | "%s: argument passsed for GETDWELLTIME is incorrect", __func__); |
| 1966 | ret = -EINVAL; |
| 1967 | return ret; |
| 1968 | } |
| 1969 | |
| 1970 | if (strncmp(command, "GETDWELLTIME ACTIVE MAX", 23) == 0) |
| 1971 | { |
| 1972 | *len = scnprintf(extra, n, "GETDWELLTIME ACTIVE MAX %u\n", |
| 1973 | (int)pCfg->nActiveMaxChnTime); |
| 1974 | return ret; |
| 1975 | } |
| 1976 | else if (strncmp(command, "GETDWELLTIME ACTIVE MIN", 23) == 0) |
| 1977 | { |
| 1978 | *len = scnprintf(extra, n, "GETDWELLTIME ACTIVE MIN %u\n", |
| 1979 | (int)pCfg->nActiveMinChnTime); |
| 1980 | return ret; |
| 1981 | } |
| 1982 | else if (strncmp(command, "GETDWELLTIME PASSIVE MAX", 24) == 0) |
| 1983 | { |
| 1984 | *len = scnprintf(extra, n, "GETDWELLTIME PASSIVE MAX %u\n", |
| 1985 | (int)pCfg->nPassiveMaxChnTime); |
| 1986 | return ret; |
| 1987 | } |
| 1988 | else if (strncmp(command, "GETDWELLTIME PASSIVE MIN", 24) == 0) |
| 1989 | { |
| 1990 | *len = scnprintf(extra, n, "GETDWELLTIME PASSIVE MIN %u\n", |
| 1991 | (int)pCfg->nPassiveMinChnTime); |
| 1992 | return ret; |
| 1993 | } |
| 1994 | else |
| 1995 | { |
| 1996 | ret = -EINVAL; |
| 1997 | } |
| 1998 | |
| 1999 | return ret; |
| 2000 | } |
| 2001 | |
| 2002 | static int hdd_set_dwell_time(hdd_adapter_t *pAdapter, tANI_U8 *command) |
| 2003 | { |
| 2004 | hdd_config_t *pCfg; |
| 2005 | tANI_U8 *value = command; |
| 2006 | int val = 0, ret = 0, temp = 0; |
| 2007 | |
| 2008 | if (!pAdapter || !command || !(pCfg = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini)) |
| 2009 | { |
| 2010 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2011 | "%s: argument passed for SETDWELLTIME is incorrect", __func__); |
| 2012 | ret = -EINVAL; |
| 2013 | return ret; |
| 2014 | } |
| 2015 | |
| 2016 | if (strncmp(command, "SETDWELLTIME ACTIVE MAX", 23) == 0 ) |
| 2017 | { |
| 2018 | value = value + 24; |
| 2019 | temp = kstrtou32(value, 10, &val); |
| 2020 | if (temp != 0 || val < CFG_ACTIVE_MAX_CHANNEL_TIME_MIN || |
| 2021 | val > CFG_ACTIVE_MAX_CHANNEL_TIME_MAX ) |
| 2022 | { |
| 2023 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2024 | "%s: argument passed for SETDWELLTIME ACTIVE MAX is incorrect", __func__); |
| 2025 | ret = -EFAULT; |
| 2026 | return ret; |
| 2027 | } |
| 2028 | pCfg->nActiveMaxChnTime = val; |
| 2029 | } |
| 2030 | else if (strncmp(command, "SETDWELLTIME ACTIVE MIN", 23) == 0) |
| 2031 | { |
| 2032 | value = value + 24; |
| 2033 | temp = kstrtou32(value, 10, &val); |
| 2034 | if (temp !=0 || val < CFG_ACTIVE_MIN_CHANNEL_TIME_MIN || |
| 2035 | val > CFG_ACTIVE_MIN_CHANNEL_TIME_MAX ) |
| 2036 | { |
| 2037 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2038 | "%s: argument passsed for SETDWELLTIME ACTIVE MIN is incorrect", __func__); |
| 2039 | ret = -EFAULT; |
| 2040 | return ret; |
| 2041 | } |
| 2042 | pCfg->nActiveMinChnTime = val; |
| 2043 | } |
| 2044 | else if (strncmp(command, "SETDWELLTIME PASSIVE MAX", 24) == 0) |
| 2045 | { |
| 2046 | value = value + 25; |
| 2047 | temp = kstrtou32(value, 10, &val); |
| 2048 | if (temp != 0 || val < CFG_PASSIVE_MAX_CHANNEL_TIME_MIN || |
| 2049 | val > CFG_PASSIVE_MAX_CHANNEL_TIME_MAX ) |
| 2050 | { |
| 2051 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2052 | "%s: argument passed for SETDWELLTIME PASSIVE MAX is incorrect", __func__); |
| 2053 | ret = -EFAULT; |
| 2054 | return ret; |
| 2055 | } |
| 2056 | pCfg->nPassiveMaxChnTime = val; |
| 2057 | } |
| 2058 | else if (strncmp(command, "SETDWELLTIME PASSIVE MIN", 24) == 0) |
| 2059 | { |
| 2060 | value = value + 25; |
| 2061 | temp = kstrtou32(value, 10, &val); |
| 2062 | if (temp != 0 || val < CFG_PASSIVE_MIN_CHANNEL_TIME_MIN || |
| 2063 | val > CFG_PASSIVE_MIN_CHANNEL_TIME_MAX ) |
| 2064 | { |
| 2065 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2066 | "%s: argument passed for SETDWELLTIME PASSIVE MIN is incorrect", __func__); |
| 2067 | ret = -EFAULT; |
| 2068 | return ret; |
| 2069 | } |
| 2070 | pCfg->nPassiveMinChnTime = val; |
| 2071 | } |
| 2072 | else |
| 2073 | { |
| 2074 | ret = -EINVAL; |
| 2075 | } |
| 2076 | |
| 2077 | return ret; |
| 2078 | } |
| 2079 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2080 | static int hdd_driver_command(hdd_adapter_t *pAdapter, |
| 2081 | hdd_priv_data_t *ppriv_data) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2082 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2083 | hdd_priv_data_t priv_data; |
| 2084 | tANI_U8 *command = NULL; |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2085 | int ret = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2086 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2087 | /* |
| 2088 | * Note that valid pointers are provided by caller |
| 2089 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2090 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2091 | /* copy to local struct to avoid numerous changes to legacy code */ |
| 2092 | priv_data = *ppriv_data; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2093 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2094 | if (priv_data.total_len <= 0 || |
| 2095 | priv_data.total_len > WLAN_PRIV_DATA_MAX_LEN) |
Sameer Thalappil | 8ef3a0e | 2013-04-05 14:36:04 -0700 | [diff] [blame] | 2096 | { |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2097 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 2098 | "%s:invalid priv_data.total_len(%d)!!!", __func__, |
| 2099 | priv_data.total_len); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 2100 | ret = -EINVAL; |
| 2101 | goto exit; |
| 2102 | } |
| 2103 | |
| 2104 | /* Allocate +1 for '\0' */ |
| 2105 | command = kmalloc(priv_data.total_len + 1, GFP_KERNEL); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2106 | if (!command) |
| 2107 | { |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2108 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2109 | "%s: failed to allocate memory", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2110 | ret = -ENOMEM; |
| 2111 | goto exit; |
| 2112 | } |
| 2113 | |
| 2114 | if (copy_from_user(command, priv_data.buf, priv_data.total_len)) |
| 2115 | { |
| 2116 | ret = -EFAULT; |
| 2117 | goto exit; |
| 2118 | } |
| 2119 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2120 | /* Make sure the command is NUL-terminated */ |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 2121 | command[priv_data.total_len] = '\0'; |
| 2122 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2123 | /* at one time the following block of code was conditional. braces |
| 2124 | * have been retained to avoid re-indenting the legacy code |
| 2125 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2126 | { |
| 2127 | hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx; |
| 2128 | |
| 2129 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | f9bdd4e | 2012-10-30 18:05:03 -0700 | [diff] [blame] | 2130 | "%s: Received %s cmd from Wi-Fi GUI***", __func__, command); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2131 | |
| 2132 | if (strncmp(command, "P2P_DEV_ADDR", 12) == 0 ) |
| 2133 | { |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2134 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2135 | TRACE_CODE_HDD_P2P_DEV_ADDR_IOCTL, |
| 2136 | pAdapter->sessionId, (unsigned) |
| 2137 | (*(pHddCtx->p2pDeviceAddress.bytes+2)<<24 | |
| 2138 | *(pHddCtx->p2pDeviceAddress.bytes+3)<<16 | |
| 2139 | *(pHddCtx->p2pDeviceAddress.bytes+4)<<8 | |
| 2140 | *(pHddCtx->p2pDeviceAddress.bytes+5)))); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2141 | if (copy_to_user(priv_data.buf, pHddCtx->p2pDeviceAddress.bytes, |
| 2142 | sizeof(tSirMacAddr))) |
| 2143 | { |
| 2144 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2145 | "%s: failed to copy data to user buffer", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2146 | ret = -EFAULT; |
| 2147 | } |
| 2148 | } |
Amar Singhal | 0974e40 | 2013-02-12 14:27:46 -0800 | [diff] [blame] | 2149 | else if(strncmp(command, "SETBAND", 7) == 0) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2150 | { |
Amar Singhal | 0974e40 | 2013-02-12 14:27:46 -0800 | [diff] [blame] | 2151 | tANI_U8 *ptr = command ; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2152 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2153 | /* Change band request received */ |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2154 | |
| 2155 | /* First 8 bytes will have "SETBAND " and |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2156 | * 9 byte will have band setting value */ |
Madan Mohan Koyyalamudi | 8bdd311 | 2012-09-24 13:55:14 -0700 | [diff] [blame] | 2157 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Amar Singhal | 0974e40 | 2013-02-12 14:27:46 -0800 | [diff] [blame] | 2158 | "%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] | 2159 | /* Change band request received */ |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2160 | ret = hdd_setBand_helper(pAdapter->dev, ptr); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 2161 | if(ret != 0) |
| 2162 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2163 | "%s: failed to set band ret=%d", __func__, ret); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2164 | } |
Kiet Lam | f040f47 | 2013-11-20 21:15:23 +0530 | [diff] [blame] | 2165 | else if(strncmp(command, "SETWMMPS", 8) == 0) |
| 2166 | { |
| 2167 | tANI_U8 *ptr = command; |
| 2168 | ret = hdd_wmmps_helper(pAdapter, ptr); |
| 2169 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2170 | else if ( strncasecmp(command, "COUNTRY", 7) == 0 ) |
| 2171 | { |
| 2172 | char *country_code; |
| 2173 | |
| 2174 | country_code = command + 8; |
Tushnim Bhattacharyya | 9cdf608 | 2013-04-21 16:33:30 -0700 | [diff] [blame] | 2175 | |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 2176 | INIT_COMPLETION(pAdapter->change_country_code); |
Tushnim Bhattacharyya | 9cdf608 | 2013-04-21 16:33:30 -0700 | [diff] [blame] | 2177 | hdd_checkandupdate_dfssetting(pAdapter, country_code); |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 2178 | #ifndef CONFIG_ENABLE_LINUX_REG |
Gopichand Nakkala | dacbcb5 | 2013-04-18 16:41:54 +0530 | [diff] [blame] | 2179 | hdd_checkandupdate_phymode(pAdapter, country_code); |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 2180 | #endif |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 2181 | ret = (int)sme_ChangeCountryCode(pHddCtx->hHal, |
| 2182 | (void *)(tSmeChangeCountryCallback) |
| 2183 | wlan_hdd_change_country_code_callback, |
Abhishek Singh | a306a44 | 2013-11-07 18:39:01 +0530 | [diff] [blame] | 2184 | country_code, pAdapter, pHddCtx->pvosContext, eSIR_TRUE, eSIR_TRUE); |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 2185 | if (eHAL_STATUS_SUCCESS == ret) |
| 2186 | { |
| 2187 | ret = wait_for_completion_interruptible_timeout( |
| 2188 | &pAdapter->change_country_code, |
| 2189 | msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY)); |
| 2190 | if (0 >= ret) |
| 2191 | { |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2192 | 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] | 2193 | __func__, ret); |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 2194 | } |
| 2195 | } |
| 2196 | else |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2197 | { |
| 2198 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2199 | "%s: SME Change Country code fail ret=%d", __func__, ret); |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 2200 | ret = -EINVAL; |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2201 | } |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 2202 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 2203 | } |
| 2204 | /* |
| 2205 | command should be a string having format |
| 2206 | SET_SAP_CHANNEL_LIST <num of channels> <the channels seperated by spaces> |
| 2207 | */ |
Amar Singhal | 0974e40 | 2013-02-12 14:27:46 -0800 | [diff] [blame] | 2208 | else if(strncmp(command, "SET_SAP_CHANNEL_LIST", 20) == 0) |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 2209 | { |
Amar Singhal | 0974e40 | 2013-02-12 14:27:46 -0800 | [diff] [blame] | 2210 | tANI_U8 *ptr = command; |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 2211 | |
| 2212 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 2213 | " Received Command to Set Preferred Channels for SAP in %s", __func__); |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 2214 | |
Mahesh Kumar Kalikot Veetil | 2aad8d8 | 2013-02-07 12:31:28 -0800 | [diff] [blame] | 2215 | ret = sapSetPreferredChannel(ptr); |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2216 | } |
Sameer Thalappil | 45931fb | 2013-02-01 11:18:05 -0800 | [diff] [blame] | 2217 | else if(strncmp(command, "SETSUSPENDMODE", 14) == 0) |
| 2218 | { |
| 2219 | int suspend = 0; |
| 2220 | tANI_U8 *ptr = (tANI_U8*)command + 15; |
| 2221 | |
| 2222 | suspend = *ptr - '0'; |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2223 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2224 | TRACE_CODE_HDD_SETSUSPENDMODE_IOCTL, |
| 2225 | pAdapter->sessionId, suspend)); |
Sameer Thalappil | 45931fb | 2013-02-01 11:18:05 -0800 | [diff] [blame] | 2226 | hdd_set_wlan_suspend_mode(suspend); |
| 2227 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2228 | #ifdef WLAN_FEATURE_NEIGHBOR_ROAMING |
| 2229 | else if (strncmp(command, "SETROAMTRIGGER", 14) == 0) |
| 2230 | { |
| 2231 | tANI_U8 *value = command; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2232 | tANI_S8 rssi = 0; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2233 | tANI_U8 lookUpThreshold = CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_DEFAULT; |
| 2234 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 2235 | |
| 2236 | /* Move pointer to ahead of SETROAMTRIGGER<delimiter> */ |
| 2237 | value = value + 15; |
| 2238 | |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2239 | /* Convert the value from ascii to integer */ |
| 2240 | ret = kstrtos8(value, 10, &rssi); |
| 2241 | if (ret < 0) |
| 2242 | { |
| 2243 | /* If the input value is greater than max value of datatype, then also |
| 2244 | kstrtou8 fails */ |
| 2245 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2246 | "%s: kstrtou8 failed Input value may be out of range[%d - %d]", |
Srinivas Girigowda | fa7157d | 2013-10-31 10:14:22 -0700 | [diff] [blame] | 2247 | __func__, |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2248 | CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MIN, |
| 2249 | CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MAX); |
| 2250 | ret = -EINVAL; |
| 2251 | goto exit; |
| 2252 | } |
| 2253 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2254 | lookUpThreshold = abs(rssi); |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2255 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2256 | if ((lookUpThreshold < CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MIN) || |
| 2257 | (lookUpThreshold > CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MAX)) |
| 2258 | { |
| 2259 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2260 | "Neighbor lookup threshold value %d is out of range" |
| 2261 | " (Min: %d Max: %d)", lookUpThreshold, |
| 2262 | CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MIN, |
| 2263 | CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MAX); |
| 2264 | ret = -EINVAL; |
| 2265 | goto exit; |
| 2266 | } |
| 2267 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2268 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2269 | TRACE_CODE_HDD_SETROAMTRIGGER_IOCTL, |
| 2270 | pAdapter->sessionId, lookUpThreshold)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2271 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2272 | "%s: Received Command to Set Roam trigger" |
| 2273 | " (Neighbor lookup threshold) = %d", __func__, lookUpThreshold); |
| 2274 | |
| 2275 | pHddCtx->cfg_ini->nNeighborLookupRssiThreshold = lookUpThreshold; |
| 2276 | status = sme_setNeighborLookupRssiThreshold((tHalHandle)(pHddCtx->hHal), lookUpThreshold); |
| 2277 | if (eHAL_STATUS_SUCCESS != status) |
| 2278 | { |
| 2279 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2280 | "%s: Failed to set roam trigger, try again", __func__); |
| 2281 | ret = -EPERM; |
| 2282 | goto exit; |
| 2283 | } |
| 2284 | |
| 2285 | /* Set Reassoc threshold to (lookup rssi threshold + 5 dBm) */ |
| 2286 | sme_setNeighborReassocRssiThreshold((tHalHandle)(pHddCtx->hHal), lookUpThreshold + 5); |
| 2287 | } |
| 2288 | else if (strncmp(command, "GETROAMTRIGGER", 14) == 0) |
| 2289 | { |
| 2290 | tANI_U8 lookUpThreshold = sme_getNeighborLookupRssiThreshold((tHalHandle)(pHddCtx->hHal)); |
| 2291 | int rssi = (-1) * lookUpThreshold; |
| 2292 | char extra[32]; |
| 2293 | tANI_U8 len = 0; |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2294 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2295 | TRACE_CODE_HDD_GETROAMTRIGGER_IOCTL, |
| 2296 | pAdapter->sessionId, lookUpThreshold)); |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2297 | len = scnprintf(extra, sizeof(extra), "%s %d", command, rssi); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2298 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2299 | { |
| 2300 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2301 | "%s: failed to copy data to user buffer", __func__); |
| 2302 | ret = -EFAULT; |
| 2303 | goto exit; |
| 2304 | } |
| 2305 | } |
| 2306 | else if (strncmp(command, "SETROAMSCANPERIOD", 17) == 0) |
| 2307 | { |
| 2308 | tANI_U8 *value = command; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2309 | tANI_U8 roamScanPeriod = 0; |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2310 | tANI_U16 neighborEmptyScanRefreshPeriod = CFG_EMPTY_SCAN_REFRESH_PERIOD_DEFAULT; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2311 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2312 | /* input refresh period is in terms of seconds */ |
| 2313 | /* Move pointer to ahead of SETROAMSCANPERIOD<delimiter> */ |
| 2314 | value = value + 18; |
| 2315 | /* Convert the value from ascii to integer */ |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2316 | ret = kstrtou8(value, 10, &roamScanPeriod); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2317 | if (ret < 0) |
| 2318 | { |
| 2319 | /* 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] | 2320 | kstrtou8 fails */ |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2321 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2322 | "%s: kstrtou8 failed Input value may be out of range[%d - %d]", |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2323 | __func__, |
Srinivas Girigowda | b8edd1e | 2013-03-19 11:42:08 -0700 | [diff] [blame] | 2324 | (CFG_EMPTY_SCAN_REFRESH_PERIOD_MIN/1000), |
| 2325 | (CFG_EMPTY_SCAN_REFRESH_PERIOD_MAX/1000)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2326 | ret = -EINVAL; |
| 2327 | goto exit; |
| 2328 | } |
| 2329 | |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2330 | if ((roamScanPeriod < (CFG_EMPTY_SCAN_REFRESH_PERIOD_MIN/1000)) || |
| 2331 | (roamScanPeriod > (CFG_EMPTY_SCAN_REFRESH_PERIOD_MAX/1000))) |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2332 | { |
| 2333 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2334 | "Roam scan period value %d is out of range" |
| 2335 | " (Min: %d Max: %d)", roamScanPeriod, |
Srinivas Girigowda | b8edd1e | 2013-03-19 11:42:08 -0700 | [diff] [blame] | 2336 | (CFG_EMPTY_SCAN_REFRESH_PERIOD_MIN/1000), |
| 2337 | (CFG_EMPTY_SCAN_REFRESH_PERIOD_MAX/1000)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2338 | ret = -EINVAL; |
| 2339 | goto exit; |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2340 | } |
| 2341 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2342 | TRACE_CODE_HDD_SETROAMSCANPERIOD_IOCTL, |
| 2343 | pAdapter->sessionId, roamScanPeriod)); |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2344 | neighborEmptyScanRefreshPeriod = roamScanPeriod * 1000; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2345 | |
| 2346 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2347 | "%s: Received Command to Set roam scan period" |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2348 | " (Empty Scan refresh period) = %d", __func__, roamScanPeriod); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2349 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2350 | pHddCtx->cfg_ini->nEmptyScanRefreshPeriod = neighborEmptyScanRefreshPeriod; |
| 2351 | sme_UpdateEmptyScanRefreshPeriod((tHalHandle)(pHddCtx->hHal), neighborEmptyScanRefreshPeriod); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2352 | } |
| 2353 | else if (strncmp(command, "GETROAMSCANPERIOD", 17) == 0) |
| 2354 | { |
| 2355 | tANI_U16 nEmptyScanRefreshPeriod = sme_getEmptyScanRefreshPeriod((tHalHandle)(pHddCtx->hHal)); |
| 2356 | char extra[32]; |
| 2357 | tANI_U8 len = 0; |
| 2358 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2359 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2360 | TRACE_CODE_HDD_GETROAMSCANPERIOD_IOCTL, |
| 2361 | pAdapter->sessionId, nEmptyScanRefreshPeriod)); |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2362 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 2363 | "GETROAMSCANPERIOD", (nEmptyScanRefreshPeriod/1000)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2364 | /* Returned value is in units of seconds */ |
| 2365 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2366 | { |
| 2367 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2368 | "%s: failed to copy data to user buffer", __func__); |
| 2369 | ret = -EFAULT; |
| 2370 | goto exit; |
| 2371 | } |
| 2372 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2373 | else if (strncmp(command, "SETROAMSCANREFRESHPERIOD", 24) == 0) |
| 2374 | { |
| 2375 | tANI_U8 *value = command; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2376 | tANI_U8 roamScanRefreshPeriod = 0; |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2377 | tANI_U16 neighborScanRefreshPeriod = CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_DEFAULT; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2378 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2379 | /* input refresh period is in terms of seconds */ |
| 2380 | /* Move pointer to ahead of SETROAMSCANREFRESHPERIOD<delimiter> */ |
| 2381 | value = value + 25; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2382 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2383 | /* Convert the value from ascii to integer */ |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2384 | ret = kstrtou8(value, 10, &roamScanRefreshPeriod); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2385 | if (ret < 0) |
| 2386 | { |
| 2387 | /* 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] | 2388 | kstrtou8 fails */ |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2389 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2390 | "%s: kstrtou8 failed Input value may be out of range[%d - %d]", |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2391 | __func__, |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2392 | (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MIN/1000), |
| 2393 | (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MAX/1000)); |
| 2394 | ret = -EINVAL; |
| 2395 | goto exit; |
| 2396 | } |
| 2397 | |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2398 | if ((roamScanRefreshPeriod < (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MIN/1000)) || |
| 2399 | (roamScanRefreshPeriod > (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MAX/1000))) |
| 2400 | { |
| 2401 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2402 | "Neighbor scan results refresh period value %d is out of range" |
| 2403 | " (Min: %d Max: %d)", roamScanRefreshPeriod, |
| 2404 | (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MIN/1000), |
| 2405 | (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MAX/1000)); |
| 2406 | ret = -EINVAL; |
| 2407 | goto exit; |
| 2408 | } |
| 2409 | neighborScanRefreshPeriod = roamScanRefreshPeriod * 1000; |
| 2410 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2411 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2412 | "%s: Received Command to Set roam scan refresh period" |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2413 | " (Scan refresh period) = %d", __func__, roamScanRefreshPeriod); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2414 | |
| 2415 | pHddCtx->cfg_ini->nNeighborResultsRefreshPeriod = neighborScanRefreshPeriod; |
| 2416 | sme_setNeighborScanRefreshPeriod((tHalHandle)(pHddCtx->hHal), neighborScanRefreshPeriod); |
| 2417 | } |
| 2418 | else if (strncmp(command, "GETROAMSCANREFRESHPERIOD", 24) == 0) |
| 2419 | { |
| 2420 | tANI_U16 value = sme_getNeighborScanRefreshPeriod((tHalHandle)(pHddCtx->hHal)); |
| 2421 | char extra[32]; |
| 2422 | tANI_U8 len = 0; |
| 2423 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2424 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 2425 | "GETROAMSCANREFRESHPERIOD", (value/1000)); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2426 | /* Returned value is in units of seconds */ |
| 2427 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2428 | { |
| 2429 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2430 | "%s: failed to copy data to user buffer", __func__); |
| 2431 | ret = -EFAULT; |
| 2432 | goto exit; |
| 2433 | } |
| 2434 | } |
Varun Reddy Yeturu | 6d99ac8 | 2013-05-08 14:15:35 -0700 | [diff] [blame] | 2435 | #ifdef FEATURE_WLAN_LFR |
| 2436 | /* SETROAMMODE */ |
| 2437 | else if (strncmp(command, "SETROAMMODE", SIZE_OF_SETROAMMODE) == 0) |
| 2438 | { |
| 2439 | tANI_U8 *value = command; |
| 2440 | tANI_BOOLEAN roamMode = CFG_LFR_FEATURE_ENABLED_DEFAULT; |
| 2441 | |
| 2442 | /* Move pointer to ahead of SETROAMMODE<delimiter> */ |
| 2443 | value = value + SIZE_OF_SETROAMMODE + 1; |
| 2444 | |
| 2445 | /* Convert the value from ascii to integer */ |
| 2446 | ret = kstrtou8(value, SIZE_OF_SETROAMMODE, &roamMode); |
| 2447 | if (ret < 0) |
| 2448 | { |
| 2449 | /* If the input value is greater than max value of datatype, then also |
| 2450 | kstrtou8 fails */ |
| 2451 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2452 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 2453 | CFG_LFR_FEATURE_ENABLED_MIN, |
| 2454 | CFG_LFR_FEATURE_ENABLED_MAX); |
| 2455 | ret = -EINVAL; |
| 2456 | goto exit; |
| 2457 | } |
| 2458 | if ((roamMode < CFG_LFR_FEATURE_ENABLED_MIN) || |
| 2459 | (roamMode > CFG_LFR_FEATURE_ENABLED_MAX)) |
| 2460 | { |
| 2461 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2462 | "Roam Mode value %d is out of range" |
| 2463 | " (Min: %d Max: %d)", roamMode, |
| 2464 | CFG_LFR_FEATURE_ENABLED_MIN, |
| 2465 | CFG_LFR_FEATURE_ENABLED_MAX); |
| 2466 | ret = -EINVAL; |
| 2467 | goto exit; |
| 2468 | } |
| 2469 | |
| 2470 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2471 | "%s: Received Command to Set Roam Mode = %d", __func__, roamMode); |
| 2472 | /* |
| 2473 | * Note that |
| 2474 | * SETROAMMODE 0 is to enable LFR while |
| 2475 | * SETROAMMODE 1 is to disable LFR, but |
| 2476 | * NotifyIsFastRoamIniFeatureEnabled 0/1 is to enable/disable. |
| 2477 | * So, we have to invert the value to call sme_UpdateIsFastRoamIniFeatureEnabled. |
| 2478 | */ |
| 2479 | if (CFG_LFR_FEATURE_ENABLED_MIN == roamMode) |
| 2480 | roamMode = CFG_LFR_FEATURE_ENABLED_MAX; /* Roam enable */ |
| 2481 | else |
| 2482 | roamMode = CFG_LFR_FEATURE_ENABLED_MIN; /* Roam disable */ |
| 2483 | |
| 2484 | pHddCtx->cfg_ini->isFastRoamIniFeatureEnabled = roamMode; |
| 2485 | sme_UpdateIsFastRoamIniFeatureEnabled((tHalHandle)(pHddCtx->hHal), roamMode); |
| 2486 | } |
| 2487 | /* GETROAMMODE */ |
| 2488 | else if (strncmp(priv_data.buf, "GETROAMMODE", SIZE_OF_GETROAMMODE) == 0) |
| 2489 | { |
| 2490 | tANI_BOOLEAN roamMode = sme_getIsLfrFeatureEnabled((tHalHandle)(pHddCtx->hHal)); |
| 2491 | char extra[32]; |
| 2492 | tANI_U8 len = 0; |
| 2493 | |
| 2494 | /* |
| 2495 | * roamMode value shall be inverted because the sementics is different. |
| 2496 | */ |
| 2497 | if (CFG_LFR_FEATURE_ENABLED_MIN == roamMode) |
| 2498 | roamMode = CFG_LFR_FEATURE_ENABLED_MAX; |
| 2499 | else |
| 2500 | roamMode = CFG_LFR_FEATURE_ENABLED_MIN; |
| 2501 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2502 | len = scnprintf(extra, sizeof(extra), "%s %d", command, roamMode); |
Varun Reddy Yeturu | 6d99ac8 | 2013-05-08 14:15:35 -0700 | [diff] [blame] | 2503 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2504 | { |
| 2505 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2506 | "%s: failed to copy data to user buffer", __func__); |
| 2507 | ret = -EFAULT; |
| 2508 | goto exit; |
| 2509 | } |
| 2510 | } |
| 2511 | #endif |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2512 | #endif |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2513 | #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] | 2514 | else if (strncmp(command, "SETROAMDELTA", 12) == 0) |
| 2515 | { |
| 2516 | tANI_U8 *value = command; |
| 2517 | tANI_U8 roamRssiDiff = CFG_ROAM_RSSI_DIFF_DEFAULT; |
| 2518 | |
| 2519 | /* Move pointer to ahead of SETROAMDELTA<delimiter> */ |
| 2520 | value = value + 13; |
| 2521 | /* Convert the value from ascii to integer */ |
| 2522 | ret = kstrtou8(value, 10, &roamRssiDiff); |
| 2523 | if (ret < 0) |
| 2524 | { |
| 2525 | /* If the input value is greater than max value of datatype, then also |
| 2526 | kstrtou8 fails */ |
| 2527 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2528 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 2529 | CFG_ROAM_RSSI_DIFF_MIN, |
| 2530 | CFG_ROAM_RSSI_DIFF_MAX); |
| 2531 | ret = -EINVAL; |
| 2532 | goto exit; |
| 2533 | } |
| 2534 | |
| 2535 | if ((roamRssiDiff < CFG_ROAM_RSSI_DIFF_MIN) || |
| 2536 | (roamRssiDiff > CFG_ROAM_RSSI_DIFF_MAX)) |
| 2537 | { |
| 2538 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2539 | "Roam rssi diff value %d is out of range" |
| 2540 | " (Min: %d Max: %d)", roamRssiDiff, |
| 2541 | CFG_ROAM_RSSI_DIFF_MIN, |
| 2542 | CFG_ROAM_RSSI_DIFF_MAX); |
| 2543 | ret = -EINVAL; |
| 2544 | goto exit; |
| 2545 | } |
| 2546 | |
| 2547 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2548 | "%s: Received Command to Set roam rssi diff = %d", __func__, roamRssiDiff); |
| 2549 | |
| 2550 | pHddCtx->cfg_ini->RoamRssiDiff = roamRssiDiff; |
| 2551 | sme_UpdateRoamRssiDiff((tHalHandle)(pHddCtx->hHal), roamRssiDiff); |
| 2552 | } |
| 2553 | else if (strncmp(priv_data.buf, "GETROAMDELTA", 12) == 0) |
| 2554 | { |
| 2555 | tANI_U8 roamRssiDiff = sme_getRoamRssiDiff((tHalHandle)(pHddCtx->hHal)); |
| 2556 | char extra[32]; |
| 2557 | tANI_U8 len = 0; |
| 2558 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2559 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2560 | TRACE_CODE_HDD_GETROAMDELTA_IOCTL, |
| 2561 | pAdapter->sessionId, roamRssiDiff)); |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2562 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 2563 | command, roamRssiDiff); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2564 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2565 | { |
| 2566 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2567 | "%s: failed to copy data to user buffer", __func__); |
| 2568 | ret = -EFAULT; |
| 2569 | goto exit; |
| 2570 | } |
| 2571 | } |
| 2572 | #endif |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2573 | #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] | 2574 | else if (strncmp(command, "GETBAND", 7) == 0) |
| 2575 | { |
| 2576 | int band = -1; |
| 2577 | char extra[32]; |
| 2578 | tANI_U8 len = 0; |
| 2579 | hdd_getBand_helper(pHddCtx, &band); |
| 2580 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2581 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2582 | TRACE_CODE_HDD_GETBAND_IOCTL, |
| 2583 | pAdapter->sessionId, band)); |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2584 | len = scnprintf(extra, sizeof(extra), "%s %d", command, band); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2585 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2586 | { |
| 2587 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2588 | "%s: failed to copy data to user buffer", __func__); |
| 2589 | ret = -EFAULT; |
| 2590 | goto exit; |
| 2591 | } |
| 2592 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2593 | else if (strncmp(command, "SETROAMSCANCHANNELS", 19) == 0) |
| 2594 | { |
| 2595 | tANI_U8 *value = command; |
| 2596 | tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0}; |
| 2597 | tANI_U8 numChannels = 0; |
| 2598 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 2599 | |
| 2600 | status = hdd_parse_channellist(value, ChannelList, &numChannels); |
| 2601 | if (eHAL_STATUS_SUCCESS != status) |
| 2602 | { |
| 2603 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2604 | "%s: Failed to parse channel list information", __func__); |
| 2605 | ret = -EINVAL; |
| 2606 | goto exit; |
| 2607 | } |
| 2608 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2609 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2610 | TRACE_CODE_HDD_SETROAMSCANCHANNELS_IOCTL, |
| 2611 | pAdapter->sessionId, numChannels)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2612 | if (numChannels > WNI_CFG_VALID_CHANNEL_LIST_LEN) |
| 2613 | { |
| 2614 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2615 | "%s: number of channels (%d) supported exceeded max (%d)", __func__, |
| 2616 | numChannels, WNI_CFG_VALID_CHANNEL_LIST_LEN); |
| 2617 | ret = -EINVAL; |
| 2618 | goto exit; |
| 2619 | } |
| 2620 | status = sme_ChangeRoamScanChannelList((tHalHandle)(pHddCtx->hHal), ChannelList, |
| 2621 | numChannels); |
| 2622 | if (eHAL_STATUS_SUCCESS != status) |
| 2623 | { |
| 2624 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2625 | "%s: Failed to update channel list information", __func__); |
| 2626 | ret = -EINVAL; |
| 2627 | goto exit; |
| 2628 | } |
| 2629 | } |
| 2630 | else if (strncmp(command, "GETROAMSCANCHANNELS", 19) == 0) |
| 2631 | { |
| 2632 | tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0}; |
| 2633 | tANI_U8 numChannels = 0; |
Jeff Johnson | 51b6778 | 2013-04-05 12:35:41 -0700 | [diff] [blame] | 2634 | tANI_U8 j = 0; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2635 | char extra[128] = {0}; |
Jeff Johnson | 51b6778 | 2013-04-05 12:35:41 -0700 | [diff] [blame] | 2636 | int len; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2637 | |
| 2638 | if (eHAL_STATUS_SUCCESS != sme_getRoamScanChannelList( (tHalHandle)(pHddCtx->hHal), |
| 2639 | ChannelList, &numChannels )) |
| 2640 | { |
| 2641 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 2642 | "%s: failed to get roam scan channel list", __func__); |
| 2643 | ret = -EFAULT; |
| 2644 | goto exit; |
| 2645 | } |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2646 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2647 | TRACE_CODE_HDD_GETROAMSCANCHANNELS_IOCTL, |
| 2648 | pAdapter->sessionId, numChannels)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2649 | /* output channel list is of the format |
| 2650 | [Number of roam scan channels][Channel1][Channel2]... */ |
| 2651 | /* copy the number of channels in the 0th index */ |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2652 | len = scnprintf(extra, sizeof(extra), "%s %d", command, numChannels); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2653 | for (j = 0; (j < numChannels); j++) |
| 2654 | { |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2655 | len += scnprintf(extra + len, sizeof(extra) - len, " %d", |
| 2656 | ChannelList[j]); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2657 | } |
| 2658 | |
| 2659 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2660 | { |
| 2661 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2662 | "%s: failed to copy data to user buffer", __func__); |
| 2663 | ret = -EFAULT; |
| 2664 | goto exit; |
| 2665 | } |
| 2666 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2667 | else if (strncmp(command, "GETCCXMODE", 10) == 0) |
| 2668 | { |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2669 | tANI_BOOLEAN eseMode = sme_getIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal)); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2670 | char extra[32]; |
| 2671 | tANI_U8 len = 0; |
| 2672 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2673 | /* Check if the features OKC/ESE/11R are supported simultaneously, |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 2674 | then this operation is not permitted (return FAILURE) */ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2675 | if (eseMode && |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 2676 | hdd_is_okc_mode_enabled(pHddCtx) && |
| 2677 | sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal))) |
| 2678 | { |
| 2679 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2680 | "%s: OKC/ESE/11R are supported simultaneously" |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 2681 | " hence this operation is not permitted!", __func__); |
| 2682 | ret = -EPERM; |
| 2683 | goto exit; |
| 2684 | } |
| 2685 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2686 | len = scnprintf(extra, sizeof(extra), "%s %d", |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2687 | "GETCCXMODE", eseMode); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2688 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2689 | { |
| 2690 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2691 | "%s: failed to copy data to user buffer", __func__); |
| 2692 | ret = -EFAULT; |
| 2693 | goto exit; |
| 2694 | } |
| 2695 | } |
| 2696 | else if (strncmp(command, "GETOKCMODE", 10) == 0) |
| 2697 | { |
| 2698 | tANI_BOOLEAN okcMode = hdd_is_okc_mode_enabled(pHddCtx); |
| 2699 | char extra[32]; |
| 2700 | tANI_U8 len = 0; |
| 2701 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2702 | /* Check if the features OKC/ESE/11R are supported simultaneously, |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 2703 | then this operation is not permitted (return FAILURE) */ |
| 2704 | if (okcMode && |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2705 | sme_getIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal)) && |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 2706 | sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal))) |
| 2707 | { |
| 2708 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2709 | "%s: OKC/ESE/11R are supported simultaneously" |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 2710 | " hence this operation is not permitted!", __func__); |
| 2711 | ret = -EPERM; |
| 2712 | goto exit; |
| 2713 | } |
| 2714 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2715 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 2716 | "GETOKCMODE", okcMode); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2717 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2718 | { |
| 2719 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2720 | "%s: failed to copy data to user buffer", __func__); |
| 2721 | ret = -EFAULT; |
| 2722 | goto exit; |
| 2723 | } |
| 2724 | } |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2725 | else if (strncmp(command, "GETFASTROAM", 11) == 0) |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2726 | { |
| 2727 | tANI_BOOLEAN lfrMode = sme_getIsLfrFeatureEnabled((tHalHandle)(pHddCtx->hHal)); |
| 2728 | char extra[32]; |
| 2729 | tANI_U8 len = 0; |
| 2730 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2731 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 2732 | "GETFASTROAM", lfrMode); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2733 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2734 | { |
| 2735 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2736 | "%s: failed to copy data to user buffer", __func__); |
| 2737 | ret = -EFAULT; |
| 2738 | goto exit; |
| 2739 | } |
| 2740 | } |
| 2741 | else if (strncmp(command, "GETFASTTRANSITION", 17) == 0) |
| 2742 | { |
| 2743 | tANI_BOOLEAN ft = sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal)); |
| 2744 | char extra[32]; |
| 2745 | tANI_U8 len = 0; |
| 2746 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2747 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 2748 | "GETFASTTRANSITION", ft); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2749 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2750 | { |
| 2751 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2752 | "%s: failed to copy data to user buffer", __func__); |
| 2753 | ret = -EFAULT; |
| 2754 | goto exit; |
| 2755 | } |
| 2756 | } |
| 2757 | else if (strncmp(command, "SETROAMSCANCHANNELMINTIME", 25) == 0) |
| 2758 | { |
| 2759 | tANI_U8 *value = command; |
| 2760 | tANI_U8 minTime = CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_DEFAULT; |
| 2761 | |
| 2762 | /* Move pointer to ahead of SETROAMSCANCHANNELMINTIME<delimiter> */ |
| 2763 | value = value + 26; |
| 2764 | /* Convert the value from ascii to integer */ |
| 2765 | ret = kstrtou8(value, 10, &minTime); |
| 2766 | if (ret < 0) |
| 2767 | { |
| 2768 | /* If the input value is greater than max value of datatype, then also |
| 2769 | kstrtou8 fails */ |
| 2770 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2771 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 2772 | CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MIN, |
| 2773 | CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MAX); |
| 2774 | ret = -EINVAL; |
| 2775 | goto exit; |
| 2776 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2777 | if ((minTime < CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MIN) || |
| 2778 | (minTime > CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MAX)) |
| 2779 | { |
| 2780 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2781 | "scan min channel time value %d is out of range" |
| 2782 | " (Min: %d Max: %d)", minTime, |
| 2783 | CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MIN, |
| 2784 | CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MAX); |
| 2785 | ret = -EINVAL; |
| 2786 | goto exit; |
| 2787 | } |
| 2788 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2789 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2790 | TRACE_CODE_HDD_SETROAMSCANCHANNELMINTIME_IOCTL, |
| 2791 | pAdapter->sessionId, minTime)); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2792 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2793 | "%s: Received Command to change channel min time = %d", __func__, minTime); |
| 2794 | |
| 2795 | pHddCtx->cfg_ini->nNeighborScanMinChanTime = minTime; |
| 2796 | sme_setNeighborScanMinChanTime((tHalHandle)(pHddCtx->hHal), minTime); |
| 2797 | } |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 2798 | else if (strncmp(command, "SENDACTIONFRAME", 15) == 0) |
| 2799 | { |
| 2800 | tANI_U8 *value = command; |
| 2801 | tANI_U8 channel = 0; |
| 2802 | tANI_U8 dwellTime = 0; |
| 2803 | tANI_U8 bufLen = 0; |
| 2804 | tANI_U8 *buf = NULL; |
| 2805 | tSirMacAddr targetApBssid; |
| 2806 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 2807 | struct ieee80211_channel chan; |
| 2808 | tANI_U8 finalLen = 0; |
| 2809 | tANI_U8 *finalBuf = NULL; |
| 2810 | tANI_U8 temp = 0; |
| 2811 | u64 cookie; |
| 2812 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 2813 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 2814 | |
| 2815 | /* if not associated, no need to send action frame */ |
| 2816 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 2817 | { |
| 2818 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__); |
| 2819 | ret = -EINVAL; |
| 2820 | goto exit; |
| 2821 | } |
| 2822 | |
| 2823 | status = hdd_parse_send_action_frame_data(value, targetApBssid, &channel, |
| 2824 | &dwellTime, &buf, &bufLen); |
| 2825 | if (eHAL_STATUS_SUCCESS != status) |
| 2826 | { |
| 2827 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2828 | "%s: Failed to parse send action frame data", __func__); |
| 2829 | ret = -EINVAL; |
| 2830 | goto exit; |
| 2831 | } |
| 2832 | |
| 2833 | /* if the target bssid is different from currently associated AP, |
| 2834 | then no need to send action frame */ |
| 2835 | if (VOS_TRUE != vos_mem_compare(targetApBssid, |
| 2836 | pHddStaCtx->conn_info.bssId, sizeof(tSirMacAddr))) |
| 2837 | { |
| 2838 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:STA is not associated to this AP!",__func__); |
| 2839 | ret = -EINVAL; |
Jeff Johnson | 11c3315 | 2013-04-16 17:52:40 -0700 | [diff] [blame] | 2840 | vos_mem_free(buf); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 2841 | buf = NULL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 2842 | goto exit; |
| 2843 | } |
| 2844 | |
| 2845 | /* if the channel number is different from operating channel then |
| 2846 | no need to send action frame */ |
| 2847 | if (channel != pHddStaCtx->conn_info.operationChannel) |
| 2848 | { |
| 2849 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2850 | "%s: channel(%d) is different from operating channel(%d)", |
| 2851 | __func__, channel, pHddStaCtx->conn_info.operationChannel); |
| 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 | chan.center_freq = sme_ChnToFreq(channel); |
| 2858 | |
| 2859 | finalLen = bufLen + 24; |
| 2860 | finalBuf = vos_mem_malloc(finalLen); |
| 2861 | if (NULL == finalBuf) |
| 2862 | { |
| 2863 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:memory allocation failed",__func__); |
| 2864 | ret = -ENOMEM; |
Jeff Johnson | 11c3315 | 2013-04-16 17:52:40 -0700 | [diff] [blame] | 2865 | vos_mem_free(buf); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 2866 | buf = NULL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 2867 | goto exit; |
| 2868 | } |
| 2869 | vos_mem_zero(finalBuf, finalLen); |
| 2870 | |
| 2871 | /* Fill subtype */ |
| 2872 | temp = SIR_MAC_MGMT_ACTION << 4; |
| 2873 | vos_mem_copy(finalBuf + 0, &temp, sizeof(temp)); |
| 2874 | |
| 2875 | /* Fill type */ |
| 2876 | temp = SIR_MAC_MGMT_FRAME; |
| 2877 | vos_mem_copy(finalBuf + 2, &temp, sizeof(temp)); |
| 2878 | |
| 2879 | /* Fill destination address (bssid of the AP) */ |
| 2880 | vos_mem_copy(finalBuf + 4, targetApBssid, sizeof(targetApBssid)); |
| 2881 | |
Srinivas Girigowda | b27c019 | 2013-06-03 10:19:56 -0700 | [diff] [blame] | 2882 | /* Fill source address (STA mac address) */ |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 2883 | vos_mem_copy(finalBuf + 10, pAdapter->macAddressCurrent.bytes, sizeof(pAdapter->macAddressCurrent.bytes)); |
| 2884 | |
Srinivas Girigowda | b27c019 | 2013-06-03 10:19:56 -0700 | [diff] [blame] | 2885 | /* Fill BSSID (AP mac address) */ |
| 2886 | vos_mem_copy(finalBuf + 16, targetApBssid, sizeof(targetApBssid)); |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 2887 | |
| 2888 | /* Fill received buffer from 24th address */ |
| 2889 | vos_mem_copy(finalBuf + 24, buf, bufLen); |
| 2890 | |
Jeff Johnson | 11c3315 | 2013-04-16 17:52:40 -0700 | [diff] [blame] | 2891 | /* done with the parsed buffer */ |
| 2892 | vos_mem_free(buf); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 2893 | buf = NULL; |
Jeff Johnson | 11c3315 | 2013-04-16 17:52:40 -0700 | [diff] [blame] | 2894 | |
DARAM SUDHA | 39eede6 | 2014-02-12 11:16:40 +0530 | [diff] [blame] | 2895 | wlan_hdd_mgmt_tx( NULL, |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 2896 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 2897 | &(pAdapter->wdev), |
| 2898 | #else |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2899 | pAdapter->dev, |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 2900 | #endif |
| 2901 | &chan, 0, |
| 2902 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)) |
| 2903 | NL80211_CHAN_HT20, 1, |
| 2904 | #endif |
| 2905 | dwellTime, finalBuf, finalLen, 1, |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 2906 | 1, &cookie ); |
| 2907 | vos_mem_free(finalBuf); |
| 2908 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2909 | else if (strncmp(command, "GETROAMSCANCHANNELMINTIME", 25) == 0) |
| 2910 | { |
| 2911 | tANI_U16 val = sme_getNeighborScanMinChanTime((tHalHandle)(pHddCtx->hHal)); |
| 2912 | char extra[32]; |
| 2913 | tANI_U8 len = 0; |
| 2914 | |
| 2915 | /* value is interms of msec */ |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2916 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 2917 | "GETROAMSCANCHANNELMINTIME", val); |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2918 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2919 | TRACE_CODE_HDD_GETROAMSCANCHANNELMINTIME_IOCTL, |
| 2920 | pAdapter->sessionId, val)); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2921 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2922 | { |
| 2923 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2924 | "%s: failed to copy data to user buffer", __func__); |
| 2925 | ret = -EFAULT; |
| 2926 | goto exit; |
| 2927 | } |
| 2928 | } |
| 2929 | else if (strncmp(command, "SETSCANCHANNELTIME", 18) == 0) |
| 2930 | { |
| 2931 | tANI_U8 *value = command; |
Varun Reddy Yeturu | 3885a66 | 2013-06-19 07:10:37 -0700 | [diff] [blame] | 2932 | tANI_U16 maxTime = CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_DEFAULT; |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2933 | |
| 2934 | /* Move pointer to ahead of SETSCANCHANNELTIME<delimiter> */ |
| 2935 | value = value + 19; |
| 2936 | /* Convert the value from ascii to integer */ |
Varun Reddy Yeturu | 3885a66 | 2013-06-19 07:10:37 -0700 | [diff] [blame] | 2937 | ret = kstrtou16(value, 10, &maxTime); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2938 | if (ret < 0) |
| 2939 | { |
| 2940 | /* 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] | 2941 | kstrtou16 fails */ |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2942 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Varun Reddy Yeturu | 3885a66 | 2013-06-19 07:10:37 -0700 | [diff] [blame] | 2943 | "%s: kstrtou16 failed range [%d - %d]", __func__, |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2944 | CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MIN, |
| 2945 | CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MAX); |
| 2946 | ret = -EINVAL; |
| 2947 | goto exit; |
| 2948 | } |
| 2949 | |
| 2950 | if ((maxTime < CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MIN) || |
| 2951 | (maxTime > CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MAX)) |
| 2952 | { |
| 2953 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2954 | "lfr mode value %d is out of range" |
| 2955 | " (Min: %d Max: %d)", maxTime, |
| 2956 | CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MIN, |
| 2957 | CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MAX); |
| 2958 | ret = -EINVAL; |
| 2959 | goto exit; |
| 2960 | } |
| 2961 | |
| 2962 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2963 | "%s: Received Command to change channel max time = %d", __func__, maxTime); |
| 2964 | |
| 2965 | pHddCtx->cfg_ini->nNeighborScanMaxChanTime = maxTime; |
| 2966 | sme_setNeighborScanMaxChanTime((tHalHandle)(pHddCtx->hHal), maxTime); |
| 2967 | } |
| 2968 | else if (strncmp(command, "GETSCANCHANNELTIME", 18) == 0) |
| 2969 | { |
| 2970 | tANI_U16 val = sme_getNeighborScanMaxChanTime((tHalHandle)(pHddCtx->hHal)); |
| 2971 | char extra[32]; |
| 2972 | tANI_U8 len = 0; |
| 2973 | |
| 2974 | /* value is interms of msec */ |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2975 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 2976 | "GETSCANCHANNELTIME", val); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2977 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2978 | { |
| 2979 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2980 | "%s: failed to copy data to user buffer", __func__); |
| 2981 | ret = -EFAULT; |
| 2982 | goto exit; |
| 2983 | } |
| 2984 | } |
| 2985 | else if (strncmp(command, "SETSCANHOMETIME", 15) == 0) |
| 2986 | { |
| 2987 | tANI_U8 *value = command; |
| 2988 | tANI_U16 val = CFG_NEIGHBOR_SCAN_TIMER_PERIOD_DEFAULT; |
| 2989 | |
| 2990 | /* Move pointer to ahead of SETSCANHOMETIME<delimiter> */ |
| 2991 | value = value + 16; |
| 2992 | /* Convert the value from ascii to integer */ |
| 2993 | ret = kstrtou16(value, 10, &val); |
| 2994 | if (ret < 0) |
| 2995 | { |
| 2996 | /* If the input value is greater than max value of datatype, then also |
| 2997 | kstrtou16 fails */ |
| 2998 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2999 | "%s: kstrtou16 failed range [%d - %d]", __func__, |
| 3000 | CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MIN, |
| 3001 | CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MAX); |
| 3002 | ret = -EINVAL; |
| 3003 | goto exit; |
| 3004 | } |
| 3005 | |
| 3006 | if ((val < CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MIN) || |
| 3007 | (val > CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MAX)) |
| 3008 | { |
| 3009 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3010 | "scan home time value %d is out of range" |
| 3011 | " (Min: %d Max: %d)", val, |
| 3012 | CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MIN, |
| 3013 | CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MAX); |
| 3014 | ret = -EINVAL; |
| 3015 | goto exit; |
| 3016 | } |
| 3017 | |
| 3018 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3019 | "%s: Received Command to change scan home time = %d", __func__, val); |
| 3020 | |
| 3021 | pHddCtx->cfg_ini->nNeighborScanPeriod = val; |
| 3022 | sme_setNeighborScanPeriod((tHalHandle)(pHddCtx->hHal), val); |
| 3023 | } |
| 3024 | else if (strncmp(command, "GETSCANHOMETIME", 15) == 0) |
| 3025 | { |
| 3026 | tANI_U16 val = sme_getNeighborScanPeriod((tHalHandle)(pHddCtx->hHal)); |
| 3027 | char extra[32]; |
| 3028 | tANI_U8 len = 0; |
| 3029 | |
| 3030 | /* value is interms of msec */ |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3031 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3032 | "GETSCANHOMETIME", val); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3033 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 3034 | { |
| 3035 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3036 | "%s: failed to copy data to user buffer", __func__); |
| 3037 | ret = -EFAULT; |
| 3038 | goto exit; |
| 3039 | } |
| 3040 | } |
| 3041 | else if (strncmp(command, "SETROAMINTRABAND", 16) == 0) |
| 3042 | { |
| 3043 | tANI_U8 *value = command; |
| 3044 | tANI_U8 val = CFG_ROAM_INTRA_BAND_DEFAULT; |
| 3045 | |
| 3046 | /* Move pointer to ahead of SETROAMINTRABAND<delimiter> */ |
| 3047 | value = value + 17; |
| 3048 | /* Convert the value from ascii to integer */ |
| 3049 | ret = kstrtou8(value, 10, &val); |
| 3050 | if (ret < 0) |
| 3051 | { |
| 3052 | /* If the input value is greater than max value of datatype, then also |
| 3053 | kstrtou8 fails */ |
| 3054 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3055 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3056 | CFG_ROAM_INTRA_BAND_MIN, |
| 3057 | CFG_ROAM_INTRA_BAND_MAX); |
| 3058 | ret = -EINVAL; |
| 3059 | goto exit; |
| 3060 | } |
| 3061 | |
| 3062 | if ((val < CFG_ROAM_INTRA_BAND_MIN) || |
| 3063 | (val > CFG_ROAM_INTRA_BAND_MAX)) |
| 3064 | { |
| 3065 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3066 | "intra band mode value %d is out of range" |
| 3067 | " (Min: %d Max: %d)", val, |
| 3068 | CFG_ROAM_INTRA_BAND_MIN, |
| 3069 | CFG_ROAM_INTRA_BAND_MAX); |
| 3070 | ret = -EINVAL; |
| 3071 | goto exit; |
| 3072 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3073 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3074 | "%s: Received Command to change intra band = %d", __func__, val); |
| 3075 | |
| 3076 | pHddCtx->cfg_ini->nRoamIntraBand = val; |
| 3077 | sme_setRoamIntraBand((tHalHandle)(pHddCtx->hHal), val); |
| 3078 | } |
| 3079 | else if (strncmp(command, "GETROAMINTRABAND", 16) == 0) |
| 3080 | { |
| 3081 | tANI_U16 val = sme_getRoamIntraBand((tHalHandle)(pHddCtx->hHal)); |
| 3082 | char extra[32]; |
| 3083 | tANI_U8 len = 0; |
| 3084 | |
| 3085 | /* value is interms of msec */ |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3086 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3087 | "GETROAMINTRABAND", val); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3088 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 3089 | { |
| 3090 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3091 | "%s: failed to copy data to user buffer", __func__); |
| 3092 | ret = -EFAULT; |
| 3093 | goto exit; |
| 3094 | } |
| 3095 | } |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3096 | else if (strncmp(command, "SETSCANNPROBES", 14) == 0) |
| 3097 | { |
| 3098 | tANI_U8 *value = command; |
| 3099 | tANI_U8 nProbes = CFG_ROAM_SCAN_N_PROBES_DEFAULT; |
| 3100 | |
| 3101 | /* Move pointer to ahead of SETSCANNPROBES<delimiter> */ |
| 3102 | value = value + 15; |
| 3103 | /* Convert the value from ascii to integer */ |
| 3104 | ret = kstrtou8(value, 10, &nProbes); |
| 3105 | if (ret < 0) |
| 3106 | { |
| 3107 | /* If the input value is greater than max value of datatype, then also |
| 3108 | kstrtou8 fails */ |
| 3109 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3110 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3111 | CFG_ROAM_SCAN_N_PROBES_MIN, |
| 3112 | CFG_ROAM_SCAN_N_PROBES_MAX); |
| 3113 | ret = -EINVAL; |
| 3114 | goto exit; |
| 3115 | } |
| 3116 | |
| 3117 | if ((nProbes < CFG_ROAM_SCAN_N_PROBES_MIN) || |
| 3118 | (nProbes > CFG_ROAM_SCAN_N_PROBES_MAX)) |
| 3119 | { |
| 3120 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3121 | "NProbes value %d is out of range" |
| 3122 | " (Min: %d Max: %d)", nProbes, |
| 3123 | CFG_ROAM_SCAN_N_PROBES_MIN, |
| 3124 | CFG_ROAM_SCAN_N_PROBES_MAX); |
| 3125 | ret = -EINVAL; |
| 3126 | goto exit; |
| 3127 | } |
| 3128 | |
| 3129 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3130 | "%s: Received Command to Set nProbes = %d", __func__, nProbes); |
| 3131 | |
| 3132 | pHddCtx->cfg_ini->nProbes = nProbes; |
| 3133 | sme_UpdateRoamScanNProbes((tHalHandle)(pHddCtx->hHal), nProbes); |
| 3134 | } |
| 3135 | else if (strncmp(priv_data.buf, "GETSCANNPROBES", 14) == 0) |
| 3136 | { |
| 3137 | tANI_U8 val = sme_getRoamScanNProbes((tHalHandle)(pHddCtx->hHal)); |
| 3138 | char extra[32]; |
| 3139 | tANI_U8 len = 0; |
| 3140 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3141 | len = scnprintf(extra, sizeof(extra), "%s %d", command, val); |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3142 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 3143 | { |
| 3144 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3145 | "%s: failed to copy data to user buffer", __func__); |
| 3146 | ret = -EFAULT; |
| 3147 | goto exit; |
| 3148 | } |
| 3149 | } |
| 3150 | else if (strncmp(command, "SETSCANHOMEAWAYTIME", 19) == 0) |
| 3151 | { |
| 3152 | tANI_U8 *value = command; |
| 3153 | tANI_U16 homeAwayTime = CFG_ROAM_SCAN_HOME_AWAY_TIME_DEFAULT; |
| 3154 | |
| 3155 | /* Move pointer to ahead of SETSCANHOMEAWAYTIME<delimiter> */ |
| 3156 | /* input value is in units of msec */ |
| 3157 | value = value + 20; |
| 3158 | /* Convert the value from ascii to integer */ |
| 3159 | ret = kstrtou16(value, 10, &homeAwayTime); |
| 3160 | if (ret < 0) |
| 3161 | { |
| 3162 | /* If the input value is greater than max value of datatype, then also |
| 3163 | kstrtou8 fails */ |
| 3164 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3165 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3166 | CFG_ROAM_SCAN_HOME_AWAY_TIME_MIN, |
| 3167 | CFG_ROAM_SCAN_HOME_AWAY_TIME_MAX); |
| 3168 | ret = -EINVAL; |
| 3169 | goto exit; |
| 3170 | } |
| 3171 | |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3172 | if ((homeAwayTime < CFG_ROAM_SCAN_HOME_AWAY_TIME_MIN) || |
| 3173 | (homeAwayTime > CFG_ROAM_SCAN_HOME_AWAY_TIME_MAX)) |
| 3174 | { |
| 3175 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3176 | "homeAwayTime value %d is out of range" |
| 3177 | " (Min: %d Max: %d)", homeAwayTime, |
| 3178 | CFG_ROAM_SCAN_HOME_AWAY_TIME_MIN, |
| 3179 | CFG_ROAM_SCAN_HOME_AWAY_TIME_MAX); |
| 3180 | ret = -EINVAL; |
| 3181 | goto exit; |
| 3182 | } |
| 3183 | |
| 3184 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3185 | "%s: Received Command to Set scan away time = %d", __func__, homeAwayTime); |
Srinivas Girigowda | 6cf0b82 | 2013-06-27 14:00:20 -0700 | [diff] [blame] | 3186 | if (pHddCtx->cfg_ini->nRoamScanHomeAwayTime != homeAwayTime) |
| 3187 | { |
| 3188 | pHddCtx->cfg_ini->nRoamScanHomeAwayTime = homeAwayTime; |
| 3189 | sme_UpdateRoamScanHomeAwayTime((tHalHandle)(pHddCtx->hHal), homeAwayTime, eANI_BOOLEAN_TRUE); |
| 3190 | } |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3191 | } |
| 3192 | else if (strncmp(priv_data.buf, "GETSCANHOMEAWAYTIME", 19) == 0) |
| 3193 | { |
| 3194 | tANI_U16 val = sme_getRoamScanHomeAwayTime((tHalHandle)(pHddCtx->hHal)); |
| 3195 | char extra[32]; |
| 3196 | tANI_U8 len = 0; |
| 3197 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3198 | len = scnprintf(extra, sizeof(extra), "%s %d", command, val); |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3199 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 3200 | { |
| 3201 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3202 | "%s: failed to copy data to user buffer", __func__); |
| 3203 | ret = -EFAULT; |
| 3204 | goto exit; |
| 3205 | } |
| 3206 | } |
| 3207 | else if (strncmp(command, "REASSOC", 7) == 0) |
| 3208 | { |
| 3209 | tANI_U8 *value = command; |
| 3210 | tANI_U8 channel = 0; |
| 3211 | tSirMacAddr targetApBssid; |
| 3212 | eHalStatus status = eHAL_STATUS_SUCCESS; |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 3213 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 3214 | tCsrHandoffRequest handoffInfo; |
| 3215 | #endif |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3216 | hdd_station_ctx_t *pHddStaCtx = NULL; |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3217 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3218 | |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3219 | /* if not associated, no need to proceed with reassoc */ |
| 3220 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 3221 | { |
| 3222 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__); |
| 3223 | ret = -EINVAL; |
| 3224 | goto exit; |
| 3225 | } |
| 3226 | |
| 3227 | status = hdd_parse_reassoc_command_data(value, targetApBssid, &channel); |
| 3228 | if (eHAL_STATUS_SUCCESS != status) |
| 3229 | { |
| 3230 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3231 | "%s: Failed to parse reassoc command data", __func__); |
| 3232 | ret = -EINVAL; |
| 3233 | goto exit; |
| 3234 | } |
| 3235 | |
| 3236 | /* if the target bssid is same as currently associated AP, |
| 3237 | then no need to proceed with reassoc */ |
| 3238 | if (VOS_TRUE == vos_mem_compare(targetApBssid, |
| 3239 | pHddStaCtx->conn_info.bssId, sizeof(tSirMacAddr))) |
| 3240 | { |
| 3241 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Reassoc BSSID is same as currently associated AP bssid",__func__); |
| 3242 | ret = -EINVAL; |
| 3243 | goto exit; |
| 3244 | } |
| 3245 | |
| 3246 | /* Check channel number is a valid channel number */ |
| 3247 | if(VOS_STATUS_SUCCESS != |
| 3248 | wlan_hdd_validate_operation_channel(pAdapter, channel)) |
| 3249 | { |
| 3250 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 3251 | "%s: Invalid Channel [%d]", __func__, channel); |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3252 | return -EINVAL; |
| 3253 | } |
| 3254 | |
| 3255 | /* Proceed with reassoc */ |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 3256 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 3257 | handoffInfo.channel = channel; |
| 3258 | vos_mem_copy(handoffInfo.bssid, targetApBssid, sizeof(tSirMacAddr)); |
| 3259 | sme_HandoffRequest(pHddCtx->hHal, &handoffInfo); |
| 3260 | #endif |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3261 | } |
Srinivas Girigowda | ad34ca9 | 2013-10-22 10:54:29 -0700 | [diff] [blame] | 3262 | else if (strncmp(command, "SETWESMODE", 10) == 0) |
| 3263 | { |
| 3264 | tANI_U8 *value = command; |
| 3265 | tANI_BOOLEAN wesMode = CFG_ENABLE_WES_MODE_NAME_DEFAULT; |
| 3266 | |
| 3267 | /* Move pointer to ahead of SETWESMODE<delimiter> */ |
| 3268 | value = value + 11; |
| 3269 | /* Convert the value from ascii to integer */ |
| 3270 | ret = kstrtou8(value, 10, &wesMode); |
| 3271 | if (ret < 0) |
| 3272 | { |
| 3273 | /* If the input value is greater than max value of datatype, then also |
| 3274 | kstrtou8 fails */ |
| 3275 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3276 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3277 | CFG_ENABLE_WES_MODE_NAME_MIN, |
| 3278 | CFG_ENABLE_WES_MODE_NAME_MAX); |
| 3279 | ret = -EINVAL; |
| 3280 | goto exit; |
| 3281 | } |
| 3282 | |
| 3283 | if ((wesMode < CFG_ENABLE_WES_MODE_NAME_MIN) || |
| 3284 | (wesMode > CFG_ENABLE_WES_MODE_NAME_MAX)) |
| 3285 | { |
| 3286 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3287 | "WES Mode value %d is out of range" |
| 3288 | " (Min: %d Max: %d)", wesMode, |
| 3289 | CFG_ENABLE_WES_MODE_NAME_MIN, |
| 3290 | CFG_ENABLE_WES_MODE_NAME_MAX); |
| 3291 | ret = -EINVAL; |
| 3292 | goto exit; |
| 3293 | } |
| 3294 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3295 | "%s: Received Command to Set WES Mode rssi diff = %d", __func__, wesMode); |
| 3296 | |
| 3297 | pHddCtx->cfg_ini->isWESModeEnabled = wesMode; |
| 3298 | sme_UpdateWESMode((tHalHandle)(pHddCtx->hHal), wesMode); |
| 3299 | } |
| 3300 | else if (strncmp(priv_data.buf, "GETWESMODE", 10) == 0) |
| 3301 | { |
| 3302 | tANI_BOOLEAN wesMode = sme_GetWESMode((tHalHandle)(pHddCtx->hHal)); |
| 3303 | char extra[32]; |
| 3304 | tANI_U8 len = 0; |
| 3305 | |
Arif Hussain | 826d941 | 2013-11-12 16:44:54 -0800 | [diff] [blame] | 3306 | len = scnprintf(extra, sizeof(extra), "%s %d", command, wesMode); |
Srinivas Girigowda | ad34ca9 | 2013-10-22 10:54:29 -0700 | [diff] [blame] | 3307 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 3308 | { |
| 3309 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3310 | "%s: failed to copy data to user buffer", __func__); |
| 3311 | ret = -EFAULT; |
| 3312 | goto exit; |
| 3313 | } |
| 3314 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3315 | #endif /* WLAN_FEATURE_VOWIFI_11R || FEATURE_WLAN_ESE || FEATURE_WLAN_LFR */ |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3316 | #ifdef FEATURE_WLAN_LFR |
| 3317 | else if (strncmp(command, "SETFASTROAM", 11) == 0) |
| 3318 | { |
| 3319 | tANI_U8 *value = command; |
| 3320 | tANI_U8 lfrMode = CFG_LFR_FEATURE_ENABLED_DEFAULT; |
| 3321 | |
| 3322 | /* Move pointer to ahead of SETFASTROAM<delimiter> */ |
| 3323 | value = value + 12; |
| 3324 | /* Convert the value from ascii to integer */ |
| 3325 | ret = kstrtou8(value, 10, &lfrMode); |
| 3326 | if (ret < 0) |
| 3327 | { |
| 3328 | /* If the input value is greater than max value of datatype, then also |
| 3329 | kstrtou8 fails */ |
| 3330 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3331 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3332 | CFG_LFR_FEATURE_ENABLED_MIN, |
| 3333 | CFG_LFR_FEATURE_ENABLED_MAX); |
| 3334 | ret = -EINVAL; |
| 3335 | goto exit; |
| 3336 | } |
| 3337 | |
| 3338 | if ((lfrMode < CFG_LFR_FEATURE_ENABLED_MIN) || |
| 3339 | (lfrMode > CFG_LFR_FEATURE_ENABLED_MAX)) |
| 3340 | { |
| 3341 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3342 | "lfr mode value %d is out of range" |
| 3343 | " (Min: %d Max: %d)", lfrMode, |
| 3344 | CFG_LFR_FEATURE_ENABLED_MIN, |
| 3345 | CFG_LFR_FEATURE_ENABLED_MAX); |
| 3346 | ret = -EINVAL; |
| 3347 | goto exit; |
| 3348 | } |
| 3349 | |
| 3350 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3351 | "%s: Received Command to change lfr mode = %d", __func__, lfrMode); |
| 3352 | |
| 3353 | pHddCtx->cfg_ini->isFastRoamIniFeatureEnabled = lfrMode; |
| 3354 | sme_UpdateIsFastRoamIniFeatureEnabled((tHalHandle)(pHddCtx->hHal), lfrMode); |
| 3355 | } |
| 3356 | #endif |
| 3357 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 3358 | else if (strncmp(command, "SETFASTTRANSITION", 17) == 0) |
| 3359 | { |
| 3360 | tANI_U8 *value = command; |
| 3361 | tANI_U8 ft = CFG_FAST_TRANSITION_ENABLED_NAME_DEFAULT; |
| 3362 | |
| 3363 | /* Move pointer to ahead of SETFASTROAM<delimiter> */ |
| 3364 | value = value + 18; |
| 3365 | /* Convert the value from ascii to integer */ |
| 3366 | ret = kstrtou8(value, 10, &ft); |
| 3367 | if (ret < 0) |
| 3368 | { |
| 3369 | /* If the input value is greater than max value of datatype, then also |
| 3370 | kstrtou8 fails */ |
| 3371 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3372 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3373 | CFG_FAST_TRANSITION_ENABLED_NAME_MIN, |
| 3374 | CFG_FAST_TRANSITION_ENABLED_NAME_MAX); |
| 3375 | ret = -EINVAL; |
| 3376 | goto exit; |
| 3377 | } |
| 3378 | |
| 3379 | if ((ft < CFG_FAST_TRANSITION_ENABLED_NAME_MIN) || |
| 3380 | (ft > CFG_FAST_TRANSITION_ENABLED_NAME_MAX)) |
| 3381 | { |
| 3382 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3383 | "ft mode value %d is out of range" |
| 3384 | " (Min: %d Max: %d)", ft, |
| 3385 | CFG_FAST_TRANSITION_ENABLED_NAME_MIN, |
| 3386 | CFG_FAST_TRANSITION_ENABLED_NAME_MAX); |
| 3387 | ret = -EINVAL; |
| 3388 | goto exit; |
| 3389 | } |
| 3390 | |
| 3391 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3392 | "%s: Received Command to change ft mode = %d", __func__, ft); |
| 3393 | |
| 3394 | pHddCtx->cfg_ini->isFastTransitionEnabled = ft; |
| 3395 | sme_UpdateFastTransitionEnabled((tHalHandle)(pHddCtx->hHal), ft); |
| 3396 | } |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 3397 | |
| 3398 | else if (strncmp(command, "FASTREASSOC", 11) == 0) |
| 3399 | { |
| 3400 | tANI_U8 *value = command; |
| 3401 | tSirMacAddr targetApBssid; |
| 3402 | tANI_U8 trigger = 0; |
| 3403 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 3404 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 3405 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3406 | |
| 3407 | /* if not associated, no need to proceed with reassoc */ |
| 3408 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 3409 | { |
| 3410 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__); |
| 3411 | ret = -EINVAL; |
| 3412 | goto exit; |
| 3413 | } |
| 3414 | |
| 3415 | status = hdd_parse_reassoc_command_data(value, targetApBssid, &trigger); |
| 3416 | if (eHAL_STATUS_SUCCESS != status) |
| 3417 | { |
| 3418 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3419 | "%s: Failed to parse reassoc command data", __func__); |
| 3420 | ret = -EINVAL; |
| 3421 | goto exit; |
| 3422 | } |
| 3423 | |
| 3424 | /* if the target bssid is same as currently associated AP, |
| 3425 | then no need to proceed with reassoc */ |
| 3426 | if (VOS_TRUE == vos_mem_compare(targetApBssid, |
| 3427 | pHddStaCtx->conn_info.bssId, sizeof(tSirMacAddr))) |
| 3428 | { |
| 3429 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3430 | "%s:11r Reassoc BSSID is same as currently associated AP bssid", |
| 3431 | __func__); |
| 3432 | ret = -EINVAL; |
| 3433 | goto exit; |
| 3434 | } |
| 3435 | |
| 3436 | /* Proceed with scan/roam */ |
| 3437 | smeIssueFastRoamNeighborAPEvent(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 3438 | &targetApBssid[0], |
| 3439 | (tSmeFastRoamTrigger)(trigger)); |
| 3440 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3441 | #endif |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3442 | #ifdef FEATURE_WLAN_ESE |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3443 | else if (strncmp(command, "SETCCXMODE", 10) == 0) |
| 3444 | { |
| 3445 | tANI_U8 *value = command; |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3446 | tANI_U8 eseMode = CFG_ESE_FEATURE_ENABLED_DEFAULT; |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3447 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3448 | /* Check if the features OKC/ESE/11R are supported simultaneously, |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 3449 | then this operation is not permitted (return FAILURE) */ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3450 | if (sme_getIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal)) && |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 3451 | hdd_is_okc_mode_enabled(pHddCtx) && |
| 3452 | sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal))) |
| 3453 | { |
| 3454 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3455 | "%s: OKC/ESE/11R are supported simultaneously" |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 3456 | " hence this operation is not permitted!", __func__); |
| 3457 | ret = -EPERM; |
| 3458 | goto exit; |
| 3459 | } |
| 3460 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3461 | /* Move pointer to ahead of SETCCXMODE<delimiter> */ |
| 3462 | value = value + 11; |
| 3463 | /* Convert the value from ascii to integer */ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3464 | ret = kstrtou8(value, 10, &eseMode); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3465 | if (ret < 0) |
| 3466 | { |
| 3467 | /* If the input value is greater than max value of datatype, then also |
| 3468 | kstrtou8 fails */ |
| 3469 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3470 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3471 | CFG_ESE_FEATURE_ENABLED_MIN, |
| 3472 | CFG_ESE_FEATURE_ENABLED_MAX); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3473 | ret = -EINVAL; |
| 3474 | goto exit; |
| 3475 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3476 | if ((eseMode < CFG_ESE_FEATURE_ENABLED_MIN) || |
| 3477 | (eseMode > CFG_ESE_FEATURE_ENABLED_MAX)) |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3478 | { |
| 3479 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3480 | "Ese mode value %d is out of range" |
| 3481 | " (Min: %d Max: %d)", eseMode, |
| 3482 | CFG_ESE_FEATURE_ENABLED_MIN, |
| 3483 | CFG_ESE_FEATURE_ENABLED_MAX); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3484 | ret = -EINVAL; |
| 3485 | goto exit; |
| 3486 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3487 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3488 | "%s: Received Command to change ese mode = %d", __func__, eseMode); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3489 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3490 | pHddCtx->cfg_ini->isEseIniFeatureEnabled = eseMode; |
| 3491 | sme_UpdateIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal), eseMode); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3492 | } |
| 3493 | #endif |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 3494 | else if (strncmp(command, "SETROAMSCANCONTROL", 18) == 0) |
| 3495 | { |
| 3496 | tANI_U8 *value = command; |
| 3497 | tANI_BOOLEAN roamScanControl = 0; |
| 3498 | |
| 3499 | /* Move pointer to ahead of SETROAMSCANCONTROL<delimiter> */ |
| 3500 | value = value + 19; |
| 3501 | /* Convert the value from ascii to integer */ |
| 3502 | ret = kstrtou8(value, 10, &roamScanControl); |
| 3503 | if (ret < 0) |
| 3504 | { |
| 3505 | /* If the input value is greater than max value of datatype, then also |
| 3506 | kstrtou8 fails */ |
| 3507 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3508 | "%s: kstrtou8 failed ", __func__); |
| 3509 | ret = -EINVAL; |
| 3510 | goto exit; |
| 3511 | } |
| 3512 | |
| 3513 | if (0 != roamScanControl) |
| 3514 | { |
| 3515 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3516 | "roam scan control invalid value = %d", |
| 3517 | roamScanControl); |
| 3518 | ret = -EINVAL; |
| 3519 | goto exit; |
| 3520 | } |
| 3521 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3522 | "%s: Received Command to Set roam scan control = %d", __func__, roamScanControl); |
| 3523 | |
| 3524 | sme_SetRoamScanControl((tHalHandle)(pHddCtx->hHal), roamScanControl); |
| 3525 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3526 | #ifdef FEATURE_WLAN_OKC |
| 3527 | else if (strncmp(command, "SETOKCMODE", 10) == 0) |
| 3528 | { |
| 3529 | tANI_U8 *value = command; |
| 3530 | tANI_U8 okcMode = CFG_OKC_FEATURE_ENABLED_DEFAULT; |
| 3531 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3532 | /* Check if the features OKC/ESE/11R are supported simultaneously, |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 3533 | then this operation is not permitted (return FAILURE) */ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3534 | if (sme_getIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal)) && |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 3535 | hdd_is_okc_mode_enabled(pHddCtx) && |
| 3536 | sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal))) |
| 3537 | { |
| 3538 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3539 | "%s: OKC/ESE/11R are supported simultaneously" |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 3540 | " hence this operation is not permitted!", __func__); |
| 3541 | ret = -EPERM; |
| 3542 | goto exit; |
| 3543 | } |
| 3544 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3545 | /* Move pointer to ahead of SETOKCMODE<delimiter> */ |
| 3546 | value = value + 11; |
| 3547 | /* Convert the value from ascii to integer */ |
| 3548 | ret = kstrtou8(value, 10, &okcMode); |
| 3549 | if (ret < 0) |
| 3550 | { |
| 3551 | /* If the input value is greater than max value of datatype, then also |
| 3552 | kstrtou8 fails */ |
| 3553 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3554 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3555 | CFG_OKC_FEATURE_ENABLED_MIN, |
| 3556 | CFG_OKC_FEATURE_ENABLED_MAX); |
| 3557 | ret = -EINVAL; |
| 3558 | goto exit; |
| 3559 | } |
| 3560 | |
| 3561 | if ((okcMode < CFG_OKC_FEATURE_ENABLED_MIN) || |
| 3562 | (okcMode > CFG_OKC_FEATURE_ENABLED_MAX)) |
| 3563 | { |
| 3564 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3565 | "Okc mode value %d is out of range" |
| 3566 | " (Min: %d Max: %d)", okcMode, |
| 3567 | CFG_OKC_FEATURE_ENABLED_MIN, |
| 3568 | CFG_OKC_FEATURE_ENABLED_MAX); |
| 3569 | ret = -EINVAL; |
| 3570 | goto exit; |
| 3571 | } |
| 3572 | |
| 3573 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3574 | "%s: Received Command to change okc mode = %d", __func__, okcMode); |
| 3575 | |
| 3576 | pHddCtx->cfg_ini->isOkcIniFeatureEnabled = okcMode; |
| 3577 | } |
Srinivas Girigowda | ad34ca9 | 2013-10-22 10:54:29 -0700 | [diff] [blame] | 3578 | #endif /* FEATURE_WLAN_OKC */ |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 3579 | else if (strncmp(priv_data.buf, "GETROAMSCANCONTROL", 18) == 0) |
| 3580 | { |
| 3581 | tANI_BOOLEAN roamScanControl = sme_GetRoamScanControl((tHalHandle)(pHddCtx->hHal)); |
| 3582 | char extra[32]; |
| 3583 | tANI_U8 len = 0; |
| 3584 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3585 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3586 | command, roamScanControl); |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 3587 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 3588 | { |
| 3589 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3590 | "%s: failed to copy data to user buffer", __func__); |
| 3591 | ret = -EFAULT; |
| 3592 | goto exit; |
| 3593 | } |
| 3594 | } |
Gopichand Nakkala | 227c7f3 | 2013-06-26 22:44:57 +0530 | [diff] [blame] | 3595 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 3596 | else if (strncmp(command, "ENABLE_PKTFILTER_IPV6", 21) == 0) |
| 3597 | { |
| 3598 | tANI_U8 filterType = 0; |
| 3599 | tANI_U8 *value = command; |
| 3600 | |
| 3601 | /* Move pointer to ahead of ENABLE_PKTFILTER_IPV6<delimiter> */ |
| 3602 | value = value + 22; |
| 3603 | |
| 3604 | /* Convert the value from ascii to integer */ |
| 3605 | ret = kstrtou8(value, 10, &filterType); |
| 3606 | if (ret < 0) |
| 3607 | { |
| 3608 | /* If the input value is greater than max value of datatype, |
| 3609 | * then also kstrtou8 fails |
| 3610 | */ |
| 3611 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3612 | "%s: kstrtou8 failed range ", __func__); |
| 3613 | ret = -EINVAL; |
| 3614 | goto exit; |
| 3615 | } |
| 3616 | |
| 3617 | if (filterType != 0 && filterType != 1) |
| 3618 | { |
| 3619 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3620 | "%s: Accepted Values are 0 and 1 ", __func__); |
| 3621 | ret = -EINVAL; |
| 3622 | goto exit; |
| 3623 | } |
| 3624 | wlan_hdd_setIPv6Filter(WLAN_HDD_GET_CTX(pAdapter), filterType, |
| 3625 | pAdapter->sessionId); |
| 3626 | } |
| 3627 | #endif |
Sundaresan Ramachandran | 76e48e8 | 2013-07-15 13:07:17 +0530 | [diff] [blame] | 3628 | else if (strncmp(command, "BTCOEXMODE", 10) == 0 ) |
| 3629 | { |
Kiet Lam | 94fd292 | 2014-06-18 19:12:43 -0700 | [diff] [blame] | 3630 | char *bcMode; |
| 3631 | bcMode = command + 11; |
| 3632 | if ('1' == *bcMode) |
Sundaresan Ramachandran | 76e48e8 | 2013-07-15 13:07:17 +0530 | [diff] [blame] | 3633 | { |
c_hpothu | 9b781ba | 2013-12-30 20:57:45 +0530 | [diff] [blame] | 3634 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Kiet Lam | 94fd292 | 2014-06-18 19:12:43 -0700 | [diff] [blame] | 3635 | FL("BTCOEXMODE %d"), *bcMode); |
c_hpothu | 9b781ba | 2013-12-30 20:57:45 +0530 | [diff] [blame] | 3636 | |
| 3637 | pHddCtx->btCoexModeSet = TRUE; |
Sundaresan Ramachandran | 76e48e8 | 2013-07-15 13:07:17 +0530 | [diff] [blame] | 3638 | } |
Kiet Lam | 94fd292 | 2014-06-18 19:12:43 -0700 | [diff] [blame] | 3639 | else if ('2' == *bcMode) |
Sundaresan Ramachandran | 76e48e8 | 2013-07-15 13:07:17 +0530 | [diff] [blame] | 3640 | { |
c_hpothu | 9b781ba | 2013-12-30 20:57:45 +0530 | [diff] [blame] | 3641 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Kiet Lam | 94fd292 | 2014-06-18 19:12:43 -0700 | [diff] [blame] | 3642 | FL("BTCOEXMODE %d"), *bcMode); |
c_hpothu | 9b781ba | 2013-12-30 20:57:45 +0530 | [diff] [blame] | 3643 | |
| 3644 | pHddCtx->btCoexModeSet = FALSE; |
Sundaresan Ramachandran | 76e48e8 | 2013-07-15 13:07:17 +0530 | [diff] [blame] | 3645 | } |
| 3646 | } |
Jeff Johnson | f54df2c | 2013-07-24 11:43:39 -0700 | [diff] [blame] | 3647 | else if (strncmp(command, "SCAN-ACTIVE", 11) == 0) |
| 3648 | { |
c_hpothu | dbefd3e | 2014-04-28 15:59:47 +0530 | [diff] [blame] | 3649 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3650 | FL("making default scan to ACTIVE")); |
| 3651 | pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN; |
Jeff Johnson | f54df2c | 2013-07-24 11:43:39 -0700 | [diff] [blame] | 3652 | } |
| 3653 | else if (strncmp(command, "SCAN-PASSIVE", 12) == 0) |
| 3654 | { |
c_hpothu | dbefd3e | 2014-04-28 15:59:47 +0530 | [diff] [blame] | 3655 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3656 | FL("making default scan to PASSIVE")); |
| 3657 | pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN; |
Jeff Johnson | f54df2c | 2013-07-24 11:43:39 -0700 | [diff] [blame] | 3658 | } |
Hanumantha Reddy Pothula | 212243c | 2013-08-01 17:28:31 +0530 | [diff] [blame] | 3659 | else if (strncmp(command, "GETDWELLTIME", 12) == 0) |
| 3660 | { |
| 3661 | hdd_config_t *pCfg = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini; |
| 3662 | char extra[32]; |
| 3663 | tANI_U8 len = 0; |
| 3664 | |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 3665 | memset(extra, 0, sizeof(extra)); |
| 3666 | ret = hdd_get_dwell_time(pCfg, command, extra, sizeof(extra), &len); |
| 3667 | 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] | 3668 | { |
| 3669 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3670 | "%s: failed to copy data to user buffer", __func__); |
| 3671 | ret = -EFAULT; |
| 3672 | goto exit; |
| 3673 | } |
| 3674 | ret = len; |
| 3675 | } |
| 3676 | else if (strncmp(command, "SETDWELLTIME", 12) == 0) |
| 3677 | { |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 3678 | ret = hdd_set_dwell_time(pAdapter, command); |
Hanumantha Reddy Pothula | 212243c | 2013-08-01 17:28:31 +0530 | [diff] [blame] | 3679 | } |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 3680 | else if ( strncasecmp(command, "MIRACAST", 8) == 0 ) |
| 3681 | { |
| 3682 | tANI_U8 filterType = 0; |
| 3683 | tANI_U8 *value; |
| 3684 | value = command + 9; |
| 3685 | |
| 3686 | /* Convert the value from ascii to integer */ |
| 3687 | ret = kstrtou8(value, 10, &filterType); |
| 3688 | if (ret < 0) |
| 3689 | { |
| 3690 | /* If the input value is greater than max value of datatype, |
| 3691 | * then also kstrtou8 fails |
| 3692 | */ |
| 3693 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3694 | "%s: kstrtou8 failed range ", __func__); |
| 3695 | ret = -EINVAL; |
| 3696 | goto exit; |
| 3697 | } |
| 3698 | if ((filterType < WLAN_HDD_DRIVER_MIRACAST_CFG_MIN_VAL ) || |
| 3699 | (filterType > WLAN_HDD_DRIVER_MIRACAST_CFG_MAX_VAL)) |
| 3700 | { |
| 3701 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3702 | "%s: Accepted Values are 0 to 2. 0-Disabled, 1-Source," |
| 3703 | " 2-Sink ", __func__); |
| 3704 | ret = -EINVAL; |
| 3705 | goto exit; |
| 3706 | } |
| 3707 | //Filtertype value should be either 0-Disabled, 1-Source, 2-sink |
| 3708 | pHddCtx->drvr_miracast = filterType; |
| 3709 | hdd_tx_rx_pkt_cnt_stat_timer_handler(pHddCtx); |
| 3710 | } |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 3711 | else if (strncmp(command, "SETMCRATE", 9) == 0) |
| 3712 | { |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 3713 | tANI_U8 *value = command; |
| 3714 | int targetRate; |
Leo Chang | 1f98cbd | 2013-10-17 15:03:52 -0700 | [diff] [blame] | 3715 | tSirRateUpdateInd *rateUpdate; |
| 3716 | eHalStatus status; |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 3717 | |
| 3718 | /* Only valid for SAP mode */ |
| 3719 | if (WLAN_HDD_SOFTAP != pAdapter->device_mode) |
| 3720 | { |
| 3721 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3722 | "%s: SAP mode is not running", __func__); |
| 3723 | ret = -EFAULT; |
| 3724 | goto exit; |
| 3725 | } |
| 3726 | |
| 3727 | /* Move pointer to ahead of SETMCRATE<delimiter> */ |
| 3728 | /* input value is in units of hundred kbps */ |
| 3729 | value = value + 10; |
| 3730 | /* Convert the value from ascii to integer, decimal base */ |
| 3731 | ret = kstrtouint(value, 10, &targetRate); |
| 3732 | |
Leo Chang | 1f98cbd | 2013-10-17 15:03:52 -0700 | [diff] [blame] | 3733 | rateUpdate = (tSirRateUpdateInd *)vos_mem_malloc(sizeof(tSirRateUpdateInd)); |
| 3734 | if (NULL == rateUpdate) |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 3735 | { |
Leo Chang | 1f98cbd | 2013-10-17 15:03:52 -0700 | [diff] [blame] | 3736 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3737 | "%s: SETMCRATE indication alloc fail", __func__); |
| 3738 | ret = -EFAULT; |
| 3739 | goto exit; |
| 3740 | } |
| 3741 | vos_mem_zero(rateUpdate, sizeof(tSirRateUpdateInd )); |
| 3742 | |
| 3743 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3744 | "MC Target rate %d", targetRate); |
| 3745 | /* Ignore unicast */ |
| 3746 | rateUpdate->ucastDataRate = -1; |
| 3747 | rateUpdate->mcastDataRate24GHz = targetRate; |
| 3748 | rateUpdate->mcastDataRate5GHz = targetRate; |
| 3749 | rateUpdate->mcastDataRate24GHzTxFlag = 0; |
| 3750 | rateUpdate->mcastDataRate5GHzTxFlag = 0; |
| 3751 | status = sme_SendRateUpdateInd(pHddCtx->hHal, rateUpdate); |
| 3752 | if (eHAL_STATUS_SUCCESS != status) |
| 3753 | { |
| 3754 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3755 | "%s: SET_MC_RATE failed", __func__); |
| 3756 | vos_mem_free(rateUpdate); |
| 3757 | ret = -EFAULT; |
| 3758 | goto exit; |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 3759 | } |
| 3760 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 3761 | #ifdef FEATURE_WLAN_BATCH_SCAN |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 3762 | else if (strncmp(command, "WLS_BATCHING", 12) == 0) |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 3763 | { |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 3764 | ret = hdd_handle_batch_scan_ioctl(pAdapter, &priv_data, command); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 3765 | } |
| 3766 | #endif |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3767 | #if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD) |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 3768 | else if (strncmp(command, "SETCCXROAMSCANCHANNELS", 22) == 0) |
| 3769 | { |
| 3770 | tANI_U8 *value = command; |
| 3771 | tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0}; |
| 3772 | tANI_U8 numChannels = 0; |
| 3773 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 3774 | |
| 3775 | status = hdd_parse_channellist(value, ChannelList, &numChannels); |
| 3776 | if (eHAL_STATUS_SUCCESS != status) |
| 3777 | { |
| 3778 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3779 | "%s: Failed to parse channel list information", __func__); |
| 3780 | ret = -EINVAL; |
| 3781 | goto exit; |
| 3782 | } |
| 3783 | |
| 3784 | if (numChannels > WNI_CFG_VALID_CHANNEL_LIST_LEN) |
| 3785 | { |
| 3786 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3787 | "%s: number of channels (%d) supported exceeded max (%d)", __func__, |
| 3788 | numChannels, WNI_CFG_VALID_CHANNEL_LIST_LEN); |
| 3789 | ret = -EINVAL; |
| 3790 | goto exit; |
| 3791 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3792 | status = sme_SetEseRoamScanChannelList((tHalHandle)(pHddCtx->hHal), |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 3793 | ChannelList, |
| 3794 | numChannels); |
| 3795 | if (eHAL_STATUS_SUCCESS != status) |
| 3796 | { |
| 3797 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3798 | "%s: Failed to update channel list information", __func__); |
| 3799 | ret = -EINVAL; |
| 3800 | goto exit; |
| 3801 | } |
| 3802 | } |
| 3803 | else if (strncmp(command, "GETTSMSTATS", 11) == 0) |
| 3804 | { |
| 3805 | tANI_U8 *value = command; |
| 3806 | char extra[128] = {0}; |
| 3807 | int len = 0; |
| 3808 | tANI_U8 tid = 0; |
| 3809 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 3810 | tAniTrafStrmMetrics tsmMetrics; |
| 3811 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3812 | |
| 3813 | /* if not associated, return error */ |
| 3814 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 3815 | { |
| 3816 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:Not associated!",__func__); |
| 3817 | ret = -EINVAL; |
| 3818 | goto exit; |
| 3819 | } |
| 3820 | |
| 3821 | /* Move pointer to ahead of GETTSMSTATS<delimiter> */ |
| 3822 | value = value + 12; |
| 3823 | /* Convert the value from ascii to integer */ |
| 3824 | ret = kstrtou8(value, 10, &tid); |
| 3825 | if (ret < 0) |
| 3826 | { |
| 3827 | /* If the input value is greater than max value of datatype, then also |
| 3828 | kstrtou8 fails */ |
| 3829 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3830 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3831 | TID_MIN_VALUE, |
| 3832 | TID_MAX_VALUE); |
| 3833 | ret = -EINVAL; |
| 3834 | goto exit; |
| 3835 | } |
| 3836 | |
| 3837 | if ((tid < TID_MIN_VALUE) || (tid > TID_MAX_VALUE)) |
| 3838 | { |
| 3839 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3840 | "tid value %d is out of range" |
| 3841 | " (Min: %d Max: %d)", tid, |
| 3842 | TID_MIN_VALUE, |
| 3843 | TID_MAX_VALUE); |
| 3844 | ret = -EINVAL; |
| 3845 | goto exit; |
| 3846 | } |
| 3847 | |
| 3848 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3849 | "%s: Received Command to get tsm stats tid = %d", __func__, tid); |
| 3850 | |
| 3851 | if (VOS_STATUS_SUCCESS != hdd_get_tsm_stats(pAdapter, tid, &tsmMetrics)) |
| 3852 | { |
| 3853 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3854 | "%s: failed to get tsm stats", __func__); |
| 3855 | ret = -EFAULT; |
| 3856 | goto exit; |
| 3857 | } |
| 3858 | |
| 3859 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3860 | "UplinkPktQueueDly(%d)\n" |
| 3861 | "UplinkPktQueueDlyHist[0](%d)\n" |
| 3862 | "UplinkPktQueueDlyHist[1](%d)\n" |
| 3863 | "UplinkPktQueueDlyHist[2](%d)\n" |
| 3864 | "UplinkPktQueueDlyHist[3](%d)\n" |
Arun Kumar Khandavalli | e876821 | 2014-02-17 16:43:34 +0530 | [diff] [blame] | 3865 | "UplinkPktTxDly(%u)\n" |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 3866 | "UplinkPktLoss(%d)\n" |
| 3867 | "UplinkPktCount(%d)\n" |
| 3868 | "RoamingCount(%d)\n" |
| 3869 | "RoamingDly(%d)", tsmMetrics.UplinkPktQueueDly, |
| 3870 | tsmMetrics.UplinkPktQueueDlyHist[0], |
| 3871 | tsmMetrics.UplinkPktQueueDlyHist[1], |
| 3872 | tsmMetrics.UplinkPktQueueDlyHist[2], |
| 3873 | tsmMetrics.UplinkPktQueueDlyHist[3], |
| 3874 | tsmMetrics.UplinkPktTxDly, tsmMetrics.UplinkPktLoss, |
| 3875 | tsmMetrics.UplinkPktCount, tsmMetrics.RoamingCount, tsmMetrics.RoamingDly); |
| 3876 | |
| 3877 | /* Output TSM stats is of the format |
| 3878 | GETTSMSTATS [PktQueueDly] [PktQueueDlyHist[0]]:[PktQueueDlyHist[1]] ...[RoamingDly] |
| 3879 | eg., GETTSMSTATS 10 1:0:0:161 20 1 17 8 39800 */ |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 3880 | 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] | 3881 | tsmMetrics.UplinkPktQueueDly, tsmMetrics.UplinkPktQueueDlyHist[0], |
| 3882 | tsmMetrics.UplinkPktQueueDlyHist[1], tsmMetrics.UplinkPktQueueDlyHist[2], |
| 3883 | tsmMetrics.UplinkPktQueueDlyHist[3], tsmMetrics.UplinkPktTxDly, |
| 3884 | tsmMetrics.UplinkPktLoss, tsmMetrics.UplinkPktCount, tsmMetrics.RoamingCount, |
| 3885 | tsmMetrics.RoamingDly); |
| 3886 | |
| 3887 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 3888 | { |
| 3889 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3890 | "%s: failed to copy data to user buffer", __func__); |
| 3891 | ret = -EFAULT; |
| 3892 | goto exit; |
| 3893 | } |
| 3894 | } |
| 3895 | else if (strncmp(command, "SETCCKMIE", 9) == 0) |
| 3896 | { |
| 3897 | tANI_U8 *value = command; |
| 3898 | tANI_U8 *cckmIe = NULL; |
| 3899 | tANI_U8 cckmIeLen = 0; |
| 3900 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 3901 | |
| 3902 | status = hdd_parse_get_cckm_ie(value, &cckmIe, &cckmIeLen); |
| 3903 | if (eHAL_STATUS_SUCCESS != status) |
| 3904 | { |
| 3905 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3906 | "%s: Failed to parse cckm ie data", __func__); |
| 3907 | ret = -EINVAL; |
| 3908 | goto exit; |
| 3909 | } |
| 3910 | |
| 3911 | if (cckmIeLen > DOT11F_IE_RSN_MAX_LEN) |
| 3912 | { |
| 3913 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3914 | "%s: CCKM Ie input length is more than max[%d]", __func__, |
| 3915 | DOT11F_IE_RSN_MAX_LEN); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 3916 | vos_mem_free(cckmIe); |
| 3917 | cckmIe = NULL; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 3918 | ret = -EINVAL; |
| 3919 | goto exit; |
| 3920 | } |
| 3921 | sme_SetCCKMIe((tHalHandle)(pHddCtx->hHal), pAdapter->sessionId, cckmIe, cckmIeLen); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 3922 | vos_mem_free(cckmIe); |
| 3923 | cckmIe = NULL; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 3924 | } |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 3925 | else if (strncmp(command, "CCXBEACONREQ", 12) == 0) |
| 3926 | { |
| 3927 | tANI_U8 *value = command; |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3928 | tCsrEseBeaconReq eseBcnReq; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 3929 | eHalStatus status = eHAL_STATUS_SUCCESS; |
Srinivas Girigowda | 0c6d7fe | 2014-05-28 18:18:10 -0700 | [diff] [blame] | 3930 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3931 | status = hdd_parse_ese_beacon_req(value, &eseBcnReq); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 3932 | if (eHAL_STATUS_SUCCESS != status) |
| 3933 | { |
| 3934 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3935 | "%s: Failed to parse ese beacon req", __func__); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 3936 | ret = -EINVAL; |
| 3937 | goto exit; |
| 3938 | } |
Srinivas Girigowda | 0c6d7fe | 2014-05-28 18:18:10 -0700 | [diff] [blame] | 3939 | if (!hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) { |
| 3940 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Not associated")); |
| 3941 | hdd_indicateEseBcnReportNoResults (pAdapter, |
| 3942 | eseBcnReq.bcnReq[0].measurementToken, |
| 3943 | 0x02, //BIT(1) set for measurement done |
| 3944 | 0); // no BSS |
| 3945 | goto exit; |
| 3946 | } |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 3947 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3948 | status = sme_SetEseBeaconRequest((tHalHandle)(pHddCtx->hHal), pAdapter->sessionId, &eseBcnReq); |
| 3949 | if (eHAL_STATUS_SUCCESS != status) |
| 3950 | { |
| 3951 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3952 | "%s: sme_SetEseBeaconRequest failed (%d)", __func__, status); |
| 3953 | ret = -EINVAL; |
| 3954 | goto exit; |
| 3955 | } |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 3956 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3957 | #endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */ |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 3958 | else if (strncmp(command, "GETBCNMISSRATE", 14) == 0) |
| 3959 | { |
| 3960 | eHalStatus status; |
| 3961 | char buf[32], len; |
| 3962 | long waitRet; |
| 3963 | bcnMissRateContext_t getBcnMissRateCtx; |
| 3964 | |
| 3965 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3966 | |
| 3967 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 3968 | { |
| 3969 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 3970 | FL("GETBCNMISSRATE: STA is not in connected state")); |
| 3971 | ret = -1; |
| 3972 | goto exit; |
| 3973 | } |
| 3974 | |
| 3975 | init_completion(&(getBcnMissRateCtx.completion)); |
| 3976 | getBcnMissRateCtx.magic = BCN_MISS_RATE_CONTEXT_MAGIC; |
| 3977 | |
| 3978 | status = sme_getBcnMissRate((tHalHandle)(pHddCtx->hHal), |
| 3979 | pAdapter->sessionId, |
| 3980 | (void *)getBcnMissRateCB, |
| 3981 | (void *)(&getBcnMissRateCtx)); |
| 3982 | if( eHAL_STATUS_SUCCESS != status) |
| 3983 | { |
| 3984 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 3985 | FL("GETBCNMISSRATE: fail to post WDA cmd")); |
| 3986 | ret = -EINVAL; |
| 3987 | goto exit; |
| 3988 | } |
| 3989 | |
| 3990 | waitRet = wait_for_completion_interruptible_timeout |
| 3991 | (&getBcnMissRateCtx.completion, BCN_MISS_RATE_TIME); |
| 3992 | if(waitRet <= 0) |
| 3993 | { |
| 3994 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3995 | FL("failed to wait on bcnMissRateComp %d"), ret); |
| 3996 | |
| 3997 | //Make magic number to zero so that callback is not called. |
| 3998 | spin_lock(&hdd_context_lock); |
| 3999 | getBcnMissRateCtx.magic = 0x0; |
| 4000 | spin_unlock(&hdd_context_lock); |
| 4001 | ret = -EINVAL; |
| 4002 | goto exit; |
| 4003 | } |
| 4004 | |
| 4005 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4006 | FL("GETBCNMISSRATE: bcnMissRate: %d"), gbcnMissRate); |
| 4007 | |
| 4008 | len = snprintf(buf, sizeof(buf), "GETBCNMISSRATE %d", gbcnMissRate); |
| 4009 | if (copy_to_user(priv_data.buf, &buf, len + 1)) |
| 4010 | { |
| 4011 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4012 | "%s: failed to copy data to user buffer", __func__); |
| 4013 | ret = -EFAULT; |
| 4014 | goto exit; |
| 4015 | } |
| 4016 | ret = len; |
| 4017 | } |
Madan Mohan Koyyalamudi | f9bdd4e | 2012-10-30 18:05:03 -0700 | [diff] [blame] | 4018 | else { |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 4019 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 4020 | TRACE_CODE_HDD_UNSUPPORTED_IOCTL, |
| 4021 | pAdapter->sessionId, 0)); |
Madan Mohan Koyyalamudi | f9bdd4e | 2012-10-30 18:05:03 -0700 | [diff] [blame] | 4022 | hddLog( VOS_TRACE_LEVEL_WARN, "%s: Unsupported GUI command %s", |
| 4023 | __func__, command); |
| 4024 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4025 | } |
| 4026 | exit: |
| 4027 | if (command) |
| 4028 | { |
| 4029 | kfree(command); |
| 4030 | } |
| 4031 | return ret; |
| 4032 | } |
| 4033 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 4034 | #ifdef CONFIG_COMPAT |
| 4035 | static int hdd_driver_compat_ioctl(hdd_adapter_t *pAdapter, struct ifreq *ifr) |
| 4036 | { |
| 4037 | struct { |
| 4038 | compat_uptr_t buf; |
| 4039 | int used_len; |
| 4040 | int total_len; |
| 4041 | } compat_priv_data; |
| 4042 | hdd_priv_data_t priv_data; |
| 4043 | int ret = 0; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4044 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 4045 | /* |
| 4046 | * Note that pAdapter and ifr have already been verified by caller, |
| 4047 | * and HDD context has also been validated |
| 4048 | */ |
| 4049 | if (copy_from_user(&compat_priv_data, ifr->ifr_data, |
| 4050 | sizeof(compat_priv_data))) { |
| 4051 | ret = -EFAULT; |
| 4052 | goto exit; |
| 4053 | } |
| 4054 | priv_data.buf = compat_ptr(compat_priv_data.buf); |
| 4055 | priv_data.used_len = compat_priv_data.used_len; |
| 4056 | priv_data.total_len = compat_priv_data.total_len; |
| 4057 | ret = hdd_driver_command(pAdapter, &priv_data); |
| 4058 | exit: |
| 4059 | return ret; |
| 4060 | } |
| 4061 | #else /* CONFIG_COMPAT */ |
| 4062 | static int hdd_driver_compat_ioctl(hdd_adapter_t *pAdapter, struct ifreq *ifr) |
| 4063 | { |
| 4064 | /* will never be invoked */ |
| 4065 | return 0; |
| 4066 | } |
| 4067 | #endif /* CONFIG_COMPAT */ |
| 4068 | |
| 4069 | static int hdd_driver_ioctl(hdd_adapter_t *pAdapter, struct ifreq *ifr) |
| 4070 | { |
| 4071 | hdd_priv_data_t priv_data; |
| 4072 | int ret = 0; |
| 4073 | |
| 4074 | /* |
| 4075 | * Note that pAdapter and ifr have already been verified by caller, |
| 4076 | * and HDD context has also been validated |
| 4077 | */ |
| 4078 | if (copy_from_user(&priv_data, ifr->ifr_data, sizeof(priv_data))) { |
| 4079 | ret = -EFAULT; |
| 4080 | } else { |
| 4081 | ret = hdd_driver_command(pAdapter, &priv_data); |
| 4082 | } |
| 4083 | return ret; |
| 4084 | } |
| 4085 | |
| 4086 | int hdd_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) |
| 4087 | { |
| 4088 | hdd_adapter_t *pAdapter; |
| 4089 | hdd_context_t *pHddCtx; |
| 4090 | int ret; |
| 4091 | |
| 4092 | pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 4093 | if (NULL == pAdapter) { |
| 4094 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 4095 | "%s: HDD adapter context is Null", __func__); |
| 4096 | ret = -ENODEV; |
| 4097 | goto exit; |
| 4098 | } |
| 4099 | if (dev != pAdapter->dev) { |
| 4100 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 4101 | "%s: HDD adapter/dev inconsistency", __func__); |
| 4102 | ret = -ENODEV; |
| 4103 | goto exit; |
| 4104 | } |
| 4105 | |
| 4106 | if ((!ifr) || (!ifr->ifr_data)) { |
| 4107 | ret = -EINVAL; |
| 4108 | goto exit; |
| 4109 | } |
| 4110 | |
| 4111 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 4112 | ret = wlan_hdd_validate_context(pHddCtx); |
| 4113 | if (ret) { |
| 4114 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4115 | "%s: invalid context", __func__); |
| 4116 | ret = -EBUSY; |
| 4117 | goto exit; |
| 4118 | } |
| 4119 | |
| 4120 | switch (cmd) { |
| 4121 | case (SIOCDEVPRIVATE + 1): |
| 4122 | if (is_compat_task()) |
| 4123 | ret = hdd_driver_compat_ioctl(pAdapter, ifr); |
| 4124 | else |
| 4125 | ret = hdd_driver_ioctl(pAdapter, ifr); |
| 4126 | break; |
| 4127 | default: |
| 4128 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unknown ioctl %d", |
| 4129 | __func__, cmd); |
| 4130 | ret = -EINVAL; |
| 4131 | break; |
| 4132 | } |
| 4133 | exit: |
| 4134 | return ret; |
| 4135 | } |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4136 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4137 | #if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4138 | /**--------------------------------------------------------------------------- |
| 4139 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4140 | \brief hdd_parse_ese_beacon_req() - Parse ese beacon request |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4141 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4142 | This function parses the ese beacon request passed in the format |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4143 | CCXBEACONREQ<space><Number of fields><space><Measurement token> |
| 4144 | <space>Channel 1<space>Scan Mode <space>Meas Duration<space>Channel N |
| 4145 | <space>Scan Mode N<space>Meas Duration N |
| 4146 | if the Number of bcn req fields (N) does not match with the actual number of fields passed |
| 4147 | then take N. |
| 4148 | <Meas Token><Channel><Scan Mode> and <Meas Duration> are treated as one pair |
| 4149 | For example, CCXBEACONREQ 2 1 1 1 30 2 44 0 40. |
| 4150 | This function does not take care of removing duplicate channels from the list |
| 4151 | |
| 4152 | \param - pValue Pointer to data |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4153 | \param - pEseBcnReq output pointer to store parsed ie information |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4154 | |
| 4155 | \return - 0 for success non-zero for failure |
| 4156 | |
| 4157 | --------------------------------------------------------------------------*/ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4158 | static VOS_STATUS hdd_parse_ese_beacon_req(tANI_U8 *pValue, |
| 4159 | tCsrEseBeaconReq *pEseBcnReq) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4160 | { |
| 4161 | tANI_U8 *inPtr = pValue; |
| 4162 | int tempInt = 0; |
| 4163 | int j = 0, i = 0, v = 0; |
| 4164 | char buf[32]; |
| 4165 | |
| 4166 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 4167 | /*no argument after the command*/ |
| 4168 | if (NULL == inPtr) |
| 4169 | { |
| 4170 | return -EINVAL; |
| 4171 | } |
| 4172 | /*no space after the command*/ |
| 4173 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 4174 | { |
| 4175 | return -EINVAL; |
| 4176 | } |
| 4177 | |
| 4178 | /*removing empty spaces*/ |
| 4179 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
| 4180 | |
| 4181 | /*no argument followed by spaces*/ |
| 4182 | if ('\0' == *inPtr) return -EINVAL; |
| 4183 | |
| 4184 | /*getting the first argument ie measurement token*/ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 4185 | v = sscanf(inPtr, "%31s ", buf); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4186 | if (1 != v) return -EINVAL; |
| 4187 | |
| 4188 | v = kstrtos32(buf, 10, &tempInt); |
| 4189 | if ( v < 0) return -EINVAL; |
| 4190 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4191 | pEseBcnReq->numBcnReqIe = tempInt; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4192 | |
| 4193 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4194 | "Number of Bcn Req Ie fields(%d)", pEseBcnReq->numBcnReqIe); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4195 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4196 | for (j = 0; j < (pEseBcnReq->numBcnReqIe); j++) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4197 | { |
| 4198 | for (i = 0; i < 4; i++) |
| 4199 | { |
| 4200 | /*inPtr pointing to the beginning of first space after number of ie fields*/ |
| 4201 | inPtr = strpbrk( inPtr, " " ); |
| 4202 | /*no ie data after the number of ie fields argument*/ |
| 4203 | if (NULL == inPtr) return -EINVAL; |
| 4204 | |
| 4205 | /*removing empty space*/ |
| 4206 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
| 4207 | |
| 4208 | /*no ie data after the number of ie fields argument and spaces*/ |
| 4209 | if ( '\0' == *inPtr ) return -EINVAL; |
| 4210 | |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 4211 | v = sscanf(inPtr, "%31s ", buf); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4212 | if (1 != v) return -EINVAL; |
| 4213 | |
| 4214 | v = kstrtos32(buf, 10, &tempInt); |
| 4215 | if (v < 0) return -EINVAL; |
| 4216 | |
| 4217 | switch (i) |
| 4218 | { |
| 4219 | case 0: /* Measurement token */ |
| 4220 | if (tempInt <= 0) |
| 4221 | { |
| 4222 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4223 | "Invalid Measurement Token(%d)", tempInt); |
| 4224 | return -EINVAL; |
| 4225 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4226 | pEseBcnReq->bcnReq[j].measurementToken = tempInt; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4227 | break; |
| 4228 | |
| 4229 | case 1: /* Channel number */ |
| 4230 | if ((tempInt <= 0) || |
| 4231 | (tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX)) |
| 4232 | { |
| 4233 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4234 | "Invalid Channel Number(%d)", tempInt); |
| 4235 | return -EINVAL; |
| 4236 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4237 | pEseBcnReq->bcnReq[j].channel = tempInt; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4238 | break; |
| 4239 | |
| 4240 | case 2: /* Scan mode */ |
Varun Reddy Yeturu | 0b18d5a | 2013-12-04 11:42:23 -0800 | [diff] [blame] | 4241 | if ((tempInt < eSIR_PASSIVE_SCAN) || (tempInt > eSIR_BEACON_TABLE)) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4242 | { |
| 4243 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4244 | "Invalid Scan Mode(%d) Expected{0|1|2}", tempInt); |
| 4245 | return -EINVAL; |
| 4246 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4247 | pEseBcnReq->bcnReq[j].scanMode= tempInt; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4248 | break; |
| 4249 | |
| 4250 | case 3: /* Measurement duration */ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4251 | if (((tempInt <= 0) && (pEseBcnReq->bcnReq[j].scanMode != eSIR_BEACON_TABLE)) || |
| 4252 | ((tempInt < 0) && (pEseBcnReq->bcnReq[j].scanMode == eSIR_BEACON_TABLE))) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4253 | { |
| 4254 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4255 | "Invalid Measurement Duration(%d)", tempInt); |
| 4256 | return -EINVAL; |
| 4257 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4258 | pEseBcnReq->bcnReq[j].measurementDuration = tempInt; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4259 | break; |
| 4260 | } |
| 4261 | } |
| 4262 | } |
| 4263 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4264 | for (j = 0; j < pEseBcnReq->numBcnReqIe; j++) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4265 | { |
| 4266 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Arun Kumar Khandavalli | e876821 | 2014-02-17 16:43:34 +0530 | [diff] [blame] | 4267 | "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] | 4268 | j, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4269 | pEseBcnReq->bcnReq[j].measurementToken, |
| 4270 | pEseBcnReq->bcnReq[j].channel, |
| 4271 | pEseBcnReq->bcnReq[j].scanMode, |
| 4272 | pEseBcnReq->bcnReq[j].measurementDuration); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4273 | } |
| 4274 | |
| 4275 | return VOS_STATUS_SUCCESS; |
| 4276 | } |
| 4277 | |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4278 | static void hdd_GetTsmStatsCB( tAniTrafStrmMetrics tsmMetrics, const tANI_U32 staId, void *pContext ) |
| 4279 | { |
| 4280 | struct statsContext *pStatsContext = NULL; |
| 4281 | hdd_adapter_t *pAdapter = NULL; |
| 4282 | |
| 4283 | if (NULL == pContext) |
| 4284 | { |
| 4285 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4286 | "%s: Bad param, pContext [%p]", |
| 4287 | __func__, pContext); |
| 4288 | return; |
| 4289 | } |
| 4290 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 4291 | /* there is a race condition that exists between this callback |
| 4292 | function and the caller since the caller could time out either |
| 4293 | before or while this code is executing. we use a spinlock to |
| 4294 | serialize these actions */ |
| 4295 | spin_lock(&hdd_context_lock); |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4296 | |
| 4297 | pStatsContext = pContext; |
| 4298 | pAdapter = pStatsContext->pAdapter; |
| 4299 | if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic)) |
| 4300 | { |
| 4301 | /* the caller presumably timed out so there is nothing we can do */ |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 4302 | spin_unlock(&hdd_context_lock); |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4303 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 4304 | "%s: Invalid context, pAdapter [%p] magic [%08x]", |
| 4305 | __func__, pAdapter, pStatsContext->magic); |
| 4306 | return; |
| 4307 | } |
| 4308 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 4309 | /* context is valid so caller is still waiting */ |
| 4310 | |
| 4311 | /* paranoia: invalidate the magic */ |
| 4312 | pStatsContext->magic = 0; |
| 4313 | |
| 4314 | /* copy over the tsm stats */ |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4315 | pAdapter->tsmStats.UplinkPktQueueDly = tsmMetrics.UplinkPktQueueDly; |
| 4316 | vos_mem_copy(pAdapter->tsmStats.UplinkPktQueueDlyHist, |
| 4317 | tsmMetrics.UplinkPktQueueDlyHist, |
| 4318 | sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist)/ |
| 4319 | sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist[0])); |
| 4320 | pAdapter->tsmStats.UplinkPktTxDly = tsmMetrics.UplinkPktTxDly; |
| 4321 | pAdapter->tsmStats.UplinkPktLoss = tsmMetrics.UplinkPktLoss; |
| 4322 | pAdapter->tsmStats.UplinkPktCount = tsmMetrics.UplinkPktCount; |
| 4323 | pAdapter->tsmStats.RoamingCount = tsmMetrics.RoamingCount; |
| 4324 | pAdapter->tsmStats.RoamingDly = tsmMetrics.RoamingDly; |
| 4325 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 4326 | /* notify the caller */ |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4327 | complete(&pStatsContext->completion); |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 4328 | |
| 4329 | /* serialization is complete */ |
| 4330 | spin_unlock(&hdd_context_lock); |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4331 | } |
| 4332 | |
| 4333 | |
| 4334 | |
| 4335 | static VOS_STATUS hdd_get_tsm_stats(hdd_adapter_t *pAdapter, const tANI_U8 tid, |
| 4336 | tAniTrafStrmMetrics* pTsmMetrics) |
| 4337 | { |
| 4338 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 4339 | eHalStatus hstatus; |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 4340 | VOS_STATUS vstatus = VOS_STATUS_SUCCESS; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4341 | long lrc; |
| 4342 | struct statsContext context; |
| 4343 | hdd_context_t *pHddCtx = NULL; |
| 4344 | |
| 4345 | if (NULL == pAdapter) |
| 4346 | { |
| 4347 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: pAdapter is NULL", __func__); |
| 4348 | return VOS_STATUS_E_FAULT; |
| 4349 | } |
| 4350 | |
| 4351 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 4352 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 4353 | |
| 4354 | /* we are connected prepare our callback context */ |
| 4355 | init_completion(&context.completion); |
| 4356 | context.pAdapter = pAdapter; |
| 4357 | context.magic = STATS_CONTEXT_MAGIC; |
| 4358 | |
| 4359 | /* query tsm stats */ |
| 4360 | hstatus = sme_GetTsmStats(pHddCtx->hHal, hdd_GetTsmStatsCB, |
| 4361 | pHddStaCtx->conn_info.staId[ 0 ], |
| 4362 | pHddStaCtx->conn_info.bssId, |
| 4363 | &context, pHddCtx->pvosContext, tid); |
| 4364 | |
| 4365 | if (eHAL_STATUS_SUCCESS != hstatus) |
| 4366 | { |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 4367 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unable to retrieve statistics", |
| 4368 | __func__); |
| 4369 | vstatus = VOS_STATUS_E_FAULT; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4370 | } |
| 4371 | else |
| 4372 | { |
| 4373 | /* request was sent -- wait for the response */ |
| 4374 | lrc = wait_for_completion_interruptible_timeout(&context.completion, |
| 4375 | msecs_to_jiffies(WLAN_WAIT_TIME_STATS)); |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4376 | if (lrc <= 0) |
| 4377 | { |
| 4378 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4379 | "%s: SME %s while retrieving statistics", |
| 4380 | __func__, (0 == lrc) ? "timeout" : "interrupt"); |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 4381 | vstatus = VOS_STATUS_E_TIMEOUT; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4382 | } |
| 4383 | } |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4384 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 4385 | /* either we never sent a request, we sent a request and received a |
| 4386 | response or we sent a request and timed out. if we never sent a |
| 4387 | request or if we sent a request and got a response, we want to |
| 4388 | clear the magic out of paranoia. if we timed out there is a |
| 4389 | race condition such that the callback function could be |
| 4390 | executing at the same time we are. of primary concern is if the |
| 4391 | callback function had already verified the "magic" but had not |
| 4392 | yet set the completion variable when a timeout occurred. we |
| 4393 | serialize these activities by invalidating the magic while |
| 4394 | holding a shared spinlock which will cause us to block if the |
| 4395 | callback is currently executing */ |
| 4396 | spin_lock(&hdd_context_lock); |
| 4397 | context.magic = 0; |
| 4398 | spin_unlock(&hdd_context_lock); |
| 4399 | |
| 4400 | if (VOS_STATUS_SUCCESS == vstatus) |
| 4401 | { |
| 4402 | pTsmMetrics->UplinkPktQueueDly = pAdapter->tsmStats.UplinkPktQueueDly; |
| 4403 | vos_mem_copy(pTsmMetrics->UplinkPktQueueDlyHist, |
| 4404 | pAdapter->tsmStats.UplinkPktQueueDlyHist, |
| 4405 | sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist)/ |
| 4406 | sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist[0])); |
| 4407 | pTsmMetrics->UplinkPktTxDly = pAdapter->tsmStats.UplinkPktTxDly; |
| 4408 | pTsmMetrics->UplinkPktLoss = pAdapter->tsmStats.UplinkPktLoss; |
| 4409 | pTsmMetrics->UplinkPktCount = pAdapter->tsmStats.UplinkPktCount; |
| 4410 | pTsmMetrics->RoamingCount = pAdapter->tsmStats.RoamingCount; |
| 4411 | pTsmMetrics->RoamingDly = pAdapter->tsmStats.RoamingDly; |
| 4412 | } |
| 4413 | return vstatus; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4414 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4415 | #endif /*FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */ |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4416 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4417 | #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] | 4418 | void hdd_getBand_helper(hdd_context_t *pHddCtx, int *pBand) |
| 4419 | { |
| 4420 | eCsrBand band = -1; |
| 4421 | sme_GetFreqBand((tHalHandle)(pHddCtx->hHal), &band); |
| 4422 | switch (band) |
| 4423 | { |
| 4424 | case eCSR_BAND_ALL: |
| 4425 | *pBand = WLAN_HDD_UI_BAND_AUTO; |
| 4426 | break; |
| 4427 | |
| 4428 | case eCSR_BAND_24: |
| 4429 | *pBand = WLAN_HDD_UI_BAND_2_4_GHZ; |
| 4430 | break; |
| 4431 | |
| 4432 | case eCSR_BAND_5G: |
| 4433 | *pBand = WLAN_HDD_UI_BAND_5_GHZ; |
| 4434 | break; |
| 4435 | |
| 4436 | default: |
| 4437 | hddLog( VOS_TRACE_LEVEL_WARN, "%s: Invalid Band %d", __func__, band); |
| 4438 | *pBand = -1; |
| 4439 | break; |
| 4440 | } |
| 4441 | } |
| 4442 | |
| 4443 | /**--------------------------------------------------------------------------- |
| 4444 | |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4445 | \brief hdd_parse_send_action_frame_data() - HDD Parse send action frame data |
| 4446 | |
| 4447 | This function parses the send action frame data passed in the format |
| 4448 | SENDACTIONFRAME<space><bssid><space><channel><space><dwelltime><space><data> |
| 4449 | |
Srinivas Girigowda | 5607685 | 2013-08-20 14:00:50 -0700 | [diff] [blame] | 4450 | \param - pValue Pointer to input data |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4451 | \param - pTargetApBssid Pointer to target Ap bssid |
| 4452 | \param - pChannel Pointer to the Target AP channel |
| 4453 | \param - pDwellTime Pointer to the time to stay off-channel after transmitting action frame |
| 4454 | \param - pBuf Pointer to data |
| 4455 | \param - pBufLen Pointer to data length |
| 4456 | |
| 4457 | \return - 0 for success non-zero for failure |
| 4458 | |
| 4459 | --------------------------------------------------------------------------*/ |
| 4460 | VOS_STATUS hdd_parse_send_action_frame_data(tANI_U8 *pValue, tANI_U8 *pTargetApBssid, tANI_U8 *pChannel, |
| 4461 | tANI_U8 *pDwellTime, tANI_U8 **pBuf, tANI_U8 *pBufLen) |
| 4462 | { |
| 4463 | tANI_U8 *inPtr = pValue; |
| 4464 | tANI_U8 *dataEnd; |
| 4465 | int tempInt; |
| 4466 | int j = 0; |
| 4467 | int i = 0; |
| 4468 | int v = 0; |
| 4469 | tANI_U8 tempBuf[32]; |
| 4470 | tANI_U8 tempByte = 0; |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 4471 | /* 12 hexa decimal digits, 5 ':' and '\0' */ |
| 4472 | tANI_U8 macAddress[18]; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4473 | |
| 4474 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 4475 | /*no argument after the command*/ |
| 4476 | if (NULL == inPtr) |
| 4477 | { |
| 4478 | return -EINVAL; |
| 4479 | } |
| 4480 | |
| 4481 | /*no space after the command*/ |
| 4482 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 4483 | { |
| 4484 | return -EINVAL; |
| 4485 | } |
| 4486 | |
| 4487 | /*removing empty spaces*/ |
| 4488 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 4489 | |
| 4490 | /*no argument followed by spaces*/ |
| 4491 | if ('\0' == *inPtr) |
| 4492 | { |
| 4493 | return -EINVAL; |
| 4494 | } |
| 4495 | |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4496 | v = sscanf(inPtr, "%17s", macAddress); |
| 4497 | if (!((1 == v) && hdd_is_valid_mac_address(macAddress))) |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4498 | { |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4499 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4500 | "Invalid MAC address or All hex inputs are not read (%d)", v); |
| 4501 | return -EINVAL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4502 | } |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4503 | |
| 4504 | pTargetApBssid[0] = hdd_parse_hex(macAddress[0]) << 4 | hdd_parse_hex(macAddress[1]); |
| 4505 | pTargetApBssid[1] = hdd_parse_hex(macAddress[3]) << 4 | hdd_parse_hex(macAddress[4]); |
| 4506 | pTargetApBssid[2] = hdd_parse_hex(macAddress[6]) << 4 | hdd_parse_hex(macAddress[7]); |
| 4507 | pTargetApBssid[3] = hdd_parse_hex(macAddress[9]) << 4 | hdd_parse_hex(macAddress[10]); |
| 4508 | pTargetApBssid[4] = hdd_parse_hex(macAddress[12]) << 4 | hdd_parse_hex(macAddress[13]); |
| 4509 | 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] | 4510 | |
| 4511 | /* point to the next argument */ |
| 4512 | inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE); |
| 4513 | /*no argument after the command*/ |
| 4514 | if (NULL == inPtr) return -EINVAL; |
| 4515 | |
| 4516 | /*removing empty spaces*/ |
| 4517 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 4518 | |
| 4519 | /*no argument followed by spaces*/ |
| 4520 | if ('\0' == *inPtr) |
| 4521 | { |
| 4522 | return -EINVAL; |
| 4523 | } |
| 4524 | |
| 4525 | /*getting the next argument ie the channel number */ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 4526 | v = sscanf(inPtr, "%31s ", tempBuf); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4527 | if (1 != v) return -EINVAL; |
| 4528 | |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4529 | v = kstrtos32(tempBuf, 10, &tempInt); |
Agarwal Ashish | 353b3a8 | 2014-04-08 14:55:11 +0530 | [diff] [blame] | 4530 | if ( v < 0 || tempInt <= 0 || tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX ) |
Kiet Lam | be150c2 | 2013-11-21 16:30:32 +0530 | [diff] [blame] | 4531 | return -EINVAL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4532 | |
| 4533 | *pChannel = tempInt; |
| 4534 | |
| 4535 | /* point to the next argument */ |
| 4536 | inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE); |
| 4537 | /*no argument after the command*/ |
| 4538 | if (NULL == inPtr) return -EINVAL; |
| 4539 | /*removing empty spaces*/ |
| 4540 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 4541 | |
| 4542 | /*no argument followed by spaces*/ |
| 4543 | if ('\0' == *inPtr) |
| 4544 | { |
| 4545 | return -EINVAL; |
| 4546 | } |
| 4547 | |
| 4548 | /*getting the next argument ie the dwell time */ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 4549 | v = sscanf(inPtr, "%31s ", tempBuf); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4550 | if (1 != v) return -EINVAL; |
| 4551 | |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4552 | v = kstrtos32(tempBuf, 10, &tempInt); |
Srinivas Girigowda | 5a6e067 | 2014-01-09 14:42:57 -0800 | [diff] [blame] | 4553 | if ( v < 0 || tempInt < 0) return -EINVAL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4554 | |
| 4555 | *pDwellTime = tempInt; |
| 4556 | |
| 4557 | /* point to the next argument */ |
| 4558 | inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE); |
| 4559 | /*no argument after the command*/ |
| 4560 | if (NULL == inPtr) return -EINVAL; |
| 4561 | /*removing empty spaces*/ |
| 4562 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 4563 | |
| 4564 | /*no argument followed by spaces*/ |
| 4565 | if ('\0' == *inPtr) |
| 4566 | { |
| 4567 | return -EINVAL; |
| 4568 | } |
| 4569 | |
| 4570 | /* find the length of data */ |
| 4571 | dataEnd = inPtr; |
| 4572 | while(('\0' != *dataEnd) ) |
| 4573 | { |
| 4574 | dataEnd++; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4575 | } |
Kiet Lam | be150c2 | 2013-11-21 16:30:32 +0530 | [diff] [blame] | 4576 | *pBufLen = dataEnd - inPtr ; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4577 | if ( *pBufLen <= 0) return -EINVAL; |
| 4578 | |
Srinivas Girigowda | b5ae85d | 2013-06-03 10:51:45 -0700 | [diff] [blame] | 4579 | /* Allocate the number of bytes based on the number of input characters |
| 4580 | whether it is even or odd. |
| 4581 | if the number of input characters are even, then we need N/2 byte. |
| 4582 | if the number of input characters are odd, then we need do (N+1)/2 to |
| 4583 | compensate rounding off. |
| 4584 | For example, if N = 18, then (18 + 1)/2 = 9 bytes are enough. |
| 4585 | If N = 19, then we need 10 bytes, hence (19 + 1)/2 = 10 bytes */ |
| 4586 | *pBuf = vos_mem_malloc((*pBufLen + 1)/2); |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4587 | if (NULL == *pBuf) |
| 4588 | { |
| 4589 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 4590 | "%s: vos_mem_alloc failed ", __func__); |
| 4591 | return -EINVAL; |
| 4592 | } |
| 4593 | |
| 4594 | /* the buffer received from the upper layer is character buffer, |
| 4595 | we need to prepare the buffer taking 2 characters in to a U8 hex decimal number |
| 4596 | for example 7f0000f0...form a buffer to contain 7f in 0th location, 00 in 1st |
| 4597 | and f0 in 3rd location */ |
| 4598 | for (i = 0, j = 0; j < *pBufLen; j += 2) |
| 4599 | { |
Kiet Lam | be150c2 | 2013-11-21 16:30:32 +0530 | [diff] [blame] | 4600 | if( j+1 == *pBufLen) |
| 4601 | { |
| 4602 | tempByte = hdd_parse_hex(inPtr[j]); |
| 4603 | } |
| 4604 | else |
| 4605 | { |
| 4606 | tempByte = (hdd_parse_hex(inPtr[j]) << 4) | (hdd_parse_hex(inPtr[j + 1])); |
| 4607 | } |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4608 | (*pBuf)[i++] = tempByte; |
| 4609 | } |
| 4610 | *pBufLen = i; |
| 4611 | return VOS_STATUS_SUCCESS; |
| 4612 | } |
| 4613 | |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4614 | /**--------------------------------------------------------------------------- |
| 4615 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4616 | \brief hdd_parse_channellist() - HDD Parse channel list |
| 4617 | |
| 4618 | This function parses the channel list passed in the format |
| 4619 | 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] | 4620 | if the Number of channels (N) does not match with the actual number of channels passed |
| 4621 | then take the minimum of N and count of (Ch1, Ch2, ...Ch M) |
| 4622 | For example, if SETROAMSCANCHANNELS 3 36 40 44 48, only 36, 40 and 44 shall be taken. |
| 4623 | If SETROAMSCANCHANNELS 5 36 40 44 48, ignore 5 and take 36, 40, 44 and 48. |
| 4624 | 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] | 4625 | |
| 4626 | \param - pValue Pointer to input channel list |
| 4627 | \param - ChannelList Pointer to local output array to record channel list |
| 4628 | \param - pNumChannels Pointer to number of roam scan channels |
| 4629 | |
| 4630 | \return - 0 for success non-zero for failure |
| 4631 | |
| 4632 | --------------------------------------------------------------------------*/ |
| 4633 | VOS_STATUS hdd_parse_channellist(tANI_U8 *pValue, tANI_U8 *pChannelList, tANI_U8 *pNumChannels) |
| 4634 | { |
| 4635 | tANI_U8 *inPtr = pValue; |
| 4636 | int tempInt; |
| 4637 | int j = 0; |
| 4638 | int v = 0; |
| 4639 | char buf[32]; |
| 4640 | |
| 4641 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 4642 | /*no argument after the command*/ |
| 4643 | if (NULL == inPtr) |
| 4644 | { |
| 4645 | return -EINVAL; |
| 4646 | } |
| 4647 | |
| 4648 | /*no space after the command*/ |
| 4649 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 4650 | { |
| 4651 | return -EINVAL; |
| 4652 | } |
| 4653 | |
| 4654 | /*removing empty spaces*/ |
Jeff Johnson | a1f9afb | 2013-04-03 09:13:31 -0700 | [diff] [blame] | 4655 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4656 | |
| 4657 | /*no argument followed by spaces*/ |
| 4658 | if ('\0' == *inPtr) |
| 4659 | { |
| 4660 | return -EINVAL; |
| 4661 | } |
| 4662 | |
| 4663 | /*getting the first argument ie the number of channels*/ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 4664 | v = sscanf(inPtr, "%31s ", buf); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4665 | if (1 != v) return -EINVAL; |
| 4666 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4667 | v = kstrtos32(buf, 10, &tempInt); |
Jeff Johnson | a1f9afb | 2013-04-03 09:13:31 -0700 | [diff] [blame] | 4668 | if ((v < 0) || |
| 4669 | (tempInt <= 0) || |
| 4670 | (tempInt > WNI_CFG_VALID_CHANNEL_LIST_LEN)) |
| 4671 | { |
| 4672 | return -EINVAL; |
| 4673 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4674 | |
| 4675 | *pNumChannels = tempInt; |
| 4676 | |
| 4677 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
| 4678 | "Number of channels are: %d", *pNumChannels); |
| 4679 | |
| 4680 | for (j = 0; j < (*pNumChannels); j++) |
| 4681 | { |
| 4682 | /*inPtr pointing to the beginning of first space after number of channels*/ |
| 4683 | inPtr = strpbrk( inPtr, " " ); |
| 4684 | /*no channel list after the number of channels argument*/ |
| 4685 | if (NULL == inPtr) |
| 4686 | { |
Srinivas Girigowda | cf9a9b4 | 2013-03-21 11:55:24 -0700 | [diff] [blame] | 4687 | if (0 != j) |
| 4688 | { |
| 4689 | *pNumChannels = j; |
| 4690 | return VOS_STATUS_SUCCESS; |
| 4691 | } |
| 4692 | else |
| 4693 | { |
| 4694 | return -EINVAL; |
| 4695 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4696 | } |
| 4697 | |
| 4698 | /*removing empty space*/ |
Jeff Johnson | a1f9afb | 2013-04-03 09:13:31 -0700 | [diff] [blame] | 4699 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4700 | |
| 4701 | /*no channel list after the number of channels argument and spaces*/ |
| 4702 | if ( '\0' == *inPtr ) |
| 4703 | { |
Srinivas Girigowda | cf9a9b4 | 2013-03-21 11:55:24 -0700 | [diff] [blame] | 4704 | if (0 != j) |
| 4705 | { |
| 4706 | *pNumChannels = j; |
| 4707 | return VOS_STATUS_SUCCESS; |
| 4708 | } |
| 4709 | else |
| 4710 | { |
| 4711 | return -EINVAL; |
| 4712 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4713 | } |
| 4714 | |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 4715 | v = sscanf(inPtr, "%31s ", buf); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4716 | if (1 != v) return -EINVAL; |
| 4717 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4718 | v = kstrtos32(buf, 10, &tempInt); |
Jeff Johnson | a1f9afb | 2013-04-03 09:13:31 -0700 | [diff] [blame] | 4719 | if ((v < 0) || |
| 4720 | (tempInt <= 0) || |
| 4721 | (tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX)) |
| 4722 | { |
| 4723 | return -EINVAL; |
| 4724 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4725 | pChannelList[j] = tempInt; |
| 4726 | |
| 4727 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
| 4728 | "Channel %d added to preferred channel list", |
| 4729 | pChannelList[j] ); |
| 4730 | } |
| 4731 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4732 | return VOS_STATUS_SUCCESS; |
| 4733 | } |
| 4734 | |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 4735 | |
| 4736 | /**--------------------------------------------------------------------------- |
| 4737 | |
| 4738 | \brief hdd_parse_reassoc_command_data() - HDD Parse reassoc command data |
| 4739 | |
| 4740 | This function parses the reasoc command data passed in the format |
| 4741 | REASSOC<space><bssid><space><channel> |
| 4742 | |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4743 | \param - pValue Pointer to input data (its a NUL terminated string) |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 4744 | \param - pTargetApBssid Pointer to target Ap bssid |
| 4745 | \param - pChannel Pointer to the Target AP channel |
| 4746 | |
| 4747 | \return - 0 for success non-zero for failure |
| 4748 | |
| 4749 | --------------------------------------------------------------------------*/ |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4750 | VOS_STATUS hdd_parse_reassoc_command_data(tANI_U8 *pValue, |
| 4751 | tANI_U8 *pTargetApBssid, tANI_U8 *pChannel) |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 4752 | { |
| 4753 | tANI_U8 *inPtr = pValue; |
| 4754 | int tempInt; |
| 4755 | int v = 0; |
| 4756 | tANI_U8 tempBuf[32]; |
Kiet Lam | aa8e15a | 2014-02-11 23:30:06 -0800 | [diff] [blame] | 4757 | /* 12 hexa decimal digits, 5 ':' and '\0' */ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 4758 | tANI_U8 macAddress[18]; |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 4759 | |
| 4760 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 4761 | /*no argument after the command*/ |
| 4762 | if (NULL == inPtr) |
| 4763 | { |
| 4764 | return -EINVAL; |
| 4765 | } |
| 4766 | |
| 4767 | /*no space after the command*/ |
| 4768 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 4769 | { |
| 4770 | return -EINVAL; |
| 4771 | } |
| 4772 | |
| 4773 | /*removing empty spaces*/ |
| 4774 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 4775 | |
| 4776 | /*no argument followed by spaces*/ |
| 4777 | if ('\0' == *inPtr) |
| 4778 | { |
| 4779 | return -EINVAL; |
| 4780 | } |
| 4781 | |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4782 | v = sscanf(inPtr, "%17s", macAddress); |
| 4783 | if (!((1 == v) && hdd_is_valid_mac_address(macAddress))) |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 4784 | { |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4785 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4786 | "Invalid MAC address or All hex inputs are not read (%d)", v); |
| 4787 | return -EINVAL; |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 4788 | } |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4789 | |
| 4790 | pTargetApBssid[0] = hdd_parse_hex(macAddress[0]) << 4 | hdd_parse_hex(macAddress[1]); |
| 4791 | pTargetApBssid[1] = hdd_parse_hex(macAddress[3]) << 4 | hdd_parse_hex(macAddress[4]); |
| 4792 | pTargetApBssid[2] = hdd_parse_hex(macAddress[6]) << 4 | hdd_parse_hex(macAddress[7]); |
| 4793 | pTargetApBssid[3] = hdd_parse_hex(macAddress[9]) << 4 | hdd_parse_hex(macAddress[10]); |
| 4794 | pTargetApBssid[4] = hdd_parse_hex(macAddress[12]) << 4 | hdd_parse_hex(macAddress[13]); |
| 4795 | 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] | 4796 | |
| 4797 | /* point to the next argument */ |
| 4798 | inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE); |
| 4799 | /*no argument after the command*/ |
| 4800 | if (NULL == inPtr) return -EINVAL; |
| 4801 | |
| 4802 | /*removing empty spaces*/ |
| 4803 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 4804 | |
| 4805 | /*no argument followed by spaces*/ |
| 4806 | if ('\0' == *inPtr) |
| 4807 | { |
| 4808 | return -EINVAL; |
| 4809 | } |
| 4810 | |
| 4811 | /*getting the next argument ie the channel number */ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 4812 | v = sscanf(inPtr, "%31s ", tempBuf); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4813 | if (1 != v) return -EINVAL; |
| 4814 | |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 4815 | v = kstrtos32(tempBuf, 10, &tempInt); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4816 | if ((v < 0) || |
| 4817 | (tempInt <= 0) || |
| 4818 | (tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX)) |
| 4819 | { |
| 4820 | return -EINVAL; |
| 4821 | } |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 4822 | |
| 4823 | *pChannel = tempInt; |
| 4824 | return VOS_STATUS_SUCCESS; |
| 4825 | } |
| 4826 | |
| 4827 | #endif |
| 4828 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4829 | #if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD) |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4830 | /**--------------------------------------------------------------------------- |
| 4831 | |
| 4832 | \brief hdd_parse_get_cckm_ie() - HDD Parse and fetch the CCKM IE |
| 4833 | |
| 4834 | This function parses the SETCCKM IE command |
| 4835 | SETCCKMIE<space><ie data> |
| 4836 | |
| 4837 | \param - pValue Pointer to input data |
| 4838 | \param - pCckmIe Pointer to output cckm Ie |
| 4839 | \param - pCckmIeLen Pointer to output cckm ie length |
| 4840 | |
| 4841 | \return - 0 for success non-zero for failure |
| 4842 | |
| 4843 | --------------------------------------------------------------------------*/ |
| 4844 | VOS_STATUS hdd_parse_get_cckm_ie(tANI_U8 *pValue, tANI_U8 **pCckmIe, |
| 4845 | tANI_U8 *pCckmIeLen) |
| 4846 | { |
| 4847 | tANI_U8 *inPtr = pValue; |
| 4848 | tANI_U8 *dataEnd; |
| 4849 | int j = 0; |
| 4850 | int i = 0; |
| 4851 | tANI_U8 tempByte = 0; |
| 4852 | |
| 4853 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 4854 | /*no argument after the command*/ |
| 4855 | if (NULL == inPtr) |
| 4856 | { |
| 4857 | return -EINVAL; |
| 4858 | } |
| 4859 | |
| 4860 | /*no space after the command*/ |
| 4861 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 4862 | { |
| 4863 | return -EINVAL; |
| 4864 | } |
| 4865 | |
| 4866 | /*removing empty spaces*/ |
| 4867 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 4868 | |
| 4869 | /*no argument followed by spaces*/ |
| 4870 | if ('\0' == *inPtr) |
| 4871 | { |
| 4872 | return -EINVAL; |
| 4873 | } |
| 4874 | |
| 4875 | /* find the length of data */ |
| 4876 | dataEnd = inPtr; |
| 4877 | while(('\0' != *dataEnd) ) |
| 4878 | { |
| 4879 | dataEnd++; |
| 4880 | ++(*pCckmIeLen); |
| 4881 | } |
| 4882 | if ( *pCckmIeLen <= 0) return -EINVAL; |
| 4883 | |
| 4884 | /* Allocate the number of bytes based on the number of input characters |
| 4885 | whether it is even or odd. |
| 4886 | if the number of input characters are even, then we need N/2 byte. |
| 4887 | if the number of input characters are odd, then we need do (N+1)/2 to |
| 4888 | compensate rounding off. |
| 4889 | For example, if N = 18, then (18 + 1)/2 = 9 bytes are enough. |
| 4890 | If N = 19, then we need 10 bytes, hence (19 + 1)/2 = 10 bytes */ |
| 4891 | *pCckmIe = vos_mem_malloc((*pCckmIeLen + 1)/2); |
| 4892 | if (NULL == *pCckmIe) |
| 4893 | { |
| 4894 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 4895 | "%s: vos_mem_alloc failed ", __func__); |
| 4896 | return -EINVAL; |
| 4897 | } |
| 4898 | vos_mem_zero(*pCckmIe, (*pCckmIeLen + 1)/2); |
| 4899 | /* the buffer received from the upper layer is character buffer, |
| 4900 | we need to prepare the buffer taking 2 characters in to a U8 hex decimal number |
| 4901 | for example 7f0000f0...form a buffer to contain 7f in 0th location, 00 in 1st |
| 4902 | and f0 in 3rd location */ |
| 4903 | for (i = 0, j = 0; j < *pCckmIeLen; j += 2) |
| 4904 | { |
| 4905 | tempByte = (hdd_parse_hex(inPtr[j]) << 4) | (hdd_parse_hex(inPtr[j + 1])); |
| 4906 | (*pCckmIe)[i++] = tempByte; |
| 4907 | } |
| 4908 | *pCckmIeLen = i; |
| 4909 | |
| 4910 | return VOS_STATUS_SUCCESS; |
| 4911 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4912 | #endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */ |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4913 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4914 | /**--------------------------------------------------------------------------- |
| 4915 | |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4916 | \brief hdd_is_valid_mac_address() - Validate MAC address |
| 4917 | |
| 4918 | This function validates whether the given MAC address is valid or not |
| 4919 | Expected MAC address is of the format XX:XX:XX:XX:XX:XX |
| 4920 | where X is the hexa decimal digit character and separated by ':' |
| 4921 | This algorithm works even if MAC address is not separated by ':' |
| 4922 | |
| 4923 | This code checks given input string mac contains exactly 12 hexadecimal digits. |
| 4924 | and a separator colon : appears in the input string only after |
| 4925 | an even number of hex digits. |
| 4926 | |
| 4927 | \param - pMacAddr pointer to the input MAC address |
| 4928 | \return - 1 for valid and 0 for invalid |
| 4929 | |
| 4930 | --------------------------------------------------------------------------*/ |
| 4931 | |
| 4932 | v_BOOL_t hdd_is_valid_mac_address(const tANI_U8 *pMacAddr) |
| 4933 | { |
| 4934 | int xdigit = 0; |
| 4935 | int separator = 0; |
| 4936 | while (*pMacAddr) |
| 4937 | { |
| 4938 | if (isxdigit(*pMacAddr)) |
| 4939 | { |
| 4940 | xdigit++; |
| 4941 | } |
| 4942 | else if (':' == *pMacAddr) |
| 4943 | { |
| 4944 | if (0 == xdigit || ((xdigit / 2) - 1) != separator) |
| 4945 | break; |
| 4946 | |
| 4947 | ++separator; |
| 4948 | } |
| 4949 | else |
| 4950 | { |
| 4951 | separator = -1; |
| 4952 | /* Invalid MAC found */ |
| 4953 | return 0; |
| 4954 | } |
| 4955 | ++pMacAddr; |
| 4956 | } |
| 4957 | return (xdigit == 12 && (separator == 5 || separator == 0)); |
| 4958 | } |
| 4959 | |
| 4960 | /**--------------------------------------------------------------------------- |
| 4961 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4962 | \brief hdd_open() - HDD Open function |
| 4963 | |
| 4964 | This is called in response to ifconfig up |
| 4965 | |
| 4966 | \param - dev Pointer to net_device structure |
| 4967 | |
| 4968 | \return - 0 for success non-zero for failure |
| 4969 | |
| 4970 | --------------------------------------------------------------------------*/ |
| 4971 | int hdd_open (struct net_device *dev) |
| 4972 | { |
| 4973 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 4974 | hdd_context_t *pHddCtx; |
| 4975 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 4976 | VOS_STATUS status; |
| 4977 | v_BOOL_t in_standby = TRUE; |
| 4978 | |
| 4979 | if (NULL == pAdapter) |
| 4980 | { |
| 4981 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Agarwal Ashish | 971c288 | 2013-10-30 20:11:12 +0530 | [diff] [blame] | 4982 | "%s: pAdapter is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4983 | return -ENODEV; |
| 4984 | } |
| 4985 | |
| 4986 | pHddCtx = (hdd_context_t*)pAdapter->pHddCtx; |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 4987 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_OPEN_REQUEST, |
| 4988 | pAdapter->sessionId, pAdapter->device_mode)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4989 | if (NULL == pHddCtx) |
| 4990 | { |
| 4991 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 4992 | "%s: HDD context is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4993 | return -ENODEV; |
| 4994 | } |
| 4995 | |
| 4996 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 4997 | while ( (NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status) ) |
| 4998 | { |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 4999 | if (test_bit(DEVICE_IFACE_OPENED, &pAdapterNode->pAdapter->event_flags)) |
| 5000 | { |
| 5001 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: chip already out of standby", |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 5002 | __func__); |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 5003 | in_standby = FALSE; |
| 5004 | break; |
| 5005 | } |
| 5006 | else |
| 5007 | { |
| 5008 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 5009 | pAdapterNode = pNext; |
| 5010 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5011 | } |
| 5012 | |
| 5013 | if (TRUE == in_standby) |
| 5014 | { |
| 5015 | if (VOS_STATUS_SUCCESS != wlan_hdd_exit_lowpower(pHddCtx, pAdapter)) |
| 5016 | { |
| 5017 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failed to bring " |
| 5018 | "wlan out of power save", __func__); |
| 5019 | return -EINVAL; |
| 5020 | } |
| 5021 | } |
| 5022 | |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 5023 | set_bit(DEVICE_IFACE_OPENED, &pAdapter->event_flags); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5024 | if (hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) |
| 5025 | { |
| 5026 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 5027 | "%s: Enabling Tx Queues", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5028 | /* Enable TX queues only when we are connected */ |
| 5029 | netif_tx_start_all_queues(dev); |
| 5030 | } |
| 5031 | |
| 5032 | return 0; |
| 5033 | } |
| 5034 | |
| 5035 | int hdd_mon_open (struct net_device *dev) |
| 5036 | { |
| 5037 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5038 | |
| 5039 | if(pAdapter == NULL) { |
| 5040 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 5041 | "%s: HDD adapter context is Null", __func__); |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 5042 | return -EINVAL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5043 | } |
| 5044 | |
| 5045 | netif_start_queue(dev); |
| 5046 | |
| 5047 | return 0; |
| 5048 | } |
| 5049 | /**--------------------------------------------------------------------------- |
| 5050 | |
| 5051 | \brief hdd_stop() - HDD stop function |
| 5052 | |
| 5053 | This is called in response to ifconfig down |
| 5054 | |
| 5055 | \param - dev Pointer to net_device structure |
| 5056 | |
| 5057 | \return - 0 for success non-zero for failure |
| 5058 | |
| 5059 | --------------------------------------------------------------------------*/ |
| 5060 | |
| 5061 | int hdd_stop (struct net_device *dev) |
| 5062 | { |
| 5063 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5064 | hdd_context_t *pHddCtx; |
| 5065 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 5066 | VOS_STATUS status; |
| 5067 | v_BOOL_t enter_standby = TRUE; |
| 5068 | |
| 5069 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5070 | if (NULL == pAdapter) |
| 5071 | { |
| 5072 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Agarwal Ashish | 971c288 | 2013-10-30 20:11:12 +0530 | [diff] [blame] | 5073 | "%s: pAdapter is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5074 | return -ENODEV; |
| 5075 | } |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 5076 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_OPEN_REQUEST, |
| 5077 | pAdapter->sessionId, pAdapter->device_mode)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5078 | pHddCtx = (hdd_context_t*)pAdapter->pHddCtx; |
| 5079 | if (NULL == pHddCtx) |
| 5080 | { |
| 5081 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 5082 | "%s: HDD context is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5083 | return -ENODEV; |
| 5084 | } |
| 5085 | |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 5086 | clear_bit(DEVICE_IFACE_OPENED, &pAdapter->event_flags); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5087 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disabling OS Tx queues", __func__); |
| 5088 | netif_tx_disable(pAdapter->dev); |
| 5089 | netif_carrier_off(pAdapter->dev); |
| 5090 | |
| 5091 | |
| 5092 | /* SoftAP ifaces should never go in power save mode |
| 5093 | making sure same here. */ |
| 5094 | if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode ) |
| 5095 | || (WLAN_HDD_MONITOR == pAdapter->device_mode ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5096 | || (WLAN_HDD_P2P_GO == pAdapter->device_mode ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5097 | ) |
| 5098 | { |
| 5099 | /* SoftAP mode, so return from here */ |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 5100 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5101 | "%s: In SAP MODE", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5102 | EXIT(); |
| 5103 | return 0; |
| 5104 | } |
| 5105 | |
| 5106 | /* Find if any iface is up then |
| 5107 | if any iface is up then can't put device to sleep/ power save mode. */ |
| 5108 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 5109 | while ( (NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status) ) |
| 5110 | { |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 5111 | if (test_bit(DEVICE_IFACE_OPENED, &pAdapterNode->pAdapter->event_flags)) |
| 5112 | { |
| 5113 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Still other ifaces are up cannot " |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 5114 | "put device to sleep", __func__); |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 5115 | enter_standby = FALSE; |
| 5116 | break; |
| 5117 | } |
| 5118 | else |
| 5119 | { |
| 5120 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 5121 | pAdapterNode = pNext; |
| 5122 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5123 | } |
| 5124 | |
| 5125 | if (TRUE == enter_standby) |
| 5126 | { |
| 5127 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: All Interfaces are Down " |
| 5128 | "entering standby", __func__); |
| 5129 | if (VOS_STATUS_SUCCESS != wlan_hdd_enter_lowpower(pHddCtx)) |
| 5130 | { |
| 5131 | /*log and return success*/ |
| 5132 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failed to put " |
| 5133 | "wlan in power save", __func__); |
| 5134 | } |
| 5135 | } |
| 5136 | |
| 5137 | EXIT(); |
| 5138 | return 0; |
| 5139 | } |
| 5140 | |
| 5141 | /**--------------------------------------------------------------------------- |
| 5142 | |
| 5143 | \brief hdd_uninit() - HDD uninit function |
| 5144 | |
| 5145 | This is called during the netdev unregister to uninitialize all data |
| 5146 | associated with the device |
| 5147 | |
| 5148 | \param - dev Pointer to net_device structure |
| 5149 | |
| 5150 | \return - void |
| 5151 | |
| 5152 | --------------------------------------------------------------------------*/ |
| 5153 | static void hdd_uninit (struct net_device *dev) |
| 5154 | { |
| 5155 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5156 | |
| 5157 | ENTER(); |
| 5158 | |
| 5159 | do |
| 5160 | { |
| 5161 | if (NULL == pAdapter) |
| 5162 | { |
| 5163 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 5164 | "%s: NULL pAdapter", __func__); |
| 5165 | break; |
| 5166 | } |
| 5167 | |
| 5168 | if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) |
| 5169 | { |
| 5170 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 5171 | "%s: Invalid magic", __func__); |
| 5172 | break; |
| 5173 | } |
| 5174 | |
| 5175 | if (NULL == pAdapter->pHddCtx) |
| 5176 | { |
| 5177 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 5178 | "%s: NULL pHddCtx", __func__); |
| 5179 | break; |
| 5180 | } |
| 5181 | |
| 5182 | if (dev != pAdapter->dev) |
| 5183 | { |
| 5184 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 5185 | "%s: Invalid device reference", __func__); |
| 5186 | /* we haven't validated all cases so let this go for now */ |
| 5187 | } |
| 5188 | |
| 5189 | hdd_deinit_adapter(pAdapter->pHddCtx, pAdapter); |
| 5190 | |
| 5191 | /* after uninit our adapter structure will no longer be valid */ |
| 5192 | pAdapter->dev = NULL; |
| 5193 | pAdapter->magic = 0; |
| 5194 | } while (0); |
| 5195 | |
| 5196 | EXIT(); |
| 5197 | } |
| 5198 | |
| 5199 | /**--------------------------------------------------------------------------- |
| 5200 | |
| 5201 | \brief hdd_release_firmware() - |
| 5202 | |
| 5203 | This function calls the release firmware API to free the firmware buffer. |
| 5204 | |
| 5205 | \param - pFileName Pointer to the File Name. |
| 5206 | pCtx - Pointer to the adapter . |
| 5207 | |
| 5208 | |
| 5209 | \return - 0 for success, non zero for failure |
| 5210 | |
| 5211 | --------------------------------------------------------------------------*/ |
| 5212 | |
| 5213 | VOS_STATUS hdd_release_firmware(char *pFileName,v_VOID_t *pCtx) |
| 5214 | { |
| 5215 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 5216 | hdd_context_t *pHddCtx = (hdd_context_t*)pCtx; |
| 5217 | ENTER(); |
| 5218 | |
| 5219 | |
| 5220 | if (!strcmp(WLAN_FW_FILE, pFileName)) { |
| 5221 | |
| 5222 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"%s: Loaded firmware file is %s",__func__,pFileName); |
| 5223 | |
| 5224 | if(pHddCtx->fw) { |
| 5225 | release_firmware(pHddCtx->fw); |
| 5226 | pHddCtx->fw = NULL; |
| 5227 | } |
| 5228 | else |
| 5229 | status = VOS_STATUS_E_FAILURE; |
| 5230 | } |
| 5231 | else if (!strcmp(WLAN_NV_FILE,pFileName)) { |
| 5232 | if(pHddCtx->nv) { |
| 5233 | release_firmware(pHddCtx->nv); |
| 5234 | pHddCtx->nv = NULL; |
| 5235 | } |
| 5236 | else |
| 5237 | status = VOS_STATUS_E_FAILURE; |
| 5238 | |
| 5239 | } |
| 5240 | |
| 5241 | EXIT(); |
| 5242 | return status; |
| 5243 | } |
| 5244 | |
| 5245 | /**--------------------------------------------------------------------------- |
| 5246 | |
| 5247 | \brief hdd_request_firmware() - |
| 5248 | |
| 5249 | This function reads the firmware file using the request firmware |
| 5250 | API and returns the the firmware data and the firmware file size. |
| 5251 | |
| 5252 | \param - pfileName - Pointer to the file name. |
| 5253 | - pCtx - Pointer to the adapter . |
| 5254 | - ppfw_data - Pointer to the pointer of the firmware data. |
| 5255 | - pSize - Pointer to the file size. |
| 5256 | |
| 5257 | \return - VOS_STATUS_SUCCESS for success, VOS_STATUS_E_FAILURE for failure |
| 5258 | |
| 5259 | --------------------------------------------------------------------------*/ |
| 5260 | |
| 5261 | |
| 5262 | VOS_STATUS hdd_request_firmware(char *pfileName,v_VOID_t *pCtx,v_VOID_t **ppfw_data, v_SIZE_t *pSize) |
| 5263 | { |
| 5264 | int status; |
| 5265 | VOS_STATUS retval = VOS_STATUS_SUCCESS; |
| 5266 | hdd_context_t *pHddCtx = (hdd_context_t*)pCtx; |
| 5267 | ENTER(); |
| 5268 | |
| 5269 | if( (!strcmp(WLAN_FW_FILE, pfileName)) ) { |
| 5270 | |
| 5271 | status = request_firmware(&pHddCtx->fw, pfileName, pHddCtx->parent_dev); |
| 5272 | |
| 5273 | if(status || !pHddCtx->fw || !pHddCtx->fw->data) { |
| 5274 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Firmware %s download failed", |
| 5275 | __func__, pfileName); |
| 5276 | retval = VOS_STATUS_E_FAILURE; |
| 5277 | } |
| 5278 | |
| 5279 | else { |
| 5280 | *ppfw_data = (v_VOID_t *)pHddCtx->fw->data; |
| 5281 | *pSize = pHddCtx->fw->size; |
| 5282 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Firmware size = %d", |
| 5283 | __func__, *pSize); |
| 5284 | } |
| 5285 | } |
| 5286 | else if(!strcmp(WLAN_NV_FILE, pfileName)) { |
| 5287 | |
| 5288 | status = request_firmware(&pHddCtx->nv, pfileName, pHddCtx->parent_dev); |
| 5289 | |
| 5290 | if(status || !pHddCtx->nv || !pHddCtx->nv->data) { |
| 5291 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: nv %s download failed", |
| 5292 | __func__, pfileName); |
| 5293 | retval = VOS_STATUS_E_FAILURE; |
| 5294 | } |
| 5295 | |
| 5296 | else { |
| 5297 | *ppfw_data = (v_VOID_t *)pHddCtx->nv->data; |
| 5298 | *pSize = pHddCtx->nv->size; |
| 5299 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: nv file size = %d", |
| 5300 | __func__, *pSize); |
| 5301 | } |
| 5302 | } |
| 5303 | |
| 5304 | EXIT(); |
| 5305 | return retval; |
| 5306 | } |
| 5307 | /**--------------------------------------------------------------------------- |
| 5308 | \brief hdd_full_pwr_cbk() - HDD full power callbackfunction |
| 5309 | |
| 5310 | This is the function invoked by SME to inform the result of a full power |
| 5311 | request issued by HDD |
| 5312 | |
| 5313 | \param - callbackcontext - Pointer to cookie |
| 5314 | status - result of request |
| 5315 | |
| 5316 | \return - None |
| 5317 | |
| 5318 | --------------------------------------------------------------------------*/ |
| 5319 | void hdd_full_pwr_cbk(void *callbackContext, eHalStatus status) |
| 5320 | { |
| 5321 | hdd_context_t *pHddCtx = (hdd_context_t*)callbackContext; |
| 5322 | |
Madan Mohan Koyyalamudi | 8bdd311 | 2012-09-24 13:55:14 -0700 | [diff] [blame] | 5323 | 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] | 5324 | if(&pHddCtx->full_pwr_comp_var) |
| 5325 | { |
| 5326 | complete(&pHddCtx->full_pwr_comp_var); |
| 5327 | } |
| 5328 | } |
| 5329 | |
| 5330 | /**--------------------------------------------------------------------------- |
| 5331 | |
| 5332 | \brief hdd_req_bmps_cbk() - HDD Request BMPS callback function |
| 5333 | |
| 5334 | This is the function invoked by SME to inform the result of BMPS |
| 5335 | request issued by HDD |
| 5336 | |
| 5337 | \param - callbackcontext - Pointer to cookie |
| 5338 | status - result of request |
| 5339 | |
| 5340 | \return - None |
| 5341 | |
| 5342 | --------------------------------------------------------------------------*/ |
| 5343 | void hdd_req_bmps_cbk(void *callbackContext, eHalStatus status) |
| 5344 | { |
| 5345 | |
| 5346 | struct completion *completion_var = (struct completion*) callbackContext; |
| 5347 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 5348 | hddLog(VOS_TRACE_LEVEL_ERROR, "HDD BMPS request Callback, status = %d", status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5349 | if(completion_var != NULL) |
| 5350 | { |
| 5351 | complete(completion_var); |
| 5352 | } |
| 5353 | } |
| 5354 | |
| 5355 | /**--------------------------------------------------------------------------- |
| 5356 | |
| 5357 | \brief hdd_get_cfg_file_size() - |
| 5358 | |
| 5359 | This function reads the configuration file using the request firmware |
| 5360 | API and returns the configuration file size. |
| 5361 | |
| 5362 | \param - pCtx - Pointer to the adapter . |
| 5363 | - pFileName - Pointer to the file name. |
| 5364 | - pBufSize - Pointer to the buffer size. |
| 5365 | |
| 5366 | \return - 0 for success, non zero for failure |
| 5367 | |
| 5368 | --------------------------------------------------------------------------*/ |
| 5369 | |
| 5370 | VOS_STATUS hdd_get_cfg_file_size(v_VOID_t *pCtx, char *pFileName, v_SIZE_t *pBufSize) |
| 5371 | { |
| 5372 | int status; |
| 5373 | hdd_context_t *pHddCtx = (hdd_context_t*)pCtx; |
| 5374 | |
| 5375 | ENTER(); |
| 5376 | |
| 5377 | status = request_firmware(&pHddCtx->fw, pFileName, pHddCtx->parent_dev); |
| 5378 | |
| 5379 | if(status || !pHddCtx->fw || !pHddCtx->fw->data) { |
| 5380 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: CFG download failed",__func__); |
| 5381 | status = VOS_STATUS_E_FAILURE; |
| 5382 | } |
| 5383 | else { |
| 5384 | *pBufSize = pHddCtx->fw->size; |
| 5385 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: CFG size = %d", __func__, *pBufSize); |
| 5386 | release_firmware(pHddCtx->fw); |
| 5387 | pHddCtx->fw = NULL; |
| 5388 | } |
| 5389 | |
| 5390 | EXIT(); |
| 5391 | return VOS_STATUS_SUCCESS; |
| 5392 | } |
| 5393 | |
| 5394 | /**--------------------------------------------------------------------------- |
| 5395 | |
| 5396 | \brief hdd_read_cfg_file() - |
| 5397 | |
| 5398 | This function reads the configuration file using the request firmware |
| 5399 | API and returns the cfg data and the buffer size of the configuration file. |
| 5400 | |
| 5401 | \param - pCtx - Pointer to the adapter . |
| 5402 | - pFileName - Pointer to the file name. |
| 5403 | - pBuffer - Pointer to the data buffer. |
| 5404 | - pBufSize - Pointer to the buffer size. |
| 5405 | |
| 5406 | \return - 0 for success, non zero for failure |
| 5407 | |
| 5408 | --------------------------------------------------------------------------*/ |
| 5409 | |
| 5410 | VOS_STATUS hdd_read_cfg_file(v_VOID_t *pCtx, char *pFileName, |
| 5411 | v_VOID_t *pBuffer, v_SIZE_t *pBufSize) |
| 5412 | { |
| 5413 | int status; |
| 5414 | hdd_context_t *pHddCtx = (hdd_context_t*)pCtx; |
| 5415 | |
| 5416 | ENTER(); |
| 5417 | |
| 5418 | status = request_firmware(&pHddCtx->fw, pFileName, pHddCtx->parent_dev); |
| 5419 | |
| 5420 | if(status || !pHddCtx->fw || !pHddCtx->fw->data) { |
| 5421 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: CFG download failed",__func__); |
| 5422 | return VOS_STATUS_E_FAILURE; |
| 5423 | } |
| 5424 | else { |
| 5425 | if(*pBufSize != pHddCtx->fw->size) { |
| 5426 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Caller sets invalid CFG " |
| 5427 | "file size", __func__); |
| 5428 | release_firmware(pHddCtx->fw); |
| 5429 | pHddCtx->fw = NULL; |
| 5430 | return VOS_STATUS_E_FAILURE; |
| 5431 | } |
| 5432 | else { |
| 5433 | if(pBuffer) { |
| 5434 | vos_mem_copy(pBuffer,pHddCtx->fw->data,*pBufSize); |
| 5435 | } |
| 5436 | release_firmware(pHddCtx->fw); |
| 5437 | pHddCtx->fw = NULL; |
| 5438 | } |
| 5439 | } |
| 5440 | |
| 5441 | EXIT(); |
| 5442 | |
| 5443 | return VOS_STATUS_SUCCESS; |
| 5444 | } |
| 5445 | |
| 5446 | /**--------------------------------------------------------------------------- |
| 5447 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5448 | \brief hdd_set_mac_address() - |
| 5449 | |
| 5450 | This function sets the user specified mac address using |
| 5451 | the command ifconfig wlanX hw ether <mac adress>. |
| 5452 | |
| 5453 | \param - dev - Pointer to the net device. |
| 5454 | - addr - Pointer to the sockaddr. |
| 5455 | \return - 0 for success, non zero for failure |
| 5456 | |
| 5457 | --------------------------------------------------------------------------*/ |
| 5458 | |
| 5459 | static int hdd_set_mac_address(struct net_device *dev, void *addr) |
| 5460 | { |
| 5461 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5462 | struct sockaddr *psta_mac_addr = addr; |
| 5463 | eHalStatus halStatus = eHAL_STATUS_SUCCESS; |
| 5464 | |
| 5465 | ENTER(); |
| 5466 | |
| 5467 | memcpy(&pAdapter->macAddressCurrent, psta_mac_addr->sa_data, ETH_ALEN); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5468 | memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN); |
| 5469 | |
| 5470 | EXIT(); |
| 5471 | return halStatus; |
| 5472 | } |
| 5473 | |
| 5474 | tANI_U8* wlan_hdd_get_intf_addr(hdd_context_t* pHddCtx) |
| 5475 | { |
| 5476 | int i; |
| 5477 | for ( i = 0; i < VOS_MAX_CONCURRENCY_PERSONA; i++) |
| 5478 | { |
Abhishek Singh | eb18378 | 2014-02-06 13:37:21 +0530 | [diff] [blame] | 5479 | if( 0 == ((pHddCtx->cfg_ini->intfAddrMask) & (1 << i)) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5480 | break; |
| 5481 | } |
| 5482 | |
| 5483 | if( VOS_MAX_CONCURRENCY_PERSONA == i) |
| 5484 | return NULL; |
| 5485 | |
| 5486 | pHddCtx->cfg_ini->intfAddrMask |= (1 << i); |
| 5487 | return &pHddCtx->cfg_ini->intfMacAddr[i].bytes[0]; |
| 5488 | } |
| 5489 | |
| 5490 | void wlan_hdd_release_intf_addr(hdd_context_t* pHddCtx, tANI_U8* releaseAddr) |
| 5491 | { |
| 5492 | int i; |
| 5493 | for ( i = 0; i < VOS_MAX_CONCURRENCY_PERSONA; i++) |
| 5494 | { |
| 5495 | if ( !memcmp(releaseAddr, &pHddCtx->cfg_ini->intfMacAddr[i].bytes[0], 6) ) |
| 5496 | { |
| 5497 | pHddCtx->cfg_ini->intfAddrMask &= ~(1 << i); |
| 5498 | break; |
| 5499 | } |
| 5500 | } |
| 5501 | return; |
| 5502 | } |
| 5503 | |
| 5504 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)) |
| 5505 | static struct net_device_ops wlan_drv_ops = { |
| 5506 | .ndo_open = hdd_open, |
| 5507 | .ndo_stop = hdd_stop, |
| 5508 | .ndo_uninit = hdd_uninit, |
| 5509 | .ndo_start_xmit = hdd_hard_start_xmit, |
| 5510 | .ndo_tx_timeout = hdd_tx_timeout, |
| 5511 | .ndo_get_stats = hdd_stats, |
| 5512 | .ndo_do_ioctl = hdd_ioctl, |
| 5513 | .ndo_set_mac_address = hdd_set_mac_address, |
| 5514 | .ndo_select_queue = hdd_select_queue, |
| 5515 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 5516 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(3,1,0)) |
| 5517 | .ndo_set_rx_mode = hdd_set_multicast_list, |
| 5518 | #else |
| 5519 | .ndo_set_multicast_list = hdd_set_multicast_list, |
| 5520 | #endif //LINUX_VERSION_CODE |
| 5521 | #endif |
| 5522 | }; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5523 | static struct net_device_ops wlan_mon_drv_ops = { |
| 5524 | .ndo_open = hdd_mon_open, |
| 5525 | .ndo_stop = hdd_stop, |
| 5526 | .ndo_uninit = hdd_uninit, |
| 5527 | .ndo_start_xmit = hdd_mon_hard_start_xmit, |
| 5528 | .ndo_tx_timeout = hdd_tx_timeout, |
| 5529 | .ndo_get_stats = hdd_stats, |
| 5530 | .ndo_do_ioctl = hdd_ioctl, |
| 5531 | .ndo_set_mac_address = hdd_set_mac_address, |
| 5532 | }; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5533 | |
| 5534 | #endif |
| 5535 | |
| 5536 | void hdd_set_station_ops( struct net_device *pWlanDev ) |
| 5537 | { |
| 5538 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5539 | pWlanDev->netdev_ops = &wlan_drv_ops; |
| 5540 | #else |
| 5541 | pWlanDev->open = hdd_open; |
| 5542 | pWlanDev->stop = hdd_stop; |
| 5543 | pWlanDev->uninit = hdd_uninit; |
| 5544 | pWlanDev->hard_start_xmit = NULL; |
| 5545 | pWlanDev->tx_timeout = hdd_tx_timeout; |
| 5546 | pWlanDev->get_stats = hdd_stats; |
| 5547 | pWlanDev->do_ioctl = hdd_ioctl; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5548 | pWlanDev->set_mac_address = hdd_set_mac_address; |
| 5549 | #endif |
| 5550 | } |
| 5551 | |
Jeff Johnson | eed415b | 2013-01-18 16:11:20 -0800 | [diff] [blame] | 5552 | 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] | 5553 | { |
| 5554 | struct net_device *pWlanDev = NULL; |
| 5555 | hdd_adapter_t *pAdapter = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5556 | /* |
| 5557 | * cfg80211 initialization and registration.... |
| 5558 | */ |
| 5559 | pWlanDev = alloc_netdev_mq(sizeof( hdd_adapter_t ), name, ether_setup, NUM_TX_QUEUES); |
| 5560 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5561 | if(pWlanDev != NULL) |
| 5562 | { |
| 5563 | |
| 5564 | //Save the pointer to the net_device in the HDD adapter |
| 5565 | pAdapter = (hdd_adapter_t*) netdev_priv( pWlanDev ); |
| 5566 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5567 | vos_mem_zero( pAdapter, sizeof( hdd_adapter_t ) ); |
| 5568 | |
| 5569 | pAdapter->dev = pWlanDev; |
| 5570 | pAdapter->pHddCtx = pHddCtx; |
| 5571 | pAdapter->magic = WLAN_HDD_ADAPTER_MAGIC; |
| 5572 | |
| 5573 | init_completion(&pAdapter->session_open_comp_var); |
| 5574 | init_completion(&pAdapter->session_close_comp_var); |
| 5575 | init_completion(&pAdapter->disconnect_comp_var); |
| 5576 | init_completion(&pAdapter->linkup_event_var); |
| 5577 | init_completion(&pAdapter->cancel_rem_on_chan_var); |
| 5578 | init_completion(&pAdapter->rem_on_chan_ready_event); |
Vinay Krishna Eranna | f0e523b | 2014-03-01 21:00:16 +0530 | [diff] [blame] | 5579 | init_completion(&pAdapter->pno_comp_var); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5580 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 5581 | init_completion(&pAdapter->offchannel_tx_event); |
| 5582 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5583 | init_completion(&pAdapter->tx_action_cnf_event); |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 5584 | #ifdef FEATURE_WLAN_TDLS |
| 5585 | init_completion(&pAdapter->tdls_add_station_comp); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 5586 | init_completion(&pAdapter->tdls_del_station_comp); |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 5587 | init_completion(&pAdapter->tdls_mgmt_comp); |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 5588 | init_completion(&pAdapter->tdls_link_establish_req_comp); |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 5589 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5590 | init_completion(&pHddCtx->mc_sus_event_var); |
| 5591 | init_completion(&pHddCtx->tx_sus_event_var); |
Gopichand Nakkala | 0562141 | 2013-06-19 19:37:38 +0530 | [diff] [blame] | 5592 | init_completion(&pHddCtx->rx_sus_event_var); |
Jeff Johnson | 9efb9aa | 2013-03-15 13:59:27 -0700 | [diff] [blame] | 5593 | init_completion(&pAdapter->ula_complete); |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 5594 | init_completion(&pAdapter->change_country_code); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5595 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 5596 | #ifdef FEATURE_WLAN_BATCH_SCAN |
| 5597 | init_completion(&pAdapter->hdd_set_batch_scan_req_var); |
| 5598 | init_completion(&pAdapter->hdd_get_batch_scan_req_var); |
| 5599 | pAdapter->pBatchScanRsp = NULL; |
| 5600 | pAdapter->numScanList = 0; |
Rajeev Kumar | 20140c1 | 2013-10-21 19:39:02 -0700 | [diff] [blame] | 5601 | pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STOPPED; |
Kiet Lam | aa8e15a | 2014-02-11 23:30:06 -0800 | [diff] [blame] | 5602 | pAdapter->prev_batch_id = 0; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 5603 | mutex_init(&pAdapter->hdd_batch_scan_lock); |
| 5604 | #endif |
| 5605 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5606 | pAdapter->isLinkUpSvcNeeded = FALSE; |
| 5607 | pAdapter->higherDtimTransition = eANI_BOOLEAN_TRUE; |
| 5608 | //Init the net_device structure |
| 5609 | strlcpy(pWlanDev->name, name, IFNAMSIZ); |
| 5610 | |
| 5611 | vos_mem_copy(pWlanDev->dev_addr, (void *)macAddr, sizeof(tSirMacAddr)); |
| 5612 | vos_mem_copy( pAdapter->macAddressCurrent.bytes, macAddr, sizeof(tSirMacAddr)); |
| 5613 | pWlanDev->watchdog_timeo = HDD_TX_TIMEOUT; |
| 5614 | pWlanDev->hard_header_len += LIBRA_HW_NEEDED_HEADROOM; |
| 5615 | |
| 5616 | hdd_set_station_ops( pAdapter->dev ); |
| 5617 | |
| 5618 | pWlanDev->destructor = free_netdev; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5619 | pWlanDev->ieee80211_ptr = &pAdapter->wdev ; |
| 5620 | pAdapter->wdev.wiphy = pHddCtx->wiphy; |
| 5621 | pAdapter->wdev.netdev = pWlanDev; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5622 | /* set pWlanDev's parent to underlying device */ |
| 5623 | SET_NETDEV_DEV(pWlanDev, pHddCtx->parent_dev); |
| 5624 | } |
| 5625 | |
| 5626 | return pAdapter; |
| 5627 | } |
| 5628 | |
| 5629 | VOS_STATUS hdd_register_interface( hdd_adapter_t *pAdapter, tANI_U8 rtnl_lock_held ) |
| 5630 | { |
| 5631 | struct net_device *pWlanDev = pAdapter->dev; |
| 5632 | //hdd_station_ctx_t *pHddStaCtx = &pAdapter->sessionCtx.station; |
| 5633 | //hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
| 5634 | //eHalStatus halStatus = eHAL_STATUS_SUCCESS; |
| 5635 | |
| 5636 | if( rtnl_lock_held ) |
| 5637 | { |
Madan Mohan Koyyalamudi | d8ac866 | 2012-11-06 19:04:56 -0800 | [diff] [blame] | 5638 | if (strnchr(pWlanDev->name, strlen(pWlanDev->name), '%')) { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5639 | if( dev_alloc_name(pWlanDev, pWlanDev->name) < 0 ) |
| 5640 | { |
| 5641 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s:Failed:dev_alloc_name",__func__); |
| 5642 | return VOS_STATUS_E_FAILURE; |
| 5643 | } |
| 5644 | } |
| 5645 | if (register_netdevice(pWlanDev)) |
| 5646 | { |
| 5647 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s:Failed:register_netdev",__func__); |
| 5648 | return VOS_STATUS_E_FAILURE; |
| 5649 | } |
| 5650 | } |
| 5651 | else |
| 5652 | { |
| 5653 | if(register_netdev(pWlanDev)) |
| 5654 | { |
| 5655 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failed:register_netdev",__func__); |
| 5656 | return VOS_STATUS_E_FAILURE; |
| 5657 | } |
| 5658 | } |
| 5659 | set_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags); |
| 5660 | |
| 5661 | return VOS_STATUS_SUCCESS; |
| 5662 | } |
| 5663 | |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 5664 | static eHalStatus hdd_smeCloseSessionCallback(void *pContext) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5665 | { |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 5666 | hdd_adapter_t *pAdapter = pContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5667 | |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 5668 | if (NULL == pAdapter) |
| 5669 | { |
| 5670 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: NULL pAdapter", __func__); |
| 5671 | return eHAL_STATUS_INVALID_PARAMETER; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5672 | } |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 5673 | |
| 5674 | if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) |
| 5675 | { |
| 5676 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Invalid magic", __func__); |
| 5677 | return eHAL_STATUS_NOT_INITIALIZED; |
| 5678 | } |
| 5679 | |
| 5680 | clear_bit(SME_SESSION_OPENED, &pAdapter->event_flags); |
| 5681 | |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 5682 | #ifndef WLAN_OPEN_SOURCE |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 5683 | /* need to make sure all of our scheduled work has completed. |
| 5684 | * This callback is called from MC thread context, so it is safe to |
| 5685 | * to call below flush workqueue API from here. |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 5686 | * |
| 5687 | * Even though this is called from MC thread context, if there is a faulty |
| 5688 | * work item in the system, that can hang this call forever. So flushing |
| 5689 | * this global work queue is not safe; and now we make sure that |
| 5690 | * individual work queues are stopped correctly. But the cancel work queue |
| 5691 | * is a GPL only API, so the proprietary version of the driver would still |
| 5692 | * rely on the global work queue flush. |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 5693 | */ |
| 5694 | flush_scheduled_work(); |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 5695 | #endif |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 5696 | |
| 5697 | /* We can be blocked while waiting for scheduled work to be |
| 5698 | * flushed, and the adapter structure can potentially be freed, in |
| 5699 | * which case the magic will have been reset. So make sure the |
| 5700 | * magic is still good, and hence the adapter structure is still |
| 5701 | * valid, before signaling completion */ |
| 5702 | if (WLAN_HDD_ADAPTER_MAGIC == pAdapter->magic) |
| 5703 | { |
| 5704 | complete(&pAdapter->session_close_comp_var); |
| 5705 | } |
| 5706 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5707 | return eHAL_STATUS_SUCCESS; |
| 5708 | } |
| 5709 | |
| 5710 | VOS_STATUS hdd_init_station_mode( hdd_adapter_t *pAdapter ) |
| 5711 | { |
| 5712 | struct net_device *pWlanDev = pAdapter->dev; |
| 5713 | hdd_station_ctx_t *pHddStaCtx = &pAdapter->sessionCtx.station; |
| 5714 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
| 5715 | eHalStatus halStatus = eHAL_STATUS_SUCCESS; |
| 5716 | VOS_STATUS status = VOS_STATUS_E_FAILURE; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 5717 | long rc = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5718 | |
| 5719 | INIT_COMPLETION(pAdapter->session_open_comp_var); |
Kiran Kumar Lokere | 0ad5cd3 | 2013-06-25 11:26:22 -0700 | [diff] [blame] | 5720 | sme_SetCurrDeviceMode(pHddCtx->hHal, pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5721 | //Open a SME session for future operation |
| 5722 | halStatus = sme_OpenSession( pHddCtx->hHal, hdd_smeRoamCallback, pAdapter, |
Kiran Kumar Lokere | 0ad5cd3 | 2013-06-25 11:26:22 -0700 | [diff] [blame] | 5723 | (tANI_U8 *)&pAdapter->macAddressCurrent, &pAdapter->sessionId); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5724 | if ( !HAL_STATUS_SUCCESS( halStatus ) ) |
| 5725 | { |
| 5726 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 5727 | "sme_OpenSession() failed with status code %08d [x%08x]", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5728 | halStatus, halStatus ); |
| 5729 | status = VOS_STATUS_E_FAILURE; |
| 5730 | goto error_sme_open; |
| 5731 | } |
| 5732 | |
| 5733 | //Block on a completion variable. Can't wait forever though. |
Vinay Krishna Eranna | 0fe2e7c | 2014-04-09 21:32:08 +0530 | [diff] [blame] | 5734 | rc = wait_for_completion_timeout( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5735 | &pAdapter->session_open_comp_var, |
| 5736 | msecs_to_jiffies(WLAN_WAIT_TIME_SESSIONOPENCLOSE)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 5737 | if (rc <= 0) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5738 | { |
| 5739 | hddLog(VOS_TRACE_LEVEL_FATAL, |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 5740 | "Session is not opened within timeout period code %ld", rc ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5741 | status = VOS_STATUS_E_FAILURE; |
| 5742 | goto error_sme_open; |
| 5743 | } |
| 5744 | |
| 5745 | // Register wireless extensions |
| 5746 | if( eHAL_STATUS_SUCCESS != (halStatus = hdd_register_wext(pWlanDev))) |
| 5747 | { |
| 5748 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 5749 | "hdd_register_wext() failed with status code %08d [x%08x]", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5750 | halStatus, halStatus ); |
| 5751 | status = VOS_STATUS_E_FAILURE; |
| 5752 | goto error_register_wext; |
| 5753 | } |
| 5754 | //Safe to register the hard_start_xmit function again |
| 5755 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)) |
| 5756 | wlan_drv_ops.ndo_start_xmit = hdd_hard_start_xmit; |
| 5757 | #else |
| 5758 | pWlanDev->hard_start_xmit = hdd_hard_start_xmit; |
| 5759 | #endif |
| 5760 | |
| 5761 | //Set the Connection State to Not Connected |
Abhishek Singh | f4669da | 2014-05-26 15:07:49 +0530 | [diff] [blame] | 5762 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 5763 | "%s: Set HDD connState to eConnectionState_NotConnected", |
| 5764 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5765 | pHddStaCtx->conn_info.connState = eConnectionState_NotConnected; |
| 5766 | |
| 5767 | //Set the default operation channel |
| 5768 | pHddStaCtx->conn_info.operationChannel = pHddCtx->cfg_ini->OperatingChannel; |
| 5769 | |
| 5770 | /* Make the default Auth Type as OPEN*/ |
| 5771 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 5772 | |
| 5773 | if( VOS_STATUS_SUCCESS != ( status = hdd_init_tx_rx( pAdapter ) ) ) |
| 5774 | { |
| 5775 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 5776 | "hdd_init_tx_rx() failed with status code %08d [x%08x]", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5777 | status, status ); |
| 5778 | goto error_init_txrx; |
| 5779 | } |
| 5780 | |
| 5781 | set_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags); |
| 5782 | |
| 5783 | if( VOS_STATUS_SUCCESS != ( status = hdd_wmm_adapter_init( pAdapter ) ) ) |
| 5784 | { |
| 5785 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 5786 | "hdd_wmm_adapter_init() failed with status code %08d [x%08x]", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5787 | status, status ); |
| 5788 | goto error_wmm_init; |
| 5789 | } |
| 5790 | |
| 5791 | set_bit(WMM_INIT_DONE, &pAdapter->event_flags); |
| 5792 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 5793 | #ifdef FEATURE_WLAN_TDLS |
| 5794 | if(0 != wlan_hdd_tdls_init(pAdapter)) |
| 5795 | { |
| 5796 | status = VOS_STATUS_E_FAILURE; |
| 5797 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wlan_hdd_tdls_init failed",__func__); |
| 5798 | goto error_tdls_init; |
| 5799 | } |
| 5800 | set_bit(TDLS_INIT_DONE, &pAdapter->event_flags); |
| 5801 | #endif |
| 5802 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5803 | return VOS_STATUS_SUCCESS; |
| 5804 | |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 5805 | #ifdef FEATURE_WLAN_TDLS |
| 5806 | error_tdls_init: |
| 5807 | clear_bit(WMM_INIT_DONE, &pAdapter->event_flags); |
| 5808 | hdd_wmm_adapter_close(pAdapter); |
| 5809 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5810 | error_wmm_init: |
| 5811 | clear_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags); |
| 5812 | hdd_deinit_tx_rx(pAdapter); |
| 5813 | error_init_txrx: |
| 5814 | hdd_UnregisterWext(pWlanDev); |
| 5815 | error_register_wext: |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 5816 | if (test_bit(SME_SESSION_OPENED, &pAdapter->event_flags)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5817 | { |
| 5818 | INIT_COMPLETION(pAdapter->session_close_comp_var); |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 5819 | if (eHAL_STATUS_SUCCESS == sme_CloseSession(pHddCtx->hHal, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5820 | pAdapter->sessionId, |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 5821 | hdd_smeCloseSessionCallback, pAdapter)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5822 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 5823 | unsigned long rc; |
| 5824 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5825 | //Block on a completion variable. Can't wait forever though. |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 5826 | rc = wait_for_completion_timeout( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5827 | &pAdapter->session_close_comp_var, |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 5828 | msecs_to_jiffies(WLAN_WAIT_TIME_SESSIONOPENCLOSE)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 5829 | if (rc <= 0) |
| 5830 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5831 | FL("Session is not opened within timeout period code %ld"), rc); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5832 | } |
| 5833 | } |
| 5834 | error_sme_open: |
| 5835 | return status; |
| 5836 | } |
| 5837 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5838 | void hdd_cleanup_actionframe( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter ) |
| 5839 | { |
| 5840 | hdd_cfg80211_state_t *cfgState; |
| 5841 | |
| 5842 | cfgState = WLAN_HDD_GET_CFG_STATE_PTR( pAdapter ); |
| 5843 | |
| 5844 | if( NULL != cfgState->buf ) |
| 5845 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 5846 | long rc; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5847 | INIT_COMPLETION(pAdapter->tx_action_cnf_event); |
| 5848 | rc = wait_for_completion_interruptible_timeout( |
| 5849 | &pAdapter->tx_action_cnf_event, |
| 5850 | msecs_to_jiffies(ACTION_FRAME_TX_TIMEOUT)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 5851 | if (rc <= 0) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5852 | { |
Sudhir Sattayappa Kohalli | 8ee532d | 2013-02-15 13:16:26 -0800 | [diff] [blame] | 5853 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 5854 | "%s ERROR: HDD Wait for Action Confirmation Failed!! %ld" |
| 5855 | , __func__, rc); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5856 | } |
| 5857 | } |
| 5858 | return; |
| 5859 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5860 | |
| 5861 | void hdd_deinit_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter ) |
| 5862 | { |
| 5863 | ENTER(); |
| 5864 | switch ( pAdapter->device_mode ) |
| 5865 | { |
| 5866 | case WLAN_HDD_INFRA_STATION: |
| 5867 | case WLAN_HDD_P2P_CLIENT: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5868 | case WLAN_HDD_P2P_DEVICE: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5869 | { |
| 5870 | if(test_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags)) |
| 5871 | { |
| 5872 | hdd_deinit_tx_rx( pAdapter ); |
| 5873 | clear_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags); |
| 5874 | } |
| 5875 | |
| 5876 | if(test_bit(WMM_INIT_DONE, &pAdapter->event_flags)) |
| 5877 | { |
| 5878 | hdd_wmm_adapter_close( pAdapter ); |
| 5879 | clear_bit(WMM_INIT_DONE, &pAdapter->event_flags); |
| 5880 | } |
| 5881 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5882 | hdd_cleanup_actionframe(pHddCtx, pAdapter); |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 5883 | #ifdef FEATURE_WLAN_TDLS |
| 5884 | if(test_bit(TDLS_INIT_DONE, &pAdapter->event_flags)) |
| 5885 | { |
| 5886 | wlan_hdd_tdls_exit(pAdapter); |
| 5887 | clear_bit(TDLS_INIT_DONE, &pAdapter->event_flags); |
| 5888 | } |
| 5889 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5890 | |
| 5891 | break; |
| 5892 | } |
| 5893 | |
| 5894 | case WLAN_HDD_SOFTAP: |
| 5895 | case WLAN_HDD_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5896 | { |
Madan Mohan Koyyalamudi | 8c6dec8 | 2013-09-26 15:56:13 +0530 | [diff] [blame] | 5897 | |
| 5898 | if (test_bit(WMM_INIT_DONE, &pAdapter->event_flags)) |
| 5899 | { |
| 5900 | hdd_wmm_adapter_close( pAdapter ); |
| 5901 | clear_bit(WMM_INIT_DONE, &pAdapter->event_flags); |
| 5902 | } |
| 5903 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5904 | hdd_cleanup_actionframe(pHddCtx, pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5905 | |
| 5906 | hdd_unregister_hostapd(pAdapter); |
| 5907 | hdd_set_conparam( 0 ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5908 | wlan_hdd_set_monitor_tx_adapter( WLAN_HDD_GET_CTX(pAdapter), NULL ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5909 | break; |
| 5910 | } |
| 5911 | |
| 5912 | case WLAN_HDD_MONITOR: |
| 5913 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5914 | hdd_adapter_t* pAdapterforTx = pAdapter->sessionCtx.monitor.pAdapterForTx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5915 | if(test_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags)) |
| 5916 | { |
| 5917 | hdd_deinit_tx_rx( pAdapter ); |
| 5918 | clear_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags); |
| 5919 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5920 | if(NULL != pAdapterforTx) |
| 5921 | { |
| 5922 | hdd_cleanup_actionframe(pHddCtx, pAdapterforTx); |
| 5923 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5924 | break; |
| 5925 | } |
| 5926 | |
| 5927 | |
| 5928 | default: |
| 5929 | break; |
| 5930 | } |
| 5931 | |
| 5932 | EXIT(); |
| 5933 | } |
| 5934 | |
| 5935 | void hdd_cleanup_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter, tANI_U8 rtnl_held ) |
| 5936 | { |
Mingcheng Zhu | 87f22fc | 2014-01-30 19:23:32 -0800 | [diff] [blame] | 5937 | struct net_device *pWlanDev = NULL; |
Srinivas, Dasari | 693dfc5 | 2013-12-27 17:29:09 +0530 | [diff] [blame] | 5938 | |
| 5939 | ENTER(); |
| 5940 | if (NULL == pAdapter) |
| 5941 | { |
| 5942 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5943 | "%s: HDD adapter is Null", __func__); |
| 5944 | return; |
| 5945 | } |
| 5946 | |
| 5947 | pWlanDev = pAdapter->dev; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5948 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 5949 | #ifdef FEATURE_WLAN_BATCH_SCAN |
Srinivas, Dasari | 693dfc5 | 2013-12-27 17:29:09 +0530 | [diff] [blame] | 5950 | if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
| 5951 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 5952 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Srinivas, Dasari | 693dfc5 | 2013-12-27 17:29:09 +0530 | [diff] [blame] | 5953 | || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE) |
| 5954 | ) |
| 5955 | { |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 5956 | if (pAdapter) |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 5957 | { |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 5958 | if (eHDD_BATCH_SCAN_STATE_STARTED == pAdapter->batchScanState) |
| 5959 | { |
| 5960 | hdd_deinit_batch_scan(pAdapter); |
| 5961 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 5962 | } |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 5963 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 5964 | #endif |
| 5965 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5966 | if(test_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags)) { |
| 5967 | if( rtnl_held ) |
| 5968 | { |
| 5969 | unregister_netdevice(pWlanDev); |
| 5970 | } |
| 5971 | else |
| 5972 | { |
| 5973 | unregister_netdev(pWlanDev); |
| 5974 | } |
| 5975 | // note that the pAdapter is no longer valid at this point |
| 5976 | // since the memory has been reclaimed |
| 5977 | } |
| 5978 | |
Srinivas, Dasari | 693dfc5 | 2013-12-27 17:29:09 +0530 | [diff] [blame] | 5979 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5980 | } |
| 5981 | |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 5982 | void hdd_set_pwrparams(hdd_context_t *pHddCtx) |
| 5983 | { |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 5984 | VOS_STATUS status; |
| 5985 | hdd_adapter_t *pAdapter = NULL; |
| 5986 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 5987 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 5988 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 5989 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 5990 | /*loop through all adapters.*/ |
| 5991 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 5992 | { |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 5993 | pAdapter = pAdapterNode->pAdapter; |
| 5994 | if ( (WLAN_HDD_INFRA_STATION != pAdapter->device_mode) |
| 5995 | && (WLAN_HDD_P2P_CLIENT != pAdapter->device_mode) ) |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 5996 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 5997 | { // we skip this registration for modes other than STA and P2P client modes. |
| 5998 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 5999 | pAdapterNode = pNext; |
| 6000 | continue; |
| 6001 | } |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 6002 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 6003 | //Apply Dynamic DTIM For P2P |
| 6004 | //Only if ignoreDynamicDtimInP2pMode is not set in ini |
| 6005 | if ((pHddCtx->cfg_ini->enableDynamicDTIM || |
| 6006 | pHddCtx->cfg_ini->enableModulatedDTIM) && |
| 6007 | ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
| 6008 | ((WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) && |
| 6009 | !(pHddCtx->cfg_ini->ignoreDynamicDtimInP2pMode))) && |
| 6010 | (eANI_BOOLEAN_TRUE == pAdapter->higherDtimTransition) && |
| 6011 | (eConnectionState_Associated == |
| 6012 | (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) && |
| 6013 | (pHddCtx->cfg_ini->fIsBmpsEnabled)) |
| 6014 | { |
| 6015 | tSirSetPowerParamsReq powerRequest = { 0 }; |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 6016 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 6017 | powerRequest.uIgnoreDTIM = 1; |
| 6018 | powerRequest.uMaxLIModulatedDTIM = pHddCtx->cfg_ini->fMaxLIModulatedDTIM; |
| 6019 | |
| 6020 | if (pHddCtx->cfg_ini->enableModulatedDTIM) |
| 6021 | { |
| 6022 | powerRequest.uDTIMPeriod = pHddCtx->cfg_ini->enableModulatedDTIM; |
| 6023 | powerRequest.uListenInterval = pHddCtx->hdd_actual_LI_value; |
| 6024 | } |
| 6025 | else |
| 6026 | { |
| 6027 | powerRequest.uListenInterval = pHddCtx->cfg_ini->enableDynamicDTIM; |
| 6028 | } |
| 6029 | |
| 6030 | /* Update ignoreDTIM and ListedInterval in CFG to remain at the DTIM |
| 6031 | * specified during Enter/Exit BMPS when LCD off*/ |
| 6032 | ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IGNORE_DTIM, powerRequest.uIgnoreDTIM, |
| 6033 | NULL, eANI_BOOLEAN_FALSE); |
| 6034 | ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_LISTEN_INTERVAL, powerRequest.uListenInterval, |
| 6035 | NULL, eANI_BOOLEAN_FALSE); |
| 6036 | |
| 6037 | /* switch to the DTIM specified in cfg.ini */ |
| 6038 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 6039 | "Switch to DTIM %d", powerRequest.uListenInterval); |
| 6040 | sme_SetPowerParams( pHddCtx->hHal, &powerRequest, TRUE); |
| 6041 | break; |
| 6042 | |
| 6043 | } |
| 6044 | |
| 6045 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 6046 | pAdapterNode = pNext; |
| 6047 | } |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 6048 | } |
| 6049 | |
| 6050 | void hdd_reset_pwrparams(hdd_context_t *pHddCtx) |
| 6051 | { |
| 6052 | /*Switch back to DTIM 1*/ |
| 6053 | tSirSetPowerParamsReq powerRequest = { 0 }; |
| 6054 | |
| 6055 | powerRequest.uIgnoreDTIM = pHddCtx->hdd_actual_ignore_DTIM_value; |
| 6056 | powerRequest.uListenInterval = pHddCtx->hdd_actual_LI_value; |
Yue Ma | c24062f | 2013-05-13 17:01:29 -0700 | [diff] [blame] | 6057 | powerRequest.uMaxLIModulatedDTIM = pHddCtx->cfg_ini->fMaxLIModulatedDTIM; |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 6058 | |
| 6059 | /* Update ignoreDTIM and ListedInterval in CFG with default values */ |
| 6060 | ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IGNORE_DTIM, powerRequest.uIgnoreDTIM, |
| 6061 | NULL, eANI_BOOLEAN_FALSE); |
| 6062 | ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_LISTEN_INTERVAL, powerRequest.uListenInterval, |
| 6063 | NULL, eANI_BOOLEAN_FALSE); |
| 6064 | |
| 6065 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 6066 | "Switch to DTIM%d",powerRequest.uListenInterval); |
| 6067 | sme_SetPowerParams( pHddCtx->hHal, &powerRequest, TRUE); |
| 6068 | |
| 6069 | } |
| 6070 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6071 | VOS_STATUS hdd_enable_bmps_imps(hdd_context_t *pHddCtx) |
| 6072 | { |
| 6073 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 6074 | |
| 6075 | if(pHddCtx->cfg_ini->fIsBmpsEnabled) |
| 6076 | { |
| 6077 | sme_EnablePowerSave(pHddCtx->hHal, ePMC_BEACON_MODE_POWER_SAVE); |
| 6078 | } |
| 6079 | |
| 6080 | if(pHddCtx->cfg_ini->fIsAutoBmpsTimerEnabled) |
| 6081 | { |
| 6082 | sme_StartAutoBmpsTimer(pHddCtx->hHal); |
| 6083 | } |
| 6084 | |
| 6085 | if (pHddCtx->cfg_ini->fIsImpsEnabled) |
| 6086 | { |
| 6087 | sme_EnablePowerSave (pHddCtx->hHal, ePMC_IDLE_MODE_POWER_SAVE); |
| 6088 | } |
| 6089 | |
| 6090 | return status; |
| 6091 | } |
| 6092 | |
| 6093 | VOS_STATUS hdd_disable_bmps_imps(hdd_context_t *pHddCtx, tANI_U8 session_type) |
| 6094 | { |
| 6095 | hdd_adapter_t *pAdapter = NULL; |
| 6096 | eHalStatus halStatus; |
| 6097 | VOS_STATUS status = VOS_STATUS_E_INVAL; |
| 6098 | v_BOOL_t disableBmps = FALSE; |
| 6099 | v_BOOL_t disableImps = FALSE; |
| 6100 | |
| 6101 | switch(session_type) |
| 6102 | { |
| 6103 | case WLAN_HDD_INFRA_STATION: |
| 6104 | case WLAN_HDD_SOFTAP: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6105 | case WLAN_HDD_P2P_CLIENT: |
| 6106 | case WLAN_HDD_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6107 | //Exit BMPS -> Is Sta/P2P Client is already connected |
| 6108 | pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 6109 | if((NULL != pAdapter)&& |
| 6110 | hdd_connIsConnected( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) |
| 6111 | { |
| 6112 | disableBmps = TRUE; |
| 6113 | } |
| 6114 | |
| 6115 | pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT); |
| 6116 | if((NULL != pAdapter)&& |
| 6117 | hdd_connIsConnected( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) |
| 6118 | { |
| 6119 | disableBmps = TRUE; |
| 6120 | } |
| 6121 | |
| 6122 | //Exit both Bmps and Imps incase of Go/SAP Mode |
| 6123 | if((WLAN_HDD_SOFTAP == session_type) || |
| 6124 | (WLAN_HDD_P2P_GO == session_type)) |
| 6125 | { |
| 6126 | disableBmps = TRUE; |
| 6127 | disableImps = TRUE; |
| 6128 | } |
| 6129 | |
| 6130 | if(TRUE == disableImps) |
| 6131 | { |
| 6132 | if (pHddCtx->cfg_ini->fIsImpsEnabled) |
| 6133 | { |
| 6134 | sme_DisablePowerSave (pHddCtx->hHal, ePMC_IDLE_MODE_POWER_SAVE); |
| 6135 | } |
| 6136 | } |
| 6137 | |
| 6138 | if(TRUE == disableBmps) |
| 6139 | { |
| 6140 | if(pHddCtx->cfg_ini->fIsBmpsEnabled) |
| 6141 | { |
| 6142 | halStatus = sme_DisablePowerSave(pHddCtx->hHal, ePMC_BEACON_MODE_POWER_SAVE); |
| 6143 | |
| 6144 | if(eHAL_STATUS_SUCCESS != halStatus) |
| 6145 | { |
| 6146 | status = VOS_STATUS_E_FAILURE; |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6147 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Fail to Disable Power Save", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6148 | VOS_ASSERT(0); |
| 6149 | return status; |
| 6150 | } |
| 6151 | } |
| 6152 | |
| 6153 | if(pHddCtx->cfg_ini->fIsAutoBmpsTimerEnabled) |
| 6154 | { |
| 6155 | halStatus = sme_StopAutoBmpsTimer(pHddCtx->hHal); |
| 6156 | |
| 6157 | if(eHAL_STATUS_SUCCESS != halStatus) |
| 6158 | { |
| 6159 | status = VOS_STATUS_E_FAILURE; |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6160 | 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] | 6161 | VOS_ASSERT(0); |
| 6162 | return status; |
| 6163 | } |
| 6164 | } |
| 6165 | } |
| 6166 | |
| 6167 | if((TRUE == disableBmps) || |
| 6168 | (TRUE == disableImps)) |
| 6169 | { |
| 6170 | /* Now, get the chip into Full Power now */ |
| 6171 | INIT_COMPLETION(pHddCtx->full_pwr_comp_var); |
| 6172 | halStatus = sme_RequestFullPower(pHddCtx->hHal, hdd_full_pwr_cbk, |
| 6173 | pHddCtx, eSME_FULL_PWR_NEEDED_BY_HDD); |
| 6174 | |
| 6175 | if(halStatus != eHAL_STATUS_SUCCESS) |
| 6176 | { |
| 6177 | if(halStatus == eHAL_STATUS_PMC_PENDING) |
| 6178 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6179 | long ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6180 | //Block on a completion variable. Can't wait forever though |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6181 | ret = wait_for_completion_interruptible_timeout( |
| 6182 | &pHddCtx->full_pwr_comp_var, |
| 6183 | msecs_to_jiffies(1000)); |
| 6184 | if (ret <= 0) |
| 6185 | { |
| 6186 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6187 | "%s: wait on full_pwr_comp_var failed %ld", |
| 6188 | __func__, ret); |
| 6189 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6190 | } |
| 6191 | else |
| 6192 | { |
| 6193 | status = VOS_STATUS_E_FAILURE; |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6194 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Request for Full Power failed", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6195 | VOS_ASSERT(0); |
| 6196 | return status; |
| 6197 | } |
| 6198 | } |
| 6199 | |
| 6200 | status = VOS_STATUS_SUCCESS; |
| 6201 | } |
| 6202 | |
| 6203 | break; |
| 6204 | } |
| 6205 | return status; |
| 6206 | } |
| 6207 | |
| 6208 | 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] | 6209 | const char *iface_name, tSirMacAddr macAddr, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6210 | tANI_U8 rtnl_held ) |
| 6211 | { |
| 6212 | hdd_adapter_t *pAdapter = NULL; |
| 6213 | hdd_adapter_list_node_t *pHddAdapterNode = NULL; |
| 6214 | VOS_STATUS status = VOS_STATUS_E_FAILURE; |
| 6215 | VOS_STATUS exitbmpsStatus; |
| 6216 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6217 | 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] | 6218 | |
Nirav Shah | 436658f | 2014-02-28 17:05:45 +0530 | [diff] [blame] | 6219 | if(macAddr == NULL) |
| 6220 | { |
| 6221 | /* Not received valid macAddr */ |
| 6222 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6223 | "%s:Unable to add virtual intf: Not able to get" |
| 6224 | "valid mac address",__func__); |
| 6225 | return NULL; |
| 6226 | } |
| 6227 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6228 | //Disable BMPS incase of Concurrency |
| 6229 | exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx, session_type); |
| 6230 | |
| 6231 | if(VOS_STATUS_E_FAILURE == exitbmpsStatus) |
| 6232 | { |
| 6233 | //Fail to Exit BMPS |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6234 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Fail to Exit BMPS", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6235 | VOS_ASSERT(0); |
| 6236 | return NULL; |
| 6237 | } |
| 6238 | |
| 6239 | switch(session_type) |
| 6240 | { |
| 6241 | case WLAN_HDD_INFRA_STATION: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6242 | case WLAN_HDD_P2P_CLIENT: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6243 | case WLAN_HDD_P2P_DEVICE: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6244 | { |
| 6245 | pAdapter = hdd_alloc_station_adapter( pHddCtx, macAddr, iface_name ); |
| 6246 | |
| 6247 | if( NULL == pAdapter ) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6248 | { |
| 6249 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 6250 | FL("failed to allocate adapter for session %d"), session_type); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6251 | return NULL; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6252 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6253 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 6254 | #ifdef FEATURE_WLAN_TDLS |
| 6255 | /* A Mutex Lock is introduced while changing/initializing the mode to |
| 6256 | * protect the concurrent access for the Adapters by TDLS module. |
| 6257 | */ |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 6258 | mutex_lock(&pHddCtx->tdls_lock); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 6259 | #endif |
| 6260 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6261 | pAdapter->wdev.iftype = (session_type == WLAN_HDD_P2P_CLIENT) ? |
| 6262 | NL80211_IFTYPE_P2P_CLIENT: |
| 6263 | NL80211_IFTYPE_STATION; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6264 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6265 | pAdapter->device_mode = session_type; |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 6266 | #ifdef FEATURE_WLAN_TDLS |
| 6267 | mutex_unlock(&pHddCtx->tdls_lock); |
| 6268 | #endif |
Sunil Dutt | 66485cb | 2013-12-19 19:05:03 +0530 | [diff] [blame] | 6269 | |
| 6270 | status = hdd_init_station_mode( pAdapter ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6271 | if( VOS_STATUS_SUCCESS != status ) |
| 6272 | goto err_free_netdev; |
| 6273 | |
| 6274 | status = hdd_register_interface( pAdapter, rtnl_held ); |
| 6275 | if( VOS_STATUS_SUCCESS != status ) |
| 6276 | { |
| 6277 | hdd_deinit_adapter(pHddCtx, pAdapter); |
| 6278 | goto err_free_netdev; |
| 6279 | } |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 6280 | |
Vinay Krishna Eranna | 4d055d4 | 2013-12-17 17:02:01 +0530 | [diff] [blame] | 6281 | // Workqueue which gets scheduled in IPv4 notification callback. |
| 6282 | INIT_WORK(&pAdapter->ipv4NotifierWorkQueue, hdd_ipv4_notifier_work_queue); |
| 6283 | |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 6284 | #ifdef WLAN_NS_OFFLOAD |
| 6285 | // Workqueue which gets scheduled in IPv6 notification callback. |
| 6286 | INIT_WORK(&pAdapter->ipv6NotifierWorkQueue, hdd_ipv6_notifier_work_queue); |
| 6287 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6288 | //Stop the Interface TX queue. |
| 6289 | netif_tx_disable(pAdapter->dev); |
| 6290 | //netif_tx_disable(pWlanDev); |
| 6291 | netif_carrier_off(pAdapter->dev); |
| 6292 | |
| 6293 | break; |
| 6294 | } |
| 6295 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6296 | case WLAN_HDD_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6297 | case WLAN_HDD_SOFTAP: |
| 6298 | { |
| 6299 | pAdapter = hdd_wlan_create_ap_dev( pHddCtx, macAddr, (tANI_U8 *)iface_name ); |
| 6300 | if( NULL == pAdapter ) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6301 | { |
| 6302 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 6303 | FL("failed to allocate adapter for session %d"), session_type); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6304 | return NULL; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6305 | } |
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->wdev.iftype = (session_type == WLAN_HDD_SOFTAP) ? |
| 6308 | NL80211_IFTYPE_AP: |
| 6309 | NL80211_IFTYPE_P2P_GO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6310 | pAdapter->device_mode = session_type; |
| 6311 | |
| 6312 | status = hdd_init_ap_mode(pAdapter); |
| 6313 | if( VOS_STATUS_SUCCESS != status ) |
| 6314 | goto err_free_netdev; |
| 6315 | |
| 6316 | status = hdd_register_hostapd( pAdapter, rtnl_held ); |
| 6317 | if( VOS_STATUS_SUCCESS != status ) |
| 6318 | { |
| 6319 | hdd_deinit_adapter(pHddCtx, pAdapter); |
| 6320 | goto err_free_netdev; |
| 6321 | } |
| 6322 | |
| 6323 | netif_tx_disable(pAdapter->dev); |
| 6324 | netif_carrier_off(pAdapter->dev); |
| 6325 | |
| 6326 | hdd_set_conparam( 1 ); |
| 6327 | break; |
| 6328 | } |
| 6329 | case WLAN_HDD_MONITOR: |
| 6330 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6331 | pAdapter = hdd_alloc_station_adapter( pHddCtx, macAddr, iface_name ); |
| 6332 | if( NULL == pAdapter ) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6333 | { |
| 6334 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 6335 | FL("failed to allocate adapter for session %d"), session_type); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6336 | return NULL; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6337 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6338 | |
| 6339 | pAdapter->wdev.iftype = NL80211_IFTYPE_MONITOR; |
| 6340 | pAdapter->device_mode = session_type; |
| 6341 | status = hdd_register_interface( pAdapter, rtnl_held ); |
| 6342 | #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29) |
| 6343 | pAdapter->dev->netdev_ops = &wlan_mon_drv_ops; |
| 6344 | #else |
| 6345 | pAdapter->dev->open = hdd_mon_open; |
| 6346 | pAdapter->dev->hard_start_xmit = hdd_mon_hard_start_xmit; |
| 6347 | #endif |
| 6348 | hdd_init_tx_rx( pAdapter ); |
| 6349 | set_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags); |
| 6350 | //Set adapter to be used for data tx. It will use either GO or softap. |
| 6351 | pAdapter->sessionCtx.monitor.pAdapterForTx = |
| 6352 | hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_SOFTAP); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6353 | if (NULL == pAdapter->sessionCtx.monitor.pAdapterForTx) |
| 6354 | { |
| 6355 | pAdapter->sessionCtx.monitor.pAdapterForTx = |
| 6356 | hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_P2P_GO); |
| 6357 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6358 | /* This workqueue will be used to transmit management packet over |
| 6359 | * monitor interface. */ |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 6360 | if (NULL == pAdapter->sessionCtx.monitor.pAdapterForTx) { |
| 6361 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s:Failed:hdd_get_adapter",__func__); |
| 6362 | return NULL; |
| 6363 | } |
Madan Mohan Koyyalamudi | 9f40ceb | 2012-10-18 19:22:56 -0700 | [diff] [blame] | 6364 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6365 | INIT_WORK(&pAdapter->sessionCtx.monitor.pAdapterForTx->monTxWorkQueue, |
| 6366 | hdd_mon_tx_work_queue); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6367 | } |
| 6368 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6369 | case WLAN_HDD_FTM: |
| 6370 | { |
| 6371 | pAdapter = hdd_alloc_station_adapter( pHddCtx, macAddr, iface_name ); |
| 6372 | |
| 6373 | if( NULL == pAdapter ) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6374 | { |
| 6375 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 6376 | FL("failed to allocate adapter for session %d"), session_type); |
| 6377 | return NULL; |
| 6378 | } |
| 6379 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6380 | /* Assign NL80211_IFTYPE_STATION as interface type to resolve Kernel Warning |
| 6381 | * message while loading driver in FTM mode. */ |
| 6382 | pAdapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 6383 | pAdapter->device_mode = session_type; |
| 6384 | status = hdd_register_interface( pAdapter, rtnl_held ); |
Madan Mohan Koyyalamudi | f89ac9f | 2013-09-19 16:58:12 +0530 | [diff] [blame] | 6385 | |
| 6386 | hdd_init_tx_rx( pAdapter ); |
| 6387 | |
| 6388 | //Stop the Interface TX queue. |
| 6389 | netif_tx_disable(pAdapter->dev); |
| 6390 | netif_carrier_off(pAdapter->dev); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6391 | } |
| 6392 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6393 | default: |
| 6394 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6395 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s Invalid session type %d", |
| 6396 | __func__, session_type); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6397 | VOS_ASSERT(0); |
| 6398 | return NULL; |
| 6399 | } |
| 6400 | } |
| 6401 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6402 | if( VOS_STATUS_SUCCESS == status ) |
| 6403 | { |
| 6404 | //Add it to the hdd's session list. |
| 6405 | pHddAdapterNode = vos_mem_malloc( sizeof( hdd_adapter_list_node_t ) ); |
| 6406 | if( NULL == pHddAdapterNode ) |
| 6407 | { |
| 6408 | status = VOS_STATUS_E_NOMEM; |
| 6409 | } |
| 6410 | else |
| 6411 | { |
| 6412 | pHddAdapterNode->pAdapter = pAdapter; |
| 6413 | status = hdd_add_adapter_back ( pHddCtx, |
| 6414 | pHddAdapterNode ); |
| 6415 | } |
| 6416 | } |
| 6417 | |
| 6418 | if( VOS_STATUS_SUCCESS != status ) |
| 6419 | { |
| 6420 | if( NULL != pAdapter ) |
| 6421 | { |
| 6422 | hdd_cleanup_adapter( pHddCtx, pAdapter, rtnl_held ); |
| 6423 | pAdapter = NULL; |
| 6424 | } |
| 6425 | if( NULL != pHddAdapterNode ) |
| 6426 | { |
| 6427 | vos_mem_free( pHddAdapterNode ); |
| 6428 | } |
| 6429 | |
| 6430 | goto resume_bmps; |
| 6431 | } |
| 6432 | |
| 6433 | if(VOS_STATUS_SUCCESS == status) |
| 6434 | { |
| 6435 | wlan_hdd_set_concurrency_mode(pHddCtx, session_type); |
| 6436 | |
Madan Mohan Koyyalamudi | 96dd30d | 2012-10-05 17:24:51 -0700 | [diff] [blame] | 6437 | //Initialize the WoWL service |
| 6438 | if(!hdd_init_wowl(pAdapter)) |
| 6439 | { |
| 6440 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hdd_init_wowl failed",__func__); |
| 6441 | goto err_free_netdev; |
| 6442 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6443 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6444 | return pAdapter; |
| 6445 | |
| 6446 | err_free_netdev: |
| 6447 | free_netdev(pAdapter->dev); |
| 6448 | wlan_hdd_release_intf_addr( pHddCtx, |
| 6449 | pAdapter->macAddressCurrent.bytes ); |
| 6450 | |
| 6451 | resume_bmps: |
| 6452 | //If bmps disabled enable it |
| 6453 | if(VOS_STATUS_SUCCESS == exitbmpsStatus) |
| 6454 | { |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 6455 | if (pHddCtx->hdd_wlan_suspended) |
| 6456 | { |
| 6457 | hdd_set_pwrparams(pHddCtx); |
| 6458 | } |
| 6459 | hdd_enable_bmps_imps(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6460 | } |
| 6461 | return NULL; |
| 6462 | } |
| 6463 | |
| 6464 | VOS_STATUS hdd_close_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter, |
| 6465 | tANI_U8 rtnl_held ) |
| 6466 | { |
| 6467 | hdd_adapter_list_node_t *pAdapterNode, *pCurrent, *pNext; |
| 6468 | VOS_STATUS status; |
| 6469 | |
| 6470 | status = hdd_get_front_adapter ( pHddCtx, &pCurrent ); |
| 6471 | if( VOS_STATUS_SUCCESS != status ) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6472 | { |
| 6473 | hddLog(VOS_TRACE_LEVEL_WARN,"%s: adapter list empty %d", |
| 6474 | __func__, status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6475 | return status; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6476 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6477 | |
| 6478 | while ( pCurrent->pAdapter != pAdapter ) |
| 6479 | { |
| 6480 | status = hdd_get_next_adapter ( pHddCtx, pCurrent, &pNext ); |
| 6481 | if( VOS_STATUS_SUCCESS != status ) |
| 6482 | break; |
| 6483 | |
| 6484 | pCurrent = pNext; |
| 6485 | } |
| 6486 | pAdapterNode = pCurrent; |
| 6487 | if( VOS_STATUS_SUCCESS == status ) |
| 6488 | { |
| 6489 | wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode); |
| 6490 | hdd_cleanup_adapter( pHddCtx, pAdapterNode->pAdapter, rtnl_held ); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 6491 | |
| 6492 | #ifdef FEATURE_WLAN_TDLS |
| 6493 | |
| 6494 | /* A Mutex Lock is introduced while changing/initializing the mode to |
| 6495 | * protect the concurrent access for the Adapters by TDLS module. |
| 6496 | */ |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 6497 | mutex_lock(&pHddCtx->tdls_lock); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 6498 | #endif |
| 6499 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6500 | hdd_remove_adapter( pHddCtx, pAdapterNode ); |
| 6501 | vos_mem_free( pAdapterNode ); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 6502 | pAdapterNode = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6503 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 6504 | #ifdef FEATURE_WLAN_TDLS |
| 6505 | mutex_unlock(&pHddCtx->tdls_lock); |
| 6506 | #endif |
| 6507 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6508 | |
| 6509 | /* If there is a single session of STA/P2P client, re-enable BMPS */ |
| 6510 | if ((!vos_concurrent_sessions_running()) && |
| 6511 | ((pHddCtx->no_of_sessions[VOS_STA_MODE] >= 1) || |
| 6512 | (pHddCtx->no_of_sessions[VOS_P2P_CLIENT_MODE] >= 1))) |
| 6513 | { |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 6514 | if (pHddCtx->hdd_wlan_suspended) |
| 6515 | { |
| 6516 | hdd_set_pwrparams(pHddCtx); |
| 6517 | } |
| 6518 | hdd_enable_bmps_imps(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6519 | } |
| 6520 | |
| 6521 | return VOS_STATUS_SUCCESS; |
| 6522 | } |
| 6523 | |
| 6524 | return VOS_STATUS_E_FAILURE; |
| 6525 | } |
| 6526 | |
| 6527 | VOS_STATUS hdd_close_all_adapters( hdd_context_t *pHddCtx ) |
| 6528 | { |
| 6529 | hdd_adapter_list_node_t *pHddAdapterNode; |
| 6530 | VOS_STATUS status; |
| 6531 | |
| 6532 | ENTER(); |
| 6533 | |
| 6534 | do |
| 6535 | { |
| 6536 | status = hdd_remove_front_adapter( pHddCtx, &pHddAdapterNode ); |
| 6537 | if( pHddAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 6538 | { |
| 6539 | hdd_cleanup_adapter( pHddCtx, pHddAdapterNode->pAdapter, FALSE ); |
| 6540 | vos_mem_free( pHddAdapterNode ); |
| 6541 | } |
| 6542 | }while( NULL != pHddAdapterNode && VOS_STATUS_E_EMPTY != status ); |
| 6543 | |
| 6544 | EXIT(); |
| 6545 | |
| 6546 | return VOS_STATUS_SUCCESS; |
| 6547 | } |
| 6548 | |
| 6549 | void wlan_hdd_reset_prob_rspies(hdd_adapter_t* pHostapdAdapter) |
| 6550 | { |
| 6551 | v_U8_t addIE[1] = {0}; |
| 6552 | |
| 6553 | if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 6554 | WNI_CFG_PROBE_RSP_ADDNIE_DATA1,(tANI_U8*)addIE, 0, NULL, |
| 6555 | eANI_BOOLEAN_FALSE) ) |
| 6556 | { |
| 6557 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6558 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6559 | } |
| 6560 | |
| 6561 | if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 6562 | WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL, |
| 6563 | eANI_BOOLEAN_FALSE) ) |
| 6564 | { |
| 6565 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6566 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6567 | } |
| 6568 | |
| 6569 | if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 6570 | WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL, |
| 6571 | eANI_BOOLEAN_FALSE) ) |
| 6572 | { |
| 6573 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6574 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6575 | } |
| 6576 | } |
| 6577 | |
| 6578 | VOS_STATUS hdd_stop_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter ) |
| 6579 | { |
| 6580 | eHalStatus halStatus = eHAL_STATUS_SUCCESS; |
| 6581 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 6582 | union iwreq_data wrqu; |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 6583 | v_U8_t retry = 0; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6584 | long ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6585 | |
| 6586 | ENTER(); |
| 6587 | |
| 6588 | switch(pAdapter->device_mode) |
| 6589 | { |
| 6590 | case WLAN_HDD_INFRA_STATION: |
| 6591 | case WLAN_HDD_P2P_CLIENT: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6592 | case WLAN_HDD_P2P_DEVICE: |
Vinay Krishna Eranna | b09d3e7 | 2014-03-26 21:23:55 +0530 | [diff] [blame] | 6593 | { |
| 6594 | hdd_station_ctx_t *pstation = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 6595 | if( hdd_connIsConnected(pstation) || |
| 6596 | (pstation->conn_info.connState == eConnectionState_Connecting) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6597 | { |
| 6598 | if (pWextState->roamProfile.BSSType == eCSR_BSS_TYPE_START_IBSS) |
| 6599 | halStatus = sme_RoamDisconnect(pHddCtx->hHal, |
| 6600 | pAdapter->sessionId, |
| 6601 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
| 6602 | else |
| 6603 | halStatus = sme_RoamDisconnect(pHddCtx->hHal, |
| 6604 | pAdapter->sessionId, |
| 6605 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
| 6606 | //success implies disconnect command got queued up successfully |
| 6607 | if(halStatus == eHAL_STATUS_SUCCESS) |
| 6608 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6609 | ret = wait_for_completion_interruptible_timeout( |
| 6610 | &pAdapter->disconnect_comp_var, |
| 6611 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 6612 | if (ret <= 0) |
| 6613 | { |
| 6614 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6615 | "%s: wait on disconnect_comp_var failed %ld", |
| 6616 | __func__, ret); |
| 6617 | } |
| 6618 | } |
| 6619 | else |
| 6620 | { |
| 6621 | hddLog(LOGE, "%s: failed to post disconnect event to SME", |
| 6622 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6623 | } |
| 6624 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 6625 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 6626 | memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN); |
| 6627 | wireless_send_event(pAdapter->dev, SIOCGIWAP, &wrqu, NULL); |
| 6628 | } |
Vinay Krishna Eranna | b09d3e7 | 2014-03-26 21:23:55 +0530 | [diff] [blame] | 6629 | else if(pstation->conn_info.connState == |
| 6630 | eConnectionState_Disconnecting) |
| 6631 | { |
| 6632 | ret = wait_for_completion_interruptible_timeout( |
| 6633 | &pAdapter->disconnect_comp_var, |
| 6634 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 6635 | if (ret <= 0) |
| 6636 | { |
| 6637 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6638 | FL("wait on disconnect_comp_var failed %ld"), ret); |
| 6639 | } |
| 6640 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6641 | else |
| 6642 | { |
Srinivas, Dasari | 138af4f | 2014-02-07 11:13:45 +0530 | [diff] [blame] | 6643 | hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId, |
| 6644 | eCSR_SCAN_ABORT_DEFAULT); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6645 | } |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 6646 | if (pAdapter->device_mode != WLAN_HDD_INFRA_STATION) |
| 6647 | { |
| 6648 | while (pAdapter->is_roc_inprogress) |
| 6649 | { |
| 6650 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6651 | "%s: ROC in progress for session %d!!!", |
| 6652 | __func__, pAdapter->sessionId); |
| 6653 | // waiting for ROC to expire |
| 6654 | msleep(500); |
| 6655 | /* In GO present case , if retry exceeds 3, |
| 6656 | it means something went wrong. */ |
| 6657 | if ( retry++ > MAX_WAIT_FOR_ROC_COMPLETION ) |
| 6658 | { |
| 6659 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6660 | "%s: ROC completion is not received.!!!", __func__); |
| 6661 | sme_CancelRemainOnChannel(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 6662 | pAdapter->sessionId); |
| 6663 | wait_for_completion_interruptible_timeout( |
| 6664 | &pAdapter->cancel_rem_on_chan_var, |
| 6665 | msecs_to_jiffies(WAIT_CANCEL_REM_CHAN)); |
| 6666 | break; |
| 6667 | } |
| 6668 | } |
| 6669 | } |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 6670 | #ifdef WLAN_NS_OFFLOAD |
Vinay Krishna Eranna | 941360f | 2014-01-16 15:38:22 +0530 | [diff] [blame] | 6671 | #ifdef WLAN_OPEN_SOURCE |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 6672 | cancel_work_sync(&pAdapter->ipv6NotifierWorkQueue); |
| 6673 | #endif |
Vinay Krishna Eranna | 941360f | 2014-01-16 15:38:22 +0530 | [diff] [blame] | 6674 | if (pAdapter->ipv6_notifier_registered) |
| 6675 | { |
| 6676 | hddLog(LOG1, FL("Unregistered IPv6 notifier")); |
| 6677 | unregister_inet6addr_notifier(&pAdapter->ipv6_notifier); |
| 6678 | pAdapter->ipv6_notifier_registered = false; |
| 6679 | } |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 6680 | #endif |
Vinay Krishna Eranna | d9cbdb3 | 2014-01-16 12:59:10 +0530 | [diff] [blame] | 6681 | if (pAdapter->ipv4_notifier_registered) |
| 6682 | { |
| 6683 | hddLog(LOG1, FL("Unregistered IPv4 notifier")); |
| 6684 | unregister_inetaddr_notifier(&pAdapter->ipv4_notifier); |
| 6685 | pAdapter->ipv4_notifier_registered = false; |
| 6686 | } |
Vinay Krishna Eranna | 4d055d4 | 2013-12-17 17:02:01 +0530 | [diff] [blame] | 6687 | #ifdef WLAN_OPEN_SOURCE |
| 6688 | cancel_work_sync(&pAdapter->ipv4NotifierWorkQueue); |
| 6689 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6690 | if (test_bit(SME_SESSION_OPENED, &pAdapter->event_flags)) |
| 6691 | { |
| 6692 | INIT_COMPLETION(pAdapter->session_close_comp_var); |
| 6693 | if (eHAL_STATUS_SUCCESS == |
| 6694 | sme_CloseSession(pHddCtx->hHal, pAdapter->sessionId, |
| 6695 | hdd_smeCloseSessionCallback, pAdapter)) |
| 6696 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6697 | unsigned long ret; |
| 6698 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6699 | //Block on a completion variable. Can't wait forever though. |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6700 | ret = wait_for_completion_timeout( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6701 | &pAdapter->session_close_comp_var, |
| 6702 | msecs_to_jiffies(WLAN_WAIT_TIME_SESSIONOPENCLOSE)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6703 | if ( 0 >= ret) |
| 6704 | { |
| 6705 | hddLog(LOGE, "%s: failure waiting for session_close_comp_var %ld", |
| 6706 | __func__, ret); |
| 6707 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6708 | } |
| 6709 | } |
Vinay Krishna Eranna | b09d3e7 | 2014-03-26 21:23:55 +0530 | [diff] [blame] | 6710 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6711 | break; |
| 6712 | |
| 6713 | case WLAN_HDD_SOFTAP: |
| 6714 | case WLAN_HDD_P2P_GO: |
| 6715 | //Any softap specific cleanup here... |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 6716 | if (pAdapter->device_mode == WLAN_HDD_P2P_GO) { |
| 6717 | while (pAdapter->is_roc_inprogress) { |
| 6718 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6719 | "%s: ROC in progress for session %d!!!", |
| 6720 | __func__, pAdapter->sessionId); |
| 6721 | msleep(500); |
| 6722 | if ( retry++ > MAX_WAIT_FOR_ROC_COMPLETION ) { |
| 6723 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6724 | "%s: ROC completion is not received.!!!", __func__); |
| 6725 | WLANSAP_CancelRemainOnChannel( |
| 6726 | (WLAN_HDD_GET_CTX(pAdapter))->pvosContext); |
| 6727 | wait_for_completion_interruptible_timeout( |
| 6728 | &pAdapter->cancel_rem_on_chan_var, |
| 6729 | msecs_to_jiffies(WAIT_CANCEL_REM_CHAN)); |
| 6730 | break; |
| 6731 | } |
| 6732 | } |
| 6733 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6734 | mutex_lock(&pHddCtx->sap_lock); |
| 6735 | if (test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags)) |
| 6736 | { |
| 6737 | VOS_STATUS status; |
| 6738 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 6739 | |
| 6740 | //Stop Bss. |
| 6741 | status = WLANSAP_StopBss(pHddCtx->pvosContext); |
| 6742 | if (VOS_IS_STATUS_SUCCESS(status)) |
| 6743 | { |
| 6744 | hdd_hostapd_state_t *pHostapdState = |
| 6745 | WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 6746 | |
| 6747 | status = vos_wait_single_event(&pHostapdState->vosEvent, 10000); |
| 6748 | |
| 6749 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 6750 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6751 | hddLog(LOGE, "%s: failure waiting for WLANSAP_StopBss %d", |
| 6752 | __func__, status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6753 | } |
| 6754 | } |
| 6755 | else |
| 6756 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 6757 | hddLog(LOGE, "%s: failure in WLANSAP_StopBss", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6758 | } |
| 6759 | clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags); |
| 6760 | |
| 6761 | if (eHAL_STATUS_FAILURE == |
| 6762 | ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, |
| 6763 | 0, NULL, eANI_BOOLEAN_FALSE)) |
| 6764 | { |
| 6765 | hddLog(LOGE, |
| 6766 | "%s: Failed to set WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 6767 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6768 | } |
| 6769 | |
| 6770 | if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal, |
| 6771 | WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL, |
| 6772 | eANI_BOOLEAN_FALSE) ) |
| 6773 | { |
| 6774 | hddLog(LOGE, |
| 6775 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM"); |
| 6776 | } |
| 6777 | |
| 6778 | // Reset WNI_CFG_PROBE_RSP Flags |
| 6779 | wlan_hdd_reset_prob_rspies(pAdapter); |
| 6780 | kfree(pAdapter->sessionCtx.ap.beacon); |
| 6781 | pAdapter->sessionCtx.ap.beacon = NULL; |
| 6782 | } |
| 6783 | mutex_unlock(&pHddCtx->sap_lock); |
| 6784 | break; |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 6785 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6786 | case WLAN_HDD_MONITOR: |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 6787 | #ifdef WLAN_OPEN_SOURCE |
| 6788 | cancel_work_sync(&pAdapter->sessionCtx.monitor.pAdapterForTx->monTxWorkQueue); |
| 6789 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6790 | break; |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 6791 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6792 | default: |
| 6793 | break; |
| 6794 | } |
| 6795 | |
| 6796 | EXIT(); |
| 6797 | return VOS_STATUS_SUCCESS; |
| 6798 | } |
| 6799 | |
| 6800 | VOS_STATUS hdd_stop_all_adapters( hdd_context_t *pHddCtx ) |
| 6801 | { |
| 6802 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 6803 | VOS_STATUS status; |
| 6804 | hdd_adapter_t *pAdapter; |
| 6805 | |
| 6806 | ENTER(); |
| 6807 | |
| 6808 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 6809 | |
| 6810 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 6811 | { |
| 6812 | pAdapter = pAdapterNode->pAdapter; |
| 6813 | netif_tx_disable(pAdapter->dev); |
| 6814 | netif_carrier_off(pAdapter->dev); |
| 6815 | |
| 6816 | hdd_stop_adapter( pHddCtx, pAdapter ); |
| 6817 | |
| 6818 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 6819 | pAdapterNode = pNext; |
| 6820 | } |
| 6821 | |
| 6822 | EXIT(); |
| 6823 | |
| 6824 | return VOS_STATUS_SUCCESS; |
| 6825 | } |
| 6826 | |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 6827 | |
| 6828 | #ifdef FEATURE_WLAN_BATCH_SCAN |
| 6829 | /**--------------------------------------------------------------------------- |
| 6830 | |
| 6831 | \brief hdd_deinit_batch_scan () - This function cleans up batch scan data |
| 6832 | structures |
| 6833 | |
| 6834 | \param - pAdapter Pointer to HDD adapter |
| 6835 | |
| 6836 | \return - None |
| 6837 | |
| 6838 | --------------------------------------------------------------------------*/ |
| 6839 | void hdd_deinit_batch_scan(hdd_adapter_t *pAdapter) |
| 6840 | { |
| 6841 | tHddBatchScanRsp *pNode; |
| 6842 | tHddBatchScanRsp *pPrev; |
| 6843 | |
Siddharth Bhal | b3e9b79 | 2014-02-24 15:14:16 +0530 | [diff] [blame] | 6844 | if (NULL == pAdapter) |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 6845 | { |
Siddharth Bhal | b3e9b79 | 2014-02-24 15:14:16 +0530 | [diff] [blame] | 6846 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6847 | "%s: Adapter context is Null", __func__); |
| 6848 | return; |
| 6849 | } |
| 6850 | |
| 6851 | pNode = pAdapter->pBatchScanRsp; |
| 6852 | while (pNode) |
| 6853 | { |
| 6854 | pPrev = pNode; |
| 6855 | pNode = pNode->pNext; |
| 6856 | vos_mem_free((v_VOID_t * )pPrev); |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 6857 | } |
| 6858 | |
| 6859 | pAdapter->pBatchScanRsp = NULL; |
| 6860 | pAdapter->numScanList = 0; |
| 6861 | pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STOPPED; |
| 6862 | pAdapter->prev_batch_id = 0; |
| 6863 | |
| 6864 | return; |
| 6865 | } |
| 6866 | #endif |
| 6867 | |
| 6868 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6869 | VOS_STATUS hdd_reset_all_adapters( hdd_context_t *pHddCtx ) |
| 6870 | { |
| 6871 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 6872 | VOS_STATUS status; |
| 6873 | hdd_adapter_t *pAdapter; |
| 6874 | |
| 6875 | ENTER(); |
| 6876 | |
| 6877 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 6878 | |
| 6879 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 6880 | { |
| 6881 | pAdapter = pAdapterNode->pAdapter; |
| 6882 | netif_tx_disable(pAdapter->dev); |
| 6883 | netif_carrier_off(pAdapter->dev); |
| 6884 | |
Srinivas Girigowda | 66c05eb | 2013-07-14 13:06:01 -0700 | [diff] [blame] | 6885 | pAdapter->sessionCtx.station.hdd_ReassocScenario = VOS_FALSE; |
| 6886 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6887 | hdd_deinit_tx_rx(pAdapter); |
Madan Mohan Koyyalamudi | 8c6dec8 | 2013-09-26 15:56:13 +0530 | [diff] [blame] | 6888 | if (test_bit(WMM_INIT_DONE, &pAdapter->event_flags)) |
| 6889 | { |
| 6890 | hdd_wmm_adapter_close( pAdapter ); |
| 6891 | clear_bit(WMM_INIT_DONE, &pAdapter->event_flags); |
| 6892 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6893 | |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 6894 | #ifdef FEATURE_WLAN_BATCH_SCAN |
| 6895 | if (eHDD_BATCH_SCAN_STATE_STARTED == pAdapter->batchScanState) |
| 6896 | { |
| 6897 | hdd_deinit_batch_scan(pAdapter); |
| 6898 | } |
| 6899 | #endif |
| 6900 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6901 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 6902 | pAdapterNode = pNext; |
| 6903 | } |
| 6904 | |
| 6905 | EXIT(); |
| 6906 | |
| 6907 | return VOS_STATUS_SUCCESS; |
| 6908 | } |
| 6909 | |
| 6910 | VOS_STATUS hdd_start_all_adapters( hdd_context_t *pHddCtx ) |
| 6911 | { |
| 6912 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 6913 | VOS_STATUS status; |
| 6914 | hdd_adapter_t *pAdapter; |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 6915 | eConnectionState connState; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6916 | |
| 6917 | ENTER(); |
| 6918 | |
| 6919 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 6920 | |
| 6921 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 6922 | { |
| 6923 | pAdapter = pAdapterNode->pAdapter; |
| 6924 | |
| 6925 | switch(pAdapter->device_mode) |
| 6926 | { |
| 6927 | case WLAN_HDD_INFRA_STATION: |
| 6928 | case WLAN_HDD_P2P_CLIENT: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6929 | case WLAN_HDD_P2P_DEVICE: |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 6930 | |
| 6931 | connState = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState; |
| 6932 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6933 | hdd_init_station_mode(pAdapter); |
| 6934 | /* Open the gates for HDD to receive Wext commands */ |
| 6935 | pAdapter->isLinkUpSvcNeeded = FALSE; |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 6936 | pHddCtx->scan_info.mScanPending = FALSE; |
| 6937 | pHddCtx->scan_info.waitScanResult = FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6938 | |
| 6939 | //Trigger the initial scan |
| 6940 | hdd_wlan_initial_scan(pAdapter); |
| 6941 | |
| 6942 | //Indicate disconnect event to supplicant if associated previously |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 6943 | if (eConnectionState_Associated == connState || |
| 6944 | eConnectionState_IbssConnected == connState ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6945 | { |
| 6946 | union iwreq_data wrqu; |
| 6947 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 6948 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 6949 | memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN); |
| 6950 | wireless_send_event(pAdapter->dev, SIOCGIWAP, &wrqu, NULL); |
Srinivas Girigowda | 66c05eb | 2013-07-14 13:06:01 -0700 | [diff] [blame] | 6951 | pAdapter->sessionCtx.station.hdd_ReassocScenario = VOS_FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6952 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6953 | /* indicate disconnected event to nl80211 */ |
| 6954 | cfg80211_disconnected(pAdapter->dev, WLAN_REASON_UNSPECIFIED, |
| 6955 | NULL, 0, GFP_KERNEL); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6956 | } |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 6957 | else if (eConnectionState_Connecting == connState) |
| 6958 | { |
| 6959 | /* |
| 6960 | * Indicate connect failure to supplicant if we were in the |
| 6961 | * process of connecting |
| 6962 | */ |
| 6963 | cfg80211_connect_result(pAdapter->dev, NULL, |
| 6964 | NULL, 0, NULL, 0, |
| 6965 | WLAN_STATUS_ASSOC_DENIED_UNSPEC, |
| 6966 | GFP_KERNEL); |
| 6967 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6968 | break; |
| 6969 | |
| 6970 | case WLAN_HDD_SOFTAP: |
| 6971 | /* softAP can handle SSR */ |
| 6972 | break; |
| 6973 | |
| 6974 | case WLAN_HDD_P2P_GO: |
Sameer Thalappil | edf0d79 | 2013-08-09 14:31:03 -0700 | [diff] [blame] | 6975 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s [SSR] send stop ap to supplicant", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6976 | __func__); |
Sameer Thalappil | edf0d79 | 2013-08-09 14:31:03 -0700 | [diff] [blame] | 6977 | cfg80211_ap_stopped(pAdapter->dev, GFP_KERNEL); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6978 | break; |
| 6979 | |
| 6980 | case WLAN_HDD_MONITOR: |
| 6981 | /* monitor interface start */ |
| 6982 | break; |
| 6983 | default: |
| 6984 | break; |
| 6985 | } |
| 6986 | |
| 6987 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 6988 | pAdapterNode = pNext; |
| 6989 | } |
| 6990 | |
| 6991 | EXIT(); |
| 6992 | |
| 6993 | return VOS_STATUS_SUCCESS; |
| 6994 | } |
| 6995 | |
| 6996 | VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx ) |
| 6997 | { |
| 6998 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 6999 | hdd_adapter_t *pAdapter; |
| 7000 | VOS_STATUS status; |
| 7001 | v_U32_t roamId; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7002 | long ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7003 | |
| 7004 | ENTER(); |
| 7005 | |
| 7006 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7007 | |
| 7008 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7009 | { |
| 7010 | pAdapter = pAdapterNode->pAdapter; |
| 7011 | |
| 7012 | if( (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
| 7013 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ) |
| 7014 | { |
| 7015 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 7016 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 7017 | |
Abhishek Singh | f4669da | 2014-05-26 15:07:49 +0530 | [diff] [blame] | 7018 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 7019 | "%s: Set HDD connState to eConnectionState_NotConnected", |
| 7020 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7021 | pHddStaCtx->conn_info.connState = eConnectionState_NotConnected; |
| 7022 | init_completion(&pAdapter->disconnect_comp_var); |
| 7023 | sme_RoamDisconnect(pHddCtx->hHal, pAdapter->sessionId, |
| 7024 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
| 7025 | |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7026 | ret = wait_for_completion_interruptible_timeout( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7027 | &pAdapter->disconnect_comp_var, |
| 7028 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7029 | if (0 >= ret) |
| 7030 | hddLog(LOGE, "%s: failure waiting for disconnect_comp_var %ld", |
| 7031 | __func__, ret); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7032 | |
| 7033 | pWextState->roamProfile.csrPersona = pAdapter->device_mode; |
| 7034 | pHddCtx->isAmpAllowed = VOS_FALSE; |
| 7035 | sme_RoamConnect(pHddCtx->hHal, |
| 7036 | pAdapter->sessionId, &(pWextState->roamProfile), |
| 7037 | &roamId); |
| 7038 | } |
| 7039 | |
| 7040 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7041 | pAdapterNode = pNext; |
| 7042 | } |
| 7043 | |
| 7044 | EXIT(); |
| 7045 | |
| 7046 | return VOS_STATUS_SUCCESS; |
| 7047 | } |
| 7048 | |
Sudhir Sattayappa Kohalli | 90e4c75 | 2013-03-21 14:25:04 -0700 | [diff] [blame] | 7049 | void hdd_dump_concurrency_info(hdd_context_t *pHddCtx) |
| 7050 | { |
| 7051 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7052 | VOS_STATUS status; |
| 7053 | hdd_adapter_t *pAdapter; |
| 7054 | hdd_station_ctx_t *pHddStaCtx; |
| 7055 | hdd_ap_ctx_t *pHddApCtx; |
| 7056 | hdd_hostapd_state_t * pHostapdState; |
| 7057 | tCsrBssid staBssid = { 0 }, p2pBssid = { 0 }, apBssid = { 0 }; |
| 7058 | v_U8_t staChannel = 0, p2pChannel = 0, apChannel = 0; |
| 7059 | const char *p2pMode = "DEV"; |
| 7060 | const char *ccMode = "Standalone"; |
| 7061 | int n; |
| 7062 | |
| 7063 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7064 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7065 | { |
| 7066 | pAdapter = pAdapterNode->pAdapter; |
| 7067 | switch (pAdapter->device_mode) { |
| 7068 | case WLAN_HDD_INFRA_STATION: |
| 7069 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 7070 | if (eConnectionState_Associated == pHddStaCtx->conn_info.connState) { |
| 7071 | staChannel = pHddStaCtx->conn_info.operationChannel; |
| 7072 | memcpy(staBssid, pHddStaCtx->conn_info.bssId, sizeof(staBssid)); |
| 7073 | } |
| 7074 | break; |
| 7075 | case WLAN_HDD_P2P_CLIENT: |
| 7076 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 7077 | if (eConnectionState_Associated == pHddStaCtx->conn_info.connState) { |
| 7078 | p2pChannel = pHddStaCtx->conn_info.operationChannel; |
| 7079 | memcpy(p2pBssid, pHddStaCtx->conn_info.bssId, sizeof(p2pBssid)); |
| 7080 | p2pMode = "CLI"; |
| 7081 | } |
| 7082 | break; |
| 7083 | case WLAN_HDD_P2P_GO: |
| 7084 | pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
| 7085 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 7086 | if (pHostapdState->bssState == BSS_START && pHostapdState->vosStatus==VOS_STATUS_SUCCESS) { |
| 7087 | p2pChannel = pHddApCtx->operatingChannel; |
| 7088 | memcpy(p2pBssid, pAdapter->macAddressCurrent.bytes, sizeof(p2pBssid)); |
| 7089 | } |
| 7090 | p2pMode = "GO"; |
| 7091 | break; |
| 7092 | case WLAN_HDD_SOFTAP: |
| 7093 | pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
| 7094 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 7095 | if (pHostapdState->bssState == BSS_START && pHostapdState->vosStatus==VOS_STATUS_SUCCESS) { |
| 7096 | apChannel = pHddApCtx->operatingChannel; |
| 7097 | memcpy(apBssid, pAdapter->macAddressCurrent.bytes, sizeof(apBssid)); |
| 7098 | } |
| 7099 | break; |
| 7100 | default: |
| 7101 | break; |
| 7102 | } |
| 7103 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7104 | pAdapterNode = pNext; |
| 7105 | } |
| 7106 | if (staChannel > 0 && (apChannel > 0 || p2pChannel > 0)) { |
| 7107 | ccMode = (p2pChannel==staChannel||apChannel==staChannel) ? "SCC" : "MCC"; |
| 7108 | } |
| 7109 | n = pr_info("wlan(%d) " MAC_ADDRESS_STR " %s", |
| 7110 | staChannel, MAC_ADDR_ARRAY(staBssid), ccMode); |
| 7111 | if (p2pChannel > 0) { |
| 7112 | n += pr_info("p2p-%s(%d) " MAC_ADDRESS_STR, |
| 7113 | p2pMode, p2pChannel, MAC_ADDR_ARRAY(p2pBssid)); |
| 7114 | } |
| 7115 | if (apChannel > 0) { |
| 7116 | n += pr_info("AP(%d) " MAC_ADDRESS_STR, |
| 7117 | apChannel, MAC_ADDR_ARRAY(apBssid)); |
| 7118 | } |
| 7119 | |
| 7120 | if (p2pChannel > 0 && apChannel > 0) { |
| 7121 | hddLog(VOS_TRACE_LEVEL_ERROR, "Error concurrent SAP %d and P2P %d which is not support", apChannel, p2pChannel); |
| 7122 | } |
| 7123 | } |
| 7124 | |
Madan Mohan Koyyalamudi | b5da533 | 2012-10-15 17:23:21 -0700 | [diff] [blame] | 7125 | bool hdd_is_ssr_required( void) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7126 | { |
Madan Mohan Koyyalamudi | b5da533 | 2012-10-15 17:23:21 -0700 | [diff] [blame] | 7127 | return (isSsrRequired == HDD_SSR_REQUIRED); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7128 | } |
| 7129 | |
Madan Mohan Koyyalamudi | b5da533 | 2012-10-15 17:23:21 -0700 | [diff] [blame] | 7130 | /* Once SSR is disabled then it cannot be set. */ |
| 7131 | void hdd_set_ssr_required( e_hdd_ssr_required value) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7132 | { |
Madan Mohan Koyyalamudi | b5da533 | 2012-10-15 17:23:21 -0700 | [diff] [blame] | 7133 | if (HDD_SSR_DISABLED == isSsrRequired) |
| 7134 | return; |
| 7135 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7136 | isSsrRequired = value; |
| 7137 | } |
| 7138 | |
| 7139 | VOS_STATUS hdd_get_front_adapter( hdd_context_t *pHddCtx, |
| 7140 | hdd_adapter_list_node_t** ppAdapterNode) |
| 7141 | { |
| 7142 | VOS_STATUS status; |
| 7143 | spin_lock(&pHddCtx->hddAdapters.lock); |
| 7144 | status = hdd_list_peek_front ( &pHddCtx->hddAdapters, |
| 7145 | (hdd_list_node_t**) ppAdapterNode ); |
| 7146 | spin_unlock(&pHddCtx->hddAdapters.lock); |
| 7147 | return status; |
| 7148 | } |
| 7149 | |
| 7150 | VOS_STATUS hdd_get_next_adapter( hdd_context_t *pHddCtx, |
| 7151 | hdd_adapter_list_node_t* pAdapterNode, |
| 7152 | hdd_adapter_list_node_t** pNextAdapterNode) |
| 7153 | { |
| 7154 | VOS_STATUS status; |
| 7155 | spin_lock(&pHddCtx->hddAdapters.lock); |
| 7156 | status = hdd_list_peek_next ( &pHddCtx->hddAdapters, |
| 7157 | (hdd_list_node_t*) pAdapterNode, |
| 7158 | (hdd_list_node_t**)pNextAdapterNode ); |
| 7159 | |
| 7160 | spin_unlock(&pHddCtx->hddAdapters.lock); |
| 7161 | return status; |
| 7162 | } |
| 7163 | |
| 7164 | VOS_STATUS hdd_remove_adapter( hdd_context_t *pHddCtx, |
| 7165 | hdd_adapter_list_node_t* pAdapterNode) |
| 7166 | { |
| 7167 | VOS_STATUS status; |
| 7168 | spin_lock(&pHddCtx->hddAdapters.lock); |
| 7169 | status = hdd_list_remove_node ( &pHddCtx->hddAdapters, |
| 7170 | &pAdapterNode->node ); |
| 7171 | spin_unlock(&pHddCtx->hddAdapters.lock); |
| 7172 | return status; |
| 7173 | } |
| 7174 | |
| 7175 | VOS_STATUS hdd_remove_front_adapter( hdd_context_t *pHddCtx, |
| 7176 | hdd_adapter_list_node_t** ppAdapterNode) |
| 7177 | { |
| 7178 | VOS_STATUS status; |
| 7179 | spin_lock(&pHddCtx->hddAdapters.lock); |
| 7180 | status = hdd_list_remove_front( &pHddCtx->hddAdapters, |
| 7181 | (hdd_list_node_t**) ppAdapterNode ); |
| 7182 | spin_unlock(&pHddCtx->hddAdapters.lock); |
| 7183 | return status; |
| 7184 | } |
| 7185 | |
| 7186 | VOS_STATUS hdd_add_adapter_back( hdd_context_t *pHddCtx, |
| 7187 | hdd_adapter_list_node_t* pAdapterNode) |
| 7188 | { |
| 7189 | VOS_STATUS status; |
| 7190 | spin_lock(&pHddCtx->hddAdapters.lock); |
| 7191 | status = hdd_list_insert_back ( &pHddCtx->hddAdapters, |
| 7192 | (hdd_list_node_t*) pAdapterNode ); |
| 7193 | spin_unlock(&pHddCtx->hddAdapters.lock); |
| 7194 | return status; |
| 7195 | } |
| 7196 | |
| 7197 | VOS_STATUS hdd_add_adapter_front( hdd_context_t *pHddCtx, |
| 7198 | hdd_adapter_list_node_t* pAdapterNode) |
| 7199 | { |
| 7200 | VOS_STATUS status; |
| 7201 | spin_lock(&pHddCtx->hddAdapters.lock); |
| 7202 | status = hdd_list_insert_front ( &pHddCtx->hddAdapters, |
| 7203 | (hdd_list_node_t*) pAdapterNode ); |
| 7204 | spin_unlock(&pHddCtx->hddAdapters.lock); |
| 7205 | return status; |
| 7206 | } |
| 7207 | |
| 7208 | hdd_adapter_t * hdd_get_adapter_by_macaddr( hdd_context_t *pHddCtx, |
| 7209 | tSirMacAddr macAddr ) |
| 7210 | { |
| 7211 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7212 | hdd_adapter_t *pAdapter; |
| 7213 | VOS_STATUS status; |
| 7214 | |
| 7215 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7216 | |
| 7217 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7218 | { |
| 7219 | pAdapter = pAdapterNode->pAdapter; |
| 7220 | |
| 7221 | if( pAdapter && vos_mem_compare( pAdapter->macAddressCurrent.bytes, |
| 7222 | macAddr, sizeof(tSirMacAddr) ) ) |
| 7223 | { |
| 7224 | return pAdapter; |
| 7225 | } |
| 7226 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7227 | pAdapterNode = pNext; |
| 7228 | } |
| 7229 | |
| 7230 | return NULL; |
| 7231 | |
| 7232 | } |
| 7233 | |
| 7234 | hdd_adapter_t * hdd_get_adapter_by_name( hdd_context_t *pHddCtx, tANI_U8 *name ) |
| 7235 | { |
| 7236 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7237 | hdd_adapter_t *pAdapter; |
| 7238 | VOS_STATUS status; |
| 7239 | |
| 7240 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7241 | |
| 7242 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7243 | { |
| 7244 | pAdapter = pAdapterNode->pAdapter; |
| 7245 | |
| 7246 | if( pAdapter && !strncmp( pAdapter->dev->name, (const char *)name, |
| 7247 | IFNAMSIZ ) ) |
| 7248 | { |
| 7249 | return pAdapter; |
| 7250 | } |
| 7251 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7252 | pAdapterNode = pNext; |
| 7253 | } |
| 7254 | |
| 7255 | return NULL; |
| 7256 | |
| 7257 | } |
| 7258 | |
| 7259 | hdd_adapter_t * hdd_get_adapter( hdd_context_t *pHddCtx, device_mode_t mode ) |
| 7260 | { |
| 7261 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7262 | hdd_adapter_t *pAdapter; |
| 7263 | VOS_STATUS status; |
| 7264 | |
| 7265 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7266 | |
| 7267 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7268 | { |
| 7269 | pAdapter = pAdapterNode->pAdapter; |
| 7270 | |
| 7271 | if( pAdapter && (mode == pAdapter->device_mode) ) |
| 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 | //Remove this function later |
| 7284 | hdd_adapter_t * hdd_get_mon_adapter( hdd_context_t *pHddCtx ) |
| 7285 | { |
| 7286 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7287 | hdd_adapter_t *pAdapter; |
| 7288 | VOS_STATUS status; |
| 7289 | |
| 7290 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7291 | |
| 7292 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7293 | { |
| 7294 | pAdapter = pAdapterNode->pAdapter; |
| 7295 | |
| 7296 | if( pAdapter && WLAN_HDD_MONITOR == pAdapter->device_mode ) |
| 7297 | { |
| 7298 | return pAdapter; |
| 7299 | } |
| 7300 | |
| 7301 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7302 | pAdapterNode = pNext; |
| 7303 | } |
| 7304 | |
| 7305 | return NULL; |
| 7306 | |
| 7307 | } |
| 7308 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7309 | /**--------------------------------------------------------------------------- |
| 7310 | |
| 7311 | \brief hdd_set_monitor_tx_adapter() - |
| 7312 | |
| 7313 | This API initializes the adapter to be used while transmitting on monitor |
| 7314 | adapter. |
| 7315 | |
| 7316 | \param - pHddCtx - Pointer to the HDD context. |
| 7317 | pAdapter - Adapter that will used for TX. This can be NULL. |
| 7318 | \return - None. |
| 7319 | --------------------------------------------------------------------------*/ |
| 7320 | void wlan_hdd_set_monitor_tx_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter ) |
| 7321 | { |
| 7322 | hdd_adapter_t *pMonAdapter; |
| 7323 | |
| 7324 | pMonAdapter = hdd_get_adapter( pHddCtx, WLAN_HDD_MONITOR ); |
| 7325 | |
| 7326 | if( NULL != pMonAdapter ) |
| 7327 | { |
| 7328 | pMonAdapter->sessionCtx.monitor.pAdapterForTx = pAdapter; |
| 7329 | } |
| 7330 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7331 | /**--------------------------------------------------------------------------- |
| 7332 | |
| 7333 | \brief hdd_select_queue() - |
| 7334 | |
| 7335 | This API returns the operating channel of the requested device mode |
| 7336 | |
| 7337 | \param - pHddCtx - Pointer to the HDD context. |
| 7338 | - mode - Device mode for which operating channel is required |
| 7339 | suported modes - WLAN_HDD_INFRA_STATION, WLAN_HDD_P2P_CLIENT |
| 7340 | WLAN_HDD_SOFTAP, WLAN_HDD_P2P_GO. |
| 7341 | \return - channel number. "0" id the requested device is not found OR it is not connected. |
| 7342 | --------------------------------------------------------------------------*/ |
| 7343 | v_U8_t hdd_get_operating_channel( hdd_context_t *pHddCtx, device_mode_t mode ) |
| 7344 | { |
| 7345 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7346 | VOS_STATUS status; |
| 7347 | hdd_adapter_t *pAdapter; |
| 7348 | v_U8_t operatingChannel = 0; |
| 7349 | |
| 7350 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7351 | |
| 7352 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7353 | { |
| 7354 | pAdapter = pAdapterNode->pAdapter; |
| 7355 | |
| 7356 | if( mode == pAdapter->device_mode ) |
| 7357 | { |
| 7358 | switch(pAdapter->device_mode) |
| 7359 | { |
| 7360 | case WLAN_HDD_INFRA_STATION: |
| 7361 | case WLAN_HDD_P2P_CLIENT: |
| 7362 | if( hdd_connIsConnected( WLAN_HDD_GET_STATION_CTX_PTR( pAdapter )) ) |
| 7363 | operatingChannel = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.operationChannel; |
| 7364 | break; |
| 7365 | case WLAN_HDD_SOFTAP: |
| 7366 | case WLAN_HDD_P2P_GO: |
| 7367 | /*softap connection info */ |
| 7368 | if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags)) |
| 7369 | operatingChannel = (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->operatingChannel; |
| 7370 | break; |
| 7371 | default: |
| 7372 | break; |
| 7373 | } |
| 7374 | |
| 7375 | break; //Found the device of interest. break the loop |
| 7376 | } |
| 7377 | |
| 7378 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7379 | pAdapterNode = pNext; |
| 7380 | } |
| 7381 | return operatingChannel; |
| 7382 | } |
| 7383 | |
| 7384 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 7385 | /**--------------------------------------------------------------------------- |
| 7386 | |
| 7387 | \brief hdd_set_multicast_list() - |
| 7388 | |
| 7389 | This used to set the multicast address list. |
| 7390 | |
| 7391 | \param - dev - Pointer to the WLAN device. |
| 7392 | - skb - Pointer to OS packet (sk_buff). |
| 7393 | \return - success/fail |
| 7394 | |
| 7395 | --------------------------------------------------------------------------*/ |
| 7396 | static void hdd_set_multicast_list(struct net_device *dev) |
| 7397 | { |
| 7398 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7399 | int mc_count; |
| 7400 | int i = 0; |
| 7401 | struct netdev_hw_addr *ha; |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 7402 | |
| 7403 | if (NULL == pAdapter) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7404 | { |
| 7405 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 7406 | "%s: Adapter context is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7407 | return; |
| 7408 | } |
| 7409 | |
| 7410 | if (dev->flags & IFF_ALLMULTI) |
| 7411 | { |
| 7412 | hddLog(VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7413 | "%s: allow all multicast frames", __func__); |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 7414 | pAdapter->mc_addr_list.mc_cnt = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7415 | } |
| 7416 | else |
| 7417 | { |
| 7418 | mc_count = netdev_mc_count(dev); |
| 7419 | hddLog(VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7420 | "%s: mc_count = %u", __func__, mc_count); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7421 | if (mc_count > WLAN_HDD_MAX_MC_ADDR_LIST) |
| 7422 | { |
| 7423 | hddLog(VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7424 | "%s: No free filter available; allow all multicast frames", __func__); |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 7425 | pAdapter->mc_addr_list.mc_cnt = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7426 | return; |
| 7427 | } |
| 7428 | |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 7429 | pAdapter->mc_addr_list.mc_cnt = mc_count; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7430 | |
| 7431 | netdev_for_each_mc_addr(ha, dev) { |
| 7432 | if (i == mc_count) |
| 7433 | break; |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 7434 | memset(&(pAdapter->mc_addr_list.addr[i][0]), 0, ETH_ALEN); |
| 7435 | memcpy(&(pAdapter->mc_addr_list.addr[i][0]), ha->addr, ETH_ALEN); |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 7436 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: mlist[%d] = "MAC_ADDRESS_STR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7437 | __func__, i, |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 7438 | MAC_ADDR_ARRAY(pAdapter->mc_addr_list.addr[i])); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7439 | i++; |
| 7440 | } |
| 7441 | } |
| 7442 | return; |
| 7443 | } |
| 7444 | #endif |
| 7445 | |
| 7446 | /**--------------------------------------------------------------------------- |
| 7447 | |
| 7448 | \brief hdd_select_queue() - |
| 7449 | |
| 7450 | This function is registered with the Linux OS for network |
| 7451 | core to decide which queue to use first. |
| 7452 | |
| 7453 | \param - dev - Pointer to the WLAN device. |
| 7454 | - skb - Pointer to OS packet (sk_buff). |
| 7455 | \return - ac, Queue Index/access category corresponding to UP in IP header |
| 7456 | |
| 7457 | --------------------------------------------------------------------------*/ |
| 7458 | v_U16_t hdd_select_queue(struct net_device *dev, |
| 7459 | struct sk_buff *skb) |
| 7460 | { |
| 7461 | return hdd_wmm_select_queue(dev, skb); |
| 7462 | } |
| 7463 | |
| 7464 | |
| 7465 | /**--------------------------------------------------------------------------- |
| 7466 | |
| 7467 | \brief hdd_wlan_initial_scan() - |
| 7468 | |
| 7469 | This function triggers the initial scan |
| 7470 | |
| 7471 | \param - pAdapter - Pointer to the HDD adapter. |
| 7472 | |
| 7473 | --------------------------------------------------------------------------*/ |
| 7474 | void hdd_wlan_initial_scan(hdd_adapter_t *pAdapter) |
| 7475 | { |
| 7476 | tCsrScanRequest scanReq; |
| 7477 | tCsrChannelInfo channelInfo; |
| 7478 | eHalStatus halStatus; |
Jeff Johnson | 0279779 | 2013-10-26 19:17:13 -0700 | [diff] [blame] | 7479 | tANI_U32 scanId; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7480 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 7481 | |
| 7482 | vos_mem_zero(&scanReq, sizeof(tCsrScanRequest)); |
| 7483 | vos_mem_set(&scanReq.bssid, sizeof(tCsrBssid), 0xff); |
| 7484 | scanReq.BSSType = eCSR_BSS_TYPE_ANY; |
| 7485 | |
| 7486 | if(sme_Is11dSupported(pHddCtx->hHal)) |
| 7487 | { |
| 7488 | halStatus = sme_ScanGetBaseChannels( pHddCtx->hHal, &channelInfo ); |
| 7489 | if ( HAL_STATUS_SUCCESS( halStatus ) ) |
| 7490 | { |
| 7491 | scanReq.ChannelInfo.ChannelList = vos_mem_malloc(channelInfo.numOfChannels); |
| 7492 | if( !scanReq.ChannelInfo.ChannelList ) |
| 7493 | { |
| 7494 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s kmalloc failed", __func__); |
| 7495 | vos_mem_free(channelInfo.ChannelList); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 7496 | channelInfo.ChannelList = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7497 | return; |
| 7498 | } |
| 7499 | vos_mem_copy(scanReq.ChannelInfo.ChannelList, channelInfo.ChannelList, |
| 7500 | channelInfo.numOfChannels); |
| 7501 | scanReq.ChannelInfo.numOfChannels = channelInfo.numOfChannels; |
| 7502 | vos_mem_free(channelInfo.ChannelList); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 7503 | channelInfo.ChannelList = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7504 | } |
| 7505 | |
| 7506 | scanReq.scanType = eSIR_PASSIVE_SCAN; |
| 7507 | scanReq.requestType = eCSR_SCAN_REQUEST_11D_SCAN; |
| 7508 | scanReq.maxChnTime = pHddCtx->cfg_ini->nPassiveMaxChnTime; |
| 7509 | scanReq.minChnTime = pHddCtx->cfg_ini->nPassiveMinChnTime; |
| 7510 | } |
| 7511 | else |
| 7512 | { |
| 7513 | scanReq.scanType = eSIR_ACTIVE_SCAN; |
| 7514 | scanReq.requestType = eCSR_SCAN_REQUEST_FULL_SCAN; |
| 7515 | scanReq.maxChnTime = pHddCtx->cfg_ini->nActiveMaxChnTime; |
| 7516 | scanReq.minChnTime = pHddCtx->cfg_ini->nActiveMinChnTime; |
| 7517 | } |
| 7518 | |
| 7519 | halStatus = sme_ScanRequest(pHddCtx->hHal, pAdapter->sessionId, &scanReq, &scanId, NULL, NULL); |
| 7520 | if ( !HAL_STATUS_SUCCESS( halStatus ) ) |
| 7521 | { |
| 7522 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_ScanRequest failed status code %d", |
| 7523 | __func__, halStatus ); |
| 7524 | } |
| 7525 | |
| 7526 | if(sme_Is11dSupported(pHddCtx->hHal)) |
| 7527 | vos_mem_free(scanReq.ChannelInfo.ChannelList); |
| 7528 | } |
| 7529 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7530 | /**--------------------------------------------------------------------------- |
| 7531 | |
| 7532 | \brief hdd_full_power_callback() - HDD full power callback function |
| 7533 | |
| 7534 | This is the function invoked by SME to inform the result of a full power |
| 7535 | request issued by HDD |
| 7536 | |
| 7537 | \param - callbackcontext - Pointer to cookie |
| 7538 | \param - status - result of request |
| 7539 | |
| 7540 | \return - None |
| 7541 | |
| 7542 | --------------------------------------------------------------------------*/ |
| 7543 | static void hdd_full_power_callback(void *callbackContext, eHalStatus status) |
| 7544 | { |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 7545 | struct statsContext *pContext = callbackContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7546 | |
| 7547 | hddLog(VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 7548 | "%s: context = %p, status = %d", __func__, pContext, status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7549 | |
| 7550 | if (NULL == callbackContext) |
| 7551 | { |
| 7552 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 7553 | "%s: Bad param, context [%p]", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7554 | __func__, callbackContext); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7555 | return; |
| 7556 | } |
| 7557 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 7558 | /* there is a race condition that exists between this callback |
| 7559 | function and the caller since the caller could time out either |
| 7560 | before or while this code is executing. we use a spinlock to |
| 7561 | serialize these actions */ |
| 7562 | spin_lock(&hdd_context_lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7563 | |
| 7564 | if (POWER_CONTEXT_MAGIC != pContext->magic) |
| 7565 | { |
| 7566 | /* the caller presumably timed out so there is nothing we can do */ |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 7567 | spin_unlock(&hdd_context_lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7568 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 7569 | "%s: Invalid context, magic [%08x]", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7570 | __func__, pContext->magic); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7571 | return; |
| 7572 | } |
| 7573 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 7574 | /* context is valid so caller is still waiting */ |
| 7575 | |
| 7576 | /* paranoia: invalidate the magic */ |
| 7577 | pContext->magic = 0; |
| 7578 | |
| 7579 | /* notify the caller */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7580 | complete(&pContext->completion); |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 7581 | |
| 7582 | /* serialization is complete */ |
| 7583 | spin_unlock(&hdd_context_lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7584 | } |
| 7585 | |
| 7586 | /**--------------------------------------------------------------------------- |
| 7587 | |
| 7588 | \brief hdd_wlan_exit() - HDD WLAN exit function |
| 7589 | |
| 7590 | This is the driver exit point (invoked during rmmod) |
| 7591 | |
| 7592 | \param - pHddCtx - Pointer to the HDD Context |
| 7593 | |
| 7594 | \return - None |
| 7595 | |
| 7596 | --------------------------------------------------------------------------*/ |
| 7597 | void hdd_wlan_exit(hdd_context_t *pHddCtx) |
| 7598 | { |
| 7599 | eHalStatus halStatus; |
| 7600 | v_CONTEXT_t pVosContext = pHddCtx->pvosContext; |
| 7601 | VOS_STATUS vosStatus; |
Gopichand Nakkala | 66923aa | 2013-03-06 23:17:24 +0530 | [diff] [blame] | 7602 | struct wiphy *wiphy = pHddCtx->wiphy; |
Mingcheng Zhu | 87f22fc | 2014-01-30 19:23:32 -0800 | [diff] [blame] | 7603 | hdd_adapter_t* pAdapter = NULL; |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 7604 | struct statsContext powerContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7605 | long lrc; |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 7606 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7607 | |
| 7608 | ENTER(); |
| 7609 | |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 7610 | if (VOS_FTM_MODE != hdd_get_conparam()) |
| 7611 | { |
| 7612 | // Unloading, restart logic is no more required. |
| 7613 | wlan_hdd_restart_deinit(pHddCtx); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7614 | |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 7615 | vosStatus = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7616 | while (NULL != pAdapterNode && VOS_STATUS_E_EMPTY != vosStatus) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7617 | { |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 7618 | pAdapter = pAdapterNode->pAdapter; |
| 7619 | if (NULL != pAdapter) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7620 | { |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 7621 | if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode || |
| 7622 | WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) |
| 7623 | { |
| 7624 | wlan_hdd_cfg80211_deregister_frames(pAdapter); |
| 7625 | hdd_UnregisterWext(pAdapter->dev); |
| 7626 | } |
| 7627 | // Cancel any outstanding scan requests. We are about to close all |
| 7628 | // of our adapters, but an adapter structure is what SME passes back |
| 7629 | // to our callback function. Hence if there are any outstanding scan |
| 7630 | // requests then there is a race condition between when the adapter |
| 7631 | // is closed and when the callback is invoked.We try to resolve that |
| 7632 | // race condition here by canceling any outstanding scans before we |
| 7633 | // close the adapters. |
| 7634 | // Note that the scans may be cancelled in an asynchronous manner, |
| 7635 | // so ideally there needs to be some kind of synchronization. Rather |
| 7636 | // than introduce a new synchronization here, we will utilize the |
| 7637 | // fact that we are about to Request Full Power, and since that is |
| 7638 | // synchronized, the expectation is that by the time Request Full |
| 7639 | // Power has completed all scans will be cancelled. |
| 7640 | if (pHddCtx->scan_info.mScanPending) |
| 7641 | { |
| 7642 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 7643 | FL("abort scan mode: %d sessionId: %d"), |
| 7644 | pAdapter->device_mode, |
| 7645 | pAdapter->sessionId); |
| 7646 | hdd_abort_mac_scan(pHddCtx, |
| 7647 | pAdapter->sessionId, |
| 7648 | eCSR_SCAN_ABORT_DEFAULT); |
| 7649 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7650 | } |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 7651 | vosStatus = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7652 | pAdapterNode = pNext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7653 | } |
| 7654 | } |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 7655 | else |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 7656 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7657 | hddLog(VOS_TRACE_LEVEL_INFO,"%s: FTM MODE",__func__); |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 7658 | wlan_hdd_ftm_close(pHddCtx); |
| 7659 | goto free_hdd_ctx; |
| 7660 | } |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7661 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7662 | /* DeRegister with platform driver as client for Suspend/Resume */ |
| 7663 | vosStatus = hddDeregisterPmOps(pHddCtx); |
| 7664 | if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) ) |
| 7665 | { |
| 7666 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddDeregisterPmOps failed",__func__); |
| 7667 | VOS_ASSERT(0); |
| 7668 | } |
| 7669 | |
| 7670 | vosStatus = hddDevTmUnregisterNotifyCallback(pHddCtx); |
| 7671 | if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) ) |
| 7672 | { |
| 7673 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddDevTmUnregisterNotifyCallback failed",__func__); |
| 7674 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7675 | |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 7676 | //Stop the traffic monitor timer |
| 7677 | if ( VOS_TIMER_STATE_RUNNING == |
| 7678 | vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)) |
| 7679 | { |
| 7680 | vos_timer_stop(&pHddCtx->tx_rx_trafficTmr); |
| 7681 | } |
| 7682 | |
| 7683 | // Destroy the traffic monitor timer |
| 7684 | if (!VOS_IS_STATUS_SUCCESS(vos_timer_destroy( |
| 7685 | &pHddCtx->tx_rx_trafficTmr))) |
| 7686 | { |
| 7687 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 7688 | "%s: Cannot deallocate Traffic monitor timer", __func__); |
| 7689 | } |
| 7690 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7691 | //Disable IMPS/BMPS as we do not want the device to enter any power |
| 7692 | //save mode during shutdown |
| 7693 | sme_DisablePowerSave(pHddCtx->hHal, ePMC_IDLE_MODE_POWER_SAVE); |
| 7694 | sme_DisablePowerSave(pHddCtx->hHal, ePMC_BEACON_MODE_POWER_SAVE); |
| 7695 | sme_DisablePowerSave(pHddCtx->hHal, ePMC_UAPSD_MODE_POWER_SAVE); |
| 7696 | |
| 7697 | //Ensure that device is in full power as we will touch H/W during vos_Stop |
| 7698 | init_completion(&powerContext.completion); |
| 7699 | powerContext.magic = POWER_CONTEXT_MAGIC; |
| 7700 | |
| 7701 | halStatus = sme_RequestFullPower(pHddCtx->hHal, hdd_full_power_callback, |
| 7702 | &powerContext, eSME_FULL_PWR_NEEDED_BY_HDD); |
| 7703 | |
| 7704 | if (eHAL_STATUS_SUCCESS != halStatus) |
| 7705 | { |
| 7706 | if (eHAL_STATUS_PMC_PENDING == halStatus) |
| 7707 | { |
| 7708 | /* request was sent -- wait for the response */ |
| 7709 | lrc = wait_for_completion_interruptible_timeout( |
| 7710 | &powerContext.completion, |
| 7711 | msecs_to_jiffies(WLAN_WAIT_TIME_POWER)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7712 | if (lrc <= 0) |
| 7713 | { |
| 7714 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s while requesting full power", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7715 | __func__, (0 == lrc) ? "timeout" : "interrupt"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7716 | } |
| 7717 | } |
| 7718 | else |
| 7719 | { |
| 7720 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 7721 | "%s: Request for Full Power failed, status %d", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7722 | __func__, halStatus); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7723 | /* continue -- need to clean up as much as possible */ |
| 7724 | } |
| 7725 | } |
| 7726 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 7727 | /* either we never sent a request, we sent a request and received a |
| 7728 | response or we sent a request and timed out. if we never sent a |
| 7729 | request or if we sent a request and got a response, we want to |
| 7730 | clear the magic out of paranoia. if we timed out there is a |
| 7731 | race condition such that the callback function could be |
| 7732 | executing at the same time we are. of primary concern is if the |
| 7733 | callback function had already verified the "magic" but had not |
| 7734 | yet set the completion variable when a timeout occurred. we |
| 7735 | serialize these activities by invalidating the magic while |
| 7736 | holding a shared spinlock which will cause us to block if the |
| 7737 | callback is currently executing */ |
| 7738 | spin_lock(&hdd_context_lock); |
| 7739 | powerContext.magic = 0; |
| 7740 | spin_unlock(&hdd_context_lock); |
| 7741 | |
Yue Ma | 0d4891e | 2013-08-06 17:01:45 -0700 | [diff] [blame] | 7742 | hdd_debugfs_exit(pHddCtx); |
| 7743 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7744 | // Unregister the Net Device Notifier |
| 7745 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 7746 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7747 | hdd_stop_all_adapters( pHddCtx ); |
| 7748 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7749 | #ifdef WLAN_BTAMP_FEATURE |
| 7750 | vosStatus = WLANBAP_Stop(pVosContext); |
| 7751 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) |
| 7752 | { |
| 7753 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 7754 | "%s: Failed to stop BAP",__func__); |
| 7755 | } |
| 7756 | #endif //WLAN_BTAMP_FEATURE |
| 7757 | |
| 7758 | //Stop all the modules |
| 7759 | vosStatus = vos_stop( pVosContext ); |
| 7760 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) |
| 7761 | { |
| 7762 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7763 | "%s: Failed to stop VOSS",__func__); |
| 7764 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) ); |
| 7765 | } |
| 7766 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7767 | //Assert Deep sleep signal now to put Libra HW in lowest power state |
| 7768 | vosStatus = vos_chipAssertDeepSleep( NULL, NULL, NULL ); |
| 7769 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) ); |
| 7770 | |
| 7771 | //Vote off any PMIC voltage supplies |
| 7772 | vos_chipPowerDown(NULL, NULL, NULL); |
| 7773 | |
| 7774 | vos_chipVoteOffXOBuffer(NULL, NULL, NULL); |
| 7775 | |
Leo Chang | 59cdc7e | 2013-07-10 10:08:21 -0700 | [diff] [blame] | 7776 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7777 | //This requires pMac access, Call this before vos_close(). |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7778 | hdd_unregister_mcast_bcast_filter(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7779 | |
| 7780 | //Close the scheduler before calling vos_close to make sure no thread is |
| 7781 | // scheduled after the each module close is called i.e after all the data |
| 7782 | // structures are freed. |
| 7783 | vosStatus = vos_sched_close( pVosContext ); |
| 7784 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) { |
| 7785 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, |
| 7786 | "%s: Failed to close VOSS Scheduler",__func__); |
| 7787 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) ); |
| 7788 | } |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 7789 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7790 | #ifdef WLAN_FEATURE_HOLD_RX_WAKELOCK |
| 7791 | /* Destroy the wake lock */ |
| 7792 | wake_lock_destroy(&pHddCtx->rx_wake_lock); |
| 7793 | #endif |
Madan Mohan Koyyalamudi | 69fc3ad | 2012-11-28 16:04:56 -0800 | [diff] [blame] | 7794 | /* Destroy the wake lock */ |
| 7795 | wake_lock_destroy(&pHddCtx->sap_wake_lock); |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 7796 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7797 | |
Mihir Shete | 7a24b5f | 2013-12-21 12:18:31 +0530 | [diff] [blame] | 7798 | #ifdef CONFIG_ENABLE_LINUX_REG |
| 7799 | vosStatus = vos_nv_close(); |
| 7800 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) |
| 7801 | { |
| 7802 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 7803 | "%s: Failed to close NV", __func__); |
| 7804 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) ); |
| 7805 | } |
| 7806 | #endif |
| 7807 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7808 | //Close VOSS |
| 7809 | //This frees pMac(HAL) context. There should not be any call that requires pMac access after this. |
| 7810 | vos_close(pVosContext); |
| 7811 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7812 | //Close Watchdog |
| 7813 | if(pHddCtx->cfg_ini->fIsLogpEnabled) |
| 7814 | vos_watchdog_close(pVosContext); |
| 7815 | |
Gopichand Nakkala | a035848 | 2013-06-12 17:05:47 +0530 | [diff] [blame] | 7816 | //Clean up HDD Nlink Service |
| 7817 | send_btc_nlink_msg(WLAN_MODULE_DOWN_IND, 0); |
Leo Chang | 59cdc7e | 2013-07-10 10:08:21 -0700 | [diff] [blame] | 7818 | #ifdef WLAN_KD_READY_NOTIFIER |
| 7819 | nl_srv_exit(pHddCtx->ptt_pid); |
| 7820 | #else |
Gopichand Nakkala | a035848 | 2013-06-12 17:05:47 +0530 | [diff] [blame] | 7821 | nl_srv_exit(); |
Leo Chang | 59cdc7e | 2013-07-10 10:08:21 -0700 | [diff] [blame] | 7822 | #endif /* WLAN_KD_READY_NOTIFIER */ |
Gopichand Nakkala | a035848 | 2013-06-12 17:05:47 +0530 | [diff] [blame] | 7823 | |
Vinay Krishna Eranna | d938c42 | 2014-03-10 17:14:21 +0530 | [diff] [blame] | 7824 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 7825 | if (pHddCtx->cfg_ini->wlanLoggingEnable) |
Vinay Krishna Eranna | d938c42 | 2014-03-10 17:14:21 +0530 | [diff] [blame] | 7826 | { |
| 7827 | wlan_logging_sock_deactivate_svc(); |
| 7828 | } |
| 7829 | #endif |
| 7830 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7831 | /* Cancel the vote for XO Core ON. |
| 7832 | * This is done here to ensure there is no race condition since MC, TX and WD threads have |
| 7833 | * exited at this point |
| 7834 | */ |
| 7835 | 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] | 7836 | " when WLAN is turned OFF"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7837 | if (vos_chipVoteXOCore(NULL, NULL, NULL, VOS_FALSE) != VOS_STATUS_SUCCESS) |
| 7838 | { |
| 7839 | hddLog(VOS_TRACE_LEVEL_ERROR, "Could not cancel the vote for XO Core ON." |
| 7840 | " Not returning failure." |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 7841 | " Power consumed will be high"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7842 | } |
| 7843 | |
| 7844 | hdd_close_all_adapters( pHddCtx ); |
| 7845 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7846 | /* free the power on lock from platform driver */ |
| 7847 | if (free_riva_power_on_lock("wlan")) |
| 7848 | { |
| 7849 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to free power on lock", |
| 7850 | __func__); |
| 7851 | } |
| 7852 | |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 7853 | free_hdd_ctx: |
c_hpothu | 78c7b60 | 2014-05-17 17:35:49 +0530 | [diff] [blame] | 7854 | |
| 7855 | //Free up dynamically allocated members inside HDD Adapter |
| 7856 | if (pHddCtx->cfg_ini) |
| 7857 | { |
| 7858 | kfree(pHddCtx->cfg_ini); |
| 7859 | pHddCtx->cfg_ini= NULL; |
| 7860 | } |
| 7861 | |
Leo Chang | f04ddad | 2013-09-18 13:46:38 -0700 | [diff] [blame] | 7862 | /* FTM mode, WIPHY did not registered |
| 7863 | If un-register here, system crash will happen */ |
| 7864 | if (VOS_FTM_MODE != hdd_get_conparam()) |
| 7865 | { |
| 7866 | wiphy_unregister(wiphy) ; |
| 7867 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7868 | wiphy_free(wiphy) ; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7869 | if (hdd_is_ssr_required()) |
| 7870 | { |
| 7871 | /* WDI timeout had happened during unload, so SSR is needed here */ |
Madan Mohan Koyyalamudi | 3246f5b | 2012-10-15 15:40:02 -0700 | [diff] [blame] | 7872 | subsystem_restart("wcnss"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7873 | msleep(5000); |
| 7874 | } |
| 7875 | hdd_set_ssr_required (VOS_FALSE); |
| 7876 | } |
| 7877 | |
| 7878 | |
| 7879 | /**--------------------------------------------------------------------------- |
| 7880 | |
| 7881 | \brief hdd_update_config_from_nv() - Function to update the contents of |
| 7882 | the running configuration with parameters taken from NV storage |
| 7883 | |
| 7884 | \param - pHddCtx - Pointer to the HDD global context |
| 7885 | |
| 7886 | \return - VOS_STATUS_SUCCESS if successful |
| 7887 | |
| 7888 | --------------------------------------------------------------------------*/ |
| 7889 | static VOS_STATUS hdd_update_config_from_nv(hdd_context_t* pHddCtx) |
| 7890 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7891 | v_BOOL_t itemIsValid = VOS_FALSE; |
| 7892 | VOS_STATUS status; |
| 7893 | v_MACADDR_t macFromNV[VOS_MAX_CONCURRENCY_PERSONA]; |
| 7894 | v_U8_t macLoop; |
| 7895 | |
| 7896 | /*If the NV is valid then get the macaddress from nv else get it from qcom_cfg.ini*/ |
| 7897 | status = vos_nv_getValidity(VNV_FIELD_IMAGE, &itemIsValid); |
| 7898 | if(status != VOS_STATUS_SUCCESS) |
| 7899 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 7900 | hddLog(VOS_TRACE_LEVEL_ERROR," vos_nv_getValidity() failed"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7901 | return VOS_STATUS_E_FAILURE; |
| 7902 | } |
| 7903 | |
| 7904 | if (itemIsValid == VOS_TRUE) |
| 7905 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 7906 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH," Reading the Macaddress from NV"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7907 | status = vos_nv_readMultiMacAddress((v_U8_t *)&macFromNV[0].bytes[0], |
| 7908 | VOS_MAX_CONCURRENCY_PERSONA); |
| 7909 | if(status != VOS_STATUS_SUCCESS) |
| 7910 | { |
| 7911 | /* Get MAC from NV fail, not update CFG info |
| 7912 | * INI MAC value will be used for MAC setting */ |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 7913 | hddLog(VOS_TRACE_LEVEL_ERROR," vos_nv_readMacAddress() failed"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7914 | return VOS_STATUS_E_FAILURE; |
| 7915 | } |
| 7916 | |
| 7917 | /* If first MAC is not valid, treat all others are not valid |
| 7918 | * Then all MACs will be got from ini file */ |
| 7919 | if(vos_is_macaddr_zero(&macFromNV[0])) |
| 7920 | { |
| 7921 | /* MAC address in NV file is not configured yet */ |
| 7922 | hddLog(VOS_TRACE_LEVEL_WARN, "Invalid MAC in NV file"); |
| 7923 | return VOS_STATUS_E_INVAL; |
| 7924 | } |
| 7925 | |
| 7926 | /* Get MAC address from NV, update CFG info */ |
| 7927 | for(macLoop = 0; macLoop < VOS_MAX_CONCURRENCY_PERSONA; macLoop++) |
| 7928 | { |
| 7929 | if(vos_is_macaddr_zero(&macFromNV[macLoop])) |
| 7930 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7931 | 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] | 7932 | /* This MAC is not valid, skip it |
| 7933 | * This MAC will be got from ini file */ |
| 7934 | } |
| 7935 | else |
| 7936 | { |
| 7937 | vos_mem_copy((v_U8_t *)&pHddCtx->cfg_ini->intfMacAddr[macLoop].bytes[0], |
| 7938 | (v_U8_t *)&macFromNV[macLoop].bytes[0], |
| 7939 | VOS_MAC_ADDR_SIZE); |
| 7940 | } |
| 7941 | } |
| 7942 | } |
| 7943 | else |
| 7944 | { |
| 7945 | hddLog(VOS_TRACE_LEVEL_ERROR, "NV ITEM, MAC Not valid"); |
| 7946 | return VOS_STATUS_E_FAILURE; |
| 7947 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7948 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7949 | |
| 7950 | return VOS_STATUS_SUCCESS; |
| 7951 | } |
| 7952 | |
| 7953 | /**--------------------------------------------------------------------------- |
| 7954 | |
| 7955 | \brief hdd_post_voss_start_config() - HDD post voss start config helper |
| 7956 | |
| 7957 | \param - pAdapter - Pointer to the HDD |
| 7958 | |
| 7959 | \return - None |
| 7960 | |
| 7961 | --------------------------------------------------------------------------*/ |
| 7962 | VOS_STATUS hdd_post_voss_start_config(hdd_context_t* pHddCtx) |
| 7963 | { |
| 7964 | eHalStatus halStatus; |
| 7965 | v_U32_t listenInterval; |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 7966 | tANI_U32 ignoreDtim; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7967 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7968 | |
| 7969 | // Send ready indication to the HDD. This will kick off the MAC |
| 7970 | // into a 'running' state and should kick off an initial scan. |
| 7971 | halStatus = sme_HDDReadyInd( pHddCtx->hHal ); |
| 7972 | if ( !HAL_STATUS_SUCCESS( halStatus ) ) |
| 7973 | { |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 7974 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: sme_HDDReadyInd() failed with status " |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7975 | "code %08d [x%08x]",__func__, halStatus, halStatus ); |
| 7976 | return VOS_STATUS_E_FAILURE; |
| 7977 | } |
| 7978 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 7979 | // Set default LI and ignoreDtim into HDD context, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7980 | // otherwise under some race condition, HDD will set 0 LI value into RIVA, |
| 7981 | // And RIVA will crash |
| 7982 | wlan_cfgGetInt(pHddCtx->hHal, WNI_CFG_LISTEN_INTERVAL, &listenInterval); |
| 7983 | pHddCtx->hdd_actual_LI_value = listenInterval; |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 7984 | wlan_cfgGetInt(pHddCtx->hHal, WNI_CFG_IGNORE_DTIM, &ignoreDtim); |
| 7985 | pHddCtx->hdd_actual_ignore_DTIM_value = ignoreDtim; |
| 7986 | |
| 7987 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7988 | return VOS_STATUS_SUCCESS; |
| 7989 | } |
| 7990 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7991 | /* wake lock APIs for HDD */ |
| 7992 | void hdd_prevent_suspend(void) |
| 7993 | { |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 7994 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7995 | wake_lock(&wlan_wake_lock); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7996 | #else |
| 7997 | wcnss_prevent_suspend(); |
| 7998 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7999 | } |
| 8000 | |
| 8001 | void hdd_allow_suspend(void) |
| 8002 | { |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 8003 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8004 | wake_unlock(&wlan_wake_lock); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8005 | #else |
| 8006 | wcnss_allow_suspend(); |
| 8007 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8008 | } |
| 8009 | |
Mahesh A Saptasagar | b9c5040 | 2014-01-16 15:49:22 +0530 | [diff] [blame] | 8010 | void hdd_prevent_suspend_timeout(v_U32_t timeout) |
Madan Mohan Koyyalamudi | 10d83a9 | 2012-09-28 15:47:05 -0700 | [diff] [blame] | 8011 | { |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 8012 | #ifdef WLAN_OPEN_SOURCE |
Amar Singhal | 6144c00 | 2013-05-03 16:11:42 -0700 | [diff] [blame] | 8013 | wake_lock_timeout(&wlan_wake_lock, msecs_to_jiffies(timeout)); |
Madan Mohan Koyyalamudi | 10d83a9 | 2012-09-28 15:47:05 -0700 | [diff] [blame] | 8014 | #else |
| 8015 | /* Do nothing as there is no API in wcnss for timeout*/ |
| 8016 | #endif |
| 8017 | } |
| 8018 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8019 | /**--------------------------------------------------------------------------- |
| 8020 | |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8021 | \brief hdd_exchange_version_and_caps() - HDD function to exchange version and capability |
| 8022 | information between Host and Riva |
| 8023 | |
| 8024 | This function gets reported version of FW |
| 8025 | It also finds the version of Riva headers used to compile the host |
| 8026 | It compares the above two and prints a warning if they are different |
| 8027 | It gets the SW and HW version string |
| 8028 | Finally, it exchanges capabilities between host and Riva i.e. host and riva exchange a msg |
| 8029 | indicating the features they support through a bitmap |
| 8030 | |
| 8031 | \param - pHddCtx - Pointer to HDD context |
| 8032 | |
| 8033 | \return - void |
| 8034 | |
| 8035 | --------------------------------------------------------------------------*/ |
| 8036 | |
| 8037 | void hdd_exchange_version_and_caps(hdd_context_t *pHddCtx) |
| 8038 | { |
| 8039 | |
| 8040 | tSirVersionType versionCompiled; |
| 8041 | tSirVersionType versionReported; |
| 8042 | tSirVersionString versionString; |
| 8043 | tANI_U8 fwFeatCapsMsgSupported = 0; |
| 8044 | VOS_STATUS vstatus; |
| 8045 | |
Mingcheng Zhu | 87f22fc | 2014-01-30 19:23:32 -0800 | [diff] [blame] | 8046 | memset(&versionCompiled, 0, sizeof(versionCompiled)); |
| 8047 | memset(&versionReported, 0, sizeof(versionReported)); |
| 8048 | |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8049 | /* retrieve and display WCNSS version information */ |
| 8050 | do { |
| 8051 | |
| 8052 | vstatus = sme_GetWcnssWlanCompiledVersion(pHddCtx->hHal, |
| 8053 | &versionCompiled); |
| 8054 | if (!VOS_IS_STATUS_SUCCESS(vstatus)) |
| 8055 | { |
| 8056 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 8057 | "%s: unable to retrieve WCNSS WLAN compiled version", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 8058 | __func__); |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8059 | break; |
| 8060 | } |
| 8061 | |
| 8062 | vstatus = sme_GetWcnssWlanReportedVersion(pHddCtx->hHal, |
| 8063 | &versionReported); |
| 8064 | if (!VOS_IS_STATUS_SUCCESS(vstatus)) |
| 8065 | { |
| 8066 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 8067 | "%s: unable to retrieve WCNSS WLAN reported version", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 8068 | __func__); |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8069 | break; |
| 8070 | } |
| 8071 | |
| 8072 | if ((versionCompiled.major != versionReported.major) || |
| 8073 | (versionCompiled.minor != versionReported.minor) || |
| 8074 | (versionCompiled.version != versionReported.version) || |
| 8075 | (versionCompiled.revision != versionReported.revision)) |
| 8076 | { |
| 8077 | pr_err("%s: WCNSS WLAN Version %u.%u.%u.%u, " |
| 8078 | "Host expected %u.%u.%u.%u\n", |
| 8079 | WLAN_MODULE_NAME, |
| 8080 | (int)versionReported.major, |
| 8081 | (int)versionReported.minor, |
| 8082 | (int)versionReported.version, |
| 8083 | (int)versionReported.revision, |
| 8084 | (int)versionCompiled.major, |
| 8085 | (int)versionCompiled.minor, |
| 8086 | (int)versionCompiled.version, |
| 8087 | (int)versionCompiled.revision); |
| 8088 | } |
| 8089 | else |
| 8090 | { |
| 8091 | pr_info("%s: WCNSS WLAN version %u.%u.%u.%u\n", |
| 8092 | WLAN_MODULE_NAME, |
| 8093 | (int)versionReported.major, |
| 8094 | (int)versionReported.minor, |
| 8095 | (int)versionReported.version, |
| 8096 | (int)versionReported.revision); |
| 8097 | } |
| 8098 | |
| 8099 | vstatus = sme_GetWcnssSoftwareVersion(pHddCtx->hHal, |
| 8100 | versionString, |
| 8101 | sizeof(versionString)); |
| 8102 | if (!VOS_IS_STATUS_SUCCESS(vstatus)) |
| 8103 | { |
| 8104 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 8105 | "%s: unable to retrieve WCNSS software version string", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 8106 | __func__); |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8107 | break; |
| 8108 | } |
| 8109 | |
| 8110 | pr_info("%s: WCNSS software version %s\n", |
| 8111 | WLAN_MODULE_NAME, versionString); |
| 8112 | |
| 8113 | vstatus = sme_GetWcnssHardwareVersion(pHddCtx->hHal, |
| 8114 | versionString, |
| 8115 | sizeof(versionString)); |
| 8116 | if (!VOS_IS_STATUS_SUCCESS(vstatus)) |
| 8117 | { |
| 8118 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 8119 | "%s: unable to retrieve WCNSS hardware version string", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 8120 | __func__); |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8121 | break; |
| 8122 | } |
| 8123 | |
| 8124 | pr_info("%s: WCNSS hardware version %s\n", |
| 8125 | WLAN_MODULE_NAME, versionString); |
| 8126 | |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 8127 | /* 1.Check if FW version is greater than 0.1.1.0. Only then send host-FW capability exchange message |
| 8128 | 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] | 8129 | send the message only if it the riva is 1.1 |
| 8130 | minor numbers for different riva branches: |
| 8131 | 0 -> (1.0)Mainline Build |
| 8132 | 1 -> (1.1)Mainline Build |
| 8133 | 2->(1.04) Stability Build |
| 8134 | */ |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 8135 | if (((versionReported.major>0) || (versionReported.minor>1) || |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8136 | ((versionReported.minor>=1) && (versionReported.version>=1))) |
| 8137 | && ((versionReported.major == 1) && (versionReported.minor >= 1))) |
| 8138 | fwFeatCapsMsgSupported = 1; |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 8139 | |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8140 | if (fwFeatCapsMsgSupported) |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 8141 | { |
| 8142 | #ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE |
| 8143 | if(!pHddCtx->cfg_ini->fEnableActiveModeOffload) |
| 8144 | sme_disableFeatureCapablity(WLANACTIVE_OFFLOAD); |
| 8145 | #endif |
Ravi Joshi | d2ca7c4 | 2013-07-23 08:37:49 -0700 | [diff] [blame] | 8146 | /* Indicate if IBSS heartbeat monitoring needs to be offloaded */ |
| 8147 | if (!pHddCtx->cfg_ini->enableIbssHeartBeatOffload) |
| 8148 | { |
| 8149 | sme_disableFeatureCapablity(IBSS_HEARTBEAT_OFFLOAD); |
| 8150 | } |
| 8151 | |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8152 | sme_featureCapsExchange(pHddCtx->hHal); |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 8153 | } |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8154 | |
| 8155 | } while (0); |
| 8156 | |
| 8157 | } |
| 8158 | |
| 8159 | /**--------------------------------------------------------------------------- |
| 8160 | |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 8161 | \brief hdd_is_5g_supported() - HDD function to know if hardware supports 5GHz |
| 8162 | |
| 8163 | \param - pHddCtx - Pointer to the hdd context |
| 8164 | |
| 8165 | \return - true if hardware supports 5GHz |
| 8166 | |
| 8167 | --------------------------------------------------------------------------*/ |
Vinay Krishna Eranna | facf5e2 | 2014-02-24 13:16:25 +0530 | [diff] [blame] | 8168 | boolean hdd_is_5g_supported(hdd_context_t * pHddCtx) |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 8169 | { |
| 8170 | /* If wcnss_wlan_iris_xo_mode() returns WCNSS_XO_48MHZ(1); |
| 8171 | * then hardware support 5Ghz. |
| 8172 | */ |
| 8173 | if (WCNSS_XO_48MHZ == wcnss_wlan_iris_xo_mode()) |
| 8174 | { |
Agarwal Ashish | 971c288 | 2013-10-30 20:11:12 +0530 | [diff] [blame] | 8175 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Hardware supports 5Ghz", __func__); |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 8176 | return true; |
| 8177 | } |
| 8178 | else |
| 8179 | { |
Agarwal Ashish | 971c288 | 2013-10-30 20:11:12 +0530 | [diff] [blame] | 8180 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Hardware doesn't supports 5Ghz", |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 8181 | __func__); |
| 8182 | return false; |
| 8183 | } |
| 8184 | } |
| 8185 | |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 8186 | /**--------------------------------------------------------------------------- |
| 8187 | |
| 8188 | \brief hdd_generate_iface_mac_addr_auto() - HDD Mac Interface Auto |
| 8189 | generate function |
| 8190 | |
| 8191 | This is generate the random mac address for WLAN interface |
| 8192 | |
| 8193 | \param - pHddCtx - Pointer to HDD context |
| 8194 | idx - Start interface index to get auto |
| 8195 | generated mac addr. |
| 8196 | mac_addr - Mac address |
| 8197 | |
| 8198 | \return - 0 for success, < 0 for failure |
| 8199 | |
| 8200 | --------------------------------------------------------------------------*/ |
| 8201 | |
| 8202 | static int hdd_generate_iface_mac_addr_auto(hdd_context_t *pHddCtx, |
| 8203 | int idx, v_MACADDR_t mac_addr) |
| 8204 | { |
| 8205 | int i; |
| 8206 | unsigned int serialno; |
| 8207 | serialno = wcnss_get_serial_number(); |
| 8208 | |
| 8209 | if (0 != serialno) |
| 8210 | { |
| 8211 | /* MAC address has 3 bytes of OUI so we have a maximum of 3 |
| 8212 | bytes of the serial number that can be used to generate |
| 8213 | the other 3 bytes of the MAC address. Mask off all but |
| 8214 | the lower 3 bytes (this will also make sure we don't |
| 8215 | overflow in the next step) */ |
| 8216 | serialno &= 0x00FFFFFF; |
| 8217 | |
| 8218 | /* we need a unique address for each session */ |
| 8219 | serialno *= VOS_MAX_CONCURRENCY_PERSONA; |
| 8220 | |
| 8221 | /* autogen other Mac addresses */ |
| 8222 | for (i = idx; i < VOS_MAX_CONCURRENCY_PERSONA; i++) |
| 8223 | { |
| 8224 | /* start with the entire default address */ |
| 8225 | pHddCtx->cfg_ini->intfMacAddr[i] = mac_addr; |
| 8226 | /* then replace the lower 3 bytes */ |
| 8227 | pHddCtx->cfg_ini->intfMacAddr[i].bytes[3] = (serialno >> 16) & 0xFF; |
| 8228 | pHddCtx->cfg_ini->intfMacAddr[i].bytes[4] = (serialno >> 8) & 0xFF; |
| 8229 | pHddCtx->cfg_ini->intfMacAddr[i].bytes[5] = serialno & 0xFF; |
| 8230 | |
| 8231 | serialno++; |
| 8232 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8233 | "%s: Derived Mac Addr: " |
| 8234 | MAC_ADDRESS_STR, __func__, |
| 8235 | MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[i].bytes)); |
| 8236 | } |
| 8237 | |
| 8238 | } |
| 8239 | else |
| 8240 | { |
| 8241 | hddLog(LOGE, FL("Failed to Get Serial NO")); |
| 8242 | return -1; |
| 8243 | } |
| 8244 | return 0; |
| 8245 | } |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 8246 | |
| 8247 | /**--------------------------------------------------------------------------- |
| 8248 | |
Mihir Shete | fc7ff5b | 2014-01-27 11:30:05 +0530 | [diff] [blame] | 8249 | \brief hdd_11d_scan_done - callback to be executed when 11d scan is |
| 8250 | completed to flush out the scan results |
| 8251 | |
| 8252 | 11d scan is done during driver load and is a passive scan on all |
| 8253 | channels supported by the device, 11d scans may find some APs on |
| 8254 | frequencies which are forbidden to be used in the regulatory domain |
| 8255 | the device is operating in. If these APs are notified to the supplicant |
| 8256 | it may try to connect to these APs, thus flush out all the scan results |
| 8257 | which are present in SME after 11d scan is done. |
| 8258 | |
| 8259 | \return - eHalStatus |
| 8260 | |
| 8261 | --------------------------------------------------------------------------*/ |
| 8262 | static eHalStatus hdd_11d_scan_done(tHalHandle halHandle, void *pContext, |
| 8263 | tANI_U32 scanId, eCsrScanStatus status) |
| 8264 | { |
| 8265 | ENTER(); |
| 8266 | |
| 8267 | sme_ScanFlushResult(halHandle, 0); |
| 8268 | |
| 8269 | EXIT(); |
| 8270 | |
| 8271 | return eHAL_STATUS_SUCCESS; |
| 8272 | } |
| 8273 | |
| 8274 | /**--------------------------------------------------------------------------- |
| 8275 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8276 | \brief hdd_wlan_startup() - HDD init function |
| 8277 | |
| 8278 | This is the driver startup code executed once a WLAN device has been detected |
| 8279 | |
| 8280 | \param - dev - Pointer to the underlying device |
| 8281 | |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 8282 | \return - 0 for success, < 0 for failure |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8283 | |
| 8284 | --------------------------------------------------------------------------*/ |
| 8285 | |
| 8286 | int hdd_wlan_startup(struct device *dev ) |
| 8287 | { |
| 8288 | VOS_STATUS status; |
| 8289 | hdd_adapter_t *pAdapter = NULL; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8290 | hdd_adapter_t *pP2pAdapter = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8291 | hdd_context_t *pHddCtx = NULL; |
| 8292 | v_CONTEXT_t pVosContext= NULL; |
| 8293 | #ifdef WLAN_BTAMP_FEATURE |
| 8294 | VOS_STATUS vStatus = VOS_STATUS_SUCCESS; |
| 8295 | WLANBAP_ConfigType btAmpConfig; |
| 8296 | hdd_config_t *pConfig; |
| 8297 | #endif |
| 8298 | int ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8299 | struct wiphy *wiphy; |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 8300 | v_MACADDR_t mac_addr; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8301 | |
| 8302 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8303 | /* |
| 8304 | * cfg80211: wiphy allocation |
| 8305 | */ |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 8306 | wiphy = wlan_hdd_cfg80211_wiphy_alloc(sizeof(hdd_context_t)) ; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8307 | |
| 8308 | if(wiphy == NULL) |
| 8309 | { |
| 8310 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: cfg80211 init failed", __func__); |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 8311 | return -EIO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8312 | } |
| 8313 | |
| 8314 | pHddCtx = wiphy_priv(wiphy); |
| 8315 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8316 | //Initialize the adapter context to zeros. |
| 8317 | vos_mem_zero(pHddCtx, sizeof( hdd_context_t )); |
| 8318 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8319 | pHddCtx->wiphy = wiphy; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8320 | hdd_prevent_suspend(); |
Mihir Shete | 1815629 | 2014-03-11 15:38:30 +0530 | [diff] [blame] | 8321 | pHddCtx->isLoadUnloadInProgress = WLAN_HDD_LOAD_IN_PROGRESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8322 | |
| 8323 | vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, TRUE); |
| 8324 | |
| 8325 | /*Get vos context here bcoz vos_open requires it*/ |
| 8326 | pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL); |
| 8327 | |
Madan Mohan Koyyalamudi | 0b78e15 | 2012-11-28 15:46:51 -0800 | [diff] [blame] | 8328 | if(pVosContext == NULL) |
| 8329 | { |
| 8330 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Failed vos_get_global_context",__func__); |
| 8331 | goto err_free_hdd_context; |
| 8332 | } |
| 8333 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8334 | //Save the Global VOSS context in adapter context for future. |
| 8335 | pHddCtx->pvosContext = pVosContext; |
| 8336 | |
| 8337 | //Save the adapter context in global context for future. |
| 8338 | ((VosContextType*)(pVosContext))->pHDDContext = (v_VOID_t*)pHddCtx; |
| 8339 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8340 | pHddCtx->parent_dev = dev; |
| 8341 | |
| 8342 | init_completion(&pHddCtx->full_pwr_comp_var); |
| 8343 | init_completion(&pHddCtx->standby_comp_var); |
| 8344 | init_completion(&pHddCtx->req_bmps_comp_var); |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 8345 | init_completion(&pHddCtx->scan_info.scan_req_completion_event); |
Madan Mohan Koyyalamudi | f4e8100 | 2012-11-13 10:46:38 -0800 | [diff] [blame] | 8346 | init_completion(&pHddCtx->scan_info.abortscan_event_var); |
Kiet Lam | 46b8e4e | 2013-11-06 21:49:53 +0530 | [diff] [blame] | 8347 | init_completion(&pHddCtx->wiphy_channel_update_event); |
Arun Kumar Khandavalli | e0b046d | 2014-03-01 21:54:25 +0530 | [diff] [blame] | 8348 | init_completion(&pHddCtx->ssr_comp_var); |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 8349 | |
| 8350 | #ifdef CONFIG_ENABLE_LINUX_REG |
Amar Singhal | fddc28c | 2013-09-05 13:03:40 -0700 | [diff] [blame] | 8351 | init_completion(&pHddCtx->linux_reg_req); |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 8352 | #else |
| 8353 | init_completion(&pHddCtx->driver_crda_req); |
| 8354 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8355 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 8356 | spin_lock_init(&pHddCtx->schedScan_lock); |
| 8357 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8358 | hdd_list_init( &pHddCtx->hddAdapters, MAX_NUMBER_OF_ADAPTERS ); |
| 8359 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 8360 | #ifdef FEATURE_WLAN_TDLS |
| 8361 | /* tdls_lock is initialized before an hdd_open_adapter ( which is |
| 8362 | * invoked by other instances also) to protect the concurrent |
| 8363 | * access for the Adapters by TDLS module. |
| 8364 | */ |
| 8365 | mutex_init(&pHddCtx->tdls_lock); |
| 8366 | #endif |
| 8367 | |
Kiet Lam | 46b8e4e | 2013-11-06 21:49:53 +0530 | [diff] [blame] | 8368 | pHddCtx->nEnableStrictRegulatoryForFCC = TRUE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8369 | // Load all config first as TL config is needed during vos_open |
| 8370 | pHddCtx->cfg_ini = (hdd_config_t*) kmalloc(sizeof(hdd_config_t), GFP_KERNEL); |
| 8371 | if(pHddCtx->cfg_ini == NULL) |
| 8372 | { |
| 8373 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Failed kmalloc hdd_config_t",__func__); |
| 8374 | goto err_free_hdd_context; |
| 8375 | } |
| 8376 | |
| 8377 | vos_mem_zero(pHddCtx->cfg_ini, sizeof( hdd_config_t )); |
| 8378 | |
| 8379 | // Read and parse the qcom_cfg.ini file |
| 8380 | status = hdd_parse_config_ini( pHddCtx ); |
| 8381 | if ( VOS_STATUS_SUCCESS != status ) |
| 8382 | { |
| 8383 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: error parsing %s", |
| 8384 | __func__, WLAN_INI_FILE); |
| 8385 | goto err_config; |
| 8386 | } |
Arif Hussain | d521891 | 2013-12-05 01:10:55 -0800 | [diff] [blame] | 8387 | #ifdef MEMORY_DEBUG |
| 8388 | if (pHddCtx->cfg_ini->IsMemoryDebugSupportEnabled) |
| 8389 | vos_mem_init(); |
| 8390 | |
| 8391 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: gEnableMemoryDebug=%d", |
| 8392 | __func__, pHddCtx->cfg_ini->IsMemoryDebugSupportEnabled); |
| 8393 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8394 | |
Gopichand Nakkala | b8f0f1a | 2013-05-23 18:19:48 +0530 | [diff] [blame] | 8395 | /* INI has been read, initialise the configuredMcastBcastFilter with |
| 8396 | * INI value as this will serve as the default value |
| 8397 | */ |
| 8398 | pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting; |
| 8399 | hddLog(VOS_TRACE_LEVEL_INFO, "Setting configuredMcastBcastFilter: %d", |
| 8400 | pHddCtx->cfg_ini->mcastBcastFilterSetting); |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 8401 | |
| 8402 | if (false == hdd_is_5g_supported(pHddCtx)) |
| 8403 | { |
| 8404 | //5Ghz is not supported. |
| 8405 | if (1 != pHddCtx->cfg_ini->nBandCapability) |
| 8406 | { |
| 8407 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 8408 | "%s: Setting pHddCtx->cfg_ini->nBandCapability = 1", __func__); |
| 8409 | pHddCtx->cfg_ini->nBandCapability = 1; |
| 8410 | } |
| 8411 | } |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 8412 | |
| 8413 | /* If SNR Monitoring is enabled, FW has to parse all beacons |
| 8414 | * for calcaluting and storing the average SNR, so set Nth beacon |
| 8415 | * filter to 1 to enable FW to parse all the beaocons |
| 8416 | */ |
| 8417 | if (1 == pHddCtx->cfg_ini->fEnableSNRMonitoring) |
| 8418 | { |
| 8419 | /* The log level is deliberately set to WARN as overriding |
| 8420 | * nthBeaconFilter to 1 will increase power cosumption and this |
| 8421 | * might just prove helpful to detect the power issue. |
| 8422 | */ |
| 8423 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 8424 | "%s: Setting pHddCtx->cfg_ini->nthBeaconFilter = 1", __func__); |
| 8425 | pHddCtx->cfg_ini->nthBeaconFilter = 1; |
| 8426 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8427 | /* |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 8428 | * cfg80211: Initialization ... |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8429 | */ |
Manjunathappa Prakash | eec4ddf | 2014-01-13 18:23:51 -0800 | [diff] [blame] | 8430 | if (VOS_FTM_MODE != hdd_get_conparam()) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8431 | { |
Manjunathappa Prakash | eec4ddf | 2014-01-13 18:23:51 -0800 | [diff] [blame] | 8432 | if (0 < wlan_hdd_cfg80211_init(dev, wiphy, pHddCtx->cfg_ini)) |
| 8433 | { |
| 8434 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 8435 | "%s: wlan_hdd_cfg80211_init return failure", __func__); |
| 8436 | goto err_config; |
| 8437 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8438 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8439 | |
Varun Reddy Yeturu | 587e680 | 2013-01-24 12:21:41 -0800 | [diff] [blame] | 8440 | // Update VOS trace levels based upon the cfg.ini |
| 8441 | hdd_vos_trace_enable(VOS_MODULE_ID_BAP, |
| 8442 | pHddCtx->cfg_ini->vosTraceEnableBAP); |
| 8443 | hdd_vos_trace_enable(VOS_MODULE_ID_TL, |
| 8444 | pHddCtx->cfg_ini->vosTraceEnableTL); |
| 8445 | hdd_vos_trace_enable(VOS_MODULE_ID_WDI, |
| 8446 | pHddCtx->cfg_ini->vosTraceEnableWDI); |
| 8447 | hdd_vos_trace_enable(VOS_MODULE_ID_HDD, |
| 8448 | pHddCtx->cfg_ini->vosTraceEnableHDD); |
| 8449 | hdd_vos_trace_enable(VOS_MODULE_ID_SME, |
| 8450 | pHddCtx->cfg_ini->vosTraceEnableSME); |
| 8451 | hdd_vos_trace_enable(VOS_MODULE_ID_PE, |
| 8452 | pHddCtx->cfg_ini->vosTraceEnablePE); |
Katya Nigam | 70d6833 | 2013-09-16 16:49:45 +0530 | [diff] [blame] | 8453 | hdd_vos_trace_enable(VOS_MODULE_ID_PMC, |
| 8454 | pHddCtx->cfg_ini->vosTraceEnablePMC); |
Varun Reddy Yeturu | 587e680 | 2013-01-24 12:21:41 -0800 | [diff] [blame] | 8455 | hdd_vos_trace_enable(VOS_MODULE_ID_WDA, |
| 8456 | pHddCtx->cfg_ini->vosTraceEnableWDA); |
| 8457 | hdd_vos_trace_enable(VOS_MODULE_ID_SYS, |
| 8458 | pHddCtx->cfg_ini->vosTraceEnableSYS); |
| 8459 | hdd_vos_trace_enable(VOS_MODULE_ID_VOSS, |
| 8460 | pHddCtx->cfg_ini->vosTraceEnableVOSS); |
Varun Reddy Yeturu | 587e680 | 2013-01-24 12:21:41 -0800 | [diff] [blame] | 8461 | hdd_vos_trace_enable(VOS_MODULE_ID_SAP, |
| 8462 | pHddCtx->cfg_ini->vosTraceEnableSAP); |
| 8463 | hdd_vos_trace_enable(VOS_MODULE_ID_HDD_SOFTAP, |
| 8464 | pHddCtx->cfg_ini->vosTraceEnableHDDSAP); |
Varun Reddy Yeturu | 587e680 | 2013-01-24 12:21:41 -0800 | [diff] [blame] | 8465 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8466 | // Update WDI trace levels based upon the cfg.ini |
| 8467 | hdd_wdi_trace_enable(eWLAN_MODULE_DAL, |
| 8468 | pHddCtx->cfg_ini->wdiTraceEnableDAL); |
| 8469 | hdd_wdi_trace_enable(eWLAN_MODULE_DAL_CTRL, |
| 8470 | pHddCtx->cfg_ini->wdiTraceEnableCTL); |
| 8471 | hdd_wdi_trace_enable(eWLAN_MODULE_DAL_DATA, |
| 8472 | pHddCtx->cfg_ini->wdiTraceEnableDAT); |
| 8473 | hdd_wdi_trace_enable(eWLAN_MODULE_PAL, |
| 8474 | pHddCtx->cfg_ini->wdiTraceEnablePAL); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8475 | |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 8476 | if (VOS_FTM_MODE == hdd_get_conparam()) |
| 8477 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8478 | if ( VOS_STATUS_SUCCESS != wlan_hdd_ftm_open(pHddCtx) ) |
| 8479 | { |
| 8480 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: wlan_hdd_ftm_open Failed",__func__); |
| 8481 | goto err_free_hdd_context; |
| 8482 | } |
| 8483 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: FTM driver loaded success fully",__func__); |
c_hpothu | 2de0ef6 | 2014-04-15 16:16:15 +0530 | [diff] [blame] | 8484 | |
| 8485 | vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, FALSE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8486 | return VOS_STATUS_SUCCESS; |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 8487 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8488 | |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 8489 | //Open watchdog module |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8490 | if(pHddCtx->cfg_ini->fIsLogpEnabled) |
| 8491 | { |
| 8492 | status = vos_watchdog_open(pVosContext, |
| 8493 | &((VosContextType*)pVosContext)->vosWatchdog, sizeof(VosWatchdogContext)); |
| 8494 | |
| 8495 | if(!VOS_IS_STATUS_SUCCESS( status )) |
| 8496 | { |
| 8497 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: vos_watchdog_open failed",__func__); |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 8498 | goto err_wdclose; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8499 | } |
| 8500 | } |
| 8501 | |
| 8502 | pHddCtx->isLogpInProgress = FALSE; |
| 8503 | vos_set_logp_in_progress(VOS_MODULE_ID_VOSS, FALSE); |
| 8504 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8505 | status = vos_chipVoteOnXOBuffer(NULL, NULL, NULL); |
| 8506 | if(!VOS_IS_STATUS_SUCCESS(status)) |
| 8507 | { |
| 8508 | 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] | 8509 | goto err_wdclose; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8510 | } |
| 8511 | |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 8512 | #ifdef CONFIG_ENABLE_LINUX_REG |
Amar Singhal | 0a40223 | 2013-10-11 20:57:16 -0700 | [diff] [blame] | 8513 | /* initialize the NV module. This is required so that |
| 8514 | we can initialize the channel information in wiphy |
| 8515 | from the NV.bin data. The channel information in |
| 8516 | wiphy needs to be initialized before wiphy registration */ |
| 8517 | |
| 8518 | status = vos_nv_open(); |
| 8519 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 8520 | { |
| 8521 | /* NV module cannot be initialized */ |
| 8522 | hddLog( VOS_TRACE_LEVEL_FATAL, |
| 8523 | "%s: vos_nv_open failed", __func__); |
| 8524 | goto err_clkvote; |
| 8525 | } |
| 8526 | |
| 8527 | status = vos_init_wiphy_from_nv_bin(); |
| 8528 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 8529 | { |
| 8530 | /* NV module cannot be initialized */ |
| 8531 | hddLog( VOS_TRACE_LEVEL_FATAL, |
| 8532 | "%s: vos_init_wiphy failed", __func__); |
| 8533 | goto err_vos_nv_close; |
| 8534 | } |
| 8535 | |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 8536 | #endif |
| 8537 | |
Arun Kumar Khandavalli | ebb1948 | 2014-03-25 13:56:53 +0530 | [diff] [blame] | 8538 | status = vos_open( &pVosContext, pHddCtx->parent_dev); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8539 | if ( !VOS_IS_STATUS_SUCCESS( status )) |
| 8540 | { |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 8541 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: vos_open failed", __func__); |
Mihir Shete | e1093ba | 2014-01-21 20:13:32 +0530 | [diff] [blame] | 8542 | goto err_vos_nv_close; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8543 | } |
| 8544 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8545 | pHddCtx->hHal = (tHalHandle)vos_get_context( VOS_MODULE_ID_SME, pVosContext ); |
| 8546 | |
| 8547 | if ( NULL == pHddCtx->hHal ) |
| 8548 | { |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 8549 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: HAL context is null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8550 | goto err_vosclose; |
| 8551 | } |
| 8552 | |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 8553 | status = vos_preStart( pHddCtx->pvosContext ); |
| 8554 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 8555 | { |
| 8556 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: vos_preStart failed", __func__); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 8557 | goto err_vosclose; |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 8558 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8559 | |
Arif Hussain | eaf6860 | 2013-12-30 23:10:44 -0800 | [diff] [blame] | 8560 | if (0 == enable_dfs_chan_scan || 1 == enable_dfs_chan_scan) |
| 8561 | { |
| 8562 | pHddCtx->cfg_ini->enableDFSChnlScan = enable_dfs_chan_scan; |
| 8563 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: module enable_dfs_chan_scan set to %d", |
| 8564 | __func__, enable_dfs_chan_scan); |
| 8565 | } |
| 8566 | if (0 == enable_11d || 1 == enable_11d) |
| 8567 | { |
| 8568 | pHddCtx->cfg_ini->Is11dSupportEnabled = enable_11d; |
| 8569 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: module enable_11d set to %d", |
| 8570 | __func__, enable_11d); |
| 8571 | } |
| 8572 | |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 8573 | /* Note that the vos_preStart() sequence triggers the cfg download. |
| 8574 | The cfg download must occur before we update the SME config |
| 8575 | since the SME config operation must access the cfg database */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8576 | status = hdd_set_sme_config( pHddCtx ); |
| 8577 | |
| 8578 | if ( VOS_STATUS_SUCCESS != status ) |
| 8579 | { |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 8580 | 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] | 8581 | goto err_vosclose; |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 8582 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8583 | |
| 8584 | //Initialize the WMM module |
Leela Venkata Kiran Kumar Reddy Chirala | 8e69fbc | 2013-10-30 18:51:13 -0700 | [diff] [blame] | 8585 | status = hdd_wmm_init(pHddCtx, hddWmmDscpToUpMapInfra); |
| 8586 | status = hdd_wmm_init(pHddCtx, hddWmmDscpToUpMapP2p); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8587 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 8588 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 8589 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: hdd_wmm_init failed", __func__); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 8590 | goto err_vosclose; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8591 | } |
| 8592 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8593 | /* In the integrated architecture we update the configuration from |
| 8594 | the INI file and from NV before vOSS has been started so that |
| 8595 | the final contents are available to send down to the cCPU */ |
| 8596 | |
| 8597 | // Apply the cfg.ini to cfg.dat |
| 8598 | if (FALSE == hdd_update_config_dat(pHddCtx)) |
| 8599 | { |
| 8600 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: config update failed",__func__ ); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 8601 | goto err_vosclose; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8602 | } |
| 8603 | |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 8604 | // Get mac addr from platform driver |
| 8605 | ret = wcnss_get_wlan_mac_address((char*)&mac_addr.bytes); |
| 8606 | |
| 8607 | if ((0 == ret) && (!vos_is_macaddr_zero(&mac_addr))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8608 | { |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 8609 | /* Store the mac addr for first interface */ |
| 8610 | pHddCtx->cfg_ini->intfMacAddr[0] = mac_addr; |
| 8611 | |
| 8612 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8613 | "%s: WLAN Mac Addr: " |
| 8614 | MAC_ADDRESS_STR, __func__, |
| 8615 | MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[0].bytes)); |
| 8616 | |
| 8617 | /* Here, passing Arg2 as 1 because we do not want to change the |
| 8618 | last 3 bytes (means non OUI bytes) of first interface mac |
| 8619 | addr. |
| 8620 | */ |
| 8621 | if (0 != hdd_generate_iface_mac_addr_auto(pHddCtx, 1, mac_addr)) |
| 8622 | { |
| 8623 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8624 | "%s: Failed to generate wlan interface mac addr " |
| 8625 | "using MAC from ini file ", __func__); |
| 8626 | } |
| 8627 | } |
| 8628 | else if (VOS_STATUS_SUCCESS != hdd_update_config_from_nv(pHddCtx)) |
| 8629 | { |
| 8630 | // Apply the NV to cfg.dat |
| 8631 | /* Prima Update MAC address only at here */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8632 | #ifdef WLAN_AUTOGEN_MACADDR_FEATURE |
| 8633 | /* There was not a valid set of MAC Addresses in NV. See if the |
| 8634 | default addresses were modified by the cfg.ini settings. If so, |
| 8635 | we'll use them, but if not, we'll autogenerate a set of MAC |
| 8636 | addresses based upon the device serial number */ |
| 8637 | |
| 8638 | static const v_MACADDR_t default_address = |
| 8639 | {{0x00, 0x0A, 0xF5, 0x89, 0x89, 0xFF}}; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8640 | |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 8641 | if (0 == memcmp(&default_address, &pHddCtx->cfg_ini->intfMacAddr[0], |
| 8642 | sizeof(default_address))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8643 | { |
| 8644 | /* cfg.ini has the default address, invoke autogen logic */ |
| 8645 | |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 8646 | /* Here, passing Arg2 as 0 because we want to change the |
| 8647 | last 3 bytes (means non OUI bytes) of all the interfaces |
| 8648 | mac addr. |
| 8649 | */ |
| 8650 | if (0 != hdd_generate_iface_mac_addr_auto(pHddCtx, 0, |
| 8651 | default_address)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8652 | { |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 8653 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8654 | "%s: Failed to generate wlan interface mac addr " |
| 8655 | "using MAC from ini file " MAC_ADDRESS_STR, __func__, |
| 8656 | MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[0].bytes)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8657 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8658 | } |
| 8659 | else |
| 8660 | #endif //WLAN_AUTOGEN_MACADDR_FEATURE |
| 8661 | { |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 8662 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8663 | "%s: Invalid MAC address in NV, using MAC from ini file " |
| 8664 | MAC_ADDRESS_STR, __func__, |
| 8665 | MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[0].bytes)); |
| 8666 | } |
| 8667 | } |
| 8668 | { |
| 8669 | eHalStatus halStatus; |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 8670 | |
| 8671 | /* Set the MAC Address Currently this is used by HAL to |
| 8672 | * add self sta. Remove this once self sta is added as |
| 8673 | * part of session open. |
| 8674 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8675 | halStatus = cfgSetStr( pHddCtx->hHal, WNI_CFG_STA_ID, |
| 8676 | (v_U8_t *)&pHddCtx->cfg_ini->intfMacAddr[0], |
| 8677 | sizeof( pHddCtx->cfg_ini->intfMacAddr[0]) ); |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 8678 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8679 | if (!HAL_STATUS_SUCCESS( halStatus )) |
| 8680 | { |
| 8681 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failed to set MAC Address. " |
| 8682 | "HALStatus is %08d [x%08x]",__func__, halStatus, halStatus ); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 8683 | goto err_vosclose; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8684 | } |
| 8685 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8686 | |
| 8687 | /*Start VOSS which starts up the SME/MAC/HAL modules and everything else |
| 8688 | Note: Firmware image will be read and downloaded inside vos_start API */ |
| 8689 | status = vos_start( pHddCtx->pvosContext ); |
| 8690 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 8691 | { |
| 8692 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: vos_start failed",__func__); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 8693 | goto err_vosclose; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8694 | } |
| 8695 | |
Leo Chang | 6cec3e2 | 2014-01-21 15:33:49 -0800 | [diff] [blame] | 8696 | #ifdef FEATURE_WLAN_CH_AVOID |
| 8697 | /* Plug in avoid channel notification callback |
| 8698 | * This should happen before ADD_SELF_STA |
| 8699 | * FW will send first IND with ADD_SELF_STA REQ from host */ |
| 8700 | sme_AddChAvoidCallback(pHddCtx->hHal, |
| 8701 | hdd_hostapd_ch_avoid_cb); |
| 8702 | #endif /* FEATURE_WLAN_CH_AVOID */ |
| 8703 | |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8704 | /* Exchange capability info between Host and FW and also get versioning info from FW */ |
| 8705 | hdd_exchange_version_and_caps(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8706 | |
Agarwal Ashish | ad9281b | 2014-06-10 14:57:30 +0530 | [diff] [blame] | 8707 | #ifdef CONFIG_ENABLE_LINUX_REG |
| 8708 | status = wlan_hdd_init_channels(pHddCtx); |
| 8709 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 8710 | { |
| 8711 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: wlan_hdd_init_channels failed", |
| 8712 | __func__); |
| 8713 | goto err_vosstop; |
| 8714 | } |
| 8715 | #endif |
| 8716 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8717 | status = hdd_post_voss_start_config( pHddCtx ); |
| 8718 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 8719 | { |
| 8720 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hdd_post_voss_start_config failed", |
| 8721 | __func__); |
| 8722 | goto err_vosstop; |
| 8723 | } |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 8724 | |
| 8725 | #ifndef CONFIG_ENABLE_LINUX_REG |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 8726 | wlan_hdd_cfg80211_update_reg_info( wiphy ); |
| 8727 | |
| 8728 | /* registration of wiphy dev with cfg80211 */ |
| 8729 | if (0 > wlan_hdd_cfg80211_register(wiphy)) |
| 8730 | { |
| 8731 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__); |
| 8732 | goto err_vosstop; |
| 8733 | } |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 8734 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8735 | |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 8736 | #ifdef CONFIG_ENABLE_LINUX_REG |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 8737 | /* registration of wiphy dev with cfg80211 */ |
| 8738 | if (0 > wlan_hdd_cfg80211_register(wiphy)) |
| 8739 | { |
| 8740 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__); |
| 8741 | goto err_vosstop; |
| 8742 | } |
| 8743 | |
| 8744 | status = wlan_hdd_init_channels_for_cc(pHddCtx); |
| 8745 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 8746 | { |
| 8747 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: wlan_hdd_init_channels_for_cc failed", |
| 8748 | __func__); |
| 8749 | goto err_unregister_wiphy; |
| 8750 | } |
| 8751 | #endif |
| 8752 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8753 | if (VOS_STA_SAP_MODE == hdd_get_conparam()) |
| 8754 | { |
| 8755 | pAdapter = hdd_open_adapter( pHddCtx, WLAN_HDD_SOFTAP, "softap.%d", |
| 8756 | wlan_hdd_get_intf_addr(pHddCtx), FALSE ); |
| 8757 | } |
| 8758 | else |
| 8759 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8760 | pAdapter = hdd_open_adapter( pHddCtx, WLAN_HDD_INFRA_STATION, "wlan%d", |
| 8761 | wlan_hdd_get_intf_addr(pHddCtx), FALSE ); |
| 8762 | if (pAdapter != NULL) |
| 8763 | { |
kai | dde6998 | 2014-06-18 13:23:21 +0800 | [diff] [blame] | 8764 | 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] | 8765 | { |
Gopichand Nakkala | 49f96f6 | 2013-02-06 14:38:17 +0530 | [diff] [blame] | 8766 | vos_mem_copy( pHddCtx->p2pDeviceAddress.bytes, |
| 8767 | pHddCtx->cfg_ini->intfMacAddr[0].bytes, |
| 8768 | sizeof(tSirMacAddr)); |
Madan Mohan Koyyalamudi | edfc1b7 | 2012-10-18 20:25:55 -0700 | [diff] [blame] | 8769 | |
Gopichand Nakkala | 49f96f6 | 2013-02-06 14:38:17 +0530 | [diff] [blame] | 8770 | /* Generate the P2P Device Address. This consists of the device's |
| 8771 | * primary MAC address with the locally administered bit set. |
| 8772 | */ |
| 8773 | pHddCtx->p2pDeviceAddress.bytes[0] |= 0x02; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8774 | } |
| 8775 | else |
| 8776 | { |
Gopichand Nakkala | 49f96f6 | 2013-02-06 14:38:17 +0530 | [diff] [blame] | 8777 | tANI_U8* p2p_dev_addr = wlan_hdd_get_intf_addr(pHddCtx); |
| 8778 | if (p2p_dev_addr != NULL) |
| 8779 | { |
| 8780 | vos_mem_copy(&pHddCtx->p2pDeviceAddress.bytes[0], |
| 8781 | p2p_dev_addr, VOS_MAC_ADDR_SIZE); |
| 8782 | } |
| 8783 | else |
| 8784 | { |
| 8785 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 8786 | "%s: Failed to allocate mac_address for p2p_device", |
| 8787 | __func__); |
| 8788 | goto err_close_adapter; |
| 8789 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8790 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8791 | |
| 8792 | pP2pAdapter = hdd_open_adapter( pHddCtx, WLAN_HDD_P2P_DEVICE, "p2p%d", |
| 8793 | &pHddCtx->p2pDeviceAddress.bytes[0], FALSE ); |
| 8794 | if ( NULL == pP2pAdapter ) |
| 8795 | { |
| 8796 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 8797 | "%s: Failed to do hdd_open_adapter for P2P Device Interface", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 8798 | __func__); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8799 | goto err_close_adapter; |
| 8800 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8801 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8802 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8803 | |
| 8804 | if( pAdapter == NULL ) |
| 8805 | { |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 8806 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: hdd_open_adapter failed", __func__); |
| 8807 | goto err_close_adapter; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8808 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8809 | |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 8810 | if (country_code) |
| 8811 | { |
| 8812 | eHalStatus ret; |
Arif Hussain | cb60708 | 2013-12-20 11:57:42 -0800 | [diff] [blame] | 8813 | INIT_COMPLETION(pAdapter->change_country_code); |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 8814 | hdd_checkandupdate_dfssetting(pAdapter, country_code); |
| 8815 | #ifndef CONFIG_ENABLE_LINUX_REG |
| 8816 | hdd_checkandupdate_phymode(pAdapter, country_code); |
| 8817 | #endif |
Arif Hussain | eaf6860 | 2013-12-30 23:10:44 -0800 | [diff] [blame] | 8818 | ret = sme_ChangeCountryCode(pHddCtx->hHal, |
| 8819 | (void *)(tSmeChangeCountryCallback) |
| 8820 | wlan_hdd_change_country_code_callback, |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 8821 | country_code, |
| 8822 | pAdapter, pHddCtx->pvosContext, |
Abhishek Singh | a306a44 | 2013-11-07 18:39:01 +0530 | [diff] [blame] | 8823 | eSIR_TRUE, eSIR_TRUE); |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 8824 | if (eHAL_STATUS_SUCCESS == ret) |
| 8825 | { |
Arif Hussain | cb60708 | 2013-12-20 11:57:42 -0800 | [diff] [blame] | 8826 | ret = wait_for_completion_interruptible_timeout( |
| 8827 | &pAdapter->change_country_code, |
| 8828 | msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY)); |
| 8829 | |
| 8830 | if (0 >= ret) |
| 8831 | { |
| 8832 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 8833 | "%s: SME while setting country code timed out", __func__); |
| 8834 | } |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 8835 | } |
| 8836 | else |
| 8837 | { |
Arif Hussain | cb60708 | 2013-12-20 11:57:42 -0800 | [diff] [blame] | 8838 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 8839 | "%s: SME Change Country code from module param fail ret=%d", |
| 8840 | __func__, ret); |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 8841 | } |
| 8842 | } |
| 8843 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8844 | #ifdef WLAN_BTAMP_FEATURE |
| 8845 | vStatus = WLANBAP_Open(pVosContext); |
| 8846 | if(!VOS_IS_STATUS_SUCCESS(vStatus)) |
| 8847 | { |
| 8848 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 8849 | "%s: Failed to open BAP",__func__); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8850 | goto err_close_adapter; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8851 | } |
| 8852 | |
| 8853 | vStatus = BSL_Init(pVosContext); |
| 8854 | if(!VOS_IS_STATUS_SUCCESS(vStatus)) |
| 8855 | { |
| 8856 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 8857 | "%s: Failed to Init BSL",__func__); |
| 8858 | goto err_bap_close; |
| 8859 | } |
| 8860 | vStatus = WLANBAP_Start(pVosContext); |
| 8861 | if (!VOS_IS_STATUS_SUCCESS(vStatus)) |
| 8862 | { |
| 8863 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 8864 | "%s: Failed to start TL",__func__); |
| 8865 | goto err_bap_close; |
| 8866 | } |
| 8867 | |
| 8868 | pConfig = pHddCtx->cfg_ini; |
| 8869 | btAmpConfig.ucPreferredChannel = pConfig->preferredChannel; |
| 8870 | status = WLANBAP_SetConfig(&btAmpConfig); |
| 8871 | |
| 8872 | #endif //WLAN_BTAMP_FEATURE |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8873 | |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 8874 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 8875 | if(!(IS_ROAM_SCAN_OFFLOAD_FEATURE_ENABLE)) |
| 8876 | { |
| 8877 | hddLog(VOS_TRACE_LEVEL_DEBUG,"%s: ROAM_SCAN_OFFLOAD Feature not supported",__func__); |
| 8878 | pHddCtx->cfg_ini->isRoamOffloadScanEnabled = 0; |
| 8879 | sme_UpdateRoamScanOffloadEnabled((tHalHandle)(pHddCtx->hHal), |
| 8880 | pHddCtx->cfg_ini->isRoamOffloadScanEnabled); |
| 8881 | } |
| 8882 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8883 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 8884 | /*SME must send channel update configuration to RIVA*/ |
| 8885 | sme_UpdateChannelConfig(pHddCtx->hHal); |
| 8886 | #endif |
| 8887 | |
Mihir Shete | fc7ff5b | 2014-01-27 11:30:05 +0530 | [diff] [blame] | 8888 | sme_Register11dScanDoneCallback(pHddCtx->hHal, hdd_11d_scan_done); |
| 8889 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8890 | /* Register with platform driver as client for Suspend/Resume */ |
| 8891 | status = hddRegisterPmOps(pHddCtx); |
| 8892 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 8893 | { |
| 8894 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddRegisterPmOps failed",__func__); |
| 8895 | #ifdef WLAN_BTAMP_FEATURE |
| 8896 | goto err_bap_stop; |
| 8897 | #else |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8898 | goto err_close_adapter; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8899 | #endif //WLAN_BTAMP_FEATURE |
| 8900 | } |
| 8901 | |
Yue Ma | 0d4891e | 2013-08-06 17:01:45 -0700 | [diff] [blame] | 8902 | /* Open debugfs interface */ |
| 8903 | if (VOS_STATUS_SUCCESS != hdd_debugfs_init(pAdapter)) |
| 8904 | { |
| 8905 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 8906 | "%s: hdd_debugfs_init failed!", __func__); |
Yue Ma | 0d4891e | 2013-08-06 17:01:45 -0700 | [diff] [blame] | 8907 | } |
| 8908 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8909 | /* Register TM level change handler function to the platform */ |
| 8910 | status = hddDevTmRegisterNotifyCallback(pHddCtx); |
| 8911 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 8912 | { |
| 8913 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddDevTmRegisterNotifyCallback failed",__func__); |
| 8914 | goto err_unregister_pmops; |
| 8915 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8916 | |
| 8917 | /* register for riva power on lock to platform driver */ |
| 8918 | if (req_riva_power_on_lock("wlan")) |
| 8919 | { |
| 8920 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: req riva power on lock failed", |
| 8921 | __func__); |
| 8922 | goto err_unregister_pmops; |
| 8923 | } |
| 8924 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8925 | // register net device notifier for device change notification |
| 8926 | ret = register_netdevice_notifier(&hdd_netdev_notifier); |
| 8927 | |
| 8928 | if(ret < 0) |
| 8929 | { |
| 8930 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: register_netdevice_notifier failed",__func__); |
| 8931 | goto err_free_power_on_lock; |
| 8932 | } |
| 8933 | |
| 8934 | //Initialize the nlink service |
| 8935 | if(nl_srv_init() != 0) |
| 8936 | { |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 8937 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: nl_srv_init failed", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8938 | goto err_reg_netdev; |
| 8939 | } |
| 8940 | |
Leo Chang | 4ce1cc5 | 2013-10-21 18:27:15 -0700 | [diff] [blame] | 8941 | #ifdef WLAN_KD_READY_NOTIFIER |
| 8942 | pHddCtx->kd_nl_init = 1; |
| 8943 | #endif /* WLAN_KD_READY_NOTIFIER */ |
| 8944 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8945 | //Initialize the BTC service |
| 8946 | if(btc_activate_service(pHddCtx) != 0) |
| 8947 | { |
| 8948 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: btc_activate_service failed",__func__); |
| 8949 | goto err_nl_srv; |
| 8950 | } |
| 8951 | |
| 8952 | #ifdef PTT_SOCK_SVC_ENABLE |
| 8953 | //Initialize the PTT service |
| 8954 | if(ptt_sock_activate_svc(pHddCtx) != 0) |
| 8955 | { |
| 8956 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: ptt_sock_activate_svc failed",__func__); |
| 8957 | goto err_nl_srv; |
| 8958 | } |
| 8959 | #endif |
| 8960 | |
Vinay Krishna Eranna | d938c42 | 2014-03-10 17:14:21 +0530 | [diff] [blame] | 8961 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 8962 | if(pHddCtx->cfg_ini && pHddCtx->cfg_ini->wlanLoggingEnable) |
| 8963 | { |
| 8964 | if(wlan_logging_sock_activate_svc( |
| 8965 | pHddCtx->cfg_ini->wlanLoggingFEToConsole, |
| 8966 | pHddCtx->cfg_ini->wlanLoggingNumBuf)) |
| 8967 | { |
| 8968 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wlan_logging_sock_activate_svc" |
| 8969 | " failed", __func__); |
| 8970 | goto err_nl_srv; |
| 8971 | } |
| 8972 | } |
| 8973 | #endif |
| 8974 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8975 | hdd_register_mcast_bcast_filter(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8976 | if (VOS_STA_SAP_MODE != hdd_get_conparam()) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8977 | { |
Madan Mohan Koyyalamudi | c537df2 | 2012-10-22 15:07:08 -0700 | [diff] [blame] | 8978 | /* Action frame registered in one adapter which will |
| 8979 | * applicable to all interfaces |
| 8980 | */ |
Agarwal Ashish | 8fa0e9a | 2014-05-23 00:40:12 +0530 | [diff] [blame] | 8981 | wlan_hdd_cfg80211_register_frames(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8982 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8983 | |
| 8984 | mutex_init(&pHddCtx->sap_lock); |
| 8985 | |
Mihir Shete | 1815629 | 2014-03-11 15:38:30 +0530 | [diff] [blame] | 8986 | pHddCtx->isLoadUnloadInProgress = WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8987 | |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 8988 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8989 | #ifdef WLAN_FEATURE_HOLD_RX_WAKELOCK |
| 8990 | /* Initialize the wake lcok */ |
| 8991 | wake_lock_init(&pHddCtx->rx_wake_lock, |
| 8992 | WAKE_LOCK_SUSPEND, |
| 8993 | "qcom_rx_wakelock"); |
| 8994 | #endif |
Madan Mohan Koyyalamudi | 69fc3ad | 2012-11-28 16:04:56 -0800 | [diff] [blame] | 8995 | /* Initialize the wake lcok */ |
| 8996 | wake_lock_init(&pHddCtx->sap_wake_lock, |
| 8997 | WAKE_LOCK_SUSPEND, |
| 8998 | "qcom_sap_wakelock"); |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 8999 | #endif |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9000 | |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 9001 | vos_event_init(&pHddCtx->scan_info.scan_finished_event); |
| 9002 | pHddCtx->scan_info.scan_pending_option = WEXT_SCAN_PENDING_GIVEUP; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9003 | |
| 9004 | vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, FALSE); |
| 9005 | hdd_allow_suspend(); |
Abhishek Singh | a306a44 | 2013-11-07 18:39:01 +0530 | [diff] [blame] | 9006 | #ifndef CONFIG_ENABLE_LINUX_REG |
| 9007 | /*updating wiphy so that regulatory user hints can be processed*/ |
| 9008 | if (wiphy) |
| 9009 | { |
| 9010 | regulatory_hint(wiphy, "00"); |
| 9011 | } |
| 9012 | #endif |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9013 | // Initialize the restart logic |
| 9014 | wlan_hdd_restart_init(pHddCtx); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 9015 | |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 9016 | //Register the traffic monitor timer now |
| 9017 | if ( pHddCtx->cfg_ini->dynSplitscan) |
| 9018 | { |
| 9019 | vos_timer_init(&pHddCtx->tx_rx_trafficTmr, |
| 9020 | VOS_TIMER_TYPE_SW, |
| 9021 | hdd_tx_rx_pkt_cnt_stat_timer_handler, |
| 9022 | (void *)pHddCtx); |
| 9023 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9024 | goto success; |
| 9025 | |
| 9026 | err_nl_srv: |
Leo Chang | 59cdc7e | 2013-07-10 10:08:21 -0700 | [diff] [blame] | 9027 | #ifdef WLAN_KD_READY_NOTIFIER |
| 9028 | nl_srv_exit(pHddCtx->ptt_pid); |
| 9029 | #else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9030 | nl_srv_exit(); |
Leo Chang | 59cdc7e | 2013-07-10 10:08:21 -0700 | [diff] [blame] | 9031 | #endif /* WLAN_KD_READY_NOTIFIER */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9032 | err_reg_netdev: |
| 9033 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 9034 | |
| 9035 | err_free_power_on_lock: |
| 9036 | free_riva_power_on_lock("wlan"); |
| 9037 | |
| 9038 | err_unregister_pmops: |
| 9039 | hddDevTmUnregisterNotifyCallback(pHddCtx); |
| 9040 | hddDeregisterPmOps(pHddCtx); |
| 9041 | |
Yue Ma | 0d4891e | 2013-08-06 17:01:45 -0700 | [diff] [blame] | 9042 | hdd_debugfs_exit(pHddCtx); |
| 9043 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9044 | #ifdef WLAN_BTAMP_FEATURE |
| 9045 | err_bap_stop: |
| 9046 | WLANBAP_Stop(pVosContext); |
| 9047 | #endif |
| 9048 | |
| 9049 | #ifdef WLAN_BTAMP_FEATURE |
| 9050 | err_bap_close: |
| 9051 | WLANBAP_Close(pVosContext); |
| 9052 | #endif |
| 9053 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9054 | err_close_adapter: |
| 9055 | hdd_close_all_adapters( pHddCtx ); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 9056 | err_unregister_wiphy: |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 9057 | wiphy_unregister(wiphy) ; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9058 | err_vosstop: |
| 9059 | vos_stop(pVosContext); |
| 9060 | |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 9061 | err_vosclose: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9062 | status = vos_sched_close( pVosContext ); |
| 9063 | if (!VOS_IS_STATUS_SUCCESS(status)) { |
| 9064 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, |
| 9065 | "%s: Failed to close VOSS Scheduler", __func__); |
| 9066 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( status ) ); |
| 9067 | } |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 9068 | vos_close(pVosContext ); |
| 9069 | |
Amar Singhal | 0a40223 | 2013-10-11 20:57:16 -0700 | [diff] [blame] | 9070 | err_vos_nv_close: |
| 9071 | |
c_hpothu | e6a3628 | 2014-03-19 12:27:38 +0530 | [diff] [blame] | 9072 | #ifdef CONFIG_ENABLE_LINUX_REG |
Amar Singhal | 0a40223 | 2013-10-11 20:57:16 -0700 | [diff] [blame] | 9073 | vos_nv_close(); |
| 9074 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9075 | err_clkvote: |
c_hpothu | 70f8d81 | 2014-03-22 22:59:23 +0530 | [diff] [blame] | 9076 | #endif |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 9077 | vos_chipVoteOffXOBuffer(NULL, NULL, NULL); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9078 | |
| 9079 | err_wdclose: |
| 9080 | if(pHddCtx->cfg_ini->fIsLogpEnabled) |
| 9081 | vos_watchdog_close(pVosContext); |
| 9082 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9083 | err_config: |
| 9084 | kfree(pHddCtx->cfg_ini); |
| 9085 | pHddCtx->cfg_ini= NULL; |
| 9086 | |
| 9087 | err_free_hdd_context: |
| 9088 | hdd_allow_suspend(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9089 | wiphy_free(wiphy) ; |
| 9090 | //kfree(wdev) ; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9091 | VOS_BUG(1); |
| 9092 | |
Madan Mohan Koyyalamudi | d57ae63 | 2012-11-06 18:42:48 -0800 | [diff] [blame] | 9093 | if (hdd_is_ssr_required()) |
| 9094 | { |
| 9095 | /* WDI timeout had happened during load, so SSR is needed here */ |
| 9096 | subsystem_restart("wcnss"); |
| 9097 | msleep(5000); |
| 9098 | } |
| 9099 | hdd_set_ssr_required (VOS_FALSE); |
| 9100 | |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 9101 | return -EIO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9102 | |
| 9103 | success: |
| 9104 | EXIT(); |
| 9105 | return 0; |
| 9106 | } |
| 9107 | |
| 9108 | /**--------------------------------------------------------------------------- |
| 9109 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 9110 | \brief hdd_driver_init() - Core Driver Init Function |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9111 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 9112 | This is the driver entry point - called in different timeline depending |
| 9113 | on whether the driver is statically or dynamically linked |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9114 | |
| 9115 | \param - None |
| 9116 | |
| 9117 | \return - 0 for success, non zero for failure |
| 9118 | |
| 9119 | --------------------------------------------------------------------------*/ |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 9120 | static int hdd_driver_init( void) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9121 | { |
| 9122 | VOS_STATUS status; |
| 9123 | v_CONTEXT_t pVosContext = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9124 | struct device *dev = NULL; |
| 9125 | int ret_status = 0; |
Sameer Thalappil | f58d7ec | 2013-04-25 20:17:12 -0700 | [diff] [blame] | 9126 | #ifdef HAVE_WCNSS_CAL_DOWNLOAD |
| 9127 | int max_retries = 0; |
| 9128 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9129 | |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 9130 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 9131 | wlan_logging_sock_init_svc(); |
| 9132 | #endif |
| 9133 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9134 | ENTER(); |
| 9135 | |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 9136 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9137 | wake_lock_init(&wlan_wake_lock, WAKE_LOCK_SUSPEND, "wlan"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9138 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9139 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 9140 | hddTraceInit(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9141 | pr_info("%s: loading driver v%s\n", WLAN_MODULE_NAME, |
| 9142 | QWLAN_VERSIONSTR TIMER_MANAGER_STR MEMORY_DEBUG_STR); |
| 9143 | |
| 9144 | //Power Up Libra WLAN card first if not already powered up |
| 9145 | status = vos_chipPowerUp(NULL,NULL,NULL); |
| 9146 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 9147 | { |
| 9148 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Libra WLAN not Powered Up. " |
| 9149 | "exiting", __func__); |
madan mohan koyyalamudi | 8c96ce1 | 2013-07-10 19:14:39 +0530 | [diff] [blame] | 9150 | #ifdef WLAN_OPEN_SOURCE |
| 9151 | wake_lock_destroy(&wlan_wake_lock); |
| 9152 | #endif |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 9153 | |
| 9154 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 9155 | wlan_logging_sock_deinit_svc(); |
| 9156 | #endif |
| 9157 | |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 9158 | return -EIO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9159 | } |
| 9160 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9161 | #ifdef ANI_BUS_TYPE_PCI |
| 9162 | |
| 9163 | dev = wcnss_wlan_get_device(); |
| 9164 | |
| 9165 | #endif // ANI_BUS_TYPE_PCI |
| 9166 | |
| 9167 | #ifdef ANI_BUS_TYPE_PLATFORM |
Sameer Thalappil | f58d7ec | 2013-04-25 20:17:12 -0700 | [diff] [blame] | 9168 | |
| 9169 | #ifdef HAVE_WCNSS_CAL_DOWNLOAD |
| 9170 | /* wait until WCNSS driver downloads NV */ |
| 9171 | while (!wcnss_device_ready() && 5 >= ++max_retries) { |
| 9172 | msleep(1000); |
| 9173 | } |
| 9174 | if (max_retries >= 5) { |
| 9175 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: WCNSS driver not ready", __func__); |
madan mohan koyyalamudi | 8c96ce1 | 2013-07-10 19:14:39 +0530 | [diff] [blame] | 9176 | #ifdef WLAN_OPEN_SOURCE |
| 9177 | wake_lock_destroy(&wlan_wake_lock); |
| 9178 | #endif |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 9179 | |
| 9180 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 9181 | wlan_logging_sock_deinit_svc(); |
| 9182 | #endif |
| 9183 | |
Sameer Thalappil | f58d7ec | 2013-04-25 20:17:12 -0700 | [diff] [blame] | 9184 | return -ENODEV; |
| 9185 | } |
| 9186 | #endif |
| 9187 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9188 | dev = wcnss_wlan_get_device(); |
| 9189 | #endif // ANI_BUS_TYPE_PLATFORM |
| 9190 | |
| 9191 | |
| 9192 | do { |
| 9193 | if (NULL == dev) { |
| 9194 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: WLAN device not found!!",__func__); |
| 9195 | ret_status = -1; |
| 9196 | break; |
| 9197 | } |
| 9198 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9199 | #ifdef TIMER_MANAGER |
| 9200 | vos_timer_manager_init(); |
| 9201 | #endif |
| 9202 | |
| 9203 | /* Preopen VOSS so that it is ready to start at least SAL */ |
| 9204 | status = vos_preOpen(&pVosContext); |
| 9205 | |
| 9206 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 9207 | { |
| 9208 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Failed to preOpen VOSS", __func__); |
| 9209 | ret_status = -1; |
| 9210 | break; |
| 9211 | } |
| 9212 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 9213 | #ifndef MODULE |
| 9214 | /* For statically linked driver, call hdd_set_conparam to update curr_con_mode |
| 9215 | */ |
| 9216 | hdd_set_conparam((v_UINT_t)con_mode); |
| 9217 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9218 | |
| 9219 | // Call our main init function |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 9220 | if (hdd_wlan_startup(dev)) |
| 9221 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9222 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: WLAN Driver Initialization failed", |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 9223 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9224 | vos_preClose( &pVosContext ); |
| 9225 | ret_status = -1; |
| 9226 | break; |
| 9227 | } |
| 9228 | |
| 9229 | /* Cancel the vote for XO Core ON |
| 9230 | * This is done here for safety purposes in case we re-initialize without turning |
| 9231 | * it OFF in any error scenario. |
| 9232 | */ |
Madan Mohan Koyyalamudi | 8b7f1e6 | 2012-10-05 14:56:51 -0700 | [diff] [blame] | 9233 | 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] | 9234 | " when WLAN is turned ON so Core toggles" |
Madan Mohan Koyyalamudi | 8b7f1e6 | 2012-10-05 14:56:51 -0700 | [diff] [blame] | 9235 | " unless we enter PSD"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9236 | if (vos_chipVoteXOCore(NULL, NULL, NULL, VOS_FALSE) != VOS_STATUS_SUCCESS) |
| 9237 | { |
| 9238 | 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] | 9239 | " Power consumed will be high"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9240 | } |
| 9241 | } while (0); |
| 9242 | |
| 9243 | if (0 != ret_status) |
| 9244 | { |
| 9245 | //Assert Deep sleep signal now to put Libra HW in lowest power state |
| 9246 | status = vos_chipAssertDeepSleep( NULL, NULL, NULL ); |
| 9247 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( status) ); |
| 9248 | |
| 9249 | //Vote off any PMIC voltage supplies |
| 9250 | vos_chipPowerDown(NULL, NULL, NULL); |
| 9251 | #ifdef TIMER_MANAGER |
| 9252 | vos_timer_exit(); |
| 9253 | #endif |
| 9254 | #ifdef MEMORY_DEBUG |
| 9255 | vos_mem_exit(); |
| 9256 | #endif |
| 9257 | |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 9258 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9259 | wake_lock_destroy(&wlan_wake_lock); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9260 | #endif |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 9261 | |
| 9262 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 9263 | wlan_logging_sock_deinit_svc(); |
| 9264 | #endif |
| 9265 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9266 | pr_err("%s: driver load failure\n", WLAN_MODULE_NAME); |
| 9267 | } |
| 9268 | else |
| 9269 | { |
| 9270 | //Send WLAN UP indication to Nlink Service |
| 9271 | send_btc_nlink_msg(WLAN_MODULE_UP_IND, 0); |
| 9272 | |
| 9273 | pr_info("%s: driver loaded\n", WLAN_MODULE_NAME); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9274 | } |
| 9275 | |
| 9276 | EXIT(); |
| 9277 | |
| 9278 | return ret_status; |
| 9279 | } |
| 9280 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 9281 | /**--------------------------------------------------------------------------- |
| 9282 | |
| 9283 | \brief hdd_module_init() - Init Function |
| 9284 | |
| 9285 | This is the driver entry point (invoked when module is loaded using insmod) |
| 9286 | |
| 9287 | \param - None |
| 9288 | |
| 9289 | \return - 0 for success, non zero for failure |
| 9290 | |
| 9291 | --------------------------------------------------------------------------*/ |
| 9292 | #ifdef MODULE |
| 9293 | static int __init hdd_module_init ( void) |
| 9294 | { |
| 9295 | return hdd_driver_init(); |
| 9296 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 9297 | #else /* #ifdef MODULE */ |
| 9298 | static int __init hdd_module_init ( void) |
| 9299 | { |
| 9300 | /* Driver initialization is delayed to fwpath_changed_handler */ |
| 9301 | return 0; |
| 9302 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 9303 | #endif /* #ifdef MODULE */ |
| 9304 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9305 | |
| 9306 | /**--------------------------------------------------------------------------- |
| 9307 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 9308 | \brief hdd_driver_exit() - Exit function |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9309 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 9310 | This is the driver exit point (invoked when module is unloaded using rmmod |
| 9311 | or con_mode was changed by userspace) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9312 | |
| 9313 | \param - None |
| 9314 | |
| 9315 | \return - None |
| 9316 | |
| 9317 | --------------------------------------------------------------------------*/ |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 9318 | static void hdd_driver_exit(void) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9319 | { |
| 9320 | hdd_context_t *pHddCtx = NULL; |
| 9321 | v_CONTEXT_t pVosContext = NULL; |
Agarwal Ashish | 5e41479 | 2014-06-08 15:25:23 +0530 | [diff] [blame] | 9322 | v_REGDOMAIN_t regId; |
Arun Kumar Khandavalli | e0b046d | 2014-03-01 21:54:25 +0530 | [diff] [blame] | 9323 | unsigned long rc = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9324 | |
| 9325 | pr_info("%s: unloading driver v%s\n", WLAN_MODULE_NAME, QWLAN_VERSIONSTR); |
| 9326 | |
| 9327 | //Get the global vos context |
| 9328 | pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL); |
| 9329 | |
| 9330 | if(!pVosContext) |
| 9331 | { |
| 9332 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Global VOS context is Null", __func__); |
| 9333 | goto done; |
| 9334 | } |
| 9335 | |
| 9336 | //Get the HDD context. |
| 9337 | pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext ); |
| 9338 | |
| 9339 | if(!pHddCtx) |
| 9340 | { |
| 9341 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: module exit called before probe",__func__); |
| 9342 | } |
| 9343 | else |
| 9344 | { |
Arun Kumar Khandavalli | e0b046d | 2014-03-01 21:54:25 +0530 | [diff] [blame] | 9345 | INIT_COMPLETION(pHddCtx->ssr_comp_var); |
| 9346 | |
| 9347 | if (pHddCtx->isLogpInProgress) |
| 9348 | { |
Sameer Thalappil | 451ebb9 | 2013-06-28 15:49:58 -0700 | [diff] [blame] | 9349 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Arun Kumar Khandavalli | e0b046d | 2014-03-01 21:54:25 +0530 | [diff] [blame] | 9350 | "%s:SSR in Progress; block rmmod !!!", __func__); |
| 9351 | rc = wait_for_completion_timeout(&pHddCtx->ssr_comp_var, |
| 9352 | msecs_to_jiffies(30000)); |
| 9353 | if(!rc) |
| 9354 | { |
| 9355 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 9356 | "%s:SSR timedout, fatal error", __func__); |
| 9357 | VOS_BUG(0); |
Sameer Thalappil | 451ebb9 | 2013-06-28 15:49:58 -0700 | [diff] [blame] | 9358 | } |
Arun Kumar Khandavalli | e0b046d | 2014-03-01 21:54:25 +0530 | [diff] [blame] | 9359 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9360 | |
Mihir Shete | 1815629 | 2014-03-11 15:38:30 +0530 | [diff] [blame] | 9361 | pHddCtx->isLoadUnloadInProgress = WLAN_HDD_UNLOAD_IN_PROGRESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9362 | vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, TRUE); |
| 9363 | |
Agarwal Ashish | 5e41479 | 2014-06-08 15:25:23 +0530 | [diff] [blame] | 9364 | if (eANI_BOOLEAN_TRUE == sme_Is11dCountrycode(pHddCtx->hHal) && |
| 9365 | pHddCtx->cfg_ini->fSupplicantCountryCodeHasPriority ) |
| 9366 | { |
| 9367 | vos_nv_getRegDomainFromCountryCode(®Id , "00", COUNTRY_USER); |
| 9368 | } |
| 9369 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9370 | //Do all the cleanup before deregistering the driver |
| 9371 | hdd_wlan_exit(pHddCtx); |
| 9372 | } |
| 9373 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9374 | vos_preClose( &pVosContext ); |
| 9375 | |
| 9376 | #ifdef TIMER_MANAGER |
| 9377 | vos_timer_exit(); |
| 9378 | #endif |
| 9379 | #ifdef MEMORY_DEBUG |
| 9380 | vos_mem_exit(); |
| 9381 | #endif |
| 9382 | |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 9383 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 9384 | wlan_logging_sock_deinit_svc(); |
| 9385 | #endif |
| 9386 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9387 | done: |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 9388 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9389 | wake_lock_destroy(&wlan_wake_lock); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9390 | #endif |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 9391 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9392 | pr_info("%s: driver unloaded\n", WLAN_MODULE_NAME); |
| 9393 | } |
| 9394 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 9395 | /**--------------------------------------------------------------------------- |
| 9396 | |
| 9397 | \brief hdd_module_exit() - Exit function |
| 9398 | |
| 9399 | This is the driver exit point (invoked when module is unloaded using rmmod) |
| 9400 | |
| 9401 | \param - None |
| 9402 | |
| 9403 | \return - None |
| 9404 | |
| 9405 | --------------------------------------------------------------------------*/ |
| 9406 | static void __exit hdd_module_exit(void) |
| 9407 | { |
| 9408 | hdd_driver_exit(); |
| 9409 | } |
| 9410 | |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 9411 | #ifdef MODULE |
| 9412 | static int fwpath_changed_handler(const char *kmessage, |
| 9413 | struct kernel_param *kp) |
| 9414 | { |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 9415 | return param_set_copystring(kmessage, kp); |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 9416 | } |
| 9417 | |
| 9418 | static int con_mode_handler(const char *kmessage, |
| 9419 | struct kernel_param *kp) |
| 9420 | { |
Madan Mohan Koyyalamudi | f2f8d8b | 2012-10-11 17:06:59 -0700 | [diff] [blame] | 9421 | return param_set_int(kmessage, kp); |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 9422 | } |
| 9423 | #else /* #ifdef MODULE */ |
| 9424 | /**--------------------------------------------------------------------------- |
| 9425 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 9426 | \brief kickstart_driver |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 9427 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 9428 | This is the driver entry point |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 9429 | - delayed driver initialization when driver is statically linked |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 9430 | - invoked when module parameter fwpath is modified from userspace to signal |
| 9431 | initializing the WLAN driver or when con_mode is modified from userspace |
| 9432 | to signal a switch in operating mode |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 9433 | |
| 9434 | \return - 0 for success, non zero for failure |
| 9435 | |
| 9436 | --------------------------------------------------------------------------*/ |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 9437 | static int kickstart_driver(void) |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 9438 | { |
Madan Mohan Koyyalamudi | 62e6005 | 2012-10-05 14:27:22 -0700 | [diff] [blame] | 9439 | int ret_status; |
| 9440 | |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 9441 | if (!wlan_hdd_inited) { |
Madan Mohan Koyyalamudi | 62e6005 | 2012-10-05 14:27:22 -0700 | [diff] [blame] | 9442 | ret_status = hdd_driver_init(); |
| 9443 | wlan_hdd_inited = ret_status ? 0 : 1; |
| 9444 | return ret_status; |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 9445 | } |
| 9446 | |
| 9447 | hdd_driver_exit(); |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 9448 | |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 9449 | msleep(200); |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 9450 | |
Madan Mohan Koyyalamudi | 62e6005 | 2012-10-05 14:27:22 -0700 | [diff] [blame] | 9451 | ret_status = hdd_driver_init(); |
| 9452 | wlan_hdd_inited = ret_status ? 0 : 1; |
| 9453 | return ret_status; |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 9454 | } |
| 9455 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9456 | /**--------------------------------------------------------------------------- |
| 9457 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 9458 | \brief fwpath_changed_handler() - Handler Function |
| 9459 | |
| 9460 | Handle changes to the fwpath parameter |
| 9461 | |
| 9462 | \return - 0 for success, non zero for failure |
| 9463 | |
| 9464 | --------------------------------------------------------------------------*/ |
| 9465 | static int fwpath_changed_handler(const char *kmessage, |
| 9466 | struct kernel_param *kp) |
| 9467 | { |
| 9468 | int ret; |
| 9469 | |
| 9470 | ret = param_set_copystring(kmessage, kp); |
| 9471 | if (0 == ret) |
| 9472 | ret = kickstart_driver(); |
| 9473 | return ret; |
| 9474 | } |
| 9475 | |
| 9476 | /**--------------------------------------------------------------------------- |
| 9477 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 9478 | \brief con_mode_handler() - |
| 9479 | |
| 9480 | Handler function for module param con_mode when it is changed by userspace |
| 9481 | Dynamically linked - do nothing |
| 9482 | Statically linked - exit and init driver, as in rmmod and insmod |
| 9483 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 9484 | \param - |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 9485 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 9486 | \return - |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 9487 | |
| 9488 | --------------------------------------------------------------------------*/ |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 9489 | 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] | 9490 | { |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 9491 | int ret; |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 9492 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 9493 | ret = param_set_int(kmessage, kp); |
| 9494 | if (0 == ret) |
| 9495 | ret = kickstart_driver(); |
| 9496 | return ret; |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 9497 | } |
| 9498 | #endif /* #ifdef MODULE */ |
| 9499 | |
| 9500 | /**--------------------------------------------------------------------------- |
| 9501 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9502 | \brief hdd_get_conparam() - |
| 9503 | |
| 9504 | This is the driver exit point (invoked when module is unloaded using rmmod) |
| 9505 | |
| 9506 | \param - None |
| 9507 | |
| 9508 | \return - tVOS_CON_MODE |
| 9509 | |
| 9510 | --------------------------------------------------------------------------*/ |
| 9511 | tVOS_CON_MODE hdd_get_conparam ( void ) |
| 9512 | { |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 9513 | #ifdef MODULE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9514 | return (tVOS_CON_MODE)con_mode; |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 9515 | #else |
| 9516 | return (tVOS_CON_MODE)curr_con_mode; |
| 9517 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9518 | } |
| 9519 | void hdd_set_conparam ( v_UINT_t newParam ) |
| 9520 | { |
| 9521 | con_mode = newParam; |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 9522 | #ifndef MODULE |
| 9523 | curr_con_mode = con_mode; |
| 9524 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9525 | } |
| 9526 | /**--------------------------------------------------------------------------- |
| 9527 | |
| 9528 | \brief hdd_softap_sta_deauth() - function |
| 9529 | |
| 9530 | This to take counter measure to handle deauth req from HDD |
| 9531 | |
| 9532 | \param - pAdapter - Pointer to the HDD |
| 9533 | |
| 9534 | \param - enable - boolean value |
| 9535 | |
| 9536 | \return - None |
| 9537 | |
| 9538 | --------------------------------------------------------------------------*/ |
| 9539 | |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 9540 | 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] | 9541 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9542 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 9543 | VOS_STATUS vosStatus = VOS_STATUS_E_FAULT; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9544 | |
| 9545 | ENTER(); |
| 9546 | |
Rajesh Chauhan | 18488fc | 2013-08-22 10:15:03 -0700 | [diff] [blame] | 9547 | hddLog(LOG1, "hdd_softap_sta_deauth:(%p, false)", |
| 9548 | (WLAN_HDD_GET_CTX(pAdapter))->pvosContext); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9549 | |
| 9550 | //Ignore request to deauth bcmc station |
| 9551 | if( pDestMacAddress[0] & 0x1 ) |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 9552 | return vosStatus; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9553 | |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 9554 | vosStatus = WLANSAP_DeauthSta(pVosContext,pDestMacAddress); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9555 | |
| 9556 | EXIT(); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 9557 | return vosStatus; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9558 | } |
| 9559 | |
| 9560 | /**--------------------------------------------------------------------------- |
| 9561 | |
| 9562 | \brief hdd_softap_sta_disassoc() - function |
| 9563 | |
| 9564 | This to take counter measure to handle deauth req from HDD |
| 9565 | |
| 9566 | \param - pAdapter - Pointer to the HDD |
| 9567 | |
| 9568 | \param - enable - boolean value |
| 9569 | |
| 9570 | \return - None |
| 9571 | |
| 9572 | --------------------------------------------------------------------------*/ |
| 9573 | |
| 9574 | void hdd_softap_sta_disassoc(hdd_adapter_t *pAdapter,v_U8_t *pDestMacAddress) |
| 9575 | { |
| 9576 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
| 9577 | |
| 9578 | ENTER(); |
| 9579 | |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 9580 | 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] | 9581 | |
| 9582 | //Ignore request to disassoc bcmc station |
| 9583 | if( pDestMacAddress[0] & 0x1 ) |
| 9584 | return; |
| 9585 | |
| 9586 | WLANSAP_DisassocSta(pVosContext,pDestMacAddress); |
| 9587 | } |
| 9588 | |
| 9589 | void hdd_softap_tkip_mic_fail_counter_measure(hdd_adapter_t *pAdapter,v_BOOL_t enable) |
| 9590 | { |
| 9591 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
| 9592 | |
| 9593 | ENTER(); |
| 9594 | |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 9595 | 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] | 9596 | |
| 9597 | WLANSAP_SetCounterMeasure(pVosContext, (v_BOOL_t)enable); |
| 9598 | } |
| 9599 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9600 | /**--------------------------------------------------------------------------- |
| 9601 | * |
| 9602 | * \brief hdd_get__concurrency_mode() - |
| 9603 | * |
| 9604 | * |
| 9605 | * \param - None |
| 9606 | * |
| 9607 | * \return - CONCURRENCY MODE |
| 9608 | * |
| 9609 | * --------------------------------------------------------------------------*/ |
| 9610 | tVOS_CONCURRENCY_MODE hdd_get_concurrency_mode ( void ) |
| 9611 | { |
| 9612 | v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL ); |
| 9613 | hdd_context_t *pHddCtx; |
| 9614 | |
| 9615 | if (NULL != pVosContext) |
| 9616 | { |
| 9617 | pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext); |
| 9618 | if (NULL != pHddCtx) |
| 9619 | { |
| 9620 | return (tVOS_CONCURRENCY_MODE)pHddCtx->concurrency_mode; |
| 9621 | } |
| 9622 | } |
| 9623 | |
| 9624 | /* we are in an invalid state :( */ |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 9625 | hddLog(LOGE, "%s: Invalid context", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9626 | return VOS_STA; |
| 9627 | } |
| 9628 | |
| 9629 | /* Decide whether to allow/not the apps power collapse. |
| 9630 | * Allow apps power collapse if we are in connected state. |
| 9631 | * if not, allow only if we are in IMPS */ |
| 9632 | v_BOOL_t hdd_is_apps_power_collapse_allowed(hdd_context_t* pHddCtx) |
| 9633 | { |
| 9634 | tPmcState pmcState = pmcGetPmcState(pHddCtx->hHal); |
Srikant Kuppa | fef66a7 | 2013-01-30 17:32:44 -0800 | [diff] [blame] | 9635 | tANI_BOOLEAN scanRspPending = csrNeighborRoamScanRspPending(pHddCtx->hHal); |
Srinivas Girigowda | a553c46 | 2013-03-07 19:42:52 -0800 | [diff] [blame] | 9636 | tANI_BOOLEAN inMiddleOfRoaming = csrNeighborMiddleOfRoaming(pHddCtx->hHal); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9637 | hdd_config_t *pConfig = pHddCtx->cfg_ini; |
| 9638 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 9639 | hdd_adapter_t *pAdapter = NULL; |
| 9640 | VOS_STATUS status; |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 9641 | tVOS_CONCURRENCY_MODE concurrent_state = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9642 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9643 | if (VOS_STA_SAP_MODE == hdd_get_conparam()) |
| 9644 | return TRUE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9645 | |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 9646 | concurrent_state = hdd_get_concurrency_mode(); |
| 9647 | |
| 9648 | #ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE |
| 9649 | if(((concurrent_state == (VOS_STA | VOS_P2P_CLIENT)) || |
| 9650 | (concurrent_state == (VOS_STA | VOS_P2P_GO))) && |
| 9651 | (IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)) |
| 9652 | return TRUE; |
| 9653 | #endif |
| 9654 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9655 | /*loop through all adapters. TBD fix for Concurrency */ |
| 9656 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 9657 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 9658 | { |
| 9659 | pAdapter = pAdapterNode->pAdapter; |
| 9660 | if ( (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) |
| 9661 | || (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ) |
| 9662 | { |
Srikant Kuppa | fef66a7 | 2013-01-30 17:32:44 -0800 | [diff] [blame] | 9663 | if (((pConfig->fIsImpsEnabled || pConfig->fIsBmpsEnabled) |
c_hpothu | 4e8faac | 2014-05-16 17:38:44 +0530 | [diff] [blame] | 9664 | && (pmcState != IMPS && pmcState != BMPS && pmcState != UAPSD |
Srikant Kuppa | fef66a7 | 2013-01-30 17:32:44 -0800 | [diff] [blame] | 9665 | && pmcState != STOPPED && pmcState != STANDBY)) || |
Srinivas Girigowda | a553c46 | 2013-03-07 19:42:52 -0800 | [diff] [blame] | 9666 | (eANI_BOOLEAN_TRUE == scanRspPending) || |
| 9667 | (eANI_BOOLEAN_TRUE == inMiddleOfRoaming)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9668 | { |
Srikant Kuppa | fef66a7 | 2013-01-30 17:32:44 -0800 | [diff] [blame] | 9669 | hddLog( LOGE, "%s: do not allow APPS power collapse-" |
Srinivas Girigowda | a553c46 | 2013-03-07 19:42:52 -0800 | [diff] [blame] | 9670 | "pmcState = %d scanRspPending = %d inMiddleOfRoaming = %d", |
| 9671 | __func__, pmcState, scanRspPending, inMiddleOfRoaming ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9672 | return FALSE; |
| 9673 | } |
| 9674 | } |
| 9675 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 9676 | pAdapterNode = pNext; |
| 9677 | } |
| 9678 | return TRUE; |
| 9679 | } |
| 9680 | |
Madan Mohan Koyyalamudi | c72a4d6 | 2012-11-08 14:59:34 -0800 | [diff] [blame] | 9681 | /* Decides whether to send suspend notification to Riva |
| 9682 | * if any adapter is in BMPS; then it is required */ |
| 9683 | v_BOOL_t hdd_is_suspend_notify_allowed(hdd_context_t* pHddCtx) |
| 9684 | { |
| 9685 | tPmcState pmcState = pmcGetPmcState(pHddCtx->hHal); |
| 9686 | hdd_config_t *pConfig = pHddCtx->cfg_ini; |
| 9687 | |
| 9688 | if (pConfig->fIsBmpsEnabled && (pmcState == BMPS)) |
| 9689 | { |
| 9690 | return TRUE; |
| 9691 | } |
| 9692 | return FALSE; |
| 9693 | } |
| 9694 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9695 | void wlan_hdd_set_concurrency_mode(hdd_context_t *pHddCtx, tVOS_CON_MODE mode) |
| 9696 | { |
| 9697 | switch(mode) |
| 9698 | { |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 9699 | case VOS_STA_MODE: |
| 9700 | case VOS_P2P_CLIENT_MODE: |
| 9701 | case VOS_P2P_GO_MODE: |
| 9702 | case VOS_STA_SAP_MODE: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9703 | pHddCtx->concurrency_mode |= (1 << mode); |
| 9704 | pHddCtx->no_of_sessions[mode]++; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9705 | break; |
| 9706 | default: |
| 9707 | break; |
| 9708 | |
| 9709 | } |
| 9710 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: concurrency_mode = 0x%x NumberofSessions for mode %d = %d", |
| 9711 | __func__,pHddCtx->concurrency_mode,mode,pHddCtx->no_of_sessions[mode]); |
| 9712 | } |
| 9713 | |
| 9714 | |
| 9715 | void wlan_hdd_clear_concurrency_mode(hdd_context_t *pHddCtx, tVOS_CON_MODE mode) |
| 9716 | { |
| 9717 | switch(mode) |
| 9718 | { |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 9719 | case VOS_STA_MODE: |
| 9720 | case VOS_P2P_CLIENT_MODE: |
| 9721 | case VOS_P2P_GO_MODE: |
| 9722 | case VOS_STA_SAP_MODE: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9723 | pHddCtx->no_of_sessions[mode]--; |
| 9724 | if (!(pHddCtx->no_of_sessions[mode])) |
| 9725 | pHddCtx->concurrency_mode &= (~(1 << mode)); |
| 9726 | break; |
| 9727 | default: |
| 9728 | break; |
| 9729 | } |
| 9730 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: concurrency_mode = 0x%x NumberofSessions for mode %d = %d", |
| 9731 | __func__,pHddCtx->concurrency_mode,mode,pHddCtx->no_of_sessions[mode]); |
| 9732 | } |
| 9733 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9734 | /**--------------------------------------------------------------------------- |
| 9735 | * |
| 9736 | * \brief wlan_hdd_restart_init |
| 9737 | * |
| 9738 | * This function initalizes restart timer/flag. An internal function. |
| 9739 | * |
| 9740 | * \param - pHddCtx |
| 9741 | * |
| 9742 | * \return - None |
| 9743 | * |
| 9744 | * --------------------------------------------------------------------------*/ |
| 9745 | |
| 9746 | static void wlan_hdd_restart_init(hdd_context_t *pHddCtx) |
| 9747 | { |
| 9748 | /* Initialize */ |
| 9749 | pHddCtx->hdd_restart_retries = 0; |
| 9750 | atomic_set(&pHddCtx->isRestartInProgress, 0); |
| 9751 | vos_timer_init(&pHddCtx->hdd_restart_timer, |
| 9752 | VOS_TIMER_TYPE_SW, |
| 9753 | wlan_hdd_restart_timer_cb, |
| 9754 | pHddCtx); |
| 9755 | } |
| 9756 | /**--------------------------------------------------------------------------- |
| 9757 | * |
| 9758 | * \brief wlan_hdd_restart_deinit |
| 9759 | * |
| 9760 | * This function cleans up the resources used. An internal function. |
| 9761 | * |
| 9762 | * \param - pHddCtx |
| 9763 | * |
| 9764 | * \return - None |
| 9765 | * |
| 9766 | * --------------------------------------------------------------------------*/ |
| 9767 | |
| 9768 | static void wlan_hdd_restart_deinit(hdd_context_t* pHddCtx) |
| 9769 | { |
| 9770 | |
| 9771 | VOS_STATUS vos_status; |
| 9772 | /* Block any further calls */ |
| 9773 | atomic_set(&pHddCtx->isRestartInProgress, 1); |
| 9774 | /* Cleanup */ |
| 9775 | vos_status = vos_timer_stop( &pHddCtx->hdd_restart_timer ); |
| 9776 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 9777 | hddLog(LOGE, FL("Failed to stop HDD restart timer")); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9778 | vos_status = vos_timer_destroy(&pHddCtx->hdd_restart_timer); |
| 9779 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 9780 | hddLog(LOGE, FL("Failed to destroy HDD restart timer")); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9781 | |
| 9782 | } |
| 9783 | |
| 9784 | /**--------------------------------------------------------------------------- |
| 9785 | * |
| 9786 | * \brief wlan_hdd_framework_restart |
| 9787 | * |
| 9788 | * This function uses a cfg80211 API to start a framework initiated WLAN |
| 9789 | * driver module unload/load. |
| 9790 | * |
| 9791 | * Also this API keep retrying (WLAN_HDD_RESTART_RETRY_MAX_CNT). |
| 9792 | * |
| 9793 | * |
| 9794 | * \param - pHddCtx |
| 9795 | * |
| 9796 | * \return - VOS_STATUS_SUCCESS: Success |
| 9797 | * VOS_STATUS_E_EMPTY: Adapter is Empty |
| 9798 | * VOS_STATUS_E_NOMEM: No memory |
| 9799 | |
| 9800 | * --------------------------------------------------------------------------*/ |
| 9801 | |
| 9802 | static VOS_STATUS wlan_hdd_framework_restart(hdd_context_t *pHddCtx) |
| 9803 | { |
| 9804 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 9805 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
Madan Mohan Koyyalamudi | fc19e44 | 2013-05-09 18:24:08 -0700 | [diff] [blame] | 9806 | int len = (sizeof (struct ieee80211_mgmt)); |
| 9807 | struct ieee80211_mgmt *mgmt = NULL; |
| 9808 | |
| 9809 | /* Prepare the DEAUTH managment frame with reason code */ |
| 9810 | mgmt = kzalloc(len, GFP_KERNEL); |
| 9811 | if(mgmt == NULL) |
| 9812 | { |
| 9813 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 9814 | "%s: memory allocation failed (%d bytes)", __func__, len); |
| 9815 | return VOS_STATUS_E_NOMEM; |
| 9816 | } |
| 9817 | mgmt->u.deauth.reason_code = WLAN_REASON_DISASSOC_LOW_ACK; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9818 | |
| 9819 | /* Iterate over all adapters/devices */ |
| 9820 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 9821 | do |
| 9822 | { |
| 9823 | if( (status == VOS_STATUS_SUCCESS) && |
| 9824 | pAdapterNode && |
| 9825 | pAdapterNode->pAdapter) |
| 9826 | { |
| 9827 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 9828 | "restarting the driver(intf:\'%s\' mode:%d :try %d)", |
| 9829 | pAdapterNode->pAdapter->dev->name, |
| 9830 | pAdapterNode->pAdapter->device_mode, |
| 9831 | pHddCtx->hdd_restart_retries + 1); |
Madan Mohan Koyyalamudi | fc19e44 | 2013-05-09 18:24:08 -0700 | [diff] [blame] | 9832 | /* |
| 9833 | * CFG80211 event to restart the driver |
| 9834 | * |
| 9835 | * 'cfg80211_send_unprot_deauth' sends a |
| 9836 | * NL80211_CMD_UNPROT_DEAUTHENTICATE event to supplicant at any state |
| 9837 | * of SME(Linux Kernel) state machine. |
| 9838 | * |
| 9839 | * Reason code WLAN_REASON_DISASSOC_LOW_ACK is currently used to restart |
| 9840 | * the driver. |
| 9841 | * |
| 9842 | */ |
| 9843 | |
| 9844 | cfg80211_send_unprot_deauth(pAdapterNode->pAdapter->dev, (u_int8_t*)mgmt, len ); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9845 | } |
| 9846 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 9847 | pAdapterNode = pNext; |
| 9848 | } while((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status)); |
| 9849 | |
Madan Mohan Koyyalamudi | fc19e44 | 2013-05-09 18:24:08 -0700 | [diff] [blame] | 9850 | |
| 9851 | /* Free the allocated management frame */ |
| 9852 | kfree(mgmt); |
| 9853 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9854 | /* Retry until we unload or reach max count */ |
| 9855 | if(++pHddCtx->hdd_restart_retries < WLAN_HDD_RESTART_RETRY_MAX_CNT) |
| 9856 | vos_timer_start(&pHddCtx->hdd_restart_timer, WLAN_HDD_RESTART_RETRY_DELAY_MS); |
| 9857 | |
| 9858 | return status; |
| 9859 | |
| 9860 | } |
| 9861 | /**--------------------------------------------------------------------------- |
| 9862 | * |
| 9863 | * \brief wlan_hdd_restart_timer_cb |
| 9864 | * |
| 9865 | * Restart timer callback. An internal function. |
| 9866 | * |
| 9867 | * \param - User data: |
| 9868 | * |
| 9869 | * \return - None |
| 9870 | * |
| 9871 | * --------------------------------------------------------------------------*/ |
| 9872 | |
| 9873 | void wlan_hdd_restart_timer_cb(v_PVOID_t usrDataForCallback) |
| 9874 | { |
| 9875 | hdd_context_t *pHddCtx = usrDataForCallback; |
| 9876 | wlan_hdd_framework_restart(pHddCtx); |
| 9877 | return; |
| 9878 | |
| 9879 | } |
| 9880 | |
| 9881 | |
| 9882 | /**--------------------------------------------------------------------------- |
| 9883 | * |
| 9884 | * \brief wlan_hdd_restart_driver |
| 9885 | * |
| 9886 | * This function sends an event to supplicant to restart the WLAN driver. |
| 9887 | * |
| 9888 | * This function is called from vos_wlanRestart. |
| 9889 | * |
| 9890 | * \param - pHddCtx |
| 9891 | * |
| 9892 | * \return - VOS_STATUS_SUCCESS: Success |
| 9893 | * VOS_STATUS_E_EMPTY: Adapter is Empty |
| 9894 | * VOS_STATUS_E_ALREADY: Request already in progress |
| 9895 | |
| 9896 | * --------------------------------------------------------------------------*/ |
| 9897 | VOS_STATUS wlan_hdd_restart_driver(hdd_context_t *pHddCtx) |
| 9898 | { |
| 9899 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 9900 | |
| 9901 | /* A tight check to make sure reentrancy */ |
| 9902 | if(atomic_xchg(&pHddCtx->isRestartInProgress, 1)) |
| 9903 | { |
| 9904 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
| 9905 | "%s: WLAN restart is already in progress", __func__); |
| 9906 | |
| 9907 | return VOS_STATUS_E_ALREADY; |
| 9908 | } |
Sameer Thalappil | 0c164f5 | 2013-03-28 15:27:56 -0700 | [diff] [blame] | 9909 | /* Send reset FIQ to WCNSS to invoke SSR. */ |
Madan Mohan Koyyalamudi | e388b34 | 2012-11-08 15:03:16 -0800 | [diff] [blame] | 9910 | #ifdef HAVE_WCNSS_RESET_INTR |
Madan Mohan Koyyalamudi | bb8f017 | 2012-09-28 15:36:06 -0700 | [diff] [blame] | 9911 | wcnss_reset_intr(); |
| 9912 | #endif |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 9913 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9914 | return status; |
| 9915 | } |
| 9916 | |
Mihir Shete | e1093ba | 2014-01-21 20:13:32 +0530 | [diff] [blame] | 9917 | /**--------------------------------------------------------------------------- |
| 9918 | * |
| 9919 | * \brief wlan_hdd_init_channels |
| 9920 | * |
| 9921 | * This function is used to initialize the channel list in CSR |
| 9922 | * |
| 9923 | * This function is called from hdd_wlan_startup |
| 9924 | * |
| 9925 | * \param - pHddCtx: HDD context |
| 9926 | * |
| 9927 | * \return - VOS_STATUS_SUCCESS: Success |
| 9928 | * VOS_STATUS_E_FAULT: Failure reported by SME |
| 9929 | |
| 9930 | * --------------------------------------------------------------------------*/ |
| 9931 | static VOS_STATUS wlan_hdd_init_channels(hdd_context_t *pHddCtx) |
| 9932 | { |
| 9933 | eHalStatus status; |
| 9934 | |
| 9935 | status = sme_InitChannels(pHddCtx->hHal); |
| 9936 | if (HAL_STATUS_SUCCESS(status)) |
| 9937 | { |
| 9938 | return VOS_STATUS_SUCCESS; |
| 9939 | } |
| 9940 | else |
| 9941 | { |
| 9942 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Channel initialization failed(%d)", |
| 9943 | __func__, status); |
| 9944 | return VOS_STATUS_E_FAULT; |
| 9945 | } |
| 9946 | } |
| 9947 | |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 9948 | static VOS_STATUS wlan_hdd_init_channels_for_cc(hdd_context_t *pHddCtx) |
| 9949 | { |
| 9950 | eHalStatus status; |
| 9951 | |
| 9952 | status = sme_InitChannelsForCC(pHddCtx->hHal); |
| 9953 | if (HAL_STATUS_SUCCESS(status)) |
| 9954 | { |
| 9955 | return VOS_STATUS_SUCCESS; |
| 9956 | } |
| 9957 | else |
| 9958 | { |
| 9959 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Issue reg hint failed(%d)", |
| 9960 | __func__, status); |
| 9961 | return VOS_STATUS_E_FAULT; |
| 9962 | } |
| 9963 | } |
Sudhir Sattayappa Kohalli | b1d8c3a | 2013-06-18 14:47:20 -0700 | [diff] [blame] | 9964 | /* |
| 9965 | * API to find if there is any STA or P2P-Client is connected |
| 9966 | */ |
| 9967 | VOS_STATUS hdd_issta_p2p_clientconnected(hdd_context_t *pHddCtx) |
| 9968 | { |
| 9969 | return sme_isSta_p2p_clientConnected(pHddCtx->hHal); |
| 9970 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9971 | |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 9972 | int wlan_hdd_scan_abort(hdd_adapter_t *pAdapter) |
| 9973 | { |
| 9974 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 9975 | hdd_scaninfo_t *pScanInfo = NULL; |
Girish Gowli | 4bf7a63 | 2014-06-12 13:42:11 +0530 | [diff] [blame] | 9976 | long status = 0; |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 9977 | |
| 9978 | pScanInfo = &pHddCtx->scan_info; |
| 9979 | if (pScanInfo->mScanPending) |
| 9980 | { |
| 9981 | INIT_COMPLETION(pScanInfo->abortscan_event_var); |
| 9982 | hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId, |
| 9983 | eCSR_SCAN_ABORT_DEFAULT); |
| 9984 | |
| 9985 | status = wait_for_completion_interruptible_timeout( |
| 9986 | &pScanInfo->abortscan_event_var, |
| 9987 | msecs_to_jiffies(5000)); |
Girish Gowli | 4bf7a63 | 2014-06-12 13:42:11 +0530 | [diff] [blame] | 9988 | if (0 >= status) |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 9989 | { |
| 9990 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Girish Gowli | 4bf7a63 | 2014-06-12 13:42:11 +0530 | [diff] [blame] | 9991 | "%s: Timeout or Interrupt occurred while waiting for abort" |
| 9992 | "scan, status- %ld", __func__, status); |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 9993 | return -ETIMEDOUT; |
| 9994 | } |
| 9995 | } |
Girish Gowli | 4bf7a63 | 2014-06-12 13:42:11 +0530 | [diff] [blame] | 9996 | return 0; |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 9997 | } |
| 9998 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9999 | //Register the module init/exit functions |
| 10000 | module_init(hdd_module_init); |
| 10001 | module_exit(hdd_module_exit); |
| 10002 | |
| 10003 | MODULE_LICENSE("Dual BSD/GPL"); |
| 10004 | MODULE_AUTHOR("Qualcomm Atheros, Inc."); |
| 10005 | MODULE_DESCRIPTION("WLAN HOST DEVICE DRIVER"); |
| 10006 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 10007 | module_param_call(con_mode, con_mode_handler, param_get_int, &con_mode, |
| 10008 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 10009 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 10010 | module_param_call(fwpath, fwpath_changed_handler, param_get_string, &fwpath, |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 10011 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 10012 | |
| 10013 | module_param(enable_dfs_chan_scan, int, |
| 10014 | S_IRUSR | S_IRGRP | S_IROTH); |
| 10015 | |
| 10016 | module_param(enable_11d, int, |
| 10017 | S_IRUSR | S_IRGRP | S_IROTH); |
| 10018 | |
| 10019 | module_param(country_code, charp, |
| 10020 | S_IRUSR | S_IRGRP | S_IROTH); |