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 | a7f454d | 2014-07-24 12:04:06 -0700 | [diff] [blame] | 23 | * This file was originally distributed by Qualcomm Atheros, Inc. |
| 24 | * under proprietary terms before Copyright ownership was assigned |
| 25 | * to the Linux Foundation. |
Gopichand Nakkala | 92f07d8 | 2013-01-08 21:16:34 -0800 | [diff] [blame] | 26 | */ |
Kiet Lam | 842dad0 | 2014-02-18 18:44:02 -0800 | [diff] [blame] | 27 | |
| 28 | |
Kiet Lam | a7f454d | 2014-07-24 12:04:06 -0700 | [diff] [blame] | 29 | |
| 30 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 31 | /*======================================================================== |
| 32 | |
| 33 | \file wlan_hdd_main.c |
| 34 | |
| 35 | \brief WLAN Host Device Driver implementation |
| 36 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 37 | |
| 38 | ========================================================================*/ |
| 39 | |
| 40 | /**========================================================================= |
| 41 | |
| 42 | EDIT HISTORY FOR FILE |
| 43 | |
| 44 | |
| 45 | This section contains comments describing changes made to the module. |
| 46 | Notice that changes are listed in reverse chronological order. |
| 47 | |
| 48 | |
| 49 | $Header:$ $DateTime: $ $Author: $ |
| 50 | |
| 51 | |
| 52 | when who what, where, why |
| 53 | -------- --- -------------------------------------------------------- |
| 54 | 04/5/09 Shailender Created module. |
| 55 | 02/24/10 Sudhir.S.Kohalli Added to support param for SoftAP module |
| 56 | 06/03/10 js - Added support to hostapd driven deauth/disassoc/mic failure |
| 57 | ==========================================================================*/ |
| 58 | |
| 59 | /*-------------------------------------------------------------------------- |
| 60 | Include Files |
| 61 | ------------------------------------------------------------------------*/ |
| 62 | //#include <wlan_qct_driver.h> |
| 63 | #include <wlan_hdd_includes.h> |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 64 | #include <vos_api.h> |
| 65 | #include <vos_sched.h> |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 66 | #include <linux/etherdevice.h> |
| 67 | #include <linux/firmware.h> |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 68 | #ifdef ANI_BUS_TYPE_PLATFORM |
| 69 | #include <linux/wcnss_wlan.h> |
| 70 | #endif //ANI_BUS_TYPE_PLATFORM |
| 71 | #ifdef ANI_BUS_TYPE_PCI |
| 72 | #include "wcnss_wlan.h" |
| 73 | #endif /* ANI_BUS_TYPE_PCI */ |
| 74 | #include <wlan_hdd_tx_rx.h> |
| 75 | #include <palTimer.h> |
| 76 | #include <wniApi.h> |
| 77 | #include <wlan_nlink_srv.h> |
| 78 | #include <wlan_btc_svc.h> |
| 79 | #include <wlan_hdd_cfg.h> |
| 80 | #include <wlan_ptt_sock_svc.h> |
Vinay Krishna Eranna | d938c42 | 2014-03-10 17:14:21 +0530 | [diff] [blame] | 81 | #include <wlan_logging_sock_svc.h> |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 82 | #include <wlan_hdd_wowl.h> |
| 83 | #include <wlan_hdd_misc.h> |
| 84 | #include <wlan_hdd_wext.h> |
| 85 | #ifdef WLAN_BTAMP_FEATURE |
| 86 | #include <bap_hdd_main.h> |
| 87 | #include <bapInternal.h> |
| 88 | #endif // WLAN_BTAMP_FEATURE |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 89 | #include "wlan_hdd_trace.h" |
| 90 | #include "vos_types.h" |
| 91 | #include "vos_trace.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 92 | #include <linux/wireless.h> |
| 93 | #include <net/cfg80211.h> |
Vinay Krishna Eranna | d9cbdb3 | 2014-01-16 12:59:10 +0530 | [diff] [blame] | 94 | #include <linux/inetdevice.h> |
| 95 | #include <net/addrconf.h> |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 96 | #include "wlan_hdd_cfg80211.h" |
| 97 | #include "wlan_hdd_p2p.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 98 | #include <linux/rtnetlink.h> |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 99 | int wlan_hdd_ftm_start(hdd_context_t *pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 100 | #include "sapApi.h" |
| 101 | #include <linux/semaphore.h> |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 102 | #include <linux/ctype.h> |
Arun Kumar Khandavalli | 74fe303 | 2014-03-17 20:35:34 +0530 | [diff] [blame] | 103 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)) |
| 104 | #include <soc/qcom/subsystem_restart.h> |
| 105 | #else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 106 | #include <mach/subsystem_restart.h> |
Arun Kumar Khandavalli | 74fe303 | 2014-03-17 20:35:34 +0530 | [diff] [blame] | 107 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 108 | #include <wlan_hdd_hostapd.h> |
| 109 | #include <wlan_hdd_softap_tx_rx.h> |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 110 | #include "cfgApi.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 111 | #include "wlan_hdd_dev_pwr.h" |
| 112 | #ifdef WLAN_BTAMP_FEATURE |
| 113 | #include "bap_hdd_misc.h" |
| 114 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 115 | #include "wlan_qct_pal_trace.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 116 | #include "qwlan_version.h" |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 117 | #include "wlan_qct_wda.h" |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 118 | #ifdef FEATURE_WLAN_TDLS |
| 119 | #include "wlan_hdd_tdls.h" |
| 120 | #endif |
Yue Ma | 0d4891e | 2013-08-06 17:01:45 -0700 | [diff] [blame] | 121 | #include "wlan_hdd_debugfs.h" |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 122 | #include "sapInternal.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 123 | |
| 124 | #ifdef MODULE |
| 125 | #define WLAN_MODULE_NAME module_name(THIS_MODULE) |
| 126 | #else |
| 127 | #define WLAN_MODULE_NAME "wlan" |
| 128 | #endif |
| 129 | |
| 130 | #ifdef TIMER_MANAGER |
| 131 | #define TIMER_MANAGER_STR " +TIMER_MANAGER" |
| 132 | #else |
| 133 | #define TIMER_MANAGER_STR "" |
| 134 | #endif |
| 135 | |
| 136 | #ifdef MEMORY_DEBUG |
| 137 | #define MEMORY_DEBUG_STR " +MEMORY_DEBUG" |
| 138 | #else |
| 139 | #define MEMORY_DEBUG_STR "" |
| 140 | #endif |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 141 | #define MAX_WAIT_FOR_ROC_COMPLETION 3 |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 142 | /* the Android framework expects this param even though we don't use it */ |
| 143 | #define BUF_LEN 20 |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 144 | static char fwpath_buffer[BUF_LEN]; |
| 145 | static struct kparam_string fwpath = { |
| 146 | .string = fwpath_buffer, |
| 147 | .maxlen = BUF_LEN, |
| 148 | }; |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 149 | |
| 150 | static char *country_code; |
| 151 | static int enable_11d = -1; |
| 152 | static int enable_dfs_chan_scan = -1; |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 153 | static int gbcnMissRate = -1; |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 154 | |
Madan Mohan Koyyalamudi | 05f313c | 2012-09-18 19:19:15 -0700 | [diff] [blame] | 155 | #ifndef MODULE |
Madan Mohan Koyyalamudi | dfd6aa8 | 2012-10-18 20:18:43 -0700 | [diff] [blame] | 156 | static int wlan_hdd_inited; |
Madan Mohan Koyyalamudi | 05f313c | 2012-09-18 19:19:15 -0700 | [diff] [blame] | 157 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 158 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 159 | /* |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 160 | * spinlock for synchronizing asynchronous request/response |
| 161 | * (full description of use in wlan_hdd_main.h) |
| 162 | */ |
| 163 | DEFINE_SPINLOCK(hdd_context_lock); |
| 164 | |
| 165 | /* |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 166 | * The rate at which the driver sends RESTART event to supplicant |
| 167 | * once the function 'vos_wlanRestart()' is called |
| 168 | * |
| 169 | */ |
| 170 | #define WLAN_HDD_RESTART_RETRY_DELAY_MS 5000 /* 5 second */ |
| 171 | #define WLAN_HDD_RESTART_RETRY_MAX_CNT 5 /* 5 retries */ |
Varun Reddy Yeturu | 6d99ac8 | 2013-05-08 14:15:35 -0700 | [diff] [blame] | 172 | |
| 173 | /* |
| 174 | * Size of Driver command strings from upper layer |
| 175 | */ |
| 176 | #define SIZE_OF_SETROAMMODE 11 /* size of SETROAMMODE */ |
| 177 | #define SIZE_OF_GETROAMMODE 11 /* size of GETROAMMODE */ |
| 178 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 179 | #if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD) |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 180 | #define TID_MIN_VALUE 0 |
| 181 | #define TID_MAX_VALUE 15 |
| 182 | static VOS_STATUS hdd_get_tsm_stats(hdd_adapter_t *pAdapter, const tANI_U8 tid, |
| 183 | tAniTrafStrmMetrics* pTsmMetrics); |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 184 | static VOS_STATUS hdd_parse_ese_beacon_req(tANI_U8 *pValue, |
| 185 | tCsrEseBeaconReq *pEseBcnReq); |
| 186 | #endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */ |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 187 | |
Atul Mittal | 1d72242 | 2014-03-19 11:15:07 +0530 | [diff] [blame] | 188 | /* |
| 189 | * Maximum buffer size used for returning the data back to user space |
| 190 | */ |
| 191 | #define WLAN_MAX_BUF_SIZE 1024 |
| 192 | #define WLAN_PRIV_DATA_MAX_LEN 8192 |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 193 | |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 194 | //wait time for beacon miss rate. |
| 195 | #define BCN_MISS_RATE_TIME 500 |
| 196 | |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 197 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 198 | static struct wake_lock wlan_wake_lock; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 199 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 200 | /* set when SSR is needed after unload */ |
Madan Mohan Koyyalamudi | b5da533 | 2012-10-15 17:23:21 -0700 | [diff] [blame] | 201 | static e_hdd_ssr_required isSsrRequired = HDD_SSR_NOT_REQUIRED; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 202 | |
| 203 | //internal function declaration |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 204 | static VOS_STATUS wlan_hdd_framework_restart(hdd_context_t *pHddCtx); |
| 205 | static void wlan_hdd_restart_init(hdd_context_t *pHddCtx); |
| 206 | static void wlan_hdd_restart_deinit(hdd_context_t *pHddCtx); |
| 207 | void wlan_hdd_restart_timer_cb(v_PVOID_t usrDataForCallback); |
Sameer Thalappil | 45931fb | 2013-02-01 11:18:05 -0800 | [diff] [blame] | 208 | void hdd_set_wlan_suspend_mode(bool suspend); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 209 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 210 | v_U16_t hdd_select_queue(struct net_device *dev, |
| 211 | struct sk_buff *skb); |
| 212 | |
| 213 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 214 | static void hdd_set_multicast_list(struct net_device *dev); |
| 215 | #endif |
| 216 | |
| 217 | void hdd_wlan_initial_scan(hdd_adapter_t *pAdapter); |
| 218 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 219 | #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] | 220 | void hdd_getBand_helper(hdd_context_t *pHddCtx, int *pBand); |
| 221 | 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] | 222 | static VOS_STATUS hdd_parse_send_action_frame_data(tANI_U8 *pValue, tANI_U8 *pTargetApBssid, |
| 223 | tANI_U8 *pChannel, tANI_U8 *pDwellTime, |
| 224 | tANI_U8 **pBuf, tANI_U8 *pBufLen); |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 225 | static VOS_STATUS hdd_parse_reassoc_command_data(tANI_U8 *pValue, |
| 226 | tANI_U8 *pTargetApBssid, |
| 227 | tANI_U8 *pChannel); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 228 | #endif |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 229 | #if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD) |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 230 | 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] | 231 | #endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */ |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 232 | |
Mihir Shete | e1093ba | 2014-01-21 20:13:32 +0530 | [diff] [blame] | 233 | static VOS_STATUS wlan_hdd_init_channels(hdd_context_t *pHddCtx); |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 234 | const char * hdd_device_modetoString(v_U8_t device_mode) |
| 235 | { |
| 236 | switch(device_mode) |
| 237 | { |
| 238 | CASE_RETURN_STRING( WLAN_HDD_INFRA_STATION ); |
| 239 | CASE_RETURN_STRING( WLAN_HDD_SOFTAP ); |
| 240 | CASE_RETURN_STRING( WLAN_HDD_P2P_CLIENT ); |
| 241 | CASE_RETURN_STRING( WLAN_HDD_P2P_GO ); |
| 242 | CASE_RETURN_STRING( WLAN_HDD_MONITOR); |
| 243 | CASE_RETURN_STRING( WLAN_HDD_FTM ); |
| 244 | CASE_RETURN_STRING( WLAN_HDD_IBSS ); |
| 245 | CASE_RETURN_STRING( WLAN_HDD_P2P_DEVICE ); |
| 246 | default: |
| 247 | return "device_mode Unknown"; |
| 248 | } |
| 249 | } |
Mihir Shete | e1093ba | 2014-01-21 20:13:32 +0530 | [diff] [blame] | 250 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 251 | static int hdd_netdev_notifier_call(struct notifier_block * nb, |
| 252 | unsigned long state, |
| 253 | void *ndev) |
| 254 | { |
| 255 | struct net_device *dev = ndev; |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 256 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 27cee45 | 2013-03-27 11:10:24 -0700 | [diff] [blame] | 257 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 258 | #ifdef WLAN_BTAMP_FEATURE |
| 259 | VOS_STATUS status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 260 | #endif |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 261 | long result; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 262 | |
| 263 | //Make sure that this callback corresponds to our device. |
Jeff Johnson | 27cee45 | 2013-03-27 11:10:24 -0700 | [diff] [blame] | 264 | if ((strncmp(dev->name, "wlan", 4)) && |
Amar Singhal | 4c723bd | 2013-03-25 18:14:15 -0700 | [diff] [blame] | 265 | (strncmp(dev->name, "p2p", 3))) |
| 266 | return NOTIFY_DONE; |
| 267 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 268 | if (!dev->ieee80211_ptr) |
Jeff Johnson | 27cee45 | 2013-03-27 11:10:24 -0700 | [diff] [blame] | 269 | return NOTIFY_DONE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 270 | |
Jeff Johnson | 27cee45 | 2013-03-27 11:10:24 -0700 | [diff] [blame] | 271 | if (NULL == pAdapter) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 272 | { |
Jeff Johnson | a8a1a48 | 2012-12-12 16:49:33 -0800 | [diff] [blame] | 273 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: HDD Adapter Null Pointer", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 274 | VOS_ASSERT(0); |
| 275 | return NOTIFY_DONE; |
| 276 | } |
| 277 | |
Jeff Johnson | 27cee45 | 2013-03-27 11:10:24 -0700 | [diff] [blame] | 278 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 279 | if (NULL == pHddCtx) |
| 280 | { |
| 281 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: HDD Context Null Pointer", __func__); |
| 282 | VOS_ASSERT(0); |
| 283 | return NOTIFY_DONE; |
| 284 | } |
Sameer Thalappil | 1406797 | 2014-01-23 14:54:54 -0800 | [diff] [blame] | 285 | if (pHddCtx->isLogpInProgress) |
| 286 | return NOTIFY_DONE; |
| 287 | |
Jeff Johnson | 27cee45 | 2013-03-27 11:10:24 -0700 | [diff] [blame] | 288 | |
| 289 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s New Net Device State = %lu", |
| 290 | __func__, dev->name, state); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 291 | |
| 292 | switch (state) { |
| 293 | case NETDEV_REGISTER: |
| 294 | break; |
| 295 | |
| 296 | case NETDEV_UNREGISTER: |
| 297 | break; |
| 298 | |
| 299 | case NETDEV_UP: |
| 300 | break; |
| 301 | |
| 302 | case NETDEV_DOWN: |
| 303 | break; |
| 304 | |
| 305 | case NETDEV_CHANGE: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 306 | if(TRUE == pAdapter->isLinkUpSvcNeeded) |
| 307 | complete(&pAdapter->linkup_event_var); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 308 | break; |
| 309 | |
| 310 | case NETDEV_GOING_DOWN: |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 311 | result = wlan_hdd_scan_abort(pAdapter); |
Girish Gowli | 4bf7a63 | 2014-06-12 13:42:11 +0530 | [diff] [blame] | 312 | if (result < 0) |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 313 | { |
| 314 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 315 | "%s: Timeout occurred while waiting for abortscan %ld", |
| 316 | __func__, result); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 317 | } |
| 318 | else |
| 319 | { |
| 320 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 321 | "%s: Scan Abort Successful" , __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 322 | } |
| 323 | #ifdef WLAN_BTAMP_FEATURE |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 324 | 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] | 325 | status = WLANBAP_StopAmp(); |
| 326 | if(VOS_STATUS_SUCCESS != status ) |
| 327 | { |
| 328 | pHddCtx->isAmpAllowed = VOS_TRUE; |
| 329 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 330 | "%s: Failed to stop AMP", __func__); |
| 331 | } |
| 332 | else |
| 333 | { |
| 334 | //a state m/c implementation in PAL is TBD to avoid this delay |
| 335 | msleep(500); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 336 | if ( pHddCtx->isAmpAllowed ) |
| 337 | { |
| 338 | WLANBAP_DeregisterFromHCI(); |
| 339 | pHddCtx->isAmpAllowed = VOS_FALSE; |
| 340 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 341 | } |
| 342 | #endif //WLAN_BTAMP_FEATURE |
| 343 | break; |
| 344 | |
| 345 | default: |
| 346 | break; |
| 347 | } |
| 348 | |
| 349 | return NOTIFY_DONE; |
| 350 | } |
| 351 | |
| 352 | struct notifier_block hdd_netdev_notifier = { |
| 353 | .notifier_call = hdd_netdev_notifier_call, |
| 354 | }; |
| 355 | |
| 356 | /*--------------------------------------------------------------------------- |
| 357 | * Function definitions |
| 358 | *-------------------------------------------------------------------------*/ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 359 | void hdd_unregister_mcast_bcast_filter(hdd_context_t *pHddCtx); |
| 360 | void hdd_register_mcast_bcast_filter(hdd_context_t *pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 361 | //variable to hold the insmod parameters |
Madan Mohan Koyyalamudi | dfd6aa8 | 2012-10-18 20:18:43 -0700 | [diff] [blame] | 362 | static int con_mode; |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 363 | #ifndef MODULE |
| 364 | /* current con_mode - used only for statically linked driver |
| 365 | * con_mode is changed by userspace to indicate a mode change which will |
| 366 | * result in calling the module exit and init functions. The module |
| 367 | * exit function will clean up based on the value of con_mode prior to it |
| 368 | * being changed by userspace. So curr_con_mode records the current con_mode |
| 369 | * for exit when con_mode becomes the next mode for init |
| 370 | */ |
Madan Mohan Koyyalamudi | dfd6aa8 | 2012-10-18 20:18:43 -0700 | [diff] [blame] | 371 | static int curr_con_mode; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 372 | #endif |
| 373 | |
Varun Reddy Yeturu | 587e680 | 2013-01-24 12:21:41 -0800 | [diff] [blame] | 374 | /**--------------------------------------------------------------------------- |
| 375 | |
| 376 | \brief hdd_vos_trace_enable() - Configure initial VOS Trace enable |
| 377 | |
| 378 | Called immediately after the cfg.ini is read in order to configure |
| 379 | the desired trace levels. |
| 380 | |
| 381 | \param - moduleId - module whose trace level is being configured |
| 382 | \param - bitmask - bitmask of log levels to be enabled |
| 383 | |
| 384 | \return - void |
| 385 | |
| 386 | --------------------------------------------------------------------------*/ |
| 387 | static void hdd_vos_trace_enable(VOS_MODULE_ID moduleId, v_U32_t bitmask) |
| 388 | { |
| 389 | wpt_tracelevel level; |
| 390 | |
| 391 | /* if the bitmask is the default value, then a bitmask was not |
| 392 | specified in cfg.ini, so leave the logging level alone (it |
| 393 | will remain at the "compiled in" default value) */ |
| 394 | if (CFG_VOS_TRACE_ENABLE_DEFAULT == bitmask) |
| 395 | { |
| 396 | return; |
| 397 | } |
| 398 | |
| 399 | /* a mask was specified. start by disabling all logging */ |
| 400 | vos_trace_setValue(moduleId, VOS_TRACE_LEVEL_NONE, 0); |
| 401 | |
| 402 | /* now cycle through the bitmask until all "set" bits are serviced */ |
| 403 | level = VOS_TRACE_LEVEL_FATAL; |
| 404 | while (0 != bitmask) |
| 405 | { |
| 406 | if (bitmask & 1) |
| 407 | { |
| 408 | vos_trace_setValue(moduleId, level, 1); |
| 409 | } |
| 410 | level++; |
| 411 | bitmask >>= 1; |
| 412 | } |
| 413 | } |
| 414 | |
| 415 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 416 | /**--------------------------------------------------------------------------- |
| 417 | |
| 418 | \brief hdd_wdi_trace_enable() - Configure initial WDI Trace enable |
| 419 | |
| 420 | Called immediately after the cfg.ini is read in order to configure |
| 421 | the desired trace levels in the WDI. |
| 422 | |
| 423 | \param - moduleId - module whose trace level is being configured |
| 424 | \param - bitmask - bitmask of log levels to be enabled |
| 425 | |
| 426 | \return - void |
| 427 | |
| 428 | --------------------------------------------------------------------------*/ |
| 429 | static void hdd_wdi_trace_enable(wpt_moduleid moduleId, v_U32_t bitmask) |
| 430 | { |
| 431 | wpt_tracelevel level; |
| 432 | |
| 433 | /* if the bitmask is the default value, then a bitmask was not |
| 434 | specified in cfg.ini, so leave the logging level alone (it |
| 435 | will remain at the "compiled in" default value) */ |
| 436 | if (CFG_WDI_TRACE_ENABLE_DEFAULT == bitmask) |
| 437 | { |
| 438 | return; |
| 439 | } |
| 440 | |
| 441 | /* a mask was specified. start by disabling all logging */ |
| 442 | wpalTraceSetLevel(moduleId, eWLAN_PAL_TRACE_LEVEL_NONE, 0); |
| 443 | |
| 444 | /* now cycle through the bitmask until all "set" bits are serviced */ |
| 445 | level = eWLAN_PAL_TRACE_LEVEL_FATAL; |
| 446 | while (0 != bitmask) |
| 447 | { |
| 448 | if (bitmask & 1) |
| 449 | { |
| 450 | wpalTraceSetLevel(moduleId, level, 1); |
| 451 | } |
| 452 | level++; |
| 453 | bitmask >>= 1; |
| 454 | } |
| 455 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 456 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 457 | /* |
| 458 | * FUNCTION: wlan_hdd_validate_context |
| 459 | * This function is used to check the HDD context |
| 460 | */ |
| 461 | int wlan_hdd_validate_context(hdd_context_t *pHddCtx) |
| 462 | { |
| 463 | ENTER(); |
| 464 | |
| 465 | if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini) |
| 466 | { |
| 467 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 468 | "%s: HDD context is Null", __func__); |
| 469 | return -ENODEV; |
| 470 | } |
| 471 | |
| 472 | if (pHddCtx->isLogpInProgress) |
| 473 | { |
| 474 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
c_hpothu | 8adb97b | 2014-12-08 19:38:20 +0530 | [diff] [blame] | 475 | "%s: LOGP %s. Ignore!!", __func__, |
| 476 | vos_is_wlan_in_badState(VOS_MODULE_ID_HDD, NULL) |
| 477 | ?"failed":"in Progress"); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 478 | return -EAGAIN; |
| 479 | } |
| 480 | |
Mihir Shete | 1815629 | 2014-03-11 15:38:30 +0530 | [diff] [blame] | 481 | if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx)) |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 482 | { |
| 483 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 484 | "%s: Unloading/Loading in Progress. Ignore!!!", __func__); |
| 485 | return -EAGAIN; |
| 486 | } |
| 487 | return 0; |
| 488 | } |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 489 | #ifdef CONFIG_ENABLE_LINUX_REG |
| 490 | void hdd_checkandupdate_phymode( hdd_context_t *pHddCtx) |
| 491 | { |
| 492 | hdd_adapter_t *pAdapter = NULL; |
| 493 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 494 | eCsrPhyMode phyMode; |
| 495 | hdd_config_t *cfg_param = NULL; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 496 | |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 497 | if (NULL == pHddCtx) |
| 498 | { |
| 499 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 500 | "HDD Context is null !!"); |
| 501 | return ; |
| 502 | } |
| 503 | |
| 504 | pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 505 | if (NULL == pAdapter) |
| 506 | { |
| 507 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 508 | "pAdapter is null !!"); |
| 509 | return ; |
| 510 | } |
| 511 | |
| 512 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 513 | if (NULL == pHddStaCtx) |
| 514 | { |
| 515 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 516 | "pHddStaCtx is null !!"); |
| 517 | return ; |
| 518 | } |
| 519 | |
| 520 | cfg_param = pHddCtx->cfg_ini; |
| 521 | if (NULL == cfg_param) |
| 522 | { |
| 523 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 524 | "cfg_params not available !!"); |
| 525 | return ; |
| 526 | } |
| 527 | |
| 528 | phyMode = sme_GetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter)); |
| 529 | |
| 530 | if (!pHddCtx->isVHT80Allowed) |
| 531 | { |
| 532 | if ((eCSR_DOT11_MODE_AUTO == phyMode) || |
| 533 | (eCSR_DOT11_MODE_11ac == phyMode) || |
| 534 | (eCSR_DOT11_MODE_11ac_ONLY == phyMode)) |
| 535 | { |
| 536 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 537 | "Setting phymode to 11n!!"); |
| 538 | sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_DOT11_MODE_11n); |
| 539 | } |
| 540 | } |
| 541 | else |
| 542 | { |
| 543 | /*New country Supports 11ac as well resetting value back from .ini*/ |
| 544 | sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 545 | hdd_cfg_xlate_to_csr_phy_mode(cfg_param->dot11Mode)); |
| 546 | return ; |
| 547 | } |
| 548 | |
| 549 | if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) && |
| 550 | ((eCSR_CFG_DOT11_MODE_11AC_ONLY == pHddStaCtx->conn_info.dot11Mode) || |
| 551 | (eCSR_CFG_DOT11_MODE_11AC == pHddStaCtx->conn_info.dot11Mode))) |
| 552 | { |
| 553 | VOS_STATUS vosStatus; |
| 554 | |
| 555 | // need to issue a disconnect to CSR. |
| 556 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 557 | vosStatus = sme_RoamDisconnect(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 558 | pAdapter->sessionId, |
| 559 | eCSR_DISCONNECT_REASON_UNSPECIFIED ); |
| 560 | |
| 561 | if (VOS_STATUS_SUCCESS == vosStatus) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 562 | { |
| 563 | long ret; |
| 564 | |
| 565 | ret = wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var, |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 566 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 567 | if (0 >= ret) |
| 568 | hddLog(LOGE, FL("failure waiting for disconnect_comp_var %ld"), |
| 569 | ret); |
| 570 | } |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 571 | |
| 572 | } |
| 573 | } |
| 574 | #else |
Gopichand Nakkala | dacbcb5 | 2013-04-18 16:41:54 +0530 | [diff] [blame] | 575 | void hdd_checkandupdate_phymode( hdd_adapter_t *pAdapter, char *country_code) |
| 576 | { |
| 577 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 578 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 579 | hdd_config_t *cfg_param; |
| 580 | eCsrPhyMode phyMode; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 581 | long ret; |
Gopichand Nakkala | dacbcb5 | 2013-04-18 16:41:54 +0530 | [diff] [blame] | 582 | |
| 583 | if (NULL == pHddCtx) |
| 584 | { |
| 585 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 586 | "HDD Context is null !!"); |
| 587 | return ; |
| 588 | } |
| 589 | |
| 590 | cfg_param = pHddCtx->cfg_ini; |
| 591 | |
| 592 | if (NULL == cfg_param) |
| 593 | { |
| 594 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 595 | "cfg_params not available !!"); |
| 596 | return ; |
| 597 | } |
| 598 | |
| 599 | phyMode = sme_GetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter)); |
| 600 | |
| 601 | if (NULL != strstr(cfg_param->listOfNon11acCountryCode, country_code)) |
| 602 | { |
| 603 | if ((eCSR_DOT11_MODE_AUTO == phyMode) || |
| 604 | (eCSR_DOT11_MODE_11ac == phyMode) || |
| 605 | (eCSR_DOT11_MODE_11ac_ONLY == phyMode)) |
| 606 | { |
| 607 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 608 | "Setting phymode to 11n!!"); |
| 609 | sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_DOT11_MODE_11n); |
| 610 | } |
| 611 | } |
| 612 | else |
| 613 | { |
| 614 | /*New country Supports 11ac as well resetting value back from .ini*/ |
| 615 | sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 616 | hdd_cfg_xlate_to_csr_phy_mode(cfg_param->dot11Mode)); |
| 617 | return ; |
| 618 | } |
| 619 | |
| 620 | if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) && |
| 621 | ((eCSR_CFG_DOT11_MODE_11AC_ONLY == pHddStaCtx->conn_info.dot11Mode) || |
| 622 | (eCSR_CFG_DOT11_MODE_11AC == pHddStaCtx->conn_info.dot11Mode))) |
| 623 | { |
| 624 | VOS_STATUS vosStatus; |
| 625 | |
| 626 | // need to issue a disconnect to CSR. |
| 627 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 628 | vosStatus = sme_RoamDisconnect(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 629 | pAdapter->sessionId, |
| 630 | eCSR_DISCONNECT_REASON_UNSPECIFIED ); |
| 631 | |
| 632 | if (VOS_STATUS_SUCCESS == vosStatus) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 633 | { |
| 634 | ret = wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var, |
Gopichand Nakkala | dacbcb5 | 2013-04-18 16:41:54 +0530 | [diff] [blame] | 635 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 636 | if (ret <= 0) |
| 637 | { |
| 638 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 639 | "wait on disconnect_comp_var is failed %ld", ret); |
| 640 | } |
| 641 | } |
Gopichand Nakkala | dacbcb5 | 2013-04-18 16:41:54 +0530 | [diff] [blame] | 642 | |
| 643 | } |
| 644 | } |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 645 | #endif //CONFIG_ENABLE_LINUX_REG |
Gopichand Nakkala | dacbcb5 | 2013-04-18 16:41:54 +0530 | [diff] [blame] | 646 | |
Tushnim Bhattacharyya | 9cdf608 | 2013-04-21 16:33:30 -0700 | [diff] [blame] | 647 | void hdd_checkandupdate_dfssetting( hdd_adapter_t *pAdapter, char *country_code) |
| 648 | { |
| 649 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 650 | hdd_config_t *cfg_param; |
| 651 | |
| 652 | if (NULL == pHddCtx) |
| 653 | { |
| 654 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 655 | "HDD Context is null !!"); |
| 656 | return ; |
| 657 | } |
| 658 | |
| 659 | cfg_param = pHddCtx->cfg_ini; |
| 660 | |
| 661 | if (NULL == cfg_param) |
| 662 | { |
| 663 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 664 | "cfg_params not available !!"); |
| 665 | return ; |
| 666 | } |
| 667 | |
Agarwal Ashish | 738843c | 2014-09-25 12:27:56 +0530 | [diff] [blame] | 668 | if (NULL != strstr(cfg_param->listOfNonDfsCountryCode, country_code) || |
| 669 | pHddCtx->disable_dfs_flag == TRUE) |
Tushnim Bhattacharyya | 9cdf608 | 2013-04-21 16:33:30 -0700 | [diff] [blame] | 670 | { |
| 671 | /*New country doesn't support DFS */ |
| 672 | sme_UpdateDfsSetting(WLAN_HDD_GET_HAL_CTX(pAdapter), 0); |
| 673 | } |
| 674 | else |
| 675 | { |
| 676 | /*New country Supports DFS as well resetting value back from .ini*/ |
| 677 | sme_UpdateDfsSetting(WLAN_HDD_GET_HAL_CTX(pAdapter), cfg_param->enableDFSChnlScan); |
| 678 | } |
| 679 | |
| 680 | } |
| 681 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 682 | #ifdef FEATURE_WLAN_BATCH_SCAN |
| 683 | |
| 684 | /**--------------------------------------------------------------------------- |
| 685 | |
| 686 | \brief hdd_extract_assigned_int_from_str() - Extracts assigned integer from |
| 687 | input string |
| 688 | |
| 689 | This function extracts assigned integer from string in below format: |
| 690 | "STRING=10" : extracts integer 10 from this string |
| 691 | |
| 692 | \param - pInPtr Pointer to input string |
| 693 | \param - base Base for string to int conversion(10 for decimal 16 for hex) |
| 694 | \param - pOutPtr Pointer to variable in which extracted integer needs to be |
| 695 | assigned |
| 696 | \param - pLastArg to tell whether it is last arguement in input string or |
| 697 | not |
| 698 | |
| 699 | \return - NULL for failure cases |
| 700 | pointer to next arguement in input string for success cases |
| 701 | --------------------------------------------------------------------------*/ |
| 702 | static tANI_U8 * |
| 703 | hdd_extract_assigned_int_from_str |
| 704 | ( |
| 705 | tANI_U8 *pInPtr, |
| 706 | tANI_U8 base, |
| 707 | tANI_U32 *pOutPtr, |
| 708 | tANI_U8 *pLastArg |
| 709 | ) |
| 710 | { |
| 711 | int tempInt; |
| 712 | int v = 0; |
| 713 | char buf[32]; |
| 714 | int val = 0; |
| 715 | *pLastArg = FALSE; |
| 716 | |
| 717 | pInPtr = strnchr(pInPtr, strlen(pInPtr), EQUALS_TO_ASCII_VALUE); |
| 718 | if (NULL == pInPtr) |
| 719 | { |
| 720 | return NULL; |
| 721 | } |
| 722 | |
| 723 | pInPtr++; |
| 724 | |
| 725 | while ((SPACE_ASCII_VALUE == *pInPtr) && ('\0' != *pInPtr)) pInPtr++; |
| 726 | |
| 727 | val = sscanf(pInPtr, "%32s ", buf); |
| 728 | if (val < 0 && val > strlen(pInPtr)) |
| 729 | { |
| 730 | return NULL; |
| 731 | } |
| 732 | pInPtr += val; |
| 733 | v = kstrtos32(buf, base, &tempInt); |
| 734 | if (v < 0) |
| 735 | { |
| 736 | return NULL; |
| 737 | } |
Rajeev Kumar | 4d93d84 | 2014-01-02 18:31:21 -0800 | [diff] [blame] | 738 | if (tempInt < 0) |
| 739 | { |
| 740 | tempInt = 0; |
| 741 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 742 | *pOutPtr = tempInt; |
| 743 | |
| 744 | pInPtr = strnchr(pInPtr, strlen(pInPtr), SPACE_ASCII_VALUE); |
| 745 | if (NULL == pInPtr) |
| 746 | { |
| 747 | *pLastArg = TRUE; |
| 748 | return NULL; |
| 749 | } |
| 750 | while ((SPACE_ASCII_VALUE == *pInPtr) && ('\0' != *pInPtr)) pInPtr++; |
| 751 | |
| 752 | return pInPtr; |
| 753 | } |
| 754 | |
| 755 | /**--------------------------------------------------------------------------- |
| 756 | |
| 757 | \brief hdd_extract_assigned_char_from_str() - Extracts assigned char from |
| 758 | input string |
| 759 | |
| 760 | This function extracts assigned character from string in below format: |
| 761 | "STRING=A" : extracts char 'A' from this string |
| 762 | |
| 763 | \param - pInPtr Pointer to input string |
| 764 | \param - pOutPtr Pointer to variable in which extracted char needs to be |
| 765 | assigned |
| 766 | \param - pLastArg to tell whether it is last arguement in input string or |
| 767 | not |
| 768 | |
| 769 | \return - NULL for failure cases |
| 770 | pointer to next arguement in input string for success cases |
| 771 | --------------------------------------------------------------------------*/ |
| 772 | static tANI_U8 * |
| 773 | hdd_extract_assigned_char_from_str |
| 774 | ( |
| 775 | tANI_U8 *pInPtr, |
| 776 | tANI_U8 *pOutPtr, |
| 777 | tANI_U8 *pLastArg |
| 778 | ) |
| 779 | { |
| 780 | *pLastArg = FALSE; |
| 781 | |
| 782 | pInPtr = strnchr(pInPtr, strlen(pInPtr), EQUALS_TO_ASCII_VALUE); |
| 783 | if (NULL == pInPtr) |
| 784 | { |
| 785 | return NULL; |
| 786 | } |
| 787 | |
| 788 | pInPtr++; |
| 789 | |
| 790 | while ((SPACE_ASCII_VALUE == *pInPtr) && ('\0' != *pInPtr)) pInPtr++; |
| 791 | |
| 792 | *pOutPtr = *pInPtr; |
| 793 | |
| 794 | pInPtr = strnchr(pInPtr, strlen(pInPtr), SPACE_ASCII_VALUE); |
| 795 | if (NULL == pInPtr) |
| 796 | { |
| 797 | *pLastArg = TRUE; |
| 798 | return NULL; |
| 799 | } |
| 800 | while ((SPACE_ASCII_VALUE == *pInPtr) && ('\0' != *pInPtr)) pInPtr++; |
| 801 | |
| 802 | return pInPtr; |
| 803 | } |
| 804 | |
| 805 | |
| 806 | /**--------------------------------------------------------------------------- |
| 807 | |
| 808 | \brief hdd_parse_set_batchscan_command () - HDD parse set batch scan command |
| 809 | |
| 810 | This function parses set batch scan command in below format: |
| 811 | WLS_BATCHING_SET <space> followed by below arguements |
| 812 | "SCANFREQ=XX" : Optional defaults to 30 sec |
| 813 | "MSCAN=XX" : Required number of scans to attempt to batch |
| 814 | "BESTN=XX" : Best Network (RSSI) defaults to 16 |
| 815 | "CHANNEL=<X,Y>" : optional defaults to all channels, can list 'A'or` B. |
| 816 | A. implies only 5 GHz , B. implies only 2.4GHz |
| 817 | "RTT=X" : optional defaults to 0 |
| 818 | returns the MIN of MSCAN or the max # of scans firmware can cache or -1 on |
| 819 | error |
| 820 | |
| 821 | For example input commands: |
| 822 | 1) WLS_BATCHING_SET SCANFREQ=60 MSCAN=10 BESTN=20 CHANNEL=A RTT=0 -> This is |
| 823 | translated into set batch scan with following parameters: |
| 824 | a) Frequence 60 seconds |
| 825 | b) Batch 10 scans together |
| 826 | c) Best RSSI to be 20 |
| 827 | d) 5GHz band only |
| 828 | e) RTT is equal to 0 |
| 829 | |
| 830 | \param - pValue Pointer to input channel list |
| 831 | \param - pHddSetBatchScanReq Pointer to HDD batch scan request structure |
| 832 | |
| 833 | \return - 0 for success non-zero for failure |
| 834 | |
| 835 | --------------------------------------------------------------------------*/ |
| 836 | static int |
| 837 | hdd_parse_set_batchscan_command |
| 838 | ( |
| 839 | tANI_U8 *pValue, |
| 840 | tSirSetBatchScanReq *pHddSetBatchScanReq |
| 841 | ) |
| 842 | { |
| 843 | tANI_U8 *inPtr = pValue; |
| 844 | tANI_U8 val = 0; |
| 845 | tANI_U8 lastArg = 0; |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 846 | tANI_U32 nScanFreq; |
| 847 | tANI_U32 nMscan; |
| 848 | tANI_U32 nBestN; |
| 849 | tANI_U8 ucRfBand; |
| 850 | tANI_U32 nRtt; |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 851 | tANI_U32 temp; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 852 | |
| 853 | /*initialize default values*/ |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 854 | nScanFreq = HDD_SET_BATCH_SCAN_DEFAULT_FREQ; |
| 855 | ucRfBand = HDD_SET_BATCH_SCAN_DEFAULT_BAND; |
| 856 | nRtt = 0; |
| 857 | nBestN = HDD_SET_BATCH_SCAN_BEST_NETWORK; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 858 | |
| 859 | /*go to space after WLS_BATCHING_SET command*/ |
| 860 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 861 | /*no argument after the command*/ |
| 862 | if (NULL == inPtr) |
| 863 | { |
| 864 | return -EINVAL; |
| 865 | } |
| 866 | |
| 867 | /*no space after the command*/ |
| 868 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 869 | { |
| 870 | return -EINVAL; |
| 871 | } |
| 872 | |
| 873 | /*removing empty spaces*/ |
| 874 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
| 875 | |
| 876 | /*no argument followed by spaces*/ |
| 877 | if ('\0' == *inPtr) |
| 878 | { |
| 879 | return -EINVAL; |
| 880 | } |
| 881 | |
| 882 | /*check and parse SCANFREQ*/ |
| 883 | if ((strncmp(inPtr, "SCANFREQ", 8) == 0)) |
| 884 | { |
| 885 | inPtr = hdd_extract_assigned_int_from_str(inPtr, 10, |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 886 | &temp, &lastArg); |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 887 | |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 888 | if (0 != temp) |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 889 | { |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 890 | nScanFreq = temp; |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 891 | } |
| 892 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 893 | if ( (NULL == inPtr) || (TRUE == lastArg)) |
| 894 | { |
| 895 | return -EINVAL; |
| 896 | } |
| 897 | } |
| 898 | |
| 899 | /*check and parse MSCAN*/ |
| 900 | if ((strncmp(inPtr, "MSCAN", 5) == 0)) |
| 901 | { |
| 902 | inPtr = hdd_extract_assigned_int_from_str(inPtr, 10, |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 903 | &nMscan, &lastArg); |
| 904 | |
| 905 | if (0 == nMscan) |
| 906 | { |
| 907 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 908 | "invalid MSCAN=%d", nMscan); |
| 909 | return -EINVAL; |
| 910 | } |
| 911 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 912 | if (TRUE == lastArg) |
| 913 | { |
| 914 | goto done; |
| 915 | } |
| 916 | else if (NULL == inPtr) |
| 917 | { |
| 918 | return -EINVAL; |
| 919 | } |
| 920 | } |
| 921 | else |
| 922 | { |
| 923 | return -EINVAL; |
| 924 | } |
| 925 | |
| 926 | /*check and parse BESTN*/ |
| 927 | if ((strncmp(inPtr, "BESTN", 5) == 0)) |
| 928 | { |
| 929 | inPtr = hdd_extract_assigned_int_from_str(inPtr, 10, |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 930 | &temp, &lastArg); |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 931 | |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 932 | if (0 != temp) |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 933 | { |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 934 | nBestN = temp; |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 935 | } |
| 936 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 937 | if (TRUE == lastArg) |
| 938 | { |
| 939 | goto done; |
| 940 | } |
| 941 | else if (NULL == inPtr) |
| 942 | { |
| 943 | return -EINVAL; |
| 944 | } |
| 945 | } |
| 946 | |
| 947 | /*check and parse CHANNEL*/ |
| 948 | if ((strncmp(inPtr, "CHANNEL", 7) == 0)) |
| 949 | { |
| 950 | inPtr = hdd_extract_assigned_char_from_str(inPtr, &val, &lastArg); |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 951 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 952 | if (('A' == val) || ('a' == val)) |
| 953 | { |
c_hpothu | ebf8973 | 2014-02-25 13:00:24 +0530 | [diff] [blame] | 954 | ucRfBand = HDD_SET_BATCH_SCAN_5GHz_BAND_ONLY; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 955 | } |
| 956 | else if (('B' == val) || ('b' == val)) |
| 957 | { |
c_hpothu | ebf8973 | 2014-02-25 13:00:24 +0530 | [diff] [blame] | 958 | ucRfBand = HDD_SET_BATCH_SCAN_24GHz_BAND_ONLY; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 959 | } |
| 960 | else |
| 961 | { |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 962 | ucRfBand = HDD_SET_BATCH_SCAN_DEFAULT_BAND; |
| 963 | } |
| 964 | |
| 965 | if (TRUE == lastArg) |
| 966 | { |
| 967 | goto done; |
| 968 | } |
| 969 | else if (NULL == inPtr) |
| 970 | { |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 971 | return -EINVAL; |
| 972 | } |
| 973 | } |
| 974 | |
| 975 | /*check and parse RTT*/ |
| 976 | if ((strncmp(inPtr, "RTT", 3) == 0)) |
| 977 | { |
| 978 | inPtr = hdd_extract_assigned_int_from_str(inPtr, 10, |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 979 | &nRtt, &lastArg); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 980 | if (TRUE == lastArg) |
| 981 | { |
| 982 | goto done; |
| 983 | } |
| 984 | if (NULL == inPtr) |
| 985 | { |
| 986 | return -EINVAL; |
| 987 | } |
| 988 | } |
| 989 | |
| 990 | |
| 991 | done: |
| 992 | |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 993 | pHddSetBatchScanReq->scanFrequency = nScanFreq; |
| 994 | pHddSetBatchScanReq->numberOfScansToBatch = nMscan; |
| 995 | pHddSetBatchScanReq->bestNetwork = nBestN; |
| 996 | pHddSetBatchScanReq->rfBand = ucRfBand; |
| 997 | pHddSetBatchScanReq->rtt = nRtt; |
| 998 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 999 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1000 | "Received WLS_BATCHING_SET with SCANFREQ=%d " |
| 1001 | "MSCAN=%d BESTN=%d CHANNEL=%d RTT=%d", |
| 1002 | pHddSetBatchScanReq->scanFrequency, |
| 1003 | pHddSetBatchScanReq->numberOfScansToBatch, |
| 1004 | pHddSetBatchScanReq->bestNetwork, |
| 1005 | pHddSetBatchScanReq->rfBand, |
| 1006 | pHddSetBatchScanReq->rtt); |
| 1007 | |
| 1008 | return 0; |
| 1009 | }/*End of hdd_parse_set_batchscan_command*/ |
| 1010 | |
| 1011 | /**--------------------------------------------------------------------------- |
| 1012 | |
| 1013 | \brief hdd_set_batch_scan_req_callback () - This function is called after |
| 1014 | receiving set batch scan response from FW and it saves set batch scan |
| 1015 | response data FW to HDD context and sets the completion event on |
| 1016 | which hdd_ioctl is waiting |
| 1017 | |
| 1018 | \param - callbackContext Pointer to HDD adapter |
| 1019 | \param - pRsp Pointer to set batch scan response data received from FW |
| 1020 | |
| 1021 | \return - nothing |
| 1022 | |
| 1023 | --------------------------------------------------------------------------*/ |
| 1024 | static void hdd_set_batch_scan_req_callback |
| 1025 | ( |
| 1026 | void *callbackContext, |
| 1027 | tSirSetBatchScanRsp *pRsp |
| 1028 | ) |
| 1029 | { |
| 1030 | hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext; |
| 1031 | tSirSetBatchScanRsp *pHddSetBatchScanRsp; |
| 1032 | |
| 1033 | /*sanity check*/ |
| 1034 | if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) |
| 1035 | { |
| 1036 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1037 | "%s: Invalid pAdapter magic", __func__); |
| 1038 | VOS_ASSERT(0); |
| 1039 | return; |
| 1040 | } |
| 1041 | pHddSetBatchScanRsp = &pAdapter->hddSetBatchScanRsp; |
| 1042 | |
| 1043 | /*save set batch scan response*/ |
| 1044 | pHddSetBatchScanRsp->nScansToBatch = pRsp->nScansToBatch; |
| 1045 | |
| 1046 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
| 1047 | "Received set batch scan rsp from FW with nScansToBatch=%d", |
| 1048 | pHddSetBatchScanRsp->nScansToBatch); |
| 1049 | |
| 1050 | pAdapter->hdd_wait_for_set_batch_scan_rsp = FALSE; |
| 1051 | complete(&pAdapter->hdd_set_batch_scan_req_var); |
| 1052 | |
| 1053 | return; |
| 1054 | }/*End of hdd_set_batch_scan_req_callback*/ |
| 1055 | |
| 1056 | |
| 1057 | /**--------------------------------------------------------------------------- |
| 1058 | |
| 1059 | \brief hdd_populate_batch_scan_rsp_queue () - This function stores AP meta |
| 1060 | info in hdd batch scan response queue |
| 1061 | |
| 1062 | \param - pAdapter Pointer to hdd adapter |
| 1063 | \param - pAPMetaInfo Pointer to access point meta info |
| 1064 | \param - scanId scan ID of batch scan response |
| 1065 | \param - isLastAp tells whether AP is last AP in batch scan response or not |
| 1066 | |
| 1067 | \return - nothing |
| 1068 | |
| 1069 | --------------------------------------------------------------------------*/ |
| 1070 | static void hdd_populate_batch_scan_rsp_queue( hdd_adapter_t* pAdapter, |
| 1071 | tpSirBatchScanNetworkInfo pApMetaInfo, tANI_U32 scanId, v_BOOL_t isLastAp) |
| 1072 | { |
| 1073 | tHddBatchScanRsp *pHead; |
| 1074 | tHddBatchScanRsp *pNode; |
| 1075 | tHddBatchScanRsp *pPrev; |
| 1076 | tHddBatchScanRsp *pTemp; |
| 1077 | tANI_U8 ssidLen; |
| 1078 | |
| 1079 | /*head of hdd batch scan response queue*/ |
| 1080 | pHead = pAdapter->pBatchScanRsp; |
| 1081 | |
| 1082 | pNode = (tHddBatchScanRsp *)vos_mem_malloc(sizeof(tHddBatchScanRsp)); |
| 1083 | if (NULL == pNode) |
| 1084 | { |
| 1085 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1086 | "%s: Could not allocate memory", __func__); |
| 1087 | VOS_ASSERT(0); |
| 1088 | return; |
| 1089 | } |
| 1090 | |
| 1091 | vos_mem_copy(pNode->ApInfo.bssid, pApMetaInfo->bssid, |
| 1092 | sizeof(pNode->ApInfo.bssid)); |
| 1093 | ssidLen = strlen(pApMetaInfo->ssid); |
| 1094 | if (SIR_MAX_SSID_SIZE < ssidLen) |
| 1095 | { |
| 1096 | /*invalid scan result*/ |
| 1097 | vos_mem_free(pNode); |
| 1098 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1099 | "%s: Invalid AP meta info ssidlen %d", __func__, ssidLen); |
| 1100 | return; |
| 1101 | } |
| 1102 | vos_mem_copy(pNode->ApInfo.ssid, pApMetaInfo->ssid, ssidLen); |
| 1103 | /*null terminate ssid*/ |
| 1104 | pNode->ApInfo.ssid[ssidLen] = '\0'; |
| 1105 | pNode->ApInfo.ch = pApMetaInfo->ch; |
| 1106 | pNode->ApInfo.rssi = pApMetaInfo->rssi; |
| 1107 | pNode->ApInfo.age = pApMetaInfo->timestamp; |
| 1108 | pNode->ApInfo.batchId = scanId; |
| 1109 | pNode->ApInfo.isLastAp = isLastAp; |
| 1110 | |
| 1111 | pNode->pNext = NULL; |
| 1112 | if (NULL == pHead) |
| 1113 | { |
| 1114 | pAdapter->pBatchScanRsp = pNode; |
| 1115 | } |
| 1116 | else |
| 1117 | { |
| 1118 | pTemp = pHead; |
| 1119 | while (NULL != pTemp) |
| 1120 | { |
| 1121 | pPrev = pTemp; |
| 1122 | pTemp = pTemp->pNext; |
| 1123 | } |
| 1124 | pPrev->pNext = pNode; |
| 1125 | } |
| 1126 | |
| 1127 | return; |
| 1128 | }/*End of hdd_populate_batch_scan_rsp_queue*/ |
| 1129 | |
| 1130 | /**--------------------------------------------------------------------------- |
| 1131 | |
| 1132 | \brief hdd_batch_scan_result_ind_callback () - This function is called after |
| 1133 | receiving batch scan response indication from FW. It saves get batch scan |
| 1134 | response data in HDD batch scan response queue. This callback sets the |
| 1135 | completion event on which hdd_ioctl is waiting only after getting complete |
| 1136 | batch scan response data from FW |
| 1137 | |
| 1138 | \param - callbackContext Pointer to HDD adapter |
| 1139 | \param - pRsp Pointer to get batch scan response data received from FW |
| 1140 | |
| 1141 | \return - nothing |
| 1142 | |
| 1143 | --------------------------------------------------------------------------*/ |
| 1144 | static void hdd_batch_scan_result_ind_callback |
| 1145 | ( |
| 1146 | void *callbackContext, |
| 1147 | void *pRsp |
| 1148 | ) |
| 1149 | { |
| 1150 | v_BOOL_t isLastAp; |
| 1151 | tANI_U32 numApMetaInfo; |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1152 | tANI_U32 numNetworkInScanList; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1153 | tANI_U32 numberScanList; |
| 1154 | tANI_U32 nextScanListOffset; |
| 1155 | tANI_U32 nextApMetaInfoOffset; |
| 1156 | hdd_adapter_t* pAdapter; |
| 1157 | tpSirBatchScanList pScanList; |
| 1158 | tpSirBatchScanNetworkInfo pApMetaInfo; |
| 1159 | tpSirBatchScanResultIndParam pBatchScanRsp;/*batch scan rsp data from FW*/ |
| 1160 | tSirSetBatchScanReq *pReq; |
| 1161 | |
| 1162 | pAdapter = (hdd_adapter_t *)callbackContext; |
| 1163 | /*sanity check*/ |
Rajeev Kumar | 5286bb9 | 2013-12-05 11:52:10 -0800 | [diff] [blame] | 1164 | if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)) |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1165 | { |
| 1166 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1167 | "%s: Invalid pAdapter magic", __func__); |
| 1168 | VOS_ASSERT(0); |
| 1169 | return; |
| 1170 | } |
| 1171 | |
| 1172 | /*initialize locals*/ |
| 1173 | pReq = &pAdapter->hddSetBatchScanReq; |
| 1174 | pBatchScanRsp = (tpSirBatchScanResultIndParam)pRsp; |
| 1175 | isLastAp = FALSE; |
| 1176 | numApMetaInfo = 0; |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1177 | numNetworkInScanList = 0; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1178 | numberScanList = 0; |
| 1179 | nextScanListOffset = 0; |
| 1180 | nextApMetaInfoOffset = 0; |
| 1181 | pScanList = NULL; |
| 1182 | pApMetaInfo = NULL; |
| 1183 | |
| 1184 | if ((NULL == pBatchScanRsp) || (NULL == pReq)) |
| 1185 | { |
| 1186 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1187 | "%s: pBatchScanRsp is %p pReq %p", __func__, pBatchScanRsp, pReq); |
| 1188 | isLastAp = TRUE; |
| 1189 | goto done; |
| 1190 | } |
| 1191 | |
| 1192 | pAdapter->numScanList = numberScanList = pBatchScanRsp->numScanLists; |
| 1193 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1194 | "Batch scan rsp: numberScalList %d", numberScanList); |
| 1195 | |
| 1196 | if ((!numberScanList) || (numberScanList > pReq->numberOfScansToBatch)) |
| 1197 | { |
| 1198 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1199 | "%s: numberScanList %d", __func__, numberScanList); |
| 1200 | isLastAp = TRUE; |
| 1201 | goto done; |
| 1202 | } |
| 1203 | |
| 1204 | while (numberScanList) |
| 1205 | { |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1206 | pScanList = (tpSirBatchScanList)((tANI_U8 *)pBatchScanRsp->scanResults + |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1207 | nextScanListOffset); |
| 1208 | if (NULL == pScanList) |
| 1209 | { |
| 1210 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1211 | "%s: pScanList is %p", __func__, pScanList); |
| 1212 | isLastAp = TRUE; |
| 1213 | goto done; |
| 1214 | } |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1215 | numNetworkInScanList = numApMetaInfo = pScanList->numNetworksInScanList; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1216 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1217 | "Batch scan rsp: numApMetaInfo %d scanId %d", |
| 1218 | numApMetaInfo, pScanList->scanId); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1219 | |
| 1220 | if ((!numApMetaInfo) || (numApMetaInfo > pReq->bestNetwork)) |
| 1221 | { |
| 1222 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1223 | "%s: numApMetaInfo %d", __func__, numApMetaInfo); |
| 1224 | isLastAp = TRUE; |
| 1225 | goto done; |
| 1226 | } |
| 1227 | |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1228 | /*Initialize next AP meta info offset for next scan list*/ |
| 1229 | nextApMetaInfoOffset = 0; |
| 1230 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1231 | while (numApMetaInfo) |
| 1232 | { |
| 1233 | pApMetaInfo = (tpSirBatchScanNetworkInfo)(pScanList->scanList + |
| 1234 | nextApMetaInfoOffset); |
| 1235 | if (NULL == pApMetaInfo) |
| 1236 | { |
| 1237 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1238 | "%s: pApMetaInfo is %p", __func__, pApMetaInfo); |
| 1239 | isLastAp = TRUE; |
| 1240 | goto done; |
| 1241 | } |
| 1242 | /*calculate AP age*/ |
| 1243 | pApMetaInfo->timestamp = |
| 1244 | pBatchScanRsp->timestamp - pApMetaInfo->timestamp; |
| 1245 | |
| 1246 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
Arif Hussain | a7c8e41 | 2013-11-20 11:06:42 -0800 | [diff] [blame] | 1247 | "%s: bssId "MAC_ADDRESS_STR |
| 1248 | " ch %d rssi %d timestamp %d", __func__, |
| 1249 | MAC_ADDR_ARRAY(pApMetaInfo->bssid), |
| 1250 | pApMetaInfo->ch, pApMetaInfo->rssi, |
| 1251 | pApMetaInfo->timestamp); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1252 | |
| 1253 | /*mark last AP in batch scan response*/ |
| 1254 | if ((TRUE == pBatchScanRsp->isLastResult) && |
| 1255 | (1 == numberScanList) && (1 == numApMetaInfo)) |
| 1256 | { |
| 1257 | isLastAp = TRUE; |
| 1258 | } |
| 1259 | |
| 1260 | mutex_lock(&pAdapter->hdd_batch_scan_lock); |
| 1261 | /*store batch scan repsonse in hdd queue*/ |
| 1262 | hdd_populate_batch_scan_rsp_queue(pAdapter, pApMetaInfo, |
| 1263 | pScanList->scanId, isLastAp); |
| 1264 | mutex_unlock(&pAdapter->hdd_batch_scan_lock); |
| 1265 | |
| 1266 | nextApMetaInfoOffset += sizeof(tSirBatchScanNetworkInfo); |
| 1267 | numApMetaInfo--; |
| 1268 | } |
| 1269 | |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1270 | nextScanListOffset += ((sizeof(tSirBatchScanList) - sizeof(tANI_U8)) |
| 1271 | + (sizeof(tSirBatchScanNetworkInfo) |
| 1272 | * numNetworkInScanList)); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1273 | numberScanList--; |
| 1274 | } |
| 1275 | |
| 1276 | done: |
| 1277 | |
| 1278 | /*notify hdd_ioctl only if complete batch scan rsp is received and it was |
| 1279 | requested from hdd_ioctl*/ |
| 1280 | if ((TRUE == pAdapter->hdd_wait_for_get_batch_scan_rsp) && |
| 1281 | (TRUE == isLastAp)) |
| 1282 | { |
| 1283 | pAdapter->hdd_wait_for_get_batch_scan_rsp = FALSE; |
| 1284 | complete(&pAdapter->hdd_get_batch_scan_req_var); |
| 1285 | } |
| 1286 | |
| 1287 | return; |
| 1288 | }/*End of hdd_batch_scan_result_ind_callback*/ |
| 1289 | |
| 1290 | /**--------------------------------------------------------------------------- |
| 1291 | |
| 1292 | \brief hdd_format_batch_scan_rsp () - This function formats batch scan |
| 1293 | response as per batch scan FR request format by putting proper markers |
| 1294 | |
| 1295 | \param - pDest pointer to destination buffer |
| 1296 | \param - cur_len current length |
| 1297 | \param - tot_len total remaining size which can be written to user space |
| 1298 | \param - pApMetaInfo Pointer to get batch scan response AP meta info |
| 1299 | \param - pAdapter Pointer to HDD adapter |
| 1300 | |
| 1301 | \return - ret no of characters written |
| 1302 | |
| 1303 | --------------------------------------------------------------------------*/ |
| 1304 | static tANI_U32 |
| 1305 | hdd_format_batch_scan_rsp |
| 1306 | ( |
| 1307 | tANI_U8 *pDest, |
| 1308 | tANI_U32 cur_len, |
| 1309 | tANI_U32 tot_len, |
| 1310 | tHddBatchScanRsp *pApMetaInfo, |
| 1311 | hdd_adapter_t* pAdapter |
| 1312 | ) |
| 1313 | { |
| 1314 | tANI_U32 ret = 0; |
| 1315 | tANI_U32 rem_len = 0; |
| 1316 | tANI_U8 temp_len = 0; |
| 1317 | tANI_U8 temp_total_len = 0; |
| 1318 | tANI_U8 temp[HDD_BATCH_SCAN_AP_META_INFO_SIZE]; |
| 1319 | tANI_U8 *pTemp = temp; |
| 1320 | |
| 1321 | /*Batch scan reponse needs to be returned to user space in |
| 1322 | following format: |
| 1323 | "scancount=X\n" where X is the number of scans in current batch |
| 1324 | batch |
| 1325 | "trunc\n" optional present if current scan truncated |
| 1326 | "bssid=XX:XX:XX:XX:XX:XX\n" |
| 1327 | "ssid=XXXX\n" |
| 1328 | "freq=X\n" frequency in Mhz |
| 1329 | "level=XX\n" |
| 1330 | "age=X\n" ms |
| 1331 | "dist=X\n" cm (-1 if not available) |
| 1332 | "errror=X\n" (-1if not available) |
| 1333 | "====\n" (end of ap marker) |
| 1334 | "####\n" (end of scan marker) |
| 1335 | "----\n" (end of results)*/ |
| 1336 | /*send scan result in above format to user space based on |
| 1337 | available length*/ |
| 1338 | /*The GET response may have more data than the driver can return in its |
| 1339 | buffer. In that case the buffer should be filled to the nearest complete |
| 1340 | scan, ending with "%%%%".Subsequent callsshould return the remaining data |
| 1341 | starting with the next scan (optional .trunc\n., .apcount=X\n., etc). |
| 1342 | The final buffer should end with "----\n"*/ |
| 1343 | |
| 1344 | /*sanity*/ |
| 1345 | if (cur_len > tot_len) |
| 1346 | { |
| 1347 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1348 | "%s: invaid cur_len %d tot_len %d", __func__, cur_len, tot_len); |
| 1349 | return 0; |
| 1350 | } |
| 1351 | else |
| 1352 | { |
| 1353 | rem_len = (tot_len - cur_len); |
| 1354 | } |
| 1355 | |
| 1356 | /*end scan marker*/ |
| 1357 | if (pApMetaInfo->ApInfo.batchId != pAdapter->prev_batch_id) |
| 1358 | { |
| 1359 | temp_len = snprintf(pTemp, sizeof(temp), "####\n"); |
| 1360 | pTemp += temp_len; |
| 1361 | temp_total_len += temp_len; |
| 1362 | } |
| 1363 | |
| 1364 | /*bssid*/ |
| 1365 | temp_len = snprintf(pTemp, sizeof(temp), |
| 1366 | "bssid=0x%x:0x%x:0x%x:0x%x:0x%x:0x%x\n", |
| 1367 | pApMetaInfo->ApInfo.bssid[0], pApMetaInfo->ApInfo.bssid[1], |
| 1368 | pApMetaInfo->ApInfo.bssid[2], pApMetaInfo->ApInfo.bssid[3], |
| 1369 | pApMetaInfo->ApInfo.bssid[4], pApMetaInfo->ApInfo.bssid[5]); |
| 1370 | pTemp += temp_len; |
| 1371 | temp_total_len += temp_len; |
| 1372 | |
| 1373 | /*ssid*/ |
| 1374 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "ssid=%s\n", |
| 1375 | pApMetaInfo->ApInfo.ssid); |
| 1376 | pTemp += temp_len; |
| 1377 | temp_total_len += temp_len; |
| 1378 | |
| 1379 | /*freq*/ |
| 1380 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "freq=%d\n", |
Rajeev Kumar | c40f751 | 2013-11-04 14:13:23 -0800 | [diff] [blame] | 1381 | sme_ChnToFreq(pApMetaInfo->ApInfo.ch)); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1382 | pTemp += temp_len; |
| 1383 | temp_total_len += temp_len; |
| 1384 | |
| 1385 | /*level*/ |
| 1386 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "level=%d\n", |
| 1387 | pApMetaInfo->ApInfo.rssi); |
| 1388 | pTemp += temp_len; |
| 1389 | temp_total_len += temp_len; |
| 1390 | |
| 1391 | /*age*/ |
Jeff Johnson | 0279779 | 2013-10-26 19:17:13 -0700 | [diff] [blame] | 1392 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "age=%d\n", |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1393 | pApMetaInfo->ApInfo.age); |
| 1394 | pTemp += temp_len; |
| 1395 | temp_total_len += temp_len; |
| 1396 | |
| 1397 | /*dist*/ |
| 1398 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "dist=-1\n"); |
| 1399 | pTemp += temp_len; |
| 1400 | temp_total_len += temp_len; |
| 1401 | |
| 1402 | /*error*/ |
| 1403 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "error=-1\n"); |
| 1404 | pTemp += temp_len; |
| 1405 | temp_total_len += temp_len; |
| 1406 | |
| 1407 | /*end AP marker*/ |
| 1408 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "====\n"); |
| 1409 | pTemp += temp_len; |
| 1410 | temp_total_len += temp_len; |
| 1411 | |
| 1412 | /*last AP in batch scan response*/ |
| 1413 | if(TRUE == pApMetaInfo->ApInfo.isLastAp) |
| 1414 | { |
| 1415 | /*end scan marker*/ |
| 1416 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "####\n"); |
| 1417 | pTemp += temp_len; |
| 1418 | temp_total_len += temp_len; |
| 1419 | |
| 1420 | /*end batch scan result marker*/ |
| 1421 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "----\n"); |
| 1422 | pTemp += temp_len; |
| 1423 | temp_total_len += temp_len; |
Kiet Lam | aa8e15a | 2014-02-11 23:30:06 -0800 | [diff] [blame] | 1424 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1425 | } |
| 1426 | |
| 1427 | if (temp_total_len < rem_len) |
| 1428 | { |
| 1429 | ret = temp_total_len + 1; |
| 1430 | strlcpy(pDest, temp, ret); |
| 1431 | pAdapter->isTruncated = FALSE; |
| 1432 | } |
| 1433 | else |
| 1434 | { |
| 1435 | pAdapter->isTruncated = TRUE; |
| 1436 | if (rem_len >= strlen("%%%%")) |
| 1437 | { |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 1438 | ret = snprintf(pDest, sizeof(temp), "%%%%"); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1439 | } |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 1440 | else |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1441 | { |
| 1442 | ret = 0; |
| 1443 | } |
| 1444 | } |
| 1445 | |
| 1446 | return ret; |
| 1447 | |
| 1448 | }/*End of hdd_format_batch_scan_rsp*/ |
| 1449 | |
| 1450 | /**--------------------------------------------------------------------------- |
| 1451 | |
| 1452 | \brief hdd_populate_user_batch_scan_rsp() - This function populates user data |
| 1453 | buffer starting with head of hdd batch scan response queue |
| 1454 | |
| 1455 | \param - pAdapter Pointer to HDD adapter |
| 1456 | \param - pDest Pointer to user data buffer |
| 1457 | \param - cur_len current offset in user buffer |
| 1458 | \param - rem_len remaining no of bytes in user buffer |
| 1459 | |
| 1460 | \return - number of bytes written in user buffer |
| 1461 | |
| 1462 | --------------------------------------------------------------------------*/ |
| 1463 | |
| 1464 | tANI_U32 hdd_populate_user_batch_scan_rsp |
| 1465 | ( |
| 1466 | hdd_adapter_t* pAdapter, |
| 1467 | tANI_U8 *pDest, |
| 1468 | tANI_U32 cur_len, |
| 1469 | tANI_U32 rem_len |
| 1470 | ) |
| 1471 | { |
| 1472 | tHddBatchScanRsp *pHead; |
| 1473 | tHddBatchScanRsp *pPrev; |
| 1474 | tANI_U32 len; |
| 1475 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1476 | pAdapter->isTruncated = FALSE; |
| 1477 | |
| 1478 | /*head of hdd batch scan response queue*/ |
| 1479 | pHead = pAdapter->pBatchScanRsp; |
| 1480 | while (pHead) |
| 1481 | { |
| 1482 | len = hdd_format_batch_scan_rsp(pDest, cur_len, rem_len, pHead, |
| 1483 | pAdapter); |
| 1484 | pDest += len; |
Rajeev Kumar | 292d2bb | 2013-10-23 15:01:44 -0700 | [diff] [blame] | 1485 | pDest--; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1486 | cur_len += len; |
| 1487 | if(TRUE == pAdapter->isTruncated) |
| 1488 | { |
| 1489 | /*result is truncated return rest of scan rsp in next req*/ |
| 1490 | cur_len = rem_len; |
| 1491 | break; |
| 1492 | } |
| 1493 | pPrev = pHead; |
| 1494 | pHead = pHead->pNext; |
| 1495 | pAdapter->pBatchScanRsp = pHead; |
Rajeev Kumar | be17d8b | 2014-01-10 15:39:45 -0800 | [diff] [blame] | 1496 | if (TRUE == pPrev->ApInfo.isLastAp) |
| 1497 | { |
| 1498 | pAdapter->prev_batch_id = 0; |
| 1499 | } |
| 1500 | else |
| 1501 | { |
| 1502 | pAdapter->prev_batch_id = pPrev->ApInfo.batchId; |
| 1503 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1504 | vos_mem_free(pPrev); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 1505 | pPrev = NULL; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1506 | } |
| 1507 | |
| 1508 | return cur_len; |
| 1509 | }/*End of hdd_populate_user_batch_scan_rsp*/ |
| 1510 | |
| 1511 | /**--------------------------------------------------------------------------- |
| 1512 | |
| 1513 | \brief hdd_return_batch_scan_rsp_to_user () - This function returns batch |
| 1514 | scan response data from HDD queue to user space |
| 1515 | It does following in detail: |
| 1516 | a) if HDD has enough data in its queue then it 1st copies data to user |
| 1517 | space and then send get batch scan indication message to FW. In this |
| 1518 | case it does not wait on any event and batch scan response data will |
| 1519 | be populated in HDD response queue in MC thread context after receiving |
| 1520 | indication from FW |
| 1521 | b) else send get batch scan indication message to FW and wait on an event |
| 1522 | which will be set once HDD receives complete batch scan response from |
| 1523 | FW and then this function returns batch scan response to user space |
| 1524 | |
| 1525 | \param - pAdapter Pointer to HDD adapter |
| 1526 | \param - pPrivData Pointer to priv_data |
| 1527 | |
| 1528 | \return - 0 for success -EFAULT for failure |
| 1529 | |
| 1530 | --------------------------------------------------------------------------*/ |
| 1531 | |
| 1532 | int hdd_return_batch_scan_rsp_to_user |
| 1533 | ( |
| 1534 | hdd_adapter_t* pAdapter, |
| 1535 | hdd_priv_data_t *pPrivData, |
| 1536 | tANI_U8 *command |
| 1537 | ) |
| 1538 | { |
| 1539 | tANI_U8 *pDest; |
| 1540 | tANI_U32 count = 0; |
| 1541 | tANI_U32 len = 0; |
| 1542 | tANI_U32 cur_len = 0; |
| 1543 | tANI_U32 rem_len = 0; |
| 1544 | eHalStatus halStatus; |
| 1545 | unsigned long rc; |
| 1546 | tSirTriggerBatchScanResultInd *pReq; |
| 1547 | |
| 1548 | pReq = &pAdapter->hddTriggerBatchScanResultInd; |
| 1549 | pReq->param = 0;/*batch scan client*/ |
| 1550 | pDest = (tANI_U8 *)(command + pPrivData->used_len); |
| 1551 | pAdapter->hdd_wait_for_get_batch_scan_rsp = FALSE; |
| 1552 | |
| 1553 | cur_len = pPrivData->used_len; |
| 1554 | if (pPrivData->total_len > pPrivData->used_len) |
| 1555 | { |
| 1556 | rem_len = pPrivData->total_len - pPrivData->used_len; |
| 1557 | } |
| 1558 | else |
| 1559 | { |
| 1560 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1561 | "%s: Invalid user data buffer total_len %d used_len %d", |
| 1562 | __func__, pPrivData->total_len, pPrivData->used_len); |
| 1563 | return -EFAULT; |
| 1564 | } |
| 1565 | |
| 1566 | mutex_lock(&pAdapter->hdd_batch_scan_lock); |
| 1567 | len = hdd_populate_user_batch_scan_rsp(pAdapter, pDest, |
| 1568 | cur_len, rem_len); |
| 1569 | mutex_unlock(&pAdapter->hdd_batch_scan_lock); |
| 1570 | |
| 1571 | /*enough scan result available in cache to return to user space or |
| 1572 | scan result needs to be fetched 1st from fw and then return*/ |
Rajeev Kumar | 99db626 | 2013-11-11 15:23:36 -0800 | [diff] [blame] | 1573 | if (len == cur_len) |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1574 | { |
| 1575 | pAdapter->hdd_wait_for_get_batch_scan_rsp = TRUE; |
| 1576 | halStatus = sme_TriggerBatchScanResultInd( |
| 1577 | WLAN_HDD_GET_HAL_CTX(pAdapter), pReq, |
| 1578 | pAdapter->sessionId, hdd_batch_scan_result_ind_callback, |
| 1579 | pAdapter); |
| 1580 | if ( eHAL_STATUS_SUCCESS == halStatus ) |
| 1581 | { |
| 1582 | if (TRUE == pAdapter->hdd_wait_for_get_batch_scan_rsp) |
| 1583 | { |
| 1584 | INIT_COMPLETION(pAdapter->hdd_get_batch_scan_req_var); |
| 1585 | rc = wait_for_completion_timeout( |
| 1586 | &pAdapter->hdd_get_batch_scan_req_var, |
| 1587 | msecs_to_jiffies(HDD_GET_BATCH_SCAN_RSP_TIME_OUT)); |
| 1588 | if (0 == rc) |
| 1589 | { |
| 1590 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1591 | "%s: Timeout waiting to fetch batch scan rsp from fw", |
| 1592 | __func__); |
| 1593 | return -EFAULT; |
| 1594 | } |
| 1595 | } |
| 1596 | |
| 1597 | len = snprintf(pDest, HDD_BATCH_SCAN_AP_META_INFO_SIZE, |
Jeff Johnson | 0279779 | 2013-10-26 19:17:13 -0700 | [diff] [blame] | 1598 | "scancount=%u\n", pAdapter->numScanList); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1599 | pDest += len; |
| 1600 | cur_len += len; |
| 1601 | |
| 1602 | mutex_lock(&pAdapter->hdd_batch_scan_lock); |
| 1603 | len = hdd_populate_user_batch_scan_rsp(pAdapter, pDest, |
| 1604 | cur_len, rem_len); |
| 1605 | mutex_unlock(&pAdapter->hdd_batch_scan_lock); |
| 1606 | |
| 1607 | count = 0; |
| 1608 | len = (len - pPrivData->used_len); |
| 1609 | pDest = (command + pPrivData->used_len); |
| 1610 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Rajeev Kumar | 99db626 | 2013-11-11 15:23:36 -0800 | [diff] [blame] | 1611 | "NEW BATCH SCAN RESULT:"); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1612 | while(count < len) |
| 1613 | { |
| 1614 | printk("%c", *(pDest + count)); |
| 1615 | count++; |
| 1616 | } |
| 1617 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1618 | "%s: copy %d data to user buffer", __func__, len); |
| 1619 | if (copy_to_user(pPrivData->buf, pDest, len)) |
| 1620 | { |
| 1621 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1622 | "%s: failed to copy data to user buffer", __func__); |
| 1623 | return -EFAULT; |
| 1624 | } |
| 1625 | } |
| 1626 | else |
| 1627 | { |
| 1628 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1629 | "sme_GetBatchScanScan returned failure halStatus %d", |
| 1630 | halStatus); |
| 1631 | return -EINVAL; |
| 1632 | } |
| 1633 | } |
| 1634 | else |
| 1635 | { |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1636 | count = 0; |
| 1637 | len = (len - pPrivData->used_len); |
| 1638 | pDest = (command + pPrivData->used_len); |
| 1639 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Rajeev Kumar | 99db626 | 2013-11-11 15:23:36 -0800 | [diff] [blame] | 1640 | "REMAINING TRUNCATED BATCH SCAN RESULT:"); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1641 | while(count < len) |
| 1642 | { |
| 1643 | printk("%c", *(pDest + count)); |
| 1644 | count++; |
| 1645 | } |
Rajeev Kumar | 99db626 | 2013-11-11 15:23:36 -0800 | [diff] [blame] | 1646 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1647 | "%s: copy %d data to user buffer", __func__, len); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1648 | if (copy_to_user(pPrivData->buf, pDest, len)) |
| 1649 | { |
| 1650 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1651 | "%s: failed to copy data to user buffer", __func__); |
| 1652 | return -EFAULT; |
| 1653 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1654 | } |
| 1655 | |
| 1656 | return 0; |
| 1657 | } /*End of hdd_return_batch_scan_rsp_to_user*/ |
| 1658 | |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 1659 | |
| 1660 | /**--------------------------------------------------------------------------- |
| 1661 | |
| 1662 | \brief hdd_handle_batch_scan_ioctl () - This function handles WLS_BATCHING |
| 1663 | IOCTLs from user space. Following BATCH SCAN DEV IOCTs are handled: |
| 1664 | WLS_BATCHING VERSION |
| 1665 | WLS_BATCHING SET |
| 1666 | WLS_BATCHING GET |
| 1667 | WLS_BATCHING STOP |
| 1668 | |
| 1669 | \param - pAdapter Pointer to HDD adapter |
| 1670 | \param - pPrivdata Pointer to priv_data |
| 1671 | \param - command Pointer to command |
| 1672 | |
| 1673 | \return - 0 for success -EFAULT for failure |
| 1674 | |
| 1675 | --------------------------------------------------------------------------*/ |
| 1676 | |
| 1677 | int hdd_handle_batch_scan_ioctl |
| 1678 | ( |
| 1679 | hdd_adapter_t *pAdapter, |
| 1680 | hdd_priv_data_t *pPrivdata, |
| 1681 | tANI_U8 *command |
| 1682 | ) |
| 1683 | { |
| 1684 | int ret = 0; |
Yue Ma | e36e355 | 2014-03-05 17:06:20 -0800 | [diff] [blame] | 1685 | hdd_context_t *pHddCtx; |
| 1686 | |
| 1687 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 1688 | ret = wlan_hdd_validate_context(pHddCtx); |
| 1689 | if (ret) |
| 1690 | { |
| 1691 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1692 | "%s: HDD context is not valid!", __func__); |
| 1693 | goto exit; |
| 1694 | } |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 1695 | |
| 1696 | if (strncmp(command, "WLS_BATCHING VERSION", 20) == 0) |
| 1697 | { |
| 1698 | char extra[32]; |
| 1699 | tANI_U8 len = 0; |
| 1700 | tANI_U8 version = HDD_BATCH_SCAN_VERSION; |
| 1701 | |
| 1702 | if (FALSE == sme_IsFeatureSupportedByFW(BATCH_SCAN)) |
| 1703 | { |
| 1704 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1705 | "%s: Batch scan feature is not supported by FW", __func__); |
| 1706 | ret = -EINVAL; |
| 1707 | goto exit; |
| 1708 | } |
| 1709 | |
| 1710 | len = scnprintf(extra, sizeof(extra), "WLS_BATCHING_VERSION %d", |
| 1711 | version); |
| 1712 | if (copy_to_user(pPrivdata->buf, &extra, len + 1)) |
| 1713 | { |
| 1714 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1715 | "%s: failed to copy data to user buffer", __func__); |
| 1716 | ret = -EFAULT; |
| 1717 | goto exit; |
| 1718 | } |
| 1719 | ret = HDD_BATCH_SCAN_VERSION; |
| 1720 | } |
| 1721 | else if (strncmp(command, "WLS_BATCHING SET", 16) == 0) |
| 1722 | { |
| 1723 | int status; |
| 1724 | tANI_U8 *value = (command + 16); |
| 1725 | eHalStatus halStatus; |
| 1726 | unsigned long rc; |
| 1727 | tSirSetBatchScanReq *pReq = &pAdapter->hddSetBatchScanReq; |
| 1728 | tSirSetBatchScanRsp *pRsp = &pAdapter->hddSetBatchScanRsp; |
| 1729 | |
| 1730 | if (FALSE == sme_IsFeatureSupportedByFW(BATCH_SCAN)) |
| 1731 | { |
| 1732 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1733 | "%s: Batch scan feature is not supported by FW", __func__); |
| 1734 | ret = -EINVAL; |
| 1735 | goto exit; |
| 1736 | } |
| 1737 | |
| 1738 | if ((WLAN_HDD_INFRA_STATION != pAdapter->device_mode) && |
| 1739 | (WLAN_HDD_P2P_CLIENT != pAdapter->device_mode) && |
| 1740 | (WLAN_HDD_P2P_GO != pAdapter->device_mode) && |
| 1741 | (WLAN_HDD_P2P_DEVICE != pAdapter->device_mode)) |
| 1742 | { |
| 1743 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 1744 | "Received WLS_BATCHING SET command in invalid mode %s (%d) " |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 1745 | "WLS_BATCHING_SET is only allowed in infra STA/P2P client mode", |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 1746 | hdd_device_modetoString(pAdapter->device_mode), |
| 1747 | pAdapter->device_mode); |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 1748 | ret = -EINVAL; |
| 1749 | goto exit; |
| 1750 | } |
| 1751 | |
| 1752 | status = hdd_parse_set_batchscan_command(value, pReq); |
| 1753 | if (status) |
| 1754 | { |
| 1755 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1756 | "Invalid WLS_BATCHING SET command"); |
| 1757 | ret = -EINVAL; |
| 1758 | goto exit; |
| 1759 | } |
| 1760 | |
| 1761 | |
| 1762 | pAdapter->hdd_wait_for_set_batch_scan_rsp = TRUE; |
| 1763 | halStatus = sme_SetBatchScanReq(WLAN_HDD_GET_HAL_CTX(pAdapter), pReq, |
| 1764 | pAdapter->sessionId, hdd_set_batch_scan_req_callback, |
| 1765 | pAdapter); |
| 1766 | |
| 1767 | if ( eHAL_STATUS_SUCCESS == halStatus ) |
| 1768 | { |
Mahesh A Saptasagar | 5f56817 | 2014-05-14 17:02:33 +0530 | [diff] [blame] | 1769 | char extra[32]; |
| 1770 | tANI_U8 len = 0; |
| 1771 | tANI_U8 mScan = 0; |
| 1772 | |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 1773 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 1774 | "sme_SetBatchScanReq returned success halStatus %d", |
| 1775 | halStatus); |
| 1776 | if (TRUE == pAdapter->hdd_wait_for_set_batch_scan_rsp) |
| 1777 | { |
| 1778 | INIT_COMPLETION(pAdapter->hdd_set_batch_scan_req_var); |
| 1779 | rc = wait_for_completion_timeout( |
| 1780 | &pAdapter->hdd_set_batch_scan_req_var, |
| 1781 | msecs_to_jiffies(HDD_SET_BATCH_SCAN_REQ_TIME_OUT)); |
| 1782 | if (0 == rc) |
| 1783 | { |
| 1784 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1785 | "%s: Timeout waiting for set batch scan to complete", |
| 1786 | __func__); |
| 1787 | ret = -EINVAL; |
| 1788 | goto exit; |
| 1789 | } |
| 1790 | } |
| 1791 | if ( !pRsp->nScansToBatch ) |
| 1792 | { |
| 1793 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1794 | "%s: Received set batch scan failure response from FW", |
| 1795 | __func__); |
| 1796 | ret = -EINVAL; |
| 1797 | goto exit; |
| 1798 | } |
| 1799 | /*As per the Batch Scan Framework API we should return the MIN of |
| 1800 | either MSCAN or the max # of scans firmware can cache*/ |
Mahesh A Saptasagar | 5f56817 | 2014-05-14 17:02:33 +0530 | [diff] [blame] | 1801 | mScan = MIN(pReq->numberOfScansToBatch , pRsp->nScansToBatch); |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 1802 | |
| 1803 | pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STARTED; |
| 1804 | |
| 1805 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1806 | "%s: request MSCAN %d response MSCAN %d ret %d", |
Mahesh A Saptasagar | 5f56817 | 2014-05-14 17:02:33 +0530 | [diff] [blame] | 1807 | __func__, pReq->numberOfScansToBatch, pRsp->nScansToBatch, mScan); |
| 1808 | len = scnprintf(extra, sizeof(extra), "%d", mScan); |
| 1809 | if (copy_to_user(pPrivdata->buf, &extra, len + 1)) |
| 1810 | { |
| 1811 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1812 | "%s: failed to copy MSCAN value to user buffer", __func__); |
| 1813 | ret = -EFAULT; |
| 1814 | goto exit; |
| 1815 | } |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 1816 | } |
| 1817 | else |
| 1818 | { |
| 1819 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1820 | "sme_SetBatchScanReq returned failure halStatus %d", |
| 1821 | halStatus); |
| 1822 | ret = -EINVAL; |
| 1823 | goto exit; |
| 1824 | } |
| 1825 | } |
| 1826 | else if (strncmp(command, "WLS_BATCHING STOP", 17) == 0) |
| 1827 | { |
| 1828 | eHalStatus halStatus; |
| 1829 | tSirStopBatchScanInd *pInd = &pAdapter->hddStopBatchScanInd; |
| 1830 | pInd->param = 0; |
| 1831 | |
| 1832 | if (FALSE == sme_IsFeatureSupportedByFW(BATCH_SCAN)) |
| 1833 | { |
| 1834 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1835 | "%s: Batch scan feature is not supported by FW", __func__); |
| 1836 | ret = -EINVAL; |
| 1837 | goto exit; |
| 1838 | } |
| 1839 | |
| 1840 | if (eHDD_BATCH_SCAN_STATE_STARTED != pAdapter->batchScanState) |
| 1841 | { |
Deepthi Gowri | bfd1713 | 2014-11-14 17:59:04 +0530 | [diff] [blame] | 1842 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 1843 | "Batch scan is not yet enabled batch scan state %d", |
| 1844 | pAdapter->batchScanState); |
| 1845 | ret = -EINVAL; |
| 1846 | goto exit; |
| 1847 | } |
| 1848 | |
Kiet Lam | aa8e15a | 2014-02-11 23:30:06 -0800 | [diff] [blame] | 1849 | mutex_lock(&pAdapter->hdd_batch_scan_lock); |
| 1850 | hdd_deinit_batch_scan(pAdapter); |
| 1851 | mutex_unlock(&pAdapter->hdd_batch_scan_lock); |
| 1852 | |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 1853 | pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STOPPED; |
| 1854 | |
| 1855 | halStatus = sme_StopBatchScanInd(WLAN_HDD_GET_HAL_CTX(pAdapter), pInd, |
| 1856 | pAdapter->sessionId); |
| 1857 | if ( eHAL_STATUS_SUCCESS == halStatus ) |
| 1858 | { |
| 1859 | ret = 0; |
| 1860 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 1861 | "sme_StopBatchScanInd returned success halStatus %d", |
| 1862 | halStatus); |
| 1863 | } |
| 1864 | else |
| 1865 | { |
| 1866 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1867 | "sme_StopBatchScanInd returned failure halStatus %d", |
| 1868 | halStatus); |
| 1869 | ret = -EINVAL; |
| 1870 | goto exit; |
| 1871 | } |
| 1872 | } |
| 1873 | else if (strncmp(command, "WLS_BATCHING GET", 16) == 0) |
| 1874 | { |
| 1875 | tANI_U32 remain_len; |
| 1876 | |
| 1877 | if (FALSE == sme_IsFeatureSupportedByFW(BATCH_SCAN)) |
| 1878 | { |
| 1879 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1880 | "%s: Batch scan feature is not supported by FW", __func__); |
| 1881 | ret = -EINVAL; |
| 1882 | goto exit; |
| 1883 | } |
| 1884 | |
| 1885 | if (eHDD_BATCH_SCAN_STATE_STARTED != pAdapter->batchScanState) |
| 1886 | { |
Deepthi Gowri | bfd1713 | 2014-11-14 17:59:04 +0530 | [diff] [blame] | 1887 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 1888 | "Batch scan is not yet enabled could not return results" |
| 1889 | "Batch Scan state %d", |
| 1890 | pAdapter->batchScanState); |
| 1891 | ret = -EINVAL; |
| 1892 | goto exit; |
| 1893 | } |
| 1894 | |
| 1895 | pPrivdata->used_len = 16; |
| 1896 | remain_len = pPrivdata->total_len - pPrivdata->used_len; |
| 1897 | if (remain_len < pPrivdata->total_len) |
| 1898 | { |
| 1899 | /*Clear previous batch scan response data if any*/ |
| 1900 | vos_mem_zero((tANI_U8 *)(command + pPrivdata->used_len), remain_len); |
| 1901 | } |
| 1902 | else |
| 1903 | { |
| 1904 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1905 | "Invalid total length from user space can't fetch batch" |
| 1906 | " scan response total_len %d used_len %d remain len %d", |
| 1907 | pPrivdata->total_len, pPrivdata->used_len, remain_len); |
| 1908 | ret = -EINVAL; |
| 1909 | goto exit; |
| 1910 | } |
| 1911 | ret = hdd_return_batch_scan_rsp_to_user(pAdapter, pPrivdata, command); |
| 1912 | } |
| 1913 | |
| 1914 | exit: |
| 1915 | |
| 1916 | return ret; |
| 1917 | } |
| 1918 | |
| 1919 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1920 | #endif/*End of FEATURE_WLAN_BATCH_SCAN*/ |
| 1921 | |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 1922 | static void getBcnMissRateCB(VOS_STATUS status, int bcnMissRate, void *data) |
| 1923 | { |
c_hpothu | 39eb1e3 | 2014-06-26 16:31:50 +0530 | [diff] [blame] | 1924 | bcnMissRateContext_t *pCBCtx; |
| 1925 | |
| 1926 | if (NULL == data) |
| 1927 | { |
| 1928 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("argument data is NULL")); |
| 1929 | return; |
| 1930 | } |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 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 | |
c_hpothu | 39eb1e3 | 2014-06-26 16:31:50 +0530 | [diff] [blame] | 1938 | pCBCtx = (bcnMissRateContext_t *)data; |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 1939 | gbcnMissRate = -1; |
| 1940 | |
c_hpothu | 39eb1e3 | 2014-06-26 16:31:50 +0530 | [diff] [blame] | 1941 | if (pCBCtx->magic != BCN_MISS_RATE_CONTEXT_MAGIC) |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 1942 | { |
| 1943 | hddLog(VOS_TRACE_LEVEL_ERROR, |
c_hpothu | 39eb1e3 | 2014-06-26 16:31:50 +0530 | [diff] [blame] | 1944 | FL("invalid context magic: %08x"), pCBCtx->magic); |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 1945 | spin_unlock(&hdd_context_lock); |
| 1946 | return ; |
| 1947 | } |
| 1948 | |
| 1949 | if (VOS_STATUS_SUCCESS == status) |
| 1950 | { |
c_hpothu | 39eb1e3 | 2014-06-26 16:31:50 +0530 | [diff] [blame] | 1951 | gbcnMissRate = bcnMissRate; |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 1952 | } |
c_hpothu | 39eb1e3 | 2014-06-26 16:31:50 +0530 | [diff] [blame] | 1953 | else |
| 1954 | { |
| 1955 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("failed to get bcnMissRate")); |
| 1956 | } |
| 1957 | |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 1958 | complete(&(pCBCtx->completion)); |
| 1959 | spin_unlock(&hdd_context_lock); |
| 1960 | |
| 1961 | return; |
| 1962 | } |
| 1963 | |
Abhishek Singh | 08aa776 | 2014-12-16 13:59:03 +0530 | [diff] [blame] | 1964 | void hdd_FWStatisCB( VOS_STATUS status, |
| 1965 | tSirFwStatsResult *fwStatsResult, void *pContext ) |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 1966 | { |
| 1967 | fwStatsContext_t *fwStatsCtx; |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 1968 | hdd_adapter_t *pAdapter; |
| 1969 | |
| 1970 | hddLog(VOS_TRACE_LEVEL_INFO, FL(" with status = %d"),status); |
| 1971 | |
Abhishek Singh | 08aa776 | 2014-12-16 13:59:03 +0530 | [diff] [blame] | 1972 | if (NULL == pContext) |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 1973 | { |
| 1974 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("argument data is NULL")); |
| 1975 | return; |
| 1976 | } |
| 1977 | /* there is a race condition that exists between this callback |
| 1978 | function and the caller since the caller could time out either |
| 1979 | before or while this code is executing. we use a spinlock to |
| 1980 | serialize these actions */ |
| 1981 | spin_lock(&hdd_context_lock); |
Abhishek Singh | 08aa776 | 2014-12-16 13:59:03 +0530 | [diff] [blame] | 1982 | fwStatsCtx = (fwStatsContext_t *) pContext; |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 1983 | if (fwStatsCtx->magic != FW_STATS_CONTEXT_MAGIC) |
| 1984 | { |
| 1985 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1986 | FL("invalid context magic: %08x"), fwStatsCtx->magic); |
| 1987 | spin_unlock(&hdd_context_lock); |
| 1988 | return; |
| 1989 | } |
| 1990 | pAdapter = fwStatsCtx->pAdapter; |
| 1991 | if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)) |
| 1992 | { |
| 1993 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1994 | FL("pAdapter returned is NULL or invalid")); |
| 1995 | spin_unlock(&hdd_context_lock); |
| 1996 | return; |
| 1997 | } |
| 1998 | pAdapter->fwStatsRsp.type = 0; |
Abhishek Singh | 08aa776 | 2014-12-16 13:59:03 +0530 | [diff] [blame] | 1999 | if ((VOS_STATUS_SUCCESS == status) && (NULL != fwStatsResult)) |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 2000 | { |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 2001 | switch( fwStatsResult->type ) |
| 2002 | { |
| 2003 | case FW_UBSP_STATS: |
| 2004 | { |
Abhishek Singh | 08aa776 | 2014-12-16 13:59:03 +0530 | [diff] [blame] | 2005 | memcpy(&pAdapter->fwStatsRsp,fwStatsResult,sizeof(tSirFwStatsResult)); |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 2006 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 2007 | FL("ubsp_enter_cnt = %d ubsp_jump_ddr_cnt = %d"), |
Abhishek Singh | 08aa776 | 2014-12-16 13:59:03 +0530 | [diff] [blame] | 2008 | pAdapter->fwStatsRsp.fwStatsData.ubspStats.ubsp_enter_cnt, |
| 2009 | pAdapter->fwStatsRsp.fwStatsData.ubspStats.ubsp_jump_ddr_cnt); |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 2010 | } |
| 2011 | break; |
| 2012 | default: |
| 2013 | { |
| 2014 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2015 | FL(" No handling for stats type %d"),fwStatsResult->type); |
| 2016 | } |
| 2017 | } |
| 2018 | } |
| 2019 | complete(&(fwStatsCtx->completion)); |
| 2020 | spin_unlock(&hdd_context_lock); |
| 2021 | return; |
| 2022 | } |
| 2023 | |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2024 | static int hdd_get_dwell_time(hdd_config_t *pCfg, tANI_U8 *command, char *extra, tANI_U8 n, tANI_U8 *len) |
| 2025 | { |
| 2026 | int ret = 0; |
| 2027 | |
| 2028 | if (!pCfg || !command || !extra || !len) |
| 2029 | { |
| 2030 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2031 | "%s: argument passsed for GETDWELLTIME is incorrect", __func__); |
| 2032 | ret = -EINVAL; |
| 2033 | return ret; |
| 2034 | } |
| 2035 | |
| 2036 | if (strncmp(command, "GETDWELLTIME ACTIVE MAX", 23) == 0) |
| 2037 | { |
| 2038 | *len = scnprintf(extra, n, "GETDWELLTIME ACTIVE MAX %u\n", |
| 2039 | (int)pCfg->nActiveMaxChnTime); |
| 2040 | return ret; |
| 2041 | } |
| 2042 | else if (strncmp(command, "GETDWELLTIME ACTIVE MIN", 23) == 0) |
| 2043 | { |
| 2044 | *len = scnprintf(extra, n, "GETDWELLTIME ACTIVE MIN %u\n", |
| 2045 | (int)pCfg->nActiveMinChnTime); |
| 2046 | return ret; |
| 2047 | } |
| 2048 | else if (strncmp(command, "GETDWELLTIME PASSIVE MAX", 24) == 0) |
| 2049 | { |
| 2050 | *len = scnprintf(extra, n, "GETDWELLTIME PASSIVE MAX %u\n", |
| 2051 | (int)pCfg->nPassiveMaxChnTime); |
| 2052 | return ret; |
| 2053 | } |
| 2054 | else if (strncmp(command, "GETDWELLTIME PASSIVE MIN", 24) == 0) |
| 2055 | { |
| 2056 | *len = scnprintf(extra, n, "GETDWELLTIME PASSIVE MIN %u\n", |
| 2057 | (int)pCfg->nPassiveMinChnTime); |
| 2058 | return ret; |
| 2059 | } |
Rajesh Babu Prathipati | 0fd227e | 2014-07-05 12:50:00 +0530 | [diff] [blame] | 2060 | else if (strncmp(command, "GETDWELLTIME", 12) == 0) |
| 2061 | { |
| 2062 | *len = scnprintf(extra, n, "GETDWELLTIME %u \n", |
| 2063 | (int)pCfg->nActiveMaxChnTime); |
| 2064 | return ret; |
| 2065 | } |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2066 | else |
| 2067 | { |
| 2068 | ret = -EINVAL; |
| 2069 | } |
| 2070 | |
| 2071 | return ret; |
| 2072 | } |
| 2073 | |
| 2074 | static int hdd_set_dwell_time(hdd_adapter_t *pAdapter, tANI_U8 *command) |
| 2075 | { |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 2076 | tHalHandle hHal; |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2077 | hdd_config_t *pCfg; |
| 2078 | tANI_U8 *value = command; |
| 2079 | int val = 0, ret = 0, temp = 0; |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 2080 | tSmeConfigParams smeConfig; |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2081 | |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 2082 | if (!pAdapter || !command || !(pCfg = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini) |
| 2083 | || !(hHal = (WLAN_HDD_GET_HAL_CTX(pAdapter)))) |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2084 | { |
| 2085 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2086 | "%s: argument passed for SETDWELLTIME is incorrect", __func__); |
| 2087 | ret = -EINVAL; |
| 2088 | return ret; |
| 2089 | } |
| 2090 | |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 2091 | vos_mem_zero(&smeConfig, sizeof(smeConfig)); |
| 2092 | sme_GetConfigParam(hHal, &smeConfig); |
| 2093 | |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2094 | if (strncmp(command, "SETDWELLTIME ACTIVE MAX", 23) == 0 ) |
| 2095 | { |
| 2096 | value = value + 24; |
| 2097 | temp = kstrtou32(value, 10, &val); |
| 2098 | if (temp != 0 || val < CFG_ACTIVE_MAX_CHANNEL_TIME_MIN || |
| 2099 | val > CFG_ACTIVE_MAX_CHANNEL_TIME_MAX ) |
| 2100 | { |
| 2101 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2102 | "%s: argument passed for SETDWELLTIME ACTIVE MAX is incorrect", __func__); |
| 2103 | ret = -EFAULT; |
| 2104 | return ret; |
| 2105 | } |
| 2106 | pCfg->nActiveMaxChnTime = val; |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 2107 | smeConfig.csrConfig.nActiveMaxChnTime = val; |
| 2108 | sme_UpdateConfig(hHal, &smeConfig); |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2109 | } |
| 2110 | else if (strncmp(command, "SETDWELLTIME ACTIVE MIN", 23) == 0) |
| 2111 | { |
| 2112 | value = value + 24; |
| 2113 | temp = kstrtou32(value, 10, &val); |
| 2114 | if (temp !=0 || val < CFG_ACTIVE_MIN_CHANNEL_TIME_MIN || |
| 2115 | val > CFG_ACTIVE_MIN_CHANNEL_TIME_MAX ) |
| 2116 | { |
| 2117 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2118 | "%s: argument passsed for SETDWELLTIME ACTIVE MIN is incorrect", __func__); |
| 2119 | ret = -EFAULT; |
| 2120 | return ret; |
| 2121 | } |
| 2122 | pCfg->nActiveMinChnTime = val; |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 2123 | smeConfig.csrConfig.nActiveMinChnTime = val; |
| 2124 | sme_UpdateConfig(hHal, &smeConfig); |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2125 | } |
| 2126 | else if (strncmp(command, "SETDWELLTIME PASSIVE MAX", 24) == 0) |
| 2127 | { |
| 2128 | value = value + 25; |
| 2129 | temp = kstrtou32(value, 10, &val); |
| 2130 | if (temp != 0 || val < CFG_PASSIVE_MAX_CHANNEL_TIME_MIN || |
| 2131 | val > CFG_PASSIVE_MAX_CHANNEL_TIME_MAX ) |
| 2132 | { |
| 2133 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2134 | "%s: argument passed for SETDWELLTIME PASSIVE MAX is incorrect", __func__); |
| 2135 | ret = -EFAULT; |
| 2136 | return ret; |
| 2137 | } |
| 2138 | pCfg->nPassiveMaxChnTime = val; |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 2139 | smeConfig.csrConfig.nPassiveMaxChnTime = val; |
| 2140 | sme_UpdateConfig(hHal, &smeConfig); |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2141 | } |
| 2142 | else if (strncmp(command, "SETDWELLTIME PASSIVE MIN", 24) == 0) |
| 2143 | { |
| 2144 | value = value + 25; |
| 2145 | temp = kstrtou32(value, 10, &val); |
| 2146 | if (temp != 0 || val < CFG_PASSIVE_MIN_CHANNEL_TIME_MIN || |
| 2147 | val > CFG_PASSIVE_MIN_CHANNEL_TIME_MAX ) |
| 2148 | { |
| 2149 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2150 | "%s: argument passed for SETDWELLTIME PASSIVE MIN is incorrect", __func__); |
| 2151 | ret = -EFAULT; |
| 2152 | return ret; |
| 2153 | } |
| 2154 | pCfg->nPassiveMinChnTime = val; |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 2155 | smeConfig.csrConfig.nPassiveMinChnTime = val; |
| 2156 | sme_UpdateConfig(hHal, &smeConfig); |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2157 | } |
Rajesh Babu Prathipati | 0fd227e | 2014-07-05 12:50:00 +0530 | [diff] [blame] | 2158 | else if (strncmp(command, "SETDWELLTIME", 12) == 0) |
| 2159 | { |
| 2160 | value = value + 13; |
| 2161 | temp = kstrtou32(value, 10, &val); |
| 2162 | if (temp != 0 || val < CFG_ACTIVE_MAX_CHANNEL_TIME_MIN || |
| 2163 | val > CFG_ACTIVE_MAX_CHANNEL_TIME_MAX ) |
| 2164 | { |
| 2165 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2166 | "%s: argument passed for SETDWELLTIME is incorrect", __func__); |
| 2167 | ret = -EFAULT; |
| 2168 | return ret; |
| 2169 | } |
| 2170 | pCfg->nActiveMaxChnTime = val; |
| 2171 | smeConfig.csrConfig.nActiveMaxChnTime = val; |
| 2172 | sme_UpdateConfig(hHal, &smeConfig); |
| 2173 | } |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2174 | else |
| 2175 | { |
| 2176 | ret = -EINVAL; |
| 2177 | } |
| 2178 | |
| 2179 | return ret; |
| 2180 | } |
| 2181 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2182 | static int hdd_driver_command(hdd_adapter_t *pAdapter, |
| 2183 | hdd_priv_data_t *ppriv_data) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2184 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2185 | hdd_priv_data_t priv_data; |
| 2186 | tANI_U8 *command = NULL; |
Kaushik, Sushant | 9612244 | 2014-10-21 16:40:18 +0530 | [diff] [blame] | 2187 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2188 | hdd_scaninfo_t *pScanInfo = NULL; |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2189 | int ret = 0; |
Kaushik, Sushant | 9612244 | 2014-10-21 16:40:18 +0530 | [diff] [blame] | 2190 | int status; |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2191 | /* |
| 2192 | * Note that valid pointers are provided by caller |
| 2193 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2194 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2195 | /* copy to local struct to avoid numerous changes to legacy code */ |
| 2196 | priv_data = *ppriv_data; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2197 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2198 | if (priv_data.total_len <= 0 || |
| 2199 | priv_data.total_len > WLAN_PRIV_DATA_MAX_LEN) |
Sameer Thalappil | 8ef3a0e | 2013-04-05 14:36:04 -0700 | [diff] [blame] | 2200 | { |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2201 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 2202 | "%s:invalid priv_data.total_len(%d)!!!", __func__, |
| 2203 | priv_data.total_len); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 2204 | ret = -EINVAL; |
| 2205 | goto exit; |
| 2206 | } |
Kaushik, Sushant | 9612244 | 2014-10-21 16:40:18 +0530 | [diff] [blame] | 2207 | status = wlan_hdd_validate_context(pHddCtx); |
| 2208 | if (0 != status) |
| 2209 | { |
| 2210 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2211 | "%s: HDD context is not valid", __func__); |
| 2212 | return status; |
| 2213 | } |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 2214 | /* Allocate +1 for '\0' */ |
| 2215 | command = kmalloc(priv_data.total_len + 1, GFP_KERNEL); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2216 | if (!command) |
| 2217 | { |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2218 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2219 | "%s: failed to allocate memory", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2220 | ret = -ENOMEM; |
| 2221 | goto exit; |
| 2222 | } |
| 2223 | |
| 2224 | if (copy_from_user(command, priv_data.buf, priv_data.total_len)) |
| 2225 | { |
| 2226 | ret = -EFAULT; |
| 2227 | goto exit; |
| 2228 | } |
| 2229 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2230 | /* Make sure the command is NUL-terminated */ |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 2231 | command[priv_data.total_len] = '\0'; |
| 2232 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2233 | /* at one time the following block of code was conditional. braces |
| 2234 | * have been retained to avoid re-indenting the legacy code |
| 2235 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2236 | { |
| 2237 | hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx; |
| 2238 | |
| 2239 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | f9bdd4e | 2012-10-30 18:05:03 -0700 | [diff] [blame] | 2240 | "%s: Received %s cmd from Wi-Fi GUI***", __func__, command); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2241 | |
| 2242 | if (strncmp(command, "P2P_DEV_ADDR", 12) == 0 ) |
| 2243 | { |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2244 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2245 | TRACE_CODE_HDD_P2P_DEV_ADDR_IOCTL, |
| 2246 | pAdapter->sessionId, (unsigned) |
| 2247 | (*(pHddCtx->p2pDeviceAddress.bytes+2)<<24 | |
| 2248 | *(pHddCtx->p2pDeviceAddress.bytes+3)<<16 | |
| 2249 | *(pHddCtx->p2pDeviceAddress.bytes+4)<<8 | |
| 2250 | *(pHddCtx->p2pDeviceAddress.bytes+5)))); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2251 | if (copy_to_user(priv_data.buf, pHddCtx->p2pDeviceAddress.bytes, |
| 2252 | sizeof(tSirMacAddr))) |
| 2253 | { |
| 2254 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2255 | "%s: failed to copy data to user buffer", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2256 | ret = -EFAULT; |
| 2257 | } |
| 2258 | } |
Amar Singhal | 0974e40 | 2013-02-12 14:27:46 -0800 | [diff] [blame] | 2259 | else if(strncmp(command, "SETBAND", 7) == 0) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2260 | { |
Amar Singhal | 0974e40 | 2013-02-12 14:27:46 -0800 | [diff] [blame] | 2261 | tANI_U8 *ptr = command ; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2262 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2263 | /* Change band request received */ |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2264 | |
| 2265 | /* First 8 bytes will have "SETBAND " and |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2266 | * 9 byte will have band setting value */ |
Madan Mohan Koyyalamudi | 8bdd311 | 2012-09-24 13:55:14 -0700 | [diff] [blame] | 2267 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Amar Singhal | 0974e40 | 2013-02-12 14:27:46 -0800 | [diff] [blame] | 2268 | "%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] | 2269 | /* Change band request received */ |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2270 | ret = hdd_setBand_helper(pAdapter->dev, ptr); |
Abhishek Singh | 2ec36ab | 2014-08-07 16:14:25 +0530 | [diff] [blame] | 2271 | if(ret < 0) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 2272 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2273 | "%s: failed to set band ret=%d", __func__, ret); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2274 | } |
Kiet Lam | f040f47 | 2013-11-20 21:15:23 +0530 | [diff] [blame] | 2275 | else if(strncmp(command, "SETWMMPS", 8) == 0) |
| 2276 | { |
| 2277 | tANI_U8 *ptr = command; |
| 2278 | ret = hdd_wmmps_helper(pAdapter, ptr); |
| 2279 | } |
Agarwal Ashish | ef54a18 | 2014-12-16 15:07:31 +0530 | [diff] [blame] | 2280 | |
| 2281 | else if(strncmp(command, "TDLSSCAN", 8) == 0) |
| 2282 | { |
| 2283 | tANI_U8 *ptr = command; |
| 2284 | ret = hdd_set_tdls_scan_type(pAdapter, ptr); |
| 2285 | } |
| 2286 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2287 | else if ( strncasecmp(command, "COUNTRY", 7) == 0 ) |
| 2288 | { |
| 2289 | char *country_code; |
| 2290 | |
| 2291 | country_code = command + 8; |
Tushnim Bhattacharyya | 9cdf608 | 2013-04-21 16:33:30 -0700 | [diff] [blame] | 2292 | |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 2293 | INIT_COMPLETION(pAdapter->change_country_code); |
Tushnim Bhattacharyya | 9cdf608 | 2013-04-21 16:33:30 -0700 | [diff] [blame] | 2294 | hdd_checkandupdate_dfssetting(pAdapter, country_code); |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 2295 | #ifndef CONFIG_ENABLE_LINUX_REG |
Gopichand Nakkala | dacbcb5 | 2013-04-18 16:41:54 +0530 | [diff] [blame] | 2296 | hdd_checkandupdate_phymode(pAdapter, country_code); |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 2297 | #endif |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 2298 | ret = (int)sme_ChangeCountryCode(pHddCtx->hHal, |
| 2299 | (void *)(tSmeChangeCountryCallback) |
| 2300 | wlan_hdd_change_country_code_callback, |
Abhishek Singh | a306a44 | 2013-11-07 18:39:01 +0530 | [diff] [blame] | 2301 | country_code, pAdapter, pHddCtx->pvosContext, eSIR_TRUE, eSIR_TRUE); |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 2302 | if (eHAL_STATUS_SUCCESS == ret) |
| 2303 | { |
| 2304 | ret = wait_for_completion_interruptible_timeout( |
| 2305 | &pAdapter->change_country_code, |
| 2306 | msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY)); |
| 2307 | if (0 >= ret) |
| 2308 | { |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2309 | 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] | 2310 | __func__, ret); |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 2311 | } |
| 2312 | } |
| 2313 | else |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2314 | { |
| 2315 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2316 | "%s: SME Change Country code fail ret=%d", __func__, ret); |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 2317 | ret = -EINVAL; |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2318 | } |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 2319 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 2320 | } |
| 2321 | /* |
| 2322 | command should be a string having format |
| 2323 | SET_SAP_CHANNEL_LIST <num of channels> <the channels seperated by spaces> |
| 2324 | */ |
Amar Singhal | 0974e40 | 2013-02-12 14:27:46 -0800 | [diff] [blame] | 2325 | else if(strncmp(command, "SET_SAP_CHANNEL_LIST", 20) == 0) |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 2326 | { |
Amar Singhal | 0974e40 | 2013-02-12 14:27:46 -0800 | [diff] [blame] | 2327 | tANI_U8 *ptr = command; |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 2328 | |
| 2329 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 2330 | " Received Command to Set Preferred Channels for SAP in %s", __func__); |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 2331 | |
Mahesh Kumar Kalikot Veetil | 2aad8d8 | 2013-02-07 12:31:28 -0800 | [diff] [blame] | 2332 | ret = sapSetPreferredChannel(ptr); |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2333 | } |
Sameer Thalappil | 45931fb | 2013-02-01 11:18:05 -0800 | [diff] [blame] | 2334 | else if(strncmp(command, "SETSUSPENDMODE", 14) == 0) |
| 2335 | { |
| 2336 | int suspend = 0; |
| 2337 | tANI_U8 *ptr = (tANI_U8*)command + 15; |
| 2338 | |
| 2339 | suspend = *ptr - '0'; |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2340 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2341 | TRACE_CODE_HDD_SETSUSPENDMODE_IOCTL, |
| 2342 | pAdapter->sessionId, suspend)); |
Sameer Thalappil | 45931fb | 2013-02-01 11:18:05 -0800 | [diff] [blame] | 2343 | hdd_set_wlan_suspend_mode(suspend); |
| 2344 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2345 | #ifdef WLAN_FEATURE_NEIGHBOR_ROAMING |
| 2346 | else if (strncmp(command, "SETROAMTRIGGER", 14) == 0) |
| 2347 | { |
| 2348 | tANI_U8 *value = command; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2349 | tANI_S8 rssi = 0; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2350 | tANI_U8 lookUpThreshold = CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_DEFAULT; |
| 2351 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 2352 | |
| 2353 | /* Move pointer to ahead of SETROAMTRIGGER<delimiter> */ |
| 2354 | value = value + 15; |
| 2355 | |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2356 | /* Convert the value from ascii to integer */ |
| 2357 | ret = kstrtos8(value, 10, &rssi); |
| 2358 | if (ret < 0) |
| 2359 | { |
| 2360 | /* If the input value is greater than max value of datatype, then also |
| 2361 | kstrtou8 fails */ |
| 2362 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2363 | "%s: kstrtou8 failed Input value may be out of range[%d - %d]", |
Srinivas Girigowda | fa7157d | 2013-10-31 10:14:22 -0700 | [diff] [blame] | 2364 | __func__, |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2365 | CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MIN, |
| 2366 | CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MAX); |
| 2367 | ret = -EINVAL; |
| 2368 | goto exit; |
| 2369 | } |
| 2370 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2371 | lookUpThreshold = abs(rssi); |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2372 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2373 | if ((lookUpThreshold < CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MIN) || |
| 2374 | (lookUpThreshold > CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MAX)) |
| 2375 | { |
| 2376 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2377 | "Neighbor lookup threshold value %d is out of range" |
| 2378 | " (Min: %d Max: %d)", lookUpThreshold, |
| 2379 | CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MIN, |
| 2380 | CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MAX); |
| 2381 | ret = -EINVAL; |
| 2382 | goto exit; |
| 2383 | } |
| 2384 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2385 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2386 | TRACE_CODE_HDD_SETROAMTRIGGER_IOCTL, |
| 2387 | pAdapter->sessionId, lookUpThreshold)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2388 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2389 | "%s: Received Command to Set Roam trigger" |
| 2390 | " (Neighbor lookup threshold) = %d", __func__, lookUpThreshold); |
| 2391 | |
| 2392 | pHddCtx->cfg_ini->nNeighborLookupRssiThreshold = lookUpThreshold; |
| 2393 | status = sme_setNeighborLookupRssiThreshold((tHalHandle)(pHddCtx->hHal), lookUpThreshold); |
| 2394 | if (eHAL_STATUS_SUCCESS != status) |
| 2395 | { |
| 2396 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2397 | "%s: Failed to set roam trigger, try again", __func__); |
| 2398 | ret = -EPERM; |
| 2399 | goto exit; |
| 2400 | } |
| 2401 | |
| 2402 | /* Set Reassoc threshold to (lookup rssi threshold + 5 dBm) */ |
mukul sharma | d6e1fdd | 2014-06-23 19:19:09 +0530 | [diff] [blame] | 2403 | pHddCtx->cfg_ini->nNeighborReassocRssiThreshold = lookUpThreshold + 5; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2404 | sme_setNeighborReassocRssiThreshold((tHalHandle)(pHddCtx->hHal), lookUpThreshold + 5); |
| 2405 | } |
| 2406 | else if (strncmp(command, "GETROAMTRIGGER", 14) == 0) |
| 2407 | { |
| 2408 | tANI_U8 lookUpThreshold = sme_getNeighborLookupRssiThreshold((tHalHandle)(pHddCtx->hHal)); |
| 2409 | int rssi = (-1) * lookUpThreshold; |
| 2410 | char extra[32]; |
| 2411 | tANI_U8 len = 0; |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2412 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2413 | TRACE_CODE_HDD_GETROAMTRIGGER_IOCTL, |
| 2414 | pAdapter->sessionId, lookUpThreshold)); |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2415 | len = scnprintf(extra, sizeof(extra), "%s %d", command, rssi); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2416 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2417 | { |
| 2418 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2419 | "%s: failed to copy data to user buffer", __func__); |
| 2420 | ret = -EFAULT; |
| 2421 | goto exit; |
| 2422 | } |
| 2423 | } |
| 2424 | else if (strncmp(command, "SETROAMSCANPERIOD", 17) == 0) |
| 2425 | { |
| 2426 | tANI_U8 *value = command; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2427 | tANI_U8 roamScanPeriod = 0; |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2428 | tANI_U16 neighborEmptyScanRefreshPeriod = CFG_EMPTY_SCAN_REFRESH_PERIOD_DEFAULT; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2429 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2430 | /* input refresh period is in terms of seconds */ |
| 2431 | /* Move pointer to ahead of SETROAMSCANPERIOD<delimiter> */ |
| 2432 | value = value + 18; |
| 2433 | /* Convert the value from ascii to integer */ |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2434 | ret = kstrtou8(value, 10, &roamScanPeriod); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2435 | if (ret < 0) |
| 2436 | { |
| 2437 | /* 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] | 2438 | kstrtou8 fails */ |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2439 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2440 | "%s: kstrtou8 failed Input value may be out of range[%d - %d]", |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2441 | __func__, |
Srinivas Girigowda | b8edd1e | 2013-03-19 11:42:08 -0700 | [diff] [blame] | 2442 | (CFG_EMPTY_SCAN_REFRESH_PERIOD_MIN/1000), |
| 2443 | (CFG_EMPTY_SCAN_REFRESH_PERIOD_MAX/1000)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2444 | ret = -EINVAL; |
| 2445 | goto exit; |
| 2446 | } |
| 2447 | |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2448 | if ((roamScanPeriod < (CFG_EMPTY_SCAN_REFRESH_PERIOD_MIN/1000)) || |
| 2449 | (roamScanPeriod > (CFG_EMPTY_SCAN_REFRESH_PERIOD_MAX/1000))) |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2450 | { |
| 2451 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2452 | "Roam scan period value %d is out of range" |
| 2453 | " (Min: %d Max: %d)", roamScanPeriod, |
Srinivas Girigowda | b8edd1e | 2013-03-19 11:42:08 -0700 | [diff] [blame] | 2454 | (CFG_EMPTY_SCAN_REFRESH_PERIOD_MIN/1000), |
| 2455 | (CFG_EMPTY_SCAN_REFRESH_PERIOD_MAX/1000)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2456 | ret = -EINVAL; |
| 2457 | goto exit; |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2458 | } |
| 2459 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2460 | TRACE_CODE_HDD_SETROAMSCANPERIOD_IOCTL, |
| 2461 | pAdapter->sessionId, roamScanPeriod)); |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2462 | neighborEmptyScanRefreshPeriod = roamScanPeriod * 1000; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2463 | |
| 2464 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2465 | "%s: Received Command to Set roam scan period" |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2466 | " (Empty Scan refresh period) = %d", __func__, roamScanPeriod); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2467 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2468 | pHddCtx->cfg_ini->nEmptyScanRefreshPeriod = neighborEmptyScanRefreshPeriod; |
| 2469 | sme_UpdateEmptyScanRefreshPeriod((tHalHandle)(pHddCtx->hHal), neighborEmptyScanRefreshPeriod); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2470 | } |
| 2471 | else if (strncmp(command, "GETROAMSCANPERIOD", 17) == 0) |
| 2472 | { |
| 2473 | tANI_U16 nEmptyScanRefreshPeriod = sme_getEmptyScanRefreshPeriod((tHalHandle)(pHddCtx->hHal)); |
| 2474 | char extra[32]; |
| 2475 | tANI_U8 len = 0; |
| 2476 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2477 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2478 | TRACE_CODE_HDD_GETROAMSCANPERIOD_IOCTL, |
| 2479 | pAdapter->sessionId, nEmptyScanRefreshPeriod)); |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2480 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 2481 | "GETROAMSCANPERIOD", (nEmptyScanRefreshPeriod/1000)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2482 | /* Returned value is in units of seconds */ |
| 2483 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2484 | { |
| 2485 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2486 | "%s: failed to copy data to user buffer", __func__); |
| 2487 | ret = -EFAULT; |
| 2488 | goto exit; |
| 2489 | } |
| 2490 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2491 | else if (strncmp(command, "SETROAMSCANREFRESHPERIOD", 24) == 0) |
| 2492 | { |
| 2493 | tANI_U8 *value = command; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2494 | tANI_U8 roamScanRefreshPeriod = 0; |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2495 | tANI_U16 neighborScanRefreshPeriod = CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_DEFAULT; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2496 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2497 | /* input refresh period is in terms of seconds */ |
| 2498 | /* Move pointer to ahead of SETROAMSCANREFRESHPERIOD<delimiter> */ |
| 2499 | value = value + 25; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2500 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2501 | /* Convert the value from ascii to integer */ |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2502 | ret = kstrtou8(value, 10, &roamScanRefreshPeriod); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2503 | if (ret < 0) |
| 2504 | { |
| 2505 | /* 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] | 2506 | kstrtou8 fails */ |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2507 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2508 | "%s: kstrtou8 failed Input value may be out of range[%d - %d]", |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2509 | __func__, |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2510 | (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MIN/1000), |
| 2511 | (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MAX/1000)); |
| 2512 | ret = -EINVAL; |
| 2513 | goto exit; |
| 2514 | } |
| 2515 | |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2516 | if ((roamScanRefreshPeriod < (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MIN/1000)) || |
| 2517 | (roamScanRefreshPeriod > (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MAX/1000))) |
| 2518 | { |
| 2519 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2520 | "Neighbor scan results refresh period value %d is out of range" |
| 2521 | " (Min: %d Max: %d)", roamScanRefreshPeriod, |
| 2522 | (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MIN/1000), |
| 2523 | (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MAX/1000)); |
| 2524 | ret = -EINVAL; |
| 2525 | goto exit; |
| 2526 | } |
| 2527 | neighborScanRefreshPeriod = roamScanRefreshPeriod * 1000; |
| 2528 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2529 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2530 | "%s: Received Command to Set roam scan refresh period" |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2531 | " (Scan refresh period) = %d", __func__, roamScanRefreshPeriod); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2532 | |
| 2533 | pHddCtx->cfg_ini->nNeighborResultsRefreshPeriod = neighborScanRefreshPeriod; |
| 2534 | sme_setNeighborScanRefreshPeriod((tHalHandle)(pHddCtx->hHal), neighborScanRefreshPeriod); |
| 2535 | } |
| 2536 | else if (strncmp(command, "GETROAMSCANREFRESHPERIOD", 24) == 0) |
| 2537 | { |
| 2538 | tANI_U16 value = sme_getNeighborScanRefreshPeriod((tHalHandle)(pHddCtx->hHal)); |
| 2539 | char extra[32]; |
| 2540 | tANI_U8 len = 0; |
| 2541 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2542 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 2543 | "GETROAMSCANREFRESHPERIOD", (value/1000)); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2544 | /* Returned value is in units of seconds */ |
| 2545 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2546 | { |
| 2547 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2548 | "%s: failed to copy data to user buffer", __func__); |
| 2549 | ret = -EFAULT; |
| 2550 | goto exit; |
| 2551 | } |
| 2552 | } |
Varun Reddy Yeturu | 6d99ac8 | 2013-05-08 14:15:35 -0700 | [diff] [blame] | 2553 | #ifdef FEATURE_WLAN_LFR |
| 2554 | /* SETROAMMODE */ |
| 2555 | else if (strncmp(command, "SETROAMMODE", SIZE_OF_SETROAMMODE) == 0) |
| 2556 | { |
| 2557 | tANI_U8 *value = command; |
| 2558 | tANI_BOOLEAN roamMode = CFG_LFR_FEATURE_ENABLED_DEFAULT; |
| 2559 | |
| 2560 | /* Move pointer to ahead of SETROAMMODE<delimiter> */ |
| 2561 | value = value + SIZE_OF_SETROAMMODE + 1; |
| 2562 | |
| 2563 | /* Convert the value from ascii to integer */ |
| 2564 | ret = kstrtou8(value, SIZE_OF_SETROAMMODE, &roamMode); |
| 2565 | if (ret < 0) |
| 2566 | { |
| 2567 | /* If the input value is greater than max value of datatype, then also |
| 2568 | kstrtou8 fails */ |
| 2569 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2570 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 2571 | CFG_LFR_FEATURE_ENABLED_MIN, |
| 2572 | CFG_LFR_FEATURE_ENABLED_MAX); |
| 2573 | ret = -EINVAL; |
| 2574 | goto exit; |
| 2575 | } |
| 2576 | if ((roamMode < CFG_LFR_FEATURE_ENABLED_MIN) || |
| 2577 | (roamMode > CFG_LFR_FEATURE_ENABLED_MAX)) |
| 2578 | { |
| 2579 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2580 | "Roam Mode value %d is out of range" |
| 2581 | " (Min: %d Max: %d)", roamMode, |
| 2582 | CFG_LFR_FEATURE_ENABLED_MIN, |
| 2583 | CFG_LFR_FEATURE_ENABLED_MAX); |
| 2584 | ret = -EINVAL; |
| 2585 | goto exit; |
| 2586 | } |
| 2587 | |
| 2588 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2589 | "%s: Received Command to Set Roam Mode = %d", __func__, roamMode); |
| 2590 | /* |
| 2591 | * Note that |
| 2592 | * SETROAMMODE 0 is to enable LFR while |
| 2593 | * SETROAMMODE 1 is to disable LFR, but |
| 2594 | * NotifyIsFastRoamIniFeatureEnabled 0/1 is to enable/disable. |
| 2595 | * So, we have to invert the value to call sme_UpdateIsFastRoamIniFeatureEnabled. |
| 2596 | */ |
| 2597 | if (CFG_LFR_FEATURE_ENABLED_MIN == roamMode) |
| 2598 | roamMode = CFG_LFR_FEATURE_ENABLED_MAX; /* Roam enable */ |
| 2599 | else |
| 2600 | roamMode = CFG_LFR_FEATURE_ENABLED_MIN; /* Roam disable */ |
| 2601 | |
| 2602 | pHddCtx->cfg_ini->isFastRoamIniFeatureEnabled = roamMode; |
| 2603 | sme_UpdateIsFastRoamIniFeatureEnabled((tHalHandle)(pHddCtx->hHal), roamMode); |
| 2604 | } |
| 2605 | /* GETROAMMODE */ |
| 2606 | else if (strncmp(priv_data.buf, "GETROAMMODE", SIZE_OF_GETROAMMODE) == 0) |
| 2607 | { |
| 2608 | tANI_BOOLEAN roamMode = sme_getIsLfrFeatureEnabled((tHalHandle)(pHddCtx->hHal)); |
| 2609 | char extra[32]; |
| 2610 | tANI_U8 len = 0; |
| 2611 | |
| 2612 | /* |
| 2613 | * roamMode value shall be inverted because the sementics is different. |
| 2614 | */ |
| 2615 | if (CFG_LFR_FEATURE_ENABLED_MIN == roamMode) |
| 2616 | roamMode = CFG_LFR_FEATURE_ENABLED_MAX; |
| 2617 | else |
| 2618 | roamMode = CFG_LFR_FEATURE_ENABLED_MIN; |
| 2619 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2620 | len = scnprintf(extra, sizeof(extra), "%s %d", command, roamMode); |
Varun Reddy Yeturu | 6d99ac8 | 2013-05-08 14:15:35 -0700 | [diff] [blame] | 2621 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2622 | { |
| 2623 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2624 | "%s: failed to copy data to user buffer", __func__); |
| 2625 | ret = -EFAULT; |
| 2626 | goto exit; |
| 2627 | } |
| 2628 | } |
| 2629 | #endif |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2630 | #endif |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2631 | #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] | 2632 | else if (strncmp(command, "SETROAMDELTA", 12) == 0) |
| 2633 | { |
| 2634 | tANI_U8 *value = command; |
| 2635 | tANI_U8 roamRssiDiff = CFG_ROAM_RSSI_DIFF_DEFAULT; |
| 2636 | |
| 2637 | /* Move pointer to ahead of SETROAMDELTA<delimiter> */ |
| 2638 | value = value + 13; |
| 2639 | /* Convert the value from ascii to integer */ |
| 2640 | ret = kstrtou8(value, 10, &roamRssiDiff); |
| 2641 | if (ret < 0) |
| 2642 | { |
| 2643 | /* If the input value is greater than max value of datatype, then also |
| 2644 | kstrtou8 fails */ |
| 2645 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2646 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 2647 | CFG_ROAM_RSSI_DIFF_MIN, |
| 2648 | CFG_ROAM_RSSI_DIFF_MAX); |
| 2649 | ret = -EINVAL; |
| 2650 | goto exit; |
| 2651 | } |
| 2652 | |
| 2653 | if ((roamRssiDiff < CFG_ROAM_RSSI_DIFF_MIN) || |
| 2654 | (roamRssiDiff > CFG_ROAM_RSSI_DIFF_MAX)) |
| 2655 | { |
| 2656 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2657 | "Roam rssi diff value %d is out of range" |
| 2658 | " (Min: %d Max: %d)", roamRssiDiff, |
| 2659 | CFG_ROAM_RSSI_DIFF_MIN, |
| 2660 | CFG_ROAM_RSSI_DIFF_MAX); |
| 2661 | ret = -EINVAL; |
| 2662 | goto exit; |
| 2663 | } |
| 2664 | |
| 2665 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2666 | "%s: Received Command to Set roam rssi diff = %d", __func__, roamRssiDiff); |
| 2667 | |
| 2668 | pHddCtx->cfg_ini->RoamRssiDiff = roamRssiDiff; |
| 2669 | sme_UpdateRoamRssiDiff((tHalHandle)(pHddCtx->hHal), roamRssiDiff); |
| 2670 | } |
| 2671 | else if (strncmp(priv_data.buf, "GETROAMDELTA", 12) == 0) |
| 2672 | { |
| 2673 | tANI_U8 roamRssiDiff = sme_getRoamRssiDiff((tHalHandle)(pHddCtx->hHal)); |
| 2674 | char extra[32]; |
| 2675 | tANI_U8 len = 0; |
| 2676 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2677 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2678 | TRACE_CODE_HDD_GETROAMDELTA_IOCTL, |
| 2679 | pAdapter->sessionId, roamRssiDiff)); |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2680 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 2681 | command, roamRssiDiff); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2682 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2683 | { |
| 2684 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2685 | "%s: failed to copy data to user buffer", __func__); |
| 2686 | ret = -EFAULT; |
| 2687 | goto exit; |
| 2688 | } |
| 2689 | } |
| 2690 | #endif |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2691 | #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] | 2692 | else if (strncmp(command, "GETBAND", 7) == 0) |
| 2693 | { |
| 2694 | int band = -1; |
| 2695 | char extra[32]; |
| 2696 | tANI_U8 len = 0; |
| 2697 | hdd_getBand_helper(pHddCtx, &band); |
| 2698 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2699 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2700 | TRACE_CODE_HDD_GETBAND_IOCTL, |
| 2701 | pAdapter->sessionId, band)); |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2702 | len = scnprintf(extra, sizeof(extra), "%s %d", command, band); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2703 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2704 | { |
| 2705 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2706 | "%s: failed to copy data to user buffer", __func__); |
| 2707 | ret = -EFAULT; |
| 2708 | goto exit; |
| 2709 | } |
| 2710 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2711 | else if (strncmp(command, "SETROAMSCANCHANNELS", 19) == 0) |
| 2712 | { |
| 2713 | tANI_U8 *value = command; |
| 2714 | tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0}; |
| 2715 | tANI_U8 numChannels = 0; |
| 2716 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 2717 | |
| 2718 | status = hdd_parse_channellist(value, ChannelList, &numChannels); |
| 2719 | if (eHAL_STATUS_SUCCESS != status) |
| 2720 | { |
| 2721 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2722 | "%s: Failed to parse channel list information", __func__); |
| 2723 | ret = -EINVAL; |
| 2724 | goto exit; |
| 2725 | } |
| 2726 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2727 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2728 | TRACE_CODE_HDD_SETROAMSCANCHANNELS_IOCTL, |
| 2729 | pAdapter->sessionId, numChannels)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2730 | if (numChannels > WNI_CFG_VALID_CHANNEL_LIST_LEN) |
| 2731 | { |
| 2732 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2733 | "%s: number of channels (%d) supported exceeded max (%d)", __func__, |
| 2734 | numChannels, WNI_CFG_VALID_CHANNEL_LIST_LEN); |
| 2735 | ret = -EINVAL; |
| 2736 | goto exit; |
| 2737 | } |
| 2738 | status = sme_ChangeRoamScanChannelList((tHalHandle)(pHddCtx->hHal), ChannelList, |
| 2739 | numChannels); |
| 2740 | if (eHAL_STATUS_SUCCESS != status) |
| 2741 | { |
| 2742 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2743 | "%s: Failed to update channel list information", __func__); |
| 2744 | ret = -EINVAL; |
| 2745 | goto exit; |
| 2746 | } |
| 2747 | } |
| 2748 | else if (strncmp(command, "GETROAMSCANCHANNELS", 19) == 0) |
| 2749 | { |
| 2750 | tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0}; |
| 2751 | tANI_U8 numChannels = 0; |
Jeff Johnson | 51b6778 | 2013-04-05 12:35:41 -0700 | [diff] [blame] | 2752 | tANI_U8 j = 0; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2753 | char extra[128] = {0}; |
Jeff Johnson | 51b6778 | 2013-04-05 12:35:41 -0700 | [diff] [blame] | 2754 | int len; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2755 | |
| 2756 | if (eHAL_STATUS_SUCCESS != sme_getRoamScanChannelList( (tHalHandle)(pHddCtx->hHal), |
| 2757 | ChannelList, &numChannels )) |
| 2758 | { |
| 2759 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 2760 | "%s: failed to get roam scan channel list", __func__); |
| 2761 | ret = -EFAULT; |
| 2762 | goto exit; |
| 2763 | } |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2764 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2765 | TRACE_CODE_HDD_GETROAMSCANCHANNELS_IOCTL, |
| 2766 | pAdapter->sessionId, numChannels)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2767 | /* output channel list is of the format |
| 2768 | [Number of roam scan channels][Channel1][Channel2]... */ |
| 2769 | /* copy the number of channels in the 0th index */ |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2770 | len = scnprintf(extra, sizeof(extra), "%s %d", command, numChannels); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2771 | for (j = 0; (j < numChannels); j++) |
| 2772 | { |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2773 | len += scnprintf(extra + len, sizeof(extra) - len, " %d", |
| 2774 | ChannelList[j]); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2775 | } |
| 2776 | |
| 2777 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2778 | { |
| 2779 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2780 | "%s: failed to copy data to user buffer", __func__); |
| 2781 | ret = -EFAULT; |
| 2782 | goto exit; |
| 2783 | } |
| 2784 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2785 | else if (strncmp(command, "GETCCXMODE", 10) == 0) |
| 2786 | { |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2787 | tANI_BOOLEAN eseMode = sme_getIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal)); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2788 | char extra[32]; |
| 2789 | tANI_U8 len = 0; |
| 2790 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2791 | /* Check if the features OKC/ESE/11R are supported simultaneously, |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 2792 | then this operation is not permitted (return FAILURE) */ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2793 | if (eseMode && |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 2794 | hdd_is_okc_mode_enabled(pHddCtx) && |
| 2795 | sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal))) |
| 2796 | { |
| 2797 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2798 | "%s: OKC/ESE/11R are supported simultaneously" |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 2799 | " hence this operation is not permitted!", __func__); |
| 2800 | ret = -EPERM; |
| 2801 | goto exit; |
| 2802 | } |
| 2803 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2804 | len = scnprintf(extra, sizeof(extra), "%s %d", |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2805 | "GETCCXMODE", eseMode); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2806 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2807 | { |
| 2808 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2809 | "%s: failed to copy data to user buffer", __func__); |
| 2810 | ret = -EFAULT; |
| 2811 | goto exit; |
| 2812 | } |
| 2813 | } |
| 2814 | else if (strncmp(command, "GETOKCMODE", 10) == 0) |
| 2815 | { |
| 2816 | tANI_BOOLEAN okcMode = hdd_is_okc_mode_enabled(pHddCtx); |
| 2817 | char extra[32]; |
| 2818 | tANI_U8 len = 0; |
| 2819 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2820 | /* Check if the features OKC/ESE/11R are supported simultaneously, |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 2821 | then this operation is not permitted (return FAILURE) */ |
| 2822 | if (okcMode && |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2823 | sme_getIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal)) && |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 2824 | sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal))) |
| 2825 | { |
| 2826 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2827 | "%s: OKC/ESE/11R are supported simultaneously" |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 2828 | " hence this operation is not permitted!", __func__); |
| 2829 | ret = -EPERM; |
| 2830 | goto exit; |
| 2831 | } |
| 2832 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2833 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 2834 | "GETOKCMODE", okcMode); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2835 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2836 | { |
| 2837 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2838 | "%s: failed to copy data to user buffer", __func__); |
| 2839 | ret = -EFAULT; |
| 2840 | goto exit; |
| 2841 | } |
| 2842 | } |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2843 | else if (strncmp(command, "GETFASTROAM", 11) == 0) |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2844 | { |
| 2845 | tANI_BOOLEAN lfrMode = sme_getIsLfrFeatureEnabled((tHalHandle)(pHddCtx->hHal)); |
| 2846 | char extra[32]; |
| 2847 | tANI_U8 len = 0; |
| 2848 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2849 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 2850 | "GETFASTROAM", lfrMode); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2851 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2852 | { |
| 2853 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2854 | "%s: failed to copy data to user buffer", __func__); |
| 2855 | ret = -EFAULT; |
| 2856 | goto exit; |
| 2857 | } |
| 2858 | } |
| 2859 | else if (strncmp(command, "GETFASTTRANSITION", 17) == 0) |
| 2860 | { |
| 2861 | tANI_BOOLEAN ft = sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal)); |
| 2862 | char extra[32]; |
| 2863 | tANI_U8 len = 0; |
| 2864 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2865 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 2866 | "GETFASTTRANSITION", ft); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2867 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2868 | { |
| 2869 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2870 | "%s: failed to copy data to user buffer", __func__); |
| 2871 | ret = -EFAULT; |
| 2872 | goto exit; |
| 2873 | } |
| 2874 | } |
| 2875 | else if (strncmp(command, "SETROAMSCANCHANNELMINTIME", 25) == 0) |
| 2876 | { |
| 2877 | tANI_U8 *value = command; |
| 2878 | tANI_U8 minTime = CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_DEFAULT; |
| 2879 | |
| 2880 | /* Move pointer to ahead of SETROAMSCANCHANNELMINTIME<delimiter> */ |
| 2881 | value = value + 26; |
| 2882 | /* Convert the value from ascii to integer */ |
| 2883 | ret = kstrtou8(value, 10, &minTime); |
| 2884 | if (ret < 0) |
| 2885 | { |
| 2886 | /* If the input value is greater than max value of datatype, then also |
| 2887 | kstrtou8 fails */ |
| 2888 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2889 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 2890 | CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MIN, |
| 2891 | CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MAX); |
| 2892 | ret = -EINVAL; |
| 2893 | goto exit; |
| 2894 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2895 | if ((minTime < CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MIN) || |
| 2896 | (minTime > CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MAX)) |
| 2897 | { |
| 2898 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2899 | "scan min channel time value %d is out of range" |
| 2900 | " (Min: %d Max: %d)", minTime, |
| 2901 | CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MIN, |
| 2902 | CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MAX); |
| 2903 | ret = -EINVAL; |
| 2904 | goto exit; |
| 2905 | } |
| 2906 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2907 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2908 | TRACE_CODE_HDD_SETROAMSCANCHANNELMINTIME_IOCTL, |
| 2909 | pAdapter->sessionId, minTime)); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2910 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2911 | "%s: Received Command to change channel min time = %d", __func__, minTime); |
| 2912 | |
| 2913 | pHddCtx->cfg_ini->nNeighborScanMinChanTime = minTime; |
| 2914 | sme_setNeighborScanMinChanTime((tHalHandle)(pHddCtx->hHal), minTime); |
| 2915 | } |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 2916 | else if (strncmp(command, "SENDACTIONFRAME", 15) == 0) |
| 2917 | { |
| 2918 | tANI_U8 *value = command; |
| 2919 | tANI_U8 channel = 0; |
| 2920 | tANI_U8 dwellTime = 0; |
| 2921 | tANI_U8 bufLen = 0; |
| 2922 | tANI_U8 *buf = NULL; |
| 2923 | tSirMacAddr targetApBssid; |
| 2924 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 2925 | struct ieee80211_channel chan; |
| 2926 | tANI_U8 finalLen = 0; |
| 2927 | tANI_U8 *finalBuf = NULL; |
| 2928 | tANI_U8 temp = 0; |
| 2929 | u64 cookie; |
| 2930 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 2931 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 2932 | |
| 2933 | /* if not associated, no need to send action frame */ |
| 2934 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 2935 | { |
| 2936 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__); |
| 2937 | ret = -EINVAL; |
| 2938 | goto exit; |
| 2939 | } |
| 2940 | |
| 2941 | status = hdd_parse_send_action_frame_data(value, targetApBssid, &channel, |
| 2942 | &dwellTime, &buf, &bufLen); |
| 2943 | if (eHAL_STATUS_SUCCESS != status) |
| 2944 | { |
| 2945 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2946 | "%s: Failed to parse send action frame data", __func__); |
| 2947 | ret = -EINVAL; |
| 2948 | goto exit; |
| 2949 | } |
| 2950 | |
| 2951 | /* if the target bssid is different from currently associated AP, |
| 2952 | then no need to send action frame */ |
| 2953 | if (VOS_TRUE != vos_mem_compare(targetApBssid, |
| 2954 | pHddStaCtx->conn_info.bssId, sizeof(tSirMacAddr))) |
| 2955 | { |
| 2956 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:STA is not associated to this AP!",__func__); |
| 2957 | ret = -EINVAL; |
Jeff Johnson | 11c3315 | 2013-04-16 17:52:40 -0700 | [diff] [blame] | 2958 | vos_mem_free(buf); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 2959 | buf = NULL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 2960 | goto exit; |
| 2961 | } |
| 2962 | |
| 2963 | /* if the channel number is different from operating channel then |
| 2964 | no need to send action frame */ |
| 2965 | if (channel != pHddStaCtx->conn_info.operationChannel) |
| 2966 | { |
| 2967 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2968 | "%s: channel(%d) is different from operating channel(%d)", |
| 2969 | __func__, channel, pHddStaCtx->conn_info.operationChannel); |
| 2970 | ret = -EINVAL; |
Jeff Johnson | 11c3315 | 2013-04-16 17:52:40 -0700 | [diff] [blame] | 2971 | vos_mem_free(buf); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 2972 | buf = NULL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 2973 | goto exit; |
| 2974 | } |
| 2975 | chan.center_freq = sme_ChnToFreq(channel); |
| 2976 | |
| 2977 | finalLen = bufLen + 24; |
| 2978 | finalBuf = vos_mem_malloc(finalLen); |
| 2979 | if (NULL == finalBuf) |
| 2980 | { |
| 2981 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:memory allocation failed",__func__); |
| 2982 | ret = -ENOMEM; |
Jeff Johnson | 11c3315 | 2013-04-16 17:52:40 -0700 | [diff] [blame] | 2983 | vos_mem_free(buf); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 2984 | buf = NULL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 2985 | goto exit; |
| 2986 | } |
| 2987 | vos_mem_zero(finalBuf, finalLen); |
| 2988 | |
| 2989 | /* Fill subtype */ |
| 2990 | temp = SIR_MAC_MGMT_ACTION << 4; |
| 2991 | vos_mem_copy(finalBuf + 0, &temp, sizeof(temp)); |
| 2992 | |
| 2993 | /* Fill type */ |
| 2994 | temp = SIR_MAC_MGMT_FRAME; |
| 2995 | vos_mem_copy(finalBuf + 2, &temp, sizeof(temp)); |
| 2996 | |
| 2997 | /* Fill destination address (bssid of the AP) */ |
| 2998 | vos_mem_copy(finalBuf + 4, targetApBssid, sizeof(targetApBssid)); |
| 2999 | |
Srinivas Girigowda | b27c019 | 2013-06-03 10:19:56 -0700 | [diff] [blame] | 3000 | /* Fill source address (STA mac address) */ |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 3001 | vos_mem_copy(finalBuf + 10, pAdapter->macAddressCurrent.bytes, sizeof(pAdapter->macAddressCurrent.bytes)); |
| 3002 | |
Srinivas Girigowda | b27c019 | 2013-06-03 10:19:56 -0700 | [diff] [blame] | 3003 | /* Fill BSSID (AP mac address) */ |
| 3004 | vos_mem_copy(finalBuf + 16, targetApBssid, sizeof(targetApBssid)); |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 3005 | |
| 3006 | /* Fill received buffer from 24th address */ |
| 3007 | vos_mem_copy(finalBuf + 24, buf, bufLen); |
| 3008 | |
Jeff Johnson | 11c3315 | 2013-04-16 17:52:40 -0700 | [diff] [blame] | 3009 | /* done with the parsed buffer */ |
| 3010 | vos_mem_free(buf); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 3011 | buf = NULL; |
Jeff Johnson | 11c3315 | 2013-04-16 17:52:40 -0700 | [diff] [blame] | 3012 | |
DARAM SUDHA | 39eede6 | 2014-02-12 11:16:40 +0530 | [diff] [blame] | 3013 | wlan_hdd_mgmt_tx( NULL, |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 3014 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 3015 | &(pAdapter->wdev), |
| 3016 | #else |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 3017 | pAdapter->dev, |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 3018 | #endif |
| 3019 | &chan, 0, |
| 3020 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)) |
| 3021 | NL80211_CHAN_HT20, 1, |
| 3022 | #endif |
| 3023 | dwellTime, finalBuf, finalLen, 1, |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 3024 | 1, &cookie ); |
| 3025 | vos_mem_free(finalBuf); |
| 3026 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3027 | else if (strncmp(command, "GETROAMSCANCHANNELMINTIME", 25) == 0) |
| 3028 | { |
| 3029 | tANI_U16 val = sme_getNeighborScanMinChanTime((tHalHandle)(pHddCtx->hHal)); |
| 3030 | char extra[32]; |
| 3031 | tANI_U8 len = 0; |
| 3032 | |
| 3033 | /* value is interms of msec */ |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3034 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3035 | "GETROAMSCANCHANNELMINTIME", val); |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 3036 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 3037 | TRACE_CODE_HDD_GETROAMSCANCHANNELMINTIME_IOCTL, |
| 3038 | pAdapter->sessionId, val)); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3039 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 3040 | { |
| 3041 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3042 | "%s: failed to copy data to user buffer", __func__); |
| 3043 | ret = -EFAULT; |
| 3044 | goto exit; |
| 3045 | } |
| 3046 | } |
| 3047 | else if (strncmp(command, "SETSCANCHANNELTIME", 18) == 0) |
| 3048 | { |
| 3049 | tANI_U8 *value = command; |
Varun Reddy Yeturu | 3885a66 | 2013-06-19 07:10:37 -0700 | [diff] [blame] | 3050 | tANI_U16 maxTime = CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_DEFAULT; |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3051 | |
| 3052 | /* Move pointer to ahead of SETSCANCHANNELTIME<delimiter> */ |
| 3053 | value = value + 19; |
| 3054 | /* Convert the value from ascii to integer */ |
Varun Reddy Yeturu | 3885a66 | 2013-06-19 07:10:37 -0700 | [diff] [blame] | 3055 | ret = kstrtou16(value, 10, &maxTime); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3056 | if (ret < 0) |
| 3057 | { |
| 3058 | /* 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] | 3059 | kstrtou16 fails */ |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3060 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Varun Reddy Yeturu | 3885a66 | 2013-06-19 07:10:37 -0700 | [diff] [blame] | 3061 | "%s: kstrtou16 failed range [%d - %d]", __func__, |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3062 | CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MIN, |
| 3063 | CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MAX); |
| 3064 | ret = -EINVAL; |
| 3065 | goto exit; |
| 3066 | } |
| 3067 | |
| 3068 | if ((maxTime < CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MIN) || |
| 3069 | (maxTime > CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MAX)) |
| 3070 | { |
| 3071 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3072 | "lfr mode value %d is out of range" |
| 3073 | " (Min: %d Max: %d)", maxTime, |
| 3074 | CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MIN, |
| 3075 | CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MAX); |
| 3076 | ret = -EINVAL; |
| 3077 | goto exit; |
| 3078 | } |
| 3079 | |
| 3080 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3081 | "%s: Received Command to change channel max time = %d", __func__, maxTime); |
| 3082 | |
| 3083 | pHddCtx->cfg_ini->nNeighborScanMaxChanTime = maxTime; |
| 3084 | sme_setNeighborScanMaxChanTime((tHalHandle)(pHddCtx->hHal), maxTime); |
| 3085 | } |
| 3086 | else if (strncmp(command, "GETSCANCHANNELTIME", 18) == 0) |
| 3087 | { |
| 3088 | tANI_U16 val = sme_getNeighborScanMaxChanTime((tHalHandle)(pHddCtx->hHal)); |
| 3089 | char extra[32]; |
| 3090 | tANI_U8 len = 0; |
| 3091 | |
| 3092 | /* value is interms of msec */ |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3093 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3094 | "GETSCANCHANNELTIME", val); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3095 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 3096 | { |
| 3097 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3098 | "%s: failed to copy data to user buffer", __func__); |
| 3099 | ret = -EFAULT; |
| 3100 | goto exit; |
| 3101 | } |
| 3102 | } |
| 3103 | else if (strncmp(command, "SETSCANHOMETIME", 15) == 0) |
| 3104 | { |
| 3105 | tANI_U8 *value = command; |
| 3106 | tANI_U16 val = CFG_NEIGHBOR_SCAN_TIMER_PERIOD_DEFAULT; |
| 3107 | |
| 3108 | /* Move pointer to ahead of SETSCANHOMETIME<delimiter> */ |
| 3109 | value = value + 16; |
| 3110 | /* Convert the value from ascii to integer */ |
| 3111 | ret = kstrtou16(value, 10, &val); |
| 3112 | if (ret < 0) |
| 3113 | { |
| 3114 | /* If the input value is greater than max value of datatype, then also |
| 3115 | kstrtou16 fails */ |
| 3116 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3117 | "%s: kstrtou16 failed range [%d - %d]", __func__, |
| 3118 | CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MIN, |
| 3119 | CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MAX); |
| 3120 | ret = -EINVAL; |
| 3121 | goto exit; |
| 3122 | } |
| 3123 | |
| 3124 | if ((val < CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MIN) || |
| 3125 | (val > CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MAX)) |
| 3126 | { |
| 3127 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3128 | "scan home time value %d is out of range" |
| 3129 | " (Min: %d Max: %d)", val, |
| 3130 | CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MIN, |
| 3131 | CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MAX); |
| 3132 | ret = -EINVAL; |
| 3133 | goto exit; |
| 3134 | } |
| 3135 | |
| 3136 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3137 | "%s: Received Command to change scan home time = %d", __func__, val); |
| 3138 | |
| 3139 | pHddCtx->cfg_ini->nNeighborScanPeriod = val; |
| 3140 | sme_setNeighborScanPeriod((tHalHandle)(pHddCtx->hHal), val); |
| 3141 | } |
| 3142 | else if (strncmp(command, "GETSCANHOMETIME", 15) == 0) |
| 3143 | { |
| 3144 | tANI_U16 val = sme_getNeighborScanPeriod((tHalHandle)(pHddCtx->hHal)); |
| 3145 | char extra[32]; |
| 3146 | tANI_U8 len = 0; |
| 3147 | |
| 3148 | /* value is interms of msec */ |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3149 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3150 | "GETSCANHOMETIME", val); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3151 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 3152 | { |
| 3153 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3154 | "%s: failed to copy data to user buffer", __func__); |
| 3155 | ret = -EFAULT; |
| 3156 | goto exit; |
| 3157 | } |
| 3158 | } |
| 3159 | else if (strncmp(command, "SETROAMINTRABAND", 16) == 0) |
| 3160 | { |
| 3161 | tANI_U8 *value = command; |
| 3162 | tANI_U8 val = CFG_ROAM_INTRA_BAND_DEFAULT; |
| 3163 | |
| 3164 | /* Move pointer to ahead of SETROAMINTRABAND<delimiter> */ |
| 3165 | value = value + 17; |
| 3166 | /* Convert the value from ascii to integer */ |
| 3167 | ret = kstrtou8(value, 10, &val); |
| 3168 | if (ret < 0) |
| 3169 | { |
| 3170 | /* If the input value is greater than max value of datatype, then also |
| 3171 | kstrtou8 fails */ |
| 3172 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3173 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3174 | CFG_ROAM_INTRA_BAND_MIN, |
| 3175 | CFG_ROAM_INTRA_BAND_MAX); |
| 3176 | ret = -EINVAL; |
| 3177 | goto exit; |
| 3178 | } |
| 3179 | |
| 3180 | if ((val < CFG_ROAM_INTRA_BAND_MIN) || |
| 3181 | (val > CFG_ROAM_INTRA_BAND_MAX)) |
| 3182 | { |
| 3183 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3184 | "intra band mode value %d is out of range" |
| 3185 | " (Min: %d Max: %d)", val, |
| 3186 | CFG_ROAM_INTRA_BAND_MIN, |
| 3187 | CFG_ROAM_INTRA_BAND_MAX); |
| 3188 | ret = -EINVAL; |
| 3189 | goto exit; |
| 3190 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3191 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3192 | "%s: Received Command to change intra band = %d", __func__, val); |
| 3193 | |
| 3194 | pHddCtx->cfg_ini->nRoamIntraBand = val; |
| 3195 | sme_setRoamIntraBand((tHalHandle)(pHddCtx->hHal), val); |
| 3196 | } |
| 3197 | else if (strncmp(command, "GETROAMINTRABAND", 16) == 0) |
| 3198 | { |
| 3199 | tANI_U16 val = sme_getRoamIntraBand((tHalHandle)(pHddCtx->hHal)); |
| 3200 | char extra[32]; |
| 3201 | tANI_U8 len = 0; |
| 3202 | |
| 3203 | /* value is interms of msec */ |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3204 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3205 | "GETROAMINTRABAND", val); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3206 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 3207 | { |
| 3208 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3209 | "%s: failed to copy data to user buffer", __func__); |
| 3210 | ret = -EFAULT; |
| 3211 | goto exit; |
| 3212 | } |
| 3213 | } |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3214 | else if (strncmp(command, "SETSCANNPROBES", 14) == 0) |
| 3215 | { |
| 3216 | tANI_U8 *value = command; |
| 3217 | tANI_U8 nProbes = CFG_ROAM_SCAN_N_PROBES_DEFAULT; |
| 3218 | |
| 3219 | /* Move pointer to ahead of SETSCANNPROBES<delimiter> */ |
| 3220 | value = value + 15; |
| 3221 | /* Convert the value from ascii to integer */ |
| 3222 | ret = kstrtou8(value, 10, &nProbes); |
| 3223 | if (ret < 0) |
| 3224 | { |
| 3225 | /* If the input value is greater than max value of datatype, then also |
| 3226 | kstrtou8 fails */ |
| 3227 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3228 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3229 | CFG_ROAM_SCAN_N_PROBES_MIN, |
| 3230 | CFG_ROAM_SCAN_N_PROBES_MAX); |
| 3231 | ret = -EINVAL; |
| 3232 | goto exit; |
| 3233 | } |
| 3234 | |
| 3235 | if ((nProbes < CFG_ROAM_SCAN_N_PROBES_MIN) || |
| 3236 | (nProbes > CFG_ROAM_SCAN_N_PROBES_MAX)) |
| 3237 | { |
| 3238 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3239 | "NProbes value %d is out of range" |
| 3240 | " (Min: %d Max: %d)", nProbes, |
| 3241 | CFG_ROAM_SCAN_N_PROBES_MIN, |
| 3242 | CFG_ROAM_SCAN_N_PROBES_MAX); |
| 3243 | ret = -EINVAL; |
| 3244 | goto exit; |
| 3245 | } |
| 3246 | |
| 3247 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3248 | "%s: Received Command to Set nProbes = %d", __func__, nProbes); |
| 3249 | |
| 3250 | pHddCtx->cfg_ini->nProbes = nProbes; |
| 3251 | sme_UpdateRoamScanNProbes((tHalHandle)(pHddCtx->hHal), nProbes); |
| 3252 | } |
| 3253 | else if (strncmp(priv_data.buf, "GETSCANNPROBES", 14) == 0) |
| 3254 | { |
| 3255 | tANI_U8 val = sme_getRoamScanNProbes((tHalHandle)(pHddCtx->hHal)); |
| 3256 | char extra[32]; |
| 3257 | tANI_U8 len = 0; |
| 3258 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3259 | len = scnprintf(extra, sizeof(extra), "%s %d", command, val); |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3260 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 3261 | { |
| 3262 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3263 | "%s: failed to copy data to user buffer", __func__); |
| 3264 | ret = -EFAULT; |
| 3265 | goto exit; |
| 3266 | } |
| 3267 | } |
| 3268 | else if (strncmp(command, "SETSCANHOMEAWAYTIME", 19) == 0) |
| 3269 | { |
| 3270 | tANI_U8 *value = command; |
| 3271 | tANI_U16 homeAwayTime = CFG_ROAM_SCAN_HOME_AWAY_TIME_DEFAULT; |
| 3272 | |
| 3273 | /* Move pointer to ahead of SETSCANHOMEAWAYTIME<delimiter> */ |
| 3274 | /* input value is in units of msec */ |
| 3275 | value = value + 20; |
| 3276 | /* Convert the value from ascii to integer */ |
| 3277 | ret = kstrtou16(value, 10, &homeAwayTime); |
| 3278 | if (ret < 0) |
| 3279 | { |
| 3280 | /* If the input value is greater than max value of datatype, then also |
| 3281 | kstrtou8 fails */ |
| 3282 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3283 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3284 | CFG_ROAM_SCAN_HOME_AWAY_TIME_MIN, |
| 3285 | CFG_ROAM_SCAN_HOME_AWAY_TIME_MAX); |
| 3286 | ret = -EINVAL; |
| 3287 | goto exit; |
| 3288 | } |
| 3289 | |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3290 | if ((homeAwayTime < CFG_ROAM_SCAN_HOME_AWAY_TIME_MIN) || |
| 3291 | (homeAwayTime > CFG_ROAM_SCAN_HOME_AWAY_TIME_MAX)) |
| 3292 | { |
| 3293 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3294 | "homeAwayTime value %d is out of range" |
| 3295 | " (Min: %d Max: %d)", homeAwayTime, |
| 3296 | CFG_ROAM_SCAN_HOME_AWAY_TIME_MIN, |
| 3297 | CFG_ROAM_SCAN_HOME_AWAY_TIME_MAX); |
| 3298 | ret = -EINVAL; |
| 3299 | goto exit; |
| 3300 | } |
| 3301 | |
| 3302 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3303 | "%s: Received Command to Set scan away time = %d", __func__, homeAwayTime); |
Srinivas Girigowda | 6cf0b82 | 2013-06-27 14:00:20 -0700 | [diff] [blame] | 3304 | if (pHddCtx->cfg_ini->nRoamScanHomeAwayTime != homeAwayTime) |
| 3305 | { |
| 3306 | pHddCtx->cfg_ini->nRoamScanHomeAwayTime = homeAwayTime; |
| 3307 | sme_UpdateRoamScanHomeAwayTime((tHalHandle)(pHddCtx->hHal), homeAwayTime, eANI_BOOLEAN_TRUE); |
| 3308 | } |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3309 | } |
| 3310 | else if (strncmp(priv_data.buf, "GETSCANHOMEAWAYTIME", 19) == 0) |
| 3311 | { |
| 3312 | tANI_U16 val = sme_getRoamScanHomeAwayTime((tHalHandle)(pHddCtx->hHal)); |
| 3313 | char extra[32]; |
| 3314 | tANI_U8 len = 0; |
| 3315 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3316 | len = scnprintf(extra, sizeof(extra), "%s %d", command, val); |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3317 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 3318 | { |
| 3319 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3320 | "%s: failed to copy data to user buffer", __func__); |
| 3321 | ret = -EFAULT; |
| 3322 | goto exit; |
| 3323 | } |
| 3324 | } |
| 3325 | else if (strncmp(command, "REASSOC", 7) == 0) |
| 3326 | { |
| 3327 | tANI_U8 *value = command; |
| 3328 | tANI_U8 channel = 0; |
| 3329 | tSirMacAddr targetApBssid; |
| 3330 | eHalStatus status = eHAL_STATUS_SUCCESS; |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 3331 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 3332 | tCsrHandoffRequest handoffInfo; |
| 3333 | #endif |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3334 | hdd_station_ctx_t *pHddStaCtx = NULL; |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3335 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3336 | |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3337 | /* if not associated, no need to proceed with reassoc */ |
| 3338 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 3339 | { |
| 3340 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__); |
| 3341 | ret = -EINVAL; |
| 3342 | goto exit; |
| 3343 | } |
| 3344 | |
| 3345 | status = hdd_parse_reassoc_command_data(value, targetApBssid, &channel); |
| 3346 | if (eHAL_STATUS_SUCCESS != status) |
| 3347 | { |
| 3348 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3349 | "%s: Failed to parse reassoc command data", __func__); |
| 3350 | ret = -EINVAL; |
| 3351 | goto exit; |
| 3352 | } |
| 3353 | |
| 3354 | /* if the target bssid is same as currently associated AP, |
| 3355 | then no need to proceed with reassoc */ |
| 3356 | if (VOS_TRUE == vos_mem_compare(targetApBssid, |
| 3357 | pHddStaCtx->conn_info.bssId, sizeof(tSirMacAddr))) |
| 3358 | { |
| 3359 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Reassoc BSSID is same as currently associated AP bssid",__func__); |
| 3360 | ret = -EINVAL; |
| 3361 | goto exit; |
| 3362 | } |
| 3363 | |
| 3364 | /* Check channel number is a valid channel number */ |
| 3365 | if(VOS_STATUS_SUCCESS != |
| 3366 | wlan_hdd_validate_operation_channel(pAdapter, channel)) |
| 3367 | { |
| 3368 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 3369 | "%s: Invalid Channel [%d]", __func__, channel); |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3370 | return -EINVAL; |
| 3371 | } |
| 3372 | |
| 3373 | /* Proceed with reassoc */ |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 3374 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 3375 | handoffInfo.channel = channel; |
| 3376 | vos_mem_copy(handoffInfo.bssid, targetApBssid, sizeof(tSirMacAddr)); |
| 3377 | sme_HandoffRequest(pHddCtx->hHal, &handoffInfo); |
| 3378 | #endif |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3379 | } |
Srinivas Girigowda | ad34ca9 | 2013-10-22 10:54:29 -0700 | [diff] [blame] | 3380 | else if (strncmp(command, "SETWESMODE", 10) == 0) |
| 3381 | { |
| 3382 | tANI_U8 *value = command; |
| 3383 | tANI_BOOLEAN wesMode = CFG_ENABLE_WES_MODE_NAME_DEFAULT; |
| 3384 | |
| 3385 | /* Move pointer to ahead of SETWESMODE<delimiter> */ |
| 3386 | value = value + 11; |
| 3387 | /* Convert the value from ascii to integer */ |
| 3388 | ret = kstrtou8(value, 10, &wesMode); |
| 3389 | if (ret < 0) |
| 3390 | { |
| 3391 | /* If the input value is greater than max value of datatype, then also |
| 3392 | kstrtou8 fails */ |
| 3393 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3394 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3395 | CFG_ENABLE_WES_MODE_NAME_MIN, |
| 3396 | CFG_ENABLE_WES_MODE_NAME_MAX); |
| 3397 | ret = -EINVAL; |
| 3398 | goto exit; |
| 3399 | } |
| 3400 | |
| 3401 | if ((wesMode < CFG_ENABLE_WES_MODE_NAME_MIN) || |
| 3402 | (wesMode > CFG_ENABLE_WES_MODE_NAME_MAX)) |
| 3403 | { |
| 3404 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3405 | "WES Mode value %d is out of range" |
| 3406 | " (Min: %d Max: %d)", wesMode, |
| 3407 | CFG_ENABLE_WES_MODE_NAME_MIN, |
| 3408 | CFG_ENABLE_WES_MODE_NAME_MAX); |
| 3409 | ret = -EINVAL; |
| 3410 | goto exit; |
| 3411 | } |
| 3412 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3413 | "%s: Received Command to Set WES Mode rssi diff = %d", __func__, wesMode); |
| 3414 | |
| 3415 | pHddCtx->cfg_ini->isWESModeEnabled = wesMode; |
| 3416 | sme_UpdateWESMode((tHalHandle)(pHddCtx->hHal), wesMode); |
| 3417 | } |
| 3418 | else if (strncmp(priv_data.buf, "GETWESMODE", 10) == 0) |
| 3419 | { |
| 3420 | tANI_BOOLEAN wesMode = sme_GetWESMode((tHalHandle)(pHddCtx->hHal)); |
| 3421 | char extra[32]; |
| 3422 | tANI_U8 len = 0; |
| 3423 | |
Arif Hussain | 826d941 | 2013-11-12 16:44:54 -0800 | [diff] [blame] | 3424 | len = scnprintf(extra, sizeof(extra), "%s %d", command, wesMode); |
Srinivas Girigowda | ad34ca9 | 2013-10-22 10:54:29 -0700 | [diff] [blame] | 3425 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 3426 | { |
| 3427 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3428 | "%s: failed to copy data to user buffer", __func__); |
| 3429 | ret = -EFAULT; |
| 3430 | goto exit; |
| 3431 | } |
| 3432 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3433 | #endif /* WLAN_FEATURE_VOWIFI_11R || FEATURE_WLAN_ESE || FEATURE_WLAN_LFR */ |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3434 | #ifdef FEATURE_WLAN_LFR |
| 3435 | else if (strncmp(command, "SETFASTROAM", 11) == 0) |
| 3436 | { |
| 3437 | tANI_U8 *value = command; |
| 3438 | tANI_U8 lfrMode = CFG_LFR_FEATURE_ENABLED_DEFAULT; |
| 3439 | |
| 3440 | /* Move pointer to ahead of SETFASTROAM<delimiter> */ |
| 3441 | value = value + 12; |
| 3442 | /* Convert the value from ascii to integer */ |
| 3443 | ret = kstrtou8(value, 10, &lfrMode); |
| 3444 | if (ret < 0) |
| 3445 | { |
| 3446 | /* If the input value is greater than max value of datatype, then also |
| 3447 | kstrtou8 fails */ |
| 3448 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3449 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3450 | CFG_LFR_FEATURE_ENABLED_MIN, |
| 3451 | CFG_LFR_FEATURE_ENABLED_MAX); |
| 3452 | ret = -EINVAL; |
| 3453 | goto exit; |
| 3454 | } |
| 3455 | |
| 3456 | if ((lfrMode < CFG_LFR_FEATURE_ENABLED_MIN) || |
| 3457 | (lfrMode > CFG_LFR_FEATURE_ENABLED_MAX)) |
| 3458 | { |
| 3459 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3460 | "lfr mode value %d is out of range" |
| 3461 | " (Min: %d Max: %d)", lfrMode, |
| 3462 | CFG_LFR_FEATURE_ENABLED_MIN, |
| 3463 | CFG_LFR_FEATURE_ENABLED_MAX); |
| 3464 | ret = -EINVAL; |
| 3465 | goto exit; |
| 3466 | } |
| 3467 | |
| 3468 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3469 | "%s: Received Command to change lfr mode = %d", __func__, lfrMode); |
| 3470 | |
| 3471 | pHddCtx->cfg_ini->isFastRoamIniFeatureEnabled = lfrMode; |
| 3472 | sme_UpdateIsFastRoamIniFeatureEnabled((tHalHandle)(pHddCtx->hHal), lfrMode); |
| 3473 | } |
| 3474 | #endif |
| 3475 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 3476 | else if (strncmp(command, "SETFASTTRANSITION", 17) == 0) |
| 3477 | { |
| 3478 | tANI_U8 *value = command; |
| 3479 | tANI_U8 ft = CFG_FAST_TRANSITION_ENABLED_NAME_DEFAULT; |
| 3480 | |
| 3481 | /* Move pointer to ahead of SETFASTROAM<delimiter> */ |
| 3482 | value = value + 18; |
| 3483 | /* Convert the value from ascii to integer */ |
| 3484 | ret = kstrtou8(value, 10, &ft); |
| 3485 | if (ret < 0) |
| 3486 | { |
| 3487 | /* If the input value is greater than max value of datatype, then also |
| 3488 | kstrtou8 fails */ |
| 3489 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3490 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3491 | CFG_FAST_TRANSITION_ENABLED_NAME_MIN, |
| 3492 | CFG_FAST_TRANSITION_ENABLED_NAME_MAX); |
| 3493 | ret = -EINVAL; |
| 3494 | goto exit; |
| 3495 | } |
| 3496 | |
| 3497 | if ((ft < CFG_FAST_TRANSITION_ENABLED_NAME_MIN) || |
| 3498 | (ft > CFG_FAST_TRANSITION_ENABLED_NAME_MAX)) |
| 3499 | { |
| 3500 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3501 | "ft mode value %d is out of range" |
| 3502 | " (Min: %d Max: %d)", ft, |
| 3503 | CFG_FAST_TRANSITION_ENABLED_NAME_MIN, |
| 3504 | CFG_FAST_TRANSITION_ENABLED_NAME_MAX); |
| 3505 | ret = -EINVAL; |
| 3506 | goto exit; |
| 3507 | } |
| 3508 | |
| 3509 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3510 | "%s: Received Command to change ft mode = %d", __func__, ft); |
| 3511 | |
| 3512 | pHddCtx->cfg_ini->isFastTransitionEnabled = ft; |
| 3513 | sme_UpdateFastTransitionEnabled((tHalHandle)(pHddCtx->hHal), ft); |
| 3514 | } |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 3515 | |
| 3516 | else if (strncmp(command, "FASTREASSOC", 11) == 0) |
| 3517 | { |
| 3518 | tANI_U8 *value = command; |
Padma, Santhosh Kumar | f4582d3 | 2014-11-06 19:24:51 +0530 | [diff] [blame] | 3519 | tANI_U8 channel = 0; |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 3520 | tSirMacAddr targetApBssid; |
| 3521 | tANI_U8 trigger = 0; |
| 3522 | eHalStatus status = eHAL_STATUS_SUCCESS; |
Padma, Santhosh Kumar | b980a6f | 2014-11-06 19:07:24 +0530 | [diff] [blame] | 3523 | tHalHandle hHal; |
| 3524 | v_U32_t roamId = 0; |
| 3525 | tCsrRoamModifyProfileFields modProfileFields; |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 3526 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 3527 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Padma, Santhosh Kumar | b980a6f | 2014-11-06 19:07:24 +0530 | [diff] [blame] | 3528 | hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 3529 | |
| 3530 | /* if not associated, no need to proceed with reassoc */ |
| 3531 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 3532 | { |
| 3533 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__); |
| 3534 | ret = -EINVAL; |
| 3535 | goto exit; |
| 3536 | } |
| 3537 | |
Padma, Santhosh Kumar | f4582d3 | 2014-11-06 19:24:51 +0530 | [diff] [blame] | 3538 | status = hdd_parse_reassoc_command_data(value, targetApBssid, &channel); |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 3539 | if (eHAL_STATUS_SUCCESS != status) |
| 3540 | { |
| 3541 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3542 | "%s: Failed to parse reassoc command data", __func__); |
| 3543 | ret = -EINVAL; |
| 3544 | goto exit; |
| 3545 | } |
| 3546 | |
| 3547 | /* if the target bssid is same as currently associated AP, |
Padma, Santhosh Kumar | b980a6f | 2014-11-06 19:07:24 +0530 | [diff] [blame] | 3548 | issue reassoc to same AP */ |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 3549 | if (VOS_TRUE == vos_mem_compare(targetApBssid, |
| 3550 | pHddStaCtx->conn_info.bssId, sizeof(tSirMacAddr))) |
| 3551 | { |
| 3552 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3553 | "%s:11r Reassoc BSSID is same as currently associated AP bssid", |
| 3554 | __func__); |
Padma, Santhosh Kumar | b980a6f | 2014-11-06 19:07:24 +0530 | [diff] [blame] | 3555 | sme_GetModifyProfileFields(hHal, pAdapter->sessionId, |
| 3556 | &modProfileFields); |
| 3557 | sme_RoamReassoc(hHal, pAdapter->sessionId, |
| 3558 | NULL, modProfileFields, &roamId, 1); |
| 3559 | return 0; |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 3560 | } |
Padma, Santhosh Kumar | 0fa809b | 2014-11-13 14:56:56 +0530 | [diff] [blame] | 3561 | |
| 3562 | /* Check channel number is a valid channel number */ |
| 3563 | if(VOS_STATUS_SUCCESS != |
| 3564 | wlan_hdd_validate_operation_channel(pAdapter, channel)) |
| 3565 | { |
| 3566 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3567 | "%s: Invalid Channel [%d]", __func__, channel); |
| 3568 | return -EINVAL; |
| 3569 | } |
| 3570 | |
Padma, Santhosh Kumar | f4582d3 | 2014-11-06 19:24:51 +0530 | [diff] [blame] | 3571 | trigger = eSME_ROAM_TRIGGER_SCAN; |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 3572 | |
| 3573 | /* Proceed with scan/roam */ |
| 3574 | smeIssueFastRoamNeighborAPEvent(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 3575 | &targetApBssid[0], |
| 3576 | (tSmeFastRoamTrigger)(trigger)); |
| 3577 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3578 | #endif |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3579 | #ifdef FEATURE_WLAN_ESE |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3580 | else if (strncmp(command, "SETCCXMODE", 10) == 0) |
| 3581 | { |
| 3582 | tANI_U8 *value = command; |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3583 | tANI_U8 eseMode = CFG_ESE_FEATURE_ENABLED_DEFAULT; |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3584 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3585 | /* Check if the features OKC/ESE/11R are supported simultaneously, |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 3586 | then this operation is not permitted (return FAILURE) */ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3587 | if (sme_getIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal)) && |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 3588 | hdd_is_okc_mode_enabled(pHddCtx) && |
| 3589 | sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal))) |
| 3590 | { |
| 3591 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3592 | "%s: OKC/ESE/11R are supported simultaneously" |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 3593 | " hence this operation is not permitted!", __func__); |
| 3594 | ret = -EPERM; |
| 3595 | goto exit; |
| 3596 | } |
| 3597 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3598 | /* Move pointer to ahead of SETCCXMODE<delimiter> */ |
| 3599 | value = value + 11; |
| 3600 | /* Convert the value from ascii to integer */ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3601 | ret = kstrtou8(value, 10, &eseMode); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3602 | if (ret < 0) |
| 3603 | { |
| 3604 | /* If the input value is greater than max value of datatype, then also |
| 3605 | kstrtou8 fails */ |
| 3606 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3607 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3608 | CFG_ESE_FEATURE_ENABLED_MIN, |
| 3609 | CFG_ESE_FEATURE_ENABLED_MAX); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3610 | ret = -EINVAL; |
| 3611 | goto exit; |
| 3612 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3613 | if ((eseMode < CFG_ESE_FEATURE_ENABLED_MIN) || |
| 3614 | (eseMode > CFG_ESE_FEATURE_ENABLED_MAX)) |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3615 | { |
| 3616 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3617 | "Ese mode value %d is out of range" |
| 3618 | " (Min: %d Max: %d)", eseMode, |
| 3619 | CFG_ESE_FEATURE_ENABLED_MIN, |
| 3620 | CFG_ESE_FEATURE_ENABLED_MAX); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3621 | ret = -EINVAL; |
| 3622 | goto exit; |
| 3623 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3624 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3625 | "%s: Received Command to change ese mode = %d", __func__, eseMode); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3626 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3627 | pHddCtx->cfg_ini->isEseIniFeatureEnabled = eseMode; |
| 3628 | sme_UpdateIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal), eseMode); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3629 | } |
| 3630 | #endif |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 3631 | else if (strncmp(command, "SETROAMSCANCONTROL", 18) == 0) |
| 3632 | { |
| 3633 | tANI_U8 *value = command; |
| 3634 | tANI_BOOLEAN roamScanControl = 0; |
| 3635 | |
| 3636 | /* Move pointer to ahead of SETROAMSCANCONTROL<delimiter> */ |
| 3637 | value = value + 19; |
| 3638 | /* Convert the value from ascii to integer */ |
| 3639 | ret = kstrtou8(value, 10, &roamScanControl); |
| 3640 | if (ret < 0) |
| 3641 | { |
| 3642 | /* If the input value is greater than max value of datatype, then also |
| 3643 | kstrtou8 fails */ |
| 3644 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3645 | "%s: kstrtou8 failed ", __func__); |
| 3646 | ret = -EINVAL; |
| 3647 | goto exit; |
| 3648 | } |
| 3649 | |
| 3650 | if (0 != roamScanControl) |
| 3651 | { |
| 3652 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3653 | "roam scan control invalid value = %d", |
| 3654 | roamScanControl); |
| 3655 | ret = -EINVAL; |
| 3656 | goto exit; |
| 3657 | } |
| 3658 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3659 | "%s: Received Command to Set roam scan control = %d", __func__, roamScanControl); |
| 3660 | |
| 3661 | sme_SetRoamScanControl((tHalHandle)(pHddCtx->hHal), roamScanControl); |
| 3662 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3663 | #ifdef FEATURE_WLAN_OKC |
| 3664 | else if (strncmp(command, "SETOKCMODE", 10) == 0) |
| 3665 | { |
| 3666 | tANI_U8 *value = command; |
| 3667 | tANI_U8 okcMode = CFG_OKC_FEATURE_ENABLED_DEFAULT; |
| 3668 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3669 | /* Check if the features OKC/ESE/11R are supported simultaneously, |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 3670 | then this operation is not permitted (return FAILURE) */ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3671 | if (sme_getIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal)) && |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 3672 | hdd_is_okc_mode_enabled(pHddCtx) && |
| 3673 | sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal))) |
| 3674 | { |
| 3675 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3676 | "%s: OKC/ESE/11R are supported simultaneously" |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 3677 | " hence this operation is not permitted!", __func__); |
| 3678 | ret = -EPERM; |
| 3679 | goto exit; |
| 3680 | } |
| 3681 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3682 | /* Move pointer to ahead of SETOKCMODE<delimiter> */ |
| 3683 | value = value + 11; |
| 3684 | /* Convert the value from ascii to integer */ |
| 3685 | ret = kstrtou8(value, 10, &okcMode); |
| 3686 | if (ret < 0) |
| 3687 | { |
| 3688 | /* If the input value is greater than max value of datatype, then also |
| 3689 | kstrtou8 fails */ |
| 3690 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3691 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3692 | CFG_OKC_FEATURE_ENABLED_MIN, |
| 3693 | CFG_OKC_FEATURE_ENABLED_MAX); |
| 3694 | ret = -EINVAL; |
| 3695 | goto exit; |
| 3696 | } |
| 3697 | |
| 3698 | if ((okcMode < CFG_OKC_FEATURE_ENABLED_MIN) || |
| 3699 | (okcMode > CFG_OKC_FEATURE_ENABLED_MAX)) |
| 3700 | { |
| 3701 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3702 | "Okc mode value %d is out of range" |
| 3703 | " (Min: %d Max: %d)", okcMode, |
| 3704 | CFG_OKC_FEATURE_ENABLED_MIN, |
| 3705 | CFG_OKC_FEATURE_ENABLED_MAX); |
| 3706 | ret = -EINVAL; |
| 3707 | goto exit; |
| 3708 | } |
| 3709 | |
| 3710 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3711 | "%s: Received Command to change okc mode = %d", __func__, okcMode); |
| 3712 | |
| 3713 | pHddCtx->cfg_ini->isOkcIniFeatureEnabled = okcMode; |
| 3714 | } |
Srinivas Girigowda | ad34ca9 | 2013-10-22 10:54:29 -0700 | [diff] [blame] | 3715 | #endif /* FEATURE_WLAN_OKC */ |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 3716 | else if (strncmp(priv_data.buf, "GETROAMSCANCONTROL", 18) == 0) |
| 3717 | { |
| 3718 | tANI_BOOLEAN roamScanControl = sme_GetRoamScanControl((tHalHandle)(pHddCtx->hHal)); |
| 3719 | char extra[32]; |
| 3720 | tANI_U8 len = 0; |
| 3721 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3722 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3723 | command, roamScanControl); |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 3724 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 3725 | { |
| 3726 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3727 | "%s: failed to copy data to user buffer", __func__); |
| 3728 | ret = -EFAULT; |
| 3729 | goto exit; |
| 3730 | } |
| 3731 | } |
Gopichand Nakkala | 227c7f3 | 2013-06-26 22:44:57 +0530 | [diff] [blame] | 3732 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 3733 | else if (strncmp(command, "ENABLE_PKTFILTER_IPV6", 21) == 0) |
| 3734 | { |
| 3735 | tANI_U8 filterType = 0; |
| 3736 | tANI_U8 *value = command; |
| 3737 | |
| 3738 | /* Move pointer to ahead of ENABLE_PKTFILTER_IPV6<delimiter> */ |
| 3739 | value = value + 22; |
| 3740 | |
| 3741 | /* Convert the value from ascii to integer */ |
| 3742 | ret = kstrtou8(value, 10, &filterType); |
| 3743 | if (ret < 0) |
| 3744 | { |
| 3745 | /* If the input value is greater than max value of datatype, |
| 3746 | * then also kstrtou8 fails |
| 3747 | */ |
| 3748 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3749 | "%s: kstrtou8 failed range ", __func__); |
| 3750 | ret = -EINVAL; |
| 3751 | goto exit; |
| 3752 | } |
| 3753 | |
| 3754 | if (filterType != 0 && filterType != 1) |
| 3755 | { |
| 3756 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3757 | "%s: Accepted Values are 0 and 1 ", __func__); |
| 3758 | ret = -EINVAL; |
| 3759 | goto exit; |
| 3760 | } |
| 3761 | wlan_hdd_setIPv6Filter(WLAN_HDD_GET_CTX(pAdapter), filterType, |
| 3762 | pAdapter->sessionId); |
| 3763 | } |
| 3764 | #endif |
Sundaresan Ramachandran | 76e48e8 | 2013-07-15 13:07:17 +0530 | [diff] [blame] | 3765 | else if (strncmp(command, "BTCOEXMODE", 10) == 0 ) |
| 3766 | { |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 3767 | char *dhcpPhase; |
Satyanarayana Dash | 1faea4f | 2014-09-22 16:21:04 +0530 | [diff] [blame] | 3768 | int ret; |
| 3769 | |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 3770 | dhcpPhase = command + 11; |
| 3771 | if ('1' == *dhcpPhase) |
Sundaresan Ramachandran | 76e48e8 | 2013-07-15 13:07:17 +0530 | [diff] [blame] | 3772 | { |
Deepthi Gowri | bfd1713 | 2014-11-14 17:59:04 +0530 | [diff] [blame] | 3773 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 3774 | FL("send DHCP START indication")); |
c_hpothu | 9b781ba | 2013-12-30 20:57:45 +0530 | [diff] [blame] | 3775 | |
| 3776 | pHddCtx->btCoexModeSet = TRUE; |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 3777 | |
Satyanarayana Dash | 1faea4f | 2014-09-22 16:21:04 +0530 | [diff] [blame] | 3778 | ret = wlan_hdd_scan_abort(pAdapter); |
| 3779 | if (ret < 0) |
| 3780 | { |
| 3781 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3782 | FL("failed to abort existing scan %d"), ret); |
| 3783 | } |
| 3784 | |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 3785 | sme_DHCPStartInd(pHddCtx->hHal, pAdapter->device_mode, |
| 3786 | pAdapter->sessionId); |
Sundaresan Ramachandran | 76e48e8 | 2013-07-15 13:07:17 +0530 | [diff] [blame] | 3787 | } |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 3788 | else if ('2' == *dhcpPhase) |
Sundaresan Ramachandran | 76e48e8 | 2013-07-15 13:07:17 +0530 | [diff] [blame] | 3789 | { |
Deepthi Gowri | bfd1713 | 2014-11-14 17:59:04 +0530 | [diff] [blame] | 3790 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 3791 | FL("send DHCP STOP indication")); |
c_hpothu | 9b781ba | 2013-12-30 20:57:45 +0530 | [diff] [blame] | 3792 | |
| 3793 | pHddCtx->btCoexModeSet = FALSE; |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 3794 | |
| 3795 | sme_DHCPStopInd(pHddCtx->hHal, pAdapter->device_mode, |
| 3796 | pAdapter->sessionId); |
Sundaresan Ramachandran | 76e48e8 | 2013-07-15 13:07:17 +0530 | [diff] [blame] | 3797 | } |
| 3798 | } |
Jeff Johnson | f54df2c | 2013-07-24 11:43:39 -0700 | [diff] [blame] | 3799 | else if (strncmp(command, "SCAN-ACTIVE", 11) == 0) |
| 3800 | { |
c_hpothu | dbefd3e | 2014-04-28 15:59:47 +0530 | [diff] [blame] | 3801 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3802 | FL("making default scan to ACTIVE")); |
| 3803 | pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN; |
Jeff Johnson | f54df2c | 2013-07-24 11:43:39 -0700 | [diff] [blame] | 3804 | } |
| 3805 | else if (strncmp(command, "SCAN-PASSIVE", 12) == 0) |
| 3806 | { |
c_hpothu | dbefd3e | 2014-04-28 15:59:47 +0530 | [diff] [blame] | 3807 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3808 | FL("making default scan to PASSIVE")); |
| 3809 | pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN; |
Jeff Johnson | f54df2c | 2013-07-24 11:43:39 -0700 | [diff] [blame] | 3810 | } |
Hanumantha Reddy Pothula | 212243c | 2013-08-01 17:28:31 +0530 | [diff] [blame] | 3811 | else if (strncmp(command, "GETDWELLTIME", 12) == 0) |
| 3812 | { |
| 3813 | hdd_config_t *pCfg = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini; |
| 3814 | char extra[32]; |
| 3815 | tANI_U8 len = 0; |
| 3816 | |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 3817 | memset(extra, 0, sizeof(extra)); |
| 3818 | ret = hdd_get_dwell_time(pCfg, command, extra, sizeof(extra), &len); |
| 3819 | 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] | 3820 | { |
| 3821 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3822 | "%s: failed to copy data to user buffer", __func__); |
| 3823 | ret = -EFAULT; |
| 3824 | goto exit; |
| 3825 | } |
| 3826 | ret = len; |
| 3827 | } |
| 3828 | else if (strncmp(command, "SETDWELLTIME", 12) == 0) |
| 3829 | { |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 3830 | ret = hdd_set_dwell_time(pAdapter, command); |
Hanumantha Reddy Pothula | 212243c | 2013-08-01 17:28:31 +0530 | [diff] [blame] | 3831 | } |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 3832 | else if ( strncasecmp(command, "MIRACAST", 8) == 0 ) |
| 3833 | { |
| 3834 | tANI_U8 filterType = 0; |
| 3835 | tANI_U8 *value; |
| 3836 | value = command + 9; |
| 3837 | |
| 3838 | /* Convert the value from ascii to integer */ |
| 3839 | ret = kstrtou8(value, 10, &filterType); |
| 3840 | if (ret < 0) |
| 3841 | { |
| 3842 | /* If the input value is greater than max value of datatype, |
| 3843 | * then also kstrtou8 fails |
| 3844 | */ |
| 3845 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3846 | "%s: kstrtou8 failed range ", __func__); |
| 3847 | ret = -EINVAL; |
| 3848 | goto exit; |
| 3849 | } |
| 3850 | if ((filterType < WLAN_HDD_DRIVER_MIRACAST_CFG_MIN_VAL ) || |
| 3851 | (filterType > WLAN_HDD_DRIVER_MIRACAST_CFG_MAX_VAL)) |
| 3852 | { |
| 3853 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3854 | "%s: Accepted Values are 0 to 2. 0-Disabled, 1-Source," |
| 3855 | " 2-Sink ", __func__); |
| 3856 | ret = -EINVAL; |
| 3857 | goto exit; |
| 3858 | } |
| 3859 | //Filtertype value should be either 0-Disabled, 1-Source, 2-sink |
| 3860 | pHddCtx->drvr_miracast = filterType; |
Kaushik, Sushant | 9612244 | 2014-10-21 16:40:18 +0530 | [diff] [blame] | 3861 | pScanInfo = &pHddCtx->scan_info; |
| 3862 | if (filterType && pScanInfo != NULL && |
| 3863 | pHddCtx->scan_info.mScanPending) |
| 3864 | { |
| 3865 | /*Miracast Session started. Abort Scan */ |
| 3866 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3867 | "%s, Aborting Scan For Miracast",__func__); |
| 3868 | hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId, |
| 3869 | eCSR_SCAN_ABORT_DEFAULT); |
| 3870 | } |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 3871 | hdd_tx_rx_pkt_cnt_stat_timer_handler(pHddCtx); |
Ganesh Kondabattini | 8f6e3b3 | 2014-08-25 16:07:54 +0530 | [diff] [blame] | 3872 | sme_SetMiracastMode(pHddCtx->hHal, pHddCtx->drvr_miracast); |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 3873 | } |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 3874 | else if (strncmp(command, "SETMCRATE", 9) == 0) |
| 3875 | { |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 3876 | tANI_U8 *value = command; |
| 3877 | int targetRate; |
Leo Chang | 1f98cbd | 2013-10-17 15:03:52 -0700 | [diff] [blame] | 3878 | tSirRateUpdateInd *rateUpdate; |
| 3879 | eHalStatus status; |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 3880 | |
| 3881 | /* Only valid for SAP mode */ |
| 3882 | if (WLAN_HDD_SOFTAP != pAdapter->device_mode) |
| 3883 | { |
| 3884 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3885 | "%s: SAP mode is not running", __func__); |
| 3886 | ret = -EFAULT; |
| 3887 | goto exit; |
| 3888 | } |
| 3889 | |
| 3890 | /* Move pointer to ahead of SETMCRATE<delimiter> */ |
| 3891 | /* input value is in units of hundred kbps */ |
| 3892 | value = value + 10; |
| 3893 | /* Convert the value from ascii to integer, decimal base */ |
| 3894 | ret = kstrtouint(value, 10, &targetRate); |
| 3895 | |
Leo Chang | 1f98cbd | 2013-10-17 15:03:52 -0700 | [diff] [blame] | 3896 | rateUpdate = (tSirRateUpdateInd *)vos_mem_malloc(sizeof(tSirRateUpdateInd)); |
| 3897 | if (NULL == rateUpdate) |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 3898 | { |
Leo Chang | 1f98cbd | 2013-10-17 15:03:52 -0700 | [diff] [blame] | 3899 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3900 | "%s: SETMCRATE indication alloc fail", __func__); |
| 3901 | ret = -EFAULT; |
| 3902 | goto exit; |
| 3903 | } |
| 3904 | vos_mem_zero(rateUpdate, sizeof(tSirRateUpdateInd )); |
| 3905 | |
| 3906 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3907 | "MC Target rate %d", targetRate); |
| 3908 | /* Ignore unicast */ |
| 3909 | rateUpdate->ucastDataRate = -1; |
| 3910 | rateUpdate->mcastDataRate24GHz = targetRate; |
| 3911 | rateUpdate->mcastDataRate5GHz = targetRate; |
| 3912 | rateUpdate->mcastDataRate24GHzTxFlag = 0; |
| 3913 | rateUpdate->mcastDataRate5GHzTxFlag = 0; |
| 3914 | status = sme_SendRateUpdateInd(pHddCtx->hHal, rateUpdate); |
| 3915 | if (eHAL_STATUS_SUCCESS != status) |
| 3916 | { |
| 3917 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3918 | "%s: SET_MC_RATE failed", __func__); |
| 3919 | vos_mem_free(rateUpdate); |
| 3920 | ret = -EFAULT; |
| 3921 | goto exit; |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 3922 | } |
| 3923 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 3924 | #ifdef FEATURE_WLAN_BATCH_SCAN |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 3925 | else if (strncmp(command, "WLS_BATCHING", 12) == 0) |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 3926 | { |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 3927 | ret = hdd_handle_batch_scan_ioctl(pAdapter, &priv_data, command); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 3928 | } |
| 3929 | #endif |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3930 | #if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD) |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 3931 | else if (strncmp(command, "SETCCXROAMSCANCHANNELS", 22) == 0) |
| 3932 | { |
| 3933 | tANI_U8 *value = command; |
| 3934 | tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0}; |
| 3935 | tANI_U8 numChannels = 0; |
| 3936 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 3937 | |
| 3938 | status = hdd_parse_channellist(value, ChannelList, &numChannels); |
| 3939 | if (eHAL_STATUS_SUCCESS != status) |
| 3940 | { |
| 3941 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3942 | "%s: Failed to parse channel list information", __func__); |
| 3943 | ret = -EINVAL; |
| 3944 | goto exit; |
| 3945 | } |
| 3946 | |
| 3947 | if (numChannels > WNI_CFG_VALID_CHANNEL_LIST_LEN) |
| 3948 | { |
| 3949 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3950 | "%s: number of channels (%d) supported exceeded max (%d)", __func__, |
| 3951 | numChannels, WNI_CFG_VALID_CHANNEL_LIST_LEN); |
| 3952 | ret = -EINVAL; |
| 3953 | goto exit; |
| 3954 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3955 | status = sme_SetEseRoamScanChannelList((tHalHandle)(pHddCtx->hHal), |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 3956 | ChannelList, |
| 3957 | numChannels); |
| 3958 | if (eHAL_STATUS_SUCCESS != status) |
| 3959 | { |
| 3960 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3961 | "%s: Failed to update channel list information", __func__); |
| 3962 | ret = -EINVAL; |
| 3963 | goto exit; |
| 3964 | } |
| 3965 | } |
| 3966 | else if (strncmp(command, "GETTSMSTATS", 11) == 0) |
| 3967 | { |
| 3968 | tANI_U8 *value = command; |
| 3969 | char extra[128] = {0}; |
| 3970 | int len = 0; |
| 3971 | tANI_U8 tid = 0; |
| 3972 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 3973 | tAniTrafStrmMetrics tsmMetrics; |
| 3974 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3975 | |
| 3976 | /* if not associated, return error */ |
| 3977 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 3978 | { |
| 3979 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:Not associated!",__func__); |
| 3980 | ret = -EINVAL; |
| 3981 | goto exit; |
| 3982 | } |
| 3983 | |
| 3984 | /* Move pointer to ahead of GETTSMSTATS<delimiter> */ |
| 3985 | value = value + 12; |
| 3986 | /* Convert the value from ascii to integer */ |
| 3987 | ret = kstrtou8(value, 10, &tid); |
| 3988 | if (ret < 0) |
| 3989 | { |
| 3990 | /* If the input value is greater than max value of datatype, then also |
| 3991 | kstrtou8 fails */ |
| 3992 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3993 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3994 | TID_MIN_VALUE, |
| 3995 | TID_MAX_VALUE); |
| 3996 | ret = -EINVAL; |
| 3997 | goto exit; |
| 3998 | } |
| 3999 | |
| 4000 | if ((tid < TID_MIN_VALUE) || (tid > TID_MAX_VALUE)) |
| 4001 | { |
| 4002 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4003 | "tid value %d is out of range" |
| 4004 | " (Min: %d Max: %d)", tid, |
| 4005 | TID_MIN_VALUE, |
| 4006 | TID_MAX_VALUE); |
| 4007 | ret = -EINVAL; |
| 4008 | goto exit; |
| 4009 | } |
| 4010 | |
| 4011 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4012 | "%s: Received Command to get tsm stats tid = %d", __func__, tid); |
| 4013 | |
| 4014 | if (VOS_STATUS_SUCCESS != hdd_get_tsm_stats(pAdapter, tid, &tsmMetrics)) |
| 4015 | { |
| 4016 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4017 | "%s: failed to get tsm stats", __func__); |
| 4018 | ret = -EFAULT; |
| 4019 | goto exit; |
| 4020 | } |
| 4021 | |
| 4022 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4023 | "UplinkPktQueueDly(%d)\n" |
| 4024 | "UplinkPktQueueDlyHist[0](%d)\n" |
| 4025 | "UplinkPktQueueDlyHist[1](%d)\n" |
| 4026 | "UplinkPktQueueDlyHist[2](%d)\n" |
| 4027 | "UplinkPktQueueDlyHist[3](%d)\n" |
Arun Kumar Khandavalli | e876821 | 2014-02-17 16:43:34 +0530 | [diff] [blame] | 4028 | "UplinkPktTxDly(%u)\n" |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4029 | "UplinkPktLoss(%d)\n" |
| 4030 | "UplinkPktCount(%d)\n" |
| 4031 | "RoamingCount(%d)\n" |
| 4032 | "RoamingDly(%d)", tsmMetrics.UplinkPktQueueDly, |
| 4033 | tsmMetrics.UplinkPktQueueDlyHist[0], |
| 4034 | tsmMetrics.UplinkPktQueueDlyHist[1], |
| 4035 | tsmMetrics.UplinkPktQueueDlyHist[2], |
| 4036 | tsmMetrics.UplinkPktQueueDlyHist[3], |
| 4037 | tsmMetrics.UplinkPktTxDly, tsmMetrics.UplinkPktLoss, |
| 4038 | tsmMetrics.UplinkPktCount, tsmMetrics.RoamingCount, tsmMetrics.RoamingDly); |
| 4039 | |
| 4040 | /* Output TSM stats is of the format |
| 4041 | GETTSMSTATS [PktQueueDly] [PktQueueDlyHist[0]]:[PktQueueDlyHist[1]] ...[RoamingDly] |
| 4042 | eg., GETTSMSTATS 10 1:0:0:161 20 1 17 8 39800 */ |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4043 | 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] | 4044 | tsmMetrics.UplinkPktQueueDly, tsmMetrics.UplinkPktQueueDlyHist[0], |
| 4045 | tsmMetrics.UplinkPktQueueDlyHist[1], tsmMetrics.UplinkPktQueueDlyHist[2], |
| 4046 | tsmMetrics.UplinkPktQueueDlyHist[3], tsmMetrics.UplinkPktTxDly, |
| 4047 | tsmMetrics.UplinkPktLoss, tsmMetrics.UplinkPktCount, tsmMetrics.RoamingCount, |
| 4048 | tsmMetrics.RoamingDly); |
| 4049 | |
| 4050 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 4051 | { |
| 4052 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4053 | "%s: failed to copy data to user buffer", __func__); |
| 4054 | ret = -EFAULT; |
| 4055 | goto exit; |
| 4056 | } |
| 4057 | } |
| 4058 | else if (strncmp(command, "SETCCKMIE", 9) == 0) |
| 4059 | { |
| 4060 | tANI_U8 *value = command; |
| 4061 | tANI_U8 *cckmIe = NULL; |
| 4062 | tANI_U8 cckmIeLen = 0; |
| 4063 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 4064 | |
| 4065 | status = hdd_parse_get_cckm_ie(value, &cckmIe, &cckmIeLen); |
| 4066 | if (eHAL_STATUS_SUCCESS != status) |
| 4067 | { |
| 4068 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4069 | "%s: Failed to parse cckm ie data", __func__); |
| 4070 | ret = -EINVAL; |
| 4071 | goto exit; |
| 4072 | } |
| 4073 | |
| 4074 | if (cckmIeLen > DOT11F_IE_RSN_MAX_LEN) |
| 4075 | { |
| 4076 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4077 | "%s: CCKM Ie input length is more than max[%d]", __func__, |
| 4078 | DOT11F_IE_RSN_MAX_LEN); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 4079 | vos_mem_free(cckmIe); |
| 4080 | cckmIe = NULL; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4081 | ret = -EINVAL; |
| 4082 | goto exit; |
| 4083 | } |
| 4084 | sme_SetCCKMIe((tHalHandle)(pHddCtx->hHal), pAdapter->sessionId, cckmIe, cckmIeLen); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 4085 | vos_mem_free(cckmIe); |
| 4086 | cckmIe = NULL; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4087 | } |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4088 | else if (strncmp(command, "CCXBEACONREQ", 12) == 0) |
| 4089 | { |
| 4090 | tANI_U8 *value = command; |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4091 | tCsrEseBeaconReq eseBcnReq; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4092 | eHalStatus status = eHAL_STATUS_SUCCESS; |
Srinivas Girigowda | 0c6d7fe | 2014-05-28 18:18:10 -0700 | [diff] [blame] | 4093 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4094 | status = hdd_parse_ese_beacon_req(value, &eseBcnReq); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4095 | if (eHAL_STATUS_SUCCESS != status) |
| 4096 | { |
| 4097 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4098 | "%s: Failed to parse ese beacon req", __func__); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4099 | ret = -EINVAL; |
| 4100 | goto exit; |
| 4101 | } |
Srinivas Girigowda | 0c6d7fe | 2014-05-28 18:18:10 -0700 | [diff] [blame] | 4102 | if (!hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) { |
| 4103 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Not associated")); |
| 4104 | hdd_indicateEseBcnReportNoResults (pAdapter, |
| 4105 | eseBcnReq.bcnReq[0].measurementToken, |
| 4106 | 0x02, //BIT(1) set for measurement done |
| 4107 | 0); // no BSS |
| 4108 | goto exit; |
| 4109 | } |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4110 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4111 | status = sme_SetEseBeaconRequest((tHalHandle)(pHddCtx->hHal), pAdapter->sessionId, &eseBcnReq); |
| 4112 | if (eHAL_STATUS_SUCCESS != status) |
| 4113 | { |
| 4114 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4115 | "%s: sme_SetEseBeaconRequest failed (%d)", __func__, status); |
| 4116 | ret = -EINVAL; |
| 4117 | goto exit; |
| 4118 | } |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4119 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4120 | #endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */ |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 4121 | else if (strncmp(command, "GETBCNMISSRATE", 14) == 0) |
| 4122 | { |
| 4123 | eHalStatus status; |
| 4124 | char buf[32], len; |
| 4125 | long waitRet; |
| 4126 | bcnMissRateContext_t getBcnMissRateCtx; |
| 4127 | |
| 4128 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 4129 | |
| 4130 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 4131 | { |
| 4132 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 4133 | FL("GETBCNMISSRATE: STA is not in connected state")); |
| 4134 | ret = -1; |
| 4135 | goto exit; |
| 4136 | } |
| 4137 | |
| 4138 | init_completion(&(getBcnMissRateCtx.completion)); |
| 4139 | getBcnMissRateCtx.magic = BCN_MISS_RATE_CONTEXT_MAGIC; |
| 4140 | |
| 4141 | status = sme_getBcnMissRate((tHalHandle)(pHddCtx->hHal), |
| 4142 | pAdapter->sessionId, |
| 4143 | (void *)getBcnMissRateCB, |
| 4144 | (void *)(&getBcnMissRateCtx)); |
| 4145 | if( eHAL_STATUS_SUCCESS != status) |
| 4146 | { |
| 4147 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4148 | FL("GETBCNMISSRATE: fail to post WDA cmd")); |
| 4149 | ret = -EINVAL; |
| 4150 | goto exit; |
| 4151 | } |
| 4152 | |
| 4153 | waitRet = wait_for_completion_interruptible_timeout |
| 4154 | (&getBcnMissRateCtx.completion, BCN_MISS_RATE_TIME); |
| 4155 | if(waitRet <= 0) |
| 4156 | { |
| 4157 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4158 | FL("failed to wait on bcnMissRateComp %d"), ret); |
| 4159 | |
| 4160 | //Make magic number to zero so that callback is not called. |
| 4161 | spin_lock(&hdd_context_lock); |
| 4162 | getBcnMissRateCtx.magic = 0x0; |
| 4163 | spin_unlock(&hdd_context_lock); |
| 4164 | ret = -EINVAL; |
| 4165 | goto exit; |
| 4166 | } |
| 4167 | |
| 4168 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4169 | FL("GETBCNMISSRATE: bcnMissRate: %d"), gbcnMissRate); |
| 4170 | |
| 4171 | len = snprintf(buf, sizeof(buf), "GETBCNMISSRATE %d", gbcnMissRate); |
| 4172 | if (copy_to_user(priv_data.buf, &buf, len + 1)) |
| 4173 | { |
| 4174 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4175 | "%s: failed to copy data to user buffer", __func__); |
| 4176 | ret = -EFAULT; |
| 4177 | goto exit; |
| 4178 | } |
| 4179 | ret = len; |
| 4180 | } |
Atul Mittal | 87ec242 | 2014-09-24 13:12:50 +0530 | [diff] [blame] | 4181 | #ifdef FEATURE_WLAN_TDLS |
| 4182 | else if (strncmp(command, "TDLSSECONDARYCHANNELOFFSET", 26) == 0) { |
| 4183 | tANI_U8 *value = command; |
| 4184 | int set_value; |
| 4185 | /* Move pointer to ahead of TDLSOFFCH*/ |
| 4186 | value += 26; |
| 4187 | sscanf(value, "%d", &set_value); |
| 4188 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4189 | "%s: Tdls offchannel offset:%d", |
| 4190 | __func__, set_value); |
| 4191 | ret = iw_set_tdlssecoffchanneloffset(pHddCtx, set_value); |
| 4192 | if (ret < 0) |
| 4193 | { |
| 4194 | ret = -EINVAL; |
| 4195 | goto exit; |
| 4196 | } |
| 4197 | |
| 4198 | } else if (strncmp(command, "TDLSOFFCHANNELMODE", 18) == 0) { |
| 4199 | tANI_U8 *value = command; |
| 4200 | int set_value; |
| 4201 | /* Move pointer to ahead of tdlsoffchnmode*/ |
| 4202 | value += 18; |
| 4203 | sscanf(value, "%d", &set_value); |
| 4204 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4205 | "%s: Tdls offchannel mode:%d", |
| 4206 | __func__, set_value); |
| 4207 | ret = iw_set_tdlsoffchannelmode(pAdapter, set_value); |
| 4208 | if (ret < 0) |
| 4209 | { |
| 4210 | ret = -EINVAL; |
| 4211 | goto exit; |
| 4212 | } |
| 4213 | } else if (strncmp(command, "TDLSOFFCHANNEL", 14) == 0) { |
| 4214 | tANI_U8 *value = command; |
| 4215 | int set_value; |
| 4216 | /* Move pointer to ahead of TDLSOFFCH*/ |
| 4217 | value += 14; |
| 4218 | sscanf(value, "%d", &set_value); |
| 4219 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4220 | "%s: Tdls offchannel num: %d", |
| 4221 | __func__, set_value); |
| 4222 | ret = iw_set_tdlsoffchannel(pHddCtx, set_value); |
| 4223 | if (ret < 0) |
| 4224 | { |
| 4225 | ret = -EINVAL; |
| 4226 | goto exit; |
| 4227 | } |
| 4228 | } |
| 4229 | #endif |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 4230 | else if (strncmp(command, "GETFWSTATS", 10) == 0) |
| 4231 | { |
| 4232 | eHalStatus status; |
| 4233 | char *buf = NULL; |
| 4234 | char len; |
| 4235 | long waitRet; |
| 4236 | fwStatsContext_t fwStatsCtx; |
Abhishek Singh | 08aa776 | 2014-12-16 13:59:03 +0530 | [diff] [blame] | 4237 | tSirFwStatsResult *fwStatsRsp = &(pAdapter->fwStatsRsp); |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 4238 | tANI_U8 *ptr = command; |
| 4239 | int stats = *(ptr + 11) - '0'; |
| 4240 | |
| 4241 | hddLog(VOS_TRACE_LEVEL_INFO, FL("stats = %d "),stats); |
| 4242 | if (!IS_FEATURE_FW_STATS_ENABLE) |
| 4243 | { |
| 4244 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4245 | FL("Get Firmware stats feature not supported")); |
| 4246 | ret = -EINVAL; |
| 4247 | goto exit; |
| 4248 | } |
| 4249 | |
| 4250 | if (FW_STATS_MAX <= stats || 0 >= stats) |
| 4251 | { |
| 4252 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4253 | FL(" stats %d not supported"),stats); |
| 4254 | ret = -EINVAL; |
| 4255 | goto exit; |
| 4256 | } |
| 4257 | |
| 4258 | init_completion(&(fwStatsCtx.completion)); |
| 4259 | fwStatsCtx.magic = FW_STATS_CONTEXT_MAGIC; |
| 4260 | fwStatsCtx.pAdapter = pAdapter; |
| 4261 | fwStatsRsp->type = 0; |
| 4262 | status = sme_GetFwStats( (tHalHandle)pHddCtx->hHal, stats, |
Abhishek Singh | 08aa776 | 2014-12-16 13:59:03 +0530 | [diff] [blame] | 4263 | &fwStatsCtx, hdd_FWStatisCB); |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 4264 | if (eHAL_STATUS_SUCCESS != status) |
| 4265 | { |
| 4266 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4267 | FL(" fail to post WDA cmd status = %d"), status); |
| 4268 | ret = -EINVAL; |
| 4269 | goto exit; |
| 4270 | } |
| 4271 | waitRet = wait_for_completion_timeout |
| 4272 | (&(fwStatsCtx.completion), FW_STATE_WAIT_TIME); |
| 4273 | if (waitRet <= 0) |
| 4274 | { |
| 4275 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4276 | FL("failed to wait on GwtFwstats")); |
| 4277 | //Make magic number to zero so that callback is not executed. |
| 4278 | spin_lock(&hdd_context_lock); |
| 4279 | fwStatsCtx.magic = 0x0; |
| 4280 | spin_unlock(&hdd_context_lock); |
| 4281 | ret = -EINVAL; |
| 4282 | goto exit; |
| 4283 | } |
| 4284 | if (fwStatsRsp->type) |
| 4285 | { |
| 4286 | buf = kmalloc(FW_STATE_RSP_LEN, GFP_KERNEL); |
| 4287 | if (!buf) |
| 4288 | { |
| 4289 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4290 | FL(" failed to allocate memory")); |
| 4291 | ret = -ENOMEM; |
| 4292 | goto exit; |
| 4293 | } |
| 4294 | switch( fwStatsRsp->type ) |
| 4295 | { |
| 4296 | case FW_UBSP_STATS: |
| 4297 | { |
| 4298 | len = snprintf(buf, FW_STATE_RSP_LEN, |
| 4299 | "GETFWSTATS: ubsp_enter_cnt %d ubsp_jump_ddr_cnt %d", |
Abhishek Singh | 08aa776 | 2014-12-16 13:59:03 +0530 | [diff] [blame] | 4300 | fwStatsRsp->fwStatsData.ubspStats.ubsp_enter_cnt, |
| 4301 | fwStatsRsp->fwStatsData.ubspStats.ubsp_jump_ddr_cnt); |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 4302 | } |
| 4303 | break; |
| 4304 | default: |
| 4305 | { |
| 4306 | hddLog(VOS_TRACE_LEVEL_ERROR, FL( "No handling for stats type %d"),fwStatsRsp->type); |
| 4307 | ret = -EFAULT; |
| 4308 | kfree(buf); |
| 4309 | goto exit; |
| 4310 | } |
| 4311 | } |
| 4312 | if (copy_to_user(priv_data.buf, buf, len + 1)) |
| 4313 | { |
| 4314 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4315 | FL(" failed to copy data to user buffer")); |
| 4316 | ret = -EFAULT; |
| 4317 | kfree(buf); |
| 4318 | goto exit; |
| 4319 | } |
| 4320 | ret = len; |
| 4321 | kfree(buf); |
| 4322 | } |
| 4323 | else |
| 4324 | { |
| 4325 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4326 | FL("failed to fetch the stats")); |
| 4327 | ret = -EFAULT; |
| 4328 | goto exit; |
| 4329 | } |
| 4330 | |
| 4331 | } |
Madan Mohan Koyyalamudi | f9bdd4e | 2012-10-30 18:05:03 -0700 | [diff] [blame] | 4332 | else { |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 4333 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 4334 | TRACE_CODE_HDD_UNSUPPORTED_IOCTL, |
| 4335 | pAdapter->sessionId, 0)); |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 4336 | hddLog( VOS_TRACE_LEVEL_WARN, FL("Unsupported GUI command %s"), |
| 4337 | command); |
Madan Mohan Koyyalamudi | f9bdd4e | 2012-10-30 18:05:03 -0700 | [diff] [blame] | 4338 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4339 | } |
| 4340 | exit: |
| 4341 | if (command) |
| 4342 | { |
| 4343 | kfree(command); |
| 4344 | } |
| 4345 | return ret; |
| 4346 | } |
| 4347 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 4348 | #ifdef CONFIG_COMPAT |
| 4349 | static int hdd_driver_compat_ioctl(hdd_adapter_t *pAdapter, struct ifreq *ifr) |
| 4350 | { |
| 4351 | struct { |
| 4352 | compat_uptr_t buf; |
| 4353 | int used_len; |
| 4354 | int total_len; |
| 4355 | } compat_priv_data; |
| 4356 | hdd_priv_data_t priv_data; |
| 4357 | int ret = 0; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4358 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 4359 | /* |
| 4360 | * Note that pAdapter and ifr have already been verified by caller, |
| 4361 | * and HDD context has also been validated |
| 4362 | */ |
| 4363 | if (copy_from_user(&compat_priv_data, ifr->ifr_data, |
| 4364 | sizeof(compat_priv_data))) { |
| 4365 | ret = -EFAULT; |
| 4366 | goto exit; |
| 4367 | } |
| 4368 | priv_data.buf = compat_ptr(compat_priv_data.buf); |
| 4369 | priv_data.used_len = compat_priv_data.used_len; |
| 4370 | priv_data.total_len = compat_priv_data.total_len; |
| 4371 | ret = hdd_driver_command(pAdapter, &priv_data); |
| 4372 | exit: |
| 4373 | return ret; |
| 4374 | } |
| 4375 | #else /* CONFIG_COMPAT */ |
| 4376 | static int hdd_driver_compat_ioctl(hdd_adapter_t *pAdapter, struct ifreq *ifr) |
| 4377 | { |
| 4378 | /* will never be invoked */ |
| 4379 | return 0; |
| 4380 | } |
| 4381 | #endif /* CONFIG_COMPAT */ |
| 4382 | |
| 4383 | static int hdd_driver_ioctl(hdd_adapter_t *pAdapter, struct ifreq *ifr) |
| 4384 | { |
| 4385 | hdd_priv_data_t priv_data; |
| 4386 | int ret = 0; |
| 4387 | |
| 4388 | /* |
| 4389 | * Note that pAdapter and ifr have already been verified by caller, |
| 4390 | * and HDD context has also been validated |
| 4391 | */ |
| 4392 | if (copy_from_user(&priv_data, ifr->ifr_data, sizeof(priv_data))) { |
| 4393 | ret = -EFAULT; |
| 4394 | } else { |
| 4395 | ret = hdd_driver_command(pAdapter, &priv_data); |
| 4396 | } |
| 4397 | return ret; |
| 4398 | } |
| 4399 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 4400 | int __hdd_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 4401 | { |
| 4402 | hdd_adapter_t *pAdapter; |
| 4403 | hdd_context_t *pHddCtx; |
| 4404 | int ret; |
| 4405 | |
| 4406 | pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 4407 | if (NULL == pAdapter) { |
| 4408 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 4409 | "%s: HDD adapter context is Null", __func__); |
| 4410 | ret = -ENODEV; |
| 4411 | goto exit; |
| 4412 | } |
| 4413 | if (dev != pAdapter->dev) { |
| 4414 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 4415 | "%s: HDD adapter/dev inconsistency", __func__); |
| 4416 | ret = -ENODEV; |
| 4417 | goto exit; |
| 4418 | } |
| 4419 | |
| 4420 | if ((!ifr) || (!ifr->ifr_data)) { |
| 4421 | ret = -EINVAL; |
| 4422 | goto exit; |
| 4423 | } |
| 4424 | |
| 4425 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 4426 | ret = wlan_hdd_validate_context(pHddCtx); |
| 4427 | if (ret) { |
Mahesh A Saptasagar | 5b16d0a | 2014-11-03 17:55:29 +0530 | [diff] [blame] | 4428 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 4429 | "%s: invalid context", __func__); |
| 4430 | ret = -EBUSY; |
| 4431 | goto exit; |
| 4432 | } |
| 4433 | |
| 4434 | switch (cmd) { |
| 4435 | case (SIOCDEVPRIVATE + 1): |
| 4436 | if (is_compat_task()) |
| 4437 | ret = hdd_driver_compat_ioctl(pAdapter, ifr); |
| 4438 | else |
| 4439 | ret = hdd_driver_ioctl(pAdapter, ifr); |
| 4440 | break; |
| 4441 | default: |
| 4442 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unknown ioctl %d", |
| 4443 | __func__, cmd); |
| 4444 | ret = -EINVAL; |
| 4445 | break; |
| 4446 | } |
| 4447 | exit: |
| 4448 | return ret; |
| 4449 | } |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4450 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 4451 | int hdd_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) |
| 4452 | { |
| 4453 | int ret; |
| 4454 | |
| 4455 | vos_ssr_protect(__func__); |
| 4456 | ret = __hdd_ioctl(dev, ifr, cmd); |
| 4457 | vos_ssr_unprotect(__func__); |
| 4458 | |
| 4459 | return ret; |
| 4460 | } |
| 4461 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4462 | #if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4463 | /**--------------------------------------------------------------------------- |
| 4464 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4465 | \brief hdd_parse_ese_beacon_req() - Parse ese beacon request |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4466 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4467 | This function parses the ese beacon request passed in the format |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4468 | CCXBEACONREQ<space><Number of fields><space><Measurement token> |
| 4469 | <space>Channel 1<space>Scan Mode <space>Meas Duration<space>Channel N |
| 4470 | <space>Scan Mode N<space>Meas Duration N |
| 4471 | if the Number of bcn req fields (N) does not match with the actual number of fields passed |
| 4472 | then take N. |
| 4473 | <Meas Token><Channel><Scan Mode> and <Meas Duration> are treated as one pair |
| 4474 | For example, CCXBEACONREQ 2 1 1 1 30 2 44 0 40. |
| 4475 | This function does not take care of removing duplicate channels from the list |
| 4476 | |
| 4477 | \param - pValue Pointer to data |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4478 | \param - pEseBcnReq output pointer to store parsed ie information |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4479 | |
| 4480 | \return - 0 for success non-zero for failure |
| 4481 | |
| 4482 | --------------------------------------------------------------------------*/ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4483 | static VOS_STATUS hdd_parse_ese_beacon_req(tANI_U8 *pValue, |
| 4484 | tCsrEseBeaconReq *pEseBcnReq) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4485 | { |
| 4486 | tANI_U8 *inPtr = pValue; |
| 4487 | int tempInt = 0; |
| 4488 | int j = 0, i = 0, v = 0; |
| 4489 | char buf[32]; |
| 4490 | |
| 4491 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 4492 | /*no argument after the command*/ |
| 4493 | if (NULL == inPtr) |
| 4494 | { |
| 4495 | return -EINVAL; |
| 4496 | } |
| 4497 | /*no space after the command*/ |
| 4498 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 4499 | { |
| 4500 | return -EINVAL; |
| 4501 | } |
| 4502 | |
| 4503 | /*removing empty spaces*/ |
| 4504 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
| 4505 | |
| 4506 | /*no argument followed by spaces*/ |
| 4507 | if ('\0' == *inPtr) return -EINVAL; |
| 4508 | |
| 4509 | /*getting the first argument ie measurement token*/ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 4510 | v = sscanf(inPtr, "%31s ", buf); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4511 | if (1 != v) return -EINVAL; |
| 4512 | |
| 4513 | v = kstrtos32(buf, 10, &tempInt); |
| 4514 | if ( v < 0) return -EINVAL; |
| 4515 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4516 | pEseBcnReq->numBcnReqIe = tempInt; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4517 | |
| 4518 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4519 | "Number of Bcn Req Ie fields(%d)", pEseBcnReq->numBcnReqIe); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4520 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4521 | for (j = 0; j < (pEseBcnReq->numBcnReqIe); j++) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4522 | { |
| 4523 | for (i = 0; i < 4; i++) |
| 4524 | { |
| 4525 | /*inPtr pointing to the beginning of first space after number of ie fields*/ |
| 4526 | inPtr = strpbrk( inPtr, " " ); |
| 4527 | /*no ie data after the number of ie fields argument*/ |
| 4528 | if (NULL == inPtr) return -EINVAL; |
| 4529 | |
| 4530 | /*removing empty space*/ |
| 4531 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
| 4532 | |
| 4533 | /*no ie data after the number of ie fields argument and spaces*/ |
| 4534 | if ( '\0' == *inPtr ) return -EINVAL; |
| 4535 | |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 4536 | v = sscanf(inPtr, "%31s ", buf); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4537 | if (1 != v) return -EINVAL; |
| 4538 | |
| 4539 | v = kstrtos32(buf, 10, &tempInt); |
| 4540 | if (v < 0) return -EINVAL; |
| 4541 | |
| 4542 | switch (i) |
| 4543 | { |
| 4544 | case 0: /* Measurement token */ |
| 4545 | if (tempInt <= 0) |
| 4546 | { |
| 4547 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4548 | "Invalid Measurement Token(%d)", tempInt); |
| 4549 | return -EINVAL; |
| 4550 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4551 | pEseBcnReq->bcnReq[j].measurementToken = tempInt; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4552 | break; |
| 4553 | |
| 4554 | case 1: /* Channel number */ |
| 4555 | if ((tempInt <= 0) || |
| 4556 | (tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX)) |
| 4557 | { |
| 4558 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4559 | "Invalid Channel Number(%d)", tempInt); |
| 4560 | return -EINVAL; |
| 4561 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4562 | pEseBcnReq->bcnReq[j].channel = tempInt; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4563 | break; |
| 4564 | |
| 4565 | case 2: /* Scan mode */ |
Varun Reddy Yeturu | 0b18d5a | 2013-12-04 11:42:23 -0800 | [diff] [blame] | 4566 | if ((tempInt < eSIR_PASSIVE_SCAN) || (tempInt > eSIR_BEACON_TABLE)) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4567 | { |
| 4568 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4569 | "Invalid Scan Mode(%d) Expected{0|1|2}", tempInt); |
| 4570 | return -EINVAL; |
| 4571 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4572 | pEseBcnReq->bcnReq[j].scanMode= tempInt; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4573 | break; |
| 4574 | |
| 4575 | case 3: /* Measurement duration */ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4576 | if (((tempInt <= 0) && (pEseBcnReq->bcnReq[j].scanMode != eSIR_BEACON_TABLE)) || |
| 4577 | ((tempInt < 0) && (pEseBcnReq->bcnReq[j].scanMode == eSIR_BEACON_TABLE))) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4578 | { |
| 4579 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4580 | "Invalid Measurement Duration(%d)", tempInt); |
| 4581 | return -EINVAL; |
| 4582 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4583 | pEseBcnReq->bcnReq[j].measurementDuration = tempInt; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4584 | break; |
| 4585 | } |
| 4586 | } |
| 4587 | } |
| 4588 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4589 | for (j = 0; j < pEseBcnReq->numBcnReqIe; j++) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4590 | { |
| 4591 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Arun Kumar Khandavalli | e876821 | 2014-02-17 16:43:34 +0530 | [diff] [blame] | 4592 | "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] | 4593 | j, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4594 | pEseBcnReq->bcnReq[j].measurementToken, |
| 4595 | pEseBcnReq->bcnReq[j].channel, |
| 4596 | pEseBcnReq->bcnReq[j].scanMode, |
| 4597 | pEseBcnReq->bcnReq[j].measurementDuration); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4598 | } |
| 4599 | |
| 4600 | return VOS_STATUS_SUCCESS; |
| 4601 | } |
| 4602 | |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4603 | static void hdd_GetTsmStatsCB( tAniTrafStrmMetrics tsmMetrics, const tANI_U32 staId, void *pContext ) |
| 4604 | { |
| 4605 | struct statsContext *pStatsContext = NULL; |
| 4606 | hdd_adapter_t *pAdapter = NULL; |
| 4607 | |
| 4608 | if (NULL == pContext) |
| 4609 | { |
| 4610 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4611 | "%s: Bad param, pContext [%p]", |
| 4612 | __func__, pContext); |
| 4613 | return; |
| 4614 | } |
| 4615 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 4616 | /* there is a race condition that exists between this callback |
| 4617 | function and the caller since the caller could time out either |
| 4618 | before or while this code is executing. we use a spinlock to |
| 4619 | serialize these actions */ |
| 4620 | spin_lock(&hdd_context_lock); |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4621 | |
| 4622 | pStatsContext = pContext; |
| 4623 | pAdapter = pStatsContext->pAdapter; |
| 4624 | if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic)) |
| 4625 | { |
| 4626 | /* the caller presumably timed out so there is nothing we can do */ |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 4627 | spin_unlock(&hdd_context_lock); |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4628 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 4629 | "%s: Invalid context, pAdapter [%p] magic [%08x]", |
| 4630 | __func__, pAdapter, pStatsContext->magic); |
| 4631 | return; |
| 4632 | } |
| 4633 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 4634 | /* context is valid so caller is still waiting */ |
| 4635 | |
| 4636 | /* paranoia: invalidate the magic */ |
| 4637 | pStatsContext->magic = 0; |
| 4638 | |
| 4639 | /* copy over the tsm stats */ |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4640 | pAdapter->tsmStats.UplinkPktQueueDly = tsmMetrics.UplinkPktQueueDly; |
| 4641 | vos_mem_copy(pAdapter->tsmStats.UplinkPktQueueDlyHist, |
| 4642 | tsmMetrics.UplinkPktQueueDlyHist, |
| 4643 | sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist)/ |
| 4644 | sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist[0])); |
| 4645 | pAdapter->tsmStats.UplinkPktTxDly = tsmMetrics.UplinkPktTxDly; |
| 4646 | pAdapter->tsmStats.UplinkPktLoss = tsmMetrics.UplinkPktLoss; |
| 4647 | pAdapter->tsmStats.UplinkPktCount = tsmMetrics.UplinkPktCount; |
| 4648 | pAdapter->tsmStats.RoamingCount = tsmMetrics.RoamingCount; |
| 4649 | pAdapter->tsmStats.RoamingDly = tsmMetrics.RoamingDly; |
| 4650 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 4651 | /* notify the caller */ |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4652 | complete(&pStatsContext->completion); |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 4653 | |
| 4654 | /* serialization is complete */ |
| 4655 | spin_unlock(&hdd_context_lock); |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4656 | } |
| 4657 | |
| 4658 | |
| 4659 | |
| 4660 | static VOS_STATUS hdd_get_tsm_stats(hdd_adapter_t *pAdapter, const tANI_U8 tid, |
| 4661 | tAniTrafStrmMetrics* pTsmMetrics) |
| 4662 | { |
| 4663 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 4664 | eHalStatus hstatus; |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 4665 | VOS_STATUS vstatus = VOS_STATUS_SUCCESS; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4666 | long lrc; |
| 4667 | struct statsContext context; |
| 4668 | hdd_context_t *pHddCtx = NULL; |
| 4669 | |
| 4670 | if (NULL == pAdapter) |
| 4671 | { |
| 4672 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: pAdapter is NULL", __func__); |
| 4673 | return VOS_STATUS_E_FAULT; |
| 4674 | } |
| 4675 | |
| 4676 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 4677 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 4678 | |
| 4679 | /* we are connected prepare our callback context */ |
| 4680 | init_completion(&context.completion); |
| 4681 | context.pAdapter = pAdapter; |
| 4682 | context.magic = STATS_CONTEXT_MAGIC; |
| 4683 | |
| 4684 | /* query tsm stats */ |
| 4685 | hstatus = sme_GetTsmStats(pHddCtx->hHal, hdd_GetTsmStatsCB, |
| 4686 | pHddStaCtx->conn_info.staId[ 0 ], |
| 4687 | pHddStaCtx->conn_info.bssId, |
| 4688 | &context, pHddCtx->pvosContext, tid); |
| 4689 | |
| 4690 | if (eHAL_STATUS_SUCCESS != hstatus) |
| 4691 | { |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 4692 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unable to retrieve statistics", |
| 4693 | __func__); |
| 4694 | vstatus = VOS_STATUS_E_FAULT; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4695 | } |
| 4696 | else |
| 4697 | { |
| 4698 | /* request was sent -- wait for the response */ |
| 4699 | lrc = wait_for_completion_interruptible_timeout(&context.completion, |
| 4700 | msecs_to_jiffies(WLAN_WAIT_TIME_STATS)); |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4701 | if (lrc <= 0) |
| 4702 | { |
| 4703 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4704 | "%s: SME %s while retrieving statistics", |
| 4705 | __func__, (0 == lrc) ? "timeout" : "interrupt"); |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 4706 | vstatus = VOS_STATUS_E_TIMEOUT; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4707 | } |
| 4708 | } |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4709 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 4710 | /* either we never sent a request, we sent a request and received a |
| 4711 | response or we sent a request and timed out. if we never sent a |
| 4712 | request or if we sent a request and got a response, we want to |
| 4713 | clear the magic out of paranoia. if we timed out there is a |
| 4714 | race condition such that the callback function could be |
| 4715 | executing at the same time we are. of primary concern is if the |
| 4716 | callback function had already verified the "magic" but had not |
| 4717 | yet set the completion variable when a timeout occurred. we |
| 4718 | serialize these activities by invalidating the magic while |
| 4719 | holding a shared spinlock which will cause us to block if the |
| 4720 | callback is currently executing */ |
| 4721 | spin_lock(&hdd_context_lock); |
| 4722 | context.magic = 0; |
| 4723 | spin_unlock(&hdd_context_lock); |
| 4724 | |
| 4725 | if (VOS_STATUS_SUCCESS == vstatus) |
| 4726 | { |
| 4727 | pTsmMetrics->UplinkPktQueueDly = pAdapter->tsmStats.UplinkPktQueueDly; |
| 4728 | vos_mem_copy(pTsmMetrics->UplinkPktQueueDlyHist, |
| 4729 | pAdapter->tsmStats.UplinkPktQueueDlyHist, |
| 4730 | sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist)/ |
| 4731 | sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist[0])); |
| 4732 | pTsmMetrics->UplinkPktTxDly = pAdapter->tsmStats.UplinkPktTxDly; |
| 4733 | pTsmMetrics->UplinkPktLoss = pAdapter->tsmStats.UplinkPktLoss; |
| 4734 | pTsmMetrics->UplinkPktCount = pAdapter->tsmStats.UplinkPktCount; |
| 4735 | pTsmMetrics->RoamingCount = pAdapter->tsmStats.RoamingCount; |
| 4736 | pTsmMetrics->RoamingDly = pAdapter->tsmStats.RoamingDly; |
| 4737 | } |
| 4738 | return vstatus; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4739 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4740 | #endif /*FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */ |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4741 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4742 | #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] | 4743 | void hdd_getBand_helper(hdd_context_t *pHddCtx, int *pBand) |
| 4744 | { |
| 4745 | eCsrBand band = -1; |
| 4746 | sme_GetFreqBand((tHalHandle)(pHddCtx->hHal), &band); |
| 4747 | switch (band) |
| 4748 | { |
| 4749 | case eCSR_BAND_ALL: |
| 4750 | *pBand = WLAN_HDD_UI_BAND_AUTO; |
| 4751 | break; |
| 4752 | |
| 4753 | case eCSR_BAND_24: |
| 4754 | *pBand = WLAN_HDD_UI_BAND_2_4_GHZ; |
| 4755 | break; |
| 4756 | |
| 4757 | case eCSR_BAND_5G: |
| 4758 | *pBand = WLAN_HDD_UI_BAND_5_GHZ; |
| 4759 | break; |
| 4760 | |
| 4761 | default: |
| 4762 | hddLog( VOS_TRACE_LEVEL_WARN, "%s: Invalid Band %d", __func__, band); |
| 4763 | *pBand = -1; |
| 4764 | break; |
| 4765 | } |
| 4766 | } |
| 4767 | |
| 4768 | /**--------------------------------------------------------------------------- |
| 4769 | |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4770 | \brief hdd_parse_send_action_frame_data() - HDD Parse send action frame data |
| 4771 | |
| 4772 | This function parses the send action frame data passed in the format |
| 4773 | SENDACTIONFRAME<space><bssid><space><channel><space><dwelltime><space><data> |
| 4774 | |
Srinivas Girigowda | 5607685 | 2013-08-20 14:00:50 -0700 | [diff] [blame] | 4775 | \param - pValue Pointer to input data |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4776 | \param - pTargetApBssid Pointer to target Ap bssid |
| 4777 | \param - pChannel Pointer to the Target AP channel |
| 4778 | \param - pDwellTime Pointer to the time to stay off-channel after transmitting action frame |
| 4779 | \param - pBuf Pointer to data |
| 4780 | \param - pBufLen Pointer to data length |
| 4781 | |
| 4782 | \return - 0 for success non-zero for failure |
| 4783 | |
| 4784 | --------------------------------------------------------------------------*/ |
| 4785 | VOS_STATUS hdd_parse_send_action_frame_data(tANI_U8 *pValue, tANI_U8 *pTargetApBssid, tANI_U8 *pChannel, |
| 4786 | tANI_U8 *pDwellTime, tANI_U8 **pBuf, tANI_U8 *pBufLen) |
| 4787 | { |
| 4788 | tANI_U8 *inPtr = pValue; |
| 4789 | tANI_U8 *dataEnd; |
| 4790 | int tempInt; |
| 4791 | int j = 0; |
| 4792 | int i = 0; |
| 4793 | int v = 0; |
| 4794 | tANI_U8 tempBuf[32]; |
| 4795 | tANI_U8 tempByte = 0; |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 4796 | /* 12 hexa decimal digits, 5 ':' and '\0' */ |
| 4797 | tANI_U8 macAddress[18]; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4798 | |
| 4799 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 4800 | /*no argument after the command*/ |
| 4801 | if (NULL == inPtr) |
| 4802 | { |
| 4803 | return -EINVAL; |
| 4804 | } |
| 4805 | |
| 4806 | /*no space after the command*/ |
| 4807 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 4808 | { |
| 4809 | return -EINVAL; |
| 4810 | } |
| 4811 | |
| 4812 | /*removing empty spaces*/ |
| 4813 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 4814 | |
| 4815 | /*no argument followed by spaces*/ |
| 4816 | if ('\0' == *inPtr) |
| 4817 | { |
| 4818 | return -EINVAL; |
| 4819 | } |
| 4820 | |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4821 | v = sscanf(inPtr, "%17s", macAddress); |
| 4822 | if (!((1 == v) && hdd_is_valid_mac_address(macAddress))) |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4823 | { |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4824 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4825 | "Invalid MAC address or All hex inputs are not read (%d)", v); |
| 4826 | return -EINVAL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4827 | } |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4828 | |
| 4829 | pTargetApBssid[0] = hdd_parse_hex(macAddress[0]) << 4 | hdd_parse_hex(macAddress[1]); |
| 4830 | pTargetApBssid[1] = hdd_parse_hex(macAddress[3]) << 4 | hdd_parse_hex(macAddress[4]); |
| 4831 | pTargetApBssid[2] = hdd_parse_hex(macAddress[6]) << 4 | hdd_parse_hex(macAddress[7]); |
| 4832 | pTargetApBssid[3] = hdd_parse_hex(macAddress[9]) << 4 | hdd_parse_hex(macAddress[10]); |
| 4833 | pTargetApBssid[4] = hdd_parse_hex(macAddress[12]) << 4 | hdd_parse_hex(macAddress[13]); |
| 4834 | 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] | 4835 | |
| 4836 | /* point to the next argument */ |
| 4837 | inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE); |
| 4838 | /*no argument after the command*/ |
| 4839 | if (NULL == inPtr) return -EINVAL; |
| 4840 | |
| 4841 | /*removing empty spaces*/ |
| 4842 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 4843 | |
| 4844 | /*no argument followed by spaces*/ |
| 4845 | if ('\0' == *inPtr) |
| 4846 | { |
| 4847 | return -EINVAL; |
| 4848 | } |
| 4849 | |
| 4850 | /*getting the next argument ie the channel number */ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 4851 | v = sscanf(inPtr, "%31s ", tempBuf); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4852 | if (1 != v) return -EINVAL; |
| 4853 | |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4854 | v = kstrtos32(tempBuf, 10, &tempInt); |
Agarwal Ashish | 353b3a8 | 2014-04-08 14:55:11 +0530 | [diff] [blame] | 4855 | if ( v < 0 || tempInt <= 0 || tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX ) |
Kiet Lam | be150c2 | 2013-11-21 16:30:32 +0530 | [diff] [blame] | 4856 | return -EINVAL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4857 | |
| 4858 | *pChannel = tempInt; |
| 4859 | |
| 4860 | /* point to the next argument */ |
| 4861 | inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE); |
| 4862 | /*no argument after the command*/ |
| 4863 | if (NULL == inPtr) return -EINVAL; |
| 4864 | /*removing empty spaces*/ |
| 4865 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 4866 | |
| 4867 | /*no argument followed by spaces*/ |
| 4868 | if ('\0' == *inPtr) |
| 4869 | { |
| 4870 | return -EINVAL; |
| 4871 | } |
| 4872 | |
| 4873 | /*getting the next argument ie the dwell time */ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 4874 | v = sscanf(inPtr, "%31s ", tempBuf); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4875 | if (1 != v) return -EINVAL; |
| 4876 | |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4877 | v = kstrtos32(tempBuf, 10, &tempInt); |
Srinivas Girigowda | 5a6e067 | 2014-01-09 14:42:57 -0800 | [diff] [blame] | 4878 | if ( v < 0 || tempInt < 0) return -EINVAL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4879 | |
| 4880 | *pDwellTime = tempInt; |
| 4881 | |
| 4882 | /* point to the next argument */ |
| 4883 | inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE); |
| 4884 | /*no argument after the command*/ |
| 4885 | if (NULL == inPtr) return -EINVAL; |
| 4886 | /*removing empty spaces*/ |
| 4887 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 4888 | |
| 4889 | /*no argument followed by spaces*/ |
| 4890 | if ('\0' == *inPtr) |
| 4891 | { |
| 4892 | return -EINVAL; |
| 4893 | } |
| 4894 | |
| 4895 | /* find the length of data */ |
| 4896 | dataEnd = inPtr; |
| 4897 | while(('\0' != *dataEnd) ) |
| 4898 | { |
| 4899 | dataEnd++; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4900 | } |
Kiet Lam | be150c2 | 2013-11-21 16:30:32 +0530 | [diff] [blame] | 4901 | *pBufLen = dataEnd - inPtr ; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4902 | if ( *pBufLen <= 0) return -EINVAL; |
| 4903 | |
Srinivas Girigowda | b5ae85d | 2013-06-03 10:51:45 -0700 | [diff] [blame] | 4904 | /* Allocate the number of bytes based on the number of input characters |
| 4905 | whether it is even or odd. |
| 4906 | if the number of input characters are even, then we need N/2 byte. |
| 4907 | if the number of input characters are odd, then we need do (N+1)/2 to |
| 4908 | compensate rounding off. |
| 4909 | For example, if N = 18, then (18 + 1)/2 = 9 bytes are enough. |
| 4910 | If N = 19, then we need 10 bytes, hence (19 + 1)/2 = 10 bytes */ |
| 4911 | *pBuf = vos_mem_malloc((*pBufLen + 1)/2); |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4912 | if (NULL == *pBuf) |
| 4913 | { |
| 4914 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 4915 | "%s: vos_mem_alloc failed ", __func__); |
| 4916 | return -EINVAL; |
| 4917 | } |
| 4918 | |
| 4919 | /* the buffer received from the upper layer is character buffer, |
| 4920 | we need to prepare the buffer taking 2 characters in to a U8 hex decimal number |
| 4921 | for example 7f0000f0...form a buffer to contain 7f in 0th location, 00 in 1st |
| 4922 | and f0 in 3rd location */ |
| 4923 | for (i = 0, j = 0; j < *pBufLen; j += 2) |
| 4924 | { |
Kiet Lam | be150c2 | 2013-11-21 16:30:32 +0530 | [diff] [blame] | 4925 | if( j+1 == *pBufLen) |
| 4926 | { |
| 4927 | tempByte = hdd_parse_hex(inPtr[j]); |
| 4928 | } |
| 4929 | else |
| 4930 | { |
| 4931 | tempByte = (hdd_parse_hex(inPtr[j]) << 4) | (hdd_parse_hex(inPtr[j + 1])); |
| 4932 | } |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4933 | (*pBuf)[i++] = tempByte; |
| 4934 | } |
| 4935 | *pBufLen = i; |
| 4936 | return VOS_STATUS_SUCCESS; |
| 4937 | } |
| 4938 | |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4939 | /**--------------------------------------------------------------------------- |
| 4940 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4941 | \brief hdd_parse_channellist() - HDD Parse channel list |
| 4942 | |
| 4943 | This function parses the channel list passed in the format |
| 4944 | 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] | 4945 | if the Number of channels (N) does not match with the actual number of channels passed |
| 4946 | then take the minimum of N and count of (Ch1, Ch2, ...Ch M) |
| 4947 | For example, if SETROAMSCANCHANNELS 3 36 40 44 48, only 36, 40 and 44 shall be taken. |
| 4948 | If SETROAMSCANCHANNELS 5 36 40 44 48, ignore 5 and take 36, 40, 44 and 48. |
| 4949 | 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] | 4950 | |
| 4951 | \param - pValue Pointer to input channel list |
| 4952 | \param - ChannelList Pointer to local output array to record channel list |
| 4953 | \param - pNumChannels Pointer to number of roam scan channels |
| 4954 | |
| 4955 | \return - 0 for success non-zero for failure |
| 4956 | |
| 4957 | --------------------------------------------------------------------------*/ |
| 4958 | VOS_STATUS hdd_parse_channellist(tANI_U8 *pValue, tANI_U8 *pChannelList, tANI_U8 *pNumChannels) |
| 4959 | { |
| 4960 | tANI_U8 *inPtr = pValue; |
| 4961 | int tempInt; |
| 4962 | int j = 0; |
| 4963 | int v = 0; |
| 4964 | char buf[32]; |
| 4965 | |
| 4966 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 4967 | /*no argument after the command*/ |
| 4968 | if (NULL == inPtr) |
| 4969 | { |
| 4970 | return -EINVAL; |
| 4971 | } |
| 4972 | |
| 4973 | /*no space after the command*/ |
| 4974 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 4975 | { |
| 4976 | return -EINVAL; |
| 4977 | } |
| 4978 | |
| 4979 | /*removing empty spaces*/ |
Jeff Johnson | a1f9afb | 2013-04-03 09:13:31 -0700 | [diff] [blame] | 4980 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4981 | |
| 4982 | /*no argument followed by spaces*/ |
| 4983 | if ('\0' == *inPtr) |
| 4984 | { |
| 4985 | return -EINVAL; |
| 4986 | } |
| 4987 | |
| 4988 | /*getting the first argument ie the number of channels*/ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 4989 | v = sscanf(inPtr, "%31s ", buf); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4990 | if (1 != v) return -EINVAL; |
| 4991 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4992 | v = kstrtos32(buf, 10, &tempInt); |
Jeff Johnson | a1f9afb | 2013-04-03 09:13:31 -0700 | [diff] [blame] | 4993 | if ((v < 0) || |
| 4994 | (tempInt <= 0) || |
| 4995 | (tempInt > WNI_CFG_VALID_CHANNEL_LIST_LEN)) |
| 4996 | { |
| 4997 | return -EINVAL; |
| 4998 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4999 | |
| 5000 | *pNumChannels = tempInt; |
| 5001 | |
| 5002 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
| 5003 | "Number of channels are: %d", *pNumChannels); |
| 5004 | |
| 5005 | for (j = 0; j < (*pNumChannels); j++) |
| 5006 | { |
| 5007 | /*inPtr pointing to the beginning of first space after number of channels*/ |
| 5008 | inPtr = strpbrk( inPtr, " " ); |
| 5009 | /*no channel list after the number of channels argument*/ |
| 5010 | if (NULL == inPtr) |
| 5011 | { |
Srinivas Girigowda | cf9a9b4 | 2013-03-21 11:55:24 -0700 | [diff] [blame] | 5012 | if (0 != j) |
| 5013 | { |
| 5014 | *pNumChannels = j; |
| 5015 | return VOS_STATUS_SUCCESS; |
| 5016 | } |
| 5017 | else |
| 5018 | { |
| 5019 | return -EINVAL; |
| 5020 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 5021 | } |
| 5022 | |
| 5023 | /*removing empty space*/ |
Jeff Johnson | a1f9afb | 2013-04-03 09:13:31 -0700 | [diff] [blame] | 5024 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 5025 | |
| 5026 | /*no channel list after the number of channels argument and spaces*/ |
| 5027 | if ( '\0' == *inPtr ) |
| 5028 | { |
Srinivas Girigowda | cf9a9b4 | 2013-03-21 11:55:24 -0700 | [diff] [blame] | 5029 | if (0 != j) |
| 5030 | { |
| 5031 | *pNumChannels = j; |
| 5032 | return VOS_STATUS_SUCCESS; |
| 5033 | } |
| 5034 | else |
| 5035 | { |
| 5036 | return -EINVAL; |
| 5037 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 5038 | } |
| 5039 | |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 5040 | v = sscanf(inPtr, "%31s ", buf); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 5041 | if (1 != v) return -EINVAL; |
| 5042 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 5043 | v = kstrtos32(buf, 10, &tempInt); |
Jeff Johnson | a1f9afb | 2013-04-03 09:13:31 -0700 | [diff] [blame] | 5044 | if ((v < 0) || |
| 5045 | (tempInt <= 0) || |
| 5046 | (tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX)) |
| 5047 | { |
| 5048 | return -EINVAL; |
| 5049 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 5050 | pChannelList[j] = tempInt; |
| 5051 | |
| 5052 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
| 5053 | "Channel %d added to preferred channel list", |
| 5054 | pChannelList[j] ); |
| 5055 | } |
| 5056 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 5057 | return VOS_STATUS_SUCCESS; |
| 5058 | } |
| 5059 | |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 5060 | |
| 5061 | /**--------------------------------------------------------------------------- |
| 5062 | |
| 5063 | \brief hdd_parse_reassoc_command_data() - HDD Parse reassoc command data |
| 5064 | |
| 5065 | This function parses the reasoc command data passed in the format |
| 5066 | REASSOC<space><bssid><space><channel> |
| 5067 | |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 5068 | \param - pValue Pointer to input data (its a NUL terminated string) |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 5069 | \param - pTargetApBssid Pointer to target Ap bssid |
| 5070 | \param - pChannel Pointer to the Target AP channel |
| 5071 | |
| 5072 | \return - 0 for success non-zero for failure |
| 5073 | |
| 5074 | --------------------------------------------------------------------------*/ |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 5075 | VOS_STATUS hdd_parse_reassoc_command_data(tANI_U8 *pValue, |
| 5076 | tANI_U8 *pTargetApBssid, tANI_U8 *pChannel) |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 5077 | { |
| 5078 | tANI_U8 *inPtr = pValue; |
| 5079 | int tempInt; |
| 5080 | int v = 0; |
| 5081 | tANI_U8 tempBuf[32]; |
Kiet Lam | aa8e15a | 2014-02-11 23:30:06 -0800 | [diff] [blame] | 5082 | /* 12 hexa decimal digits, 5 ':' and '\0' */ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 5083 | tANI_U8 macAddress[18]; |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 5084 | |
| 5085 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 5086 | /*no argument after the command*/ |
| 5087 | if (NULL == inPtr) |
| 5088 | { |
| 5089 | return -EINVAL; |
| 5090 | } |
| 5091 | |
| 5092 | /*no space after the command*/ |
| 5093 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 5094 | { |
| 5095 | return -EINVAL; |
| 5096 | } |
| 5097 | |
| 5098 | /*removing empty spaces*/ |
| 5099 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 5100 | |
| 5101 | /*no argument followed by spaces*/ |
| 5102 | if ('\0' == *inPtr) |
| 5103 | { |
| 5104 | return -EINVAL; |
| 5105 | } |
| 5106 | |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 5107 | v = sscanf(inPtr, "%17s", macAddress); |
| 5108 | if (!((1 == v) && hdd_is_valid_mac_address(macAddress))) |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 5109 | { |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 5110 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5111 | "Invalid MAC address or All hex inputs are not read (%d)", v); |
| 5112 | return -EINVAL; |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 5113 | } |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 5114 | |
| 5115 | pTargetApBssid[0] = hdd_parse_hex(macAddress[0]) << 4 | hdd_parse_hex(macAddress[1]); |
| 5116 | pTargetApBssid[1] = hdd_parse_hex(macAddress[3]) << 4 | hdd_parse_hex(macAddress[4]); |
| 5117 | pTargetApBssid[2] = hdd_parse_hex(macAddress[6]) << 4 | hdd_parse_hex(macAddress[7]); |
| 5118 | pTargetApBssid[3] = hdd_parse_hex(macAddress[9]) << 4 | hdd_parse_hex(macAddress[10]); |
| 5119 | pTargetApBssid[4] = hdd_parse_hex(macAddress[12]) << 4 | hdd_parse_hex(macAddress[13]); |
| 5120 | 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] | 5121 | |
| 5122 | /* point to the next argument */ |
| 5123 | inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE); |
| 5124 | /*no argument after the command*/ |
| 5125 | if (NULL == inPtr) return -EINVAL; |
| 5126 | |
| 5127 | /*removing empty spaces*/ |
| 5128 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 5129 | |
| 5130 | /*no argument followed by spaces*/ |
| 5131 | if ('\0' == *inPtr) |
| 5132 | { |
| 5133 | return -EINVAL; |
| 5134 | } |
| 5135 | |
| 5136 | /*getting the next argument ie the channel number */ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 5137 | v = sscanf(inPtr, "%31s ", tempBuf); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 5138 | if (1 != v) return -EINVAL; |
| 5139 | |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 5140 | v = kstrtos32(tempBuf, 10, &tempInt); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 5141 | if ((v < 0) || |
Padma, Santhosh Kumar | 0fa809b | 2014-11-13 14:56:56 +0530 | [diff] [blame] | 5142 | (tempInt < 0) || |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 5143 | (tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX)) |
| 5144 | { |
| 5145 | return -EINVAL; |
| 5146 | } |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 5147 | |
| 5148 | *pChannel = tempInt; |
| 5149 | return VOS_STATUS_SUCCESS; |
| 5150 | } |
| 5151 | |
| 5152 | #endif |
| 5153 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 5154 | #if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD) |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 5155 | /**--------------------------------------------------------------------------- |
| 5156 | |
| 5157 | \brief hdd_parse_get_cckm_ie() - HDD Parse and fetch the CCKM IE |
| 5158 | |
| 5159 | This function parses the SETCCKM IE command |
| 5160 | SETCCKMIE<space><ie data> |
| 5161 | |
| 5162 | \param - pValue Pointer to input data |
| 5163 | \param - pCckmIe Pointer to output cckm Ie |
| 5164 | \param - pCckmIeLen Pointer to output cckm ie length |
| 5165 | |
| 5166 | \return - 0 for success non-zero for failure |
| 5167 | |
| 5168 | --------------------------------------------------------------------------*/ |
| 5169 | VOS_STATUS hdd_parse_get_cckm_ie(tANI_U8 *pValue, tANI_U8 **pCckmIe, |
| 5170 | tANI_U8 *pCckmIeLen) |
| 5171 | { |
| 5172 | tANI_U8 *inPtr = pValue; |
| 5173 | tANI_U8 *dataEnd; |
| 5174 | int j = 0; |
| 5175 | int i = 0; |
| 5176 | tANI_U8 tempByte = 0; |
| 5177 | |
| 5178 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 5179 | /*no argument after the command*/ |
| 5180 | if (NULL == inPtr) |
| 5181 | { |
| 5182 | return -EINVAL; |
| 5183 | } |
| 5184 | |
| 5185 | /*no space after the command*/ |
| 5186 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 5187 | { |
| 5188 | return -EINVAL; |
| 5189 | } |
| 5190 | |
| 5191 | /*removing empty spaces*/ |
| 5192 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 5193 | |
| 5194 | /*no argument followed by spaces*/ |
| 5195 | if ('\0' == *inPtr) |
| 5196 | { |
| 5197 | return -EINVAL; |
| 5198 | } |
| 5199 | |
| 5200 | /* find the length of data */ |
| 5201 | dataEnd = inPtr; |
| 5202 | while(('\0' != *dataEnd) ) |
| 5203 | { |
| 5204 | dataEnd++; |
| 5205 | ++(*pCckmIeLen); |
| 5206 | } |
| 5207 | if ( *pCckmIeLen <= 0) return -EINVAL; |
| 5208 | |
| 5209 | /* Allocate the number of bytes based on the number of input characters |
| 5210 | whether it is even or odd. |
| 5211 | if the number of input characters are even, then we need N/2 byte. |
| 5212 | if the number of input characters are odd, then we need do (N+1)/2 to |
| 5213 | compensate rounding off. |
| 5214 | For example, if N = 18, then (18 + 1)/2 = 9 bytes are enough. |
| 5215 | If N = 19, then we need 10 bytes, hence (19 + 1)/2 = 10 bytes */ |
| 5216 | *pCckmIe = vos_mem_malloc((*pCckmIeLen + 1)/2); |
| 5217 | if (NULL == *pCckmIe) |
| 5218 | { |
| 5219 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 5220 | "%s: vos_mem_alloc failed ", __func__); |
| 5221 | return -EINVAL; |
| 5222 | } |
| 5223 | vos_mem_zero(*pCckmIe, (*pCckmIeLen + 1)/2); |
| 5224 | /* the buffer received from the upper layer is character buffer, |
| 5225 | we need to prepare the buffer taking 2 characters in to a U8 hex decimal number |
| 5226 | for example 7f0000f0...form a buffer to contain 7f in 0th location, 00 in 1st |
| 5227 | and f0 in 3rd location */ |
| 5228 | for (i = 0, j = 0; j < *pCckmIeLen; j += 2) |
| 5229 | { |
| 5230 | tempByte = (hdd_parse_hex(inPtr[j]) << 4) | (hdd_parse_hex(inPtr[j + 1])); |
| 5231 | (*pCckmIe)[i++] = tempByte; |
| 5232 | } |
| 5233 | *pCckmIeLen = i; |
| 5234 | |
| 5235 | return VOS_STATUS_SUCCESS; |
| 5236 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 5237 | #endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */ |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 5238 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5239 | /**--------------------------------------------------------------------------- |
| 5240 | |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 5241 | \brief hdd_is_valid_mac_address() - Validate MAC address |
| 5242 | |
| 5243 | This function validates whether the given MAC address is valid or not |
| 5244 | Expected MAC address is of the format XX:XX:XX:XX:XX:XX |
| 5245 | where X is the hexa decimal digit character and separated by ':' |
| 5246 | This algorithm works even if MAC address is not separated by ':' |
| 5247 | |
| 5248 | This code checks given input string mac contains exactly 12 hexadecimal digits. |
| 5249 | and a separator colon : appears in the input string only after |
| 5250 | an even number of hex digits. |
| 5251 | |
| 5252 | \param - pMacAddr pointer to the input MAC address |
| 5253 | \return - 1 for valid and 0 for invalid |
| 5254 | |
| 5255 | --------------------------------------------------------------------------*/ |
| 5256 | |
| 5257 | v_BOOL_t hdd_is_valid_mac_address(const tANI_U8 *pMacAddr) |
| 5258 | { |
| 5259 | int xdigit = 0; |
| 5260 | int separator = 0; |
| 5261 | while (*pMacAddr) |
| 5262 | { |
| 5263 | if (isxdigit(*pMacAddr)) |
| 5264 | { |
| 5265 | xdigit++; |
| 5266 | } |
| 5267 | else if (':' == *pMacAddr) |
| 5268 | { |
| 5269 | if (0 == xdigit || ((xdigit / 2) - 1) != separator) |
| 5270 | break; |
| 5271 | |
| 5272 | ++separator; |
| 5273 | } |
| 5274 | else |
| 5275 | { |
| 5276 | separator = -1; |
| 5277 | /* Invalid MAC found */ |
| 5278 | return 0; |
| 5279 | } |
| 5280 | ++pMacAddr; |
| 5281 | } |
| 5282 | return (xdigit == 12 && (separator == 5 || separator == 0)); |
| 5283 | } |
| 5284 | |
| 5285 | /**--------------------------------------------------------------------------- |
| 5286 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 5287 | \brief __hdd_open() - HDD Open function |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5288 | |
| 5289 | \param - dev Pointer to net_device structure |
| 5290 | |
| 5291 | \return - 0 for success non-zero for failure |
| 5292 | |
| 5293 | --------------------------------------------------------------------------*/ |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 5294 | int __hdd_open(struct net_device *dev) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5295 | { |
| 5296 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5297 | hdd_context_t *pHddCtx; |
| 5298 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 5299 | VOS_STATUS status; |
| 5300 | v_BOOL_t in_standby = TRUE; |
| 5301 | |
| 5302 | if (NULL == pAdapter) |
| 5303 | { |
| 5304 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Agarwal Ashish | 971c288 | 2013-10-30 20:11:12 +0530 | [diff] [blame] | 5305 | "%s: pAdapter is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5306 | return -ENODEV; |
| 5307 | } |
| 5308 | |
| 5309 | pHddCtx = (hdd_context_t*)pAdapter->pHddCtx; |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 5310 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_OPEN_REQUEST, |
| 5311 | pAdapter->sessionId, pAdapter->device_mode)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5312 | if (NULL == pHddCtx) |
| 5313 | { |
| 5314 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 5315 | "%s: HDD context is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5316 | return -ENODEV; |
| 5317 | } |
| 5318 | |
| 5319 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 5320 | while ( (NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status) ) |
| 5321 | { |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 5322 | if (test_bit(DEVICE_IFACE_OPENED, &pAdapterNode->pAdapter->event_flags)) |
| 5323 | { |
| 5324 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: chip already out of standby", |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 5325 | __func__); |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 5326 | in_standby = FALSE; |
| 5327 | break; |
| 5328 | } |
| 5329 | else |
| 5330 | { |
| 5331 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 5332 | pAdapterNode = pNext; |
| 5333 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5334 | } |
| 5335 | |
| 5336 | if (TRUE == in_standby) |
| 5337 | { |
| 5338 | if (VOS_STATUS_SUCCESS != wlan_hdd_exit_lowpower(pHddCtx, pAdapter)) |
| 5339 | { |
| 5340 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failed to bring " |
| 5341 | "wlan out of power save", __func__); |
| 5342 | return -EINVAL; |
| 5343 | } |
| 5344 | } |
| 5345 | |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 5346 | set_bit(DEVICE_IFACE_OPENED, &pAdapter->event_flags); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5347 | if (hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) |
| 5348 | { |
| 5349 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 5350 | "%s: Enabling Tx Queues", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5351 | /* Enable TX queues only when we are connected */ |
Padma, Santhosh Kumar | 9dacb5c | 2014-12-17 19:22:56 +0530 | [diff] [blame] | 5352 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5353 | netif_tx_start_all_queues(dev); |
| 5354 | } |
| 5355 | |
| 5356 | return 0; |
| 5357 | } |
| 5358 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 5359 | /**--------------------------------------------------------------------------- |
| 5360 | |
| 5361 | \brief hdd_open() - Wrapper function for __hdd_open to protect it from SSR |
| 5362 | |
| 5363 | This is called in response to ifconfig up |
| 5364 | |
| 5365 | \param - dev Pointer to net_device structure |
| 5366 | |
| 5367 | \return - 0 for success non-zero for failure |
| 5368 | |
| 5369 | --------------------------------------------------------------------------*/ |
| 5370 | int hdd_open(struct net_device *dev) |
| 5371 | { |
| 5372 | int ret; |
| 5373 | |
| 5374 | vos_ssr_protect(__func__); |
| 5375 | ret = __hdd_open(dev); |
| 5376 | vos_ssr_unprotect(__func__); |
| 5377 | |
| 5378 | return ret; |
| 5379 | } |
| 5380 | |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 5381 | int __hdd_mon_open (struct net_device *dev) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5382 | { |
| 5383 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5384 | |
| 5385 | if(pAdapter == NULL) { |
| 5386 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 5387 | "%s: HDD adapter context is Null", __func__); |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 5388 | return -EINVAL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5389 | } |
| 5390 | |
| 5391 | netif_start_queue(dev); |
| 5392 | |
| 5393 | return 0; |
| 5394 | } |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 5395 | |
| 5396 | int hdd_mon_open (struct net_device *dev) |
| 5397 | { |
| 5398 | int ret; |
| 5399 | |
| 5400 | vos_ssr_protect(__func__); |
| 5401 | ret = __hdd_mon_open(dev); |
| 5402 | vos_ssr_unprotect(__func__); |
| 5403 | |
| 5404 | return ret; |
| 5405 | } |
| 5406 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5407 | /**--------------------------------------------------------------------------- |
| 5408 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 5409 | \brief __hdd_stop() - HDD stop function |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5410 | |
| 5411 | \param - dev Pointer to net_device structure |
| 5412 | |
| 5413 | \return - 0 for success non-zero for failure |
| 5414 | |
| 5415 | --------------------------------------------------------------------------*/ |
| 5416 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 5417 | int __hdd_stop (struct net_device *dev) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5418 | { |
Vinay Krishna Eranna | 90f4353 | 2014-10-27 16:45:54 +0530 | [diff] [blame] | 5419 | int ret = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5420 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5421 | hdd_context_t *pHddCtx; |
| 5422 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 5423 | VOS_STATUS status; |
| 5424 | v_BOOL_t enter_standby = TRUE; |
| 5425 | |
| 5426 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5427 | if (NULL == pAdapter) |
| 5428 | { |
| 5429 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Agarwal Ashish | 971c288 | 2013-10-30 20:11:12 +0530 | [diff] [blame] | 5430 | "%s: pAdapter is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5431 | return -ENODEV; |
| 5432 | } |
Sachin Ahuja | 9b4958f | 2015-01-15 21:37:00 +0530 | [diff] [blame] | 5433 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_STOP_REQUEST, |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 5434 | pAdapter->sessionId, pAdapter->device_mode)); |
Vinay Krishna Eranna | 90f4353 | 2014-10-27 16:45:54 +0530 | [diff] [blame] | 5435 | |
| 5436 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 5437 | ret = wlan_hdd_validate_context(pHddCtx); |
| 5438 | if (ret) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5439 | { |
Vinay Krishna Eranna | 90f4353 | 2014-10-27 16:45:54 +0530 | [diff] [blame] | 5440 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5441 | "%s: HDD context is not valid!", __func__); |
| 5442 | return ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5443 | } |
| 5444 | |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 5445 | /* Nothing to be done if the interface is not opened */ |
| 5446 | if (VOS_FALSE == test_bit(DEVICE_IFACE_OPENED, &pAdapter->event_flags)) |
| 5447 | { |
| 5448 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5449 | "%s: NETDEV Interface is not OPENED", __func__); |
| 5450 | return -ENODEV; |
| 5451 | } |
| 5452 | |
| 5453 | /* Make sure the interface is marked as closed */ |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 5454 | clear_bit(DEVICE_IFACE_OPENED, &pAdapter->event_flags); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5455 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disabling OS Tx queues", __func__); |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 5456 | |
| 5457 | /* Disable TX on the interface, after this hard_start_xmit() will not |
| 5458 | * be called on that interface |
| 5459 | */ |
Padma, Santhosh Kumar | 9dacb5c | 2014-12-17 19:22:56 +0530 | [diff] [blame] | 5460 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5461 | netif_tx_disable(pAdapter->dev); |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 5462 | |
| 5463 | /* Mark the interface status as "down" for outside world */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5464 | netif_carrier_off(pAdapter->dev); |
| 5465 | |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 5466 | /* The interface is marked as down for outside world (aka kernel) |
| 5467 | * But the driver is pretty much alive inside. The driver needs to |
| 5468 | * tear down the existing connection on the netdev (session) |
| 5469 | * cleanup the data pipes and wait until the control plane is stabilized |
| 5470 | * for this interface. The call also needs to wait until the above |
| 5471 | * mentioned actions are completed before returning to the caller. |
| 5472 | * Notice that the hdd_stop_adapter is requested not to close the session |
| 5473 | * That is intentional to be able to scan if it is a STA/P2P interface |
| 5474 | */ |
| 5475 | hdd_stop_adapter(pHddCtx, pAdapter, VOS_FALSE); |
Mahesh A Saptasagar | 02e36e8 | 2015-01-14 20:39:19 +0530 | [diff] [blame] | 5476 | #ifdef FEATURE_WLAN_TDLS |
| 5477 | mutex_lock(&pHddCtx->tdls_lock); |
| 5478 | #endif |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 5479 | /* DeInit the adapter. This ensures datapath cleanup as well */ |
c_hpothu | 002231a | 2015-02-05 14:58:51 +0530 | [diff] [blame] | 5480 | hdd_deinit_adapter(pHddCtx, pAdapter, TRUE); |
Mahesh A Saptasagar | 02e36e8 | 2015-01-14 20:39:19 +0530 | [diff] [blame] | 5481 | #ifdef FEATURE_WLAN_TDLS |
| 5482 | mutex_unlock(&pHddCtx->tdls_lock); |
| 5483 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5484 | /* SoftAP ifaces should never go in power save mode |
| 5485 | making sure same here. */ |
| 5486 | if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode ) |
| 5487 | || (WLAN_HDD_MONITOR == pAdapter->device_mode ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5488 | || (WLAN_HDD_P2P_GO == pAdapter->device_mode ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5489 | ) |
| 5490 | { |
| 5491 | /* SoftAP mode, so return from here */ |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 5492 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5493 | "%s: In SAP MODE", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5494 | EXIT(); |
| 5495 | return 0; |
| 5496 | } |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 5497 | /* Find if any iface is up. If any iface is up then can't put device to |
| 5498 | * sleep/power save mode |
| 5499 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5500 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 5501 | while ( (NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status) ) |
| 5502 | { |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 5503 | if (test_bit(DEVICE_IFACE_OPENED, &pAdapterNode->pAdapter->event_flags)) |
| 5504 | { |
| 5505 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Still other ifaces are up cannot " |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 5506 | "put device to sleep", __func__); |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 5507 | enter_standby = FALSE; |
| 5508 | break; |
| 5509 | } |
| 5510 | else |
| 5511 | { |
| 5512 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 5513 | pAdapterNode = pNext; |
| 5514 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5515 | } |
| 5516 | |
| 5517 | if (TRUE == enter_standby) |
| 5518 | { |
| 5519 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: All Interfaces are Down " |
| 5520 | "entering standby", __func__); |
| 5521 | if (VOS_STATUS_SUCCESS != wlan_hdd_enter_lowpower(pHddCtx)) |
| 5522 | { |
| 5523 | /*log and return success*/ |
| 5524 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failed to put " |
| 5525 | "wlan in power save", __func__); |
| 5526 | } |
| 5527 | } |
| 5528 | |
| 5529 | EXIT(); |
| 5530 | return 0; |
| 5531 | } |
| 5532 | |
| 5533 | /**--------------------------------------------------------------------------- |
| 5534 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 5535 | \brief hdd_stop() - wrapper_function for __hdd_stop to protect it from SSR |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5536 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 5537 | This is called in response to ifconfig down |
| 5538 | |
| 5539 | \param - dev Pointer to net_device structure |
| 5540 | |
| 5541 | \return - 0 for success non-zero for failure |
| 5542 | -----------------------------------------------------------------------------*/ |
| 5543 | int hdd_stop (struct net_device *dev) |
| 5544 | { |
| 5545 | int ret; |
| 5546 | |
| 5547 | vos_ssr_protect(__func__); |
| 5548 | ret = __hdd_stop(dev); |
| 5549 | vos_ssr_unprotect(__func__); |
| 5550 | |
| 5551 | return ret; |
| 5552 | } |
| 5553 | |
| 5554 | /**--------------------------------------------------------------------------- |
| 5555 | |
| 5556 | \brief __hdd_uninit() - HDD uninit function |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5557 | |
| 5558 | \param - dev Pointer to net_device structure |
| 5559 | |
| 5560 | \return - void |
| 5561 | |
| 5562 | --------------------------------------------------------------------------*/ |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 5563 | static void __hdd_uninit (struct net_device *dev) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5564 | { |
| 5565 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Mahesh A Saptasagar | 02e36e8 | 2015-01-14 20:39:19 +0530 | [diff] [blame] | 5566 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5567 | ENTER(); |
| 5568 | |
| 5569 | do |
| 5570 | { |
| 5571 | if (NULL == pAdapter) |
| 5572 | { |
| 5573 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 5574 | "%s: NULL pAdapter", __func__); |
| 5575 | break; |
| 5576 | } |
| 5577 | |
| 5578 | if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) |
| 5579 | { |
| 5580 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 5581 | "%s: Invalid magic", __func__); |
| 5582 | break; |
| 5583 | } |
Mahesh A Saptasagar | 02e36e8 | 2015-01-14 20:39:19 +0530 | [diff] [blame] | 5584 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 5585 | if (NULL == pHddCtx) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5586 | { |
| 5587 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 5588 | "%s: NULL pHddCtx", __func__); |
| 5589 | break; |
| 5590 | } |
| 5591 | |
| 5592 | if (dev != pAdapter->dev) |
| 5593 | { |
| 5594 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 5595 | "%s: Invalid device reference", __func__); |
| 5596 | /* we haven't validated all cases so let this go for now */ |
| 5597 | } |
Mahesh A Saptasagar | 02e36e8 | 2015-01-14 20:39:19 +0530 | [diff] [blame] | 5598 | #ifdef FEATURE_WLAN_TDLS |
| 5599 | mutex_lock(&pHddCtx->tdls_lock); |
| 5600 | #endif |
c_hpothu | 002231a | 2015-02-05 14:58:51 +0530 | [diff] [blame] | 5601 | hdd_deinit_adapter(pHddCtx, pAdapter, TRUE); |
Mahesh A Saptasagar | 02e36e8 | 2015-01-14 20:39:19 +0530 | [diff] [blame] | 5602 | #ifdef FEATURE_WLAN_TDLS |
| 5603 | mutex_unlock(&pHddCtx->tdls_lock); |
| 5604 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5605 | |
| 5606 | /* after uninit our adapter structure will no longer be valid */ |
| 5607 | pAdapter->dev = NULL; |
| 5608 | pAdapter->magic = 0; |
| 5609 | } while (0); |
| 5610 | |
| 5611 | EXIT(); |
| 5612 | } |
| 5613 | |
| 5614 | /**--------------------------------------------------------------------------- |
| 5615 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 5616 | \brief hdd_uninit() - Wrapper function to protect __hdd_uninit from SSR |
| 5617 | |
| 5618 | This is called during the netdev unregister to uninitialize all data |
| 5619 | associated with the device |
| 5620 | |
| 5621 | \param - dev Pointer to net_device structure |
| 5622 | |
| 5623 | \return - void |
| 5624 | |
| 5625 | --------------------------------------------------------------------------*/ |
| 5626 | static void hdd_uninit (struct net_device *dev) |
| 5627 | { |
| 5628 | vos_ssr_protect(__func__); |
| 5629 | __hdd_uninit(dev); |
| 5630 | vos_ssr_unprotect(__func__); |
| 5631 | } |
| 5632 | |
| 5633 | /**--------------------------------------------------------------------------- |
| 5634 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5635 | \brief hdd_release_firmware() - |
| 5636 | |
| 5637 | This function calls the release firmware API to free the firmware buffer. |
| 5638 | |
| 5639 | \param - pFileName Pointer to the File Name. |
| 5640 | pCtx - Pointer to the adapter . |
| 5641 | |
| 5642 | |
| 5643 | \return - 0 for success, non zero for failure |
| 5644 | |
| 5645 | --------------------------------------------------------------------------*/ |
| 5646 | |
| 5647 | VOS_STATUS hdd_release_firmware(char *pFileName,v_VOID_t *pCtx) |
| 5648 | { |
| 5649 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 5650 | hdd_context_t *pHddCtx = (hdd_context_t*)pCtx; |
| 5651 | ENTER(); |
| 5652 | |
| 5653 | |
| 5654 | if (!strcmp(WLAN_FW_FILE, pFileName)) { |
| 5655 | |
| 5656 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"%s: Loaded firmware file is %s",__func__,pFileName); |
| 5657 | |
| 5658 | if(pHddCtx->fw) { |
| 5659 | release_firmware(pHddCtx->fw); |
| 5660 | pHddCtx->fw = NULL; |
| 5661 | } |
| 5662 | else |
| 5663 | status = VOS_STATUS_E_FAILURE; |
| 5664 | } |
| 5665 | else if (!strcmp(WLAN_NV_FILE,pFileName)) { |
| 5666 | if(pHddCtx->nv) { |
| 5667 | release_firmware(pHddCtx->nv); |
| 5668 | pHddCtx->nv = NULL; |
| 5669 | } |
| 5670 | else |
| 5671 | status = VOS_STATUS_E_FAILURE; |
| 5672 | |
| 5673 | } |
| 5674 | |
| 5675 | EXIT(); |
| 5676 | return status; |
| 5677 | } |
| 5678 | |
| 5679 | /**--------------------------------------------------------------------------- |
| 5680 | |
| 5681 | \brief hdd_request_firmware() - |
| 5682 | |
| 5683 | This function reads the firmware file using the request firmware |
| 5684 | API and returns the the firmware data and the firmware file size. |
| 5685 | |
| 5686 | \param - pfileName - Pointer to the file name. |
| 5687 | - pCtx - Pointer to the adapter . |
| 5688 | - ppfw_data - Pointer to the pointer of the firmware data. |
| 5689 | - pSize - Pointer to the file size. |
| 5690 | |
| 5691 | \return - VOS_STATUS_SUCCESS for success, VOS_STATUS_E_FAILURE for failure |
| 5692 | |
| 5693 | --------------------------------------------------------------------------*/ |
| 5694 | |
| 5695 | |
| 5696 | VOS_STATUS hdd_request_firmware(char *pfileName,v_VOID_t *pCtx,v_VOID_t **ppfw_data, v_SIZE_t *pSize) |
| 5697 | { |
| 5698 | int status; |
| 5699 | VOS_STATUS retval = VOS_STATUS_SUCCESS; |
| 5700 | hdd_context_t *pHddCtx = (hdd_context_t*)pCtx; |
| 5701 | ENTER(); |
| 5702 | |
| 5703 | if( (!strcmp(WLAN_FW_FILE, pfileName)) ) { |
| 5704 | |
| 5705 | status = request_firmware(&pHddCtx->fw, pfileName, pHddCtx->parent_dev); |
| 5706 | |
| 5707 | if(status || !pHddCtx->fw || !pHddCtx->fw->data) { |
| 5708 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Firmware %s download failed", |
| 5709 | __func__, pfileName); |
| 5710 | retval = VOS_STATUS_E_FAILURE; |
| 5711 | } |
| 5712 | |
| 5713 | else { |
| 5714 | *ppfw_data = (v_VOID_t *)pHddCtx->fw->data; |
| 5715 | *pSize = pHddCtx->fw->size; |
| 5716 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Firmware size = %d", |
| 5717 | __func__, *pSize); |
| 5718 | } |
| 5719 | } |
| 5720 | else if(!strcmp(WLAN_NV_FILE, pfileName)) { |
| 5721 | |
| 5722 | status = request_firmware(&pHddCtx->nv, pfileName, pHddCtx->parent_dev); |
| 5723 | |
| 5724 | if(status || !pHddCtx->nv || !pHddCtx->nv->data) { |
| 5725 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: nv %s download failed", |
| 5726 | __func__, pfileName); |
| 5727 | retval = VOS_STATUS_E_FAILURE; |
| 5728 | } |
| 5729 | |
| 5730 | else { |
| 5731 | *ppfw_data = (v_VOID_t *)pHddCtx->nv->data; |
| 5732 | *pSize = pHddCtx->nv->size; |
| 5733 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: nv file size = %d", |
| 5734 | __func__, *pSize); |
| 5735 | } |
| 5736 | } |
| 5737 | |
| 5738 | EXIT(); |
| 5739 | return retval; |
| 5740 | } |
| 5741 | /**--------------------------------------------------------------------------- |
| 5742 | \brief hdd_full_pwr_cbk() - HDD full power callbackfunction |
| 5743 | |
| 5744 | This is the function invoked by SME to inform the result of a full power |
| 5745 | request issued by HDD |
| 5746 | |
| 5747 | \param - callbackcontext - Pointer to cookie |
| 5748 | status - result of request |
| 5749 | |
| 5750 | \return - None |
| 5751 | |
| 5752 | --------------------------------------------------------------------------*/ |
| 5753 | void hdd_full_pwr_cbk(void *callbackContext, eHalStatus status) |
| 5754 | { |
| 5755 | hdd_context_t *pHddCtx = (hdd_context_t*)callbackContext; |
| 5756 | |
Madan Mohan Koyyalamudi | 8bdd311 | 2012-09-24 13:55:14 -0700 | [diff] [blame] | 5757 | 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] | 5758 | if(&pHddCtx->full_pwr_comp_var) |
| 5759 | { |
| 5760 | complete(&pHddCtx->full_pwr_comp_var); |
| 5761 | } |
| 5762 | } |
| 5763 | |
| 5764 | /**--------------------------------------------------------------------------- |
| 5765 | |
| 5766 | \brief hdd_req_bmps_cbk() - HDD Request BMPS callback function |
| 5767 | |
| 5768 | This is the function invoked by SME to inform the result of BMPS |
| 5769 | request issued by HDD |
| 5770 | |
| 5771 | \param - callbackcontext - Pointer to cookie |
| 5772 | status - result of request |
| 5773 | |
| 5774 | \return - None |
| 5775 | |
| 5776 | --------------------------------------------------------------------------*/ |
| 5777 | void hdd_req_bmps_cbk(void *callbackContext, eHalStatus status) |
| 5778 | { |
| 5779 | |
| 5780 | struct completion *completion_var = (struct completion*) callbackContext; |
| 5781 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 5782 | hddLog(VOS_TRACE_LEVEL_ERROR, "HDD BMPS request Callback, status = %d", status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5783 | if(completion_var != NULL) |
| 5784 | { |
| 5785 | complete(completion_var); |
| 5786 | } |
| 5787 | } |
| 5788 | |
| 5789 | /**--------------------------------------------------------------------------- |
| 5790 | |
| 5791 | \brief hdd_get_cfg_file_size() - |
| 5792 | |
| 5793 | This function reads the configuration file using the request firmware |
| 5794 | API and returns the configuration file size. |
| 5795 | |
| 5796 | \param - pCtx - Pointer to the adapter . |
| 5797 | - pFileName - Pointer to the file name. |
| 5798 | - pBufSize - Pointer to the buffer size. |
| 5799 | |
| 5800 | \return - 0 for success, non zero for failure |
| 5801 | |
| 5802 | --------------------------------------------------------------------------*/ |
| 5803 | |
| 5804 | VOS_STATUS hdd_get_cfg_file_size(v_VOID_t *pCtx, char *pFileName, v_SIZE_t *pBufSize) |
| 5805 | { |
| 5806 | int status; |
| 5807 | hdd_context_t *pHddCtx = (hdd_context_t*)pCtx; |
| 5808 | |
| 5809 | ENTER(); |
| 5810 | |
| 5811 | status = request_firmware(&pHddCtx->fw, pFileName, pHddCtx->parent_dev); |
| 5812 | |
| 5813 | if(status || !pHddCtx->fw || !pHddCtx->fw->data) { |
| 5814 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: CFG download failed",__func__); |
| 5815 | status = VOS_STATUS_E_FAILURE; |
| 5816 | } |
| 5817 | else { |
| 5818 | *pBufSize = pHddCtx->fw->size; |
| 5819 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: CFG size = %d", __func__, *pBufSize); |
| 5820 | release_firmware(pHddCtx->fw); |
| 5821 | pHddCtx->fw = NULL; |
| 5822 | } |
| 5823 | |
| 5824 | EXIT(); |
| 5825 | return VOS_STATUS_SUCCESS; |
| 5826 | } |
| 5827 | |
| 5828 | /**--------------------------------------------------------------------------- |
| 5829 | |
| 5830 | \brief hdd_read_cfg_file() - |
| 5831 | |
| 5832 | This function reads the configuration file using the request firmware |
| 5833 | API and returns the cfg data and the buffer size of the configuration file. |
| 5834 | |
| 5835 | \param - pCtx - Pointer to the adapter . |
| 5836 | - pFileName - Pointer to the file name. |
| 5837 | - pBuffer - Pointer to the data buffer. |
| 5838 | - pBufSize - Pointer to the buffer size. |
| 5839 | |
| 5840 | \return - 0 for success, non zero for failure |
| 5841 | |
| 5842 | --------------------------------------------------------------------------*/ |
| 5843 | |
| 5844 | VOS_STATUS hdd_read_cfg_file(v_VOID_t *pCtx, char *pFileName, |
| 5845 | v_VOID_t *pBuffer, v_SIZE_t *pBufSize) |
| 5846 | { |
| 5847 | int status; |
| 5848 | hdd_context_t *pHddCtx = (hdd_context_t*)pCtx; |
| 5849 | |
| 5850 | ENTER(); |
| 5851 | |
| 5852 | status = request_firmware(&pHddCtx->fw, pFileName, pHddCtx->parent_dev); |
| 5853 | |
| 5854 | if(status || !pHddCtx->fw || !pHddCtx->fw->data) { |
| 5855 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: CFG download failed",__func__); |
| 5856 | return VOS_STATUS_E_FAILURE; |
| 5857 | } |
| 5858 | else { |
| 5859 | if(*pBufSize != pHddCtx->fw->size) { |
| 5860 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Caller sets invalid CFG " |
| 5861 | "file size", __func__); |
| 5862 | release_firmware(pHddCtx->fw); |
| 5863 | pHddCtx->fw = NULL; |
| 5864 | return VOS_STATUS_E_FAILURE; |
| 5865 | } |
| 5866 | else { |
| 5867 | if(pBuffer) { |
| 5868 | vos_mem_copy(pBuffer,pHddCtx->fw->data,*pBufSize); |
| 5869 | } |
| 5870 | release_firmware(pHddCtx->fw); |
| 5871 | pHddCtx->fw = NULL; |
| 5872 | } |
| 5873 | } |
| 5874 | |
| 5875 | EXIT(); |
| 5876 | |
| 5877 | return VOS_STATUS_SUCCESS; |
| 5878 | } |
| 5879 | |
| 5880 | /**--------------------------------------------------------------------------- |
| 5881 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 5882 | \brief __hdd_set_mac_address() - |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5883 | |
| 5884 | This function sets the user specified mac address using |
| 5885 | the command ifconfig wlanX hw ether <mac adress>. |
| 5886 | |
| 5887 | \param - dev - Pointer to the net device. |
| 5888 | - addr - Pointer to the sockaddr. |
| 5889 | \return - 0 for success, non zero for failure |
| 5890 | |
| 5891 | --------------------------------------------------------------------------*/ |
| 5892 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 5893 | static int __hdd_set_mac_address(struct net_device *dev, void *addr) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5894 | { |
| 5895 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5896 | struct sockaddr *psta_mac_addr = addr; |
| 5897 | eHalStatus halStatus = eHAL_STATUS_SUCCESS; |
| 5898 | |
| 5899 | ENTER(); |
| 5900 | |
| 5901 | memcpy(&pAdapter->macAddressCurrent, psta_mac_addr->sa_data, ETH_ALEN); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5902 | memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN); |
| 5903 | |
| 5904 | EXIT(); |
| 5905 | return halStatus; |
| 5906 | } |
| 5907 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 5908 | /**--------------------------------------------------------------------------- |
| 5909 | |
| 5910 | \brief hdd_set_mac_address() - |
| 5911 | |
| 5912 | Wrapper function to protect __hdd_set_mac_address() function from ssr |
| 5913 | |
| 5914 | \param - dev - Pointer to the net device. |
| 5915 | - addr - Pointer to the sockaddr. |
| 5916 | \return - 0 for success, non zero for failure |
| 5917 | |
| 5918 | --------------------------------------------------------------------------*/ |
| 5919 | static int hdd_set_mac_address(struct net_device *dev, void *addr) |
| 5920 | { |
| 5921 | int ret; |
| 5922 | |
| 5923 | vos_ssr_protect(__func__); |
| 5924 | ret = __hdd_set_mac_address(dev, addr); |
| 5925 | vos_ssr_unprotect(__func__); |
| 5926 | |
| 5927 | return ret; |
| 5928 | } |
| 5929 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5930 | tANI_U8* wlan_hdd_get_intf_addr(hdd_context_t* pHddCtx) |
| 5931 | { |
| 5932 | int i; |
| 5933 | for ( i = 0; i < VOS_MAX_CONCURRENCY_PERSONA; i++) |
| 5934 | { |
Abhishek Singh | eb18378 | 2014-02-06 13:37:21 +0530 | [diff] [blame] | 5935 | if( 0 == ((pHddCtx->cfg_ini->intfAddrMask) & (1 << i)) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5936 | break; |
| 5937 | } |
| 5938 | |
| 5939 | if( VOS_MAX_CONCURRENCY_PERSONA == i) |
| 5940 | return NULL; |
| 5941 | |
| 5942 | pHddCtx->cfg_ini->intfAddrMask |= (1 << i); |
| 5943 | return &pHddCtx->cfg_ini->intfMacAddr[i].bytes[0]; |
| 5944 | } |
| 5945 | |
| 5946 | void wlan_hdd_release_intf_addr(hdd_context_t* pHddCtx, tANI_U8* releaseAddr) |
| 5947 | { |
| 5948 | int i; |
| 5949 | for ( i = 0; i < VOS_MAX_CONCURRENCY_PERSONA; i++) |
| 5950 | { |
| 5951 | if ( !memcmp(releaseAddr, &pHddCtx->cfg_ini->intfMacAddr[i].bytes[0], 6) ) |
| 5952 | { |
| 5953 | pHddCtx->cfg_ini->intfAddrMask &= ~(1 << i); |
| 5954 | break; |
| 5955 | } |
| 5956 | } |
| 5957 | return; |
| 5958 | } |
| 5959 | |
| 5960 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)) |
| 5961 | static struct net_device_ops wlan_drv_ops = { |
| 5962 | .ndo_open = hdd_open, |
| 5963 | .ndo_stop = hdd_stop, |
| 5964 | .ndo_uninit = hdd_uninit, |
| 5965 | .ndo_start_xmit = hdd_hard_start_xmit, |
| 5966 | .ndo_tx_timeout = hdd_tx_timeout, |
| 5967 | .ndo_get_stats = hdd_stats, |
| 5968 | .ndo_do_ioctl = hdd_ioctl, |
| 5969 | .ndo_set_mac_address = hdd_set_mac_address, |
| 5970 | .ndo_select_queue = hdd_select_queue, |
| 5971 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 5972 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(3,1,0)) |
| 5973 | .ndo_set_rx_mode = hdd_set_multicast_list, |
| 5974 | #else |
| 5975 | .ndo_set_multicast_list = hdd_set_multicast_list, |
| 5976 | #endif //LINUX_VERSION_CODE |
| 5977 | #endif |
| 5978 | }; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5979 | static struct net_device_ops wlan_mon_drv_ops = { |
| 5980 | .ndo_open = hdd_mon_open, |
| 5981 | .ndo_stop = hdd_stop, |
| 5982 | .ndo_uninit = hdd_uninit, |
| 5983 | .ndo_start_xmit = hdd_mon_hard_start_xmit, |
| 5984 | .ndo_tx_timeout = hdd_tx_timeout, |
| 5985 | .ndo_get_stats = hdd_stats, |
| 5986 | .ndo_do_ioctl = hdd_ioctl, |
| 5987 | .ndo_set_mac_address = hdd_set_mac_address, |
| 5988 | }; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5989 | |
| 5990 | #endif |
| 5991 | |
| 5992 | void hdd_set_station_ops( struct net_device *pWlanDev ) |
| 5993 | { |
| 5994 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5995 | pWlanDev->netdev_ops = &wlan_drv_ops; |
| 5996 | #else |
| 5997 | pWlanDev->open = hdd_open; |
| 5998 | pWlanDev->stop = hdd_stop; |
| 5999 | pWlanDev->uninit = hdd_uninit; |
| 6000 | pWlanDev->hard_start_xmit = NULL; |
| 6001 | pWlanDev->tx_timeout = hdd_tx_timeout; |
| 6002 | pWlanDev->get_stats = hdd_stats; |
| 6003 | pWlanDev->do_ioctl = hdd_ioctl; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6004 | pWlanDev->set_mac_address = hdd_set_mac_address; |
| 6005 | #endif |
| 6006 | } |
| 6007 | |
Jeff Johnson | eed415b | 2013-01-18 16:11:20 -0800 | [diff] [blame] | 6008 | 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] | 6009 | { |
| 6010 | struct net_device *pWlanDev = NULL; |
| 6011 | hdd_adapter_t *pAdapter = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6012 | /* |
| 6013 | * cfg80211 initialization and registration.... |
| 6014 | */ |
| 6015 | pWlanDev = alloc_netdev_mq(sizeof( hdd_adapter_t ), name, ether_setup, NUM_TX_QUEUES); |
| 6016 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6017 | if(pWlanDev != NULL) |
| 6018 | { |
| 6019 | |
| 6020 | //Save the pointer to the net_device in the HDD adapter |
| 6021 | pAdapter = (hdd_adapter_t*) netdev_priv( pWlanDev ); |
| 6022 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6023 | vos_mem_zero( pAdapter, sizeof( hdd_adapter_t ) ); |
| 6024 | |
| 6025 | pAdapter->dev = pWlanDev; |
| 6026 | pAdapter->pHddCtx = pHddCtx; |
| 6027 | pAdapter->magic = WLAN_HDD_ADAPTER_MAGIC; |
Agarwal Ashish | 47d1811 | 2014-08-04 19:55:07 +0530 | [diff] [blame] | 6028 | spin_lock_init(&pAdapter->lock_for_active_session); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6029 | |
| 6030 | init_completion(&pAdapter->session_open_comp_var); |
| 6031 | init_completion(&pAdapter->session_close_comp_var); |
| 6032 | init_completion(&pAdapter->disconnect_comp_var); |
| 6033 | init_completion(&pAdapter->linkup_event_var); |
| 6034 | init_completion(&pAdapter->cancel_rem_on_chan_var); |
| 6035 | init_completion(&pAdapter->rem_on_chan_ready_event); |
Vinay Krishna Eranna | f0e523b | 2014-03-01 21:00:16 +0530 | [diff] [blame] | 6036 | init_completion(&pAdapter->pno_comp_var); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6037 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 6038 | init_completion(&pAdapter->offchannel_tx_event); |
| 6039 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6040 | init_completion(&pAdapter->tx_action_cnf_event); |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 6041 | #ifdef FEATURE_WLAN_TDLS |
| 6042 | init_completion(&pAdapter->tdls_add_station_comp); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 6043 | init_completion(&pAdapter->tdls_del_station_comp); |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 6044 | init_completion(&pAdapter->tdls_mgmt_comp); |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 6045 | init_completion(&pAdapter->tdls_link_establish_req_comp); |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 6046 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6047 | init_completion(&pHddCtx->mc_sus_event_var); |
| 6048 | init_completion(&pHddCtx->tx_sus_event_var); |
Gopichand Nakkala | 0562141 | 2013-06-19 19:37:38 +0530 | [diff] [blame] | 6049 | init_completion(&pHddCtx->rx_sus_event_var); |
Jeff Johnson | 9efb9aa | 2013-03-15 13:59:27 -0700 | [diff] [blame] | 6050 | init_completion(&pAdapter->ula_complete); |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 6051 | init_completion(&pAdapter->change_country_code); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6052 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 6053 | #ifdef FEATURE_WLAN_BATCH_SCAN |
| 6054 | init_completion(&pAdapter->hdd_set_batch_scan_req_var); |
| 6055 | init_completion(&pAdapter->hdd_get_batch_scan_req_var); |
| 6056 | pAdapter->pBatchScanRsp = NULL; |
| 6057 | pAdapter->numScanList = 0; |
Rajeev Kumar | 20140c1 | 2013-10-21 19:39:02 -0700 | [diff] [blame] | 6058 | pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STOPPED; |
Kiet Lam | aa8e15a | 2014-02-11 23:30:06 -0800 | [diff] [blame] | 6059 | pAdapter->prev_batch_id = 0; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 6060 | mutex_init(&pAdapter->hdd_batch_scan_lock); |
| 6061 | #endif |
| 6062 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6063 | pAdapter->isLinkUpSvcNeeded = FALSE; |
| 6064 | pAdapter->higherDtimTransition = eANI_BOOLEAN_TRUE; |
| 6065 | //Init the net_device structure |
| 6066 | strlcpy(pWlanDev->name, name, IFNAMSIZ); |
| 6067 | |
| 6068 | vos_mem_copy(pWlanDev->dev_addr, (void *)macAddr, sizeof(tSirMacAddr)); |
| 6069 | vos_mem_copy( pAdapter->macAddressCurrent.bytes, macAddr, sizeof(tSirMacAddr)); |
| 6070 | pWlanDev->watchdog_timeo = HDD_TX_TIMEOUT; |
| 6071 | pWlanDev->hard_header_len += LIBRA_HW_NEEDED_HEADROOM; |
| 6072 | |
| 6073 | hdd_set_station_ops( pAdapter->dev ); |
| 6074 | |
| 6075 | pWlanDev->destructor = free_netdev; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6076 | pWlanDev->ieee80211_ptr = &pAdapter->wdev ; |
| 6077 | pAdapter->wdev.wiphy = pHddCtx->wiphy; |
| 6078 | pAdapter->wdev.netdev = pWlanDev; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6079 | /* set pWlanDev's parent to underlying device */ |
| 6080 | SET_NETDEV_DEV(pWlanDev, pHddCtx->parent_dev); |
Kumar Anand | 82c009f | 2014-05-29 00:29:42 -0700 | [diff] [blame] | 6081 | |
| 6082 | hdd_wmm_init( pAdapter ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6083 | } |
| 6084 | |
| 6085 | return pAdapter; |
| 6086 | } |
| 6087 | |
| 6088 | VOS_STATUS hdd_register_interface( hdd_adapter_t *pAdapter, tANI_U8 rtnl_lock_held ) |
| 6089 | { |
| 6090 | struct net_device *pWlanDev = pAdapter->dev; |
| 6091 | //hdd_station_ctx_t *pHddStaCtx = &pAdapter->sessionCtx.station; |
| 6092 | //hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
| 6093 | //eHalStatus halStatus = eHAL_STATUS_SUCCESS; |
| 6094 | |
| 6095 | if( rtnl_lock_held ) |
| 6096 | { |
Madan Mohan Koyyalamudi | d8ac866 | 2012-11-06 19:04:56 -0800 | [diff] [blame] | 6097 | if (strnchr(pWlanDev->name, strlen(pWlanDev->name), '%')) { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6098 | if( dev_alloc_name(pWlanDev, pWlanDev->name) < 0 ) |
| 6099 | { |
| 6100 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s:Failed:dev_alloc_name",__func__); |
| 6101 | return VOS_STATUS_E_FAILURE; |
| 6102 | } |
| 6103 | } |
| 6104 | if (register_netdevice(pWlanDev)) |
| 6105 | { |
| 6106 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s:Failed:register_netdev",__func__); |
| 6107 | return VOS_STATUS_E_FAILURE; |
| 6108 | } |
| 6109 | } |
| 6110 | else |
| 6111 | { |
| 6112 | if(register_netdev(pWlanDev)) |
| 6113 | { |
| 6114 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failed:register_netdev",__func__); |
| 6115 | return VOS_STATUS_E_FAILURE; |
| 6116 | } |
| 6117 | } |
| 6118 | set_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags); |
| 6119 | |
| 6120 | return VOS_STATUS_SUCCESS; |
| 6121 | } |
| 6122 | |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 6123 | static eHalStatus hdd_smeCloseSessionCallback(void *pContext) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6124 | { |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 6125 | hdd_adapter_t *pAdapter = pContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6126 | |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 6127 | if (NULL == pAdapter) |
| 6128 | { |
| 6129 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: NULL pAdapter", __func__); |
| 6130 | return eHAL_STATUS_INVALID_PARAMETER; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6131 | } |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 6132 | |
| 6133 | if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) |
| 6134 | { |
| 6135 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Invalid magic", __func__); |
| 6136 | return eHAL_STATUS_NOT_INITIALIZED; |
| 6137 | } |
| 6138 | |
| 6139 | clear_bit(SME_SESSION_OPENED, &pAdapter->event_flags); |
| 6140 | |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 6141 | #ifndef WLAN_OPEN_SOURCE |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 6142 | /* need to make sure all of our scheduled work has completed. |
| 6143 | * This callback is called from MC thread context, so it is safe to |
| 6144 | * to call below flush workqueue API from here. |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 6145 | * |
| 6146 | * Even though this is called from MC thread context, if there is a faulty |
| 6147 | * work item in the system, that can hang this call forever. So flushing |
| 6148 | * this global work queue is not safe; and now we make sure that |
| 6149 | * individual work queues are stopped correctly. But the cancel work queue |
| 6150 | * is a GPL only API, so the proprietary version of the driver would still |
| 6151 | * rely on the global work queue flush. |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 6152 | */ |
| 6153 | flush_scheduled_work(); |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 6154 | #endif |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 6155 | |
| 6156 | /* We can be blocked while waiting for scheduled work to be |
| 6157 | * flushed, and the adapter structure can potentially be freed, in |
| 6158 | * which case the magic will have been reset. So make sure the |
| 6159 | * magic is still good, and hence the adapter structure is still |
| 6160 | * valid, before signaling completion */ |
| 6161 | if (WLAN_HDD_ADAPTER_MAGIC == pAdapter->magic) |
| 6162 | { |
| 6163 | complete(&pAdapter->session_close_comp_var); |
| 6164 | } |
| 6165 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6166 | return eHAL_STATUS_SUCCESS; |
| 6167 | } |
| 6168 | |
| 6169 | VOS_STATUS hdd_init_station_mode( hdd_adapter_t *pAdapter ) |
| 6170 | { |
| 6171 | struct net_device *pWlanDev = pAdapter->dev; |
| 6172 | hdd_station_ctx_t *pHddStaCtx = &pAdapter->sessionCtx.station; |
| 6173 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
| 6174 | eHalStatus halStatus = eHAL_STATUS_SUCCESS; |
| 6175 | VOS_STATUS status = VOS_STATUS_E_FAILURE; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6176 | long rc = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6177 | |
| 6178 | INIT_COMPLETION(pAdapter->session_open_comp_var); |
Kiran Kumar Lokere | 0ad5cd3 | 2013-06-25 11:26:22 -0700 | [diff] [blame] | 6179 | sme_SetCurrDeviceMode(pHddCtx->hHal, pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6180 | //Open a SME session for future operation |
| 6181 | halStatus = sme_OpenSession( pHddCtx->hHal, hdd_smeRoamCallback, pAdapter, |
Kiran Kumar Lokere | 0ad5cd3 | 2013-06-25 11:26:22 -0700 | [diff] [blame] | 6182 | (tANI_U8 *)&pAdapter->macAddressCurrent, &pAdapter->sessionId); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6183 | if ( !HAL_STATUS_SUCCESS( halStatus ) ) |
| 6184 | { |
| 6185 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 6186 | "sme_OpenSession() failed with status code %08d [x%08x]", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6187 | halStatus, halStatus ); |
| 6188 | status = VOS_STATUS_E_FAILURE; |
| 6189 | goto error_sme_open; |
| 6190 | } |
| 6191 | |
| 6192 | //Block on a completion variable. Can't wait forever though. |
Vinay Krishna Eranna | 0fe2e7c | 2014-04-09 21:32:08 +0530 | [diff] [blame] | 6193 | rc = wait_for_completion_timeout( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6194 | &pAdapter->session_open_comp_var, |
| 6195 | msecs_to_jiffies(WLAN_WAIT_TIME_SESSIONOPENCLOSE)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6196 | if (rc <= 0) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6197 | { |
| 6198 | hddLog(VOS_TRACE_LEVEL_FATAL, |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6199 | "Session is not opened within timeout period code %ld", rc ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6200 | status = VOS_STATUS_E_FAILURE; |
| 6201 | goto error_sme_open; |
| 6202 | } |
| 6203 | |
| 6204 | // Register wireless extensions |
| 6205 | if( eHAL_STATUS_SUCCESS != (halStatus = hdd_register_wext(pWlanDev))) |
| 6206 | { |
| 6207 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 6208 | "hdd_register_wext() failed with status code %08d [x%08x]", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6209 | halStatus, halStatus ); |
| 6210 | status = VOS_STATUS_E_FAILURE; |
| 6211 | goto error_register_wext; |
| 6212 | } |
| 6213 | //Safe to register the hard_start_xmit function again |
| 6214 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)) |
| 6215 | wlan_drv_ops.ndo_start_xmit = hdd_hard_start_xmit; |
| 6216 | #else |
| 6217 | pWlanDev->hard_start_xmit = hdd_hard_start_xmit; |
| 6218 | #endif |
| 6219 | |
| 6220 | //Set the Connection State to Not Connected |
Abhishek Singh | f4669da | 2014-05-26 15:07:49 +0530 | [diff] [blame] | 6221 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6222 | "%s: Set HDD connState to eConnectionState_NotConnected", |
| 6223 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6224 | pHddStaCtx->conn_info.connState = eConnectionState_NotConnected; |
| 6225 | |
| 6226 | //Set the default operation channel |
| 6227 | pHddStaCtx->conn_info.operationChannel = pHddCtx->cfg_ini->OperatingChannel; |
| 6228 | |
| 6229 | /* Make the default Auth Type as OPEN*/ |
| 6230 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 6231 | |
| 6232 | if( VOS_STATUS_SUCCESS != ( status = hdd_init_tx_rx( pAdapter ) ) ) |
| 6233 | { |
| 6234 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 6235 | "hdd_init_tx_rx() failed with status code %08d [x%08x]", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6236 | status, status ); |
| 6237 | goto error_init_txrx; |
| 6238 | } |
| 6239 | |
| 6240 | set_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags); |
| 6241 | |
| 6242 | if( VOS_STATUS_SUCCESS != ( status = hdd_wmm_adapter_init( pAdapter ) ) ) |
| 6243 | { |
| 6244 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 6245 | "hdd_wmm_adapter_init() failed with status code %08d [x%08x]", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6246 | status, status ); |
| 6247 | goto error_wmm_init; |
| 6248 | } |
| 6249 | |
| 6250 | set_bit(WMM_INIT_DONE, &pAdapter->event_flags); |
| 6251 | |
| 6252 | return VOS_STATUS_SUCCESS; |
| 6253 | |
| 6254 | error_wmm_init: |
| 6255 | clear_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags); |
| 6256 | hdd_deinit_tx_rx(pAdapter); |
| 6257 | error_init_txrx: |
| 6258 | hdd_UnregisterWext(pWlanDev); |
| 6259 | error_register_wext: |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 6260 | if (test_bit(SME_SESSION_OPENED, &pAdapter->event_flags)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6261 | { |
| 6262 | INIT_COMPLETION(pAdapter->session_close_comp_var); |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 6263 | if (eHAL_STATUS_SUCCESS == sme_CloseSession(pHddCtx->hHal, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6264 | pAdapter->sessionId, |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 6265 | hdd_smeCloseSessionCallback, pAdapter)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6266 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6267 | unsigned long rc; |
| 6268 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6269 | //Block on a completion variable. Can't wait forever though. |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6270 | rc = wait_for_completion_timeout( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6271 | &pAdapter->session_close_comp_var, |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 6272 | msecs_to_jiffies(WLAN_WAIT_TIME_SESSIONOPENCLOSE)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6273 | if (rc <= 0) |
| 6274 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6275 | FL("Session is not opened within timeout period code %ld"), rc); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6276 | } |
| 6277 | } |
| 6278 | error_sme_open: |
| 6279 | return status; |
| 6280 | } |
| 6281 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6282 | void hdd_cleanup_actionframe( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter ) |
| 6283 | { |
| 6284 | hdd_cfg80211_state_t *cfgState; |
| 6285 | |
| 6286 | cfgState = WLAN_HDD_GET_CFG_STATE_PTR( pAdapter ); |
| 6287 | |
| 6288 | if( NULL != cfgState->buf ) |
| 6289 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6290 | long rc; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6291 | INIT_COMPLETION(pAdapter->tx_action_cnf_event); |
| 6292 | rc = wait_for_completion_interruptible_timeout( |
| 6293 | &pAdapter->tx_action_cnf_event, |
| 6294 | msecs_to_jiffies(ACTION_FRAME_TX_TIMEOUT)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6295 | if (rc <= 0) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6296 | { |
Sudhir Sattayappa Kohalli | 8ee532d | 2013-02-15 13:16:26 -0800 | [diff] [blame] | 6297 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6298 | "%s ERROR: HDD Wait for Action Confirmation Failed!! %ld" |
| 6299 | , __func__, rc); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6300 | } |
| 6301 | } |
| 6302 | return; |
| 6303 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6304 | |
c_hpothu | 002231a | 2015-02-05 14:58:51 +0530 | [diff] [blame] | 6305 | void hdd_deinit_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter, tANI_U8 rtnl_held ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6306 | { |
| 6307 | ENTER(); |
| 6308 | switch ( pAdapter->device_mode ) |
| 6309 | { |
| 6310 | case WLAN_HDD_INFRA_STATION: |
| 6311 | case WLAN_HDD_P2P_CLIENT: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6312 | case WLAN_HDD_P2P_DEVICE: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6313 | { |
| 6314 | if(test_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags)) |
| 6315 | { |
| 6316 | hdd_deinit_tx_rx( pAdapter ); |
| 6317 | clear_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags); |
| 6318 | } |
| 6319 | |
| 6320 | if(test_bit(WMM_INIT_DONE, &pAdapter->event_flags)) |
| 6321 | { |
| 6322 | hdd_wmm_adapter_close( pAdapter ); |
| 6323 | clear_bit(WMM_INIT_DONE, &pAdapter->event_flags); |
| 6324 | } |
| 6325 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6326 | hdd_cleanup_actionframe(pHddCtx, pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6327 | break; |
| 6328 | } |
| 6329 | |
| 6330 | case WLAN_HDD_SOFTAP: |
| 6331 | case WLAN_HDD_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6332 | { |
Madan Mohan Koyyalamudi | 8c6dec8 | 2013-09-26 15:56:13 +0530 | [diff] [blame] | 6333 | |
| 6334 | if (test_bit(WMM_INIT_DONE, &pAdapter->event_flags)) |
| 6335 | { |
| 6336 | hdd_wmm_adapter_close( pAdapter ); |
| 6337 | clear_bit(WMM_INIT_DONE, &pAdapter->event_flags); |
| 6338 | } |
| 6339 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6340 | hdd_cleanup_actionframe(pHddCtx, pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6341 | |
c_hpothu | 002231a | 2015-02-05 14:58:51 +0530 | [diff] [blame] | 6342 | hdd_unregister_hostapd(pAdapter, rtnl_held); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6343 | hdd_set_conparam( 0 ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6344 | wlan_hdd_set_monitor_tx_adapter( WLAN_HDD_GET_CTX(pAdapter), NULL ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6345 | break; |
| 6346 | } |
| 6347 | |
| 6348 | case WLAN_HDD_MONITOR: |
| 6349 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6350 | hdd_adapter_t* pAdapterforTx = pAdapter->sessionCtx.monitor.pAdapterForTx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6351 | if(test_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags)) |
| 6352 | { |
| 6353 | hdd_deinit_tx_rx( pAdapter ); |
| 6354 | clear_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags); |
| 6355 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6356 | if(NULL != pAdapterforTx) |
| 6357 | { |
| 6358 | hdd_cleanup_actionframe(pHddCtx, pAdapterforTx); |
| 6359 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6360 | break; |
| 6361 | } |
| 6362 | |
| 6363 | |
| 6364 | default: |
| 6365 | break; |
| 6366 | } |
| 6367 | |
| 6368 | EXIT(); |
| 6369 | } |
| 6370 | |
| 6371 | void hdd_cleanup_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter, tANI_U8 rtnl_held ) |
| 6372 | { |
Mingcheng Zhu | 87f22fc | 2014-01-30 19:23:32 -0800 | [diff] [blame] | 6373 | struct net_device *pWlanDev = NULL; |
Srinivas, Dasari | 693dfc5 | 2013-12-27 17:29:09 +0530 | [diff] [blame] | 6374 | |
| 6375 | ENTER(); |
| 6376 | if (NULL == pAdapter) |
| 6377 | { |
| 6378 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6379 | "%s: HDD adapter is Null", __func__); |
| 6380 | return; |
| 6381 | } |
| 6382 | |
| 6383 | pWlanDev = pAdapter->dev; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6384 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 6385 | #ifdef FEATURE_WLAN_BATCH_SCAN |
Srinivas, Dasari | 693dfc5 | 2013-12-27 17:29:09 +0530 | [diff] [blame] | 6386 | if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
| 6387 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 6388 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Srinivas, Dasari | 693dfc5 | 2013-12-27 17:29:09 +0530 | [diff] [blame] | 6389 | || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE) |
| 6390 | ) |
| 6391 | { |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 6392 | if (pAdapter) |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 6393 | { |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 6394 | if (eHDD_BATCH_SCAN_STATE_STARTED == pAdapter->batchScanState) |
| 6395 | { |
| 6396 | hdd_deinit_batch_scan(pAdapter); |
| 6397 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 6398 | } |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 6399 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 6400 | #endif |
| 6401 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6402 | if(test_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags)) { |
| 6403 | if( rtnl_held ) |
| 6404 | { |
| 6405 | unregister_netdevice(pWlanDev); |
| 6406 | } |
| 6407 | else |
| 6408 | { |
| 6409 | unregister_netdev(pWlanDev); |
| 6410 | } |
| 6411 | // note that the pAdapter is no longer valid at this point |
| 6412 | // since the memory has been reclaimed |
| 6413 | } |
| 6414 | |
Srinivas, Dasari | 693dfc5 | 2013-12-27 17:29:09 +0530 | [diff] [blame] | 6415 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6416 | } |
| 6417 | |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 6418 | void hdd_set_pwrparams(hdd_context_t *pHddCtx) |
| 6419 | { |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 6420 | VOS_STATUS status; |
| 6421 | hdd_adapter_t *pAdapter = NULL; |
| 6422 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 6423 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 6424 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 6425 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 6426 | /*loop through all adapters.*/ |
| 6427 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 6428 | { |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 6429 | pAdapter = pAdapterNode->pAdapter; |
| 6430 | if ( (WLAN_HDD_INFRA_STATION != pAdapter->device_mode) |
| 6431 | && (WLAN_HDD_P2P_CLIENT != pAdapter->device_mode) ) |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 6432 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 6433 | { // we skip this registration for modes other than STA and P2P client modes. |
| 6434 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 6435 | pAdapterNode = pNext; |
| 6436 | continue; |
| 6437 | } |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 6438 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 6439 | //Apply Dynamic DTIM For P2P |
| 6440 | //Only if ignoreDynamicDtimInP2pMode is not set in ini |
| 6441 | if ((pHddCtx->cfg_ini->enableDynamicDTIM || |
| 6442 | pHddCtx->cfg_ini->enableModulatedDTIM) && |
| 6443 | ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
| 6444 | ((WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) && |
| 6445 | !(pHddCtx->cfg_ini->ignoreDynamicDtimInP2pMode))) && |
| 6446 | (eANI_BOOLEAN_TRUE == pAdapter->higherDtimTransition) && |
| 6447 | (eConnectionState_Associated == |
| 6448 | (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) && |
| 6449 | (pHddCtx->cfg_ini->fIsBmpsEnabled)) |
| 6450 | { |
| 6451 | tSirSetPowerParamsReq powerRequest = { 0 }; |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 6452 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 6453 | powerRequest.uIgnoreDTIM = 1; |
| 6454 | powerRequest.uMaxLIModulatedDTIM = pHddCtx->cfg_ini->fMaxLIModulatedDTIM; |
| 6455 | |
| 6456 | if (pHddCtx->cfg_ini->enableModulatedDTIM) |
| 6457 | { |
| 6458 | powerRequest.uDTIMPeriod = pHddCtx->cfg_ini->enableModulatedDTIM; |
| 6459 | powerRequest.uListenInterval = pHddCtx->hdd_actual_LI_value; |
| 6460 | } |
| 6461 | else |
| 6462 | { |
| 6463 | powerRequest.uListenInterval = pHddCtx->cfg_ini->enableDynamicDTIM; |
| 6464 | } |
| 6465 | |
| 6466 | /* Update ignoreDTIM and ListedInterval in CFG to remain at the DTIM |
| 6467 | * specified during Enter/Exit BMPS when LCD off*/ |
| 6468 | ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IGNORE_DTIM, powerRequest.uIgnoreDTIM, |
| 6469 | NULL, eANI_BOOLEAN_FALSE); |
| 6470 | ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_LISTEN_INTERVAL, powerRequest.uListenInterval, |
| 6471 | NULL, eANI_BOOLEAN_FALSE); |
| 6472 | |
| 6473 | /* switch to the DTIM specified in cfg.ini */ |
| 6474 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 6475 | "Switch to DTIM %d", powerRequest.uListenInterval); |
| 6476 | sme_SetPowerParams( pHddCtx->hHal, &powerRequest, TRUE); |
| 6477 | break; |
| 6478 | |
| 6479 | } |
| 6480 | |
| 6481 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 6482 | pAdapterNode = pNext; |
| 6483 | } |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 6484 | } |
| 6485 | |
| 6486 | void hdd_reset_pwrparams(hdd_context_t *pHddCtx) |
| 6487 | { |
| 6488 | /*Switch back to DTIM 1*/ |
| 6489 | tSirSetPowerParamsReq powerRequest = { 0 }; |
| 6490 | |
| 6491 | powerRequest.uIgnoreDTIM = pHddCtx->hdd_actual_ignore_DTIM_value; |
| 6492 | powerRequest.uListenInterval = pHddCtx->hdd_actual_LI_value; |
Yue Ma | c24062f | 2013-05-13 17:01:29 -0700 | [diff] [blame] | 6493 | powerRequest.uMaxLIModulatedDTIM = pHddCtx->cfg_ini->fMaxLIModulatedDTIM; |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 6494 | |
| 6495 | /* Update ignoreDTIM and ListedInterval in CFG with default values */ |
| 6496 | ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IGNORE_DTIM, powerRequest.uIgnoreDTIM, |
| 6497 | NULL, eANI_BOOLEAN_FALSE); |
| 6498 | ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_LISTEN_INTERVAL, powerRequest.uListenInterval, |
| 6499 | NULL, eANI_BOOLEAN_FALSE); |
| 6500 | |
| 6501 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 6502 | "Switch to DTIM%d",powerRequest.uListenInterval); |
| 6503 | sme_SetPowerParams( pHddCtx->hHal, &powerRequest, TRUE); |
| 6504 | |
| 6505 | } |
| 6506 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6507 | VOS_STATUS hdd_enable_bmps_imps(hdd_context_t *pHddCtx) |
| 6508 | { |
| 6509 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
Sushant Kaushik | 4928e54 | 2014-12-29 15:25:54 +0530 | [diff] [blame] | 6510 | if (WLAN_HDD_IS_UNLOAD_IN_PROGRESS(pHddCtx)) |
| 6511 | { |
| 6512 | hddLog( LOGE, FL("Wlan Unload in progress")); |
| 6513 | return VOS_STATUS_E_PERM; |
| 6514 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6515 | if(pHddCtx->cfg_ini->fIsBmpsEnabled) |
| 6516 | { |
| 6517 | sme_EnablePowerSave(pHddCtx->hHal, ePMC_BEACON_MODE_POWER_SAVE); |
| 6518 | } |
| 6519 | |
| 6520 | if(pHddCtx->cfg_ini->fIsAutoBmpsTimerEnabled) |
| 6521 | { |
| 6522 | sme_StartAutoBmpsTimer(pHddCtx->hHal); |
| 6523 | } |
| 6524 | |
| 6525 | if (pHddCtx->cfg_ini->fIsImpsEnabled) |
| 6526 | { |
| 6527 | sme_EnablePowerSave (pHddCtx->hHal, ePMC_IDLE_MODE_POWER_SAVE); |
| 6528 | } |
| 6529 | |
| 6530 | return status; |
| 6531 | } |
| 6532 | |
| 6533 | VOS_STATUS hdd_disable_bmps_imps(hdd_context_t *pHddCtx, tANI_U8 session_type) |
| 6534 | { |
| 6535 | hdd_adapter_t *pAdapter = NULL; |
| 6536 | eHalStatus halStatus; |
| 6537 | VOS_STATUS status = VOS_STATUS_E_INVAL; |
| 6538 | v_BOOL_t disableBmps = FALSE; |
| 6539 | v_BOOL_t disableImps = FALSE; |
| 6540 | |
| 6541 | switch(session_type) |
| 6542 | { |
| 6543 | case WLAN_HDD_INFRA_STATION: |
| 6544 | case WLAN_HDD_SOFTAP: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6545 | case WLAN_HDD_P2P_CLIENT: |
| 6546 | case WLAN_HDD_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6547 | //Exit BMPS -> Is Sta/P2P Client is already connected |
| 6548 | pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 6549 | if((NULL != pAdapter)&& |
| 6550 | hdd_connIsConnected( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) |
| 6551 | { |
| 6552 | disableBmps = TRUE; |
| 6553 | } |
| 6554 | |
| 6555 | pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT); |
| 6556 | if((NULL != pAdapter)&& |
| 6557 | hdd_connIsConnected( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) |
| 6558 | { |
| 6559 | disableBmps = TRUE; |
| 6560 | } |
| 6561 | |
| 6562 | //Exit both Bmps and Imps incase of Go/SAP Mode |
| 6563 | if((WLAN_HDD_SOFTAP == session_type) || |
| 6564 | (WLAN_HDD_P2P_GO == session_type)) |
| 6565 | { |
| 6566 | disableBmps = TRUE; |
| 6567 | disableImps = TRUE; |
| 6568 | } |
| 6569 | |
| 6570 | if(TRUE == disableImps) |
| 6571 | { |
| 6572 | if (pHddCtx->cfg_ini->fIsImpsEnabled) |
| 6573 | { |
| 6574 | sme_DisablePowerSave (pHddCtx->hHal, ePMC_IDLE_MODE_POWER_SAVE); |
| 6575 | } |
| 6576 | } |
| 6577 | |
| 6578 | if(TRUE == disableBmps) |
| 6579 | { |
| 6580 | if(pHddCtx->cfg_ini->fIsBmpsEnabled) |
| 6581 | { |
| 6582 | halStatus = sme_DisablePowerSave(pHddCtx->hHal, ePMC_BEACON_MODE_POWER_SAVE); |
| 6583 | |
| 6584 | if(eHAL_STATUS_SUCCESS != halStatus) |
| 6585 | { |
| 6586 | status = VOS_STATUS_E_FAILURE; |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6587 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Fail to Disable Power Save", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6588 | VOS_ASSERT(0); |
| 6589 | return status; |
| 6590 | } |
| 6591 | } |
| 6592 | |
| 6593 | if(pHddCtx->cfg_ini->fIsAutoBmpsTimerEnabled) |
| 6594 | { |
| 6595 | halStatus = sme_StopAutoBmpsTimer(pHddCtx->hHal); |
| 6596 | |
| 6597 | if(eHAL_STATUS_SUCCESS != halStatus) |
| 6598 | { |
| 6599 | status = VOS_STATUS_E_FAILURE; |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6600 | 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] | 6601 | VOS_ASSERT(0); |
| 6602 | return status; |
| 6603 | } |
| 6604 | } |
| 6605 | } |
| 6606 | |
| 6607 | if((TRUE == disableBmps) || |
| 6608 | (TRUE == disableImps)) |
| 6609 | { |
| 6610 | /* Now, get the chip into Full Power now */ |
| 6611 | INIT_COMPLETION(pHddCtx->full_pwr_comp_var); |
| 6612 | halStatus = sme_RequestFullPower(pHddCtx->hHal, hdd_full_pwr_cbk, |
| 6613 | pHddCtx, eSME_FULL_PWR_NEEDED_BY_HDD); |
| 6614 | |
| 6615 | if(halStatus != eHAL_STATUS_SUCCESS) |
| 6616 | { |
| 6617 | if(halStatus == eHAL_STATUS_PMC_PENDING) |
| 6618 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6619 | long ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6620 | //Block on a completion variable. Can't wait forever though |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6621 | ret = wait_for_completion_interruptible_timeout( |
| 6622 | &pHddCtx->full_pwr_comp_var, |
| 6623 | msecs_to_jiffies(1000)); |
| 6624 | if (ret <= 0) |
| 6625 | { |
| 6626 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6627 | "%s: wait on full_pwr_comp_var failed %ld", |
| 6628 | __func__, ret); |
| 6629 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6630 | } |
| 6631 | else |
| 6632 | { |
| 6633 | status = VOS_STATUS_E_FAILURE; |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6634 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Request for Full Power failed", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6635 | VOS_ASSERT(0); |
| 6636 | return status; |
| 6637 | } |
| 6638 | } |
| 6639 | |
| 6640 | status = VOS_STATUS_SUCCESS; |
| 6641 | } |
| 6642 | |
| 6643 | break; |
| 6644 | } |
| 6645 | return status; |
| 6646 | } |
| 6647 | |
| 6648 | 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] | 6649 | const char *iface_name, tSirMacAddr macAddr, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6650 | tANI_U8 rtnl_held ) |
| 6651 | { |
| 6652 | hdd_adapter_t *pAdapter = NULL; |
| 6653 | hdd_adapter_list_node_t *pHddAdapterNode = NULL; |
| 6654 | VOS_STATUS status = VOS_STATUS_E_FAILURE; |
| 6655 | VOS_STATUS exitbmpsStatus; |
| 6656 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6657 | 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] | 6658 | |
Nirav Shah | 436658f | 2014-02-28 17:05:45 +0530 | [diff] [blame] | 6659 | if(macAddr == NULL) |
| 6660 | { |
| 6661 | /* Not received valid macAddr */ |
| 6662 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6663 | "%s:Unable to add virtual intf: Not able to get" |
| 6664 | "valid mac address",__func__); |
| 6665 | return NULL; |
| 6666 | } |
| 6667 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6668 | //Disable BMPS incase of Concurrency |
| 6669 | exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx, session_type); |
| 6670 | |
| 6671 | if(VOS_STATUS_E_FAILURE == exitbmpsStatus) |
| 6672 | { |
| 6673 | //Fail to Exit BMPS |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6674 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Fail to Exit BMPS", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6675 | VOS_ASSERT(0); |
| 6676 | return NULL; |
| 6677 | } |
| 6678 | |
| 6679 | switch(session_type) |
| 6680 | { |
| 6681 | case WLAN_HDD_INFRA_STATION: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6682 | case WLAN_HDD_P2P_CLIENT: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6683 | case WLAN_HDD_P2P_DEVICE: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6684 | { |
| 6685 | pAdapter = hdd_alloc_station_adapter( pHddCtx, macAddr, iface_name ); |
| 6686 | |
| 6687 | if( NULL == pAdapter ) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6688 | { |
| 6689 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 6690 | FL("failed to allocate adapter for session %d"), session_type); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6691 | return NULL; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6692 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6693 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 6694 | #ifdef FEATURE_WLAN_TDLS |
| 6695 | /* A Mutex Lock is introduced while changing/initializing the mode to |
| 6696 | * protect the concurrent access for the Adapters by TDLS module. |
| 6697 | */ |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 6698 | mutex_lock(&pHddCtx->tdls_lock); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 6699 | #endif |
| 6700 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6701 | pAdapter->wdev.iftype = (session_type == WLAN_HDD_P2P_CLIENT) ? |
| 6702 | NL80211_IFTYPE_P2P_CLIENT: |
| 6703 | NL80211_IFTYPE_STATION; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6704 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6705 | pAdapter->device_mode = session_type; |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 6706 | #ifdef FEATURE_WLAN_TDLS |
| 6707 | mutex_unlock(&pHddCtx->tdls_lock); |
| 6708 | #endif |
Sunil Dutt | 66485cb | 2013-12-19 19:05:03 +0530 | [diff] [blame] | 6709 | |
| 6710 | status = hdd_init_station_mode( pAdapter ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6711 | if( VOS_STATUS_SUCCESS != status ) |
| 6712 | goto err_free_netdev; |
| 6713 | |
| 6714 | status = hdd_register_interface( pAdapter, rtnl_held ); |
| 6715 | if( VOS_STATUS_SUCCESS != status ) |
| 6716 | { |
Mahesh A Saptasagar | 02e36e8 | 2015-01-14 20:39:19 +0530 | [diff] [blame] | 6717 | #ifdef FEATURE_WLAN_TDLS |
| 6718 | mutex_lock(&pHddCtx->tdls_lock); |
| 6719 | #endif |
c_hpothu | 002231a | 2015-02-05 14:58:51 +0530 | [diff] [blame] | 6720 | hdd_deinit_adapter(pHddCtx, pAdapter, rtnl_held); |
Mahesh A Saptasagar | 02e36e8 | 2015-01-14 20:39:19 +0530 | [diff] [blame] | 6721 | #ifdef FEATURE_WLAN_TDLS |
| 6722 | mutex_unlock(&pHddCtx->tdls_lock); |
| 6723 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6724 | goto err_free_netdev; |
| 6725 | } |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 6726 | |
Vinay Krishna Eranna | 4d055d4 | 2013-12-17 17:02:01 +0530 | [diff] [blame] | 6727 | // Workqueue which gets scheduled in IPv4 notification callback. |
| 6728 | INIT_WORK(&pAdapter->ipv4NotifierWorkQueue, hdd_ipv4_notifier_work_queue); |
| 6729 | |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 6730 | #ifdef WLAN_NS_OFFLOAD |
| 6731 | // Workqueue which gets scheduled in IPv6 notification callback. |
| 6732 | INIT_WORK(&pAdapter->ipv6NotifierWorkQueue, hdd_ipv6_notifier_work_queue); |
| 6733 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6734 | //Stop the Interface TX queue. |
Padma, Santhosh Kumar | 9dacb5c | 2014-12-17 19:22:56 +0530 | [diff] [blame] | 6735 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6736 | netif_tx_disable(pAdapter->dev); |
| 6737 | //netif_tx_disable(pWlanDev); |
| 6738 | netif_carrier_off(pAdapter->dev); |
| 6739 | |
Ganesh Kondabattini | babfb49 | 2014-12-17 20:25:29 +0530 | [diff] [blame] | 6740 | if (WLAN_HDD_P2P_CLIENT == session_type || |
| 6741 | WLAN_HDD_P2P_DEVICE == session_type) |
| 6742 | { |
| 6743 | /* Initialize the work queue to defer the |
| 6744 | * back to back RoC request */ |
| 6745 | INIT_DELAYED_WORK(&pAdapter->roc_work, |
| 6746 | hdd_p2p_roc_work_queue); |
| 6747 | } |
| 6748 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6749 | break; |
| 6750 | } |
| 6751 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6752 | case WLAN_HDD_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6753 | case WLAN_HDD_SOFTAP: |
| 6754 | { |
| 6755 | pAdapter = hdd_wlan_create_ap_dev( pHddCtx, macAddr, (tANI_U8 *)iface_name ); |
| 6756 | if( NULL == pAdapter ) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6757 | { |
| 6758 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 6759 | FL("failed to allocate adapter for session %d"), session_type); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6760 | return NULL; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6761 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6762 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6763 | pAdapter->wdev.iftype = (session_type == WLAN_HDD_SOFTAP) ? |
| 6764 | NL80211_IFTYPE_AP: |
| 6765 | NL80211_IFTYPE_P2P_GO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6766 | pAdapter->device_mode = session_type; |
| 6767 | |
| 6768 | status = hdd_init_ap_mode(pAdapter); |
| 6769 | if( VOS_STATUS_SUCCESS != status ) |
| 6770 | goto err_free_netdev; |
| 6771 | |
| 6772 | status = hdd_register_hostapd( pAdapter, rtnl_held ); |
| 6773 | if( VOS_STATUS_SUCCESS != status ) |
| 6774 | { |
c_hpothu | 002231a | 2015-02-05 14:58:51 +0530 | [diff] [blame] | 6775 | hdd_deinit_adapter(pHddCtx, pAdapter, rtnl_held); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6776 | goto err_free_netdev; |
| 6777 | } |
Padma, Santhosh Kumar | 9dacb5c | 2014-12-17 19:22:56 +0530 | [diff] [blame] | 6778 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6779 | netif_tx_disable(pAdapter->dev); |
| 6780 | netif_carrier_off(pAdapter->dev); |
| 6781 | |
| 6782 | hdd_set_conparam( 1 ); |
Ganesh Kondabattini | babfb49 | 2014-12-17 20:25:29 +0530 | [diff] [blame] | 6783 | |
| 6784 | if (WLAN_HDD_P2P_GO == session_type) |
| 6785 | { |
| 6786 | /* Initialize the work queue to |
| 6787 | * defer the back to back RoC request */ |
| 6788 | INIT_DELAYED_WORK(&pAdapter->roc_work, |
| 6789 | hdd_p2p_roc_work_queue); |
| 6790 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6791 | break; |
| 6792 | } |
| 6793 | case WLAN_HDD_MONITOR: |
| 6794 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6795 | pAdapter = hdd_alloc_station_adapter( pHddCtx, macAddr, iface_name ); |
| 6796 | if( NULL == pAdapter ) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6797 | { |
| 6798 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 6799 | FL("failed to allocate adapter for session %d"), session_type); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6800 | return NULL; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6801 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6802 | |
| 6803 | pAdapter->wdev.iftype = NL80211_IFTYPE_MONITOR; |
| 6804 | pAdapter->device_mode = session_type; |
| 6805 | status = hdd_register_interface( pAdapter, rtnl_held ); |
| 6806 | #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29) |
| 6807 | pAdapter->dev->netdev_ops = &wlan_mon_drv_ops; |
| 6808 | #else |
| 6809 | pAdapter->dev->open = hdd_mon_open; |
| 6810 | pAdapter->dev->hard_start_xmit = hdd_mon_hard_start_xmit; |
| 6811 | #endif |
| 6812 | hdd_init_tx_rx( pAdapter ); |
| 6813 | set_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags); |
| 6814 | //Set adapter to be used for data tx. It will use either GO or softap. |
| 6815 | pAdapter->sessionCtx.monitor.pAdapterForTx = |
| 6816 | hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_SOFTAP); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6817 | if (NULL == pAdapter->sessionCtx.monitor.pAdapterForTx) |
| 6818 | { |
| 6819 | pAdapter->sessionCtx.monitor.pAdapterForTx = |
| 6820 | hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_P2P_GO); |
| 6821 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6822 | /* This workqueue will be used to transmit management packet over |
| 6823 | * monitor interface. */ |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 6824 | if (NULL == pAdapter->sessionCtx.monitor.pAdapterForTx) { |
| 6825 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s:Failed:hdd_get_adapter",__func__); |
| 6826 | return NULL; |
| 6827 | } |
Madan Mohan Koyyalamudi | 9f40ceb | 2012-10-18 19:22:56 -0700 | [diff] [blame] | 6828 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6829 | INIT_WORK(&pAdapter->sessionCtx.monitor.pAdapterForTx->monTxWorkQueue, |
| 6830 | hdd_mon_tx_work_queue); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6831 | } |
| 6832 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6833 | case WLAN_HDD_FTM: |
| 6834 | { |
| 6835 | pAdapter = hdd_alloc_station_adapter( pHddCtx, macAddr, iface_name ); |
| 6836 | |
| 6837 | if( NULL == pAdapter ) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6838 | { |
| 6839 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 6840 | FL("failed to allocate adapter for session %d"), session_type); |
| 6841 | return NULL; |
| 6842 | } |
| 6843 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6844 | /* Assign NL80211_IFTYPE_STATION as interface type to resolve Kernel Warning |
| 6845 | * message while loading driver in FTM mode. */ |
| 6846 | pAdapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 6847 | pAdapter->device_mode = session_type; |
| 6848 | status = hdd_register_interface( pAdapter, rtnl_held ); |
Madan Mohan Koyyalamudi | f89ac9f | 2013-09-19 16:58:12 +0530 | [diff] [blame] | 6849 | |
| 6850 | hdd_init_tx_rx( pAdapter ); |
| 6851 | |
| 6852 | //Stop the Interface TX queue. |
Padma, Santhosh Kumar | 9dacb5c | 2014-12-17 19:22:56 +0530 | [diff] [blame] | 6853 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues")); |
Madan Mohan Koyyalamudi | f89ac9f | 2013-09-19 16:58:12 +0530 | [diff] [blame] | 6854 | netif_tx_disable(pAdapter->dev); |
| 6855 | netif_carrier_off(pAdapter->dev); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6856 | } |
| 6857 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6858 | default: |
| 6859 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6860 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s Invalid session type %d", |
| 6861 | __func__, session_type); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6862 | VOS_ASSERT(0); |
| 6863 | return NULL; |
| 6864 | } |
| 6865 | } |
| 6866 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6867 | if( VOS_STATUS_SUCCESS == status ) |
| 6868 | { |
| 6869 | //Add it to the hdd's session list. |
| 6870 | pHddAdapterNode = vos_mem_malloc( sizeof( hdd_adapter_list_node_t ) ); |
| 6871 | if( NULL == pHddAdapterNode ) |
| 6872 | { |
| 6873 | status = VOS_STATUS_E_NOMEM; |
| 6874 | } |
| 6875 | else |
| 6876 | { |
| 6877 | pHddAdapterNode->pAdapter = pAdapter; |
| 6878 | status = hdd_add_adapter_back ( pHddCtx, |
| 6879 | pHddAdapterNode ); |
| 6880 | } |
| 6881 | } |
| 6882 | |
| 6883 | if( VOS_STATUS_SUCCESS != status ) |
| 6884 | { |
| 6885 | if( NULL != pAdapter ) |
| 6886 | { |
| 6887 | hdd_cleanup_adapter( pHddCtx, pAdapter, rtnl_held ); |
| 6888 | pAdapter = NULL; |
| 6889 | } |
| 6890 | if( NULL != pHddAdapterNode ) |
| 6891 | { |
| 6892 | vos_mem_free( pHddAdapterNode ); |
| 6893 | } |
| 6894 | |
| 6895 | goto resume_bmps; |
| 6896 | } |
| 6897 | |
| 6898 | if(VOS_STATUS_SUCCESS == status) |
| 6899 | { |
| 6900 | wlan_hdd_set_concurrency_mode(pHddCtx, session_type); |
| 6901 | |
Madan Mohan Koyyalamudi | 96dd30d | 2012-10-05 17:24:51 -0700 | [diff] [blame] | 6902 | //Initialize the WoWL service |
| 6903 | if(!hdd_init_wowl(pAdapter)) |
| 6904 | { |
| 6905 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hdd_init_wowl failed",__func__); |
| 6906 | goto err_free_netdev; |
| 6907 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6908 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6909 | return pAdapter; |
| 6910 | |
| 6911 | err_free_netdev: |
| 6912 | free_netdev(pAdapter->dev); |
| 6913 | wlan_hdd_release_intf_addr( pHddCtx, |
| 6914 | pAdapter->macAddressCurrent.bytes ); |
| 6915 | |
| 6916 | resume_bmps: |
| 6917 | //If bmps disabled enable it |
| 6918 | if(VOS_STATUS_SUCCESS == exitbmpsStatus) |
| 6919 | { |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 6920 | if (pHddCtx->hdd_wlan_suspended) |
| 6921 | { |
| 6922 | hdd_set_pwrparams(pHddCtx); |
| 6923 | } |
| 6924 | hdd_enable_bmps_imps(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6925 | } |
| 6926 | return NULL; |
| 6927 | } |
| 6928 | |
| 6929 | VOS_STATUS hdd_close_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter, |
| 6930 | tANI_U8 rtnl_held ) |
| 6931 | { |
| 6932 | hdd_adapter_list_node_t *pAdapterNode, *pCurrent, *pNext; |
| 6933 | VOS_STATUS status; |
| 6934 | |
| 6935 | status = hdd_get_front_adapter ( pHddCtx, &pCurrent ); |
| 6936 | if( VOS_STATUS_SUCCESS != status ) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6937 | { |
| 6938 | hddLog(VOS_TRACE_LEVEL_WARN,"%s: adapter list empty %d", |
| 6939 | __func__, status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6940 | return status; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6941 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6942 | |
| 6943 | while ( pCurrent->pAdapter != pAdapter ) |
| 6944 | { |
| 6945 | status = hdd_get_next_adapter ( pHddCtx, pCurrent, &pNext ); |
| 6946 | if( VOS_STATUS_SUCCESS != status ) |
| 6947 | break; |
| 6948 | |
| 6949 | pCurrent = pNext; |
| 6950 | } |
| 6951 | pAdapterNode = pCurrent; |
| 6952 | if( VOS_STATUS_SUCCESS == status ) |
| 6953 | { |
| 6954 | wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode); |
| 6955 | hdd_cleanup_adapter( pHddCtx, pAdapterNode->pAdapter, rtnl_held ); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 6956 | |
| 6957 | #ifdef FEATURE_WLAN_TDLS |
| 6958 | |
| 6959 | /* A Mutex Lock is introduced while changing/initializing the mode to |
| 6960 | * protect the concurrent access for the Adapters by TDLS module. |
| 6961 | */ |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 6962 | mutex_lock(&pHddCtx->tdls_lock); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 6963 | #endif |
| 6964 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6965 | hdd_remove_adapter( pHddCtx, pAdapterNode ); |
| 6966 | vos_mem_free( pAdapterNode ); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 6967 | pAdapterNode = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6968 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 6969 | #ifdef FEATURE_WLAN_TDLS |
| 6970 | mutex_unlock(&pHddCtx->tdls_lock); |
| 6971 | #endif |
| 6972 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6973 | |
| 6974 | /* If there is a single session of STA/P2P client, re-enable BMPS */ |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 6975 | if ((!vos_concurrent_open_sessions_running()) && |
| 6976 | ((pHddCtx->no_of_open_sessions[VOS_STA_MODE] >= 1) || |
| 6977 | (pHddCtx->no_of_open_sessions[VOS_P2P_CLIENT_MODE] >= 1))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6978 | { |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 6979 | if (pHddCtx->hdd_wlan_suspended) |
| 6980 | { |
| 6981 | hdd_set_pwrparams(pHddCtx); |
| 6982 | } |
| 6983 | hdd_enable_bmps_imps(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6984 | } |
| 6985 | |
| 6986 | return VOS_STATUS_SUCCESS; |
| 6987 | } |
| 6988 | |
| 6989 | return VOS_STATUS_E_FAILURE; |
| 6990 | } |
| 6991 | |
| 6992 | VOS_STATUS hdd_close_all_adapters( hdd_context_t *pHddCtx ) |
| 6993 | { |
| 6994 | hdd_adapter_list_node_t *pHddAdapterNode; |
| 6995 | VOS_STATUS status; |
| 6996 | |
| 6997 | ENTER(); |
| 6998 | |
| 6999 | do |
| 7000 | { |
| 7001 | status = hdd_remove_front_adapter( pHddCtx, &pHddAdapterNode ); |
| 7002 | if( pHddAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7003 | { |
| 7004 | hdd_cleanup_adapter( pHddCtx, pHddAdapterNode->pAdapter, FALSE ); |
| 7005 | vos_mem_free( pHddAdapterNode ); |
| 7006 | } |
| 7007 | }while( NULL != pHddAdapterNode && VOS_STATUS_E_EMPTY != status ); |
| 7008 | |
| 7009 | EXIT(); |
| 7010 | |
| 7011 | return VOS_STATUS_SUCCESS; |
| 7012 | } |
| 7013 | |
| 7014 | void wlan_hdd_reset_prob_rspies(hdd_adapter_t* pHostapdAdapter) |
| 7015 | { |
| 7016 | v_U8_t addIE[1] = {0}; |
| 7017 | |
| 7018 | if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 7019 | WNI_CFG_PROBE_RSP_ADDNIE_DATA1,(tANI_U8*)addIE, 0, NULL, |
| 7020 | eANI_BOOLEAN_FALSE) ) |
| 7021 | { |
| 7022 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 7023 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7024 | } |
| 7025 | |
| 7026 | if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 7027 | WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL, |
| 7028 | eANI_BOOLEAN_FALSE) ) |
| 7029 | { |
| 7030 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 7031 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7032 | } |
| 7033 | |
| 7034 | if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 7035 | WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL, |
| 7036 | eANI_BOOLEAN_FALSE) ) |
| 7037 | { |
| 7038 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 7039 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7040 | } |
| 7041 | } |
| 7042 | |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 7043 | VOS_STATUS hdd_stop_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter, |
| 7044 | const v_BOOL_t bCloseSession ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7045 | { |
| 7046 | eHalStatus halStatus = eHAL_STATUS_SUCCESS; |
| 7047 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Kaushik, Sushant | 4975a57 | 2014-10-21 16:07:48 +0530 | [diff] [blame] | 7048 | hdd_scaninfo_t *pScanInfo = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7049 | union iwreq_data wrqu; |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 7050 | v_U8_t retry = 0; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7051 | long ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7052 | |
Anand N Sunkad | 26d71b9 | 2014-12-24 18:08:22 +0530 | [diff] [blame] | 7053 | if (pHddCtx->isLogpInProgress) { |
| 7054 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 7055 | "%s:LOGP in Progress. Ignore!!!",__func__); |
| 7056 | return VOS_STATUS_E_FAILURE; |
| 7057 | } |
| 7058 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7059 | ENTER(); |
Vinay Krishna Eranna | f97ef5c | 2014-12-26 17:47:19 +0530 | [diff] [blame] | 7060 | |
Kaushik, Sushant | 4975a57 | 2014-10-21 16:07:48 +0530 | [diff] [blame] | 7061 | pScanInfo = &pHddCtx->scan_info; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7062 | switch(pAdapter->device_mode) |
| 7063 | { |
| 7064 | case WLAN_HDD_INFRA_STATION: |
| 7065 | case WLAN_HDD_P2P_CLIENT: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7066 | case WLAN_HDD_P2P_DEVICE: |
Vinay Krishna Eranna | b09d3e7 | 2014-03-26 21:23:55 +0530 | [diff] [blame] | 7067 | { |
| 7068 | hdd_station_ctx_t *pstation = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 7069 | if( hdd_connIsConnected(pstation) || |
| 7070 | (pstation->conn_info.connState == eConnectionState_Connecting) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7071 | { |
Mahesh A Saptasagar | f5b8eff | 2015-01-31 01:07:07 +0530 | [diff] [blame] | 7072 | #ifdef FEATURE_WLAN_TDLS |
| 7073 | mutex_lock(&pHddCtx->tdls_lock); |
| 7074 | wlan_hdd_tdls_exit(pAdapter); |
| 7075 | mutex_unlock(&pHddCtx->tdls_lock); |
| 7076 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7077 | if (pWextState->roamProfile.BSSType == eCSR_BSS_TYPE_START_IBSS) |
| 7078 | halStatus = sme_RoamDisconnect(pHddCtx->hHal, |
| 7079 | pAdapter->sessionId, |
| 7080 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
| 7081 | else |
| 7082 | halStatus = sme_RoamDisconnect(pHddCtx->hHal, |
| 7083 | pAdapter->sessionId, |
| 7084 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
| 7085 | //success implies disconnect command got queued up successfully |
| 7086 | if(halStatus == eHAL_STATUS_SUCCESS) |
| 7087 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7088 | ret = wait_for_completion_interruptible_timeout( |
| 7089 | &pAdapter->disconnect_comp_var, |
| 7090 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 7091 | if (ret <= 0) |
| 7092 | { |
| 7093 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 7094 | "%s: wait on disconnect_comp_var failed %ld", |
| 7095 | __func__, ret); |
| 7096 | } |
| 7097 | } |
| 7098 | else |
| 7099 | { |
| 7100 | hddLog(LOGE, "%s: failed to post disconnect event to SME", |
| 7101 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7102 | } |
| 7103 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 7104 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 7105 | memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN); |
| 7106 | wireless_send_event(pAdapter->dev, SIOCGIWAP, &wrqu, NULL); |
| 7107 | } |
Vinay Krishna Eranna | b09d3e7 | 2014-03-26 21:23:55 +0530 | [diff] [blame] | 7108 | else if(pstation->conn_info.connState == |
| 7109 | eConnectionState_Disconnecting) |
| 7110 | { |
| 7111 | ret = wait_for_completion_interruptible_timeout( |
| 7112 | &pAdapter->disconnect_comp_var, |
| 7113 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 7114 | if (ret <= 0) |
| 7115 | { |
| 7116 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 7117 | FL("wait on disconnect_comp_var failed %ld"), ret); |
| 7118 | } |
| 7119 | } |
Kaushik, Sushant | 4975a57 | 2014-10-21 16:07:48 +0530 | [diff] [blame] | 7120 | else if(pScanInfo != NULL && pHddCtx->scan_info.mScanPending) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7121 | { |
Kaushik, Sushant | 4975a57 | 2014-10-21 16:07:48 +0530 | [diff] [blame] | 7122 | hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId, |
Srinivas, Dasari | 138af4f | 2014-02-07 11:13:45 +0530 | [diff] [blame] | 7123 | eCSR_SCAN_ABORT_DEFAULT); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7124 | } |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 7125 | if (pAdapter->device_mode != WLAN_HDD_INFRA_STATION) |
| 7126 | { |
| 7127 | while (pAdapter->is_roc_inprogress) |
| 7128 | { |
| 7129 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7130 | "%s: ROC in progress for session %d!!!", |
| 7131 | __func__, pAdapter->sessionId); |
| 7132 | // waiting for ROC to expire |
| 7133 | msleep(500); |
| 7134 | /* In GO present case , if retry exceeds 3, |
| 7135 | it means something went wrong. */ |
| 7136 | if ( retry++ > MAX_WAIT_FOR_ROC_COMPLETION ) |
| 7137 | { |
| 7138 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7139 | "%s: ROC completion is not received.!!!", __func__); |
| 7140 | sme_CancelRemainOnChannel(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 7141 | pAdapter->sessionId); |
| 7142 | wait_for_completion_interruptible_timeout( |
| 7143 | &pAdapter->cancel_rem_on_chan_var, |
| 7144 | msecs_to_jiffies(WAIT_CANCEL_REM_CHAN)); |
| 7145 | break; |
| 7146 | } |
| 7147 | } |
Ganesh Kondabattini | babfb49 | 2014-12-17 20:25:29 +0530 | [diff] [blame] | 7148 | #ifdef WLAN_OPEN_SOURCE |
| 7149 | cancel_delayed_work_sync(&pAdapter->roc_work); |
| 7150 | #endif |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 7151 | } |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 7152 | #ifdef WLAN_NS_OFFLOAD |
Vinay Krishna Eranna | 941360f | 2014-01-16 15:38:22 +0530 | [diff] [blame] | 7153 | #ifdef WLAN_OPEN_SOURCE |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 7154 | cancel_work_sync(&pAdapter->ipv6NotifierWorkQueue); |
| 7155 | #endif |
| 7156 | #endif |
Vinay Krishna Eranna | f97ef5c | 2014-12-26 17:47:19 +0530 | [diff] [blame] | 7157 | |
Vinay Krishna Eranna | 4d055d4 | 2013-12-17 17:02:01 +0530 | [diff] [blame] | 7158 | #ifdef WLAN_OPEN_SOURCE |
| 7159 | cancel_work_sync(&pAdapter->ipv4NotifierWorkQueue); |
| 7160 | #endif |
Vinay Krishna Eranna | f97ef5c | 2014-12-26 17:47:19 +0530 | [diff] [blame] | 7161 | |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 7162 | /* It is possible that the caller of this function does not |
| 7163 | * wish to close the session |
| 7164 | */ |
| 7165 | if (VOS_TRUE == bCloseSession && |
| 7166 | test_bit(SME_SESSION_OPENED, &pAdapter->event_flags)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7167 | { |
| 7168 | INIT_COMPLETION(pAdapter->session_close_comp_var); |
| 7169 | if (eHAL_STATUS_SUCCESS == |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 7170 | sme_CloseSession(pHddCtx->hHal, pAdapter->sessionId, |
| 7171 | hdd_smeCloseSessionCallback, pAdapter)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7172 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7173 | unsigned long ret; |
| 7174 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7175 | //Block on a completion variable. Can't wait forever though. |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7176 | ret = wait_for_completion_timeout( |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 7177 | &pAdapter->session_close_comp_var, |
| 7178 | msecs_to_jiffies(WLAN_WAIT_TIME_SESSIONOPENCLOSE)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7179 | if ( 0 >= ret) |
| 7180 | { |
| 7181 | hddLog(LOGE, "%s: failure waiting for session_close_comp_var %ld", |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 7182 | __func__, ret); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7183 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7184 | } |
| 7185 | } |
Vinay Krishna Eranna | b09d3e7 | 2014-03-26 21:23:55 +0530 | [diff] [blame] | 7186 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7187 | break; |
| 7188 | |
| 7189 | case WLAN_HDD_SOFTAP: |
| 7190 | case WLAN_HDD_P2P_GO: |
| 7191 | //Any softap specific cleanup here... |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 7192 | if (pAdapter->device_mode == WLAN_HDD_P2P_GO) { |
| 7193 | while (pAdapter->is_roc_inprogress) { |
| 7194 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7195 | "%s: ROC in progress for session %d!!!", |
| 7196 | __func__, pAdapter->sessionId); |
| 7197 | msleep(500); |
| 7198 | if ( retry++ > MAX_WAIT_FOR_ROC_COMPLETION ) { |
| 7199 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7200 | "%s: ROC completion is not received.!!!", __func__); |
| 7201 | WLANSAP_CancelRemainOnChannel( |
| 7202 | (WLAN_HDD_GET_CTX(pAdapter))->pvosContext); |
| 7203 | wait_for_completion_interruptible_timeout( |
| 7204 | &pAdapter->cancel_rem_on_chan_var, |
| 7205 | msecs_to_jiffies(WAIT_CANCEL_REM_CHAN)); |
| 7206 | break; |
| 7207 | } |
| 7208 | } |
Ganesh Kondabattini | babfb49 | 2014-12-17 20:25:29 +0530 | [diff] [blame] | 7209 | |
| 7210 | #ifdef WLAN_OPEN_SOURCE |
| 7211 | cancel_delayed_work_sync(&pAdapter->roc_work); |
| 7212 | #endif |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 7213 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7214 | mutex_lock(&pHddCtx->sap_lock); |
| 7215 | if (test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags)) |
| 7216 | { |
| 7217 | VOS_STATUS status; |
| 7218 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 7219 | |
| 7220 | //Stop Bss. |
| 7221 | status = WLANSAP_StopBss(pHddCtx->pvosContext); |
| 7222 | if (VOS_IS_STATUS_SUCCESS(status)) |
| 7223 | { |
| 7224 | hdd_hostapd_state_t *pHostapdState = |
| 7225 | WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 7226 | |
| 7227 | status = vos_wait_single_event(&pHostapdState->vosEvent, 10000); |
| 7228 | |
| 7229 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 7230 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7231 | hddLog(LOGE, "%s: failure waiting for WLANSAP_StopBss %d", |
| 7232 | __func__, status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7233 | } |
| 7234 | } |
| 7235 | else |
| 7236 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7237 | hddLog(LOGE, "%s: failure in WLANSAP_StopBss", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7238 | } |
| 7239 | clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags); |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 7240 | wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7241 | |
| 7242 | if (eHAL_STATUS_FAILURE == |
| 7243 | ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, |
| 7244 | 0, NULL, eANI_BOOLEAN_FALSE)) |
| 7245 | { |
| 7246 | hddLog(LOGE, |
| 7247 | "%s: Failed to set WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7248 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7249 | } |
| 7250 | |
| 7251 | if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal, |
| 7252 | WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL, |
| 7253 | eANI_BOOLEAN_FALSE) ) |
| 7254 | { |
| 7255 | hddLog(LOGE, |
| 7256 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM"); |
| 7257 | } |
| 7258 | |
| 7259 | // Reset WNI_CFG_PROBE_RSP Flags |
| 7260 | wlan_hdd_reset_prob_rspies(pAdapter); |
| 7261 | kfree(pAdapter->sessionCtx.ap.beacon); |
| 7262 | pAdapter->sessionCtx.ap.beacon = NULL; |
| 7263 | } |
| 7264 | mutex_unlock(&pHddCtx->sap_lock); |
| 7265 | break; |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 7266 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7267 | case WLAN_HDD_MONITOR: |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 7268 | #ifdef WLAN_OPEN_SOURCE |
| 7269 | cancel_work_sync(&pAdapter->sessionCtx.monitor.pAdapterForTx->monTxWorkQueue); |
| 7270 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7271 | break; |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 7272 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7273 | default: |
| 7274 | break; |
| 7275 | } |
| 7276 | |
| 7277 | EXIT(); |
| 7278 | return VOS_STATUS_SUCCESS; |
| 7279 | } |
| 7280 | |
| 7281 | VOS_STATUS hdd_stop_all_adapters( hdd_context_t *pHddCtx ) |
| 7282 | { |
| 7283 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7284 | VOS_STATUS status; |
| 7285 | hdd_adapter_t *pAdapter; |
| 7286 | |
| 7287 | ENTER(); |
| 7288 | |
| 7289 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7290 | |
| 7291 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7292 | { |
| 7293 | pAdapter = pAdapterNode->pAdapter; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7294 | |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 7295 | hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7296 | |
| 7297 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7298 | pAdapterNode = pNext; |
| 7299 | } |
| 7300 | |
| 7301 | EXIT(); |
| 7302 | |
| 7303 | return VOS_STATUS_SUCCESS; |
| 7304 | } |
| 7305 | |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 7306 | |
| 7307 | #ifdef FEATURE_WLAN_BATCH_SCAN |
| 7308 | /**--------------------------------------------------------------------------- |
| 7309 | |
| 7310 | \brief hdd_deinit_batch_scan () - This function cleans up batch scan data |
| 7311 | structures |
| 7312 | |
| 7313 | \param - pAdapter Pointer to HDD adapter |
| 7314 | |
| 7315 | \return - None |
| 7316 | |
| 7317 | --------------------------------------------------------------------------*/ |
| 7318 | void hdd_deinit_batch_scan(hdd_adapter_t *pAdapter) |
| 7319 | { |
| 7320 | tHddBatchScanRsp *pNode; |
| 7321 | tHddBatchScanRsp *pPrev; |
| 7322 | |
Siddharth Bhal | b3e9b79 | 2014-02-24 15:14:16 +0530 | [diff] [blame] | 7323 | if (NULL == pAdapter) |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 7324 | { |
Siddharth Bhal | b3e9b79 | 2014-02-24 15:14:16 +0530 | [diff] [blame] | 7325 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 7326 | "%s: Adapter context is Null", __func__); |
| 7327 | return; |
| 7328 | } |
| 7329 | |
| 7330 | pNode = pAdapter->pBatchScanRsp; |
| 7331 | while (pNode) |
| 7332 | { |
| 7333 | pPrev = pNode; |
| 7334 | pNode = pNode->pNext; |
| 7335 | vos_mem_free((v_VOID_t * )pPrev); |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 7336 | } |
| 7337 | |
| 7338 | pAdapter->pBatchScanRsp = NULL; |
| 7339 | pAdapter->numScanList = 0; |
| 7340 | pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STOPPED; |
| 7341 | pAdapter->prev_batch_id = 0; |
| 7342 | |
| 7343 | return; |
| 7344 | } |
| 7345 | #endif |
| 7346 | |
| 7347 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7348 | VOS_STATUS hdd_reset_all_adapters( hdd_context_t *pHddCtx ) |
| 7349 | { |
| 7350 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7351 | VOS_STATUS status; |
| 7352 | hdd_adapter_t *pAdapter; |
| 7353 | |
| 7354 | ENTER(); |
| 7355 | |
| 7356 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7357 | |
| 7358 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7359 | { |
| 7360 | pAdapter = pAdapterNode->pAdapter; |
Padma, Santhosh Kumar | 9dacb5c | 2014-12-17 19:22:56 +0530 | [diff] [blame] | 7361 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7362 | netif_tx_disable(pAdapter->dev); |
| 7363 | netif_carrier_off(pAdapter->dev); |
| 7364 | |
Srinivas Girigowda | 66c05eb | 2013-07-14 13:06:01 -0700 | [diff] [blame] | 7365 | pAdapter->sessionCtx.station.hdd_ReassocScenario = VOS_FALSE; |
| 7366 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7367 | hdd_deinit_tx_rx(pAdapter); |
Agarwal Ashish | 6267caa | 2014-08-06 19:16:21 +0530 | [diff] [blame] | 7368 | |
| 7369 | wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode); |
| 7370 | |
Madan Mohan Koyyalamudi | 8c6dec8 | 2013-09-26 15:56:13 +0530 | [diff] [blame] | 7371 | if (test_bit(WMM_INIT_DONE, &pAdapter->event_flags)) |
| 7372 | { |
| 7373 | hdd_wmm_adapter_close( pAdapter ); |
| 7374 | clear_bit(WMM_INIT_DONE, &pAdapter->event_flags); |
| 7375 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7376 | |
Siddharth Bhal | 2db319d | 2014-12-03 12:37:18 +0530 | [diff] [blame] | 7377 | if (test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags)) |
| 7378 | { |
| 7379 | clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags); |
| 7380 | } |
| 7381 | |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 7382 | #ifdef FEATURE_WLAN_BATCH_SCAN |
| 7383 | if (eHDD_BATCH_SCAN_STATE_STARTED == pAdapter->batchScanState) |
| 7384 | { |
| 7385 | hdd_deinit_batch_scan(pAdapter); |
| 7386 | } |
| 7387 | #endif |
| 7388 | |
Mahesh A Saptasagar | f5b8eff | 2015-01-31 01:07:07 +0530 | [diff] [blame] | 7389 | #ifdef FEATURE_WLAN_TDLS |
| 7390 | mutex_lock(&pHddCtx->tdls_lock); |
| 7391 | wlan_hdd_tdls_exit(pAdapter); |
| 7392 | mutex_unlock(&pHddCtx->tdls_lock); |
| 7393 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7394 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7395 | pAdapterNode = pNext; |
| 7396 | } |
| 7397 | |
| 7398 | EXIT(); |
| 7399 | |
| 7400 | return VOS_STATUS_SUCCESS; |
| 7401 | } |
| 7402 | |
| 7403 | VOS_STATUS hdd_start_all_adapters( hdd_context_t *pHddCtx ) |
| 7404 | { |
| 7405 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7406 | VOS_STATUS status; |
| 7407 | hdd_adapter_t *pAdapter; |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 7408 | eConnectionState connState; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7409 | |
| 7410 | ENTER(); |
| 7411 | |
| 7412 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7413 | |
| 7414 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7415 | { |
| 7416 | pAdapter = pAdapterNode->pAdapter; |
| 7417 | |
Kumar Anand | 82c009f | 2014-05-29 00:29:42 -0700 | [diff] [blame] | 7418 | hdd_wmm_init( pAdapter ); |
| 7419 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7420 | switch(pAdapter->device_mode) |
| 7421 | { |
| 7422 | case WLAN_HDD_INFRA_STATION: |
| 7423 | case WLAN_HDD_P2P_CLIENT: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7424 | case WLAN_HDD_P2P_DEVICE: |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 7425 | |
| 7426 | connState = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState; |
| 7427 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7428 | hdd_init_station_mode(pAdapter); |
| 7429 | /* Open the gates for HDD to receive Wext commands */ |
| 7430 | pAdapter->isLinkUpSvcNeeded = FALSE; |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 7431 | pHddCtx->scan_info.mScanPending = FALSE; |
| 7432 | pHddCtx->scan_info.waitScanResult = FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7433 | |
| 7434 | //Trigger the initial scan |
| 7435 | hdd_wlan_initial_scan(pAdapter); |
| 7436 | |
| 7437 | //Indicate disconnect event to supplicant if associated previously |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 7438 | if (eConnectionState_Associated == connState || |
| 7439 | eConnectionState_IbssConnected == connState ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7440 | { |
| 7441 | union iwreq_data wrqu; |
| 7442 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 7443 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 7444 | memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN); |
| 7445 | wireless_send_event(pAdapter->dev, SIOCGIWAP, &wrqu, NULL); |
Srinivas Girigowda | 66c05eb | 2013-07-14 13:06:01 -0700 | [diff] [blame] | 7446 | pAdapter->sessionCtx.station.hdd_ReassocScenario = VOS_FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7447 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7448 | /* indicate disconnected event to nl80211 */ |
| 7449 | cfg80211_disconnected(pAdapter->dev, WLAN_REASON_UNSPECIFIED, |
| 7450 | NULL, 0, GFP_KERNEL); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7451 | } |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 7452 | else if (eConnectionState_Connecting == connState) |
| 7453 | { |
| 7454 | /* |
| 7455 | * Indicate connect failure to supplicant if we were in the |
| 7456 | * process of connecting |
| 7457 | */ |
| 7458 | cfg80211_connect_result(pAdapter->dev, NULL, |
| 7459 | NULL, 0, NULL, 0, |
| 7460 | WLAN_STATUS_ASSOC_DENIED_UNSPEC, |
| 7461 | GFP_KERNEL); |
| 7462 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7463 | break; |
| 7464 | |
| 7465 | case WLAN_HDD_SOFTAP: |
| 7466 | /* softAP can handle SSR */ |
| 7467 | break; |
| 7468 | |
| 7469 | case WLAN_HDD_P2P_GO: |
Sameer Thalappil | edf0d79 | 2013-08-09 14:31:03 -0700 | [diff] [blame] | 7470 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s [SSR] send stop ap to supplicant", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7471 | __func__); |
Sameer Thalappil | edf0d79 | 2013-08-09 14:31:03 -0700 | [diff] [blame] | 7472 | cfg80211_ap_stopped(pAdapter->dev, GFP_KERNEL); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7473 | break; |
| 7474 | |
| 7475 | case WLAN_HDD_MONITOR: |
| 7476 | /* monitor interface start */ |
| 7477 | break; |
| 7478 | default: |
| 7479 | break; |
| 7480 | } |
| 7481 | |
| 7482 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7483 | pAdapterNode = pNext; |
| 7484 | } |
| 7485 | |
| 7486 | EXIT(); |
| 7487 | |
| 7488 | return VOS_STATUS_SUCCESS; |
| 7489 | } |
| 7490 | |
| 7491 | VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx ) |
| 7492 | { |
| 7493 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7494 | hdd_adapter_t *pAdapter; |
| 7495 | VOS_STATUS status; |
| 7496 | v_U32_t roamId; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7497 | long ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7498 | |
| 7499 | ENTER(); |
| 7500 | |
| 7501 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7502 | |
| 7503 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7504 | { |
| 7505 | pAdapter = pAdapterNode->pAdapter; |
| 7506 | |
| 7507 | if( (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
| 7508 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ) |
| 7509 | { |
| 7510 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 7511 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 7512 | |
Abhishek Singh | f4669da | 2014-05-26 15:07:49 +0530 | [diff] [blame] | 7513 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 7514 | "%s: Set HDD connState to eConnectionState_NotConnected", |
| 7515 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7516 | pHddStaCtx->conn_info.connState = eConnectionState_NotConnected; |
| 7517 | init_completion(&pAdapter->disconnect_comp_var); |
| 7518 | sme_RoamDisconnect(pHddCtx->hHal, pAdapter->sessionId, |
| 7519 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
| 7520 | |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7521 | ret = wait_for_completion_interruptible_timeout( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7522 | &pAdapter->disconnect_comp_var, |
| 7523 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7524 | if (0 >= ret) |
| 7525 | hddLog(LOGE, "%s: failure waiting for disconnect_comp_var %ld", |
| 7526 | __func__, ret); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7527 | |
| 7528 | pWextState->roamProfile.csrPersona = pAdapter->device_mode; |
| 7529 | pHddCtx->isAmpAllowed = VOS_FALSE; |
| 7530 | sme_RoamConnect(pHddCtx->hHal, |
| 7531 | pAdapter->sessionId, &(pWextState->roamProfile), |
| 7532 | &roamId); |
| 7533 | } |
| 7534 | |
| 7535 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7536 | pAdapterNode = pNext; |
| 7537 | } |
| 7538 | |
| 7539 | EXIT(); |
| 7540 | |
| 7541 | return VOS_STATUS_SUCCESS; |
| 7542 | } |
| 7543 | |
Sudhir Sattayappa Kohalli | 90e4c75 | 2013-03-21 14:25:04 -0700 | [diff] [blame] | 7544 | void hdd_dump_concurrency_info(hdd_context_t *pHddCtx) |
| 7545 | { |
| 7546 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7547 | VOS_STATUS status; |
| 7548 | hdd_adapter_t *pAdapter; |
| 7549 | hdd_station_ctx_t *pHddStaCtx; |
| 7550 | hdd_ap_ctx_t *pHddApCtx; |
| 7551 | hdd_hostapd_state_t * pHostapdState; |
| 7552 | tCsrBssid staBssid = { 0 }, p2pBssid = { 0 }, apBssid = { 0 }; |
| 7553 | v_U8_t staChannel = 0, p2pChannel = 0, apChannel = 0; |
| 7554 | const char *p2pMode = "DEV"; |
| 7555 | const char *ccMode = "Standalone"; |
| 7556 | int n; |
| 7557 | |
| 7558 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7559 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7560 | { |
| 7561 | pAdapter = pAdapterNode->pAdapter; |
| 7562 | switch (pAdapter->device_mode) { |
| 7563 | case WLAN_HDD_INFRA_STATION: |
| 7564 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 7565 | if (eConnectionState_Associated == pHddStaCtx->conn_info.connState) { |
| 7566 | staChannel = pHddStaCtx->conn_info.operationChannel; |
| 7567 | memcpy(staBssid, pHddStaCtx->conn_info.bssId, sizeof(staBssid)); |
| 7568 | } |
| 7569 | break; |
| 7570 | case WLAN_HDD_P2P_CLIENT: |
| 7571 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 7572 | if (eConnectionState_Associated == pHddStaCtx->conn_info.connState) { |
| 7573 | p2pChannel = pHddStaCtx->conn_info.operationChannel; |
| 7574 | memcpy(p2pBssid, pHddStaCtx->conn_info.bssId, sizeof(p2pBssid)); |
| 7575 | p2pMode = "CLI"; |
| 7576 | } |
| 7577 | break; |
| 7578 | case WLAN_HDD_P2P_GO: |
| 7579 | pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
| 7580 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 7581 | if (pHostapdState->bssState == BSS_START && pHostapdState->vosStatus==VOS_STATUS_SUCCESS) { |
| 7582 | p2pChannel = pHddApCtx->operatingChannel; |
| 7583 | memcpy(p2pBssid, pAdapter->macAddressCurrent.bytes, sizeof(p2pBssid)); |
| 7584 | } |
| 7585 | p2pMode = "GO"; |
| 7586 | break; |
| 7587 | case WLAN_HDD_SOFTAP: |
| 7588 | pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
| 7589 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 7590 | if (pHostapdState->bssState == BSS_START && pHostapdState->vosStatus==VOS_STATUS_SUCCESS) { |
| 7591 | apChannel = pHddApCtx->operatingChannel; |
| 7592 | memcpy(apBssid, pAdapter->macAddressCurrent.bytes, sizeof(apBssid)); |
| 7593 | } |
| 7594 | break; |
| 7595 | default: |
| 7596 | break; |
| 7597 | } |
| 7598 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7599 | pAdapterNode = pNext; |
| 7600 | } |
| 7601 | if (staChannel > 0 && (apChannel > 0 || p2pChannel > 0)) { |
| 7602 | ccMode = (p2pChannel==staChannel||apChannel==staChannel) ? "SCC" : "MCC"; |
| 7603 | } |
| 7604 | n = pr_info("wlan(%d) " MAC_ADDRESS_STR " %s", |
| 7605 | staChannel, MAC_ADDR_ARRAY(staBssid), ccMode); |
| 7606 | if (p2pChannel > 0) { |
| 7607 | n += pr_info("p2p-%s(%d) " MAC_ADDRESS_STR, |
| 7608 | p2pMode, p2pChannel, MAC_ADDR_ARRAY(p2pBssid)); |
| 7609 | } |
| 7610 | if (apChannel > 0) { |
| 7611 | n += pr_info("AP(%d) " MAC_ADDRESS_STR, |
| 7612 | apChannel, MAC_ADDR_ARRAY(apBssid)); |
| 7613 | } |
| 7614 | |
| 7615 | if (p2pChannel > 0 && apChannel > 0) { |
| 7616 | hddLog(VOS_TRACE_LEVEL_ERROR, "Error concurrent SAP %d and P2P %d which is not support", apChannel, p2pChannel); |
| 7617 | } |
| 7618 | } |
| 7619 | |
Madan Mohan Koyyalamudi | b5da533 | 2012-10-15 17:23:21 -0700 | [diff] [blame] | 7620 | bool hdd_is_ssr_required( void) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7621 | { |
Madan Mohan Koyyalamudi | b5da533 | 2012-10-15 17:23:21 -0700 | [diff] [blame] | 7622 | return (isSsrRequired == HDD_SSR_REQUIRED); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7623 | } |
| 7624 | |
Madan Mohan Koyyalamudi | b5da533 | 2012-10-15 17:23:21 -0700 | [diff] [blame] | 7625 | /* Once SSR is disabled then it cannot be set. */ |
| 7626 | void hdd_set_ssr_required( e_hdd_ssr_required value) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7627 | { |
Madan Mohan Koyyalamudi | b5da533 | 2012-10-15 17:23:21 -0700 | [diff] [blame] | 7628 | if (HDD_SSR_DISABLED == isSsrRequired) |
| 7629 | return; |
| 7630 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7631 | isSsrRequired = value; |
| 7632 | } |
| 7633 | |
| 7634 | VOS_STATUS hdd_get_front_adapter( hdd_context_t *pHddCtx, |
| 7635 | hdd_adapter_list_node_t** ppAdapterNode) |
| 7636 | { |
| 7637 | VOS_STATUS status; |
| 7638 | spin_lock(&pHddCtx->hddAdapters.lock); |
| 7639 | status = hdd_list_peek_front ( &pHddCtx->hddAdapters, |
| 7640 | (hdd_list_node_t**) ppAdapterNode ); |
| 7641 | spin_unlock(&pHddCtx->hddAdapters.lock); |
| 7642 | return status; |
| 7643 | } |
| 7644 | |
| 7645 | VOS_STATUS hdd_get_next_adapter( hdd_context_t *pHddCtx, |
| 7646 | hdd_adapter_list_node_t* pAdapterNode, |
| 7647 | hdd_adapter_list_node_t** pNextAdapterNode) |
| 7648 | { |
| 7649 | VOS_STATUS status; |
| 7650 | spin_lock(&pHddCtx->hddAdapters.lock); |
| 7651 | status = hdd_list_peek_next ( &pHddCtx->hddAdapters, |
| 7652 | (hdd_list_node_t*) pAdapterNode, |
| 7653 | (hdd_list_node_t**)pNextAdapterNode ); |
| 7654 | |
| 7655 | spin_unlock(&pHddCtx->hddAdapters.lock); |
| 7656 | return status; |
| 7657 | } |
| 7658 | |
| 7659 | VOS_STATUS hdd_remove_adapter( hdd_context_t *pHddCtx, |
| 7660 | hdd_adapter_list_node_t* pAdapterNode) |
| 7661 | { |
| 7662 | VOS_STATUS status; |
| 7663 | spin_lock(&pHddCtx->hddAdapters.lock); |
| 7664 | status = hdd_list_remove_node ( &pHddCtx->hddAdapters, |
| 7665 | &pAdapterNode->node ); |
| 7666 | spin_unlock(&pHddCtx->hddAdapters.lock); |
| 7667 | return status; |
| 7668 | } |
| 7669 | |
| 7670 | VOS_STATUS hdd_remove_front_adapter( hdd_context_t *pHddCtx, |
| 7671 | hdd_adapter_list_node_t** ppAdapterNode) |
| 7672 | { |
| 7673 | VOS_STATUS status; |
| 7674 | spin_lock(&pHddCtx->hddAdapters.lock); |
| 7675 | status = hdd_list_remove_front( &pHddCtx->hddAdapters, |
| 7676 | (hdd_list_node_t**) ppAdapterNode ); |
| 7677 | spin_unlock(&pHddCtx->hddAdapters.lock); |
| 7678 | return status; |
| 7679 | } |
| 7680 | |
| 7681 | VOS_STATUS hdd_add_adapter_back( hdd_context_t *pHddCtx, |
| 7682 | hdd_adapter_list_node_t* pAdapterNode) |
| 7683 | { |
| 7684 | VOS_STATUS status; |
| 7685 | spin_lock(&pHddCtx->hddAdapters.lock); |
| 7686 | status = hdd_list_insert_back ( &pHddCtx->hddAdapters, |
| 7687 | (hdd_list_node_t*) pAdapterNode ); |
| 7688 | spin_unlock(&pHddCtx->hddAdapters.lock); |
| 7689 | return status; |
| 7690 | } |
| 7691 | |
| 7692 | VOS_STATUS hdd_add_adapter_front( hdd_context_t *pHddCtx, |
| 7693 | hdd_adapter_list_node_t* pAdapterNode) |
| 7694 | { |
| 7695 | VOS_STATUS status; |
| 7696 | spin_lock(&pHddCtx->hddAdapters.lock); |
| 7697 | status = hdd_list_insert_front ( &pHddCtx->hddAdapters, |
| 7698 | (hdd_list_node_t*) pAdapterNode ); |
| 7699 | spin_unlock(&pHddCtx->hddAdapters.lock); |
| 7700 | return status; |
| 7701 | } |
| 7702 | |
| 7703 | hdd_adapter_t * hdd_get_adapter_by_macaddr( hdd_context_t *pHddCtx, |
| 7704 | tSirMacAddr macAddr ) |
| 7705 | { |
| 7706 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7707 | hdd_adapter_t *pAdapter; |
| 7708 | VOS_STATUS status; |
| 7709 | |
| 7710 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7711 | |
| 7712 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7713 | { |
| 7714 | pAdapter = pAdapterNode->pAdapter; |
| 7715 | |
| 7716 | if( pAdapter && vos_mem_compare( pAdapter->macAddressCurrent.bytes, |
| 7717 | macAddr, sizeof(tSirMacAddr) ) ) |
| 7718 | { |
| 7719 | return pAdapter; |
| 7720 | } |
| 7721 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7722 | pAdapterNode = pNext; |
| 7723 | } |
| 7724 | |
| 7725 | return NULL; |
| 7726 | |
| 7727 | } |
| 7728 | |
| 7729 | hdd_adapter_t * hdd_get_adapter_by_name( hdd_context_t *pHddCtx, tANI_U8 *name ) |
| 7730 | { |
| 7731 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7732 | hdd_adapter_t *pAdapter; |
| 7733 | VOS_STATUS status; |
| 7734 | |
| 7735 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7736 | |
| 7737 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7738 | { |
| 7739 | pAdapter = pAdapterNode->pAdapter; |
| 7740 | |
| 7741 | if( pAdapter && !strncmp( pAdapter->dev->name, (const char *)name, |
| 7742 | IFNAMSIZ ) ) |
| 7743 | { |
| 7744 | return pAdapter; |
| 7745 | } |
| 7746 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7747 | pAdapterNode = pNext; |
| 7748 | } |
| 7749 | |
| 7750 | return NULL; |
| 7751 | |
| 7752 | } |
| 7753 | |
| 7754 | hdd_adapter_t * hdd_get_adapter( hdd_context_t *pHddCtx, device_mode_t mode ) |
| 7755 | { |
| 7756 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7757 | hdd_adapter_t *pAdapter; |
| 7758 | VOS_STATUS status; |
| 7759 | |
| 7760 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7761 | |
| 7762 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7763 | { |
| 7764 | pAdapter = pAdapterNode->pAdapter; |
| 7765 | |
| 7766 | if( pAdapter && (mode == pAdapter->device_mode) ) |
| 7767 | { |
| 7768 | return pAdapter; |
| 7769 | } |
| 7770 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7771 | pAdapterNode = pNext; |
| 7772 | } |
| 7773 | |
| 7774 | return NULL; |
| 7775 | |
| 7776 | } |
| 7777 | |
| 7778 | //Remove this function later |
| 7779 | hdd_adapter_t * hdd_get_mon_adapter( hdd_context_t *pHddCtx ) |
| 7780 | { |
| 7781 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7782 | hdd_adapter_t *pAdapter; |
| 7783 | VOS_STATUS status; |
| 7784 | |
| 7785 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7786 | |
| 7787 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7788 | { |
| 7789 | pAdapter = pAdapterNode->pAdapter; |
| 7790 | |
| 7791 | if( pAdapter && WLAN_HDD_MONITOR == pAdapter->device_mode ) |
| 7792 | { |
| 7793 | return pAdapter; |
| 7794 | } |
| 7795 | |
| 7796 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7797 | pAdapterNode = pNext; |
| 7798 | } |
| 7799 | |
| 7800 | return NULL; |
| 7801 | |
| 7802 | } |
| 7803 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7804 | /**--------------------------------------------------------------------------- |
| 7805 | |
| 7806 | \brief hdd_set_monitor_tx_adapter() - |
| 7807 | |
| 7808 | This API initializes the adapter to be used while transmitting on monitor |
| 7809 | adapter. |
| 7810 | |
| 7811 | \param - pHddCtx - Pointer to the HDD context. |
| 7812 | pAdapter - Adapter that will used for TX. This can be NULL. |
| 7813 | \return - None. |
| 7814 | --------------------------------------------------------------------------*/ |
| 7815 | void wlan_hdd_set_monitor_tx_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter ) |
| 7816 | { |
| 7817 | hdd_adapter_t *pMonAdapter; |
| 7818 | |
| 7819 | pMonAdapter = hdd_get_adapter( pHddCtx, WLAN_HDD_MONITOR ); |
| 7820 | |
| 7821 | if( NULL != pMonAdapter ) |
| 7822 | { |
| 7823 | pMonAdapter->sessionCtx.monitor.pAdapterForTx = pAdapter; |
| 7824 | } |
| 7825 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7826 | /**--------------------------------------------------------------------------- |
| 7827 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 7828 | \brief hdd_get_operating_channel() - |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7829 | |
| 7830 | This API returns the operating channel of the requested device mode |
| 7831 | |
| 7832 | \param - pHddCtx - Pointer to the HDD context. |
| 7833 | - mode - Device mode for which operating channel is required |
| 7834 | suported modes - WLAN_HDD_INFRA_STATION, WLAN_HDD_P2P_CLIENT |
| 7835 | WLAN_HDD_SOFTAP, WLAN_HDD_P2P_GO. |
| 7836 | \return - channel number. "0" id the requested device is not found OR it is not connected. |
| 7837 | --------------------------------------------------------------------------*/ |
| 7838 | v_U8_t hdd_get_operating_channel( hdd_context_t *pHddCtx, device_mode_t mode ) |
| 7839 | { |
| 7840 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7841 | VOS_STATUS status; |
| 7842 | hdd_adapter_t *pAdapter; |
| 7843 | v_U8_t operatingChannel = 0; |
| 7844 | |
| 7845 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7846 | |
| 7847 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7848 | { |
| 7849 | pAdapter = pAdapterNode->pAdapter; |
| 7850 | |
| 7851 | if( mode == pAdapter->device_mode ) |
| 7852 | { |
| 7853 | switch(pAdapter->device_mode) |
| 7854 | { |
| 7855 | case WLAN_HDD_INFRA_STATION: |
| 7856 | case WLAN_HDD_P2P_CLIENT: |
| 7857 | if( hdd_connIsConnected( WLAN_HDD_GET_STATION_CTX_PTR( pAdapter )) ) |
| 7858 | operatingChannel = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.operationChannel; |
| 7859 | break; |
| 7860 | case WLAN_HDD_SOFTAP: |
| 7861 | case WLAN_HDD_P2P_GO: |
| 7862 | /*softap connection info */ |
| 7863 | if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags)) |
| 7864 | operatingChannel = (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->operatingChannel; |
| 7865 | break; |
| 7866 | default: |
| 7867 | break; |
| 7868 | } |
| 7869 | |
| 7870 | break; //Found the device of interest. break the loop |
| 7871 | } |
| 7872 | |
| 7873 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7874 | pAdapterNode = pNext; |
| 7875 | } |
| 7876 | return operatingChannel; |
| 7877 | } |
| 7878 | |
| 7879 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 7880 | /**--------------------------------------------------------------------------- |
| 7881 | |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 7882 | \brief __hdd_set_multicast_list() - |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7883 | |
| 7884 | This used to set the multicast address list. |
| 7885 | |
| 7886 | \param - dev - Pointer to the WLAN device. |
| 7887 | - skb - Pointer to OS packet (sk_buff). |
| 7888 | \return - success/fail |
| 7889 | |
| 7890 | --------------------------------------------------------------------------*/ |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 7891 | static void __hdd_set_multicast_list(struct net_device *dev) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7892 | { |
| 7893 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7894 | int mc_count; |
| 7895 | int i = 0; |
| 7896 | struct netdev_hw_addr *ha; |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 7897 | |
| 7898 | if (NULL == pAdapter) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7899 | { |
| 7900 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 7901 | "%s: Adapter context is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7902 | return; |
| 7903 | } |
| 7904 | |
| 7905 | if (dev->flags & IFF_ALLMULTI) |
| 7906 | { |
| 7907 | hddLog(VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7908 | "%s: allow all multicast frames", __func__); |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 7909 | pAdapter->mc_addr_list.mc_cnt = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7910 | } |
| 7911 | else |
| 7912 | { |
| 7913 | mc_count = netdev_mc_count(dev); |
| 7914 | hddLog(VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7915 | "%s: mc_count = %u", __func__, mc_count); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7916 | if (mc_count > WLAN_HDD_MAX_MC_ADDR_LIST) |
| 7917 | { |
| 7918 | hddLog(VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7919 | "%s: No free filter available; allow all multicast frames", __func__); |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 7920 | pAdapter->mc_addr_list.mc_cnt = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7921 | return; |
| 7922 | } |
| 7923 | |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 7924 | pAdapter->mc_addr_list.mc_cnt = mc_count; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7925 | |
| 7926 | netdev_for_each_mc_addr(ha, dev) { |
| 7927 | if (i == mc_count) |
| 7928 | break; |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 7929 | memset(&(pAdapter->mc_addr_list.addr[i][0]), 0, ETH_ALEN); |
| 7930 | memcpy(&(pAdapter->mc_addr_list.addr[i][0]), ha->addr, ETH_ALEN); |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 7931 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: mlist[%d] = "MAC_ADDRESS_STR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7932 | __func__, i, |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 7933 | MAC_ADDR_ARRAY(pAdapter->mc_addr_list.addr[i])); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7934 | i++; |
| 7935 | } |
| 7936 | } |
| 7937 | return; |
| 7938 | } |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 7939 | |
| 7940 | static void hdd_set_multicast_list(struct net_device *dev) |
| 7941 | { |
| 7942 | vos_ssr_protect(__func__); |
| 7943 | __hdd_set_multicast_list(dev); |
| 7944 | vos_ssr_unprotect(__func__); |
| 7945 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7946 | #endif |
| 7947 | |
| 7948 | /**--------------------------------------------------------------------------- |
| 7949 | |
| 7950 | \brief hdd_select_queue() - |
| 7951 | |
| 7952 | This function is registered with the Linux OS for network |
| 7953 | core to decide which queue to use first. |
| 7954 | |
| 7955 | \param - dev - Pointer to the WLAN device. |
| 7956 | - skb - Pointer to OS packet (sk_buff). |
| 7957 | \return - ac, Queue Index/access category corresponding to UP in IP header |
| 7958 | |
| 7959 | --------------------------------------------------------------------------*/ |
| 7960 | v_U16_t hdd_select_queue(struct net_device *dev, |
| 7961 | struct sk_buff *skb) |
| 7962 | { |
| 7963 | return hdd_wmm_select_queue(dev, skb); |
| 7964 | } |
| 7965 | |
| 7966 | |
| 7967 | /**--------------------------------------------------------------------------- |
| 7968 | |
| 7969 | \brief hdd_wlan_initial_scan() - |
| 7970 | |
| 7971 | This function triggers the initial scan |
| 7972 | |
| 7973 | \param - pAdapter - Pointer to the HDD adapter. |
| 7974 | |
| 7975 | --------------------------------------------------------------------------*/ |
| 7976 | void hdd_wlan_initial_scan(hdd_adapter_t *pAdapter) |
| 7977 | { |
| 7978 | tCsrScanRequest scanReq; |
| 7979 | tCsrChannelInfo channelInfo; |
| 7980 | eHalStatus halStatus; |
Jeff Johnson | 0279779 | 2013-10-26 19:17:13 -0700 | [diff] [blame] | 7981 | tANI_U32 scanId; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7982 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 7983 | |
| 7984 | vos_mem_zero(&scanReq, sizeof(tCsrScanRequest)); |
| 7985 | vos_mem_set(&scanReq.bssid, sizeof(tCsrBssid), 0xff); |
| 7986 | scanReq.BSSType = eCSR_BSS_TYPE_ANY; |
| 7987 | |
| 7988 | if(sme_Is11dSupported(pHddCtx->hHal)) |
| 7989 | { |
| 7990 | halStatus = sme_ScanGetBaseChannels( pHddCtx->hHal, &channelInfo ); |
| 7991 | if ( HAL_STATUS_SUCCESS( halStatus ) ) |
| 7992 | { |
| 7993 | scanReq.ChannelInfo.ChannelList = vos_mem_malloc(channelInfo.numOfChannels); |
| 7994 | if( !scanReq.ChannelInfo.ChannelList ) |
| 7995 | { |
| 7996 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s kmalloc failed", __func__); |
| 7997 | vos_mem_free(channelInfo.ChannelList); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 7998 | channelInfo.ChannelList = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7999 | return; |
| 8000 | } |
| 8001 | vos_mem_copy(scanReq.ChannelInfo.ChannelList, channelInfo.ChannelList, |
| 8002 | channelInfo.numOfChannels); |
| 8003 | scanReq.ChannelInfo.numOfChannels = channelInfo.numOfChannels; |
| 8004 | vos_mem_free(channelInfo.ChannelList); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 8005 | channelInfo.ChannelList = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8006 | } |
| 8007 | |
| 8008 | scanReq.scanType = eSIR_PASSIVE_SCAN; |
| 8009 | scanReq.requestType = eCSR_SCAN_REQUEST_11D_SCAN; |
| 8010 | scanReq.maxChnTime = pHddCtx->cfg_ini->nPassiveMaxChnTime; |
| 8011 | scanReq.minChnTime = pHddCtx->cfg_ini->nPassiveMinChnTime; |
| 8012 | } |
| 8013 | else |
| 8014 | { |
| 8015 | scanReq.scanType = eSIR_ACTIVE_SCAN; |
| 8016 | scanReq.requestType = eCSR_SCAN_REQUEST_FULL_SCAN; |
| 8017 | scanReq.maxChnTime = pHddCtx->cfg_ini->nActiveMaxChnTime; |
| 8018 | scanReq.minChnTime = pHddCtx->cfg_ini->nActiveMinChnTime; |
| 8019 | } |
| 8020 | |
| 8021 | halStatus = sme_ScanRequest(pHddCtx->hHal, pAdapter->sessionId, &scanReq, &scanId, NULL, NULL); |
| 8022 | if ( !HAL_STATUS_SUCCESS( halStatus ) ) |
| 8023 | { |
| 8024 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_ScanRequest failed status code %d", |
| 8025 | __func__, halStatus ); |
| 8026 | } |
| 8027 | |
| 8028 | if(sme_Is11dSupported(pHddCtx->hHal)) |
| 8029 | vos_mem_free(scanReq.ChannelInfo.ChannelList); |
| 8030 | } |
| 8031 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8032 | /**--------------------------------------------------------------------------- |
| 8033 | |
| 8034 | \brief hdd_full_power_callback() - HDD full power callback function |
| 8035 | |
| 8036 | This is the function invoked by SME to inform the result of a full power |
| 8037 | request issued by HDD |
| 8038 | |
| 8039 | \param - callbackcontext - Pointer to cookie |
| 8040 | \param - status - result of request |
| 8041 | |
| 8042 | \return - None |
| 8043 | |
| 8044 | --------------------------------------------------------------------------*/ |
| 8045 | static void hdd_full_power_callback(void *callbackContext, eHalStatus status) |
| 8046 | { |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 8047 | struct statsContext *pContext = callbackContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8048 | |
| 8049 | hddLog(VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 8050 | "%s: context = %p, status = %d", __func__, pContext, status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8051 | |
| 8052 | if (NULL == callbackContext) |
| 8053 | { |
| 8054 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8055 | "%s: Bad param, context [%p]", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 8056 | __func__, callbackContext); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8057 | return; |
| 8058 | } |
| 8059 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 8060 | /* there is a race condition that exists between this callback |
| 8061 | function and the caller since the caller could time out either |
| 8062 | before or while this code is executing. we use a spinlock to |
| 8063 | serialize these actions */ |
| 8064 | spin_lock(&hdd_context_lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8065 | |
| 8066 | if (POWER_CONTEXT_MAGIC != pContext->magic) |
| 8067 | { |
| 8068 | /* the caller presumably timed out so there is nothing we can do */ |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 8069 | spin_unlock(&hdd_context_lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8070 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 8071 | "%s: Invalid context, magic [%08x]", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 8072 | __func__, pContext->magic); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8073 | return; |
| 8074 | } |
| 8075 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 8076 | /* context is valid so caller is still waiting */ |
| 8077 | |
| 8078 | /* paranoia: invalidate the magic */ |
| 8079 | pContext->magic = 0; |
| 8080 | |
| 8081 | /* notify the caller */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8082 | complete(&pContext->completion); |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 8083 | |
| 8084 | /* serialization is complete */ |
| 8085 | spin_unlock(&hdd_context_lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8086 | } |
| 8087 | |
| 8088 | /**--------------------------------------------------------------------------- |
| 8089 | |
| 8090 | \brief hdd_wlan_exit() - HDD WLAN exit function |
| 8091 | |
| 8092 | This is the driver exit point (invoked during rmmod) |
| 8093 | |
| 8094 | \param - pHddCtx - Pointer to the HDD Context |
| 8095 | |
| 8096 | \return - None |
| 8097 | |
| 8098 | --------------------------------------------------------------------------*/ |
| 8099 | void hdd_wlan_exit(hdd_context_t *pHddCtx) |
| 8100 | { |
| 8101 | eHalStatus halStatus; |
| 8102 | v_CONTEXT_t pVosContext = pHddCtx->pvosContext; |
| 8103 | VOS_STATUS vosStatus; |
Gopichand Nakkala | 66923aa | 2013-03-06 23:17:24 +0530 | [diff] [blame] | 8104 | struct wiphy *wiphy = pHddCtx->wiphy; |
Mingcheng Zhu | 87f22fc | 2014-01-30 19:23:32 -0800 | [diff] [blame] | 8105 | hdd_adapter_t* pAdapter = NULL; |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 8106 | struct statsContext powerContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8107 | long lrc; |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 8108 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8109 | |
| 8110 | ENTER(); |
| 8111 | |
Vinay Krishna Eranna | f97ef5c | 2014-12-26 17:47:19 +0530 | [diff] [blame] | 8112 | #ifdef WLAN_NS_OFFLOAD |
| 8113 | hddLog(LOGE, FL("Unregister IPv6 notifier")); |
| 8114 | unregister_inet6addr_notifier(&pHddCtx->ipv6_notifier); |
| 8115 | #endif |
| 8116 | hddLog(LOGE, FL("Unregister IPv4 notifier")); |
| 8117 | unregister_inetaddr_notifier(&pHddCtx->ipv4_notifier); |
| 8118 | |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 8119 | if (VOS_FTM_MODE != hdd_get_conparam()) |
| 8120 | { |
| 8121 | // Unloading, restart logic is no more required. |
| 8122 | wlan_hdd_restart_deinit(pHddCtx); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8123 | |
Agarwal Ashish | b20e0ff | 2014-12-17 22:50:19 +0530 | [diff] [blame] | 8124 | #ifdef FEATURE_WLAN_TDLS |
| 8125 | /* At the time of driver unloading; if tdls connection is present; |
| 8126 | * hdd_rx_packet_cbk calls wlan_hdd_tdls_find_peer. |
| 8127 | * wlan_hdd_tdls_find_peer always checks for valid context; |
| 8128 | * as load/unload in progress there can be a race condition. |
| 8129 | * hdd_rx_packet_cbk calls wlan_hdd_tdls_find_peer only |
| 8130 | * when tdls state is enabled. |
| 8131 | * As soon as driver set load/unload flag; tdls flag also needs |
| 8132 | * to be disabled so that hdd_rx_packet_cbk won't call |
| 8133 | * wlan_hdd_tdls_find_peer. |
| 8134 | */ |
| 8135 | wlan_hdd_tdls_set_mode(pHddCtx, eTDLS_SUPPORT_DISABLED, FALSE); |
| 8136 | #endif |
| 8137 | |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 8138 | vosStatus = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 8139 | while (NULL != pAdapterNode && VOS_STATUS_E_EMPTY != vosStatus) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8140 | { |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 8141 | pAdapter = pAdapterNode->pAdapter; |
| 8142 | if (NULL != pAdapter) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8143 | { |
Agarwal Ashish | 9ffa5b9 | 2014-11-18 21:07:02 +0530 | [diff] [blame] | 8144 | /* Disable TX on the interface, after this hard_start_xmit() will |
| 8145 | * not be called on that interface |
| 8146 | */ |
Padma, Santhosh Kumar | 9dacb5c | 2014-12-17 19:22:56 +0530 | [diff] [blame] | 8147 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues")); |
Agarwal Ashish | 9ffa5b9 | 2014-11-18 21:07:02 +0530 | [diff] [blame] | 8148 | netif_tx_disable(pAdapter->dev); |
| 8149 | |
| 8150 | /* Mark the interface status as "down" for outside world */ |
| 8151 | netif_carrier_off(pAdapter->dev); |
| 8152 | |
| 8153 | /* DeInit the adapter. This ensures that all data packets |
| 8154 | * are freed. |
| 8155 | */ |
Mahesh A Saptasagar | 02e36e8 | 2015-01-14 20:39:19 +0530 | [diff] [blame] | 8156 | #ifdef FEATURE_WLAN_TDLS |
| 8157 | mutex_lock(&pHddCtx->tdls_lock); |
| 8158 | #endif |
c_hpothu | 002231a | 2015-02-05 14:58:51 +0530 | [diff] [blame] | 8159 | hdd_deinit_adapter(pHddCtx, pAdapter, FALSE); |
Mahesh A Saptasagar | 02e36e8 | 2015-01-14 20:39:19 +0530 | [diff] [blame] | 8160 | #ifdef FEATURE_WLAN_TDLS |
| 8161 | mutex_unlock(&pHddCtx->tdls_lock); |
| 8162 | #endif |
Agarwal Ashish | 9ffa5b9 | 2014-11-18 21:07:02 +0530 | [diff] [blame] | 8163 | |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 8164 | if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode || |
| 8165 | WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) |
| 8166 | { |
| 8167 | wlan_hdd_cfg80211_deregister_frames(pAdapter); |
| 8168 | hdd_UnregisterWext(pAdapter->dev); |
| 8169 | } |
Kaushik, Sushant | 4975a57 | 2014-10-21 16:07:48 +0530 | [diff] [blame] | 8170 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8171 | } |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 8172 | vosStatus = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 8173 | pAdapterNode = pNext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8174 | } |
Kaushik, Sushant | 4975a57 | 2014-10-21 16:07:48 +0530 | [diff] [blame] | 8175 | // Cancel any outstanding scan requests. We are about to close all |
| 8176 | // of our adapters, but an adapter structure is what SME passes back |
| 8177 | // to our callback function. Hence if there are any outstanding scan |
| 8178 | // requests then there is a race condition between when the adapter |
| 8179 | // is closed and when the callback is invoked.We try to resolve that |
| 8180 | // race condition here by canceling any outstanding scans before we |
| 8181 | // close the adapters. |
| 8182 | // Note that the scans may be cancelled in an asynchronous manner, |
| 8183 | // so ideally there needs to be some kind of synchronization. Rather |
| 8184 | // than introduce a new synchronization here, we will utilize the |
| 8185 | // fact that we are about to Request Full Power, and since that is |
| 8186 | // synchronized, the expectation is that by the time Request Full |
| 8187 | // Power has completed all scans will be cancelled. |
| 8188 | if (pHddCtx->scan_info.mScanPending) |
| 8189 | { |
Hema Aparna Medicharla | f05f6cd | 2015-01-21 14:44:19 +0530 | [diff] [blame] | 8190 | if(NULL != pAdapter) |
| 8191 | { |
| 8192 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 8193 | FL("abort scan mode: %d sessionId: %d"), |
| 8194 | pAdapter->device_mode, |
| 8195 | pAdapter->sessionId); |
| 8196 | } |
| 8197 | hdd_abort_mac_scan(pHddCtx, |
| 8198 | pHddCtx->scan_info.sessionId, |
| 8199 | eCSR_SCAN_ABORT_DEFAULT); |
Kaushik, Sushant | 4975a57 | 2014-10-21 16:07:48 +0530 | [diff] [blame] | 8200 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8201 | } |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 8202 | else |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 8203 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8204 | hddLog(VOS_TRACE_LEVEL_INFO,"%s: FTM MODE",__func__); |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 8205 | wlan_hdd_ftm_close(pHddCtx); |
| 8206 | goto free_hdd_ctx; |
| 8207 | } |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8208 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8209 | /* DeRegister with platform driver as client for Suspend/Resume */ |
| 8210 | vosStatus = hddDeregisterPmOps(pHddCtx); |
| 8211 | if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) ) |
| 8212 | { |
| 8213 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddDeregisterPmOps failed",__func__); |
| 8214 | VOS_ASSERT(0); |
| 8215 | } |
| 8216 | |
| 8217 | vosStatus = hddDevTmUnregisterNotifyCallback(pHddCtx); |
| 8218 | if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) ) |
| 8219 | { |
| 8220 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddDevTmUnregisterNotifyCallback failed",__func__); |
| 8221 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8222 | |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 8223 | //Stop the traffic monitor timer |
| 8224 | if ( VOS_TIMER_STATE_RUNNING == |
| 8225 | vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)) |
| 8226 | { |
| 8227 | vos_timer_stop(&pHddCtx->tx_rx_trafficTmr); |
| 8228 | } |
| 8229 | |
| 8230 | // Destroy the traffic monitor timer |
| 8231 | if (!VOS_IS_STATUS_SUCCESS(vos_timer_destroy( |
| 8232 | &pHddCtx->tx_rx_trafficTmr))) |
| 8233 | { |
| 8234 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8235 | "%s: Cannot deallocate Traffic monitor timer", __func__); |
| 8236 | } |
| 8237 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8238 | //Disable IMPS/BMPS as we do not want the device to enter any power |
| 8239 | //save mode during shutdown |
| 8240 | sme_DisablePowerSave(pHddCtx->hHal, ePMC_IDLE_MODE_POWER_SAVE); |
| 8241 | sme_DisablePowerSave(pHddCtx->hHal, ePMC_BEACON_MODE_POWER_SAVE); |
| 8242 | sme_DisablePowerSave(pHddCtx->hHal, ePMC_UAPSD_MODE_POWER_SAVE); |
| 8243 | |
| 8244 | //Ensure that device is in full power as we will touch H/W during vos_Stop |
| 8245 | init_completion(&powerContext.completion); |
| 8246 | powerContext.magic = POWER_CONTEXT_MAGIC; |
| 8247 | |
| 8248 | halStatus = sme_RequestFullPower(pHddCtx->hHal, hdd_full_power_callback, |
| 8249 | &powerContext, eSME_FULL_PWR_NEEDED_BY_HDD); |
| 8250 | |
| 8251 | if (eHAL_STATUS_SUCCESS != halStatus) |
| 8252 | { |
| 8253 | if (eHAL_STATUS_PMC_PENDING == halStatus) |
| 8254 | { |
| 8255 | /* request was sent -- wait for the response */ |
| 8256 | lrc = wait_for_completion_interruptible_timeout( |
| 8257 | &powerContext.completion, |
| 8258 | msecs_to_jiffies(WLAN_WAIT_TIME_POWER)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8259 | if (lrc <= 0) |
| 8260 | { |
| 8261 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s while requesting full power", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 8262 | __func__, (0 == lrc) ? "timeout" : "interrupt"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8263 | } |
| 8264 | } |
| 8265 | else |
| 8266 | { |
| 8267 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8268 | "%s: Request for Full Power failed, status %d", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 8269 | __func__, halStatus); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8270 | /* continue -- need to clean up as much as possible */ |
| 8271 | } |
| 8272 | } |
| 8273 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 8274 | /* either we never sent a request, we sent a request and received a |
| 8275 | response or we sent a request and timed out. if we never sent a |
| 8276 | request or if we sent a request and got a response, we want to |
| 8277 | clear the magic out of paranoia. if we timed out there is a |
| 8278 | race condition such that the callback function could be |
| 8279 | executing at the same time we are. of primary concern is if the |
| 8280 | callback function had already verified the "magic" but had not |
| 8281 | yet set the completion variable when a timeout occurred. we |
| 8282 | serialize these activities by invalidating the magic while |
| 8283 | holding a shared spinlock which will cause us to block if the |
| 8284 | callback is currently executing */ |
| 8285 | spin_lock(&hdd_context_lock); |
| 8286 | powerContext.magic = 0; |
| 8287 | spin_unlock(&hdd_context_lock); |
| 8288 | |
Yue Ma | 0d4891e | 2013-08-06 17:01:45 -0700 | [diff] [blame] | 8289 | hdd_debugfs_exit(pHddCtx); |
| 8290 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8291 | // Unregister the Net Device Notifier |
| 8292 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 8293 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8294 | hdd_stop_all_adapters( pHddCtx ); |
| 8295 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8296 | #ifdef WLAN_BTAMP_FEATURE |
| 8297 | vosStatus = WLANBAP_Stop(pVosContext); |
| 8298 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) |
| 8299 | { |
| 8300 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 8301 | "%s: Failed to stop BAP",__func__); |
| 8302 | } |
| 8303 | #endif //WLAN_BTAMP_FEATURE |
| 8304 | |
| 8305 | //Stop all the modules |
| 8306 | vosStatus = vos_stop( pVosContext ); |
| 8307 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) |
| 8308 | { |
| 8309 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 8310 | "%s: Failed to stop VOSS",__func__); |
| 8311 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) ); |
| 8312 | } |
| 8313 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8314 | //This requires pMac access, Call this before vos_close(). |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8315 | hdd_unregister_mcast_bcast_filter(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8316 | |
| 8317 | //Close the scheduler before calling vos_close to make sure no thread is |
| 8318 | // scheduled after the each module close is called i.e after all the data |
| 8319 | // structures are freed. |
| 8320 | vosStatus = vos_sched_close( pVosContext ); |
| 8321 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) { |
| 8322 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, |
| 8323 | "%s: Failed to close VOSS Scheduler",__func__); |
| 8324 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) ); |
| 8325 | } |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 8326 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8327 | #ifdef WLAN_FEATURE_HOLD_RX_WAKELOCK |
| 8328 | /* Destroy the wake lock */ |
| 8329 | wake_lock_destroy(&pHddCtx->rx_wake_lock); |
| 8330 | #endif |
Madan Mohan Koyyalamudi | 69fc3ad | 2012-11-28 16:04:56 -0800 | [diff] [blame] | 8331 | /* Destroy the wake lock */ |
| 8332 | wake_lock_destroy(&pHddCtx->sap_wake_lock); |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 8333 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8334 | |
Mihir Shete | 7a24b5f | 2013-12-21 12:18:31 +0530 | [diff] [blame] | 8335 | #ifdef CONFIG_ENABLE_LINUX_REG |
| 8336 | vosStatus = vos_nv_close(); |
| 8337 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) |
| 8338 | { |
| 8339 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 8340 | "%s: Failed to close NV", __func__); |
| 8341 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) ); |
| 8342 | } |
| 8343 | #endif |
| 8344 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8345 | //Close VOSS |
| 8346 | //This frees pMac(HAL) context. There should not be any call that requires pMac access after this. |
| 8347 | vos_close(pVosContext); |
| 8348 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8349 | //Close Watchdog |
| 8350 | if(pHddCtx->cfg_ini->fIsLogpEnabled) |
| 8351 | vos_watchdog_close(pVosContext); |
| 8352 | |
Gopichand Nakkala | a035848 | 2013-06-12 17:05:47 +0530 | [diff] [blame] | 8353 | //Clean up HDD Nlink Service |
| 8354 | send_btc_nlink_msg(WLAN_MODULE_DOWN_IND, 0); |
Gopichand Nakkala | a035848 | 2013-06-12 17:05:47 +0530 | [diff] [blame] | 8355 | |
Vinay Krishna Eranna | d938c42 | 2014-03-10 17:14:21 +0530 | [diff] [blame] | 8356 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 8357 | if (pHddCtx->cfg_ini->wlanLoggingEnable) |
Vinay Krishna Eranna | d938c42 | 2014-03-10 17:14:21 +0530 | [diff] [blame] | 8358 | { |
| 8359 | wlan_logging_sock_deactivate_svc(); |
| 8360 | } |
| 8361 | #endif |
| 8362 | |
Vinay Krishna Eranna | ef30b52 | 2014-08-26 17:48:16 +0530 | [diff] [blame] | 8363 | #ifdef WLAN_KD_READY_NOTIFIER |
| 8364 | nl_srv_exit(pHddCtx->ptt_pid); |
| 8365 | #else |
| 8366 | nl_srv_exit(); |
| 8367 | #endif /* WLAN_KD_READY_NOTIFIER */ |
| 8368 | |
| 8369 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8370 | hdd_close_all_adapters( pHddCtx ); |
| 8371 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8372 | /* free the power on lock from platform driver */ |
| 8373 | if (free_riva_power_on_lock("wlan")) |
| 8374 | { |
| 8375 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to free power on lock", |
| 8376 | __func__); |
| 8377 | } |
| 8378 | |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 8379 | free_hdd_ctx: |
c_hpothu | 78c7b60 | 2014-05-17 17:35:49 +0530 | [diff] [blame] | 8380 | |
| 8381 | //Free up dynamically allocated members inside HDD Adapter |
| 8382 | if (pHddCtx->cfg_ini) |
| 8383 | { |
| 8384 | kfree(pHddCtx->cfg_ini); |
| 8385 | pHddCtx->cfg_ini= NULL; |
| 8386 | } |
| 8387 | |
Leo Chang | f04ddad | 2013-09-18 13:46:38 -0700 | [diff] [blame] | 8388 | /* FTM mode, WIPHY did not registered |
| 8389 | If un-register here, system crash will happen */ |
| 8390 | if (VOS_FTM_MODE != hdd_get_conparam()) |
| 8391 | { |
| 8392 | wiphy_unregister(wiphy) ; |
| 8393 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8394 | wiphy_free(wiphy) ; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8395 | if (hdd_is_ssr_required()) |
| 8396 | { |
| 8397 | /* WDI timeout had happened during unload, so SSR is needed here */ |
Madan Mohan Koyyalamudi | 3246f5b | 2012-10-15 15:40:02 -0700 | [diff] [blame] | 8398 | subsystem_restart("wcnss"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8399 | msleep(5000); |
| 8400 | } |
| 8401 | hdd_set_ssr_required (VOS_FALSE); |
| 8402 | } |
| 8403 | |
| 8404 | |
| 8405 | /**--------------------------------------------------------------------------- |
| 8406 | |
| 8407 | \brief hdd_update_config_from_nv() - Function to update the contents of |
| 8408 | the running configuration with parameters taken from NV storage |
| 8409 | |
| 8410 | \param - pHddCtx - Pointer to the HDD global context |
| 8411 | |
| 8412 | \return - VOS_STATUS_SUCCESS if successful |
| 8413 | |
| 8414 | --------------------------------------------------------------------------*/ |
| 8415 | static VOS_STATUS hdd_update_config_from_nv(hdd_context_t* pHddCtx) |
| 8416 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8417 | v_BOOL_t itemIsValid = VOS_FALSE; |
| 8418 | VOS_STATUS status; |
| 8419 | v_MACADDR_t macFromNV[VOS_MAX_CONCURRENCY_PERSONA]; |
| 8420 | v_U8_t macLoop; |
| 8421 | |
| 8422 | /*If the NV is valid then get the macaddress from nv else get it from qcom_cfg.ini*/ |
| 8423 | status = vos_nv_getValidity(VNV_FIELD_IMAGE, &itemIsValid); |
| 8424 | if(status != VOS_STATUS_SUCCESS) |
| 8425 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 8426 | hddLog(VOS_TRACE_LEVEL_ERROR," vos_nv_getValidity() failed"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8427 | return VOS_STATUS_E_FAILURE; |
| 8428 | } |
| 8429 | |
| 8430 | if (itemIsValid == VOS_TRUE) |
| 8431 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 8432 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH," Reading the Macaddress from NV"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8433 | status = vos_nv_readMultiMacAddress((v_U8_t *)&macFromNV[0].bytes[0], |
| 8434 | VOS_MAX_CONCURRENCY_PERSONA); |
| 8435 | if(status != VOS_STATUS_SUCCESS) |
| 8436 | { |
| 8437 | /* Get MAC from NV fail, not update CFG info |
| 8438 | * INI MAC value will be used for MAC setting */ |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 8439 | hddLog(VOS_TRACE_LEVEL_ERROR," vos_nv_readMacAddress() failed"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8440 | return VOS_STATUS_E_FAILURE; |
| 8441 | } |
| 8442 | |
| 8443 | /* If first MAC is not valid, treat all others are not valid |
| 8444 | * Then all MACs will be got from ini file */ |
| 8445 | if(vos_is_macaddr_zero(&macFromNV[0])) |
| 8446 | { |
| 8447 | /* MAC address in NV file is not configured yet */ |
| 8448 | hddLog(VOS_TRACE_LEVEL_WARN, "Invalid MAC in NV file"); |
| 8449 | return VOS_STATUS_E_INVAL; |
| 8450 | } |
| 8451 | |
| 8452 | /* Get MAC address from NV, update CFG info */ |
| 8453 | for(macLoop = 0; macLoop < VOS_MAX_CONCURRENCY_PERSONA; macLoop++) |
| 8454 | { |
| 8455 | if(vos_is_macaddr_zero(&macFromNV[macLoop])) |
| 8456 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8457 | 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] | 8458 | /* This MAC is not valid, skip it |
| 8459 | * This MAC will be got from ini file */ |
| 8460 | } |
| 8461 | else |
| 8462 | { |
| 8463 | vos_mem_copy((v_U8_t *)&pHddCtx->cfg_ini->intfMacAddr[macLoop].bytes[0], |
| 8464 | (v_U8_t *)&macFromNV[macLoop].bytes[0], |
| 8465 | VOS_MAC_ADDR_SIZE); |
| 8466 | } |
| 8467 | } |
| 8468 | } |
| 8469 | else |
| 8470 | { |
| 8471 | hddLog(VOS_TRACE_LEVEL_ERROR, "NV ITEM, MAC Not valid"); |
| 8472 | return VOS_STATUS_E_FAILURE; |
| 8473 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8474 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8475 | |
| 8476 | return VOS_STATUS_SUCCESS; |
| 8477 | } |
| 8478 | |
| 8479 | /**--------------------------------------------------------------------------- |
| 8480 | |
| 8481 | \brief hdd_post_voss_start_config() - HDD post voss start config helper |
| 8482 | |
| 8483 | \param - pAdapter - Pointer to the HDD |
| 8484 | |
| 8485 | \return - None |
| 8486 | |
| 8487 | --------------------------------------------------------------------------*/ |
| 8488 | VOS_STATUS hdd_post_voss_start_config(hdd_context_t* pHddCtx) |
| 8489 | { |
| 8490 | eHalStatus halStatus; |
| 8491 | v_U32_t listenInterval; |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 8492 | tANI_U32 ignoreDtim; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8493 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8494 | |
| 8495 | // Send ready indication to the HDD. This will kick off the MAC |
| 8496 | // into a 'running' state and should kick off an initial scan. |
| 8497 | halStatus = sme_HDDReadyInd( pHddCtx->hHal ); |
| 8498 | if ( !HAL_STATUS_SUCCESS( halStatus ) ) |
| 8499 | { |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 8500 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: sme_HDDReadyInd() failed with status " |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8501 | "code %08d [x%08x]",__func__, halStatus, halStatus ); |
| 8502 | return VOS_STATUS_E_FAILURE; |
| 8503 | } |
| 8504 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 8505 | // Set default LI and ignoreDtim into HDD context, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8506 | // otherwise under some race condition, HDD will set 0 LI value into RIVA, |
| 8507 | // And RIVA will crash |
| 8508 | wlan_cfgGetInt(pHddCtx->hHal, WNI_CFG_LISTEN_INTERVAL, &listenInterval); |
| 8509 | pHddCtx->hdd_actual_LI_value = listenInterval; |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 8510 | wlan_cfgGetInt(pHddCtx->hHal, WNI_CFG_IGNORE_DTIM, &ignoreDtim); |
| 8511 | pHddCtx->hdd_actual_ignore_DTIM_value = ignoreDtim; |
| 8512 | |
| 8513 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8514 | return VOS_STATUS_SUCCESS; |
| 8515 | } |
| 8516 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8517 | /* wake lock APIs for HDD */ |
| 8518 | void hdd_prevent_suspend(void) |
| 8519 | { |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 8520 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8521 | wake_lock(&wlan_wake_lock); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8522 | #else |
| 8523 | wcnss_prevent_suspend(); |
| 8524 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8525 | } |
| 8526 | |
| 8527 | void hdd_allow_suspend(void) |
| 8528 | { |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 8529 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8530 | wake_unlock(&wlan_wake_lock); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8531 | #else |
| 8532 | wcnss_allow_suspend(); |
| 8533 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8534 | } |
| 8535 | |
Mahesh A Saptasagar | b9c5040 | 2014-01-16 15:49:22 +0530 | [diff] [blame] | 8536 | void hdd_prevent_suspend_timeout(v_U32_t timeout) |
Madan Mohan Koyyalamudi | 10d83a9 | 2012-09-28 15:47:05 -0700 | [diff] [blame] | 8537 | { |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 8538 | #ifdef WLAN_OPEN_SOURCE |
Amar Singhal | 6144c00 | 2013-05-03 16:11:42 -0700 | [diff] [blame] | 8539 | wake_lock_timeout(&wlan_wake_lock, msecs_to_jiffies(timeout)); |
Madan Mohan Koyyalamudi | 10d83a9 | 2012-09-28 15:47:05 -0700 | [diff] [blame] | 8540 | #else |
| 8541 | /* Do nothing as there is no API in wcnss for timeout*/ |
| 8542 | #endif |
| 8543 | } |
| 8544 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8545 | /**--------------------------------------------------------------------------- |
| 8546 | |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8547 | \brief hdd_exchange_version_and_caps() - HDD function to exchange version and capability |
| 8548 | information between Host and Riva |
| 8549 | |
| 8550 | This function gets reported version of FW |
| 8551 | It also finds the version of Riva headers used to compile the host |
| 8552 | It compares the above two and prints a warning if they are different |
| 8553 | It gets the SW and HW version string |
| 8554 | Finally, it exchanges capabilities between host and Riva i.e. host and riva exchange a msg |
| 8555 | indicating the features they support through a bitmap |
| 8556 | |
| 8557 | \param - pHddCtx - Pointer to HDD context |
| 8558 | |
| 8559 | \return - void |
| 8560 | |
| 8561 | --------------------------------------------------------------------------*/ |
| 8562 | |
| 8563 | void hdd_exchange_version_and_caps(hdd_context_t *pHddCtx) |
| 8564 | { |
| 8565 | |
| 8566 | tSirVersionType versionCompiled; |
| 8567 | tSirVersionType versionReported; |
| 8568 | tSirVersionString versionString; |
| 8569 | tANI_U8 fwFeatCapsMsgSupported = 0; |
| 8570 | VOS_STATUS vstatus; |
| 8571 | |
Mingcheng Zhu | 87f22fc | 2014-01-30 19:23:32 -0800 | [diff] [blame] | 8572 | memset(&versionCompiled, 0, sizeof(versionCompiled)); |
| 8573 | memset(&versionReported, 0, sizeof(versionReported)); |
| 8574 | |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8575 | /* retrieve and display WCNSS version information */ |
| 8576 | do { |
| 8577 | |
| 8578 | vstatus = sme_GetWcnssWlanCompiledVersion(pHddCtx->hHal, |
| 8579 | &versionCompiled); |
| 8580 | if (!VOS_IS_STATUS_SUCCESS(vstatus)) |
| 8581 | { |
| 8582 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 8583 | "%s: unable to retrieve WCNSS WLAN compiled version", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 8584 | __func__); |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8585 | break; |
| 8586 | } |
| 8587 | |
| 8588 | vstatus = sme_GetWcnssWlanReportedVersion(pHddCtx->hHal, |
| 8589 | &versionReported); |
| 8590 | if (!VOS_IS_STATUS_SUCCESS(vstatus)) |
| 8591 | { |
| 8592 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 8593 | "%s: unable to retrieve WCNSS WLAN reported version", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 8594 | __func__); |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8595 | break; |
| 8596 | } |
| 8597 | |
| 8598 | if ((versionCompiled.major != versionReported.major) || |
| 8599 | (versionCompiled.minor != versionReported.minor) || |
| 8600 | (versionCompiled.version != versionReported.version) || |
| 8601 | (versionCompiled.revision != versionReported.revision)) |
| 8602 | { |
| 8603 | pr_err("%s: WCNSS WLAN Version %u.%u.%u.%u, " |
| 8604 | "Host expected %u.%u.%u.%u\n", |
| 8605 | WLAN_MODULE_NAME, |
| 8606 | (int)versionReported.major, |
| 8607 | (int)versionReported.minor, |
| 8608 | (int)versionReported.version, |
| 8609 | (int)versionReported.revision, |
| 8610 | (int)versionCompiled.major, |
| 8611 | (int)versionCompiled.minor, |
| 8612 | (int)versionCompiled.version, |
| 8613 | (int)versionCompiled.revision); |
| 8614 | } |
| 8615 | else |
| 8616 | { |
| 8617 | pr_info("%s: WCNSS WLAN version %u.%u.%u.%u\n", |
| 8618 | WLAN_MODULE_NAME, |
| 8619 | (int)versionReported.major, |
| 8620 | (int)versionReported.minor, |
| 8621 | (int)versionReported.version, |
| 8622 | (int)versionReported.revision); |
| 8623 | } |
| 8624 | |
| 8625 | vstatus = sme_GetWcnssSoftwareVersion(pHddCtx->hHal, |
| 8626 | versionString, |
| 8627 | sizeof(versionString)); |
| 8628 | if (!VOS_IS_STATUS_SUCCESS(vstatus)) |
| 8629 | { |
| 8630 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 8631 | "%s: unable to retrieve WCNSS software version string", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 8632 | __func__); |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8633 | break; |
| 8634 | } |
| 8635 | |
| 8636 | pr_info("%s: WCNSS software version %s\n", |
| 8637 | WLAN_MODULE_NAME, versionString); |
| 8638 | |
| 8639 | vstatus = sme_GetWcnssHardwareVersion(pHddCtx->hHal, |
| 8640 | versionString, |
| 8641 | sizeof(versionString)); |
| 8642 | if (!VOS_IS_STATUS_SUCCESS(vstatus)) |
| 8643 | { |
| 8644 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 8645 | "%s: unable to retrieve WCNSS hardware version string", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 8646 | __func__); |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8647 | break; |
| 8648 | } |
| 8649 | |
| 8650 | pr_info("%s: WCNSS hardware version %s\n", |
| 8651 | WLAN_MODULE_NAME, versionString); |
| 8652 | |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 8653 | /* 1.Check if FW version is greater than 0.1.1.0. Only then send host-FW capability exchange message |
| 8654 | 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] | 8655 | send the message only if it the riva is 1.1 |
| 8656 | minor numbers for different riva branches: |
| 8657 | 0 -> (1.0)Mainline Build |
| 8658 | 1 -> (1.1)Mainline Build |
| 8659 | 2->(1.04) Stability Build |
| 8660 | */ |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 8661 | if (((versionReported.major>0) || (versionReported.minor>1) || |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8662 | ((versionReported.minor>=1) && (versionReported.version>=1))) |
| 8663 | && ((versionReported.major == 1) && (versionReported.minor >= 1))) |
| 8664 | fwFeatCapsMsgSupported = 1; |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 8665 | |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8666 | if (fwFeatCapsMsgSupported) |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 8667 | { |
| 8668 | #ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE |
| 8669 | if(!pHddCtx->cfg_ini->fEnableActiveModeOffload) |
| 8670 | sme_disableFeatureCapablity(WLANACTIVE_OFFLOAD); |
| 8671 | #endif |
Ravi Joshi | d2ca7c4 | 2013-07-23 08:37:49 -0700 | [diff] [blame] | 8672 | /* Indicate if IBSS heartbeat monitoring needs to be offloaded */ |
| 8673 | if (!pHddCtx->cfg_ini->enableIbssHeartBeatOffload) |
| 8674 | { |
| 8675 | sme_disableFeatureCapablity(IBSS_HEARTBEAT_OFFLOAD); |
| 8676 | } |
| 8677 | |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8678 | sme_featureCapsExchange(pHddCtx->hHal); |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 8679 | } |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8680 | |
| 8681 | } while (0); |
| 8682 | |
| 8683 | } |
Neelansh Mittal | edafed2 | 2014-09-04 18:54:39 +0530 | [diff] [blame] | 8684 | void wlan_hdd_send_svc_nlink_msg(int type, void *data, int len) |
| 8685 | { |
| 8686 | struct sk_buff *skb; |
| 8687 | struct nlmsghdr *nlh; |
| 8688 | tAniMsgHdr *ani_hdr; |
| 8689 | |
| 8690 | skb = alloc_skb(NLMSG_SPACE(WLAN_NL_MAX_PAYLOAD), GFP_KERNEL); |
| 8691 | |
| 8692 | if(skb == NULL) { |
| 8693 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8694 | "%s: alloc_skb failed", __func__); |
| 8695 | return; |
| 8696 | } |
| 8697 | |
| 8698 | nlh = (struct nlmsghdr *)skb->data; |
| 8699 | nlh->nlmsg_pid = 0; /* from kernel */ |
| 8700 | nlh->nlmsg_flags = 0; |
| 8701 | nlh->nlmsg_seq = 0; |
| 8702 | nlh->nlmsg_type = WLAN_NL_MSG_SVC; |
| 8703 | |
| 8704 | ani_hdr = NLMSG_DATA(nlh); |
| 8705 | ani_hdr->type = type; |
| 8706 | |
| 8707 | switch(type) { |
| 8708 | case WLAN_SVC_SAP_RESTART_IND: |
| 8709 | ani_hdr->length = 0; |
| 8710 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr))); |
| 8711 | skb_put(skb, NLMSG_SPACE(sizeof(tAniMsgHdr))); |
| 8712 | break; |
| 8713 | default: |
| 8714 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8715 | "Attempt to send unknown nlink message %d", type); |
| 8716 | kfree_skb(skb); |
| 8717 | return; |
| 8718 | } |
| 8719 | |
| 8720 | nl_srv_bcast(skb); |
| 8721 | |
| 8722 | return; |
| 8723 | } |
| 8724 | |
| 8725 | |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8726 | |
| 8727 | /**--------------------------------------------------------------------------- |
| 8728 | |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 8729 | \brief hdd_is_5g_supported() - HDD function to know if hardware supports 5GHz |
| 8730 | |
| 8731 | \param - pHddCtx - Pointer to the hdd context |
| 8732 | |
| 8733 | \return - true if hardware supports 5GHz |
| 8734 | |
| 8735 | --------------------------------------------------------------------------*/ |
Vinay Krishna Eranna | facf5e2 | 2014-02-24 13:16:25 +0530 | [diff] [blame] | 8736 | boolean hdd_is_5g_supported(hdd_context_t * pHddCtx) |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 8737 | { |
| 8738 | /* If wcnss_wlan_iris_xo_mode() returns WCNSS_XO_48MHZ(1); |
| 8739 | * then hardware support 5Ghz. |
| 8740 | */ |
| 8741 | if (WCNSS_XO_48MHZ == wcnss_wlan_iris_xo_mode()) |
| 8742 | { |
Agarwal Ashish | 971c288 | 2013-10-30 20:11:12 +0530 | [diff] [blame] | 8743 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Hardware supports 5Ghz", __func__); |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 8744 | return true; |
| 8745 | } |
| 8746 | else |
| 8747 | { |
Agarwal Ashish | 971c288 | 2013-10-30 20:11:12 +0530 | [diff] [blame] | 8748 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Hardware doesn't supports 5Ghz", |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 8749 | __func__); |
| 8750 | return false; |
| 8751 | } |
| 8752 | } |
| 8753 | |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 8754 | /**--------------------------------------------------------------------------- |
| 8755 | |
| 8756 | \brief hdd_generate_iface_mac_addr_auto() - HDD Mac Interface Auto |
| 8757 | generate function |
| 8758 | |
| 8759 | This is generate the random mac address for WLAN interface |
| 8760 | |
| 8761 | \param - pHddCtx - Pointer to HDD context |
| 8762 | idx - Start interface index to get auto |
| 8763 | generated mac addr. |
| 8764 | mac_addr - Mac address |
| 8765 | |
| 8766 | \return - 0 for success, < 0 for failure |
| 8767 | |
| 8768 | --------------------------------------------------------------------------*/ |
| 8769 | |
| 8770 | static int hdd_generate_iface_mac_addr_auto(hdd_context_t *pHddCtx, |
| 8771 | int idx, v_MACADDR_t mac_addr) |
| 8772 | { |
| 8773 | int i; |
| 8774 | unsigned int serialno; |
| 8775 | serialno = wcnss_get_serial_number(); |
| 8776 | |
| 8777 | if (0 != serialno) |
| 8778 | { |
| 8779 | /* MAC address has 3 bytes of OUI so we have a maximum of 3 |
| 8780 | bytes of the serial number that can be used to generate |
| 8781 | the other 3 bytes of the MAC address. Mask off all but |
| 8782 | the lower 3 bytes (this will also make sure we don't |
| 8783 | overflow in the next step) */ |
| 8784 | serialno &= 0x00FFFFFF; |
| 8785 | |
| 8786 | /* we need a unique address for each session */ |
| 8787 | serialno *= VOS_MAX_CONCURRENCY_PERSONA; |
| 8788 | |
| 8789 | /* autogen other Mac addresses */ |
| 8790 | for (i = idx; i < VOS_MAX_CONCURRENCY_PERSONA; i++) |
| 8791 | { |
| 8792 | /* start with the entire default address */ |
| 8793 | pHddCtx->cfg_ini->intfMacAddr[i] = mac_addr; |
| 8794 | /* then replace the lower 3 bytes */ |
| 8795 | pHddCtx->cfg_ini->intfMacAddr[i].bytes[3] = (serialno >> 16) & 0xFF; |
| 8796 | pHddCtx->cfg_ini->intfMacAddr[i].bytes[4] = (serialno >> 8) & 0xFF; |
| 8797 | pHddCtx->cfg_ini->intfMacAddr[i].bytes[5] = serialno & 0xFF; |
| 8798 | |
| 8799 | serialno++; |
| 8800 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8801 | "%s: Derived Mac Addr: " |
| 8802 | MAC_ADDRESS_STR, __func__, |
| 8803 | MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[i].bytes)); |
| 8804 | } |
| 8805 | |
| 8806 | } |
| 8807 | else |
| 8808 | { |
| 8809 | hddLog(LOGE, FL("Failed to Get Serial NO")); |
| 8810 | return -1; |
| 8811 | } |
| 8812 | return 0; |
| 8813 | } |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 8814 | |
| 8815 | /**--------------------------------------------------------------------------- |
| 8816 | |
Mihir Shete | fc7ff5b | 2014-01-27 11:30:05 +0530 | [diff] [blame] | 8817 | \brief hdd_11d_scan_done - callback to be executed when 11d scan is |
| 8818 | completed to flush out the scan results |
| 8819 | |
| 8820 | 11d scan is done during driver load and is a passive scan on all |
| 8821 | channels supported by the device, 11d scans may find some APs on |
| 8822 | frequencies which are forbidden to be used in the regulatory domain |
| 8823 | the device is operating in. If these APs are notified to the supplicant |
| 8824 | it may try to connect to these APs, thus flush out all the scan results |
| 8825 | which are present in SME after 11d scan is done. |
| 8826 | |
| 8827 | \return - eHalStatus |
| 8828 | |
| 8829 | --------------------------------------------------------------------------*/ |
| 8830 | static eHalStatus hdd_11d_scan_done(tHalHandle halHandle, void *pContext, |
| 8831 | tANI_U32 scanId, eCsrScanStatus status) |
| 8832 | { |
| 8833 | ENTER(); |
| 8834 | |
| 8835 | sme_ScanFlushResult(halHandle, 0); |
| 8836 | |
| 8837 | EXIT(); |
| 8838 | |
| 8839 | return eHAL_STATUS_SUCCESS; |
| 8840 | } |
| 8841 | |
| 8842 | /**--------------------------------------------------------------------------- |
| 8843 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8844 | \brief hdd_wlan_startup() - HDD init function |
| 8845 | |
| 8846 | This is the driver startup code executed once a WLAN device has been detected |
| 8847 | |
| 8848 | \param - dev - Pointer to the underlying device |
| 8849 | |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 8850 | \return - 0 for success, < 0 for failure |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8851 | |
| 8852 | --------------------------------------------------------------------------*/ |
| 8853 | |
| 8854 | int hdd_wlan_startup(struct device *dev ) |
| 8855 | { |
| 8856 | VOS_STATUS status; |
| 8857 | hdd_adapter_t *pAdapter = NULL; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8858 | hdd_adapter_t *pP2pAdapter = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8859 | hdd_context_t *pHddCtx = NULL; |
| 8860 | v_CONTEXT_t pVosContext= NULL; |
| 8861 | #ifdef WLAN_BTAMP_FEATURE |
| 8862 | VOS_STATUS vStatus = VOS_STATUS_SUCCESS; |
| 8863 | WLANBAP_ConfigType btAmpConfig; |
| 8864 | hdd_config_t *pConfig; |
| 8865 | #endif |
| 8866 | int ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8867 | struct wiphy *wiphy; |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 8868 | v_MACADDR_t mac_addr; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8869 | |
| 8870 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8871 | /* |
| 8872 | * cfg80211: wiphy allocation |
| 8873 | */ |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 8874 | wiphy = wlan_hdd_cfg80211_wiphy_alloc(sizeof(hdd_context_t)) ; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8875 | |
| 8876 | if(wiphy == NULL) |
| 8877 | { |
| 8878 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: cfg80211 init failed", __func__); |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 8879 | return -EIO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8880 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8881 | pHddCtx = wiphy_priv(wiphy); |
| 8882 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8883 | //Initialize the adapter context to zeros. |
| 8884 | vos_mem_zero(pHddCtx, sizeof( hdd_context_t )); |
| 8885 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8886 | pHddCtx->wiphy = wiphy; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8887 | hdd_prevent_suspend(); |
Mihir Shete | 1815629 | 2014-03-11 15:38:30 +0530 | [diff] [blame] | 8888 | pHddCtx->isLoadUnloadInProgress = WLAN_HDD_LOAD_IN_PROGRESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8889 | |
| 8890 | vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, TRUE); |
| 8891 | |
| 8892 | /*Get vos context here bcoz vos_open requires it*/ |
| 8893 | pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL); |
| 8894 | |
Madan Mohan Koyyalamudi | 0b78e15 | 2012-11-28 15:46:51 -0800 | [diff] [blame] | 8895 | if(pVosContext == NULL) |
| 8896 | { |
| 8897 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Failed vos_get_global_context",__func__); |
| 8898 | goto err_free_hdd_context; |
| 8899 | } |
| 8900 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8901 | //Save the Global VOSS context in adapter context for future. |
| 8902 | pHddCtx->pvosContext = pVosContext; |
| 8903 | |
| 8904 | //Save the adapter context in global context for future. |
| 8905 | ((VosContextType*)(pVosContext))->pHDDContext = (v_VOID_t*)pHddCtx; |
| 8906 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8907 | pHddCtx->parent_dev = dev; |
| 8908 | |
| 8909 | init_completion(&pHddCtx->full_pwr_comp_var); |
| 8910 | init_completion(&pHddCtx->standby_comp_var); |
| 8911 | init_completion(&pHddCtx->req_bmps_comp_var); |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 8912 | init_completion(&pHddCtx->scan_info.scan_req_completion_event); |
Madan Mohan Koyyalamudi | f4e8100 | 2012-11-13 10:46:38 -0800 | [diff] [blame] | 8913 | init_completion(&pHddCtx->scan_info.abortscan_event_var); |
Kiet Lam | 46b8e4e | 2013-11-06 21:49:53 +0530 | [diff] [blame] | 8914 | init_completion(&pHddCtx->wiphy_channel_update_event); |
Arun Kumar Khandavalli | e0b046d | 2014-03-01 21:54:25 +0530 | [diff] [blame] | 8915 | init_completion(&pHddCtx->ssr_comp_var); |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 8916 | |
| 8917 | #ifdef CONFIG_ENABLE_LINUX_REG |
Amar Singhal | fddc28c | 2013-09-05 13:03:40 -0700 | [diff] [blame] | 8918 | init_completion(&pHddCtx->linux_reg_req); |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 8919 | #else |
| 8920 | init_completion(&pHddCtx->driver_crda_req); |
| 8921 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8922 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 8923 | spin_lock_init(&pHddCtx->schedScan_lock); |
| 8924 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8925 | hdd_list_init( &pHddCtx->hddAdapters, MAX_NUMBER_OF_ADAPTERS ); |
| 8926 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 8927 | #ifdef FEATURE_WLAN_TDLS |
| 8928 | /* tdls_lock is initialized before an hdd_open_adapter ( which is |
| 8929 | * invoked by other instances also) to protect the concurrent |
| 8930 | * access for the Adapters by TDLS module. |
| 8931 | */ |
| 8932 | mutex_init(&pHddCtx->tdls_lock); |
| 8933 | #endif |
Siddharth Bhal | 7697221 | 2014-10-15 16:22:51 +0530 | [diff] [blame] | 8934 | mutex_init(&pHddCtx->spoofMacAddr.macSpoofingLock); |
Agarwal Ashish | 1f42287 | 2014-07-22 00:11:55 +0530 | [diff] [blame] | 8935 | /* By default Strict Regulatory For FCC should be false */ |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 8936 | |
Agarwal Ashish | 1f42287 | 2014-07-22 00:11:55 +0530 | [diff] [blame] | 8937 | pHddCtx->nEnableStrictRegulatoryForFCC = FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8938 | // Load all config first as TL config is needed during vos_open |
| 8939 | pHddCtx->cfg_ini = (hdd_config_t*) kmalloc(sizeof(hdd_config_t), GFP_KERNEL); |
| 8940 | if(pHddCtx->cfg_ini == NULL) |
| 8941 | { |
| 8942 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Failed kmalloc hdd_config_t",__func__); |
| 8943 | goto err_free_hdd_context; |
| 8944 | } |
| 8945 | |
| 8946 | vos_mem_zero(pHddCtx->cfg_ini, sizeof( hdd_config_t )); |
| 8947 | |
| 8948 | // Read and parse the qcom_cfg.ini file |
| 8949 | status = hdd_parse_config_ini( pHddCtx ); |
| 8950 | if ( VOS_STATUS_SUCCESS != status ) |
| 8951 | { |
| 8952 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: error parsing %s", |
| 8953 | __func__, WLAN_INI_FILE); |
| 8954 | goto err_config; |
| 8955 | } |
Arif Hussain | d521891 | 2013-12-05 01:10:55 -0800 | [diff] [blame] | 8956 | #ifdef MEMORY_DEBUG |
| 8957 | if (pHddCtx->cfg_ini->IsMemoryDebugSupportEnabled) |
| 8958 | vos_mem_init(); |
| 8959 | |
| 8960 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: gEnableMemoryDebug=%d", |
| 8961 | __func__, pHddCtx->cfg_ini->IsMemoryDebugSupportEnabled); |
| 8962 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8963 | |
Gopichand Nakkala | b8f0f1a | 2013-05-23 18:19:48 +0530 | [diff] [blame] | 8964 | /* INI has been read, initialise the configuredMcastBcastFilter with |
| 8965 | * INI value as this will serve as the default value |
| 8966 | */ |
| 8967 | pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting; |
| 8968 | hddLog(VOS_TRACE_LEVEL_INFO, "Setting configuredMcastBcastFilter: %d", |
| 8969 | pHddCtx->cfg_ini->mcastBcastFilterSetting); |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 8970 | |
| 8971 | if (false == hdd_is_5g_supported(pHddCtx)) |
| 8972 | { |
| 8973 | //5Ghz is not supported. |
| 8974 | if (1 != pHddCtx->cfg_ini->nBandCapability) |
| 8975 | { |
| 8976 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 8977 | "%s: Setting pHddCtx->cfg_ini->nBandCapability = 1", __func__); |
| 8978 | pHddCtx->cfg_ini->nBandCapability = 1; |
| 8979 | } |
| 8980 | } |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 8981 | |
| 8982 | /* If SNR Monitoring is enabled, FW has to parse all beacons |
| 8983 | * for calcaluting and storing the average SNR, so set Nth beacon |
| 8984 | * filter to 1 to enable FW to parse all the beaocons |
| 8985 | */ |
| 8986 | if (1 == pHddCtx->cfg_ini->fEnableSNRMonitoring) |
| 8987 | { |
| 8988 | /* The log level is deliberately set to WARN as overriding |
| 8989 | * nthBeaconFilter to 1 will increase power cosumption and this |
| 8990 | * might just prove helpful to detect the power issue. |
| 8991 | */ |
| 8992 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 8993 | "%s: Setting pHddCtx->cfg_ini->nthBeaconFilter = 1", __func__); |
| 8994 | pHddCtx->cfg_ini->nthBeaconFilter = 1; |
| 8995 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8996 | /* |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 8997 | * cfg80211: Initialization ... |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8998 | */ |
Manjunathappa Prakash | eec4ddf | 2014-01-13 18:23:51 -0800 | [diff] [blame] | 8999 | if (VOS_FTM_MODE != hdd_get_conparam()) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9000 | { |
Manjunathappa Prakash | eec4ddf | 2014-01-13 18:23:51 -0800 | [diff] [blame] | 9001 | if (0 < wlan_hdd_cfg80211_init(dev, wiphy, pHddCtx->cfg_ini)) |
| 9002 | { |
| 9003 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 9004 | "%s: wlan_hdd_cfg80211_init return failure", __func__); |
| 9005 | goto err_config; |
| 9006 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9007 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9008 | |
Varun Reddy Yeturu | 587e680 | 2013-01-24 12:21:41 -0800 | [diff] [blame] | 9009 | // Update VOS trace levels based upon the cfg.ini |
| 9010 | hdd_vos_trace_enable(VOS_MODULE_ID_BAP, |
| 9011 | pHddCtx->cfg_ini->vosTraceEnableBAP); |
| 9012 | hdd_vos_trace_enable(VOS_MODULE_ID_TL, |
| 9013 | pHddCtx->cfg_ini->vosTraceEnableTL); |
| 9014 | hdd_vos_trace_enable(VOS_MODULE_ID_WDI, |
| 9015 | pHddCtx->cfg_ini->vosTraceEnableWDI); |
| 9016 | hdd_vos_trace_enable(VOS_MODULE_ID_HDD, |
| 9017 | pHddCtx->cfg_ini->vosTraceEnableHDD); |
| 9018 | hdd_vos_trace_enable(VOS_MODULE_ID_SME, |
| 9019 | pHddCtx->cfg_ini->vosTraceEnableSME); |
| 9020 | hdd_vos_trace_enable(VOS_MODULE_ID_PE, |
| 9021 | pHddCtx->cfg_ini->vosTraceEnablePE); |
Katya Nigam | 70d6833 | 2013-09-16 16:49:45 +0530 | [diff] [blame] | 9022 | hdd_vos_trace_enable(VOS_MODULE_ID_PMC, |
| 9023 | pHddCtx->cfg_ini->vosTraceEnablePMC); |
Varun Reddy Yeturu | 587e680 | 2013-01-24 12:21:41 -0800 | [diff] [blame] | 9024 | hdd_vos_trace_enable(VOS_MODULE_ID_WDA, |
| 9025 | pHddCtx->cfg_ini->vosTraceEnableWDA); |
| 9026 | hdd_vos_trace_enable(VOS_MODULE_ID_SYS, |
| 9027 | pHddCtx->cfg_ini->vosTraceEnableSYS); |
| 9028 | hdd_vos_trace_enable(VOS_MODULE_ID_VOSS, |
| 9029 | pHddCtx->cfg_ini->vosTraceEnableVOSS); |
Varun Reddy Yeturu | 587e680 | 2013-01-24 12:21:41 -0800 | [diff] [blame] | 9030 | hdd_vos_trace_enable(VOS_MODULE_ID_SAP, |
| 9031 | pHddCtx->cfg_ini->vosTraceEnableSAP); |
| 9032 | hdd_vos_trace_enable(VOS_MODULE_ID_HDD_SOFTAP, |
| 9033 | pHddCtx->cfg_ini->vosTraceEnableHDDSAP); |
Varun Reddy Yeturu | 587e680 | 2013-01-24 12:21:41 -0800 | [diff] [blame] | 9034 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9035 | // Update WDI trace levels based upon the cfg.ini |
| 9036 | hdd_wdi_trace_enable(eWLAN_MODULE_DAL, |
| 9037 | pHddCtx->cfg_ini->wdiTraceEnableDAL); |
| 9038 | hdd_wdi_trace_enable(eWLAN_MODULE_DAL_CTRL, |
| 9039 | pHddCtx->cfg_ini->wdiTraceEnableCTL); |
| 9040 | hdd_wdi_trace_enable(eWLAN_MODULE_DAL_DATA, |
| 9041 | pHddCtx->cfg_ini->wdiTraceEnableDAT); |
| 9042 | hdd_wdi_trace_enable(eWLAN_MODULE_PAL, |
| 9043 | pHddCtx->cfg_ini->wdiTraceEnablePAL); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9044 | |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 9045 | if (VOS_FTM_MODE == hdd_get_conparam()) |
| 9046 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9047 | if ( VOS_STATUS_SUCCESS != wlan_hdd_ftm_open(pHddCtx) ) |
| 9048 | { |
| 9049 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: wlan_hdd_ftm_open Failed",__func__); |
| 9050 | goto err_free_hdd_context; |
| 9051 | } |
| 9052 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: FTM driver loaded success fully",__func__); |
c_hpothu | 2de0ef6 | 2014-04-15 16:16:15 +0530 | [diff] [blame] | 9053 | |
| 9054 | vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, FALSE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9055 | return VOS_STATUS_SUCCESS; |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 9056 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9057 | |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 9058 | //Open watchdog module |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9059 | if(pHddCtx->cfg_ini->fIsLogpEnabled) |
| 9060 | { |
| 9061 | status = vos_watchdog_open(pVosContext, |
| 9062 | &((VosContextType*)pVosContext)->vosWatchdog, sizeof(VosWatchdogContext)); |
| 9063 | |
| 9064 | if(!VOS_IS_STATUS_SUCCESS( status )) |
| 9065 | { |
| 9066 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: vos_watchdog_open failed",__func__); |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 9067 | goto err_wdclose; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9068 | } |
| 9069 | } |
| 9070 | |
| 9071 | pHddCtx->isLogpInProgress = FALSE; |
| 9072 | vos_set_logp_in_progress(VOS_MODULE_ID_VOSS, FALSE); |
| 9073 | |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 9074 | #ifdef CONFIG_ENABLE_LINUX_REG |
Amar Singhal | 0a40223 | 2013-10-11 20:57:16 -0700 | [diff] [blame] | 9075 | /* initialize the NV module. This is required so that |
| 9076 | we can initialize the channel information in wiphy |
| 9077 | from the NV.bin data. The channel information in |
| 9078 | wiphy needs to be initialized before wiphy registration */ |
| 9079 | |
| 9080 | status = vos_nv_open(); |
| 9081 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 9082 | { |
| 9083 | /* NV module cannot be initialized */ |
| 9084 | hddLog( VOS_TRACE_LEVEL_FATAL, |
| 9085 | "%s: vos_nv_open failed", __func__); |
Vinay Krishna Eranna | 2025d89 | 2014-09-18 16:51:42 +0530 | [diff] [blame] | 9086 | goto err_wdclose; |
Amar Singhal | 0a40223 | 2013-10-11 20:57:16 -0700 | [diff] [blame] | 9087 | } |
| 9088 | |
| 9089 | status = vos_init_wiphy_from_nv_bin(); |
| 9090 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 9091 | { |
| 9092 | /* NV module cannot be initialized */ |
| 9093 | hddLog( VOS_TRACE_LEVEL_FATAL, |
| 9094 | "%s: vos_init_wiphy failed", __func__); |
| 9095 | goto err_vos_nv_close; |
| 9096 | } |
| 9097 | |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 9098 | #endif |
Girish Gowli | bf0e1ab | 2015-01-19 16:05:16 +0530 | [diff] [blame] | 9099 | #ifdef DEBUG_ROAM_DELAY |
| 9100 | vos_set_roam_delay_stats_enabled(pHddCtx->cfg_ini->gEnableRoamDelayStats); |
| 9101 | #endif //#ifdef DEBUG_ROAM_DELAY |
Arun Kumar Khandavalli | ebb1948 | 2014-03-25 13:56:53 +0530 | [diff] [blame] | 9102 | status = vos_open( &pVosContext, pHddCtx->parent_dev); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9103 | if ( !VOS_IS_STATUS_SUCCESS( status )) |
| 9104 | { |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 9105 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: vos_open failed", __func__); |
Mihir Shete | e1093ba | 2014-01-21 20:13:32 +0530 | [diff] [blame] | 9106 | goto err_vos_nv_close; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9107 | } |
| 9108 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9109 | pHddCtx->hHal = (tHalHandle)vos_get_context( VOS_MODULE_ID_SME, pVosContext ); |
| 9110 | |
| 9111 | if ( NULL == pHddCtx->hHal ) |
| 9112 | { |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 9113 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: HAL context is null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9114 | goto err_vosclose; |
| 9115 | } |
| 9116 | |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 9117 | status = vos_preStart( pHddCtx->pvosContext ); |
| 9118 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 9119 | { |
| 9120 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: vos_preStart failed", __func__); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 9121 | goto err_vosclose; |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 9122 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9123 | |
Arif Hussain | eaf6860 | 2013-12-30 23:10:44 -0800 | [diff] [blame] | 9124 | if (0 == enable_dfs_chan_scan || 1 == enable_dfs_chan_scan) |
| 9125 | { |
| 9126 | pHddCtx->cfg_ini->enableDFSChnlScan = enable_dfs_chan_scan; |
| 9127 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: module enable_dfs_chan_scan set to %d", |
| 9128 | __func__, enable_dfs_chan_scan); |
| 9129 | } |
| 9130 | if (0 == enable_11d || 1 == enable_11d) |
| 9131 | { |
| 9132 | pHddCtx->cfg_ini->Is11dSupportEnabled = enable_11d; |
| 9133 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: module enable_11d set to %d", |
| 9134 | __func__, enable_11d); |
| 9135 | } |
| 9136 | |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 9137 | /* Note that the vos_preStart() sequence triggers the cfg download. |
| 9138 | The cfg download must occur before we update the SME config |
| 9139 | since the SME config operation must access the cfg database */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9140 | status = hdd_set_sme_config( pHddCtx ); |
| 9141 | |
| 9142 | if ( VOS_STATUS_SUCCESS != status ) |
| 9143 | { |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 9144 | 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] | 9145 | goto err_vosclose; |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 9146 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9147 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9148 | /* In the integrated architecture we update the configuration from |
| 9149 | the INI file and from NV before vOSS has been started so that |
| 9150 | the final contents are available to send down to the cCPU */ |
| 9151 | |
| 9152 | // Apply the cfg.ini to cfg.dat |
| 9153 | if (FALSE == hdd_update_config_dat(pHddCtx)) |
| 9154 | { |
| 9155 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: config update failed",__func__ ); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 9156 | goto err_vosclose; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9157 | } |
| 9158 | |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 9159 | // Get mac addr from platform driver |
| 9160 | ret = wcnss_get_wlan_mac_address((char*)&mac_addr.bytes); |
| 9161 | |
| 9162 | if ((0 == ret) && (!vos_is_macaddr_zero(&mac_addr))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9163 | { |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 9164 | /* Store the mac addr for first interface */ |
| 9165 | pHddCtx->cfg_ini->intfMacAddr[0] = mac_addr; |
| 9166 | |
| 9167 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 9168 | "%s: WLAN Mac Addr: " |
| 9169 | MAC_ADDRESS_STR, __func__, |
| 9170 | MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[0].bytes)); |
| 9171 | |
| 9172 | /* Here, passing Arg2 as 1 because we do not want to change the |
| 9173 | last 3 bytes (means non OUI bytes) of first interface mac |
| 9174 | addr. |
| 9175 | */ |
| 9176 | if (0 != hdd_generate_iface_mac_addr_auto(pHddCtx, 1, mac_addr)) |
| 9177 | { |
| 9178 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 9179 | "%s: Failed to generate wlan interface mac addr " |
| 9180 | "using MAC from ini file ", __func__); |
| 9181 | } |
| 9182 | } |
| 9183 | else if (VOS_STATUS_SUCCESS != hdd_update_config_from_nv(pHddCtx)) |
| 9184 | { |
| 9185 | // Apply the NV to cfg.dat |
| 9186 | /* Prima Update MAC address only at here */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9187 | #ifdef WLAN_AUTOGEN_MACADDR_FEATURE |
| 9188 | /* There was not a valid set of MAC Addresses in NV. See if the |
| 9189 | default addresses were modified by the cfg.ini settings. If so, |
| 9190 | we'll use them, but if not, we'll autogenerate a set of MAC |
| 9191 | addresses based upon the device serial number */ |
| 9192 | |
| 9193 | static const v_MACADDR_t default_address = |
| 9194 | {{0x00, 0x0A, 0xF5, 0x89, 0x89, 0xFF}}; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9195 | |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 9196 | if (0 == memcmp(&default_address, &pHddCtx->cfg_ini->intfMacAddr[0], |
| 9197 | sizeof(default_address))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9198 | { |
| 9199 | /* cfg.ini has the default address, invoke autogen logic */ |
| 9200 | |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 9201 | /* Here, passing Arg2 as 0 because we want to change the |
| 9202 | last 3 bytes (means non OUI bytes) of all the interfaces |
| 9203 | mac addr. |
| 9204 | */ |
| 9205 | if (0 != hdd_generate_iface_mac_addr_auto(pHddCtx, 0, |
| 9206 | default_address)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9207 | { |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 9208 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 9209 | "%s: Failed to generate wlan interface mac addr " |
| 9210 | "using MAC from ini file " MAC_ADDRESS_STR, __func__, |
| 9211 | MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[0].bytes)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9212 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9213 | } |
| 9214 | else |
| 9215 | #endif //WLAN_AUTOGEN_MACADDR_FEATURE |
| 9216 | { |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 9217 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9218 | "%s: Invalid MAC address in NV, using MAC from ini file " |
| 9219 | MAC_ADDRESS_STR, __func__, |
| 9220 | MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[0].bytes)); |
| 9221 | } |
| 9222 | } |
| 9223 | { |
| 9224 | eHalStatus halStatus; |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 9225 | |
| 9226 | /* Set the MAC Address Currently this is used by HAL to |
| 9227 | * add self sta. Remove this once self sta is added as |
| 9228 | * part of session open. |
| 9229 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9230 | halStatus = cfgSetStr( pHddCtx->hHal, WNI_CFG_STA_ID, |
| 9231 | (v_U8_t *)&pHddCtx->cfg_ini->intfMacAddr[0], |
| 9232 | sizeof( pHddCtx->cfg_ini->intfMacAddr[0]) ); |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 9233 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9234 | if (!HAL_STATUS_SUCCESS( halStatus )) |
| 9235 | { |
| 9236 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failed to set MAC Address. " |
| 9237 | "HALStatus is %08d [x%08x]",__func__, halStatus, halStatus ); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 9238 | goto err_vosclose; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9239 | } |
| 9240 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9241 | |
| 9242 | /*Start VOSS which starts up the SME/MAC/HAL modules and everything else |
| 9243 | Note: Firmware image will be read and downloaded inside vos_start API */ |
| 9244 | status = vos_start( pHddCtx->pvosContext ); |
| 9245 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 9246 | { |
| 9247 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: vos_start failed",__func__); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 9248 | goto err_vosclose; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9249 | } |
| 9250 | |
Leo Chang | 6cec3e2 | 2014-01-21 15:33:49 -0800 | [diff] [blame] | 9251 | #ifdef FEATURE_WLAN_CH_AVOID |
| 9252 | /* Plug in avoid channel notification callback |
| 9253 | * This should happen before ADD_SELF_STA |
| 9254 | * FW will send first IND with ADD_SELF_STA REQ from host */ |
Pradeep Reddy POTTETI | 5c2e16d | 2014-06-27 16:47:38 +0530 | [diff] [blame] | 9255 | |
| 9256 | /* check the Channel Avoidance is enabled */ |
| 9257 | if (TRUE == pHddCtx->cfg_ini->fenableCHAvoidance) |
| 9258 | { |
| 9259 | sme_AddChAvoidCallback(pHddCtx->hHal, |
| 9260 | hdd_hostapd_ch_avoid_cb); |
| 9261 | } |
Leo Chang | 6cec3e2 | 2014-01-21 15:33:49 -0800 | [diff] [blame] | 9262 | #endif /* FEATURE_WLAN_CH_AVOID */ |
| 9263 | |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 9264 | /* Exchange capability info between Host and FW and also get versioning info from FW */ |
| 9265 | hdd_exchange_version_and_caps(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9266 | |
Agarwal Ashish | ad9281b | 2014-06-10 14:57:30 +0530 | [diff] [blame] | 9267 | #ifdef CONFIG_ENABLE_LINUX_REG |
| 9268 | status = wlan_hdd_init_channels(pHddCtx); |
| 9269 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 9270 | { |
| 9271 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: wlan_hdd_init_channels failed", |
| 9272 | __func__); |
| 9273 | goto err_vosstop; |
| 9274 | } |
| 9275 | #endif |
| 9276 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9277 | status = hdd_post_voss_start_config( pHddCtx ); |
| 9278 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 9279 | { |
| 9280 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hdd_post_voss_start_config failed", |
| 9281 | __func__); |
| 9282 | goto err_vosstop; |
| 9283 | } |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 9284 | |
| 9285 | #ifndef CONFIG_ENABLE_LINUX_REG |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 9286 | wlan_hdd_cfg80211_update_reg_info( wiphy ); |
| 9287 | |
| 9288 | /* registration of wiphy dev with cfg80211 */ |
| 9289 | if (0 > wlan_hdd_cfg80211_register(wiphy)) |
| 9290 | { |
| 9291 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__); |
| 9292 | goto err_vosstop; |
| 9293 | } |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 9294 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9295 | |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 9296 | #ifdef CONFIG_ENABLE_LINUX_REG |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 9297 | /* registration of wiphy dev with cfg80211 */ |
| 9298 | if (0 > wlan_hdd_cfg80211_register(wiphy)) |
| 9299 | { |
| 9300 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__); |
| 9301 | goto err_vosstop; |
| 9302 | } |
| 9303 | |
Agarwal Ashish | 6db9d53 | 2014-09-30 18:19:10 +0530 | [diff] [blame] | 9304 | status = wlan_hdd_init_channels_for_cc(pHddCtx, INIT); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 9305 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 9306 | { |
| 9307 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: wlan_hdd_init_channels_for_cc failed", |
| 9308 | __func__); |
| 9309 | goto err_unregister_wiphy; |
| 9310 | } |
| 9311 | #endif |
| 9312 | |
c_hpothu | 4a298be | 2014-12-22 21:12:51 +0530 | [diff] [blame] | 9313 | wcnss_wlan_set_drvdata(pHddCtx->parent_dev, pHddCtx); |
| 9314 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9315 | if (VOS_STA_SAP_MODE == hdd_get_conparam()) |
| 9316 | { |
| 9317 | pAdapter = hdd_open_adapter( pHddCtx, WLAN_HDD_SOFTAP, "softap.%d", |
| 9318 | wlan_hdd_get_intf_addr(pHddCtx), FALSE ); |
| 9319 | } |
| 9320 | else |
| 9321 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9322 | pAdapter = hdd_open_adapter( pHddCtx, WLAN_HDD_INFRA_STATION, "wlan%d", |
| 9323 | wlan_hdd_get_intf_addr(pHddCtx), FALSE ); |
| 9324 | if (pAdapter != NULL) |
| 9325 | { |
Katya Nigam | a7d81d7 | 2014-11-12 12:44:34 +0530 | [diff] [blame] | 9326 | 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] | 9327 | { |
Gopichand Nakkala | 49f96f6 | 2013-02-06 14:38:17 +0530 | [diff] [blame] | 9328 | vos_mem_copy( pHddCtx->p2pDeviceAddress.bytes, |
| 9329 | pHddCtx->cfg_ini->intfMacAddr[0].bytes, |
| 9330 | sizeof(tSirMacAddr)); |
Madan Mohan Koyyalamudi | edfc1b7 | 2012-10-18 20:25:55 -0700 | [diff] [blame] | 9331 | |
Gopichand Nakkala | 49f96f6 | 2013-02-06 14:38:17 +0530 | [diff] [blame] | 9332 | /* Generate the P2P Device Address. This consists of the device's |
| 9333 | * primary MAC address with the locally administered bit set. |
| 9334 | */ |
| 9335 | pHddCtx->p2pDeviceAddress.bytes[0] |= 0x02; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9336 | } |
| 9337 | else |
| 9338 | { |
Gopichand Nakkala | 49f96f6 | 2013-02-06 14:38:17 +0530 | [diff] [blame] | 9339 | tANI_U8* p2p_dev_addr = wlan_hdd_get_intf_addr(pHddCtx); |
| 9340 | if (p2p_dev_addr != NULL) |
| 9341 | { |
| 9342 | vos_mem_copy(&pHddCtx->p2pDeviceAddress.bytes[0], |
| 9343 | p2p_dev_addr, VOS_MAC_ADDR_SIZE); |
| 9344 | } |
| 9345 | else |
| 9346 | { |
| 9347 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 9348 | "%s: Failed to allocate mac_address for p2p_device", |
| 9349 | __func__); |
| 9350 | goto err_close_adapter; |
| 9351 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9352 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9353 | |
| 9354 | pP2pAdapter = hdd_open_adapter( pHddCtx, WLAN_HDD_P2P_DEVICE, "p2p%d", |
| 9355 | &pHddCtx->p2pDeviceAddress.bytes[0], FALSE ); |
| 9356 | if ( NULL == pP2pAdapter ) |
| 9357 | { |
| 9358 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 9359 | "%s: Failed to do hdd_open_adapter for P2P Device Interface", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 9360 | __func__); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9361 | goto err_close_adapter; |
| 9362 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9363 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9364 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9365 | |
| 9366 | if( pAdapter == NULL ) |
| 9367 | { |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 9368 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: hdd_open_adapter failed", __func__); |
| 9369 | goto err_close_adapter; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9370 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9371 | |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 9372 | if (country_code) |
| 9373 | { |
| 9374 | eHalStatus ret; |
Arif Hussain | cb60708 | 2013-12-20 11:57:42 -0800 | [diff] [blame] | 9375 | INIT_COMPLETION(pAdapter->change_country_code); |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 9376 | hdd_checkandupdate_dfssetting(pAdapter, country_code); |
| 9377 | #ifndef CONFIG_ENABLE_LINUX_REG |
| 9378 | hdd_checkandupdate_phymode(pAdapter, country_code); |
| 9379 | #endif |
Arif Hussain | eaf6860 | 2013-12-30 23:10:44 -0800 | [diff] [blame] | 9380 | ret = sme_ChangeCountryCode(pHddCtx->hHal, |
| 9381 | (void *)(tSmeChangeCountryCallback) |
| 9382 | wlan_hdd_change_country_code_callback, |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 9383 | country_code, |
| 9384 | pAdapter, pHddCtx->pvosContext, |
Abhishek Singh | a306a44 | 2013-11-07 18:39:01 +0530 | [diff] [blame] | 9385 | eSIR_TRUE, eSIR_TRUE); |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 9386 | if (eHAL_STATUS_SUCCESS == ret) |
| 9387 | { |
Arif Hussain | cb60708 | 2013-12-20 11:57:42 -0800 | [diff] [blame] | 9388 | ret = wait_for_completion_interruptible_timeout( |
| 9389 | &pAdapter->change_country_code, |
| 9390 | msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY)); |
| 9391 | |
| 9392 | if (0 >= ret) |
| 9393 | { |
| 9394 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 9395 | "%s: SME while setting country code timed out", __func__); |
| 9396 | } |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 9397 | } |
| 9398 | else |
| 9399 | { |
Arif Hussain | cb60708 | 2013-12-20 11:57:42 -0800 | [diff] [blame] | 9400 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 9401 | "%s: SME Change Country code from module param fail ret=%d", |
| 9402 | __func__, ret); |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 9403 | } |
| 9404 | } |
| 9405 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9406 | #ifdef WLAN_BTAMP_FEATURE |
| 9407 | vStatus = WLANBAP_Open(pVosContext); |
| 9408 | if(!VOS_IS_STATUS_SUCCESS(vStatus)) |
| 9409 | { |
| 9410 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 9411 | "%s: Failed to open BAP",__func__); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9412 | goto err_close_adapter; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9413 | } |
| 9414 | |
| 9415 | vStatus = BSL_Init(pVosContext); |
| 9416 | if(!VOS_IS_STATUS_SUCCESS(vStatus)) |
| 9417 | { |
| 9418 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 9419 | "%s: Failed to Init BSL",__func__); |
| 9420 | goto err_bap_close; |
| 9421 | } |
| 9422 | vStatus = WLANBAP_Start(pVosContext); |
| 9423 | if (!VOS_IS_STATUS_SUCCESS(vStatus)) |
| 9424 | { |
| 9425 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 9426 | "%s: Failed to start TL",__func__); |
| 9427 | goto err_bap_close; |
| 9428 | } |
| 9429 | |
| 9430 | pConfig = pHddCtx->cfg_ini; |
| 9431 | btAmpConfig.ucPreferredChannel = pConfig->preferredChannel; |
| 9432 | status = WLANBAP_SetConfig(&btAmpConfig); |
| 9433 | |
| 9434 | #endif //WLAN_BTAMP_FEATURE |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9435 | |
Mihir Shete | 9c23877 | 2014-10-15 14:35:16 +0530 | [diff] [blame] | 9436 | /* |
| 9437 | * UapsdMask is 0xf if U-APSD is enbaled for all AC's... |
| 9438 | * The value of CFG_QOS_WMM_UAPSD_MASK_DEFAULT is 0xaa(Magic Value) |
| 9439 | * which is greater than 0xf. So the below check is safe to make |
| 9440 | * sure that there is no entry for UapsdMask in the ini |
| 9441 | */ |
| 9442 | if (CFG_QOS_WMM_UAPSD_MASK_DEFAULT == pHddCtx->cfg_ini->UapsdMask) |
| 9443 | { |
| 9444 | if(IS_DYNAMIC_WMM_PS_ENABLED) |
| 9445 | { |
| 9446 | hddLog(VOS_TRACE_LEVEL_DEBUG,"%s: Enable UAPSD for VI & VO", |
| 9447 | __func__); |
| 9448 | pHddCtx->cfg_ini->UapsdMask = |
| 9449 | CFG_QOS_WMM_UAPSD_MASK_DYMANIC_WMM_PS_DEFAULT; |
| 9450 | } |
| 9451 | else |
| 9452 | { |
| 9453 | hddLog(VOS_TRACE_LEVEL_DEBUG,"%s: Do not enable UAPSD", |
| 9454 | __func__); |
| 9455 | pHddCtx->cfg_ini->UapsdMask = |
| 9456 | CFG_QOS_WMM_UAPSD_MASK_LEGACY_WMM_PS_DEFAULT; |
| 9457 | } |
| 9458 | } |
| 9459 | |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 9460 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 9461 | if(!(IS_ROAM_SCAN_OFFLOAD_FEATURE_ENABLE)) |
| 9462 | { |
| 9463 | hddLog(VOS_TRACE_LEVEL_DEBUG,"%s: ROAM_SCAN_OFFLOAD Feature not supported",__func__); |
| 9464 | pHddCtx->cfg_ini->isRoamOffloadScanEnabled = 0; |
| 9465 | sme_UpdateRoamScanOffloadEnabled((tHalHandle)(pHddCtx->hHal), |
| 9466 | pHddCtx->cfg_ini->isRoamOffloadScanEnabled); |
| 9467 | } |
| 9468 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9469 | |
Agarwal Ashish | 4b87f92 | 2014-06-18 03:03:21 +0530 | [diff] [blame] | 9470 | wlan_hdd_tdls_init(pHddCtx); |
| 9471 | |
Mihir Shete | fc7ff5b | 2014-01-27 11:30:05 +0530 | [diff] [blame] | 9472 | sme_Register11dScanDoneCallback(pHddCtx->hHal, hdd_11d_scan_done); |
| 9473 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9474 | /* Register with platform driver as client for Suspend/Resume */ |
| 9475 | status = hddRegisterPmOps(pHddCtx); |
| 9476 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 9477 | { |
| 9478 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddRegisterPmOps failed",__func__); |
| 9479 | #ifdef WLAN_BTAMP_FEATURE |
| 9480 | goto err_bap_stop; |
| 9481 | #else |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9482 | goto err_close_adapter; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9483 | #endif //WLAN_BTAMP_FEATURE |
| 9484 | } |
| 9485 | |
Yue Ma | 0d4891e | 2013-08-06 17:01:45 -0700 | [diff] [blame] | 9486 | /* Open debugfs interface */ |
| 9487 | if (VOS_STATUS_SUCCESS != hdd_debugfs_init(pAdapter)) |
| 9488 | { |
| 9489 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 9490 | "%s: hdd_debugfs_init failed!", __func__); |
Yue Ma | 0d4891e | 2013-08-06 17:01:45 -0700 | [diff] [blame] | 9491 | } |
| 9492 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9493 | /* Register TM level change handler function to the platform */ |
| 9494 | status = hddDevTmRegisterNotifyCallback(pHddCtx); |
| 9495 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 9496 | { |
| 9497 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddDevTmRegisterNotifyCallback failed",__func__); |
| 9498 | goto err_unregister_pmops; |
| 9499 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9500 | |
| 9501 | /* register for riva power on lock to platform driver */ |
| 9502 | if (req_riva_power_on_lock("wlan")) |
| 9503 | { |
| 9504 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: req riva power on lock failed", |
| 9505 | __func__); |
| 9506 | goto err_unregister_pmops; |
| 9507 | } |
| 9508 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9509 | // register net device notifier for device change notification |
| 9510 | ret = register_netdevice_notifier(&hdd_netdev_notifier); |
| 9511 | |
| 9512 | if(ret < 0) |
| 9513 | { |
| 9514 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: register_netdevice_notifier failed",__func__); |
| 9515 | goto err_free_power_on_lock; |
| 9516 | } |
| 9517 | |
| 9518 | //Initialize the nlink service |
| 9519 | if(nl_srv_init() != 0) |
| 9520 | { |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 9521 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: nl_srv_init failed", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9522 | goto err_reg_netdev; |
| 9523 | } |
| 9524 | |
Leo Chang | 4ce1cc5 | 2013-10-21 18:27:15 -0700 | [diff] [blame] | 9525 | #ifdef WLAN_KD_READY_NOTIFIER |
| 9526 | pHddCtx->kd_nl_init = 1; |
| 9527 | #endif /* WLAN_KD_READY_NOTIFIER */ |
| 9528 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9529 | //Initialize the BTC service |
| 9530 | if(btc_activate_service(pHddCtx) != 0) |
| 9531 | { |
| 9532 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: btc_activate_service failed",__func__); |
| 9533 | goto err_nl_srv; |
| 9534 | } |
| 9535 | |
| 9536 | #ifdef PTT_SOCK_SVC_ENABLE |
| 9537 | //Initialize the PTT service |
| 9538 | if(ptt_sock_activate_svc(pHddCtx) != 0) |
| 9539 | { |
| 9540 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: ptt_sock_activate_svc failed",__func__); |
| 9541 | goto err_nl_srv; |
| 9542 | } |
| 9543 | #endif |
| 9544 | |
Vinay Krishna Eranna | d938c42 | 2014-03-10 17:14:21 +0530 | [diff] [blame] | 9545 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 9546 | if(pHddCtx->cfg_ini && pHddCtx->cfg_ini->wlanLoggingEnable) |
| 9547 | { |
Deepthi Gowri | 78083a3 | 2014-11-04 12:55:51 +0530 | [diff] [blame] | 9548 | if(wlan_logging_sock_activate_svc( |
| 9549 | pHddCtx->cfg_ini->wlanLoggingFEToConsole, |
| 9550 | pHddCtx->cfg_ini->wlanLoggingNumBuf)) |
| 9551 | { |
| 9552 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wlan_logging_sock_activate_svc" |
| 9553 | " failed", __func__); |
| 9554 | goto err_nl_srv; |
| 9555 | } |
| 9556 | //TODO: To Remove enableDhcpDebug and use gEnableDebugLog for |
| 9557 | //EAPOL and DHCP |
Sachin Ahuja | 8c65f38 | 2014-12-12 15:34:21 +0530 | [diff] [blame] | 9558 | if (!pHddCtx->cfg_ini->gEnableDebugLog) |
| 9559 | pHddCtx->cfg_ini->gEnableDebugLog = |
| 9560 | VOS_PKT_PROTO_TYPE_EAPOL | VOS_PKT_PROTO_TYPE_DHCP; |
Vinay Krishna Eranna | d938c42 | 2014-03-10 17:14:21 +0530 | [diff] [blame] | 9561 | } |
| 9562 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9563 | hdd_register_mcast_bcast_filter(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9564 | if (VOS_STA_SAP_MODE != hdd_get_conparam()) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9565 | { |
Madan Mohan Koyyalamudi | c537df2 | 2012-10-22 15:07:08 -0700 | [diff] [blame] | 9566 | /* Action frame registered in one adapter which will |
| 9567 | * applicable to all interfaces |
| 9568 | */ |
Agarwal Ashish | 8fa0e9a | 2014-05-23 00:40:12 +0530 | [diff] [blame] | 9569 | wlan_hdd_cfg80211_register_frames(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9570 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9571 | |
| 9572 | mutex_init(&pHddCtx->sap_lock); |
Mahesh A Saptasagar | 6062794 | 2014-10-13 13:55:14 +0530 | [diff] [blame] | 9573 | mutex_init(&pHddCtx->roc_lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9574 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9575 | |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 9576 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9577 | #ifdef WLAN_FEATURE_HOLD_RX_WAKELOCK |
| 9578 | /* Initialize the wake lcok */ |
| 9579 | wake_lock_init(&pHddCtx->rx_wake_lock, |
| 9580 | WAKE_LOCK_SUSPEND, |
| 9581 | "qcom_rx_wakelock"); |
| 9582 | #endif |
Madan Mohan Koyyalamudi | 69fc3ad | 2012-11-28 16:04:56 -0800 | [diff] [blame] | 9583 | /* Initialize the wake lcok */ |
| 9584 | wake_lock_init(&pHddCtx->sap_wake_lock, |
| 9585 | WAKE_LOCK_SUSPEND, |
| 9586 | "qcom_sap_wakelock"); |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 9587 | #endif |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9588 | |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 9589 | vos_event_init(&pHddCtx->scan_info.scan_finished_event); |
| 9590 | pHddCtx->scan_info.scan_pending_option = WEXT_SCAN_PENDING_GIVEUP; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9591 | |
Katya Nigam | 5c306ea | 2014-06-19 15:39:54 +0530 | [diff] [blame] | 9592 | pHddCtx->isLoadUnloadInProgress = WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9593 | vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, FALSE); |
| 9594 | hdd_allow_suspend(); |
Katya Nigam | 5c306ea | 2014-06-19 15:39:54 +0530 | [diff] [blame] | 9595 | |
| 9596 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 9597 | /*SME must send channel update configuration to RIVA*/ |
| 9598 | sme_UpdateChannelConfig(pHddCtx->hHal); |
| 9599 | #endif |
Abhishek Singh | f644b27 | 2014-08-21 02:59:39 +0530 | [diff] [blame] | 9600 | /* Send the update default channel list to the FW*/ |
| 9601 | sme_UpdateChannelList(pHddCtx->hHal); |
Abhishek Singh | a306a44 | 2013-11-07 18:39:01 +0530 | [diff] [blame] | 9602 | #ifndef CONFIG_ENABLE_LINUX_REG |
| 9603 | /*updating wiphy so that regulatory user hints can be processed*/ |
| 9604 | if (wiphy) |
| 9605 | { |
| 9606 | regulatory_hint(wiphy, "00"); |
| 9607 | } |
| 9608 | #endif |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9609 | // Initialize the restart logic |
| 9610 | wlan_hdd_restart_init(pHddCtx); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 9611 | |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 9612 | //Register the traffic monitor timer now |
| 9613 | if ( pHddCtx->cfg_ini->dynSplitscan) |
| 9614 | { |
| 9615 | vos_timer_init(&pHddCtx->tx_rx_trafficTmr, |
| 9616 | VOS_TIMER_TYPE_SW, |
| 9617 | hdd_tx_rx_pkt_cnt_stat_timer_handler, |
| 9618 | (void *)pHddCtx); |
| 9619 | } |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 9620 | #ifdef WLAN_FEATURE_EXTSCAN |
| 9621 | sme_EXTScanRegisterCallback(pHddCtx->hHal, |
| 9622 | wlan_hdd_cfg80211_extscan_callback, |
| 9623 | pHddCtx); |
| 9624 | #endif /* WLAN_FEATURE_EXTSCAN */ |
Vinay Krishna Eranna | f97ef5c | 2014-12-26 17:47:19 +0530 | [diff] [blame] | 9625 | |
| 9626 | #ifdef WLAN_NS_OFFLOAD |
| 9627 | // Register IPv6 notifier to notify if any change in IP |
| 9628 | // So that we can reconfigure the offload parameters |
| 9629 | pHddCtx->ipv6_notifier.notifier_call = wlan_hdd_ipv6_changed; |
| 9630 | ret = register_inet6addr_notifier(&pHddCtx->ipv6_notifier); |
| 9631 | if (ret) |
| 9632 | { |
| 9633 | hddLog(LOGE, FL("Failed to register IPv6 notifier")); |
| 9634 | } |
| 9635 | else |
| 9636 | { |
| 9637 | hddLog(LOGE, FL("Registered IPv6 notifier")); |
| 9638 | } |
| 9639 | #endif |
| 9640 | |
| 9641 | // Register IPv4 notifier to notify if any change in IP |
| 9642 | // So that we can reconfigure the offload parameters |
| 9643 | pHddCtx->ipv4_notifier.notifier_call = wlan_hdd_ipv4_changed; |
| 9644 | ret = register_inetaddr_notifier(&pHddCtx->ipv4_notifier); |
| 9645 | if (ret) |
| 9646 | { |
| 9647 | hddLog(LOGE, FL("Failed to register IPv4 notifier")); |
| 9648 | } |
| 9649 | else |
| 9650 | { |
| 9651 | hddLog(LOGE, FL("Registered IPv4 notifier")); |
| 9652 | } |
| 9653 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9654 | goto success; |
| 9655 | |
| 9656 | err_nl_srv: |
Leo Chang | 59cdc7e | 2013-07-10 10:08:21 -0700 | [diff] [blame] | 9657 | #ifdef WLAN_KD_READY_NOTIFIER |
| 9658 | nl_srv_exit(pHddCtx->ptt_pid); |
| 9659 | #else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9660 | nl_srv_exit(); |
Leo Chang | 59cdc7e | 2013-07-10 10:08:21 -0700 | [diff] [blame] | 9661 | #endif /* WLAN_KD_READY_NOTIFIER */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9662 | err_reg_netdev: |
| 9663 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 9664 | |
| 9665 | err_free_power_on_lock: |
| 9666 | free_riva_power_on_lock("wlan"); |
| 9667 | |
| 9668 | err_unregister_pmops: |
| 9669 | hddDevTmUnregisterNotifyCallback(pHddCtx); |
| 9670 | hddDeregisterPmOps(pHddCtx); |
| 9671 | |
Yue Ma | 0d4891e | 2013-08-06 17:01:45 -0700 | [diff] [blame] | 9672 | hdd_debugfs_exit(pHddCtx); |
| 9673 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9674 | #ifdef WLAN_BTAMP_FEATURE |
| 9675 | err_bap_stop: |
| 9676 | WLANBAP_Stop(pVosContext); |
| 9677 | #endif |
| 9678 | |
| 9679 | #ifdef WLAN_BTAMP_FEATURE |
| 9680 | err_bap_close: |
| 9681 | WLANBAP_Close(pVosContext); |
| 9682 | #endif |
| 9683 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9684 | err_close_adapter: |
| 9685 | hdd_close_all_adapters( pHddCtx ); |
Mahesh A Saptasagar | 9ecefe4 | 2014-07-15 18:43:49 +0530 | [diff] [blame] | 9686 | #ifdef CONFIG_ENABLE_LINUX_REG |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 9687 | err_unregister_wiphy: |
Mahesh A Saptasagar | 9ecefe4 | 2014-07-15 18:43:49 +0530 | [diff] [blame] | 9688 | #endif |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 9689 | wiphy_unregister(wiphy) ; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9690 | err_vosstop: |
| 9691 | vos_stop(pVosContext); |
| 9692 | |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 9693 | err_vosclose: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9694 | status = vos_sched_close( pVosContext ); |
| 9695 | if (!VOS_IS_STATUS_SUCCESS(status)) { |
| 9696 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, |
| 9697 | "%s: Failed to close VOSS Scheduler", __func__); |
| 9698 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( status ) ); |
| 9699 | } |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 9700 | vos_close(pVosContext ); |
| 9701 | |
Amar Singhal | 0a40223 | 2013-10-11 20:57:16 -0700 | [diff] [blame] | 9702 | err_vos_nv_close: |
| 9703 | |
c_hpothu | e6a3628 | 2014-03-19 12:27:38 +0530 | [diff] [blame] | 9704 | #ifdef CONFIG_ENABLE_LINUX_REG |
Amar Singhal | 0a40223 | 2013-10-11 20:57:16 -0700 | [diff] [blame] | 9705 | vos_nv_close(); |
| 9706 | |
c_hpothu | 70f8d81 | 2014-03-22 22:59:23 +0530 | [diff] [blame] | 9707 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9708 | |
| 9709 | err_wdclose: |
| 9710 | if(pHddCtx->cfg_ini->fIsLogpEnabled) |
| 9711 | vos_watchdog_close(pVosContext); |
| 9712 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9713 | err_config: |
| 9714 | kfree(pHddCtx->cfg_ini); |
| 9715 | pHddCtx->cfg_ini= NULL; |
| 9716 | |
| 9717 | err_free_hdd_context: |
| 9718 | hdd_allow_suspend(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9719 | wiphy_free(wiphy) ; |
| 9720 | //kfree(wdev) ; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9721 | VOS_BUG(1); |
| 9722 | |
Madan Mohan Koyyalamudi | d57ae63 | 2012-11-06 18:42:48 -0800 | [diff] [blame] | 9723 | if (hdd_is_ssr_required()) |
| 9724 | { |
| 9725 | /* WDI timeout had happened during load, so SSR is needed here */ |
| 9726 | subsystem_restart("wcnss"); |
| 9727 | msleep(5000); |
| 9728 | } |
| 9729 | hdd_set_ssr_required (VOS_FALSE); |
| 9730 | |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 9731 | return -EIO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9732 | |
| 9733 | success: |
| 9734 | EXIT(); |
| 9735 | return 0; |
| 9736 | } |
| 9737 | |
| 9738 | /**--------------------------------------------------------------------------- |
| 9739 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 9740 | \brief hdd_driver_init() - Core Driver Init Function |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9741 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 9742 | This is the driver entry point - called in different timeline depending |
| 9743 | on whether the driver is statically or dynamically linked |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9744 | |
| 9745 | \param - None |
| 9746 | |
| 9747 | \return - 0 for success, non zero for failure |
| 9748 | |
| 9749 | --------------------------------------------------------------------------*/ |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 9750 | static int hdd_driver_init( void) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9751 | { |
| 9752 | VOS_STATUS status; |
| 9753 | v_CONTEXT_t pVosContext = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9754 | struct device *dev = NULL; |
| 9755 | int ret_status = 0; |
Sameer Thalappil | f58d7ec | 2013-04-25 20:17:12 -0700 | [diff] [blame] | 9756 | #ifdef HAVE_WCNSS_CAL_DOWNLOAD |
| 9757 | int max_retries = 0; |
| 9758 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9759 | |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 9760 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 9761 | wlan_logging_sock_init_svc(); |
| 9762 | #endif |
| 9763 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9764 | ENTER(); |
| 9765 | |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 9766 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9767 | wake_lock_init(&wlan_wake_lock, WAKE_LOCK_SUSPEND, "wlan"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9768 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9769 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 9770 | hddTraceInit(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9771 | pr_info("%s: loading driver v%s\n", WLAN_MODULE_NAME, |
| 9772 | QWLAN_VERSIONSTR TIMER_MANAGER_STR MEMORY_DEBUG_STR); |
| 9773 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9774 | #ifdef ANI_BUS_TYPE_PCI |
| 9775 | |
| 9776 | dev = wcnss_wlan_get_device(); |
| 9777 | |
| 9778 | #endif // ANI_BUS_TYPE_PCI |
| 9779 | |
| 9780 | #ifdef ANI_BUS_TYPE_PLATFORM |
Sameer Thalappil | f58d7ec | 2013-04-25 20:17:12 -0700 | [diff] [blame] | 9781 | |
| 9782 | #ifdef HAVE_WCNSS_CAL_DOWNLOAD |
| 9783 | /* wait until WCNSS driver downloads NV */ |
| 9784 | while (!wcnss_device_ready() && 5 >= ++max_retries) { |
| 9785 | msleep(1000); |
| 9786 | } |
| 9787 | if (max_retries >= 5) { |
| 9788 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: WCNSS driver not ready", __func__); |
madan mohan koyyalamudi | 8c96ce1 | 2013-07-10 19:14:39 +0530 | [diff] [blame] | 9789 | #ifdef WLAN_OPEN_SOURCE |
| 9790 | wake_lock_destroy(&wlan_wake_lock); |
| 9791 | #endif |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 9792 | |
| 9793 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 9794 | wlan_logging_sock_deinit_svc(); |
| 9795 | #endif |
| 9796 | |
Sameer Thalappil | f58d7ec | 2013-04-25 20:17:12 -0700 | [diff] [blame] | 9797 | return -ENODEV; |
| 9798 | } |
| 9799 | #endif |
| 9800 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9801 | dev = wcnss_wlan_get_device(); |
| 9802 | #endif // ANI_BUS_TYPE_PLATFORM |
| 9803 | |
| 9804 | |
| 9805 | do { |
| 9806 | if (NULL == dev) { |
| 9807 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: WLAN device not found!!",__func__); |
| 9808 | ret_status = -1; |
| 9809 | break; |
| 9810 | } |
| 9811 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9812 | #ifdef TIMER_MANAGER |
| 9813 | vos_timer_manager_init(); |
| 9814 | #endif |
| 9815 | |
| 9816 | /* Preopen VOSS so that it is ready to start at least SAL */ |
| 9817 | status = vos_preOpen(&pVosContext); |
| 9818 | |
| 9819 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 9820 | { |
| 9821 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Failed to preOpen VOSS", __func__); |
| 9822 | ret_status = -1; |
| 9823 | break; |
| 9824 | } |
| 9825 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 9826 | #ifndef MODULE |
| 9827 | /* For statically linked driver, call hdd_set_conparam to update curr_con_mode |
| 9828 | */ |
| 9829 | hdd_set_conparam((v_UINT_t)con_mode); |
| 9830 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9831 | |
| 9832 | // Call our main init function |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 9833 | if (hdd_wlan_startup(dev)) |
| 9834 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9835 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: WLAN Driver Initialization failed", |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 9836 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9837 | vos_preClose( &pVosContext ); |
| 9838 | ret_status = -1; |
| 9839 | break; |
| 9840 | } |
| 9841 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9842 | } while (0); |
| 9843 | |
| 9844 | if (0 != ret_status) |
| 9845 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9846 | #ifdef TIMER_MANAGER |
| 9847 | vos_timer_exit(); |
| 9848 | #endif |
| 9849 | #ifdef MEMORY_DEBUG |
| 9850 | vos_mem_exit(); |
| 9851 | #endif |
| 9852 | |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 9853 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9854 | wake_lock_destroy(&wlan_wake_lock); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9855 | #endif |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 9856 | |
| 9857 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 9858 | wlan_logging_sock_deinit_svc(); |
| 9859 | #endif |
| 9860 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9861 | pr_err("%s: driver load failure\n", WLAN_MODULE_NAME); |
| 9862 | } |
| 9863 | else |
| 9864 | { |
| 9865 | //Send WLAN UP indication to Nlink Service |
| 9866 | send_btc_nlink_msg(WLAN_MODULE_UP_IND, 0); |
| 9867 | |
| 9868 | pr_info("%s: driver loaded\n", WLAN_MODULE_NAME); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9869 | } |
| 9870 | |
| 9871 | EXIT(); |
| 9872 | |
| 9873 | return ret_status; |
| 9874 | } |
| 9875 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 9876 | /**--------------------------------------------------------------------------- |
| 9877 | |
| 9878 | \brief hdd_module_init() - Init Function |
| 9879 | |
| 9880 | This is the driver entry point (invoked when module is loaded using insmod) |
| 9881 | |
| 9882 | \param - None |
| 9883 | |
| 9884 | \return - 0 for success, non zero for failure |
| 9885 | |
| 9886 | --------------------------------------------------------------------------*/ |
| 9887 | #ifdef MODULE |
| 9888 | static int __init hdd_module_init ( void) |
| 9889 | { |
| 9890 | return hdd_driver_init(); |
| 9891 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 9892 | #else /* #ifdef MODULE */ |
| 9893 | static int __init hdd_module_init ( void) |
| 9894 | { |
| 9895 | /* Driver initialization is delayed to fwpath_changed_handler */ |
| 9896 | return 0; |
| 9897 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 9898 | #endif /* #ifdef MODULE */ |
| 9899 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9900 | |
| 9901 | /**--------------------------------------------------------------------------- |
| 9902 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 9903 | \brief hdd_driver_exit() - Exit function |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9904 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 9905 | This is the driver exit point (invoked when module is unloaded using rmmod |
| 9906 | or con_mode was changed by userspace) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9907 | |
| 9908 | \param - None |
| 9909 | |
| 9910 | \return - None |
| 9911 | |
| 9912 | --------------------------------------------------------------------------*/ |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 9913 | static void hdd_driver_exit(void) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9914 | { |
| 9915 | hdd_context_t *pHddCtx = NULL; |
| 9916 | v_CONTEXT_t pVosContext = NULL; |
Siddharth Bhal | a204f57 | 2015-01-17 02:03:36 +0530 | [diff] [blame] | 9917 | pVosWatchdogContext pVosWDCtx = NULL; |
Agarwal Ashish | 5e41479 | 2014-06-08 15:25:23 +0530 | [diff] [blame] | 9918 | v_REGDOMAIN_t regId; |
Arun Kumar Khandavalli | e0b046d | 2014-03-01 21:54:25 +0530 | [diff] [blame] | 9919 | unsigned long rc = 0; |
Siddharth Bhal | a204f57 | 2015-01-17 02:03:36 +0530 | [diff] [blame] | 9920 | unsigned long flags; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9921 | |
| 9922 | pr_info("%s: unloading driver v%s\n", WLAN_MODULE_NAME, QWLAN_VERSIONSTR); |
| 9923 | |
| 9924 | //Get the global vos context |
| 9925 | pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL); |
| 9926 | |
| 9927 | if(!pVosContext) |
| 9928 | { |
| 9929 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Global VOS context is Null", __func__); |
| 9930 | goto done; |
| 9931 | } |
| 9932 | |
| 9933 | //Get the HDD context. |
| 9934 | pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext ); |
| 9935 | |
| 9936 | if(!pHddCtx) |
| 9937 | { |
| 9938 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: module exit called before probe",__func__); |
| 9939 | } |
| 9940 | else |
| 9941 | { |
Siddharth Bhal | a204f57 | 2015-01-17 02:03:36 +0530 | [diff] [blame] | 9942 | pVosWDCtx = get_vos_watchdog_ctxt(); |
| 9943 | if(pVosWDCtx == NULL) |
| 9944 | { |
| 9945 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("WD context is invalid")); |
| 9946 | goto done; |
| 9947 | } |
| 9948 | spin_lock_irqsave(&pVosWDCtx->wdLock, flags); |
| 9949 | if (!pHddCtx->isLogpInProgress || (TRUE == |
| 9950 | vos_is_wlan_in_badState(VOS_MODULE_ID_HDD, NULL))) |
| 9951 | { |
| 9952 | //SSR isn't in progress OR last wlan reinit wasn't successful |
| 9953 | pHddCtx->isLoadUnloadInProgress = WLAN_HDD_UNLOAD_IN_PROGRESS; |
| 9954 | vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, TRUE); |
| 9955 | spin_unlock_irqrestore(&pVosWDCtx->wdLock, flags); |
| 9956 | } |
| 9957 | else |
| 9958 | { |
| 9959 | INIT_COMPLETION(pHddCtx->ssr_comp_var); |
Arun Kumar Khandavalli | e0b046d | 2014-03-01 21:54:25 +0530 | [diff] [blame] | 9960 | |
Siddharth Bhal | a204f57 | 2015-01-17 02:03:36 +0530 | [diff] [blame] | 9961 | pHddCtx->isLoadUnloadInProgress = WLAN_HDD_UNLOAD_IN_PROGRESS; |
| 9962 | vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, TRUE); |
| 9963 | spin_unlock_irqrestore(&pVosWDCtx->wdLock, flags); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9964 | |
Siddharth Bhal | a204f57 | 2015-01-17 02:03:36 +0530 | [diff] [blame] | 9965 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9966 | "%s:SSR is in Progress; block rmmod !!!", __func__); |
| 9967 | rc = wait_for_completion_timeout(&pHddCtx->ssr_comp_var, |
| 9968 | msecs_to_jiffies(30000)); |
| 9969 | if(!rc) |
| 9970 | { |
| 9971 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 9972 | "%s:SSR timedout, fatal error", __func__); |
| 9973 | VOS_BUG(0); |
| 9974 | } |
| 9975 | } |
| 9976 | |
| 9977 | /* We wait for active entry threads to exit from driver |
| 9978 | * by waiting until rtnl_lock is available. |
| 9979 | */ |
| 9980 | rtnl_lock(); |
| 9981 | rtnl_unlock(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9982 | |
c_hpothu | 8adb97b | 2014-12-08 19:38:20 +0530 | [diff] [blame] | 9983 | /* Driver Need to send country code 00 in below condition |
| 9984 | * 1) If gCountryCodePriority is set to 1; and last country |
| 9985 | * code set is through 11d. This needs to be done in case |
| 9986 | * when NV country code is 00. |
| 9987 | * This Needs to be done as when kernel store last country |
| 9988 | * code and if stored country code is not through 11d, |
| 9989 | * in sme_HandleChangeCountryCodeByUser we will disable 11d |
| 9990 | * in next load/unload as soon as we get any country through |
| 9991 | * 11d. In sme_HandleChangeCountryCodeByUser |
| 9992 | * pMsg->countryCode will be last countryCode and |
| 9993 | * pMac->scan.countryCode11d will be country through 11d so |
| 9994 | * due to mismatch driver will disable 11d. |
| 9995 | * |
| 9996 | */ |
Agarwal Ashish | 8db3988 | 2014-07-30 21:56:07 +0530 | [diff] [blame] | 9997 | |
c_hpothu | 8adb97b | 2014-12-08 19:38:20 +0530 | [diff] [blame] | 9998 | if ((eANI_BOOLEAN_TRUE == sme_Is11dCountrycode(pHddCtx->hHal) && |
Agarwal Ashish | 8dcd286 | 2014-07-25 11:58:52 +0530 | [diff] [blame] | 9999 | pHddCtx->cfg_ini->fSupplicantCountryCodeHasPriority && |
Abhishek Singh | 2a70596 | 2014-10-30 14:47:28 +0530 | [diff] [blame] | 10000 | sme_Is11dSupported(pHddCtx->hHal))) |
c_hpothu | 8adb97b | 2014-12-08 19:38:20 +0530 | [diff] [blame] | 10001 | { |
| 10002 | hddLog(VOS_TRACE_LEVEL_INFO, |
Agarwal Ashish | 8dcd286 | 2014-07-25 11:58:52 +0530 | [diff] [blame] | 10003 | FL("CountryCode 00 is being set while unloading driver")); |
c_hpothu | 8adb97b | 2014-12-08 19:38:20 +0530 | [diff] [blame] | 10004 | vos_nv_getRegDomainFromCountryCode(®Id , "00", COUNTRY_USER); |
| 10005 | } |
Agarwal Ashish | 5e41479 | 2014-06-08 15:25:23 +0530 | [diff] [blame] | 10006 | |
c_hpothu | 8adb97b | 2014-12-08 19:38:20 +0530 | [diff] [blame] | 10007 | //Do all the cleanup before deregistering the driver |
| 10008 | hdd_wlan_exit(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10009 | } |
| 10010 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10011 | vos_preClose( &pVosContext ); |
| 10012 | |
| 10013 | #ifdef TIMER_MANAGER |
| 10014 | vos_timer_exit(); |
| 10015 | #endif |
| 10016 | #ifdef MEMORY_DEBUG |
| 10017 | vos_mem_exit(); |
| 10018 | #endif |
| 10019 | |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 10020 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 10021 | wlan_logging_sock_deinit_svc(); |
| 10022 | #endif |
| 10023 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10024 | done: |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 10025 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10026 | wake_lock_destroy(&wlan_wake_lock); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10027 | #endif |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 10028 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10029 | pr_info("%s: driver unloaded\n", WLAN_MODULE_NAME); |
| 10030 | } |
| 10031 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 10032 | /**--------------------------------------------------------------------------- |
| 10033 | |
| 10034 | \brief hdd_module_exit() - Exit function |
| 10035 | |
| 10036 | This is the driver exit point (invoked when module is unloaded using rmmod) |
| 10037 | |
| 10038 | \param - None |
| 10039 | |
| 10040 | \return - None |
| 10041 | |
| 10042 | --------------------------------------------------------------------------*/ |
| 10043 | static void __exit hdd_module_exit(void) |
| 10044 | { |
| 10045 | hdd_driver_exit(); |
| 10046 | } |
| 10047 | |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 10048 | #ifdef MODULE |
| 10049 | static int fwpath_changed_handler(const char *kmessage, |
| 10050 | struct kernel_param *kp) |
| 10051 | { |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 10052 | return param_set_copystring(kmessage, kp); |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 10053 | } |
| 10054 | |
| 10055 | static int con_mode_handler(const char *kmessage, |
| 10056 | struct kernel_param *kp) |
| 10057 | { |
Madan Mohan Koyyalamudi | f2f8d8b | 2012-10-11 17:06:59 -0700 | [diff] [blame] | 10058 | return param_set_int(kmessage, kp); |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 10059 | } |
| 10060 | #else /* #ifdef MODULE */ |
| 10061 | /**--------------------------------------------------------------------------- |
| 10062 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 10063 | \brief kickstart_driver |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 10064 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 10065 | This is the driver entry point |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 10066 | - delayed driver initialization when driver is statically linked |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 10067 | - invoked when module parameter fwpath is modified from userspace to signal |
| 10068 | initializing the WLAN driver or when con_mode is modified from userspace |
| 10069 | to signal a switch in operating mode |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 10070 | |
| 10071 | \return - 0 for success, non zero for failure |
| 10072 | |
| 10073 | --------------------------------------------------------------------------*/ |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 10074 | static int kickstart_driver(void) |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 10075 | { |
Madan Mohan Koyyalamudi | 62e6005 | 2012-10-05 14:27:22 -0700 | [diff] [blame] | 10076 | int ret_status; |
| 10077 | |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 10078 | if (!wlan_hdd_inited) { |
Madan Mohan Koyyalamudi | 62e6005 | 2012-10-05 14:27:22 -0700 | [diff] [blame] | 10079 | ret_status = hdd_driver_init(); |
| 10080 | wlan_hdd_inited = ret_status ? 0 : 1; |
| 10081 | return ret_status; |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 10082 | } |
| 10083 | |
| 10084 | hdd_driver_exit(); |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 10085 | |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 10086 | msleep(200); |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 10087 | |
Madan Mohan Koyyalamudi | 62e6005 | 2012-10-05 14:27:22 -0700 | [diff] [blame] | 10088 | ret_status = hdd_driver_init(); |
| 10089 | wlan_hdd_inited = ret_status ? 0 : 1; |
| 10090 | return ret_status; |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 10091 | } |
| 10092 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10093 | /**--------------------------------------------------------------------------- |
| 10094 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 10095 | \brief fwpath_changed_handler() - Handler Function |
| 10096 | |
| 10097 | Handle changes to the fwpath parameter |
| 10098 | |
| 10099 | \return - 0 for success, non zero for failure |
| 10100 | |
| 10101 | --------------------------------------------------------------------------*/ |
| 10102 | static int fwpath_changed_handler(const char *kmessage, |
| 10103 | struct kernel_param *kp) |
| 10104 | { |
| 10105 | int ret; |
| 10106 | |
| 10107 | ret = param_set_copystring(kmessage, kp); |
| 10108 | if (0 == ret) |
| 10109 | ret = kickstart_driver(); |
| 10110 | return ret; |
| 10111 | } |
| 10112 | |
| 10113 | /**--------------------------------------------------------------------------- |
| 10114 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 10115 | \brief con_mode_handler() - |
| 10116 | |
| 10117 | Handler function for module param con_mode when it is changed by userspace |
| 10118 | Dynamically linked - do nothing |
| 10119 | Statically linked - exit and init driver, as in rmmod and insmod |
| 10120 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 10121 | \param - |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 10122 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 10123 | \return - |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 10124 | |
| 10125 | --------------------------------------------------------------------------*/ |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 10126 | 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] | 10127 | { |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 10128 | int ret; |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 10129 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 10130 | ret = param_set_int(kmessage, kp); |
| 10131 | if (0 == ret) |
| 10132 | ret = kickstart_driver(); |
| 10133 | return ret; |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 10134 | } |
| 10135 | #endif /* #ifdef MODULE */ |
| 10136 | |
| 10137 | /**--------------------------------------------------------------------------- |
| 10138 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10139 | \brief hdd_get_conparam() - |
| 10140 | |
| 10141 | This is the driver exit point (invoked when module is unloaded using rmmod) |
| 10142 | |
| 10143 | \param - None |
| 10144 | |
| 10145 | \return - tVOS_CON_MODE |
| 10146 | |
| 10147 | --------------------------------------------------------------------------*/ |
| 10148 | tVOS_CON_MODE hdd_get_conparam ( void ) |
| 10149 | { |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 10150 | #ifdef MODULE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10151 | return (tVOS_CON_MODE)con_mode; |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 10152 | #else |
| 10153 | return (tVOS_CON_MODE)curr_con_mode; |
| 10154 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10155 | } |
| 10156 | void hdd_set_conparam ( v_UINT_t newParam ) |
| 10157 | { |
| 10158 | con_mode = newParam; |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 10159 | #ifndef MODULE |
| 10160 | curr_con_mode = con_mode; |
| 10161 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10162 | } |
| 10163 | /**--------------------------------------------------------------------------- |
| 10164 | |
| 10165 | \brief hdd_softap_sta_deauth() - function |
| 10166 | |
| 10167 | This to take counter measure to handle deauth req from HDD |
| 10168 | |
| 10169 | \param - pAdapter - Pointer to the HDD |
| 10170 | |
| 10171 | \param - enable - boolean value |
| 10172 | |
| 10173 | \return - None |
| 10174 | |
| 10175 | --------------------------------------------------------------------------*/ |
| 10176 | |
Hanumantha Reddy Pothula | bfd06f7 | 2014-10-31 14:03:37 +0530 | [diff] [blame] | 10177 | VOS_STATUS hdd_softap_sta_deauth(hdd_adapter_t *pAdapter, |
| 10178 | struct tagCsrDelStaParams *pDelStaParams) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10179 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10180 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 10181 | VOS_STATUS vosStatus = VOS_STATUS_E_FAULT; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10182 | |
| 10183 | ENTER(); |
| 10184 | |
Rajesh Chauhan | 18488fc | 2013-08-22 10:15:03 -0700 | [diff] [blame] | 10185 | hddLog(LOG1, "hdd_softap_sta_deauth:(%p, false)", |
| 10186 | (WLAN_HDD_GET_CTX(pAdapter))->pvosContext); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10187 | |
| 10188 | //Ignore request to deauth bcmc station |
Hanumantha Reddy Pothula | bfd06f7 | 2014-10-31 14:03:37 +0530 | [diff] [blame] | 10189 | if (pDelStaParams->peerMacAddr[0] & 0x1) |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 10190 | return vosStatus; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10191 | |
Hanumantha Reddy Pothula | bfd06f7 | 2014-10-31 14:03:37 +0530 | [diff] [blame] | 10192 | vosStatus = WLANSAP_DeauthSta(pVosContext, pDelStaParams); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10193 | |
| 10194 | EXIT(); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 10195 | return vosStatus; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10196 | } |
| 10197 | |
| 10198 | /**--------------------------------------------------------------------------- |
| 10199 | |
Rashmi Ramanna | 1f0948d | 2014-08-28 15:33:48 +0530 | [diff] [blame] | 10200 | \brief hdd_del_all_sta() - function |
| 10201 | |
| 10202 | This function removes all the stations associated on stopping AP/P2P GO. |
| 10203 | |
| 10204 | \param - pAdapter - Pointer to the HDD |
| 10205 | |
| 10206 | \return - None |
| 10207 | |
| 10208 | --------------------------------------------------------------------------*/ |
| 10209 | |
| 10210 | int hdd_del_all_sta(hdd_adapter_t *pAdapter) |
| 10211 | { |
| 10212 | v_U16_t i; |
| 10213 | VOS_STATUS vos_status; |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 10214 | v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
| 10215 | ptSapContext pSapCtx = NULL; |
| 10216 | pSapCtx = VOS_GET_SAP_CB(pVosContext); |
| 10217 | if(pSapCtx == NULL){ |
| 10218 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10219 | FL("psapCtx is NULL")); |
| 10220 | return 1; |
| 10221 | } |
Rashmi Ramanna | 1f0948d | 2014-08-28 15:33:48 +0530 | [diff] [blame] | 10222 | ENTER(); |
| 10223 | |
| 10224 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 10225 | "%s: Delete all STAs associated.",__func__); |
| 10226 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
| 10227 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
| 10228 | ) |
| 10229 | { |
| 10230 | for(i = 0; i < WLAN_MAX_STA_COUNT; i++) |
| 10231 | { |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 10232 | if ((pSapCtx->aStaInfo[i].isUsed) && |
| 10233 | (!pSapCtx->aStaInfo[i].isDeauthInProgress)) |
Rashmi Ramanna | 1f0948d | 2014-08-28 15:33:48 +0530 | [diff] [blame] | 10234 | { |
Hanumantha Reddy Pothula | bfd06f7 | 2014-10-31 14:03:37 +0530 | [diff] [blame] | 10235 | struct tagCsrDelStaParams delStaParams; |
| 10236 | |
| 10237 | WLANSAP_PopulateDelStaParams( |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 10238 | pSapCtx->aStaInfo[i].macAddrSTA.bytes, |
Sushant Kaushik | 4cd28f6 | 2014-12-26 14:23:50 +0530 | [diff] [blame] | 10239 | eSIR_MAC_DEAUTH_LEAVING_BSS_REASON, |
| 10240 | SIR_MAC_MGMT_DEAUTH >> 4, |
Hanumantha Reddy Pothula | bfd06f7 | 2014-10-31 14:03:37 +0530 | [diff] [blame] | 10241 | &delStaParams); |
| 10242 | vos_status = hdd_softap_sta_deauth(pAdapter, &delStaParams); |
Rashmi Ramanna | 1f0948d | 2014-08-28 15:33:48 +0530 | [diff] [blame] | 10243 | if (VOS_IS_STATUS_SUCCESS(vos_status)) |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 10244 | pSapCtx->aStaInfo[i].isDeauthInProgress = TRUE; |
Rashmi Ramanna | 1f0948d | 2014-08-28 15:33:48 +0530 | [diff] [blame] | 10245 | } |
| 10246 | } |
| 10247 | } |
| 10248 | |
| 10249 | EXIT(); |
| 10250 | return 0; |
| 10251 | } |
| 10252 | |
| 10253 | /**--------------------------------------------------------------------------- |
| 10254 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10255 | \brief hdd_softap_sta_disassoc() - function |
| 10256 | |
| 10257 | This to take counter measure to handle deauth req from HDD |
| 10258 | |
| 10259 | \param - pAdapter - Pointer to the HDD |
| 10260 | |
| 10261 | \param - enable - boolean value |
| 10262 | |
| 10263 | \return - None |
| 10264 | |
| 10265 | --------------------------------------------------------------------------*/ |
| 10266 | |
| 10267 | void hdd_softap_sta_disassoc(hdd_adapter_t *pAdapter,v_U8_t *pDestMacAddress) |
| 10268 | { |
| 10269 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
| 10270 | |
| 10271 | ENTER(); |
| 10272 | |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 10273 | 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] | 10274 | |
| 10275 | //Ignore request to disassoc bcmc station |
| 10276 | if( pDestMacAddress[0] & 0x1 ) |
| 10277 | return; |
| 10278 | |
| 10279 | WLANSAP_DisassocSta(pVosContext,pDestMacAddress); |
| 10280 | } |
| 10281 | |
| 10282 | void hdd_softap_tkip_mic_fail_counter_measure(hdd_adapter_t *pAdapter,v_BOOL_t enable) |
| 10283 | { |
| 10284 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
| 10285 | |
| 10286 | ENTER(); |
| 10287 | |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 10288 | 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] | 10289 | |
| 10290 | WLANSAP_SetCounterMeasure(pVosContext, (v_BOOL_t)enable); |
| 10291 | } |
| 10292 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10293 | /**--------------------------------------------------------------------------- |
| 10294 | * |
| 10295 | * \brief hdd_get__concurrency_mode() - |
| 10296 | * |
| 10297 | * |
| 10298 | * \param - None |
| 10299 | * |
| 10300 | * \return - CONCURRENCY MODE |
| 10301 | * |
| 10302 | * --------------------------------------------------------------------------*/ |
| 10303 | tVOS_CONCURRENCY_MODE hdd_get_concurrency_mode ( void ) |
| 10304 | { |
| 10305 | v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL ); |
| 10306 | hdd_context_t *pHddCtx; |
| 10307 | |
| 10308 | if (NULL != pVosContext) |
| 10309 | { |
| 10310 | pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext); |
| 10311 | if (NULL != pHddCtx) |
| 10312 | { |
| 10313 | return (tVOS_CONCURRENCY_MODE)pHddCtx->concurrency_mode; |
| 10314 | } |
| 10315 | } |
| 10316 | |
| 10317 | /* we are in an invalid state :( */ |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 10318 | hddLog(LOGE, "%s: Invalid context", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10319 | return VOS_STA; |
| 10320 | } |
Sushant Kaushik | abb7ee6 | 2014-07-18 16:20:12 +0530 | [diff] [blame] | 10321 | v_BOOL_t |
| 10322 | wlan_hdd_is_GO_power_collapse_allowed (hdd_context_t* pHddCtx) |
| 10323 | { |
| 10324 | hdd_adapter_t *pAdapter = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10325 | |
Sushant Kaushik | abb7ee6 | 2014-07-18 16:20:12 +0530 | [diff] [blame] | 10326 | pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_GO); |
| 10327 | if (pAdapter == NULL) |
| 10328 | { |
| 10329 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 10330 | FL("GO doesn't exist")); |
| 10331 | return TRUE; |
| 10332 | } |
| 10333 | if (test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags)) |
| 10334 | { |
| 10335 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 10336 | FL("GO started")); |
| 10337 | return TRUE; |
| 10338 | } |
| 10339 | else |
| 10340 | /* wait till GO changes its interface to p2p device */ |
| 10341 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 10342 | FL("Del_bss called, avoid apps suspend")); |
| 10343 | return FALSE; |
| 10344 | |
| 10345 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10346 | /* Decide whether to allow/not the apps power collapse. |
| 10347 | * Allow apps power collapse if we are in connected state. |
| 10348 | * if not, allow only if we are in IMPS */ |
| 10349 | v_BOOL_t hdd_is_apps_power_collapse_allowed(hdd_context_t* pHddCtx) |
| 10350 | { |
| 10351 | tPmcState pmcState = pmcGetPmcState(pHddCtx->hHal); |
Srikant Kuppa | fef66a7 | 2013-01-30 17:32:44 -0800 | [diff] [blame] | 10352 | tANI_BOOLEAN scanRspPending = csrNeighborRoamScanRspPending(pHddCtx->hHal); |
Srinivas Girigowda | a553c46 | 2013-03-07 19:42:52 -0800 | [diff] [blame] | 10353 | tANI_BOOLEAN inMiddleOfRoaming = csrNeighborMiddleOfRoaming(pHddCtx->hHal); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10354 | hdd_config_t *pConfig = pHddCtx->cfg_ini; |
| 10355 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 10356 | hdd_adapter_t *pAdapter = NULL; |
| 10357 | VOS_STATUS status; |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 10358 | tVOS_CONCURRENCY_MODE concurrent_state = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10359 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10360 | if (VOS_STA_SAP_MODE == hdd_get_conparam()) |
| 10361 | return TRUE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10362 | |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 10363 | concurrent_state = hdd_get_concurrency_mode(); |
| 10364 | |
Sushant Kaushik | abb7ee6 | 2014-07-18 16:20:12 +0530 | [diff] [blame] | 10365 | if ((concurrent_state == (VOS_STA | VOS_P2P_GO)) && |
| 10366 | !(wlan_hdd_is_GO_power_collapse_allowed(pHddCtx))) |
| 10367 | return FALSE; |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 10368 | #ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE |
Sushant Kaushik | abb7ee6 | 2014-07-18 16:20:12 +0530 | [diff] [blame] | 10369 | |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 10370 | if(((concurrent_state == (VOS_STA | VOS_P2P_CLIENT)) || |
Sushant Kaushik | abb7ee6 | 2014-07-18 16:20:12 +0530 | [diff] [blame] | 10371 | (concurrent_state == (VOS_STA | VOS_P2P_GO)))&& |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 10372 | (IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)) |
| 10373 | return TRUE; |
| 10374 | #endif |
| 10375 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10376 | /*loop through all adapters. TBD fix for Concurrency */ |
| 10377 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 10378 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 10379 | { |
| 10380 | pAdapter = pAdapterNode->pAdapter; |
| 10381 | if ( (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) |
| 10382 | || (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ) |
| 10383 | { |
Srikant Kuppa | fef66a7 | 2013-01-30 17:32:44 -0800 | [diff] [blame] | 10384 | if (((pConfig->fIsImpsEnabled || pConfig->fIsBmpsEnabled) |
c_hpothu | 4e8faac | 2014-05-16 17:38:44 +0530 | [diff] [blame] | 10385 | && (pmcState != IMPS && pmcState != BMPS && pmcState != UAPSD |
c_hpothu | 1c6957d | 2015-01-06 18:19:47 +0530 | [diff] [blame] | 10386 | && pmcState != STOPPED && pmcState != STANDBY && |
| 10387 | pmcState != WOWL)) || |
Srinivas Girigowda | a553c46 | 2013-03-07 19:42:52 -0800 | [diff] [blame] | 10388 | (eANI_BOOLEAN_TRUE == scanRspPending) || |
| 10389 | (eANI_BOOLEAN_TRUE == inMiddleOfRoaming)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10390 | { |
Srikant Kuppa | fef66a7 | 2013-01-30 17:32:44 -0800 | [diff] [blame] | 10391 | hddLog( LOGE, "%s: do not allow APPS power collapse-" |
Srinivas Girigowda | a553c46 | 2013-03-07 19:42:52 -0800 | [diff] [blame] | 10392 | "pmcState = %d scanRspPending = %d inMiddleOfRoaming = %d", |
| 10393 | __func__, pmcState, scanRspPending, inMiddleOfRoaming ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10394 | return FALSE; |
| 10395 | } |
| 10396 | } |
| 10397 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 10398 | pAdapterNode = pNext; |
| 10399 | } |
| 10400 | return TRUE; |
| 10401 | } |
| 10402 | |
Madan Mohan Koyyalamudi | c72a4d6 | 2012-11-08 14:59:34 -0800 | [diff] [blame] | 10403 | /* Decides whether to send suspend notification to Riva |
| 10404 | * if any adapter is in BMPS; then it is required */ |
| 10405 | v_BOOL_t hdd_is_suspend_notify_allowed(hdd_context_t* pHddCtx) |
| 10406 | { |
| 10407 | tPmcState pmcState = pmcGetPmcState(pHddCtx->hHal); |
| 10408 | hdd_config_t *pConfig = pHddCtx->cfg_ini; |
| 10409 | |
| 10410 | if (pConfig->fIsBmpsEnabled && (pmcState == BMPS)) |
| 10411 | { |
| 10412 | return TRUE; |
| 10413 | } |
| 10414 | return FALSE; |
| 10415 | } |
| 10416 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10417 | void wlan_hdd_set_concurrency_mode(hdd_context_t *pHddCtx, tVOS_CON_MODE mode) |
| 10418 | { |
| 10419 | switch(mode) |
| 10420 | { |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 10421 | case VOS_STA_MODE: |
| 10422 | case VOS_P2P_CLIENT_MODE: |
| 10423 | case VOS_P2P_GO_MODE: |
| 10424 | case VOS_STA_SAP_MODE: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10425 | pHddCtx->concurrency_mode |= (1 << mode); |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 10426 | pHddCtx->no_of_open_sessions[mode]++; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10427 | break; |
| 10428 | default: |
| 10429 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10430 | } |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 10431 | hddLog(VOS_TRACE_LEVEL_INFO, FL("concurrency_mode = 0x%x " |
| 10432 | "Number of open sessions for mode %d = %d"), |
| 10433 | pHddCtx->concurrency_mode, mode, |
| 10434 | pHddCtx->no_of_open_sessions[mode]); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10435 | } |
| 10436 | |
| 10437 | |
| 10438 | void wlan_hdd_clear_concurrency_mode(hdd_context_t *pHddCtx, tVOS_CON_MODE mode) |
| 10439 | { |
| 10440 | switch(mode) |
| 10441 | { |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 10442 | case VOS_STA_MODE: |
| 10443 | case VOS_P2P_CLIENT_MODE: |
| 10444 | case VOS_P2P_GO_MODE: |
| 10445 | case VOS_STA_SAP_MODE: |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 10446 | pHddCtx->no_of_open_sessions[mode]--; |
| 10447 | if (!(pHddCtx->no_of_open_sessions[mode])) |
| 10448 | pHddCtx->concurrency_mode &= (~(1 << mode)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10449 | break; |
| 10450 | default: |
| 10451 | break; |
| 10452 | } |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 10453 | hddLog(VOS_TRACE_LEVEL_INFO, FL("concurrency_mode = 0x%x " |
| 10454 | "Number of open sessions for mode %d = %d"), |
| 10455 | pHddCtx->concurrency_mode, mode, pHddCtx->no_of_open_sessions[mode]); |
| 10456 | |
| 10457 | } |
| 10458 | /**--------------------------------------------------------------------------- |
| 10459 | * |
| 10460 | * \brief wlan_hdd_incr_active_session() |
| 10461 | * |
| 10462 | * This function increments the number of active sessions |
| 10463 | * maintained per device mode |
| 10464 | * Incase of STA/P2P CLI/IBSS upon connection indication it is incremented |
| 10465 | * Incase of SAP/P2P GO upon bss start it is incremented |
| 10466 | * |
| 10467 | * \param pHddCtx - HDD Context |
| 10468 | * \param mode - device mode |
| 10469 | * |
| 10470 | * \return - None |
| 10471 | * |
| 10472 | * --------------------------------------------------------------------------*/ |
| 10473 | void wlan_hdd_incr_active_session(hdd_context_t *pHddCtx, tVOS_CON_MODE mode) |
| 10474 | { |
| 10475 | switch (mode) { |
| 10476 | case VOS_STA_MODE: |
| 10477 | case VOS_P2P_CLIENT_MODE: |
| 10478 | case VOS_P2P_GO_MODE: |
| 10479 | case VOS_STA_SAP_MODE: |
| 10480 | pHddCtx->no_of_active_sessions[mode]++; |
| 10481 | break; |
| 10482 | default: |
| 10483 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Not Expected Mode %d"), mode); |
| 10484 | break; |
| 10485 | } |
| 10486 | hddLog(VOS_TRACE_LEVEL_INFO, FL("No.# of active sessions for mode %d = %d"), |
| 10487 | mode, |
| 10488 | pHddCtx->no_of_active_sessions[mode]); |
| 10489 | } |
| 10490 | |
| 10491 | /**--------------------------------------------------------------------------- |
| 10492 | * |
| 10493 | * \brief wlan_hdd_decr_active_session() |
| 10494 | * |
| 10495 | * This function decrements the number of active sessions |
| 10496 | * maintained per device mode |
| 10497 | * Incase of STA/P2P CLI/IBSS upon disconnection it is decremented |
| 10498 | * Incase of SAP/P2P GO upon bss stop it is decremented |
| 10499 | * |
| 10500 | * \param pHddCtx - HDD Context |
| 10501 | * \param mode - device mode |
| 10502 | * |
| 10503 | * \return - None |
| 10504 | * |
| 10505 | * --------------------------------------------------------------------------*/ |
| 10506 | void wlan_hdd_decr_active_session(hdd_context_t *pHddCtx, tVOS_CON_MODE mode) |
| 10507 | { |
| 10508 | switch (mode) { |
| 10509 | case VOS_STA_MODE: |
| 10510 | case VOS_P2P_CLIENT_MODE: |
| 10511 | case VOS_P2P_GO_MODE: |
| 10512 | case VOS_STA_SAP_MODE: |
Agarwal Ashish | 5325f52 | 2014-08-06 00:58:44 +0530 | [diff] [blame] | 10513 | if (pHddCtx->no_of_active_sessions[mode] > 0) |
| 10514 | pHddCtx->no_of_active_sessions[mode]--; |
| 10515 | else |
| 10516 | hddLog(VOS_TRACE_LEVEL_INFO, FL(" No.# of Active sessions" |
| 10517 | "is already Zero")); |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 10518 | break; |
| 10519 | default: |
| 10520 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Not Expected Mode %d"), mode); |
| 10521 | break; |
| 10522 | } |
| 10523 | hddLog(VOS_TRACE_LEVEL_INFO, FL("No.# of active sessions for mode %d = %d"), |
| 10524 | mode, |
| 10525 | pHddCtx->no_of_active_sessions[mode]); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10526 | } |
| 10527 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10528 | /**--------------------------------------------------------------------------- |
| 10529 | * |
| 10530 | * \brief wlan_hdd_restart_init |
| 10531 | * |
| 10532 | * This function initalizes restart timer/flag. An internal function. |
| 10533 | * |
| 10534 | * \param - pHddCtx |
| 10535 | * |
| 10536 | * \return - None |
| 10537 | * |
| 10538 | * --------------------------------------------------------------------------*/ |
| 10539 | |
| 10540 | static void wlan_hdd_restart_init(hdd_context_t *pHddCtx) |
| 10541 | { |
| 10542 | /* Initialize */ |
| 10543 | pHddCtx->hdd_restart_retries = 0; |
| 10544 | atomic_set(&pHddCtx->isRestartInProgress, 0); |
| 10545 | vos_timer_init(&pHddCtx->hdd_restart_timer, |
| 10546 | VOS_TIMER_TYPE_SW, |
| 10547 | wlan_hdd_restart_timer_cb, |
| 10548 | pHddCtx); |
| 10549 | } |
| 10550 | /**--------------------------------------------------------------------------- |
| 10551 | * |
| 10552 | * \brief wlan_hdd_restart_deinit |
| 10553 | * |
| 10554 | * This function cleans up the resources used. An internal function. |
| 10555 | * |
| 10556 | * \param - pHddCtx |
| 10557 | * |
| 10558 | * \return - None |
| 10559 | * |
| 10560 | * --------------------------------------------------------------------------*/ |
| 10561 | |
| 10562 | static void wlan_hdd_restart_deinit(hdd_context_t* pHddCtx) |
| 10563 | { |
| 10564 | |
| 10565 | VOS_STATUS vos_status; |
| 10566 | /* Block any further calls */ |
| 10567 | atomic_set(&pHddCtx->isRestartInProgress, 1); |
| 10568 | /* Cleanup */ |
| 10569 | vos_status = vos_timer_stop( &pHddCtx->hdd_restart_timer ); |
| 10570 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 10571 | hddLog(LOGE, FL("Failed to stop HDD restart timer")); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10572 | vos_status = vos_timer_destroy(&pHddCtx->hdd_restart_timer); |
| 10573 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 10574 | hddLog(LOGE, FL("Failed to destroy HDD restart timer")); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10575 | |
| 10576 | } |
| 10577 | |
| 10578 | /**--------------------------------------------------------------------------- |
| 10579 | * |
| 10580 | * \brief wlan_hdd_framework_restart |
| 10581 | * |
| 10582 | * This function uses a cfg80211 API to start a framework initiated WLAN |
| 10583 | * driver module unload/load. |
| 10584 | * |
| 10585 | * Also this API keep retrying (WLAN_HDD_RESTART_RETRY_MAX_CNT). |
| 10586 | * |
| 10587 | * |
| 10588 | * \param - pHddCtx |
| 10589 | * |
| 10590 | * \return - VOS_STATUS_SUCCESS: Success |
| 10591 | * VOS_STATUS_E_EMPTY: Adapter is Empty |
| 10592 | * VOS_STATUS_E_NOMEM: No memory |
| 10593 | |
| 10594 | * --------------------------------------------------------------------------*/ |
| 10595 | |
| 10596 | static VOS_STATUS wlan_hdd_framework_restart(hdd_context_t *pHddCtx) |
| 10597 | { |
| 10598 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 10599 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
Madan Mohan Koyyalamudi | fc19e44 | 2013-05-09 18:24:08 -0700 | [diff] [blame] | 10600 | int len = (sizeof (struct ieee80211_mgmt)); |
| 10601 | struct ieee80211_mgmt *mgmt = NULL; |
| 10602 | |
| 10603 | /* Prepare the DEAUTH managment frame with reason code */ |
| 10604 | mgmt = kzalloc(len, GFP_KERNEL); |
| 10605 | if(mgmt == NULL) |
| 10606 | { |
| 10607 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 10608 | "%s: memory allocation failed (%d bytes)", __func__, len); |
| 10609 | return VOS_STATUS_E_NOMEM; |
| 10610 | } |
| 10611 | mgmt->u.deauth.reason_code = WLAN_REASON_DISASSOC_LOW_ACK; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10612 | |
| 10613 | /* Iterate over all adapters/devices */ |
| 10614 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 10615 | do |
| 10616 | { |
| 10617 | if( (status == VOS_STATUS_SUCCESS) && |
| 10618 | pAdapterNode && |
| 10619 | pAdapterNode->pAdapter) |
| 10620 | { |
| 10621 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 10622 | "restarting the driver(intf:\'%s\' mode:%d :try %d)", |
| 10623 | pAdapterNode->pAdapter->dev->name, |
| 10624 | pAdapterNode->pAdapter->device_mode, |
| 10625 | pHddCtx->hdd_restart_retries + 1); |
Madan Mohan Koyyalamudi | fc19e44 | 2013-05-09 18:24:08 -0700 | [diff] [blame] | 10626 | /* |
| 10627 | * CFG80211 event to restart the driver |
| 10628 | * |
| 10629 | * 'cfg80211_send_unprot_deauth' sends a |
| 10630 | * NL80211_CMD_UNPROT_DEAUTHENTICATE event to supplicant at any state |
| 10631 | * of SME(Linux Kernel) state machine. |
| 10632 | * |
| 10633 | * Reason code WLAN_REASON_DISASSOC_LOW_ACK is currently used to restart |
| 10634 | * the driver. |
| 10635 | * |
| 10636 | */ |
| 10637 | |
| 10638 | cfg80211_send_unprot_deauth(pAdapterNode->pAdapter->dev, (u_int8_t*)mgmt, len ); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10639 | } |
| 10640 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 10641 | pAdapterNode = pNext; |
| 10642 | } while((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status)); |
| 10643 | |
Madan Mohan Koyyalamudi | fc19e44 | 2013-05-09 18:24:08 -0700 | [diff] [blame] | 10644 | |
| 10645 | /* Free the allocated management frame */ |
| 10646 | kfree(mgmt); |
| 10647 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10648 | /* Retry until we unload or reach max count */ |
| 10649 | if(++pHddCtx->hdd_restart_retries < WLAN_HDD_RESTART_RETRY_MAX_CNT) |
| 10650 | vos_timer_start(&pHddCtx->hdd_restart_timer, WLAN_HDD_RESTART_RETRY_DELAY_MS); |
| 10651 | |
| 10652 | return status; |
| 10653 | |
| 10654 | } |
| 10655 | /**--------------------------------------------------------------------------- |
| 10656 | * |
| 10657 | * \brief wlan_hdd_restart_timer_cb |
| 10658 | * |
| 10659 | * Restart timer callback. An internal function. |
| 10660 | * |
| 10661 | * \param - User data: |
| 10662 | * |
| 10663 | * \return - None |
| 10664 | * |
| 10665 | * --------------------------------------------------------------------------*/ |
| 10666 | |
| 10667 | void wlan_hdd_restart_timer_cb(v_PVOID_t usrDataForCallback) |
| 10668 | { |
| 10669 | hdd_context_t *pHddCtx = usrDataForCallback; |
| 10670 | wlan_hdd_framework_restart(pHddCtx); |
| 10671 | return; |
| 10672 | |
| 10673 | } |
| 10674 | |
| 10675 | |
| 10676 | /**--------------------------------------------------------------------------- |
| 10677 | * |
| 10678 | * \brief wlan_hdd_restart_driver |
| 10679 | * |
| 10680 | * This function sends an event to supplicant to restart the WLAN driver. |
| 10681 | * |
| 10682 | * This function is called from vos_wlanRestart. |
| 10683 | * |
| 10684 | * \param - pHddCtx |
| 10685 | * |
| 10686 | * \return - VOS_STATUS_SUCCESS: Success |
| 10687 | * VOS_STATUS_E_EMPTY: Adapter is Empty |
| 10688 | * VOS_STATUS_E_ALREADY: Request already in progress |
| 10689 | |
| 10690 | * --------------------------------------------------------------------------*/ |
| 10691 | VOS_STATUS wlan_hdd_restart_driver(hdd_context_t *pHddCtx) |
| 10692 | { |
| 10693 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 10694 | |
| 10695 | /* A tight check to make sure reentrancy */ |
| 10696 | if(atomic_xchg(&pHddCtx->isRestartInProgress, 1)) |
| 10697 | { |
Mihir Shete | fd52865 | 2014-06-23 19:07:50 +0530 | [diff] [blame] | 10698 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10699 | "%s: WLAN restart is already in progress", __func__); |
| 10700 | |
| 10701 | return VOS_STATUS_E_ALREADY; |
| 10702 | } |
Sameer Thalappil | 0c164f5 | 2013-03-28 15:27:56 -0700 | [diff] [blame] | 10703 | /* Send reset FIQ to WCNSS to invoke SSR. */ |
Madan Mohan Koyyalamudi | e388b34 | 2012-11-08 15:03:16 -0800 | [diff] [blame] | 10704 | #ifdef HAVE_WCNSS_RESET_INTR |
Madan Mohan Koyyalamudi | bb8f017 | 2012-09-28 15:36:06 -0700 | [diff] [blame] | 10705 | wcnss_reset_intr(); |
| 10706 | #endif |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 10707 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10708 | return status; |
| 10709 | } |
| 10710 | |
Mihir Shete | e1093ba | 2014-01-21 20:13:32 +0530 | [diff] [blame] | 10711 | /**--------------------------------------------------------------------------- |
| 10712 | * |
| 10713 | * \brief wlan_hdd_init_channels |
| 10714 | * |
| 10715 | * This function is used to initialize the channel list in CSR |
| 10716 | * |
| 10717 | * This function is called from hdd_wlan_startup |
| 10718 | * |
| 10719 | * \param - pHddCtx: HDD context |
| 10720 | * |
| 10721 | * \return - VOS_STATUS_SUCCESS: Success |
| 10722 | * VOS_STATUS_E_FAULT: Failure reported by SME |
| 10723 | |
| 10724 | * --------------------------------------------------------------------------*/ |
| 10725 | static VOS_STATUS wlan_hdd_init_channels(hdd_context_t *pHddCtx) |
| 10726 | { |
| 10727 | eHalStatus status; |
| 10728 | |
| 10729 | status = sme_InitChannels(pHddCtx->hHal); |
| 10730 | if (HAL_STATUS_SUCCESS(status)) |
| 10731 | { |
| 10732 | return VOS_STATUS_SUCCESS; |
| 10733 | } |
| 10734 | else |
| 10735 | { |
| 10736 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Channel initialization failed(%d)", |
| 10737 | __func__, status); |
| 10738 | return VOS_STATUS_E_FAULT; |
| 10739 | } |
| 10740 | } |
| 10741 | |
Mihir Shete | 0420645 | 2014-11-20 17:50:58 +0530 | [diff] [blame] | 10742 | #ifdef CONFIG_ENABLE_LINUX_REG |
Agarwal Ashish | 6db9d53 | 2014-09-30 18:19:10 +0530 | [diff] [blame] | 10743 | VOS_STATUS wlan_hdd_init_channels_for_cc(hdd_context_t *pHddCtx, driver_load_type init ) |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 10744 | { |
| 10745 | eHalStatus status; |
| 10746 | |
Agarwal Ashish | 6db9d53 | 2014-09-30 18:19:10 +0530 | [diff] [blame] | 10747 | status = sme_InitChannelsForCC(pHddCtx->hHal, init); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 10748 | if (HAL_STATUS_SUCCESS(status)) |
| 10749 | { |
| 10750 | return VOS_STATUS_SUCCESS; |
| 10751 | } |
| 10752 | else |
| 10753 | { |
| 10754 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Issue reg hint failed(%d)", |
| 10755 | __func__, status); |
| 10756 | return VOS_STATUS_E_FAULT; |
| 10757 | } |
| 10758 | } |
Mihir Shete | 0420645 | 2014-11-20 17:50:58 +0530 | [diff] [blame] | 10759 | #endif |
Sudhir Sattayappa Kohalli | b1d8c3a | 2013-06-18 14:47:20 -0700 | [diff] [blame] | 10760 | /* |
| 10761 | * API to find if there is any STA or P2P-Client is connected |
| 10762 | */ |
| 10763 | VOS_STATUS hdd_issta_p2p_clientconnected(hdd_context_t *pHddCtx) |
| 10764 | { |
| 10765 | return sme_isSta_p2p_clientConnected(pHddCtx->hHal); |
| 10766 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10767 | |
Agarwal Ashish | 57e8437 | 2014-12-05 18:26:53 +0530 | [diff] [blame] | 10768 | /* |
| 10769 | * API to find if there is any session connected |
| 10770 | */ |
| 10771 | VOS_STATUS hdd_is_any_session_connected(hdd_context_t *pHddCtx) |
| 10772 | { |
| 10773 | return sme_is_any_session_connected(pHddCtx->hHal); |
| 10774 | } |
| 10775 | |
| 10776 | |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 10777 | int wlan_hdd_scan_abort(hdd_adapter_t *pAdapter) |
| 10778 | { |
| 10779 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 10780 | hdd_scaninfo_t *pScanInfo = NULL; |
Girish Gowli | 4bf7a63 | 2014-06-12 13:42:11 +0530 | [diff] [blame] | 10781 | long status = 0; |
c_hpothu | a3d45d5 | 2015-01-05 14:11:17 +0530 | [diff] [blame] | 10782 | tSirAbortScanStatus abortScanStatus; |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 10783 | |
| 10784 | pScanInfo = &pHddCtx->scan_info; |
| 10785 | if (pScanInfo->mScanPending) |
| 10786 | { |
c_hpothu | a3d45d5 | 2015-01-05 14:11:17 +0530 | [diff] [blame] | 10787 | abortScanStatus = hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId, |
| 10788 | eCSR_SCAN_ABORT_DEFAULT); |
| 10789 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 10790 | FL("abortScanStatus: %d"), abortScanStatus); |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 10791 | |
c_hpothu | a3d45d5 | 2015-01-05 14:11:17 +0530 | [diff] [blame] | 10792 | /* If there is active scan command lets wait for the completion else |
| 10793 | * there is no need to wait as scan command might be in the SME pending |
| 10794 | * command list. |
| 10795 | */ |
| 10796 | if (abortScanStatus == eSIR_ABORT_ACTIVE_SCAN_LIST_NOT_EMPTY) |
| 10797 | { |
| 10798 | INIT_COMPLETION(pScanInfo->abortscan_event_var); |
| 10799 | status = wait_for_completion_interruptible_timeout( |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 10800 | &pScanInfo->abortscan_event_var, |
| 10801 | msecs_to_jiffies(5000)); |
c_hpothu | a3d45d5 | 2015-01-05 14:11:17 +0530 | [diff] [blame] | 10802 | if (0 >= status) |
| 10803 | { |
| 10804 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Girish Gowli | 4bf7a63 | 2014-06-12 13:42:11 +0530 | [diff] [blame] | 10805 | "%s: Timeout or Interrupt occurred while waiting for abort" |
| 10806 | "scan, status- %ld", __func__, status); |
c_hpothu | a3d45d5 | 2015-01-05 14:11:17 +0530 | [diff] [blame] | 10807 | return -ETIMEDOUT; |
| 10808 | } |
| 10809 | } |
| 10810 | else if (abortScanStatus == eSIR_ABORT_SCAN_FAILURE) |
| 10811 | { |
| 10812 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10813 | FL("hdd_abort_mac_scan failed")); |
| 10814 | return -VOS_STATUS_E_FAILURE; |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 10815 | } |
| 10816 | } |
Girish Gowli | 4bf7a63 | 2014-06-12 13:42:11 +0530 | [diff] [blame] | 10817 | return 0; |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 10818 | } |
| 10819 | |
c_hpothu | 225aa7c | 2014-10-22 17:45:13 +0530 | [diff] [blame] | 10820 | VOS_STATUS wlan_hdd_cancel_remain_on_channel(hdd_context_t *pHddCtx) |
| 10821 | { |
| 10822 | hdd_adapter_t *pAdapter; |
| 10823 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 10824 | VOS_STATUS vosStatus; |
| 10825 | |
| 10826 | vosStatus = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 10827 | while (NULL != pAdapterNode && VOS_STATUS_E_EMPTY != vosStatus) |
| 10828 | { |
| 10829 | pAdapter = pAdapterNode->pAdapter; |
| 10830 | if (NULL != pAdapter) |
| 10831 | { |
| 10832 | if (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode || |
| 10833 | WLAN_HDD_P2P_CLIENT == pAdapter->device_mode || |
| 10834 | WLAN_HDD_P2P_GO == pAdapter->device_mode) |
| 10835 | { |
| 10836 | hddLog(LOG1, FL("abort ROC deviceMode: %d"), |
| 10837 | pAdapter->device_mode); |
| 10838 | if (VOS_STATUS_SUCCESS != |
| 10839 | wlan_hdd_cancel_existing_remain_on_channel(pAdapter)) |
| 10840 | { |
| 10841 | hddLog(LOGE, FL("failed to abort ROC")); |
| 10842 | return VOS_STATUS_E_FAILURE; |
| 10843 | } |
| 10844 | } |
| 10845 | } |
| 10846 | vosStatus = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 10847 | pAdapterNode = pNext; |
| 10848 | } |
| 10849 | return VOS_STATUS_SUCCESS; |
| 10850 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10851 | //Register the module init/exit functions |
| 10852 | module_init(hdd_module_init); |
| 10853 | module_exit(hdd_module_exit); |
| 10854 | |
| 10855 | MODULE_LICENSE("Dual BSD/GPL"); |
| 10856 | MODULE_AUTHOR("Qualcomm Atheros, Inc."); |
| 10857 | MODULE_DESCRIPTION("WLAN HOST DEVICE DRIVER"); |
| 10858 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 10859 | module_param_call(con_mode, con_mode_handler, param_get_int, &con_mode, |
| 10860 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 10861 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 10862 | module_param_call(fwpath, fwpath_changed_handler, param_get_string, &fwpath, |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 10863 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 10864 | |
| 10865 | module_param(enable_dfs_chan_scan, int, |
| 10866 | S_IRUSR | S_IRGRP | S_IROTH); |
| 10867 | |
| 10868 | module_param(enable_11d, int, |
| 10869 | S_IRUSR | S_IRGRP | S_IROTH); |
| 10870 | |
| 10871 | module_param(country_code, charp, |
| 10872 | S_IRUSR | S_IRGRP | S_IROTH); |