Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
Mukul Sharma | 1fd6efd | 2015-02-14 00:29:14 +0530 | [diff] [blame] | 2 | * Copyright (c) 2012-2015 The Linux Foundation. All rights reserved. |
Kiet Lam | 842dad0 | 2014-02-18 18:44:02 -0800 | [diff] [blame] | 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 |
Ratheesh S P | 2128041 | 2015-05-19 14:21:52 +0530 | [diff] [blame] | 229 | |
| 230 | /* Store WLAN driver info in a global variable such that crash debugger |
| 231 | can extract it from driver debug symbol and crashdump for post processing */ |
| 232 | tANI_U8 g_wlan_driver[ ] = "pronto_driver"; |
| 233 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 234 | #if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD) |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 235 | 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] | 236 | #endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */ |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 237 | |
Mihir Shete | e1093ba | 2014-01-21 20:13:32 +0530 | [diff] [blame] | 238 | static VOS_STATUS wlan_hdd_init_channels(hdd_context_t *pHddCtx); |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 239 | const char * hdd_device_modetoString(v_U8_t device_mode) |
| 240 | { |
| 241 | switch(device_mode) |
| 242 | { |
| 243 | CASE_RETURN_STRING( WLAN_HDD_INFRA_STATION ); |
| 244 | CASE_RETURN_STRING( WLAN_HDD_SOFTAP ); |
| 245 | CASE_RETURN_STRING( WLAN_HDD_P2P_CLIENT ); |
| 246 | CASE_RETURN_STRING( WLAN_HDD_P2P_GO ); |
| 247 | CASE_RETURN_STRING( WLAN_HDD_MONITOR); |
| 248 | CASE_RETURN_STRING( WLAN_HDD_FTM ); |
| 249 | CASE_RETURN_STRING( WLAN_HDD_IBSS ); |
| 250 | CASE_RETURN_STRING( WLAN_HDD_P2P_DEVICE ); |
| 251 | default: |
| 252 | return "device_mode Unknown"; |
| 253 | } |
| 254 | } |
Mihir Shete | e1093ba | 2014-01-21 20:13:32 +0530 | [diff] [blame] | 255 | |
Mukul Sharma | a78cf6b | 2015-02-24 16:59:01 +0530 | [diff] [blame] | 256 | static int __hdd_netdev_notifier_call(struct notifier_block * nb, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 257 | unsigned long state, |
| 258 | void *ndev) |
| 259 | { |
| 260 | struct net_device *dev = ndev; |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 261 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 27cee45 | 2013-03-27 11:10:24 -0700 | [diff] [blame] | 262 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 263 | #ifdef WLAN_BTAMP_FEATURE |
| 264 | VOS_STATUS status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 265 | #endif |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 266 | long result; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 267 | |
| 268 | //Make sure that this callback corresponds to our device. |
Jeff Johnson | 27cee45 | 2013-03-27 11:10:24 -0700 | [diff] [blame] | 269 | if ((strncmp(dev->name, "wlan", 4)) && |
Amar Singhal | 4c723bd | 2013-03-25 18:14:15 -0700 | [diff] [blame] | 270 | (strncmp(dev->name, "p2p", 3))) |
| 271 | return NOTIFY_DONE; |
| 272 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 273 | if (!dev->ieee80211_ptr) |
Jeff Johnson | 27cee45 | 2013-03-27 11:10:24 -0700 | [diff] [blame] | 274 | return NOTIFY_DONE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 275 | |
Jeff Johnson | 27cee45 | 2013-03-27 11:10:24 -0700 | [diff] [blame] | 276 | if (NULL == pAdapter) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 277 | { |
Jeff Johnson | a8a1a48 | 2012-12-12 16:49:33 -0800 | [diff] [blame] | 278 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: HDD Adapter Null Pointer", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 279 | VOS_ASSERT(0); |
| 280 | return NOTIFY_DONE; |
| 281 | } |
| 282 | |
Jeff Johnson | 27cee45 | 2013-03-27 11:10:24 -0700 | [diff] [blame] | 283 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 284 | if (NULL == pHddCtx) |
| 285 | { |
| 286 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: HDD Context Null Pointer", __func__); |
| 287 | VOS_ASSERT(0); |
| 288 | return NOTIFY_DONE; |
| 289 | } |
Sameer Thalappil | 1406797 | 2014-01-23 14:54:54 -0800 | [diff] [blame] | 290 | if (pHddCtx->isLogpInProgress) |
| 291 | return NOTIFY_DONE; |
| 292 | |
Jeff Johnson | 27cee45 | 2013-03-27 11:10:24 -0700 | [diff] [blame] | 293 | |
| 294 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s New Net Device State = %lu", |
| 295 | __func__, dev->name, state); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 296 | |
| 297 | switch (state) { |
| 298 | case NETDEV_REGISTER: |
| 299 | break; |
| 300 | |
| 301 | case NETDEV_UNREGISTER: |
| 302 | break; |
| 303 | |
| 304 | case NETDEV_UP: |
| 305 | break; |
| 306 | |
| 307 | case NETDEV_DOWN: |
| 308 | break; |
| 309 | |
| 310 | case NETDEV_CHANGE: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 311 | if(TRUE == pAdapter->isLinkUpSvcNeeded) |
| 312 | complete(&pAdapter->linkup_event_var); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 313 | break; |
| 314 | |
| 315 | case NETDEV_GOING_DOWN: |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 316 | result = wlan_hdd_scan_abort(pAdapter); |
Girish Gowli | 4bf7a63 | 2014-06-12 13:42:11 +0530 | [diff] [blame] | 317 | if (result < 0) |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 318 | { |
| 319 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 320 | "%s: Timeout occurred while waiting for abortscan %ld", |
| 321 | __func__, result); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 322 | } |
| 323 | else |
| 324 | { |
| 325 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 326 | "%s: Scan Abort Successful" , __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 327 | } |
| 328 | #ifdef WLAN_BTAMP_FEATURE |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 329 | 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] | 330 | status = WLANBAP_StopAmp(); |
| 331 | if(VOS_STATUS_SUCCESS != status ) |
| 332 | { |
| 333 | pHddCtx->isAmpAllowed = VOS_TRUE; |
| 334 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 335 | "%s: Failed to stop AMP", __func__); |
| 336 | } |
| 337 | else |
| 338 | { |
| 339 | //a state m/c implementation in PAL is TBD to avoid this delay |
| 340 | msleep(500); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 341 | if ( pHddCtx->isAmpAllowed ) |
| 342 | { |
| 343 | WLANBAP_DeregisterFromHCI(); |
| 344 | pHddCtx->isAmpAllowed = VOS_FALSE; |
| 345 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 346 | } |
| 347 | #endif //WLAN_BTAMP_FEATURE |
| 348 | break; |
| 349 | |
| 350 | default: |
| 351 | break; |
| 352 | } |
| 353 | |
| 354 | return NOTIFY_DONE; |
| 355 | } |
| 356 | |
Mukul Sharma | a78cf6b | 2015-02-24 16:59:01 +0530 | [diff] [blame] | 357 | static int hdd_netdev_notifier_call(struct notifier_block * nb, |
| 358 | unsigned long state, |
| 359 | void *ndev) |
| 360 | { |
| 361 | int ret; |
| 362 | vos_ssr_protect(__func__); |
| 363 | ret = __hdd_netdev_notifier_call( nb, state, ndev); |
| 364 | vos_ssr_unprotect(__func__); |
| 365 | return ret; |
| 366 | } |
| 367 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 368 | struct notifier_block hdd_netdev_notifier = { |
| 369 | .notifier_call = hdd_netdev_notifier_call, |
| 370 | }; |
| 371 | |
| 372 | /*--------------------------------------------------------------------------- |
| 373 | * Function definitions |
| 374 | *-------------------------------------------------------------------------*/ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 375 | void hdd_unregister_mcast_bcast_filter(hdd_context_t *pHddCtx); |
| 376 | void hdd_register_mcast_bcast_filter(hdd_context_t *pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 377 | //variable to hold the insmod parameters |
Madan Mohan Koyyalamudi | dfd6aa8 | 2012-10-18 20:18:43 -0700 | [diff] [blame] | 378 | static int con_mode; |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 379 | #ifndef MODULE |
| 380 | /* current con_mode - used only for statically linked driver |
| 381 | * con_mode is changed by userspace to indicate a mode change which will |
| 382 | * result in calling the module exit and init functions. The module |
| 383 | * exit function will clean up based on the value of con_mode prior to it |
| 384 | * being changed by userspace. So curr_con_mode records the current con_mode |
| 385 | * for exit when con_mode becomes the next mode for init |
| 386 | */ |
Madan Mohan Koyyalamudi | dfd6aa8 | 2012-10-18 20:18:43 -0700 | [diff] [blame] | 387 | static int curr_con_mode; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 388 | #endif |
| 389 | |
Varun Reddy Yeturu | 587e680 | 2013-01-24 12:21:41 -0800 | [diff] [blame] | 390 | /**--------------------------------------------------------------------------- |
| 391 | |
| 392 | \brief hdd_vos_trace_enable() - Configure initial VOS Trace enable |
| 393 | |
| 394 | Called immediately after the cfg.ini is read in order to configure |
| 395 | the desired trace levels. |
| 396 | |
| 397 | \param - moduleId - module whose trace level is being configured |
| 398 | \param - bitmask - bitmask of log levels to be enabled |
| 399 | |
| 400 | \return - void |
| 401 | |
| 402 | --------------------------------------------------------------------------*/ |
| 403 | static void hdd_vos_trace_enable(VOS_MODULE_ID moduleId, v_U32_t bitmask) |
| 404 | { |
| 405 | wpt_tracelevel level; |
| 406 | |
| 407 | /* if the bitmask is the default value, then a bitmask was not |
| 408 | specified in cfg.ini, so leave the logging level alone (it |
| 409 | will remain at the "compiled in" default value) */ |
| 410 | if (CFG_VOS_TRACE_ENABLE_DEFAULT == bitmask) |
| 411 | { |
| 412 | return; |
| 413 | } |
| 414 | |
| 415 | /* a mask was specified. start by disabling all logging */ |
| 416 | vos_trace_setValue(moduleId, VOS_TRACE_LEVEL_NONE, 0); |
| 417 | |
| 418 | /* now cycle through the bitmask until all "set" bits are serviced */ |
| 419 | level = VOS_TRACE_LEVEL_FATAL; |
| 420 | while (0 != bitmask) |
| 421 | { |
| 422 | if (bitmask & 1) |
| 423 | { |
| 424 | vos_trace_setValue(moduleId, level, 1); |
| 425 | } |
| 426 | level++; |
| 427 | bitmask >>= 1; |
| 428 | } |
| 429 | } |
| 430 | |
| 431 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 432 | /**--------------------------------------------------------------------------- |
| 433 | |
| 434 | \brief hdd_wdi_trace_enable() - Configure initial WDI Trace enable |
| 435 | |
| 436 | Called immediately after the cfg.ini is read in order to configure |
| 437 | the desired trace levels in the WDI. |
| 438 | |
| 439 | \param - moduleId - module whose trace level is being configured |
| 440 | \param - bitmask - bitmask of log levels to be enabled |
| 441 | |
| 442 | \return - void |
| 443 | |
| 444 | --------------------------------------------------------------------------*/ |
| 445 | static void hdd_wdi_trace_enable(wpt_moduleid moduleId, v_U32_t bitmask) |
| 446 | { |
| 447 | wpt_tracelevel level; |
| 448 | |
| 449 | /* if the bitmask is the default value, then a bitmask was not |
| 450 | specified in cfg.ini, so leave the logging level alone (it |
| 451 | will remain at the "compiled in" default value) */ |
| 452 | if (CFG_WDI_TRACE_ENABLE_DEFAULT == bitmask) |
| 453 | { |
| 454 | return; |
| 455 | } |
| 456 | |
| 457 | /* a mask was specified. start by disabling all logging */ |
| 458 | wpalTraceSetLevel(moduleId, eWLAN_PAL_TRACE_LEVEL_NONE, 0); |
| 459 | |
| 460 | /* now cycle through the bitmask until all "set" bits are serviced */ |
| 461 | level = eWLAN_PAL_TRACE_LEVEL_FATAL; |
| 462 | while (0 != bitmask) |
| 463 | { |
| 464 | if (bitmask & 1) |
| 465 | { |
| 466 | wpalTraceSetLevel(moduleId, level, 1); |
| 467 | } |
| 468 | level++; |
| 469 | bitmask >>= 1; |
| 470 | } |
| 471 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 472 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 473 | /* |
| 474 | * FUNCTION: wlan_hdd_validate_context |
| 475 | * This function is used to check the HDD context |
| 476 | */ |
| 477 | int wlan_hdd_validate_context(hdd_context_t *pHddCtx) |
| 478 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 479 | |
| 480 | if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini) |
| 481 | { |
Mahesh A Saptasagar | 886997a | 2015-03-04 13:15:51 +0530 | [diff] [blame] | 482 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 483 | "%s: HDD context is Null", __func__); |
| 484 | return -ENODEV; |
| 485 | } |
| 486 | |
| 487 | if (pHddCtx->isLogpInProgress) |
| 488 | { |
Mahesh A Saptasagar | 886997a | 2015-03-04 13:15:51 +0530 | [diff] [blame] | 489 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
c_hpothu | 8adb97b | 2014-12-08 19:38:20 +0530 | [diff] [blame] | 490 | "%s: LOGP %s. Ignore!!", __func__, |
| 491 | vos_is_wlan_in_badState(VOS_MODULE_ID_HDD, NULL) |
| 492 | ?"failed":"in Progress"); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 493 | return -EAGAIN; |
| 494 | } |
| 495 | |
Mihir Shete | 1815629 | 2014-03-11 15:38:30 +0530 | [diff] [blame] | 496 | if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx)) |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 497 | { |
Mahesh A Saptasagar | 886997a | 2015-03-04 13:15:51 +0530 | [diff] [blame] | 498 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 499 | "%s: Unloading/Loading in Progress. Ignore!!!", __func__); |
| 500 | return -EAGAIN; |
| 501 | } |
| 502 | return 0; |
| 503 | } |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 504 | #ifdef CONFIG_ENABLE_LINUX_REG |
| 505 | void hdd_checkandupdate_phymode( hdd_context_t *pHddCtx) |
| 506 | { |
| 507 | hdd_adapter_t *pAdapter = NULL; |
| 508 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 509 | eCsrPhyMode phyMode; |
| 510 | hdd_config_t *cfg_param = NULL; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 511 | |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 512 | if (NULL == pHddCtx) |
| 513 | { |
| 514 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 515 | "HDD Context is null !!"); |
| 516 | return ; |
| 517 | } |
| 518 | |
| 519 | pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 520 | if (NULL == pAdapter) |
| 521 | { |
| 522 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 523 | "pAdapter is null !!"); |
| 524 | return ; |
| 525 | } |
| 526 | |
| 527 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 528 | if (NULL == pHddStaCtx) |
| 529 | { |
| 530 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 531 | "pHddStaCtx is null !!"); |
| 532 | return ; |
| 533 | } |
| 534 | |
| 535 | cfg_param = pHddCtx->cfg_ini; |
| 536 | if (NULL == cfg_param) |
| 537 | { |
| 538 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 539 | "cfg_params not available !!"); |
| 540 | return ; |
| 541 | } |
| 542 | |
| 543 | phyMode = sme_GetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter)); |
| 544 | |
| 545 | if (!pHddCtx->isVHT80Allowed) |
| 546 | { |
| 547 | if ((eCSR_DOT11_MODE_AUTO == phyMode) || |
| 548 | (eCSR_DOT11_MODE_11ac == phyMode) || |
| 549 | (eCSR_DOT11_MODE_11ac_ONLY == phyMode)) |
| 550 | { |
| 551 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 552 | "Setting phymode to 11n!!"); |
| 553 | sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_DOT11_MODE_11n); |
| 554 | } |
| 555 | } |
| 556 | else |
| 557 | { |
| 558 | /*New country Supports 11ac as well resetting value back from .ini*/ |
| 559 | sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 560 | hdd_cfg_xlate_to_csr_phy_mode(cfg_param->dot11Mode)); |
| 561 | return ; |
| 562 | } |
| 563 | |
| 564 | if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) && |
| 565 | ((eCSR_CFG_DOT11_MODE_11AC_ONLY == pHddStaCtx->conn_info.dot11Mode) || |
| 566 | (eCSR_CFG_DOT11_MODE_11AC == pHddStaCtx->conn_info.dot11Mode))) |
| 567 | { |
| 568 | VOS_STATUS vosStatus; |
| 569 | |
| 570 | // need to issue a disconnect to CSR. |
| 571 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 572 | vosStatus = sme_RoamDisconnect(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 573 | pAdapter->sessionId, |
| 574 | eCSR_DISCONNECT_REASON_UNSPECIFIED ); |
| 575 | |
| 576 | if (VOS_STATUS_SUCCESS == vosStatus) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 577 | { |
| 578 | long ret; |
| 579 | |
| 580 | ret = wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var, |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 581 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 582 | if (0 >= ret) |
| 583 | hddLog(LOGE, FL("failure waiting for disconnect_comp_var %ld"), |
| 584 | ret); |
| 585 | } |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 586 | |
| 587 | } |
| 588 | } |
| 589 | #else |
Gopichand Nakkala | dacbcb5 | 2013-04-18 16:41:54 +0530 | [diff] [blame] | 590 | void hdd_checkandupdate_phymode( hdd_adapter_t *pAdapter, char *country_code) |
| 591 | { |
| 592 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 593 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 594 | hdd_config_t *cfg_param; |
| 595 | eCsrPhyMode phyMode; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 596 | long ret; |
Gopichand Nakkala | dacbcb5 | 2013-04-18 16:41:54 +0530 | [diff] [blame] | 597 | |
| 598 | if (NULL == pHddCtx) |
| 599 | { |
| 600 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 601 | "HDD Context is null !!"); |
| 602 | return ; |
| 603 | } |
| 604 | |
| 605 | cfg_param = pHddCtx->cfg_ini; |
| 606 | |
| 607 | if (NULL == cfg_param) |
| 608 | { |
| 609 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 610 | "cfg_params not available !!"); |
| 611 | return ; |
| 612 | } |
| 613 | |
| 614 | phyMode = sme_GetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter)); |
| 615 | |
| 616 | if (NULL != strstr(cfg_param->listOfNon11acCountryCode, country_code)) |
| 617 | { |
| 618 | if ((eCSR_DOT11_MODE_AUTO == phyMode) || |
| 619 | (eCSR_DOT11_MODE_11ac == phyMode) || |
| 620 | (eCSR_DOT11_MODE_11ac_ONLY == phyMode)) |
| 621 | { |
| 622 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 623 | "Setting phymode to 11n!!"); |
| 624 | sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_DOT11_MODE_11n); |
| 625 | } |
| 626 | } |
| 627 | else |
| 628 | { |
| 629 | /*New country Supports 11ac as well resetting value back from .ini*/ |
| 630 | sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 631 | hdd_cfg_xlate_to_csr_phy_mode(cfg_param->dot11Mode)); |
| 632 | return ; |
| 633 | } |
| 634 | |
| 635 | if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) && |
| 636 | ((eCSR_CFG_DOT11_MODE_11AC_ONLY == pHddStaCtx->conn_info.dot11Mode) || |
| 637 | (eCSR_CFG_DOT11_MODE_11AC == pHddStaCtx->conn_info.dot11Mode))) |
| 638 | { |
| 639 | VOS_STATUS vosStatus; |
| 640 | |
| 641 | // need to issue a disconnect to CSR. |
| 642 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 643 | vosStatus = sme_RoamDisconnect(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 644 | pAdapter->sessionId, |
| 645 | eCSR_DISCONNECT_REASON_UNSPECIFIED ); |
| 646 | |
| 647 | if (VOS_STATUS_SUCCESS == vosStatus) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 648 | { |
| 649 | ret = wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var, |
Gopichand Nakkala | dacbcb5 | 2013-04-18 16:41:54 +0530 | [diff] [blame] | 650 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 651 | if (ret <= 0) |
| 652 | { |
| 653 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 654 | "wait on disconnect_comp_var is failed %ld", ret); |
| 655 | } |
| 656 | } |
Gopichand Nakkala | dacbcb5 | 2013-04-18 16:41:54 +0530 | [diff] [blame] | 657 | |
| 658 | } |
| 659 | } |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 660 | #endif //CONFIG_ENABLE_LINUX_REG |
Gopichand Nakkala | dacbcb5 | 2013-04-18 16:41:54 +0530 | [diff] [blame] | 661 | |
Tushnim Bhattacharyya | 9cdf608 | 2013-04-21 16:33:30 -0700 | [diff] [blame] | 662 | void hdd_checkandupdate_dfssetting( hdd_adapter_t *pAdapter, char *country_code) |
| 663 | { |
| 664 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 665 | hdd_config_t *cfg_param; |
| 666 | |
| 667 | if (NULL == pHddCtx) |
| 668 | { |
| 669 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 670 | "HDD Context is null !!"); |
| 671 | return ; |
| 672 | } |
| 673 | |
| 674 | cfg_param = pHddCtx->cfg_ini; |
| 675 | |
| 676 | if (NULL == cfg_param) |
| 677 | { |
| 678 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 679 | "cfg_params not available !!"); |
| 680 | return ; |
| 681 | } |
| 682 | |
Agarwal Ashish | 738843c | 2014-09-25 12:27:56 +0530 | [diff] [blame] | 683 | if (NULL != strstr(cfg_param->listOfNonDfsCountryCode, country_code) || |
| 684 | pHddCtx->disable_dfs_flag == TRUE) |
Tushnim Bhattacharyya | 9cdf608 | 2013-04-21 16:33:30 -0700 | [diff] [blame] | 685 | { |
| 686 | /*New country doesn't support DFS */ |
| 687 | sme_UpdateDfsSetting(WLAN_HDD_GET_HAL_CTX(pAdapter), 0); |
| 688 | } |
| 689 | else |
| 690 | { |
| 691 | /*New country Supports DFS as well resetting value back from .ini*/ |
| 692 | sme_UpdateDfsSetting(WLAN_HDD_GET_HAL_CTX(pAdapter), cfg_param->enableDFSChnlScan); |
| 693 | } |
| 694 | |
| 695 | } |
| 696 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 697 | #ifdef FEATURE_WLAN_BATCH_SCAN |
| 698 | |
| 699 | /**--------------------------------------------------------------------------- |
| 700 | |
| 701 | \brief hdd_extract_assigned_int_from_str() - Extracts assigned integer from |
| 702 | input string |
| 703 | |
| 704 | This function extracts assigned integer from string in below format: |
| 705 | "STRING=10" : extracts integer 10 from this string |
| 706 | |
| 707 | \param - pInPtr Pointer to input string |
| 708 | \param - base Base for string to int conversion(10 for decimal 16 for hex) |
| 709 | \param - pOutPtr Pointer to variable in which extracted integer needs to be |
| 710 | assigned |
| 711 | \param - pLastArg to tell whether it is last arguement in input string or |
| 712 | not |
| 713 | |
| 714 | \return - NULL for failure cases |
| 715 | pointer to next arguement in input string for success cases |
| 716 | --------------------------------------------------------------------------*/ |
| 717 | static tANI_U8 * |
| 718 | hdd_extract_assigned_int_from_str |
| 719 | ( |
| 720 | tANI_U8 *pInPtr, |
| 721 | tANI_U8 base, |
| 722 | tANI_U32 *pOutPtr, |
| 723 | tANI_U8 *pLastArg |
| 724 | ) |
| 725 | { |
| 726 | int tempInt; |
| 727 | int v = 0; |
| 728 | char buf[32]; |
| 729 | int val = 0; |
| 730 | *pLastArg = FALSE; |
| 731 | |
| 732 | pInPtr = strnchr(pInPtr, strlen(pInPtr), EQUALS_TO_ASCII_VALUE); |
| 733 | if (NULL == pInPtr) |
| 734 | { |
| 735 | return NULL; |
| 736 | } |
| 737 | |
| 738 | pInPtr++; |
| 739 | |
| 740 | while ((SPACE_ASCII_VALUE == *pInPtr) && ('\0' != *pInPtr)) pInPtr++; |
| 741 | |
| 742 | val = sscanf(pInPtr, "%32s ", buf); |
| 743 | if (val < 0 && val > strlen(pInPtr)) |
| 744 | { |
| 745 | return NULL; |
| 746 | } |
| 747 | pInPtr += val; |
| 748 | v = kstrtos32(buf, base, &tempInt); |
| 749 | if (v < 0) |
| 750 | { |
| 751 | return NULL; |
| 752 | } |
Rajeev Kumar | 4d93d84 | 2014-01-02 18:31:21 -0800 | [diff] [blame] | 753 | if (tempInt < 0) |
| 754 | { |
| 755 | tempInt = 0; |
| 756 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 757 | *pOutPtr = tempInt; |
| 758 | |
| 759 | pInPtr = strnchr(pInPtr, strlen(pInPtr), SPACE_ASCII_VALUE); |
| 760 | if (NULL == pInPtr) |
| 761 | { |
| 762 | *pLastArg = TRUE; |
| 763 | return NULL; |
| 764 | } |
| 765 | while ((SPACE_ASCII_VALUE == *pInPtr) && ('\0' != *pInPtr)) pInPtr++; |
| 766 | |
| 767 | return pInPtr; |
| 768 | } |
| 769 | |
| 770 | /**--------------------------------------------------------------------------- |
| 771 | |
| 772 | \brief hdd_extract_assigned_char_from_str() - Extracts assigned char from |
| 773 | input string |
| 774 | |
| 775 | This function extracts assigned character from string in below format: |
| 776 | "STRING=A" : extracts char 'A' from this string |
| 777 | |
| 778 | \param - pInPtr Pointer to input string |
| 779 | \param - pOutPtr Pointer to variable in which extracted char needs to be |
| 780 | assigned |
| 781 | \param - pLastArg to tell whether it is last arguement in input string or |
| 782 | not |
| 783 | |
| 784 | \return - NULL for failure cases |
| 785 | pointer to next arguement in input string for success cases |
| 786 | --------------------------------------------------------------------------*/ |
| 787 | static tANI_U8 * |
| 788 | hdd_extract_assigned_char_from_str |
| 789 | ( |
| 790 | tANI_U8 *pInPtr, |
| 791 | tANI_U8 *pOutPtr, |
| 792 | tANI_U8 *pLastArg |
| 793 | ) |
| 794 | { |
| 795 | *pLastArg = FALSE; |
| 796 | |
| 797 | pInPtr = strnchr(pInPtr, strlen(pInPtr), EQUALS_TO_ASCII_VALUE); |
| 798 | if (NULL == pInPtr) |
| 799 | { |
| 800 | return NULL; |
| 801 | } |
| 802 | |
| 803 | pInPtr++; |
| 804 | |
| 805 | while ((SPACE_ASCII_VALUE == *pInPtr) && ('\0' != *pInPtr)) pInPtr++; |
| 806 | |
| 807 | *pOutPtr = *pInPtr; |
| 808 | |
| 809 | pInPtr = strnchr(pInPtr, strlen(pInPtr), SPACE_ASCII_VALUE); |
| 810 | if (NULL == pInPtr) |
| 811 | { |
| 812 | *pLastArg = TRUE; |
| 813 | return NULL; |
| 814 | } |
| 815 | while ((SPACE_ASCII_VALUE == *pInPtr) && ('\0' != *pInPtr)) pInPtr++; |
| 816 | |
| 817 | return pInPtr; |
| 818 | } |
| 819 | |
| 820 | |
| 821 | /**--------------------------------------------------------------------------- |
| 822 | |
| 823 | \brief hdd_parse_set_batchscan_command () - HDD parse set batch scan command |
| 824 | |
| 825 | This function parses set batch scan command in below format: |
| 826 | WLS_BATCHING_SET <space> followed by below arguements |
| 827 | "SCANFREQ=XX" : Optional defaults to 30 sec |
| 828 | "MSCAN=XX" : Required number of scans to attempt to batch |
| 829 | "BESTN=XX" : Best Network (RSSI) defaults to 16 |
| 830 | "CHANNEL=<X,Y>" : optional defaults to all channels, can list 'A'or` B. |
| 831 | A. implies only 5 GHz , B. implies only 2.4GHz |
| 832 | "RTT=X" : optional defaults to 0 |
| 833 | returns the MIN of MSCAN or the max # of scans firmware can cache or -1 on |
| 834 | error |
| 835 | |
| 836 | For example input commands: |
| 837 | 1) WLS_BATCHING_SET SCANFREQ=60 MSCAN=10 BESTN=20 CHANNEL=A RTT=0 -> This is |
| 838 | translated into set batch scan with following parameters: |
| 839 | a) Frequence 60 seconds |
| 840 | b) Batch 10 scans together |
| 841 | c) Best RSSI to be 20 |
| 842 | d) 5GHz band only |
| 843 | e) RTT is equal to 0 |
| 844 | |
| 845 | \param - pValue Pointer to input channel list |
| 846 | \param - pHddSetBatchScanReq Pointer to HDD batch scan request structure |
| 847 | |
| 848 | \return - 0 for success non-zero for failure |
| 849 | |
| 850 | --------------------------------------------------------------------------*/ |
| 851 | static int |
| 852 | hdd_parse_set_batchscan_command |
| 853 | ( |
| 854 | tANI_U8 *pValue, |
| 855 | tSirSetBatchScanReq *pHddSetBatchScanReq |
| 856 | ) |
| 857 | { |
| 858 | tANI_U8 *inPtr = pValue; |
| 859 | tANI_U8 val = 0; |
| 860 | tANI_U8 lastArg = 0; |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 861 | tANI_U32 nScanFreq; |
| 862 | tANI_U32 nMscan; |
| 863 | tANI_U32 nBestN; |
| 864 | tANI_U8 ucRfBand; |
| 865 | tANI_U32 nRtt; |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 866 | tANI_U32 temp; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 867 | |
| 868 | /*initialize default values*/ |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 869 | nScanFreq = HDD_SET_BATCH_SCAN_DEFAULT_FREQ; |
| 870 | ucRfBand = HDD_SET_BATCH_SCAN_DEFAULT_BAND; |
| 871 | nRtt = 0; |
| 872 | nBestN = HDD_SET_BATCH_SCAN_BEST_NETWORK; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 873 | |
| 874 | /*go to space after WLS_BATCHING_SET command*/ |
| 875 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 876 | /*no argument after the command*/ |
| 877 | if (NULL == inPtr) |
| 878 | { |
| 879 | return -EINVAL; |
| 880 | } |
| 881 | |
| 882 | /*no space after the command*/ |
| 883 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 884 | { |
| 885 | return -EINVAL; |
| 886 | } |
| 887 | |
| 888 | /*removing empty spaces*/ |
| 889 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
| 890 | |
| 891 | /*no argument followed by spaces*/ |
| 892 | if ('\0' == *inPtr) |
| 893 | { |
| 894 | return -EINVAL; |
| 895 | } |
| 896 | |
| 897 | /*check and parse SCANFREQ*/ |
| 898 | if ((strncmp(inPtr, "SCANFREQ", 8) == 0)) |
| 899 | { |
| 900 | inPtr = hdd_extract_assigned_int_from_str(inPtr, 10, |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 901 | &temp, &lastArg); |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 902 | |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 903 | if (0 != temp) |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 904 | { |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 905 | nScanFreq = temp; |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 906 | } |
| 907 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 908 | if ( (NULL == inPtr) || (TRUE == lastArg)) |
| 909 | { |
| 910 | return -EINVAL; |
| 911 | } |
| 912 | } |
| 913 | |
| 914 | /*check and parse MSCAN*/ |
| 915 | if ((strncmp(inPtr, "MSCAN", 5) == 0)) |
| 916 | { |
| 917 | inPtr = hdd_extract_assigned_int_from_str(inPtr, 10, |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 918 | &nMscan, &lastArg); |
| 919 | |
| 920 | if (0 == nMscan) |
| 921 | { |
| 922 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 923 | "invalid MSCAN=%d", nMscan); |
| 924 | return -EINVAL; |
| 925 | } |
| 926 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 927 | if (TRUE == lastArg) |
| 928 | { |
| 929 | goto done; |
| 930 | } |
| 931 | else if (NULL == inPtr) |
| 932 | { |
| 933 | return -EINVAL; |
| 934 | } |
| 935 | } |
| 936 | else |
| 937 | { |
| 938 | return -EINVAL; |
| 939 | } |
| 940 | |
| 941 | /*check and parse BESTN*/ |
| 942 | if ((strncmp(inPtr, "BESTN", 5) == 0)) |
| 943 | { |
| 944 | inPtr = hdd_extract_assigned_int_from_str(inPtr, 10, |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 945 | &temp, &lastArg); |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 946 | |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 947 | if (0 != temp) |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 948 | { |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 949 | nBestN = temp; |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 950 | } |
| 951 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 952 | if (TRUE == lastArg) |
| 953 | { |
| 954 | goto done; |
| 955 | } |
| 956 | else if (NULL == inPtr) |
| 957 | { |
| 958 | return -EINVAL; |
| 959 | } |
| 960 | } |
| 961 | |
| 962 | /*check and parse CHANNEL*/ |
| 963 | if ((strncmp(inPtr, "CHANNEL", 7) == 0)) |
| 964 | { |
| 965 | inPtr = hdd_extract_assigned_char_from_str(inPtr, &val, &lastArg); |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 966 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 967 | if (('A' == val) || ('a' == val)) |
| 968 | { |
c_hpothu | ebf8973 | 2014-02-25 13:00:24 +0530 | [diff] [blame] | 969 | ucRfBand = HDD_SET_BATCH_SCAN_5GHz_BAND_ONLY; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 970 | } |
| 971 | else if (('B' == val) || ('b' == val)) |
| 972 | { |
c_hpothu | ebf8973 | 2014-02-25 13:00:24 +0530 | [diff] [blame] | 973 | ucRfBand = HDD_SET_BATCH_SCAN_24GHz_BAND_ONLY; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 974 | } |
| 975 | else |
| 976 | { |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 977 | ucRfBand = HDD_SET_BATCH_SCAN_DEFAULT_BAND; |
| 978 | } |
| 979 | |
| 980 | if (TRUE == lastArg) |
| 981 | { |
| 982 | goto done; |
| 983 | } |
| 984 | else if (NULL == inPtr) |
| 985 | { |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 986 | return -EINVAL; |
| 987 | } |
| 988 | } |
| 989 | |
| 990 | /*check and parse RTT*/ |
| 991 | if ((strncmp(inPtr, "RTT", 3) == 0)) |
| 992 | { |
| 993 | inPtr = hdd_extract_assigned_int_from_str(inPtr, 10, |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 994 | &nRtt, &lastArg); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 995 | if (TRUE == lastArg) |
| 996 | { |
| 997 | goto done; |
| 998 | } |
| 999 | if (NULL == inPtr) |
| 1000 | { |
| 1001 | return -EINVAL; |
| 1002 | } |
| 1003 | } |
| 1004 | |
| 1005 | |
| 1006 | done: |
| 1007 | |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 1008 | pHddSetBatchScanReq->scanFrequency = nScanFreq; |
| 1009 | pHddSetBatchScanReq->numberOfScansToBatch = nMscan; |
| 1010 | pHddSetBatchScanReq->bestNetwork = nBestN; |
| 1011 | pHddSetBatchScanReq->rfBand = ucRfBand; |
| 1012 | pHddSetBatchScanReq->rtt = nRtt; |
| 1013 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1014 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1015 | "Received WLS_BATCHING_SET with SCANFREQ=%d " |
| 1016 | "MSCAN=%d BESTN=%d CHANNEL=%d RTT=%d", |
| 1017 | pHddSetBatchScanReq->scanFrequency, |
| 1018 | pHddSetBatchScanReq->numberOfScansToBatch, |
| 1019 | pHddSetBatchScanReq->bestNetwork, |
| 1020 | pHddSetBatchScanReq->rfBand, |
| 1021 | pHddSetBatchScanReq->rtt); |
| 1022 | |
| 1023 | return 0; |
| 1024 | }/*End of hdd_parse_set_batchscan_command*/ |
| 1025 | |
| 1026 | /**--------------------------------------------------------------------------- |
| 1027 | |
| 1028 | \brief hdd_set_batch_scan_req_callback () - This function is called after |
| 1029 | receiving set batch scan response from FW and it saves set batch scan |
| 1030 | response data FW to HDD context and sets the completion event on |
| 1031 | which hdd_ioctl is waiting |
| 1032 | |
| 1033 | \param - callbackContext Pointer to HDD adapter |
| 1034 | \param - pRsp Pointer to set batch scan response data received from FW |
| 1035 | |
| 1036 | \return - nothing |
| 1037 | |
| 1038 | --------------------------------------------------------------------------*/ |
| 1039 | static void hdd_set_batch_scan_req_callback |
| 1040 | ( |
| 1041 | void *callbackContext, |
| 1042 | tSirSetBatchScanRsp *pRsp |
| 1043 | ) |
| 1044 | { |
| 1045 | hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext; |
| 1046 | tSirSetBatchScanRsp *pHddSetBatchScanRsp; |
| 1047 | |
| 1048 | /*sanity check*/ |
| 1049 | if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) |
| 1050 | { |
| 1051 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1052 | "%s: Invalid pAdapter magic", __func__); |
| 1053 | VOS_ASSERT(0); |
| 1054 | return; |
| 1055 | } |
| 1056 | pHddSetBatchScanRsp = &pAdapter->hddSetBatchScanRsp; |
| 1057 | |
| 1058 | /*save set batch scan response*/ |
| 1059 | pHddSetBatchScanRsp->nScansToBatch = pRsp->nScansToBatch; |
| 1060 | |
| 1061 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
| 1062 | "Received set batch scan rsp from FW with nScansToBatch=%d", |
| 1063 | pHddSetBatchScanRsp->nScansToBatch); |
| 1064 | |
| 1065 | pAdapter->hdd_wait_for_set_batch_scan_rsp = FALSE; |
| 1066 | complete(&pAdapter->hdd_set_batch_scan_req_var); |
| 1067 | |
| 1068 | return; |
| 1069 | }/*End of hdd_set_batch_scan_req_callback*/ |
| 1070 | |
| 1071 | |
| 1072 | /**--------------------------------------------------------------------------- |
| 1073 | |
| 1074 | \brief hdd_populate_batch_scan_rsp_queue () - This function stores AP meta |
| 1075 | info in hdd batch scan response queue |
| 1076 | |
| 1077 | \param - pAdapter Pointer to hdd adapter |
| 1078 | \param - pAPMetaInfo Pointer to access point meta info |
| 1079 | \param - scanId scan ID of batch scan response |
| 1080 | \param - isLastAp tells whether AP is last AP in batch scan response or not |
| 1081 | |
| 1082 | \return - nothing |
| 1083 | |
| 1084 | --------------------------------------------------------------------------*/ |
| 1085 | static void hdd_populate_batch_scan_rsp_queue( hdd_adapter_t* pAdapter, |
| 1086 | tpSirBatchScanNetworkInfo pApMetaInfo, tANI_U32 scanId, v_BOOL_t isLastAp) |
| 1087 | { |
| 1088 | tHddBatchScanRsp *pHead; |
| 1089 | tHddBatchScanRsp *pNode; |
| 1090 | tHddBatchScanRsp *pPrev; |
| 1091 | tHddBatchScanRsp *pTemp; |
| 1092 | tANI_U8 ssidLen; |
| 1093 | |
| 1094 | /*head of hdd batch scan response queue*/ |
| 1095 | pHead = pAdapter->pBatchScanRsp; |
| 1096 | |
| 1097 | pNode = (tHddBatchScanRsp *)vos_mem_malloc(sizeof(tHddBatchScanRsp)); |
| 1098 | if (NULL == pNode) |
| 1099 | { |
| 1100 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1101 | "%s: Could not allocate memory", __func__); |
| 1102 | VOS_ASSERT(0); |
| 1103 | return; |
| 1104 | } |
| 1105 | |
| 1106 | vos_mem_copy(pNode->ApInfo.bssid, pApMetaInfo->bssid, |
| 1107 | sizeof(pNode->ApInfo.bssid)); |
| 1108 | ssidLen = strlen(pApMetaInfo->ssid); |
| 1109 | if (SIR_MAX_SSID_SIZE < ssidLen) |
| 1110 | { |
| 1111 | /*invalid scan result*/ |
| 1112 | vos_mem_free(pNode); |
| 1113 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1114 | "%s: Invalid AP meta info ssidlen %d", __func__, ssidLen); |
| 1115 | return; |
| 1116 | } |
| 1117 | vos_mem_copy(pNode->ApInfo.ssid, pApMetaInfo->ssid, ssidLen); |
| 1118 | /*null terminate ssid*/ |
| 1119 | pNode->ApInfo.ssid[ssidLen] = '\0'; |
| 1120 | pNode->ApInfo.ch = pApMetaInfo->ch; |
| 1121 | pNode->ApInfo.rssi = pApMetaInfo->rssi; |
| 1122 | pNode->ApInfo.age = pApMetaInfo->timestamp; |
| 1123 | pNode->ApInfo.batchId = scanId; |
| 1124 | pNode->ApInfo.isLastAp = isLastAp; |
| 1125 | |
| 1126 | pNode->pNext = NULL; |
| 1127 | if (NULL == pHead) |
| 1128 | { |
| 1129 | pAdapter->pBatchScanRsp = pNode; |
| 1130 | } |
| 1131 | else |
| 1132 | { |
| 1133 | pTemp = pHead; |
| 1134 | while (NULL != pTemp) |
| 1135 | { |
| 1136 | pPrev = pTemp; |
| 1137 | pTemp = pTemp->pNext; |
| 1138 | } |
| 1139 | pPrev->pNext = pNode; |
| 1140 | } |
| 1141 | |
| 1142 | return; |
| 1143 | }/*End of hdd_populate_batch_scan_rsp_queue*/ |
| 1144 | |
| 1145 | /**--------------------------------------------------------------------------- |
| 1146 | |
| 1147 | \brief hdd_batch_scan_result_ind_callback () - This function is called after |
| 1148 | receiving batch scan response indication from FW. It saves get batch scan |
| 1149 | response data in HDD batch scan response queue. This callback sets the |
| 1150 | completion event on which hdd_ioctl is waiting only after getting complete |
| 1151 | batch scan response data from FW |
| 1152 | |
| 1153 | \param - callbackContext Pointer to HDD adapter |
| 1154 | \param - pRsp Pointer to get batch scan response data received from FW |
| 1155 | |
| 1156 | \return - nothing |
| 1157 | |
| 1158 | --------------------------------------------------------------------------*/ |
| 1159 | static void hdd_batch_scan_result_ind_callback |
| 1160 | ( |
| 1161 | void *callbackContext, |
| 1162 | void *pRsp |
| 1163 | ) |
| 1164 | { |
| 1165 | v_BOOL_t isLastAp; |
| 1166 | tANI_U32 numApMetaInfo; |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1167 | tANI_U32 numNetworkInScanList; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1168 | tANI_U32 numberScanList; |
| 1169 | tANI_U32 nextScanListOffset; |
| 1170 | tANI_U32 nextApMetaInfoOffset; |
| 1171 | hdd_adapter_t* pAdapter; |
| 1172 | tpSirBatchScanList pScanList; |
| 1173 | tpSirBatchScanNetworkInfo pApMetaInfo; |
| 1174 | tpSirBatchScanResultIndParam pBatchScanRsp;/*batch scan rsp data from FW*/ |
| 1175 | tSirSetBatchScanReq *pReq; |
| 1176 | |
| 1177 | pAdapter = (hdd_adapter_t *)callbackContext; |
| 1178 | /*sanity check*/ |
Rajeev Kumar | 5286bb9 | 2013-12-05 11:52:10 -0800 | [diff] [blame] | 1179 | if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)) |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1180 | { |
| 1181 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1182 | "%s: Invalid pAdapter magic", __func__); |
| 1183 | VOS_ASSERT(0); |
| 1184 | return; |
| 1185 | } |
| 1186 | |
| 1187 | /*initialize locals*/ |
| 1188 | pReq = &pAdapter->hddSetBatchScanReq; |
| 1189 | pBatchScanRsp = (tpSirBatchScanResultIndParam)pRsp; |
| 1190 | isLastAp = FALSE; |
| 1191 | numApMetaInfo = 0; |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1192 | numNetworkInScanList = 0; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1193 | numberScanList = 0; |
| 1194 | nextScanListOffset = 0; |
| 1195 | nextApMetaInfoOffset = 0; |
| 1196 | pScanList = NULL; |
| 1197 | pApMetaInfo = NULL; |
| 1198 | |
| 1199 | if ((NULL == pBatchScanRsp) || (NULL == pReq)) |
| 1200 | { |
| 1201 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1202 | "%s: pBatchScanRsp is %p pReq %p", __func__, pBatchScanRsp, pReq); |
| 1203 | isLastAp = TRUE; |
| 1204 | goto done; |
| 1205 | } |
| 1206 | |
| 1207 | pAdapter->numScanList = numberScanList = pBatchScanRsp->numScanLists; |
| 1208 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1209 | "Batch scan rsp: numberScalList %d", numberScanList); |
| 1210 | |
| 1211 | if ((!numberScanList) || (numberScanList > pReq->numberOfScansToBatch)) |
| 1212 | { |
| 1213 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1214 | "%s: numberScanList %d", __func__, numberScanList); |
| 1215 | isLastAp = TRUE; |
| 1216 | goto done; |
| 1217 | } |
| 1218 | |
| 1219 | while (numberScanList) |
| 1220 | { |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1221 | pScanList = (tpSirBatchScanList)((tANI_U8 *)pBatchScanRsp->scanResults + |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1222 | nextScanListOffset); |
| 1223 | if (NULL == pScanList) |
| 1224 | { |
| 1225 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1226 | "%s: pScanList is %p", __func__, pScanList); |
| 1227 | isLastAp = TRUE; |
| 1228 | goto done; |
| 1229 | } |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1230 | numNetworkInScanList = numApMetaInfo = pScanList->numNetworksInScanList; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1231 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1232 | "Batch scan rsp: numApMetaInfo %d scanId %d", |
| 1233 | numApMetaInfo, pScanList->scanId); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1234 | |
| 1235 | if ((!numApMetaInfo) || (numApMetaInfo > pReq->bestNetwork)) |
| 1236 | { |
| 1237 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1238 | "%s: numApMetaInfo %d", __func__, numApMetaInfo); |
| 1239 | isLastAp = TRUE; |
| 1240 | goto done; |
| 1241 | } |
| 1242 | |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1243 | /*Initialize next AP meta info offset for next scan list*/ |
| 1244 | nextApMetaInfoOffset = 0; |
| 1245 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1246 | while (numApMetaInfo) |
| 1247 | { |
| 1248 | pApMetaInfo = (tpSirBatchScanNetworkInfo)(pScanList->scanList + |
| 1249 | nextApMetaInfoOffset); |
| 1250 | if (NULL == pApMetaInfo) |
| 1251 | { |
| 1252 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1253 | "%s: pApMetaInfo is %p", __func__, pApMetaInfo); |
| 1254 | isLastAp = TRUE; |
| 1255 | goto done; |
| 1256 | } |
| 1257 | /*calculate AP age*/ |
| 1258 | pApMetaInfo->timestamp = |
| 1259 | pBatchScanRsp->timestamp - pApMetaInfo->timestamp; |
| 1260 | |
| 1261 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
Arif Hussain | a7c8e41 | 2013-11-20 11:06:42 -0800 | [diff] [blame] | 1262 | "%s: bssId "MAC_ADDRESS_STR |
| 1263 | " ch %d rssi %d timestamp %d", __func__, |
| 1264 | MAC_ADDR_ARRAY(pApMetaInfo->bssid), |
| 1265 | pApMetaInfo->ch, pApMetaInfo->rssi, |
| 1266 | pApMetaInfo->timestamp); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1267 | |
| 1268 | /*mark last AP in batch scan response*/ |
| 1269 | if ((TRUE == pBatchScanRsp->isLastResult) && |
| 1270 | (1 == numberScanList) && (1 == numApMetaInfo)) |
| 1271 | { |
| 1272 | isLastAp = TRUE; |
| 1273 | } |
| 1274 | |
| 1275 | mutex_lock(&pAdapter->hdd_batch_scan_lock); |
| 1276 | /*store batch scan repsonse in hdd queue*/ |
| 1277 | hdd_populate_batch_scan_rsp_queue(pAdapter, pApMetaInfo, |
| 1278 | pScanList->scanId, isLastAp); |
| 1279 | mutex_unlock(&pAdapter->hdd_batch_scan_lock); |
| 1280 | |
| 1281 | nextApMetaInfoOffset += sizeof(tSirBatchScanNetworkInfo); |
| 1282 | numApMetaInfo--; |
| 1283 | } |
| 1284 | |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1285 | nextScanListOffset += ((sizeof(tSirBatchScanList) - sizeof(tANI_U8)) |
| 1286 | + (sizeof(tSirBatchScanNetworkInfo) |
| 1287 | * numNetworkInScanList)); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1288 | numberScanList--; |
| 1289 | } |
| 1290 | |
| 1291 | done: |
| 1292 | |
| 1293 | /*notify hdd_ioctl only if complete batch scan rsp is received and it was |
| 1294 | requested from hdd_ioctl*/ |
| 1295 | if ((TRUE == pAdapter->hdd_wait_for_get_batch_scan_rsp) && |
| 1296 | (TRUE == isLastAp)) |
| 1297 | { |
| 1298 | pAdapter->hdd_wait_for_get_batch_scan_rsp = FALSE; |
| 1299 | complete(&pAdapter->hdd_get_batch_scan_req_var); |
| 1300 | } |
| 1301 | |
| 1302 | return; |
| 1303 | }/*End of hdd_batch_scan_result_ind_callback*/ |
| 1304 | |
| 1305 | /**--------------------------------------------------------------------------- |
| 1306 | |
| 1307 | \brief hdd_format_batch_scan_rsp () - This function formats batch scan |
| 1308 | response as per batch scan FR request format by putting proper markers |
| 1309 | |
| 1310 | \param - pDest pointer to destination buffer |
| 1311 | \param - cur_len current length |
| 1312 | \param - tot_len total remaining size which can be written to user space |
| 1313 | \param - pApMetaInfo Pointer to get batch scan response AP meta info |
| 1314 | \param - pAdapter Pointer to HDD adapter |
| 1315 | |
| 1316 | \return - ret no of characters written |
| 1317 | |
| 1318 | --------------------------------------------------------------------------*/ |
| 1319 | static tANI_U32 |
| 1320 | hdd_format_batch_scan_rsp |
| 1321 | ( |
| 1322 | tANI_U8 *pDest, |
| 1323 | tANI_U32 cur_len, |
| 1324 | tANI_U32 tot_len, |
| 1325 | tHddBatchScanRsp *pApMetaInfo, |
| 1326 | hdd_adapter_t* pAdapter |
| 1327 | ) |
| 1328 | { |
| 1329 | tANI_U32 ret = 0; |
| 1330 | tANI_U32 rem_len = 0; |
| 1331 | tANI_U8 temp_len = 0; |
| 1332 | tANI_U8 temp_total_len = 0; |
| 1333 | tANI_U8 temp[HDD_BATCH_SCAN_AP_META_INFO_SIZE]; |
| 1334 | tANI_U8 *pTemp = temp; |
| 1335 | |
| 1336 | /*Batch scan reponse needs to be returned to user space in |
| 1337 | following format: |
| 1338 | "scancount=X\n" where X is the number of scans in current batch |
| 1339 | batch |
| 1340 | "trunc\n" optional present if current scan truncated |
| 1341 | "bssid=XX:XX:XX:XX:XX:XX\n" |
| 1342 | "ssid=XXXX\n" |
| 1343 | "freq=X\n" frequency in Mhz |
| 1344 | "level=XX\n" |
| 1345 | "age=X\n" ms |
| 1346 | "dist=X\n" cm (-1 if not available) |
| 1347 | "errror=X\n" (-1if not available) |
| 1348 | "====\n" (end of ap marker) |
| 1349 | "####\n" (end of scan marker) |
| 1350 | "----\n" (end of results)*/ |
| 1351 | /*send scan result in above format to user space based on |
| 1352 | available length*/ |
| 1353 | /*The GET response may have more data than the driver can return in its |
| 1354 | buffer. In that case the buffer should be filled to the nearest complete |
| 1355 | scan, ending with "%%%%".Subsequent callsshould return the remaining data |
| 1356 | starting with the next scan (optional .trunc\n., .apcount=X\n., etc). |
| 1357 | The final buffer should end with "----\n"*/ |
| 1358 | |
| 1359 | /*sanity*/ |
| 1360 | if (cur_len > tot_len) |
| 1361 | { |
| 1362 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1363 | "%s: invaid cur_len %d tot_len %d", __func__, cur_len, tot_len); |
| 1364 | return 0; |
| 1365 | } |
| 1366 | else |
| 1367 | { |
| 1368 | rem_len = (tot_len - cur_len); |
| 1369 | } |
| 1370 | |
| 1371 | /*end scan marker*/ |
| 1372 | if (pApMetaInfo->ApInfo.batchId != pAdapter->prev_batch_id) |
| 1373 | { |
| 1374 | temp_len = snprintf(pTemp, sizeof(temp), "####\n"); |
| 1375 | pTemp += temp_len; |
| 1376 | temp_total_len += temp_len; |
| 1377 | } |
| 1378 | |
| 1379 | /*bssid*/ |
| 1380 | temp_len = snprintf(pTemp, sizeof(temp), |
| 1381 | "bssid=0x%x:0x%x:0x%x:0x%x:0x%x:0x%x\n", |
| 1382 | pApMetaInfo->ApInfo.bssid[0], pApMetaInfo->ApInfo.bssid[1], |
| 1383 | pApMetaInfo->ApInfo.bssid[2], pApMetaInfo->ApInfo.bssid[3], |
| 1384 | pApMetaInfo->ApInfo.bssid[4], pApMetaInfo->ApInfo.bssid[5]); |
| 1385 | pTemp += temp_len; |
| 1386 | temp_total_len += temp_len; |
| 1387 | |
| 1388 | /*ssid*/ |
| 1389 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "ssid=%s\n", |
| 1390 | pApMetaInfo->ApInfo.ssid); |
| 1391 | pTemp += temp_len; |
| 1392 | temp_total_len += temp_len; |
| 1393 | |
| 1394 | /*freq*/ |
| 1395 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "freq=%d\n", |
Rajeev Kumar | c40f751 | 2013-11-04 14:13:23 -0800 | [diff] [blame] | 1396 | sme_ChnToFreq(pApMetaInfo->ApInfo.ch)); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1397 | pTemp += temp_len; |
| 1398 | temp_total_len += temp_len; |
| 1399 | |
| 1400 | /*level*/ |
| 1401 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "level=%d\n", |
| 1402 | pApMetaInfo->ApInfo.rssi); |
| 1403 | pTemp += temp_len; |
| 1404 | temp_total_len += temp_len; |
| 1405 | |
| 1406 | /*age*/ |
Jeff Johnson | 0279779 | 2013-10-26 19:17:13 -0700 | [diff] [blame] | 1407 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "age=%d\n", |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1408 | pApMetaInfo->ApInfo.age); |
| 1409 | pTemp += temp_len; |
| 1410 | temp_total_len += temp_len; |
| 1411 | |
| 1412 | /*dist*/ |
| 1413 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "dist=-1\n"); |
| 1414 | pTemp += temp_len; |
| 1415 | temp_total_len += temp_len; |
| 1416 | |
| 1417 | /*error*/ |
| 1418 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "error=-1\n"); |
| 1419 | pTemp += temp_len; |
| 1420 | temp_total_len += temp_len; |
| 1421 | |
| 1422 | /*end AP marker*/ |
| 1423 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "====\n"); |
| 1424 | pTemp += temp_len; |
| 1425 | temp_total_len += temp_len; |
| 1426 | |
| 1427 | /*last AP in batch scan response*/ |
| 1428 | if(TRUE == pApMetaInfo->ApInfo.isLastAp) |
| 1429 | { |
| 1430 | /*end scan marker*/ |
| 1431 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "####\n"); |
| 1432 | pTemp += temp_len; |
| 1433 | temp_total_len += temp_len; |
| 1434 | |
| 1435 | /*end batch scan result marker*/ |
| 1436 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "----\n"); |
| 1437 | pTemp += temp_len; |
| 1438 | temp_total_len += temp_len; |
Kiet Lam | aa8e15a | 2014-02-11 23:30:06 -0800 | [diff] [blame] | 1439 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1440 | } |
| 1441 | |
| 1442 | if (temp_total_len < rem_len) |
| 1443 | { |
| 1444 | ret = temp_total_len + 1; |
| 1445 | strlcpy(pDest, temp, ret); |
| 1446 | pAdapter->isTruncated = FALSE; |
| 1447 | } |
| 1448 | else |
| 1449 | { |
| 1450 | pAdapter->isTruncated = TRUE; |
| 1451 | if (rem_len >= strlen("%%%%")) |
| 1452 | { |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 1453 | ret = snprintf(pDest, sizeof(temp), "%%%%"); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1454 | } |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 1455 | else |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1456 | { |
| 1457 | ret = 0; |
| 1458 | } |
| 1459 | } |
| 1460 | |
| 1461 | return ret; |
| 1462 | |
| 1463 | }/*End of hdd_format_batch_scan_rsp*/ |
| 1464 | |
| 1465 | /**--------------------------------------------------------------------------- |
| 1466 | |
| 1467 | \brief hdd_populate_user_batch_scan_rsp() - This function populates user data |
| 1468 | buffer starting with head of hdd batch scan response queue |
| 1469 | |
| 1470 | \param - pAdapter Pointer to HDD adapter |
| 1471 | \param - pDest Pointer to user data buffer |
| 1472 | \param - cur_len current offset in user buffer |
| 1473 | \param - rem_len remaining no of bytes in user buffer |
| 1474 | |
| 1475 | \return - number of bytes written in user buffer |
| 1476 | |
| 1477 | --------------------------------------------------------------------------*/ |
| 1478 | |
| 1479 | tANI_U32 hdd_populate_user_batch_scan_rsp |
| 1480 | ( |
| 1481 | hdd_adapter_t* pAdapter, |
| 1482 | tANI_U8 *pDest, |
| 1483 | tANI_U32 cur_len, |
| 1484 | tANI_U32 rem_len |
| 1485 | ) |
| 1486 | { |
| 1487 | tHddBatchScanRsp *pHead; |
| 1488 | tHddBatchScanRsp *pPrev; |
| 1489 | tANI_U32 len; |
| 1490 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1491 | pAdapter->isTruncated = FALSE; |
| 1492 | |
| 1493 | /*head of hdd batch scan response queue*/ |
| 1494 | pHead = pAdapter->pBatchScanRsp; |
| 1495 | while (pHead) |
| 1496 | { |
| 1497 | len = hdd_format_batch_scan_rsp(pDest, cur_len, rem_len, pHead, |
| 1498 | pAdapter); |
| 1499 | pDest += len; |
Rajeev Kumar | 292d2bb | 2013-10-23 15:01:44 -0700 | [diff] [blame] | 1500 | pDest--; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1501 | cur_len += len; |
| 1502 | if(TRUE == pAdapter->isTruncated) |
| 1503 | { |
| 1504 | /*result is truncated return rest of scan rsp in next req*/ |
| 1505 | cur_len = rem_len; |
| 1506 | break; |
| 1507 | } |
| 1508 | pPrev = pHead; |
| 1509 | pHead = pHead->pNext; |
| 1510 | pAdapter->pBatchScanRsp = pHead; |
Rajeev Kumar | be17d8b | 2014-01-10 15:39:45 -0800 | [diff] [blame] | 1511 | if (TRUE == pPrev->ApInfo.isLastAp) |
| 1512 | { |
| 1513 | pAdapter->prev_batch_id = 0; |
| 1514 | } |
| 1515 | else |
| 1516 | { |
| 1517 | pAdapter->prev_batch_id = pPrev->ApInfo.batchId; |
| 1518 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1519 | vos_mem_free(pPrev); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 1520 | pPrev = NULL; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1521 | } |
| 1522 | |
| 1523 | return cur_len; |
| 1524 | }/*End of hdd_populate_user_batch_scan_rsp*/ |
| 1525 | |
| 1526 | /**--------------------------------------------------------------------------- |
| 1527 | |
| 1528 | \brief hdd_return_batch_scan_rsp_to_user () - This function returns batch |
| 1529 | scan response data from HDD queue to user space |
| 1530 | It does following in detail: |
| 1531 | a) if HDD has enough data in its queue then it 1st copies data to user |
| 1532 | space and then send get batch scan indication message to FW. In this |
| 1533 | case it does not wait on any event and batch scan response data will |
| 1534 | be populated in HDD response queue in MC thread context after receiving |
| 1535 | indication from FW |
| 1536 | b) else send get batch scan indication message to FW and wait on an event |
| 1537 | which will be set once HDD receives complete batch scan response from |
| 1538 | FW and then this function returns batch scan response to user space |
| 1539 | |
| 1540 | \param - pAdapter Pointer to HDD adapter |
| 1541 | \param - pPrivData Pointer to priv_data |
| 1542 | |
| 1543 | \return - 0 for success -EFAULT for failure |
| 1544 | |
| 1545 | --------------------------------------------------------------------------*/ |
| 1546 | |
| 1547 | int hdd_return_batch_scan_rsp_to_user |
| 1548 | ( |
| 1549 | hdd_adapter_t* pAdapter, |
| 1550 | hdd_priv_data_t *pPrivData, |
| 1551 | tANI_U8 *command |
| 1552 | ) |
| 1553 | { |
| 1554 | tANI_U8 *pDest; |
| 1555 | tANI_U32 count = 0; |
| 1556 | tANI_U32 len = 0; |
| 1557 | tANI_U32 cur_len = 0; |
| 1558 | tANI_U32 rem_len = 0; |
| 1559 | eHalStatus halStatus; |
| 1560 | unsigned long rc; |
| 1561 | tSirTriggerBatchScanResultInd *pReq; |
| 1562 | |
| 1563 | pReq = &pAdapter->hddTriggerBatchScanResultInd; |
| 1564 | pReq->param = 0;/*batch scan client*/ |
| 1565 | pDest = (tANI_U8 *)(command + pPrivData->used_len); |
| 1566 | pAdapter->hdd_wait_for_get_batch_scan_rsp = FALSE; |
| 1567 | |
| 1568 | cur_len = pPrivData->used_len; |
| 1569 | if (pPrivData->total_len > pPrivData->used_len) |
| 1570 | { |
| 1571 | rem_len = pPrivData->total_len - pPrivData->used_len; |
| 1572 | } |
| 1573 | else |
| 1574 | { |
| 1575 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1576 | "%s: Invalid user data buffer total_len %d used_len %d", |
| 1577 | __func__, pPrivData->total_len, pPrivData->used_len); |
| 1578 | return -EFAULT; |
| 1579 | } |
| 1580 | |
| 1581 | mutex_lock(&pAdapter->hdd_batch_scan_lock); |
| 1582 | len = hdd_populate_user_batch_scan_rsp(pAdapter, pDest, |
| 1583 | cur_len, rem_len); |
| 1584 | mutex_unlock(&pAdapter->hdd_batch_scan_lock); |
| 1585 | |
| 1586 | /*enough scan result available in cache to return to user space or |
| 1587 | scan result needs to be fetched 1st from fw and then return*/ |
Rajeev Kumar | 99db626 | 2013-11-11 15:23:36 -0800 | [diff] [blame] | 1588 | if (len == cur_len) |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1589 | { |
| 1590 | pAdapter->hdd_wait_for_get_batch_scan_rsp = TRUE; |
| 1591 | halStatus = sme_TriggerBatchScanResultInd( |
| 1592 | WLAN_HDD_GET_HAL_CTX(pAdapter), pReq, |
| 1593 | pAdapter->sessionId, hdd_batch_scan_result_ind_callback, |
| 1594 | pAdapter); |
| 1595 | if ( eHAL_STATUS_SUCCESS == halStatus ) |
| 1596 | { |
| 1597 | if (TRUE == pAdapter->hdd_wait_for_get_batch_scan_rsp) |
| 1598 | { |
| 1599 | INIT_COMPLETION(pAdapter->hdd_get_batch_scan_req_var); |
| 1600 | rc = wait_for_completion_timeout( |
| 1601 | &pAdapter->hdd_get_batch_scan_req_var, |
| 1602 | msecs_to_jiffies(HDD_GET_BATCH_SCAN_RSP_TIME_OUT)); |
| 1603 | if (0 == rc) |
| 1604 | { |
| 1605 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1606 | "%s: Timeout waiting to fetch batch scan rsp from fw", |
| 1607 | __func__); |
| 1608 | return -EFAULT; |
| 1609 | } |
| 1610 | } |
| 1611 | |
| 1612 | len = snprintf(pDest, HDD_BATCH_SCAN_AP_META_INFO_SIZE, |
Jeff Johnson | 0279779 | 2013-10-26 19:17:13 -0700 | [diff] [blame] | 1613 | "scancount=%u\n", pAdapter->numScanList); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1614 | pDest += len; |
| 1615 | cur_len += len; |
| 1616 | |
| 1617 | mutex_lock(&pAdapter->hdd_batch_scan_lock); |
| 1618 | len = hdd_populate_user_batch_scan_rsp(pAdapter, pDest, |
| 1619 | cur_len, rem_len); |
| 1620 | mutex_unlock(&pAdapter->hdd_batch_scan_lock); |
| 1621 | |
| 1622 | count = 0; |
| 1623 | len = (len - pPrivData->used_len); |
| 1624 | pDest = (command + pPrivData->used_len); |
| 1625 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Rajeev Kumar | 99db626 | 2013-11-11 15:23:36 -0800 | [diff] [blame] | 1626 | "NEW BATCH SCAN RESULT:"); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1627 | while(count < len) |
| 1628 | { |
| 1629 | printk("%c", *(pDest + count)); |
| 1630 | count++; |
| 1631 | } |
| 1632 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1633 | "%s: copy %d data to user buffer", __func__, len); |
| 1634 | if (copy_to_user(pPrivData->buf, pDest, len)) |
| 1635 | { |
| 1636 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1637 | "%s: failed to copy data to user buffer", __func__); |
| 1638 | return -EFAULT; |
| 1639 | } |
| 1640 | } |
| 1641 | else |
| 1642 | { |
| 1643 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1644 | "sme_GetBatchScanScan returned failure halStatus %d", |
| 1645 | halStatus); |
| 1646 | return -EINVAL; |
| 1647 | } |
| 1648 | } |
| 1649 | else |
| 1650 | { |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1651 | count = 0; |
| 1652 | len = (len - pPrivData->used_len); |
| 1653 | pDest = (command + pPrivData->used_len); |
| 1654 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Rajeev Kumar | 99db626 | 2013-11-11 15:23:36 -0800 | [diff] [blame] | 1655 | "REMAINING TRUNCATED BATCH SCAN RESULT:"); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1656 | while(count < len) |
| 1657 | { |
| 1658 | printk("%c", *(pDest + count)); |
| 1659 | count++; |
| 1660 | } |
Rajeev Kumar | 99db626 | 2013-11-11 15:23:36 -0800 | [diff] [blame] | 1661 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1662 | "%s: copy %d data to user buffer", __func__, len); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1663 | if (copy_to_user(pPrivData->buf, pDest, len)) |
| 1664 | { |
| 1665 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1666 | "%s: failed to copy data to user buffer", __func__); |
| 1667 | return -EFAULT; |
| 1668 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1669 | } |
| 1670 | |
| 1671 | return 0; |
| 1672 | } /*End of hdd_return_batch_scan_rsp_to_user*/ |
| 1673 | |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 1674 | |
| 1675 | /**--------------------------------------------------------------------------- |
| 1676 | |
| 1677 | \brief hdd_handle_batch_scan_ioctl () - This function handles WLS_BATCHING |
| 1678 | IOCTLs from user space. Following BATCH SCAN DEV IOCTs are handled: |
| 1679 | WLS_BATCHING VERSION |
| 1680 | WLS_BATCHING SET |
| 1681 | WLS_BATCHING GET |
| 1682 | WLS_BATCHING STOP |
| 1683 | |
| 1684 | \param - pAdapter Pointer to HDD adapter |
| 1685 | \param - pPrivdata Pointer to priv_data |
| 1686 | \param - command Pointer to command |
| 1687 | |
| 1688 | \return - 0 for success -EFAULT for failure |
| 1689 | |
| 1690 | --------------------------------------------------------------------------*/ |
| 1691 | |
| 1692 | int hdd_handle_batch_scan_ioctl |
| 1693 | ( |
| 1694 | hdd_adapter_t *pAdapter, |
| 1695 | hdd_priv_data_t *pPrivdata, |
| 1696 | tANI_U8 *command |
| 1697 | ) |
| 1698 | { |
| 1699 | int ret = 0; |
Yue Ma | e36e355 | 2014-03-05 17:06:20 -0800 | [diff] [blame] | 1700 | hdd_context_t *pHddCtx; |
| 1701 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 1702 | ENTER(); |
| 1703 | |
Yue Ma | e36e355 | 2014-03-05 17:06:20 -0800 | [diff] [blame] | 1704 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 1705 | ret = wlan_hdd_validate_context(pHddCtx); |
| 1706 | if (ret) |
| 1707 | { |
Yue Ma | e36e355 | 2014-03-05 17:06:20 -0800 | [diff] [blame] | 1708 | goto exit; |
| 1709 | } |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 1710 | |
| 1711 | if (strncmp(command, "WLS_BATCHING VERSION", 20) == 0) |
| 1712 | { |
| 1713 | char extra[32]; |
| 1714 | tANI_U8 len = 0; |
| 1715 | tANI_U8 version = HDD_BATCH_SCAN_VERSION; |
| 1716 | |
| 1717 | if (FALSE == sme_IsFeatureSupportedByFW(BATCH_SCAN)) |
| 1718 | { |
| 1719 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1720 | "%s: Batch scan feature is not supported by FW", __func__); |
| 1721 | ret = -EINVAL; |
| 1722 | goto exit; |
| 1723 | } |
| 1724 | |
| 1725 | len = scnprintf(extra, sizeof(extra), "WLS_BATCHING_VERSION %d", |
| 1726 | version); |
| 1727 | if (copy_to_user(pPrivdata->buf, &extra, len + 1)) |
| 1728 | { |
| 1729 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1730 | "%s: failed to copy data to user buffer", __func__); |
| 1731 | ret = -EFAULT; |
| 1732 | goto exit; |
| 1733 | } |
| 1734 | ret = HDD_BATCH_SCAN_VERSION; |
| 1735 | } |
| 1736 | else if (strncmp(command, "WLS_BATCHING SET", 16) == 0) |
| 1737 | { |
| 1738 | int status; |
| 1739 | tANI_U8 *value = (command + 16); |
| 1740 | eHalStatus halStatus; |
| 1741 | unsigned long rc; |
| 1742 | tSirSetBatchScanReq *pReq = &pAdapter->hddSetBatchScanReq; |
| 1743 | tSirSetBatchScanRsp *pRsp = &pAdapter->hddSetBatchScanRsp; |
| 1744 | |
| 1745 | if (FALSE == sme_IsFeatureSupportedByFW(BATCH_SCAN)) |
| 1746 | { |
| 1747 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1748 | "%s: Batch scan feature is not supported by FW", __func__); |
| 1749 | ret = -EINVAL; |
| 1750 | goto exit; |
| 1751 | } |
| 1752 | |
| 1753 | if ((WLAN_HDD_INFRA_STATION != pAdapter->device_mode) && |
| 1754 | (WLAN_HDD_P2P_CLIENT != pAdapter->device_mode) && |
| 1755 | (WLAN_HDD_P2P_GO != pAdapter->device_mode) && |
| 1756 | (WLAN_HDD_P2P_DEVICE != pAdapter->device_mode)) |
| 1757 | { |
| 1758 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 1759 | "Received WLS_BATCHING SET command in invalid mode %s (%d) " |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 1760 | "WLS_BATCHING_SET is only allowed in infra STA/P2P client mode", |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 1761 | hdd_device_modetoString(pAdapter->device_mode), |
| 1762 | pAdapter->device_mode); |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 1763 | ret = -EINVAL; |
| 1764 | goto exit; |
| 1765 | } |
| 1766 | |
| 1767 | status = hdd_parse_set_batchscan_command(value, pReq); |
| 1768 | if (status) |
| 1769 | { |
| 1770 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1771 | "Invalid WLS_BATCHING SET command"); |
| 1772 | ret = -EINVAL; |
| 1773 | goto exit; |
| 1774 | } |
| 1775 | |
| 1776 | |
| 1777 | pAdapter->hdd_wait_for_set_batch_scan_rsp = TRUE; |
| 1778 | halStatus = sme_SetBatchScanReq(WLAN_HDD_GET_HAL_CTX(pAdapter), pReq, |
| 1779 | pAdapter->sessionId, hdd_set_batch_scan_req_callback, |
| 1780 | pAdapter); |
| 1781 | |
| 1782 | if ( eHAL_STATUS_SUCCESS == halStatus ) |
| 1783 | { |
Mahesh A Saptasagar | 5f56817 | 2014-05-14 17:02:33 +0530 | [diff] [blame] | 1784 | char extra[32]; |
| 1785 | tANI_U8 len = 0; |
| 1786 | tANI_U8 mScan = 0; |
| 1787 | |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 1788 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 1789 | "sme_SetBatchScanReq returned success halStatus %d", |
| 1790 | halStatus); |
| 1791 | if (TRUE == pAdapter->hdd_wait_for_set_batch_scan_rsp) |
| 1792 | { |
| 1793 | INIT_COMPLETION(pAdapter->hdd_set_batch_scan_req_var); |
| 1794 | rc = wait_for_completion_timeout( |
| 1795 | &pAdapter->hdd_set_batch_scan_req_var, |
| 1796 | msecs_to_jiffies(HDD_SET_BATCH_SCAN_REQ_TIME_OUT)); |
| 1797 | if (0 == rc) |
| 1798 | { |
| 1799 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1800 | "%s: Timeout waiting for set batch scan to complete", |
| 1801 | __func__); |
| 1802 | ret = -EINVAL; |
| 1803 | goto exit; |
| 1804 | } |
| 1805 | } |
| 1806 | if ( !pRsp->nScansToBatch ) |
| 1807 | { |
| 1808 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1809 | "%s: Received set batch scan failure response from FW", |
| 1810 | __func__); |
| 1811 | ret = -EINVAL; |
| 1812 | goto exit; |
| 1813 | } |
| 1814 | /*As per the Batch Scan Framework API we should return the MIN of |
| 1815 | either MSCAN or the max # of scans firmware can cache*/ |
Mahesh A Saptasagar | 5f56817 | 2014-05-14 17:02:33 +0530 | [diff] [blame] | 1816 | mScan = MIN(pReq->numberOfScansToBatch , pRsp->nScansToBatch); |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 1817 | |
| 1818 | pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STARTED; |
| 1819 | |
| 1820 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1821 | "%s: request MSCAN %d response MSCAN %d ret %d", |
Mahesh A Saptasagar | 5f56817 | 2014-05-14 17:02:33 +0530 | [diff] [blame] | 1822 | __func__, pReq->numberOfScansToBatch, pRsp->nScansToBatch, mScan); |
| 1823 | len = scnprintf(extra, sizeof(extra), "%d", mScan); |
| 1824 | if (copy_to_user(pPrivdata->buf, &extra, len + 1)) |
| 1825 | { |
| 1826 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1827 | "%s: failed to copy MSCAN value to user buffer", __func__); |
| 1828 | ret = -EFAULT; |
| 1829 | goto exit; |
| 1830 | } |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 1831 | } |
| 1832 | else |
| 1833 | { |
| 1834 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1835 | "sme_SetBatchScanReq returned failure halStatus %d", |
| 1836 | halStatus); |
| 1837 | ret = -EINVAL; |
| 1838 | goto exit; |
| 1839 | } |
| 1840 | } |
| 1841 | else if (strncmp(command, "WLS_BATCHING STOP", 17) == 0) |
| 1842 | { |
| 1843 | eHalStatus halStatus; |
| 1844 | tSirStopBatchScanInd *pInd = &pAdapter->hddStopBatchScanInd; |
| 1845 | pInd->param = 0; |
| 1846 | |
| 1847 | if (FALSE == sme_IsFeatureSupportedByFW(BATCH_SCAN)) |
| 1848 | { |
| 1849 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1850 | "%s: Batch scan feature is not supported by FW", __func__); |
| 1851 | ret = -EINVAL; |
| 1852 | goto exit; |
| 1853 | } |
| 1854 | |
| 1855 | if (eHDD_BATCH_SCAN_STATE_STARTED != pAdapter->batchScanState) |
| 1856 | { |
Deepthi Gowri | bfd1713 | 2014-11-14 17:59:04 +0530 | [diff] [blame] | 1857 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 1858 | "Batch scan is not yet enabled batch scan state %d", |
| 1859 | pAdapter->batchScanState); |
| 1860 | ret = -EINVAL; |
| 1861 | goto exit; |
| 1862 | } |
| 1863 | |
Kiet Lam | aa8e15a | 2014-02-11 23:30:06 -0800 | [diff] [blame] | 1864 | mutex_lock(&pAdapter->hdd_batch_scan_lock); |
| 1865 | hdd_deinit_batch_scan(pAdapter); |
| 1866 | mutex_unlock(&pAdapter->hdd_batch_scan_lock); |
| 1867 | |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 1868 | pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STOPPED; |
| 1869 | |
| 1870 | halStatus = sme_StopBatchScanInd(WLAN_HDD_GET_HAL_CTX(pAdapter), pInd, |
| 1871 | pAdapter->sessionId); |
| 1872 | if ( eHAL_STATUS_SUCCESS == halStatus ) |
| 1873 | { |
| 1874 | ret = 0; |
| 1875 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 1876 | "sme_StopBatchScanInd returned success halStatus %d", |
| 1877 | halStatus); |
| 1878 | } |
| 1879 | else |
| 1880 | { |
| 1881 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1882 | "sme_StopBatchScanInd returned failure halStatus %d", |
| 1883 | halStatus); |
| 1884 | ret = -EINVAL; |
| 1885 | goto exit; |
| 1886 | } |
| 1887 | } |
| 1888 | else if (strncmp(command, "WLS_BATCHING GET", 16) == 0) |
| 1889 | { |
| 1890 | tANI_U32 remain_len; |
| 1891 | |
| 1892 | if (FALSE == sme_IsFeatureSupportedByFW(BATCH_SCAN)) |
| 1893 | { |
| 1894 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1895 | "%s: Batch scan feature is not supported by FW", __func__); |
| 1896 | ret = -EINVAL; |
| 1897 | goto exit; |
| 1898 | } |
| 1899 | |
| 1900 | if (eHDD_BATCH_SCAN_STATE_STARTED != pAdapter->batchScanState) |
| 1901 | { |
Deepthi Gowri | bfd1713 | 2014-11-14 17:59:04 +0530 | [diff] [blame] | 1902 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 1903 | "Batch scan is not yet enabled could not return results" |
| 1904 | "Batch Scan state %d", |
| 1905 | pAdapter->batchScanState); |
| 1906 | ret = -EINVAL; |
| 1907 | goto exit; |
| 1908 | } |
| 1909 | |
| 1910 | pPrivdata->used_len = 16; |
| 1911 | remain_len = pPrivdata->total_len - pPrivdata->used_len; |
| 1912 | if (remain_len < pPrivdata->total_len) |
| 1913 | { |
| 1914 | /*Clear previous batch scan response data if any*/ |
| 1915 | vos_mem_zero((tANI_U8 *)(command + pPrivdata->used_len), remain_len); |
| 1916 | } |
| 1917 | else |
| 1918 | { |
| 1919 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1920 | "Invalid total length from user space can't fetch batch" |
| 1921 | " scan response total_len %d used_len %d remain len %d", |
| 1922 | pPrivdata->total_len, pPrivdata->used_len, remain_len); |
| 1923 | ret = -EINVAL; |
| 1924 | goto exit; |
| 1925 | } |
| 1926 | ret = hdd_return_batch_scan_rsp_to_user(pAdapter, pPrivdata, command); |
| 1927 | } |
| 1928 | |
| 1929 | exit: |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 1930 | EXIT(); |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 1931 | return ret; |
| 1932 | } |
| 1933 | |
| 1934 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1935 | #endif/*End of FEATURE_WLAN_BATCH_SCAN*/ |
| 1936 | |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 1937 | static void getBcnMissRateCB(VOS_STATUS status, int bcnMissRate, void *data) |
| 1938 | { |
c_hpothu | 39eb1e3 | 2014-06-26 16:31:50 +0530 | [diff] [blame] | 1939 | bcnMissRateContext_t *pCBCtx; |
| 1940 | |
| 1941 | if (NULL == data) |
| 1942 | { |
| 1943 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("argument data is NULL")); |
| 1944 | return; |
| 1945 | } |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 1946 | |
| 1947 | /* there is a race condition that exists between this callback |
| 1948 | function and the caller since the caller could time out either |
| 1949 | before or while this code is executing. we use a spinlock to |
| 1950 | serialize these actions */ |
| 1951 | spin_lock(&hdd_context_lock); |
| 1952 | |
c_hpothu | 39eb1e3 | 2014-06-26 16:31:50 +0530 | [diff] [blame] | 1953 | pCBCtx = (bcnMissRateContext_t *)data; |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 1954 | gbcnMissRate = -1; |
| 1955 | |
c_hpothu | 39eb1e3 | 2014-06-26 16:31:50 +0530 | [diff] [blame] | 1956 | if (pCBCtx->magic != BCN_MISS_RATE_CONTEXT_MAGIC) |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 1957 | { |
| 1958 | hddLog(VOS_TRACE_LEVEL_ERROR, |
c_hpothu | 39eb1e3 | 2014-06-26 16:31:50 +0530 | [diff] [blame] | 1959 | FL("invalid context magic: %08x"), pCBCtx->magic); |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 1960 | spin_unlock(&hdd_context_lock); |
| 1961 | return ; |
| 1962 | } |
| 1963 | |
| 1964 | if (VOS_STATUS_SUCCESS == status) |
| 1965 | { |
c_hpothu | 39eb1e3 | 2014-06-26 16:31:50 +0530 | [diff] [blame] | 1966 | gbcnMissRate = bcnMissRate; |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 1967 | } |
c_hpothu | 39eb1e3 | 2014-06-26 16:31:50 +0530 | [diff] [blame] | 1968 | else |
| 1969 | { |
| 1970 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("failed to get bcnMissRate")); |
| 1971 | } |
| 1972 | |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 1973 | complete(&(pCBCtx->completion)); |
| 1974 | spin_unlock(&hdd_context_lock); |
| 1975 | |
| 1976 | return; |
| 1977 | } |
| 1978 | |
Abhishek Singh | 08aa776 | 2014-12-16 13:59:03 +0530 | [diff] [blame] | 1979 | void hdd_FWStatisCB( VOS_STATUS status, |
| 1980 | tSirFwStatsResult *fwStatsResult, void *pContext ) |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 1981 | { |
| 1982 | fwStatsContext_t *fwStatsCtx; |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 1983 | hdd_adapter_t *pAdapter; |
| 1984 | |
| 1985 | hddLog(VOS_TRACE_LEVEL_INFO, FL(" with status = %d"),status); |
| 1986 | |
Abhishek Singh | 08aa776 | 2014-12-16 13:59:03 +0530 | [diff] [blame] | 1987 | if (NULL == pContext) |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 1988 | { |
| 1989 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("argument data is NULL")); |
| 1990 | return; |
| 1991 | } |
| 1992 | /* there is a race condition that exists between this callback |
| 1993 | function and the caller since the caller could time out either |
| 1994 | before or while this code is executing. we use a spinlock to |
| 1995 | serialize these actions */ |
| 1996 | spin_lock(&hdd_context_lock); |
Abhishek Singh | 08aa776 | 2014-12-16 13:59:03 +0530 | [diff] [blame] | 1997 | fwStatsCtx = (fwStatsContext_t *) pContext; |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 1998 | if (fwStatsCtx->magic != FW_STATS_CONTEXT_MAGIC) |
| 1999 | { |
| 2000 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2001 | FL("invalid context magic: %08x"), fwStatsCtx->magic); |
| 2002 | spin_unlock(&hdd_context_lock); |
| 2003 | return; |
| 2004 | } |
| 2005 | pAdapter = fwStatsCtx->pAdapter; |
| 2006 | if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)) |
| 2007 | { |
| 2008 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2009 | FL("pAdapter returned is NULL or invalid")); |
| 2010 | spin_unlock(&hdd_context_lock); |
| 2011 | return; |
| 2012 | } |
| 2013 | pAdapter->fwStatsRsp.type = 0; |
Abhishek Singh | 08aa776 | 2014-12-16 13:59:03 +0530 | [diff] [blame] | 2014 | if ((VOS_STATUS_SUCCESS == status) && (NULL != fwStatsResult)) |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 2015 | { |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 2016 | switch( fwStatsResult->type ) |
| 2017 | { |
| 2018 | case FW_UBSP_STATS: |
| 2019 | { |
Abhishek Singh | 08aa776 | 2014-12-16 13:59:03 +0530 | [diff] [blame] | 2020 | memcpy(&pAdapter->fwStatsRsp,fwStatsResult,sizeof(tSirFwStatsResult)); |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 2021 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 2022 | FL("ubsp_enter_cnt = %d ubsp_jump_ddr_cnt = %d"), |
Abhishek Singh | 08aa776 | 2014-12-16 13:59:03 +0530 | [diff] [blame] | 2023 | pAdapter->fwStatsRsp.fwStatsData.ubspStats.ubsp_enter_cnt, |
| 2024 | pAdapter->fwStatsRsp.fwStatsData.ubspStats.ubsp_jump_ddr_cnt); |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 2025 | } |
| 2026 | break; |
| 2027 | default: |
| 2028 | { |
| 2029 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2030 | FL(" No handling for stats type %d"),fwStatsResult->type); |
| 2031 | } |
| 2032 | } |
| 2033 | } |
| 2034 | complete(&(fwStatsCtx->completion)); |
| 2035 | spin_unlock(&hdd_context_lock); |
| 2036 | return; |
| 2037 | } |
| 2038 | |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2039 | static int hdd_get_dwell_time(hdd_config_t *pCfg, tANI_U8 *command, char *extra, tANI_U8 n, tANI_U8 *len) |
| 2040 | { |
| 2041 | int ret = 0; |
| 2042 | |
| 2043 | if (!pCfg || !command || !extra || !len) |
| 2044 | { |
| 2045 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2046 | "%s: argument passsed for GETDWELLTIME is incorrect", __func__); |
| 2047 | ret = -EINVAL; |
| 2048 | return ret; |
| 2049 | } |
| 2050 | |
| 2051 | if (strncmp(command, "GETDWELLTIME ACTIVE MAX", 23) == 0) |
| 2052 | { |
| 2053 | *len = scnprintf(extra, n, "GETDWELLTIME ACTIVE MAX %u\n", |
| 2054 | (int)pCfg->nActiveMaxChnTime); |
| 2055 | return ret; |
| 2056 | } |
| 2057 | else if (strncmp(command, "GETDWELLTIME ACTIVE MIN", 23) == 0) |
| 2058 | { |
| 2059 | *len = scnprintf(extra, n, "GETDWELLTIME ACTIVE MIN %u\n", |
| 2060 | (int)pCfg->nActiveMinChnTime); |
| 2061 | return ret; |
| 2062 | } |
| 2063 | else if (strncmp(command, "GETDWELLTIME PASSIVE MAX", 24) == 0) |
| 2064 | { |
| 2065 | *len = scnprintf(extra, n, "GETDWELLTIME PASSIVE MAX %u\n", |
| 2066 | (int)pCfg->nPassiveMaxChnTime); |
| 2067 | return ret; |
| 2068 | } |
| 2069 | else if (strncmp(command, "GETDWELLTIME PASSIVE MIN", 24) == 0) |
| 2070 | { |
| 2071 | *len = scnprintf(extra, n, "GETDWELLTIME PASSIVE MIN %u\n", |
| 2072 | (int)pCfg->nPassiveMinChnTime); |
| 2073 | return ret; |
| 2074 | } |
Rajesh Babu Prathipati | 0fd227e | 2014-07-05 12:50:00 +0530 | [diff] [blame] | 2075 | else if (strncmp(command, "GETDWELLTIME", 12) == 0) |
| 2076 | { |
| 2077 | *len = scnprintf(extra, n, "GETDWELLTIME %u \n", |
| 2078 | (int)pCfg->nActiveMaxChnTime); |
| 2079 | return ret; |
| 2080 | } |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2081 | else |
| 2082 | { |
| 2083 | ret = -EINVAL; |
| 2084 | } |
| 2085 | |
| 2086 | return ret; |
| 2087 | } |
| 2088 | |
| 2089 | static int hdd_set_dwell_time(hdd_adapter_t *pAdapter, tANI_U8 *command) |
| 2090 | { |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 2091 | tHalHandle hHal; |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2092 | hdd_config_t *pCfg; |
| 2093 | tANI_U8 *value = command; |
| 2094 | int val = 0, ret = 0, temp = 0; |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 2095 | tSmeConfigParams smeConfig; |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2096 | |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 2097 | if (!pAdapter || !command || !(pCfg = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini) |
| 2098 | || !(hHal = (WLAN_HDD_GET_HAL_CTX(pAdapter)))) |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2099 | { |
| 2100 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2101 | "%s: argument passed for SETDWELLTIME is incorrect", __func__); |
| 2102 | ret = -EINVAL; |
| 2103 | return ret; |
| 2104 | } |
| 2105 | |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 2106 | vos_mem_zero(&smeConfig, sizeof(smeConfig)); |
| 2107 | sme_GetConfigParam(hHal, &smeConfig); |
| 2108 | |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2109 | if (strncmp(command, "SETDWELLTIME ACTIVE MAX", 23) == 0 ) |
| 2110 | { |
| 2111 | value = value + 24; |
| 2112 | temp = kstrtou32(value, 10, &val); |
| 2113 | if (temp != 0 || val < CFG_ACTIVE_MAX_CHANNEL_TIME_MIN || |
| 2114 | val > CFG_ACTIVE_MAX_CHANNEL_TIME_MAX ) |
| 2115 | { |
| 2116 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2117 | "%s: argument passed for SETDWELLTIME ACTIVE MAX is incorrect", __func__); |
| 2118 | ret = -EFAULT; |
| 2119 | return ret; |
| 2120 | } |
| 2121 | pCfg->nActiveMaxChnTime = val; |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 2122 | smeConfig.csrConfig.nActiveMaxChnTime = val; |
| 2123 | sme_UpdateConfig(hHal, &smeConfig); |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2124 | } |
| 2125 | else if (strncmp(command, "SETDWELLTIME ACTIVE MIN", 23) == 0) |
| 2126 | { |
| 2127 | value = value + 24; |
| 2128 | temp = kstrtou32(value, 10, &val); |
| 2129 | if (temp !=0 || val < CFG_ACTIVE_MIN_CHANNEL_TIME_MIN || |
| 2130 | val > CFG_ACTIVE_MIN_CHANNEL_TIME_MAX ) |
| 2131 | { |
| 2132 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2133 | "%s: argument passsed for SETDWELLTIME ACTIVE MIN is incorrect", __func__); |
| 2134 | ret = -EFAULT; |
| 2135 | return ret; |
| 2136 | } |
| 2137 | pCfg->nActiveMinChnTime = val; |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 2138 | smeConfig.csrConfig.nActiveMinChnTime = val; |
| 2139 | sme_UpdateConfig(hHal, &smeConfig); |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2140 | } |
| 2141 | else if (strncmp(command, "SETDWELLTIME PASSIVE MAX", 24) == 0) |
| 2142 | { |
| 2143 | value = value + 25; |
| 2144 | temp = kstrtou32(value, 10, &val); |
| 2145 | if (temp != 0 || val < CFG_PASSIVE_MAX_CHANNEL_TIME_MIN || |
| 2146 | val > CFG_PASSIVE_MAX_CHANNEL_TIME_MAX ) |
| 2147 | { |
| 2148 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2149 | "%s: argument passed for SETDWELLTIME PASSIVE MAX is incorrect", __func__); |
| 2150 | ret = -EFAULT; |
| 2151 | return ret; |
| 2152 | } |
| 2153 | pCfg->nPassiveMaxChnTime = val; |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 2154 | smeConfig.csrConfig.nPassiveMaxChnTime = val; |
| 2155 | sme_UpdateConfig(hHal, &smeConfig); |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2156 | } |
| 2157 | else if (strncmp(command, "SETDWELLTIME PASSIVE MIN", 24) == 0) |
| 2158 | { |
| 2159 | value = value + 25; |
| 2160 | temp = kstrtou32(value, 10, &val); |
| 2161 | if (temp != 0 || val < CFG_PASSIVE_MIN_CHANNEL_TIME_MIN || |
| 2162 | val > CFG_PASSIVE_MIN_CHANNEL_TIME_MAX ) |
| 2163 | { |
| 2164 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2165 | "%s: argument passed for SETDWELLTIME PASSIVE MIN is incorrect", __func__); |
| 2166 | ret = -EFAULT; |
| 2167 | return ret; |
| 2168 | } |
| 2169 | pCfg->nPassiveMinChnTime = val; |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 2170 | smeConfig.csrConfig.nPassiveMinChnTime = val; |
| 2171 | sme_UpdateConfig(hHal, &smeConfig); |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2172 | } |
Rajesh Babu Prathipati | 0fd227e | 2014-07-05 12:50:00 +0530 | [diff] [blame] | 2173 | else if (strncmp(command, "SETDWELLTIME", 12) == 0) |
| 2174 | { |
| 2175 | value = value + 13; |
| 2176 | temp = kstrtou32(value, 10, &val); |
| 2177 | if (temp != 0 || val < CFG_ACTIVE_MAX_CHANNEL_TIME_MIN || |
| 2178 | val > CFG_ACTIVE_MAX_CHANNEL_TIME_MAX ) |
| 2179 | { |
| 2180 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2181 | "%s: argument passed for SETDWELLTIME is incorrect", __func__); |
| 2182 | ret = -EFAULT; |
| 2183 | return ret; |
| 2184 | } |
| 2185 | pCfg->nActiveMaxChnTime = val; |
| 2186 | smeConfig.csrConfig.nActiveMaxChnTime = val; |
| 2187 | sme_UpdateConfig(hHal, &smeConfig); |
| 2188 | } |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2189 | else |
| 2190 | { |
| 2191 | ret = -EINVAL; |
| 2192 | } |
| 2193 | |
| 2194 | return ret; |
| 2195 | } |
| 2196 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2197 | static int hdd_driver_command(hdd_adapter_t *pAdapter, |
| 2198 | hdd_priv_data_t *ppriv_data) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2199 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2200 | hdd_priv_data_t priv_data; |
| 2201 | tANI_U8 *command = NULL; |
Kaushik, Sushant | 9612244 | 2014-10-21 16:40:18 +0530 | [diff] [blame] | 2202 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2203 | hdd_scaninfo_t *pScanInfo = NULL; |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2204 | int ret = 0; |
Kaushik, Sushant | 9612244 | 2014-10-21 16:40:18 +0530 | [diff] [blame] | 2205 | int status; |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2206 | |
| 2207 | ENTER(); |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2208 | /* |
| 2209 | * Note that valid pointers are provided by caller |
| 2210 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2211 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2212 | /* copy to local struct to avoid numerous changes to legacy code */ |
| 2213 | priv_data = *ppriv_data; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2214 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2215 | if (priv_data.total_len <= 0 || |
| 2216 | priv_data.total_len > WLAN_PRIV_DATA_MAX_LEN) |
Sameer Thalappil | 8ef3a0e | 2013-04-05 14:36:04 -0700 | [diff] [blame] | 2217 | { |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2218 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 2219 | "%s:invalid priv_data.total_len(%d)!!!", __func__, |
| 2220 | priv_data.total_len); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 2221 | ret = -EINVAL; |
| 2222 | goto exit; |
| 2223 | } |
Kaushik, Sushant | 9612244 | 2014-10-21 16:40:18 +0530 | [diff] [blame] | 2224 | status = wlan_hdd_validate_context(pHddCtx); |
| 2225 | if (0 != status) |
| 2226 | { |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2227 | ret = -EINVAL; |
| 2228 | goto exit; |
Kaushik, Sushant | 9612244 | 2014-10-21 16:40:18 +0530 | [diff] [blame] | 2229 | } |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 2230 | /* Allocate +1 for '\0' */ |
| 2231 | command = kmalloc(priv_data.total_len + 1, GFP_KERNEL); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2232 | if (!command) |
| 2233 | { |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2234 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2235 | "%s: failed to allocate memory", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2236 | ret = -ENOMEM; |
| 2237 | goto exit; |
| 2238 | } |
| 2239 | |
| 2240 | if (copy_from_user(command, priv_data.buf, priv_data.total_len)) |
| 2241 | { |
| 2242 | ret = -EFAULT; |
| 2243 | goto exit; |
| 2244 | } |
| 2245 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2246 | /* Make sure the command is NUL-terminated */ |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 2247 | command[priv_data.total_len] = '\0'; |
| 2248 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2249 | /* at one time the following block of code was conditional. braces |
| 2250 | * have been retained to avoid re-indenting the legacy code |
| 2251 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2252 | { |
| 2253 | hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx; |
| 2254 | |
| 2255 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | f9bdd4e | 2012-10-30 18:05:03 -0700 | [diff] [blame] | 2256 | "%s: Received %s cmd from Wi-Fi GUI***", __func__, command); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2257 | |
| 2258 | if (strncmp(command, "P2P_DEV_ADDR", 12) == 0 ) |
| 2259 | { |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2260 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2261 | TRACE_CODE_HDD_P2P_DEV_ADDR_IOCTL, |
| 2262 | pAdapter->sessionId, (unsigned) |
| 2263 | (*(pHddCtx->p2pDeviceAddress.bytes+2)<<24 | |
| 2264 | *(pHddCtx->p2pDeviceAddress.bytes+3)<<16 | |
| 2265 | *(pHddCtx->p2pDeviceAddress.bytes+4)<<8 | |
| 2266 | *(pHddCtx->p2pDeviceAddress.bytes+5)))); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2267 | if (copy_to_user(priv_data.buf, pHddCtx->p2pDeviceAddress.bytes, |
| 2268 | sizeof(tSirMacAddr))) |
| 2269 | { |
| 2270 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2271 | "%s: failed to copy data to user buffer", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2272 | ret = -EFAULT; |
| 2273 | } |
| 2274 | } |
Amar Singhal | 0974e40 | 2013-02-12 14:27:46 -0800 | [diff] [blame] | 2275 | else if(strncmp(command, "SETBAND", 7) == 0) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2276 | { |
Amar Singhal | 0974e40 | 2013-02-12 14:27:46 -0800 | [diff] [blame] | 2277 | tANI_U8 *ptr = command ; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2278 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2279 | /* Change band request received */ |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2280 | |
| 2281 | /* First 8 bytes will have "SETBAND " and |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2282 | * 9 byte will have band setting value */ |
Madan Mohan Koyyalamudi | 8bdd311 | 2012-09-24 13:55:14 -0700 | [diff] [blame] | 2283 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Amar Singhal | 0974e40 | 2013-02-12 14:27:46 -0800 | [diff] [blame] | 2284 | "%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] | 2285 | /* Change band request received */ |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2286 | ret = hdd_setBand_helper(pAdapter->dev, ptr); |
Abhishek Singh | 2ec36ab | 2014-08-07 16:14:25 +0530 | [diff] [blame] | 2287 | if(ret < 0) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 2288 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2289 | "%s: failed to set band ret=%d", __func__, ret); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2290 | } |
Kiet Lam | f040f47 | 2013-11-20 21:15:23 +0530 | [diff] [blame] | 2291 | else if(strncmp(command, "SETWMMPS", 8) == 0) |
| 2292 | { |
| 2293 | tANI_U8 *ptr = command; |
| 2294 | ret = hdd_wmmps_helper(pAdapter, ptr); |
| 2295 | } |
Agarwal Ashish | ef54a18 | 2014-12-16 15:07:31 +0530 | [diff] [blame] | 2296 | |
| 2297 | else if(strncmp(command, "TDLSSCAN", 8) == 0) |
| 2298 | { |
| 2299 | tANI_U8 *ptr = command; |
| 2300 | ret = hdd_set_tdls_scan_type(pAdapter, ptr); |
| 2301 | } |
| 2302 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2303 | else if ( strncasecmp(command, "COUNTRY", 7) == 0 ) |
| 2304 | { |
| 2305 | char *country_code; |
| 2306 | |
| 2307 | country_code = command + 8; |
Tushnim Bhattacharyya | 9cdf608 | 2013-04-21 16:33:30 -0700 | [diff] [blame] | 2308 | |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 2309 | INIT_COMPLETION(pAdapter->change_country_code); |
Tushnim Bhattacharyya | 9cdf608 | 2013-04-21 16:33:30 -0700 | [diff] [blame] | 2310 | hdd_checkandupdate_dfssetting(pAdapter, country_code); |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 2311 | #ifndef CONFIG_ENABLE_LINUX_REG |
Gopichand Nakkala | dacbcb5 | 2013-04-18 16:41:54 +0530 | [diff] [blame] | 2312 | hdd_checkandupdate_phymode(pAdapter, country_code); |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 2313 | #endif |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 2314 | ret = (int)sme_ChangeCountryCode(pHddCtx->hHal, |
| 2315 | (void *)(tSmeChangeCountryCallback) |
| 2316 | wlan_hdd_change_country_code_callback, |
Abhishek Singh | a306a44 | 2013-11-07 18:39:01 +0530 | [diff] [blame] | 2317 | country_code, pAdapter, pHddCtx->pvosContext, eSIR_TRUE, eSIR_TRUE); |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 2318 | if (eHAL_STATUS_SUCCESS == ret) |
| 2319 | { |
| 2320 | ret = wait_for_completion_interruptible_timeout( |
| 2321 | &pAdapter->change_country_code, |
| 2322 | msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY)); |
| 2323 | if (0 >= ret) |
| 2324 | { |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2325 | 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] | 2326 | __func__, ret); |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 2327 | } |
| 2328 | } |
| 2329 | else |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2330 | { |
| 2331 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2332 | "%s: SME Change Country code fail ret=%d", __func__, ret); |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 2333 | ret = -EINVAL; |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2334 | } |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 2335 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 2336 | } |
| 2337 | /* |
| 2338 | command should be a string having format |
| 2339 | SET_SAP_CHANNEL_LIST <num of channels> <the channels seperated by spaces> |
| 2340 | */ |
Amar Singhal | 0974e40 | 2013-02-12 14:27:46 -0800 | [diff] [blame] | 2341 | else if(strncmp(command, "SET_SAP_CHANNEL_LIST", 20) == 0) |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 2342 | { |
Amar Singhal | 0974e40 | 2013-02-12 14:27:46 -0800 | [diff] [blame] | 2343 | tANI_U8 *ptr = command; |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 2344 | |
| 2345 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 2346 | " Received Command to Set Preferred Channels for SAP in %s", __func__); |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 2347 | |
Mahesh Kumar Kalikot Veetil | 2aad8d8 | 2013-02-07 12:31:28 -0800 | [diff] [blame] | 2348 | ret = sapSetPreferredChannel(ptr); |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2349 | } |
Sameer Thalappil | 45931fb | 2013-02-01 11:18:05 -0800 | [diff] [blame] | 2350 | else if(strncmp(command, "SETSUSPENDMODE", 14) == 0) |
| 2351 | { |
| 2352 | int suspend = 0; |
| 2353 | tANI_U8 *ptr = (tANI_U8*)command + 15; |
| 2354 | |
| 2355 | suspend = *ptr - '0'; |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2356 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2357 | TRACE_CODE_HDD_SETSUSPENDMODE_IOCTL, |
| 2358 | pAdapter->sessionId, suspend)); |
Sameer Thalappil | 45931fb | 2013-02-01 11:18:05 -0800 | [diff] [blame] | 2359 | hdd_set_wlan_suspend_mode(suspend); |
| 2360 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2361 | #ifdef WLAN_FEATURE_NEIGHBOR_ROAMING |
| 2362 | else if (strncmp(command, "SETROAMTRIGGER", 14) == 0) |
| 2363 | { |
| 2364 | tANI_U8 *value = command; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2365 | tANI_S8 rssi = 0; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2366 | tANI_U8 lookUpThreshold = CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_DEFAULT; |
| 2367 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 2368 | |
| 2369 | /* Move pointer to ahead of SETROAMTRIGGER<delimiter> */ |
| 2370 | value = value + 15; |
| 2371 | |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2372 | /* Convert the value from ascii to integer */ |
| 2373 | ret = kstrtos8(value, 10, &rssi); |
| 2374 | if (ret < 0) |
| 2375 | { |
| 2376 | /* If the input value is greater than max value of datatype, then also |
| 2377 | kstrtou8 fails */ |
| 2378 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2379 | "%s: kstrtou8 failed Input value may be out of range[%d - %d]", |
Srinivas Girigowda | fa7157d | 2013-10-31 10:14:22 -0700 | [diff] [blame] | 2380 | __func__, |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2381 | CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MIN, |
| 2382 | CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MAX); |
| 2383 | ret = -EINVAL; |
| 2384 | goto exit; |
| 2385 | } |
| 2386 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2387 | lookUpThreshold = abs(rssi); |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2388 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2389 | if ((lookUpThreshold < CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MIN) || |
| 2390 | (lookUpThreshold > CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MAX)) |
| 2391 | { |
| 2392 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2393 | "Neighbor lookup threshold value %d is out of range" |
| 2394 | " (Min: %d Max: %d)", lookUpThreshold, |
| 2395 | CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MIN, |
| 2396 | CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MAX); |
| 2397 | ret = -EINVAL; |
| 2398 | goto exit; |
| 2399 | } |
| 2400 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2401 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2402 | TRACE_CODE_HDD_SETROAMTRIGGER_IOCTL, |
| 2403 | pAdapter->sessionId, lookUpThreshold)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2404 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2405 | "%s: Received Command to Set Roam trigger" |
| 2406 | " (Neighbor lookup threshold) = %d", __func__, lookUpThreshold); |
| 2407 | |
| 2408 | pHddCtx->cfg_ini->nNeighborLookupRssiThreshold = lookUpThreshold; |
| 2409 | status = sme_setNeighborLookupRssiThreshold((tHalHandle)(pHddCtx->hHal), lookUpThreshold); |
| 2410 | if (eHAL_STATUS_SUCCESS != status) |
| 2411 | { |
| 2412 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2413 | "%s: Failed to set roam trigger, try again", __func__); |
| 2414 | ret = -EPERM; |
| 2415 | goto exit; |
| 2416 | } |
| 2417 | |
| 2418 | /* Set Reassoc threshold to (lookup rssi threshold + 5 dBm) */ |
mukul sharma | d6e1fdd | 2014-06-23 19:19:09 +0530 | [diff] [blame] | 2419 | pHddCtx->cfg_ini->nNeighborReassocRssiThreshold = lookUpThreshold + 5; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2420 | sme_setNeighborReassocRssiThreshold((tHalHandle)(pHddCtx->hHal), lookUpThreshold + 5); |
| 2421 | } |
| 2422 | else if (strncmp(command, "GETROAMTRIGGER", 14) == 0) |
| 2423 | { |
| 2424 | tANI_U8 lookUpThreshold = sme_getNeighborLookupRssiThreshold((tHalHandle)(pHddCtx->hHal)); |
| 2425 | int rssi = (-1) * lookUpThreshold; |
| 2426 | char extra[32]; |
| 2427 | tANI_U8 len = 0; |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2428 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2429 | TRACE_CODE_HDD_GETROAMTRIGGER_IOCTL, |
| 2430 | pAdapter->sessionId, lookUpThreshold)); |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2431 | len = scnprintf(extra, sizeof(extra), "%s %d", command, rssi); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2432 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2433 | { |
| 2434 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2435 | "%s: failed to copy data to user buffer", __func__); |
| 2436 | ret = -EFAULT; |
| 2437 | goto exit; |
| 2438 | } |
| 2439 | } |
| 2440 | else if (strncmp(command, "SETROAMSCANPERIOD", 17) == 0) |
| 2441 | { |
| 2442 | tANI_U8 *value = command; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2443 | tANI_U8 roamScanPeriod = 0; |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2444 | tANI_U16 neighborEmptyScanRefreshPeriod = CFG_EMPTY_SCAN_REFRESH_PERIOD_DEFAULT; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2445 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2446 | /* input refresh period is in terms of seconds */ |
| 2447 | /* Move pointer to ahead of SETROAMSCANPERIOD<delimiter> */ |
| 2448 | value = value + 18; |
| 2449 | /* Convert the value from ascii to integer */ |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2450 | ret = kstrtou8(value, 10, &roamScanPeriod); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2451 | if (ret < 0) |
| 2452 | { |
| 2453 | /* 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] | 2454 | kstrtou8 fails */ |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2455 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2456 | "%s: kstrtou8 failed Input value may be out of range[%d - %d]", |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2457 | __func__, |
Srinivas Girigowda | b8edd1e | 2013-03-19 11:42:08 -0700 | [diff] [blame] | 2458 | (CFG_EMPTY_SCAN_REFRESH_PERIOD_MIN/1000), |
| 2459 | (CFG_EMPTY_SCAN_REFRESH_PERIOD_MAX/1000)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2460 | ret = -EINVAL; |
| 2461 | goto exit; |
| 2462 | } |
| 2463 | |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2464 | if ((roamScanPeriod < (CFG_EMPTY_SCAN_REFRESH_PERIOD_MIN/1000)) || |
| 2465 | (roamScanPeriod > (CFG_EMPTY_SCAN_REFRESH_PERIOD_MAX/1000))) |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2466 | { |
| 2467 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2468 | "Roam scan period value %d is out of range" |
| 2469 | " (Min: %d Max: %d)", roamScanPeriod, |
Srinivas Girigowda | b8edd1e | 2013-03-19 11:42:08 -0700 | [diff] [blame] | 2470 | (CFG_EMPTY_SCAN_REFRESH_PERIOD_MIN/1000), |
| 2471 | (CFG_EMPTY_SCAN_REFRESH_PERIOD_MAX/1000)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2472 | ret = -EINVAL; |
| 2473 | goto exit; |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2474 | } |
| 2475 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2476 | TRACE_CODE_HDD_SETROAMSCANPERIOD_IOCTL, |
| 2477 | pAdapter->sessionId, roamScanPeriod)); |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2478 | neighborEmptyScanRefreshPeriod = roamScanPeriod * 1000; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2479 | |
| 2480 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2481 | "%s: Received Command to Set roam scan period" |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2482 | " (Empty Scan refresh period) = %d", __func__, roamScanPeriod); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2483 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2484 | pHddCtx->cfg_ini->nEmptyScanRefreshPeriod = neighborEmptyScanRefreshPeriod; |
| 2485 | sme_UpdateEmptyScanRefreshPeriod((tHalHandle)(pHddCtx->hHal), neighborEmptyScanRefreshPeriod); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2486 | } |
| 2487 | else if (strncmp(command, "GETROAMSCANPERIOD", 17) == 0) |
| 2488 | { |
| 2489 | tANI_U16 nEmptyScanRefreshPeriod = sme_getEmptyScanRefreshPeriod((tHalHandle)(pHddCtx->hHal)); |
| 2490 | char extra[32]; |
| 2491 | tANI_U8 len = 0; |
| 2492 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2493 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2494 | TRACE_CODE_HDD_GETROAMSCANPERIOD_IOCTL, |
| 2495 | pAdapter->sessionId, nEmptyScanRefreshPeriod)); |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2496 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 2497 | "GETROAMSCANPERIOD", (nEmptyScanRefreshPeriod/1000)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2498 | /* Returned value is in units of seconds */ |
| 2499 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2500 | { |
| 2501 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2502 | "%s: failed to copy data to user buffer", __func__); |
| 2503 | ret = -EFAULT; |
| 2504 | goto exit; |
| 2505 | } |
| 2506 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2507 | else if (strncmp(command, "SETROAMSCANREFRESHPERIOD", 24) == 0) |
| 2508 | { |
| 2509 | tANI_U8 *value = command; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2510 | tANI_U8 roamScanRefreshPeriod = 0; |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2511 | tANI_U16 neighborScanRefreshPeriod = CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_DEFAULT; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2512 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2513 | /* input refresh period is in terms of seconds */ |
| 2514 | /* Move pointer to ahead of SETROAMSCANREFRESHPERIOD<delimiter> */ |
| 2515 | value = value + 25; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2516 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2517 | /* Convert the value from ascii to integer */ |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2518 | ret = kstrtou8(value, 10, &roamScanRefreshPeriod); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2519 | if (ret < 0) |
| 2520 | { |
| 2521 | /* 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] | 2522 | kstrtou8 fails */ |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2523 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2524 | "%s: kstrtou8 failed Input value may be out of range[%d - %d]", |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2525 | __func__, |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2526 | (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MIN/1000), |
| 2527 | (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MAX/1000)); |
| 2528 | ret = -EINVAL; |
| 2529 | goto exit; |
| 2530 | } |
| 2531 | |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2532 | if ((roamScanRefreshPeriod < (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MIN/1000)) || |
| 2533 | (roamScanRefreshPeriod > (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MAX/1000))) |
| 2534 | { |
| 2535 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2536 | "Neighbor scan results refresh period value %d is out of range" |
| 2537 | " (Min: %d Max: %d)", roamScanRefreshPeriod, |
| 2538 | (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MIN/1000), |
| 2539 | (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MAX/1000)); |
| 2540 | ret = -EINVAL; |
| 2541 | goto exit; |
| 2542 | } |
| 2543 | neighborScanRefreshPeriod = roamScanRefreshPeriod * 1000; |
| 2544 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2545 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2546 | "%s: Received Command to Set roam scan refresh period" |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2547 | " (Scan refresh period) = %d", __func__, roamScanRefreshPeriod); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2548 | |
| 2549 | pHddCtx->cfg_ini->nNeighborResultsRefreshPeriod = neighborScanRefreshPeriod; |
| 2550 | sme_setNeighborScanRefreshPeriod((tHalHandle)(pHddCtx->hHal), neighborScanRefreshPeriod); |
| 2551 | } |
| 2552 | else if (strncmp(command, "GETROAMSCANREFRESHPERIOD", 24) == 0) |
| 2553 | { |
| 2554 | tANI_U16 value = sme_getNeighborScanRefreshPeriod((tHalHandle)(pHddCtx->hHal)); |
| 2555 | char extra[32]; |
| 2556 | tANI_U8 len = 0; |
| 2557 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2558 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 2559 | "GETROAMSCANREFRESHPERIOD", (value/1000)); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2560 | /* Returned value is in units of seconds */ |
| 2561 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2562 | { |
| 2563 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2564 | "%s: failed to copy data to user buffer", __func__); |
| 2565 | ret = -EFAULT; |
| 2566 | goto exit; |
| 2567 | } |
| 2568 | } |
Varun Reddy Yeturu | 6d99ac8 | 2013-05-08 14:15:35 -0700 | [diff] [blame] | 2569 | #ifdef FEATURE_WLAN_LFR |
| 2570 | /* SETROAMMODE */ |
| 2571 | else if (strncmp(command, "SETROAMMODE", SIZE_OF_SETROAMMODE) == 0) |
| 2572 | { |
| 2573 | tANI_U8 *value = command; |
| 2574 | tANI_BOOLEAN roamMode = CFG_LFR_FEATURE_ENABLED_DEFAULT; |
| 2575 | |
| 2576 | /* Move pointer to ahead of SETROAMMODE<delimiter> */ |
| 2577 | value = value + SIZE_OF_SETROAMMODE + 1; |
| 2578 | |
| 2579 | /* Convert the value from ascii to integer */ |
| 2580 | ret = kstrtou8(value, SIZE_OF_SETROAMMODE, &roamMode); |
| 2581 | if (ret < 0) |
| 2582 | { |
| 2583 | /* If the input value is greater than max value of datatype, then also |
| 2584 | kstrtou8 fails */ |
| 2585 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2586 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 2587 | CFG_LFR_FEATURE_ENABLED_MIN, |
| 2588 | CFG_LFR_FEATURE_ENABLED_MAX); |
| 2589 | ret = -EINVAL; |
| 2590 | goto exit; |
| 2591 | } |
| 2592 | if ((roamMode < CFG_LFR_FEATURE_ENABLED_MIN) || |
| 2593 | (roamMode > CFG_LFR_FEATURE_ENABLED_MAX)) |
| 2594 | { |
| 2595 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2596 | "Roam Mode value %d is out of range" |
| 2597 | " (Min: %d Max: %d)", roamMode, |
| 2598 | CFG_LFR_FEATURE_ENABLED_MIN, |
| 2599 | CFG_LFR_FEATURE_ENABLED_MAX); |
| 2600 | ret = -EINVAL; |
| 2601 | goto exit; |
| 2602 | } |
| 2603 | |
| 2604 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2605 | "%s: Received Command to Set Roam Mode = %d", __func__, roamMode); |
| 2606 | /* |
| 2607 | * Note that |
| 2608 | * SETROAMMODE 0 is to enable LFR while |
| 2609 | * SETROAMMODE 1 is to disable LFR, but |
| 2610 | * NotifyIsFastRoamIniFeatureEnabled 0/1 is to enable/disable. |
| 2611 | * So, we have to invert the value to call sme_UpdateIsFastRoamIniFeatureEnabled. |
| 2612 | */ |
| 2613 | if (CFG_LFR_FEATURE_ENABLED_MIN == roamMode) |
| 2614 | roamMode = CFG_LFR_FEATURE_ENABLED_MAX; /* Roam enable */ |
| 2615 | else |
| 2616 | roamMode = CFG_LFR_FEATURE_ENABLED_MIN; /* Roam disable */ |
| 2617 | |
| 2618 | pHddCtx->cfg_ini->isFastRoamIniFeatureEnabled = roamMode; |
| 2619 | sme_UpdateIsFastRoamIniFeatureEnabled((tHalHandle)(pHddCtx->hHal), roamMode); |
| 2620 | } |
| 2621 | /* GETROAMMODE */ |
Mahesh A Saptasagar | ec7d109 | 2015-04-02 13:41:34 +0530 | [diff] [blame] | 2622 | else if (strncmp(command, "GETROAMMODE", SIZE_OF_GETROAMMODE) == 0) |
Varun Reddy Yeturu | 6d99ac8 | 2013-05-08 14:15:35 -0700 | [diff] [blame] | 2623 | { |
| 2624 | tANI_BOOLEAN roamMode = sme_getIsLfrFeatureEnabled((tHalHandle)(pHddCtx->hHal)); |
| 2625 | char extra[32]; |
| 2626 | tANI_U8 len = 0; |
| 2627 | |
| 2628 | /* |
| 2629 | * roamMode value shall be inverted because the sementics is different. |
| 2630 | */ |
| 2631 | if (CFG_LFR_FEATURE_ENABLED_MIN == roamMode) |
| 2632 | roamMode = CFG_LFR_FEATURE_ENABLED_MAX; |
| 2633 | else |
| 2634 | roamMode = CFG_LFR_FEATURE_ENABLED_MIN; |
| 2635 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2636 | len = scnprintf(extra, sizeof(extra), "%s %d", command, roamMode); |
Varun Reddy Yeturu | 6d99ac8 | 2013-05-08 14:15:35 -0700 | [diff] [blame] | 2637 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2638 | { |
| 2639 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2640 | "%s: failed to copy data to user buffer", __func__); |
| 2641 | ret = -EFAULT; |
| 2642 | goto exit; |
| 2643 | } |
| 2644 | } |
| 2645 | #endif |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2646 | #endif |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2647 | #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] | 2648 | else if (strncmp(command, "SETROAMDELTA", 12) == 0) |
| 2649 | { |
| 2650 | tANI_U8 *value = command; |
| 2651 | tANI_U8 roamRssiDiff = CFG_ROAM_RSSI_DIFF_DEFAULT; |
| 2652 | |
| 2653 | /* Move pointer to ahead of SETROAMDELTA<delimiter> */ |
| 2654 | value = value + 13; |
| 2655 | /* Convert the value from ascii to integer */ |
| 2656 | ret = kstrtou8(value, 10, &roamRssiDiff); |
| 2657 | if (ret < 0) |
| 2658 | { |
| 2659 | /* If the input value is greater than max value of datatype, then also |
| 2660 | kstrtou8 fails */ |
| 2661 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2662 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 2663 | CFG_ROAM_RSSI_DIFF_MIN, |
| 2664 | CFG_ROAM_RSSI_DIFF_MAX); |
| 2665 | ret = -EINVAL; |
| 2666 | goto exit; |
| 2667 | } |
| 2668 | |
| 2669 | if ((roamRssiDiff < CFG_ROAM_RSSI_DIFF_MIN) || |
| 2670 | (roamRssiDiff > CFG_ROAM_RSSI_DIFF_MAX)) |
| 2671 | { |
| 2672 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2673 | "Roam rssi diff value %d is out of range" |
| 2674 | " (Min: %d Max: %d)", roamRssiDiff, |
| 2675 | CFG_ROAM_RSSI_DIFF_MIN, |
| 2676 | CFG_ROAM_RSSI_DIFF_MAX); |
| 2677 | ret = -EINVAL; |
| 2678 | goto exit; |
| 2679 | } |
| 2680 | |
| 2681 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2682 | "%s: Received Command to Set roam rssi diff = %d", __func__, roamRssiDiff); |
| 2683 | |
| 2684 | pHddCtx->cfg_ini->RoamRssiDiff = roamRssiDiff; |
| 2685 | sme_UpdateRoamRssiDiff((tHalHandle)(pHddCtx->hHal), roamRssiDiff); |
| 2686 | } |
Mahesh A Saptasagar | ec7d109 | 2015-04-02 13:41:34 +0530 | [diff] [blame] | 2687 | else if (strncmp(command, "GETROAMDELTA", 12) == 0) |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2688 | { |
| 2689 | tANI_U8 roamRssiDiff = sme_getRoamRssiDiff((tHalHandle)(pHddCtx->hHal)); |
| 2690 | char extra[32]; |
| 2691 | tANI_U8 len = 0; |
| 2692 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2693 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2694 | TRACE_CODE_HDD_GETROAMDELTA_IOCTL, |
| 2695 | pAdapter->sessionId, roamRssiDiff)); |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2696 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 2697 | command, roamRssiDiff); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2698 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2699 | { |
| 2700 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2701 | "%s: failed to copy data to user buffer", __func__); |
| 2702 | ret = -EFAULT; |
| 2703 | goto exit; |
| 2704 | } |
| 2705 | } |
| 2706 | #endif |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2707 | #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] | 2708 | else if (strncmp(command, "GETBAND", 7) == 0) |
| 2709 | { |
| 2710 | int band = -1; |
| 2711 | char extra[32]; |
| 2712 | tANI_U8 len = 0; |
| 2713 | hdd_getBand_helper(pHddCtx, &band); |
| 2714 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2715 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2716 | TRACE_CODE_HDD_GETBAND_IOCTL, |
| 2717 | pAdapter->sessionId, band)); |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2718 | len = scnprintf(extra, sizeof(extra), "%s %d", command, band); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2719 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2720 | { |
| 2721 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2722 | "%s: failed to copy data to user buffer", __func__); |
| 2723 | ret = -EFAULT; |
| 2724 | goto exit; |
| 2725 | } |
| 2726 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2727 | else if (strncmp(command, "SETROAMSCANCHANNELS", 19) == 0) |
| 2728 | { |
| 2729 | tANI_U8 *value = command; |
| 2730 | tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0}; |
| 2731 | tANI_U8 numChannels = 0; |
| 2732 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 2733 | |
| 2734 | status = hdd_parse_channellist(value, ChannelList, &numChannels); |
| 2735 | if (eHAL_STATUS_SUCCESS != status) |
| 2736 | { |
| 2737 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2738 | "%s: Failed to parse channel list information", __func__); |
| 2739 | ret = -EINVAL; |
| 2740 | goto exit; |
| 2741 | } |
| 2742 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2743 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2744 | TRACE_CODE_HDD_SETROAMSCANCHANNELS_IOCTL, |
| 2745 | pAdapter->sessionId, numChannels)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2746 | if (numChannels > WNI_CFG_VALID_CHANNEL_LIST_LEN) |
| 2747 | { |
| 2748 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2749 | "%s: number of channels (%d) supported exceeded max (%d)", __func__, |
| 2750 | numChannels, WNI_CFG_VALID_CHANNEL_LIST_LEN); |
| 2751 | ret = -EINVAL; |
| 2752 | goto exit; |
| 2753 | } |
| 2754 | status = sme_ChangeRoamScanChannelList((tHalHandle)(pHddCtx->hHal), ChannelList, |
| 2755 | numChannels); |
| 2756 | if (eHAL_STATUS_SUCCESS != status) |
| 2757 | { |
| 2758 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2759 | "%s: Failed to update channel list information", __func__); |
| 2760 | ret = -EINVAL; |
| 2761 | goto exit; |
| 2762 | } |
| 2763 | } |
| 2764 | else if (strncmp(command, "GETROAMSCANCHANNELS", 19) == 0) |
| 2765 | { |
| 2766 | tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0}; |
| 2767 | tANI_U8 numChannels = 0; |
Jeff Johnson | 51b6778 | 2013-04-05 12:35:41 -0700 | [diff] [blame] | 2768 | tANI_U8 j = 0; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2769 | char extra[128] = {0}; |
Jeff Johnson | 51b6778 | 2013-04-05 12:35:41 -0700 | [diff] [blame] | 2770 | int len; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2771 | |
| 2772 | if (eHAL_STATUS_SUCCESS != sme_getRoamScanChannelList( (tHalHandle)(pHddCtx->hHal), |
| 2773 | ChannelList, &numChannels )) |
| 2774 | { |
| 2775 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 2776 | "%s: failed to get roam scan channel list", __func__); |
| 2777 | ret = -EFAULT; |
| 2778 | goto exit; |
| 2779 | } |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2780 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2781 | TRACE_CODE_HDD_GETROAMSCANCHANNELS_IOCTL, |
| 2782 | pAdapter->sessionId, numChannels)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2783 | /* output channel list is of the format |
| 2784 | [Number of roam scan channels][Channel1][Channel2]... */ |
| 2785 | /* copy the number of channels in the 0th index */ |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2786 | len = scnprintf(extra, sizeof(extra), "%s %d", command, numChannels); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2787 | for (j = 0; (j < numChannels); j++) |
| 2788 | { |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2789 | len += scnprintf(extra + len, sizeof(extra) - len, " %d", |
| 2790 | ChannelList[j]); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2791 | } |
| 2792 | |
| 2793 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2794 | { |
| 2795 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2796 | "%s: failed to copy data to user buffer", __func__); |
| 2797 | ret = -EFAULT; |
| 2798 | goto exit; |
| 2799 | } |
| 2800 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2801 | else if (strncmp(command, "GETCCXMODE", 10) == 0) |
| 2802 | { |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2803 | tANI_BOOLEAN eseMode = sme_getIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal)); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2804 | char extra[32]; |
| 2805 | tANI_U8 len = 0; |
| 2806 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2807 | /* Check if the features OKC/ESE/11R are supported simultaneously, |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 2808 | then this operation is not permitted (return FAILURE) */ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2809 | if (eseMode && |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 2810 | hdd_is_okc_mode_enabled(pHddCtx) && |
| 2811 | sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal))) |
| 2812 | { |
| 2813 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2814 | "%s: OKC/ESE/11R are supported simultaneously" |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 2815 | " hence this operation is not permitted!", __func__); |
| 2816 | ret = -EPERM; |
| 2817 | goto exit; |
| 2818 | } |
| 2819 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2820 | len = scnprintf(extra, sizeof(extra), "%s %d", |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2821 | "GETCCXMODE", eseMode); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2822 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2823 | { |
| 2824 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2825 | "%s: failed to copy data to user buffer", __func__); |
| 2826 | ret = -EFAULT; |
| 2827 | goto exit; |
| 2828 | } |
| 2829 | } |
| 2830 | else if (strncmp(command, "GETOKCMODE", 10) == 0) |
| 2831 | { |
| 2832 | tANI_BOOLEAN okcMode = hdd_is_okc_mode_enabled(pHddCtx); |
| 2833 | char extra[32]; |
| 2834 | tANI_U8 len = 0; |
| 2835 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2836 | /* Check if the features OKC/ESE/11R are supported simultaneously, |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 2837 | then this operation is not permitted (return FAILURE) */ |
| 2838 | if (okcMode && |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2839 | sme_getIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal)) && |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 2840 | sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal))) |
| 2841 | { |
| 2842 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2843 | "%s: OKC/ESE/11R are supported simultaneously" |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 2844 | " hence this operation is not permitted!", __func__); |
| 2845 | ret = -EPERM; |
| 2846 | goto exit; |
| 2847 | } |
| 2848 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2849 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 2850 | "GETOKCMODE", okcMode); |
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 | } |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2859 | else if (strncmp(command, "GETFASTROAM", 11) == 0) |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2860 | { |
| 2861 | tANI_BOOLEAN lfrMode = sme_getIsLfrFeatureEnabled((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 | "GETFASTROAM", lfrMode); |
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, "GETFASTTRANSITION", 17) == 0) |
| 2876 | { |
| 2877 | tANI_BOOLEAN ft = sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal)); |
| 2878 | char extra[32]; |
| 2879 | tANI_U8 len = 0; |
| 2880 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 2881 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 2882 | "GETFASTTRANSITION", ft); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2883 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 2884 | { |
| 2885 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2886 | "%s: failed to copy data to user buffer", __func__); |
| 2887 | ret = -EFAULT; |
| 2888 | goto exit; |
| 2889 | } |
| 2890 | } |
| 2891 | else if (strncmp(command, "SETROAMSCANCHANNELMINTIME", 25) == 0) |
| 2892 | { |
| 2893 | tANI_U8 *value = command; |
| 2894 | tANI_U8 minTime = CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_DEFAULT; |
| 2895 | |
| 2896 | /* Move pointer to ahead of SETROAMSCANCHANNELMINTIME<delimiter> */ |
| 2897 | value = value + 26; |
| 2898 | /* Convert the value from ascii to integer */ |
| 2899 | ret = kstrtou8(value, 10, &minTime); |
| 2900 | if (ret < 0) |
| 2901 | { |
| 2902 | /* If the input value is greater than max value of datatype, then also |
| 2903 | kstrtou8 fails */ |
| 2904 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2905 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 2906 | CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MIN, |
| 2907 | CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MAX); |
| 2908 | ret = -EINVAL; |
| 2909 | goto exit; |
| 2910 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2911 | if ((minTime < CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MIN) || |
| 2912 | (minTime > CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MAX)) |
| 2913 | { |
| 2914 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2915 | "scan min channel time value %d is out of range" |
| 2916 | " (Min: %d Max: %d)", minTime, |
| 2917 | CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MIN, |
| 2918 | CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MAX); |
| 2919 | ret = -EINVAL; |
| 2920 | goto exit; |
| 2921 | } |
| 2922 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2923 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2924 | TRACE_CODE_HDD_SETROAMSCANCHANNELMINTIME_IOCTL, |
| 2925 | pAdapter->sessionId, minTime)); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 2926 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2927 | "%s: Received Command to change channel min time = %d", __func__, minTime); |
| 2928 | |
| 2929 | pHddCtx->cfg_ini->nNeighborScanMinChanTime = minTime; |
| 2930 | sme_setNeighborScanMinChanTime((tHalHandle)(pHddCtx->hHal), minTime); |
| 2931 | } |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 2932 | else if (strncmp(command, "SENDACTIONFRAME", 15) == 0) |
| 2933 | { |
| 2934 | tANI_U8 *value = command; |
| 2935 | tANI_U8 channel = 0; |
| 2936 | tANI_U8 dwellTime = 0; |
| 2937 | tANI_U8 bufLen = 0; |
| 2938 | tANI_U8 *buf = NULL; |
| 2939 | tSirMacAddr targetApBssid; |
| 2940 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 2941 | struct ieee80211_channel chan; |
| 2942 | tANI_U8 finalLen = 0; |
| 2943 | tANI_U8 *finalBuf = NULL; |
| 2944 | tANI_U8 temp = 0; |
| 2945 | u64 cookie; |
| 2946 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 2947 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 2948 | |
| 2949 | /* if not associated, no need to send action frame */ |
| 2950 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 2951 | { |
| 2952 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__); |
| 2953 | ret = -EINVAL; |
| 2954 | goto exit; |
| 2955 | } |
| 2956 | |
| 2957 | status = hdd_parse_send_action_frame_data(value, targetApBssid, &channel, |
| 2958 | &dwellTime, &buf, &bufLen); |
| 2959 | if (eHAL_STATUS_SUCCESS != status) |
| 2960 | { |
| 2961 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2962 | "%s: Failed to parse send action frame data", __func__); |
| 2963 | ret = -EINVAL; |
| 2964 | goto exit; |
| 2965 | } |
| 2966 | |
| 2967 | /* if the target bssid is different from currently associated AP, |
| 2968 | then no need to send action frame */ |
| 2969 | if (VOS_TRUE != vos_mem_compare(targetApBssid, |
| 2970 | pHddStaCtx->conn_info.bssId, sizeof(tSirMacAddr))) |
| 2971 | { |
| 2972 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:STA is not associated to this AP!",__func__); |
| 2973 | ret = -EINVAL; |
Jeff Johnson | 11c3315 | 2013-04-16 17:52:40 -0700 | [diff] [blame] | 2974 | vos_mem_free(buf); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 2975 | buf = NULL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 2976 | goto exit; |
| 2977 | } |
| 2978 | |
| 2979 | /* if the channel number is different from operating channel then |
| 2980 | no need to send action frame */ |
| 2981 | if (channel != pHddStaCtx->conn_info.operationChannel) |
| 2982 | { |
| 2983 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2984 | "%s: channel(%d) is different from operating channel(%d)", |
| 2985 | __func__, channel, pHddStaCtx->conn_info.operationChannel); |
| 2986 | ret = -EINVAL; |
Jeff Johnson | 11c3315 | 2013-04-16 17:52:40 -0700 | [diff] [blame] | 2987 | vos_mem_free(buf); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 2988 | buf = NULL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 2989 | goto exit; |
| 2990 | } |
| 2991 | chan.center_freq = sme_ChnToFreq(channel); |
| 2992 | |
| 2993 | finalLen = bufLen + 24; |
| 2994 | finalBuf = vos_mem_malloc(finalLen); |
| 2995 | if (NULL == finalBuf) |
| 2996 | { |
| 2997 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:memory allocation failed",__func__); |
| 2998 | ret = -ENOMEM; |
Jeff Johnson | 11c3315 | 2013-04-16 17:52:40 -0700 | [diff] [blame] | 2999 | vos_mem_free(buf); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 3000 | buf = NULL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 3001 | goto exit; |
| 3002 | } |
| 3003 | vos_mem_zero(finalBuf, finalLen); |
| 3004 | |
| 3005 | /* Fill subtype */ |
| 3006 | temp = SIR_MAC_MGMT_ACTION << 4; |
| 3007 | vos_mem_copy(finalBuf + 0, &temp, sizeof(temp)); |
| 3008 | |
| 3009 | /* Fill type */ |
| 3010 | temp = SIR_MAC_MGMT_FRAME; |
| 3011 | vos_mem_copy(finalBuf + 2, &temp, sizeof(temp)); |
| 3012 | |
| 3013 | /* Fill destination address (bssid of the AP) */ |
| 3014 | vos_mem_copy(finalBuf + 4, targetApBssid, sizeof(targetApBssid)); |
| 3015 | |
Srinivas Girigowda | b27c019 | 2013-06-03 10:19:56 -0700 | [diff] [blame] | 3016 | /* Fill source address (STA mac address) */ |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 3017 | vos_mem_copy(finalBuf + 10, pAdapter->macAddressCurrent.bytes, sizeof(pAdapter->macAddressCurrent.bytes)); |
| 3018 | |
Srinivas Girigowda | b27c019 | 2013-06-03 10:19:56 -0700 | [diff] [blame] | 3019 | /* Fill BSSID (AP mac address) */ |
| 3020 | vos_mem_copy(finalBuf + 16, targetApBssid, sizeof(targetApBssid)); |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 3021 | |
| 3022 | /* Fill received buffer from 24th address */ |
| 3023 | vos_mem_copy(finalBuf + 24, buf, bufLen); |
| 3024 | |
Jeff Johnson | 11c3315 | 2013-04-16 17:52:40 -0700 | [diff] [blame] | 3025 | /* done with the parsed buffer */ |
| 3026 | vos_mem_free(buf); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 3027 | buf = NULL; |
Jeff Johnson | 11c3315 | 2013-04-16 17:52:40 -0700 | [diff] [blame] | 3028 | |
DARAM SUDHA | 39eede6 | 2014-02-12 11:16:40 +0530 | [diff] [blame] | 3029 | wlan_hdd_mgmt_tx( NULL, |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 3030 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 3031 | &(pAdapter->wdev), |
| 3032 | #else |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 3033 | pAdapter->dev, |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 3034 | #endif |
| 3035 | &chan, 0, |
| 3036 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)) |
| 3037 | NL80211_CHAN_HT20, 1, |
| 3038 | #endif |
| 3039 | dwellTime, finalBuf, finalLen, 1, |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 3040 | 1, &cookie ); |
| 3041 | vos_mem_free(finalBuf); |
| 3042 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3043 | else if (strncmp(command, "GETROAMSCANCHANNELMINTIME", 25) == 0) |
| 3044 | { |
| 3045 | tANI_U16 val = sme_getNeighborScanMinChanTime((tHalHandle)(pHddCtx->hHal)); |
| 3046 | char extra[32]; |
| 3047 | tANI_U8 len = 0; |
| 3048 | |
| 3049 | /* value is interms of msec */ |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3050 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3051 | "GETROAMSCANCHANNELMINTIME", val); |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 3052 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 3053 | TRACE_CODE_HDD_GETROAMSCANCHANNELMINTIME_IOCTL, |
| 3054 | pAdapter->sessionId, val)); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3055 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 3056 | { |
| 3057 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3058 | "%s: failed to copy data to user buffer", __func__); |
| 3059 | ret = -EFAULT; |
| 3060 | goto exit; |
| 3061 | } |
| 3062 | } |
| 3063 | else if (strncmp(command, "SETSCANCHANNELTIME", 18) == 0) |
| 3064 | { |
| 3065 | tANI_U8 *value = command; |
Varun Reddy Yeturu | 3885a66 | 2013-06-19 07:10:37 -0700 | [diff] [blame] | 3066 | tANI_U16 maxTime = CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_DEFAULT; |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3067 | |
| 3068 | /* Move pointer to ahead of SETSCANCHANNELTIME<delimiter> */ |
| 3069 | value = value + 19; |
| 3070 | /* Convert the value from ascii to integer */ |
Varun Reddy Yeturu | 3885a66 | 2013-06-19 07:10:37 -0700 | [diff] [blame] | 3071 | ret = kstrtou16(value, 10, &maxTime); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3072 | if (ret < 0) |
| 3073 | { |
| 3074 | /* 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] | 3075 | kstrtou16 fails */ |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3076 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Varun Reddy Yeturu | 3885a66 | 2013-06-19 07:10:37 -0700 | [diff] [blame] | 3077 | "%s: kstrtou16 failed range [%d - %d]", __func__, |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3078 | CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MIN, |
| 3079 | CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MAX); |
| 3080 | ret = -EINVAL; |
| 3081 | goto exit; |
| 3082 | } |
| 3083 | |
| 3084 | if ((maxTime < CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MIN) || |
| 3085 | (maxTime > CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MAX)) |
| 3086 | { |
| 3087 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3088 | "lfr mode value %d is out of range" |
| 3089 | " (Min: %d Max: %d)", maxTime, |
| 3090 | CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MIN, |
| 3091 | CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MAX); |
| 3092 | ret = -EINVAL; |
| 3093 | goto exit; |
| 3094 | } |
| 3095 | |
| 3096 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3097 | "%s: Received Command to change channel max time = %d", __func__, maxTime); |
| 3098 | |
| 3099 | pHddCtx->cfg_ini->nNeighborScanMaxChanTime = maxTime; |
| 3100 | sme_setNeighborScanMaxChanTime((tHalHandle)(pHddCtx->hHal), maxTime); |
| 3101 | } |
| 3102 | else if (strncmp(command, "GETSCANCHANNELTIME", 18) == 0) |
| 3103 | { |
| 3104 | tANI_U16 val = sme_getNeighborScanMaxChanTime((tHalHandle)(pHddCtx->hHal)); |
| 3105 | char extra[32]; |
| 3106 | tANI_U8 len = 0; |
| 3107 | |
| 3108 | /* value is interms of msec */ |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3109 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3110 | "GETSCANCHANNELTIME", val); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3111 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 3112 | { |
| 3113 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3114 | "%s: failed to copy data to user buffer", __func__); |
| 3115 | ret = -EFAULT; |
| 3116 | goto exit; |
| 3117 | } |
| 3118 | } |
| 3119 | else if (strncmp(command, "SETSCANHOMETIME", 15) == 0) |
| 3120 | { |
| 3121 | tANI_U8 *value = command; |
| 3122 | tANI_U16 val = CFG_NEIGHBOR_SCAN_TIMER_PERIOD_DEFAULT; |
| 3123 | |
| 3124 | /* Move pointer to ahead of SETSCANHOMETIME<delimiter> */ |
| 3125 | value = value + 16; |
| 3126 | /* Convert the value from ascii to integer */ |
| 3127 | ret = kstrtou16(value, 10, &val); |
| 3128 | if (ret < 0) |
| 3129 | { |
| 3130 | /* If the input value is greater than max value of datatype, then also |
| 3131 | kstrtou16 fails */ |
| 3132 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3133 | "%s: kstrtou16 failed range [%d - %d]", __func__, |
| 3134 | CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MIN, |
| 3135 | CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MAX); |
| 3136 | ret = -EINVAL; |
| 3137 | goto exit; |
| 3138 | } |
| 3139 | |
| 3140 | if ((val < CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MIN) || |
| 3141 | (val > CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MAX)) |
| 3142 | { |
| 3143 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3144 | "scan home time value %d is out of range" |
| 3145 | " (Min: %d Max: %d)", val, |
| 3146 | CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MIN, |
| 3147 | CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MAX); |
| 3148 | ret = -EINVAL; |
| 3149 | goto exit; |
| 3150 | } |
| 3151 | |
| 3152 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3153 | "%s: Received Command to change scan home time = %d", __func__, val); |
| 3154 | |
| 3155 | pHddCtx->cfg_ini->nNeighborScanPeriod = val; |
| 3156 | sme_setNeighborScanPeriod((tHalHandle)(pHddCtx->hHal), val); |
| 3157 | } |
| 3158 | else if (strncmp(command, "GETSCANHOMETIME", 15) == 0) |
| 3159 | { |
| 3160 | tANI_U16 val = sme_getNeighborScanPeriod((tHalHandle)(pHddCtx->hHal)); |
| 3161 | char extra[32]; |
| 3162 | tANI_U8 len = 0; |
| 3163 | |
| 3164 | /* value is interms of msec */ |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3165 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3166 | "GETSCANHOMETIME", val); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3167 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 3168 | { |
| 3169 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3170 | "%s: failed to copy data to user buffer", __func__); |
| 3171 | ret = -EFAULT; |
| 3172 | goto exit; |
| 3173 | } |
| 3174 | } |
| 3175 | else if (strncmp(command, "SETROAMINTRABAND", 16) == 0) |
| 3176 | { |
| 3177 | tANI_U8 *value = command; |
| 3178 | tANI_U8 val = CFG_ROAM_INTRA_BAND_DEFAULT; |
| 3179 | |
| 3180 | /* Move pointer to ahead of SETROAMINTRABAND<delimiter> */ |
| 3181 | value = value + 17; |
| 3182 | /* Convert the value from ascii to integer */ |
| 3183 | ret = kstrtou8(value, 10, &val); |
| 3184 | if (ret < 0) |
| 3185 | { |
| 3186 | /* If the input value is greater than max value of datatype, then also |
| 3187 | kstrtou8 fails */ |
| 3188 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3189 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3190 | CFG_ROAM_INTRA_BAND_MIN, |
| 3191 | CFG_ROAM_INTRA_BAND_MAX); |
| 3192 | ret = -EINVAL; |
| 3193 | goto exit; |
| 3194 | } |
| 3195 | |
| 3196 | if ((val < CFG_ROAM_INTRA_BAND_MIN) || |
| 3197 | (val > CFG_ROAM_INTRA_BAND_MAX)) |
| 3198 | { |
| 3199 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3200 | "intra band mode value %d is out of range" |
| 3201 | " (Min: %d Max: %d)", val, |
| 3202 | CFG_ROAM_INTRA_BAND_MIN, |
| 3203 | CFG_ROAM_INTRA_BAND_MAX); |
| 3204 | ret = -EINVAL; |
| 3205 | goto exit; |
| 3206 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3207 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3208 | "%s: Received Command to change intra band = %d", __func__, val); |
| 3209 | |
| 3210 | pHddCtx->cfg_ini->nRoamIntraBand = val; |
| 3211 | sme_setRoamIntraBand((tHalHandle)(pHddCtx->hHal), val); |
| 3212 | } |
| 3213 | else if (strncmp(command, "GETROAMINTRABAND", 16) == 0) |
| 3214 | { |
| 3215 | tANI_U16 val = sme_getRoamIntraBand((tHalHandle)(pHddCtx->hHal)); |
| 3216 | char extra[32]; |
| 3217 | tANI_U8 len = 0; |
| 3218 | |
| 3219 | /* value is interms of msec */ |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3220 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3221 | "GETROAMINTRABAND", val); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3222 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 3223 | { |
| 3224 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3225 | "%s: failed to copy data to user buffer", __func__); |
| 3226 | ret = -EFAULT; |
| 3227 | goto exit; |
| 3228 | } |
| 3229 | } |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3230 | else if (strncmp(command, "SETSCANNPROBES", 14) == 0) |
| 3231 | { |
| 3232 | tANI_U8 *value = command; |
| 3233 | tANI_U8 nProbes = CFG_ROAM_SCAN_N_PROBES_DEFAULT; |
| 3234 | |
| 3235 | /* Move pointer to ahead of SETSCANNPROBES<delimiter> */ |
| 3236 | value = value + 15; |
| 3237 | /* Convert the value from ascii to integer */ |
| 3238 | ret = kstrtou8(value, 10, &nProbes); |
| 3239 | if (ret < 0) |
| 3240 | { |
| 3241 | /* If the input value is greater than max value of datatype, then also |
| 3242 | kstrtou8 fails */ |
| 3243 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3244 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3245 | CFG_ROAM_SCAN_N_PROBES_MIN, |
| 3246 | CFG_ROAM_SCAN_N_PROBES_MAX); |
| 3247 | ret = -EINVAL; |
| 3248 | goto exit; |
| 3249 | } |
| 3250 | |
| 3251 | if ((nProbes < CFG_ROAM_SCAN_N_PROBES_MIN) || |
| 3252 | (nProbes > CFG_ROAM_SCAN_N_PROBES_MAX)) |
| 3253 | { |
| 3254 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3255 | "NProbes value %d is out of range" |
| 3256 | " (Min: %d Max: %d)", nProbes, |
| 3257 | CFG_ROAM_SCAN_N_PROBES_MIN, |
| 3258 | CFG_ROAM_SCAN_N_PROBES_MAX); |
| 3259 | ret = -EINVAL; |
| 3260 | goto exit; |
| 3261 | } |
| 3262 | |
| 3263 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3264 | "%s: Received Command to Set nProbes = %d", __func__, nProbes); |
| 3265 | |
| 3266 | pHddCtx->cfg_ini->nProbes = nProbes; |
| 3267 | sme_UpdateRoamScanNProbes((tHalHandle)(pHddCtx->hHal), nProbes); |
| 3268 | } |
Mahesh A Saptasagar | ec7d109 | 2015-04-02 13:41:34 +0530 | [diff] [blame] | 3269 | else if (strncmp(command, "GETSCANNPROBES", 14) == 0) |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3270 | { |
| 3271 | tANI_U8 val = sme_getRoamScanNProbes((tHalHandle)(pHddCtx->hHal)); |
| 3272 | char extra[32]; |
| 3273 | tANI_U8 len = 0; |
| 3274 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3275 | len = scnprintf(extra, sizeof(extra), "%s %d", command, val); |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3276 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 3277 | { |
| 3278 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3279 | "%s: failed to copy data to user buffer", __func__); |
| 3280 | ret = -EFAULT; |
| 3281 | goto exit; |
| 3282 | } |
| 3283 | } |
| 3284 | else if (strncmp(command, "SETSCANHOMEAWAYTIME", 19) == 0) |
| 3285 | { |
| 3286 | tANI_U8 *value = command; |
| 3287 | tANI_U16 homeAwayTime = CFG_ROAM_SCAN_HOME_AWAY_TIME_DEFAULT; |
| 3288 | |
| 3289 | /* Move pointer to ahead of SETSCANHOMEAWAYTIME<delimiter> */ |
| 3290 | /* input value is in units of msec */ |
| 3291 | value = value + 20; |
| 3292 | /* Convert the value from ascii to integer */ |
| 3293 | ret = kstrtou16(value, 10, &homeAwayTime); |
| 3294 | if (ret < 0) |
| 3295 | { |
| 3296 | /* If the input value is greater than max value of datatype, then also |
| 3297 | kstrtou8 fails */ |
| 3298 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3299 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3300 | CFG_ROAM_SCAN_HOME_AWAY_TIME_MIN, |
| 3301 | CFG_ROAM_SCAN_HOME_AWAY_TIME_MAX); |
| 3302 | ret = -EINVAL; |
| 3303 | goto exit; |
| 3304 | } |
| 3305 | |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3306 | if ((homeAwayTime < CFG_ROAM_SCAN_HOME_AWAY_TIME_MIN) || |
| 3307 | (homeAwayTime > CFG_ROAM_SCAN_HOME_AWAY_TIME_MAX)) |
| 3308 | { |
| 3309 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3310 | "homeAwayTime value %d is out of range" |
| 3311 | " (Min: %d Max: %d)", homeAwayTime, |
| 3312 | CFG_ROAM_SCAN_HOME_AWAY_TIME_MIN, |
| 3313 | CFG_ROAM_SCAN_HOME_AWAY_TIME_MAX); |
| 3314 | ret = -EINVAL; |
| 3315 | goto exit; |
| 3316 | } |
| 3317 | |
| 3318 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3319 | "%s: Received Command to Set scan away time = %d", __func__, homeAwayTime); |
Srinivas Girigowda | 6cf0b82 | 2013-06-27 14:00:20 -0700 | [diff] [blame] | 3320 | if (pHddCtx->cfg_ini->nRoamScanHomeAwayTime != homeAwayTime) |
| 3321 | { |
| 3322 | pHddCtx->cfg_ini->nRoamScanHomeAwayTime = homeAwayTime; |
| 3323 | sme_UpdateRoamScanHomeAwayTime((tHalHandle)(pHddCtx->hHal), homeAwayTime, eANI_BOOLEAN_TRUE); |
| 3324 | } |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3325 | } |
Mahesh A Saptasagar | ec7d109 | 2015-04-02 13:41:34 +0530 | [diff] [blame] | 3326 | else if (strncmp(command, "GETSCANHOMEAWAYTIME", 19) == 0) |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3327 | { |
| 3328 | tANI_U16 val = sme_getRoamScanHomeAwayTime((tHalHandle)(pHddCtx->hHal)); |
| 3329 | char extra[32]; |
| 3330 | tANI_U8 len = 0; |
| 3331 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3332 | len = scnprintf(extra, sizeof(extra), "%s %d", command, val); |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3333 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 3334 | { |
| 3335 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3336 | "%s: failed to copy data to user buffer", __func__); |
| 3337 | ret = -EFAULT; |
| 3338 | goto exit; |
| 3339 | } |
| 3340 | } |
| 3341 | else if (strncmp(command, "REASSOC", 7) == 0) |
| 3342 | { |
| 3343 | tANI_U8 *value = command; |
| 3344 | tANI_U8 channel = 0; |
| 3345 | tSirMacAddr targetApBssid; |
| 3346 | eHalStatus status = eHAL_STATUS_SUCCESS; |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 3347 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 3348 | tCsrHandoffRequest handoffInfo; |
| 3349 | #endif |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3350 | hdd_station_ctx_t *pHddStaCtx = NULL; |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3351 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3352 | |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3353 | /* if not associated, no need to proceed with reassoc */ |
| 3354 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 3355 | { |
| 3356 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__); |
| 3357 | ret = -EINVAL; |
| 3358 | goto exit; |
| 3359 | } |
| 3360 | |
| 3361 | status = hdd_parse_reassoc_command_data(value, targetApBssid, &channel); |
| 3362 | if (eHAL_STATUS_SUCCESS != status) |
| 3363 | { |
| 3364 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3365 | "%s: Failed to parse reassoc command data", __func__); |
| 3366 | ret = -EINVAL; |
| 3367 | goto exit; |
| 3368 | } |
| 3369 | |
| 3370 | /* if the target bssid is same as currently associated AP, |
| 3371 | then no need to proceed with reassoc */ |
| 3372 | if (VOS_TRUE == vos_mem_compare(targetApBssid, |
| 3373 | pHddStaCtx->conn_info.bssId, sizeof(tSirMacAddr))) |
| 3374 | { |
| 3375 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Reassoc BSSID is same as currently associated AP bssid",__func__); |
| 3376 | ret = -EINVAL; |
| 3377 | goto exit; |
| 3378 | } |
| 3379 | |
| 3380 | /* Check channel number is a valid channel number */ |
| 3381 | if(VOS_STATUS_SUCCESS != |
| 3382 | wlan_hdd_validate_operation_channel(pAdapter, channel)) |
| 3383 | { |
| 3384 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 3385 | "%s: Invalid Channel [%d]", __func__, channel); |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3386 | return -EINVAL; |
| 3387 | } |
| 3388 | |
| 3389 | /* Proceed with reassoc */ |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 3390 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 3391 | handoffInfo.channel = channel; |
| 3392 | vos_mem_copy(handoffInfo.bssid, targetApBssid, sizeof(tSirMacAddr)); |
| 3393 | sme_HandoffRequest(pHddCtx->hHal, &handoffInfo); |
| 3394 | #endif |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3395 | } |
Srinivas Girigowda | ad34ca9 | 2013-10-22 10:54:29 -0700 | [diff] [blame] | 3396 | else if (strncmp(command, "SETWESMODE", 10) == 0) |
| 3397 | { |
| 3398 | tANI_U8 *value = command; |
| 3399 | tANI_BOOLEAN wesMode = CFG_ENABLE_WES_MODE_NAME_DEFAULT; |
| 3400 | |
| 3401 | /* Move pointer to ahead of SETWESMODE<delimiter> */ |
| 3402 | value = value + 11; |
| 3403 | /* Convert the value from ascii to integer */ |
| 3404 | ret = kstrtou8(value, 10, &wesMode); |
| 3405 | if (ret < 0) |
| 3406 | { |
| 3407 | /* If the input value is greater than max value of datatype, then also |
| 3408 | kstrtou8 fails */ |
| 3409 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3410 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3411 | CFG_ENABLE_WES_MODE_NAME_MIN, |
| 3412 | CFG_ENABLE_WES_MODE_NAME_MAX); |
| 3413 | ret = -EINVAL; |
| 3414 | goto exit; |
| 3415 | } |
| 3416 | |
| 3417 | if ((wesMode < CFG_ENABLE_WES_MODE_NAME_MIN) || |
| 3418 | (wesMode > CFG_ENABLE_WES_MODE_NAME_MAX)) |
| 3419 | { |
| 3420 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3421 | "WES Mode value %d is out of range" |
| 3422 | " (Min: %d Max: %d)", wesMode, |
| 3423 | CFG_ENABLE_WES_MODE_NAME_MIN, |
| 3424 | CFG_ENABLE_WES_MODE_NAME_MAX); |
| 3425 | ret = -EINVAL; |
| 3426 | goto exit; |
| 3427 | } |
| 3428 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3429 | "%s: Received Command to Set WES Mode rssi diff = %d", __func__, wesMode); |
| 3430 | |
| 3431 | pHddCtx->cfg_ini->isWESModeEnabled = wesMode; |
| 3432 | sme_UpdateWESMode((tHalHandle)(pHddCtx->hHal), wesMode); |
| 3433 | } |
Mahesh A Saptasagar | ec7d109 | 2015-04-02 13:41:34 +0530 | [diff] [blame] | 3434 | else if (strncmp(command, "GETWESMODE", 10) == 0) |
Srinivas Girigowda | ad34ca9 | 2013-10-22 10:54:29 -0700 | [diff] [blame] | 3435 | { |
| 3436 | tANI_BOOLEAN wesMode = sme_GetWESMode((tHalHandle)(pHddCtx->hHal)); |
| 3437 | char extra[32]; |
| 3438 | tANI_U8 len = 0; |
| 3439 | |
Arif Hussain | 826d941 | 2013-11-12 16:44:54 -0800 | [diff] [blame] | 3440 | len = scnprintf(extra, sizeof(extra), "%s %d", command, wesMode); |
Srinivas Girigowda | ad34ca9 | 2013-10-22 10:54:29 -0700 | [diff] [blame] | 3441 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 3442 | { |
| 3443 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3444 | "%s: failed to copy data to user buffer", __func__); |
| 3445 | ret = -EFAULT; |
| 3446 | goto exit; |
| 3447 | } |
| 3448 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3449 | #endif /* WLAN_FEATURE_VOWIFI_11R || FEATURE_WLAN_ESE || FEATURE_WLAN_LFR */ |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3450 | #ifdef FEATURE_WLAN_LFR |
| 3451 | else if (strncmp(command, "SETFASTROAM", 11) == 0) |
| 3452 | { |
| 3453 | tANI_U8 *value = command; |
| 3454 | tANI_U8 lfrMode = CFG_LFR_FEATURE_ENABLED_DEFAULT; |
| 3455 | |
| 3456 | /* Move pointer to ahead of SETFASTROAM<delimiter> */ |
| 3457 | value = value + 12; |
| 3458 | /* Convert the value from ascii to integer */ |
| 3459 | ret = kstrtou8(value, 10, &lfrMode); |
| 3460 | if (ret < 0) |
| 3461 | { |
| 3462 | /* If the input value is greater than max value of datatype, then also |
| 3463 | kstrtou8 fails */ |
| 3464 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3465 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3466 | CFG_LFR_FEATURE_ENABLED_MIN, |
| 3467 | CFG_LFR_FEATURE_ENABLED_MAX); |
| 3468 | ret = -EINVAL; |
| 3469 | goto exit; |
| 3470 | } |
| 3471 | |
| 3472 | if ((lfrMode < CFG_LFR_FEATURE_ENABLED_MIN) || |
| 3473 | (lfrMode > CFG_LFR_FEATURE_ENABLED_MAX)) |
| 3474 | { |
| 3475 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3476 | "lfr mode value %d is out of range" |
| 3477 | " (Min: %d Max: %d)", lfrMode, |
| 3478 | CFG_LFR_FEATURE_ENABLED_MIN, |
| 3479 | CFG_LFR_FEATURE_ENABLED_MAX); |
| 3480 | ret = -EINVAL; |
| 3481 | goto exit; |
| 3482 | } |
| 3483 | |
| 3484 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3485 | "%s: Received Command to change lfr mode = %d", __func__, lfrMode); |
| 3486 | |
| 3487 | pHddCtx->cfg_ini->isFastRoamIniFeatureEnabled = lfrMode; |
| 3488 | sme_UpdateIsFastRoamIniFeatureEnabled((tHalHandle)(pHddCtx->hHal), lfrMode); |
| 3489 | } |
| 3490 | #endif |
| 3491 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 3492 | else if (strncmp(command, "SETFASTTRANSITION", 17) == 0) |
| 3493 | { |
| 3494 | tANI_U8 *value = command; |
| 3495 | tANI_U8 ft = CFG_FAST_TRANSITION_ENABLED_NAME_DEFAULT; |
| 3496 | |
| 3497 | /* Move pointer to ahead of SETFASTROAM<delimiter> */ |
| 3498 | value = value + 18; |
| 3499 | /* Convert the value from ascii to integer */ |
| 3500 | ret = kstrtou8(value, 10, &ft); |
| 3501 | if (ret < 0) |
| 3502 | { |
| 3503 | /* If the input value is greater than max value of datatype, then also |
| 3504 | kstrtou8 fails */ |
| 3505 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3506 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3507 | CFG_FAST_TRANSITION_ENABLED_NAME_MIN, |
| 3508 | CFG_FAST_TRANSITION_ENABLED_NAME_MAX); |
| 3509 | ret = -EINVAL; |
| 3510 | goto exit; |
| 3511 | } |
| 3512 | |
| 3513 | if ((ft < CFG_FAST_TRANSITION_ENABLED_NAME_MIN) || |
| 3514 | (ft > CFG_FAST_TRANSITION_ENABLED_NAME_MAX)) |
| 3515 | { |
| 3516 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3517 | "ft mode value %d is out of range" |
| 3518 | " (Min: %d Max: %d)", ft, |
| 3519 | CFG_FAST_TRANSITION_ENABLED_NAME_MIN, |
| 3520 | CFG_FAST_TRANSITION_ENABLED_NAME_MAX); |
| 3521 | ret = -EINVAL; |
| 3522 | goto exit; |
| 3523 | } |
| 3524 | |
| 3525 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3526 | "%s: Received Command to change ft mode = %d", __func__, ft); |
| 3527 | |
| 3528 | pHddCtx->cfg_ini->isFastTransitionEnabled = ft; |
| 3529 | sme_UpdateFastTransitionEnabled((tHalHandle)(pHddCtx->hHal), ft); |
| 3530 | } |
Padma, Santhosh Kumar | 778d838 | 2015-03-04 17:41:22 +0530 | [diff] [blame] | 3531 | else if (strncmp(command, "SETDFSSCANMODE", 14) == 0) |
| 3532 | { |
| 3533 | tANI_U8 *value = command; |
| 3534 | tANI_U8 dfsScanMode = DFS_CHNL_SCAN_ENABLED_NORMAL; |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 3535 | |
Padma, Santhosh Kumar | 778d838 | 2015-03-04 17:41:22 +0530 | [diff] [blame] | 3536 | /* Move pointer to ahead of SETDFSSCANMODE<delimiter> */ |
| 3537 | value = value + 15; |
| 3538 | /* Convert the value from ascii to integer */ |
| 3539 | ret = kstrtou8(value, 10, &dfsScanMode); |
| 3540 | if (ret < 0) |
| 3541 | { |
| 3542 | /* If the input value is greater than max value of |
| 3543 | datatype, then also kstrtou8 fails |
| 3544 | */ |
| 3545 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3546 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3547 | CFG_ENABLE_DFS_CHNL_SCAN_MIN, |
| 3548 | CFG_ENABLE_DFS_CHNL_SCAN_MAX); |
| 3549 | ret = -EINVAL; |
| 3550 | goto exit; |
| 3551 | } |
| 3552 | |
| 3553 | if ((dfsScanMode < CFG_ENABLE_DFS_CHNL_SCAN_MIN) || |
| 3554 | (dfsScanMode > CFG_ENABLE_DFS_CHNL_SCAN_MAX)) |
| 3555 | { |
| 3556 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3557 | "dfsScanMode value %d is out of range" |
| 3558 | " (Min: %d Max: %d)", dfsScanMode, |
| 3559 | CFG_ENABLE_DFS_CHNL_SCAN_MIN, |
| 3560 | CFG_ENABLE_DFS_CHNL_SCAN_MAX); |
| 3561 | ret = -EINVAL; |
| 3562 | goto exit; |
| 3563 | } |
| 3564 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3565 | "%s: Received Command to Set DFS Scan Mode = %d", |
| 3566 | __func__, dfsScanMode); |
| 3567 | |
| 3568 | ret = wlan_hdd_handle_dfs_chan_scan(pHddCtx, dfsScanMode); |
| 3569 | } |
| 3570 | else if (strncmp(command, "GETDFSSCANMODE", 14) == 0) |
| 3571 | { |
| 3572 | tANI_U8 dfsScanMode = sme_GetDFSScanMode(pHddCtx->hHal); |
| 3573 | char extra[32]; |
| 3574 | tANI_U8 len = 0; |
| 3575 | |
| 3576 | len = scnprintf(extra, sizeof(extra), "%s %d", command, dfsScanMode); |
| 3577 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 3578 | { |
| 3579 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3580 | "%s: failed to copy data to user buffer", __func__); |
| 3581 | ret = -EFAULT; |
| 3582 | goto exit; |
| 3583 | } |
| 3584 | } |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 3585 | else if (strncmp(command, "FASTREASSOC", 11) == 0) |
| 3586 | { |
| 3587 | tANI_U8 *value = command; |
Padma, Santhosh Kumar | f4582d3 | 2014-11-06 19:24:51 +0530 | [diff] [blame] | 3588 | tANI_U8 channel = 0; |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 3589 | tSirMacAddr targetApBssid; |
| 3590 | tANI_U8 trigger = 0; |
| 3591 | eHalStatus status = eHAL_STATUS_SUCCESS; |
Padma, Santhosh Kumar | b980a6f | 2014-11-06 19:07:24 +0530 | [diff] [blame] | 3592 | tHalHandle hHal; |
| 3593 | v_U32_t roamId = 0; |
| 3594 | tCsrRoamModifyProfileFields modProfileFields; |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 3595 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 3596 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Padma, Santhosh Kumar | b980a6f | 2014-11-06 19:07:24 +0530 | [diff] [blame] | 3597 | hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 3598 | |
| 3599 | /* if not associated, no need to proceed with reassoc */ |
| 3600 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 3601 | { |
| 3602 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__); |
| 3603 | ret = -EINVAL; |
| 3604 | goto exit; |
| 3605 | } |
| 3606 | |
Padma, Santhosh Kumar | f4582d3 | 2014-11-06 19:24:51 +0530 | [diff] [blame] | 3607 | status = hdd_parse_reassoc_command_data(value, targetApBssid, &channel); |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 3608 | if (eHAL_STATUS_SUCCESS != status) |
| 3609 | { |
| 3610 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3611 | "%s: Failed to parse reassoc command data", __func__); |
| 3612 | ret = -EINVAL; |
| 3613 | goto exit; |
| 3614 | } |
| 3615 | |
| 3616 | /* if the target bssid is same as currently associated AP, |
Padma, Santhosh Kumar | b980a6f | 2014-11-06 19:07:24 +0530 | [diff] [blame] | 3617 | issue reassoc to same AP */ |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 3618 | if (VOS_TRUE == vos_mem_compare(targetApBssid, |
| 3619 | pHddStaCtx->conn_info.bssId, sizeof(tSirMacAddr))) |
| 3620 | { |
| 3621 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3622 | "%s:11r Reassoc BSSID is same as currently associated AP bssid", |
| 3623 | __func__); |
Padma, Santhosh Kumar | b980a6f | 2014-11-06 19:07:24 +0530 | [diff] [blame] | 3624 | sme_GetModifyProfileFields(hHal, pAdapter->sessionId, |
| 3625 | &modProfileFields); |
| 3626 | sme_RoamReassoc(hHal, pAdapter->sessionId, |
| 3627 | NULL, modProfileFields, &roamId, 1); |
| 3628 | return 0; |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 3629 | } |
Padma, Santhosh Kumar | 0fa809b | 2014-11-13 14:56:56 +0530 | [diff] [blame] | 3630 | |
| 3631 | /* Check channel number is a valid channel number */ |
| 3632 | if(VOS_STATUS_SUCCESS != |
| 3633 | wlan_hdd_validate_operation_channel(pAdapter, channel)) |
| 3634 | { |
| 3635 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3636 | "%s: Invalid Channel [%d]", __func__, channel); |
| 3637 | return -EINVAL; |
| 3638 | } |
| 3639 | |
Padma, Santhosh Kumar | f4582d3 | 2014-11-06 19:24:51 +0530 | [diff] [blame] | 3640 | trigger = eSME_ROAM_TRIGGER_SCAN; |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 3641 | |
| 3642 | /* Proceed with scan/roam */ |
| 3643 | smeIssueFastRoamNeighborAPEvent(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 3644 | &targetApBssid[0], |
Mukul Sharma | 9e4e0f9 | 2015-02-13 18:45:20 +0530 | [diff] [blame] | 3645 | (tSmeFastRoamTrigger)(trigger), |
| 3646 | channel); |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 3647 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3648 | #endif |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3649 | #ifdef FEATURE_WLAN_ESE |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3650 | else if (strncmp(command, "SETCCXMODE", 10) == 0) |
| 3651 | { |
| 3652 | tANI_U8 *value = command; |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3653 | tANI_U8 eseMode = CFG_ESE_FEATURE_ENABLED_DEFAULT; |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3654 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3655 | /* Check if the features OKC/ESE/11R are supported simultaneously, |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 3656 | then this operation is not permitted (return FAILURE) */ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3657 | if (sme_getIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal)) && |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 3658 | hdd_is_okc_mode_enabled(pHddCtx) && |
| 3659 | sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal))) |
| 3660 | { |
| 3661 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3662 | "%s: OKC/ESE/11R are supported simultaneously" |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 3663 | " hence this operation is not permitted!", __func__); |
| 3664 | ret = -EPERM; |
| 3665 | goto exit; |
| 3666 | } |
| 3667 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3668 | /* Move pointer to ahead of SETCCXMODE<delimiter> */ |
| 3669 | value = value + 11; |
| 3670 | /* Convert the value from ascii to integer */ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3671 | ret = kstrtou8(value, 10, &eseMode); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3672 | if (ret < 0) |
| 3673 | { |
| 3674 | /* If the input value is greater than max value of datatype, then also |
| 3675 | kstrtou8 fails */ |
| 3676 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3677 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3678 | CFG_ESE_FEATURE_ENABLED_MIN, |
| 3679 | CFG_ESE_FEATURE_ENABLED_MAX); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3680 | ret = -EINVAL; |
| 3681 | goto exit; |
| 3682 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3683 | if ((eseMode < CFG_ESE_FEATURE_ENABLED_MIN) || |
| 3684 | (eseMode > CFG_ESE_FEATURE_ENABLED_MAX)) |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3685 | { |
| 3686 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3687 | "Ese mode value %d is out of range" |
| 3688 | " (Min: %d Max: %d)", eseMode, |
| 3689 | CFG_ESE_FEATURE_ENABLED_MIN, |
| 3690 | CFG_ESE_FEATURE_ENABLED_MAX); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3691 | ret = -EINVAL; |
| 3692 | goto exit; |
| 3693 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3694 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3695 | "%s: Received Command to change ese mode = %d", __func__, eseMode); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3696 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3697 | pHddCtx->cfg_ini->isEseIniFeatureEnabled = eseMode; |
| 3698 | sme_UpdateIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal), eseMode); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3699 | } |
| 3700 | #endif |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 3701 | else if (strncmp(command, "SETROAMSCANCONTROL", 18) == 0) |
| 3702 | { |
| 3703 | tANI_U8 *value = command; |
| 3704 | tANI_BOOLEAN roamScanControl = 0; |
| 3705 | |
| 3706 | /* Move pointer to ahead of SETROAMSCANCONTROL<delimiter> */ |
| 3707 | value = value + 19; |
| 3708 | /* Convert the value from ascii to integer */ |
| 3709 | ret = kstrtou8(value, 10, &roamScanControl); |
| 3710 | if (ret < 0) |
| 3711 | { |
| 3712 | /* If the input value is greater than max value of datatype, then also |
| 3713 | kstrtou8 fails */ |
| 3714 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3715 | "%s: kstrtou8 failed ", __func__); |
| 3716 | ret = -EINVAL; |
| 3717 | goto exit; |
| 3718 | } |
| 3719 | |
| 3720 | if (0 != roamScanControl) |
| 3721 | { |
| 3722 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3723 | "roam scan control invalid value = %d", |
| 3724 | roamScanControl); |
| 3725 | ret = -EINVAL; |
| 3726 | goto exit; |
| 3727 | } |
| 3728 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3729 | "%s: Received Command to Set roam scan control = %d", __func__, roamScanControl); |
| 3730 | |
| 3731 | sme_SetRoamScanControl((tHalHandle)(pHddCtx->hHal), roamScanControl); |
| 3732 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3733 | #ifdef FEATURE_WLAN_OKC |
| 3734 | else if (strncmp(command, "SETOKCMODE", 10) == 0) |
| 3735 | { |
| 3736 | tANI_U8 *value = command; |
| 3737 | tANI_U8 okcMode = CFG_OKC_FEATURE_ENABLED_DEFAULT; |
| 3738 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3739 | /* Check if the features OKC/ESE/11R are supported simultaneously, |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 3740 | then this operation is not permitted (return FAILURE) */ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3741 | if (sme_getIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal)) && |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 3742 | hdd_is_okc_mode_enabled(pHddCtx) && |
| 3743 | sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal))) |
| 3744 | { |
| 3745 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3746 | "%s: OKC/ESE/11R are supported simultaneously" |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 3747 | " hence this operation is not permitted!", __func__); |
| 3748 | ret = -EPERM; |
| 3749 | goto exit; |
| 3750 | } |
| 3751 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3752 | /* Move pointer to ahead of SETOKCMODE<delimiter> */ |
| 3753 | value = value + 11; |
| 3754 | /* Convert the value from ascii to integer */ |
| 3755 | ret = kstrtou8(value, 10, &okcMode); |
| 3756 | if (ret < 0) |
| 3757 | { |
| 3758 | /* If the input value is greater than max value of datatype, then also |
| 3759 | kstrtou8 fails */ |
| 3760 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3761 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3762 | CFG_OKC_FEATURE_ENABLED_MIN, |
| 3763 | CFG_OKC_FEATURE_ENABLED_MAX); |
| 3764 | ret = -EINVAL; |
| 3765 | goto exit; |
| 3766 | } |
| 3767 | |
| 3768 | if ((okcMode < CFG_OKC_FEATURE_ENABLED_MIN) || |
| 3769 | (okcMode > CFG_OKC_FEATURE_ENABLED_MAX)) |
| 3770 | { |
| 3771 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3772 | "Okc mode value %d is out of range" |
| 3773 | " (Min: %d Max: %d)", okcMode, |
| 3774 | CFG_OKC_FEATURE_ENABLED_MIN, |
| 3775 | CFG_OKC_FEATURE_ENABLED_MAX); |
| 3776 | ret = -EINVAL; |
| 3777 | goto exit; |
| 3778 | } |
| 3779 | |
| 3780 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3781 | "%s: Received Command to change okc mode = %d", __func__, okcMode); |
| 3782 | |
| 3783 | pHddCtx->cfg_ini->isOkcIniFeatureEnabled = okcMode; |
| 3784 | } |
Srinivas Girigowda | ad34ca9 | 2013-10-22 10:54:29 -0700 | [diff] [blame] | 3785 | #endif /* FEATURE_WLAN_OKC */ |
Mahesh A Saptasagar | ec7d109 | 2015-04-02 13:41:34 +0530 | [diff] [blame] | 3786 | else if (strncmp(command, "GETROAMSCANCONTROL", 18) == 0) |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 3787 | { |
| 3788 | tANI_BOOLEAN roamScanControl = sme_GetRoamScanControl((tHalHandle)(pHddCtx->hHal)); |
| 3789 | char extra[32]; |
| 3790 | tANI_U8 len = 0; |
| 3791 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3792 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3793 | command, roamScanControl); |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 3794 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 3795 | { |
| 3796 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3797 | "%s: failed to copy data to user buffer", __func__); |
| 3798 | ret = -EFAULT; |
| 3799 | goto exit; |
| 3800 | } |
| 3801 | } |
Gopichand Nakkala | 227c7f3 | 2013-06-26 22:44:57 +0530 | [diff] [blame] | 3802 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 3803 | else if (strncmp(command, "ENABLE_PKTFILTER_IPV6", 21) == 0) |
| 3804 | { |
| 3805 | tANI_U8 filterType = 0; |
| 3806 | tANI_U8 *value = command; |
| 3807 | |
| 3808 | /* Move pointer to ahead of ENABLE_PKTFILTER_IPV6<delimiter> */ |
| 3809 | value = value + 22; |
| 3810 | |
| 3811 | /* Convert the value from ascii to integer */ |
| 3812 | ret = kstrtou8(value, 10, &filterType); |
| 3813 | if (ret < 0) |
| 3814 | { |
| 3815 | /* If the input value is greater than max value of datatype, |
| 3816 | * then also kstrtou8 fails |
| 3817 | */ |
| 3818 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3819 | "%s: kstrtou8 failed range ", __func__); |
| 3820 | ret = -EINVAL; |
| 3821 | goto exit; |
| 3822 | } |
| 3823 | |
| 3824 | if (filterType != 0 && filterType != 1) |
| 3825 | { |
| 3826 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3827 | "%s: Accepted Values are 0 and 1 ", __func__); |
| 3828 | ret = -EINVAL; |
| 3829 | goto exit; |
| 3830 | } |
| 3831 | wlan_hdd_setIPv6Filter(WLAN_HDD_GET_CTX(pAdapter), filterType, |
| 3832 | pAdapter->sessionId); |
| 3833 | } |
| 3834 | #endif |
Sundaresan Ramachandran | 76e48e8 | 2013-07-15 13:07:17 +0530 | [diff] [blame] | 3835 | else if (strncmp(command, "BTCOEXMODE", 10) == 0 ) |
| 3836 | { |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 3837 | char *dhcpPhase; |
Satyanarayana Dash | 1faea4f | 2014-09-22 16:21:04 +0530 | [diff] [blame] | 3838 | int ret; |
| 3839 | |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 3840 | dhcpPhase = command + 11; |
| 3841 | if ('1' == *dhcpPhase) |
Sundaresan Ramachandran | 76e48e8 | 2013-07-15 13:07:17 +0530 | [diff] [blame] | 3842 | { |
Deepthi Gowri | bfd1713 | 2014-11-14 17:59:04 +0530 | [diff] [blame] | 3843 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 3844 | FL("send DHCP START indication")); |
c_hpothu | 9b781ba | 2013-12-30 20:57:45 +0530 | [diff] [blame] | 3845 | |
| 3846 | pHddCtx->btCoexModeSet = TRUE; |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 3847 | |
Satyanarayana Dash | 1faea4f | 2014-09-22 16:21:04 +0530 | [diff] [blame] | 3848 | ret = wlan_hdd_scan_abort(pAdapter); |
| 3849 | if (ret < 0) |
| 3850 | { |
| 3851 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3852 | FL("failed to abort existing scan %d"), ret); |
| 3853 | } |
| 3854 | |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 3855 | sme_DHCPStartInd(pHddCtx->hHal, pAdapter->device_mode, |
| 3856 | pAdapter->sessionId); |
Sundaresan Ramachandran | 76e48e8 | 2013-07-15 13:07:17 +0530 | [diff] [blame] | 3857 | } |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 3858 | else if ('2' == *dhcpPhase) |
Sundaresan Ramachandran | 76e48e8 | 2013-07-15 13:07:17 +0530 | [diff] [blame] | 3859 | { |
Deepthi Gowri | bfd1713 | 2014-11-14 17:59:04 +0530 | [diff] [blame] | 3860 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 3861 | FL("send DHCP STOP indication")); |
c_hpothu | 9b781ba | 2013-12-30 20:57:45 +0530 | [diff] [blame] | 3862 | |
| 3863 | pHddCtx->btCoexModeSet = FALSE; |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 3864 | |
| 3865 | sme_DHCPStopInd(pHddCtx->hHal, pAdapter->device_mode, |
| 3866 | pAdapter->sessionId); |
Sundaresan Ramachandran | 76e48e8 | 2013-07-15 13:07:17 +0530 | [diff] [blame] | 3867 | } |
| 3868 | } |
Jeff Johnson | f54df2c | 2013-07-24 11:43:39 -0700 | [diff] [blame] | 3869 | else if (strncmp(command, "SCAN-ACTIVE", 11) == 0) |
| 3870 | { |
c_hpothu | dbefd3e | 2014-04-28 15:59:47 +0530 | [diff] [blame] | 3871 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3872 | FL("making default scan to ACTIVE")); |
| 3873 | pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN; |
Jeff Johnson | f54df2c | 2013-07-24 11:43:39 -0700 | [diff] [blame] | 3874 | } |
| 3875 | else if (strncmp(command, "SCAN-PASSIVE", 12) == 0) |
| 3876 | { |
c_hpothu | dbefd3e | 2014-04-28 15:59:47 +0530 | [diff] [blame] | 3877 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3878 | FL("making default scan to PASSIVE")); |
| 3879 | pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN; |
Jeff Johnson | f54df2c | 2013-07-24 11:43:39 -0700 | [diff] [blame] | 3880 | } |
Hanumantha Reddy Pothula | 212243c | 2013-08-01 17:28:31 +0530 | [diff] [blame] | 3881 | else if (strncmp(command, "GETDWELLTIME", 12) == 0) |
| 3882 | { |
| 3883 | hdd_config_t *pCfg = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini; |
| 3884 | char extra[32]; |
| 3885 | tANI_U8 len = 0; |
| 3886 | |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 3887 | memset(extra, 0, sizeof(extra)); |
| 3888 | ret = hdd_get_dwell_time(pCfg, command, extra, sizeof(extra), &len); |
| 3889 | 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] | 3890 | { |
| 3891 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3892 | "%s: failed to copy data to user buffer", __func__); |
| 3893 | ret = -EFAULT; |
| 3894 | goto exit; |
| 3895 | } |
| 3896 | ret = len; |
| 3897 | } |
| 3898 | else if (strncmp(command, "SETDWELLTIME", 12) == 0) |
| 3899 | { |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 3900 | ret = hdd_set_dwell_time(pAdapter, command); |
Hanumantha Reddy Pothula | 212243c | 2013-08-01 17:28:31 +0530 | [diff] [blame] | 3901 | } |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 3902 | else if ( strncasecmp(command, "MIRACAST", 8) == 0 ) |
| 3903 | { |
| 3904 | tANI_U8 filterType = 0; |
| 3905 | tANI_U8 *value; |
| 3906 | value = command + 9; |
| 3907 | |
| 3908 | /* Convert the value from ascii to integer */ |
| 3909 | ret = kstrtou8(value, 10, &filterType); |
| 3910 | if (ret < 0) |
| 3911 | { |
| 3912 | /* If the input value is greater than max value of datatype, |
| 3913 | * then also kstrtou8 fails |
| 3914 | */ |
| 3915 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3916 | "%s: kstrtou8 failed range ", __func__); |
| 3917 | ret = -EINVAL; |
| 3918 | goto exit; |
| 3919 | } |
| 3920 | if ((filterType < WLAN_HDD_DRIVER_MIRACAST_CFG_MIN_VAL ) || |
| 3921 | (filterType > WLAN_HDD_DRIVER_MIRACAST_CFG_MAX_VAL)) |
| 3922 | { |
| 3923 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3924 | "%s: Accepted Values are 0 to 2. 0-Disabled, 1-Source," |
| 3925 | " 2-Sink ", __func__); |
| 3926 | ret = -EINVAL; |
| 3927 | goto exit; |
| 3928 | } |
| 3929 | //Filtertype value should be either 0-Disabled, 1-Source, 2-sink |
| 3930 | pHddCtx->drvr_miracast = filterType; |
Kaushik, Sushant | 9612244 | 2014-10-21 16:40:18 +0530 | [diff] [blame] | 3931 | pScanInfo = &pHddCtx->scan_info; |
| 3932 | if (filterType && pScanInfo != NULL && |
| 3933 | pHddCtx->scan_info.mScanPending) |
| 3934 | { |
| 3935 | /*Miracast Session started. Abort Scan */ |
| 3936 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3937 | "%s, Aborting Scan For Miracast",__func__); |
| 3938 | hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId, |
| 3939 | eCSR_SCAN_ABORT_DEFAULT); |
| 3940 | } |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 3941 | hdd_tx_rx_pkt_cnt_stat_timer_handler(pHddCtx); |
Ganesh Kondabattini | 8f6e3b3 | 2014-08-25 16:07:54 +0530 | [diff] [blame] | 3942 | sme_SetMiracastMode(pHddCtx->hHal, pHddCtx->drvr_miracast); |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 3943 | } |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 3944 | else if (strncmp(command, "SETMCRATE", 9) == 0) |
| 3945 | { |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 3946 | tANI_U8 *value = command; |
| 3947 | int targetRate; |
Leo Chang | 1f98cbd | 2013-10-17 15:03:52 -0700 | [diff] [blame] | 3948 | tSirRateUpdateInd *rateUpdate; |
| 3949 | eHalStatus status; |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 3950 | |
| 3951 | /* Only valid for SAP mode */ |
| 3952 | if (WLAN_HDD_SOFTAP != pAdapter->device_mode) |
| 3953 | { |
| 3954 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3955 | "%s: SAP mode is not running", __func__); |
| 3956 | ret = -EFAULT; |
| 3957 | goto exit; |
| 3958 | } |
| 3959 | |
| 3960 | /* Move pointer to ahead of SETMCRATE<delimiter> */ |
| 3961 | /* input value is in units of hundred kbps */ |
| 3962 | value = value + 10; |
| 3963 | /* Convert the value from ascii to integer, decimal base */ |
| 3964 | ret = kstrtouint(value, 10, &targetRate); |
| 3965 | |
Leo Chang | 1f98cbd | 2013-10-17 15:03:52 -0700 | [diff] [blame] | 3966 | rateUpdate = (tSirRateUpdateInd *)vos_mem_malloc(sizeof(tSirRateUpdateInd)); |
| 3967 | if (NULL == rateUpdate) |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 3968 | { |
Leo Chang | 1f98cbd | 2013-10-17 15:03:52 -0700 | [diff] [blame] | 3969 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3970 | "%s: SETMCRATE indication alloc fail", __func__); |
| 3971 | ret = -EFAULT; |
| 3972 | goto exit; |
| 3973 | } |
| 3974 | vos_mem_zero(rateUpdate, sizeof(tSirRateUpdateInd )); |
| 3975 | |
| 3976 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3977 | "MC Target rate %d", targetRate); |
| 3978 | /* Ignore unicast */ |
| 3979 | rateUpdate->ucastDataRate = -1; |
| 3980 | rateUpdate->mcastDataRate24GHz = targetRate; |
| 3981 | rateUpdate->mcastDataRate5GHz = targetRate; |
| 3982 | rateUpdate->mcastDataRate24GHzTxFlag = 0; |
| 3983 | rateUpdate->mcastDataRate5GHzTxFlag = 0; |
| 3984 | status = sme_SendRateUpdateInd(pHddCtx->hHal, rateUpdate); |
| 3985 | if (eHAL_STATUS_SUCCESS != status) |
| 3986 | { |
| 3987 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3988 | "%s: SET_MC_RATE failed", __func__); |
| 3989 | vos_mem_free(rateUpdate); |
| 3990 | ret = -EFAULT; |
| 3991 | goto exit; |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 3992 | } |
| 3993 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 3994 | #ifdef FEATURE_WLAN_BATCH_SCAN |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 3995 | else if (strncmp(command, "WLS_BATCHING", 12) == 0) |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 3996 | { |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 3997 | ret = hdd_handle_batch_scan_ioctl(pAdapter, &priv_data, command); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 3998 | } |
| 3999 | #endif |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4000 | #if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD) |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4001 | else if (strncmp(command, "SETCCXROAMSCANCHANNELS", 22) == 0) |
| 4002 | { |
| 4003 | tANI_U8 *value = command; |
| 4004 | tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0}; |
| 4005 | tANI_U8 numChannels = 0; |
| 4006 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 4007 | |
| 4008 | status = hdd_parse_channellist(value, ChannelList, &numChannels); |
| 4009 | if (eHAL_STATUS_SUCCESS != status) |
| 4010 | { |
| 4011 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4012 | "%s: Failed to parse channel list information", __func__); |
| 4013 | ret = -EINVAL; |
| 4014 | goto exit; |
| 4015 | } |
| 4016 | |
| 4017 | if (numChannels > WNI_CFG_VALID_CHANNEL_LIST_LEN) |
| 4018 | { |
| 4019 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4020 | "%s: number of channels (%d) supported exceeded max (%d)", __func__, |
| 4021 | numChannels, WNI_CFG_VALID_CHANNEL_LIST_LEN); |
| 4022 | ret = -EINVAL; |
| 4023 | goto exit; |
| 4024 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4025 | status = sme_SetEseRoamScanChannelList((tHalHandle)(pHddCtx->hHal), |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4026 | ChannelList, |
| 4027 | numChannels); |
| 4028 | if (eHAL_STATUS_SUCCESS != status) |
| 4029 | { |
| 4030 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4031 | "%s: Failed to update channel list information", __func__); |
| 4032 | ret = -EINVAL; |
| 4033 | goto exit; |
| 4034 | } |
| 4035 | } |
| 4036 | else if (strncmp(command, "GETTSMSTATS", 11) == 0) |
| 4037 | { |
| 4038 | tANI_U8 *value = command; |
| 4039 | char extra[128] = {0}; |
| 4040 | int len = 0; |
| 4041 | tANI_U8 tid = 0; |
| 4042 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 4043 | tAniTrafStrmMetrics tsmMetrics; |
| 4044 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 4045 | |
| 4046 | /* if not associated, return error */ |
| 4047 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 4048 | { |
| 4049 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:Not associated!",__func__); |
| 4050 | ret = -EINVAL; |
| 4051 | goto exit; |
| 4052 | } |
| 4053 | |
| 4054 | /* Move pointer to ahead of GETTSMSTATS<delimiter> */ |
| 4055 | value = value + 12; |
| 4056 | /* Convert the value from ascii to integer */ |
| 4057 | ret = kstrtou8(value, 10, &tid); |
| 4058 | if (ret < 0) |
| 4059 | { |
| 4060 | /* If the input value is greater than max value of datatype, then also |
| 4061 | kstrtou8 fails */ |
| 4062 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4063 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 4064 | TID_MIN_VALUE, |
| 4065 | TID_MAX_VALUE); |
| 4066 | ret = -EINVAL; |
| 4067 | goto exit; |
| 4068 | } |
| 4069 | |
| 4070 | if ((tid < TID_MIN_VALUE) || (tid > TID_MAX_VALUE)) |
| 4071 | { |
| 4072 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4073 | "tid value %d is out of range" |
| 4074 | " (Min: %d Max: %d)", tid, |
| 4075 | TID_MIN_VALUE, |
| 4076 | TID_MAX_VALUE); |
| 4077 | ret = -EINVAL; |
| 4078 | goto exit; |
| 4079 | } |
| 4080 | |
| 4081 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4082 | "%s: Received Command to get tsm stats tid = %d", __func__, tid); |
| 4083 | |
| 4084 | if (VOS_STATUS_SUCCESS != hdd_get_tsm_stats(pAdapter, tid, &tsmMetrics)) |
| 4085 | { |
| 4086 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4087 | "%s: failed to get tsm stats", __func__); |
| 4088 | ret = -EFAULT; |
| 4089 | goto exit; |
| 4090 | } |
| 4091 | |
| 4092 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4093 | "UplinkPktQueueDly(%d)\n" |
| 4094 | "UplinkPktQueueDlyHist[0](%d)\n" |
| 4095 | "UplinkPktQueueDlyHist[1](%d)\n" |
| 4096 | "UplinkPktQueueDlyHist[2](%d)\n" |
| 4097 | "UplinkPktQueueDlyHist[3](%d)\n" |
Arun Kumar Khandavalli | e876821 | 2014-02-17 16:43:34 +0530 | [diff] [blame] | 4098 | "UplinkPktTxDly(%u)\n" |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4099 | "UplinkPktLoss(%d)\n" |
| 4100 | "UplinkPktCount(%d)\n" |
| 4101 | "RoamingCount(%d)\n" |
| 4102 | "RoamingDly(%d)", tsmMetrics.UplinkPktQueueDly, |
| 4103 | tsmMetrics.UplinkPktQueueDlyHist[0], |
| 4104 | tsmMetrics.UplinkPktQueueDlyHist[1], |
| 4105 | tsmMetrics.UplinkPktQueueDlyHist[2], |
| 4106 | tsmMetrics.UplinkPktQueueDlyHist[3], |
| 4107 | tsmMetrics.UplinkPktTxDly, tsmMetrics.UplinkPktLoss, |
| 4108 | tsmMetrics.UplinkPktCount, tsmMetrics.RoamingCount, tsmMetrics.RoamingDly); |
| 4109 | |
| 4110 | /* Output TSM stats is of the format |
| 4111 | GETTSMSTATS [PktQueueDly] [PktQueueDlyHist[0]]:[PktQueueDlyHist[1]] ...[RoamingDly] |
| 4112 | eg., GETTSMSTATS 10 1:0:0:161 20 1 17 8 39800 */ |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4113 | 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] | 4114 | tsmMetrics.UplinkPktQueueDly, tsmMetrics.UplinkPktQueueDlyHist[0], |
| 4115 | tsmMetrics.UplinkPktQueueDlyHist[1], tsmMetrics.UplinkPktQueueDlyHist[2], |
| 4116 | tsmMetrics.UplinkPktQueueDlyHist[3], tsmMetrics.UplinkPktTxDly, |
| 4117 | tsmMetrics.UplinkPktLoss, tsmMetrics.UplinkPktCount, tsmMetrics.RoamingCount, |
| 4118 | tsmMetrics.RoamingDly); |
| 4119 | |
| 4120 | if (copy_to_user(priv_data.buf, &extra, len + 1)) |
| 4121 | { |
| 4122 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4123 | "%s: failed to copy data to user buffer", __func__); |
| 4124 | ret = -EFAULT; |
| 4125 | goto exit; |
| 4126 | } |
| 4127 | } |
| 4128 | else if (strncmp(command, "SETCCKMIE", 9) == 0) |
| 4129 | { |
| 4130 | tANI_U8 *value = command; |
| 4131 | tANI_U8 *cckmIe = NULL; |
| 4132 | tANI_U8 cckmIeLen = 0; |
| 4133 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 4134 | |
| 4135 | status = hdd_parse_get_cckm_ie(value, &cckmIe, &cckmIeLen); |
| 4136 | if (eHAL_STATUS_SUCCESS != status) |
| 4137 | { |
| 4138 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4139 | "%s: Failed to parse cckm ie data", __func__); |
| 4140 | ret = -EINVAL; |
| 4141 | goto exit; |
| 4142 | } |
| 4143 | |
| 4144 | if (cckmIeLen > DOT11F_IE_RSN_MAX_LEN) |
| 4145 | { |
| 4146 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4147 | "%s: CCKM Ie input length is more than max[%d]", __func__, |
| 4148 | DOT11F_IE_RSN_MAX_LEN); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 4149 | vos_mem_free(cckmIe); |
| 4150 | cckmIe = NULL; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4151 | ret = -EINVAL; |
| 4152 | goto exit; |
| 4153 | } |
| 4154 | sme_SetCCKMIe((tHalHandle)(pHddCtx->hHal), pAdapter->sessionId, cckmIe, cckmIeLen); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 4155 | vos_mem_free(cckmIe); |
| 4156 | cckmIe = NULL; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4157 | } |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4158 | else if (strncmp(command, "CCXBEACONREQ", 12) == 0) |
| 4159 | { |
| 4160 | tANI_U8 *value = command; |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4161 | tCsrEseBeaconReq eseBcnReq; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4162 | eHalStatus status = eHAL_STATUS_SUCCESS; |
Srinivas Girigowda | 0c6d7fe | 2014-05-28 18:18:10 -0700 | [diff] [blame] | 4163 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4164 | status = hdd_parse_ese_beacon_req(value, &eseBcnReq); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4165 | if (eHAL_STATUS_SUCCESS != status) |
| 4166 | { |
| 4167 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4168 | "%s: Failed to parse ese beacon req", __func__); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4169 | ret = -EINVAL; |
| 4170 | goto exit; |
| 4171 | } |
Srinivas Girigowda | 0c6d7fe | 2014-05-28 18:18:10 -0700 | [diff] [blame] | 4172 | if (!hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) { |
| 4173 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Not associated")); |
| 4174 | hdd_indicateEseBcnReportNoResults (pAdapter, |
| 4175 | eseBcnReq.bcnReq[0].measurementToken, |
| 4176 | 0x02, //BIT(1) set for measurement done |
| 4177 | 0); // no BSS |
| 4178 | goto exit; |
| 4179 | } |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4180 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4181 | status = sme_SetEseBeaconRequest((tHalHandle)(pHddCtx->hHal), pAdapter->sessionId, &eseBcnReq); |
| 4182 | if (eHAL_STATUS_SUCCESS != status) |
| 4183 | { |
| 4184 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4185 | "%s: sme_SetEseBeaconRequest failed (%d)", __func__, status); |
| 4186 | ret = -EINVAL; |
| 4187 | goto exit; |
| 4188 | } |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4189 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4190 | #endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */ |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 4191 | else if (strncmp(command, "GETBCNMISSRATE", 14) == 0) |
| 4192 | { |
| 4193 | eHalStatus status; |
| 4194 | char buf[32], len; |
| 4195 | long waitRet; |
| 4196 | bcnMissRateContext_t getBcnMissRateCtx; |
| 4197 | |
| 4198 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 4199 | |
| 4200 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 4201 | { |
| 4202 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 4203 | FL("GETBCNMISSRATE: STA is not in connected state")); |
| 4204 | ret = -1; |
| 4205 | goto exit; |
| 4206 | } |
| 4207 | |
| 4208 | init_completion(&(getBcnMissRateCtx.completion)); |
| 4209 | getBcnMissRateCtx.magic = BCN_MISS_RATE_CONTEXT_MAGIC; |
| 4210 | |
| 4211 | status = sme_getBcnMissRate((tHalHandle)(pHddCtx->hHal), |
| 4212 | pAdapter->sessionId, |
| 4213 | (void *)getBcnMissRateCB, |
| 4214 | (void *)(&getBcnMissRateCtx)); |
| 4215 | if( eHAL_STATUS_SUCCESS != status) |
| 4216 | { |
| 4217 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4218 | FL("GETBCNMISSRATE: fail to post WDA cmd")); |
| 4219 | ret = -EINVAL; |
| 4220 | goto exit; |
| 4221 | } |
| 4222 | |
| 4223 | waitRet = wait_for_completion_interruptible_timeout |
| 4224 | (&getBcnMissRateCtx.completion, BCN_MISS_RATE_TIME); |
| 4225 | if(waitRet <= 0) |
| 4226 | { |
| 4227 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4228 | FL("failed to wait on bcnMissRateComp %d"), ret); |
| 4229 | |
| 4230 | //Make magic number to zero so that callback is not called. |
| 4231 | spin_lock(&hdd_context_lock); |
| 4232 | getBcnMissRateCtx.magic = 0x0; |
| 4233 | spin_unlock(&hdd_context_lock); |
| 4234 | ret = -EINVAL; |
| 4235 | goto exit; |
| 4236 | } |
| 4237 | |
| 4238 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4239 | FL("GETBCNMISSRATE: bcnMissRate: %d"), gbcnMissRate); |
| 4240 | |
| 4241 | len = snprintf(buf, sizeof(buf), "GETBCNMISSRATE %d", gbcnMissRate); |
| 4242 | if (copy_to_user(priv_data.buf, &buf, len + 1)) |
| 4243 | { |
| 4244 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4245 | "%s: failed to copy data to user buffer", __func__); |
| 4246 | ret = -EFAULT; |
| 4247 | goto exit; |
| 4248 | } |
| 4249 | ret = len; |
| 4250 | } |
Atul Mittal | 87ec242 | 2014-09-24 13:12:50 +0530 | [diff] [blame] | 4251 | #ifdef FEATURE_WLAN_TDLS |
| 4252 | else if (strncmp(command, "TDLSSECONDARYCHANNELOFFSET", 26) == 0) { |
| 4253 | tANI_U8 *value = command; |
| 4254 | int set_value; |
| 4255 | /* Move pointer to ahead of TDLSOFFCH*/ |
| 4256 | value += 26; |
| 4257 | sscanf(value, "%d", &set_value); |
| 4258 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4259 | "%s: Tdls offchannel offset:%d", |
| 4260 | __func__, set_value); |
| 4261 | ret = iw_set_tdlssecoffchanneloffset(pHddCtx, set_value); |
| 4262 | if (ret < 0) |
| 4263 | { |
| 4264 | ret = -EINVAL; |
| 4265 | goto exit; |
| 4266 | } |
| 4267 | |
| 4268 | } else if (strncmp(command, "TDLSOFFCHANNELMODE", 18) == 0) { |
| 4269 | tANI_U8 *value = command; |
| 4270 | int set_value; |
| 4271 | /* Move pointer to ahead of tdlsoffchnmode*/ |
| 4272 | value += 18; |
| 4273 | sscanf(value, "%d", &set_value); |
| 4274 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4275 | "%s: Tdls offchannel mode:%d", |
| 4276 | __func__, set_value); |
| 4277 | ret = iw_set_tdlsoffchannelmode(pAdapter, set_value); |
| 4278 | if (ret < 0) |
| 4279 | { |
| 4280 | ret = -EINVAL; |
| 4281 | goto exit; |
| 4282 | } |
| 4283 | } else if (strncmp(command, "TDLSOFFCHANNEL", 14) == 0) { |
| 4284 | tANI_U8 *value = command; |
| 4285 | int set_value; |
| 4286 | /* Move pointer to ahead of TDLSOFFCH*/ |
| 4287 | value += 14; |
| 4288 | sscanf(value, "%d", &set_value); |
| 4289 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4290 | "%s: Tdls offchannel num: %d", |
| 4291 | __func__, set_value); |
| 4292 | ret = iw_set_tdlsoffchannel(pHddCtx, set_value); |
| 4293 | if (ret < 0) |
| 4294 | { |
| 4295 | ret = -EINVAL; |
| 4296 | goto exit; |
| 4297 | } |
| 4298 | } |
| 4299 | #endif |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 4300 | else if (strncmp(command, "GETFWSTATS", 10) == 0) |
| 4301 | { |
| 4302 | eHalStatus status; |
| 4303 | char *buf = NULL; |
| 4304 | char len; |
| 4305 | long waitRet; |
| 4306 | fwStatsContext_t fwStatsCtx; |
Abhishek Singh | 08aa776 | 2014-12-16 13:59:03 +0530 | [diff] [blame] | 4307 | tSirFwStatsResult *fwStatsRsp = &(pAdapter->fwStatsRsp); |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 4308 | tANI_U8 *ptr = command; |
| 4309 | int stats = *(ptr + 11) - '0'; |
| 4310 | |
| 4311 | hddLog(VOS_TRACE_LEVEL_INFO, FL("stats = %d "),stats); |
| 4312 | if (!IS_FEATURE_FW_STATS_ENABLE) |
| 4313 | { |
| 4314 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4315 | FL("Get Firmware stats feature not supported")); |
| 4316 | ret = -EINVAL; |
| 4317 | goto exit; |
| 4318 | } |
| 4319 | |
| 4320 | if (FW_STATS_MAX <= stats || 0 >= stats) |
| 4321 | { |
| 4322 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4323 | FL(" stats %d not supported"),stats); |
| 4324 | ret = -EINVAL; |
| 4325 | goto exit; |
| 4326 | } |
| 4327 | |
| 4328 | init_completion(&(fwStatsCtx.completion)); |
| 4329 | fwStatsCtx.magic = FW_STATS_CONTEXT_MAGIC; |
| 4330 | fwStatsCtx.pAdapter = pAdapter; |
| 4331 | fwStatsRsp->type = 0; |
| 4332 | status = sme_GetFwStats( (tHalHandle)pHddCtx->hHal, stats, |
Abhishek Singh | 08aa776 | 2014-12-16 13:59:03 +0530 | [diff] [blame] | 4333 | &fwStatsCtx, hdd_FWStatisCB); |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 4334 | if (eHAL_STATUS_SUCCESS != status) |
| 4335 | { |
| 4336 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4337 | FL(" fail to post WDA cmd status = %d"), status); |
| 4338 | ret = -EINVAL; |
| 4339 | goto exit; |
| 4340 | } |
| 4341 | waitRet = wait_for_completion_timeout |
| 4342 | (&(fwStatsCtx.completion), FW_STATE_WAIT_TIME); |
| 4343 | if (waitRet <= 0) |
| 4344 | { |
| 4345 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4346 | FL("failed to wait on GwtFwstats")); |
| 4347 | //Make magic number to zero so that callback is not executed. |
| 4348 | spin_lock(&hdd_context_lock); |
| 4349 | fwStatsCtx.magic = 0x0; |
| 4350 | spin_unlock(&hdd_context_lock); |
| 4351 | ret = -EINVAL; |
| 4352 | goto exit; |
| 4353 | } |
| 4354 | if (fwStatsRsp->type) |
| 4355 | { |
| 4356 | buf = kmalloc(FW_STATE_RSP_LEN, GFP_KERNEL); |
| 4357 | if (!buf) |
| 4358 | { |
| 4359 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4360 | FL(" failed to allocate memory")); |
| 4361 | ret = -ENOMEM; |
| 4362 | goto exit; |
| 4363 | } |
| 4364 | switch( fwStatsRsp->type ) |
| 4365 | { |
| 4366 | case FW_UBSP_STATS: |
| 4367 | { |
| 4368 | len = snprintf(buf, FW_STATE_RSP_LEN, |
| 4369 | "GETFWSTATS: ubsp_enter_cnt %d ubsp_jump_ddr_cnt %d", |
Abhishek Singh | 08aa776 | 2014-12-16 13:59:03 +0530 | [diff] [blame] | 4370 | fwStatsRsp->fwStatsData.ubspStats.ubsp_enter_cnt, |
| 4371 | fwStatsRsp->fwStatsData.ubspStats.ubsp_jump_ddr_cnt); |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 4372 | } |
| 4373 | break; |
| 4374 | default: |
| 4375 | { |
| 4376 | hddLog(VOS_TRACE_LEVEL_ERROR, FL( "No handling for stats type %d"),fwStatsRsp->type); |
| 4377 | ret = -EFAULT; |
| 4378 | kfree(buf); |
| 4379 | goto exit; |
| 4380 | } |
| 4381 | } |
| 4382 | if (copy_to_user(priv_data.buf, buf, len + 1)) |
| 4383 | { |
| 4384 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4385 | FL(" failed to copy data to user buffer")); |
| 4386 | ret = -EFAULT; |
| 4387 | kfree(buf); |
| 4388 | goto exit; |
| 4389 | } |
| 4390 | ret = len; |
| 4391 | kfree(buf); |
| 4392 | } |
| 4393 | else |
| 4394 | { |
| 4395 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4396 | FL("failed to fetch the stats")); |
| 4397 | ret = -EFAULT; |
| 4398 | goto exit; |
| 4399 | } |
| 4400 | |
| 4401 | } |
Madan Mohan Koyyalamudi | f9bdd4e | 2012-10-30 18:05:03 -0700 | [diff] [blame] | 4402 | else { |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 4403 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 4404 | TRACE_CODE_HDD_UNSUPPORTED_IOCTL, |
| 4405 | pAdapter->sessionId, 0)); |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 4406 | hddLog( VOS_TRACE_LEVEL_WARN, FL("Unsupported GUI command %s"), |
| 4407 | command); |
Madan Mohan Koyyalamudi | f9bdd4e | 2012-10-30 18:05:03 -0700 | [diff] [blame] | 4408 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4409 | } |
| 4410 | exit: |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 4411 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4412 | if (command) |
| 4413 | { |
| 4414 | kfree(command); |
| 4415 | } |
| 4416 | return ret; |
| 4417 | } |
| 4418 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 4419 | #ifdef CONFIG_COMPAT |
| 4420 | static int hdd_driver_compat_ioctl(hdd_adapter_t *pAdapter, struct ifreq *ifr) |
| 4421 | { |
| 4422 | struct { |
| 4423 | compat_uptr_t buf; |
| 4424 | int used_len; |
| 4425 | int total_len; |
| 4426 | } compat_priv_data; |
| 4427 | hdd_priv_data_t priv_data; |
| 4428 | int ret = 0; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4429 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 4430 | /* |
| 4431 | * Note that pAdapter and ifr have already been verified by caller, |
| 4432 | * and HDD context has also been validated |
| 4433 | */ |
| 4434 | if (copy_from_user(&compat_priv_data, ifr->ifr_data, |
| 4435 | sizeof(compat_priv_data))) { |
| 4436 | ret = -EFAULT; |
| 4437 | goto exit; |
| 4438 | } |
| 4439 | priv_data.buf = compat_ptr(compat_priv_data.buf); |
| 4440 | priv_data.used_len = compat_priv_data.used_len; |
| 4441 | priv_data.total_len = compat_priv_data.total_len; |
| 4442 | ret = hdd_driver_command(pAdapter, &priv_data); |
| 4443 | exit: |
| 4444 | return ret; |
| 4445 | } |
| 4446 | #else /* CONFIG_COMPAT */ |
| 4447 | static int hdd_driver_compat_ioctl(hdd_adapter_t *pAdapter, struct ifreq *ifr) |
| 4448 | { |
| 4449 | /* will never be invoked */ |
| 4450 | return 0; |
| 4451 | } |
| 4452 | #endif /* CONFIG_COMPAT */ |
| 4453 | |
| 4454 | static int hdd_driver_ioctl(hdd_adapter_t *pAdapter, struct ifreq *ifr) |
| 4455 | { |
| 4456 | hdd_priv_data_t priv_data; |
| 4457 | int ret = 0; |
| 4458 | |
| 4459 | /* |
| 4460 | * Note that pAdapter and ifr have already been verified by caller, |
| 4461 | * and HDD context has also been validated |
| 4462 | */ |
| 4463 | if (copy_from_user(&priv_data, ifr->ifr_data, sizeof(priv_data))) { |
| 4464 | ret = -EFAULT; |
| 4465 | } else { |
| 4466 | ret = hdd_driver_command(pAdapter, &priv_data); |
| 4467 | } |
| 4468 | return ret; |
| 4469 | } |
| 4470 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 4471 | int __hdd_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 4472 | { |
| 4473 | hdd_adapter_t *pAdapter; |
| 4474 | hdd_context_t *pHddCtx; |
| 4475 | int ret; |
| 4476 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 4477 | ENTER(); |
| 4478 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 4479 | pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 4480 | if (NULL == pAdapter) { |
| 4481 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 4482 | "%s: HDD adapter context is Null", __func__); |
| 4483 | ret = -ENODEV; |
| 4484 | goto exit; |
| 4485 | } |
| 4486 | if (dev != pAdapter->dev) { |
| 4487 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 4488 | "%s: HDD adapter/dev inconsistency", __func__); |
| 4489 | ret = -ENODEV; |
| 4490 | goto exit; |
| 4491 | } |
| 4492 | |
| 4493 | if ((!ifr) || (!ifr->ifr_data)) { |
| 4494 | ret = -EINVAL; |
| 4495 | goto exit; |
| 4496 | } |
| 4497 | |
| 4498 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 4499 | ret = wlan_hdd_validate_context(pHddCtx); |
| 4500 | if (ret) { |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 4501 | ret = -EBUSY; |
| 4502 | goto exit; |
| 4503 | } |
| 4504 | |
| 4505 | switch (cmd) { |
| 4506 | case (SIOCDEVPRIVATE + 1): |
| 4507 | if (is_compat_task()) |
| 4508 | ret = hdd_driver_compat_ioctl(pAdapter, ifr); |
| 4509 | else |
| 4510 | ret = hdd_driver_ioctl(pAdapter, ifr); |
| 4511 | break; |
| 4512 | default: |
| 4513 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unknown ioctl %d", |
| 4514 | __func__, cmd); |
| 4515 | ret = -EINVAL; |
| 4516 | break; |
| 4517 | } |
| 4518 | exit: |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 4519 | EXIT(); |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 4520 | return ret; |
| 4521 | } |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4522 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 4523 | int hdd_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) |
| 4524 | { |
| 4525 | int ret; |
| 4526 | |
| 4527 | vos_ssr_protect(__func__); |
| 4528 | ret = __hdd_ioctl(dev, ifr, cmd); |
| 4529 | vos_ssr_unprotect(__func__); |
| 4530 | |
| 4531 | return ret; |
| 4532 | } |
| 4533 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4534 | #if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4535 | /**--------------------------------------------------------------------------- |
| 4536 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4537 | \brief hdd_parse_ese_beacon_req() - Parse ese beacon request |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4538 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4539 | This function parses the ese beacon request passed in the format |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4540 | CCXBEACONREQ<space><Number of fields><space><Measurement token> |
| 4541 | <space>Channel 1<space>Scan Mode <space>Meas Duration<space>Channel N |
| 4542 | <space>Scan Mode N<space>Meas Duration N |
| 4543 | if the Number of bcn req fields (N) does not match with the actual number of fields passed |
| 4544 | then take N. |
| 4545 | <Meas Token><Channel><Scan Mode> and <Meas Duration> are treated as one pair |
| 4546 | For example, CCXBEACONREQ 2 1 1 1 30 2 44 0 40. |
| 4547 | This function does not take care of removing duplicate channels from the list |
| 4548 | |
| 4549 | \param - pValue Pointer to data |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4550 | \param - pEseBcnReq output pointer to store parsed ie information |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4551 | |
| 4552 | \return - 0 for success non-zero for failure |
| 4553 | |
| 4554 | --------------------------------------------------------------------------*/ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4555 | static VOS_STATUS hdd_parse_ese_beacon_req(tANI_U8 *pValue, |
| 4556 | tCsrEseBeaconReq *pEseBcnReq) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4557 | { |
| 4558 | tANI_U8 *inPtr = pValue; |
| 4559 | int tempInt = 0; |
| 4560 | int j = 0, i = 0, v = 0; |
| 4561 | char buf[32]; |
| 4562 | |
| 4563 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 4564 | /*no argument after the command*/ |
| 4565 | if (NULL == inPtr) |
| 4566 | { |
| 4567 | return -EINVAL; |
| 4568 | } |
| 4569 | /*no space after the command*/ |
| 4570 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 4571 | { |
| 4572 | return -EINVAL; |
| 4573 | } |
| 4574 | |
| 4575 | /*removing empty spaces*/ |
| 4576 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
| 4577 | |
| 4578 | /*no argument followed by spaces*/ |
| 4579 | if ('\0' == *inPtr) return -EINVAL; |
| 4580 | |
| 4581 | /*getting the first argument ie measurement token*/ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 4582 | v = sscanf(inPtr, "%31s ", buf); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4583 | if (1 != v) return -EINVAL; |
| 4584 | |
| 4585 | v = kstrtos32(buf, 10, &tempInt); |
| 4586 | if ( v < 0) return -EINVAL; |
| 4587 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4588 | pEseBcnReq->numBcnReqIe = tempInt; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4589 | |
| 4590 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4591 | "Number of Bcn Req Ie fields(%d)", pEseBcnReq->numBcnReqIe); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4592 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4593 | for (j = 0; j < (pEseBcnReq->numBcnReqIe); j++) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4594 | { |
| 4595 | for (i = 0; i < 4; i++) |
| 4596 | { |
| 4597 | /*inPtr pointing to the beginning of first space after number of ie fields*/ |
| 4598 | inPtr = strpbrk( inPtr, " " ); |
| 4599 | /*no ie data after the number of ie fields argument*/ |
| 4600 | if (NULL == inPtr) return -EINVAL; |
| 4601 | |
| 4602 | /*removing empty space*/ |
| 4603 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
| 4604 | |
| 4605 | /*no ie data after the number of ie fields argument and spaces*/ |
| 4606 | if ( '\0' == *inPtr ) return -EINVAL; |
| 4607 | |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 4608 | v = sscanf(inPtr, "%31s ", buf); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4609 | if (1 != v) return -EINVAL; |
| 4610 | |
| 4611 | v = kstrtos32(buf, 10, &tempInt); |
| 4612 | if (v < 0) return -EINVAL; |
| 4613 | |
| 4614 | switch (i) |
| 4615 | { |
| 4616 | case 0: /* Measurement token */ |
| 4617 | if (tempInt <= 0) |
| 4618 | { |
| 4619 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4620 | "Invalid Measurement Token(%d)", tempInt); |
| 4621 | return -EINVAL; |
| 4622 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4623 | pEseBcnReq->bcnReq[j].measurementToken = tempInt; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4624 | break; |
| 4625 | |
| 4626 | case 1: /* Channel number */ |
| 4627 | if ((tempInt <= 0) || |
| 4628 | (tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX)) |
| 4629 | { |
| 4630 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4631 | "Invalid Channel Number(%d)", tempInt); |
| 4632 | return -EINVAL; |
| 4633 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4634 | pEseBcnReq->bcnReq[j].channel = tempInt; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4635 | break; |
| 4636 | |
| 4637 | case 2: /* Scan mode */ |
Varun Reddy Yeturu | 0b18d5a | 2013-12-04 11:42:23 -0800 | [diff] [blame] | 4638 | if ((tempInt < eSIR_PASSIVE_SCAN) || (tempInt > eSIR_BEACON_TABLE)) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4639 | { |
| 4640 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4641 | "Invalid Scan Mode(%d) Expected{0|1|2}", tempInt); |
| 4642 | return -EINVAL; |
| 4643 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4644 | pEseBcnReq->bcnReq[j].scanMode= tempInt; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4645 | break; |
| 4646 | |
| 4647 | case 3: /* Measurement duration */ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4648 | if (((tempInt <= 0) && (pEseBcnReq->bcnReq[j].scanMode != eSIR_BEACON_TABLE)) || |
| 4649 | ((tempInt < 0) && (pEseBcnReq->bcnReq[j].scanMode == eSIR_BEACON_TABLE))) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4650 | { |
| 4651 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4652 | "Invalid Measurement Duration(%d)", tempInt); |
| 4653 | return -EINVAL; |
| 4654 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4655 | pEseBcnReq->bcnReq[j].measurementDuration = tempInt; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4656 | break; |
| 4657 | } |
| 4658 | } |
| 4659 | } |
| 4660 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4661 | for (j = 0; j < pEseBcnReq->numBcnReqIe; j++) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4662 | { |
| 4663 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Arun Kumar Khandavalli | e876821 | 2014-02-17 16:43:34 +0530 | [diff] [blame] | 4664 | "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] | 4665 | j, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4666 | pEseBcnReq->bcnReq[j].measurementToken, |
| 4667 | pEseBcnReq->bcnReq[j].channel, |
| 4668 | pEseBcnReq->bcnReq[j].scanMode, |
| 4669 | pEseBcnReq->bcnReq[j].measurementDuration); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 4670 | } |
| 4671 | |
| 4672 | return VOS_STATUS_SUCCESS; |
| 4673 | } |
| 4674 | |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4675 | static void hdd_GetTsmStatsCB( tAniTrafStrmMetrics tsmMetrics, const tANI_U32 staId, void *pContext ) |
| 4676 | { |
| 4677 | struct statsContext *pStatsContext = NULL; |
| 4678 | hdd_adapter_t *pAdapter = NULL; |
| 4679 | |
| 4680 | if (NULL == pContext) |
| 4681 | { |
| 4682 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4683 | "%s: Bad param, pContext [%p]", |
| 4684 | __func__, pContext); |
| 4685 | return; |
| 4686 | } |
| 4687 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 4688 | /* there is a race condition that exists between this callback |
| 4689 | function and the caller since the caller could time out either |
| 4690 | before or while this code is executing. we use a spinlock to |
| 4691 | serialize these actions */ |
| 4692 | spin_lock(&hdd_context_lock); |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4693 | |
| 4694 | pStatsContext = pContext; |
| 4695 | pAdapter = pStatsContext->pAdapter; |
| 4696 | if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic)) |
| 4697 | { |
| 4698 | /* the caller presumably timed out so there is nothing we can do */ |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 4699 | spin_unlock(&hdd_context_lock); |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4700 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 4701 | "%s: Invalid context, pAdapter [%p] magic [%08x]", |
| 4702 | __func__, pAdapter, pStatsContext->magic); |
| 4703 | return; |
| 4704 | } |
| 4705 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 4706 | /* context is valid so caller is still waiting */ |
| 4707 | |
| 4708 | /* paranoia: invalidate the magic */ |
| 4709 | pStatsContext->magic = 0; |
| 4710 | |
| 4711 | /* copy over the tsm stats */ |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4712 | pAdapter->tsmStats.UplinkPktQueueDly = tsmMetrics.UplinkPktQueueDly; |
| 4713 | vos_mem_copy(pAdapter->tsmStats.UplinkPktQueueDlyHist, |
| 4714 | tsmMetrics.UplinkPktQueueDlyHist, |
| 4715 | sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist)/ |
| 4716 | sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist[0])); |
| 4717 | pAdapter->tsmStats.UplinkPktTxDly = tsmMetrics.UplinkPktTxDly; |
| 4718 | pAdapter->tsmStats.UplinkPktLoss = tsmMetrics.UplinkPktLoss; |
| 4719 | pAdapter->tsmStats.UplinkPktCount = tsmMetrics.UplinkPktCount; |
| 4720 | pAdapter->tsmStats.RoamingCount = tsmMetrics.RoamingCount; |
| 4721 | pAdapter->tsmStats.RoamingDly = tsmMetrics.RoamingDly; |
| 4722 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 4723 | /* notify the caller */ |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4724 | complete(&pStatsContext->completion); |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 4725 | |
| 4726 | /* serialization is complete */ |
| 4727 | spin_unlock(&hdd_context_lock); |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4728 | } |
| 4729 | |
| 4730 | |
| 4731 | |
| 4732 | static VOS_STATUS hdd_get_tsm_stats(hdd_adapter_t *pAdapter, const tANI_U8 tid, |
| 4733 | tAniTrafStrmMetrics* pTsmMetrics) |
| 4734 | { |
| 4735 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 4736 | eHalStatus hstatus; |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 4737 | VOS_STATUS vstatus = VOS_STATUS_SUCCESS; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4738 | long lrc; |
| 4739 | struct statsContext context; |
| 4740 | hdd_context_t *pHddCtx = NULL; |
| 4741 | |
| 4742 | if (NULL == pAdapter) |
| 4743 | { |
| 4744 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: pAdapter is NULL", __func__); |
| 4745 | return VOS_STATUS_E_FAULT; |
| 4746 | } |
| 4747 | |
| 4748 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 4749 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 4750 | |
| 4751 | /* we are connected prepare our callback context */ |
| 4752 | init_completion(&context.completion); |
| 4753 | context.pAdapter = pAdapter; |
| 4754 | context.magic = STATS_CONTEXT_MAGIC; |
| 4755 | |
| 4756 | /* query tsm stats */ |
| 4757 | hstatus = sme_GetTsmStats(pHddCtx->hHal, hdd_GetTsmStatsCB, |
| 4758 | pHddStaCtx->conn_info.staId[ 0 ], |
| 4759 | pHddStaCtx->conn_info.bssId, |
| 4760 | &context, pHddCtx->pvosContext, tid); |
| 4761 | |
| 4762 | if (eHAL_STATUS_SUCCESS != hstatus) |
| 4763 | { |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 4764 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unable to retrieve statistics", |
| 4765 | __func__); |
| 4766 | vstatus = VOS_STATUS_E_FAULT; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4767 | } |
| 4768 | else |
| 4769 | { |
| 4770 | /* request was sent -- wait for the response */ |
| 4771 | lrc = wait_for_completion_interruptible_timeout(&context.completion, |
| 4772 | msecs_to_jiffies(WLAN_WAIT_TIME_STATS)); |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4773 | if (lrc <= 0) |
| 4774 | { |
| 4775 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4776 | "%s: SME %s while retrieving statistics", |
| 4777 | __func__, (0 == lrc) ? "timeout" : "interrupt"); |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 4778 | vstatus = VOS_STATUS_E_TIMEOUT; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4779 | } |
| 4780 | } |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4781 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 4782 | /* either we never sent a request, we sent a request and received a |
| 4783 | response or we sent a request and timed out. if we never sent a |
| 4784 | request or if we sent a request and got a response, we want to |
| 4785 | clear the magic out of paranoia. if we timed out there is a |
| 4786 | race condition such that the callback function could be |
| 4787 | executing at the same time we are. of primary concern is if the |
| 4788 | callback function had already verified the "magic" but had not |
| 4789 | yet set the completion variable when a timeout occurred. we |
| 4790 | serialize these activities by invalidating the magic while |
| 4791 | holding a shared spinlock which will cause us to block if the |
| 4792 | callback is currently executing */ |
| 4793 | spin_lock(&hdd_context_lock); |
| 4794 | context.magic = 0; |
| 4795 | spin_unlock(&hdd_context_lock); |
| 4796 | |
| 4797 | if (VOS_STATUS_SUCCESS == vstatus) |
| 4798 | { |
| 4799 | pTsmMetrics->UplinkPktQueueDly = pAdapter->tsmStats.UplinkPktQueueDly; |
| 4800 | vos_mem_copy(pTsmMetrics->UplinkPktQueueDlyHist, |
| 4801 | pAdapter->tsmStats.UplinkPktQueueDlyHist, |
| 4802 | sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist)/ |
| 4803 | sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist[0])); |
| 4804 | pTsmMetrics->UplinkPktTxDly = pAdapter->tsmStats.UplinkPktTxDly; |
| 4805 | pTsmMetrics->UplinkPktLoss = pAdapter->tsmStats.UplinkPktLoss; |
| 4806 | pTsmMetrics->UplinkPktCount = pAdapter->tsmStats.UplinkPktCount; |
| 4807 | pTsmMetrics->RoamingCount = pAdapter->tsmStats.RoamingCount; |
| 4808 | pTsmMetrics->RoamingDly = pAdapter->tsmStats.RoamingDly; |
| 4809 | } |
| 4810 | return vstatus; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4811 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4812 | #endif /*FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */ |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 4813 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4814 | #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] | 4815 | void hdd_getBand_helper(hdd_context_t *pHddCtx, int *pBand) |
| 4816 | { |
| 4817 | eCsrBand band = -1; |
| 4818 | sme_GetFreqBand((tHalHandle)(pHddCtx->hHal), &band); |
| 4819 | switch (band) |
| 4820 | { |
| 4821 | case eCSR_BAND_ALL: |
| 4822 | *pBand = WLAN_HDD_UI_BAND_AUTO; |
| 4823 | break; |
| 4824 | |
| 4825 | case eCSR_BAND_24: |
| 4826 | *pBand = WLAN_HDD_UI_BAND_2_4_GHZ; |
| 4827 | break; |
| 4828 | |
| 4829 | case eCSR_BAND_5G: |
| 4830 | *pBand = WLAN_HDD_UI_BAND_5_GHZ; |
| 4831 | break; |
| 4832 | |
| 4833 | default: |
| 4834 | hddLog( VOS_TRACE_LEVEL_WARN, "%s: Invalid Band %d", __func__, band); |
| 4835 | *pBand = -1; |
| 4836 | break; |
| 4837 | } |
| 4838 | } |
| 4839 | |
| 4840 | /**--------------------------------------------------------------------------- |
| 4841 | |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4842 | \brief hdd_parse_send_action_frame_data() - HDD Parse send action frame data |
| 4843 | |
| 4844 | This function parses the send action frame data passed in the format |
| 4845 | SENDACTIONFRAME<space><bssid><space><channel><space><dwelltime><space><data> |
| 4846 | |
Srinivas Girigowda | 5607685 | 2013-08-20 14:00:50 -0700 | [diff] [blame] | 4847 | \param - pValue Pointer to input data |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4848 | \param - pTargetApBssid Pointer to target Ap bssid |
| 4849 | \param - pChannel Pointer to the Target AP channel |
| 4850 | \param - pDwellTime Pointer to the time to stay off-channel after transmitting action frame |
| 4851 | \param - pBuf Pointer to data |
| 4852 | \param - pBufLen Pointer to data length |
| 4853 | |
| 4854 | \return - 0 for success non-zero for failure |
| 4855 | |
| 4856 | --------------------------------------------------------------------------*/ |
| 4857 | VOS_STATUS hdd_parse_send_action_frame_data(tANI_U8 *pValue, tANI_U8 *pTargetApBssid, tANI_U8 *pChannel, |
| 4858 | tANI_U8 *pDwellTime, tANI_U8 **pBuf, tANI_U8 *pBufLen) |
| 4859 | { |
| 4860 | tANI_U8 *inPtr = pValue; |
| 4861 | tANI_U8 *dataEnd; |
| 4862 | int tempInt; |
| 4863 | int j = 0; |
| 4864 | int i = 0; |
| 4865 | int v = 0; |
| 4866 | tANI_U8 tempBuf[32]; |
| 4867 | tANI_U8 tempByte = 0; |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 4868 | /* 12 hexa decimal digits, 5 ':' and '\0' */ |
| 4869 | tANI_U8 macAddress[18]; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4870 | |
| 4871 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 4872 | /*no argument after the command*/ |
| 4873 | if (NULL == inPtr) |
| 4874 | { |
| 4875 | return -EINVAL; |
| 4876 | } |
| 4877 | |
| 4878 | /*no space after the command*/ |
| 4879 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 4880 | { |
| 4881 | return -EINVAL; |
| 4882 | } |
| 4883 | |
| 4884 | /*removing empty spaces*/ |
| 4885 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 4886 | |
| 4887 | /*no argument followed by spaces*/ |
| 4888 | if ('\0' == *inPtr) |
| 4889 | { |
| 4890 | return -EINVAL; |
| 4891 | } |
| 4892 | |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4893 | v = sscanf(inPtr, "%17s", macAddress); |
| 4894 | if (!((1 == v) && hdd_is_valid_mac_address(macAddress))) |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4895 | { |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4896 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4897 | "Invalid MAC address or All hex inputs are not read (%d)", v); |
| 4898 | return -EINVAL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4899 | } |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4900 | |
| 4901 | pTargetApBssid[0] = hdd_parse_hex(macAddress[0]) << 4 | hdd_parse_hex(macAddress[1]); |
| 4902 | pTargetApBssid[1] = hdd_parse_hex(macAddress[3]) << 4 | hdd_parse_hex(macAddress[4]); |
| 4903 | pTargetApBssid[2] = hdd_parse_hex(macAddress[6]) << 4 | hdd_parse_hex(macAddress[7]); |
| 4904 | pTargetApBssid[3] = hdd_parse_hex(macAddress[9]) << 4 | hdd_parse_hex(macAddress[10]); |
| 4905 | pTargetApBssid[4] = hdd_parse_hex(macAddress[12]) << 4 | hdd_parse_hex(macAddress[13]); |
| 4906 | 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] | 4907 | |
| 4908 | /* point to the next argument */ |
| 4909 | inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE); |
| 4910 | /*no argument after the command*/ |
| 4911 | if (NULL == inPtr) return -EINVAL; |
| 4912 | |
| 4913 | /*removing empty spaces*/ |
| 4914 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 4915 | |
| 4916 | /*no argument followed by spaces*/ |
| 4917 | if ('\0' == *inPtr) |
| 4918 | { |
| 4919 | return -EINVAL; |
| 4920 | } |
| 4921 | |
| 4922 | /*getting the next argument ie the channel number */ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 4923 | v = sscanf(inPtr, "%31s ", tempBuf); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4924 | if (1 != v) return -EINVAL; |
| 4925 | |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4926 | v = kstrtos32(tempBuf, 10, &tempInt); |
Agarwal Ashish | 353b3a8 | 2014-04-08 14:55:11 +0530 | [diff] [blame] | 4927 | if ( v < 0 || tempInt <= 0 || tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX ) |
Kiet Lam | be150c2 | 2013-11-21 16:30:32 +0530 | [diff] [blame] | 4928 | return -EINVAL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4929 | |
| 4930 | *pChannel = tempInt; |
| 4931 | |
| 4932 | /* point to the next argument */ |
| 4933 | inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE); |
| 4934 | /*no argument after the command*/ |
| 4935 | if (NULL == inPtr) return -EINVAL; |
| 4936 | /*removing empty spaces*/ |
| 4937 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 4938 | |
| 4939 | /*no argument followed by spaces*/ |
| 4940 | if ('\0' == *inPtr) |
| 4941 | { |
| 4942 | return -EINVAL; |
| 4943 | } |
| 4944 | |
| 4945 | /*getting the next argument ie the dwell time */ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 4946 | v = sscanf(inPtr, "%31s ", tempBuf); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 4947 | if (1 != v) return -EINVAL; |
| 4948 | |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4949 | v = kstrtos32(tempBuf, 10, &tempInt); |
Srinivas Girigowda | 5a6e067 | 2014-01-09 14:42:57 -0800 | [diff] [blame] | 4950 | if ( v < 0 || tempInt < 0) return -EINVAL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4951 | |
| 4952 | *pDwellTime = tempInt; |
| 4953 | |
| 4954 | /* point to the next argument */ |
| 4955 | inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE); |
| 4956 | /*no argument after the command*/ |
| 4957 | if (NULL == inPtr) return -EINVAL; |
| 4958 | /*removing empty spaces*/ |
| 4959 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 4960 | |
| 4961 | /*no argument followed by spaces*/ |
| 4962 | if ('\0' == *inPtr) |
| 4963 | { |
| 4964 | return -EINVAL; |
| 4965 | } |
| 4966 | |
| 4967 | /* find the length of data */ |
| 4968 | dataEnd = inPtr; |
| 4969 | while(('\0' != *dataEnd) ) |
| 4970 | { |
| 4971 | dataEnd++; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4972 | } |
Kiet Lam | be150c2 | 2013-11-21 16:30:32 +0530 | [diff] [blame] | 4973 | *pBufLen = dataEnd - inPtr ; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4974 | if ( *pBufLen <= 0) return -EINVAL; |
| 4975 | |
Srinivas Girigowda | b5ae85d | 2013-06-03 10:51:45 -0700 | [diff] [blame] | 4976 | /* Allocate the number of bytes based on the number of input characters |
| 4977 | whether it is even or odd. |
| 4978 | if the number of input characters are even, then we need N/2 byte. |
| 4979 | if the number of input characters are odd, then we need do (N+1)/2 to |
| 4980 | compensate rounding off. |
| 4981 | For example, if N = 18, then (18 + 1)/2 = 9 bytes are enough. |
| 4982 | If N = 19, then we need 10 bytes, hence (19 + 1)/2 = 10 bytes */ |
| 4983 | *pBuf = vos_mem_malloc((*pBufLen + 1)/2); |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4984 | if (NULL == *pBuf) |
| 4985 | { |
| 4986 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 4987 | "%s: vos_mem_alloc failed ", __func__); |
| 4988 | return -EINVAL; |
| 4989 | } |
| 4990 | |
| 4991 | /* the buffer received from the upper layer is character buffer, |
| 4992 | we need to prepare the buffer taking 2 characters in to a U8 hex decimal number |
| 4993 | for example 7f0000f0...form a buffer to contain 7f in 0th location, 00 in 1st |
| 4994 | and f0 in 3rd location */ |
| 4995 | for (i = 0, j = 0; j < *pBufLen; j += 2) |
| 4996 | { |
Kiet Lam | be150c2 | 2013-11-21 16:30:32 +0530 | [diff] [blame] | 4997 | if( j+1 == *pBufLen) |
| 4998 | { |
| 4999 | tempByte = hdd_parse_hex(inPtr[j]); |
| 5000 | } |
| 5001 | else |
| 5002 | { |
| 5003 | tempByte = (hdd_parse_hex(inPtr[j]) << 4) | (hdd_parse_hex(inPtr[j + 1])); |
| 5004 | } |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 5005 | (*pBuf)[i++] = tempByte; |
| 5006 | } |
| 5007 | *pBufLen = i; |
| 5008 | return VOS_STATUS_SUCCESS; |
| 5009 | } |
| 5010 | |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 5011 | /**--------------------------------------------------------------------------- |
| 5012 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 5013 | \brief hdd_parse_channellist() - HDD Parse channel list |
| 5014 | |
| 5015 | This function parses the channel list passed in the format |
| 5016 | 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] | 5017 | if the Number of channels (N) does not match with the actual number of channels passed |
| 5018 | then take the minimum of N and count of (Ch1, Ch2, ...Ch M) |
| 5019 | For example, if SETROAMSCANCHANNELS 3 36 40 44 48, only 36, 40 and 44 shall be taken. |
| 5020 | If SETROAMSCANCHANNELS 5 36 40 44 48, ignore 5 and take 36, 40, 44 and 48. |
| 5021 | 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] | 5022 | |
| 5023 | \param - pValue Pointer to input channel list |
| 5024 | \param - ChannelList Pointer to local output array to record channel list |
| 5025 | \param - pNumChannels Pointer to number of roam scan channels |
| 5026 | |
| 5027 | \return - 0 for success non-zero for failure |
| 5028 | |
| 5029 | --------------------------------------------------------------------------*/ |
| 5030 | VOS_STATUS hdd_parse_channellist(tANI_U8 *pValue, tANI_U8 *pChannelList, tANI_U8 *pNumChannels) |
| 5031 | { |
| 5032 | tANI_U8 *inPtr = pValue; |
| 5033 | int tempInt; |
| 5034 | int j = 0; |
| 5035 | int v = 0; |
| 5036 | char buf[32]; |
| 5037 | |
| 5038 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 5039 | /*no argument after the command*/ |
| 5040 | if (NULL == inPtr) |
| 5041 | { |
| 5042 | return -EINVAL; |
| 5043 | } |
| 5044 | |
| 5045 | /*no space after the command*/ |
| 5046 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 5047 | { |
| 5048 | return -EINVAL; |
| 5049 | } |
| 5050 | |
| 5051 | /*removing empty spaces*/ |
Jeff Johnson | a1f9afb | 2013-04-03 09:13:31 -0700 | [diff] [blame] | 5052 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 5053 | |
| 5054 | /*no argument followed by spaces*/ |
| 5055 | if ('\0' == *inPtr) |
| 5056 | { |
| 5057 | return -EINVAL; |
| 5058 | } |
| 5059 | |
| 5060 | /*getting the first argument ie the number of channels*/ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 5061 | v = sscanf(inPtr, "%31s ", buf); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 5062 | if (1 != v) return -EINVAL; |
| 5063 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 5064 | v = kstrtos32(buf, 10, &tempInt); |
Jeff Johnson | a1f9afb | 2013-04-03 09:13:31 -0700 | [diff] [blame] | 5065 | if ((v < 0) || |
| 5066 | (tempInt <= 0) || |
| 5067 | (tempInt > WNI_CFG_VALID_CHANNEL_LIST_LEN)) |
| 5068 | { |
| 5069 | return -EINVAL; |
| 5070 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 5071 | |
| 5072 | *pNumChannels = tempInt; |
| 5073 | |
| 5074 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
| 5075 | "Number of channels are: %d", *pNumChannels); |
| 5076 | |
| 5077 | for (j = 0; j < (*pNumChannels); j++) |
| 5078 | { |
| 5079 | /*inPtr pointing to the beginning of first space after number of channels*/ |
| 5080 | inPtr = strpbrk( inPtr, " " ); |
| 5081 | /*no channel list after the number of channels argument*/ |
| 5082 | if (NULL == inPtr) |
| 5083 | { |
Srinivas Girigowda | cf9a9b4 | 2013-03-21 11:55:24 -0700 | [diff] [blame] | 5084 | if (0 != j) |
| 5085 | { |
| 5086 | *pNumChannels = j; |
| 5087 | return VOS_STATUS_SUCCESS; |
| 5088 | } |
| 5089 | else |
| 5090 | { |
| 5091 | return -EINVAL; |
| 5092 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 5093 | } |
| 5094 | |
| 5095 | /*removing empty space*/ |
Jeff Johnson | a1f9afb | 2013-04-03 09:13:31 -0700 | [diff] [blame] | 5096 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 5097 | |
| 5098 | /*no channel list after the number of channels argument and spaces*/ |
| 5099 | if ( '\0' == *inPtr ) |
| 5100 | { |
Srinivas Girigowda | cf9a9b4 | 2013-03-21 11:55:24 -0700 | [diff] [blame] | 5101 | if (0 != j) |
| 5102 | { |
| 5103 | *pNumChannels = j; |
| 5104 | return VOS_STATUS_SUCCESS; |
| 5105 | } |
| 5106 | else |
| 5107 | { |
| 5108 | return -EINVAL; |
| 5109 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 5110 | } |
| 5111 | |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 5112 | v = sscanf(inPtr, "%31s ", buf); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 5113 | if (1 != v) return -EINVAL; |
| 5114 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 5115 | v = kstrtos32(buf, 10, &tempInt); |
Jeff Johnson | a1f9afb | 2013-04-03 09:13:31 -0700 | [diff] [blame] | 5116 | if ((v < 0) || |
| 5117 | (tempInt <= 0) || |
| 5118 | (tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX)) |
| 5119 | { |
| 5120 | return -EINVAL; |
| 5121 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 5122 | pChannelList[j] = tempInt; |
| 5123 | |
| 5124 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
| 5125 | "Channel %d added to preferred channel list", |
| 5126 | pChannelList[j] ); |
| 5127 | } |
| 5128 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 5129 | return VOS_STATUS_SUCCESS; |
| 5130 | } |
| 5131 | |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 5132 | |
| 5133 | /**--------------------------------------------------------------------------- |
| 5134 | |
| 5135 | \brief hdd_parse_reassoc_command_data() - HDD Parse reassoc command data |
| 5136 | |
| 5137 | This function parses the reasoc command data passed in the format |
| 5138 | REASSOC<space><bssid><space><channel> |
| 5139 | |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 5140 | \param - pValue Pointer to input data (its a NUL terminated string) |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 5141 | \param - pTargetApBssid Pointer to target Ap bssid |
| 5142 | \param - pChannel Pointer to the Target AP channel |
| 5143 | |
| 5144 | \return - 0 for success non-zero for failure |
| 5145 | |
| 5146 | --------------------------------------------------------------------------*/ |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 5147 | VOS_STATUS hdd_parse_reassoc_command_data(tANI_U8 *pValue, |
| 5148 | tANI_U8 *pTargetApBssid, tANI_U8 *pChannel) |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 5149 | { |
| 5150 | tANI_U8 *inPtr = pValue; |
| 5151 | int tempInt; |
| 5152 | int v = 0; |
| 5153 | tANI_U8 tempBuf[32]; |
Kiet Lam | aa8e15a | 2014-02-11 23:30:06 -0800 | [diff] [blame] | 5154 | /* 12 hexa decimal digits, 5 ':' and '\0' */ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 5155 | tANI_U8 macAddress[18]; |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 5156 | |
| 5157 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 5158 | /*no argument after the command*/ |
| 5159 | if (NULL == inPtr) |
| 5160 | { |
| 5161 | return -EINVAL; |
| 5162 | } |
| 5163 | |
| 5164 | /*no space after the command*/ |
| 5165 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 5166 | { |
| 5167 | return -EINVAL; |
| 5168 | } |
| 5169 | |
| 5170 | /*removing empty spaces*/ |
| 5171 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 5172 | |
| 5173 | /*no argument followed by spaces*/ |
| 5174 | if ('\0' == *inPtr) |
| 5175 | { |
| 5176 | return -EINVAL; |
| 5177 | } |
| 5178 | |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 5179 | v = sscanf(inPtr, "%17s", macAddress); |
| 5180 | if (!((1 == v) && hdd_is_valid_mac_address(macAddress))) |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 5181 | { |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 5182 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5183 | "Invalid MAC address or All hex inputs are not read (%d)", v); |
| 5184 | return -EINVAL; |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 5185 | } |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 5186 | |
| 5187 | pTargetApBssid[0] = hdd_parse_hex(macAddress[0]) << 4 | hdd_parse_hex(macAddress[1]); |
| 5188 | pTargetApBssid[1] = hdd_parse_hex(macAddress[3]) << 4 | hdd_parse_hex(macAddress[4]); |
| 5189 | pTargetApBssid[2] = hdd_parse_hex(macAddress[6]) << 4 | hdd_parse_hex(macAddress[7]); |
| 5190 | pTargetApBssid[3] = hdd_parse_hex(macAddress[9]) << 4 | hdd_parse_hex(macAddress[10]); |
| 5191 | pTargetApBssid[4] = hdd_parse_hex(macAddress[12]) << 4 | hdd_parse_hex(macAddress[13]); |
| 5192 | 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] | 5193 | |
| 5194 | /* point to the next argument */ |
| 5195 | inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE); |
| 5196 | /*no argument after the command*/ |
| 5197 | if (NULL == inPtr) return -EINVAL; |
| 5198 | |
| 5199 | /*removing empty spaces*/ |
| 5200 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 5201 | |
| 5202 | /*no argument followed by spaces*/ |
| 5203 | if ('\0' == *inPtr) |
| 5204 | { |
| 5205 | return -EINVAL; |
| 5206 | } |
| 5207 | |
| 5208 | /*getting the next argument ie the channel number */ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 5209 | v = sscanf(inPtr, "%31s ", tempBuf); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 5210 | if (1 != v) return -EINVAL; |
| 5211 | |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 5212 | v = kstrtos32(tempBuf, 10, &tempInt); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 5213 | if ((v < 0) || |
Padma, Santhosh Kumar | 0fa809b | 2014-11-13 14:56:56 +0530 | [diff] [blame] | 5214 | (tempInt < 0) || |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 5215 | (tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX)) |
| 5216 | { |
| 5217 | return -EINVAL; |
| 5218 | } |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 5219 | |
| 5220 | *pChannel = tempInt; |
| 5221 | return VOS_STATUS_SUCCESS; |
| 5222 | } |
| 5223 | |
| 5224 | #endif |
| 5225 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 5226 | #if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD) |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 5227 | /**--------------------------------------------------------------------------- |
| 5228 | |
| 5229 | \brief hdd_parse_get_cckm_ie() - HDD Parse and fetch the CCKM IE |
| 5230 | |
| 5231 | This function parses the SETCCKM IE command |
| 5232 | SETCCKMIE<space><ie data> |
| 5233 | |
| 5234 | \param - pValue Pointer to input data |
| 5235 | \param - pCckmIe Pointer to output cckm Ie |
| 5236 | \param - pCckmIeLen Pointer to output cckm ie length |
| 5237 | |
| 5238 | \return - 0 for success non-zero for failure |
| 5239 | |
| 5240 | --------------------------------------------------------------------------*/ |
| 5241 | VOS_STATUS hdd_parse_get_cckm_ie(tANI_U8 *pValue, tANI_U8 **pCckmIe, |
| 5242 | tANI_U8 *pCckmIeLen) |
| 5243 | { |
| 5244 | tANI_U8 *inPtr = pValue; |
| 5245 | tANI_U8 *dataEnd; |
| 5246 | int j = 0; |
| 5247 | int i = 0; |
| 5248 | tANI_U8 tempByte = 0; |
| 5249 | |
| 5250 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 5251 | /*no argument after the command*/ |
| 5252 | if (NULL == inPtr) |
| 5253 | { |
| 5254 | return -EINVAL; |
| 5255 | } |
| 5256 | |
| 5257 | /*no space after the command*/ |
| 5258 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 5259 | { |
| 5260 | return -EINVAL; |
| 5261 | } |
| 5262 | |
| 5263 | /*removing empty spaces*/ |
| 5264 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 5265 | |
| 5266 | /*no argument followed by spaces*/ |
| 5267 | if ('\0' == *inPtr) |
| 5268 | { |
| 5269 | return -EINVAL; |
| 5270 | } |
| 5271 | |
| 5272 | /* find the length of data */ |
| 5273 | dataEnd = inPtr; |
| 5274 | while(('\0' != *dataEnd) ) |
| 5275 | { |
| 5276 | dataEnd++; |
| 5277 | ++(*pCckmIeLen); |
| 5278 | } |
| 5279 | if ( *pCckmIeLen <= 0) return -EINVAL; |
| 5280 | |
| 5281 | /* Allocate the number of bytes based on the number of input characters |
| 5282 | whether it is even or odd. |
| 5283 | if the number of input characters are even, then we need N/2 byte. |
| 5284 | if the number of input characters are odd, then we need do (N+1)/2 to |
| 5285 | compensate rounding off. |
| 5286 | For example, if N = 18, then (18 + 1)/2 = 9 bytes are enough. |
| 5287 | If N = 19, then we need 10 bytes, hence (19 + 1)/2 = 10 bytes */ |
| 5288 | *pCckmIe = vos_mem_malloc((*pCckmIeLen + 1)/2); |
| 5289 | if (NULL == *pCckmIe) |
| 5290 | { |
| 5291 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 5292 | "%s: vos_mem_alloc failed ", __func__); |
| 5293 | return -EINVAL; |
| 5294 | } |
| 5295 | vos_mem_zero(*pCckmIe, (*pCckmIeLen + 1)/2); |
| 5296 | /* the buffer received from the upper layer is character buffer, |
| 5297 | we need to prepare the buffer taking 2 characters in to a U8 hex decimal number |
| 5298 | for example 7f0000f0...form a buffer to contain 7f in 0th location, 00 in 1st |
| 5299 | and f0 in 3rd location */ |
| 5300 | for (i = 0, j = 0; j < *pCckmIeLen; j += 2) |
| 5301 | { |
| 5302 | tempByte = (hdd_parse_hex(inPtr[j]) << 4) | (hdd_parse_hex(inPtr[j + 1])); |
| 5303 | (*pCckmIe)[i++] = tempByte; |
| 5304 | } |
| 5305 | *pCckmIeLen = i; |
| 5306 | |
| 5307 | return VOS_STATUS_SUCCESS; |
| 5308 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 5309 | #endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */ |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 5310 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5311 | /**--------------------------------------------------------------------------- |
| 5312 | |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 5313 | \brief hdd_is_valid_mac_address() - Validate MAC address |
| 5314 | |
| 5315 | This function validates whether the given MAC address is valid or not |
| 5316 | Expected MAC address is of the format XX:XX:XX:XX:XX:XX |
| 5317 | where X is the hexa decimal digit character and separated by ':' |
| 5318 | This algorithm works even if MAC address is not separated by ':' |
| 5319 | |
| 5320 | This code checks given input string mac contains exactly 12 hexadecimal digits. |
| 5321 | and a separator colon : appears in the input string only after |
| 5322 | an even number of hex digits. |
| 5323 | |
| 5324 | \param - pMacAddr pointer to the input MAC address |
| 5325 | \return - 1 for valid and 0 for invalid |
| 5326 | |
| 5327 | --------------------------------------------------------------------------*/ |
| 5328 | |
| 5329 | v_BOOL_t hdd_is_valid_mac_address(const tANI_U8 *pMacAddr) |
| 5330 | { |
| 5331 | int xdigit = 0; |
| 5332 | int separator = 0; |
| 5333 | while (*pMacAddr) |
| 5334 | { |
| 5335 | if (isxdigit(*pMacAddr)) |
| 5336 | { |
| 5337 | xdigit++; |
| 5338 | } |
| 5339 | else if (':' == *pMacAddr) |
| 5340 | { |
| 5341 | if (0 == xdigit || ((xdigit / 2) - 1) != separator) |
| 5342 | break; |
| 5343 | |
| 5344 | ++separator; |
| 5345 | } |
| 5346 | else |
| 5347 | { |
| 5348 | separator = -1; |
| 5349 | /* Invalid MAC found */ |
| 5350 | return 0; |
| 5351 | } |
| 5352 | ++pMacAddr; |
| 5353 | } |
| 5354 | return (xdigit == 12 && (separator == 5 || separator == 0)); |
| 5355 | } |
| 5356 | |
| 5357 | /**--------------------------------------------------------------------------- |
| 5358 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 5359 | \brief __hdd_open() - HDD Open function |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5360 | |
| 5361 | \param - dev Pointer to net_device structure |
| 5362 | |
| 5363 | \return - 0 for success non-zero for failure |
| 5364 | |
| 5365 | --------------------------------------------------------------------------*/ |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 5366 | int __hdd_open(struct net_device *dev) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5367 | { |
| 5368 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5369 | hdd_context_t *pHddCtx; |
| 5370 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 5371 | VOS_STATUS status; |
| 5372 | v_BOOL_t in_standby = TRUE; |
| 5373 | |
| 5374 | if (NULL == pAdapter) |
| 5375 | { |
| 5376 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Agarwal Ashish | 971c288 | 2013-10-30 20:11:12 +0530 | [diff] [blame] | 5377 | "%s: pAdapter is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5378 | return -ENODEV; |
| 5379 | } |
| 5380 | |
| 5381 | pHddCtx = (hdd_context_t*)pAdapter->pHddCtx; |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 5382 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_OPEN_REQUEST, |
| 5383 | pAdapter->sessionId, pAdapter->device_mode)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5384 | if (NULL == pHddCtx) |
| 5385 | { |
| 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 context is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5388 | return -ENODEV; |
| 5389 | } |
| 5390 | |
| 5391 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 5392 | while ( (NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status) ) |
| 5393 | { |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 5394 | if (test_bit(DEVICE_IFACE_OPENED, &pAdapterNode->pAdapter->event_flags)) |
| 5395 | { |
| 5396 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: chip already out of standby", |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 5397 | __func__); |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 5398 | in_standby = FALSE; |
| 5399 | break; |
| 5400 | } |
| 5401 | else |
| 5402 | { |
| 5403 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 5404 | pAdapterNode = pNext; |
| 5405 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5406 | } |
| 5407 | |
| 5408 | if (TRUE == in_standby) |
| 5409 | { |
| 5410 | if (VOS_STATUS_SUCCESS != wlan_hdd_exit_lowpower(pHddCtx, pAdapter)) |
| 5411 | { |
| 5412 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failed to bring " |
| 5413 | "wlan out of power save", __func__); |
| 5414 | return -EINVAL; |
| 5415 | } |
| 5416 | } |
| 5417 | |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 5418 | set_bit(DEVICE_IFACE_OPENED, &pAdapter->event_flags); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5419 | if (hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) |
| 5420 | { |
| 5421 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 5422 | "%s: Enabling Tx Queues", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5423 | /* Enable TX queues only when we are connected */ |
Padma, Santhosh Kumar | 9dacb5c | 2014-12-17 19:22:56 +0530 | [diff] [blame] | 5424 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5425 | netif_tx_start_all_queues(dev); |
| 5426 | } |
| 5427 | |
| 5428 | return 0; |
| 5429 | } |
| 5430 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 5431 | /**--------------------------------------------------------------------------- |
| 5432 | |
| 5433 | \brief hdd_open() - Wrapper function for __hdd_open to protect it from SSR |
| 5434 | |
| 5435 | This is called in response to ifconfig up |
| 5436 | |
| 5437 | \param - dev Pointer to net_device structure |
| 5438 | |
| 5439 | \return - 0 for success non-zero for failure |
| 5440 | |
| 5441 | --------------------------------------------------------------------------*/ |
| 5442 | int hdd_open(struct net_device *dev) |
| 5443 | { |
| 5444 | int ret; |
| 5445 | |
| 5446 | vos_ssr_protect(__func__); |
| 5447 | ret = __hdd_open(dev); |
| 5448 | vos_ssr_unprotect(__func__); |
| 5449 | |
| 5450 | return ret; |
| 5451 | } |
| 5452 | |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 5453 | int __hdd_mon_open (struct net_device *dev) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5454 | { |
| 5455 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5456 | |
| 5457 | if(pAdapter == NULL) { |
| 5458 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 5459 | "%s: HDD adapter context is Null", __func__); |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 5460 | return -EINVAL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5461 | } |
| 5462 | |
| 5463 | netif_start_queue(dev); |
| 5464 | |
| 5465 | return 0; |
| 5466 | } |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 5467 | |
| 5468 | int hdd_mon_open (struct net_device *dev) |
| 5469 | { |
| 5470 | int ret; |
| 5471 | |
| 5472 | vos_ssr_protect(__func__); |
| 5473 | ret = __hdd_mon_open(dev); |
| 5474 | vos_ssr_unprotect(__func__); |
| 5475 | |
| 5476 | return ret; |
| 5477 | } |
| 5478 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5479 | /**--------------------------------------------------------------------------- |
| 5480 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 5481 | \brief __hdd_stop() - HDD stop function |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5482 | |
| 5483 | \param - dev Pointer to net_device structure |
| 5484 | |
| 5485 | \return - 0 for success non-zero for failure |
| 5486 | |
| 5487 | --------------------------------------------------------------------------*/ |
| 5488 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 5489 | int __hdd_stop (struct net_device *dev) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5490 | { |
Vinay Krishna Eranna | 90f4353 | 2014-10-27 16:45:54 +0530 | [diff] [blame] | 5491 | int ret = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5492 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5493 | hdd_context_t *pHddCtx; |
| 5494 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 5495 | VOS_STATUS status; |
| 5496 | v_BOOL_t enter_standby = TRUE; |
| 5497 | |
| 5498 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5499 | if (NULL == pAdapter) |
| 5500 | { |
| 5501 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Agarwal Ashish | 971c288 | 2013-10-30 20:11:12 +0530 | [diff] [blame] | 5502 | "%s: pAdapter is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5503 | return -ENODEV; |
| 5504 | } |
Sachin Ahuja | 9b4958f | 2015-01-15 21:37:00 +0530 | [diff] [blame] | 5505 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_STOP_REQUEST, |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 5506 | pAdapter->sessionId, pAdapter->device_mode)); |
Vinay Krishna Eranna | 90f4353 | 2014-10-27 16:45:54 +0530 | [diff] [blame] | 5507 | |
| 5508 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 5509 | ret = wlan_hdd_validate_context(pHddCtx); |
| 5510 | if (ret) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5511 | { |
Vinay Krishna Eranna | 90f4353 | 2014-10-27 16:45:54 +0530 | [diff] [blame] | 5512 | return ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5513 | } |
| 5514 | |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 5515 | /* Nothing to be done if the interface is not opened */ |
| 5516 | if (VOS_FALSE == test_bit(DEVICE_IFACE_OPENED, &pAdapter->event_flags)) |
| 5517 | { |
| 5518 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5519 | "%s: NETDEV Interface is not OPENED", __func__); |
| 5520 | return -ENODEV; |
| 5521 | } |
| 5522 | |
| 5523 | /* Make sure the interface is marked as closed */ |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 5524 | clear_bit(DEVICE_IFACE_OPENED, &pAdapter->event_flags); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5525 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disabling OS Tx queues", __func__); |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 5526 | |
| 5527 | /* Disable TX on the interface, after this hard_start_xmit() will not |
| 5528 | * be called on that interface |
| 5529 | */ |
Padma, Santhosh Kumar | 9dacb5c | 2014-12-17 19:22:56 +0530 | [diff] [blame] | 5530 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5531 | netif_tx_disable(pAdapter->dev); |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 5532 | |
| 5533 | /* Mark the interface status as "down" for outside world */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5534 | netif_carrier_off(pAdapter->dev); |
| 5535 | |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 5536 | /* The interface is marked as down for outside world (aka kernel) |
| 5537 | * But the driver is pretty much alive inside. The driver needs to |
| 5538 | * tear down the existing connection on the netdev (session) |
| 5539 | * cleanup the data pipes and wait until the control plane is stabilized |
| 5540 | * for this interface. The call also needs to wait until the above |
| 5541 | * mentioned actions are completed before returning to the caller. |
| 5542 | * Notice that the hdd_stop_adapter is requested not to close the session |
| 5543 | * That is intentional to be able to scan if it is a STA/P2P interface |
| 5544 | */ |
| 5545 | hdd_stop_adapter(pHddCtx, pAdapter, VOS_FALSE); |
Mahesh A Saptasagar | 02e36e8 | 2015-01-14 20:39:19 +0530 | [diff] [blame] | 5546 | #ifdef FEATURE_WLAN_TDLS |
| 5547 | mutex_lock(&pHddCtx->tdls_lock); |
| 5548 | #endif |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 5549 | /* DeInit the adapter. This ensures datapath cleanup as well */ |
c_hpothu | 002231a | 2015-02-05 14:58:51 +0530 | [diff] [blame] | 5550 | hdd_deinit_adapter(pHddCtx, pAdapter, TRUE); |
Mahesh A Saptasagar | 02e36e8 | 2015-01-14 20:39:19 +0530 | [diff] [blame] | 5551 | #ifdef FEATURE_WLAN_TDLS |
| 5552 | mutex_unlock(&pHddCtx->tdls_lock); |
| 5553 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5554 | /* SoftAP ifaces should never go in power save mode |
| 5555 | making sure same here. */ |
| 5556 | if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode ) |
| 5557 | || (WLAN_HDD_MONITOR == pAdapter->device_mode ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5558 | || (WLAN_HDD_P2P_GO == pAdapter->device_mode ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5559 | ) |
| 5560 | { |
| 5561 | /* SoftAP mode, so return from here */ |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 5562 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5563 | "%s: In SAP MODE", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5564 | EXIT(); |
| 5565 | return 0; |
| 5566 | } |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 5567 | /* Find if any iface is up. If any iface is up then can't put device to |
| 5568 | * sleep/power save mode |
| 5569 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5570 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 5571 | while ( (NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status) ) |
| 5572 | { |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 5573 | if (test_bit(DEVICE_IFACE_OPENED, &pAdapterNode->pAdapter->event_flags)) |
| 5574 | { |
| 5575 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Still other ifaces are up cannot " |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 5576 | "put device to sleep", __func__); |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 5577 | enter_standby = FALSE; |
| 5578 | break; |
| 5579 | } |
| 5580 | else |
| 5581 | { |
| 5582 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 5583 | pAdapterNode = pNext; |
| 5584 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5585 | } |
| 5586 | |
| 5587 | if (TRUE == enter_standby) |
| 5588 | { |
| 5589 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: All Interfaces are Down " |
| 5590 | "entering standby", __func__); |
| 5591 | if (VOS_STATUS_SUCCESS != wlan_hdd_enter_lowpower(pHddCtx)) |
| 5592 | { |
| 5593 | /*log and return success*/ |
| 5594 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failed to put " |
| 5595 | "wlan in power save", __func__); |
| 5596 | } |
| 5597 | } |
| 5598 | |
| 5599 | EXIT(); |
| 5600 | return 0; |
| 5601 | } |
| 5602 | |
| 5603 | /**--------------------------------------------------------------------------- |
| 5604 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 5605 | \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] | 5606 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 5607 | This is called in response to ifconfig down |
| 5608 | |
| 5609 | \param - dev Pointer to net_device structure |
| 5610 | |
| 5611 | \return - 0 for success non-zero for failure |
| 5612 | -----------------------------------------------------------------------------*/ |
| 5613 | int hdd_stop (struct net_device *dev) |
| 5614 | { |
| 5615 | int ret; |
| 5616 | |
| 5617 | vos_ssr_protect(__func__); |
| 5618 | ret = __hdd_stop(dev); |
| 5619 | vos_ssr_unprotect(__func__); |
| 5620 | |
| 5621 | return ret; |
| 5622 | } |
| 5623 | |
| 5624 | /**--------------------------------------------------------------------------- |
| 5625 | |
| 5626 | \brief __hdd_uninit() - HDD uninit function |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5627 | |
| 5628 | \param - dev Pointer to net_device structure |
| 5629 | |
| 5630 | \return - void |
| 5631 | |
| 5632 | --------------------------------------------------------------------------*/ |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 5633 | static void __hdd_uninit (struct net_device *dev) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5634 | { |
| 5635 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Mahesh A Saptasagar | 02e36e8 | 2015-01-14 20:39:19 +0530 | [diff] [blame] | 5636 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5637 | ENTER(); |
| 5638 | |
| 5639 | do |
| 5640 | { |
| 5641 | if (NULL == pAdapter) |
| 5642 | { |
| 5643 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 5644 | "%s: NULL pAdapter", __func__); |
| 5645 | break; |
| 5646 | } |
| 5647 | |
| 5648 | if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) |
| 5649 | { |
| 5650 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 5651 | "%s: Invalid magic", __func__); |
| 5652 | break; |
| 5653 | } |
Mahesh A Saptasagar | 02e36e8 | 2015-01-14 20:39:19 +0530 | [diff] [blame] | 5654 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 5655 | if (NULL == pHddCtx) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5656 | { |
| 5657 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 5658 | "%s: NULL pHddCtx", __func__); |
| 5659 | break; |
| 5660 | } |
| 5661 | |
| 5662 | if (dev != pAdapter->dev) |
| 5663 | { |
| 5664 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 5665 | "%s: Invalid device reference", __func__); |
| 5666 | /* we haven't validated all cases so let this go for now */ |
| 5667 | } |
Mahesh A Saptasagar | 02e36e8 | 2015-01-14 20:39:19 +0530 | [diff] [blame] | 5668 | #ifdef FEATURE_WLAN_TDLS |
| 5669 | mutex_lock(&pHddCtx->tdls_lock); |
| 5670 | #endif |
c_hpothu | 002231a | 2015-02-05 14:58:51 +0530 | [diff] [blame] | 5671 | hdd_deinit_adapter(pHddCtx, pAdapter, TRUE); |
Mahesh A Saptasagar | 02e36e8 | 2015-01-14 20:39:19 +0530 | [diff] [blame] | 5672 | #ifdef FEATURE_WLAN_TDLS |
| 5673 | mutex_unlock(&pHddCtx->tdls_lock); |
| 5674 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5675 | |
| 5676 | /* after uninit our adapter structure will no longer be valid */ |
| 5677 | pAdapter->dev = NULL; |
| 5678 | pAdapter->magic = 0; |
| 5679 | } while (0); |
| 5680 | |
| 5681 | EXIT(); |
| 5682 | } |
| 5683 | |
| 5684 | /**--------------------------------------------------------------------------- |
| 5685 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 5686 | \brief hdd_uninit() - Wrapper function to protect __hdd_uninit from SSR |
| 5687 | |
| 5688 | This is called during the netdev unregister to uninitialize all data |
| 5689 | associated with the device |
| 5690 | |
| 5691 | \param - dev Pointer to net_device structure |
| 5692 | |
| 5693 | \return - void |
| 5694 | |
| 5695 | --------------------------------------------------------------------------*/ |
| 5696 | static void hdd_uninit (struct net_device *dev) |
| 5697 | { |
| 5698 | vos_ssr_protect(__func__); |
| 5699 | __hdd_uninit(dev); |
| 5700 | vos_ssr_unprotect(__func__); |
| 5701 | } |
| 5702 | |
| 5703 | /**--------------------------------------------------------------------------- |
| 5704 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5705 | \brief hdd_release_firmware() - |
| 5706 | |
| 5707 | This function calls the release firmware API to free the firmware buffer. |
| 5708 | |
| 5709 | \param - pFileName Pointer to the File Name. |
| 5710 | pCtx - Pointer to the adapter . |
| 5711 | |
| 5712 | |
| 5713 | \return - 0 for success, non zero for failure |
| 5714 | |
| 5715 | --------------------------------------------------------------------------*/ |
| 5716 | |
| 5717 | VOS_STATUS hdd_release_firmware(char *pFileName,v_VOID_t *pCtx) |
| 5718 | { |
| 5719 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 5720 | hdd_context_t *pHddCtx = (hdd_context_t*)pCtx; |
| 5721 | ENTER(); |
| 5722 | |
| 5723 | |
| 5724 | if (!strcmp(WLAN_FW_FILE, pFileName)) { |
| 5725 | |
| 5726 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"%s: Loaded firmware file is %s",__func__,pFileName); |
| 5727 | |
| 5728 | if(pHddCtx->fw) { |
| 5729 | release_firmware(pHddCtx->fw); |
| 5730 | pHddCtx->fw = NULL; |
| 5731 | } |
| 5732 | else |
| 5733 | status = VOS_STATUS_E_FAILURE; |
| 5734 | } |
| 5735 | else if (!strcmp(WLAN_NV_FILE,pFileName)) { |
| 5736 | if(pHddCtx->nv) { |
| 5737 | release_firmware(pHddCtx->nv); |
| 5738 | pHddCtx->nv = NULL; |
| 5739 | } |
| 5740 | else |
| 5741 | status = VOS_STATUS_E_FAILURE; |
| 5742 | |
| 5743 | } |
| 5744 | |
| 5745 | EXIT(); |
| 5746 | return status; |
| 5747 | } |
| 5748 | |
| 5749 | /**--------------------------------------------------------------------------- |
| 5750 | |
| 5751 | \brief hdd_request_firmware() - |
| 5752 | |
| 5753 | This function reads the firmware file using the request firmware |
| 5754 | API and returns the the firmware data and the firmware file size. |
| 5755 | |
| 5756 | \param - pfileName - Pointer to the file name. |
| 5757 | - pCtx - Pointer to the adapter . |
| 5758 | - ppfw_data - Pointer to the pointer of the firmware data. |
| 5759 | - pSize - Pointer to the file size. |
| 5760 | |
| 5761 | \return - VOS_STATUS_SUCCESS for success, VOS_STATUS_E_FAILURE for failure |
| 5762 | |
| 5763 | --------------------------------------------------------------------------*/ |
| 5764 | |
| 5765 | |
| 5766 | VOS_STATUS hdd_request_firmware(char *pfileName,v_VOID_t *pCtx,v_VOID_t **ppfw_data, v_SIZE_t *pSize) |
| 5767 | { |
| 5768 | int status; |
| 5769 | VOS_STATUS retval = VOS_STATUS_SUCCESS; |
| 5770 | hdd_context_t *pHddCtx = (hdd_context_t*)pCtx; |
| 5771 | ENTER(); |
| 5772 | |
| 5773 | if( (!strcmp(WLAN_FW_FILE, pfileName)) ) { |
| 5774 | |
| 5775 | status = request_firmware(&pHddCtx->fw, pfileName, pHddCtx->parent_dev); |
| 5776 | |
| 5777 | if(status || !pHddCtx->fw || !pHddCtx->fw->data) { |
| 5778 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Firmware %s download failed", |
| 5779 | __func__, pfileName); |
| 5780 | retval = VOS_STATUS_E_FAILURE; |
| 5781 | } |
| 5782 | |
| 5783 | else { |
| 5784 | *ppfw_data = (v_VOID_t *)pHddCtx->fw->data; |
| 5785 | *pSize = pHddCtx->fw->size; |
| 5786 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Firmware size = %d", |
| 5787 | __func__, *pSize); |
| 5788 | } |
| 5789 | } |
| 5790 | else if(!strcmp(WLAN_NV_FILE, pfileName)) { |
| 5791 | |
| 5792 | status = request_firmware(&pHddCtx->nv, pfileName, pHddCtx->parent_dev); |
| 5793 | |
| 5794 | if(status || !pHddCtx->nv || !pHddCtx->nv->data) { |
| 5795 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: nv %s download failed", |
| 5796 | __func__, pfileName); |
| 5797 | retval = VOS_STATUS_E_FAILURE; |
| 5798 | } |
| 5799 | |
| 5800 | else { |
| 5801 | *ppfw_data = (v_VOID_t *)pHddCtx->nv->data; |
| 5802 | *pSize = pHddCtx->nv->size; |
| 5803 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: nv file size = %d", |
| 5804 | __func__, *pSize); |
| 5805 | } |
| 5806 | } |
| 5807 | |
| 5808 | EXIT(); |
| 5809 | return retval; |
| 5810 | } |
| 5811 | /**--------------------------------------------------------------------------- |
| 5812 | \brief hdd_full_pwr_cbk() - HDD full power callbackfunction |
| 5813 | |
| 5814 | This is the function invoked by SME to inform the result of a full power |
| 5815 | request issued by HDD |
| 5816 | |
| 5817 | \param - callbackcontext - Pointer to cookie |
| 5818 | status - result of request |
| 5819 | |
| 5820 | \return - None |
| 5821 | |
| 5822 | --------------------------------------------------------------------------*/ |
| 5823 | void hdd_full_pwr_cbk(void *callbackContext, eHalStatus status) |
| 5824 | { |
| 5825 | hdd_context_t *pHddCtx = (hdd_context_t*)callbackContext; |
| 5826 | |
Madan Mohan Koyyalamudi | 8bdd311 | 2012-09-24 13:55:14 -0700 | [diff] [blame] | 5827 | 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] | 5828 | if(&pHddCtx->full_pwr_comp_var) |
| 5829 | { |
| 5830 | complete(&pHddCtx->full_pwr_comp_var); |
| 5831 | } |
| 5832 | } |
| 5833 | |
| 5834 | /**--------------------------------------------------------------------------- |
| 5835 | |
| 5836 | \brief hdd_req_bmps_cbk() - HDD Request BMPS callback function |
| 5837 | |
| 5838 | This is the function invoked by SME to inform the result of BMPS |
| 5839 | request issued by HDD |
| 5840 | |
| 5841 | \param - callbackcontext - Pointer to cookie |
| 5842 | status - result of request |
| 5843 | |
| 5844 | \return - None |
| 5845 | |
| 5846 | --------------------------------------------------------------------------*/ |
| 5847 | void hdd_req_bmps_cbk(void *callbackContext, eHalStatus status) |
| 5848 | { |
| 5849 | |
| 5850 | struct completion *completion_var = (struct completion*) callbackContext; |
| 5851 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 5852 | hddLog(VOS_TRACE_LEVEL_ERROR, "HDD BMPS request Callback, status = %d", status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5853 | if(completion_var != NULL) |
| 5854 | { |
| 5855 | complete(completion_var); |
| 5856 | } |
| 5857 | } |
| 5858 | |
| 5859 | /**--------------------------------------------------------------------------- |
| 5860 | |
| 5861 | \brief hdd_get_cfg_file_size() - |
| 5862 | |
| 5863 | This function reads the configuration file using the request firmware |
| 5864 | API and returns the configuration file size. |
| 5865 | |
| 5866 | \param - pCtx - Pointer to the adapter . |
| 5867 | - pFileName - Pointer to the file name. |
| 5868 | - pBufSize - Pointer to the buffer size. |
| 5869 | |
| 5870 | \return - 0 for success, non zero for failure |
| 5871 | |
| 5872 | --------------------------------------------------------------------------*/ |
| 5873 | |
| 5874 | VOS_STATUS hdd_get_cfg_file_size(v_VOID_t *pCtx, char *pFileName, v_SIZE_t *pBufSize) |
| 5875 | { |
| 5876 | int status; |
| 5877 | hdd_context_t *pHddCtx = (hdd_context_t*)pCtx; |
| 5878 | |
| 5879 | ENTER(); |
| 5880 | |
| 5881 | status = request_firmware(&pHddCtx->fw, pFileName, pHddCtx->parent_dev); |
| 5882 | |
| 5883 | if(status || !pHddCtx->fw || !pHddCtx->fw->data) { |
| 5884 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: CFG download failed",__func__); |
| 5885 | status = VOS_STATUS_E_FAILURE; |
| 5886 | } |
| 5887 | else { |
| 5888 | *pBufSize = pHddCtx->fw->size; |
| 5889 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: CFG size = %d", __func__, *pBufSize); |
| 5890 | release_firmware(pHddCtx->fw); |
| 5891 | pHddCtx->fw = NULL; |
| 5892 | } |
| 5893 | |
| 5894 | EXIT(); |
| 5895 | return VOS_STATUS_SUCCESS; |
| 5896 | } |
| 5897 | |
| 5898 | /**--------------------------------------------------------------------------- |
| 5899 | |
| 5900 | \brief hdd_read_cfg_file() - |
| 5901 | |
| 5902 | This function reads the configuration file using the request firmware |
| 5903 | API and returns the cfg data and the buffer size of the configuration file. |
| 5904 | |
| 5905 | \param - pCtx - Pointer to the adapter . |
| 5906 | - pFileName - Pointer to the file name. |
| 5907 | - pBuffer - Pointer to the data buffer. |
| 5908 | - pBufSize - Pointer to the buffer size. |
| 5909 | |
| 5910 | \return - 0 for success, non zero for failure |
| 5911 | |
| 5912 | --------------------------------------------------------------------------*/ |
| 5913 | |
| 5914 | VOS_STATUS hdd_read_cfg_file(v_VOID_t *pCtx, char *pFileName, |
| 5915 | v_VOID_t *pBuffer, v_SIZE_t *pBufSize) |
| 5916 | { |
| 5917 | int status; |
| 5918 | hdd_context_t *pHddCtx = (hdd_context_t*)pCtx; |
| 5919 | |
| 5920 | ENTER(); |
| 5921 | |
| 5922 | status = request_firmware(&pHddCtx->fw, pFileName, pHddCtx->parent_dev); |
| 5923 | |
| 5924 | if(status || !pHddCtx->fw || !pHddCtx->fw->data) { |
| 5925 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: CFG download failed",__func__); |
| 5926 | return VOS_STATUS_E_FAILURE; |
| 5927 | } |
| 5928 | else { |
| 5929 | if(*pBufSize != pHddCtx->fw->size) { |
| 5930 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Caller sets invalid CFG " |
| 5931 | "file size", __func__); |
| 5932 | release_firmware(pHddCtx->fw); |
| 5933 | pHddCtx->fw = NULL; |
| 5934 | return VOS_STATUS_E_FAILURE; |
| 5935 | } |
| 5936 | else { |
| 5937 | if(pBuffer) { |
| 5938 | vos_mem_copy(pBuffer,pHddCtx->fw->data,*pBufSize); |
| 5939 | } |
| 5940 | release_firmware(pHddCtx->fw); |
| 5941 | pHddCtx->fw = NULL; |
| 5942 | } |
| 5943 | } |
| 5944 | |
| 5945 | EXIT(); |
| 5946 | |
| 5947 | return VOS_STATUS_SUCCESS; |
| 5948 | } |
| 5949 | |
| 5950 | /**--------------------------------------------------------------------------- |
| 5951 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 5952 | \brief __hdd_set_mac_address() - |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5953 | |
| 5954 | This function sets the user specified mac address using |
| 5955 | the command ifconfig wlanX hw ether <mac adress>. |
| 5956 | |
| 5957 | \param - dev - Pointer to the net device. |
| 5958 | - addr - Pointer to the sockaddr. |
| 5959 | \return - 0 for success, non zero for failure |
| 5960 | |
| 5961 | --------------------------------------------------------------------------*/ |
| 5962 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 5963 | static int __hdd_set_mac_address(struct net_device *dev, void *addr) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5964 | { |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 5965 | hdd_adapter_t *pAdapter; |
| 5966 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5967 | struct sockaddr *psta_mac_addr = addr; |
| 5968 | eHalStatus halStatus = eHAL_STATUS_SUCCESS; |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 5969 | int ret = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5970 | |
| 5971 | ENTER(); |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 5972 | pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5973 | if (NULL == pAdapter) |
| 5974 | { |
| 5975 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5976 | "%s: Adapter is NULL",__func__); |
| 5977 | return -EINVAL; |
| 5978 | } |
| 5979 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 5980 | ret = wlan_hdd_validate_context(pHddCtx); |
| 5981 | if (0 != ret) |
| 5982 | { |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 5983 | return ret; |
| 5984 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5985 | |
| 5986 | memcpy(&pAdapter->macAddressCurrent, psta_mac_addr->sa_data, ETH_ALEN); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5987 | memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN); |
| 5988 | |
| 5989 | EXIT(); |
| 5990 | return halStatus; |
| 5991 | } |
| 5992 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 5993 | /**--------------------------------------------------------------------------- |
| 5994 | |
| 5995 | \brief hdd_set_mac_address() - |
| 5996 | |
| 5997 | Wrapper function to protect __hdd_set_mac_address() function from ssr |
| 5998 | |
| 5999 | \param - dev - Pointer to the net device. |
| 6000 | - addr - Pointer to the sockaddr. |
| 6001 | \return - 0 for success, non zero for failure |
| 6002 | |
| 6003 | --------------------------------------------------------------------------*/ |
| 6004 | static int hdd_set_mac_address(struct net_device *dev, void *addr) |
| 6005 | { |
| 6006 | int ret; |
| 6007 | |
| 6008 | vos_ssr_protect(__func__); |
| 6009 | ret = __hdd_set_mac_address(dev, addr); |
| 6010 | vos_ssr_unprotect(__func__); |
| 6011 | |
| 6012 | return ret; |
| 6013 | } |
| 6014 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6015 | tANI_U8* wlan_hdd_get_intf_addr(hdd_context_t* pHddCtx) |
| 6016 | { |
| 6017 | int i; |
| 6018 | for ( i = 0; i < VOS_MAX_CONCURRENCY_PERSONA; i++) |
| 6019 | { |
Abhishek Singh | eb18378 | 2014-02-06 13:37:21 +0530 | [diff] [blame] | 6020 | if( 0 == ((pHddCtx->cfg_ini->intfAddrMask) & (1 << i)) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6021 | break; |
| 6022 | } |
| 6023 | |
| 6024 | if( VOS_MAX_CONCURRENCY_PERSONA == i) |
| 6025 | return NULL; |
| 6026 | |
| 6027 | pHddCtx->cfg_ini->intfAddrMask |= (1 << i); |
| 6028 | return &pHddCtx->cfg_ini->intfMacAddr[i].bytes[0]; |
| 6029 | } |
| 6030 | |
| 6031 | void wlan_hdd_release_intf_addr(hdd_context_t* pHddCtx, tANI_U8* releaseAddr) |
| 6032 | { |
| 6033 | int i; |
| 6034 | for ( i = 0; i < VOS_MAX_CONCURRENCY_PERSONA; i++) |
| 6035 | { |
| 6036 | if ( !memcmp(releaseAddr, &pHddCtx->cfg_ini->intfMacAddr[i].bytes[0], 6) ) |
| 6037 | { |
| 6038 | pHddCtx->cfg_ini->intfAddrMask &= ~(1 << i); |
| 6039 | break; |
| 6040 | } |
| 6041 | } |
| 6042 | return; |
| 6043 | } |
| 6044 | |
| 6045 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)) |
| 6046 | static struct net_device_ops wlan_drv_ops = { |
| 6047 | .ndo_open = hdd_open, |
| 6048 | .ndo_stop = hdd_stop, |
| 6049 | .ndo_uninit = hdd_uninit, |
| 6050 | .ndo_start_xmit = hdd_hard_start_xmit, |
| 6051 | .ndo_tx_timeout = hdd_tx_timeout, |
| 6052 | .ndo_get_stats = hdd_stats, |
| 6053 | .ndo_do_ioctl = hdd_ioctl, |
| 6054 | .ndo_set_mac_address = hdd_set_mac_address, |
| 6055 | .ndo_select_queue = hdd_select_queue, |
| 6056 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 6057 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(3,1,0)) |
| 6058 | .ndo_set_rx_mode = hdd_set_multicast_list, |
| 6059 | #else |
| 6060 | .ndo_set_multicast_list = hdd_set_multicast_list, |
| 6061 | #endif //LINUX_VERSION_CODE |
| 6062 | #endif |
| 6063 | }; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6064 | static struct net_device_ops wlan_mon_drv_ops = { |
| 6065 | .ndo_open = hdd_mon_open, |
| 6066 | .ndo_stop = hdd_stop, |
| 6067 | .ndo_uninit = hdd_uninit, |
| 6068 | .ndo_start_xmit = hdd_mon_hard_start_xmit, |
| 6069 | .ndo_tx_timeout = hdd_tx_timeout, |
| 6070 | .ndo_get_stats = hdd_stats, |
| 6071 | .ndo_do_ioctl = hdd_ioctl, |
| 6072 | .ndo_set_mac_address = hdd_set_mac_address, |
| 6073 | }; |
Mahesh A Saptasagar | 305e263 | 2015-03-04 12:57:33 +0530 | [diff] [blame] | 6074 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6075 | #endif |
| 6076 | |
| 6077 | void hdd_set_station_ops( struct net_device *pWlanDev ) |
| 6078 | { |
| 6079 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6080 | pWlanDev->netdev_ops = &wlan_drv_ops; |
| 6081 | #else |
| 6082 | pWlanDev->open = hdd_open; |
| 6083 | pWlanDev->stop = hdd_stop; |
| 6084 | pWlanDev->uninit = hdd_uninit; |
| 6085 | pWlanDev->hard_start_xmit = NULL; |
| 6086 | pWlanDev->tx_timeout = hdd_tx_timeout; |
| 6087 | pWlanDev->get_stats = hdd_stats; |
| 6088 | pWlanDev->do_ioctl = hdd_ioctl; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6089 | pWlanDev->set_mac_address = hdd_set_mac_address; |
| 6090 | #endif |
| 6091 | } |
| 6092 | |
Katya Nigam | 1fd2440 | 2015-02-16 14:52:19 +0530 | [diff] [blame] | 6093 | void hdd_set_ibss_ops( hdd_adapter_t *pAdapter ) |
| 6094 | { |
| 6095 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)) |
| 6096 | wlan_drv_ops.ndo_start_xmit = hdd_ibss_hard_start_xmit; |
| 6097 | #else |
| 6098 | pAdapter->dev->hard_start_xmit = hdd_ibss_hard_start_xmit; |
| 6099 | #endif |
| 6100 | } |
| 6101 | |
Jeff Johnson | eed415b | 2013-01-18 16:11:20 -0800 | [diff] [blame] | 6102 | 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] | 6103 | { |
| 6104 | struct net_device *pWlanDev = NULL; |
| 6105 | hdd_adapter_t *pAdapter = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6106 | /* |
| 6107 | * cfg80211 initialization and registration.... |
| 6108 | */ |
| 6109 | pWlanDev = alloc_netdev_mq(sizeof( hdd_adapter_t ), name, ether_setup, NUM_TX_QUEUES); |
| 6110 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6111 | if(pWlanDev != NULL) |
| 6112 | { |
| 6113 | |
| 6114 | //Save the pointer to the net_device in the HDD adapter |
| 6115 | pAdapter = (hdd_adapter_t*) netdev_priv( pWlanDev ); |
| 6116 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6117 | vos_mem_zero( pAdapter, sizeof( hdd_adapter_t ) ); |
| 6118 | |
| 6119 | pAdapter->dev = pWlanDev; |
| 6120 | pAdapter->pHddCtx = pHddCtx; |
| 6121 | pAdapter->magic = WLAN_HDD_ADAPTER_MAGIC; |
Agarwal Ashish | 47d1811 | 2014-08-04 19:55:07 +0530 | [diff] [blame] | 6122 | spin_lock_init(&pAdapter->lock_for_active_session); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6123 | |
| 6124 | init_completion(&pAdapter->session_open_comp_var); |
| 6125 | init_completion(&pAdapter->session_close_comp_var); |
| 6126 | init_completion(&pAdapter->disconnect_comp_var); |
| 6127 | init_completion(&pAdapter->linkup_event_var); |
| 6128 | init_completion(&pAdapter->cancel_rem_on_chan_var); |
| 6129 | init_completion(&pAdapter->rem_on_chan_ready_event); |
Vinay Krishna Eranna | f0e523b | 2014-03-01 21:00:16 +0530 | [diff] [blame] | 6130 | init_completion(&pAdapter->pno_comp_var); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6131 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 6132 | init_completion(&pAdapter->offchannel_tx_event); |
| 6133 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6134 | init_completion(&pAdapter->tx_action_cnf_event); |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 6135 | #ifdef FEATURE_WLAN_TDLS |
| 6136 | init_completion(&pAdapter->tdls_add_station_comp); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 6137 | init_completion(&pAdapter->tdls_del_station_comp); |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 6138 | init_completion(&pAdapter->tdls_mgmt_comp); |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 6139 | init_completion(&pAdapter->tdls_link_establish_req_comp); |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 6140 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6141 | init_completion(&pHddCtx->mc_sus_event_var); |
| 6142 | init_completion(&pHddCtx->tx_sus_event_var); |
Gopichand Nakkala | 0562141 | 2013-06-19 19:37:38 +0530 | [diff] [blame] | 6143 | init_completion(&pHddCtx->rx_sus_event_var); |
Jeff Johnson | 9efb9aa | 2013-03-15 13:59:27 -0700 | [diff] [blame] | 6144 | init_completion(&pAdapter->ula_complete); |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 6145 | init_completion(&pAdapter->change_country_code); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6146 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 6147 | #ifdef FEATURE_WLAN_BATCH_SCAN |
| 6148 | init_completion(&pAdapter->hdd_set_batch_scan_req_var); |
| 6149 | init_completion(&pAdapter->hdd_get_batch_scan_req_var); |
| 6150 | pAdapter->pBatchScanRsp = NULL; |
| 6151 | pAdapter->numScanList = 0; |
Rajeev Kumar | 20140c1 | 2013-10-21 19:39:02 -0700 | [diff] [blame] | 6152 | pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STOPPED; |
Kiet Lam | aa8e15a | 2014-02-11 23:30:06 -0800 | [diff] [blame] | 6153 | pAdapter->prev_batch_id = 0; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 6154 | mutex_init(&pAdapter->hdd_batch_scan_lock); |
| 6155 | #endif |
| 6156 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6157 | pAdapter->isLinkUpSvcNeeded = FALSE; |
| 6158 | pAdapter->higherDtimTransition = eANI_BOOLEAN_TRUE; |
| 6159 | //Init the net_device structure |
| 6160 | strlcpy(pWlanDev->name, name, IFNAMSIZ); |
| 6161 | |
| 6162 | vos_mem_copy(pWlanDev->dev_addr, (void *)macAddr, sizeof(tSirMacAddr)); |
| 6163 | vos_mem_copy( pAdapter->macAddressCurrent.bytes, macAddr, sizeof(tSirMacAddr)); |
| 6164 | pWlanDev->watchdog_timeo = HDD_TX_TIMEOUT; |
| 6165 | pWlanDev->hard_header_len += LIBRA_HW_NEEDED_HEADROOM; |
| 6166 | |
| 6167 | hdd_set_station_ops( pAdapter->dev ); |
| 6168 | |
| 6169 | pWlanDev->destructor = free_netdev; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6170 | pWlanDev->ieee80211_ptr = &pAdapter->wdev ; |
| 6171 | pAdapter->wdev.wiphy = pHddCtx->wiphy; |
| 6172 | pAdapter->wdev.netdev = pWlanDev; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6173 | /* set pWlanDev's parent to underlying device */ |
| 6174 | SET_NETDEV_DEV(pWlanDev, pHddCtx->parent_dev); |
Kumar Anand | 82c009f | 2014-05-29 00:29:42 -0700 | [diff] [blame] | 6175 | |
| 6176 | hdd_wmm_init( pAdapter ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6177 | } |
| 6178 | |
| 6179 | return pAdapter; |
| 6180 | } |
| 6181 | |
| 6182 | VOS_STATUS hdd_register_interface( hdd_adapter_t *pAdapter, tANI_U8 rtnl_lock_held ) |
| 6183 | { |
| 6184 | struct net_device *pWlanDev = pAdapter->dev; |
| 6185 | //hdd_station_ctx_t *pHddStaCtx = &pAdapter->sessionCtx.station; |
| 6186 | //hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
| 6187 | //eHalStatus halStatus = eHAL_STATUS_SUCCESS; |
| 6188 | |
| 6189 | if( rtnl_lock_held ) |
| 6190 | { |
Madan Mohan Koyyalamudi | d8ac866 | 2012-11-06 19:04:56 -0800 | [diff] [blame] | 6191 | if (strnchr(pWlanDev->name, strlen(pWlanDev->name), '%')) { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6192 | if( dev_alloc_name(pWlanDev, pWlanDev->name) < 0 ) |
| 6193 | { |
| 6194 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s:Failed:dev_alloc_name",__func__); |
| 6195 | return VOS_STATUS_E_FAILURE; |
| 6196 | } |
| 6197 | } |
| 6198 | if (register_netdevice(pWlanDev)) |
| 6199 | { |
| 6200 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s:Failed:register_netdev",__func__); |
| 6201 | return VOS_STATUS_E_FAILURE; |
| 6202 | } |
| 6203 | } |
| 6204 | else |
| 6205 | { |
| 6206 | if(register_netdev(pWlanDev)) |
| 6207 | { |
| 6208 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failed:register_netdev",__func__); |
| 6209 | return VOS_STATUS_E_FAILURE; |
| 6210 | } |
| 6211 | } |
| 6212 | set_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags); |
| 6213 | |
| 6214 | return VOS_STATUS_SUCCESS; |
| 6215 | } |
| 6216 | |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 6217 | static eHalStatus hdd_smeCloseSessionCallback(void *pContext) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6218 | { |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 6219 | hdd_adapter_t *pAdapter = pContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6220 | |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 6221 | if (NULL == pAdapter) |
| 6222 | { |
| 6223 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: NULL pAdapter", __func__); |
| 6224 | return eHAL_STATUS_INVALID_PARAMETER; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6225 | } |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 6226 | |
| 6227 | if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) |
| 6228 | { |
| 6229 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Invalid magic", __func__); |
| 6230 | return eHAL_STATUS_NOT_INITIALIZED; |
| 6231 | } |
| 6232 | |
| 6233 | clear_bit(SME_SESSION_OPENED, &pAdapter->event_flags); |
| 6234 | |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 6235 | #ifndef WLAN_OPEN_SOURCE |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 6236 | /* need to make sure all of our scheduled work has completed. |
| 6237 | * This callback is called from MC thread context, so it is safe to |
| 6238 | * to call below flush workqueue API from here. |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 6239 | * |
| 6240 | * Even though this is called from MC thread context, if there is a faulty |
| 6241 | * work item in the system, that can hang this call forever. So flushing |
| 6242 | * this global work queue is not safe; and now we make sure that |
| 6243 | * individual work queues are stopped correctly. But the cancel work queue |
| 6244 | * is a GPL only API, so the proprietary version of the driver would still |
| 6245 | * rely on the global work queue flush. |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 6246 | */ |
| 6247 | flush_scheduled_work(); |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 6248 | #endif |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 6249 | |
| 6250 | /* We can be blocked while waiting for scheduled work to be |
| 6251 | * flushed, and the adapter structure can potentially be freed, in |
| 6252 | * which case the magic will have been reset. So make sure the |
| 6253 | * magic is still good, and hence the adapter structure is still |
| 6254 | * valid, before signaling completion */ |
| 6255 | if (WLAN_HDD_ADAPTER_MAGIC == pAdapter->magic) |
| 6256 | { |
| 6257 | complete(&pAdapter->session_close_comp_var); |
| 6258 | } |
| 6259 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6260 | return eHAL_STATUS_SUCCESS; |
| 6261 | } |
| 6262 | |
| 6263 | VOS_STATUS hdd_init_station_mode( hdd_adapter_t *pAdapter ) |
| 6264 | { |
| 6265 | struct net_device *pWlanDev = pAdapter->dev; |
| 6266 | hdd_station_ctx_t *pHddStaCtx = &pAdapter->sessionCtx.station; |
| 6267 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
| 6268 | eHalStatus halStatus = eHAL_STATUS_SUCCESS; |
| 6269 | VOS_STATUS status = VOS_STATUS_E_FAILURE; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6270 | long rc = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6271 | |
| 6272 | INIT_COMPLETION(pAdapter->session_open_comp_var); |
Kiran Kumar Lokere | 0ad5cd3 | 2013-06-25 11:26:22 -0700 | [diff] [blame] | 6273 | sme_SetCurrDeviceMode(pHddCtx->hHal, pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6274 | //Open a SME session for future operation |
| 6275 | halStatus = sme_OpenSession( pHddCtx->hHal, hdd_smeRoamCallback, pAdapter, |
Kiran Kumar Lokere | 0ad5cd3 | 2013-06-25 11:26:22 -0700 | [diff] [blame] | 6276 | (tANI_U8 *)&pAdapter->macAddressCurrent, &pAdapter->sessionId); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6277 | if ( !HAL_STATUS_SUCCESS( halStatus ) ) |
| 6278 | { |
| 6279 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 6280 | "sme_OpenSession() failed with status code %08d [x%08x]", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6281 | halStatus, halStatus ); |
| 6282 | status = VOS_STATUS_E_FAILURE; |
| 6283 | goto error_sme_open; |
| 6284 | } |
| 6285 | |
| 6286 | //Block on a completion variable. Can't wait forever though. |
Vinay Krishna Eranna | 0fe2e7c | 2014-04-09 21:32:08 +0530 | [diff] [blame] | 6287 | rc = wait_for_completion_timeout( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6288 | &pAdapter->session_open_comp_var, |
| 6289 | msecs_to_jiffies(WLAN_WAIT_TIME_SESSIONOPENCLOSE)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6290 | if (rc <= 0) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6291 | { |
| 6292 | hddLog(VOS_TRACE_LEVEL_FATAL, |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6293 | "Session is not opened within timeout period code %ld", rc ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6294 | status = VOS_STATUS_E_FAILURE; |
| 6295 | goto error_sme_open; |
| 6296 | } |
| 6297 | |
| 6298 | // Register wireless extensions |
| 6299 | if( eHAL_STATUS_SUCCESS != (halStatus = hdd_register_wext(pWlanDev))) |
| 6300 | { |
| 6301 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 6302 | "hdd_register_wext() failed with status code %08d [x%08x]", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6303 | halStatus, halStatus ); |
| 6304 | status = VOS_STATUS_E_FAILURE; |
| 6305 | goto error_register_wext; |
| 6306 | } |
Katya Nigam | 1fd2440 | 2015-02-16 14:52:19 +0530 | [diff] [blame] | 6307 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6308 | //Safe to register the hard_start_xmit function again |
Katya Nigam | 1fd2440 | 2015-02-16 14:52:19 +0530 | [diff] [blame] | 6309 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)) |
| 6310 | wlan_drv_ops.ndo_start_xmit = hdd_hard_start_xmit; |
| 6311 | #else |
| 6312 | pWlanDev->hard_start_xmit = hdd_hard_start_xmit; |
| 6313 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6314 | |
| 6315 | //Set the Connection State to Not Connected |
Abhishek Singh | f4669da | 2014-05-26 15:07:49 +0530 | [diff] [blame] | 6316 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6317 | "%s: Set HDD connState to eConnectionState_NotConnected", |
| 6318 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6319 | pHddStaCtx->conn_info.connState = eConnectionState_NotConnected; |
| 6320 | |
| 6321 | //Set the default operation channel |
| 6322 | pHddStaCtx->conn_info.operationChannel = pHddCtx->cfg_ini->OperatingChannel; |
| 6323 | |
| 6324 | /* Make the default Auth Type as OPEN*/ |
| 6325 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 6326 | |
| 6327 | if( VOS_STATUS_SUCCESS != ( status = hdd_init_tx_rx( pAdapter ) ) ) |
| 6328 | { |
| 6329 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 6330 | "hdd_init_tx_rx() failed with status code %08d [x%08x]", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6331 | status, status ); |
| 6332 | goto error_init_txrx; |
| 6333 | } |
| 6334 | |
| 6335 | set_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags); |
| 6336 | |
| 6337 | if( VOS_STATUS_SUCCESS != ( status = hdd_wmm_adapter_init( pAdapter ) ) ) |
| 6338 | { |
| 6339 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 6340 | "hdd_wmm_adapter_init() failed with status code %08d [x%08x]", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6341 | status, status ); |
| 6342 | goto error_wmm_init; |
| 6343 | } |
| 6344 | |
| 6345 | set_bit(WMM_INIT_DONE, &pAdapter->event_flags); |
| 6346 | |
| 6347 | return VOS_STATUS_SUCCESS; |
| 6348 | |
| 6349 | error_wmm_init: |
| 6350 | clear_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags); |
| 6351 | hdd_deinit_tx_rx(pAdapter); |
| 6352 | error_init_txrx: |
| 6353 | hdd_UnregisterWext(pWlanDev); |
| 6354 | error_register_wext: |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 6355 | if (test_bit(SME_SESSION_OPENED, &pAdapter->event_flags)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6356 | { |
| 6357 | INIT_COMPLETION(pAdapter->session_close_comp_var); |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 6358 | if (eHAL_STATUS_SUCCESS == sme_CloseSession(pHddCtx->hHal, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6359 | pAdapter->sessionId, |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 6360 | hdd_smeCloseSessionCallback, pAdapter)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6361 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6362 | unsigned long rc; |
| 6363 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6364 | //Block on a completion variable. Can't wait forever though. |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6365 | rc = wait_for_completion_timeout( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6366 | &pAdapter->session_close_comp_var, |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 6367 | msecs_to_jiffies(WLAN_WAIT_TIME_SESSIONOPENCLOSE)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6368 | if (rc <= 0) |
| 6369 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6370 | FL("Session is not opened within timeout period code %ld"), rc); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6371 | } |
| 6372 | } |
| 6373 | error_sme_open: |
| 6374 | return status; |
| 6375 | } |
| 6376 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6377 | void hdd_cleanup_actionframe( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter ) |
| 6378 | { |
| 6379 | hdd_cfg80211_state_t *cfgState; |
| 6380 | |
| 6381 | cfgState = WLAN_HDD_GET_CFG_STATE_PTR( pAdapter ); |
| 6382 | |
| 6383 | if( NULL != cfgState->buf ) |
| 6384 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6385 | long rc; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6386 | INIT_COMPLETION(pAdapter->tx_action_cnf_event); |
| 6387 | rc = wait_for_completion_interruptible_timeout( |
| 6388 | &pAdapter->tx_action_cnf_event, |
| 6389 | msecs_to_jiffies(ACTION_FRAME_TX_TIMEOUT)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6390 | if (rc <= 0) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6391 | { |
Sudhir Sattayappa Kohalli | 8ee532d | 2013-02-15 13:16:26 -0800 | [diff] [blame] | 6392 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6393 | "%s ERROR: HDD Wait for Action Confirmation Failed!! %ld" |
| 6394 | , __func__, rc); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6395 | } |
| 6396 | } |
| 6397 | return; |
| 6398 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6399 | |
c_hpothu | 002231a | 2015-02-05 14:58:51 +0530 | [diff] [blame] | 6400 | 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] | 6401 | { |
| 6402 | ENTER(); |
| 6403 | switch ( pAdapter->device_mode ) |
| 6404 | { |
Katya Nigam | 1fd2440 | 2015-02-16 14:52:19 +0530 | [diff] [blame] | 6405 | case WLAN_HDD_IBSS: |
| 6406 | { |
| 6407 | if(test_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags)) |
| 6408 | { |
| 6409 | hdd_ibss_deinit_tx_rx( pAdapter ); |
| 6410 | clear_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags); |
| 6411 | } |
| 6412 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6413 | case WLAN_HDD_INFRA_STATION: |
| 6414 | case WLAN_HDD_P2P_CLIENT: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6415 | case WLAN_HDD_P2P_DEVICE: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6416 | { |
| 6417 | if(test_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags)) |
| 6418 | { |
| 6419 | hdd_deinit_tx_rx( pAdapter ); |
| 6420 | clear_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags); |
| 6421 | } |
| 6422 | |
| 6423 | if(test_bit(WMM_INIT_DONE, &pAdapter->event_flags)) |
| 6424 | { |
| 6425 | hdd_wmm_adapter_close( pAdapter ); |
| 6426 | clear_bit(WMM_INIT_DONE, &pAdapter->event_flags); |
| 6427 | } |
| 6428 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6429 | hdd_cleanup_actionframe(pHddCtx, pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6430 | break; |
| 6431 | } |
| 6432 | |
| 6433 | case WLAN_HDD_SOFTAP: |
| 6434 | case WLAN_HDD_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6435 | { |
Madan Mohan Koyyalamudi | 8c6dec8 | 2013-09-26 15:56:13 +0530 | [diff] [blame] | 6436 | |
| 6437 | if (test_bit(WMM_INIT_DONE, &pAdapter->event_flags)) |
| 6438 | { |
| 6439 | hdd_wmm_adapter_close( pAdapter ); |
| 6440 | clear_bit(WMM_INIT_DONE, &pAdapter->event_flags); |
| 6441 | } |
| 6442 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6443 | hdd_cleanup_actionframe(pHddCtx, pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6444 | |
c_hpothu | 002231a | 2015-02-05 14:58:51 +0530 | [diff] [blame] | 6445 | hdd_unregister_hostapd(pAdapter, rtnl_held); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6446 | hdd_set_conparam( 0 ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6447 | wlan_hdd_set_monitor_tx_adapter( WLAN_HDD_GET_CTX(pAdapter), NULL ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6448 | break; |
| 6449 | } |
| 6450 | |
| 6451 | case WLAN_HDD_MONITOR: |
| 6452 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6453 | hdd_adapter_t* pAdapterforTx = pAdapter->sessionCtx.monitor.pAdapterForTx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6454 | if(test_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags)) |
| 6455 | { |
| 6456 | hdd_deinit_tx_rx( pAdapter ); |
| 6457 | clear_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags); |
| 6458 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6459 | if(NULL != pAdapterforTx) |
| 6460 | { |
| 6461 | hdd_cleanup_actionframe(pHddCtx, pAdapterforTx); |
| 6462 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6463 | break; |
| 6464 | } |
| 6465 | |
| 6466 | |
| 6467 | default: |
| 6468 | break; |
| 6469 | } |
| 6470 | |
| 6471 | EXIT(); |
| 6472 | } |
| 6473 | |
| 6474 | void hdd_cleanup_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter, tANI_U8 rtnl_held ) |
| 6475 | { |
Mingcheng Zhu | 87f22fc | 2014-01-30 19:23:32 -0800 | [diff] [blame] | 6476 | struct net_device *pWlanDev = NULL; |
Srinivas, Dasari | 693dfc5 | 2013-12-27 17:29:09 +0530 | [diff] [blame] | 6477 | |
| 6478 | ENTER(); |
| 6479 | if (NULL == pAdapter) |
| 6480 | { |
| 6481 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6482 | "%s: HDD adapter is Null", __func__); |
| 6483 | return; |
| 6484 | } |
| 6485 | |
| 6486 | pWlanDev = pAdapter->dev; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6487 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 6488 | #ifdef FEATURE_WLAN_BATCH_SCAN |
Srinivas, Dasari | 693dfc5 | 2013-12-27 17:29:09 +0530 | [diff] [blame] | 6489 | if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
| 6490 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 6491 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Srinivas, Dasari | 693dfc5 | 2013-12-27 17:29:09 +0530 | [diff] [blame] | 6492 | || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE) |
| 6493 | ) |
| 6494 | { |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 6495 | if (pAdapter) |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 6496 | { |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 6497 | if (eHDD_BATCH_SCAN_STATE_STARTED == pAdapter->batchScanState) |
| 6498 | { |
| 6499 | hdd_deinit_batch_scan(pAdapter); |
| 6500 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 6501 | } |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 6502 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 6503 | #endif |
| 6504 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6505 | if(test_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags)) { |
| 6506 | if( rtnl_held ) |
| 6507 | { |
| 6508 | unregister_netdevice(pWlanDev); |
| 6509 | } |
| 6510 | else |
| 6511 | { |
| 6512 | unregister_netdev(pWlanDev); |
| 6513 | } |
| 6514 | // note that the pAdapter is no longer valid at this point |
| 6515 | // since the memory has been reclaimed |
| 6516 | } |
| 6517 | |
Srinivas, Dasari | 693dfc5 | 2013-12-27 17:29:09 +0530 | [diff] [blame] | 6518 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6519 | } |
| 6520 | |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 6521 | void hdd_set_pwrparams(hdd_context_t *pHddCtx) |
| 6522 | { |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 6523 | VOS_STATUS status; |
| 6524 | hdd_adapter_t *pAdapter = NULL; |
| 6525 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 6526 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 6527 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 6528 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 6529 | /*loop through all adapters.*/ |
| 6530 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 6531 | { |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 6532 | pAdapter = pAdapterNode->pAdapter; |
| 6533 | if ( (WLAN_HDD_INFRA_STATION != pAdapter->device_mode) |
| 6534 | && (WLAN_HDD_P2P_CLIENT != pAdapter->device_mode) ) |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 6535 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 6536 | { // we skip this registration for modes other than STA and P2P client modes. |
| 6537 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 6538 | pAdapterNode = pNext; |
| 6539 | continue; |
| 6540 | } |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 6541 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 6542 | //Apply Dynamic DTIM For P2P |
| 6543 | //Only if ignoreDynamicDtimInP2pMode is not set in ini |
| 6544 | if ((pHddCtx->cfg_ini->enableDynamicDTIM || |
| 6545 | pHddCtx->cfg_ini->enableModulatedDTIM) && |
| 6546 | ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
| 6547 | ((WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) && |
| 6548 | !(pHddCtx->cfg_ini->ignoreDynamicDtimInP2pMode))) && |
| 6549 | (eANI_BOOLEAN_TRUE == pAdapter->higherDtimTransition) && |
| 6550 | (eConnectionState_Associated == |
| 6551 | (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) && |
| 6552 | (pHddCtx->cfg_ini->fIsBmpsEnabled)) |
| 6553 | { |
| 6554 | tSirSetPowerParamsReq powerRequest = { 0 }; |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 6555 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 6556 | powerRequest.uIgnoreDTIM = 1; |
| 6557 | powerRequest.uMaxLIModulatedDTIM = pHddCtx->cfg_ini->fMaxLIModulatedDTIM; |
| 6558 | |
| 6559 | if (pHddCtx->cfg_ini->enableModulatedDTIM) |
| 6560 | { |
| 6561 | powerRequest.uDTIMPeriod = pHddCtx->cfg_ini->enableModulatedDTIM; |
| 6562 | powerRequest.uListenInterval = pHddCtx->hdd_actual_LI_value; |
| 6563 | } |
| 6564 | else |
| 6565 | { |
| 6566 | powerRequest.uListenInterval = pHddCtx->cfg_ini->enableDynamicDTIM; |
| 6567 | } |
| 6568 | |
| 6569 | /* Update ignoreDTIM and ListedInterval in CFG to remain at the DTIM |
| 6570 | * specified during Enter/Exit BMPS when LCD off*/ |
| 6571 | ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IGNORE_DTIM, powerRequest.uIgnoreDTIM, |
| 6572 | NULL, eANI_BOOLEAN_FALSE); |
| 6573 | ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_LISTEN_INTERVAL, powerRequest.uListenInterval, |
| 6574 | NULL, eANI_BOOLEAN_FALSE); |
| 6575 | |
| 6576 | /* switch to the DTIM specified in cfg.ini */ |
| 6577 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 6578 | "Switch to DTIM %d", powerRequest.uListenInterval); |
| 6579 | sme_SetPowerParams( pHddCtx->hHal, &powerRequest, TRUE); |
| 6580 | break; |
| 6581 | |
| 6582 | } |
| 6583 | |
| 6584 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 6585 | pAdapterNode = pNext; |
| 6586 | } |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 6587 | } |
| 6588 | |
| 6589 | void hdd_reset_pwrparams(hdd_context_t *pHddCtx) |
| 6590 | { |
| 6591 | /*Switch back to DTIM 1*/ |
| 6592 | tSirSetPowerParamsReq powerRequest = { 0 }; |
| 6593 | |
| 6594 | powerRequest.uIgnoreDTIM = pHddCtx->hdd_actual_ignore_DTIM_value; |
| 6595 | powerRequest.uListenInterval = pHddCtx->hdd_actual_LI_value; |
Yue Ma | c24062f | 2013-05-13 17:01:29 -0700 | [diff] [blame] | 6596 | powerRequest.uMaxLIModulatedDTIM = pHddCtx->cfg_ini->fMaxLIModulatedDTIM; |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 6597 | |
| 6598 | /* Update ignoreDTIM and ListedInterval in CFG with default values */ |
| 6599 | ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IGNORE_DTIM, powerRequest.uIgnoreDTIM, |
| 6600 | NULL, eANI_BOOLEAN_FALSE); |
| 6601 | ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_LISTEN_INTERVAL, powerRequest.uListenInterval, |
| 6602 | NULL, eANI_BOOLEAN_FALSE); |
| 6603 | |
| 6604 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 6605 | "Switch to DTIM%d",powerRequest.uListenInterval); |
| 6606 | sme_SetPowerParams( pHddCtx->hHal, &powerRequest, TRUE); |
| 6607 | |
| 6608 | } |
| 6609 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6610 | VOS_STATUS hdd_enable_bmps_imps(hdd_context_t *pHddCtx) |
| 6611 | { |
| 6612 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
Sushant Kaushik | 4928e54 | 2014-12-29 15:25:54 +0530 | [diff] [blame] | 6613 | if (WLAN_HDD_IS_UNLOAD_IN_PROGRESS(pHddCtx)) |
| 6614 | { |
| 6615 | hddLog( LOGE, FL("Wlan Unload in progress")); |
| 6616 | return VOS_STATUS_E_PERM; |
| 6617 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6618 | if(pHddCtx->cfg_ini->fIsBmpsEnabled) |
| 6619 | { |
| 6620 | sme_EnablePowerSave(pHddCtx->hHal, ePMC_BEACON_MODE_POWER_SAVE); |
| 6621 | } |
| 6622 | |
| 6623 | if(pHddCtx->cfg_ini->fIsAutoBmpsTimerEnabled) |
| 6624 | { |
| 6625 | sme_StartAutoBmpsTimer(pHddCtx->hHal); |
| 6626 | } |
| 6627 | |
| 6628 | if (pHddCtx->cfg_ini->fIsImpsEnabled) |
| 6629 | { |
| 6630 | sme_EnablePowerSave (pHddCtx->hHal, ePMC_IDLE_MODE_POWER_SAVE); |
| 6631 | } |
| 6632 | |
| 6633 | return status; |
| 6634 | } |
| 6635 | |
| 6636 | VOS_STATUS hdd_disable_bmps_imps(hdd_context_t *pHddCtx, tANI_U8 session_type) |
| 6637 | { |
| 6638 | hdd_adapter_t *pAdapter = NULL; |
| 6639 | eHalStatus halStatus; |
| 6640 | VOS_STATUS status = VOS_STATUS_E_INVAL; |
| 6641 | v_BOOL_t disableBmps = FALSE; |
| 6642 | v_BOOL_t disableImps = FALSE; |
| 6643 | |
| 6644 | switch(session_type) |
| 6645 | { |
| 6646 | case WLAN_HDD_INFRA_STATION: |
| 6647 | case WLAN_HDD_SOFTAP: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6648 | case WLAN_HDD_P2P_CLIENT: |
| 6649 | case WLAN_HDD_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6650 | //Exit BMPS -> Is Sta/P2P Client is already connected |
| 6651 | pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 6652 | if((NULL != pAdapter)&& |
| 6653 | hdd_connIsConnected( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) |
| 6654 | { |
| 6655 | disableBmps = TRUE; |
| 6656 | } |
| 6657 | |
| 6658 | pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT); |
| 6659 | if((NULL != pAdapter)&& |
| 6660 | hdd_connIsConnected( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) |
| 6661 | { |
| 6662 | disableBmps = TRUE; |
| 6663 | } |
| 6664 | |
| 6665 | //Exit both Bmps and Imps incase of Go/SAP Mode |
| 6666 | if((WLAN_HDD_SOFTAP == session_type) || |
| 6667 | (WLAN_HDD_P2P_GO == session_type)) |
| 6668 | { |
| 6669 | disableBmps = TRUE; |
| 6670 | disableImps = TRUE; |
| 6671 | } |
| 6672 | |
| 6673 | if(TRUE == disableImps) |
| 6674 | { |
| 6675 | if (pHddCtx->cfg_ini->fIsImpsEnabled) |
| 6676 | { |
| 6677 | sme_DisablePowerSave (pHddCtx->hHal, ePMC_IDLE_MODE_POWER_SAVE); |
| 6678 | } |
| 6679 | } |
| 6680 | |
| 6681 | if(TRUE == disableBmps) |
| 6682 | { |
| 6683 | if(pHddCtx->cfg_ini->fIsBmpsEnabled) |
| 6684 | { |
| 6685 | halStatus = sme_DisablePowerSave(pHddCtx->hHal, ePMC_BEACON_MODE_POWER_SAVE); |
| 6686 | |
| 6687 | if(eHAL_STATUS_SUCCESS != halStatus) |
| 6688 | { |
| 6689 | status = VOS_STATUS_E_FAILURE; |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6690 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Fail to Disable Power Save", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6691 | VOS_ASSERT(0); |
| 6692 | return status; |
| 6693 | } |
| 6694 | } |
| 6695 | |
| 6696 | if(pHddCtx->cfg_ini->fIsAutoBmpsTimerEnabled) |
| 6697 | { |
| 6698 | halStatus = sme_StopAutoBmpsTimer(pHddCtx->hHal); |
| 6699 | |
| 6700 | if(eHAL_STATUS_SUCCESS != halStatus) |
| 6701 | { |
| 6702 | status = VOS_STATUS_E_FAILURE; |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6703 | 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] | 6704 | VOS_ASSERT(0); |
| 6705 | return status; |
| 6706 | } |
| 6707 | } |
| 6708 | } |
| 6709 | |
| 6710 | if((TRUE == disableBmps) || |
| 6711 | (TRUE == disableImps)) |
| 6712 | { |
| 6713 | /* Now, get the chip into Full Power now */ |
| 6714 | INIT_COMPLETION(pHddCtx->full_pwr_comp_var); |
| 6715 | halStatus = sme_RequestFullPower(pHddCtx->hHal, hdd_full_pwr_cbk, |
| 6716 | pHddCtx, eSME_FULL_PWR_NEEDED_BY_HDD); |
| 6717 | |
| 6718 | if(halStatus != eHAL_STATUS_SUCCESS) |
| 6719 | { |
| 6720 | if(halStatus == eHAL_STATUS_PMC_PENDING) |
| 6721 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6722 | long ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6723 | //Block on a completion variable. Can't wait forever though |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6724 | ret = wait_for_completion_interruptible_timeout( |
| 6725 | &pHddCtx->full_pwr_comp_var, |
| 6726 | msecs_to_jiffies(1000)); |
| 6727 | if (ret <= 0) |
| 6728 | { |
| 6729 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6730 | "%s: wait on full_pwr_comp_var failed %ld", |
| 6731 | __func__, ret); |
| 6732 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6733 | } |
| 6734 | else |
| 6735 | { |
| 6736 | status = VOS_STATUS_E_FAILURE; |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6737 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Request for Full Power failed", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6738 | VOS_ASSERT(0); |
| 6739 | return status; |
| 6740 | } |
| 6741 | } |
| 6742 | |
| 6743 | status = VOS_STATUS_SUCCESS; |
| 6744 | } |
| 6745 | |
| 6746 | break; |
| 6747 | } |
| 6748 | return status; |
| 6749 | } |
| 6750 | |
| 6751 | 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] | 6752 | const char *iface_name, tSirMacAddr macAddr, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6753 | tANI_U8 rtnl_held ) |
| 6754 | { |
| 6755 | hdd_adapter_t *pAdapter = NULL; |
| 6756 | hdd_adapter_list_node_t *pHddAdapterNode = NULL; |
| 6757 | VOS_STATUS status = VOS_STATUS_E_FAILURE; |
| 6758 | VOS_STATUS exitbmpsStatus; |
| 6759 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6760 | 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] | 6761 | |
Nirav Shah | 436658f | 2014-02-28 17:05:45 +0530 | [diff] [blame] | 6762 | if(macAddr == NULL) |
| 6763 | { |
| 6764 | /* Not received valid macAddr */ |
| 6765 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6766 | "%s:Unable to add virtual intf: Not able to get" |
| 6767 | "valid mac address",__func__); |
| 6768 | return NULL; |
| 6769 | } |
| 6770 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6771 | //Disable BMPS incase of Concurrency |
| 6772 | exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx, session_type); |
| 6773 | |
| 6774 | if(VOS_STATUS_E_FAILURE == exitbmpsStatus) |
| 6775 | { |
| 6776 | //Fail to Exit BMPS |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6777 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Fail to Exit BMPS", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6778 | VOS_ASSERT(0); |
| 6779 | return NULL; |
| 6780 | } |
| 6781 | |
| 6782 | switch(session_type) |
| 6783 | { |
| 6784 | case WLAN_HDD_INFRA_STATION: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6785 | case WLAN_HDD_P2P_CLIENT: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6786 | case WLAN_HDD_P2P_DEVICE: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6787 | { |
| 6788 | pAdapter = hdd_alloc_station_adapter( pHddCtx, macAddr, iface_name ); |
| 6789 | |
| 6790 | if( NULL == pAdapter ) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6791 | { |
| 6792 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 6793 | FL("failed to allocate adapter for session %d"), session_type); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6794 | return NULL; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6795 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6796 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 6797 | #ifdef FEATURE_WLAN_TDLS |
| 6798 | /* A Mutex Lock is introduced while changing/initializing the mode to |
| 6799 | * protect the concurrent access for the Adapters by TDLS module. |
| 6800 | */ |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 6801 | mutex_lock(&pHddCtx->tdls_lock); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 6802 | #endif |
| 6803 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6804 | pAdapter->wdev.iftype = (session_type == WLAN_HDD_P2P_CLIENT) ? |
| 6805 | NL80211_IFTYPE_P2P_CLIENT: |
| 6806 | NL80211_IFTYPE_STATION; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6807 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6808 | pAdapter->device_mode = session_type; |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 6809 | #ifdef FEATURE_WLAN_TDLS |
| 6810 | mutex_unlock(&pHddCtx->tdls_lock); |
| 6811 | #endif |
Sunil Dutt | 66485cb | 2013-12-19 19:05:03 +0530 | [diff] [blame] | 6812 | |
| 6813 | status = hdd_init_station_mode( pAdapter ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6814 | if( VOS_STATUS_SUCCESS != status ) |
| 6815 | goto err_free_netdev; |
| 6816 | |
| 6817 | status = hdd_register_interface( pAdapter, rtnl_held ); |
| 6818 | if( VOS_STATUS_SUCCESS != status ) |
| 6819 | { |
Mahesh A Saptasagar | 02e36e8 | 2015-01-14 20:39:19 +0530 | [diff] [blame] | 6820 | #ifdef FEATURE_WLAN_TDLS |
| 6821 | mutex_lock(&pHddCtx->tdls_lock); |
| 6822 | #endif |
c_hpothu | 002231a | 2015-02-05 14:58:51 +0530 | [diff] [blame] | 6823 | hdd_deinit_adapter(pHddCtx, pAdapter, rtnl_held); |
Mahesh A Saptasagar | 02e36e8 | 2015-01-14 20:39:19 +0530 | [diff] [blame] | 6824 | #ifdef FEATURE_WLAN_TDLS |
| 6825 | mutex_unlock(&pHddCtx->tdls_lock); |
| 6826 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6827 | goto err_free_netdev; |
| 6828 | } |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 6829 | |
Vinay Krishna Eranna | 4d055d4 | 2013-12-17 17:02:01 +0530 | [diff] [blame] | 6830 | // Workqueue which gets scheduled in IPv4 notification callback. |
| 6831 | INIT_WORK(&pAdapter->ipv4NotifierWorkQueue, hdd_ipv4_notifier_work_queue); |
| 6832 | |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 6833 | #ifdef WLAN_NS_OFFLOAD |
| 6834 | // Workqueue which gets scheduled in IPv6 notification callback. |
| 6835 | INIT_WORK(&pAdapter->ipv6NotifierWorkQueue, hdd_ipv6_notifier_work_queue); |
| 6836 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6837 | //Stop the Interface TX queue. |
Padma, Santhosh Kumar | 9dacb5c | 2014-12-17 19:22:56 +0530 | [diff] [blame] | 6838 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6839 | netif_tx_disable(pAdapter->dev); |
| 6840 | //netif_tx_disable(pWlanDev); |
| 6841 | netif_carrier_off(pAdapter->dev); |
| 6842 | |
Ganesh Kondabattini | babfb49 | 2014-12-17 20:25:29 +0530 | [diff] [blame] | 6843 | if (WLAN_HDD_P2P_CLIENT == session_type || |
| 6844 | WLAN_HDD_P2P_DEVICE == session_type) |
| 6845 | { |
| 6846 | /* Initialize the work queue to defer the |
| 6847 | * back to back RoC request */ |
| 6848 | INIT_DELAYED_WORK(&pAdapter->roc_work, |
| 6849 | hdd_p2p_roc_work_queue); |
| 6850 | } |
| 6851 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6852 | break; |
| 6853 | } |
| 6854 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6855 | case WLAN_HDD_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6856 | case WLAN_HDD_SOFTAP: |
| 6857 | { |
| 6858 | pAdapter = hdd_wlan_create_ap_dev( pHddCtx, macAddr, (tANI_U8 *)iface_name ); |
| 6859 | if( NULL == pAdapter ) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6860 | { |
| 6861 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 6862 | FL("failed to allocate adapter for session %d"), session_type); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6863 | return NULL; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6864 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6865 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6866 | pAdapter->wdev.iftype = (session_type == WLAN_HDD_SOFTAP) ? |
| 6867 | NL80211_IFTYPE_AP: |
| 6868 | NL80211_IFTYPE_P2P_GO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6869 | pAdapter->device_mode = session_type; |
| 6870 | |
| 6871 | status = hdd_init_ap_mode(pAdapter); |
| 6872 | if( VOS_STATUS_SUCCESS != status ) |
| 6873 | goto err_free_netdev; |
| 6874 | |
| 6875 | status = hdd_register_hostapd( pAdapter, rtnl_held ); |
| 6876 | if( VOS_STATUS_SUCCESS != status ) |
| 6877 | { |
c_hpothu | 002231a | 2015-02-05 14:58:51 +0530 | [diff] [blame] | 6878 | hdd_deinit_adapter(pHddCtx, pAdapter, rtnl_held); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6879 | goto err_free_netdev; |
| 6880 | } |
Padma, Santhosh Kumar | 9dacb5c | 2014-12-17 19:22:56 +0530 | [diff] [blame] | 6881 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6882 | netif_tx_disable(pAdapter->dev); |
| 6883 | netif_carrier_off(pAdapter->dev); |
| 6884 | |
| 6885 | hdd_set_conparam( 1 ); |
Ganesh Kondabattini | babfb49 | 2014-12-17 20:25:29 +0530 | [diff] [blame] | 6886 | |
| 6887 | if (WLAN_HDD_P2P_GO == session_type) |
| 6888 | { |
| 6889 | /* Initialize the work queue to |
| 6890 | * defer the back to back RoC request */ |
| 6891 | INIT_DELAYED_WORK(&pAdapter->roc_work, |
| 6892 | hdd_p2p_roc_work_queue); |
| 6893 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6894 | break; |
| 6895 | } |
| 6896 | case WLAN_HDD_MONITOR: |
| 6897 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6898 | pAdapter = hdd_alloc_station_adapter( pHddCtx, macAddr, iface_name ); |
| 6899 | if( NULL == pAdapter ) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6900 | { |
| 6901 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 6902 | FL("failed to allocate adapter for session %d"), session_type); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6903 | return NULL; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6904 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6905 | |
| 6906 | pAdapter->wdev.iftype = NL80211_IFTYPE_MONITOR; |
| 6907 | pAdapter->device_mode = session_type; |
| 6908 | status = hdd_register_interface( pAdapter, rtnl_held ); |
| 6909 | #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29) |
| 6910 | pAdapter->dev->netdev_ops = &wlan_mon_drv_ops; |
| 6911 | #else |
| 6912 | pAdapter->dev->open = hdd_mon_open; |
| 6913 | pAdapter->dev->hard_start_xmit = hdd_mon_hard_start_xmit; |
| 6914 | #endif |
| 6915 | hdd_init_tx_rx( pAdapter ); |
| 6916 | set_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags); |
| 6917 | //Set adapter to be used for data tx. It will use either GO or softap. |
| 6918 | pAdapter->sessionCtx.monitor.pAdapterForTx = |
| 6919 | hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_SOFTAP); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6920 | if (NULL == pAdapter->sessionCtx.monitor.pAdapterForTx) |
| 6921 | { |
| 6922 | pAdapter->sessionCtx.monitor.pAdapterForTx = |
| 6923 | hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_P2P_GO); |
| 6924 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6925 | /* This workqueue will be used to transmit management packet over |
| 6926 | * monitor interface. */ |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 6927 | if (NULL == pAdapter->sessionCtx.monitor.pAdapterForTx) { |
| 6928 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s:Failed:hdd_get_adapter",__func__); |
| 6929 | return NULL; |
| 6930 | } |
Madan Mohan Koyyalamudi | 9f40ceb | 2012-10-18 19:22:56 -0700 | [diff] [blame] | 6931 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6932 | INIT_WORK(&pAdapter->sessionCtx.monitor.pAdapterForTx->monTxWorkQueue, |
| 6933 | hdd_mon_tx_work_queue); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6934 | } |
| 6935 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6936 | case WLAN_HDD_FTM: |
| 6937 | { |
| 6938 | pAdapter = hdd_alloc_station_adapter( pHddCtx, macAddr, iface_name ); |
| 6939 | |
| 6940 | if( NULL == pAdapter ) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6941 | { |
| 6942 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 6943 | FL("failed to allocate adapter for session %d"), session_type); |
| 6944 | return NULL; |
| 6945 | } |
| 6946 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6947 | /* Assign NL80211_IFTYPE_STATION as interface type to resolve Kernel Warning |
| 6948 | * message while loading driver in FTM mode. */ |
| 6949 | pAdapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 6950 | pAdapter->device_mode = session_type; |
| 6951 | status = hdd_register_interface( pAdapter, rtnl_held ); |
Madan Mohan Koyyalamudi | f89ac9f | 2013-09-19 16:58:12 +0530 | [diff] [blame] | 6952 | |
| 6953 | hdd_init_tx_rx( pAdapter ); |
| 6954 | |
| 6955 | //Stop the Interface TX queue. |
Padma, Santhosh Kumar | 9dacb5c | 2014-12-17 19:22:56 +0530 | [diff] [blame] | 6956 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues")); |
Madan Mohan Koyyalamudi | f89ac9f | 2013-09-19 16:58:12 +0530 | [diff] [blame] | 6957 | netif_tx_disable(pAdapter->dev); |
| 6958 | netif_carrier_off(pAdapter->dev); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6959 | } |
| 6960 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6961 | default: |
| 6962 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6963 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s Invalid session type %d", |
| 6964 | __func__, session_type); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6965 | VOS_ASSERT(0); |
| 6966 | return NULL; |
| 6967 | } |
| 6968 | } |
| 6969 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6970 | if( VOS_STATUS_SUCCESS == status ) |
| 6971 | { |
| 6972 | //Add it to the hdd's session list. |
| 6973 | pHddAdapterNode = vos_mem_malloc( sizeof( hdd_adapter_list_node_t ) ); |
| 6974 | if( NULL == pHddAdapterNode ) |
| 6975 | { |
| 6976 | status = VOS_STATUS_E_NOMEM; |
| 6977 | } |
| 6978 | else |
| 6979 | { |
| 6980 | pHddAdapterNode->pAdapter = pAdapter; |
| 6981 | status = hdd_add_adapter_back ( pHddCtx, |
| 6982 | pHddAdapterNode ); |
| 6983 | } |
| 6984 | } |
| 6985 | |
| 6986 | if( VOS_STATUS_SUCCESS != status ) |
| 6987 | { |
| 6988 | if( NULL != pAdapter ) |
| 6989 | { |
| 6990 | hdd_cleanup_adapter( pHddCtx, pAdapter, rtnl_held ); |
| 6991 | pAdapter = NULL; |
| 6992 | } |
| 6993 | if( NULL != pHddAdapterNode ) |
| 6994 | { |
| 6995 | vos_mem_free( pHddAdapterNode ); |
| 6996 | } |
| 6997 | |
| 6998 | goto resume_bmps; |
| 6999 | } |
| 7000 | |
| 7001 | if(VOS_STATUS_SUCCESS == status) |
| 7002 | { |
| 7003 | wlan_hdd_set_concurrency_mode(pHddCtx, session_type); |
| 7004 | |
Madan Mohan Koyyalamudi | 96dd30d | 2012-10-05 17:24:51 -0700 | [diff] [blame] | 7005 | //Initialize the WoWL service |
| 7006 | if(!hdd_init_wowl(pAdapter)) |
| 7007 | { |
| 7008 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hdd_init_wowl failed",__func__); |
| 7009 | goto err_free_netdev; |
| 7010 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7011 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7012 | return pAdapter; |
| 7013 | |
| 7014 | err_free_netdev: |
| 7015 | free_netdev(pAdapter->dev); |
| 7016 | wlan_hdd_release_intf_addr( pHddCtx, |
| 7017 | pAdapter->macAddressCurrent.bytes ); |
| 7018 | |
| 7019 | resume_bmps: |
| 7020 | //If bmps disabled enable it |
| 7021 | if(VOS_STATUS_SUCCESS == exitbmpsStatus) |
| 7022 | { |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 7023 | if (pHddCtx->hdd_wlan_suspended) |
| 7024 | { |
| 7025 | hdd_set_pwrparams(pHddCtx); |
| 7026 | } |
| 7027 | hdd_enable_bmps_imps(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7028 | } |
| 7029 | return NULL; |
| 7030 | } |
| 7031 | |
| 7032 | VOS_STATUS hdd_close_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter, |
| 7033 | tANI_U8 rtnl_held ) |
| 7034 | { |
| 7035 | hdd_adapter_list_node_t *pAdapterNode, *pCurrent, *pNext; |
| 7036 | VOS_STATUS status; |
| 7037 | |
| 7038 | status = hdd_get_front_adapter ( pHddCtx, &pCurrent ); |
| 7039 | if( VOS_STATUS_SUCCESS != status ) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7040 | { |
| 7041 | hddLog(VOS_TRACE_LEVEL_WARN,"%s: adapter list empty %d", |
| 7042 | __func__, status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7043 | return status; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7044 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7045 | |
| 7046 | while ( pCurrent->pAdapter != pAdapter ) |
| 7047 | { |
| 7048 | status = hdd_get_next_adapter ( pHddCtx, pCurrent, &pNext ); |
| 7049 | if( VOS_STATUS_SUCCESS != status ) |
| 7050 | break; |
| 7051 | |
| 7052 | pCurrent = pNext; |
| 7053 | } |
| 7054 | pAdapterNode = pCurrent; |
| 7055 | if( VOS_STATUS_SUCCESS == status ) |
| 7056 | { |
| 7057 | wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode); |
| 7058 | hdd_cleanup_adapter( pHddCtx, pAdapterNode->pAdapter, rtnl_held ); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 7059 | |
| 7060 | #ifdef FEATURE_WLAN_TDLS |
| 7061 | |
| 7062 | /* A Mutex Lock is introduced while changing/initializing the mode to |
| 7063 | * protect the concurrent access for the Adapters by TDLS module. |
| 7064 | */ |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 7065 | mutex_lock(&pHddCtx->tdls_lock); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 7066 | #endif |
| 7067 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7068 | hdd_remove_adapter( pHddCtx, pAdapterNode ); |
| 7069 | vos_mem_free( pAdapterNode ); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 7070 | pAdapterNode = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7071 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 7072 | #ifdef FEATURE_WLAN_TDLS |
| 7073 | mutex_unlock(&pHddCtx->tdls_lock); |
| 7074 | #endif |
| 7075 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7076 | |
| 7077 | /* 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] | 7078 | if ((!vos_concurrent_open_sessions_running()) && |
| 7079 | ((pHddCtx->no_of_open_sessions[VOS_STA_MODE] >= 1) || |
| 7080 | (pHddCtx->no_of_open_sessions[VOS_P2P_CLIENT_MODE] >= 1))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7081 | { |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 7082 | if (pHddCtx->hdd_wlan_suspended) |
| 7083 | { |
| 7084 | hdd_set_pwrparams(pHddCtx); |
| 7085 | } |
| 7086 | hdd_enable_bmps_imps(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7087 | } |
| 7088 | |
| 7089 | return VOS_STATUS_SUCCESS; |
| 7090 | } |
| 7091 | |
| 7092 | return VOS_STATUS_E_FAILURE; |
| 7093 | } |
| 7094 | |
| 7095 | VOS_STATUS hdd_close_all_adapters( hdd_context_t *pHddCtx ) |
| 7096 | { |
| 7097 | hdd_adapter_list_node_t *pHddAdapterNode; |
| 7098 | VOS_STATUS status; |
| 7099 | |
| 7100 | ENTER(); |
| 7101 | |
| 7102 | do |
| 7103 | { |
| 7104 | status = hdd_remove_front_adapter( pHddCtx, &pHddAdapterNode ); |
| 7105 | if( pHddAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7106 | { |
| 7107 | hdd_cleanup_adapter( pHddCtx, pHddAdapterNode->pAdapter, FALSE ); |
| 7108 | vos_mem_free( pHddAdapterNode ); |
| 7109 | } |
| 7110 | }while( NULL != pHddAdapterNode && VOS_STATUS_E_EMPTY != status ); |
| 7111 | |
| 7112 | EXIT(); |
| 7113 | |
| 7114 | return VOS_STATUS_SUCCESS; |
| 7115 | } |
| 7116 | |
| 7117 | void wlan_hdd_reset_prob_rspies(hdd_adapter_t* pHostapdAdapter) |
| 7118 | { |
| 7119 | v_U8_t addIE[1] = {0}; |
| 7120 | |
| 7121 | if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 7122 | WNI_CFG_PROBE_RSP_ADDNIE_DATA1,(tANI_U8*)addIE, 0, NULL, |
| 7123 | eANI_BOOLEAN_FALSE) ) |
| 7124 | { |
| 7125 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 7126 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7127 | } |
| 7128 | |
| 7129 | if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 7130 | WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL, |
| 7131 | eANI_BOOLEAN_FALSE) ) |
| 7132 | { |
| 7133 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 7134 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7135 | } |
| 7136 | |
| 7137 | if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 7138 | WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL, |
| 7139 | eANI_BOOLEAN_FALSE) ) |
| 7140 | { |
| 7141 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 7142 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7143 | } |
| 7144 | } |
| 7145 | |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 7146 | VOS_STATUS hdd_stop_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter, |
| 7147 | const v_BOOL_t bCloseSession ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7148 | { |
| 7149 | eHalStatus halStatus = eHAL_STATUS_SUCCESS; |
| 7150 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Kaushik, Sushant | 4975a57 | 2014-10-21 16:07:48 +0530 | [diff] [blame] | 7151 | hdd_scaninfo_t *pScanInfo = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7152 | union iwreq_data wrqu; |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 7153 | v_U8_t retry = 0; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7154 | long ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7155 | |
Anand N Sunkad | 26d71b9 | 2014-12-24 18:08:22 +0530 | [diff] [blame] | 7156 | if (pHddCtx->isLogpInProgress) { |
| 7157 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 7158 | "%s:LOGP in Progress. Ignore!!!",__func__); |
| 7159 | return VOS_STATUS_E_FAILURE; |
| 7160 | } |
| 7161 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7162 | ENTER(); |
Vinay Krishna Eranna | f97ef5c | 2014-12-26 17:47:19 +0530 | [diff] [blame] | 7163 | |
Kaushik, Sushant | 4975a57 | 2014-10-21 16:07:48 +0530 | [diff] [blame] | 7164 | pScanInfo = &pHddCtx->scan_info; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7165 | switch(pAdapter->device_mode) |
| 7166 | { |
| 7167 | case WLAN_HDD_INFRA_STATION: |
| 7168 | case WLAN_HDD_P2P_CLIENT: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7169 | case WLAN_HDD_P2P_DEVICE: |
Vinay Krishna Eranna | b09d3e7 | 2014-03-26 21:23:55 +0530 | [diff] [blame] | 7170 | { |
| 7171 | hdd_station_ctx_t *pstation = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 7172 | if( hdd_connIsConnected(pstation) || |
| 7173 | (pstation->conn_info.connState == eConnectionState_Connecting) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7174 | { |
Mahesh A Saptasagar | f5b8eff | 2015-01-31 01:07:07 +0530 | [diff] [blame] | 7175 | #ifdef FEATURE_WLAN_TDLS |
| 7176 | mutex_lock(&pHddCtx->tdls_lock); |
Pradeep Reddy POTTETI | 2d4d5c4 | 2015-03-03 14:34:19 +0530 | [diff] [blame] | 7177 | wlan_hdd_tdls_exit(pAdapter, TRUE); |
Mahesh A Saptasagar | f5b8eff | 2015-01-31 01:07:07 +0530 | [diff] [blame] | 7178 | mutex_unlock(&pHddCtx->tdls_lock); |
| 7179 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7180 | if (pWextState->roamProfile.BSSType == eCSR_BSS_TYPE_START_IBSS) |
| 7181 | halStatus = sme_RoamDisconnect(pHddCtx->hHal, |
| 7182 | pAdapter->sessionId, |
| 7183 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
| 7184 | else |
| 7185 | halStatus = sme_RoamDisconnect(pHddCtx->hHal, |
| 7186 | pAdapter->sessionId, |
| 7187 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
| 7188 | //success implies disconnect command got queued up successfully |
| 7189 | if(halStatus == eHAL_STATUS_SUCCESS) |
| 7190 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7191 | ret = wait_for_completion_interruptible_timeout( |
| 7192 | &pAdapter->disconnect_comp_var, |
| 7193 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 7194 | if (ret <= 0) |
| 7195 | { |
| 7196 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 7197 | "%s: wait on disconnect_comp_var failed %ld", |
| 7198 | __func__, ret); |
| 7199 | } |
| 7200 | } |
| 7201 | else |
| 7202 | { |
| 7203 | hddLog(LOGE, "%s: failed to post disconnect event to SME", |
| 7204 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7205 | } |
| 7206 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 7207 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 7208 | memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN); |
| 7209 | wireless_send_event(pAdapter->dev, SIOCGIWAP, &wrqu, NULL); |
| 7210 | } |
Vinay Krishna Eranna | b09d3e7 | 2014-03-26 21:23:55 +0530 | [diff] [blame] | 7211 | else if(pstation->conn_info.connState == |
| 7212 | eConnectionState_Disconnecting) |
| 7213 | { |
| 7214 | ret = wait_for_completion_interruptible_timeout( |
| 7215 | &pAdapter->disconnect_comp_var, |
| 7216 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 7217 | if (ret <= 0) |
| 7218 | { |
| 7219 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 7220 | FL("wait on disconnect_comp_var failed %ld"), ret); |
| 7221 | } |
| 7222 | } |
Kaushik, Sushant | 4975a57 | 2014-10-21 16:07:48 +0530 | [diff] [blame] | 7223 | else if(pScanInfo != NULL && pHddCtx->scan_info.mScanPending) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7224 | { |
Kaushik, Sushant | 4975a57 | 2014-10-21 16:07:48 +0530 | [diff] [blame] | 7225 | hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId, |
Srinivas, Dasari | 138af4f | 2014-02-07 11:13:45 +0530 | [diff] [blame] | 7226 | eCSR_SCAN_ABORT_DEFAULT); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7227 | } |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 7228 | if (pAdapter->device_mode != WLAN_HDD_INFRA_STATION) |
| 7229 | { |
| 7230 | while (pAdapter->is_roc_inprogress) |
| 7231 | { |
| 7232 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7233 | "%s: ROC in progress for session %d!!!", |
| 7234 | __func__, pAdapter->sessionId); |
| 7235 | // waiting for ROC to expire |
| 7236 | msleep(500); |
| 7237 | /* In GO present case , if retry exceeds 3, |
| 7238 | it means something went wrong. */ |
| 7239 | if ( retry++ > MAX_WAIT_FOR_ROC_COMPLETION ) |
| 7240 | { |
| 7241 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7242 | "%s: ROC completion is not received.!!!", __func__); |
Deepthi Gowri | 7049825 | 2015-01-20 15:56:45 +0530 | [diff] [blame] | 7243 | if (eHAL_STATUS_SUCCESS != |
| 7244 | sme_CancelRemainOnChannel( WLAN_HDD_GET_HAL_CTX( pAdapter), |
| 7245 | pAdapter->sessionId )) |
| 7246 | { |
| 7247 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7248 | FL("Failed to Cancel Remain on Channel")); |
| 7249 | } |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 7250 | wait_for_completion_interruptible_timeout( |
| 7251 | &pAdapter->cancel_rem_on_chan_var, |
| 7252 | msecs_to_jiffies(WAIT_CANCEL_REM_CHAN)); |
| 7253 | break; |
| 7254 | } |
| 7255 | } |
Ganesh Kondabattini | babfb49 | 2014-12-17 20:25:29 +0530 | [diff] [blame] | 7256 | #ifdef WLAN_OPEN_SOURCE |
| 7257 | cancel_delayed_work_sync(&pAdapter->roc_work); |
| 7258 | #endif |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 7259 | } |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 7260 | #ifdef WLAN_NS_OFFLOAD |
Vinay Krishna Eranna | 941360f | 2014-01-16 15:38:22 +0530 | [diff] [blame] | 7261 | #ifdef WLAN_OPEN_SOURCE |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 7262 | cancel_work_sync(&pAdapter->ipv6NotifierWorkQueue); |
| 7263 | #endif |
| 7264 | #endif |
Vinay Krishna Eranna | f97ef5c | 2014-12-26 17:47:19 +0530 | [diff] [blame] | 7265 | |
Vinay Krishna Eranna | 4d055d4 | 2013-12-17 17:02:01 +0530 | [diff] [blame] | 7266 | #ifdef WLAN_OPEN_SOURCE |
| 7267 | cancel_work_sync(&pAdapter->ipv4NotifierWorkQueue); |
| 7268 | #endif |
Vinay Krishna Eranna | f97ef5c | 2014-12-26 17:47:19 +0530 | [diff] [blame] | 7269 | |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 7270 | /* It is possible that the caller of this function does not |
| 7271 | * wish to close the session |
| 7272 | */ |
| 7273 | if (VOS_TRUE == bCloseSession && |
| 7274 | test_bit(SME_SESSION_OPENED, &pAdapter->event_flags)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7275 | { |
| 7276 | INIT_COMPLETION(pAdapter->session_close_comp_var); |
| 7277 | if (eHAL_STATUS_SUCCESS == |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 7278 | sme_CloseSession(pHddCtx->hHal, pAdapter->sessionId, |
| 7279 | hdd_smeCloseSessionCallback, pAdapter)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7280 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7281 | unsigned long ret; |
| 7282 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7283 | //Block on a completion variable. Can't wait forever though. |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7284 | ret = wait_for_completion_timeout( |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 7285 | &pAdapter->session_close_comp_var, |
| 7286 | msecs_to_jiffies(WLAN_WAIT_TIME_SESSIONOPENCLOSE)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7287 | if ( 0 >= ret) |
| 7288 | { |
| 7289 | hddLog(LOGE, "%s: failure waiting for session_close_comp_var %ld", |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 7290 | __func__, ret); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7291 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7292 | } |
| 7293 | } |
Vinay Krishna Eranna | b09d3e7 | 2014-03-26 21:23:55 +0530 | [diff] [blame] | 7294 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7295 | break; |
| 7296 | |
| 7297 | case WLAN_HDD_SOFTAP: |
| 7298 | case WLAN_HDD_P2P_GO: |
| 7299 | //Any softap specific cleanup here... |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 7300 | if (pAdapter->device_mode == WLAN_HDD_P2P_GO) { |
| 7301 | while (pAdapter->is_roc_inprogress) { |
| 7302 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7303 | "%s: ROC in progress for session %d!!!", |
| 7304 | __func__, pAdapter->sessionId); |
| 7305 | msleep(500); |
| 7306 | if ( retry++ > MAX_WAIT_FOR_ROC_COMPLETION ) { |
| 7307 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7308 | "%s: ROC completion is not received.!!!", __func__); |
| 7309 | WLANSAP_CancelRemainOnChannel( |
| 7310 | (WLAN_HDD_GET_CTX(pAdapter))->pvosContext); |
| 7311 | wait_for_completion_interruptible_timeout( |
| 7312 | &pAdapter->cancel_rem_on_chan_var, |
| 7313 | msecs_to_jiffies(WAIT_CANCEL_REM_CHAN)); |
| 7314 | break; |
| 7315 | } |
| 7316 | } |
Ganesh Kondabattini | babfb49 | 2014-12-17 20:25:29 +0530 | [diff] [blame] | 7317 | |
| 7318 | #ifdef WLAN_OPEN_SOURCE |
| 7319 | cancel_delayed_work_sync(&pAdapter->roc_work); |
| 7320 | #endif |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 7321 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7322 | mutex_lock(&pHddCtx->sap_lock); |
| 7323 | if (test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags)) |
| 7324 | { |
| 7325 | VOS_STATUS status; |
| 7326 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 7327 | |
| 7328 | //Stop Bss. |
| 7329 | status = WLANSAP_StopBss(pHddCtx->pvosContext); |
| 7330 | if (VOS_IS_STATUS_SUCCESS(status)) |
| 7331 | { |
| 7332 | hdd_hostapd_state_t *pHostapdState = |
| 7333 | WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 7334 | |
| 7335 | status = vos_wait_single_event(&pHostapdState->vosEvent, 10000); |
| 7336 | |
| 7337 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 7338 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7339 | hddLog(LOGE, "%s: failure waiting for WLANSAP_StopBss %d", |
| 7340 | __func__, status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7341 | } |
| 7342 | } |
| 7343 | else |
| 7344 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7345 | hddLog(LOGE, "%s: failure in WLANSAP_StopBss", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7346 | } |
| 7347 | clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags); |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 7348 | wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7349 | |
| 7350 | if (eHAL_STATUS_FAILURE == |
| 7351 | ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, |
| 7352 | 0, NULL, eANI_BOOLEAN_FALSE)) |
| 7353 | { |
| 7354 | hddLog(LOGE, |
| 7355 | "%s: Failed to set WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7356 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7357 | } |
| 7358 | |
| 7359 | if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal, |
| 7360 | WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL, |
| 7361 | eANI_BOOLEAN_FALSE) ) |
| 7362 | { |
| 7363 | hddLog(LOGE, |
| 7364 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM"); |
| 7365 | } |
| 7366 | |
| 7367 | // Reset WNI_CFG_PROBE_RSP Flags |
| 7368 | wlan_hdd_reset_prob_rspies(pAdapter); |
| 7369 | kfree(pAdapter->sessionCtx.ap.beacon); |
| 7370 | pAdapter->sessionCtx.ap.beacon = NULL; |
| 7371 | } |
| 7372 | mutex_unlock(&pHddCtx->sap_lock); |
| 7373 | break; |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 7374 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7375 | case WLAN_HDD_MONITOR: |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 7376 | #ifdef WLAN_OPEN_SOURCE |
| 7377 | cancel_work_sync(&pAdapter->sessionCtx.monitor.pAdapterForTx->monTxWorkQueue); |
| 7378 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7379 | break; |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 7380 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7381 | default: |
| 7382 | break; |
| 7383 | } |
| 7384 | |
| 7385 | EXIT(); |
| 7386 | return VOS_STATUS_SUCCESS; |
| 7387 | } |
| 7388 | |
| 7389 | VOS_STATUS hdd_stop_all_adapters( hdd_context_t *pHddCtx ) |
| 7390 | { |
| 7391 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7392 | VOS_STATUS status; |
| 7393 | hdd_adapter_t *pAdapter; |
| 7394 | |
| 7395 | ENTER(); |
| 7396 | |
| 7397 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7398 | |
| 7399 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7400 | { |
| 7401 | pAdapter = pAdapterNode->pAdapter; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7402 | |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 7403 | hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7404 | |
| 7405 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7406 | pAdapterNode = pNext; |
| 7407 | } |
| 7408 | |
| 7409 | EXIT(); |
| 7410 | |
| 7411 | return VOS_STATUS_SUCCESS; |
| 7412 | } |
| 7413 | |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 7414 | |
| 7415 | #ifdef FEATURE_WLAN_BATCH_SCAN |
| 7416 | /**--------------------------------------------------------------------------- |
| 7417 | |
| 7418 | \brief hdd_deinit_batch_scan () - This function cleans up batch scan data |
| 7419 | structures |
| 7420 | |
| 7421 | \param - pAdapter Pointer to HDD adapter |
| 7422 | |
| 7423 | \return - None |
| 7424 | |
| 7425 | --------------------------------------------------------------------------*/ |
| 7426 | void hdd_deinit_batch_scan(hdd_adapter_t *pAdapter) |
| 7427 | { |
| 7428 | tHddBatchScanRsp *pNode; |
| 7429 | tHddBatchScanRsp *pPrev; |
| 7430 | |
Siddharth Bhal | b3e9b79 | 2014-02-24 15:14:16 +0530 | [diff] [blame] | 7431 | if (NULL == pAdapter) |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 7432 | { |
Siddharth Bhal | b3e9b79 | 2014-02-24 15:14:16 +0530 | [diff] [blame] | 7433 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 7434 | "%s: Adapter context is Null", __func__); |
| 7435 | return; |
| 7436 | } |
| 7437 | |
| 7438 | pNode = pAdapter->pBatchScanRsp; |
| 7439 | while (pNode) |
| 7440 | { |
| 7441 | pPrev = pNode; |
| 7442 | pNode = pNode->pNext; |
| 7443 | vos_mem_free((v_VOID_t * )pPrev); |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 7444 | } |
| 7445 | |
| 7446 | pAdapter->pBatchScanRsp = NULL; |
| 7447 | pAdapter->numScanList = 0; |
| 7448 | pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STOPPED; |
| 7449 | pAdapter->prev_batch_id = 0; |
| 7450 | |
| 7451 | return; |
| 7452 | } |
| 7453 | #endif |
| 7454 | |
| 7455 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7456 | VOS_STATUS hdd_reset_all_adapters( hdd_context_t *pHddCtx ) |
| 7457 | { |
| 7458 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7459 | VOS_STATUS status; |
| 7460 | hdd_adapter_t *pAdapter; |
| 7461 | |
| 7462 | ENTER(); |
| 7463 | |
| 7464 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7465 | |
| 7466 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7467 | { |
| 7468 | pAdapter = pAdapterNode->pAdapter; |
Padma, Santhosh Kumar | 9dacb5c | 2014-12-17 19:22:56 +0530 | [diff] [blame] | 7469 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7470 | netif_tx_disable(pAdapter->dev); |
| 7471 | netif_carrier_off(pAdapter->dev); |
| 7472 | |
Srinivas Girigowda | 66c05eb | 2013-07-14 13:06:01 -0700 | [diff] [blame] | 7473 | pAdapter->sessionCtx.station.hdd_ReassocScenario = VOS_FALSE; |
| 7474 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7475 | hdd_deinit_tx_rx(pAdapter); |
Agarwal Ashish | 6267caa | 2014-08-06 19:16:21 +0530 | [diff] [blame] | 7476 | |
Katya Nigam | 1fd2440 | 2015-02-16 14:52:19 +0530 | [diff] [blame] | 7477 | if(pAdapter->device_mode == WLAN_HDD_IBSS ) |
| 7478 | hdd_ibss_deinit_tx_rx(pAdapter); |
| 7479 | |
Agarwal Ashish | 6267caa | 2014-08-06 19:16:21 +0530 | [diff] [blame] | 7480 | wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode); |
| 7481 | |
Madan Mohan Koyyalamudi | 8c6dec8 | 2013-09-26 15:56:13 +0530 | [diff] [blame] | 7482 | if (test_bit(WMM_INIT_DONE, &pAdapter->event_flags)) |
| 7483 | { |
| 7484 | hdd_wmm_adapter_close( pAdapter ); |
| 7485 | clear_bit(WMM_INIT_DONE, &pAdapter->event_flags); |
| 7486 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7487 | |
Siddharth Bhal | 2db319d | 2014-12-03 12:37:18 +0530 | [diff] [blame] | 7488 | if (test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags)) |
| 7489 | { |
| 7490 | clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags); |
| 7491 | } |
| 7492 | |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 7493 | #ifdef FEATURE_WLAN_BATCH_SCAN |
| 7494 | if (eHDD_BATCH_SCAN_STATE_STARTED == pAdapter->batchScanState) |
| 7495 | { |
| 7496 | hdd_deinit_batch_scan(pAdapter); |
| 7497 | } |
| 7498 | #endif |
| 7499 | |
Mahesh A Saptasagar | f5b8eff | 2015-01-31 01:07:07 +0530 | [diff] [blame] | 7500 | #ifdef FEATURE_WLAN_TDLS |
| 7501 | mutex_lock(&pHddCtx->tdls_lock); |
Pradeep Reddy POTTETI | 2d4d5c4 | 2015-03-03 14:34:19 +0530 | [diff] [blame] | 7502 | wlan_hdd_tdls_exit(pAdapter, TRUE); |
Mahesh A Saptasagar | f5b8eff | 2015-01-31 01:07:07 +0530 | [diff] [blame] | 7503 | mutex_unlock(&pHddCtx->tdls_lock); |
| 7504 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7505 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7506 | pAdapterNode = pNext; |
| 7507 | } |
| 7508 | |
| 7509 | EXIT(); |
| 7510 | |
| 7511 | return VOS_STATUS_SUCCESS; |
| 7512 | } |
| 7513 | |
| 7514 | VOS_STATUS hdd_start_all_adapters( hdd_context_t *pHddCtx ) |
| 7515 | { |
| 7516 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7517 | VOS_STATUS status; |
| 7518 | hdd_adapter_t *pAdapter; |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 7519 | eConnectionState connState; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7520 | |
| 7521 | ENTER(); |
| 7522 | |
| 7523 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7524 | |
| 7525 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7526 | { |
| 7527 | pAdapter = pAdapterNode->pAdapter; |
| 7528 | |
Kumar Anand | 82c009f | 2014-05-29 00:29:42 -0700 | [diff] [blame] | 7529 | hdd_wmm_init( pAdapter ); |
| 7530 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7531 | switch(pAdapter->device_mode) |
| 7532 | { |
| 7533 | case WLAN_HDD_INFRA_STATION: |
| 7534 | case WLAN_HDD_P2P_CLIENT: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7535 | case WLAN_HDD_P2P_DEVICE: |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 7536 | |
| 7537 | connState = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState; |
| 7538 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7539 | hdd_init_station_mode(pAdapter); |
| 7540 | /* Open the gates for HDD to receive Wext commands */ |
| 7541 | pAdapter->isLinkUpSvcNeeded = FALSE; |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 7542 | pHddCtx->scan_info.mScanPending = FALSE; |
| 7543 | pHddCtx->scan_info.waitScanResult = FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7544 | |
| 7545 | //Trigger the initial scan |
| 7546 | hdd_wlan_initial_scan(pAdapter); |
| 7547 | |
| 7548 | //Indicate disconnect event to supplicant if associated previously |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 7549 | if (eConnectionState_Associated == connState || |
| 7550 | eConnectionState_IbssConnected == connState ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7551 | { |
| 7552 | union iwreq_data wrqu; |
| 7553 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 7554 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 7555 | memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN); |
| 7556 | wireless_send_event(pAdapter->dev, SIOCGIWAP, &wrqu, NULL); |
Srinivas Girigowda | 66c05eb | 2013-07-14 13:06:01 -0700 | [diff] [blame] | 7557 | pAdapter->sessionCtx.station.hdd_ReassocScenario = VOS_FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7558 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7559 | /* indicate disconnected event to nl80211 */ |
| 7560 | cfg80211_disconnected(pAdapter->dev, WLAN_REASON_UNSPECIFIED, |
| 7561 | NULL, 0, GFP_KERNEL); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7562 | } |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 7563 | else if (eConnectionState_Connecting == connState) |
| 7564 | { |
| 7565 | /* |
| 7566 | * Indicate connect failure to supplicant if we were in the |
| 7567 | * process of connecting |
| 7568 | */ |
| 7569 | cfg80211_connect_result(pAdapter->dev, NULL, |
| 7570 | NULL, 0, NULL, 0, |
| 7571 | WLAN_STATUS_ASSOC_DENIED_UNSPEC, |
| 7572 | GFP_KERNEL); |
| 7573 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7574 | break; |
| 7575 | |
| 7576 | case WLAN_HDD_SOFTAP: |
| 7577 | /* softAP can handle SSR */ |
| 7578 | break; |
| 7579 | |
| 7580 | case WLAN_HDD_P2P_GO: |
Sameer Thalappil | edf0d79 | 2013-08-09 14:31:03 -0700 | [diff] [blame] | 7581 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s [SSR] send stop ap to supplicant", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7582 | __func__); |
Sameer Thalappil | edf0d79 | 2013-08-09 14:31:03 -0700 | [diff] [blame] | 7583 | cfg80211_ap_stopped(pAdapter->dev, GFP_KERNEL); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7584 | break; |
| 7585 | |
| 7586 | case WLAN_HDD_MONITOR: |
| 7587 | /* monitor interface start */ |
| 7588 | break; |
| 7589 | default: |
| 7590 | break; |
| 7591 | } |
| 7592 | |
| 7593 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7594 | pAdapterNode = pNext; |
| 7595 | } |
| 7596 | |
| 7597 | EXIT(); |
| 7598 | |
| 7599 | return VOS_STATUS_SUCCESS; |
| 7600 | } |
| 7601 | |
| 7602 | VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx ) |
| 7603 | { |
| 7604 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7605 | hdd_adapter_t *pAdapter; |
| 7606 | VOS_STATUS status; |
| 7607 | v_U32_t roamId; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7608 | long ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7609 | |
| 7610 | ENTER(); |
| 7611 | |
| 7612 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7613 | |
| 7614 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7615 | { |
| 7616 | pAdapter = pAdapterNode->pAdapter; |
| 7617 | |
| 7618 | if( (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
| 7619 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ) |
| 7620 | { |
| 7621 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 7622 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 7623 | |
Abhishek Singh | f4669da | 2014-05-26 15:07:49 +0530 | [diff] [blame] | 7624 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 7625 | "%s: Set HDD connState to eConnectionState_NotConnected", |
| 7626 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7627 | pHddStaCtx->conn_info.connState = eConnectionState_NotConnected; |
| 7628 | init_completion(&pAdapter->disconnect_comp_var); |
| 7629 | sme_RoamDisconnect(pHddCtx->hHal, pAdapter->sessionId, |
| 7630 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
| 7631 | |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7632 | ret = wait_for_completion_interruptible_timeout( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7633 | &pAdapter->disconnect_comp_var, |
| 7634 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7635 | if (0 >= ret) |
| 7636 | hddLog(LOGE, "%s: failure waiting for disconnect_comp_var %ld", |
| 7637 | __func__, ret); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7638 | |
| 7639 | pWextState->roamProfile.csrPersona = pAdapter->device_mode; |
| 7640 | pHddCtx->isAmpAllowed = VOS_FALSE; |
| 7641 | sme_RoamConnect(pHddCtx->hHal, |
| 7642 | pAdapter->sessionId, &(pWextState->roamProfile), |
| 7643 | &roamId); |
| 7644 | } |
| 7645 | |
| 7646 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7647 | pAdapterNode = pNext; |
| 7648 | } |
| 7649 | |
| 7650 | EXIT(); |
| 7651 | |
| 7652 | return VOS_STATUS_SUCCESS; |
| 7653 | } |
| 7654 | |
Sudhir Sattayappa Kohalli | 90e4c75 | 2013-03-21 14:25:04 -0700 | [diff] [blame] | 7655 | void hdd_dump_concurrency_info(hdd_context_t *pHddCtx) |
| 7656 | { |
| 7657 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7658 | VOS_STATUS status; |
| 7659 | hdd_adapter_t *pAdapter; |
| 7660 | hdd_station_ctx_t *pHddStaCtx; |
| 7661 | hdd_ap_ctx_t *pHddApCtx; |
| 7662 | hdd_hostapd_state_t * pHostapdState; |
| 7663 | tCsrBssid staBssid = { 0 }, p2pBssid = { 0 }, apBssid = { 0 }; |
| 7664 | v_U8_t staChannel = 0, p2pChannel = 0, apChannel = 0; |
| 7665 | const char *p2pMode = "DEV"; |
| 7666 | const char *ccMode = "Standalone"; |
| 7667 | int n; |
| 7668 | |
| 7669 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7670 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7671 | { |
| 7672 | pAdapter = pAdapterNode->pAdapter; |
| 7673 | switch (pAdapter->device_mode) { |
| 7674 | case WLAN_HDD_INFRA_STATION: |
| 7675 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 7676 | if (eConnectionState_Associated == pHddStaCtx->conn_info.connState) { |
| 7677 | staChannel = pHddStaCtx->conn_info.operationChannel; |
| 7678 | memcpy(staBssid, pHddStaCtx->conn_info.bssId, sizeof(staBssid)); |
| 7679 | } |
| 7680 | break; |
| 7681 | case WLAN_HDD_P2P_CLIENT: |
| 7682 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 7683 | if (eConnectionState_Associated == pHddStaCtx->conn_info.connState) { |
| 7684 | p2pChannel = pHddStaCtx->conn_info.operationChannel; |
| 7685 | memcpy(p2pBssid, pHddStaCtx->conn_info.bssId, sizeof(p2pBssid)); |
| 7686 | p2pMode = "CLI"; |
| 7687 | } |
| 7688 | break; |
| 7689 | case WLAN_HDD_P2P_GO: |
| 7690 | pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
| 7691 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 7692 | if (pHostapdState->bssState == BSS_START && pHostapdState->vosStatus==VOS_STATUS_SUCCESS) { |
| 7693 | p2pChannel = pHddApCtx->operatingChannel; |
| 7694 | memcpy(p2pBssid, pAdapter->macAddressCurrent.bytes, sizeof(p2pBssid)); |
| 7695 | } |
| 7696 | p2pMode = "GO"; |
| 7697 | break; |
| 7698 | case WLAN_HDD_SOFTAP: |
| 7699 | pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
| 7700 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 7701 | if (pHostapdState->bssState == BSS_START && pHostapdState->vosStatus==VOS_STATUS_SUCCESS) { |
| 7702 | apChannel = pHddApCtx->operatingChannel; |
| 7703 | memcpy(apBssid, pAdapter->macAddressCurrent.bytes, sizeof(apBssid)); |
| 7704 | } |
| 7705 | break; |
| 7706 | default: |
| 7707 | break; |
| 7708 | } |
| 7709 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7710 | pAdapterNode = pNext; |
| 7711 | } |
| 7712 | if (staChannel > 0 && (apChannel > 0 || p2pChannel > 0)) { |
| 7713 | ccMode = (p2pChannel==staChannel||apChannel==staChannel) ? "SCC" : "MCC"; |
| 7714 | } |
| 7715 | n = pr_info("wlan(%d) " MAC_ADDRESS_STR " %s", |
| 7716 | staChannel, MAC_ADDR_ARRAY(staBssid), ccMode); |
| 7717 | if (p2pChannel > 0) { |
| 7718 | n += pr_info("p2p-%s(%d) " MAC_ADDRESS_STR, |
| 7719 | p2pMode, p2pChannel, MAC_ADDR_ARRAY(p2pBssid)); |
| 7720 | } |
| 7721 | if (apChannel > 0) { |
| 7722 | n += pr_info("AP(%d) " MAC_ADDRESS_STR, |
| 7723 | apChannel, MAC_ADDR_ARRAY(apBssid)); |
| 7724 | } |
| 7725 | |
| 7726 | if (p2pChannel > 0 && apChannel > 0) { |
| 7727 | hddLog(VOS_TRACE_LEVEL_ERROR, "Error concurrent SAP %d and P2P %d which is not support", apChannel, p2pChannel); |
| 7728 | } |
| 7729 | } |
| 7730 | |
Madan Mohan Koyyalamudi | b5da533 | 2012-10-15 17:23:21 -0700 | [diff] [blame] | 7731 | bool hdd_is_ssr_required( void) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7732 | { |
Madan Mohan Koyyalamudi | b5da533 | 2012-10-15 17:23:21 -0700 | [diff] [blame] | 7733 | return (isSsrRequired == HDD_SSR_REQUIRED); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7734 | } |
| 7735 | |
Madan Mohan Koyyalamudi | b5da533 | 2012-10-15 17:23:21 -0700 | [diff] [blame] | 7736 | /* Once SSR is disabled then it cannot be set. */ |
| 7737 | void hdd_set_ssr_required( e_hdd_ssr_required value) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7738 | { |
Madan Mohan Koyyalamudi | b5da533 | 2012-10-15 17:23:21 -0700 | [diff] [blame] | 7739 | if (HDD_SSR_DISABLED == isSsrRequired) |
| 7740 | return; |
| 7741 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7742 | isSsrRequired = value; |
| 7743 | } |
| 7744 | |
| 7745 | VOS_STATUS hdd_get_front_adapter( hdd_context_t *pHddCtx, |
| 7746 | hdd_adapter_list_node_t** ppAdapterNode) |
| 7747 | { |
| 7748 | VOS_STATUS status; |
| 7749 | spin_lock(&pHddCtx->hddAdapters.lock); |
| 7750 | status = hdd_list_peek_front ( &pHddCtx->hddAdapters, |
| 7751 | (hdd_list_node_t**) ppAdapterNode ); |
| 7752 | spin_unlock(&pHddCtx->hddAdapters.lock); |
| 7753 | return status; |
| 7754 | } |
| 7755 | |
| 7756 | VOS_STATUS hdd_get_next_adapter( hdd_context_t *pHddCtx, |
| 7757 | hdd_adapter_list_node_t* pAdapterNode, |
| 7758 | hdd_adapter_list_node_t** pNextAdapterNode) |
| 7759 | { |
| 7760 | VOS_STATUS status; |
| 7761 | spin_lock(&pHddCtx->hddAdapters.lock); |
| 7762 | status = hdd_list_peek_next ( &pHddCtx->hddAdapters, |
| 7763 | (hdd_list_node_t*) pAdapterNode, |
| 7764 | (hdd_list_node_t**)pNextAdapterNode ); |
| 7765 | |
| 7766 | spin_unlock(&pHddCtx->hddAdapters.lock); |
| 7767 | return status; |
| 7768 | } |
| 7769 | |
| 7770 | VOS_STATUS hdd_remove_adapter( hdd_context_t *pHddCtx, |
| 7771 | hdd_adapter_list_node_t* pAdapterNode) |
| 7772 | { |
| 7773 | VOS_STATUS status; |
| 7774 | spin_lock(&pHddCtx->hddAdapters.lock); |
| 7775 | status = hdd_list_remove_node ( &pHddCtx->hddAdapters, |
| 7776 | &pAdapterNode->node ); |
| 7777 | spin_unlock(&pHddCtx->hddAdapters.lock); |
| 7778 | return status; |
| 7779 | } |
| 7780 | |
| 7781 | VOS_STATUS hdd_remove_front_adapter( hdd_context_t *pHddCtx, |
| 7782 | hdd_adapter_list_node_t** ppAdapterNode) |
| 7783 | { |
| 7784 | VOS_STATUS status; |
| 7785 | spin_lock(&pHddCtx->hddAdapters.lock); |
| 7786 | status = hdd_list_remove_front( &pHddCtx->hddAdapters, |
| 7787 | (hdd_list_node_t**) ppAdapterNode ); |
| 7788 | spin_unlock(&pHddCtx->hddAdapters.lock); |
| 7789 | return status; |
| 7790 | } |
| 7791 | |
| 7792 | VOS_STATUS hdd_add_adapter_back( hdd_context_t *pHddCtx, |
| 7793 | hdd_adapter_list_node_t* pAdapterNode) |
| 7794 | { |
| 7795 | VOS_STATUS status; |
| 7796 | spin_lock(&pHddCtx->hddAdapters.lock); |
| 7797 | status = hdd_list_insert_back ( &pHddCtx->hddAdapters, |
| 7798 | (hdd_list_node_t*) pAdapterNode ); |
| 7799 | spin_unlock(&pHddCtx->hddAdapters.lock); |
| 7800 | return status; |
| 7801 | } |
| 7802 | |
| 7803 | VOS_STATUS hdd_add_adapter_front( hdd_context_t *pHddCtx, |
| 7804 | hdd_adapter_list_node_t* pAdapterNode) |
| 7805 | { |
| 7806 | VOS_STATUS status; |
| 7807 | spin_lock(&pHddCtx->hddAdapters.lock); |
| 7808 | status = hdd_list_insert_front ( &pHddCtx->hddAdapters, |
| 7809 | (hdd_list_node_t*) pAdapterNode ); |
| 7810 | spin_unlock(&pHddCtx->hddAdapters.lock); |
| 7811 | return status; |
| 7812 | } |
| 7813 | |
| 7814 | hdd_adapter_t * hdd_get_adapter_by_macaddr( hdd_context_t *pHddCtx, |
| 7815 | tSirMacAddr macAddr ) |
| 7816 | { |
| 7817 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7818 | hdd_adapter_t *pAdapter; |
| 7819 | VOS_STATUS status; |
| 7820 | |
| 7821 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7822 | |
| 7823 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7824 | { |
| 7825 | pAdapter = pAdapterNode->pAdapter; |
| 7826 | |
| 7827 | if( pAdapter && vos_mem_compare( pAdapter->macAddressCurrent.bytes, |
| 7828 | macAddr, sizeof(tSirMacAddr) ) ) |
| 7829 | { |
| 7830 | return pAdapter; |
| 7831 | } |
| 7832 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7833 | pAdapterNode = pNext; |
| 7834 | } |
| 7835 | |
| 7836 | return NULL; |
| 7837 | |
| 7838 | } |
| 7839 | |
| 7840 | hdd_adapter_t * hdd_get_adapter_by_name( hdd_context_t *pHddCtx, tANI_U8 *name ) |
| 7841 | { |
| 7842 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7843 | hdd_adapter_t *pAdapter; |
| 7844 | VOS_STATUS status; |
| 7845 | |
| 7846 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7847 | |
| 7848 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7849 | { |
| 7850 | pAdapter = pAdapterNode->pAdapter; |
| 7851 | |
| 7852 | if( pAdapter && !strncmp( pAdapter->dev->name, (const char *)name, |
| 7853 | IFNAMSIZ ) ) |
| 7854 | { |
| 7855 | return pAdapter; |
| 7856 | } |
| 7857 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7858 | pAdapterNode = pNext; |
| 7859 | } |
| 7860 | |
| 7861 | return NULL; |
| 7862 | |
| 7863 | } |
| 7864 | |
| 7865 | hdd_adapter_t * hdd_get_adapter( hdd_context_t *pHddCtx, device_mode_t mode ) |
| 7866 | { |
| 7867 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7868 | hdd_adapter_t *pAdapter; |
| 7869 | VOS_STATUS status; |
| 7870 | |
| 7871 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7872 | |
| 7873 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7874 | { |
| 7875 | pAdapter = pAdapterNode->pAdapter; |
| 7876 | |
| 7877 | if( pAdapter && (mode == pAdapter->device_mode) ) |
| 7878 | { |
| 7879 | return pAdapter; |
| 7880 | } |
| 7881 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7882 | pAdapterNode = pNext; |
| 7883 | } |
| 7884 | |
| 7885 | return NULL; |
| 7886 | |
| 7887 | } |
| 7888 | |
| 7889 | //Remove this function later |
| 7890 | hdd_adapter_t * hdd_get_mon_adapter( hdd_context_t *pHddCtx ) |
| 7891 | { |
| 7892 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7893 | hdd_adapter_t *pAdapter; |
| 7894 | VOS_STATUS status; |
| 7895 | |
| 7896 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7897 | |
| 7898 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7899 | { |
| 7900 | pAdapter = pAdapterNode->pAdapter; |
| 7901 | |
| 7902 | if( pAdapter && WLAN_HDD_MONITOR == pAdapter->device_mode ) |
| 7903 | { |
| 7904 | return pAdapter; |
| 7905 | } |
| 7906 | |
| 7907 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7908 | pAdapterNode = pNext; |
| 7909 | } |
| 7910 | |
| 7911 | return NULL; |
| 7912 | |
| 7913 | } |
| 7914 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7915 | /**--------------------------------------------------------------------------- |
| 7916 | |
| 7917 | \brief hdd_set_monitor_tx_adapter() - |
| 7918 | |
| 7919 | This API initializes the adapter to be used while transmitting on monitor |
| 7920 | adapter. |
| 7921 | |
| 7922 | \param - pHddCtx - Pointer to the HDD context. |
| 7923 | pAdapter - Adapter that will used for TX. This can be NULL. |
| 7924 | \return - None. |
| 7925 | --------------------------------------------------------------------------*/ |
| 7926 | void wlan_hdd_set_monitor_tx_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter ) |
| 7927 | { |
| 7928 | hdd_adapter_t *pMonAdapter; |
| 7929 | |
| 7930 | pMonAdapter = hdd_get_adapter( pHddCtx, WLAN_HDD_MONITOR ); |
| 7931 | |
| 7932 | if( NULL != pMonAdapter ) |
| 7933 | { |
| 7934 | pMonAdapter->sessionCtx.monitor.pAdapterForTx = pAdapter; |
| 7935 | } |
| 7936 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7937 | /**--------------------------------------------------------------------------- |
| 7938 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 7939 | \brief hdd_get_operating_channel() - |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7940 | |
| 7941 | This API returns the operating channel of the requested device mode |
| 7942 | |
| 7943 | \param - pHddCtx - Pointer to the HDD context. |
| 7944 | - mode - Device mode for which operating channel is required |
| 7945 | suported modes - WLAN_HDD_INFRA_STATION, WLAN_HDD_P2P_CLIENT |
| 7946 | WLAN_HDD_SOFTAP, WLAN_HDD_P2P_GO. |
| 7947 | \return - channel number. "0" id the requested device is not found OR it is not connected. |
| 7948 | --------------------------------------------------------------------------*/ |
| 7949 | v_U8_t hdd_get_operating_channel( hdd_context_t *pHddCtx, device_mode_t mode ) |
| 7950 | { |
| 7951 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7952 | VOS_STATUS status; |
| 7953 | hdd_adapter_t *pAdapter; |
| 7954 | v_U8_t operatingChannel = 0; |
| 7955 | |
| 7956 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7957 | |
| 7958 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 7959 | { |
| 7960 | pAdapter = pAdapterNode->pAdapter; |
| 7961 | |
| 7962 | if( mode == pAdapter->device_mode ) |
| 7963 | { |
| 7964 | switch(pAdapter->device_mode) |
| 7965 | { |
| 7966 | case WLAN_HDD_INFRA_STATION: |
| 7967 | case WLAN_HDD_P2P_CLIENT: |
| 7968 | if( hdd_connIsConnected( WLAN_HDD_GET_STATION_CTX_PTR( pAdapter )) ) |
| 7969 | operatingChannel = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.operationChannel; |
| 7970 | break; |
| 7971 | case WLAN_HDD_SOFTAP: |
| 7972 | case WLAN_HDD_P2P_GO: |
| 7973 | /*softap connection info */ |
| 7974 | if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags)) |
| 7975 | operatingChannel = (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->operatingChannel; |
| 7976 | break; |
| 7977 | default: |
| 7978 | break; |
| 7979 | } |
| 7980 | |
| 7981 | break; //Found the device of interest. break the loop |
| 7982 | } |
| 7983 | |
| 7984 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7985 | pAdapterNode = pNext; |
| 7986 | } |
| 7987 | return operatingChannel; |
| 7988 | } |
| 7989 | |
| 7990 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 7991 | /**--------------------------------------------------------------------------- |
| 7992 | |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 7993 | \brief __hdd_set_multicast_list() - |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7994 | |
| 7995 | This used to set the multicast address list. |
| 7996 | |
| 7997 | \param - dev - Pointer to the WLAN device. |
| 7998 | - skb - Pointer to OS packet (sk_buff). |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 7999 | \return - success/fail |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8000 | |
| 8001 | --------------------------------------------------------------------------*/ |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 8002 | static void __hdd_set_multicast_list(struct net_device *dev) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8003 | { |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 8004 | hdd_adapter_t *pAdapter; |
| 8005 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8006 | int mc_count; |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 8007 | int i = 0, ret = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8008 | struct netdev_hw_addr *ha; |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 8009 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 8010 | ENTER(); |
| 8011 | |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 8012 | pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 8013 | if (NULL == pAdapter) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8014 | { |
| 8015 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 8016 | "%s: Adapter context is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8017 | return; |
| 8018 | } |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 8019 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 8020 | ret = wlan_hdd_validate_context(pHddCtx); |
| 8021 | if (0 != ret) |
| 8022 | { |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 8023 | return; |
| 8024 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8025 | if (dev->flags & IFF_ALLMULTI) |
| 8026 | { |
| 8027 | hddLog(VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 8028 | "%s: allow all multicast frames", __func__); |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 8029 | pAdapter->mc_addr_list.mc_cnt = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8030 | } |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 8031 | else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8032 | { |
| 8033 | mc_count = netdev_mc_count(dev); |
| 8034 | hddLog(VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 8035 | "%s: mc_count = %u", __func__, mc_count); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8036 | if (mc_count > WLAN_HDD_MAX_MC_ADDR_LIST) |
| 8037 | { |
| 8038 | hddLog(VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 8039 | "%s: No free filter available; allow all multicast frames", __func__); |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 8040 | pAdapter->mc_addr_list.mc_cnt = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8041 | return; |
| 8042 | } |
| 8043 | |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 8044 | pAdapter->mc_addr_list.mc_cnt = mc_count; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8045 | |
| 8046 | netdev_for_each_mc_addr(ha, dev) { |
| 8047 | if (i == mc_count) |
| 8048 | break; |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 8049 | memset(&(pAdapter->mc_addr_list.addr[i][0]), 0, ETH_ALEN); |
| 8050 | memcpy(&(pAdapter->mc_addr_list.addr[i][0]), ha->addr, ETH_ALEN); |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 8051 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: mlist[%d] = "MAC_ADDRESS_STR, |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 8052 | __func__, i, |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 8053 | MAC_ADDR_ARRAY(pAdapter->mc_addr_list.addr[i])); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8054 | i++; |
| 8055 | } |
| 8056 | } |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 8057 | |
| 8058 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8059 | return; |
| 8060 | } |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 8061 | |
| 8062 | static void hdd_set_multicast_list(struct net_device *dev) |
| 8063 | { |
| 8064 | vos_ssr_protect(__func__); |
| 8065 | __hdd_set_multicast_list(dev); |
| 8066 | vos_ssr_unprotect(__func__); |
| 8067 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8068 | #endif |
| 8069 | |
| 8070 | /**--------------------------------------------------------------------------- |
| 8071 | |
| 8072 | \brief hdd_select_queue() - |
| 8073 | |
| 8074 | This function is registered with the Linux OS for network |
| 8075 | core to decide which queue to use first. |
| 8076 | |
| 8077 | \param - dev - Pointer to the WLAN device. |
| 8078 | - skb - Pointer to OS packet (sk_buff). |
| 8079 | \return - ac, Queue Index/access category corresponding to UP in IP header |
| 8080 | |
| 8081 | --------------------------------------------------------------------------*/ |
| 8082 | v_U16_t hdd_select_queue(struct net_device *dev, |
| 8083 | struct sk_buff *skb) |
| 8084 | { |
| 8085 | return hdd_wmm_select_queue(dev, skb); |
| 8086 | } |
| 8087 | |
| 8088 | |
| 8089 | /**--------------------------------------------------------------------------- |
| 8090 | |
| 8091 | \brief hdd_wlan_initial_scan() - |
| 8092 | |
| 8093 | This function triggers the initial scan |
| 8094 | |
| 8095 | \param - pAdapter - Pointer to the HDD adapter. |
| 8096 | |
| 8097 | --------------------------------------------------------------------------*/ |
| 8098 | void hdd_wlan_initial_scan(hdd_adapter_t *pAdapter) |
| 8099 | { |
| 8100 | tCsrScanRequest scanReq; |
| 8101 | tCsrChannelInfo channelInfo; |
| 8102 | eHalStatus halStatus; |
Jeff Johnson | 0279779 | 2013-10-26 19:17:13 -0700 | [diff] [blame] | 8103 | tANI_U32 scanId; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8104 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 8105 | |
| 8106 | vos_mem_zero(&scanReq, sizeof(tCsrScanRequest)); |
| 8107 | vos_mem_set(&scanReq.bssid, sizeof(tCsrBssid), 0xff); |
| 8108 | scanReq.BSSType = eCSR_BSS_TYPE_ANY; |
| 8109 | |
| 8110 | if(sme_Is11dSupported(pHddCtx->hHal)) |
| 8111 | { |
| 8112 | halStatus = sme_ScanGetBaseChannels( pHddCtx->hHal, &channelInfo ); |
| 8113 | if ( HAL_STATUS_SUCCESS( halStatus ) ) |
| 8114 | { |
| 8115 | scanReq.ChannelInfo.ChannelList = vos_mem_malloc(channelInfo.numOfChannels); |
| 8116 | if( !scanReq.ChannelInfo.ChannelList ) |
| 8117 | { |
| 8118 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s kmalloc failed", __func__); |
| 8119 | vos_mem_free(channelInfo.ChannelList); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 8120 | channelInfo.ChannelList = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8121 | return; |
| 8122 | } |
| 8123 | vos_mem_copy(scanReq.ChannelInfo.ChannelList, channelInfo.ChannelList, |
| 8124 | channelInfo.numOfChannels); |
| 8125 | scanReq.ChannelInfo.numOfChannels = channelInfo.numOfChannels; |
| 8126 | vos_mem_free(channelInfo.ChannelList); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 8127 | channelInfo.ChannelList = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8128 | } |
| 8129 | |
| 8130 | scanReq.scanType = eSIR_PASSIVE_SCAN; |
| 8131 | scanReq.requestType = eCSR_SCAN_REQUEST_11D_SCAN; |
| 8132 | scanReq.maxChnTime = pHddCtx->cfg_ini->nPassiveMaxChnTime; |
| 8133 | scanReq.minChnTime = pHddCtx->cfg_ini->nPassiveMinChnTime; |
| 8134 | } |
| 8135 | else |
| 8136 | { |
| 8137 | scanReq.scanType = eSIR_ACTIVE_SCAN; |
| 8138 | scanReq.requestType = eCSR_SCAN_REQUEST_FULL_SCAN; |
| 8139 | scanReq.maxChnTime = pHddCtx->cfg_ini->nActiveMaxChnTime; |
| 8140 | scanReq.minChnTime = pHddCtx->cfg_ini->nActiveMinChnTime; |
| 8141 | } |
| 8142 | |
| 8143 | halStatus = sme_ScanRequest(pHddCtx->hHal, pAdapter->sessionId, &scanReq, &scanId, NULL, NULL); |
| 8144 | if ( !HAL_STATUS_SUCCESS( halStatus ) ) |
| 8145 | { |
| 8146 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_ScanRequest failed status code %d", |
| 8147 | __func__, halStatus ); |
| 8148 | } |
| 8149 | |
| 8150 | if(sme_Is11dSupported(pHddCtx->hHal)) |
| 8151 | vos_mem_free(scanReq.ChannelInfo.ChannelList); |
| 8152 | } |
| 8153 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8154 | /**--------------------------------------------------------------------------- |
| 8155 | |
| 8156 | \brief hdd_full_power_callback() - HDD full power callback function |
| 8157 | |
| 8158 | This is the function invoked by SME to inform the result of a full power |
| 8159 | request issued by HDD |
| 8160 | |
| 8161 | \param - callbackcontext - Pointer to cookie |
| 8162 | \param - status - result of request |
| 8163 | |
| 8164 | \return - None |
| 8165 | |
| 8166 | --------------------------------------------------------------------------*/ |
| 8167 | static void hdd_full_power_callback(void *callbackContext, eHalStatus status) |
| 8168 | { |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 8169 | struct statsContext *pContext = callbackContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8170 | |
| 8171 | hddLog(VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 8172 | "%s: context = %p, status = %d", __func__, pContext, status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8173 | |
| 8174 | if (NULL == callbackContext) |
| 8175 | { |
| 8176 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8177 | "%s: Bad param, context [%p]", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 8178 | __func__, callbackContext); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8179 | return; |
| 8180 | } |
| 8181 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 8182 | /* there is a race condition that exists between this callback |
| 8183 | function and the caller since the caller could time out either |
| 8184 | before or while this code is executing. we use a spinlock to |
| 8185 | serialize these actions */ |
| 8186 | spin_lock(&hdd_context_lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8187 | |
| 8188 | if (POWER_CONTEXT_MAGIC != pContext->magic) |
| 8189 | { |
| 8190 | /* the caller presumably timed out so there is nothing we can do */ |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 8191 | spin_unlock(&hdd_context_lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8192 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 8193 | "%s: Invalid context, magic [%08x]", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 8194 | __func__, pContext->magic); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8195 | return; |
| 8196 | } |
| 8197 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 8198 | /* context is valid so caller is still waiting */ |
| 8199 | |
| 8200 | /* paranoia: invalidate the magic */ |
| 8201 | pContext->magic = 0; |
| 8202 | |
| 8203 | /* notify the caller */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8204 | complete(&pContext->completion); |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 8205 | |
| 8206 | /* serialization is complete */ |
| 8207 | spin_unlock(&hdd_context_lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8208 | } |
| 8209 | |
| 8210 | /**--------------------------------------------------------------------------- |
| 8211 | |
| 8212 | \brief hdd_wlan_exit() - HDD WLAN exit function |
| 8213 | |
| 8214 | This is the driver exit point (invoked during rmmod) |
| 8215 | |
| 8216 | \param - pHddCtx - Pointer to the HDD Context |
| 8217 | |
| 8218 | \return - None |
| 8219 | |
| 8220 | --------------------------------------------------------------------------*/ |
| 8221 | void hdd_wlan_exit(hdd_context_t *pHddCtx) |
| 8222 | { |
| 8223 | eHalStatus halStatus; |
| 8224 | v_CONTEXT_t pVosContext = pHddCtx->pvosContext; |
| 8225 | VOS_STATUS vosStatus; |
Gopichand Nakkala | 66923aa | 2013-03-06 23:17:24 +0530 | [diff] [blame] | 8226 | struct wiphy *wiphy = pHddCtx->wiphy; |
Mingcheng Zhu | 87f22fc | 2014-01-30 19:23:32 -0800 | [diff] [blame] | 8227 | hdd_adapter_t* pAdapter = NULL; |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 8228 | struct statsContext powerContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8229 | long lrc; |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 8230 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8231 | |
| 8232 | ENTER(); |
| 8233 | |
Vinay Krishna Eranna | f97ef5c | 2014-12-26 17:47:19 +0530 | [diff] [blame] | 8234 | |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 8235 | if (VOS_FTM_MODE != hdd_get_conparam()) |
| 8236 | { |
| 8237 | // Unloading, restart logic is no more required. |
| 8238 | wlan_hdd_restart_deinit(pHddCtx); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8239 | |
Agarwal Ashish | b20e0ff | 2014-12-17 22:50:19 +0530 | [diff] [blame] | 8240 | #ifdef FEATURE_WLAN_TDLS |
| 8241 | /* At the time of driver unloading; if tdls connection is present; |
| 8242 | * hdd_rx_packet_cbk calls wlan_hdd_tdls_find_peer. |
| 8243 | * wlan_hdd_tdls_find_peer always checks for valid context; |
| 8244 | * as load/unload in progress there can be a race condition. |
| 8245 | * hdd_rx_packet_cbk calls wlan_hdd_tdls_find_peer only |
| 8246 | * when tdls state is enabled. |
| 8247 | * As soon as driver set load/unload flag; tdls flag also needs |
| 8248 | * to be disabled so that hdd_rx_packet_cbk won't call |
| 8249 | * wlan_hdd_tdls_find_peer. |
| 8250 | */ |
| 8251 | wlan_hdd_tdls_set_mode(pHddCtx, eTDLS_SUPPORT_DISABLED, FALSE); |
| 8252 | #endif |
| 8253 | |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 8254 | vosStatus = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 8255 | while (NULL != pAdapterNode && VOS_STATUS_E_EMPTY != vosStatus) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8256 | { |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 8257 | pAdapter = pAdapterNode->pAdapter; |
| 8258 | if (NULL != pAdapter) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8259 | { |
Mahesh A Saptasagar | 305e263 | 2015-03-04 12:57:33 +0530 | [diff] [blame] | 8260 | /* Disable TX on the interface, after this hard_start_xmit() will |
| 8261 | * not be called on that interface |
| 8262 | */ |
| 8263 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues")); |
| 8264 | netif_tx_disable(pAdapter->dev); |
| 8265 | |
| 8266 | /* Mark the interface status as "down" for outside world */ |
| 8267 | netif_carrier_off(pAdapter->dev); |
| 8268 | |
Agarwal Ashish | 9ffa5b9 | 2014-11-18 21:07:02 +0530 | [diff] [blame] | 8269 | /* DeInit the adapter. This ensures that all data packets |
| 8270 | * are freed. |
| 8271 | */ |
Mahesh A Saptasagar | 02e36e8 | 2015-01-14 20:39:19 +0530 | [diff] [blame] | 8272 | #ifdef FEATURE_WLAN_TDLS |
| 8273 | mutex_lock(&pHddCtx->tdls_lock); |
| 8274 | #endif |
c_hpothu | 002231a | 2015-02-05 14:58:51 +0530 | [diff] [blame] | 8275 | hdd_deinit_adapter(pHddCtx, pAdapter, FALSE); |
Mahesh A Saptasagar | 02e36e8 | 2015-01-14 20:39:19 +0530 | [diff] [blame] | 8276 | #ifdef FEATURE_WLAN_TDLS |
| 8277 | mutex_unlock(&pHddCtx->tdls_lock); |
| 8278 | #endif |
Agarwal Ashish | 9ffa5b9 | 2014-11-18 21:07:02 +0530 | [diff] [blame] | 8279 | |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 8280 | if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode || |
| 8281 | WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) |
| 8282 | { |
| 8283 | wlan_hdd_cfg80211_deregister_frames(pAdapter); |
| 8284 | hdd_UnregisterWext(pAdapter->dev); |
| 8285 | } |
Kaushik, Sushant | 4975a57 | 2014-10-21 16:07:48 +0530 | [diff] [blame] | 8286 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8287 | } |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 8288 | vosStatus = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 8289 | pAdapterNode = pNext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8290 | } |
Kaushik, Sushant | 4975a57 | 2014-10-21 16:07:48 +0530 | [diff] [blame] | 8291 | // Cancel any outstanding scan requests. We are about to close all |
| 8292 | // of our adapters, but an adapter structure is what SME passes back |
| 8293 | // to our callback function. Hence if there are any outstanding scan |
| 8294 | // requests then there is a race condition between when the adapter |
| 8295 | // is closed and when the callback is invoked.We try to resolve that |
| 8296 | // race condition here by canceling any outstanding scans before we |
| 8297 | // close the adapters. |
| 8298 | // Note that the scans may be cancelled in an asynchronous manner, |
| 8299 | // so ideally there needs to be some kind of synchronization. Rather |
| 8300 | // than introduce a new synchronization here, we will utilize the |
| 8301 | // fact that we are about to Request Full Power, and since that is |
| 8302 | // synchronized, the expectation is that by the time Request Full |
| 8303 | // Power has completed all scans will be cancelled. |
| 8304 | if (pHddCtx->scan_info.mScanPending) |
| 8305 | { |
Hema Aparna Medicharla | f05f6cd | 2015-01-21 14:44:19 +0530 | [diff] [blame] | 8306 | if(NULL != pAdapter) |
| 8307 | { |
| 8308 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 8309 | FL("abort scan mode: %d sessionId: %d"), |
| 8310 | pAdapter->device_mode, |
| 8311 | pAdapter->sessionId); |
| 8312 | } |
| 8313 | hdd_abort_mac_scan(pHddCtx, |
| 8314 | pHddCtx->scan_info.sessionId, |
| 8315 | eCSR_SCAN_ABORT_DEFAULT); |
Kaushik, Sushant | 4975a57 | 2014-10-21 16:07:48 +0530 | [diff] [blame] | 8316 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8317 | } |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 8318 | else |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 8319 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8320 | hddLog(VOS_TRACE_LEVEL_INFO,"%s: FTM MODE",__func__); |
Hanumantha Reddy Pothula | 45af96b | 2015-02-12 16:07:58 +0530 | [diff] [blame] | 8321 | if (pHddCtx->ftm.ftm_state == WLAN_FTM_STARTING) |
| 8322 | { |
| 8323 | INIT_COMPLETION(pHddCtx->ftm.startCmpVar); |
| 8324 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8325 | "%s: in middle of FTM START", __func__); |
| 8326 | lrc = wait_for_completion_timeout(&pHddCtx->ftm.startCmpVar, |
| 8327 | msecs_to_jiffies(20000)); |
| 8328 | if(!lrc) |
| 8329 | { |
| 8330 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 8331 | "%s: timedout on ftmStartCmpVar fatal error", __func__); |
| 8332 | } |
| 8333 | } |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 8334 | wlan_hdd_ftm_close(pHddCtx); |
| 8335 | goto free_hdd_ctx; |
| 8336 | } |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8337 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8338 | /* DeRegister with platform driver as client for Suspend/Resume */ |
| 8339 | vosStatus = hddDeregisterPmOps(pHddCtx); |
| 8340 | if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) ) |
| 8341 | { |
| 8342 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddDeregisterPmOps failed",__func__); |
| 8343 | VOS_ASSERT(0); |
| 8344 | } |
| 8345 | |
| 8346 | vosStatus = hddDevTmUnregisterNotifyCallback(pHddCtx); |
| 8347 | if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) ) |
| 8348 | { |
| 8349 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddDevTmUnregisterNotifyCallback failed",__func__); |
| 8350 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8351 | |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 8352 | //Stop the traffic monitor timer |
| 8353 | if ( VOS_TIMER_STATE_RUNNING == |
| 8354 | vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)) |
| 8355 | { |
| 8356 | vos_timer_stop(&pHddCtx->tx_rx_trafficTmr); |
| 8357 | } |
| 8358 | |
| 8359 | // Destroy the traffic monitor timer |
| 8360 | if (!VOS_IS_STATUS_SUCCESS(vos_timer_destroy( |
| 8361 | &pHddCtx->tx_rx_trafficTmr))) |
| 8362 | { |
| 8363 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8364 | "%s: Cannot deallocate Traffic monitor timer", __func__); |
| 8365 | } |
| 8366 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8367 | //Disable IMPS/BMPS as we do not want the device to enter any power |
| 8368 | //save mode during shutdown |
| 8369 | sme_DisablePowerSave(pHddCtx->hHal, ePMC_IDLE_MODE_POWER_SAVE); |
| 8370 | sme_DisablePowerSave(pHddCtx->hHal, ePMC_BEACON_MODE_POWER_SAVE); |
| 8371 | sme_DisablePowerSave(pHddCtx->hHal, ePMC_UAPSD_MODE_POWER_SAVE); |
| 8372 | |
| 8373 | //Ensure that device is in full power as we will touch H/W during vos_Stop |
| 8374 | init_completion(&powerContext.completion); |
| 8375 | powerContext.magic = POWER_CONTEXT_MAGIC; |
| 8376 | |
| 8377 | halStatus = sme_RequestFullPower(pHddCtx->hHal, hdd_full_power_callback, |
| 8378 | &powerContext, eSME_FULL_PWR_NEEDED_BY_HDD); |
| 8379 | |
| 8380 | if (eHAL_STATUS_SUCCESS != halStatus) |
| 8381 | { |
| 8382 | if (eHAL_STATUS_PMC_PENDING == halStatus) |
| 8383 | { |
| 8384 | /* request was sent -- wait for the response */ |
| 8385 | lrc = wait_for_completion_interruptible_timeout( |
| 8386 | &powerContext.completion, |
| 8387 | msecs_to_jiffies(WLAN_WAIT_TIME_POWER)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8388 | if (lrc <= 0) |
| 8389 | { |
| 8390 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s while requesting full power", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 8391 | __func__, (0 == lrc) ? "timeout" : "interrupt"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8392 | } |
| 8393 | } |
| 8394 | else |
| 8395 | { |
| 8396 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8397 | "%s: Request for Full Power failed, status %d", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 8398 | __func__, halStatus); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8399 | /* continue -- need to clean up as much as possible */ |
| 8400 | } |
| 8401 | } |
Hanumantha Reddy Pothula | 81b42b2 | 2015-05-12 13:52:00 +0530 | [diff] [blame] | 8402 | if ((eHAL_STATUS_SUCCESS == halStatus) || |
| 8403 | (eHAL_STATUS_PMC_PENDING == halStatus && lrc > 0)) |
| 8404 | { |
| 8405 | /* This will issue a dump command which will clean up |
| 8406 | BTQM queues and unblock MC thread */ |
| 8407 | vos_fwDumpReq(274, 0, 0, 0, 0, 1); |
| 8408 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8409 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 8410 | /* either we never sent a request, we sent a request and received a |
| 8411 | response or we sent a request and timed out. if we never sent a |
| 8412 | request or if we sent a request and got a response, we want to |
| 8413 | clear the magic out of paranoia. if we timed out there is a |
| 8414 | race condition such that the callback function could be |
| 8415 | executing at the same time we are. of primary concern is if the |
| 8416 | callback function had already verified the "magic" but had not |
| 8417 | yet set the completion variable when a timeout occurred. we |
| 8418 | serialize these activities by invalidating the magic while |
| 8419 | holding a shared spinlock which will cause us to block if the |
| 8420 | callback is currently executing */ |
| 8421 | spin_lock(&hdd_context_lock); |
| 8422 | powerContext.magic = 0; |
| 8423 | spin_unlock(&hdd_context_lock); |
| 8424 | |
Yue Ma | 0d4891e | 2013-08-06 17:01:45 -0700 | [diff] [blame] | 8425 | hdd_debugfs_exit(pHddCtx); |
| 8426 | |
Ratheesh S P | 35ed8b1 | 2015-04-27 14:01:07 +0530 | [diff] [blame] | 8427 | #ifdef WLAN_NS_OFFLOAD |
| 8428 | hddLog(LOGE, FL("Unregister IPv6 notifier")); |
| 8429 | unregister_inet6addr_notifier(&pHddCtx->ipv6_notifier); |
| 8430 | #endif |
| 8431 | hddLog(LOGE, FL("Unregister IPv4 notifier")); |
| 8432 | unregister_inetaddr_notifier(&pHddCtx->ipv4_notifier); |
| 8433 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8434 | // Unregister the Net Device Notifier |
| 8435 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 8436 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8437 | hdd_stop_all_adapters( pHddCtx ); |
| 8438 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8439 | #ifdef WLAN_BTAMP_FEATURE |
| 8440 | vosStatus = WLANBAP_Stop(pVosContext); |
| 8441 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) |
| 8442 | { |
| 8443 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 8444 | "%s: Failed to stop BAP",__func__); |
| 8445 | } |
| 8446 | #endif //WLAN_BTAMP_FEATURE |
| 8447 | |
| 8448 | //Stop all the modules |
| 8449 | vosStatus = vos_stop( pVosContext ); |
| 8450 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) |
| 8451 | { |
| 8452 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 8453 | "%s: Failed to stop VOSS",__func__); |
| 8454 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) ); |
| 8455 | } |
| 8456 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8457 | //This requires pMac access, Call this before vos_close(). |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8458 | hdd_unregister_mcast_bcast_filter(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8459 | |
| 8460 | //Close the scheduler before calling vos_close to make sure no thread is |
| 8461 | // scheduled after the each module close is called i.e after all the data |
| 8462 | // structures are freed. |
| 8463 | vosStatus = vos_sched_close( pVosContext ); |
| 8464 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) { |
| 8465 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, |
| 8466 | "%s: Failed to close VOSS Scheduler",__func__); |
| 8467 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) ); |
| 8468 | } |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 8469 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8470 | #ifdef WLAN_FEATURE_HOLD_RX_WAKELOCK |
| 8471 | /* Destroy the wake lock */ |
| 8472 | wake_lock_destroy(&pHddCtx->rx_wake_lock); |
| 8473 | #endif |
Madan Mohan Koyyalamudi | 69fc3ad | 2012-11-28 16:04:56 -0800 | [diff] [blame] | 8474 | /* Destroy the wake lock */ |
| 8475 | wake_lock_destroy(&pHddCtx->sap_wake_lock); |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 8476 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8477 | |
Mihir Shete | 7a24b5f | 2013-12-21 12:18:31 +0530 | [diff] [blame] | 8478 | #ifdef CONFIG_ENABLE_LINUX_REG |
| 8479 | vosStatus = vos_nv_close(); |
| 8480 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) |
| 8481 | { |
| 8482 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 8483 | "%s: Failed to close NV", __func__); |
| 8484 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) ); |
| 8485 | } |
| 8486 | #endif |
| 8487 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8488 | //Close VOSS |
| 8489 | //This frees pMac(HAL) context. There should not be any call that requires pMac access after this. |
| 8490 | vos_close(pVosContext); |
| 8491 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8492 | //Close Watchdog |
| 8493 | if(pHddCtx->cfg_ini->fIsLogpEnabled) |
| 8494 | vos_watchdog_close(pVosContext); |
| 8495 | |
Gopichand Nakkala | a035848 | 2013-06-12 17:05:47 +0530 | [diff] [blame] | 8496 | //Clean up HDD Nlink Service |
| 8497 | send_btc_nlink_msg(WLAN_MODULE_DOWN_IND, 0); |
Gopichand Nakkala | a035848 | 2013-06-12 17:05:47 +0530 | [diff] [blame] | 8498 | |
Vinay Krishna Eranna | d938c42 | 2014-03-10 17:14:21 +0530 | [diff] [blame] | 8499 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 8500 | if (pHddCtx->cfg_ini->wlanLoggingEnable) |
Vinay Krishna Eranna | d938c42 | 2014-03-10 17:14:21 +0530 | [diff] [blame] | 8501 | { |
| 8502 | wlan_logging_sock_deactivate_svc(); |
| 8503 | } |
| 8504 | #endif |
| 8505 | |
Vinay Krishna Eranna | ef30b52 | 2014-08-26 17:48:16 +0530 | [diff] [blame] | 8506 | #ifdef WLAN_KD_READY_NOTIFIER |
| 8507 | nl_srv_exit(pHddCtx->ptt_pid); |
| 8508 | #else |
| 8509 | nl_srv_exit(); |
| 8510 | #endif /* WLAN_KD_READY_NOTIFIER */ |
| 8511 | |
| 8512 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8513 | hdd_close_all_adapters( pHddCtx ); |
| 8514 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8515 | /* free the power on lock from platform driver */ |
| 8516 | if (free_riva_power_on_lock("wlan")) |
| 8517 | { |
| 8518 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to free power on lock", |
| 8519 | __func__); |
| 8520 | } |
| 8521 | |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 8522 | free_hdd_ctx: |
c_hpothu | 78c7b60 | 2014-05-17 17:35:49 +0530 | [diff] [blame] | 8523 | |
| 8524 | //Free up dynamically allocated members inside HDD Adapter |
| 8525 | if (pHddCtx->cfg_ini) |
| 8526 | { |
| 8527 | kfree(pHddCtx->cfg_ini); |
| 8528 | pHddCtx->cfg_ini= NULL; |
| 8529 | } |
| 8530 | |
Leo Chang | f04ddad | 2013-09-18 13:46:38 -0700 | [diff] [blame] | 8531 | /* FTM mode, WIPHY did not registered |
| 8532 | If un-register here, system crash will happen */ |
| 8533 | if (VOS_FTM_MODE != hdd_get_conparam()) |
| 8534 | { |
| 8535 | wiphy_unregister(wiphy) ; |
| 8536 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8537 | wiphy_free(wiphy) ; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8538 | if (hdd_is_ssr_required()) |
| 8539 | { |
| 8540 | /* WDI timeout had happened during unload, so SSR is needed here */ |
Madan Mohan Koyyalamudi | 3246f5b | 2012-10-15 15:40:02 -0700 | [diff] [blame] | 8541 | subsystem_restart("wcnss"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8542 | msleep(5000); |
| 8543 | } |
| 8544 | hdd_set_ssr_required (VOS_FALSE); |
| 8545 | } |
| 8546 | |
| 8547 | |
| 8548 | /**--------------------------------------------------------------------------- |
| 8549 | |
| 8550 | \brief hdd_update_config_from_nv() - Function to update the contents of |
| 8551 | the running configuration with parameters taken from NV storage |
| 8552 | |
| 8553 | \param - pHddCtx - Pointer to the HDD global context |
| 8554 | |
| 8555 | \return - VOS_STATUS_SUCCESS if successful |
| 8556 | |
| 8557 | --------------------------------------------------------------------------*/ |
| 8558 | static VOS_STATUS hdd_update_config_from_nv(hdd_context_t* pHddCtx) |
| 8559 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8560 | v_BOOL_t itemIsValid = VOS_FALSE; |
| 8561 | VOS_STATUS status; |
| 8562 | v_MACADDR_t macFromNV[VOS_MAX_CONCURRENCY_PERSONA]; |
| 8563 | v_U8_t macLoop; |
| 8564 | |
| 8565 | /*If the NV is valid then get the macaddress from nv else get it from qcom_cfg.ini*/ |
| 8566 | status = vos_nv_getValidity(VNV_FIELD_IMAGE, &itemIsValid); |
| 8567 | if(status != VOS_STATUS_SUCCESS) |
| 8568 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 8569 | hddLog(VOS_TRACE_LEVEL_ERROR," vos_nv_getValidity() failed"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8570 | return VOS_STATUS_E_FAILURE; |
| 8571 | } |
| 8572 | |
| 8573 | if (itemIsValid == VOS_TRUE) |
| 8574 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 8575 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH," Reading the Macaddress from NV"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8576 | status = vos_nv_readMultiMacAddress((v_U8_t *)&macFromNV[0].bytes[0], |
| 8577 | VOS_MAX_CONCURRENCY_PERSONA); |
| 8578 | if(status != VOS_STATUS_SUCCESS) |
| 8579 | { |
| 8580 | /* Get MAC from NV fail, not update CFG info |
| 8581 | * INI MAC value will be used for MAC setting */ |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 8582 | hddLog(VOS_TRACE_LEVEL_ERROR," vos_nv_readMacAddress() failed"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8583 | return VOS_STATUS_E_FAILURE; |
| 8584 | } |
| 8585 | |
| 8586 | /* If first MAC is not valid, treat all others are not valid |
| 8587 | * Then all MACs will be got from ini file */ |
| 8588 | if(vos_is_macaddr_zero(&macFromNV[0])) |
| 8589 | { |
| 8590 | /* MAC address in NV file is not configured yet */ |
| 8591 | hddLog(VOS_TRACE_LEVEL_WARN, "Invalid MAC in NV file"); |
| 8592 | return VOS_STATUS_E_INVAL; |
| 8593 | } |
| 8594 | |
| 8595 | /* Get MAC address from NV, update CFG info */ |
| 8596 | for(macLoop = 0; macLoop < VOS_MAX_CONCURRENCY_PERSONA; macLoop++) |
| 8597 | { |
| 8598 | if(vos_is_macaddr_zero(&macFromNV[macLoop])) |
| 8599 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8600 | 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] | 8601 | /* This MAC is not valid, skip it |
| 8602 | * This MAC will be got from ini file */ |
| 8603 | } |
| 8604 | else |
| 8605 | { |
| 8606 | vos_mem_copy((v_U8_t *)&pHddCtx->cfg_ini->intfMacAddr[macLoop].bytes[0], |
| 8607 | (v_U8_t *)&macFromNV[macLoop].bytes[0], |
| 8608 | VOS_MAC_ADDR_SIZE); |
| 8609 | } |
| 8610 | } |
| 8611 | } |
| 8612 | else |
| 8613 | { |
| 8614 | hddLog(VOS_TRACE_LEVEL_ERROR, "NV ITEM, MAC Not valid"); |
| 8615 | return VOS_STATUS_E_FAILURE; |
| 8616 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8617 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8618 | |
| 8619 | return VOS_STATUS_SUCCESS; |
| 8620 | } |
| 8621 | |
| 8622 | /**--------------------------------------------------------------------------- |
| 8623 | |
| 8624 | \brief hdd_post_voss_start_config() - HDD post voss start config helper |
| 8625 | |
| 8626 | \param - pAdapter - Pointer to the HDD |
| 8627 | |
| 8628 | \return - None |
| 8629 | |
| 8630 | --------------------------------------------------------------------------*/ |
| 8631 | VOS_STATUS hdd_post_voss_start_config(hdd_context_t* pHddCtx) |
| 8632 | { |
| 8633 | eHalStatus halStatus; |
| 8634 | v_U32_t listenInterval; |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 8635 | tANI_U32 ignoreDtim; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8636 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8637 | |
| 8638 | // Send ready indication to the HDD. This will kick off the MAC |
| 8639 | // into a 'running' state and should kick off an initial scan. |
| 8640 | halStatus = sme_HDDReadyInd( pHddCtx->hHal ); |
| 8641 | if ( !HAL_STATUS_SUCCESS( halStatus ) ) |
| 8642 | { |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 8643 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: sme_HDDReadyInd() failed with status " |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8644 | "code %08d [x%08x]",__func__, halStatus, halStatus ); |
| 8645 | return VOS_STATUS_E_FAILURE; |
| 8646 | } |
| 8647 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 8648 | // Set default LI and ignoreDtim into HDD context, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8649 | // otherwise under some race condition, HDD will set 0 LI value into RIVA, |
| 8650 | // And RIVA will crash |
| 8651 | wlan_cfgGetInt(pHddCtx->hHal, WNI_CFG_LISTEN_INTERVAL, &listenInterval); |
| 8652 | pHddCtx->hdd_actual_LI_value = listenInterval; |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 8653 | wlan_cfgGetInt(pHddCtx->hHal, WNI_CFG_IGNORE_DTIM, &ignoreDtim); |
| 8654 | pHddCtx->hdd_actual_ignore_DTIM_value = ignoreDtim; |
| 8655 | |
| 8656 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8657 | return VOS_STATUS_SUCCESS; |
| 8658 | } |
| 8659 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8660 | /* wake lock APIs for HDD */ |
| 8661 | void hdd_prevent_suspend(void) |
| 8662 | { |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 8663 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8664 | wake_lock(&wlan_wake_lock); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8665 | #else |
| 8666 | wcnss_prevent_suspend(); |
| 8667 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8668 | } |
| 8669 | |
| 8670 | void hdd_allow_suspend(void) |
| 8671 | { |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 8672 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8673 | wake_unlock(&wlan_wake_lock); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8674 | #else |
| 8675 | wcnss_allow_suspend(); |
| 8676 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8677 | } |
| 8678 | |
Mahesh A Saptasagar | b9c5040 | 2014-01-16 15:49:22 +0530 | [diff] [blame] | 8679 | void hdd_prevent_suspend_timeout(v_U32_t timeout) |
Madan Mohan Koyyalamudi | 10d83a9 | 2012-09-28 15:47:05 -0700 | [diff] [blame] | 8680 | { |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 8681 | #ifdef WLAN_OPEN_SOURCE |
Amar Singhal | 6144c00 | 2013-05-03 16:11:42 -0700 | [diff] [blame] | 8682 | wake_lock_timeout(&wlan_wake_lock, msecs_to_jiffies(timeout)); |
Madan Mohan Koyyalamudi | 10d83a9 | 2012-09-28 15:47:05 -0700 | [diff] [blame] | 8683 | #else |
| 8684 | /* Do nothing as there is no API in wcnss for timeout*/ |
| 8685 | #endif |
| 8686 | } |
| 8687 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8688 | /**--------------------------------------------------------------------------- |
| 8689 | |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8690 | \brief hdd_exchange_version_and_caps() - HDD function to exchange version and capability |
| 8691 | information between Host and Riva |
| 8692 | |
| 8693 | This function gets reported version of FW |
| 8694 | It also finds the version of Riva headers used to compile the host |
| 8695 | It compares the above two and prints a warning if they are different |
| 8696 | It gets the SW and HW version string |
| 8697 | Finally, it exchanges capabilities between host and Riva i.e. host and riva exchange a msg |
| 8698 | indicating the features they support through a bitmap |
| 8699 | |
| 8700 | \param - pHddCtx - Pointer to HDD context |
| 8701 | |
| 8702 | \return - void |
| 8703 | |
| 8704 | --------------------------------------------------------------------------*/ |
| 8705 | |
| 8706 | void hdd_exchange_version_and_caps(hdd_context_t *pHddCtx) |
| 8707 | { |
| 8708 | |
| 8709 | tSirVersionType versionCompiled; |
| 8710 | tSirVersionType versionReported; |
| 8711 | tSirVersionString versionString; |
| 8712 | tANI_U8 fwFeatCapsMsgSupported = 0; |
| 8713 | VOS_STATUS vstatus; |
| 8714 | |
Mingcheng Zhu | 87f22fc | 2014-01-30 19:23:32 -0800 | [diff] [blame] | 8715 | memset(&versionCompiled, 0, sizeof(versionCompiled)); |
| 8716 | memset(&versionReported, 0, sizeof(versionReported)); |
| 8717 | |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8718 | /* retrieve and display WCNSS version information */ |
| 8719 | do { |
| 8720 | |
| 8721 | vstatus = sme_GetWcnssWlanCompiledVersion(pHddCtx->hHal, |
| 8722 | &versionCompiled); |
| 8723 | if (!VOS_IS_STATUS_SUCCESS(vstatus)) |
| 8724 | { |
| 8725 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 8726 | "%s: unable to retrieve WCNSS WLAN compiled version", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 8727 | __func__); |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8728 | break; |
| 8729 | } |
| 8730 | |
| 8731 | vstatus = sme_GetWcnssWlanReportedVersion(pHddCtx->hHal, |
| 8732 | &versionReported); |
| 8733 | if (!VOS_IS_STATUS_SUCCESS(vstatus)) |
| 8734 | { |
| 8735 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 8736 | "%s: unable to retrieve WCNSS WLAN reported version", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 8737 | __func__); |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8738 | break; |
| 8739 | } |
| 8740 | |
| 8741 | if ((versionCompiled.major != versionReported.major) || |
| 8742 | (versionCompiled.minor != versionReported.minor) || |
| 8743 | (versionCompiled.version != versionReported.version) || |
| 8744 | (versionCompiled.revision != versionReported.revision)) |
| 8745 | { |
| 8746 | pr_err("%s: WCNSS WLAN Version %u.%u.%u.%u, " |
| 8747 | "Host expected %u.%u.%u.%u\n", |
| 8748 | WLAN_MODULE_NAME, |
| 8749 | (int)versionReported.major, |
| 8750 | (int)versionReported.minor, |
| 8751 | (int)versionReported.version, |
| 8752 | (int)versionReported.revision, |
| 8753 | (int)versionCompiled.major, |
| 8754 | (int)versionCompiled.minor, |
| 8755 | (int)versionCompiled.version, |
| 8756 | (int)versionCompiled.revision); |
| 8757 | } |
| 8758 | else |
| 8759 | { |
| 8760 | pr_info("%s: WCNSS WLAN version %u.%u.%u.%u\n", |
| 8761 | WLAN_MODULE_NAME, |
| 8762 | (int)versionReported.major, |
| 8763 | (int)versionReported.minor, |
| 8764 | (int)versionReported.version, |
| 8765 | (int)versionReported.revision); |
| 8766 | } |
| 8767 | |
| 8768 | vstatus = sme_GetWcnssSoftwareVersion(pHddCtx->hHal, |
| 8769 | versionString, |
| 8770 | sizeof(versionString)); |
| 8771 | if (!VOS_IS_STATUS_SUCCESS(vstatus)) |
| 8772 | { |
| 8773 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 8774 | "%s: unable to retrieve WCNSS software version string", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 8775 | __func__); |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8776 | break; |
| 8777 | } |
| 8778 | |
| 8779 | pr_info("%s: WCNSS software version %s\n", |
| 8780 | WLAN_MODULE_NAME, versionString); |
| 8781 | |
| 8782 | vstatus = sme_GetWcnssHardwareVersion(pHddCtx->hHal, |
| 8783 | versionString, |
| 8784 | sizeof(versionString)); |
| 8785 | if (!VOS_IS_STATUS_SUCCESS(vstatus)) |
| 8786 | { |
| 8787 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 8788 | "%s: unable to retrieve WCNSS hardware version string", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 8789 | __func__); |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8790 | break; |
| 8791 | } |
| 8792 | |
| 8793 | pr_info("%s: WCNSS hardware version %s\n", |
| 8794 | WLAN_MODULE_NAME, versionString); |
| 8795 | |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 8796 | /* 1.Check if FW version is greater than 0.1.1.0. Only then send host-FW capability exchange message |
| 8797 | 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] | 8798 | send the message only if it the riva is 1.1 |
| 8799 | minor numbers for different riva branches: |
| 8800 | 0 -> (1.0)Mainline Build |
| 8801 | 1 -> (1.1)Mainline Build |
| 8802 | 2->(1.04) Stability Build |
| 8803 | */ |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 8804 | if (((versionReported.major>0) || (versionReported.minor>1) || |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8805 | ((versionReported.minor>=1) && (versionReported.version>=1))) |
| 8806 | && ((versionReported.major == 1) && (versionReported.minor >= 1))) |
| 8807 | fwFeatCapsMsgSupported = 1; |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 8808 | |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8809 | if (fwFeatCapsMsgSupported) |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 8810 | { |
| 8811 | #ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE |
| 8812 | if(!pHddCtx->cfg_ini->fEnableActiveModeOffload) |
| 8813 | sme_disableFeatureCapablity(WLANACTIVE_OFFLOAD); |
| 8814 | #endif |
Ravi Joshi | d2ca7c4 | 2013-07-23 08:37:49 -0700 | [diff] [blame] | 8815 | /* Indicate if IBSS heartbeat monitoring needs to be offloaded */ |
| 8816 | if (!pHddCtx->cfg_ini->enableIbssHeartBeatOffload) |
| 8817 | { |
| 8818 | sme_disableFeatureCapablity(IBSS_HEARTBEAT_OFFLOAD); |
| 8819 | } |
| 8820 | |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8821 | sme_featureCapsExchange(pHddCtx->hHal); |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 8822 | } |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8823 | |
| 8824 | } while (0); |
| 8825 | |
| 8826 | } |
Neelansh Mittal | edafed2 | 2014-09-04 18:54:39 +0530 | [diff] [blame] | 8827 | void wlan_hdd_send_svc_nlink_msg(int type, void *data, int len) |
| 8828 | { |
| 8829 | struct sk_buff *skb; |
| 8830 | struct nlmsghdr *nlh; |
| 8831 | tAniMsgHdr *ani_hdr; |
Hanumantha Reddy Pothula | cf2c7ea | 2015-04-27 14:50:47 +0530 | [diff] [blame] | 8832 | int flags = GFP_KERNEL; |
Neelansh Mittal | edafed2 | 2014-09-04 18:54:39 +0530 | [diff] [blame] | 8833 | |
Hanumantha Reddy Pothula | cf2c7ea | 2015-04-27 14:50:47 +0530 | [diff] [blame] | 8834 | if (in_interrupt() || irqs_disabled() || in_atomic()) |
| 8835 | flags = GFP_ATOMIC; |
| 8836 | |
| 8837 | skb = alloc_skb(NLMSG_SPACE(WLAN_NL_MAX_PAYLOAD), flags); |
Neelansh Mittal | edafed2 | 2014-09-04 18:54:39 +0530 | [diff] [blame] | 8838 | |
| 8839 | if(skb == NULL) { |
| 8840 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8841 | "%s: alloc_skb failed", __func__); |
| 8842 | return; |
| 8843 | } |
| 8844 | |
| 8845 | nlh = (struct nlmsghdr *)skb->data; |
| 8846 | nlh->nlmsg_pid = 0; /* from kernel */ |
| 8847 | nlh->nlmsg_flags = 0; |
| 8848 | nlh->nlmsg_seq = 0; |
| 8849 | nlh->nlmsg_type = WLAN_NL_MSG_SVC; |
| 8850 | |
| 8851 | ani_hdr = NLMSG_DATA(nlh); |
| 8852 | ani_hdr->type = type; |
| 8853 | |
| 8854 | switch(type) { |
| 8855 | case WLAN_SVC_SAP_RESTART_IND: |
| 8856 | ani_hdr->length = 0; |
| 8857 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr))); |
| 8858 | skb_put(skb, NLMSG_SPACE(sizeof(tAniMsgHdr))); |
| 8859 | break; |
| 8860 | default: |
| 8861 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8862 | "Attempt to send unknown nlink message %d", type); |
| 8863 | kfree_skb(skb); |
| 8864 | return; |
| 8865 | } |
| 8866 | |
| 8867 | nl_srv_bcast(skb); |
| 8868 | |
| 8869 | return; |
| 8870 | } |
| 8871 | |
| 8872 | |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 8873 | |
| 8874 | /**--------------------------------------------------------------------------- |
| 8875 | |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 8876 | \brief hdd_is_5g_supported() - HDD function to know if hardware supports 5GHz |
| 8877 | |
| 8878 | \param - pHddCtx - Pointer to the hdd context |
| 8879 | |
| 8880 | \return - true if hardware supports 5GHz |
| 8881 | |
| 8882 | --------------------------------------------------------------------------*/ |
Vinay Krishna Eranna | facf5e2 | 2014-02-24 13:16:25 +0530 | [diff] [blame] | 8883 | boolean hdd_is_5g_supported(hdd_context_t * pHddCtx) |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 8884 | { |
| 8885 | /* If wcnss_wlan_iris_xo_mode() returns WCNSS_XO_48MHZ(1); |
| 8886 | * then hardware support 5Ghz. |
| 8887 | */ |
| 8888 | if (WCNSS_XO_48MHZ == wcnss_wlan_iris_xo_mode()) |
| 8889 | { |
Agarwal Ashish | 971c288 | 2013-10-30 20:11:12 +0530 | [diff] [blame] | 8890 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Hardware supports 5Ghz", __func__); |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 8891 | return true; |
| 8892 | } |
| 8893 | else |
| 8894 | { |
Agarwal Ashish | 971c288 | 2013-10-30 20:11:12 +0530 | [diff] [blame] | 8895 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Hardware doesn't supports 5Ghz", |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 8896 | __func__); |
| 8897 | return false; |
| 8898 | } |
| 8899 | } |
| 8900 | |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 8901 | /**--------------------------------------------------------------------------- |
| 8902 | |
| 8903 | \brief hdd_generate_iface_mac_addr_auto() - HDD Mac Interface Auto |
| 8904 | generate function |
| 8905 | |
| 8906 | This is generate the random mac address for WLAN interface |
| 8907 | |
| 8908 | \param - pHddCtx - Pointer to HDD context |
| 8909 | idx - Start interface index to get auto |
| 8910 | generated mac addr. |
| 8911 | mac_addr - Mac address |
| 8912 | |
| 8913 | \return - 0 for success, < 0 for failure |
| 8914 | |
| 8915 | --------------------------------------------------------------------------*/ |
| 8916 | |
| 8917 | static int hdd_generate_iface_mac_addr_auto(hdd_context_t *pHddCtx, |
| 8918 | int idx, v_MACADDR_t mac_addr) |
| 8919 | { |
| 8920 | int i; |
| 8921 | unsigned int serialno; |
| 8922 | serialno = wcnss_get_serial_number(); |
| 8923 | |
| 8924 | if (0 != serialno) |
| 8925 | { |
| 8926 | /* MAC address has 3 bytes of OUI so we have a maximum of 3 |
| 8927 | bytes of the serial number that can be used to generate |
| 8928 | the other 3 bytes of the MAC address. Mask off all but |
| 8929 | the lower 3 bytes (this will also make sure we don't |
| 8930 | overflow in the next step) */ |
| 8931 | serialno &= 0x00FFFFFF; |
| 8932 | |
| 8933 | /* we need a unique address for each session */ |
| 8934 | serialno *= VOS_MAX_CONCURRENCY_PERSONA; |
| 8935 | |
| 8936 | /* autogen other Mac addresses */ |
| 8937 | for (i = idx; i < VOS_MAX_CONCURRENCY_PERSONA; i++) |
| 8938 | { |
| 8939 | /* start with the entire default address */ |
| 8940 | pHddCtx->cfg_ini->intfMacAddr[i] = mac_addr; |
| 8941 | /* then replace the lower 3 bytes */ |
| 8942 | pHddCtx->cfg_ini->intfMacAddr[i].bytes[3] = (serialno >> 16) & 0xFF; |
| 8943 | pHddCtx->cfg_ini->intfMacAddr[i].bytes[4] = (serialno >> 8) & 0xFF; |
| 8944 | pHddCtx->cfg_ini->intfMacAddr[i].bytes[5] = serialno & 0xFF; |
| 8945 | |
| 8946 | serialno++; |
| 8947 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8948 | "%s: Derived Mac Addr: " |
| 8949 | MAC_ADDRESS_STR, __func__, |
| 8950 | MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[i].bytes)); |
| 8951 | } |
| 8952 | |
| 8953 | } |
| 8954 | else |
| 8955 | { |
| 8956 | hddLog(LOGE, FL("Failed to Get Serial NO")); |
| 8957 | return -1; |
| 8958 | } |
| 8959 | return 0; |
| 8960 | } |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 8961 | |
| 8962 | /**--------------------------------------------------------------------------- |
| 8963 | |
Mihir Shete | fc7ff5b | 2014-01-27 11:30:05 +0530 | [diff] [blame] | 8964 | \brief hdd_11d_scan_done - callback to be executed when 11d scan is |
| 8965 | completed to flush out the scan results |
| 8966 | |
| 8967 | 11d scan is done during driver load and is a passive scan on all |
| 8968 | channels supported by the device, 11d scans may find some APs on |
| 8969 | frequencies which are forbidden to be used in the regulatory domain |
| 8970 | the device is operating in. If these APs are notified to the supplicant |
| 8971 | it may try to connect to these APs, thus flush out all the scan results |
| 8972 | which are present in SME after 11d scan is done. |
| 8973 | |
| 8974 | \return - eHalStatus |
| 8975 | |
| 8976 | --------------------------------------------------------------------------*/ |
| 8977 | static eHalStatus hdd_11d_scan_done(tHalHandle halHandle, void *pContext, |
| 8978 | tANI_U32 scanId, eCsrScanStatus status) |
| 8979 | { |
| 8980 | ENTER(); |
| 8981 | |
| 8982 | sme_ScanFlushResult(halHandle, 0); |
| 8983 | |
| 8984 | EXIT(); |
| 8985 | |
| 8986 | return eHAL_STATUS_SUCCESS; |
| 8987 | } |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 8988 | /**--------------------------------------------------------------------------- |
| 8989 | |
| 8990 | \brief hdd_init_frame_logging_done - callback to be executed when mgmt frame |
| 8991 | logging is completed successfully. |
| 8992 | |
| 8993 | \return - None |
| 8994 | |
| 8995 | --------------------------------------------------------------------------*/ |
| 8996 | void hdd_init_frame_logging_done(void *mgmtlogInitCbContext, VOS_STATUS status) |
| 8997 | { |
| 8998 | hdd_context_t* pHddCtx = (hdd_context_t*)mgmtlogInitCbContext; |
| 8999 | |
| 9000 | if (NULL == pHddCtx) |
| 9001 | { |
| 9002 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 9003 | "%s: HDD context is NULL",__func__); |
| 9004 | return; |
| 9005 | } |
| 9006 | |
| 9007 | if (VOS_STATUS_SUCCESS == status) |
| 9008 | { |
| 9009 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Mgmt Frame Logging init successful")); |
| 9010 | pHddCtx->mgmt_frame_logging = TRUE; |
| 9011 | } |
| 9012 | else |
| 9013 | { |
| 9014 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Mgmt Frame Logging init not success")); |
| 9015 | pHddCtx->mgmt_frame_logging = FALSE; |
| 9016 | } |
| 9017 | |
| 9018 | return; |
| 9019 | } |
| 9020 | /**--------------------------------------------------------------------------- |
| 9021 | |
| 9022 | \brief hdd_init_frame_logging - function to initialize frame logging. |
| 9023 | Currently only Mgmt Frames are logged in both TX |
| 9024 | and Rx direction and are sent to userspace |
| 9025 | application using logger thread when queried. |
| 9026 | |
| 9027 | \return - None |
| 9028 | |
| 9029 | --------------------------------------------------------------------------*/ |
| 9030 | void hdd_init_frame_logging(hdd_context_t* pHddCtx, v_BOOL_t enable) |
| 9031 | { |
| 9032 | eHalStatus halStatus = eHAL_STATUS_FAILURE; |
| 9033 | tpSirMgmtLoggingInitParam wlanMgmtLoggingInitParam; |
| 9034 | |
| 9035 | if (TRUE != sme_IsFeatureSupportedByFW(MGMT_FRAME_LOGGING)) |
| 9036 | { |
| 9037 | hddLog(VOS_TRACE_LEVEL_INFO, FL("MGMT_FRAME_LOGGING not supp by FW")); |
| 9038 | return; |
| 9039 | } |
| 9040 | |
| 9041 | wlanMgmtLoggingInitParam = vos_mem_malloc(sizeof(tSirMgmtLoggingInitParam)); |
| 9042 | if(NULL == wlanMgmtLoggingInitParam) |
| 9043 | { |
| 9044 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: vos_mem_alloc failed ", __func__); |
| 9045 | return; |
| 9046 | } |
| 9047 | |
| 9048 | vos_mem_set(wlanMgmtLoggingInitParam, sizeof(tSirMgmtLoggingInitParam), 0); |
| 9049 | |
| 9050 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Configuring Mgmt Frame Logging %d", |
| 9051 | __func__, enable); |
| 9052 | |
| 9053 | if (enable) |
| 9054 | { |
| 9055 | wlanMgmtLoggingInitParam->enableFlag |= WLAN_FRAME_LOG_EN; |
| 9056 | } |
| 9057 | |
| 9058 | if (pHddCtx->cfg_ini->enableBMUHWtracing) |
| 9059 | { |
| 9060 | wlanMgmtLoggingInitParam->enableFlag |= WLAN_BMUHW_TRACE_LOG_EN; |
| 9061 | } |
| 9062 | |
| 9063 | wlanMgmtLoggingInitParam->frameType = WLAN_FRAME_LOGGING_FRAMETYPE_MGMT; |
| 9064 | wlanMgmtLoggingInitParam->frameSize = WLAN_MGMT_LOGGING_FRAMESIZE_128BYTES; |
| 9065 | wlanMgmtLoggingInitParam->bufferMode = |
| 9066 | WLAN_FRAME_LOGGING_BUFFERMODE_CIRCULAR; |
| 9067 | |
| 9068 | wlanMgmtLoggingInitParam->enableFlag &= ~WLAN_QXDM_LOG_EN; |
| 9069 | wlanMgmtLoggingInitParam->enableFlag &= ~WLAN_DPU_TXP_LOG_EN; |
| 9070 | |
| 9071 | wlanMgmtLoggingInitParam->mgmtlogInitCallback = hdd_init_frame_logging_done; |
| 9072 | wlanMgmtLoggingInitParam->mgmtlogInitCbContext= pHddCtx; |
| 9073 | |
| 9074 | halStatus = sme_InitMgmtFrameLogging(pHddCtx->hHal, |
| 9075 | wlanMgmtLoggingInitParam); |
| 9076 | |
| 9077 | if (eHAL_STATUS_SUCCESS != halStatus) |
| 9078 | { |
| 9079 | vos_mem_free(wlanMgmtLoggingInitParam); |
| 9080 | } |
| 9081 | |
| 9082 | return; |
| 9083 | } |
Mihir Shete | fc7ff5b | 2014-01-27 11:30:05 +0530 | [diff] [blame] | 9084 | |
| 9085 | /**--------------------------------------------------------------------------- |
| 9086 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9087 | \brief hdd_wlan_startup() - HDD init function |
| 9088 | |
| 9089 | This is the driver startup code executed once a WLAN device has been detected |
| 9090 | |
| 9091 | \param - dev - Pointer to the underlying device |
| 9092 | |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 9093 | \return - 0 for success, < 0 for failure |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9094 | |
| 9095 | --------------------------------------------------------------------------*/ |
| 9096 | |
| 9097 | int hdd_wlan_startup(struct device *dev ) |
| 9098 | { |
| 9099 | VOS_STATUS status; |
| 9100 | hdd_adapter_t *pAdapter = NULL; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9101 | hdd_adapter_t *pP2pAdapter = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9102 | hdd_context_t *pHddCtx = NULL; |
| 9103 | v_CONTEXT_t pVosContext= NULL; |
| 9104 | #ifdef WLAN_BTAMP_FEATURE |
| 9105 | VOS_STATUS vStatus = VOS_STATUS_SUCCESS; |
| 9106 | WLANBAP_ConfigType btAmpConfig; |
| 9107 | hdd_config_t *pConfig; |
| 9108 | #endif |
| 9109 | int ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9110 | struct wiphy *wiphy; |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 9111 | v_MACADDR_t mac_addr; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9112 | |
| 9113 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9114 | /* |
| 9115 | * cfg80211: wiphy allocation |
| 9116 | */ |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 9117 | wiphy = wlan_hdd_cfg80211_wiphy_alloc(sizeof(hdd_context_t)) ; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9118 | |
| 9119 | if(wiphy == NULL) |
| 9120 | { |
| 9121 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: cfg80211 init failed", __func__); |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 9122 | return -EIO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9123 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9124 | pHddCtx = wiphy_priv(wiphy); |
| 9125 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9126 | //Initialize the adapter context to zeros. |
| 9127 | vos_mem_zero(pHddCtx, sizeof( hdd_context_t )); |
| 9128 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9129 | pHddCtx->wiphy = wiphy; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9130 | hdd_prevent_suspend(); |
Mihir Shete | 1815629 | 2014-03-11 15:38:30 +0530 | [diff] [blame] | 9131 | pHddCtx->isLoadUnloadInProgress = WLAN_HDD_LOAD_IN_PROGRESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9132 | |
| 9133 | vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, TRUE); |
| 9134 | |
| 9135 | /*Get vos context here bcoz vos_open requires it*/ |
| 9136 | pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL); |
| 9137 | |
Madan Mohan Koyyalamudi | 0b78e15 | 2012-11-28 15:46:51 -0800 | [diff] [blame] | 9138 | if(pVosContext == NULL) |
| 9139 | { |
| 9140 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Failed vos_get_global_context",__func__); |
| 9141 | goto err_free_hdd_context; |
| 9142 | } |
| 9143 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9144 | //Save the Global VOSS context in adapter context for future. |
| 9145 | pHddCtx->pvosContext = pVosContext; |
| 9146 | |
| 9147 | //Save the adapter context in global context for future. |
| 9148 | ((VosContextType*)(pVosContext))->pHDDContext = (v_VOID_t*)pHddCtx; |
| 9149 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9150 | pHddCtx->parent_dev = dev; |
| 9151 | |
| 9152 | init_completion(&pHddCtx->full_pwr_comp_var); |
| 9153 | init_completion(&pHddCtx->standby_comp_var); |
| 9154 | init_completion(&pHddCtx->req_bmps_comp_var); |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 9155 | init_completion(&pHddCtx->scan_info.scan_req_completion_event); |
Madan Mohan Koyyalamudi | f4e8100 | 2012-11-13 10:46:38 -0800 | [diff] [blame] | 9156 | init_completion(&pHddCtx->scan_info.abortscan_event_var); |
Kiet Lam | 46b8e4e | 2013-11-06 21:49:53 +0530 | [diff] [blame] | 9157 | init_completion(&pHddCtx->wiphy_channel_update_event); |
Arun Kumar Khandavalli | e0b046d | 2014-03-01 21:54:25 +0530 | [diff] [blame] | 9158 | init_completion(&pHddCtx->ssr_comp_var); |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 9159 | |
| 9160 | #ifdef CONFIG_ENABLE_LINUX_REG |
Amar Singhal | fddc28c | 2013-09-05 13:03:40 -0700 | [diff] [blame] | 9161 | init_completion(&pHddCtx->linux_reg_req); |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 9162 | #else |
| 9163 | init_completion(&pHddCtx->driver_crda_req); |
| 9164 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9165 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 9166 | spin_lock_init(&pHddCtx->schedScan_lock); |
| 9167 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9168 | hdd_list_init( &pHddCtx->hddAdapters, MAX_NUMBER_OF_ADAPTERS ); |
| 9169 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 9170 | #ifdef FEATURE_WLAN_TDLS |
| 9171 | /* tdls_lock is initialized before an hdd_open_adapter ( which is |
| 9172 | * invoked by other instances also) to protect the concurrent |
| 9173 | * access for the Adapters by TDLS module. |
| 9174 | */ |
| 9175 | mutex_init(&pHddCtx->tdls_lock); |
| 9176 | #endif |
Siddharth Bhal | 7697221 | 2014-10-15 16:22:51 +0530 | [diff] [blame] | 9177 | mutex_init(&pHddCtx->spoofMacAddr.macSpoofingLock); |
Mukul Sharma | 1fd6efd | 2015-02-14 00:29:14 +0530 | [diff] [blame] | 9178 | mutex_init(&pHddCtx->wmmLock); |
| 9179 | |
Agarwal Ashish | 1f42287 | 2014-07-22 00:11:55 +0530 | [diff] [blame] | 9180 | /* By default Strict Regulatory For FCC should be false */ |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 9181 | |
Agarwal Ashish | 1f42287 | 2014-07-22 00:11:55 +0530 | [diff] [blame] | 9182 | pHddCtx->nEnableStrictRegulatoryForFCC = FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9183 | // Load all config first as TL config is needed during vos_open |
| 9184 | pHddCtx->cfg_ini = (hdd_config_t*) kmalloc(sizeof(hdd_config_t), GFP_KERNEL); |
| 9185 | if(pHddCtx->cfg_ini == NULL) |
| 9186 | { |
| 9187 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Failed kmalloc hdd_config_t",__func__); |
| 9188 | goto err_free_hdd_context; |
| 9189 | } |
| 9190 | |
| 9191 | vos_mem_zero(pHddCtx->cfg_ini, sizeof( hdd_config_t )); |
| 9192 | |
| 9193 | // Read and parse the qcom_cfg.ini file |
| 9194 | status = hdd_parse_config_ini( pHddCtx ); |
| 9195 | if ( VOS_STATUS_SUCCESS != status ) |
| 9196 | { |
| 9197 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: error parsing %s", |
| 9198 | __func__, WLAN_INI_FILE); |
| 9199 | goto err_config; |
| 9200 | } |
Arif Hussain | d521891 | 2013-12-05 01:10:55 -0800 | [diff] [blame] | 9201 | #ifdef MEMORY_DEBUG |
| 9202 | if (pHddCtx->cfg_ini->IsMemoryDebugSupportEnabled) |
| 9203 | vos_mem_init(); |
| 9204 | |
| 9205 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: gEnableMemoryDebug=%d", |
| 9206 | __func__, pHddCtx->cfg_ini->IsMemoryDebugSupportEnabled); |
| 9207 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9208 | |
Gopichand Nakkala | b8f0f1a | 2013-05-23 18:19:48 +0530 | [diff] [blame] | 9209 | /* INI has been read, initialise the configuredMcastBcastFilter with |
| 9210 | * INI value as this will serve as the default value |
| 9211 | */ |
| 9212 | pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting; |
| 9213 | hddLog(VOS_TRACE_LEVEL_INFO, "Setting configuredMcastBcastFilter: %d", |
| 9214 | pHddCtx->cfg_ini->mcastBcastFilterSetting); |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 9215 | |
| 9216 | if (false == hdd_is_5g_supported(pHddCtx)) |
| 9217 | { |
| 9218 | //5Ghz is not supported. |
| 9219 | if (1 != pHddCtx->cfg_ini->nBandCapability) |
| 9220 | { |
| 9221 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 9222 | "%s: Setting pHddCtx->cfg_ini->nBandCapability = 1", __func__); |
| 9223 | pHddCtx->cfg_ini->nBandCapability = 1; |
| 9224 | } |
| 9225 | } |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 9226 | |
| 9227 | /* If SNR Monitoring is enabled, FW has to parse all beacons |
| 9228 | * for calcaluting and storing the average SNR, so set Nth beacon |
| 9229 | * filter to 1 to enable FW to parse all the beaocons |
| 9230 | */ |
| 9231 | if (1 == pHddCtx->cfg_ini->fEnableSNRMonitoring) |
| 9232 | { |
| 9233 | /* The log level is deliberately set to WARN as overriding |
| 9234 | * nthBeaconFilter to 1 will increase power cosumption and this |
| 9235 | * might just prove helpful to detect the power issue. |
| 9236 | */ |
| 9237 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 9238 | "%s: Setting pHddCtx->cfg_ini->nthBeaconFilter = 1", __func__); |
| 9239 | pHddCtx->cfg_ini->nthBeaconFilter = 1; |
| 9240 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9241 | /* |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 9242 | * cfg80211: Initialization ... |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9243 | */ |
Manjunathappa Prakash | eec4ddf | 2014-01-13 18:23:51 -0800 | [diff] [blame] | 9244 | if (VOS_FTM_MODE != hdd_get_conparam()) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9245 | { |
Manjunathappa Prakash | eec4ddf | 2014-01-13 18:23:51 -0800 | [diff] [blame] | 9246 | if (0 < wlan_hdd_cfg80211_init(dev, wiphy, pHddCtx->cfg_ini)) |
| 9247 | { |
| 9248 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 9249 | "%s: wlan_hdd_cfg80211_init return failure", __func__); |
| 9250 | goto err_config; |
| 9251 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9252 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9253 | |
Varun Reddy Yeturu | 587e680 | 2013-01-24 12:21:41 -0800 | [diff] [blame] | 9254 | // Update VOS trace levels based upon the cfg.ini |
| 9255 | hdd_vos_trace_enable(VOS_MODULE_ID_BAP, |
| 9256 | pHddCtx->cfg_ini->vosTraceEnableBAP); |
| 9257 | hdd_vos_trace_enable(VOS_MODULE_ID_TL, |
| 9258 | pHddCtx->cfg_ini->vosTraceEnableTL); |
| 9259 | hdd_vos_trace_enable(VOS_MODULE_ID_WDI, |
| 9260 | pHddCtx->cfg_ini->vosTraceEnableWDI); |
| 9261 | hdd_vos_trace_enable(VOS_MODULE_ID_HDD, |
| 9262 | pHddCtx->cfg_ini->vosTraceEnableHDD); |
| 9263 | hdd_vos_trace_enable(VOS_MODULE_ID_SME, |
| 9264 | pHddCtx->cfg_ini->vosTraceEnableSME); |
| 9265 | hdd_vos_trace_enable(VOS_MODULE_ID_PE, |
| 9266 | pHddCtx->cfg_ini->vosTraceEnablePE); |
Katya Nigam | 70d6833 | 2013-09-16 16:49:45 +0530 | [diff] [blame] | 9267 | hdd_vos_trace_enable(VOS_MODULE_ID_PMC, |
| 9268 | pHddCtx->cfg_ini->vosTraceEnablePMC); |
Varun Reddy Yeturu | 587e680 | 2013-01-24 12:21:41 -0800 | [diff] [blame] | 9269 | hdd_vos_trace_enable(VOS_MODULE_ID_WDA, |
| 9270 | pHddCtx->cfg_ini->vosTraceEnableWDA); |
| 9271 | hdd_vos_trace_enable(VOS_MODULE_ID_SYS, |
| 9272 | pHddCtx->cfg_ini->vosTraceEnableSYS); |
| 9273 | hdd_vos_trace_enable(VOS_MODULE_ID_VOSS, |
| 9274 | pHddCtx->cfg_ini->vosTraceEnableVOSS); |
Varun Reddy Yeturu | 587e680 | 2013-01-24 12:21:41 -0800 | [diff] [blame] | 9275 | hdd_vos_trace_enable(VOS_MODULE_ID_SAP, |
| 9276 | pHddCtx->cfg_ini->vosTraceEnableSAP); |
| 9277 | hdd_vos_trace_enable(VOS_MODULE_ID_HDD_SOFTAP, |
| 9278 | pHddCtx->cfg_ini->vosTraceEnableHDDSAP); |
Varun Reddy Yeturu | 587e680 | 2013-01-24 12:21:41 -0800 | [diff] [blame] | 9279 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9280 | // Update WDI trace levels based upon the cfg.ini |
| 9281 | hdd_wdi_trace_enable(eWLAN_MODULE_DAL, |
| 9282 | pHddCtx->cfg_ini->wdiTraceEnableDAL); |
| 9283 | hdd_wdi_trace_enable(eWLAN_MODULE_DAL_CTRL, |
| 9284 | pHddCtx->cfg_ini->wdiTraceEnableCTL); |
| 9285 | hdd_wdi_trace_enable(eWLAN_MODULE_DAL_DATA, |
| 9286 | pHddCtx->cfg_ini->wdiTraceEnableDAT); |
| 9287 | hdd_wdi_trace_enable(eWLAN_MODULE_PAL, |
| 9288 | pHddCtx->cfg_ini->wdiTraceEnablePAL); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9289 | |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 9290 | if (VOS_FTM_MODE == hdd_get_conparam()) |
| 9291 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9292 | if ( VOS_STATUS_SUCCESS != wlan_hdd_ftm_open(pHddCtx) ) |
| 9293 | { |
| 9294 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: wlan_hdd_ftm_open Failed",__func__); |
| 9295 | goto err_free_hdd_context; |
| 9296 | } |
| 9297 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: FTM driver loaded success fully",__func__); |
Sachin Ahuja | 38ef5e0 | 2015-03-13 17:31:16 +0530 | [diff] [blame] | 9298 | pHddCtx->isLoadUnloadInProgress = WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS; |
c_hpothu | 2de0ef6 | 2014-04-15 16:16:15 +0530 | [diff] [blame] | 9299 | vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, FALSE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9300 | return VOS_STATUS_SUCCESS; |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 9301 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9302 | |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 9303 | //Open watchdog module |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9304 | if(pHddCtx->cfg_ini->fIsLogpEnabled) |
| 9305 | { |
| 9306 | status = vos_watchdog_open(pVosContext, |
| 9307 | &((VosContextType*)pVosContext)->vosWatchdog, sizeof(VosWatchdogContext)); |
| 9308 | |
| 9309 | if(!VOS_IS_STATUS_SUCCESS( status )) |
| 9310 | { |
| 9311 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: vos_watchdog_open failed",__func__); |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 9312 | goto err_wdclose; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9313 | } |
| 9314 | } |
| 9315 | |
| 9316 | pHddCtx->isLogpInProgress = FALSE; |
| 9317 | vos_set_logp_in_progress(VOS_MODULE_ID_VOSS, FALSE); |
| 9318 | |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 9319 | #ifdef CONFIG_ENABLE_LINUX_REG |
Amar Singhal | 0a40223 | 2013-10-11 20:57:16 -0700 | [diff] [blame] | 9320 | /* initialize the NV module. This is required so that |
| 9321 | we can initialize the channel information in wiphy |
| 9322 | from the NV.bin data. The channel information in |
| 9323 | wiphy needs to be initialized before wiphy registration */ |
| 9324 | |
| 9325 | status = vos_nv_open(); |
| 9326 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 9327 | { |
| 9328 | /* NV module cannot be initialized */ |
| 9329 | hddLog( VOS_TRACE_LEVEL_FATAL, |
| 9330 | "%s: vos_nv_open failed", __func__); |
Vinay Krishna Eranna | 2025d89 | 2014-09-18 16:51:42 +0530 | [diff] [blame] | 9331 | goto err_wdclose; |
Amar Singhal | 0a40223 | 2013-10-11 20:57:16 -0700 | [diff] [blame] | 9332 | } |
| 9333 | |
| 9334 | status = vos_init_wiphy_from_nv_bin(); |
| 9335 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 9336 | { |
| 9337 | /* NV module cannot be initialized */ |
| 9338 | hddLog( VOS_TRACE_LEVEL_FATAL, |
| 9339 | "%s: vos_init_wiphy failed", __func__); |
| 9340 | goto err_vos_nv_close; |
| 9341 | } |
| 9342 | |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 9343 | #endif |
Girish Gowli | bf0e1ab | 2015-01-19 16:05:16 +0530 | [diff] [blame] | 9344 | vos_set_roam_delay_stats_enabled(pHddCtx->cfg_ini->gEnableRoamDelayStats); |
Arun Kumar Khandavalli | ebb1948 | 2014-03-25 13:56:53 +0530 | [diff] [blame] | 9345 | status = vos_open( &pVosContext, pHddCtx->parent_dev); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9346 | if ( !VOS_IS_STATUS_SUCCESS( status )) |
| 9347 | { |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 9348 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: vos_open failed", __func__); |
Mihir Shete | e1093ba | 2014-01-21 20:13:32 +0530 | [diff] [blame] | 9349 | goto err_vos_nv_close; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9350 | } |
| 9351 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9352 | pHddCtx->hHal = (tHalHandle)vos_get_context( VOS_MODULE_ID_SME, pVosContext ); |
| 9353 | |
| 9354 | if ( NULL == pHddCtx->hHal ) |
| 9355 | { |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 9356 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: HAL context is null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9357 | goto err_vosclose; |
| 9358 | } |
| 9359 | |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 9360 | status = vos_preStart( pHddCtx->pvosContext ); |
| 9361 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 9362 | { |
| 9363 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: vos_preStart failed", __func__); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 9364 | goto err_vosclose; |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 9365 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9366 | |
Arif Hussain | eaf6860 | 2013-12-30 23:10:44 -0800 | [diff] [blame] | 9367 | if (0 == enable_dfs_chan_scan || 1 == enable_dfs_chan_scan) |
| 9368 | { |
| 9369 | pHddCtx->cfg_ini->enableDFSChnlScan = enable_dfs_chan_scan; |
| 9370 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: module enable_dfs_chan_scan set to %d", |
| 9371 | __func__, enable_dfs_chan_scan); |
| 9372 | } |
| 9373 | if (0 == enable_11d || 1 == enable_11d) |
| 9374 | { |
| 9375 | pHddCtx->cfg_ini->Is11dSupportEnabled = enable_11d; |
| 9376 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: module enable_11d set to %d", |
| 9377 | __func__, enable_11d); |
| 9378 | } |
| 9379 | |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 9380 | /* Note that the vos_preStart() sequence triggers the cfg download. |
| 9381 | The cfg download must occur before we update the SME config |
| 9382 | since the SME config operation must access the cfg database */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9383 | status = hdd_set_sme_config( pHddCtx ); |
| 9384 | |
| 9385 | if ( VOS_STATUS_SUCCESS != status ) |
| 9386 | { |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 9387 | 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] | 9388 | goto err_vosclose; |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 9389 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9390 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9391 | /* In the integrated architecture we update the configuration from |
| 9392 | the INI file and from NV before vOSS has been started so that |
| 9393 | the final contents are available to send down to the cCPU */ |
| 9394 | |
| 9395 | // Apply the cfg.ini to cfg.dat |
| 9396 | if (FALSE == hdd_update_config_dat(pHddCtx)) |
| 9397 | { |
| 9398 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: config update failed",__func__ ); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 9399 | goto err_vosclose; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9400 | } |
| 9401 | |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 9402 | // Get mac addr from platform driver |
| 9403 | ret = wcnss_get_wlan_mac_address((char*)&mac_addr.bytes); |
| 9404 | |
| 9405 | if ((0 == ret) && (!vos_is_macaddr_zero(&mac_addr))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9406 | { |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 9407 | /* Store the mac addr for first interface */ |
| 9408 | pHddCtx->cfg_ini->intfMacAddr[0] = mac_addr; |
| 9409 | |
| 9410 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 9411 | "%s: WLAN Mac Addr: " |
| 9412 | MAC_ADDRESS_STR, __func__, |
| 9413 | MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[0].bytes)); |
| 9414 | |
| 9415 | /* Here, passing Arg2 as 1 because we do not want to change the |
| 9416 | last 3 bytes (means non OUI bytes) of first interface mac |
| 9417 | addr. |
| 9418 | */ |
| 9419 | if (0 != hdd_generate_iface_mac_addr_auto(pHddCtx, 1, mac_addr)) |
| 9420 | { |
| 9421 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 9422 | "%s: Failed to generate wlan interface mac addr " |
| 9423 | "using MAC from ini file ", __func__); |
| 9424 | } |
| 9425 | } |
| 9426 | else if (VOS_STATUS_SUCCESS != hdd_update_config_from_nv(pHddCtx)) |
| 9427 | { |
| 9428 | // Apply the NV to cfg.dat |
| 9429 | /* Prima Update MAC address only at here */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9430 | #ifdef WLAN_AUTOGEN_MACADDR_FEATURE |
| 9431 | /* There was not a valid set of MAC Addresses in NV. See if the |
| 9432 | default addresses were modified by the cfg.ini settings. If so, |
| 9433 | we'll use them, but if not, we'll autogenerate a set of MAC |
| 9434 | addresses based upon the device serial number */ |
| 9435 | |
| 9436 | static const v_MACADDR_t default_address = |
| 9437 | {{0x00, 0x0A, 0xF5, 0x89, 0x89, 0xFF}}; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9438 | |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 9439 | if (0 == memcmp(&default_address, &pHddCtx->cfg_ini->intfMacAddr[0], |
| 9440 | sizeof(default_address))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9441 | { |
| 9442 | /* cfg.ini has the default address, invoke autogen logic */ |
| 9443 | |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 9444 | /* Here, passing Arg2 as 0 because we want to change the |
| 9445 | last 3 bytes (means non OUI bytes) of all the interfaces |
| 9446 | mac addr. |
| 9447 | */ |
| 9448 | if (0 != hdd_generate_iface_mac_addr_auto(pHddCtx, 0, |
| 9449 | default_address)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9450 | { |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 9451 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 9452 | "%s: Failed to generate wlan interface mac addr " |
| 9453 | "using MAC from ini file " MAC_ADDRESS_STR, __func__, |
| 9454 | MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[0].bytes)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9455 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9456 | } |
| 9457 | else |
| 9458 | #endif //WLAN_AUTOGEN_MACADDR_FEATURE |
| 9459 | { |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 9460 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9461 | "%s: Invalid MAC address in NV, using MAC from ini file " |
| 9462 | MAC_ADDRESS_STR, __func__, |
| 9463 | MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[0].bytes)); |
| 9464 | } |
| 9465 | } |
| 9466 | { |
| 9467 | eHalStatus halStatus; |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 9468 | |
| 9469 | /* Set the MAC Address Currently this is used by HAL to |
| 9470 | * add self sta. Remove this once self sta is added as |
| 9471 | * part of session open. |
| 9472 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9473 | halStatus = cfgSetStr( pHddCtx->hHal, WNI_CFG_STA_ID, |
| 9474 | (v_U8_t *)&pHddCtx->cfg_ini->intfMacAddr[0], |
| 9475 | sizeof( pHddCtx->cfg_ini->intfMacAddr[0]) ); |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 9476 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9477 | if (!HAL_STATUS_SUCCESS( halStatus )) |
| 9478 | { |
| 9479 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failed to set MAC Address. " |
| 9480 | "HALStatus is %08d [x%08x]",__func__, halStatus, halStatus ); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 9481 | goto err_vosclose; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9482 | } |
| 9483 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9484 | |
| 9485 | /*Start VOSS which starts up the SME/MAC/HAL modules and everything else |
| 9486 | Note: Firmware image will be read and downloaded inside vos_start API */ |
| 9487 | status = vos_start( pHddCtx->pvosContext ); |
| 9488 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 9489 | { |
| 9490 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: vos_start failed",__func__); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 9491 | goto err_vosclose; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9492 | } |
| 9493 | |
Leo Chang | 6cec3e2 | 2014-01-21 15:33:49 -0800 | [diff] [blame] | 9494 | #ifdef FEATURE_WLAN_CH_AVOID |
| 9495 | /* Plug in avoid channel notification callback |
| 9496 | * This should happen before ADD_SELF_STA |
| 9497 | * 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] | 9498 | |
| 9499 | /* check the Channel Avoidance is enabled */ |
| 9500 | if (TRUE == pHddCtx->cfg_ini->fenableCHAvoidance) |
| 9501 | { |
| 9502 | sme_AddChAvoidCallback(pHddCtx->hHal, |
| 9503 | hdd_hostapd_ch_avoid_cb); |
| 9504 | } |
Leo Chang | 6cec3e2 | 2014-01-21 15:33:49 -0800 | [diff] [blame] | 9505 | #endif /* FEATURE_WLAN_CH_AVOID */ |
| 9506 | |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 9507 | /* Exchange capability info between Host and FW and also get versioning info from FW */ |
| 9508 | hdd_exchange_version_and_caps(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9509 | |
Agarwal Ashish | ad9281b | 2014-06-10 14:57:30 +0530 | [diff] [blame] | 9510 | #ifdef CONFIG_ENABLE_LINUX_REG |
| 9511 | status = wlan_hdd_init_channels(pHddCtx); |
| 9512 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 9513 | { |
| 9514 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: wlan_hdd_init_channels failed", |
| 9515 | __func__); |
| 9516 | goto err_vosstop; |
| 9517 | } |
| 9518 | #endif |
| 9519 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9520 | status = hdd_post_voss_start_config( pHddCtx ); |
| 9521 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 9522 | { |
| 9523 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hdd_post_voss_start_config failed", |
| 9524 | __func__); |
| 9525 | goto err_vosstop; |
| 9526 | } |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 9527 | |
| 9528 | #ifndef CONFIG_ENABLE_LINUX_REG |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 9529 | wlan_hdd_cfg80211_update_reg_info( wiphy ); |
| 9530 | |
| 9531 | /* registration of wiphy dev with cfg80211 */ |
| 9532 | if (0 > wlan_hdd_cfg80211_register(wiphy)) |
| 9533 | { |
| 9534 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__); |
| 9535 | goto err_vosstop; |
| 9536 | } |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 9537 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9538 | |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 9539 | #ifdef CONFIG_ENABLE_LINUX_REG |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 9540 | /* registration of wiphy dev with cfg80211 */ |
| 9541 | if (0 > wlan_hdd_cfg80211_register(wiphy)) |
| 9542 | { |
| 9543 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__); |
| 9544 | goto err_vosstop; |
| 9545 | } |
| 9546 | |
Agarwal Ashish | 6db9d53 | 2014-09-30 18:19:10 +0530 | [diff] [blame] | 9547 | status = wlan_hdd_init_channels_for_cc(pHddCtx, INIT); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 9548 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 9549 | { |
| 9550 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: wlan_hdd_init_channels_for_cc failed", |
| 9551 | __func__); |
| 9552 | goto err_unregister_wiphy; |
| 9553 | } |
| 9554 | #endif |
| 9555 | |
c_hpothu | 4a298be | 2014-12-22 21:12:51 +0530 | [diff] [blame] | 9556 | wcnss_wlan_set_drvdata(pHddCtx->parent_dev, pHddCtx); |
| 9557 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9558 | if (VOS_STA_SAP_MODE == hdd_get_conparam()) |
| 9559 | { |
| 9560 | pAdapter = hdd_open_adapter( pHddCtx, WLAN_HDD_SOFTAP, "softap.%d", |
| 9561 | wlan_hdd_get_intf_addr(pHddCtx), FALSE ); |
| 9562 | } |
| 9563 | else |
| 9564 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9565 | pAdapter = hdd_open_adapter( pHddCtx, WLAN_HDD_INFRA_STATION, "wlan%d", |
| 9566 | wlan_hdd_get_intf_addr(pHddCtx), FALSE ); |
| 9567 | if (pAdapter != NULL) |
| 9568 | { |
Katya Nigam | a7d81d7 | 2014-11-12 12:44:34 +0530 | [diff] [blame] | 9569 | 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] | 9570 | { |
Gopichand Nakkala | 49f96f6 | 2013-02-06 14:38:17 +0530 | [diff] [blame] | 9571 | vos_mem_copy( pHddCtx->p2pDeviceAddress.bytes, |
| 9572 | pHddCtx->cfg_ini->intfMacAddr[0].bytes, |
| 9573 | sizeof(tSirMacAddr)); |
Madan Mohan Koyyalamudi | edfc1b7 | 2012-10-18 20:25:55 -0700 | [diff] [blame] | 9574 | |
Gopichand Nakkala | 49f96f6 | 2013-02-06 14:38:17 +0530 | [diff] [blame] | 9575 | /* Generate the P2P Device Address. This consists of the device's |
| 9576 | * primary MAC address with the locally administered bit set. |
| 9577 | */ |
| 9578 | pHddCtx->p2pDeviceAddress.bytes[0] |= 0x02; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9579 | } |
| 9580 | else |
| 9581 | { |
Gopichand Nakkala | 49f96f6 | 2013-02-06 14:38:17 +0530 | [diff] [blame] | 9582 | tANI_U8* p2p_dev_addr = wlan_hdd_get_intf_addr(pHddCtx); |
| 9583 | if (p2p_dev_addr != NULL) |
| 9584 | { |
| 9585 | vos_mem_copy(&pHddCtx->p2pDeviceAddress.bytes[0], |
| 9586 | p2p_dev_addr, VOS_MAC_ADDR_SIZE); |
| 9587 | } |
| 9588 | else |
| 9589 | { |
| 9590 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 9591 | "%s: Failed to allocate mac_address for p2p_device", |
| 9592 | __func__); |
| 9593 | goto err_close_adapter; |
| 9594 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9595 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9596 | |
| 9597 | pP2pAdapter = hdd_open_adapter( pHddCtx, WLAN_HDD_P2P_DEVICE, "p2p%d", |
| 9598 | &pHddCtx->p2pDeviceAddress.bytes[0], FALSE ); |
| 9599 | if ( NULL == pP2pAdapter ) |
| 9600 | { |
| 9601 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 9602 | "%s: Failed to do hdd_open_adapter for P2P Device Interface", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 9603 | __func__); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9604 | goto err_close_adapter; |
| 9605 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9606 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9607 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9608 | |
| 9609 | if( pAdapter == NULL ) |
| 9610 | { |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 9611 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: hdd_open_adapter failed", __func__); |
| 9612 | goto err_close_adapter; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9613 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9614 | |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 9615 | if (country_code) |
| 9616 | { |
| 9617 | eHalStatus ret; |
Arif Hussain | cb60708 | 2013-12-20 11:57:42 -0800 | [diff] [blame] | 9618 | INIT_COMPLETION(pAdapter->change_country_code); |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 9619 | hdd_checkandupdate_dfssetting(pAdapter, country_code); |
| 9620 | #ifndef CONFIG_ENABLE_LINUX_REG |
| 9621 | hdd_checkandupdate_phymode(pAdapter, country_code); |
| 9622 | #endif |
Arif Hussain | eaf6860 | 2013-12-30 23:10:44 -0800 | [diff] [blame] | 9623 | ret = sme_ChangeCountryCode(pHddCtx->hHal, |
| 9624 | (void *)(tSmeChangeCountryCallback) |
| 9625 | wlan_hdd_change_country_code_callback, |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 9626 | country_code, |
| 9627 | pAdapter, pHddCtx->pvosContext, |
Abhishek Singh | a306a44 | 2013-11-07 18:39:01 +0530 | [diff] [blame] | 9628 | eSIR_TRUE, eSIR_TRUE); |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 9629 | if (eHAL_STATUS_SUCCESS == ret) |
| 9630 | { |
Arif Hussain | cb60708 | 2013-12-20 11:57:42 -0800 | [diff] [blame] | 9631 | ret = wait_for_completion_interruptible_timeout( |
| 9632 | &pAdapter->change_country_code, |
| 9633 | msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY)); |
| 9634 | |
| 9635 | if (0 >= ret) |
| 9636 | { |
| 9637 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 9638 | "%s: SME while setting country code timed out", __func__); |
| 9639 | } |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 9640 | } |
| 9641 | else |
| 9642 | { |
Arif Hussain | cb60708 | 2013-12-20 11:57:42 -0800 | [diff] [blame] | 9643 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 9644 | "%s: SME Change Country code from module param fail ret=%d", |
| 9645 | __func__, ret); |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 9646 | } |
| 9647 | } |
| 9648 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9649 | #ifdef WLAN_BTAMP_FEATURE |
| 9650 | vStatus = WLANBAP_Open(pVosContext); |
| 9651 | if(!VOS_IS_STATUS_SUCCESS(vStatus)) |
| 9652 | { |
| 9653 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 9654 | "%s: Failed to open BAP",__func__); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9655 | goto err_close_adapter; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9656 | } |
| 9657 | |
| 9658 | vStatus = BSL_Init(pVosContext); |
| 9659 | if(!VOS_IS_STATUS_SUCCESS(vStatus)) |
| 9660 | { |
| 9661 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 9662 | "%s: Failed to Init BSL",__func__); |
| 9663 | goto err_bap_close; |
| 9664 | } |
| 9665 | vStatus = WLANBAP_Start(pVosContext); |
| 9666 | if (!VOS_IS_STATUS_SUCCESS(vStatus)) |
| 9667 | { |
| 9668 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 9669 | "%s: Failed to start TL",__func__); |
| 9670 | goto err_bap_close; |
| 9671 | } |
| 9672 | |
| 9673 | pConfig = pHddCtx->cfg_ini; |
| 9674 | btAmpConfig.ucPreferredChannel = pConfig->preferredChannel; |
| 9675 | status = WLANBAP_SetConfig(&btAmpConfig); |
| 9676 | |
| 9677 | #endif //WLAN_BTAMP_FEATURE |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9678 | |
Mihir Shete | 9c23877 | 2014-10-15 14:35:16 +0530 | [diff] [blame] | 9679 | /* |
| 9680 | * UapsdMask is 0xf if U-APSD is enbaled for all AC's... |
| 9681 | * The value of CFG_QOS_WMM_UAPSD_MASK_DEFAULT is 0xaa(Magic Value) |
| 9682 | * which is greater than 0xf. So the below check is safe to make |
| 9683 | * sure that there is no entry for UapsdMask in the ini |
| 9684 | */ |
| 9685 | if (CFG_QOS_WMM_UAPSD_MASK_DEFAULT == pHddCtx->cfg_ini->UapsdMask) |
| 9686 | { |
| 9687 | if(IS_DYNAMIC_WMM_PS_ENABLED) |
| 9688 | { |
| 9689 | hddLog(VOS_TRACE_LEVEL_DEBUG,"%s: Enable UAPSD for VI & VO", |
| 9690 | __func__); |
| 9691 | pHddCtx->cfg_ini->UapsdMask = |
| 9692 | CFG_QOS_WMM_UAPSD_MASK_DYMANIC_WMM_PS_DEFAULT; |
| 9693 | } |
| 9694 | else |
| 9695 | { |
| 9696 | hddLog(VOS_TRACE_LEVEL_DEBUG,"%s: Do not enable UAPSD", |
| 9697 | __func__); |
| 9698 | pHddCtx->cfg_ini->UapsdMask = |
| 9699 | CFG_QOS_WMM_UAPSD_MASK_LEGACY_WMM_PS_DEFAULT; |
| 9700 | } |
| 9701 | } |
| 9702 | |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 9703 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 9704 | if(!(IS_ROAM_SCAN_OFFLOAD_FEATURE_ENABLE)) |
| 9705 | { |
| 9706 | hddLog(VOS_TRACE_LEVEL_DEBUG,"%s: ROAM_SCAN_OFFLOAD Feature not supported",__func__); |
| 9707 | pHddCtx->cfg_ini->isRoamOffloadScanEnabled = 0; |
| 9708 | sme_UpdateRoamScanOffloadEnabled((tHalHandle)(pHddCtx->hHal), |
| 9709 | pHddCtx->cfg_ini->isRoamOffloadScanEnabled); |
| 9710 | } |
| 9711 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9712 | |
Agarwal Ashish | 4b87f92 | 2014-06-18 03:03:21 +0530 | [diff] [blame] | 9713 | wlan_hdd_tdls_init(pHddCtx); |
| 9714 | |
Mihir Shete | fc7ff5b | 2014-01-27 11:30:05 +0530 | [diff] [blame] | 9715 | sme_Register11dScanDoneCallback(pHddCtx->hHal, hdd_11d_scan_done); |
| 9716 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9717 | /* Register with platform driver as client for Suspend/Resume */ |
| 9718 | status = hddRegisterPmOps(pHddCtx); |
| 9719 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 9720 | { |
| 9721 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddRegisterPmOps failed",__func__); |
| 9722 | #ifdef WLAN_BTAMP_FEATURE |
| 9723 | goto err_bap_stop; |
| 9724 | #else |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9725 | goto err_close_adapter; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9726 | #endif //WLAN_BTAMP_FEATURE |
| 9727 | } |
| 9728 | |
Yue Ma | 0d4891e | 2013-08-06 17:01:45 -0700 | [diff] [blame] | 9729 | /* Open debugfs interface */ |
| 9730 | if (VOS_STATUS_SUCCESS != hdd_debugfs_init(pAdapter)) |
| 9731 | { |
| 9732 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 9733 | "%s: hdd_debugfs_init failed!", __func__); |
Yue Ma | 0d4891e | 2013-08-06 17:01:45 -0700 | [diff] [blame] | 9734 | } |
| 9735 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9736 | /* Register TM level change handler function to the platform */ |
| 9737 | status = hddDevTmRegisterNotifyCallback(pHddCtx); |
| 9738 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 9739 | { |
| 9740 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddDevTmRegisterNotifyCallback failed",__func__); |
| 9741 | goto err_unregister_pmops; |
| 9742 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9743 | |
| 9744 | /* register for riva power on lock to platform driver */ |
| 9745 | if (req_riva_power_on_lock("wlan")) |
| 9746 | { |
| 9747 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: req riva power on lock failed", |
| 9748 | __func__); |
| 9749 | goto err_unregister_pmops; |
| 9750 | } |
| 9751 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9752 | // register net device notifier for device change notification |
| 9753 | ret = register_netdevice_notifier(&hdd_netdev_notifier); |
| 9754 | |
| 9755 | if(ret < 0) |
| 9756 | { |
| 9757 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: register_netdevice_notifier failed",__func__); |
| 9758 | goto err_free_power_on_lock; |
| 9759 | } |
| 9760 | |
| 9761 | //Initialize the nlink service |
| 9762 | if(nl_srv_init() != 0) |
| 9763 | { |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 9764 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: nl_srv_init failed", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9765 | goto err_reg_netdev; |
| 9766 | } |
| 9767 | |
Leo Chang | 4ce1cc5 | 2013-10-21 18:27:15 -0700 | [diff] [blame] | 9768 | #ifdef WLAN_KD_READY_NOTIFIER |
| 9769 | pHddCtx->kd_nl_init = 1; |
| 9770 | #endif /* WLAN_KD_READY_NOTIFIER */ |
| 9771 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9772 | //Initialize the BTC service |
| 9773 | if(btc_activate_service(pHddCtx) != 0) |
| 9774 | { |
| 9775 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: btc_activate_service failed",__func__); |
| 9776 | goto err_nl_srv; |
| 9777 | } |
| 9778 | |
| 9779 | #ifdef PTT_SOCK_SVC_ENABLE |
| 9780 | //Initialize the PTT service |
| 9781 | if(ptt_sock_activate_svc(pHddCtx) != 0) |
| 9782 | { |
| 9783 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: ptt_sock_activate_svc failed",__func__); |
| 9784 | goto err_nl_srv; |
| 9785 | } |
| 9786 | #endif |
| 9787 | |
Vinay Krishna Eranna | d938c42 | 2014-03-10 17:14:21 +0530 | [diff] [blame] | 9788 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 9789 | if(pHddCtx->cfg_ini && pHddCtx->cfg_ini->wlanLoggingEnable) |
| 9790 | { |
Deepthi Gowri | 78083a3 | 2014-11-04 12:55:51 +0530 | [diff] [blame] | 9791 | if(wlan_logging_sock_activate_svc( |
| 9792 | pHddCtx->cfg_ini->wlanLoggingFEToConsole, |
| 9793 | pHddCtx->cfg_ini->wlanLoggingNumBuf)) |
| 9794 | { |
| 9795 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wlan_logging_sock_activate_svc" |
| 9796 | " failed", __func__); |
| 9797 | goto err_nl_srv; |
| 9798 | } |
| 9799 | //TODO: To Remove enableDhcpDebug and use gEnableDebugLog for |
| 9800 | //EAPOL and DHCP |
Sachin Ahuja | 8c65f38 | 2014-12-12 15:34:21 +0530 | [diff] [blame] | 9801 | if (!pHddCtx->cfg_ini->gEnableDebugLog) |
| 9802 | pHddCtx->cfg_ini->gEnableDebugLog = |
| 9803 | VOS_PKT_PROTO_TYPE_EAPOL | VOS_PKT_PROTO_TYPE_DHCP; |
Vinay Krishna Eranna | d938c42 | 2014-03-10 17:14:21 +0530 | [diff] [blame] | 9804 | } |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 9805 | |
| 9806 | if (pHddCtx->cfg_ini->enableMgmtLogging && |
| 9807 | pHddCtx->cfg_ini->wlanLoggingEnable) |
| 9808 | { |
| 9809 | hdd_init_frame_logging(pHddCtx, TRUE); |
| 9810 | } |
| 9811 | else |
| 9812 | { |
| 9813 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Mgmt Logging disabled in ini")); |
| 9814 | } |
| 9815 | |
Vinay Krishna Eranna | d938c42 | 2014-03-10 17:14:21 +0530 | [diff] [blame] | 9816 | #endif |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 9817 | |
| 9818 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9819 | hdd_register_mcast_bcast_filter(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9820 | if (VOS_STA_SAP_MODE != hdd_get_conparam()) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9821 | { |
Madan Mohan Koyyalamudi | c537df2 | 2012-10-22 15:07:08 -0700 | [diff] [blame] | 9822 | /* Action frame registered in one adapter which will |
| 9823 | * applicable to all interfaces |
| 9824 | */ |
Agarwal Ashish | 8fa0e9a | 2014-05-23 00:40:12 +0530 | [diff] [blame] | 9825 | wlan_hdd_cfg80211_register_frames(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9826 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9827 | |
| 9828 | mutex_init(&pHddCtx->sap_lock); |
Mahesh A Saptasagar | 6062794 | 2014-10-13 13:55:14 +0530 | [diff] [blame] | 9829 | mutex_init(&pHddCtx->roc_lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9830 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9831 | |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 9832 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9833 | #ifdef WLAN_FEATURE_HOLD_RX_WAKELOCK |
| 9834 | /* Initialize the wake lcok */ |
| 9835 | wake_lock_init(&pHddCtx->rx_wake_lock, |
| 9836 | WAKE_LOCK_SUSPEND, |
| 9837 | "qcom_rx_wakelock"); |
| 9838 | #endif |
Madan Mohan Koyyalamudi | 69fc3ad | 2012-11-28 16:04:56 -0800 | [diff] [blame] | 9839 | /* Initialize the wake lcok */ |
| 9840 | wake_lock_init(&pHddCtx->sap_wake_lock, |
| 9841 | WAKE_LOCK_SUSPEND, |
| 9842 | "qcom_sap_wakelock"); |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 9843 | #endif |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9844 | |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 9845 | vos_event_init(&pHddCtx->scan_info.scan_finished_event); |
| 9846 | pHddCtx->scan_info.scan_pending_option = WEXT_SCAN_PENDING_GIVEUP; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9847 | |
Katya Nigam | 5c306ea | 2014-06-19 15:39:54 +0530 | [diff] [blame] | 9848 | pHddCtx->isLoadUnloadInProgress = WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9849 | vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, FALSE); |
| 9850 | hdd_allow_suspend(); |
Katya Nigam | 5c306ea | 2014-06-19 15:39:54 +0530 | [diff] [blame] | 9851 | |
| 9852 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 9853 | /*SME must send channel update configuration to RIVA*/ |
| 9854 | sme_UpdateChannelConfig(pHddCtx->hHal); |
| 9855 | #endif |
Abhishek Singh | f644b27 | 2014-08-21 02:59:39 +0530 | [diff] [blame] | 9856 | /* Send the update default channel list to the FW*/ |
| 9857 | sme_UpdateChannelList(pHddCtx->hHal); |
Mukul Sharma | 4506394 | 2015-04-01 20:07:59 +0530 | [diff] [blame] | 9858 | |
| 9859 | /* Fwr capabilities received, Set the Dot11 mode */ |
| 9860 | sme_SetDefDot11Mode(pHddCtx->hHal); |
| 9861 | |
Abhishek Singh | a306a44 | 2013-11-07 18:39:01 +0530 | [diff] [blame] | 9862 | #ifndef CONFIG_ENABLE_LINUX_REG |
| 9863 | /*updating wiphy so that regulatory user hints can be processed*/ |
| 9864 | if (wiphy) |
| 9865 | { |
| 9866 | regulatory_hint(wiphy, "00"); |
| 9867 | } |
| 9868 | #endif |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9869 | // Initialize the restart logic |
| 9870 | wlan_hdd_restart_init(pHddCtx); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 9871 | |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 9872 | //Register the traffic monitor timer now |
| 9873 | if ( pHddCtx->cfg_ini->dynSplitscan) |
| 9874 | { |
| 9875 | vos_timer_init(&pHddCtx->tx_rx_trafficTmr, |
| 9876 | VOS_TIMER_TYPE_SW, |
| 9877 | hdd_tx_rx_pkt_cnt_stat_timer_handler, |
| 9878 | (void *)pHddCtx); |
| 9879 | } |
Srinivas Dasari | 030bad3 | 2015-02-18 23:23:54 +0530 | [diff] [blame] | 9880 | wlan_hdd_cfg80211_nan_init(pHddCtx); |
| 9881 | |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 9882 | #ifdef WLAN_FEATURE_EXTSCAN |
| 9883 | sme_EXTScanRegisterCallback(pHddCtx->hHal, |
| 9884 | wlan_hdd_cfg80211_extscan_callback, |
| 9885 | pHddCtx); |
| 9886 | #endif /* WLAN_FEATURE_EXTSCAN */ |
Vinay Krishna Eranna | f97ef5c | 2014-12-26 17:47:19 +0530 | [diff] [blame] | 9887 | |
| 9888 | #ifdef WLAN_NS_OFFLOAD |
| 9889 | // Register IPv6 notifier to notify if any change in IP |
| 9890 | // So that we can reconfigure the offload parameters |
| 9891 | pHddCtx->ipv6_notifier.notifier_call = wlan_hdd_ipv6_changed; |
| 9892 | ret = register_inet6addr_notifier(&pHddCtx->ipv6_notifier); |
| 9893 | if (ret) |
| 9894 | { |
| 9895 | hddLog(LOGE, FL("Failed to register IPv6 notifier")); |
| 9896 | } |
| 9897 | else |
| 9898 | { |
| 9899 | hddLog(LOGE, FL("Registered IPv6 notifier")); |
| 9900 | } |
| 9901 | #endif |
| 9902 | |
| 9903 | // Register IPv4 notifier to notify if any change in IP |
| 9904 | // So that we can reconfigure the offload parameters |
| 9905 | pHddCtx->ipv4_notifier.notifier_call = wlan_hdd_ipv4_changed; |
| 9906 | ret = register_inetaddr_notifier(&pHddCtx->ipv4_notifier); |
| 9907 | if (ret) |
| 9908 | { |
| 9909 | hddLog(LOGE, FL("Failed to register IPv4 notifier")); |
| 9910 | } |
| 9911 | else |
| 9912 | { |
| 9913 | hddLog(LOGE, FL("Registered IPv4 notifier")); |
| 9914 | } |
| 9915 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9916 | goto success; |
| 9917 | |
| 9918 | err_nl_srv: |
Leo Chang | 59cdc7e | 2013-07-10 10:08:21 -0700 | [diff] [blame] | 9919 | #ifdef WLAN_KD_READY_NOTIFIER |
| 9920 | nl_srv_exit(pHddCtx->ptt_pid); |
| 9921 | #else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9922 | nl_srv_exit(); |
Leo Chang | 59cdc7e | 2013-07-10 10:08:21 -0700 | [diff] [blame] | 9923 | #endif /* WLAN_KD_READY_NOTIFIER */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9924 | err_reg_netdev: |
| 9925 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 9926 | |
| 9927 | err_free_power_on_lock: |
| 9928 | free_riva_power_on_lock("wlan"); |
| 9929 | |
| 9930 | err_unregister_pmops: |
| 9931 | hddDevTmUnregisterNotifyCallback(pHddCtx); |
| 9932 | hddDeregisterPmOps(pHddCtx); |
| 9933 | |
Yue Ma | 0d4891e | 2013-08-06 17:01:45 -0700 | [diff] [blame] | 9934 | hdd_debugfs_exit(pHddCtx); |
| 9935 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9936 | #ifdef WLAN_BTAMP_FEATURE |
| 9937 | err_bap_stop: |
| 9938 | WLANBAP_Stop(pVosContext); |
| 9939 | #endif |
| 9940 | |
| 9941 | #ifdef WLAN_BTAMP_FEATURE |
| 9942 | err_bap_close: |
| 9943 | WLANBAP_Close(pVosContext); |
| 9944 | #endif |
| 9945 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9946 | err_close_adapter: |
| 9947 | hdd_close_all_adapters( pHddCtx ); |
Mahesh A Saptasagar | 9ecefe4 | 2014-07-15 18:43:49 +0530 | [diff] [blame] | 9948 | #ifdef CONFIG_ENABLE_LINUX_REG |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 9949 | err_unregister_wiphy: |
Mahesh A Saptasagar | 9ecefe4 | 2014-07-15 18:43:49 +0530 | [diff] [blame] | 9950 | #endif |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 9951 | wiphy_unregister(wiphy) ; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9952 | err_vosstop: |
| 9953 | vos_stop(pVosContext); |
| 9954 | |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 9955 | err_vosclose: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9956 | status = vos_sched_close( pVosContext ); |
| 9957 | if (!VOS_IS_STATUS_SUCCESS(status)) { |
| 9958 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, |
| 9959 | "%s: Failed to close VOSS Scheduler", __func__); |
| 9960 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( status ) ); |
| 9961 | } |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 9962 | vos_close(pVosContext ); |
| 9963 | |
Amar Singhal | 0a40223 | 2013-10-11 20:57:16 -0700 | [diff] [blame] | 9964 | err_vos_nv_close: |
| 9965 | |
c_hpothu | e6a3628 | 2014-03-19 12:27:38 +0530 | [diff] [blame] | 9966 | #ifdef CONFIG_ENABLE_LINUX_REG |
Amar Singhal | 0a40223 | 2013-10-11 20:57:16 -0700 | [diff] [blame] | 9967 | vos_nv_close(); |
| 9968 | |
c_hpothu | 70f8d81 | 2014-03-22 22:59:23 +0530 | [diff] [blame] | 9969 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9970 | |
| 9971 | err_wdclose: |
| 9972 | if(pHddCtx->cfg_ini->fIsLogpEnabled) |
| 9973 | vos_watchdog_close(pVosContext); |
| 9974 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9975 | err_config: |
| 9976 | kfree(pHddCtx->cfg_ini); |
| 9977 | pHddCtx->cfg_ini= NULL; |
| 9978 | |
| 9979 | err_free_hdd_context: |
| 9980 | hdd_allow_suspend(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9981 | wiphy_free(wiphy) ; |
| 9982 | //kfree(wdev) ; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9983 | VOS_BUG(1); |
| 9984 | |
Madan Mohan Koyyalamudi | d57ae63 | 2012-11-06 18:42:48 -0800 | [diff] [blame] | 9985 | if (hdd_is_ssr_required()) |
| 9986 | { |
| 9987 | /* WDI timeout had happened during load, so SSR is needed here */ |
| 9988 | subsystem_restart("wcnss"); |
| 9989 | msleep(5000); |
| 9990 | } |
| 9991 | hdd_set_ssr_required (VOS_FALSE); |
| 9992 | |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 9993 | return -EIO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9994 | |
| 9995 | success: |
| 9996 | EXIT(); |
| 9997 | return 0; |
| 9998 | } |
| 9999 | |
| 10000 | /**--------------------------------------------------------------------------- |
| 10001 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 10002 | \brief hdd_driver_init() - Core Driver Init Function |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10003 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 10004 | This is the driver entry point - called in different timeline depending |
| 10005 | on whether the driver is statically or dynamically linked |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10006 | |
| 10007 | \param - None |
| 10008 | |
| 10009 | \return - 0 for success, non zero for failure |
| 10010 | |
| 10011 | --------------------------------------------------------------------------*/ |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 10012 | static int hdd_driver_init( void) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10013 | { |
| 10014 | VOS_STATUS status; |
| 10015 | v_CONTEXT_t pVosContext = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10016 | struct device *dev = NULL; |
| 10017 | int ret_status = 0; |
Sameer Thalappil | f58d7ec | 2013-04-25 20:17:12 -0700 | [diff] [blame] | 10018 | #ifdef HAVE_WCNSS_CAL_DOWNLOAD |
| 10019 | int max_retries = 0; |
| 10020 | #endif |
Siddharth Bhal | c7e79b6 | 2014-10-10 22:37:38 +0530 | [diff] [blame] | 10021 | #ifdef HAVE_CBC_DONE |
| 10022 | int max_cbc_retries = 0; |
| 10023 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10024 | |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 10025 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 10026 | wlan_logging_sock_init_svc(); |
| 10027 | #endif |
| 10028 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10029 | ENTER(); |
| 10030 | |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 10031 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10032 | wake_lock_init(&wlan_wake_lock, WAKE_LOCK_SUSPEND, "wlan"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10033 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10034 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 10035 | hddTraceInit(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10036 | pr_info("%s: loading driver v%s\n", WLAN_MODULE_NAME, |
| 10037 | QWLAN_VERSIONSTR TIMER_MANAGER_STR MEMORY_DEBUG_STR); |
| 10038 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10039 | #ifdef ANI_BUS_TYPE_PCI |
| 10040 | |
| 10041 | dev = wcnss_wlan_get_device(); |
| 10042 | |
| 10043 | #endif // ANI_BUS_TYPE_PCI |
| 10044 | |
| 10045 | #ifdef ANI_BUS_TYPE_PLATFORM |
Sameer Thalappil | f58d7ec | 2013-04-25 20:17:12 -0700 | [diff] [blame] | 10046 | |
| 10047 | #ifdef HAVE_WCNSS_CAL_DOWNLOAD |
| 10048 | /* wait until WCNSS driver downloads NV */ |
| 10049 | while (!wcnss_device_ready() && 5 >= ++max_retries) { |
| 10050 | msleep(1000); |
| 10051 | } |
Siddharth Bhal | c7e79b6 | 2014-10-10 22:37:38 +0530 | [diff] [blame] | 10052 | |
Sameer Thalappil | f58d7ec | 2013-04-25 20:17:12 -0700 | [diff] [blame] | 10053 | if (max_retries >= 5) { |
| 10054 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: WCNSS driver not ready", __func__); |
madan mohan koyyalamudi | 8c96ce1 | 2013-07-10 19:14:39 +0530 | [diff] [blame] | 10055 | #ifdef WLAN_OPEN_SOURCE |
| 10056 | wake_lock_destroy(&wlan_wake_lock); |
| 10057 | #endif |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 10058 | |
| 10059 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 10060 | wlan_logging_sock_deinit_svc(); |
| 10061 | #endif |
| 10062 | |
Sameer Thalappil | f58d7ec | 2013-04-25 20:17:12 -0700 | [diff] [blame] | 10063 | return -ENODEV; |
| 10064 | } |
| 10065 | #endif |
| 10066 | |
Siddharth Bhal | c7e79b6 | 2014-10-10 22:37:38 +0530 | [diff] [blame] | 10067 | #ifdef HAVE_CBC_DONE |
| 10068 | while (!wcnss_cbc_complete() && 10 >= ++max_cbc_retries) { |
| 10069 | msleep(1000); |
| 10070 | } |
| 10071 | if (max_cbc_retries >= 10) { |
| 10072 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s:CBC not completed", __func__); |
| 10073 | } |
| 10074 | #endif |
| 10075 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10076 | dev = wcnss_wlan_get_device(); |
| 10077 | #endif // ANI_BUS_TYPE_PLATFORM |
| 10078 | |
| 10079 | |
| 10080 | do { |
| 10081 | if (NULL == dev) { |
| 10082 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: WLAN device not found!!",__func__); |
| 10083 | ret_status = -1; |
| 10084 | break; |
| 10085 | } |
| 10086 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10087 | #ifdef TIMER_MANAGER |
| 10088 | vos_timer_manager_init(); |
| 10089 | #endif |
| 10090 | |
| 10091 | /* Preopen VOSS so that it is ready to start at least SAL */ |
| 10092 | status = vos_preOpen(&pVosContext); |
| 10093 | |
| 10094 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 10095 | { |
| 10096 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Failed to preOpen VOSS", __func__); |
| 10097 | ret_status = -1; |
| 10098 | break; |
| 10099 | } |
| 10100 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 10101 | #ifndef MODULE |
| 10102 | /* For statically linked driver, call hdd_set_conparam to update curr_con_mode |
| 10103 | */ |
| 10104 | hdd_set_conparam((v_UINT_t)con_mode); |
| 10105 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10106 | |
| 10107 | // Call our main init function |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 10108 | if (hdd_wlan_startup(dev)) |
| 10109 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10110 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: WLAN Driver Initialization failed", |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 10111 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10112 | vos_preClose( &pVosContext ); |
| 10113 | ret_status = -1; |
| 10114 | break; |
| 10115 | } |
| 10116 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10117 | } while (0); |
| 10118 | |
| 10119 | if (0 != ret_status) |
| 10120 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10121 | #ifdef TIMER_MANAGER |
| 10122 | vos_timer_exit(); |
| 10123 | #endif |
| 10124 | #ifdef MEMORY_DEBUG |
| 10125 | vos_mem_exit(); |
| 10126 | #endif |
| 10127 | |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 10128 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10129 | wake_lock_destroy(&wlan_wake_lock); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10130 | #endif |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 10131 | |
| 10132 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 10133 | wlan_logging_sock_deinit_svc(); |
| 10134 | #endif |
| 10135 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10136 | pr_err("%s: driver load failure\n", WLAN_MODULE_NAME); |
| 10137 | } |
| 10138 | else |
| 10139 | { |
| 10140 | //Send WLAN UP indication to Nlink Service |
| 10141 | send_btc_nlink_msg(WLAN_MODULE_UP_IND, 0); |
| 10142 | |
| 10143 | pr_info("%s: driver loaded\n", WLAN_MODULE_NAME); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10144 | } |
| 10145 | |
| 10146 | EXIT(); |
| 10147 | |
| 10148 | return ret_status; |
| 10149 | } |
| 10150 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 10151 | /**--------------------------------------------------------------------------- |
| 10152 | |
| 10153 | \brief hdd_module_init() - Init Function |
| 10154 | |
| 10155 | This is the driver entry point (invoked when module is loaded using insmod) |
| 10156 | |
| 10157 | \param - None |
| 10158 | |
| 10159 | \return - 0 for success, non zero for failure |
| 10160 | |
| 10161 | --------------------------------------------------------------------------*/ |
| 10162 | #ifdef MODULE |
| 10163 | static int __init hdd_module_init ( void) |
| 10164 | { |
| 10165 | return hdd_driver_init(); |
| 10166 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 10167 | #else /* #ifdef MODULE */ |
| 10168 | static int __init hdd_module_init ( void) |
| 10169 | { |
| 10170 | /* Driver initialization is delayed to fwpath_changed_handler */ |
| 10171 | return 0; |
| 10172 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 10173 | #endif /* #ifdef MODULE */ |
| 10174 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10175 | |
| 10176 | /**--------------------------------------------------------------------------- |
| 10177 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 10178 | \brief hdd_driver_exit() - Exit function |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10179 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 10180 | This is the driver exit point (invoked when module is unloaded using rmmod |
| 10181 | or con_mode was changed by userspace) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10182 | |
| 10183 | \param - None |
| 10184 | |
| 10185 | \return - None |
| 10186 | |
| 10187 | --------------------------------------------------------------------------*/ |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 10188 | static void hdd_driver_exit(void) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10189 | { |
| 10190 | hdd_context_t *pHddCtx = NULL; |
| 10191 | v_CONTEXT_t pVosContext = NULL; |
Agarwal Ashish | 5e41479 | 2014-06-08 15:25:23 +0530 | [diff] [blame] | 10192 | v_REGDOMAIN_t regId; |
Arun Kumar Khandavalli | e0b046d | 2014-03-01 21:54:25 +0530 | [diff] [blame] | 10193 | unsigned long rc = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10194 | |
| 10195 | pr_info("%s: unloading driver v%s\n", WLAN_MODULE_NAME, QWLAN_VERSIONSTR); |
| 10196 | |
| 10197 | //Get the global vos context |
| 10198 | pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL); |
| 10199 | |
| 10200 | if(!pVosContext) |
| 10201 | { |
| 10202 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Global VOS context is Null", __func__); |
| 10203 | goto done; |
| 10204 | } |
| 10205 | |
| 10206 | //Get the HDD context. |
| 10207 | pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext ); |
| 10208 | |
| 10209 | if(!pHddCtx) |
| 10210 | { |
| 10211 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: module exit called before probe",__func__); |
| 10212 | } |
| 10213 | else |
| 10214 | { |
Siddharth Bhal | 2e5871b | 2015-03-24 16:20:51 +0530 | [diff] [blame] | 10215 | /* We wait for active entry threads to exit from driver |
| 10216 | * by waiting until rtnl_lock is available. |
| 10217 | */ |
| 10218 | rtnl_lock(); |
| 10219 | rtnl_unlock(); |
| 10220 | |
Siddharth Bhal | 3c29dca | 2015-02-19 00:41:40 +0530 | [diff] [blame] | 10221 | INIT_COMPLETION(pHddCtx->ssr_comp_var); |
| 10222 | if ((pHddCtx->isLogpInProgress) && (FALSE == |
| 10223 | vos_is_wlan_in_badState(VOS_MODULE_ID_HDD, NULL))) |
| 10224 | { |
Siddharth Bhal | a204f57 | 2015-01-17 02:03:36 +0530 | [diff] [blame] | 10225 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Siddharth Bhal | 3c29dca | 2015-02-19 00:41:40 +0530 | [diff] [blame] | 10226 | "%s:SSR in Progress; block rmmod !!!", __func__); |
Siddharth Bhal | a204f57 | 2015-01-17 02:03:36 +0530 | [diff] [blame] | 10227 | rc = wait_for_completion_timeout(&pHddCtx->ssr_comp_var, |
| 10228 | msecs_to_jiffies(30000)); |
| 10229 | if(!rc) |
| 10230 | { |
| 10231 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 10232 | "%s:SSR timedout, fatal error", __func__); |
| 10233 | VOS_BUG(0); |
| 10234 | } |
| 10235 | } |
| 10236 | |
Siddharth Bhal | 3c29dca | 2015-02-19 00:41:40 +0530 | [diff] [blame] | 10237 | pHddCtx->isLoadUnloadInProgress = WLAN_HDD_UNLOAD_IN_PROGRESS; |
| 10238 | vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, TRUE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10239 | |
c_hpothu | 8adb97b | 2014-12-08 19:38:20 +0530 | [diff] [blame] | 10240 | /* Driver Need to send country code 00 in below condition |
| 10241 | * 1) If gCountryCodePriority is set to 1; and last country |
| 10242 | * code set is through 11d. This needs to be done in case |
| 10243 | * when NV country code is 00. |
| 10244 | * This Needs to be done as when kernel store last country |
| 10245 | * code and if stored country code is not through 11d, |
| 10246 | * in sme_HandleChangeCountryCodeByUser we will disable 11d |
| 10247 | * in next load/unload as soon as we get any country through |
| 10248 | * 11d. In sme_HandleChangeCountryCodeByUser |
| 10249 | * pMsg->countryCode will be last countryCode and |
| 10250 | * pMac->scan.countryCode11d will be country through 11d so |
| 10251 | * due to mismatch driver will disable 11d. |
| 10252 | * |
| 10253 | */ |
Agarwal Ashish | 8db3988 | 2014-07-30 21:56:07 +0530 | [diff] [blame] | 10254 | |
c_hpothu | 8adb97b | 2014-12-08 19:38:20 +0530 | [diff] [blame] | 10255 | if ((eANI_BOOLEAN_TRUE == sme_Is11dCountrycode(pHddCtx->hHal) && |
Agarwal Ashish | 8dcd286 | 2014-07-25 11:58:52 +0530 | [diff] [blame] | 10256 | pHddCtx->cfg_ini->fSupplicantCountryCodeHasPriority && |
Abhishek Singh | 2a70596 | 2014-10-30 14:47:28 +0530 | [diff] [blame] | 10257 | sme_Is11dSupported(pHddCtx->hHal))) |
c_hpothu | 8adb97b | 2014-12-08 19:38:20 +0530 | [diff] [blame] | 10258 | { |
| 10259 | hddLog(VOS_TRACE_LEVEL_INFO, |
Agarwal Ashish | 8dcd286 | 2014-07-25 11:58:52 +0530 | [diff] [blame] | 10260 | FL("CountryCode 00 is being set while unloading driver")); |
c_hpothu | 8adb97b | 2014-12-08 19:38:20 +0530 | [diff] [blame] | 10261 | vos_nv_getRegDomainFromCountryCode(®Id , "00", COUNTRY_USER); |
| 10262 | } |
Agarwal Ashish | 5e41479 | 2014-06-08 15:25:23 +0530 | [diff] [blame] | 10263 | |
c_hpothu | 8adb97b | 2014-12-08 19:38:20 +0530 | [diff] [blame] | 10264 | //Do all the cleanup before deregistering the driver |
| 10265 | hdd_wlan_exit(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10266 | } |
| 10267 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10268 | vos_preClose( &pVosContext ); |
| 10269 | |
| 10270 | #ifdef TIMER_MANAGER |
| 10271 | vos_timer_exit(); |
| 10272 | #endif |
| 10273 | #ifdef MEMORY_DEBUG |
| 10274 | vos_mem_exit(); |
| 10275 | #endif |
| 10276 | |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 10277 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 10278 | wlan_logging_sock_deinit_svc(); |
| 10279 | #endif |
| 10280 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10281 | done: |
Sameer Thalappil | 50dc009 | 2013-02-19 17:23:33 -0800 | [diff] [blame] | 10282 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10283 | wake_lock_destroy(&wlan_wake_lock); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10284 | #endif |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 10285 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10286 | pr_info("%s: driver unloaded\n", WLAN_MODULE_NAME); |
| 10287 | } |
| 10288 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 10289 | /**--------------------------------------------------------------------------- |
| 10290 | |
| 10291 | \brief hdd_module_exit() - Exit function |
| 10292 | |
| 10293 | This is the driver exit point (invoked when module is unloaded using rmmod) |
| 10294 | |
| 10295 | \param - None |
| 10296 | |
| 10297 | \return - None |
| 10298 | |
| 10299 | --------------------------------------------------------------------------*/ |
| 10300 | static void __exit hdd_module_exit(void) |
| 10301 | { |
| 10302 | hdd_driver_exit(); |
| 10303 | } |
| 10304 | |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 10305 | #ifdef MODULE |
| 10306 | static int fwpath_changed_handler(const char *kmessage, |
| 10307 | struct kernel_param *kp) |
| 10308 | { |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 10309 | return param_set_copystring(kmessage, kp); |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 10310 | } |
| 10311 | |
| 10312 | static int con_mode_handler(const char *kmessage, |
| 10313 | struct kernel_param *kp) |
| 10314 | { |
Madan Mohan Koyyalamudi | f2f8d8b | 2012-10-11 17:06:59 -0700 | [diff] [blame] | 10315 | return param_set_int(kmessage, kp); |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 10316 | } |
| 10317 | #else /* #ifdef MODULE */ |
| 10318 | /**--------------------------------------------------------------------------- |
| 10319 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 10320 | \brief kickstart_driver |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 10321 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 10322 | This is the driver entry point |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 10323 | - delayed driver initialization when driver is statically linked |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 10324 | - invoked when module parameter fwpath is modified from userspace to signal |
| 10325 | initializing the WLAN driver or when con_mode is modified from userspace |
| 10326 | to signal a switch in operating mode |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 10327 | |
| 10328 | \return - 0 for success, non zero for failure |
| 10329 | |
| 10330 | --------------------------------------------------------------------------*/ |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 10331 | static int kickstart_driver(void) |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 10332 | { |
Madan Mohan Koyyalamudi | 62e6005 | 2012-10-05 14:27:22 -0700 | [diff] [blame] | 10333 | int ret_status; |
| 10334 | |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 10335 | if (!wlan_hdd_inited) { |
Madan Mohan Koyyalamudi | 62e6005 | 2012-10-05 14:27:22 -0700 | [diff] [blame] | 10336 | ret_status = hdd_driver_init(); |
| 10337 | wlan_hdd_inited = ret_status ? 0 : 1; |
| 10338 | return ret_status; |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 10339 | } |
| 10340 | |
| 10341 | hdd_driver_exit(); |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 10342 | |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 10343 | msleep(200); |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 10344 | |
Madan Mohan Koyyalamudi | 62e6005 | 2012-10-05 14:27:22 -0700 | [diff] [blame] | 10345 | ret_status = hdd_driver_init(); |
| 10346 | wlan_hdd_inited = ret_status ? 0 : 1; |
| 10347 | return ret_status; |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 10348 | } |
| 10349 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10350 | /**--------------------------------------------------------------------------- |
| 10351 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 10352 | \brief fwpath_changed_handler() - Handler Function |
| 10353 | |
| 10354 | Handle changes to the fwpath parameter |
| 10355 | |
| 10356 | \return - 0 for success, non zero for failure |
| 10357 | |
| 10358 | --------------------------------------------------------------------------*/ |
| 10359 | static int fwpath_changed_handler(const char *kmessage, |
| 10360 | struct kernel_param *kp) |
| 10361 | { |
| 10362 | int ret; |
| 10363 | |
| 10364 | ret = param_set_copystring(kmessage, kp); |
| 10365 | if (0 == ret) |
| 10366 | ret = kickstart_driver(); |
| 10367 | return ret; |
| 10368 | } |
| 10369 | |
| 10370 | /**--------------------------------------------------------------------------- |
| 10371 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 10372 | \brief con_mode_handler() - |
| 10373 | |
| 10374 | Handler function for module param con_mode when it is changed by userspace |
| 10375 | Dynamically linked - do nothing |
| 10376 | Statically linked - exit and init driver, as in rmmod and insmod |
| 10377 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 10378 | \param - |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 10379 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 10380 | \return - |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 10381 | |
| 10382 | --------------------------------------------------------------------------*/ |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 10383 | 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] | 10384 | { |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 10385 | int ret; |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 10386 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 10387 | ret = param_set_int(kmessage, kp); |
| 10388 | if (0 == ret) |
| 10389 | ret = kickstart_driver(); |
| 10390 | return ret; |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 10391 | } |
| 10392 | #endif /* #ifdef MODULE */ |
| 10393 | |
| 10394 | /**--------------------------------------------------------------------------- |
| 10395 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10396 | \brief hdd_get_conparam() - |
| 10397 | |
| 10398 | This is the driver exit point (invoked when module is unloaded using rmmod) |
| 10399 | |
| 10400 | \param - None |
| 10401 | |
| 10402 | \return - tVOS_CON_MODE |
| 10403 | |
| 10404 | --------------------------------------------------------------------------*/ |
| 10405 | tVOS_CON_MODE hdd_get_conparam ( void ) |
| 10406 | { |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 10407 | #ifdef MODULE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10408 | return (tVOS_CON_MODE)con_mode; |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 10409 | #else |
| 10410 | return (tVOS_CON_MODE)curr_con_mode; |
| 10411 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10412 | } |
| 10413 | void hdd_set_conparam ( v_UINT_t newParam ) |
| 10414 | { |
| 10415 | con_mode = newParam; |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 10416 | #ifndef MODULE |
| 10417 | curr_con_mode = con_mode; |
| 10418 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10419 | } |
| 10420 | /**--------------------------------------------------------------------------- |
| 10421 | |
| 10422 | \brief hdd_softap_sta_deauth() - function |
| 10423 | |
| 10424 | This to take counter measure to handle deauth req from HDD |
| 10425 | |
| 10426 | \param - pAdapter - Pointer to the HDD |
| 10427 | |
| 10428 | \param - enable - boolean value |
| 10429 | |
| 10430 | \return - None |
| 10431 | |
| 10432 | --------------------------------------------------------------------------*/ |
| 10433 | |
Hanumantha Reddy Pothula | bfd06f7 | 2014-10-31 14:03:37 +0530 | [diff] [blame] | 10434 | VOS_STATUS hdd_softap_sta_deauth(hdd_adapter_t *pAdapter, |
| 10435 | struct tagCsrDelStaParams *pDelStaParams) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10436 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10437 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 10438 | VOS_STATUS vosStatus = VOS_STATUS_E_FAULT; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10439 | |
| 10440 | ENTER(); |
| 10441 | |
Rajesh Chauhan | 18488fc | 2013-08-22 10:15:03 -0700 | [diff] [blame] | 10442 | hddLog(LOG1, "hdd_softap_sta_deauth:(%p, false)", |
| 10443 | (WLAN_HDD_GET_CTX(pAdapter))->pvosContext); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10444 | |
| 10445 | //Ignore request to deauth bcmc station |
Hanumantha Reddy Pothula | bfd06f7 | 2014-10-31 14:03:37 +0530 | [diff] [blame] | 10446 | if (pDelStaParams->peerMacAddr[0] & 0x1) |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 10447 | return vosStatus; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10448 | |
Hanumantha Reddy Pothula | bfd06f7 | 2014-10-31 14:03:37 +0530 | [diff] [blame] | 10449 | vosStatus = WLANSAP_DeauthSta(pVosContext, pDelStaParams); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10450 | |
| 10451 | EXIT(); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 10452 | return vosStatus; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10453 | } |
| 10454 | |
| 10455 | /**--------------------------------------------------------------------------- |
| 10456 | |
Rashmi Ramanna | 1f0948d | 2014-08-28 15:33:48 +0530 | [diff] [blame] | 10457 | \brief hdd_del_all_sta() - function |
| 10458 | |
| 10459 | This function removes all the stations associated on stopping AP/P2P GO. |
| 10460 | |
| 10461 | \param - pAdapter - Pointer to the HDD |
| 10462 | |
| 10463 | \return - None |
| 10464 | |
| 10465 | --------------------------------------------------------------------------*/ |
| 10466 | |
| 10467 | int hdd_del_all_sta(hdd_adapter_t *pAdapter) |
| 10468 | { |
| 10469 | v_U16_t i; |
| 10470 | VOS_STATUS vos_status; |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 10471 | v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
| 10472 | ptSapContext pSapCtx = NULL; |
| 10473 | pSapCtx = VOS_GET_SAP_CB(pVosContext); |
| 10474 | if(pSapCtx == NULL){ |
| 10475 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10476 | FL("psapCtx is NULL")); |
| 10477 | return 1; |
| 10478 | } |
Rashmi Ramanna | 1f0948d | 2014-08-28 15:33:48 +0530 | [diff] [blame] | 10479 | ENTER(); |
| 10480 | |
| 10481 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 10482 | "%s: Delete all STAs associated.",__func__); |
| 10483 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
| 10484 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
| 10485 | ) |
| 10486 | { |
| 10487 | for(i = 0; i < WLAN_MAX_STA_COUNT; i++) |
| 10488 | { |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 10489 | if ((pSapCtx->aStaInfo[i].isUsed) && |
| 10490 | (!pSapCtx->aStaInfo[i].isDeauthInProgress)) |
Rashmi Ramanna | 1f0948d | 2014-08-28 15:33:48 +0530 | [diff] [blame] | 10491 | { |
Hanumantha Reddy Pothula | bfd06f7 | 2014-10-31 14:03:37 +0530 | [diff] [blame] | 10492 | struct tagCsrDelStaParams delStaParams; |
| 10493 | |
| 10494 | WLANSAP_PopulateDelStaParams( |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 10495 | pSapCtx->aStaInfo[i].macAddrSTA.bytes, |
Sushant Kaushik | 4cd28f6 | 2014-12-26 14:23:50 +0530 | [diff] [blame] | 10496 | eSIR_MAC_DEAUTH_LEAVING_BSS_REASON, |
| 10497 | SIR_MAC_MGMT_DEAUTH >> 4, |
Hanumantha Reddy Pothula | bfd06f7 | 2014-10-31 14:03:37 +0530 | [diff] [blame] | 10498 | &delStaParams); |
| 10499 | vos_status = hdd_softap_sta_deauth(pAdapter, &delStaParams); |
Rashmi Ramanna | 1f0948d | 2014-08-28 15:33:48 +0530 | [diff] [blame] | 10500 | if (VOS_IS_STATUS_SUCCESS(vos_status)) |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 10501 | pSapCtx->aStaInfo[i].isDeauthInProgress = TRUE; |
Rashmi Ramanna | 1f0948d | 2014-08-28 15:33:48 +0530 | [diff] [blame] | 10502 | } |
| 10503 | } |
| 10504 | } |
| 10505 | |
| 10506 | EXIT(); |
| 10507 | return 0; |
| 10508 | } |
| 10509 | |
| 10510 | /**--------------------------------------------------------------------------- |
| 10511 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10512 | \brief hdd_softap_sta_disassoc() - function |
| 10513 | |
| 10514 | This to take counter measure to handle deauth req from HDD |
| 10515 | |
| 10516 | \param - pAdapter - Pointer to the HDD |
| 10517 | |
| 10518 | \param - enable - boolean value |
| 10519 | |
| 10520 | \return - None |
| 10521 | |
| 10522 | --------------------------------------------------------------------------*/ |
| 10523 | |
| 10524 | void hdd_softap_sta_disassoc(hdd_adapter_t *pAdapter,v_U8_t *pDestMacAddress) |
| 10525 | { |
| 10526 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
| 10527 | |
| 10528 | ENTER(); |
| 10529 | |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 10530 | 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] | 10531 | |
| 10532 | //Ignore request to disassoc bcmc station |
| 10533 | if( pDestMacAddress[0] & 0x1 ) |
| 10534 | return; |
| 10535 | |
| 10536 | WLANSAP_DisassocSta(pVosContext,pDestMacAddress); |
| 10537 | } |
| 10538 | |
| 10539 | void hdd_softap_tkip_mic_fail_counter_measure(hdd_adapter_t *pAdapter,v_BOOL_t enable) |
| 10540 | { |
| 10541 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
| 10542 | |
| 10543 | ENTER(); |
| 10544 | |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 10545 | 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] | 10546 | |
| 10547 | WLANSAP_SetCounterMeasure(pVosContext, (v_BOOL_t)enable); |
| 10548 | } |
| 10549 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10550 | /**--------------------------------------------------------------------------- |
| 10551 | * |
| 10552 | * \brief hdd_get__concurrency_mode() - |
| 10553 | * |
| 10554 | * |
| 10555 | * \param - None |
| 10556 | * |
| 10557 | * \return - CONCURRENCY MODE |
| 10558 | * |
| 10559 | * --------------------------------------------------------------------------*/ |
| 10560 | tVOS_CONCURRENCY_MODE hdd_get_concurrency_mode ( void ) |
| 10561 | { |
| 10562 | v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL ); |
| 10563 | hdd_context_t *pHddCtx; |
| 10564 | |
| 10565 | if (NULL != pVosContext) |
| 10566 | { |
| 10567 | pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext); |
| 10568 | if (NULL != pHddCtx) |
| 10569 | { |
| 10570 | return (tVOS_CONCURRENCY_MODE)pHddCtx->concurrency_mode; |
| 10571 | } |
| 10572 | } |
| 10573 | |
| 10574 | /* we are in an invalid state :( */ |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 10575 | hddLog(LOGE, "%s: Invalid context", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10576 | return VOS_STA; |
| 10577 | } |
Sushant Kaushik | abb7ee6 | 2014-07-18 16:20:12 +0530 | [diff] [blame] | 10578 | v_BOOL_t |
| 10579 | wlan_hdd_is_GO_power_collapse_allowed (hdd_context_t* pHddCtx) |
| 10580 | { |
| 10581 | hdd_adapter_t *pAdapter = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10582 | |
Sushant Kaushik | abb7ee6 | 2014-07-18 16:20:12 +0530 | [diff] [blame] | 10583 | pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_GO); |
| 10584 | if (pAdapter == NULL) |
| 10585 | { |
| 10586 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 10587 | FL("GO doesn't exist")); |
| 10588 | return TRUE; |
| 10589 | } |
| 10590 | if (test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags)) |
| 10591 | { |
| 10592 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 10593 | FL("GO started")); |
| 10594 | return TRUE; |
| 10595 | } |
| 10596 | else |
| 10597 | /* wait till GO changes its interface to p2p device */ |
| 10598 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 10599 | FL("Del_bss called, avoid apps suspend")); |
| 10600 | return FALSE; |
| 10601 | |
| 10602 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10603 | /* Decide whether to allow/not the apps power collapse. |
| 10604 | * Allow apps power collapse if we are in connected state. |
| 10605 | * if not, allow only if we are in IMPS */ |
| 10606 | v_BOOL_t hdd_is_apps_power_collapse_allowed(hdd_context_t* pHddCtx) |
| 10607 | { |
| 10608 | tPmcState pmcState = pmcGetPmcState(pHddCtx->hHal); |
Srikant Kuppa | fef66a7 | 2013-01-30 17:32:44 -0800 | [diff] [blame] | 10609 | tANI_BOOLEAN scanRspPending = csrNeighborRoamScanRspPending(pHddCtx->hHal); |
Srinivas Girigowda | a553c46 | 2013-03-07 19:42:52 -0800 | [diff] [blame] | 10610 | tANI_BOOLEAN inMiddleOfRoaming = csrNeighborMiddleOfRoaming(pHddCtx->hHal); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10611 | hdd_config_t *pConfig = pHddCtx->cfg_ini; |
| 10612 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 10613 | hdd_adapter_t *pAdapter = NULL; |
| 10614 | VOS_STATUS status; |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 10615 | tVOS_CONCURRENCY_MODE concurrent_state = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10616 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10617 | if (VOS_STA_SAP_MODE == hdd_get_conparam()) |
| 10618 | return TRUE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10619 | |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 10620 | concurrent_state = hdd_get_concurrency_mode(); |
| 10621 | |
Sushant Kaushik | abb7ee6 | 2014-07-18 16:20:12 +0530 | [diff] [blame] | 10622 | if ((concurrent_state == (VOS_STA | VOS_P2P_GO)) && |
| 10623 | !(wlan_hdd_is_GO_power_collapse_allowed(pHddCtx))) |
| 10624 | return FALSE; |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 10625 | #ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE |
Sushant Kaushik | abb7ee6 | 2014-07-18 16:20:12 +0530 | [diff] [blame] | 10626 | |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 10627 | if(((concurrent_state == (VOS_STA | VOS_P2P_CLIENT)) || |
Sushant Kaushik | abb7ee6 | 2014-07-18 16:20:12 +0530 | [diff] [blame] | 10628 | (concurrent_state == (VOS_STA | VOS_P2P_GO)))&& |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 10629 | (IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)) |
| 10630 | return TRUE; |
| 10631 | #endif |
| 10632 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10633 | /*loop through all adapters. TBD fix for Concurrency */ |
| 10634 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 10635 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 10636 | { |
| 10637 | pAdapter = pAdapterNode->pAdapter; |
| 10638 | if ( (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) |
| 10639 | || (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ) |
| 10640 | { |
Srikant Kuppa | fef66a7 | 2013-01-30 17:32:44 -0800 | [diff] [blame] | 10641 | if (((pConfig->fIsImpsEnabled || pConfig->fIsBmpsEnabled) |
c_hpothu | 4e8faac | 2014-05-16 17:38:44 +0530 | [diff] [blame] | 10642 | && (pmcState != IMPS && pmcState != BMPS && pmcState != UAPSD |
c_hpothu | 1c6957d | 2015-01-06 18:19:47 +0530 | [diff] [blame] | 10643 | && pmcState != STOPPED && pmcState != STANDBY && |
| 10644 | pmcState != WOWL)) || |
Srinivas Girigowda | a553c46 | 2013-03-07 19:42:52 -0800 | [diff] [blame] | 10645 | (eANI_BOOLEAN_TRUE == scanRspPending) || |
| 10646 | (eANI_BOOLEAN_TRUE == inMiddleOfRoaming)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10647 | { |
Mukul Sharma | 4be8842 | 2015-03-09 20:29:07 +0530 | [diff] [blame] | 10648 | if(pmcState == FULL_POWER && |
| 10649 | sme_IsCoexScoIndicationSet(pHddCtx->hHal)) |
| 10650 | { |
| 10651 | /* |
| 10652 | * When SCO indication comes from Coex module , host will |
| 10653 | * enter in to full power mode, but this should not prevent |
| 10654 | * apps processor power collapse. |
| 10655 | */ |
| 10656 | hddLog(LOG1, |
| 10657 | FL("Allow apps power collapse" |
| 10658 | "even when sco indication is set")); |
| 10659 | return TRUE; |
| 10660 | } |
Srikant Kuppa | fef66a7 | 2013-01-30 17:32:44 -0800 | [diff] [blame] | 10661 | hddLog( LOGE, "%s: do not allow APPS power collapse-" |
Srinivas Girigowda | a553c46 | 2013-03-07 19:42:52 -0800 | [diff] [blame] | 10662 | "pmcState = %d scanRspPending = %d inMiddleOfRoaming = %d", |
| 10663 | __func__, pmcState, scanRspPending, inMiddleOfRoaming ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10664 | return FALSE; |
| 10665 | } |
| 10666 | } |
| 10667 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 10668 | pAdapterNode = pNext; |
| 10669 | } |
| 10670 | return TRUE; |
| 10671 | } |
| 10672 | |
Madan Mohan Koyyalamudi | c72a4d6 | 2012-11-08 14:59:34 -0800 | [diff] [blame] | 10673 | /* Decides whether to send suspend notification to Riva |
| 10674 | * if any adapter is in BMPS; then it is required */ |
| 10675 | v_BOOL_t hdd_is_suspend_notify_allowed(hdd_context_t* pHddCtx) |
| 10676 | { |
| 10677 | tPmcState pmcState = pmcGetPmcState(pHddCtx->hHal); |
| 10678 | hdd_config_t *pConfig = pHddCtx->cfg_ini; |
| 10679 | |
| 10680 | if (pConfig->fIsBmpsEnabled && (pmcState == BMPS)) |
| 10681 | { |
| 10682 | return TRUE; |
| 10683 | } |
| 10684 | return FALSE; |
| 10685 | } |
| 10686 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10687 | void wlan_hdd_set_concurrency_mode(hdd_context_t *pHddCtx, tVOS_CON_MODE mode) |
| 10688 | { |
| 10689 | switch(mode) |
| 10690 | { |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 10691 | case VOS_STA_MODE: |
| 10692 | case VOS_P2P_CLIENT_MODE: |
| 10693 | case VOS_P2P_GO_MODE: |
| 10694 | case VOS_STA_SAP_MODE: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10695 | pHddCtx->concurrency_mode |= (1 << mode); |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 10696 | pHddCtx->no_of_open_sessions[mode]++; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10697 | break; |
| 10698 | default: |
| 10699 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10700 | } |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 10701 | hddLog(VOS_TRACE_LEVEL_INFO, FL("concurrency_mode = 0x%x " |
| 10702 | "Number of open sessions for mode %d = %d"), |
| 10703 | pHddCtx->concurrency_mode, mode, |
| 10704 | pHddCtx->no_of_open_sessions[mode]); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10705 | } |
| 10706 | |
| 10707 | |
| 10708 | void wlan_hdd_clear_concurrency_mode(hdd_context_t *pHddCtx, tVOS_CON_MODE mode) |
| 10709 | { |
| 10710 | switch(mode) |
| 10711 | { |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 10712 | case VOS_STA_MODE: |
| 10713 | case VOS_P2P_CLIENT_MODE: |
| 10714 | case VOS_P2P_GO_MODE: |
| 10715 | case VOS_STA_SAP_MODE: |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 10716 | pHddCtx->no_of_open_sessions[mode]--; |
| 10717 | if (!(pHddCtx->no_of_open_sessions[mode])) |
| 10718 | pHddCtx->concurrency_mode &= (~(1 << mode)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10719 | break; |
| 10720 | default: |
| 10721 | break; |
| 10722 | } |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 10723 | hddLog(VOS_TRACE_LEVEL_INFO, FL("concurrency_mode = 0x%x " |
| 10724 | "Number of open sessions for mode %d = %d"), |
| 10725 | pHddCtx->concurrency_mode, mode, pHddCtx->no_of_open_sessions[mode]); |
| 10726 | |
| 10727 | } |
| 10728 | /**--------------------------------------------------------------------------- |
| 10729 | * |
| 10730 | * \brief wlan_hdd_incr_active_session() |
| 10731 | * |
| 10732 | * This function increments the number of active sessions |
| 10733 | * maintained per device mode |
| 10734 | * Incase of STA/P2P CLI/IBSS upon connection indication it is incremented |
| 10735 | * Incase of SAP/P2P GO upon bss start it is incremented |
| 10736 | * |
| 10737 | * \param pHddCtx - HDD Context |
| 10738 | * \param mode - device mode |
| 10739 | * |
| 10740 | * \return - None |
| 10741 | * |
| 10742 | * --------------------------------------------------------------------------*/ |
| 10743 | void wlan_hdd_incr_active_session(hdd_context_t *pHddCtx, tVOS_CON_MODE mode) |
| 10744 | { |
| 10745 | switch (mode) { |
| 10746 | case VOS_STA_MODE: |
| 10747 | case VOS_P2P_CLIENT_MODE: |
| 10748 | case VOS_P2P_GO_MODE: |
| 10749 | case VOS_STA_SAP_MODE: |
| 10750 | pHddCtx->no_of_active_sessions[mode]++; |
| 10751 | break; |
| 10752 | default: |
| 10753 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Not Expected Mode %d"), mode); |
| 10754 | break; |
| 10755 | } |
| 10756 | hddLog(VOS_TRACE_LEVEL_INFO, FL("No.# of active sessions for mode %d = %d"), |
| 10757 | mode, |
| 10758 | pHddCtx->no_of_active_sessions[mode]); |
| 10759 | } |
| 10760 | |
| 10761 | /**--------------------------------------------------------------------------- |
| 10762 | * |
| 10763 | * \brief wlan_hdd_decr_active_session() |
| 10764 | * |
| 10765 | * This function decrements the number of active sessions |
| 10766 | * maintained per device mode |
| 10767 | * Incase of STA/P2P CLI/IBSS upon disconnection it is decremented |
| 10768 | * Incase of SAP/P2P GO upon bss stop it is decremented |
| 10769 | * |
| 10770 | * \param pHddCtx - HDD Context |
| 10771 | * \param mode - device mode |
| 10772 | * |
| 10773 | * \return - None |
| 10774 | * |
| 10775 | * --------------------------------------------------------------------------*/ |
| 10776 | void wlan_hdd_decr_active_session(hdd_context_t *pHddCtx, tVOS_CON_MODE mode) |
| 10777 | { |
| 10778 | switch (mode) { |
| 10779 | case VOS_STA_MODE: |
| 10780 | case VOS_P2P_CLIENT_MODE: |
| 10781 | case VOS_P2P_GO_MODE: |
| 10782 | case VOS_STA_SAP_MODE: |
Agarwal Ashish | 5325f52 | 2014-08-06 00:58:44 +0530 | [diff] [blame] | 10783 | if (pHddCtx->no_of_active_sessions[mode] > 0) |
| 10784 | pHddCtx->no_of_active_sessions[mode]--; |
| 10785 | else |
| 10786 | hddLog(VOS_TRACE_LEVEL_INFO, FL(" No.# of Active sessions" |
| 10787 | "is already Zero")); |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 10788 | break; |
| 10789 | default: |
| 10790 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Not Expected Mode %d"), mode); |
| 10791 | break; |
| 10792 | } |
| 10793 | hddLog(VOS_TRACE_LEVEL_INFO, FL("No.# of active sessions for mode %d = %d"), |
| 10794 | mode, |
| 10795 | pHddCtx->no_of_active_sessions[mode]); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10796 | } |
| 10797 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10798 | /**--------------------------------------------------------------------------- |
| 10799 | * |
| 10800 | * \brief wlan_hdd_restart_init |
| 10801 | * |
| 10802 | * This function initalizes restart timer/flag. An internal function. |
| 10803 | * |
| 10804 | * \param - pHddCtx |
| 10805 | * |
| 10806 | * \return - None |
| 10807 | * |
| 10808 | * --------------------------------------------------------------------------*/ |
| 10809 | |
| 10810 | static void wlan_hdd_restart_init(hdd_context_t *pHddCtx) |
| 10811 | { |
| 10812 | /* Initialize */ |
| 10813 | pHddCtx->hdd_restart_retries = 0; |
| 10814 | atomic_set(&pHddCtx->isRestartInProgress, 0); |
| 10815 | vos_timer_init(&pHddCtx->hdd_restart_timer, |
| 10816 | VOS_TIMER_TYPE_SW, |
| 10817 | wlan_hdd_restart_timer_cb, |
| 10818 | pHddCtx); |
| 10819 | } |
| 10820 | /**--------------------------------------------------------------------------- |
| 10821 | * |
| 10822 | * \brief wlan_hdd_restart_deinit |
| 10823 | * |
| 10824 | * This function cleans up the resources used. An internal function. |
| 10825 | * |
| 10826 | * \param - pHddCtx |
| 10827 | * |
| 10828 | * \return - None |
| 10829 | * |
| 10830 | * --------------------------------------------------------------------------*/ |
| 10831 | |
| 10832 | static void wlan_hdd_restart_deinit(hdd_context_t* pHddCtx) |
| 10833 | { |
| 10834 | |
| 10835 | VOS_STATUS vos_status; |
| 10836 | /* Block any further calls */ |
| 10837 | atomic_set(&pHddCtx->isRestartInProgress, 1); |
| 10838 | /* Cleanup */ |
| 10839 | vos_status = vos_timer_stop( &pHddCtx->hdd_restart_timer ); |
| 10840 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 10841 | hddLog(LOGE, FL("Failed to stop HDD restart timer")); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10842 | vos_status = vos_timer_destroy(&pHddCtx->hdd_restart_timer); |
| 10843 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 10844 | hddLog(LOGE, FL("Failed to destroy HDD restart timer")); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10845 | |
| 10846 | } |
| 10847 | |
| 10848 | /**--------------------------------------------------------------------------- |
| 10849 | * |
| 10850 | * \brief wlan_hdd_framework_restart |
| 10851 | * |
| 10852 | * This function uses a cfg80211 API to start a framework initiated WLAN |
| 10853 | * driver module unload/load. |
| 10854 | * |
| 10855 | * Also this API keep retrying (WLAN_HDD_RESTART_RETRY_MAX_CNT). |
| 10856 | * |
| 10857 | * |
| 10858 | * \param - pHddCtx |
| 10859 | * |
| 10860 | * \return - VOS_STATUS_SUCCESS: Success |
| 10861 | * VOS_STATUS_E_EMPTY: Adapter is Empty |
| 10862 | * VOS_STATUS_E_NOMEM: No memory |
| 10863 | |
| 10864 | * --------------------------------------------------------------------------*/ |
| 10865 | |
| 10866 | static VOS_STATUS wlan_hdd_framework_restart(hdd_context_t *pHddCtx) |
| 10867 | { |
| 10868 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 10869 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
Madan Mohan Koyyalamudi | fc19e44 | 2013-05-09 18:24:08 -0700 | [diff] [blame] | 10870 | int len = (sizeof (struct ieee80211_mgmt)); |
| 10871 | struct ieee80211_mgmt *mgmt = NULL; |
| 10872 | |
| 10873 | /* Prepare the DEAUTH managment frame with reason code */ |
| 10874 | mgmt = kzalloc(len, GFP_KERNEL); |
| 10875 | if(mgmt == NULL) |
| 10876 | { |
| 10877 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 10878 | "%s: memory allocation failed (%d bytes)", __func__, len); |
| 10879 | return VOS_STATUS_E_NOMEM; |
| 10880 | } |
| 10881 | mgmt->u.deauth.reason_code = WLAN_REASON_DISASSOC_LOW_ACK; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10882 | |
| 10883 | /* Iterate over all adapters/devices */ |
| 10884 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
Hanumantha Reddy Pothula | da0fe36 | 2015-02-27 18:37:03 +0530 | [diff] [blame] | 10885 | if ((NULL == pAdapterNode) || (VOS_STATUS_SUCCESS != status)) |
| 10886 | { |
| 10887 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10888 | FL("fail to get adapter: %p %d"), pAdapterNode, status); |
| 10889 | goto end; |
| 10890 | } |
| 10891 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10892 | do |
| 10893 | { |
Hanumantha Reddy Pothula | da0fe36 | 2015-02-27 18:37:03 +0530 | [diff] [blame] | 10894 | if(pAdapterNode->pAdapter && |
| 10895 | WLAN_HDD_ADAPTER_MAGIC == pAdapterNode->pAdapter->magic) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10896 | { |
| 10897 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 10898 | "restarting the driver(intf:\'%s\' mode:%d :try %d)", |
| 10899 | pAdapterNode->pAdapter->dev->name, |
| 10900 | pAdapterNode->pAdapter->device_mode, |
| 10901 | pHddCtx->hdd_restart_retries + 1); |
Madan Mohan Koyyalamudi | fc19e44 | 2013-05-09 18:24:08 -0700 | [diff] [blame] | 10902 | /* |
| 10903 | * CFG80211 event to restart the driver |
| 10904 | * |
| 10905 | * 'cfg80211_send_unprot_deauth' sends a |
| 10906 | * NL80211_CMD_UNPROT_DEAUTHENTICATE event to supplicant at any state |
| 10907 | * of SME(Linux Kernel) state machine. |
| 10908 | * |
| 10909 | * Reason code WLAN_REASON_DISASSOC_LOW_ACK is currently used to restart |
| 10910 | * the driver. |
| 10911 | * |
| 10912 | */ |
| 10913 | |
| 10914 | cfg80211_send_unprot_deauth(pAdapterNode->pAdapter->dev, (u_int8_t*)mgmt, len ); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10915 | } |
| 10916 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 10917 | pAdapterNode = pNext; |
| 10918 | } while((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status)); |
| 10919 | |
Hanumantha Reddy Pothula | da0fe36 | 2015-02-27 18:37:03 +0530 | [diff] [blame] | 10920 | end: |
Madan Mohan Koyyalamudi | fc19e44 | 2013-05-09 18:24:08 -0700 | [diff] [blame] | 10921 | /* Free the allocated management frame */ |
| 10922 | kfree(mgmt); |
| 10923 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10924 | /* Retry until we unload or reach max count */ |
| 10925 | if(++pHddCtx->hdd_restart_retries < WLAN_HDD_RESTART_RETRY_MAX_CNT) |
| 10926 | vos_timer_start(&pHddCtx->hdd_restart_timer, WLAN_HDD_RESTART_RETRY_DELAY_MS); |
| 10927 | |
| 10928 | return status; |
| 10929 | |
| 10930 | } |
| 10931 | /**--------------------------------------------------------------------------- |
| 10932 | * |
| 10933 | * \brief wlan_hdd_restart_timer_cb |
| 10934 | * |
| 10935 | * Restart timer callback. An internal function. |
| 10936 | * |
| 10937 | * \param - User data: |
| 10938 | * |
| 10939 | * \return - None |
| 10940 | * |
| 10941 | * --------------------------------------------------------------------------*/ |
| 10942 | |
| 10943 | void wlan_hdd_restart_timer_cb(v_PVOID_t usrDataForCallback) |
| 10944 | { |
| 10945 | hdd_context_t *pHddCtx = usrDataForCallback; |
| 10946 | wlan_hdd_framework_restart(pHddCtx); |
| 10947 | return; |
| 10948 | |
| 10949 | } |
| 10950 | |
| 10951 | |
| 10952 | /**--------------------------------------------------------------------------- |
| 10953 | * |
| 10954 | * \brief wlan_hdd_restart_driver |
| 10955 | * |
| 10956 | * This function sends an event to supplicant to restart the WLAN driver. |
| 10957 | * |
| 10958 | * This function is called from vos_wlanRestart. |
| 10959 | * |
| 10960 | * \param - pHddCtx |
| 10961 | * |
| 10962 | * \return - VOS_STATUS_SUCCESS: Success |
| 10963 | * VOS_STATUS_E_EMPTY: Adapter is Empty |
| 10964 | * VOS_STATUS_E_ALREADY: Request already in progress |
| 10965 | |
| 10966 | * --------------------------------------------------------------------------*/ |
| 10967 | VOS_STATUS wlan_hdd_restart_driver(hdd_context_t *pHddCtx) |
| 10968 | { |
| 10969 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 10970 | |
| 10971 | /* A tight check to make sure reentrancy */ |
| 10972 | if(atomic_xchg(&pHddCtx->isRestartInProgress, 1)) |
| 10973 | { |
Mihir Shete | fd52865 | 2014-06-23 19:07:50 +0530 | [diff] [blame] | 10974 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10975 | "%s: WLAN restart is already in progress", __func__); |
| 10976 | |
| 10977 | return VOS_STATUS_E_ALREADY; |
| 10978 | } |
Sameer Thalappil | 0c164f5 | 2013-03-28 15:27:56 -0700 | [diff] [blame] | 10979 | /* Send reset FIQ to WCNSS to invoke SSR. */ |
Madan Mohan Koyyalamudi | e388b34 | 2012-11-08 15:03:16 -0800 | [diff] [blame] | 10980 | #ifdef HAVE_WCNSS_RESET_INTR |
Siddharth Bhal | 864e7e8 | 2015-04-07 20:07:24 +0530 | [diff] [blame] | 10981 | wcnss_reset_fiq(TRUE); |
Madan Mohan Koyyalamudi | bb8f017 | 2012-09-28 15:36:06 -0700 | [diff] [blame] | 10982 | #endif |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 10983 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10984 | return status; |
| 10985 | } |
| 10986 | |
Mihir Shete | e1093ba | 2014-01-21 20:13:32 +0530 | [diff] [blame] | 10987 | /**--------------------------------------------------------------------------- |
| 10988 | * |
| 10989 | * \brief wlan_hdd_init_channels |
| 10990 | * |
| 10991 | * This function is used to initialize the channel list in CSR |
| 10992 | * |
| 10993 | * This function is called from hdd_wlan_startup |
| 10994 | * |
| 10995 | * \param - pHddCtx: HDD context |
| 10996 | * |
| 10997 | * \return - VOS_STATUS_SUCCESS: Success |
| 10998 | * VOS_STATUS_E_FAULT: Failure reported by SME |
| 10999 | |
| 11000 | * --------------------------------------------------------------------------*/ |
| 11001 | static VOS_STATUS wlan_hdd_init_channels(hdd_context_t *pHddCtx) |
| 11002 | { |
| 11003 | eHalStatus status; |
| 11004 | |
| 11005 | status = sme_InitChannels(pHddCtx->hHal); |
| 11006 | if (HAL_STATUS_SUCCESS(status)) |
| 11007 | { |
| 11008 | return VOS_STATUS_SUCCESS; |
| 11009 | } |
| 11010 | else |
| 11011 | { |
| 11012 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Channel initialization failed(%d)", |
| 11013 | __func__, status); |
| 11014 | return VOS_STATUS_E_FAULT; |
| 11015 | } |
| 11016 | } |
| 11017 | |
Mihir Shete | 0420645 | 2014-11-20 17:50:58 +0530 | [diff] [blame] | 11018 | #ifdef CONFIG_ENABLE_LINUX_REG |
Agarwal Ashish | 6db9d53 | 2014-09-30 18:19:10 +0530 | [diff] [blame] | 11019 | 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] | 11020 | { |
| 11021 | eHalStatus status; |
| 11022 | |
Agarwal Ashish | 6db9d53 | 2014-09-30 18:19:10 +0530 | [diff] [blame] | 11023 | status = sme_InitChannelsForCC(pHddCtx->hHal, init); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 11024 | if (HAL_STATUS_SUCCESS(status)) |
| 11025 | { |
| 11026 | return VOS_STATUS_SUCCESS; |
| 11027 | } |
| 11028 | else |
| 11029 | { |
| 11030 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Issue reg hint failed(%d)", |
| 11031 | __func__, status); |
| 11032 | return VOS_STATUS_E_FAULT; |
| 11033 | } |
| 11034 | } |
Mihir Shete | 0420645 | 2014-11-20 17:50:58 +0530 | [diff] [blame] | 11035 | #endif |
Sudhir Sattayappa Kohalli | b1d8c3a | 2013-06-18 14:47:20 -0700 | [diff] [blame] | 11036 | /* |
| 11037 | * API to find if there is any STA or P2P-Client is connected |
| 11038 | */ |
| 11039 | VOS_STATUS hdd_issta_p2p_clientconnected(hdd_context_t *pHddCtx) |
| 11040 | { |
| 11041 | return sme_isSta_p2p_clientConnected(pHddCtx->hHal); |
| 11042 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 11043 | |
Mihir Shete | e2ae82a | 2015-03-16 14:08:49 +0530 | [diff] [blame] | 11044 | |
| 11045 | /* |
| 11046 | * API to find if the firmware will send logs using DXE channel |
| 11047 | */ |
| 11048 | v_U8_t hdd_is_fw_logging_enabled(void) |
| 11049 | { |
| 11050 | hdd_context_t *pHddCtx; |
| 11051 | |
| 11052 | pHddCtx = vos_get_context(VOS_MODULE_ID_HDD, |
| 11053 | vos_get_global_context(VOS_MODULE_ID_HDD, NULL)); |
| 11054 | |
Sachin Ahuja | 084313e | 2015-05-21 17:57:10 +0530 | [diff] [blame^] | 11055 | return (pHddCtx && pHddCtx->cfg_ini->enableMgmtLogging); |
Mihir Shete | e2ae82a | 2015-03-16 14:08:49 +0530 | [diff] [blame] | 11056 | } |
| 11057 | |
Agarwal Ashish | 57e8437 | 2014-12-05 18:26:53 +0530 | [diff] [blame] | 11058 | /* |
| 11059 | * API to find if there is any session connected |
| 11060 | */ |
| 11061 | VOS_STATUS hdd_is_any_session_connected(hdd_context_t *pHddCtx) |
| 11062 | { |
| 11063 | return sme_is_any_session_connected(pHddCtx->hHal); |
| 11064 | } |
| 11065 | |
| 11066 | |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 11067 | int wlan_hdd_scan_abort(hdd_adapter_t *pAdapter) |
| 11068 | { |
| 11069 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 11070 | hdd_scaninfo_t *pScanInfo = NULL; |
Girish Gowli | 4bf7a63 | 2014-06-12 13:42:11 +0530 | [diff] [blame] | 11071 | long status = 0; |
c_hpothu | a3d45d5 | 2015-01-05 14:11:17 +0530 | [diff] [blame] | 11072 | tSirAbortScanStatus abortScanStatus; |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 11073 | |
| 11074 | pScanInfo = &pHddCtx->scan_info; |
| 11075 | if (pScanInfo->mScanPending) |
| 11076 | { |
c_hpothu | a3d45d5 | 2015-01-05 14:11:17 +0530 | [diff] [blame] | 11077 | abortScanStatus = hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId, |
| 11078 | eCSR_SCAN_ABORT_DEFAULT); |
| 11079 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 11080 | FL("abortScanStatus: %d"), abortScanStatus); |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 11081 | |
c_hpothu | a3d45d5 | 2015-01-05 14:11:17 +0530 | [diff] [blame] | 11082 | /* If there is active scan command lets wait for the completion else |
| 11083 | * there is no need to wait as scan command might be in the SME pending |
| 11084 | * command list. |
| 11085 | */ |
| 11086 | if (abortScanStatus == eSIR_ABORT_ACTIVE_SCAN_LIST_NOT_EMPTY) |
| 11087 | { |
| 11088 | INIT_COMPLETION(pScanInfo->abortscan_event_var); |
| 11089 | status = wait_for_completion_interruptible_timeout( |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 11090 | &pScanInfo->abortscan_event_var, |
| 11091 | msecs_to_jiffies(5000)); |
c_hpothu | a3d45d5 | 2015-01-05 14:11:17 +0530 | [diff] [blame] | 11092 | if (0 >= status) |
| 11093 | { |
| 11094 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Girish Gowli | 4bf7a63 | 2014-06-12 13:42:11 +0530 | [diff] [blame] | 11095 | "%s: Timeout or Interrupt occurred while waiting for abort" |
| 11096 | "scan, status- %ld", __func__, status); |
c_hpothu | a3d45d5 | 2015-01-05 14:11:17 +0530 | [diff] [blame] | 11097 | return -ETIMEDOUT; |
| 11098 | } |
| 11099 | } |
| 11100 | else if (abortScanStatus == eSIR_ABORT_SCAN_FAILURE) |
| 11101 | { |
| 11102 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 11103 | FL("hdd_abort_mac_scan failed")); |
| 11104 | return -VOS_STATUS_E_FAILURE; |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 11105 | } |
| 11106 | } |
Girish Gowli | 4bf7a63 | 2014-06-12 13:42:11 +0530 | [diff] [blame] | 11107 | return 0; |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 11108 | } |
| 11109 | |
c_hpothu | 225aa7c | 2014-10-22 17:45:13 +0530 | [diff] [blame] | 11110 | VOS_STATUS wlan_hdd_cancel_remain_on_channel(hdd_context_t *pHddCtx) |
| 11111 | { |
| 11112 | hdd_adapter_t *pAdapter; |
| 11113 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 11114 | VOS_STATUS vosStatus; |
| 11115 | |
| 11116 | vosStatus = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 11117 | while (NULL != pAdapterNode && VOS_STATUS_E_EMPTY != vosStatus) |
| 11118 | { |
| 11119 | pAdapter = pAdapterNode->pAdapter; |
| 11120 | if (NULL != pAdapter) |
| 11121 | { |
| 11122 | if (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode || |
| 11123 | WLAN_HDD_P2P_CLIENT == pAdapter->device_mode || |
| 11124 | WLAN_HDD_P2P_GO == pAdapter->device_mode) |
| 11125 | { |
| 11126 | hddLog(LOG1, FL("abort ROC deviceMode: %d"), |
| 11127 | pAdapter->device_mode); |
| 11128 | if (VOS_STATUS_SUCCESS != |
| 11129 | wlan_hdd_cancel_existing_remain_on_channel(pAdapter)) |
| 11130 | { |
| 11131 | hddLog(LOGE, FL("failed to abort ROC")); |
| 11132 | return VOS_STATUS_E_FAILURE; |
| 11133 | } |
| 11134 | } |
| 11135 | } |
| 11136 | vosStatus = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 11137 | pAdapterNode = pNext; |
| 11138 | } |
| 11139 | return VOS_STATUS_SUCCESS; |
| 11140 | } |
Mahesh A Saptasagar | d477b09 | 2015-02-06 15:12:16 +0530 | [diff] [blame] | 11141 | |
Mihir Shete | 0be2877 | 2015-02-17 18:42:14 +0530 | [diff] [blame] | 11142 | hdd_remain_on_chan_ctx_t *hdd_get_remain_on_channel_ctx(hdd_context_t *pHddCtx) |
| 11143 | { |
| 11144 | hdd_adapter_t *pAdapter; |
| 11145 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 11146 | hdd_cfg80211_state_t *cfgState; |
| 11147 | hdd_remain_on_chan_ctx_t *pRemainChanCtx = NULL; |
| 11148 | VOS_STATUS vosStatus; |
| 11149 | |
| 11150 | vosStatus = hdd_get_front_adapter (pHddCtx, &pAdapterNode); |
| 11151 | while (NULL != pAdapterNode && VOS_STATUS_E_EMPTY != vosStatus) |
| 11152 | { |
| 11153 | pAdapter = pAdapterNode->pAdapter; |
| 11154 | if (NULL != pAdapter) |
| 11155 | { |
| 11156 | cfgState = WLAN_HDD_GET_CFG_STATE_PTR(pAdapter); |
| 11157 | pRemainChanCtx = cfgState->remain_on_chan_ctx; |
| 11158 | if (pRemainChanCtx) |
| 11159 | break; |
| 11160 | } |
| 11161 | vosStatus = hdd_get_next_adapter (pHddCtx, pAdapterNode, &pNext); |
| 11162 | pAdapterNode = pNext; |
| 11163 | } |
| 11164 | return pRemainChanCtx; |
| 11165 | } |
| 11166 | |
Padma, Santhosh Kumar | 778d838 | 2015-03-04 17:41:22 +0530 | [diff] [blame] | 11167 | /** |
| 11168 | * wlan_hdd_handle_dfs_chan_scan () - handles disable/enable DFS channels |
| 11169 | * |
| 11170 | * @pHddCtx: HDD context within host driver |
| 11171 | * @dfsScanMode: dfsScanMode passed from ioctl |
| 11172 | * |
| 11173 | */ |
| 11174 | |
| 11175 | VOS_STATUS wlan_hdd_handle_dfs_chan_scan(hdd_context_t *pHddCtx, |
| 11176 | tANI_U8 dfsScanMode) |
| 11177 | { |
| 11178 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 11179 | hdd_adapter_t *pAdapter; |
| 11180 | VOS_STATUS vosStatus; |
| 11181 | hdd_station_ctx_t *pHddStaCtx; |
| 11182 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 11183 | |
| 11184 | if(!pHddCtx) |
| 11185 | { |
| 11186 | hddLog(LOGE, FL("HDD context is Null")); |
| 11187 | return eHAL_STATUS_FAILURE; |
| 11188 | } |
| 11189 | |
| 11190 | if (pHddCtx->scan_info.mScanPending) |
| 11191 | { |
| 11192 | hddLog(LOG1, FL("Aborting scan for sessionId: %d"), |
| 11193 | pHddCtx->scan_info.sessionId); |
| 11194 | hdd_abort_mac_scan(pHddCtx, |
| 11195 | pHddCtx->scan_info.sessionId, |
| 11196 | eCSR_SCAN_ABORT_DEFAULT); |
| 11197 | } |
| 11198 | |
| 11199 | if (!dfsScanMode) |
| 11200 | { |
| 11201 | vosStatus = hdd_get_front_adapter( pHddCtx, &pAdapterNode); |
| 11202 | while ((NULL != pAdapterNode) && |
| 11203 | (VOS_STATUS_SUCCESS == vosStatus)) |
| 11204 | { |
| 11205 | pAdapter = pAdapterNode->pAdapter; |
| 11206 | |
| 11207 | if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) |
| 11208 | { |
| 11209 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 11210 | |
| 11211 | if(!pHddStaCtx) |
| 11212 | { |
| 11213 | hddLog(LOGE, FL("HDD STA context is Null")); |
| 11214 | return eHAL_STATUS_FAILURE; |
| 11215 | } |
| 11216 | |
| 11217 | /* if STA is already connected on DFS channel, |
| 11218 | disconnect immediately*/ |
| 11219 | if (hdd_connIsConnected(pHddStaCtx) && |
| 11220 | (NV_CHANNEL_DFS == |
| 11221 | vos_nv_getChannelEnabledState( |
| 11222 | pHddStaCtx->conn_info.operationChannel))) |
| 11223 | { |
| 11224 | status = sme_RoamDisconnect(pHddCtx->hHal, |
| 11225 | pAdapter->sessionId, |
| 11226 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
| 11227 | hddLog(LOG1, FL("Client connected on DFS channel %d," |
| 11228 | "sme_RoamDisconnect returned with status: %d" |
| 11229 | "for sessionid: %d"), pHddStaCtx->conn_info. |
| 11230 | operationChannel, status, pAdapter->sessionId); |
| 11231 | } |
| 11232 | } |
| 11233 | |
| 11234 | vosStatus = hdd_get_next_adapter(pHddCtx, pAdapterNode, |
| 11235 | &pNext); |
| 11236 | pAdapterNode = pNext; |
| 11237 | } |
| 11238 | } |
| 11239 | |
| 11240 | sme_UpdateDFSScanMode(pHddCtx->hHal, dfsScanMode); |
| 11241 | sme_UpdateDFSRoamMode(pHddCtx->hHal, |
| 11242 | (dfsScanMode != DFS_CHNL_SCAN_DISABLED)); |
| 11243 | |
| 11244 | status = sme_HandleDFSChanScan(pHddCtx->hHal); |
| 11245 | if (!HAL_STATUS_SUCCESS(status)) |
| 11246 | { |
| 11247 | hddLog(LOGE, |
| 11248 | FL("Failed in sme_HandleDFSChanScan (err=%d)"), status); |
| 11249 | return status; |
| 11250 | } |
| 11251 | |
| 11252 | return status; |
| 11253 | } |
| 11254 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11255 | //Register the module init/exit functions |
| 11256 | module_init(hdd_module_init); |
| 11257 | module_exit(hdd_module_exit); |
| 11258 | |
| 11259 | MODULE_LICENSE("Dual BSD/GPL"); |
| 11260 | MODULE_AUTHOR("Qualcomm Atheros, Inc."); |
| 11261 | MODULE_DESCRIPTION("WLAN HOST DEVICE DRIVER"); |
| 11262 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 11263 | module_param_call(con_mode, con_mode_handler, param_get_int, &con_mode, |
| 11264 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 11265 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 11266 | module_param_call(fwpath, fwpath_changed_handler, param_get_string, &fwpath, |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 11267 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 11268 | |
| 11269 | module_param(enable_dfs_chan_scan, int, |
| 11270 | S_IRUSR | S_IRGRP | S_IROTH); |
| 11271 | |
| 11272 | module_param(enable_11d, int, |
| 11273 | S_IRUSR | S_IRGRP | S_IROTH); |
| 11274 | |
| 11275 | module_param(country_code, charp, |
| 11276 | S_IRUSR | S_IRGRP | S_IROTH); |