Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
Masti, Narayanraddi | 44b0db0 | 2015-12-22 11:54:35 +0530 | [diff] [blame] | 2 | * Copyright (c) 2012-2016 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 | |
Abhishek Singh | 00b7197 | 2016-01-07 10:51:04 +0530 | [diff] [blame] | 179 | #ifdef WLAN_FEATURE_RMC |
| 180 | /* |
| 181 | * Ibss prop IE from command will be of size: |
| 182 | * size = sizeof(oui) + sizeof(oui_data) + 1(Element ID) + 1(EID Length) |
| 183 | * OUI_DATA should be at least 3 bytes long |
| 184 | */ |
| 185 | #define WLAN_HDD_IBSS_MIN_OUI_DATA_LENGTH (3) |
| 186 | #endif |
| 187 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 188 | #if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD) |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 189 | #define TID_MIN_VALUE 0 |
| 190 | #define TID_MAX_VALUE 15 |
| 191 | static VOS_STATUS hdd_get_tsm_stats(hdd_adapter_t *pAdapter, const tANI_U8 tid, |
| 192 | tAniTrafStrmMetrics* pTsmMetrics); |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 193 | static VOS_STATUS hdd_parse_ese_beacon_req(tANI_U8 *pValue, |
| 194 | tCsrEseBeaconReq *pEseBcnReq); |
| 195 | #endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */ |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 196 | |
Atul Mittal | 1d72242 | 2014-03-19 11:15:07 +0530 | [diff] [blame] | 197 | /* |
| 198 | * Maximum buffer size used for returning the data back to user space |
| 199 | */ |
| 200 | #define WLAN_MAX_BUF_SIZE 1024 |
| 201 | #define WLAN_PRIV_DATA_MAX_LEN 8192 |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 202 | |
Abhishek Singh | 00b7197 | 2016-01-07 10:51:04 +0530 | [diff] [blame] | 203 | /* |
| 204 | * When ever we need to print IBSSPEERINFOALL for morethan 16 STA |
| 205 | * we will split the printing. |
| 206 | */ |
| 207 | #define NUM_OF_STA_DATA_TO_PRINT 16 |
| 208 | |
| 209 | #ifdef WLAN_FEATURE_RMC |
| 210 | #define WLAN_NLINK_CESIUM 30 |
| 211 | #endif |
| 212 | |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 213 | //wait time for beacon miss rate. |
| 214 | #define BCN_MISS_RATE_TIME 500 |
| 215 | |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 216 | static vos_wake_lock_t wlan_wake_lock; |
| 217 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 218 | /* set when SSR is needed after unload */ |
Madan Mohan Koyyalamudi | b5da533 | 2012-10-15 17:23:21 -0700 | [diff] [blame] | 219 | static e_hdd_ssr_required isSsrRequired = HDD_SSR_NOT_REQUIRED; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 220 | |
| 221 | //internal function declaration |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 222 | static VOS_STATUS wlan_hdd_framework_restart(hdd_context_t *pHddCtx); |
| 223 | static void wlan_hdd_restart_init(hdd_context_t *pHddCtx); |
| 224 | static void wlan_hdd_restart_deinit(hdd_context_t *pHddCtx); |
Abhishek Singh | 00b7197 | 2016-01-07 10:51:04 +0530 | [diff] [blame] | 225 | |
| 226 | #ifdef WLAN_FEATURE_RMC |
| 227 | static void hdd_tx_fail_ind_callback(v_U8_t *MacAddr, v_U8_t seqNo); |
| 228 | |
| 229 | static int hdd_open_cesium_nl_sock(void); |
| 230 | static void hdd_close_cesium_nl_sock(void); |
| 231 | static struct sock *cesium_nl_srv_sock; |
| 232 | static v_U16_t cesium_pid; |
| 233 | |
| 234 | static int hdd_ParseIBSSTXFailEventParams(tANI_U8 *pValue, |
| 235 | tANI_U8 *tx_fail_count, |
| 236 | tANI_U16 *pid); |
| 237 | |
| 238 | static int hdd_ParseUserParams(tANI_U8 *pValue, tANI_U8 **ppArg); |
| 239 | |
| 240 | #endif /* WLAN_FEATURE_RMC */ |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 241 | void wlan_hdd_restart_timer_cb(v_PVOID_t usrDataForCallback); |
Sameer Thalappil | 45931fb | 2013-02-01 11:18:05 -0800 | [diff] [blame] | 242 | void hdd_set_wlan_suspend_mode(bool suspend); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 243 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 244 | v_U16_t hdd_select_queue(struct net_device *dev, |
Anand N Sunkad | e9adb1b | 2015-07-29 09:56:45 +0530 | [diff] [blame] | 245 | struct sk_buff *skb |
| 246 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0)) |
| 247 | , void *accel_priv |
| 248 | #endif |
| 249 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) |
| 250 | , select_queue_fallback_t fallback |
| 251 | #endif |
| 252 | ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 253 | |
| 254 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 255 | static void hdd_set_multicast_list(struct net_device *dev); |
| 256 | #endif |
| 257 | |
| 258 | void hdd_wlan_initial_scan(hdd_adapter_t *pAdapter); |
| 259 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 260 | #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] | 261 | void hdd_getBand_helper(hdd_context_t *pHddCtx, int *pBand); |
| 262 | 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] | 263 | static VOS_STATUS hdd_parse_send_action_frame_data(tANI_U8 *pValue, tANI_U8 *pTargetApBssid, |
| 264 | tANI_U8 *pChannel, tANI_U8 *pDwellTime, |
| 265 | tANI_U8 **pBuf, tANI_U8 *pBufLen); |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 266 | static VOS_STATUS hdd_parse_reassoc_command_data(tANI_U8 *pValue, |
| 267 | tANI_U8 *pTargetApBssid, |
| 268 | tANI_U8 *pChannel); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 269 | #endif |
Ratheesh S P | 2128041 | 2015-05-19 14:21:52 +0530 | [diff] [blame] | 270 | |
| 271 | /* Store WLAN driver info in a global variable such that crash debugger |
| 272 | can extract it from driver debug symbol and crashdump for post processing */ |
| 273 | tANI_U8 g_wlan_driver[ ] = "pronto_driver"; |
| 274 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 275 | #if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD) |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 276 | 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] | 277 | #endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */ |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 278 | |
Mihir Shete | e1093ba | 2014-01-21 20:13:32 +0530 | [diff] [blame] | 279 | static VOS_STATUS wlan_hdd_init_channels(hdd_context_t *pHddCtx); |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 280 | const char * hdd_device_modetoString(v_U8_t device_mode) |
| 281 | { |
| 282 | switch(device_mode) |
| 283 | { |
| 284 | CASE_RETURN_STRING( WLAN_HDD_INFRA_STATION ); |
| 285 | CASE_RETURN_STRING( WLAN_HDD_SOFTAP ); |
| 286 | CASE_RETURN_STRING( WLAN_HDD_P2P_CLIENT ); |
| 287 | CASE_RETURN_STRING( WLAN_HDD_P2P_GO ); |
| 288 | CASE_RETURN_STRING( WLAN_HDD_MONITOR); |
| 289 | CASE_RETURN_STRING( WLAN_HDD_FTM ); |
| 290 | CASE_RETURN_STRING( WLAN_HDD_IBSS ); |
| 291 | CASE_RETURN_STRING( WLAN_HDD_P2P_DEVICE ); |
| 292 | default: |
| 293 | return "device_mode Unknown"; |
| 294 | } |
| 295 | } |
Mihir Shete | e1093ba | 2014-01-21 20:13:32 +0530 | [diff] [blame] | 296 | |
Mukul Sharma | a78cf6b | 2015-02-24 16:59:01 +0530 | [diff] [blame] | 297 | static int __hdd_netdev_notifier_call(struct notifier_block * nb, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 298 | unsigned long state, |
| 299 | void *ndev) |
| 300 | { |
| 301 | struct net_device *dev = ndev; |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 302 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 27cee45 | 2013-03-27 11:10:24 -0700 | [diff] [blame] | 303 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 304 | #ifdef WLAN_BTAMP_FEATURE |
| 305 | VOS_STATUS status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 306 | #endif |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 307 | long result; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 308 | |
| 309 | //Make sure that this callback corresponds to our device. |
Jeff Johnson | 27cee45 | 2013-03-27 11:10:24 -0700 | [diff] [blame] | 310 | if ((strncmp(dev->name, "wlan", 4)) && |
Amar Singhal | 4c723bd | 2013-03-25 18:14:15 -0700 | [diff] [blame] | 311 | (strncmp(dev->name, "p2p", 3))) |
| 312 | return NOTIFY_DONE; |
| 313 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 314 | if (!dev->ieee80211_ptr) |
Jeff Johnson | 27cee45 | 2013-03-27 11:10:24 -0700 | [diff] [blame] | 315 | return NOTIFY_DONE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 316 | |
Jeff Johnson | 27cee45 | 2013-03-27 11:10:24 -0700 | [diff] [blame] | 317 | if (NULL == pAdapter) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 318 | { |
Jeff Johnson | a8a1a48 | 2012-12-12 16:49:33 -0800 | [diff] [blame] | 319 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: HDD Adapter Null Pointer", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 320 | VOS_ASSERT(0); |
| 321 | return NOTIFY_DONE; |
| 322 | } |
| 323 | |
Jeff Johnson | 27cee45 | 2013-03-27 11:10:24 -0700 | [diff] [blame] | 324 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 325 | if (NULL == pHddCtx) |
| 326 | { |
| 327 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: HDD Context Null Pointer", __func__); |
| 328 | VOS_ASSERT(0); |
| 329 | return NOTIFY_DONE; |
| 330 | } |
Sameer Thalappil | 1406797 | 2014-01-23 14:54:54 -0800 | [diff] [blame] | 331 | if (pHddCtx->isLogpInProgress) |
| 332 | return NOTIFY_DONE; |
| 333 | |
Jeff Johnson | 27cee45 | 2013-03-27 11:10:24 -0700 | [diff] [blame] | 334 | |
| 335 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s New Net Device State = %lu", |
| 336 | __func__, dev->name, state); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 337 | |
| 338 | switch (state) { |
| 339 | case NETDEV_REGISTER: |
| 340 | break; |
| 341 | |
| 342 | case NETDEV_UNREGISTER: |
| 343 | break; |
| 344 | |
| 345 | case NETDEV_UP: |
| 346 | break; |
| 347 | |
| 348 | case NETDEV_DOWN: |
| 349 | break; |
| 350 | |
| 351 | case NETDEV_CHANGE: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 352 | if(TRUE == pAdapter->isLinkUpSvcNeeded) |
| 353 | complete(&pAdapter->linkup_event_var); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 354 | break; |
| 355 | |
| 356 | case NETDEV_GOING_DOWN: |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 357 | result = wlan_hdd_scan_abort(pAdapter); |
Girish Gowli | 4bf7a63 | 2014-06-12 13:42:11 +0530 | [diff] [blame] | 358 | if (result < 0) |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 359 | { |
| 360 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 361 | "%s: Timeout occurred while waiting for abortscan %ld", |
| 362 | __func__, result); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 363 | } |
| 364 | else |
| 365 | { |
| 366 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 367 | "%s: Scan Abort Successful" , __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 368 | } |
| 369 | #ifdef WLAN_BTAMP_FEATURE |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 370 | 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] | 371 | status = WLANBAP_StopAmp(); |
| 372 | if(VOS_STATUS_SUCCESS != status ) |
| 373 | { |
| 374 | pHddCtx->isAmpAllowed = VOS_TRUE; |
| 375 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 376 | "%s: Failed to stop AMP", __func__); |
| 377 | } |
| 378 | else |
| 379 | { |
| 380 | //a state m/c implementation in PAL is TBD to avoid this delay |
| 381 | msleep(500); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 382 | if ( pHddCtx->isAmpAllowed ) |
| 383 | { |
| 384 | WLANBAP_DeregisterFromHCI(); |
| 385 | pHddCtx->isAmpAllowed = VOS_FALSE; |
| 386 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 387 | } |
| 388 | #endif //WLAN_BTAMP_FEATURE |
| 389 | break; |
| 390 | |
| 391 | default: |
| 392 | break; |
| 393 | } |
| 394 | |
| 395 | return NOTIFY_DONE; |
| 396 | } |
| 397 | |
Mukul Sharma | a78cf6b | 2015-02-24 16:59:01 +0530 | [diff] [blame] | 398 | static int hdd_netdev_notifier_call(struct notifier_block * nb, |
| 399 | unsigned long state, |
| 400 | void *ndev) |
| 401 | { |
| 402 | int ret; |
| 403 | vos_ssr_protect(__func__); |
| 404 | ret = __hdd_netdev_notifier_call( nb, state, ndev); |
| 405 | vos_ssr_unprotect(__func__); |
| 406 | return ret; |
| 407 | } |
| 408 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 409 | struct notifier_block hdd_netdev_notifier = { |
| 410 | .notifier_call = hdd_netdev_notifier_call, |
| 411 | }; |
| 412 | |
| 413 | /*--------------------------------------------------------------------------- |
| 414 | * Function definitions |
| 415 | *-------------------------------------------------------------------------*/ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 416 | void hdd_unregister_mcast_bcast_filter(hdd_context_t *pHddCtx); |
| 417 | void hdd_register_mcast_bcast_filter(hdd_context_t *pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 418 | //variable to hold the insmod parameters |
Madan Mohan Koyyalamudi | dfd6aa8 | 2012-10-18 20:18:43 -0700 | [diff] [blame] | 419 | static int con_mode; |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 420 | #ifndef MODULE |
| 421 | /* current con_mode - used only for statically linked driver |
| 422 | * con_mode is changed by userspace to indicate a mode change which will |
| 423 | * result in calling the module exit and init functions. The module |
| 424 | * exit function will clean up based on the value of con_mode prior to it |
| 425 | * being changed by userspace. So curr_con_mode records the current con_mode |
| 426 | * for exit when con_mode becomes the next mode for init |
| 427 | */ |
Madan Mohan Koyyalamudi | dfd6aa8 | 2012-10-18 20:18:43 -0700 | [diff] [blame] | 428 | static int curr_con_mode; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 429 | #endif |
| 430 | |
Srinivas Girigowda | 8bf64cb | 2015-09-30 19:50:09 +0530 | [diff] [blame] | 431 | #ifdef WLAN_FEATURE_OFFLOAD_PACKETS |
| 432 | /** |
| 433 | * hdd_init_offloaded_packets_ctx() - Initialize offload packets context |
| 434 | * @hdd_ctx: hdd global context |
| 435 | * |
| 436 | * Return: none |
| 437 | */ |
| 438 | static void hdd_init_offloaded_packets_ctx(hdd_context_t *hdd_ctx) |
| 439 | { |
| 440 | uint8_t i; |
| 441 | |
| 442 | mutex_init(&hdd_ctx->op_ctx.op_lock); |
| 443 | for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++) |
| 444 | { |
| 445 | hdd_ctx->op_ctx.op_table[i].request_id = 0; |
| 446 | hdd_ctx->op_ctx.op_table[i].pattern_id = i; |
| 447 | } |
| 448 | } |
| 449 | #else |
| 450 | static void hdd_init_offloaded_packets_ctx(hdd_context_t *hdd_ctx) |
| 451 | { |
| 452 | } |
| 453 | #endif |
| 454 | |
Varun Reddy Yeturu | 587e680 | 2013-01-24 12:21:41 -0800 | [diff] [blame] | 455 | /**--------------------------------------------------------------------------- |
| 456 | |
| 457 | \brief hdd_vos_trace_enable() - Configure initial VOS Trace enable |
| 458 | |
| 459 | Called immediately after the cfg.ini is read in order to configure |
| 460 | the desired trace levels. |
| 461 | |
| 462 | \param - moduleId - module whose trace level is being configured |
| 463 | \param - bitmask - bitmask of log levels to be enabled |
| 464 | |
| 465 | \return - void |
| 466 | |
| 467 | --------------------------------------------------------------------------*/ |
| 468 | static void hdd_vos_trace_enable(VOS_MODULE_ID moduleId, v_U32_t bitmask) |
| 469 | { |
| 470 | wpt_tracelevel level; |
| 471 | |
| 472 | /* if the bitmask is the default value, then a bitmask was not |
| 473 | specified in cfg.ini, so leave the logging level alone (it |
| 474 | will remain at the "compiled in" default value) */ |
| 475 | if (CFG_VOS_TRACE_ENABLE_DEFAULT == bitmask) |
| 476 | { |
| 477 | return; |
| 478 | } |
| 479 | |
| 480 | /* a mask was specified. start by disabling all logging */ |
| 481 | vos_trace_setValue(moduleId, VOS_TRACE_LEVEL_NONE, 0); |
| 482 | |
| 483 | /* now cycle through the bitmask until all "set" bits are serviced */ |
| 484 | level = VOS_TRACE_LEVEL_FATAL; |
| 485 | while (0 != bitmask) |
| 486 | { |
| 487 | if (bitmask & 1) |
| 488 | { |
| 489 | vos_trace_setValue(moduleId, level, 1); |
| 490 | } |
| 491 | level++; |
| 492 | bitmask >>= 1; |
| 493 | } |
| 494 | } |
| 495 | |
| 496 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 497 | /**--------------------------------------------------------------------------- |
| 498 | |
| 499 | \brief hdd_wdi_trace_enable() - Configure initial WDI Trace enable |
| 500 | |
| 501 | Called immediately after the cfg.ini is read in order to configure |
| 502 | the desired trace levels in the WDI. |
| 503 | |
| 504 | \param - moduleId - module whose trace level is being configured |
| 505 | \param - bitmask - bitmask of log levels to be enabled |
| 506 | |
| 507 | \return - void |
| 508 | |
| 509 | --------------------------------------------------------------------------*/ |
| 510 | static void hdd_wdi_trace_enable(wpt_moduleid moduleId, v_U32_t bitmask) |
| 511 | { |
| 512 | wpt_tracelevel level; |
| 513 | |
| 514 | /* if the bitmask is the default value, then a bitmask was not |
| 515 | specified in cfg.ini, so leave the logging level alone (it |
| 516 | will remain at the "compiled in" default value) */ |
| 517 | if (CFG_WDI_TRACE_ENABLE_DEFAULT == bitmask) |
| 518 | { |
| 519 | return; |
| 520 | } |
| 521 | |
| 522 | /* a mask was specified. start by disabling all logging */ |
| 523 | wpalTraceSetLevel(moduleId, eWLAN_PAL_TRACE_LEVEL_NONE, 0); |
| 524 | |
| 525 | /* now cycle through the bitmask until all "set" bits are serviced */ |
| 526 | level = eWLAN_PAL_TRACE_LEVEL_FATAL; |
| 527 | while (0 != bitmask) |
| 528 | { |
| 529 | if (bitmask & 1) |
| 530 | { |
| 531 | wpalTraceSetLevel(moduleId, level, 1); |
| 532 | } |
| 533 | level++; |
| 534 | bitmask >>= 1; |
| 535 | } |
| 536 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 537 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 538 | /* |
| 539 | * FUNCTION: wlan_hdd_validate_context |
| 540 | * This function is used to check the HDD context |
| 541 | */ |
| 542 | int wlan_hdd_validate_context(hdd_context_t *pHddCtx) |
| 543 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 544 | |
| 545 | if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini) |
| 546 | { |
Mahesh A Saptasagar | 886997a | 2015-03-04 13:15:51 +0530 | [diff] [blame] | 547 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 548 | "%s: HDD context is Null", __func__); |
| 549 | return -ENODEV; |
| 550 | } |
| 551 | |
| 552 | if (pHddCtx->isLogpInProgress) |
| 553 | { |
Mahesh A Saptasagar | 886997a | 2015-03-04 13:15:51 +0530 | [diff] [blame] | 554 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
c_hpothu | 8adb97b | 2014-12-08 19:38:20 +0530 | [diff] [blame] | 555 | "%s: LOGP %s. Ignore!!", __func__, |
| 556 | vos_is_wlan_in_badState(VOS_MODULE_ID_HDD, NULL) |
| 557 | ?"failed":"in Progress"); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 558 | return -EAGAIN; |
| 559 | } |
| 560 | |
Mihir Shete | 1815629 | 2014-03-11 15:38:30 +0530 | [diff] [blame] | 561 | if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx)) |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 562 | { |
Mahesh A Saptasagar | 886997a | 2015-03-04 13:15:51 +0530 | [diff] [blame] | 563 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 564 | "%s: Unloading/Loading in Progress. Ignore!!!", __func__); |
| 565 | return -EAGAIN; |
| 566 | } |
| 567 | return 0; |
| 568 | } |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 569 | #ifdef CONFIG_ENABLE_LINUX_REG |
| 570 | void hdd_checkandupdate_phymode( hdd_context_t *pHddCtx) |
| 571 | { |
| 572 | hdd_adapter_t *pAdapter = NULL; |
| 573 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 574 | eCsrPhyMode phyMode; |
| 575 | hdd_config_t *cfg_param = NULL; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 576 | |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 577 | if (NULL == pHddCtx) |
| 578 | { |
| 579 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 580 | "HDD Context is null !!"); |
| 581 | return ; |
| 582 | } |
| 583 | |
| 584 | pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 585 | if (NULL == pAdapter) |
| 586 | { |
| 587 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 588 | "pAdapter is null !!"); |
| 589 | return ; |
| 590 | } |
| 591 | |
| 592 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 593 | if (NULL == pHddStaCtx) |
| 594 | { |
| 595 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 596 | "pHddStaCtx is null !!"); |
| 597 | return ; |
| 598 | } |
| 599 | |
| 600 | cfg_param = pHddCtx->cfg_ini; |
| 601 | if (NULL == cfg_param) |
| 602 | { |
| 603 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 604 | "cfg_params not available !!"); |
| 605 | return ; |
| 606 | } |
| 607 | |
| 608 | phyMode = sme_GetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter)); |
| 609 | |
| 610 | if (!pHddCtx->isVHT80Allowed) |
| 611 | { |
| 612 | if ((eCSR_DOT11_MODE_AUTO == phyMode) || |
| 613 | (eCSR_DOT11_MODE_11ac == phyMode) || |
| 614 | (eCSR_DOT11_MODE_11ac_ONLY == phyMode)) |
| 615 | { |
| 616 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 617 | "Setting phymode to 11n!!"); |
| 618 | sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_DOT11_MODE_11n); |
| 619 | } |
| 620 | } |
| 621 | else |
| 622 | { |
| 623 | /*New country Supports 11ac as well resetting value back from .ini*/ |
| 624 | sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 625 | hdd_cfg_xlate_to_csr_phy_mode(cfg_param->dot11Mode)); |
| 626 | return ; |
| 627 | } |
| 628 | |
| 629 | if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) && |
| 630 | ((eCSR_CFG_DOT11_MODE_11AC_ONLY == pHddStaCtx->conn_info.dot11Mode) || |
| 631 | (eCSR_CFG_DOT11_MODE_11AC == pHddStaCtx->conn_info.dot11Mode))) |
| 632 | { |
| 633 | VOS_STATUS vosStatus; |
| 634 | |
| 635 | // need to issue a disconnect to CSR. |
| 636 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 637 | vosStatus = sme_RoamDisconnect(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 638 | pAdapter->sessionId, |
| 639 | eCSR_DISCONNECT_REASON_UNSPECIFIED ); |
| 640 | |
| 641 | if (VOS_STATUS_SUCCESS == vosStatus) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 642 | { |
| 643 | long ret; |
| 644 | |
| 645 | ret = wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var, |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 646 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 647 | if (0 >= ret) |
| 648 | hddLog(LOGE, FL("failure waiting for disconnect_comp_var %ld"), |
| 649 | ret); |
| 650 | } |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 651 | |
| 652 | } |
| 653 | } |
| 654 | #else |
Gopichand Nakkala | dacbcb5 | 2013-04-18 16:41:54 +0530 | [diff] [blame] | 655 | void hdd_checkandupdate_phymode( hdd_adapter_t *pAdapter, char *country_code) |
| 656 | { |
| 657 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 658 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 659 | hdd_config_t *cfg_param; |
| 660 | eCsrPhyMode phyMode; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 661 | long ret; |
Gopichand Nakkala | dacbcb5 | 2013-04-18 16:41:54 +0530 | [diff] [blame] | 662 | |
| 663 | if (NULL == pHddCtx) |
| 664 | { |
| 665 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 666 | "HDD Context is null !!"); |
| 667 | return ; |
| 668 | } |
| 669 | |
| 670 | cfg_param = pHddCtx->cfg_ini; |
| 671 | |
| 672 | if (NULL == cfg_param) |
| 673 | { |
| 674 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 675 | "cfg_params not available !!"); |
| 676 | return ; |
| 677 | } |
| 678 | |
| 679 | phyMode = sme_GetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter)); |
| 680 | |
| 681 | if (NULL != strstr(cfg_param->listOfNon11acCountryCode, country_code)) |
| 682 | { |
| 683 | if ((eCSR_DOT11_MODE_AUTO == phyMode) || |
| 684 | (eCSR_DOT11_MODE_11ac == phyMode) || |
| 685 | (eCSR_DOT11_MODE_11ac_ONLY == phyMode)) |
| 686 | { |
| 687 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 688 | "Setting phymode to 11n!!"); |
| 689 | sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_DOT11_MODE_11n); |
| 690 | } |
| 691 | } |
| 692 | else |
| 693 | { |
| 694 | /*New country Supports 11ac as well resetting value back from .ini*/ |
| 695 | sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 696 | hdd_cfg_xlate_to_csr_phy_mode(cfg_param->dot11Mode)); |
| 697 | return ; |
| 698 | } |
| 699 | |
| 700 | if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) && |
| 701 | ((eCSR_CFG_DOT11_MODE_11AC_ONLY == pHddStaCtx->conn_info.dot11Mode) || |
| 702 | (eCSR_CFG_DOT11_MODE_11AC == pHddStaCtx->conn_info.dot11Mode))) |
| 703 | { |
| 704 | VOS_STATUS vosStatus; |
| 705 | |
| 706 | // need to issue a disconnect to CSR. |
| 707 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 708 | vosStatus = sme_RoamDisconnect(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 709 | pAdapter->sessionId, |
| 710 | eCSR_DISCONNECT_REASON_UNSPECIFIED ); |
| 711 | |
| 712 | if (VOS_STATUS_SUCCESS == vosStatus) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 713 | { |
| 714 | ret = wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var, |
Gopichand Nakkala | dacbcb5 | 2013-04-18 16:41:54 +0530 | [diff] [blame] | 715 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 716 | if (ret <= 0) |
| 717 | { |
| 718 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 719 | "wait on disconnect_comp_var is failed %ld", ret); |
| 720 | } |
| 721 | } |
Gopichand Nakkala | dacbcb5 | 2013-04-18 16:41:54 +0530 | [diff] [blame] | 722 | |
| 723 | } |
| 724 | } |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 725 | #endif //CONFIG_ENABLE_LINUX_REG |
Gopichand Nakkala | dacbcb5 | 2013-04-18 16:41:54 +0530 | [diff] [blame] | 726 | |
Tushnim Bhattacharyya | 9cdf608 | 2013-04-21 16:33:30 -0700 | [diff] [blame] | 727 | void hdd_checkandupdate_dfssetting( hdd_adapter_t *pAdapter, char *country_code) |
| 728 | { |
| 729 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 730 | hdd_config_t *cfg_param; |
| 731 | |
| 732 | if (NULL == pHddCtx) |
| 733 | { |
| 734 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 735 | "HDD Context is null !!"); |
| 736 | return ; |
| 737 | } |
| 738 | |
| 739 | cfg_param = pHddCtx->cfg_ini; |
| 740 | |
| 741 | if (NULL == cfg_param) |
| 742 | { |
| 743 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 744 | "cfg_params not available !!"); |
| 745 | return ; |
| 746 | } |
| 747 | |
Agarwal Ashish | 738843c | 2014-09-25 12:27:56 +0530 | [diff] [blame] | 748 | if (NULL != strstr(cfg_param->listOfNonDfsCountryCode, country_code) || |
| 749 | pHddCtx->disable_dfs_flag == TRUE) |
Tushnim Bhattacharyya | 9cdf608 | 2013-04-21 16:33:30 -0700 | [diff] [blame] | 750 | { |
| 751 | /*New country doesn't support DFS */ |
| 752 | sme_UpdateDfsSetting(WLAN_HDD_GET_HAL_CTX(pAdapter), 0); |
| 753 | } |
| 754 | else |
| 755 | { |
| 756 | /*New country Supports DFS as well resetting value back from .ini*/ |
| 757 | sme_UpdateDfsSetting(WLAN_HDD_GET_HAL_CTX(pAdapter), cfg_param->enableDFSChnlScan); |
| 758 | } |
| 759 | |
| 760 | } |
| 761 | |
Abhishek Singh | 00b7197 | 2016-01-07 10:51:04 +0530 | [diff] [blame] | 762 | #ifdef WLAN_FEATURE_RMC |
| 763 | static int hdd_parse_setrmcenable_command(tANI_U8 *pValue, tANI_U8 *pRmcEnable) |
| 764 | { |
| 765 | tANI_U8 *inPtr = pValue; |
| 766 | int tempInt; |
| 767 | int v = 0; |
| 768 | char buf[32]; |
| 769 | *pRmcEnable = 0; |
| 770 | |
| 771 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 772 | /*no argument after the command*/ |
| 773 | if (NULL == inPtr) |
| 774 | { |
| 775 | return 0; |
| 776 | } |
| 777 | |
| 778 | /*no space after the command*/ |
| 779 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 780 | { |
| 781 | return 0; |
| 782 | } |
| 783 | |
| 784 | /*removing empty spaces*/ |
| 785 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
| 786 | |
| 787 | /*no argument followed by spaces*/ |
| 788 | if ('\0' == *inPtr) |
| 789 | { |
| 790 | return 0; |
| 791 | } |
| 792 | |
| 793 | /* getting the first argument which enables or disables RMC |
| 794 | * for input IP v4 address*/ |
| 795 | sscanf(inPtr, "%32s ", buf); |
| 796 | v = kstrtos32(buf, 10, &tempInt); |
| 797 | if ( v < 0) |
| 798 | { |
| 799 | return -EINVAL; |
| 800 | } |
| 801 | |
| 802 | *pRmcEnable = tempInt; |
| 803 | |
| 804 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 805 | "ucRmcEnable: %d", *pRmcEnable); |
| 806 | |
| 807 | return 0; |
| 808 | } |
| 809 | |
| 810 | /* Function header left blank Intentionally */ |
| 811 | static int hdd_parse_setrmcactionperiod_command(tANI_U8 *pValue, |
| 812 | tANI_U32 *pActionPeriod) |
| 813 | { |
| 814 | tANI_U8 *inPtr = pValue; |
| 815 | int tempInt; |
| 816 | int v = 0; |
| 817 | char buf[32]; |
| 818 | *pActionPeriod = 0; |
| 819 | |
| 820 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 821 | /*no argument after the command*/ |
| 822 | if (NULL == inPtr) |
| 823 | { |
| 824 | return -EINVAL; |
| 825 | } |
| 826 | |
| 827 | /*no space after the command*/ |
| 828 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 829 | { |
| 830 | return -EINVAL; |
| 831 | } |
| 832 | |
| 833 | /*removing empty spaces*/ |
| 834 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
| 835 | |
| 836 | /*no argument followed by spaces*/ |
| 837 | if ('\0' == *inPtr) |
| 838 | { |
| 839 | return 0; |
| 840 | } |
| 841 | |
| 842 | /* getting the first argument which enables or disables RMC |
| 843 | * for input IP v4 address*/ |
| 844 | sscanf(inPtr, "%32s ", buf); |
| 845 | v = kstrtos32(buf, 10, &tempInt); |
| 846 | if ( v < 0) |
| 847 | { |
| 848 | return -EINVAL; |
| 849 | } |
| 850 | |
| 851 | /* Range checking for passed paramter */ |
| 852 | if (tempInt < WNI_CFG_RMC_ACTION_PERIOD_FREQUENCY_STAMIN || |
| 853 | tempInt > WNI_CFG_RMC_ACTION_PERIOD_FREQUENCY_STAMAX) |
| 854 | { |
| 855 | return -EINVAL; |
| 856 | } |
| 857 | |
| 858 | *pActionPeriod = tempInt; |
| 859 | |
| 860 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 861 | "uActionPeriod: %d", *pActionPeriod); |
| 862 | |
| 863 | return 0; |
| 864 | } |
| 865 | |
| 866 | /* Function header left blank Intentionally */ |
| 867 | static int hdd_parse_setrmcrate_command(tANI_U8 *pValue, |
| 868 | tANI_U32 *pRate, tTxrateinfoflags *pTxFlags) |
| 869 | { |
| 870 | tANI_U8 *inPtr = pValue; |
| 871 | int tempInt; |
| 872 | int v = 0; |
| 873 | char buf[32]; |
| 874 | *pRate = 0; |
| 875 | *pTxFlags = 0; |
| 876 | |
| 877 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 878 | /*no argument after the command*/ |
| 879 | if (NULL == inPtr) |
| 880 | { |
| 881 | return -EINVAL; |
| 882 | } |
| 883 | |
| 884 | /*no space after the command*/ |
| 885 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 886 | { |
| 887 | return -EINVAL; |
| 888 | } |
| 889 | |
| 890 | /*removing empty spaces*/ |
| 891 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
| 892 | |
| 893 | /*no argument followed by spaces*/ |
| 894 | if ('\0' == *inPtr) |
| 895 | { |
| 896 | return 0; |
| 897 | } |
| 898 | |
| 899 | /* |
| 900 | * getting the first argument which sets multicast rate. |
| 901 | */ |
| 902 | sscanf(inPtr, "%32s ", buf); |
| 903 | v = kstrtos32(buf, 10, &tempInt); |
| 904 | if ( v < 0) |
| 905 | { |
| 906 | return -EINVAL; |
| 907 | } |
| 908 | |
| 909 | /* |
| 910 | * Validate the multicast rate. |
| 911 | */ |
| 912 | switch (tempInt) |
| 913 | { |
| 914 | default: |
| 915 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
| 916 | "Unsupported rate: %d", tempInt); |
| 917 | return -EINVAL; |
| 918 | case 0: |
| 919 | case 6: |
| 920 | case 9: |
| 921 | case 12: |
| 922 | case 18: |
| 923 | case 24: |
| 924 | case 36: |
| 925 | case 48: |
| 926 | case 54: |
| 927 | *pTxFlags = eHAL_TX_RATE_LEGACY; |
| 928 | *pRate = tempInt * 10; |
| 929 | break; |
| 930 | case 65: |
| 931 | *pTxFlags = eHAL_TX_RATE_HT20; |
| 932 | *pRate = tempInt * 10; |
| 933 | break; |
| 934 | case 72: |
| 935 | *pTxFlags = eHAL_TX_RATE_HT20 | eHAL_TX_RATE_SGI; |
| 936 | *pRate = 722; /* fractional rate 72.2 Mbps */ |
| 937 | break; |
| 938 | } |
| 939 | |
| 940 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 941 | "Rate: %d", *pRate); |
| 942 | |
| 943 | return 0; |
| 944 | } |
| 945 | |
| 946 | /**--------------------------------------------------------------------------- |
| 947 | |
| 948 | \brief hdd_cfg80211_get_ibss_peer_info_cb() - Callback function for IBSS |
| 949 | Peer Info request |
| 950 | |
| 951 | This is an asynchronous callback function from SME when the peer info |
| 952 | is received |
| 953 | |
| 954 | \pUserData -> Adapter private data |
| 955 | \pPeerInfoRsp -> Peer info response |
| 956 | |
| 957 | \return - 0 for success non-zero for failure |
| 958 | --------------------------------------------------------------------------*/ |
| 959 | static void |
| 960 | hdd_cfg80211_get_ibss_peer_info_cb(v_VOID_t *pUserData, v_VOID_t *pPeerInfoRsp) |
| 961 | { |
| 962 | hdd_adapter_t *pAdapter = (hdd_adapter_t *)pUserData; |
| 963 | tSirPeerInfoRspParams *pPeerInfo = (tSirPeerInfoRspParams *)pPeerInfoRsp; |
| 964 | hdd_station_ctx_t *pStaCtx; |
| 965 | v_U8_t i; |
| 966 | |
| 967 | /*Sanity check*/ |
| 968 | if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)) |
| 969 | { |
| 970 | hddLog(LOGE, |
| 971 | FL("invalid adapter or adapter has invalid magic")); |
| 972 | return; |
| 973 | } |
| 974 | |
| 975 | pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 976 | if (NULL != pStaCtx && NULL != pPeerInfo && |
| 977 | eHAL_STATUS_SUCCESS == pPeerInfo->status) |
| 978 | { |
| 979 | pStaCtx->ibss_peer_info.status = pPeerInfo->status; |
| 980 | pStaCtx->ibss_peer_info.numIBSSPeers = pPeerInfo->numPeers; |
| 981 | |
| 982 | /* Paranoia check */ |
| 983 | if (pPeerInfo->numPeers < HDD_MAX_NUM_IBSS_STA) |
| 984 | { |
| 985 | for (i = 0; i < pPeerInfo->numPeers; i++) |
| 986 | { |
| 987 | memcpy(&pStaCtx->ibss_peer_info.ibssPeerList[i], |
| 988 | &pPeerInfo->peerInfoParams[i], |
| 989 | sizeof(hdd_ibss_peer_info_params_t)); |
| 990 | } |
| 991 | hddLog(LOG1, |
| 992 | FL("Peer Info copied in HDD")); |
| 993 | } |
| 994 | else |
| 995 | { |
| 996 | hddLog(LOGE, |
| 997 | FL(" Number of peers %d returned is more than limit %d"), |
| 998 | pPeerInfo->numPeers, HDD_MAX_NUM_IBSS_STA); |
| 999 | } |
| 1000 | } |
| 1001 | else |
| 1002 | { |
| 1003 | hddLog(LOG1, |
| 1004 | FL("peerInfo returned is NULL")); |
| 1005 | } |
| 1006 | |
| 1007 | complete(&pAdapter->ibss_peer_info_comp); |
| 1008 | } |
| 1009 | |
| 1010 | /**--------------------------------------------------------------------------- |
| 1011 | |
| 1012 | \brief hdd_cfg80211_get_ibss_peer_info_all() - |
| 1013 | |
| 1014 | Request function to get IBSS peer info from lower layers |
| 1015 | |
| 1016 | \pAdapter -> Adapter context |
| 1017 | |
| 1018 | \return - 0 for success non-zero for failure |
| 1019 | --------------------------------------------------------------------------*/ |
| 1020 | static |
| 1021 | VOS_STATUS hdd_cfg80211_get_ibss_peer_info_all(hdd_adapter_t *pAdapter) |
| 1022 | { |
| 1023 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 1024 | long status; |
| 1025 | VOS_STATUS retStatus = VOS_STATUS_E_FAILURE; |
| 1026 | |
| 1027 | INIT_COMPLETION(pAdapter->ibss_peer_info_comp); |
| 1028 | |
| 1029 | retStatus = sme_RequestIBSSPeerInfo(hHal, pAdapter, |
| 1030 | hdd_cfg80211_get_ibss_peer_info_cb, |
| 1031 | VOS_TRUE, 0xFF); |
| 1032 | |
| 1033 | if (VOS_STATUS_SUCCESS == retStatus) |
| 1034 | { |
| 1035 | status = wait_for_completion_interruptible_timeout |
| 1036 | (&pAdapter->ibss_peer_info_comp, |
| 1037 | msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT)); |
| 1038 | |
| 1039 | /* status will be 0 if timed out */ |
| 1040 | if (status <= 0) |
| 1041 | { |
| 1042 | hddLog(VOS_TRACE_LEVEL_WARN, "%s: Warning: IBSS_PEER_INFO_TIMEOUT %ld", |
| 1043 | __func__, status); |
| 1044 | retStatus = VOS_STATUS_E_FAILURE; |
| 1045 | return retStatus; |
| 1046 | } |
| 1047 | } |
| 1048 | else |
| 1049 | { |
| 1050 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 1051 | "%s: Warning: sme_RequestIBSSPeerInfo Request failed", __func__); |
| 1052 | } |
| 1053 | |
| 1054 | return retStatus; |
| 1055 | } |
| 1056 | |
| 1057 | /**--------------------------------------------------------------------------- |
| 1058 | |
| 1059 | \brief hdd_cfg80211_get_ibss_peer_info() - |
| 1060 | |
| 1061 | Request function to get IBSS peer info from lower layers |
| 1062 | |
| 1063 | \pAdapter -> Adapter context |
| 1064 | \staIdx -> Sta index for which the peer info is requested |
| 1065 | |
| 1066 | \return - 0 for success non-zero for failure |
| 1067 | --------------------------------------------------------------------------*/ |
| 1068 | static VOS_STATUS |
| 1069 | hdd_cfg80211_get_ibss_peer_info(hdd_adapter_t *pAdapter, v_U8_t staIdx) |
| 1070 | { |
| 1071 | long status; |
| 1072 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 1073 | VOS_STATUS retStatus = VOS_STATUS_E_FAILURE; |
| 1074 | |
| 1075 | INIT_COMPLETION(pAdapter->ibss_peer_info_comp); |
| 1076 | |
| 1077 | retStatus = sme_RequestIBSSPeerInfo(hHal, pAdapter, |
| 1078 | hdd_cfg80211_get_ibss_peer_info_cb, |
| 1079 | VOS_FALSE, staIdx); |
| 1080 | |
| 1081 | if (VOS_STATUS_SUCCESS == retStatus) |
| 1082 | { |
| 1083 | status = wait_for_completion_interruptible_timeout |
| 1084 | (&pAdapter->ibss_peer_info_comp, |
| 1085 | msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT)); |
| 1086 | |
| 1087 | /* status = 0 on timeout */ |
| 1088 | if (status <= 0) |
| 1089 | { |
| 1090 | hddLog(VOS_TRACE_LEVEL_WARN, "%s: Warning: IBSS_PEER_INFO_TIMEOUT %ld", |
| 1091 | __func__, status); |
| 1092 | retStatus = VOS_STATUS_E_FAILURE; |
| 1093 | return retStatus; |
| 1094 | } |
| 1095 | } |
| 1096 | else |
| 1097 | { |
| 1098 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 1099 | "%s: Warning: sme_RequestIBSSPeerInfo Request failed", __func__); |
| 1100 | } |
| 1101 | |
| 1102 | return retStatus; |
| 1103 | } |
| 1104 | |
| 1105 | /* Function header left blank Intentionally */ |
| 1106 | VOS_STATUS |
| 1107 | hdd_parse_get_ibss_peer_info(tANI_U8 *pValue, v_MACADDR_t *pPeerMacAddr) |
| 1108 | { |
| 1109 | tANI_U8 *inPtr = pValue; |
| 1110 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 1111 | |
| 1112 | /*no argument after the command*/ |
| 1113 | if (NULL == inPtr) |
| 1114 | { |
| 1115 | return VOS_STATUS_E_FAILURE;; |
| 1116 | } |
| 1117 | |
| 1118 | /*no space after the command*/ |
| 1119 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 1120 | { |
| 1121 | return VOS_STATUS_E_FAILURE;; |
| 1122 | } |
| 1123 | |
| 1124 | /*removing empty spaces*/ |
| 1125 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 1126 | |
| 1127 | /*no argument followed by spaces*/ |
| 1128 | if ('\0' == *inPtr) |
| 1129 | { |
| 1130 | return VOS_STATUS_E_FAILURE;; |
| 1131 | } |
| 1132 | |
| 1133 | /*getting the first argument ie the peer mac address */ |
| 1134 | if (inPtr[2] != ':' || inPtr[5] != ':' || inPtr[8] != ':' || |
| 1135 | inPtr[11] != ':' || inPtr[14] != ':') |
| 1136 | { |
| 1137 | return VOS_STATUS_E_FAILURE;; |
| 1138 | } |
| 1139 | sscanf(inPtr, "%2x:%2x:%2x:%2x:%2x:%2x", |
| 1140 | (unsigned int *)&pPeerMacAddr->bytes[0], |
| 1141 | (unsigned int *)&pPeerMacAddr->bytes[1], |
| 1142 | (unsigned int *)&pPeerMacAddr->bytes[2], |
| 1143 | (unsigned int *)&pPeerMacAddr->bytes[3], |
| 1144 | (unsigned int *)&pPeerMacAddr->bytes[4], |
| 1145 | (unsigned int *)&pPeerMacAddr->bytes[5]); |
| 1146 | |
| 1147 | /* The command buffer seems to be fine */ |
| 1148 | return VOS_STATUS_SUCCESS; |
| 1149 | } |
| 1150 | |
| 1151 | /* Function header left blank Intentionally */ |
| 1152 | static int hdd_parse_set_ibss_oui_data_command(tANI_U8 *command, tANI_U8 *ie, |
| 1153 | tANI_U32 limit) |
| 1154 | { |
| 1155 | tANI_U8 len; |
| 1156 | tANI_U8 data; |
| 1157 | |
| 1158 | /* skip white space */ |
| 1159 | while ((SPACE_ASCII_VALUE == *command) && ('\0' != *command)) |
| 1160 | { |
| 1161 | command++; |
| 1162 | limit--; |
| 1163 | } |
| 1164 | |
| 1165 | /* skip element id and element length */ |
| 1166 | len = 2; |
| 1167 | |
| 1168 | /* extract oui */ |
| 1169 | while ((SPACE_ASCII_VALUE != *command) && ('\0' != *command) && |
| 1170 | (limit > 1)) |
| 1171 | { |
| 1172 | /* Convert ASCII to decimal */ |
| 1173 | data = ((*command -'0') << 4) | (*(command + 1) - '0'); |
| 1174 | ie[len++] = data; |
| 1175 | command += 2; |
| 1176 | limit -= 2; |
| 1177 | } |
| 1178 | |
| 1179 | /* skip white space */ |
| 1180 | while ((SPACE_ASCII_VALUE == *command) && ('\0' != *command)) |
| 1181 | { |
| 1182 | command++; |
| 1183 | limit--; |
| 1184 | } |
| 1185 | |
| 1186 | /* extract data */ |
| 1187 | while ((SPACE_ASCII_VALUE != *command) && ('\0' != *command) && |
| 1188 | (limit > 1)) |
| 1189 | { |
| 1190 | /* Convert ASCII to decimal */ |
| 1191 | data = ((*command -'0') << 4) | (*(command + 1) - '0'); |
| 1192 | ie[len++] = data; |
| 1193 | command += 2; |
| 1194 | limit -= 2; |
| 1195 | } |
| 1196 | |
| 1197 | /* fill element id and element length */ |
| 1198 | ie[0] = IE_EID_VENDOR; |
| 1199 | ie[1] = len - 2; |
| 1200 | |
| 1201 | return len; |
| 1202 | } |
| 1203 | |
| 1204 | static tANI_U32 hdd_find_ibss_wpa_ie_pos(tANI_U8 *addIePtr, tANI_U32 addIeLen) |
| 1205 | { |
| 1206 | tANI_U32 ieLenPresent = 0; |
| 1207 | int left = addIeLen; |
| 1208 | v_U8_t *ptr = addIePtr; |
| 1209 | v_U8_t elem_id,elem_len; |
| 1210 | |
| 1211 | while(left >= 2) |
| 1212 | { |
| 1213 | elem_id = ptr[0]; |
| 1214 | elem_len = ptr[1]; |
| 1215 | left -= 2; |
| 1216 | if(elem_len > left) |
| 1217 | { |
| 1218 | hddLog(LOGE, |
| 1219 | FL("****Invalid elem_len=%d left=%d*****"), |
| 1220 | elem_len,left); |
| 1221 | return 0; |
| 1222 | } |
| 1223 | if ((elem_id == IE_EID_VENDOR) && |
| 1224 | (left >= WPA_OUI_TYPE_SIZE)) |
| 1225 | { |
| 1226 | if (!memcmp(&ptr[2], WPA_OUI_TYPE, |
| 1227 | WPA_OUI_TYPE_SIZE)) |
| 1228 | { |
| 1229 | ieLenPresent += elem_len + 2; |
| 1230 | return ieLenPresent; |
| 1231 | } |
| 1232 | } |
| 1233 | ieLenPresent += (elem_len + 2); |
| 1234 | left -= elem_len; |
| 1235 | ptr += (elem_len + 2); |
| 1236 | } |
| 1237 | return 0; |
| 1238 | } |
| 1239 | |
| 1240 | #endif /* WLAN_FEATURE_RMC */ |
| 1241 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1242 | #ifdef FEATURE_WLAN_BATCH_SCAN |
| 1243 | |
| 1244 | /**--------------------------------------------------------------------------- |
| 1245 | |
| 1246 | \brief hdd_extract_assigned_int_from_str() - Extracts assigned integer from |
| 1247 | input string |
| 1248 | |
| 1249 | This function extracts assigned integer from string in below format: |
| 1250 | "STRING=10" : extracts integer 10 from this string |
| 1251 | |
| 1252 | \param - pInPtr Pointer to input string |
| 1253 | \param - base Base for string to int conversion(10 for decimal 16 for hex) |
| 1254 | \param - pOutPtr Pointer to variable in which extracted integer needs to be |
| 1255 | assigned |
| 1256 | \param - pLastArg to tell whether it is last arguement in input string or |
| 1257 | not |
| 1258 | |
| 1259 | \return - NULL for failure cases |
| 1260 | pointer to next arguement in input string for success cases |
| 1261 | --------------------------------------------------------------------------*/ |
| 1262 | static tANI_U8 * |
| 1263 | hdd_extract_assigned_int_from_str |
| 1264 | ( |
| 1265 | tANI_U8 *pInPtr, |
| 1266 | tANI_U8 base, |
| 1267 | tANI_U32 *pOutPtr, |
| 1268 | tANI_U8 *pLastArg |
| 1269 | ) |
| 1270 | { |
| 1271 | int tempInt; |
| 1272 | int v = 0; |
| 1273 | char buf[32]; |
| 1274 | int val = 0; |
| 1275 | *pLastArg = FALSE; |
| 1276 | |
| 1277 | pInPtr = strnchr(pInPtr, strlen(pInPtr), EQUALS_TO_ASCII_VALUE); |
| 1278 | if (NULL == pInPtr) |
| 1279 | { |
| 1280 | return NULL; |
| 1281 | } |
| 1282 | |
| 1283 | pInPtr++; |
| 1284 | |
| 1285 | while ((SPACE_ASCII_VALUE == *pInPtr) && ('\0' != *pInPtr)) pInPtr++; |
| 1286 | |
| 1287 | val = sscanf(pInPtr, "%32s ", buf); |
| 1288 | if (val < 0 && val > strlen(pInPtr)) |
| 1289 | { |
| 1290 | return NULL; |
| 1291 | } |
| 1292 | pInPtr += val; |
| 1293 | v = kstrtos32(buf, base, &tempInt); |
| 1294 | if (v < 0) |
| 1295 | { |
| 1296 | return NULL; |
| 1297 | } |
Rajeev Kumar | 4d93d84 | 2014-01-02 18:31:21 -0800 | [diff] [blame] | 1298 | if (tempInt < 0) |
| 1299 | { |
| 1300 | tempInt = 0; |
| 1301 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1302 | *pOutPtr = tempInt; |
| 1303 | |
| 1304 | pInPtr = strnchr(pInPtr, strlen(pInPtr), SPACE_ASCII_VALUE); |
| 1305 | if (NULL == pInPtr) |
| 1306 | { |
| 1307 | *pLastArg = TRUE; |
| 1308 | return NULL; |
| 1309 | } |
| 1310 | while ((SPACE_ASCII_VALUE == *pInPtr) && ('\0' != *pInPtr)) pInPtr++; |
| 1311 | |
| 1312 | return pInPtr; |
| 1313 | } |
| 1314 | |
| 1315 | /**--------------------------------------------------------------------------- |
| 1316 | |
| 1317 | \brief hdd_extract_assigned_char_from_str() - Extracts assigned char from |
| 1318 | input string |
| 1319 | |
| 1320 | This function extracts assigned character from string in below format: |
| 1321 | "STRING=A" : extracts char 'A' from this string |
| 1322 | |
| 1323 | \param - pInPtr Pointer to input string |
| 1324 | \param - pOutPtr Pointer to variable in which extracted char needs to be |
| 1325 | assigned |
| 1326 | \param - pLastArg to tell whether it is last arguement in input string or |
| 1327 | not |
| 1328 | |
| 1329 | \return - NULL for failure cases |
| 1330 | pointer to next arguement in input string for success cases |
| 1331 | --------------------------------------------------------------------------*/ |
| 1332 | static tANI_U8 * |
| 1333 | hdd_extract_assigned_char_from_str |
| 1334 | ( |
| 1335 | tANI_U8 *pInPtr, |
| 1336 | tANI_U8 *pOutPtr, |
| 1337 | tANI_U8 *pLastArg |
| 1338 | ) |
| 1339 | { |
| 1340 | *pLastArg = FALSE; |
| 1341 | |
| 1342 | pInPtr = strnchr(pInPtr, strlen(pInPtr), EQUALS_TO_ASCII_VALUE); |
| 1343 | if (NULL == pInPtr) |
| 1344 | { |
| 1345 | return NULL; |
| 1346 | } |
| 1347 | |
| 1348 | pInPtr++; |
| 1349 | |
| 1350 | while ((SPACE_ASCII_VALUE == *pInPtr) && ('\0' != *pInPtr)) pInPtr++; |
| 1351 | |
| 1352 | *pOutPtr = *pInPtr; |
| 1353 | |
| 1354 | pInPtr = strnchr(pInPtr, strlen(pInPtr), SPACE_ASCII_VALUE); |
| 1355 | if (NULL == pInPtr) |
| 1356 | { |
| 1357 | *pLastArg = TRUE; |
| 1358 | return NULL; |
| 1359 | } |
| 1360 | while ((SPACE_ASCII_VALUE == *pInPtr) && ('\0' != *pInPtr)) pInPtr++; |
| 1361 | |
| 1362 | return pInPtr; |
| 1363 | } |
| 1364 | |
| 1365 | |
| 1366 | /**--------------------------------------------------------------------------- |
| 1367 | |
| 1368 | \brief hdd_parse_set_batchscan_command () - HDD parse set batch scan command |
| 1369 | |
| 1370 | This function parses set batch scan command in below format: |
| 1371 | WLS_BATCHING_SET <space> followed by below arguements |
| 1372 | "SCANFREQ=XX" : Optional defaults to 30 sec |
| 1373 | "MSCAN=XX" : Required number of scans to attempt to batch |
| 1374 | "BESTN=XX" : Best Network (RSSI) defaults to 16 |
| 1375 | "CHANNEL=<X,Y>" : optional defaults to all channels, can list 'A'or` B. |
| 1376 | A. implies only 5 GHz , B. implies only 2.4GHz |
| 1377 | "RTT=X" : optional defaults to 0 |
| 1378 | returns the MIN of MSCAN or the max # of scans firmware can cache or -1 on |
| 1379 | error |
| 1380 | |
| 1381 | For example input commands: |
| 1382 | 1) WLS_BATCHING_SET SCANFREQ=60 MSCAN=10 BESTN=20 CHANNEL=A RTT=0 -> This is |
| 1383 | translated into set batch scan with following parameters: |
| 1384 | a) Frequence 60 seconds |
| 1385 | b) Batch 10 scans together |
| 1386 | c) Best RSSI to be 20 |
| 1387 | d) 5GHz band only |
| 1388 | e) RTT is equal to 0 |
| 1389 | |
| 1390 | \param - pValue Pointer to input channel list |
| 1391 | \param - pHddSetBatchScanReq Pointer to HDD batch scan request structure |
| 1392 | |
| 1393 | \return - 0 for success non-zero for failure |
| 1394 | |
| 1395 | --------------------------------------------------------------------------*/ |
| 1396 | static int |
| 1397 | hdd_parse_set_batchscan_command |
| 1398 | ( |
| 1399 | tANI_U8 *pValue, |
| 1400 | tSirSetBatchScanReq *pHddSetBatchScanReq |
| 1401 | ) |
| 1402 | { |
| 1403 | tANI_U8 *inPtr = pValue; |
| 1404 | tANI_U8 val = 0; |
| 1405 | tANI_U8 lastArg = 0; |
Abhishek Singh | 00b7197 | 2016-01-07 10:51:04 +0530 | [diff] [blame] | 1406 | tANI_U32 nScanFreq = HDD_SET_BATCH_SCAN_DEFAULT_FREQ; |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 1407 | tANI_U32 nMscan; |
Abhishek Singh | 00b7197 | 2016-01-07 10:51:04 +0530 | [diff] [blame] | 1408 | tANI_U32 nBestN = HDD_SET_BATCH_SCAN_BEST_NETWORK; |
| 1409 | tANI_U8 ucRfBand = HDD_SET_BATCH_SCAN_DEFAULT_BAND; |
| 1410 | tANI_U32 nRtt = 0; |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 1411 | tANI_U32 temp; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1412 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1413 | /*go to space after WLS_BATCHING_SET command*/ |
| 1414 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 1415 | /*no argument after the command*/ |
| 1416 | if (NULL == inPtr) |
| 1417 | { |
| 1418 | return -EINVAL; |
| 1419 | } |
| 1420 | |
| 1421 | /*no space after the command*/ |
| 1422 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 1423 | { |
| 1424 | return -EINVAL; |
| 1425 | } |
| 1426 | |
| 1427 | /*removing empty spaces*/ |
| 1428 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
| 1429 | |
| 1430 | /*no argument followed by spaces*/ |
| 1431 | if ('\0' == *inPtr) |
| 1432 | { |
| 1433 | return -EINVAL; |
| 1434 | } |
| 1435 | |
| 1436 | /*check and parse SCANFREQ*/ |
| 1437 | if ((strncmp(inPtr, "SCANFREQ", 8) == 0)) |
| 1438 | { |
| 1439 | inPtr = hdd_extract_assigned_int_from_str(inPtr, 10, |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 1440 | &temp, &lastArg); |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 1441 | |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 1442 | if (0 != temp) |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 1443 | { |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 1444 | nScanFreq = temp; |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 1445 | } |
| 1446 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1447 | if ( (NULL == inPtr) || (TRUE == lastArg)) |
| 1448 | { |
| 1449 | return -EINVAL; |
| 1450 | } |
| 1451 | } |
| 1452 | |
| 1453 | /*check and parse MSCAN*/ |
| 1454 | if ((strncmp(inPtr, "MSCAN", 5) == 0)) |
| 1455 | { |
| 1456 | inPtr = hdd_extract_assigned_int_from_str(inPtr, 10, |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 1457 | &nMscan, &lastArg); |
| 1458 | |
| 1459 | if (0 == nMscan) |
| 1460 | { |
| 1461 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1462 | "invalid MSCAN=%d", nMscan); |
| 1463 | return -EINVAL; |
| 1464 | } |
| 1465 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1466 | if (TRUE == lastArg) |
| 1467 | { |
| 1468 | goto done; |
| 1469 | } |
| 1470 | else if (NULL == inPtr) |
| 1471 | { |
| 1472 | return -EINVAL; |
| 1473 | } |
| 1474 | } |
| 1475 | else |
| 1476 | { |
| 1477 | return -EINVAL; |
| 1478 | } |
| 1479 | |
| 1480 | /*check and parse BESTN*/ |
| 1481 | if ((strncmp(inPtr, "BESTN", 5) == 0)) |
| 1482 | { |
| 1483 | inPtr = hdd_extract_assigned_int_from_str(inPtr, 10, |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 1484 | &temp, &lastArg); |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 1485 | |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 1486 | if (0 != temp) |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 1487 | { |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 1488 | nBestN = temp; |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 1489 | } |
| 1490 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1491 | if (TRUE == lastArg) |
| 1492 | { |
| 1493 | goto done; |
| 1494 | } |
| 1495 | else if (NULL == inPtr) |
| 1496 | { |
| 1497 | return -EINVAL; |
| 1498 | } |
| 1499 | } |
| 1500 | |
| 1501 | /*check and parse CHANNEL*/ |
| 1502 | if ((strncmp(inPtr, "CHANNEL", 7) == 0)) |
| 1503 | { |
| 1504 | inPtr = hdd_extract_assigned_char_from_str(inPtr, &val, &lastArg); |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 1505 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1506 | if (('A' == val) || ('a' == val)) |
| 1507 | { |
c_hpothu | ebf8973 | 2014-02-25 13:00:24 +0530 | [diff] [blame] | 1508 | ucRfBand = HDD_SET_BATCH_SCAN_5GHz_BAND_ONLY; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1509 | } |
| 1510 | else if (('B' == val) || ('b' == val)) |
| 1511 | { |
c_hpothu | ebf8973 | 2014-02-25 13:00:24 +0530 | [diff] [blame] | 1512 | ucRfBand = HDD_SET_BATCH_SCAN_24GHz_BAND_ONLY; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1513 | } |
| 1514 | else |
| 1515 | { |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 1516 | ucRfBand = HDD_SET_BATCH_SCAN_DEFAULT_BAND; |
| 1517 | } |
| 1518 | |
| 1519 | if (TRUE == lastArg) |
| 1520 | { |
| 1521 | goto done; |
| 1522 | } |
| 1523 | else if (NULL == inPtr) |
| 1524 | { |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1525 | return -EINVAL; |
| 1526 | } |
| 1527 | } |
| 1528 | |
| 1529 | /*check and parse RTT*/ |
| 1530 | if ((strncmp(inPtr, "RTT", 3) == 0)) |
| 1531 | { |
| 1532 | inPtr = hdd_extract_assigned_int_from_str(inPtr, 10, |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 1533 | &nRtt, &lastArg); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1534 | if (TRUE == lastArg) |
| 1535 | { |
| 1536 | goto done; |
| 1537 | } |
| 1538 | if (NULL == inPtr) |
| 1539 | { |
| 1540 | return -EINVAL; |
| 1541 | } |
| 1542 | } |
| 1543 | |
| 1544 | |
| 1545 | done: |
| 1546 | |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 1547 | pHddSetBatchScanReq->scanFrequency = nScanFreq; |
| 1548 | pHddSetBatchScanReq->numberOfScansToBatch = nMscan; |
| 1549 | pHddSetBatchScanReq->bestNetwork = nBestN; |
| 1550 | pHddSetBatchScanReq->rfBand = ucRfBand; |
| 1551 | pHddSetBatchScanReq->rtt = nRtt; |
| 1552 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1553 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1554 | "Received WLS_BATCHING_SET with SCANFREQ=%d " |
| 1555 | "MSCAN=%d BESTN=%d CHANNEL=%d RTT=%d", |
| 1556 | pHddSetBatchScanReq->scanFrequency, |
| 1557 | pHddSetBatchScanReq->numberOfScansToBatch, |
| 1558 | pHddSetBatchScanReq->bestNetwork, |
| 1559 | pHddSetBatchScanReq->rfBand, |
| 1560 | pHddSetBatchScanReq->rtt); |
| 1561 | |
| 1562 | return 0; |
| 1563 | }/*End of hdd_parse_set_batchscan_command*/ |
| 1564 | |
| 1565 | /**--------------------------------------------------------------------------- |
| 1566 | |
| 1567 | \brief hdd_set_batch_scan_req_callback () - This function is called after |
| 1568 | receiving set batch scan response from FW and it saves set batch scan |
| 1569 | response data FW to HDD context and sets the completion event on |
| 1570 | which hdd_ioctl is waiting |
| 1571 | |
| 1572 | \param - callbackContext Pointer to HDD adapter |
| 1573 | \param - pRsp Pointer to set batch scan response data received from FW |
| 1574 | |
| 1575 | \return - nothing |
| 1576 | |
| 1577 | --------------------------------------------------------------------------*/ |
| 1578 | static void hdd_set_batch_scan_req_callback |
| 1579 | ( |
| 1580 | void *callbackContext, |
| 1581 | tSirSetBatchScanRsp *pRsp |
| 1582 | ) |
| 1583 | { |
| 1584 | hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext; |
| 1585 | tSirSetBatchScanRsp *pHddSetBatchScanRsp; |
| 1586 | |
| 1587 | /*sanity check*/ |
| 1588 | if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) |
| 1589 | { |
| 1590 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1591 | "%s: Invalid pAdapter magic", __func__); |
| 1592 | VOS_ASSERT(0); |
| 1593 | return; |
| 1594 | } |
| 1595 | pHddSetBatchScanRsp = &pAdapter->hddSetBatchScanRsp; |
| 1596 | |
| 1597 | /*save set batch scan response*/ |
| 1598 | pHddSetBatchScanRsp->nScansToBatch = pRsp->nScansToBatch; |
| 1599 | |
| 1600 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
| 1601 | "Received set batch scan rsp from FW with nScansToBatch=%d", |
| 1602 | pHddSetBatchScanRsp->nScansToBatch); |
| 1603 | |
| 1604 | pAdapter->hdd_wait_for_set_batch_scan_rsp = FALSE; |
| 1605 | complete(&pAdapter->hdd_set_batch_scan_req_var); |
| 1606 | |
| 1607 | return; |
| 1608 | }/*End of hdd_set_batch_scan_req_callback*/ |
| 1609 | |
| 1610 | |
| 1611 | /**--------------------------------------------------------------------------- |
| 1612 | |
| 1613 | \brief hdd_populate_batch_scan_rsp_queue () - This function stores AP meta |
| 1614 | info in hdd batch scan response queue |
| 1615 | |
| 1616 | \param - pAdapter Pointer to hdd adapter |
| 1617 | \param - pAPMetaInfo Pointer to access point meta info |
| 1618 | \param - scanId scan ID of batch scan response |
| 1619 | \param - isLastAp tells whether AP is last AP in batch scan response or not |
| 1620 | |
| 1621 | \return - nothing |
| 1622 | |
| 1623 | --------------------------------------------------------------------------*/ |
| 1624 | static void hdd_populate_batch_scan_rsp_queue( hdd_adapter_t* pAdapter, |
| 1625 | tpSirBatchScanNetworkInfo pApMetaInfo, tANI_U32 scanId, v_BOOL_t isLastAp) |
| 1626 | { |
| 1627 | tHddBatchScanRsp *pHead; |
| 1628 | tHddBatchScanRsp *pNode; |
| 1629 | tHddBatchScanRsp *pPrev; |
| 1630 | tHddBatchScanRsp *pTemp; |
| 1631 | tANI_U8 ssidLen; |
| 1632 | |
| 1633 | /*head of hdd batch scan response queue*/ |
| 1634 | pHead = pAdapter->pBatchScanRsp; |
| 1635 | |
| 1636 | pNode = (tHddBatchScanRsp *)vos_mem_malloc(sizeof(tHddBatchScanRsp)); |
| 1637 | if (NULL == pNode) |
| 1638 | { |
| 1639 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1640 | "%s: Could not allocate memory", __func__); |
| 1641 | VOS_ASSERT(0); |
| 1642 | return; |
| 1643 | } |
| 1644 | |
| 1645 | vos_mem_copy(pNode->ApInfo.bssid, pApMetaInfo->bssid, |
| 1646 | sizeof(pNode->ApInfo.bssid)); |
| 1647 | ssidLen = strlen(pApMetaInfo->ssid); |
| 1648 | if (SIR_MAX_SSID_SIZE < ssidLen) |
| 1649 | { |
| 1650 | /*invalid scan result*/ |
| 1651 | vos_mem_free(pNode); |
| 1652 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1653 | "%s: Invalid AP meta info ssidlen %d", __func__, ssidLen); |
| 1654 | return; |
| 1655 | } |
| 1656 | vos_mem_copy(pNode->ApInfo.ssid, pApMetaInfo->ssid, ssidLen); |
| 1657 | /*null terminate ssid*/ |
| 1658 | pNode->ApInfo.ssid[ssidLen] = '\0'; |
| 1659 | pNode->ApInfo.ch = pApMetaInfo->ch; |
| 1660 | pNode->ApInfo.rssi = pApMetaInfo->rssi; |
| 1661 | pNode->ApInfo.age = pApMetaInfo->timestamp; |
| 1662 | pNode->ApInfo.batchId = scanId; |
| 1663 | pNode->ApInfo.isLastAp = isLastAp; |
| 1664 | |
| 1665 | pNode->pNext = NULL; |
| 1666 | if (NULL == pHead) |
| 1667 | { |
| 1668 | pAdapter->pBatchScanRsp = pNode; |
| 1669 | } |
| 1670 | else |
| 1671 | { |
| 1672 | pTemp = pHead; |
| 1673 | while (NULL != pTemp) |
| 1674 | { |
| 1675 | pPrev = pTemp; |
| 1676 | pTemp = pTemp->pNext; |
| 1677 | } |
| 1678 | pPrev->pNext = pNode; |
| 1679 | } |
| 1680 | |
| 1681 | return; |
| 1682 | }/*End of hdd_populate_batch_scan_rsp_queue*/ |
| 1683 | |
| 1684 | /**--------------------------------------------------------------------------- |
| 1685 | |
| 1686 | \brief hdd_batch_scan_result_ind_callback () - This function is called after |
| 1687 | receiving batch scan response indication from FW. It saves get batch scan |
| 1688 | response data in HDD batch scan response queue. This callback sets the |
| 1689 | completion event on which hdd_ioctl is waiting only after getting complete |
| 1690 | batch scan response data from FW |
| 1691 | |
| 1692 | \param - callbackContext Pointer to HDD adapter |
| 1693 | \param - pRsp Pointer to get batch scan response data received from FW |
| 1694 | |
| 1695 | \return - nothing |
| 1696 | |
| 1697 | --------------------------------------------------------------------------*/ |
| 1698 | static void hdd_batch_scan_result_ind_callback |
| 1699 | ( |
| 1700 | void *callbackContext, |
| 1701 | void *pRsp |
| 1702 | ) |
| 1703 | { |
| 1704 | v_BOOL_t isLastAp; |
| 1705 | tANI_U32 numApMetaInfo; |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1706 | tANI_U32 numNetworkInScanList; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1707 | tANI_U32 numberScanList; |
| 1708 | tANI_U32 nextScanListOffset; |
| 1709 | tANI_U32 nextApMetaInfoOffset; |
| 1710 | hdd_adapter_t* pAdapter; |
| 1711 | tpSirBatchScanList pScanList; |
| 1712 | tpSirBatchScanNetworkInfo pApMetaInfo; |
| 1713 | tpSirBatchScanResultIndParam pBatchScanRsp;/*batch scan rsp data from FW*/ |
| 1714 | tSirSetBatchScanReq *pReq; |
| 1715 | |
| 1716 | pAdapter = (hdd_adapter_t *)callbackContext; |
| 1717 | /*sanity check*/ |
Rajeev Kumar | 5286bb9 | 2013-12-05 11:52:10 -0800 | [diff] [blame] | 1718 | if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)) |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1719 | { |
| 1720 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1721 | "%s: Invalid pAdapter magic", __func__); |
| 1722 | VOS_ASSERT(0); |
| 1723 | return; |
| 1724 | } |
| 1725 | |
| 1726 | /*initialize locals*/ |
| 1727 | pReq = &pAdapter->hddSetBatchScanReq; |
| 1728 | pBatchScanRsp = (tpSirBatchScanResultIndParam)pRsp; |
| 1729 | isLastAp = FALSE; |
| 1730 | numApMetaInfo = 0; |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1731 | numNetworkInScanList = 0; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1732 | numberScanList = 0; |
| 1733 | nextScanListOffset = 0; |
| 1734 | nextApMetaInfoOffset = 0; |
| 1735 | pScanList = NULL; |
| 1736 | pApMetaInfo = NULL; |
| 1737 | |
| 1738 | if ((NULL == pBatchScanRsp) || (NULL == pReq)) |
| 1739 | { |
| 1740 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1741 | "%s: pBatchScanRsp is %p pReq %p", __func__, pBatchScanRsp, pReq); |
| 1742 | isLastAp = TRUE; |
| 1743 | goto done; |
| 1744 | } |
| 1745 | |
| 1746 | pAdapter->numScanList = numberScanList = pBatchScanRsp->numScanLists; |
| 1747 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1748 | "Batch scan rsp: numberScalList %d", numberScanList); |
| 1749 | |
| 1750 | if ((!numberScanList) || (numberScanList > pReq->numberOfScansToBatch)) |
| 1751 | { |
| 1752 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1753 | "%s: numberScanList %d", __func__, numberScanList); |
| 1754 | isLastAp = TRUE; |
| 1755 | goto done; |
| 1756 | } |
| 1757 | |
| 1758 | while (numberScanList) |
| 1759 | { |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1760 | pScanList = (tpSirBatchScanList)((tANI_U8 *)pBatchScanRsp->scanResults + |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1761 | nextScanListOffset); |
| 1762 | if (NULL == pScanList) |
| 1763 | { |
| 1764 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1765 | "%s: pScanList is %p", __func__, pScanList); |
| 1766 | isLastAp = TRUE; |
| 1767 | goto done; |
| 1768 | } |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1769 | numNetworkInScanList = numApMetaInfo = pScanList->numNetworksInScanList; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1770 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1771 | "Batch scan rsp: numApMetaInfo %d scanId %d", |
| 1772 | numApMetaInfo, pScanList->scanId); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1773 | |
| 1774 | if ((!numApMetaInfo) || (numApMetaInfo > pReq->bestNetwork)) |
| 1775 | { |
| 1776 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1777 | "%s: numApMetaInfo %d", __func__, numApMetaInfo); |
| 1778 | isLastAp = TRUE; |
| 1779 | goto done; |
| 1780 | } |
| 1781 | |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1782 | /*Initialize next AP meta info offset for next scan list*/ |
| 1783 | nextApMetaInfoOffset = 0; |
| 1784 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1785 | while (numApMetaInfo) |
| 1786 | { |
| 1787 | pApMetaInfo = (tpSirBatchScanNetworkInfo)(pScanList->scanList + |
| 1788 | nextApMetaInfoOffset); |
| 1789 | if (NULL == pApMetaInfo) |
| 1790 | { |
| 1791 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1792 | "%s: pApMetaInfo is %p", __func__, pApMetaInfo); |
| 1793 | isLastAp = TRUE; |
| 1794 | goto done; |
| 1795 | } |
| 1796 | /*calculate AP age*/ |
| 1797 | pApMetaInfo->timestamp = |
| 1798 | pBatchScanRsp->timestamp - pApMetaInfo->timestamp; |
| 1799 | |
| 1800 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
Arif Hussain | a7c8e41 | 2013-11-20 11:06:42 -0800 | [diff] [blame] | 1801 | "%s: bssId "MAC_ADDRESS_STR |
| 1802 | " ch %d rssi %d timestamp %d", __func__, |
| 1803 | MAC_ADDR_ARRAY(pApMetaInfo->bssid), |
| 1804 | pApMetaInfo->ch, pApMetaInfo->rssi, |
| 1805 | pApMetaInfo->timestamp); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1806 | |
| 1807 | /*mark last AP in batch scan response*/ |
| 1808 | if ((TRUE == pBatchScanRsp->isLastResult) && |
| 1809 | (1 == numberScanList) && (1 == numApMetaInfo)) |
| 1810 | { |
| 1811 | isLastAp = TRUE; |
| 1812 | } |
| 1813 | |
| 1814 | mutex_lock(&pAdapter->hdd_batch_scan_lock); |
| 1815 | /*store batch scan repsonse in hdd queue*/ |
| 1816 | hdd_populate_batch_scan_rsp_queue(pAdapter, pApMetaInfo, |
| 1817 | pScanList->scanId, isLastAp); |
| 1818 | mutex_unlock(&pAdapter->hdd_batch_scan_lock); |
| 1819 | |
| 1820 | nextApMetaInfoOffset += sizeof(tSirBatchScanNetworkInfo); |
| 1821 | numApMetaInfo--; |
| 1822 | } |
| 1823 | |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1824 | nextScanListOffset += ((sizeof(tSirBatchScanList) - sizeof(tANI_U8)) |
| 1825 | + (sizeof(tSirBatchScanNetworkInfo) |
| 1826 | * numNetworkInScanList)); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1827 | numberScanList--; |
| 1828 | } |
| 1829 | |
| 1830 | done: |
| 1831 | |
| 1832 | /*notify hdd_ioctl only if complete batch scan rsp is received and it was |
| 1833 | requested from hdd_ioctl*/ |
| 1834 | if ((TRUE == pAdapter->hdd_wait_for_get_batch_scan_rsp) && |
| 1835 | (TRUE == isLastAp)) |
| 1836 | { |
| 1837 | pAdapter->hdd_wait_for_get_batch_scan_rsp = FALSE; |
| 1838 | complete(&pAdapter->hdd_get_batch_scan_req_var); |
| 1839 | } |
| 1840 | |
| 1841 | return; |
| 1842 | }/*End of hdd_batch_scan_result_ind_callback*/ |
| 1843 | |
| 1844 | /**--------------------------------------------------------------------------- |
| 1845 | |
| 1846 | \brief hdd_format_batch_scan_rsp () - This function formats batch scan |
| 1847 | response as per batch scan FR request format by putting proper markers |
| 1848 | |
| 1849 | \param - pDest pointer to destination buffer |
| 1850 | \param - cur_len current length |
| 1851 | \param - tot_len total remaining size which can be written to user space |
| 1852 | \param - pApMetaInfo Pointer to get batch scan response AP meta info |
| 1853 | \param - pAdapter Pointer to HDD adapter |
| 1854 | |
| 1855 | \return - ret no of characters written |
| 1856 | |
| 1857 | --------------------------------------------------------------------------*/ |
| 1858 | static tANI_U32 |
| 1859 | hdd_format_batch_scan_rsp |
| 1860 | ( |
| 1861 | tANI_U8 *pDest, |
| 1862 | tANI_U32 cur_len, |
| 1863 | tANI_U32 tot_len, |
| 1864 | tHddBatchScanRsp *pApMetaInfo, |
| 1865 | hdd_adapter_t* pAdapter |
| 1866 | ) |
| 1867 | { |
| 1868 | tANI_U32 ret = 0; |
| 1869 | tANI_U32 rem_len = 0; |
| 1870 | tANI_U8 temp_len = 0; |
| 1871 | tANI_U8 temp_total_len = 0; |
| 1872 | tANI_U8 temp[HDD_BATCH_SCAN_AP_META_INFO_SIZE]; |
| 1873 | tANI_U8 *pTemp = temp; |
| 1874 | |
| 1875 | /*Batch scan reponse needs to be returned to user space in |
| 1876 | following format: |
| 1877 | "scancount=X\n" where X is the number of scans in current batch |
| 1878 | batch |
| 1879 | "trunc\n" optional present if current scan truncated |
| 1880 | "bssid=XX:XX:XX:XX:XX:XX\n" |
| 1881 | "ssid=XXXX\n" |
| 1882 | "freq=X\n" frequency in Mhz |
| 1883 | "level=XX\n" |
| 1884 | "age=X\n" ms |
| 1885 | "dist=X\n" cm (-1 if not available) |
| 1886 | "errror=X\n" (-1if not available) |
| 1887 | "====\n" (end of ap marker) |
| 1888 | "####\n" (end of scan marker) |
| 1889 | "----\n" (end of results)*/ |
| 1890 | /*send scan result in above format to user space based on |
| 1891 | available length*/ |
| 1892 | /*The GET response may have more data than the driver can return in its |
| 1893 | buffer. In that case the buffer should be filled to the nearest complete |
| 1894 | scan, ending with "%%%%".Subsequent callsshould return the remaining data |
| 1895 | starting with the next scan (optional .trunc\n., .apcount=X\n., etc). |
| 1896 | The final buffer should end with "----\n"*/ |
| 1897 | |
| 1898 | /*sanity*/ |
| 1899 | if (cur_len > tot_len) |
| 1900 | { |
| 1901 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1902 | "%s: invaid cur_len %d tot_len %d", __func__, cur_len, tot_len); |
| 1903 | return 0; |
| 1904 | } |
| 1905 | else |
| 1906 | { |
| 1907 | rem_len = (tot_len - cur_len); |
| 1908 | } |
| 1909 | |
| 1910 | /*end scan marker*/ |
| 1911 | if (pApMetaInfo->ApInfo.batchId != pAdapter->prev_batch_id) |
| 1912 | { |
| 1913 | temp_len = snprintf(pTemp, sizeof(temp), "####\n"); |
| 1914 | pTemp += temp_len; |
| 1915 | temp_total_len += temp_len; |
| 1916 | } |
| 1917 | |
| 1918 | /*bssid*/ |
| 1919 | temp_len = snprintf(pTemp, sizeof(temp), |
| 1920 | "bssid=0x%x:0x%x:0x%x:0x%x:0x%x:0x%x\n", |
| 1921 | pApMetaInfo->ApInfo.bssid[0], pApMetaInfo->ApInfo.bssid[1], |
| 1922 | pApMetaInfo->ApInfo.bssid[2], pApMetaInfo->ApInfo.bssid[3], |
| 1923 | pApMetaInfo->ApInfo.bssid[4], pApMetaInfo->ApInfo.bssid[5]); |
| 1924 | pTemp += temp_len; |
| 1925 | temp_total_len += temp_len; |
| 1926 | |
| 1927 | /*ssid*/ |
| 1928 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "ssid=%s\n", |
| 1929 | pApMetaInfo->ApInfo.ssid); |
| 1930 | pTemp += temp_len; |
| 1931 | temp_total_len += temp_len; |
| 1932 | |
| 1933 | /*freq*/ |
| 1934 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "freq=%d\n", |
Rajeev Kumar | c40f751 | 2013-11-04 14:13:23 -0800 | [diff] [blame] | 1935 | sme_ChnToFreq(pApMetaInfo->ApInfo.ch)); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1936 | pTemp += temp_len; |
| 1937 | temp_total_len += temp_len; |
| 1938 | |
| 1939 | /*level*/ |
| 1940 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "level=%d\n", |
| 1941 | pApMetaInfo->ApInfo.rssi); |
| 1942 | pTemp += temp_len; |
| 1943 | temp_total_len += temp_len; |
| 1944 | |
| 1945 | /*age*/ |
Jeff Johnson | 0279779 | 2013-10-26 19:17:13 -0700 | [diff] [blame] | 1946 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "age=%d\n", |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1947 | pApMetaInfo->ApInfo.age); |
| 1948 | pTemp += temp_len; |
| 1949 | temp_total_len += temp_len; |
| 1950 | |
| 1951 | /*dist*/ |
| 1952 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "dist=-1\n"); |
| 1953 | pTemp += temp_len; |
| 1954 | temp_total_len += temp_len; |
| 1955 | |
| 1956 | /*error*/ |
| 1957 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "error=-1\n"); |
| 1958 | pTemp += temp_len; |
| 1959 | temp_total_len += temp_len; |
| 1960 | |
| 1961 | /*end AP marker*/ |
| 1962 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "====\n"); |
| 1963 | pTemp += temp_len; |
| 1964 | temp_total_len += temp_len; |
| 1965 | |
| 1966 | /*last AP in batch scan response*/ |
| 1967 | if(TRUE == pApMetaInfo->ApInfo.isLastAp) |
| 1968 | { |
| 1969 | /*end scan marker*/ |
| 1970 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "####\n"); |
| 1971 | pTemp += temp_len; |
| 1972 | temp_total_len += temp_len; |
| 1973 | |
| 1974 | /*end batch scan result marker*/ |
| 1975 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "----\n"); |
| 1976 | pTemp += temp_len; |
| 1977 | temp_total_len += temp_len; |
Kiet Lam | aa8e15a | 2014-02-11 23:30:06 -0800 | [diff] [blame] | 1978 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1979 | } |
| 1980 | |
| 1981 | if (temp_total_len < rem_len) |
| 1982 | { |
| 1983 | ret = temp_total_len + 1; |
| 1984 | strlcpy(pDest, temp, ret); |
| 1985 | pAdapter->isTruncated = FALSE; |
| 1986 | } |
| 1987 | else |
| 1988 | { |
| 1989 | pAdapter->isTruncated = TRUE; |
| 1990 | if (rem_len >= strlen("%%%%")) |
| 1991 | { |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 1992 | ret = snprintf(pDest, sizeof(temp), "%%%%"); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1993 | } |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 1994 | else |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1995 | { |
| 1996 | ret = 0; |
| 1997 | } |
| 1998 | } |
| 1999 | |
| 2000 | return ret; |
| 2001 | |
| 2002 | }/*End of hdd_format_batch_scan_rsp*/ |
| 2003 | |
| 2004 | /**--------------------------------------------------------------------------- |
| 2005 | |
| 2006 | \brief hdd_populate_user_batch_scan_rsp() - This function populates user data |
| 2007 | buffer starting with head of hdd batch scan response queue |
| 2008 | |
| 2009 | \param - pAdapter Pointer to HDD adapter |
| 2010 | \param - pDest Pointer to user data buffer |
| 2011 | \param - cur_len current offset in user buffer |
| 2012 | \param - rem_len remaining no of bytes in user buffer |
| 2013 | |
| 2014 | \return - number of bytes written in user buffer |
| 2015 | |
| 2016 | --------------------------------------------------------------------------*/ |
| 2017 | |
| 2018 | tANI_U32 hdd_populate_user_batch_scan_rsp |
| 2019 | ( |
| 2020 | hdd_adapter_t* pAdapter, |
| 2021 | tANI_U8 *pDest, |
| 2022 | tANI_U32 cur_len, |
| 2023 | tANI_U32 rem_len |
| 2024 | ) |
| 2025 | { |
| 2026 | tHddBatchScanRsp *pHead; |
| 2027 | tHddBatchScanRsp *pPrev; |
| 2028 | tANI_U32 len; |
| 2029 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 2030 | pAdapter->isTruncated = FALSE; |
| 2031 | |
| 2032 | /*head of hdd batch scan response queue*/ |
| 2033 | pHead = pAdapter->pBatchScanRsp; |
| 2034 | while (pHead) |
| 2035 | { |
| 2036 | len = hdd_format_batch_scan_rsp(pDest, cur_len, rem_len, pHead, |
| 2037 | pAdapter); |
| 2038 | pDest += len; |
Rajeev Kumar | 292d2bb | 2013-10-23 15:01:44 -0700 | [diff] [blame] | 2039 | pDest--; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 2040 | cur_len += len; |
| 2041 | if(TRUE == pAdapter->isTruncated) |
| 2042 | { |
| 2043 | /*result is truncated return rest of scan rsp in next req*/ |
| 2044 | cur_len = rem_len; |
| 2045 | break; |
| 2046 | } |
| 2047 | pPrev = pHead; |
| 2048 | pHead = pHead->pNext; |
| 2049 | pAdapter->pBatchScanRsp = pHead; |
Rajeev Kumar | be17d8b | 2014-01-10 15:39:45 -0800 | [diff] [blame] | 2050 | if (TRUE == pPrev->ApInfo.isLastAp) |
| 2051 | { |
| 2052 | pAdapter->prev_batch_id = 0; |
| 2053 | } |
| 2054 | else |
| 2055 | { |
| 2056 | pAdapter->prev_batch_id = pPrev->ApInfo.batchId; |
| 2057 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 2058 | vos_mem_free(pPrev); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 2059 | pPrev = NULL; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 2060 | } |
| 2061 | |
| 2062 | return cur_len; |
| 2063 | }/*End of hdd_populate_user_batch_scan_rsp*/ |
| 2064 | |
| 2065 | /**--------------------------------------------------------------------------- |
| 2066 | |
| 2067 | \brief hdd_return_batch_scan_rsp_to_user () - This function returns batch |
| 2068 | scan response data from HDD queue to user space |
| 2069 | It does following in detail: |
| 2070 | a) if HDD has enough data in its queue then it 1st copies data to user |
| 2071 | space and then send get batch scan indication message to FW. In this |
| 2072 | case it does not wait on any event and batch scan response data will |
| 2073 | be populated in HDD response queue in MC thread context after receiving |
| 2074 | indication from FW |
| 2075 | b) else send get batch scan indication message to FW and wait on an event |
| 2076 | which will be set once HDD receives complete batch scan response from |
| 2077 | FW and then this function returns batch scan response to user space |
| 2078 | |
| 2079 | \param - pAdapter Pointer to HDD adapter |
| 2080 | \param - pPrivData Pointer to priv_data |
| 2081 | |
| 2082 | \return - 0 for success -EFAULT for failure |
| 2083 | |
| 2084 | --------------------------------------------------------------------------*/ |
| 2085 | |
| 2086 | int hdd_return_batch_scan_rsp_to_user |
| 2087 | ( |
| 2088 | hdd_adapter_t* pAdapter, |
| 2089 | hdd_priv_data_t *pPrivData, |
| 2090 | tANI_U8 *command |
| 2091 | ) |
| 2092 | { |
| 2093 | tANI_U8 *pDest; |
| 2094 | tANI_U32 count = 0; |
| 2095 | tANI_U32 len = 0; |
| 2096 | tANI_U32 cur_len = 0; |
| 2097 | tANI_U32 rem_len = 0; |
| 2098 | eHalStatus halStatus; |
| 2099 | unsigned long rc; |
| 2100 | tSirTriggerBatchScanResultInd *pReq; |
| 2101 | |
| 2102 | pReq = &pAdapter->hddTriggerBatchScanResultInd; |
| 2103 | pReq->param = 0;/*batch scan client*/ |
| 2104 | pDest = (tANI_U8 *)(command + pPrivData->used_len); |
| 2105 | pAdapter->hdd_wait_for_get_batch_scan_rsp = FALSE; |
| 2106 | |
| 2107 | cur_len = pPrivData->used_len; |
| 2108 | if (pPrivData->total_len > pPrivData->used_len) |
| 2109 | { |
| 2110 | rem_len = pPrivData->total_len - pPrivData->used_len; |
| 2111 | } |
| 2112 | else |
| 2113 | { |
| 2114 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2115 | "%s: Invalid user data buffer total_len %d used_len %d", |
| 2116 | __func__, pPrivData->total_len, pPrivData->used_len); |
| 2117 | return -EFAULT; |
| 2118 | } |
| 2119 | |
| 2120 | mutex_lock(&pAdapter->hdd_batch_scan_lock); |
| 2121 | len = hdd_populate_user_batch_scan_rsp(pAdapter, pDest, |
| 2122 | cur_len, rem_len); |
| 2123 | mutex_unlock(&pAdapter->hdd_batch_scan_lock); |
| 2124 | |
| 2125 | /*enough scan result available in cache to return to user space or |
| 2126 | scan result needs to be fetched 1st from fw and then return*/ |
Rajeev Kumar | 99db626 | 2013-11-11 15:23:36 -0800 | [diff] [blame] | 2127 | if (len == cur_len) |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 2128 | { |
| 2129 | pAdapter->hdd_wait_for_get_batch_scan_rsp = TRUE; |
| 2130 | halStatus = sme_TriggerBatchScanResultInd( |
| 2131 | WLAN_HDD_GET_HAL_CTX(pAdapter), pReq, |
| 2132 | pAdapter->sessionId, hdd_batch_scan_result_ind_callback, |
| 2133 | pAdapter); |
| 2134 | if ( eHAL_STATUS_SUCCESS == halStatus ) |
| 2135 | { |
| 2136 | if (TRUE == pAdapter->hdd_wait_for_get_batch_scan_rsp) |
| 2137 | { |
| 2138 | INIT_COMPLETION(pAdapter->hdd_get_batch_scan_req_var); |
| 2139 | rc = wait_for_completion_timeout( |
| 2140 | &pAdapter->hdd_get_batch_scan_req_var, |
| 2141 | msecs_to_jiffies(HDD_GET_BATCH_SCAN_RSP_TIME_OUT)); |
Abhishek Singh | 00b7197 | 2016-01-07 10:51:04 +0530 | [diff] [blame] | 2142 | if (0 >= rc) |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 2143 | { |
| 2144 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Abhishek Singh | 00b7197 | 2016-01-07 10:51:04 +0530 | [diff] [blame] | 2145 | "%s: wait on hdd_get_batch_scan_req_var failed %ld", |
| 2146 | __func__, rc); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 2147 | return -EFAULT; |
| 2148 | } |
| 2149 | } |
| 2150 | |
| 2151 | len = snprintf(pDest, HDD_BATCH_SCAN_AP_META_INFO_SIZE, |
Jeff Johnson | 0279779 | 2013-10-26 19:17:13 -0700 | [diff] [blame] | 2152 | "scancount=%u\n", pAdapter->numScanList); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 2153 | pDest += len; |
| 2154 | cur_len += len; |
| 2155 | |
| 2156 | mutex_lock(&pAdapter->hdd_batch_scan_lock); |
| 2157 | len = hdd_populate_user_batch_scan_rsp(pAdapter, pDest, |
| 2158 | cur_len, rem_len); |
| 2159 | mutex_unlock(&pAdapter->hdd_batch_scan_lock); |
| 2160 | |
| 2161 | count = 0; |
| 2162 | len = (len - pPrivData->used_len); |
| 2163 | pDest = (command + pPrivData->used_len); |
| 2164 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Rajeev Kumar | 99db626 | 2013-11-11 15:23:36 -0800 | [diff] [blame] | 2165 | "NEW BATCH SCAN RESULT:"); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 2166 | while(count < len) |
| 2167 | { |
| 2168 | printk("%c", *(pDest + count)); |
| 2169 | count++; |
| 2170 | } |
| 2171 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2172 | "%s: copy %d data to user buffer", __func__, len); |
| 2173 | if (copy_to_user(pPrivData->buf, pDest, len)) |
| 2174 | { |
| 2175 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2176 | "%s: failed to copy data to user buffer", __func__); |
| 2177 | return -EFAULT; |
| 2178 | } |
| 2179 | } |
| 2180 | else |
| 2181 | { |
| 2182 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2183 | "sme_GetBatchScanScan returned failure halStatus %d", |
| 2184 | halStatus); |
| 2185 | return -EINVAL; |
| 2186 | } |
| 2187 | } |
| 2188 | else |
| 2189 | { |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 2190 | count = 0; |
| 2191 | len = (len - pPrivData->used_len); |
| 2192 | pDest = (command + pPrivData->used_len); |
| 2193 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Rajeev Kumar | 99db626 | 2013-11-11 15:23:36 -0800 | [diff] [blame] | 2194 | "REMAINING TRUNCATED BATCH SCAN RESULT:"); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 2195 | while(count < len) |
| 2196 | { |
| 2197 | printk("%c", *(pDest + count)); |
| 2198 | count++; |
| 2199 | } |
Rajeev Kumar | 99db626 | 2013-11-11 15:23:36 -0800 | [diff] [blame] | 2200 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2201 | "%s: copy %d data to user buffer", __func__, len); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 2202 | if (copy_to_user(pPrivData->buf, pDest, len)) |
| 2203 | { |
| 2204 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2205 | "%s: failed to copy data to user buffer", __func__); |
| 2206 | return -EFAULT; |
| 2207 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 2208 | } |
| 2209 | |
| 2210 | return 0; |
| 2211 | } /*End of hdd_return_batch_scan_rsp_to_user*/ |
| 2212 | |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 2213 | /**--------------------------------------------------------------------------- |
| 2214 | |
| 2215 | \brief hdd_handle_batch_scan_ioctl () - This function handles WLS_BATCHING |
| 2216 | IOCTLs from user space. Following BATCH SCAN DEV IOCTs are handled: |
| 2217 | WLS_BATCHING VERSION |
| 2218 | WLS_BATCHING SET |
| 2219 | WLS_BATCHING GET |
| 2220 | WLS_BATCHING STOP |
| 2221 | |
| 2222 | \param - pAdapter Pointer to HDD adapter |
| 2223 | \param - pPrivdata Pointer to priv_data |
| 2224 | \param - command Pointer to command |
| 2225 | |
| 2226 | \return - 0 for success -EFAULT for failure |
| 2227 | |
| 2228 | --------------------------------------------------------------------------*/ |
| 2229 | |
| 2230 | int hdd_handle_batch_scan_ioctl |
| 2231 | ( |
| 2232 | hdd_adapter_t *pAdapter, |
| 2233 | hdd_priv_data_t *pPrivdata, |
| 2234 | tANI_U8 *command |
| 2235 | ) |
| 2236 | { |
| 2237 | int ret = 0; |
Yue Ma | e36e355 | 2014-03-05 17:06:20 -0800 | [diff] [blame] | 2238 | hdd_context_t *pHddCtx; |
| 2239 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2240 | ENTER(); |
| 2241 | |
Yue Ma | e36e355 | 2014-03-05 17:06:20 -0800 | [diff] [blame] | 2242 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2243 | ret = wlan_hdd_validate_context(pHddCtx); |
| 2244 | if (ret) |
| 2245 | { |
Yue Ma | e36e355 | 2014-03-05 17:06:20 -0800 | [diff] [blame] | 2246 | goto exit; |
| 2247 | } |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 2248 | |
| 2249 | if (strncmp(command, "WLS_BATCHING VERSION", 20) == 0) |
| 2250 | { |
| 2251 | char extra[32]; |
| 2252 | tANI_U8 len = 0; |
| 2253 | tANI_U8 version = HDD_BATCH_SCAN_VERSION; |
| 2254 | |
| 2255 | if (FALSE == sme_IsFeatureSupportedByFW(BATCH_SCAN)) |
| 2256 | { |
| 2257 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2258 | "%s: Batch scan feature is not supported by FW", __func__); |
| 2259 | ret = -EINVAL; |
| 2260 | goto exit; |
| 2261 | } |
| 2262 | |
| 2263 | len = scnprintf(extra, sizeof(extra), "WLS_BATCHING_VERSION %d", |
| 2264 | version); |
| 2265 | if (copy_to_user(pPrivdata->buf, &extra, len + 1)) |
| 2266 | { |
| 2267 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2268 | "%s: failed to copy data to user buffer", __func__); |
| 2269 | ret = -EFAULT; |
| 2270 | goto exit; |
| 2271 | } |
| 2272 | ret = HDD_BATCH_SCAN_VERSION; |
| 2273 | } |
| 2274 | else if (strncmp(command, "WLS_BATCHING SET", 16) == 0) |
| 2275 | { |
| 2276 | int status; |
| 2277 | tANI_U8 *value = (command + 16); |
| 2278 | eHalStatus halStatus; |
| 2279 | unsigned long rc; |
| 2280 | tSirSetBatchScanReq *pReq = &pAdapter->hddSetBatchScanReq; |
| 2281 | tSirSetBatchScanRsp *pRsp = &pAdapter->hddSetBatchScanRsp; |
| 2282 | |
| 2283 | if (FALSE == sme_IsFeatureSupportedByFW(BATCH_SCAN)) |
| 2284 | { |
| 2285 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2286 | "%s: Batch scan feature is not supported by FW", __func__); |
| 2287 | ret = -EINVAL; |
| 2288 | goto exit; |
| 2289 | } |
| 2290 | |
| 2291 | if ((WLAN_HDD_INFRA_STATION != pAdapter->device_mode) && |
| 2292 | (WLAN_HDD_P2P_CLIENT != pAdapter->device_mode) && |
| 2293 | (WLAN_HDD_P2P_GO != pAdapter->device_mode) && |
| 2294 | (WLAN_HDD_P2P_DEVICE != pAdapter->device_mode)) |
| 2295 | { |
| 2296 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 2297 | "Received WLS_BATCHING SET command in invalid mode %s (%d) " |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 2298 | "WLS_BATCHING_SET is only allowed in infra STA/P2P client mode", |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 2299 | hdd_device_modetoString(pAdapter->device_mode), |
| 2300 | pAdapter->device_mode); |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 2301 | ret = -EINVAL; |
| 2302 | goto exit; |
| 2303 | } |
| 2304 | |
| 2305 | status = hdd_parse_set_batchscan_command(value, pReq); |
| 2306 | if (status) |
| 2307 | { |
| 2308 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2309 | "Invalid WLS_BATCHING SET command"); |
| 2310 | ret = -EINVAL; |
| 2311 | goto exit; |
| 2312 | } |
| 2313 | |
| 2314 | |
| 2315 | pAdapter->hdd_wait_for_set_batch_scan_rsp = TRUE; |
| 2316 | halStatus = sme_SetBatchScanReq(WLAN_HDD_GET_HAL_CTX(pAdapter), pReq, |
| 2317 | pAdapter->sessionId, hdd_set_batch_scan_req_callback, |
| 2318 | pAdapter); |
| 2319 | |
| 2320 | if ( eHAL_STATUS_SUCCESS == halStatus ) |
| 2321 | { |
Mahesh A Saptasagar | 5f56817 | 2014-05-14 17:02:33 +0530 | [diff] [blame] | 2322 | char extra[32]; |
| 2323 | tANI_U8 len = 0; |
| 2324 | tANI_U8 mScan = 0; |
| 2325 | |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 2326 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2327 | "sme_SetBatchScanReq returned success halStatus %d", |
| 2328 | halStatus); |
| 2329 | if (TRUE == pAdapter->hdd_wait_for_set_batch_scan_rsp) |
| 2330 | { |
| 2331 | INIT_COMPLETION(pAdapter->hdd_set_batch_scan_req_var); |
| 2332 | rc = wait_for_completion_timeout( |
| 2333 | &pAdapter->hdd_set_batch_scan_req_var, |
| 2334 | msecs_to_jiffies(HDD_SET_BATCH_SCAN_REQ_TIME_OUT)); |
| 2335 | if (0 == rc) |
| 2336 | { |
| 2337 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2338 | "%s: Timeout waiting for set batch scan to complete", |
| 2339 | __func__); |
| 2340 | ret = -EINVAL; |
| 2341 | goto exit; |
| 2342 | } |
| 2343 | } |
| 2344 | if ( !pRsp->nScansToBatch ) |
| 2345 | { |
| 2346 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2347 | "%s: Received set batch scan failure response from FW", |
| 2348 | __func__); |
| 2349 | ret = -EINVAL; |
| 2350 | goto exit; |
| 2351 | } |
| 2352 | /*As per the Batch Scan Framework API we should return the MIN of |
| 2353 | either MSCAN or the max # of scans firmware can cache*/ |
Mahesh A Saptasagar | 5f56817 | 2014-05-14 17:02:33 +0530 | [diff] [blame] | 2354 | mScan = MIN(pReq->numberOfScansToBatch , pRsp->nScansToBatch); |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 2355 | |
| 2356 | pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STARTED; |
| 2357 | |
| 2358 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2359 | "%s: request MSCAN %d response MSCAN %d ret %d", |
Mahesh A Saptasagar | 5f56817 | 2014-05-14 17:02:33 +0530 | [diff] [blame] | 2360 | __func__, pReq->numberOfScansToBatch, pRsp->nScansToBatch, mScan); |
| 2361 | len = scnprintf(extra, sizeof(extra), "%d", mScan); |
| 2362 | if (copy_to_user(pPrivdata->buf, &extra, len + 1)) |
| 2363 | { |
| 2364 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2365 | "%s: failed to copy MSCAN value to user buffer", __func__); |
| 2366 | ret = -EFAULT; |
| 2367 | goto exit; |
| 2368 | } |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 2369 | } |
| 2370 | else |
| 2371 | { |
| 2372 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2373 | "sme_SetBatchScanReq returned failure halStatus %d", |
| 2374 | halStatus); |
| 2375 | ret = -EINVAL; |
| 2376 | goto exit; |
| 2377 | } |
| 2378 | } |
| 2379 | else if (strncmp(command, "WLS_BATCHING STOP", 17) == 0) |
| 2380 | { |
| 2381 | eHalStatus halStatus; |
| 2382 | tSirStopBatchScanInd *pInd = &pAdapter->hddStopBatchScanInd; |
| 2383 | pInd->param = 0; |
| 2384 | |
| 2385 | if (FALSE == sme_IsFeatureSupportedByFW(BATCH_SCAN)) |
| 2386 | { |
| 2387 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2388 | "%s: Batch scan feature is not supported by FW", __func__); |
| 2389 | ret = -EINVAL; |
| 2390 | goto exit; |
| 2391 | } |
| 2392 | |
| 2393 | if (eHDD_BATCH_SCAN_STATE_STARTED != pAdapter->batchScanState) |
| 2394 | { |
Deepthi Gowri | bfd1713 | 2014-11-14 17:59:04 +0530 | [diff] [blame] | 2395 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 2396 | "Batch scan is not yet enabled batch scan state %d", |
| 2397 | pAdapter->batchScanState); |
| 2398 | ret = -EINVAL; |
| 2399 | goto exit; |
| 2400 | } |
| 2401 | |
Kiet Lam | aa8e15a | 2014-02-11 23:30:06 -0800 | [diff] [blame] | 2402 | mutex_lock(&pAdapter->hdd_batch_scan_lock); |
| 2403 | hdd_deinit_batch_scan(pAdapter); |
| 2404 | mutex_unlock(&pAdapter->hdd_batch_scan_lock); |
| 2405 | |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 2406 | pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STOPPED; |
| 2407 | |
| 2408 | halStatus = sme_StopBatchScanInd(WLAN_HDD_GET_HAL_CTX(pAdapter), pInd, |
| 2409 | pAdapter->sessionId); |
| 2410 | if ( eHAL_STATUS_SUCCESS == halStatus ) |
| 2411 | { |
| 2412 | ret = 0; |
| 2413 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2414 | "sme_StopBatchScanInd returned success halStatus %d", |
| 2415 | halStatus); |
| 2416 | } |
| 2417 | else |
| 2418 | { |
| 2419 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2420 | "sme_StopBatchScanInd returned failure halStatus %d", |
| 2421 | halStatus); |
| 2422 | ret = -EINVAL; |
| 2423 | goto exit; |
| 2424 | } |
| 2425 | } |
| 2426 | else if (strncmp(command, "WLS_BATCHING GET", 16) == 0) |
| 2427 | { |
| 2428 | tANI_U32 remain_len; |
| 2429 | |
| 2430 | if (FALSE == sme_IsFeatureSupportedByFW(BATCH_SCAN)) |
| 2431 | { |
| 2432 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2433 | "%s: Batch scan feature is not supported by FW", __func__); |
| 2434 | ret = -EINVAL; |
| 2435 | goto exit; |
| 2436 | } |
| 2437 | |
| 2438 | if (eHDD_BATCH_SCAN_STATE_STARTED != pAdapter->batchScanState) |
| 2439 | { |
Deepthi Gowri | bfd1713 | 2014-11-14 17:59:04 +0530 | [diff] [blame] | 2440 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 2441 | "Batch scan is not yet enabled could not return results" |
| 2442 | "Batch Scan state %d", |
| 2443 | pAdapter->batchScanState); |
| 2444 | ret = -EINVAL; |
| 2445 | goto exit; |
| 2446 | } |
| 2447 | |
| 2448 | pPrivdata->used_len = 16; |
| 2449 | remain_len = pPrivdata->total_len - pPrivdata->used_len; |
| 2450 | if (remain_len < pPrivdata->total_len) |
| 2451 | { |
| 2452 | /*Clear previous batch scan response data if any*/ |
| 2453 | vos_mem_zero((tANI_U8 *)(command + pPrivdata->used_len), remain_len); |
| 2454 | } |
| 2455 | else |
| 2456 | { |
| 2457 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2458 | "Invalid total length from user space can't fetch batch" |
| 2459 | " scan response total_len %d used_len %d remain len %d", |
| 2460 | pPrivdata->total_len, pPrivdata->used_len, remain_len); |
| 2461 | ret = -EINVAL; |
| 2462 | goto exit; |
| 2463 | } |
| 2464 | ret = hdd_return_batch_scan_rsp_to_user(pAdapter, pPrivdata, command); |
| 2465 | } |
| 2466 | |
| 2467 | exit: |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2468 | EXIT(); |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 2469 | return ret; |
| 2470 | } |
| 2471 | |
| 2472 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 2473 | #endif/*End of FEATURE_WLAN_BATCH_SCAN*/ |
| 2474 | |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 2475 | static void getBcnMissRateCB(VOS_STATUS status, int bcnMissRate, void *data) |
| 2476 | { |
c_hpothu | 39eb1e3 | 2014-06-26 16:31:50 +0530 | [diff] [blame] | 2477 | bcnMissRateContext_t *pCBCtx; |
| 2478 | |
| 2479 | if (NULL == data) |
| 2480 | { |
| 2481 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("argument data is NULL")); |
| 2482 | return; |
| 2483 | } |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 2484 | |
| 2485 | /* there is a race condition that exists between this callback |
| 2486 | function and the caller since the caller could time out either |
| 2487 | before or while this code is executing. we use a spinlock to |
| 2488 | serialize these actions */ |
| 2489 | spin_lock(&hdd_context_lock); |
| 2490 | |
c_hpothu | 39eb1e3 | 2014-06-26 16:31:50 +0530 | [diff] [blame] | 2491 | pCBCtx = (bcnMissRateContext_t *)data; |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 2492 | gbcnMissRate = -1; |
| 2493 | |
c_hpothu | 39eb1e3 | 2014-06-26 16:31:50 +0530 | [diff] [blame] | 2494 | if (pCBCtx->magic != BCN_MISS_RATE_CONTEXT_MAGIC) |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 2495 | { |
| 2496 | hddLog(VOS_TRACE_LEVEL_ERROR, |
c_hpothu | 39eb1e3 | 2014-06-26 16:31:50 +0530 | [diff] [blame] | 2497 | FL("invalid context magic: %08x"), pCBCtx->magic); |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 2498 | spin_unlock(&hdd_context_lock); |
| 2499 | return ; |
| 2500 | } |
| 2501 | |
| 2502 | if (VOS_STATUS_SUCCESS == status) |
| 2503 | { |
c_hpothu | 39eb1e3 | 2014-06-26 16:31:50 +0530 | [diff] [blame] | 2504 | gbcnMissRate = bcnMissRate; |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 2505 | } |
c_hpothu | 39eb1e3 | 2014-06-26 16:31:50 +0530 | [diff] [blame] | 2506 | else |
| 2507 | { |
| 2508 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("failed to get bcnMissRate")); |
| 2509 | } |
| 2510 | |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 2511 | complete(&(pCBCtx->completion)); |
| 2512 | spin_unlock(&hdd_context_lock); |
| 2513 | |
| 2514 | return; |
| 2515 | } |
| 2516 | |
Abhishek Singh | 08aa776 | 2014-12-16 13:59:03 +0530 | [diff] [blame] | 2517 | void hdd_FWStatisCB( VOS_STATUS status, |
| 2518 | tSirFwStatsResult *fwStatsResult, void *pContext ) |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 2519 | { |
| 2520 | fwStatsContext_t *fwStatsCtx; |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 2521 | hdd_adapter_t *pAdapter; |
| 2522 | |
| 2523 | hddLog(VOS_TRACE_LEVEL_INFO, FL(" with status = %d"),status); |
| 2524 | |
Abhishek Singh | 08aa776 | 2014-12-16 13:59:03 +0530 | [diff] [blame] | 2525 | if (NULL == pContext) |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 2526 | { |
| 2527 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("argument data is NULL")); |
| 2528 | return; |
| 2529 | } |
| 2530 | /* there is a race condition that exists between this callback |
| 2531 | function and the caller since the caller could time out either |
| 2532 | before or while this code is executing. we use a spinlock to |
| 2533 | serialize these actions */ |
| 2534 | spin_lock(&hdd_context_lock); |
Abhishek Singh | 08aa776 | 2014-12-16 13:59:03 +0530 | [diff] [blame] | 2535 | fwStatsCtx = (fwStatsContext_t *) pContext; |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 2536 | if (fwStatsCtx->magic != FW_STATS_CONTEXT_MAGIC) |
| 2537 | { |
| 2538 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2539 | FL("invalid context magic: %08x"), fwStatsCtx->magic); |
| 2540 | spin_unlock(&hdd_context_lock); |
| 2541 | return; |
| 2542 | } |
| 2543 | pAdapter = fwStatsCtx->pAdapter; |
| 2544 | if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)) |
| 2545 | { |
| 2546 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2547 | FL("pAdapter returned is NULL or invalid")); |
| 2548 | spin_unlock(&hdd_context_lock); |
| 2549 | return; |
| 2550 | } |
| 2551 | pAdapter->fwStatsRsp.type = 0; |
Abhishek Singh | 08aa776 | 2014-12-16 13:59:03 +0530 | [diff] [blame] | 2552 | if ((VOS_STATUS_SUCCESS == status) && (NULL != fwStatsResult)) |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 2553 | { |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 2554 | switch( fwStatsResult->type ) |
| 2555 | { |
| 2556 | case FW_UBSP_STATS: |
| 2557 | { |
Abhishek Singh | 08aa776 | 2014-12-16 13:59:03 +0530 | [diff] [blame] | 2558 | memcpy(&pAdapter->fwStatsRsp,fwStatsResult,sizeof(tSirFwStatsResult)); |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 2559 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 2560 | FL("ubsp_enter_cnt = %d ubsp_jump_ddr_cnt = %d"), |
Abhishek Singh | 08aa776 | 2014-12-16 13:59:03 +0530 | [diff] [blame] | 2561 | pAdapter->fwStatsRsp.fwStatsData.ubspStats.ubsp_enter_cnt, |
| 2562 | pAdapter->fwStatsRsp.fwStatsData.ubspStats.ubsp_jump_ddr_cnt); |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 2563 | } |
| 2564 | break; |
| 2565 | default: |
| 2566 | { |
| 2567 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2568 | FL(" No handling for stats type %d"),fwStatsResult->type); |
| 2569 | } |
| 2570 | } |
| 2571 | } |
| 2572 | complete(&(fwStatsCtx->completion)); |
| 2573 | spin_unlock(&hdd_context_lock); |
| 2574 | return; |
| 2575 | } |
| 2576 | |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2577 | static int hdd_get_dwell_time(hdd_config_t *pCfg, tANI_U8 *command, char *extra, tANI_U8 n, tANI_U8 *len) |
| 2578 | { |
| 2579 | int ret = 0; |
| 2580 | |
| 2581 | if (!pCfg || !command || !extra || !len) |
| 2582 | { |
| 2583 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2584 | "%s: argument passsed for GETDWELLTIME is incorrect", __func__); |
| 2585 | ret = -EINVAL; |
| 2586 | return ret; |
| 2587 | } |
| 2588 | |
| 2589 | if (strncmp(command, "GETDWELLTIME ACTIVE MAX", 23) == 0) |
| 2590 | { |
| 2591 | *len = scnprintf(extra, n, "GETDWELLTIME ACTIVE MAX %u\n", |
| 2592 | (int)pCfg->nActiveMaxChnTime); |
| 2593 | return ret; |
| 2594 | } |
| 2595 | else if (strncmp(command, "GETDWELLTIME ACTIVE MIN", 23) == 0) |
| 2596 | { |
| 2597 | *len = scnprintf(extra, n, "GETDWELLTIME ACTIVE MIN %u\n", |
| 2598 | (int)pCfg->nActiveMinChnTime); |
| 2599 | return ret; |
| 2600 | } |
| 2601 | else if (strncmp(command, "GETDWELLTIME PASSIVE MAX", 24) == 0) |
| 2602 | { |
| 2603 | *len = scnprintf(extra, n, "GETDWELLTIME PASSIVE MAX %u\n", |
| 2604 | (int)pCfg->nPassiveMaxChnTime); |
| 2605 | return ret; |
| 2606 | } |
| 2607 | else if (strncmp(command, "GETDWELLTIME PASSIVE MIN", 24) == 0) |
| 2608 | { |
| 2609 | *len = scnprintf(extra, n, "GETDWELLTIME PASSIVE MIN %u\n", |
| 2610 | (int)pCfg->nPassiveMinChnTime); |
| 2611 | return ret; |
| 2612 | } |
Rajesh Babu Prathipati | 0fd227e | 2014-07-05 12:50:00 +0530 | [diff] [blame] | 2613 | else if (strncmp(command, "GETDWELLTIME", 12) == 0) |
| 2614 | { |
| 2615 | *len = scnprintf(extra, n, "GETDWELLTIME %u \n", |
| 2616 | (int)pCfg->nActiveMaxChnTime); |
| 2617 | return ret; |
| 2618 | } |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2619 | else |
| 2620 | { |
| 2621 | ret = -EINVAL; |
| 2622 | } |
| 2623 | |
| 2624 | return ret; |
| 2625 | } |
| 2626 | |
| 2627 | static int hdd_set_dwell_time(hdd_adapter_t *pAdapter, tANI_U8 *command) |
| 2628 | { |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 2629 | tHalHandle hHal; |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2630 | hdd_config_t *pCfg; |
| 2631 | tANI_U8 *value = command; |
| 2632 | int val = 0, ret = 0, temp = 0; |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 2633 | tSmeConfigParams smeConfig; |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2634 | |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 2635 | if (!pAdapter || !command || !(pCfg = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini) |
| 2636 | || !(hHal = (WLAN_HDD_GET_HAL_CTX(pAdapter)))) |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2637 | { |
| 2638 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2639 | "%s: argument passed for SETDWELLTIME is incorrect", __func__); |
| 2640 | ret = -EINVAL; |
| 2641 | return ret; |
| 2642 | } |
| 2643 | |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 2644 | vos_mem_zero(&smeConfig, sizeof(smeConfig)); |
| 2645 | sme_GetConfigParam(hHal, &smeConfig); |
| 2646 | |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2647 | if (strncmp(command, "SETDWELLTIME ACTIVE MAX", 23) == 0 ) |
| 2648 | { |
| 2649 | value = value + 24; |
| 2650 | temp = kstrtou32(value, 10, &val); |
| 2651 | if (temp != 0 || val < CFG_ACTIVE_MAX_CHANNEL_TIME_MIN || |
| 2652 | val > CFG_ACTIVE_MAX_CHANNEL_TIME_MAX ) |
| 2653 | { |
| 2654 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2655 | "%s: argument passed for SETDWELLTIME ACTIVE MAX is incorrect", __func__); |
| 2656 | ret = -EFAULT; |
| 2657 | return ret; |
| 2658 | } |
| 2659 | pCfg->nActiveMaxChnTime = val; |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 2660 | smeConfig.csrConfig.nActiveMaxChnTime = val; |
| 2661 | sme_UpdateConfig(hHal, &smeConfig); |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2662 | } |
| 2663 | else if (strncmp(command, "SETDWELLTIME ACTIVE MIN", 23) == 0) |
| 2664 | { |
| 2665 | value = value + 24; |
| 2666 | temp = kstrtou32(value, 10, &val); |
| 2667 | if (temp !=0 || val < CFG_ACTIVE_MIN_CHANNEL_TIME_MIN || |
| 2668 | val > CFG_ACTIVE_MIN_CHANNEL_TIME_MAX ) |
| 2669 | { |
| 2670 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2671 | "%s: argument passsed for SETDWELLTIME ACTIVE MIN is incorrect", __func__); |
| 2672 | ret = -EFAULT; |
| 2673 | return ret; |
| 2674 | } |
| 2675 | pCfg->nActiveMinChnTime = val; |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 2676 | smeConfig.csrConfig.nActiveMinChnTime = val; |
| 2677 | sme_UpdateConfig(hHal, &smeConfig); |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2678 | } |
| 2679 | else if (strncmp(command, "SETDWELLTIME PASSIVE MAX", 24) == 0) |
| 2680 | { |
| 2681 | value = value + 25; |
| 2682 | temp = kstrtou32(value, 10, &val); |
| 2683 | if (temp != 0 || val < CFG_PASSIVE_MAX_CHANNEL_TIME_MIN || |
| 2684 | val > CFG_PASSIVE_MAX_CHANNEL_TIME_MAX ) |
| 2685 | { |
| 2686 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2687 | "%s: argument passed for SETDWELLTIME PASSIVE MAX is incorrect", __func__); |
| 2688 | ret = -EFAULT; |
| 2689 | return ret; |
| 2690 | } |
| 2691 | pCfg->nPassiveMaxChnTime = val; |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 2692 | smeConfig.csrConfig.nPassiveMaxChnTime = val; |
| 2693 | sme_UpdateConfig(hHal, &smeConfig); |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2694 | } |
| 2695 | else if (strncmp(command, "SETDWELLTIME PASSIVE MIN", 24) == 0) |
| 2696 | { |
| 2697 | value = value + 25; |
| 2698 | temp = kstrtou32(value, 10, &val); |
| 2699 | if (temp != 0 || val < CFG_PASSIVE_MIN_CHANNEL_TIME_MIN || |
| 2700 | val > CFG_PASSIVE_MIN_CHANNEL_TIME_MAX ) |
| 2701 | { |
| 2702 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2703 | "%s: argument passed for SETDWELLTIME PASSIVE MIN is incorrect", __func__); |
| 2704 | ret = -EFAULT; |
| 2705 | return ret; |
| 2706 | } |
| 2707 | pCfg->nPassiveMinChnTime = val; |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 2708 | smeConfig.csrConfig.nPassiveMinChnTime = val; |
| 2709 | sme_UpdateConfig(hHal, &smeConfig); |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2710 | } |
Rajesh Babu Prathipati | 0fd227e | 2014-07-05 12:50:00 +0530 | [diff] [blame] | 2711 | else if (strncmp(command, "SETDWELLTIME", 12) == 0) |
| 2712 | { |
| 2713 | value = value + 13; |
| 2714 | temp = kstrtou32(value, 10, &val); |
| 2715 | if (temp != 0 || val < CFG_ACTIVE_MAX_CHANNEL_TIME_MIN || |
| 2716 | val > CFG_ACTIVE_MAX_CHANNEL_TIME_MAX ) |
| 2717 | { |
| 2718 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2719 | "%s: argument passed for SETDWELLTIME is incorrect", __func__); |
| 2720 | ret = -EFAULT; |
| 2721 | return ret; |
| 2722 | } |
| 2723 | pCfg->nActiveMaxChnTime = val; |
| 2724 | smeConfig.csrConfig.nActiveMaxChnTime = val; |
| 2725 | sme_UpdateConfig(hHal, &smeConfig); |
| 2726 | } |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2727 | else |
| 2728 | { |
| 2729 | ret = -EINVAL; |
| 2730 | } |
| 2731 | |
| 2732 | return ret; |
| 2733 | } |
Agarwal Ashish | 8bd53ae | 2015-06-12 18:03:45 +0530 | [diff] [blame] | 2734 | static int hdd_cmd_setFccChannel(hdd_context_t *pHddCtx, tANI_U8 *cmd, |
| 2735 | tANI_U8 cmd_len) |
| 2736 | { |
| 2737 | tANI_U8 *value; |
| 2738 | tANI_U8 fcc_constraint; |
| 2739 | |
| 2740 | eHalStatus status; |
| 2741 | int ret = 0; |
| 2742 | value = cmd + cmd_len + 1; |
| 2743 | |
| 2744 | ret = kstrtou8(value, 10, &fcc_constraint); |
| 2745 | if ((ret < 0) || (fcc_constraint > 1)) { |
| 2746 | /* |
| 2747 | * If the input value is greater than max value of datatype, |
| 2748 | * then also it is a failure |
| 2749 | */ |
| 2750 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2751 | "%s: value out of range", __func__); |
| 2752 | return -EINVAL; |
| 2753 | } |
| 2754 | |
| 2755 | status = sme_handleSetFccChannel(pHddCtx->hHal, fcc_constraint); |
| 2756 | if (status != eHAL_STATUS_SUCCESS) |
| 2757 | ret = -EPERM; |
| 2758 | |
| 2759 | return ret; |
| 2760 | } |
| 2761 | |
Mahesh A Saptasagar | beca12c | 2015-09-07 16:21:06 +0530 | [diff] [blame] | 2762 | /**--------------------------------------------------------------------------- |
Agarwal Ashish | 8bd53ae | 2015-06-12 18:03:45 +0530 | [diff] [blame] | 2763 | |
Mahesh A Saptasagar | beca12c | 2015-09-07 16:21:06 +0530 | [diff] [blame] | 2764 | \brief hdd_enable_disable_ca_event() - When Host sends IOCTL (enabled), |
| 2765 | FW will send *ONE* CA ind to Host(even though it is duplicate). |
| 2766 | When Host send IOCTL (disable), FW doesn't perform any action. |
| 2767 | Whenever any change in CA *and* WLAN is in SAP/P2P-GO mode, FW |
| 2768 | sends CA ind to host. (regard less of IOCTL status) |
| 2769 | \param - pHddCtx - HDD context |
| 2770 | \param - command - command received from framework |
| 2771 | \param - cmd_len - len of the command |
| 2772 | |
| 2773 | \return - 0 on success, appropriate error values on failure. |
| 2774 | |
| 2775 | --------------------------------------------------------------------------*/ |
| 2776 | int hdd_enable_disable_ca_event(hdd_context_t *pHddCtx, tANI_U8* command, tANI_U8 cmd_len) |
| 2777 | { |
| 2778 | tANI_U8 set_value; |
| 2779 | int ret = 0; |
| 2780 | eHalStatus status; |
| 2781 | |
| 2782 | ret = wlan_hdd_validate_context(pHddCtx); |
| 2783 | if (0 != ret) |
| 2784 | { |
| 2785 | ret = -EINVAL; |
| 2786 | goto exit; |
| 2787 | } |
| 2788 | |
| 2789 | if (pHddCtx->cfg_ini->gOptimizeCAevent == 0) |
| 2790 | { |
| 2791 | hddLog(VOS_TRACE_LEVEL_ERROR, "Enable gOptimizeCAevent" |
| 2792 | " ini param to control channel avooidance indication"); |
| 2793 | ret = 0; |
| 2794 | goto exit; |
| 2795 | } |
| 2796 | |
| 2797 | set_value = command[cmd_len + 1] - '0'; |
| 2798 | status = sme_enableDisableChanAvoidIndEvent(pHddCtx->hHal, set_value); |
| 2799 | if (status != eHAL_STATUS_SUCCESS) |
| 2800 | { |
| 2801 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failed to send" |
| 2802 | " enableDisableChanAoidance command to SME\n", __func__); |
| 2803 | ret = -EINVAL; |
| 2804 | } |
| 2805 | |
| 2806 | exit: |
| 2807 | return ret; |
| 2808 | } |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2809 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2810 | static int hdd_driver_command(hdd_adapter_t *pAdapter, |
| 2811 | hdd_priv_data_t *ppriv_data) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2812 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2813 | hdd_priv_data_t priv_data; |
| 2814 | tANI_U8 *command = NULL; |
Kaushik, Sushant | 9612244 | 2014-10-21 16:40:18 +0530 | [diff] [blame] | 2815 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2816 | hdd_scaninfo_t *pScanInfo = NULL; |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2817 | int ret = 0; |
Kaushik, Sushant | 9612244 | 2014-10-21 16:40:18 +0530 | [diff] [blame] | 2818 | int status; |
Anand N Sunkad | e9adb1b | 2015-07-29 09:56:45 +0530 | [diff] [blame] | 2819 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) |
| 2820 | struct cfg80211_mgmt_tx_params params; |
| 2821 | #endif |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2822 | |
| 2823 | ENTER(); |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2824 | /* |
| 2825 | * Note that valid pointers are provided by caller |
| 2826 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2827 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2828 | /* copy to local struct to avoid numerous changes to legacy code */ |
| 2829 | priv_data = *ppriv_data; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2830 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2831 | if (priv_data.total_len <= 0 || |
| 2832 | priv_data.total_len > WLAN_PRIV_DATA_MAX_LEN) |
Sameer Thalappil | 8ef3a0e | 2013-04-05 14:36:04 -0700 | [diff] [blame] | 2833 | { |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2834 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 2835 | "%s:invalid priv_data.total_len(%d)!!!", __func__, |
| 2836 | priv_data.total_len); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 2837 | ret = -EINVAL; |
| 2838 | goto exit; |
| 2839 | } |
Kaushik, Sushant | 9612244 | 2014-10-21 16:40:18 +0530 | [diff] [blame] | 2840 | status = wlan_hdd_validate_context(pHddCtx); |
| 2841 | if (0 != status) |
| 2842 | { |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2843 | ret = -EINVAL; |
| 2844 | goto exit; |
Kaushik, Sushant | 9612244 | 2014-10-21 16:40:18 +0530 | [diff] [blame] | 2845 | } |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 2846 | /* Allocate +1 for '\0' */ |
| 2847 | command = kmalloc(priv_data.total_len + 1, GFP_KERNEL); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2848 | if (!command) |
| 2849 | { |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2850 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2851 | "%s: failed to allocate memory", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2852 | ret = -ENOMEM; |
| 2853 | goto exit; |
| 2854 | } |
| 2855 | |
| 2856 | if (copy_from_user(command, priv_data.buf, priv_data.total_len)) |
| 2857 | { |
| 2858 | ret = -EFAULT; |
| 2859 | goto exit; |
| 2860 | } |
| 2861 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2862 | /* Make sure the command is NUL-terminated */ |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 2863 | command[priv_data.total_len] = '\0'; |
| 2864 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2865 | /* at one time the following block of code was conditional. braces |
| 2866 | * have been retained to avoid re-indenting the legacy code |
| 2867 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2868 | { |
| 2869 | hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx; |
| 2870 | |
| 2871 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | f9bdd4e | 2012-10-30 18:05:03 -0700 | [diff] [blame] | 2872 | "%s: Received %s cmd from Wi-Fi GUI***", __func__, command); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2873 | |
| 2874 | if (strncmp(command, "P2P_DEV_ADDR", 12) == 0 ) |
| 2875 | { |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2876 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2877 | TRACE_CODE_HDD_P2P_DEV_ADDR_IOCTL, |
| 2878 | pAdapter->sessionId, (unsigned) |
| 2879 | (*(pHddCtx->p2pDeviceAddress.bytes+2)<<24 | |
| 2880 | *(pHddCtx->p2pDeviceAddress.bytes+3)<<16 | |
| 2881 | *(pHddCtx->p2pDeviceAddress.bytes+4)<<8 | |
| 2882 | *(pHddCtx->p2pDeviceAddress.bytes+5)))); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2883 | if (copy_to_user(priv_data.buf, pHddCtx->p2pDeviceAddress.bytes, |
| 2884 | sizeof(tSirMacAddr))) |
| 2885 | { |
| 2886 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2887 | "%s: failed to copy data to user buffer", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2888 | ret = -EFAULT; |
| 2889 | } |
| 2890 | } |
Amar Singhal | 0974e40 | 2013-02-12 14:27:46 -0800 | [diff] [blame] | 2891 | else if(strncmp(command, "SETBAND", 7) == 0) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2892 | { |
Amar Singhal | 0974e40 | 2013-02-12 14:27:46 -0800 | [diff] [blame] | 2893 | tANI_U8 *ptr = command ; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2894 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2895 | /* Change band request received */ |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2896 | |
| 2897 | /* First 8 bytes will have "SETBAND " and |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2898 | * 9 byte will have band setting value */ |
Madan Mohan Koyyalamudi | 8bdd311 | 2012-09-24 13:55:14 -0700 | [diff] [blame] | 2899 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Amar Singhal | 0974e40 | 2013-02-12 14:27:46 -0800 | [diff] [blame] | 2900 | "%s: SetBandCommand Info comm %s UL %d, TL %d", __func__, command, priv_data.used_len, priv_data.total_len); |
Anand N Sunkad | 27354cf | 2015-07-13 14:39:11 +0530 | [diff] [blame] | 2901 | if(VOS_FTM_MODE != hdd_get_conparam()) |
| 2902 | { |
| 2903 | /* Change band request received */ |
| 2904 | ret = hdd_setBand_helper(pAdapter->dev, ptr); |
| 2905 | if(ret < 0) |
| 2906 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 2907 | "%s: failed to set band ret=%d", __func__, ret); |
| 2908 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2909 | } |
Kiet Lam | f040f47 | 2013-11-20 21:15:23 +0530 | [diff] [blame] | 2910 | else if(strncmp(command, "SETWMMPS", 8) == 0) |
| 2911 | { |
| 2912 | tANI_U8 *ptr = command; |
| 2913 | ret = hdd_wmmps_helper(pAdapter, ptr); |
| 2914 | } |
Agarwal Ashish | ef54a18 | 2014-12-16 15:07:31 +0530 | [diff] [blame] | 2915 | |
| 2916 | else if(strncmp(command, "TDLSSCAN", 8) == 0) |
| 2917 | { |
| 2918 | tANI_U8 *ptr = command; |
| 2919 | ret = hdd_set_tdls_scan_type(pAdapter, ptr); |
| 2920 | } |
| 2921 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2922 | else if ( strncasecmp(command, "COUNTRY", 7) == 0 ) |
| 2923 | { |
| 2924 | char *country_code; |
| 2925 | |
| 2926 | country_code = command + 8; |
Tushnim Bhattacharyya | 9cdf608 | 2013-04-21 16:33:30 -0700 | [diff] [blame] | 2927 | |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 2928 | INIT_COMPLETION(pAdapter->change_country_code); |
Tushnim Bhattacharyya | 9cdf608 | 2013-04-21 16:33:30 -0700 | [diff] [blame] | 2929 | hdd_checkandupdate_dfssetting(pAdapter, country_code); |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 2930 | #ifndef CONFIG_ENABLE_LINUX_REG |
Gopichand Nakkala | dacbcb5 | 2013-04-18 16:41:54 +0530 | [diff] [blame] | 2931 | hdd_checkandupdate_phymode(pAdapter, country_code); |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 2932 | #endif |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 2933 | ret = (int)sme_ChangeCountryCode(pHddCtx->hHal, |
| 2934 | (void *)(tSmeChangeCountryCallback) |
| 2935 | wlan_hdd_change_country_code_callback, |
Abhishek Singh | a306a44 | 2013-11-07 18:39:01 +0530 | [diff] [blame] | 2936 | country_code, pAdapter, pHddCtx->pvosContext, eSIR_TRUE, eSIR_TRUE); |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 2937 | if (eHAL_STATUS_SUCCESS == ret) |
| 2938 | { |
| 2939 | ret = wait_for_completion_interruptible_timeout( |
| 2940 | &pAdapter->change_country_code, |
| 2941 | msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY)); |
| 2942 | if (0 >= ret) |
| 2943 | { |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2944 | 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] | 2945 | __func__, ret); |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 2946 | } |
| 2947 | } |
| 2948 | else |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2949 | { |
| 2950 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 2951 | "%s: SME Change Country code fail ret=%d", __func__, ret); |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 2952 | ret = -EINVAL; |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2953 | } |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 2954 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 2955 | } |
| 2956 | /* |
| 2957 | command should be a string having format |
| 2958 | SET_SAP_CHANNEL_LIST <num of channels> <the channels seperated by spaces> |
| 2959 | */ |
Amar Singhal | 0974e40 | 2013-02-12 14:27:46 -0800 | [diff] [blame] | 2960 | else if(strncmp(command, "SET_SAP_CHANNEL_LIST", 20) == 0) |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 2961 | { |
Amar Singhal | 0974e40 | 2013-02-12 14:27:46 -0800 | [diff] [blame] | 2962 | tANI_U8 *ptr = command; |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 2963 | |
| 2964 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 2965 | " Received Command to Set Preferred Channels for SAP in %s", __func__); |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 2966 | |
Mahesh Kumar Kalikot Veetil | 2aad8d8 | 2013-02-07 12:31:28 -0800 | [diff] [blame] | 2967 | ret = sapSetPreferredChannel(ptr); |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2968 | } |
Sameer Thalappil | 45931fb | 2013-02-01 11:18:05 -0800 | [diff] [blame] | 2969 | else if(strncmp(command, "SETSUSPENDMODE", 14) == 0) |
| 2970 | { |
| 2971 | int suspend = 0; |
| 2972 | tANI_U8 *ptr = (tANI_U8*)command + 15; |
| 2973 | |
| 2974 | suspend = *ptr - '0'; |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 2975 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 2976 | TRACE_CODE_HDD_SETSUSPENDMODE_IOCTL, |
| 2977 | pAdapter->sessionId, suspend)); |
Sameer Thalappil | 45931fb | 2013-02-01 11:18:05 -0800 | [diff] [blame] | 2978 | hdd_set_wlan_suspend_mode(suspend); |
| 2979 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2980 | #ifdef WLAN_FEATURE_NEIGHBOR_ROAMING |
| 2981 | else if (strncmp(command, "SETROAMTRIGGER", 14) == 0) |
| 2982 | { |
| 2983 | tANI_U8 *value = command; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2984 | tANI_S8 rssi = 0; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 2985 | tANI_U8 lookUpThreshold = CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_DEFAULT; |
| 2986 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 2987 | |
| 2988 | /* Move pointer to ahead of SETROAMTRIGGER<delimiter> */ |
| 2989 | value = value + 15; |
| 2990 | |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 2991 | /* Convert the value from ascii to integer */ |
| 2992 | ret = kstrtos8(value, 10, &rssi); |
| 2993 | if (ret < 0) |
| 2994 | { |
| 2995 | /* If the input value is greater than max value of datatype, then also |
| 2996 | kstrtou8 fails */ |
| 2997 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2998 | "%s: kstrtou8 failed Input value may be out of range[%d - %d]", |
Srinivas Girigowda | fa7157d | 2013-10-31 10:14:22 -0700 | [diff] [blame] | 2999 | __func__, |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 3000 | CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MIN, |
| 3001 | CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MAX); |
| 3002 | ret = -EINVAL; |
| 3003 | goto exit; |
| 3004 | } |
| 3005 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3006 | lookUpThreshold = abs(rssi); |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 3007 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3008 | if ((lookUpThreshold < CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MIN) || |
| 3009 | (lookUpThreshold > CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MAX)) |
| 3010 | { |
| 3011 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3012 | "Neighbor lookup threshold value %d is out of range" |
| 3013 | " (Min: %d Max: %d)", lookUpThreshold, |
| 3014 | CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MIN, |
| 3015 | CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MAX); |
| 3016 | ret = -EINVAL; |
| 3017 | goto exit; |
| 3018 | } |
| 3019 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 3020 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 3021 | TRACE_CODE_HDD_SETROAMTRIGGER_IOCTL, |
| 3022 | pAdapter->sessionId, lookUpThreshold)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3023 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3024 | "%s: Received Command to Set Roam trigger" |
| 3025 | " (Neighbor lookup threshold) = %d", __func__, lookUpThreshold); |
| 3026 | |
| 3027 | pHddCtx->cfg_ini->nNeighborLookupRssiThreshold = lookUpThreshold; |
| 3028 | status = sme_setNeighborLookupRssiThreshold((tHalHandle)(pHddCtx->hHal), lookUpThreshold); |
| 3029 | if (eHAL_STATUS_SUCCESS != status) |
| 3030 | { |
| 3031 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3032 | "%s: Failed to set roam trigger, try again", __func__); |
| 3033 | ret = -EPERM; |
| 3034 | goto exit; |
| 3035 | } |
| 3036 | |
| 3037 | /* Set Reassoc threshold to (lookup rssi threshold + 5 dBm) */ |
mukul sharma | d6e1fdd | 2014-06-23 19:19:09 +0530 | [diff] [blame] | 3038 | pHddCtx->cfg_ini->nNeighborReassocRssiThreshold = lookUpThreshold + 5; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3039 | sme_setNeighborReassocRssiThreshold((tHalHandle)(pHddCtx->hHal), lookUpThreshold + 5); |
| 3040 | } |
| 3041 | else if (strncmp(command, "GETROAMTRIGGER", 14) == 0) |
| 3042 | { |
| 3043 | tANI_U8 lookUpThreshold = sme_getNeighborLookupRssiThreshold((tHalHandle)(pHddCtx->hHal)); |
| 3044 | int rssi = (-1) * lookUpThreshold; |
| 3045 | char extra[32]; |
| 3046 | tANI_U8 len = 0; |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 3047 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 3048 | TRACE_CODE_HDD_GETROAMTRIGGER_IOCTL, |
| 3049 | pAdapter->sessionId, lookUpThreshold)); |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3050 | len = scnprintf(extra, sizeof(extra), "%s %d", command, rssi); |
Srinivas Girigowda | 9171923 | 2015-07-13 15:10:10 +0530 | [diff] [blame] | 3051 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 3052 | if (copy_to_user(priv_data.buf, &extra, len)) |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3053 | { |
| 3054 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3055 | "%s: failed to copy data to user buffer", __func__); |
| 3056 | ret = -EFAULT; |
| 3057 | goto exit; |
| 3058 | } |
| 3059 | } |
| 3060 | else if (strncmp(command, "SETROAMSCANPERIOD", 17) == 0) |
| 3061 | { |
| 3062 | tANI_U8 *value = command; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 3063 | tANI_U8 roamScanPeriod = 0; |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3064 | tANI_U16 neighborEmptyScanRefreshPeriod = CFG_EMPTY_SCAN_REFRESH_PERIOD_DEFAULT; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 3065 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3066 | /* input refresh period is in terms of seconds */ |
| 3067 | /* Move pointer to ahead of SETROAMSCANPERIOD<delimiter> */ |
| 3068 | value = value + 18; |
| 3069 | /* Convert the value from ascii to integer */ |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 3070 | ret = kstrtou8(value, 10, &roamScanPeriod); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3071 | if (ret < 0) |
| 3072 | { |
| 3073 | /* 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] | 3074 | kstrtou8 fails */ |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3075 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 3076 | "%s: kstrtou8 failed Input value may be out of range[%d - %d]", |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3077 | __func__, |
Srinivas Girigowda | b8edd1e | 2013-03-19 11:42:08 -0700 | [diff] [blame] | 3078 | (CFG_EMPTY_SCAN_REFRESH_PERIOD_MIN/1000), |
| 3079 | (CFG_EMPTY_SCAN_REFRESH_PERIOD_MAX/1000)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3080 | ret = -EINVAL; |
| 3081 | goto exit; |
| 3082 | } |
| 3083 | |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 3084 | if ((roamScanPeriod < (CFG_EMPTY_SCAN_REFRESH_PERIOD_MIN/1000)) || |
| 3085 | (roamScanPeriod > (CFG_EMPTY_SCAN_REFRESH_PERIOD_MAX/1000))) |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3086 | { |
| 3087 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 3088 | "Roam scan period value %d is out of range" |
| 3089 | " (Min: %d Max: %d)", roamScanPeriod, |
Srinivas Girigowda | b8edd1e | 2013-03-19 11:42:08 -0700 | [diff] [blame] | 3090 | (CFG_EMPTY_SCAN_REFRESH_PERIOD_MIN/1000), |
| 3091 | (CFG_EMPTY_SCAN_REFRESH_PERIOD_MAX/1000)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3092 | ret = -EINVAL; |
| 3093 | goto exit; |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 3094 | } |
| 3095 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 3096 | TRACE_CODE_HDD_SETROAMSCANPERIOD_IOCTL, |
| 3097 | pAdapter->sessionId, roamScanPeriod)); |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 3098 | neighborEmptyScanRefreshPeriod = roamScanPeriod * 1000; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3099 | |
| 3100 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3101 | "%s: Received Command to Set roam scan period" |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 3102 | " (Empty Scan refresh period) = %d", __func__, roamScanPeriod); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3103 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3104 | pHddCtx->cfg_ini->nEmptyScanRefreshPeriod = neighborEmptyScanRefreshPeriod; |
| 3105 | sme_UpdateEmptyScanRefreshPeriod((tHalHandle)(pHddCtx->hHal), neighborEmptyScanRefreshPeriod); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3106 | } |
| 3107 | else if (strncmp(command, "GETROAMSCANPERIOD", 17) == 0) |
| 3108 | { |
| 3109 | tANI_U16 nEmptyScanRefreshPeriod = sme_getEmptyScanRefreshPeriod((tHalHandle)(pHddCtx->hHal)); |
| 3110 | char extra[32]; |
| 3111 | tANI_U8 len = 0; |
| 3112 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 3113 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 3114 | TRACE_CODE_HDD_GETROAMSCANPERIOD_IOCTL, |
| 3115 | pAdapter->sessionId, nEmptyScanRefreshPeriod)); |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3116 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3117 | "GETROAMSCANPERIOD", (nEmptyScanRefreshPeriod/1000)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3118 | /* Returned value is in units of seconds */ |
Ratnam Rachuri | a72ba11 | 2015-07-17 13:27:03 +0530 | [diff] [blame] | 3119 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 3120 | if (copy_to_user(priv_data.buf, &extra, len)) { |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3121 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3122 | "%s: failed to copy data to user buffer", __func__); |
| 3123 | ret = -EFAULT; |
| 3124 | goto exit; |
| 3125 | } |
| 3126 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3127 | else if (strncmp(command, "SETROAMSCANREFRESHPERIOD", 24) == 0) |
| 3128 | { |
| 3129 | tANI_U8 *value = command; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 3130 | tANI_U8 roamScanRefreshPeriod = 0; |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3131 | tANI_U16 neighborScanRefreshPeriod = CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_DEFAULT; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 3132 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3133 | /* input refresh period is in terms of seconds */ |
| 3134 | /* Move pointer to ahead of SETROAMSCANREFRESHPERIOD<delimiter> */ |
| 3135 | value = value + 25; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 3136 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3137 | /* Convert the value from ascii to integer */ |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 3138 | ret = kstrtou8(value, 10, &roamScanRefreshPeriod); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3139 | if (ret < 0) |
| 3140 | { |
| 3141 | /* 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] | 3142 | kstrtou8 fails */ |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3143 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 3144 | "%s: kstrtou8 failed Input value may be out of range[%d - %d]", |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3145 | __func__, |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3146 | (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MIN/1000), |
| 3147 | (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MAX/1000)); |
| 3148 | ret = -EINVAL; |
| 3149 | goto exit; |
| 3150 | } |
| 3151 | |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 3152 | if ((roamScanRefreshPeriod < (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MIN/1000)) || |
| 3153 | (roamScanRefreshPeriod > (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MAX/1000))) |
| 3154 | { |
| 3155 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3156 | "Neighbor scan results refresh period value %d is out of range" |
| 3157 | " (Min: %d Max: %d)", roamScanRefreshPeriod, |
| 3158 | (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MIN/1000), |
| 3159 | (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MAX/1000)); |
| 3160 | ret = -EINVAL; |
| 3161 | goto exit; |
| 3162 | } |
| 3163 | neighborScanRefreshPeriod = roamScanRefreshPeriod * 1000; |
| 3164 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3165 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3166 | "%s: Received Command to Set roam scan refresh period" |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 3167 | " (Scan refresh period) = %d", __func__, roamScanRefreshPeriod); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3168 | |
| 3169 | pHddCtx->cfg_ini->nNeighborResultsRefreshPeriod = neighborScanRefreshPeriod; |
| 3170 | sme_setNeighborScanRefreshPeriod((tHalHandle)(pHddCtx->hHal), neighborScanRefreshPeriod); |
| 3171 | } |
| 3172 | else if (strncmp(command, "GETROAMSCANREFRESHPERIOD", 24) == 0) |
| 3173 | { |
| 3174 | tANI_U16 value = sme_getNeighborScanRefreshPeriod((tHalHandle)(pHddCtx->hHal)); |
| 3175 | char extra[32]; |
| 3176 | tANI_U8 len = 0; |
| 3177 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3178 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3179 | "GETROAMSCANREFRESHPERIOD", (value/1000)); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3180 | /* Returned value is in units of seconds */ |
Ratnam Rachuri | 2c9d670 | 2015-07-17 13:25:16 +0530 | [diff] [blame] | 3181 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 3182 | if (copy_to_user(priv_data.buf, &extra, len)) { |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3183 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3184 | "%s: failed to copy data to user buffer", __func__); |
| 3185 | ret = -EFAULT; |
| 3186 | goto exit; |
| 3187 | } |
| 3188 | } |
Varun Reddy Yeturu | 6d99ac8 | 2013-05-08 14:15:35 -0700 | [diff] [blame] | 3189 | #ifdef FEATURE_WLAN_LFR |
| 3190 | /* SETROAMMODE */ |
| 3191 | else if (strncmp(command, "SETROAMMODE", SIZE_OF_SETROAMMODE) == 0) |
| 3192 | { |
| 3193 | tANI_U8 *value = command; |
| 3194 | tANI_BOOLEAN roamMode = CFG_LFR_FEATURE_ENABLED_DEFAULT; |
| 3195 | |
| 3196 | /* Move pointer to ahead of SETROAMMODE<delimiter> */ |
| 3197 | value = value + SIZE_OF_SETROAMMODE + 1; |
| 3198 | |
| 3199 | /* Convert the value from ascii to integer */ |
| 3200 | ret = kstrtou8(value, SIZE_OF_SETROAMMODE, &roamMode); |
| 3201 | if (ret < 0) |
| 3202 | { |
| 3203 | /* If the input value is greater than max value of datatype, then also |
| 3204 | kstrtou8 fails */ |
| 3205 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3206 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3207 | CFG_LFR_FEATURE_ENABLED_MIN, |
| 3208 | CFG_LFR_FEATURE_ENABLED_MAX); |
| 3209 | ret = -EINVAL; |
| 3210 | goto exit; |
| 3211 | } |
| 3212 | if ((roamMode < CFG_LFR_FEATURE_ENABLED_MIN) || |
| 3213 | (roamMode > CFG_LFR_FEATURE_ENABLED_MAX)) |
| 3214 | { |
| 3215 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3216 | "Roam Mode value %d is out of range" |
| 3217 | " (Min: %d Max: %d)", roamMode, |
| 3218 | CFG_LFR_FEATURE_ENABLED_MIN, |
| 3219 | CFG_LFR_FEATURE_ENABLED_MAX); |
| 3220 | ret = -EINVAL; |
| 3221 | goto exit; |
| 3222 | } |
| 3223 | |
| 3224 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3225 | "%s: Received Command to Set Roam Mode = %d", __func__, roamMode); |
| 3226 | /* |
| 3227 | * Note that |
| 3228 | * SETROAMMODE 0 is to enable LFR while |
| 3229 | * SETROAMMODE 1 is to disable LFR, but |
| 3230 | * NotifyIsFastRoamIniFeatureEnabled 0/1 is to enable/disable. |
| 3231 | * So, we have to invert the value to call sme_UpdateIsFastRoamIniFeatureEnabled. |
| 3232 | */ |
| 3233 | if (CFG_LFR_FEATURE_ENABLED_MIN == roamMode) |
| 3234 | roamMode = CFG_LFR_FEATURE_ENABLED_MAX; /* Roam enable */ |
| 3235 | else |
| 3236 | roamMode = CFG_LFR_FEATURE_ENABLED_MIN; /* Roam disable */ |
| 3237 | |
| 3238 | pHddCtx->cfg_ini->isFastRoamIniFeatureEnabled = roamMode; |
| 3239 | sme_UpdateIsFastRoamIniFeatureEnabled((tHalHandle)(pHddCtx->hHal), roamMode); |
| 3240 | } |
| 3241 | /* GETROAMMODE */ |
Mahesh A Saptasagar | ec7d109 | 2015-04-02 13:41:34 +0530 | [diff] [blame] | 3242 | else if (strncmp(command, "GETROAMMODE", SIZE_OF_GETROAMMODE) == 0) |
Varun Reddy Yeturu | 6d99ac8 | 2013-05-08 14:15:35 -0700 | [diff] [blame] | 3243 | { |
| 3244 | tANI_BOOLEAN roamMode = sme_getIsLfrFeatureEnabled((tHalHandle)(pHddCtx->hHal)); |
| 3245 | char extra[32]; |
| 3246 | tANI_U8 len = 0; |
| 3247 | |
| 3248 | /* |
| 3249 | * roamMode value shall be inverted because the sementics is different. |
| 3250 | */ |
| 3251 | if (CFG_LFR_FEATURE_ENABLED_MIN == roamMode) |
| 3252 | roamMode = CFG_LFR_FEATURE_ENABLED_MAX; |
| 3253 | else |
| 3254 | roamMode = CFG_LFR_FEATURE_ENABLED_MIN; |
| 3255 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3256 | len = scnprintf(extra, sizeof(extra), "%s %d", command, roamMode); |
Ratnam Rachuri | 28693eb | 2015-07-17 13:23:42 +0530 | [diff] [blame] | 3257 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 3258 | if (copy_to_user(priv_data.buf, &extra, len)) { |
Varun Reddy Yeturu | 6d99ac8 | 2013-05-08 14:15:35 -0700 | [diff] [blame] | 3259 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3260 | "%s: failed to copy data to user buffer", __func__); |
| 3261 | ret = -EFAULT; |
| 3262 | goto exit; |
| 3263 | } |
| 3264 | } |
| 3265 | #endif |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3266 | #endif |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3267 | #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] | 3268 | else if (strncmp(command, "SETROAMDELTA", 12) == 0) |
| 3269 | { |
| 3270 | tANI_U8 *value = command; |
| 3271 | tANI_U8 roamRssiDiff = CFG_ROAM_RSSI_DIFF_DEFAULT; |
| 3272 | |
| 3273 | /* Move pointer to ahead of SETROAMDELTA<delimiter> */ |
| 3274 | value = value + 13; |
| 3275 | /* Convert the value from ascii to integer */ |
| 3276 | ret = kstrtou8(value, 10, &roamRssiDiff); |
| 3277 | if (ret < 0) |
| 3278 | { |
| 3279 | /* If the input value is greater than max value of datatype, then also |
| 3280 | kstrtou8 fails */ |
| 3281 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3282 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3283 | CFG_ROAM_RSSI_DIFF_MIN, |
| 3284 | CFG_ROAM_RSSI_DIFF_MAX); |
| 3285 | ret = -EINVAL; |
| 3286 | goto exit; |
| 3287 | } |
| 3288 | |
| 3289 | if ((roamRssiDiff < CFG_ROAM_RSSI_DIFF_MIN) || |
| 3290 | (roamRssiDiff > CFG_ROAM_RSSI_DIFF_MAX)) |
| 3291 | { |
| 3292 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3293 | "Roam rssi diff value %d is out of range" |
| 3294 | " (Min: %d Max: %d)", roamRssiDiff, |
| 3295 | CFG_ROAM_RSSI_DIFF_MIN, |
| 3296 | CFG_ROAM_RSSI_DIFF_MAX); |
| 3297 | ret = -EINVAL; |
| 3298 | goto exit; |
| 3299 | } |
| 3300 | |
| 3301 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3302 | "%s: Received Command to Set roam rssi diff = %d", __func__, roamRssiDiff); |
| 3303 | |
| 3304 | pHddCtx->cfg_ini->RoamRssiDiff = roamRssiDiff; |
| 3305 | sme_UpdateRoamRssiDiff((tHalHandle)(pHddCtx->hHal), roamRssiDiff); |
| 3306 | } |
Mahesh A Saptasagar | ec7d109 | 2015-04-02 13:41:34 +0530 | [diff] [blame] | 3307 | else if (strncmp(command, "GETROAMDELTA", 12) == 0) |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3308 | { |
| 3309 | tANI_U8 roamRssiDiff = sme_getRoamRssiDiff((tHalHandle)(pHddCtx->hHal)); |
| 3310 | char extra[32]; |
| 3311 | tANI_U8 len = 0; |
| 3312 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 3313 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 3314 | TRACE_CODE_HDD_GETROAMDELTA_IOCTL, |
| 3315 | pAdapter->sessionId, roamRssiDiff)); |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3316 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3317 | command, roamRssiDiff); |
Ratnam Rachuri | 22a3b40 | 2015-07-17 13:21:49 +0530 | [diff] [blame] | 3318 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 3319 | if (copy_to_user(priv_data.buf, &extra, len)) { |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3320 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3321 | "%s: failed to copy data to user buffer", __func__); |
| 3322 | ret = -EFAULT; |
| 3323 | goto exit; |
| 3324 | } |
| 3325 | } |
| 3326 | #endif |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3327 | #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] | 3328 | else if (strncmp(command, "GETBAND", 7) == 0) |
| 3329 | { |
| 3330 | int band = -1; |
| 3331 | char extra[32]; |
| 3332 | tANI_U8 len = 0; |
| 3333 | hdd_getBand_helper(pHddCtx, &band); |
| 3334 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 3335 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 3336 | TRACE_CODE_HDD_GETBAND_IOCTL, |
| 3337 | pAdapter->sessionId, band)); |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3338 | len = scnprintf(extra, sizeof(extra), "%s %d", command, band); |
Ratnam Rachuri | 5213959 | 2015-07-17 13:17:29 +0530 | [diff] [blame] | 3339 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 3340 | if (copy_to_user(priv_data.buf, &extra, len)) { |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3341 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3342 | "%s: failed to copy data to user buffer", __func__); |
| 3343 | ret = -EFAULT; |
| 3344 | goto exit; |
| 3345 | } |
| 3346 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3347 | else if (strncmp(command, "SETROAMSCANCHANNELS", 19) == 0) |
| 3348 | { |
| 3349 | tANI_U8 *value = command; |
| 3350 | tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0}; |
| 3351 | tANI_U8 numChannels = 0; |
| 3352 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 3353 | |
| 3354 | status = hdd_parse_channellist(value, ChannelList, &numChannels); |
| 3355 | if (eHAL_STATUS_SUCCESS != status) |
| 3356 | { |
| 3357 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3358 | "%s: Failed to parse channel list information", __func__); |
| 3359 | ret = -EINVAL; |
| 3360 | goto exit; |
| 3361 | } |
| 3362 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 3363 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 3364 | TRACE_CODE_HDD_SETROAMSCANCHANNELS_IOCTL, |
| 3365 | pAdapter->sessionId, numChannels)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3366 | if (numChannels > WNI_CFG_VALID_CHANNEL_LIST_LEN) |
| 3367 | { |
| 3368 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3369 | "%s: number of channels (%d) supported exceeded max (%d)", __func__, |
| 3370 | numChannels, WNI_CFG_VALID_CHANNEL_LIST_LEN); |
| 3371 | ret = -EINVAL; |
| 3372 | goto exit; |
| 3373 | } |
| 3374 | status = sme_ChangeRoamScanChannelList((tHalHandle)(pHddCtx->hHal), ChannelList, |
| 3375 | numChannels); |
| 3376 | if (eHAL_STATUS_SUCCESS != status) |
| 3377 | { |
| 3378 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3379 | "%s: Failed to update channel list information", __func__); |
| 3380 | ret = -EINVAL; |
| 3381 | goto exit; |
| 3382 | } |
| 3383 | } |
| 3384 | else if (strncmp(command, "GETROAMSCANCHANNELS", 19) == 0) |
| 3385 | { |
| 3386 | tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0}; |
| 3387 | tANI_U8 numChannels = 0; |
Jeff Johnson | 51b6778 | 2013-04-05 12:35:41 -0700 | [diff] [blame] | 3388 | tANI_U8 j = 0; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3389 | char extra[128] = {0}; |
Jeff Johnson | 51b6778 | 2013-04-05 12:35:41 -0700 | [diff] [blame] | 3390 | int len; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3391 | |
| 3392 | if (eHAL_STATUS_SUCCESS != sme_getRoamScanChannelList( (tHalHandle)(pHddCtx->hHal), |
| 3393 | ChannelList, &numChannels )) |
| 3394 | { |
| 3395 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 3396 | "%s: failed to get roam scan channel list", __func__); |
| 3397 | ret = -EFAULT; |
| 3398 | goto exit; |
| 3399 | } |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 3400 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 3401 | TRACE_CODE_HDD_GETROAMSCANCHANNELS_IOCTL, |
| 3402 | pAdapter->sessionId, numChannels)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3403 | /* output channel list is of the format |
| 3404 | [Number of roam scan channels][Channel1][Channel2]... */ |
| 3405 | /* copy the number of channels in the 0th index */ |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3406 | len = scnprintf(extra, sizeof(extra), "%s %d", command, numChannels); |
Sushant Kaushik | a08ca19 | 2015-09-16 15:52:04 +0530 | [diff] [blame] | 3407 | for (j = 0; (j < numChannels) && len <= sizeof(extra); j++) |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3408 | { |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3409 | len += scnprintf(extra + len, sizeof(extra) - len, " %d", |
| 3410 | ChannelList[j]); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3411 | } |
| 3412 | |
Sushant Kaushik | c9b8be5 | 2015-07-15 16:41:27 +0530 | [diff] [blame] | 3413 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 3414 | if (copy_to_user(priv_data.buf, &extra, len)) |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3415 | { |
| 3416 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3417 | "%s: failed to copy data to user buffer", __func__); |
| 3418 | ret = -EFAULT; |
| 3419 | goto exit; |
| 3420 | } |
| 3421 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3422 | else if (strncmp(command, "GETCCXMODE", 10) == 0) |
| 3423 | { |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3424 | tANI_BOOLEAN eseMode = sme_getIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal)); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3425 | char extra[32]; |
| 3426 | tANI_U8 len = 0; |
| 3427 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3428 | /* Check if the features OKC/ESE/11R are supported simultaneously, |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 3429 | then this operation is not permitted (return FAILURE) */ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3430 | if (eseMode && |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 3431 | hdd_is_okc_mode_enabled(pHddCtx) && |
| 3432 | sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal))) |
| 3433 | { |
| 3434 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3435 | "%s: OKC/ESE/11R are supported simultaneously" |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 3436 | " hence this operation is not permitted!", __func__); |
| 3437 | ret = -EPERM; |
| 3438 | goto exit; |
| 3439 | } |
| 3440 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3441 | len = scnprintf(extra, sizeof(extra), "%s %d", |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3442 | "GETCCXMODE", eseMode); |
Sushant Kaushik | f8abd35 | 2015-07-15 16:37:49 +0530 | [diff] [blame] | 3443 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 3444 | if (copy_to_user(priv_data.buf, &extra, len)) |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3445 | { |
| 3446 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3447 | "%s: failed to copy data to user buffer", __func__); |
| 3448 | ret = -EFAULT; |
| 3449 | goto exit; |
| 3450 | } |
| 3451 | } |
| 3452 | else if (strncmp(command, "GETOKCMODE", 10) == 0) |
| 3453 | { |
| 3454 | tANI_BOOLEAN okcMode = hdd_is_okc_mode_enabled(pHddCtx); |
| 3455 | char extra[32]; |
| 3456 | tANI_U8 len = 0; |
| 3457 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3458 | /* Check if the features OKC/ESE/11R are supported simultaneously, |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 3459 | then this operation is not permitted (return FAILURE) */ |
| 3460 | if (okcMode && |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3461 | sme_getIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal)) && |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 3462 | sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal))) |
| 3463 | { |
| 3464 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3465 | "%s: OKC/ESE/11R are supported simultaneously" |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 3466 | " hence this operation is not permitted!", __func__); |
| 3467 | ret = -EPERM; |
| 3468 | goto exit; |
| 3469 | } |
| 3470 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3471 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3472 | "GETOKCMODE", okcMode); |
Sushant Kaushik | bc2fb5c | 2015-07-15 16:43:16 +0530 | [diff] [blame] | 3473 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 3474 | if (copy_to_user(priv_data.buf, &extra, len)) |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3475 | { |
| 3476 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3477 | "%s: failed to copy data to user buffer", __func__); |
| 3478 | ret = -EFAULT; |
| 3479 | goto exit; |
| 3480 | } |
| 3481 | } |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 3482 | else if (strncmp(command, "GETFASTROAM", 11) == 0) |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3483 | { |
| 3484 | tANI_BOOLEAN lfrMode = sme_getIsLfrFeatureEnabled((tHalHandle)(pHddCtx->hHal)); |
| 3485 | char extra[32]; |
| 3486 | tANI_U8 len = 0; |
| 3487 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3488 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3489 | "GETFASTROAM", lfrMode); |
Sushant Kaushik | 4da7ec9 | 2015-07-15 16:39:32 +0530 | [diff] [blame] | 3490 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 3491 | if (copy_to_user(priv_data.buf, &extra, len)) |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3492 | { |
| 3493 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3494 | "%s: failed to copy data to user buffer", __func__); |
| 3495 | ret = -EFAULT; |
| 3496 | goto exit; |
| 3497 | } |
| 3498 | } |
| 3499 | else if (strncmp(command, "GETFASTTRANSITION", 17) == 0) |
| 3500 | { |
| 3501 | tANI_BOOLEAN ft = sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal)); |
| 3502 | char extra[32]; |
| 3503 | tANI_U8 len = 0; |
| 3504 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3505 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3506 | "GETFASTTRANSITION", ft); |
Sushant Kaushik | 231a445 | 2015-07-15 16:23:56 +0530 | [diff] [blame] | 3507 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 3508 | if (copy_to_user(priv_data.buf, &extra, len)) |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3509 | { |
| 3510 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3511 | "%s: failed to copy data to user buffer", __func__); |
| 3512 | ret = -EFAULT; |
| 3513 | goto exit; |
| 3514 | } |
| 3515 | } |
| 3516 | else if (strncmp(command, "SETROAMSCANCHANNELMINTIME", 25) == 0) |
| 3517 | { |
| 3518 | tANI_U8 *value = command; |
| 3519 | tANI_U8 minTime = CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_DEFAULT; |
| 3520 | |
| 3521 | /* Move pointer to ahead of SETROAMSCANCHANNELMINTIME<delimiter> */ |
| 3522 | value = value + 26; |
| 3523 | /* Convert the value from ascii to integer */ |
| 3524 | ret = kstrtou8(value, 10, &minTime); |
| 3525 | if (ret < 0) |
| 3526 | { |
| 3527 | /* If the input value is greater than max value of datatype, then also |
| 3528 | kstrtou8 fails */ |
| 3529 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3530 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3531 | CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MIN, |
| 3532 | CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MAX); |
| 3533 | ret = -EINVAL; |
| 3534 | goto exit; |
| 3535 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3536 | if ((minTime < CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MIN) || |
| 3537 | (minTime > CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MAX)) |
| 3538 | { |
| 3539 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3540 | "scan min channel time value %d is out of range" |
| 3541 | " (Min: %d Max: %d)", minTime, |
| 3542 | CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MIN, |
| 3543 | CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MAX); |
| 3544 | ret = -EINVAL; |
| 3545 | goto exit; |
| 3546 | } |
| 3547 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 3548 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 3549 | TRACE_CODE_HDD_SETROAMSCANCHANNELMINTIME_IOCTL, |
| 3550 | pAdapter->sessionId, minTime)); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3551 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3552 | "%s: Received Command to change channel min time = %d", __func__, minTime); |
| 3553 | |
| 3554 | pHddCtx->cfg_ini->nNeighborScanMinChanTime = minTime; |
| 3555 | sme_setNeighborScanMinChanTime((tHalHandle)(pHddCtx->hHal), minTime); |
| 3556 | } |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 3557 | else if (strncmp(command, "SENDACTIONFRAME", 15) == 0) |
| 3558 | { |
| 3559 | tANI_U8 *value = command; |
| 3560 | tANI_U8 channel = 0; |
| 3561 | tANI_U8 dwellTime = 0; |
| 3562 | tANI_U8 bufLen = 0; |
| 3563 | tANI_U8 *buf = NULL; |
| 3564 | tSirMacAddr targetApBssid; |
| 3565 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 3566 | struct ieee80211_channel chan; |
| 3567 | tANI_U8 finalLen = 0; |
| 3568 | tANI_U8 *finalBuf = NULL; |
| 3569 | tANI_U8 temp = 0; |
| 3570 | u64 cookie; |
| 3571 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 3572 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3573 | |
| 3574 | /* if not associated, no need to send action frame */ |
| 3575 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 3576 | { |
| 3577 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__); |
| 3578 | ret = -EINVAL; |
| 3579 | goto exit; |
| 3580 | } |
| 3581 | |
| 3582 | status = hdd_parse_send_action_frame_data(value, targetApBssid, &channel, |
| 3583 | &dwellTime, &buf, &bufLen); |
| 3584 | if (eHAL_STATUS_SUCCESS != status) |
| 3585 | { |
| 3586 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3587 | "%s: Failed to parse send action frame data", __func__); |
| 3588 | ret = -EINVAL; |
| 3589 | goto exit; |
| 3590 | } |
| 3591 | |
| 3592 | /* if the target bssid is different from currently associated AP, |
| 3593 | then no need to send action frame */ |
| 3594 | if (VOS_TRUE != vos_mem_compare(targetApBssid, |
| 3595 | pHddStaCtx->conn_info.bssId, sizeof(tSirMacAddr))) |
| 3596 | { |
| 3597 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:STA is not associated to this AP!",__func__); |
| 3598 | ret = -EINVAL; |
Jeff Johnson | 11c3315 | 2013-04-16 17:52:40 -0700 | [diff] [blame] | 3599 | vos_mem_free(buf); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 3600 | buf = NULL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 3601 | goto exit; |
| 3602 | } |
| 3603 | |
| 3604 | /* if the channel number is different from operating channel then |
| 3605 | no need to send action frame */ |
| 3606 | if (channel != pHddStaCtx->conn_info.operationChannel) |
| 3607 | { |
| 3608 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3609 | "%s: channel(%d) is different from operating channel(%d)", |
| 3610 | __func__, channel, pHddStaCtx->conn_info.operationChannel); |
| 3611 | ret = -EINVAL; |
Jeff Johnson | 11c3315 | 2013-04-16 17:52:40 -0700 | [diff] [blame] | 3612 | vos_mem_free(buf); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 3613 | buf = NULL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 3614 | goto exit; |
| 3615 | } |
| 3616 | chan.center_freq = sme_ChnToFreq(channel); |
| 3617 | |
| 3618 | finalLen = bufLen + 24; |
| 3619 | finalBuf = vos_mem_malloc(finalLen); |
| 3620 | if (NULL == finalBuf) |
| 3621 | { |
| 3622 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:memory allocation failed",__func__); |
| 3623 | ret = -ENOMEM; |
Jeff Johnson | 11c3315 | 2013-04-16 17:52:40 -0700 | [diff] [blame] | 3624 | vos_mem_free(buf); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 3625 | buf = NULL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 3626 | goto exit; |
| 3627 | } |
| 3628 | vos_mem_zero(finalBuf, finalLen); |
| 3629 | |
| 3630 | /* Fill subtype */ |
| 3631 | temp = SIR_MAC_MGMT_ACTION << 4; |
| 3632 | vos_mem_copy(finalBuf + 0, &temp, sizeof(temp)); |
| 3633 | |
| 3634 | /* Fill type */ |
| 3635 | temp = SIR_MAC_MGMT_FRAME; |
| 3636 | vos_mem_copy(finalBuf + 2, &temp, sizeof(temp)); |
| 3637 | |
| 3638 | /* Fill destination address (bssid of the AP) */ |
| 3639 | vos_mem_copy(finalBuf + 4, targetApBssid, sizeof(targetApBssid)); |
| 3640 | |
Srinivas Girigowda | b27c019 | 2013-06-03 10:19:56 -0700 | [diff] [blame] | 3641 | /* Fill source address (STA mac address) */ |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 3642 | vos_mem_copy(finalBuf + 10, pAdapter->macAddressCurrent.bytes, sizeof(pAdapter->macAddressCurrent.bytes)); |
| 3643 | |
Srinivas Girigowda | b27c019 | 2013-06-03 10:19:56 -0700 | [diff] [blame] | 3644 | /* Fill BSSID (AP mac address) */ |
| 3645 | vos_mem_copy(finalBuf + 16, targetApBssid, sizeof(targetApBssid)); |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 3646 | |
| 3647 | /* Fill received buffer from 24th address */ |
| 3648 | vos_mem_copy(finalBuf + 24, buf, bufLen); |
| 3649 | |
Jeff Johnson | 11c3315 | 2013-04-16 17:52:40 -0700 | [diff] [blame] | 3650 | /* done with the parsed buffer */ |
| 3651 | vos_mem_free(buf); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 3652 | buf = NULL; |
Jeff Johnson | 11c3315 | 2013-04-16 17:52:40 -0700 | [diff] [blame] | 3653 | |
Anand N Sunkad | e9adb1b | 2015-07-29 09:56:45 +0530 | [diff] [blame] | 3654 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) |
| 3655 | params.chan = &chan; |
| 3656 | params.offchan = 0; |
| 3657 | params.wait = dwellTime; |
| 3658 | params.buf = finalBuf; |
| 3659 | params.len = finalLen; |
| 3660 | params.no_cck = 1; |
| 3661 | params.dont_wait_for_ack = 1; |
| 3662 | ret = wlan_hdd_mgmt_tx(NULL, &pAdapter->wdev, ¶ms, &cookie); |
| 3663 | #else |
DARAM SUDHA | 39eede6 | 2014-02-12 11:16:40 +0530 | [diff] [blame] | 3664 | wlan_hdd_mgmt_tx( NULL, |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 3665 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 3666 | &(pAdapter->wdev), |
| 3667 | #else |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 3668 | pAdapter->dev, |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 3669 | #endif |
| 3670 | &chan, 0, |
| 3671 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)) |
| 3672 | NL80211_CHAN_HT20, 1, |
| 3673 | #endif |
| 3674 | dwellTime, finalBuf, finalLen, 1, |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 3675 | 1, &cookie ); |
Anand N Sunkad | e9adb1b | 2015-07-29 09:56:45 +0530 | [diff] [blame] | 3676 | #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)*/ |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 3677 | vos_mem_free(finalBuf); |
| 3678 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3679 | else if (strncmp(command, "GETROAMSCANCHANNELMINTIME", 25) == 0) |
| 3680 | { |
| 3681 | tANI_U16 val = sme_getNeighborScanMinChanTime((tHalHandle)(pHddCtx->hHal)); |
| 3682 | char extra[32]; |
| 3683 | tANI_U8 len = 0; |
| 3684 | |
| 3685 | /* value is interms of msec */ |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3686 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3687 | "GETROAMSCANCHANNELMINTIME", val); |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 3688 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 3689 | TRACE_CODE_HDD_GETROAMSCANCHANNELMINTIME_IOCTL, |
| 3690 | pAdapter->sessionId, val)); |
Sushant Kaushik | bb8c52c | 2015-07-15 16:36:23 +0530 | [diff] [blame] | 3691 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 3692 | if (copy_to_user(priv_data.buf, &extra, len)) |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3693 | { |
| 3694 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3695 | "%s: failed to copy data to user buffer", __func__); |
| 3696 | ret = -EFAULT; |
| 3697 | goto exit; |
| 3698 | } |
| 3699 | } |
| 3700 | else if (strncmp(command, "SETSCANCHANNELTIME", 18) == 0) |
| 3701 | { |
| 3702 | tANI_U8 *value = command; |
Varun Reddy Yeturu | 3885a66 | 2013-06-19 07:10:37 -0700 | [diff] [blame] | 3703 | tANI_U16 maxTime = CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_DEFAULT; |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3704 | |
| 3705 | /* Move pointer to ahead of SETSCANCHANNELTIME<delimiter> */ |
| 3706 | value = value + 19; |
| 3707 | /* Convert the value from ascii to integer */ |
Varun Reddy Yeturu | 3885a66 | 2013-06-19 07:10:37 -0700 | [diff] [blame] | 3708 | ret = kstrtou16(value, 10, &maxTime); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3709 | if (ret < 0) |
| 3710 | { |
| 3711 | /* 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] | 3712 | kstrtou16 fails */ |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3713 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Varun Reddy Yeturu | 3885a66 | 2013-06-19 07:10:37 -0700 | [diff] [blame] | 3714 | "%s: kstrtou16 failed range [%d - %d]", __func__, |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3715 | CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MIN, |
| 3716 | CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MAX); |
| 3717 | ret = -EINVAL; |
| 3718 | goto exit; |
| 3719 | } |
| 3720 | |
| 3721 | if ((maxTime < CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MIN) || |
| 3722 | (maxTime > CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MAX)) |
| 3723 | { |
| 3724 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3725 | "lfr mode value %d is out of range" |
| 3726 | " (Min: %d Max: %d)", maxTime, |
| 3727 | CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MIN, |
| 3728 | CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MAX); |
| 3729 | ret = -EINVAL; |
| 3730 | goto exit; |
| 3731 | } |
| 3732 | |
| 3733 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3734 | "%s: Received Command to change channel max time = %d", __func__, maxTime); |
| 3735 | |
| 3736 | pHddCtx->cfg_ini->nNeighborScanMaxChanTime = maxTime; |
| 3737 | sme_setNeighborScanMaxChanTime((tHalHandle)(pHddCtx->hHal), maxTime); |
| 3738 | } |
| 3739 | else if (strncmp(command, "GETSCANCHANNELTIME", 18) == 0) |
| 3740 | { |
| 3741 | tANI_U16 val = sme_getNeighborScanMaxChanTime((tHalHandle)(pHddCtx->hHal)); |
| 3742 | char extra[32]; |
| 3743 | tANI_U8 len = 0; |
| 3744 | |
| 3745 | /* value is interms of msec */ |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3746 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3747 | "GETSCANCHANNELTIME", val); |
Ratheesh S P | acbfa93 | 2015-07-16 15:27:18 +0530 | [diff] [blame] | 3748 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 3749 | if (copy_to_user(priv_data.buf, &extra, len)) |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3750 | { |
| 3751 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3752 | "%s: failed to copy data to user buffer", __func__); |
| 3753 | ret = -EFAULT; |
| 3754 | goto exit; |
| 3755 | } |
| 3756 | } |
| 3757 | else if (strncmp(command, "SETSCANHOMETIME", 15) == 0) |
| 3758 | { |
| 3759 | tANI_U8 *value = command; |
| 3760 | tANI_U16 val = CFG_NEIGHBOR_SCAN_TIMER_PERIOD_DEFAULT; |
| 3761 | |
| 3762 | /* Move pointer to ahead of SETSCANHOMETIME<delimiter> */ |
| 3763 | value = value + 16; |
| 3764 | /* Convert the value from ascii to integer */ |
| 3765 | ret = kstrtou16(value, 10, &val); |
| 3766 | if (ret < 0) |
| 3767 | { |
| 3768 | /* If the input value is greater than max value of datatype, then also |
| 3769 | kstrtou16 fails */ |
| 3770 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3771 | "%s: kstrtou16 failed range [%d - %d]", __func__, |
| 3772 | CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MIN, |
| 3773 | CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MAX); |
| 3774 | ret = -EINVAL; |
| 3775 | goto exit; |
| 3776 | } |
| 3777 | |
| 3778 | if ((val < CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MIN) || |
| 3779 | (val > CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MAX)) |
| 3780 | { |
| 3781 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3782 | "scan home time value %d is out of range" |
| 3783 | " (Min: %d Max: %d)", val, |
| 3784 | CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MIN, |
| 3785 | CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MAX); |
| 3786 | ret = -EINVAL; |
| 3787 | goto exit; |
| 3788 | } |
| 3789 | |
| 3790 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3791 | "%s: Received Command to change scan home time = %d", __func__, val); |
| 3792 | |
| 3793 | pHddCtx->cfg_ini->nNeighborScanPeriod = val; |
| 3794 | sme_setNeighborScanPeriod((tHalHandle)(pHddCtx->hHal), val); |
| 3795 | } |
| 3796 | else if (strncmp(command, "GETSCANHOMETIME", 15) == 0) |
| 3797 | { |
| 3798 | tANI_U16 val = sme_getNeighborScanPeriod((tHalHandle)(pHddCtx->hHal)); |
| 3799 | char extra[32]; |
| 3800 | tANI_U8 len = 0; |
| 3801 | |
| 3802 | /* value is interms of msec */ |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3803 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3804 | "GETSCANHOMETIME", val); |
Ratheesh S P | 728d7c6 | 2015-07-16 15:38:58 +0530 | [diff] [blame] | 3805 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 3806 | if (copy_to_user(priv_data.buf, &extra, len)) |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3807 | { |
| 3808 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3809 | "%s: failed to copy data to user buffer", __func__); |
| 3810 | ret = -EFAULT; |
| 3811 | goto exit; |
| 3812 | } |
| 3813 | } |
| 3814 | else if (strncmp(command, "SETROAMINTRABAND", 16) == 0) |
| 3815 | { |
| 3816 | tANI_U8 *value = command; |
| 3817 | tANI_U8 val = CFG_ROAM_INTRA_BAND_DEFAULT; |
| 3818 | |
| 3819 | /* Move pointer to ahead of SETROAMINTRABAND<delimiter> */ |
| 3820 | value = value + 17; |
| 3821 | /* Convert the value from ascii to integer */ |
| 3822 | ret = kstrtou8(value, 10, &val); |
| 3823 | if (ret < 0) |
| 3824 | { |
| 3825 | /* If the input value is greater than max value of datatype, then also |
| 3826 | kstrtou8 fails */ |
| 3827 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3828 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3829 | CFG_ROAM_INTRA_BAND_MIN, |
| 3830 | CFG_ROAM_INTRA_BAND_MAX); |
| 3831 | ret = -EINVAL; |
| 3832 | goto exit; |
| 3833 | } |
| 3834 | |
| 3835 | if ((val < CFG_ROAM_INTRA_BAND_MIN) || |
| 3836 | (val > CFG_ROAM_INTRA_BAND_MAX)) |
| 3837 | { |
| 3838 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3839 | "intra band mode value %d is out of range" |
| 3840 | " (Min: %d Max: %d)", val, |
| 3841 | CFG_ROAM_INTRA_BAND_MIN, |
| 3842 | CFG_ROAM_INTRA_BAND_MAX); |
| 3843 | ret = -EINVAL; |
| 3844 | goto exit; |
| 3845 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3846 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3847 | "%s: Received Command to change intra band = %d", __func__, val); |
| 3848 | |
| 3849 | pHddCtx->cfg_ini->nRoamIntraBand = val; |
| 3850 | sme_setRoamIntraBand((tHalHandle)(pHddCtx->hHal), val); |
| 3851 | } |
| 3852 | else if (strncmp(command, "GETROAMINTRABAND", 16) == 0) |
| 3853 | { |
| 3854 | tANI_U16 val = sme_getRoamIntraBand((tHalHandle)(pHddCtx->hHal)); |
| 3855 | char extra[32]; |
| 3856 | tANI_U8 len = 0; |
| 3857 | |
| 3858 | /* value is interms of msec */ |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3859 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3860 | "GETROAMINTRABAND", val); |
Ratheesh S P | 2dd2a3e | 2015-07-16 15:34:23 +0530 | [diff] [blame] | 3861 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 3862 | if (copy_to_user(priv_data.buf, &extra, len)) |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3863 | { |
| 3864 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3865 | "%s: failed to copy data to user buffer", __func__); |
| 3866 | ret = -EFAULT; |
| 3867 | goto exit; |
| 3868 | } |
| 3869 | } |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3870 | else if (strncmp(command, "SETSCANNPROBES", 14) == 0) |
| 3871 | { |
| 3872 | tANI_U8 *value = command; |
| 3873 | tANI_U8 nProbes = CFG_ROAM_SCAN_N_PROBES_DEFAULT; |
| 3874 | |
| 3875 | /* Move pointer to ahead of SETSCANNPROBES<delimiter> */ |
| 3876 | value = value + 15; |
| 3877 | /* Convert the value from ascii to integer */ |
| 3878 | ret = kstrtou8(value, 10, &nProbes); |
| 3879 | if (ret < 0) |
| 3880 | { |
| 3881 | /* If the input value is greater than max value of datatype, then also |
| 3882 | kstrtou8 fails */ |
| 3883 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3884 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3885 | CFG_ROAM_SCAN_N_PROBES_MIN, |
| 3886 | CFG_ROAM_SCAN_N_PROBES_MAX); |
| 3887 | ret = -EINVAL; |
| 3888 | goto exit; |
| 3889 | } |
| 3890 | |
| 3891 | if ((nProbes < CFG_ROAM_SCAN_N_PROBES_MIN) || |
| 3892 | (nProbes > CFG_ROAM_SCAN_N_PROBES_MAX)) |
| 3893 | { |
| 3894 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3895 | "NProbes value %d is out of range" |
| 3896 | " (Min: %d Max: %d)", nProbes, |
| 3897 | CFG_ROAM_SCAN_N_PROBES_MIN, |
| 3898 | CFG_ROAM_SCAN_N_PROBES_MAX); |
| 3899 | ret = -EINVAL; |
| 3900 | goto exit; |
| 3901 | } |
| 3902 | |
| 3903 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3904 | "%s: Received Command to Set nProbes = %d", __func__, nProbes); |
| 3905 | |
| 3906 | pHddCtx->cfg_ini->nProbes = nProbes; |
| 3907 | sme_UpdateRoamScanNProbes((tHalHandle)(pHddCtx->hHal), nProbes); |
| 3908 | } |
Mahesh A Saptasagar | ec7d109 | 2015-04-02 13:41:34 +0530 | [diff] [blame] | 3909 | else if (strncmp(command, "GETSCANNPROBES", 14) == 0) |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3910 | { |
| 3911 | tANI_U8 val = sme_getRoamScanNProbes((tHalHandle)(pHddCtx->hHal)); |
| 3912 | char extra[32]; |
| 3913 | tANI_U8 len = 0; |
| 3914 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3915 | len = scnprintf(extra, sizeof(extra), "%s %d", command, val); |
Ratnam Rachuri | 6da525d | 2015-08-07 13:55:54 +0530 | [diff] [blame] | 3916 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 3917 | if (copy_to_user(priv_data.buf, &extra, len)) { |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3918 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3919 | "%s: failed to copy data to user buffer", __func__); |
| 3920 | ret = -EFAULT; |
| 3921 | goto exit; |
| 3922 | } |
| 3923 | } |
| 3924 | else if (strncmp(command, "SETSCANHOMEAWAYTIME", 19) == 0) |
| 3925 | { |
| 3926 | tANI_U8 *value = command; |
| 3927 | tANI_U16 homeAwayTime = CFG_ROAM_SCAN_HOME_AWAY_TIME_DEFAULT; |
| 3928 | |
| 3929 | /* Move pointer to ahead of SETSCANHOMEAWAYTIME<delimiter> */ |
| 3930 | /* input value is in units of msec */ |
| 3931 | value = value + 20; |
| 3932 | /* Convert the value from ascii to integer */ |
| 3933 | ret = kstrtou16(value, 10, &homeAwayTime); |
| 3934 | if (ret < 0) |
| 3935 | { |
| 3936 | /* If the input value is greater than max value of datatype, then also |
| 3937 | kstrtou8 fails */ |
| 3938 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3939 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3940 | CFG_ROAM_SCAN_HOME_AWAY_TIME_MIN, |
| 3941 | CFG_ROAM_SCAN_HOME_AWAY_TIME_MAX); |
| 3942 | ret = -EINVAL; |
| 3943 | goto exit; |
| 3944 | } |
| 3945 | |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3946 | if ((homeAwayTime < CFG_ROAM_SCAN_HOME_AWAY_TIME_MIN) || |
| 3947 | (homeAwayTime > CFG_ROAM_SCAN_HOME_AWAY_TIME_MAX)) |
| 3948 | { |
| 3949 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3950 | "homeAwayTime value %d is out of range" |
| 3951 | " (Min: %d Max: %d)", homeAwayTime, |
| 3952 | CFG_ROAM_SCAN_HOME_AWAY_TIME_MIN, |
| 3953 | CFG_ROAM_SCAN_HOME_AWAY_TIME_MAX); |
| 3954 | ret = -EINVAL; |
| 3955 | goto exit; |
| 3956 | } |
| 3957 | |
| 3958 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3959 | "%s: Received Command to Set scan away time = %d", __func__, homeAwayTime); |
Srinivas Girigowda | 6cf0b82 | 2013-06-27 14:00:20 -0700 | [diff] [blame] | 3960 | if (pHddCtx->cfg_ini->nRoamScanHomeAwayTime != homeAwayTime) |
| 3961 | { |
| 3962 | pHddCtx->cfg_ini->nRoamScanHomeAwayTime = homeAwayTime; |
| 3963 | sme_UpdateRoamScanHomeAwayTime((tHalHandle)(pHddCtx->hHal), homeAwayTime, eANI_BOOLEAN_TRUE); |
| 3964 | } |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3965 | } |
Mahesh A Saptasagar | ec7d109 | 2015-04-02 13:41:34 +0530 | [diff] [blame] | 3966 | else if (strncmp(command, "GETSCANHOMEAWAYTIME", 19) == 0) |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3967 | { |
| 3968 | tANI_U16 val = sme_getRoamScanHomeAwayTime((tHalHandle)(pHddCtx->hHal)); |
| 3969 | char extra[32]; |
| 3970 | tANI_U8 len = 0; |
| 3971 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3972 | len = scnprintf(extra, sizeof(extra), "%s %d", command, val); |
Ratnam Rachuri | 51a5ad1 | 2015-08-07 14:06:37 +0530 | [diff] [blame] | 3973 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 3974 | if (copy_to_user(priv_data.buf, &extra, len)) { |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3975 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3976 | "%s: failed to copy data to user buffer", __func__); |
| 3977 | ret = -EFAULT; |
| 3978 | goto exit; |
| 3979 | } |
| 3980 | } |
| 3981 | else if (strncmp(command, "REASSOC", 7) == 0) |
| 3982 | { |
| 3983 | tANI_U8 *value = command; |
| 3984 | tANI_U8 channel = 0; |
| 3985 | tSirMacAddr targetApBssid; |
| 3986 | eHalStatus status = eHAL_STATUS_SUCCESS; |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 3987 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 3988 | tCsrHandoffRequest handoffInfo; |
| 3989 | #endif |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3990 | hdd_station_ctx_t *pHddStaCtx = NULL; |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3991 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3992 | |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 3993 | /* if not associated, no need to proceed with reassoc */ |
| 3994 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 3995 | { |
| 3996 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__); |
| 3997 | ret = -EINVAL; |
| 3998 | goto exit; |
| 3999 | } |
| 4000 | |
| 4001 | status = hdd_parse_reassoc_command_data(value, targetApBssid, &channel); |
| 4002 | if (eHAL_STATUS_SUCCESS != status) |
| 4003 | { |
| 4004 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4005 | "%s: Failed to parse reassoc command data", __func__); |
| 4006 | ret = -EINVAL; |
| 4007 | goto exit; |
| 4008 | } |
| 4009 | |
| 4010 | /* if the target bssid is same as currently associated AP, |
| 4011 | then no need to proceed with reassoc */ |
| 4012 | if (VOS_TRUE == vos_mem_compare(targetApBssid, |
| 4013 | pHddStaCtx->conn_info.bssId, sizeof(tSirMacAddr))) |
| 4014 | { |
| 4015 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Reassoc BSSID is same as currently associated AP bssid",__func__); |
c_manjee | 6de1f45 | 2015-12-08 14:13:28 +0530 | [diff] [blame] | 4016 | ret = 0; |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 4017 | goto exit; |
| 4018 | } |
| 4019 | |
| 4020 | /* Check channel number is a valid channel number */ |
| 4021 | if(VOS_STATUS_SUCCESS != |
| 4022 | wlan_hdd_validate_operation_channel(pAdapter, channel)) |
| 4023 | { |
| 4024 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 4025 | "%s: Invalid Channel [%d]", __func__, channel); |
c_manjee | 6de1f45 | 2015-12-08 14:13:28 +0530 | [diff] [blame] | 4026 | |
| 4027 | ret = -EINVAL; |
| 4028 | goto exit; |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 4029 | } |
| 4030 | |
| 4031 | /* Proceed with reassoc */ |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 4032 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 4033 | handoffInfo.channel = channel; |
| 4034 | vos_mem_copy(handoffInfo.bssid, targetApBssid, sizeof(tSirMacAddr)); |
| 4035 | sme_HandoffRequest(pHddCtx->hHal, &handoffInfo); |
| 4036 | #endif |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 4037 | } |
Srinivas Girigowda | ad34ca9 | 2013-10-22 10:54:29 -0700 | [diff] [blame] | 4038 | else if (strncmp(command, "SETWESMODE", 10) == 0) |
| 4039 | { |
| 4040 | tANI_U8 *value = command; |
| 4041 | tANI_BOOLEAN wesMode = CFG_ENABLE_WES_MODE_NAME_DEFAULT; |
| 4042 | |
| 4043 | /* Move pointer to ahead of SETWESMODE<delimiter> */ |
| 4044 | value = value + 11; |
| 4045 | /* Convert the value from ascii to integer */ |
| 4046 | ret = kstrtou8(value, 10, &wesMode); |
| 4047 | if (ret < 0) |
| 4048 | { |
| 4049 | /* If the input value is greater than max value of datatype, then also |
| 4050 | kstrtou8 fails */ |
| 4051 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4052 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 4053 | CFG_ENABLE_WES_MODE_NAME_MIN, |
| 4054 | CFG_ENABLE_WES_MODE_NAME_MAX); |
| 4055 | ret = -EINVAL; |
| 4056 | goto exit; |
| 4057 | } |
| 4058 | |
| 4059 | if ((wesMode < CFG_ENABLE_WES_MODE_NAME_MIN) || |
| 4060 | (wesMode > CFG_ENABLE_WES_MODE_NAME_MAX)) |
| 4061 | { |
| 4062 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4063 | "WES Mode value %d is out of range" |
| 4064 | " (Min: %d Max: %d)", wesMode, |
| 4065 | CFG_ENABLE_WES_MODE_NAME_MIN, |
| 4066 | CFG_ENABLE_WES_MODE_NAME_MAX); |
| 4067 | ret = -EINVAL; |
| 4068 | goto exit; |
| 4069 | } |
| 4070 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4071 | "%s: Received Command to Set WES Mode rssi diff = %d", __func__, wesMode); |
| 4072 | |
| 4073 | pHddCtx->cfg_ini->isWESModeEnabled = wesMode; |
| 4074 | sme_UpdateWESMode((tHalHandle)(pHddCtx->hHal), wesMode); |
| 4075 | } |
Mahesh A Saptasagar | ec7d109 | 2015-04-02 13:41:34 +0530 | [diff] [blame] | 4076 | else if (strncmp(command, "GETWESMODE", 10) == 0) |
Srinivas Girigowda | ad34ca9 | 2013-10-22 10:54:29 -0700 | [diff] [blame] | 4077 | { |
| 4078 | tANI_BOOLEAN wesMode = sme_GetWESMode((tHalHandle)(pHddCtx->hHal)); |
| 4079 | char extra[32]; |
| 4080 | tANI_U8 len = 0; |
| 4081 | |
Arif Hussain | 826d941 | 2013-11-12 16:44:54 -0800 | [diff] [blame] | 4082 | len = scnprintf(extra, sizeof(extra), "%s %d", command, wesMode); |
Ratnam Rachuri | 8fe90c6 | 2015-08-07 14:03:26 +0530 | [diff] [blame] | 4083 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 4084 | if (copy_to_user(priv_data.buf, &extra, len)) { |
Srinivas Girigowda | ad34ca9 | 2013-10-22 10:54:29 -0700 | [diff] [blame] | 4085 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4086 | "%s: failed to copy data to user buffer", __func__); |
| 4087 | ret = -EFAULT; |
| 4088 | goto exit; |
| 4089 | } |
| 4090 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4091 | #endif /* WLAN_FEATURE_VOWIFI_11R || FEATURE_WLAN_ESE || FEATURE_WLAN_LFR */ |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4092 | #ifdef FEATURE_WLAN_LFR |
| 4093 | else if (strncmp(command, "SETFASTROAM", 11) == 0) |
| 4094 | { |
| 4095 | tANI_U8 *value = command; |
| 4096 | tANI_U8 lfrMode = CFG_LFR_FEATURE_ENABLED_DEFAULT; |
| 4097 | |
| 4098 | /* Move pointer to ahead of SETFASTROAM<delimiter> */ |
| 4099 | value = value + 12; |
| 4100 | /* Convert the value from ascii to integer */ |
| 4101 | ret = kstrtou8(value, 10, &lfrMode); |
| 4102 | if (ret < 0) |
| 4103 | { |
| 4104 | /* If the input value is greater than max value of datatype, then also |
| 4105 | kstrtou8 fails */ |
| 4106 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4107 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 4108 | CFG_LFR_FEATURE_ENABLED_MIN, |
| 4109 | CFG_LFR_FEATURE_ENABLED_MAX); |
| 4110 | ret = -EINVAL; |
| 4111 | goto exit; |
| 4112 | } |
| 4113 | |
| 4114 | if ((lfrMode < CFG_LFR_FEATURE_ENABLED_MIN) || |
| 4115 | (lfrMode > CFG_LFR_FEATURE_ENABLED_MAX)) |
| 4116 | { |
| 4117 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4118 | "lfr mode value %d is out of range" |
| 4119 | " (Min: %d Max: %d)", lfrMode, |
| 4120 | CFG_LFR_FEATURE_ENABLED_MIN, |
| 4121 | CFG_LFR_FEATURE_ENABLED_MAX); |
| 4122 | ret = -EINVAL; |
| 4123 | goto exit; |
| 4124 | } |
| 4125 | |
| 4126 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4127 | "%s: Received Command to change lfr mode = %d", __func__, lfrMode); |
| 4128 | |
| 4129 | pHddCtx->cfg_ini->isFastRoamIniFeatureEnabled = lfrMode; |
| 4130 | sme_UpdateIsFastRoamIniFeatureEnabled((tHalHandle)(pHddCtx->hHal), lfrMode); |
| 4131 | } |
| 4132 | #endif |
| 4133 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 4134 | else if (strncmp(command, "SETFASTTRANSITION", 17) == 0) |
| 4135 | { |
| 4136 | tANI_U8 *value = command; |
| 4137 | tANI_U8 ft = CFG_FAST_TRANSITION_ENABLED_NAME_DEFAULT; |
| 4138 | |
| 4139 | /* Move pointer to ahead of SETFASTROAM<delimiter> */ |
| 4140 | value = value + 18; |
| 4141 | /* Convert the value from ascii to integer */ |
| 4142 | ret = kstrtou8(value, 10, &ft); |
| 4143 | if (ret < 0) |
| 4144 | { |
| 4145 | /* If the input value is greater than max value of datatype, then also |
| 4146 | kstrtou8 fails */ |
| 4147 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4148 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 4149 | CFG_FAST_TRANSITION_ENABLED_NAME_MIN, |
| 4150 | CFG_FAST_TRANSITION_ENABLED_NAME_MAX); |
| 4151 | ret = -EINVAL; |
| 4152 | goto exit; |
| 4153 | } |
| 4154 | |
| 4155 | if ((ft < CFG_FAST_TRANSITION_ENABLED_NAME_MIN) || |
| 4156 | (ft > CFG_FAST_TRANSITION_ENABLED_NAME_MAX)) |
| 4157 | { |
| 4158 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4159 | "ft mode value %d is out of range" |
| 4160 | " (Min: %d Max: %d)", ft, |
| 4161 | CFG_FAST_TRANSITION_ENABLED_NAME_MIN, |
| 4162 | CFG_FAST_TRANSITION_ENABLED_NAME_MAX); |
| 4163 | ret = -EINVAL; |
| 4164 | goto exit; |
| 4165 | } |
| 4166 | |
| 4167 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4168 | "%s: Received Command to change ft mode = %d", __func__, ft); |
| 4169 | |
| 4170 | pHddCtx->cfg_ini->isFastTransitionEnabled = ft; |
| 4171 | sme_UpdateFastTransitionEnabled((tHalHandle)(pHddCtx->hHal), ft); |
| 4172 | } |
Padma, Santhosh Kumar | 778d838 | 2015-03-04 17:41:22 +0530 | [diff] [blame] | 4173 | else if (strncmp(command, "SETDFSSCANMODE", 14) == 0) |
| 4174 | { |
| 4175 | tANI_U8 *value = command; |
| 4176 | tANI_U8 dfsScanMode = DFS_CHNL_SCAN_ENABLED_NORMAL; |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 4177 | |
Padma, Santhosh Kumar | 778d838 | 2015-03-04 17:41:22 +0530 | [diff] [blame] | 4178 | /* Move pointer to ahead of SETDFSSCANMODE<delimiter> */ |
| 4179 | value = value + 15; |
| 4180 | /* Convert the value from ascii to integer */ |
| 4181 | ret = kstrtou8(value, 10, &dfsScanMode); |
| 4182 | if (ret < 0) |
| 4183 | { |
| 4184 | /* If the input value is greater than max value of |
| 4185 | datatype, then also kstrtou8 fails |
| 4186 | */ |
| 4187 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4188 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 4189 | CFG_ENABLE_DFS_CHNL_SCAN_MIN, |
| 4190 | CFG_ENABLE_DFS_CHNL_SCAN_MAX); |
| 4191 | ret = -EINVAL; |
| 4192 | goto exit; |
| 4193 | } |
| 4194 | |
| 4195 | if ((dfsScanMode < CFG_ENABLE_DFS_CHNL_SCAN_MIN) || |
| 4196 | (dfsScanMode > CFG_ENABLE_DFS_CHNL_SCAN_MAX)) |
| 4197 | { |
| 4198 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4199 | "dfsScanMode value %d is out of range" |
| 4200 | " (Min: %d Max: %d)", dfsScanMode, |
| 4201 | CFG_ENABLE_DFS_CHNL_SCAN_MIN, |
| 4202 | CFG_ENABLE_DFS_CHNL_SCAN_MAX); |
| 4203 | ret = -EINVAL; |
| 4204 | goto exit; |
| 4205 | } |
| 4206 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4207 | "%s: Received Command to Set DFS Scan Mode = %d", |
| 4208 | __func__, dfsScanMode); |
| 4209 | |
| 4210 | ret = wlan_hdd_handle_dfs_chan_scan(pHddCtx, dfsScanMode); |
| 4211 | } |
| 4212 | else if (strncmp(command, "GETDFSSCANMODE", 14) == 0) |
| 4213 | { |
| 4214 | tANI_U8 dfsScanMode = sme_GetDFSScanMode(pHddCtx->hHal); |
| 4215 | char extra[32]; |
| 4216 | tANI_U8 len = 0; |
| 4217 | |
| 4218 | len = scnprintf(extra, sizeof(extra), "%s %d", command, dfsScanMode); |
Ratheesh S P | 767224e | 2015-07-16 15:35:51 +0530 | [diff] [blame] | 4219 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 4220 | if (copy_to_user(priv_data.buf, &extra, len)) |
Padma, Santhosh Kumar | 778d838 | 2015-03-04 17:41:22 +0530 | [diff] [blame] | 4221 | { |
| 4222 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4223 | "%s: failed to copy data to user buffer", __func__); |
| 4224 | ret = -EFAULT; |
| 4225 | goto exit; |
| 4226 | } |
| 4227 | } |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 4228 | else if (strncmp(command, "FASTREASSOC", 11) == 0) |
| 4229 | { |
| 4230 | tANI_U8 *value = command; |
Padma, Santhosh Kumar | f4582d3 | 2014-11-06 19:24:51 +0530 | [diff] [blame] | 4231 | tANI_U8 channel = 0; |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 4232 | tSirMacAddr targetApBssid; |
| 4233 | tANI_U8 trigger = 0; |
| 4234 | eHalStatus status = eHAL_STATUS_SUCCESS; |
Padma, Santhosh Kumar | b980a6f | 2014-11-06 19:07:24 +0530 | [diff] [blame] | 4235 | tHalHandle hHal; |
| 4236 | v_U32_t roamId = 0; |
| 4237 | tCsrRoamModifyProfileFields modProfileFields; |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 4238 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 4239 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Padma, Santhosh Kumar | b980a6f | 2014-11-06 19:07:24 +0530 | [diff] [blame] | 4240 | hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 4241 | |
| 4242 | /* if not associated, no need to proceed with reassoc */ |
| 4243 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 4244 | { |
| 4245 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__); |
| 4246 | ret = -EINVAL; |
| 4247 | goto exit; |
| 4248 | } |
| 4249 | |
Padma, Santhosh Kumar | f4582d3 | 2014-11-06 19:24:51 +0530 | [diff] [blame] | 4250 | status = hdd_parse_reassoc_command_data(value, targetApBssid, &channel); |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 4251 | if (eHAL_STATUS_SUCCESS != status) |
| 4252 | { |
| 4253 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4254 | "%s: Failed to parse reassoc command data", __func__); |
| 4255 | ret = -EINVAL; |
| 4256 | goto exit; |
| 4257 | } |
| 4258 | |
| 4259 | /* if the target bssid is same as currently associated AP, |
Padma, Santhosh Kumar | b980a6f | 2014-11-06 19:07:24 +0530 | [diff] [blame] | 4260 | issue reassoc to same AP */ |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 4261 | if (VOS_TRUE == vos_mem_compare(targetApBssid, |
| 4262 | pHddStaCtx->conn_info.bssId, sizeof(tSirMacAddr))) |
| 4263 | { |
AnjaneeDevi Kapparapu | 228d0c5 | 2015-11-09 12:32:21 +0530 | [diff] [blame] | 4264 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4265 | "%s:11r Reassoc BSSID is same as currently associated AP bssid", |
| 4266 | __func__); |
Padma, Santhosh Kumar | b980a6f | 2014-11-06 19:07:24 +0530 | [diff] [blame] | 4267 | sme_GetModifyProfileFields(hHal, pAdapter->sessionId, |
| 4268 | &modProfileFields); |
| 4269 | sme_RoamReassoc(hHal, pAdapter->sessionId, |
| 4270 | NULL, modProfileFields, &roamId, 1); |
AnjaneeDevi Kapparapu | 228d0c5 | 2015-11-09 12:32:21 +0530 | [diff] [blame] | 4271 | return 0; |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 4272 | } |
Padma, Santhosh Kumar | 0fa809b | 2014-11-13 14:56:56 +0530 | [diff] [blame] | 4273 | |
| 4274 | /* Check channel number is a valid channel number */ |
| 4275 | if(VOS_STATUS_SUCCESS != |
| 4276 | wlan_hdd_validate_operation_channel(pAdapter, channel)) |
| 4277 | { |
| 4278 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4279 | "%s: Invalid Channel [%d]", __func__, channel); |
AnjaneeDevi Kapparapu | 228d0c5 | 2015-11-09 12:32:21 +0530 | [diff] [blame] | 4280 | return -EINVAL; |
Padma, Santhosh Kumar | 0fa809b | 2014-11-13 14:56:56 +0530 | [diff] [blame] | 4281 | } |
| 4282 | |
Padma, Santhosh Kumar | f4582d3 | 2014-11-06 19:24:51 +0530 | [diff] [blame] | 4283 | trigger = eSME_ROAM_TRIGGER_SCAN; |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 4284 | |
| 4285 | /* Proceed with scan/roam */ |
| 4286 | smeIssueFastRoamNeighborAPEvent(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 4287 | &targetApBssid[0], |
Mukul Sharma | 9e4e0f9 | 2015-02-13 18:45:20 +0530 | [diff] [blame] | 4288 | (tSmeFastRoamTrigger)(trigger), |
| 4289 | channel); |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 4290 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4291 | #endif |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4292 | #ifdef FEATURE_WLAN_ESE |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4293 | else if (strncmp(command, "SETCCXMODE", 10) == 0) |
| 4294 | { |
| 4295 | tANI_U8 *value = command; |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4296 | tANI_U8 eseMode = CFG_ESE_FEATURE_ENABLED_DEFAULT; |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4297 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4298 | /* Check if the features OKC/ESE/11R are supported simultaneously, |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 4299 | then this operation is not permitted (return FAILURE) */ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4300 | if (sme_getIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal)) && |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 4301 | hdd_is_okc_mode_enabled(pHddCtx) && |
| 4302 | sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal))) |
| 4303 | { |
| 4304 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4305 | "%s: OKC/ESE/11R are supported simultaneously" |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 4306 | " hence this operation is not permitted!", __func__); |
| 4307 | ret = -EPERM; |
| 4308 | goto exit; |
| 4309 | } |
| 4310 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4311 | /* Move pointer to ahead of SETCCXMODE<delimiter> */ |
| 4312 | value = value + 11; |
| 4313 | /* Convert the value from ascii to integer */ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4314 | ret = kstrtou8(value, 10, &eseMode); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4315 | if (ret < 0) |
| 4316 | { |
| 4317 | /* If the input value is greater than max value of datatype, then also |
| 4318 | kstrtou8 fails */ |
| 4319 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4320 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4321 | CFG_ESE_FEATURE_ENABLED_MIN, |
| 4322 | CFG_ESE_FEATURE_ENABLED_MAX); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4323 | ret = -EINVAL; |
| 4324 | goto exit; |
| 4325 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4326 | if ((eseMode < CFG_ESE_FEATURE_ENABLED_MIN) || |
| 4327 | (eseMode > CFG_ESE_FEATURE_ENABLED_MAX)) |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4328 | { |
| 4329 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4330 | "Ese mode value %d is out of range" |
| 4331 | " (Min: %d Max: %d)", eseMode, |
| 4332 | CFG_ESE_FEATURE_ENABLED_MIN, |
| 4333 | CFG_ESE_FEATURE_ENABLED_MAX); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4334 | ret = -EINVAL; |
| 4335 | goto exit; |
| 4336 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4337 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4338 | "%s: Received Command to change ese mode = %d", __func__, eseMode); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4339 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4340 | pHddCtx->cfg_ini->isEseIniFeatureEnabled = eseMode; |
| 4341 | sme_UpdateIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal), eseMode); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4342 | } |
| 4343 | #endif |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4344 | else if (strncmp(command, "SETROAMSCANCONTROL", 18) == 0) |
| 4345 | { |
| 4346 | tANI_U8 *value = command; |
| 4347 | tANI_BOOLEAN roamScanControl = 0; |
| 4348 | |
| 4349 | /* Move pointer to ahead of SETROAMSCANCONTROL<delimiter> */ |
| 4350 | value = value + 19; |
| 4351 | /* Convert the value from ascii to integer */ |
| 4352 | ret = kstrtou8(value, 10, &roamScanControl); |
| 4353 | if (ret < 0) |
| 4354 | { |
| 4355 | /* If the input value is greater than max value of datatype, then also |
| 4356 | kstrtou8 fails */ |
| 4357 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4358 | "%s: kstrtou8 failed ", __func__); |
| 4359 | ret = -EINVAL; |
| 4360 | goto exit; |
| 4361 | } |
| 4362 | |
| 4363 | if (0 != roamScanControl) |
| 4364 | { |
| 4365 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4366 | "roam scan control invalid value = %d", |
| 4367 | roamScanControl); |
| 4368 | ret = -EINVAL; |
| 4369 | goto exit; |
| 4370 | } |
| 4371 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4372 | "%s: Received Command to Set roam scan control = %d", __func__, roamScanControl); |
| 4373 | |
| 4374 | sme_SetRoamScanControl((tHalHandle)(pHddCtx->hHal), roamScanControl); |
| 4375 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4376 | #ifdef FEATURE_WLAN_OKC |
| 4377 | else if (strncmp(command, "SETOKCMODE", 10) == 0) |
| 4378 | { |
| 4379 | tANI_U8 *value = command; |
| 4380 | tANI_U8 okcMode = CFG_OKC_FEATURE_ENABLED_DEFAULT; |
| 4381 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4382 | /* Check if the features OKC/ESE/11R are supported simultaneously, |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 4383 | then this operation is not permitted (return FAILURE) */ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4384 | if (sme_getIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal)) && |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 4385 | hdd_is_okc_mode_enabled(pHddCtx) && |
| 4386 | sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal))) |
| 4387 | { |
| 4388 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4389 | "%s: OKC/ESE/11R are supported simultaneously" |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 4390 | " hence this operation is not permitted!", __func__); |
| 4391 | ret = -EPERM; |
| 4392 | goto exit; |
| 4393 | } |
| 4394 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4395 | /* Move pointer to ahead of SETOKCMODE<delimiter> */ |
| 4396 | value = value + 11; |
| 4397 | /* Convert the value from ascii to integer */ |
| 4398 | ret = kstrtou8(value, 10, &okcMode); |
| 4399 | if (ret < 0) |
| 4400 | { |
| 4401 | /* If the input value is greater than max value of datatype, then also |
| 4402 | kstrtou8 fails */ |
| 4403 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4404 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 4405 | CFG_OKC_FEATURE_ENABLED_MIN, |
| 4406 | CFG_OKC_FEATURE_ENABLED_MAX); |
| 4407 | ret = -EINVAL; |
| 4408 | goto exit; |
| 4409 | } |
| 4410 | |
| 4411 | if ((okcMode < CFG_OKC_FEATURE_ENABLED_MIN) || |
| 4412 | (okcMode > CFG_OKC_FEATURE_ENABLED_MAX)) |
| 4413 | { |
| 4414 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4415 | "Okc mode value %d is out of range" |
| 4416 | " (Min: %d Max: %d)", okcMode, |
| 4417 | CFG_OKC_FEATURE_ENABLED_MIN, |
| 4418 | CFG_OKC_FEATURE_ENABLED_MAX); |
| 4419 | ret = -EINVAL; |
| 4420 | goto exit; |
| 4421 | } |
| 4422 | |
| 4423 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4424 | "%s: Received Command to change okc mode = %d", __func__, okcMode); |
| 4425 | |
| 4426 | pHddCtx->cfg_ini->isOkcIniFeatureEnabled = okcMode; |
| 4427 | } |
Srinivas Girigowda | ad34ca9 | 2013-10-22 10:54:29 -0700 | [diff] [blame] | 4428 | #endif /* FEATURE_WLAN_OKC */ |
Mahesh A Saptasagar | ec7d109 | 2015-04-02 13:41:34 +0530 | [diff] [blame] | 4429 | else if (strncmp(command, "GETROAMSCANCONTROL", 18) == 0) |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4430 | { |
| 4431 | tANI_BOOLEAN roamScanControl = sme_GetRoamScanControl((tHalHandle)(pHddCtx->hHal)); |
| 4432 | char extra[32]; |
| 4433 | tANI_U8 len = 0; |
| 4434 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 4435 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 4436 | command, roamScanControl); |
Ratnam Rachuri | 083ada8 | 2015-08-07 14:01:05 +0530 | [diff] [blame] | 4437 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 4438 | if (copy_to_user(priv_data.buf, &extra, len)) { |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4439 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4440 | "%s: failed to copy data to user buffer", __func__); |
| 4441 | ret = -EFAULT; |
| 4442 | goto exit; |
| 4443 | } |
| 4444 | } |
Gopichand Nakkala | 227c7f3 | 2013-06-26 22:44:57 +0530 | [diff] [blame] | 4445 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 4446 | else if (strncmp(command, "ENABLE_PKTFILTER_IPV6", 21) == 0) |
| 4447 | { |
| 4448 | tANI_U8 filterType = 0; |
| 4449 | tANI_U8 *value = command; |
| 4450 | |
| 4451 | /* Move pointer to ahead of ENABLE_PKTFILTER_IPV6<delimiter> */ |
| 4452 | value = value + 22; |
| 4453 | |
| 4454 | /* Convert the value from ascii to integer */ |
| 4455 | ret = kstrtou8(value, 10, &filterType); |
| 4456 | if (ret < 0) |
| 4457 | { |
| 4458 | /* If the input value is greater than max value of datatype, |
| 4459 | * then also kstrtou8 fails |
| 4460 | */ |
| 4461 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4462 | "%s: kstrtou8 failed range ", __func__); |
| 4463 | ret = -EINVAL; |
| 4464 | goto exit; |
| 4465 | } |
| 4466 | |
| 4467 | if (filterType != 0 && filterType != 1) |
| 4468 | { |
| 4469 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4470 | "%s: Accepted Values are 0 and 1 ", __func__); |
| 4471 | ret = -EINVAL; |
| 4472 | goto exit; |
| 4473 | } |
| 4474 | wlan_hdd_setIPv6Filter(WLAN_HDD_GET_CTX(pAdapter), filterType, |
| 4475 | pAdapter->sessionId); |
| 4476 | } |
| 4477 | #endif |
Sundaresan Ramachandran | 76e48e8 | 2013-07-15 13:07:17 +0530 | [diff] [blame] | 4478 | else if (strncmp(command, "BTCOEXMODE", 10) == 0 ) |
| 4479 | { |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 4480 | char *dhcpPhase; |
Satyanarayana Dash | 1faea4f | 2014-09-22 16:21:04 +0530 | [diff] [blame] | 4481 | int ret; |
| 4482 | |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 4483 | dhcpPhase = command + 11; |
| 4484 | if ('1' == *dhcpPhase) |
Sundaresan Ramachandran | 76e48e8 | 2013-07-15 13:07:17 +0530 | [diff] [blame] | 4485 | { |
Deepthi Gowri | bfd1713 | 2014-11-14 17:59:04 +0530 | [diff] [blame] | 4486 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 4487 | FL("send DHCP START indication")); |
c_hpothu | 9b781ba | 2013-12-30 20:57:45 +0530 | [diff] [blame] | 4488 | |
| 4489 | pHddCtx->btCoexModeSet = TRUE; |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 4490 | |
Satyanarayana Dash | 1faea4f | 2014-09-22 16:21:04 +0530 | [diff] [blame] | 4491 | ret = wlan_hdd_scan_abort(pAdapter); |
| 4492 | if (ret < 0) |
| 4493 | { |
| 4494 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4495 | FL("failed to abort existing scan %d"), ret); |
| 4496 | } |
| 4497 | |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 4498 | sme_DHCPStartInd(pHddCtx->hHal, pAdapter->device_mode, |
| 4499 | pAdapter->sessionId); |
Sundaresan Ramachandran | 76e48e8 | 2013-07-15 13:07:17 +0530 | [diff] [blame] | 4500 | } |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 4501 | else if ('2' == *dhcpPhase) |
Sundaresan Ramachandran | 76e48e8 | 2013-07-15 13:07:17 +0530 | [diff] [blame] | 4502 | { |
Deepthi Gowri | bfd1713 | 2014-11-14 17:59:04 +0530 | [diff] [blame] | 4503 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 4504 | FL("send DHCP STOP indication")); |
c_hpothu | 9b781ba | 2013-12-30 20:57:45 +0530 | [diff] [blame] | 4505 | |
| 4506 | pHddCtx->btCoexModeSet = FALSE; |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 4507 | |
| 4508 | sme_DHCPStopInd(pHddCtx->hHal, pAdapter->device_mode, |
| 4509 | pAdapter->sessionId); |
Sundaresan Ramachandran | 76e48e8 | 2013-07-15 13:07:17 +0530 | [diff] [blame] | 4510 | } |
| 4511 | } |
Jeff Johnson | f54df2c | 2013-07-24 11:43:39 -0700 | [diff] [blame] | 4512 | else if (strncmp(command, "SCAN-ACTIVE", 11) == 0) |
| 4513 | { |
Abhishek Singh | 58749d6 | 2016-02-03 15:27:20 +0530 | [diff] [blame] | 4514 | hddLog(LOG1, |
| 4515 | FL("making default scan to ACTIVE")); |
c_hpothu | dbefd3e | 2014-04-28 15:59:47 +0530 | [diff] [blame] | 4516 | pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN; |
Jeff Johnson | f54df2c | 2013-07-24 11:43:39 -0700 | [diff] [blame] | 4517 | } |
| 4518 | else if (strncmp(command, "SCAN-PASSIVE", 12) == 0) |
| 4519 | { |
Abhishek Singh | 58749d6 | 2016-02-03 15:27:20 +0530 | [diff] [blame] | 4520 | hddLog(LOG1, |
| 4521 | FL("making default scan to PASSIVE")); |
c_hpothu | dbefd3e | 2014-04-28 15:59:47 +0530 | [diff] [blame] | 4522 | pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN; |
Jeff Johnson | f54df2c | 2013-07-24 11:43:39 -0700 | [diff] [blame] | 4523 | } |
Hanumantha Reddy Pothula | 212243c | 2013-08-01 17:28:31 +0530 | [diff] [blame] | 4524 | else if (strncmp(command, "GETDWELLTIME", 12) == 0) |
| 4525 | { |
| 4526 | hdd_config_t *pCfg = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini; |
| 4527 | char extra[32]; |
| 4528 | tANI_U8 len = 0; |
| 4529 | |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 4530 | memset(extra, 0, sizeof(extra)); |
| 4531 | ret = hdd_get_dwell_time(pCfg, command, extra, sizeof(extra), &len); |
Ratnam Rachuri | 12d5d46 | 2015-08-07 14:10:23 +0530 | [diff] [blame] | 4532 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 4533 | if (ret != 0 || copy_to_user(priv_data.buf, &extra, len)) { |
Hanumantha Reddy Pothula | 212243c | 2013-08-01 17:28:31 +0530 | [diff] [blame] | 4534 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4535 | "%s: failed to copy data to user buffer", __func__); |
| 4536 | ret = -EFAULT; |
| 4537 | goto exit; |
| 4538 | } |
| 4539 | ret = len; |
| 4540 | } |
| 4541 | else if (strncmp(command, "SETDWELLTIME", 12) == 0) |
| 4542 | { |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 4543 | ret = hdd_set_dwell_time(pAdapter, command); |
Hanumantha Reddy Pothula | 212243c | 2013-08-01 17:28:31 +0530 | [diff] [blame] | 4544 | } |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 4545 | else if ( strncasecmp(command, "MIRACAST", 8) == 0 ) |
| 4546 | { |
| 4547 | tANI_U8 filterType = 0; |
| 4548 | tANI_U8 *value; |
| 4549 | value = command + 9; |
| 4550 | |
| 4551 | /* Convert the value from ascii to integer */ |
| 4552 | ret = kstrtou8(value, 10, &filterType); |
| 4553 | if (ret < 0) |
| 4554 | { |
| 4555 | /* If the input value is greater than max value of datatype, |
| 4556 | * then also kstrtou8 fails |
| 4557 | */ |
| 4558 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4559 | "%s: kstrtou8 failed range ", __func__); |
| 4560 | ret = -EINVAL; |
| 4561 | goto exit; |
| 4562 | } |
| 4563 | if ((filterType < WLAN_HDD_DRIVER_MIRACAST_CFG_MIN_VAL ) || |
| 4564 | (filterType > WLAN_HDD_DRIVER_MIRACAST_CFG_MAX_VAL)) |
| 4565 | { |
| 4566 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4567 | "%s: Accepted Values are 0 to 2. 0-Disabled, 1-Source," |
| 4568 | " 2-Sink ", __func__); |
| 4569 | ret = -EINVAL; |
| 4570 | goto exit; |
| 4571 | } |
| 4572 | //Filtertype value should be either 0-Disabled, 1-Source, 2-sink |
| 4573 | pHddCtx->drvr_miracast = filterType; |
Kaushik, Sushant | 9612244 | 2014-10-21 16:40:18 +0530 | [diff] [blame] | 4574 | pScanInfo = &pHddCtx->scan_info; |
| 4575 | if (filterType && pScanInfo != NULL && |
| 4576 | pHddCtx->scan_info.mScanPending) |
| 4577 | { |
| 4578 | /*Miracast Session started. Abort Scan */ |
| 4579 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4580 | "%s, Aborting Scan For Miracast",__func__); |
| 4581 | hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId, |
| 4582 | eCSR_SCAN_ABORT_DEFAULT); |
| 4583 | } |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 4584 | hdd_tx_rx_pkt_cnt_stat_timer_handler(pHddCtx); |
Ganesh Kondabattini | 8f6e3b3 | 2014-08-25 16:07:54 +0530 | [diff] [blame] | 4585 | sme_SetMiracastMode(pHddCtx->hHal, pHddCtx->drvr_miracast); |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 4586 | } |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 4587 | else if (strncmp(command, "SETMCRATE", 9) == 0) |
| 4588 | { |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 4589 | tANI_U8 *value = command; |
| 4590 | int targetRate; |
Leo Chang | 1f98cbd | 2013-10-17 15:03:52 -0700 | [diff] [blame] | 4591 | tSirRateUpdateInd *rateUpdate; |
| 4592 | eHalStatus status; |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 4593 | |
| 4594 | /* Only valid for SAP mode */ |
| 4595 | if (WLAN_HDD_SOFTAP != pAdapter->device_mode) |
| 4596 | { |
| 4597 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4598 | "%s: SAP mode is not running", __func__); |
| 4599 | ret = -EFAULT; |
| 4600 | goto exit; |
| 4601 | } |
| 4602 | |
| 4603 | /* Move pointer to ahead of SETMCRATE<delimiter> */ |
| 4604 | /* input value is in units of hundred kbps */ |
| 4605 | value = value + 10; |
| 4606 | /* Convert the value from ascii to integer, decimal base */ |
| 4607 | ret = kstrtouint(value, 10, &targetRate); |
| 4608 | |
Leo Chang | 1f98cbd | 2013-10-17 15:03:52 -0700 | [diff] [blame] | 4609 | rateUpdate = (tSirRateUpdateInd *)vos_mem_malloc(sizeof(tSirRateUpdateInd)); |
| 4610 | if (NULL == rateUpdate) |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 4611 | { |
Leo Chang | 1f98cbd | 2013-10-17 15:03:52 -0700 | [diff] [blame] | 4612 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4613 | "%s: SETMCRATE indication alloc fail", __func__); |
| 4614 | ret = -EFAULT; |
| 4615 | goto exit; |
| 4616 | } |
| 4617 | vos_mem_zero(rateUpdate, sizeof(tSirRateUpdateInd )); |
| 4618 | |
| 4619 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4620 | "MC Target rate %d", targetRate); |
| 4621 | /* Ignore unicast */ |
| 4622 | rateUpdate->ucastDataRate = -1; |
| 4623 | rateUpdate->mcastDataRate24GHz = targetRate; |
| 4624 | rateUpdate->mcastDataRate5GHz = targetRate; |
| 4625 | rateUpdate->mcastDataRate24GHzTxFlag = 0; |
| 4626 | rateUpdate->mcastDataRate5GHzTxFlag = 0; |
| 4627 | status = sme_SendRateUpdateInd(pHddCtx->hHal, rateUpdate); |
| 4628 | if (eHAL_STATUS_SUCCESS != status) |
| 4629 | { |
| 4630 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4631 | "%s: SET_MC_RATE failed", __func__); |
| 4632 | vos_mem_free(rateUpdate); |
| 4633 | ret = -EFAULT; |
| 4634 | goto exit; |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 4635 | } |
| 4636 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 4637 | #ifdef FEATURE_WLAN_BATCH_SCAN |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 4638 | else if (strncmp(command, "WLS_BATCHING", 12) == 0) |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 4639 | { |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 4640 | ret = hdd_handle_batch_scan_ioctl(pAdapter, &priv_data, command); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 4641 | } |
| 4642 | #endif |
Abhishek Singh | 00b7197 | 2016-01-07 10:51:04 +0530 | [diff] [blame] | 4643 | #ifdef WLAN_FEATURE_RMC |
| 4644 | else if ((strncasecmp(command, "SETIBSSBEACONOUIDATA", 20) == 0) && |
| 4645 | (WLAN_HDD_IBSS == pAdapter->device_mode)) |
| 4646 | { |
| 4647 | int i = 0; |
| 4648 | tANI_U8 *ibss_ie; |
| 4649 | tANI_U32 command_len; |
| 4650 | tANI_U8 *value = command; |
| 4651 | tHalHandle hHal = pHddCtx->hHal; |
| 4652 | tpAniSirGlobal pMac = PMAC_STRUCT(hHal); |
| 4653 | tANI_U32 ibss_ie_length; |
| 4654 | tANI_U32 len, present; |
| 4655 | tANI_U8 *addIE; |
| 4656 | tANI_U8 *addIEData; |
| 4657 | |
| 4658 | hddLog(LOG1, |
| 4659 | FL(" received command %s"),((char *) value)); |
| 4660 | /* validate argument of command */ |
| 4661 | if (strlen(value) <= 21) |
| 4662 | { |
| 4663 | hddLog(LOGE, |
| 4664 | FL("No arguements in command length %zu"), strlen(value)); |
| 4665 | ret = -EFAULT; |
| 4666 | goto exit; |
| 4667 | } |
| 4668 | |
| 4669 | /* moving to arguments of commands */ |
| 4670 | value = value + 21; |
| 4671 | command_len = strlen(value); |
| 4672 | |
| 4673 | /* oui_data can't be less than 3 bytes */ |
| 4674 | if (command_len <= (2 * WLAN_HDD_IBSS_MIN_OUI_DATA_LENGTH)) |
| 4675 | { |
| 4676 | hddLog(LOGE, |
| 4677 | FL("Invalid SETIBSSBEACONOUIDATA command length %d"), |
| 4678 | command_len); |
| 4679 | ret = -EFAULT; |
| 4680 | goto exit; |
| 4681 | } |
| 4682 | ibss_ie = vos_mem_malloc(command_len); |
| 4683 | if (!ibss_ie) { |
| 4684 | hddLog(LOGE, |
| 4685 | FL("Could not allocate memory for command length %d"), |
| 4686 | command_len); |
| 4687 | ret = -ENOMEM; |
| 4688 | goto exit; |
| 4689 | } |
| 4690 | vos_mem_zero(ibss_ie, command_len); |
| 4691 | |
| 4692 | ibss_ie_length = hdd_parse_set_ibss_oui_data_command(value, ibss_ie, |
| 4693 | command_len); |
| 4694 | if (ibss_ie_length < (2 * WLAN_HDD_IBSS_MIN_OUI_DATA_LENGTH)) { |
| 4695 | hddLog(LOGE, FL("Could not parse command %s return length %d"), |
| 4696 | value, ibss_ie_length); |
| 4697 | ret = -EFAULT; |
| 4698 | vos_mem_free(ibss_ie); |
| 4699 | goto exit; |
| 4700 | } |
| 4701 | |
| 4702 | hddLog(LOG1, FL("ibss_ie length %d ibss_ie:"), ibss_ie_length); |
| 4703 | while (i < ibss_ie_length) |
| 4704 | hddLog(LOG1, FL("0x%x"), ibss_ie[i++]); |
| 4705 | |
| 4706 | /* Populate Vendor IE in Beacon */ |
| 4707 | if ((ccmCfgGetInt(hHal, |
| 4708 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, |
| 4709 | &present)) != eHAL_STATUS_SUCCESS) |
| 4710 | { |
| 4711 | hddLog(LOGE, |
| 4712 | FL("unable to ftch WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG")); |
| 4713 | ret = -EFAULT; |
| 4714 | vos_mem_free(ibss_ie); |
| 4715 | goto exit; |
| 4716 | } |
| 4717 | |
| 4718 | addIE = vos_mem_malloc(WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA_LEN); |
| 4719 | if (!addIE) { |
| 4720 | hddLog(LOGE, |
| 4721 | FL("Could not allocate memory for command length %d"), |
| 4722 | command_len); |
| 4723 | vos_mem_free(ibss_ie); |
| 4724 | ret = -ENOMEM; |
| 4725 | goto exit; |
| 4726 | } |
| 4727 | vos_mem_zero(addIE, WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA_LEN); |
| 4728 | |
| 4729 | if (present) |
| 4730 | { |
| 4731 | if ((wlan_cfgGetStrLen(pMac, |
| 4732 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, &len)) != eSIR_SUCCESS) |
| 4733 | { |
| 4734 | hddLog(LOGE, |
| 4735 | FL("unable to fetch WNI_CFG_PROBE_RSP_BCN_ADDNIE_LEN")); |
| 4736 | ret = -EFAULT; |
| 4737 | vos_mem_free(ibss_ie); |
| 4738 | vos_mem_free(addIE); |
| 4739 | goto exit; |
| 4740 | } |
| 4741 | |
| 4742 | if (len <= WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA_LEN && len && |
| 4743 | ((len + ibss_ie_length) <= |
| 4744 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA_LEN)) |
| 4745 | { |
| 4746 | if ((ccmCfgGetStr(hHal, |
| 4747 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, addIE, &len)) |
| 4748 | != eHAL_STATUS_SUCCESS) |
| 4749 | { |
| 4750 | hddLog(LOGE, |
| 4751 | FL("unable to fetch WNI_PROBE_RSP_BCN_ADDNIE_DATA")); |
| 4752 | ret = -EFAULT; |
| 4753 | vos_mem_free(ibss_ie); |
| 4754 | vos_mem_free(addIE); |
| 4755 | goto exit; |
| 4756 | } |
| 4757 | else |
| 4758 | { |
| 4759 | /* Curruntly only WPA IE is added before Vendor IE |
| 4760 | * so we can blindly place the Vendor IE after WPA |
| 4761 | * IE. If no WPA IE found replace all with Vendor IE. |
| 4762 | */ |
| 4763 | len = hdd_find_ibss_wpa_ie_pos(addIE, len); |
| 4764 | } |
| 4765 | } |
| 4766 | else |
| 4767 | { |
| 4768 | hddLog(LOGE, |
| 4769 | FL("IE len exceed limit len %d,ibss_ie_length %d "), |
| 4770 | len, ibss_ie_length); |
| 4771 | ret = -EFAULT; |
| 4772 | vos_mem_free(addIE); |
| 4773 | vos_mem_free(ibss_ie); |
| 4774 | goto exit; |
| 4775 | } |
| 4776 | } |
| 4777 | else { |
| 4778 | len = 0; |
| 4779 | } |
| 4780 | |
| 4781 | vos_mem_copy (addIE + len , ibss_ie, ibss_ie_length); |
| 4782 | len += ibss_ie_length; |
| 4783 | |
| 4784 | if (ccmCfgSetStr(hHal, |
| 4785 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, addIE, len, NULL, |
| 4786 | eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS) |
| 4787 | { |
| 4788 | hddLog(LOGE, |
| 4789 | FL("unable to set WNI_CFG_PRBE_RSP_BCN_ADDNIE_DATA")); |
| 4790 | ret = -EFAULT; |
| 4791 | vos_mem_free(ibss_ie); |
| 4792 | vos_mem_free(addIE); |
| 4793 | goto exit; |
| 4794 | } |
| 4795 | vos_mem_free(addIE); |
| 4796 | if (ccmCfgSetInt(hHal, |
| 4797 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL, |
| 4798 | eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS) |
| 4799 | { |
| 4800 | hddLog(LOGE, |
| 4801 | FL("unble to set WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG")); |
| 4802 | ret = -EFAULT; |
| 4803 | vos_mem_free(ibss_ie); |
| 4804 | goto exit; |
| 4805 | } |
| 4806 | |
| 4807 | /* Populate Vendor IE in probe resp */ |
| 4808 | if ((ccmCfgGetInt(hHal, |
| 4809 | WNI_CFG_PROBE_RSP_ADDNIE_FLAG, |
| 4810 | &present)) != eHAL_STATUS_SUCCESS) |
| 4811 | { |
| 4812 | hddLog(LOGE, |
| 4813 | FL("unable to fetch WNI_CFG_PROBE_RSP_ADDNIE_FLAG")); |
| 4814 | ret = -EFAULT; |
| 4815 | vos_mem_free(ibss_ie); |
| 4816 | goto exit; |
| 4817 | } |
| 4818 | |
| 4819 | addIEData = vos_mem_malloc(WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN); |
| 4820 | if (!addIEData) { |
| 4821 | hddLog(LOGE, |
| 4822 | FL("Could not allocate memory for command length %d"), |
| 4823 | command_len); |
| 4824 | vos_mem_free(ibss_ie); |
| 4825 | ret = -ENOMEM; |
| 4826 | goto exit; |
| 4827 | } |
| 4828 | vos_mem_zero(addIEData, WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN); |
| 4829 | |
| 4830 | if (present) { |
| 4831 | if (eSIR_SUCCESS != wlan_cfgGetStrLen(pMac, |
| 4832 | WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &len)) { |
| 4833 | hddLog(LOGE, |
| 4834 | FL("unable to fetch WNI_CFG_PROBE_RSP_ADDNIE_DATA1")); |
| 4835 | ret = -EFAULT; |
| 4836 | vos_mem_free(ibss_ie); |
| 4837 | vos_mem_free(addIEData); |
| 4838 | goto exit; |
| 4839 | } |
| 4840 | if (len < WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN && len && |
| 4841 | (ibss_ie_length + len) <= |
| 4842 | WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN) { |
| 4843 | |
| 4844 | if ((ccmCfgGetStr(hHal, |
| 4845 | WNI_CFG_PROBE_RSP_ADDNIE_DATA1, addIEData, &len)) |
| 4846 | != eHAL_STATUS_SUCCESS) { |
| 4847 | hddLog(LOGE, |
| 4848 | FL("unable fetch WNI_CFG_PROBE_RSP_ADDNIE_DATA1")); |
| 4849 | ret = -EFAULT; |
| 4850 | vos_mem_free(ibss_ie); |
| 4851 | vos_mem_free(addIEData); |
| 4852 | goto exit; |
| 4853 | } |
| 4854 | else { |
| 4855 | /* Curruntly only WPA IE is added before Vendor IE |
| 4856 | * so we can blindly place the Vendor IE after WPA |
| 4857 | * IE. If no WPA IE found replace all with Vendor IE. |
| 4858 | */ |
| 4859 | len = hdd_find_ibss_wpa_ie_pos(addIEData, len); |
| 4860 | } |
| 4861 | } |
| 4862 | else |
| 4863 | { |
| 4864 | hddLog(LOGE, |
| 4865 | FL("IE len exceed limit len %d,ibss_ie_length %d "), |
| 4866 | len, ibss_ie_length); |
| 4867 | ret = -EFAULT; |
| 4868 | vos_mem_free(addIEData); |
| 4869 | vos_mem_free(ibss_ie); |
| 4870 | goto exit; |
| 4871 | } |
| 4872 | } /* probe rsp ADD IE present */ |
| 4873 | else { |
| 4874 | /* probe rsp add IE is not present */ |
| 4875 | len = 0; |
| 4876 | } |
| 4877 | |
| 4878 | vos_mem_copy(addIEData +len , ibss_ie, ibss_ie_length); |
| 4879 | len += ibss_ie_length; |
| 4880 | |
| 4881 | vos_mem_free(ibss_ie); |
| 4882 | |
| 4883 | if (ccmCfgSetStr(hHal, |
| 4884 | WNI_CFG_PROBE_RSP_ADDNIE_DATA1, |
| 4885 | (tANI_U8*)(addIEData), |
| 4886 | len, NULL, |
| 4887 | eANI_BOOLEAN_FALSE) |
| 4888 | == eHAL_STATUS_FAILURE) { |
| 4889 | hddLog(LOGE, |
| 4890 | FL("unable to copy to WNI_CFG_PROBE_RSP_ADDNIE_DATA1")); |
| 4891 | ret = -EFAULT; |
| 4892 | vos_mem_free(addIEData); |
| 4893 | goto exit; |
| 4894 | } |
| 4895 | vos_mem_free(addIEData); |
| 4896 | if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 4897 | WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL, |
| 4898 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 4899 | { |
| 4900 | hddLog(LOGE, |
| 4901 | FL("unable to copy WNI_CFG_PROBE_RSP_ADDNIE_FLAG")); |
| 4902 | ret = -EFAULT; |
| 4903 | goto exit; |
| 4904 | } |
| 4905 | } |
| 4906 | else if (strncasecmp(command, "SETRMCENABLE", 12) == 0) |
| 4907 | { |
| 4908 | tANI_U8 *value = command; |
| 4909 | tANI_U8 ucRmcEnable = 0; |
| 4910 | int status; |
| 4911 | |
| 4912 | if ((WLAN_HDD_IBSS != pAdapter->device_mode) && |
| 4913 | (WLAN_HDD_SOFTAP != pAdapter->device_mode)) |
| 4914 | { |
| 4915 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4916 | "Received SETRMCENABLE command in invalid mode %d " |
| 4917 | "SETRMCENABLE command is only allowed in IBSS or SOFTAP mode", |
| 4918 | pAdapter->device_mode); |
| 4919 | ret = -EINVAL; |
| 4920 | goto exit; |
| 4921 | } |
| 4922 | |
| 4923 | status = hdd_parse_setrmcenable_command(value, &ucRmcEnable); |
| 4924 | if (status) |
| 4925 | { |
| 4926 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4927 | "Invalid SETRMCENABLE command "); |
| 4928 | ret = -EINVAL; |
| 4929 | goto exit; |
| 4930 | } |
| 4931 | |
| 4932 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4933 | "%s: ucRmcEnable %d ", __func__, ucRmcEnable); |
| 4934 | |
| 4935 | if (TRUE == ucRmcEnable) |
| 4936 | { |
| 4937 | status = sme_EnableRMC( (tHalHandle)(pHddCtx->hHal), |
| 4938 | pAdapter->sessionId ); |
| 4939 | } |
| 4940 | else if(FALSE == ucRmcEnable) |
| 4941 | { |
| 4942 | status = sme_DisableRMC( (tHalHandle)(pHddCtx->hHal), |
| 4943 | pAdapter->sessionId ); |
| 4944 | } |
| 4945 | else |
| 4946 | { |
| 4947 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4948 | "Invalid SETRMCENABLE command %d", ucRmcEnable); |
| 4949 | ret = -EINVAL; |
| 4950 | goto exit; |
| 4951 | } |
| 4952 | |
| 4953 | if (VOS_STATUS_SUCCESS != status) |
| 4954 | { |
| 4955 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4956 | "%s: SETRMC %d failed status %d", __func__, ucRmcEnable, |
| 4957 | status); |
| 4958 | ret = -EINVAL; |
| 4959 | goto exit; |
| 4960 | } |
| 4961 | } |
| 4962 | else if (strncasecmp(command, "SETRMCACTIONPERIOD", 18) == 0) |
| 4963 | { |
| 4964 | tANI_U8 *value = command; |
| 4965 | tANI_U32 uActionPeriod = 0; |
| 4966 | int status; |
| 4967 | |
| 4968 | if ((WLAN_HDD_IBSS != pAdapter->device_mode) && |
| 4969 | (WLAN_HDD_SOFTAP != pAdapter->device_mode)) |
| 4970 | { |
| 4971 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4972 | "Received SETRMC command in invalid mode %d " |
| 4973 | "SETRMC command is only allowed in IBSS or SOFTAP mode", |
| 4974 | pAdapter->device_mode); |
| 4975 | ret = -EINVAL; |
| 4976 | goto exit; |
| 4977 | } |
| 4978 | |
| 4979 | status = hdd_parse_setrmcactionperiod_command(value, &uActionPeriod); |
| 4980 | if (status) |
| 4981 | { |
| 4982 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4983 | "Invalid SETRMCACTIONPERIOD command "); |
| 4984 | ret = -EINVAL; |
| 4985 | goto exit; |
| 4986 | } |
| 4987 | |
| 4988 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4989 | "%s: uActionPeriod %d ", __func__, uActionPeriod); |
| 4990 | |
| 4991 | if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_RMC_ACTION_PERIOD_FREQUENCY, |
| 4992 | uActionPeriod, NULL, eANI_BOOLEAN_FALSE)) |
| 4993 | { |
| 4994 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4995 | "%s: Could not set SETRMCACTIONPERIOD %d", __func__, uActionPeriod); |
| 4996 | ret = -EINVAL; |
| 4997 | goto exit; |
| 4998 | } |
| 4999 | |
| 5000 | } |
| 5001 | else if (strncasecmp(command, "GETIBSSPEERINFOALL", 18) == 0) |
| 5002 | { |
| 5003 | /* Peer Info All Command */ |
| 5004 | int status = eHAL_STATUS_SUCCESS; |
| 5005 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 5006 | char *extra = NULL; |
| 5007 | int idx = 0, length = 0; |
| 5008 | v_MACADDR_t *macAddr; |
| 5009 | v_U32_t txRateMbps = 0, numOfBytestoPrint = 0; |
| 5010 | |
| 5011 | if (WLAN_HDD_IBSS == pAdapter->device_mode) |
| 5012 | { |
| 5013 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 5014 | } |
| 5015 | else |
| 5016 | { |
| 5017 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5018 | "%s: pAdapter is not valid for this device mode", |
| 5019 | __func__); |
| 5020 | ret = -EINVAL; |
| 5021 | goto exit; |
| 5022 | } |
| 5023 | |
| 5024 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5025 | "%s: Received GETIBSSPEERINFOALL Command", __func__); |
| 5026 | |
| 5027 | |
| 5028 | /* Handle the command */ |
| 5029 | status = hdd_cfg80211_get_ibss_peer_info_all(pAdapter); |
| 5030 | if (VOS_STATUS_SUCCESS == status) |
| 5031 | { |
| 5032 | /* The variable extra needed to be allocated on the heap since |
| 5033 | * amount of memory required to copy the data for 32 devices |
| 5034 | * exceeds the size of 1024 bytes of default stack size. On |
| 5035 | * 64 bit devices, the default max stack size of 2048 bytes |
| 5036 | */ |
| 5037 | extra = kmalloc(WLAN_MAX_BUF_SIZE, GFP_KERNEL); |
| 5038 | |
| 5039 | if (NULL == extra) |
| 5040 | { |
| 5041 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5042 | "%s:kmalloc failed", __func__); |
| 5043 | ret = -EINVAL; |
| 5044 | goto exit; |
| 5045 | } |
| 5046 | |
| 5047 | /* Copy number of stations */ |
| 5048 | length = scnprintf( extra, WLAN_MAX_BUF_SIZE, "%d ", |
| 5049 | pHddStaCtx->ibss_peer_info.numIBSSPeers); |
| 5050 | numOfBytestoPrint = length; |
| 5051 | for (idx = 0; idx < pHddStaCtx->ibss_peer_info.numIBSSPeers; idx++) |
| 5052 | { |
| 5053 | macAddr = |
| 5054 | hdd_wlan_get_ibss_mac_addr_from_staid(pAdapter, |
| 5055 | pHddStaCtx->ibss_peer_info.ibssPeerList[idx].staIdx); |
| 5056 | if (NULL != macAddr) |
| 5057 | { |
| 5058 | txRateMbps = |
| 5059 | ((pHddStaCtx->ibss_peer_info.ibssPeerList[idx].txRate)*500*1000)/1000000; |
| 5060 | |
| 5061 | length += scnprintf( (extra + length), WLAN_MAX_BUF_SIZE - length, |
| 5062 | "%02x:%02x:%02x:%02x:%02x:%02x %d %d ", |
| 5063 | macAddr->bytes[0], macAddr->bytes[1], macAddr->bytes[2], |
| 5064 | macAddr->bytes[3], macAddr->bytes[4], macAddr->bytes[5], |
| 5065 | (int)txRateMbps, |
| 5066 | (int)pHddStaCtx->ibss_peer_info.ibssPeerList[idx].rssi); |
| 5067 | } |
| 5068 | else |
| 5069 | { |
| 5070 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5071 | "%s: MAC ADDR is NULL for staIdx: %d", __func__, |
| 5072 | pHddStaCtx->ibss_peer_info.ibssPeerList[idx].staIdx); |
| 5073 | } |
| 5074 | |
| 5075 | /* |
| 5076 | * VOS_TRACE() macro has limitation of 512 bytes for the print |
| 5077 | * buffer. Hence printing the data in two chunks. The first chunk |
| 5078 | * will have the data for 16 devices and the second chunk will |
| 5079 | * have the rest. |
| 5080 | */ |
| 5081 | if (idx < NUM_OF_STA_DATA_TO_PRINT) |
| 5082 | { |
| 5083 | numOfBytestoPrint = length; |
| 5084 | } |
| 5085 | } |
| 5086 | |
| 5087 | /* |
| 5088 | * Copy the data back into buffer, if the data to copy is |
| 5089 | * morethan 512 bytes than we will split the data and do |
| 5090 | * it in two shots |
| 5091 | */ |
| 5092 | if (copy_to_user(priv_data.buf, extra, numOfBytestoPrint)) |
| 5093 | { |
| 5094 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5095 | "%s: Copy into user data buffer failed ", __func__); |
| 5096 | ret = -EFAULT; |
| 5097 | kfree(extra); |
| 5098 | goto exit; |
| 5099 | } |
| 5100 | priv_data.buf[numOfBytestoPrint] = '\0'; |
| 5101 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, |
| 5102 | "%s", priv_data.buf); |
| 5103 | |
| 5104 | if (length > numOfBytestoPrint) |
| 5105 | { |
| 5106 | if (copy_to_user(priv_data.buf + numOfBytestoPrint, |
| 5107 | extra + numOfBytestoPrint, |
| 5108 | length - numOfBytestoPrint + 1)) |
| 5109 | { |
| 5110 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5111 | "%s: Copy into user data buffer failed ", __func__); |
| 5112 | ret = -EFAULT; |
| 5113 | kfree(extra); |
| 5114 | goto exit; |
| 5115 | } |
| 5116 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, |
| 5117 | "%s", &priv_data.buf[numOfBytestoPrint]); |
| 5118 | } |
| 5119 | |
| 5120 | /* Free temporary buffer */ |
| 5121 | kfree(extra); |
| 5122 | } |
| 5123 | |
| 5124 | else |
| 5125 | { |
| 5126 | /* Command failed, log error */ |
| 5127 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5128 | "%s: GETIBSSPEERINFOALL command failed with status code %d", |
| 5129 | __func__, status); |
| 5130 | ret = -EINVAL; |
| 5131 | goto exit; |
| 5132 | } |
| 5133 | ret = 0; |
| 5134 | } |
| 5135 | else if(strncasecmp(command, "GETIBSSPEERINFO", 15) == 0) |
| 5136 | { |
| 5137 | /* Peer Info <Peer Addr> command */ |
| 5138 | tANI_U8 *value = command; |
| 5139 | VOS_STATUS status; |
| 5140 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 5141 | char extra[128] = { 0 }; |
| 5142 | v_U32_t length = 0; |
| 5143 | v_U8_t staIdx = 0; |
| 5144 | v_U32_t txRateMbps = 0; |
| 5145 | v_MACADDR_t peerMacAddr; |
| 5146 | |
| 5147 | if (WLAN_HDD_IBSS == pAdapter->device_mode) |
| 5148 | { |
| 5149 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 5150 | } |
| 5151 | else |
| 5152 | { |
| 5153 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5154 | "%s: pAdapter is not valid for this device mode", |
| 5155 | __func__); |
| 5156 | ret = -EINVAL; |
| 5157 | goto exit; |
| 5158 | } |
| 5159 | |
| 5160 | /* if there are no peers, no need to continue with the command */ |
| 5161 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5162 | "%s: Received GETIBSSPEERINFO Command", __func__); |
| 5163 | |
| 5164 | if (eConnectionState_IbssConnected != pHddStaCtx->conn_info.connState) |
| 5165 | { |
| 5166 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5167 | "%s:No IBSS Peers coalesced", __func__); |
| 5168 | ret = -EINVAL; |
| 5169 | goto exit; |
| 5170 | } |
| 5171 | |
| 5172 | /* Parse the incoming command buffer */ |
| 5173 | status = hdd_parse_get_ibss_peer_info(value, &peerMacAddr); |
| 5174 | if (VOS_STATUS_SUCCESS != status) |
| 5175 | { |
| 5176 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5177 | "%s: Invalid GETIBSSPEERINFO command", __func__); |
| 5178 | ret = -EINVAL; |
| 5179 | goto exit; |
| 5180 | } |
| 5181 | |
| 5182 | /* Get station index for the peer mac address */ |
| 5183 | hdd_Ibss_GetStaId(pHddStaCtx, &peerMacAddr, &staIdx); |
| 5184 | |
| 5185 | if (staIdx > HDD_MAX_NUM_IBSS_STA) |
| 5186 | { |
| 5187 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5188 | "%s: Invalid StaIdx %d returned", __func__, staIdx); |
| 5189 | ret = -EINVAL; |
| 5190 | goto exit; |
| 5191 | } |
| 5192 | |
| 5193 | /* Handle the command */ |
| 5194 | status = hdd_cfg80211_get_ibss_peer_info(pAdapter, staIdx); |
| 5195 | if (VOS_STATUS_SUCCESS == status) |
| 5196 | { |
| 5197 | v_U32_t txRate = pHddStaCtx->ibss_peer_info.ibssPeerList[0].txRate; |
| 5198 | txRateMbps = (txRate * 500 * 1000)/1000000; |
| 5199 | |
| 5200 | length = scnprintf( extra, sizeof(extra), "%d %d", (int)txRateMbps, |
| 5201 | (int)pHddStaCtx->ibss_peer_info.ibssPeerList[0].rssi); |
| 5202 | |
| 5203 | /* Copy the data back into buffer */ |
| 5204 | if (copy_to_user(priv_data.buf, &extra, length+ 1)) |
| 5205 | { |
| 5206 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5207 | "%s: copy data to user buffer failed GETIBSSPEERINFO command", |
| 5208 | __func__); |
| 5209 | ret = -EFAULT; |
| 5210 | goto exit; |
| 5211 | } |
| 5212 | } |
| 5213 | else |
| 5214 | { |
| 5215 | /* Command failed, log error */ |
| 5216 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5217 | "%s: GETIBSSPEERINFO command failed with status code %d", |
| 5218 | __func__, status); |
| 5219 | ret = -EINVAL; |
| 5220 | goto exit; |
| 5221 | } |
| 5222 | |
| 5223 | /* Success ! */ |
| 5224 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, |
| 5225 | "%s", priv_data.buf); |
| 5226 | ret = 0; |
| 5227 | } |
| 5228 | else if (strncasecmp(command, "SETRMCTXRATE", 12) == 0) |
| 5229 | { |
| 5230 | tANI_U8 *value = command; |
| 5231 | tANI_U32 uRate = 0; |
| 5232 | tTxrateinfoflags txFlags = 0; |
| 5233 | tSirRateUpdateInd *rateUpdateParams; |
| 5234 | int status; |
| 5235 | |
| 5236 | if ((WLAN_HDD_IBSS != pAdapter->device_mode) && |
| 5237 | (WLAN_HDD_SOFTAP != pAdapter->device_mode)) |
| 5238 | { |
| 5239 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5240 | "Received SETRMCTXRATE command in invalid mode %d " |
| 5241 | "SETRMC command is only allowed in IBSS or SOFTAP mode", |
| 5242 | pAdapter->device_mode); |
| 5243 | ret = -EINVAL; |
| 5244 | goto exit; |
| 5245 | } |
| 5246 | |
| 5247 | status = hdd_parse_setrmcrate_command(value, &uRate, &txFlags); |
| 5248 | if (status) |
| 5249 | { |
| 5250 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5251 | "Invalid SETRMCTXRATE command "); |
| 5252 | ret = -EINVAL; |
| 5253 | goto exit; |
| 5254 | } |
| 5255 | |
| 5256 | rateUpdateParams = vos_mem_malloc(sizeof(tSirRateUpdateInd)); |
| 5257 | if (NULL == rateUpdateParams) |
| 5258 | { |
| 5259 | ret = -EINVAL; |
| 5260 | goto exit; |
| 5261 | } |
| 5262 | |
| 5263 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5264 | "%s: uRate %d ", __func__, uRate); |
| 5265 | |
| 5266 | vos_mem_zero(rateUpdateParams, sizeof(tSirRateUpdateInd )); |
| 5267 | |
| 5268 | /* -1 implies ignore this param */ |
| 5269 | rateUpdateParams->ucastDataRate = -1; |
| 5270 | |
| 5271 | /* |
| 5272 | * Fill the user specifieed RMC rate param |
| 5273 | * and the derived tx flags. |
| 5274 | */ |
| 5275 | rateUpdateParams->rmcDataRate = uRate; |
| 5276 | rateUpdateParams->rmcDataRateTxFlag = txFlags; |
| 5277 | |
| 5278 | status = sme_SendRateUpdateInd((tHalHandle)(pHddCtx->hHal), rateUpdateParams); |
| 5279 | } |
| 5280 | else if (strncasecmp(command, "SETIBSSTXFAILEVENT", 18) == 0 ) |
| 5281 | { |
| 5282 | char *value; |
| 5283 | tANI_U8 tx_fail_count = 0; |
| 5284 | tANI_U16 pid = 0; |
| 5285 | |
| 5286 | value = command; |
| 5287 | |
| 5288 | ret = hdd_ParseIBSSTXFailEventParams(value, &tx_fail_count, &pid); |
| 5289 | |
| 5290 | if (0 != ret) |
| 5291 | { |
| 5292 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 5293 | "%s: Failed to parse SETIBSSTXFAILEVENT arguments", |
| 5294 | __func__); |
| 5295 | goto exit; |
| 5296 | } |
| 5297 | |
| 5298 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: tx_fail_cnt=%hhu, pid=%hu", |
| 5299 | __func__, tx_fail_count, pid); |
| 5300 | |
| 5301 | if (0 == tx_fail_count) |
| 5302 | { |
| 5303 | // Disable TX Fail Indication |
| 5304 | if (eHAL_STATUS_SUCCESS == |
| 5305 | sme_TXFailMonitorStartStopInd(pHddCtx->hHal, |
| 5306 | tx_fail_count, |
| 5307 | NULL)) |
| 5308 | { |
| 5309 | cesium_pid = 0; |
| 5310 | } |
| 5311 | else |
| 5312 | { |
| 5313 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5314 | "%s: failed to disable TX Fail Event ", __func__); |
| 5315 | ret = -EINVAL; |
| 5316 | } |
| 5317 | } |
| 5318 | else |
| 5319 | { |
| 5320 | if (eHAL_STATUS_SUCCESS == |
| 5321 | sme_TXFailMonitorStartStopInd(pHddCtx->hHal, |
| 5322 | tx_fail_count, |
| 5323 | (void*)hdd_tx_fail_ind_callback)) |
| 5324 | { |
| 5325 | cesium_pid = pid; |
| 5326 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5327 | "%s: Registered Cesium pid %u", __func__, |
| 5328 | cesium_pid); |
| 5329 | } |
| 5330 | else |
| 5331 | { |
| 5332 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5333 | "%s: Failed to enable TX Fail Monitoring", __func__); |
| 5334 | ret = -EINVAL; |
| 5335 | } |
| 5336 | } |
| 5337 | } |
| 5338 | |
| 5339 | #endif /* WLAN_FEATURE_RMC */ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 5340 | #if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD) |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 5341 | else if (strncmp(command, "SETCCXROAMSCANCHANNELS", 22) == 0) |
| 5342 | { |
| 5343 | tANI_U8 *value = command; |
| 5344 | tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0}; |
| 5345 | tANI_U8 numChannels = 0; |
| 5346 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 5347 | |
| 5348 | status = hdd_parse_channellist(value, ChannelList, &numChannels); |
| 5349 | if (eHAL_STATUS_SUCCESS != status) |
| 5350 | { |
| 5351 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5352 | "%s: Failed to parse channel list information", __func__); |
| 5353 | ret = -EINVAL; |
| 5354 | goto exit; |
| 5355 | } |
| 5356 | |
| 5357 | if (numChannels > WNI_CFG_VALID_CHANNEL_LIST_LEN) |
| 5358 | { |
| 5359 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5360 | "%s: number of channels (%d) supported exceeded max (%d)", __func__, |
| 5361 | numChannels, WNI_CFG_VALID_CHANNEL_LIST_LEN); |
| 5362 | ret = -EINVAL; |
| 5363 | goto exit; |
| 5364 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 5365 | status = sme_SetEseRoamScanChannelList((tHalHandle)(pHddCtx->hHal), |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 5366 | ChannelList, |
| 5367 | numChannels); |
| 5368 | if (eHAL_STATUS_SUCCESS != status) |
| 5369 | { |
| 5370 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5371 | "%s: Failed to update channel list information", __func__); |
| 5372 | ret = -EINVAL; |
| 5373 | goto exit; |
| 5374 | } |
| 5375 | } |
| 5376 | else if (strncmp(command, "GETTSMSTATS", 11) == 0) |
| 5377 | { |
| 5378 | tANI_U8 *value = command; |
| 5379 | char extra[128] = {0}; |
| 5380 | int len = 0; |
| 5381 | tANI_U8 tid = 0; |
| 5382 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 5383 | tAniTrafStrmMetrics tsmMetrics; |
| 5384 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 5385 | |
| 5386 | /* if not associated, return error */ |
| 5387 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 5388 | { |
| 5389 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:Not associated!",__func__); |
| 5390 | ret = -EINVAL; |
| 5391 | goto exit; |
| 5392 | } |
| 5393 | |
| 5394 | /* Move pointer to ahead of GETTSMSTATS<delimiter> */ |
| 5395 | value = value + 12; |
| 5396 | /* Convert the value from ascii to integer */ |
| 5397 | ret = kstrtou8(value, 10, &tid); |
| 5398 | if (ret < 0) |
| 5399 | { |
| 5400 | /* If the input value is greater than max value of datatype, then also |
| 5401 | kstrtou8 fails */ |
| 5402 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5403 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 5404 | TID_MIN_VALUE, |
| 5405 | TID_MAX_VALUE); |
| 5406 | ret = -EINVAL; |
| 5407 | goto exit; |
| 5408 | } |
| 5409 | |
| 5410 | if ((tid < TID_MIN_VALUE) || (tid > TID_MAX_VALUE)) |
| 5411 | { |
| 5412 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5413 | "tid value %d is out of range" |
| 5414 | " (Min: %d Max: %d)", tid, |
| 5415 | TID_MIN_VALUE, |
| 5416 | TID_MAX_VALUE); |
| 5417 | ret = -EINVAL; |
| 5418 | goto exit; |
| 5419 | } |
| 5420 | |
| 5421 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5422 | "%s: Received Command to get tsm stats tid = %d", __func__, tid); |
| 5423 | |
| 5424 | if (VOS_STATUS_SUCCESS != hdd_get_tsm_stats(pAdapter, tid, &tsmMetrics)) |
| 5425 | { |
| 5426 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5427 | "%s: failed to get tsm stats", __func__); |
| 5428 | ret = -EFAULT; |
| 5429 | goto exit; |
| 5430 | } |
| 5431 | |
| 5432 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5433 | "UplinkPktQueueDly(%d)\n" |
| 5434 | "UplinkPktQueueDlyHist[0](%d)\n" |
| 5435 | "UplinkPktQueueDlyHist[1](%d)\n" |
| 5436 | "UplinkPktQueueDlyHist[2](%d)\n" |
| 5437 | "UplinkPktQueueDlyHist[3](%d)\n" |
Arun Kumar Khandavalli | e876821 | 2014-02-17 16:43:34 +0530 | [diff] [blame] | 5438 | "UplinkPktTxDly(%u)\n" |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 5439 | "UplinkPktLoss(%d)\n" |
| 5440 | "UplinkPktCount(%d)\n" |
| 5441 | "RoamingCount(%d)\n" |
| 5442 | "RoamingDly(%d)", tsmMetrics.UplinkPktQueueDly, |
| 5443 | tsmMetrics.UplinkPktQueueDlyHist[0], |
| 5444 | tsmMetrics.UplinkPktQueueDlyHist[1], |
| 5445 | tsmMetrics.UplinkPktQueueDlyHist[2], |
| 5446 | tsmMetrics.UplinkPktQueueDlyHist[3], |
| 5447 | tsmMetrics.UplinkPktTxDly, tsmMetrics.UplinkPktLoss, |
| 5448 | tsmMetrics.UplinkPktCount, tsmMetrics.RoamingCount, tsmMetrics.RoamingDly); |
| 5449 | |
| 5450 | /* Output TSM stats is of the format |
| 5451 | GETTSMSTATS [PktQueueDly] [PktQueueDlyHist[0]]:[PktQueueDlyHist[1]] ...[RoamingDly] |
| 5452 | eg., GETTSMSTATS 10 1:0:0:161 20 1 17 8 39800 */ |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 5453 | 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] | 5454 | tsmMetrics.UplinkPktQueueDly, tsmMetrics.UplinkPktQueueDlyHist[0], |
| 5455 | tsmMetrics.UplinkPktQueueDlyHist[1], tsmMetrics.UplinkPktQueueDlyHist[2], |
| 5456 | tsmMetrics.UplinkPktQueueDlyHist[3], tsmMetrics.UplinkPktTxDly, |
| 5457 | tsmMetrics.UplinkPktLoss, tsmMetrics.UplinkPktCount, tsmMetrics.RoamingCount, |
| 5458 | tsmMetrics.RoamingDly); |
| 5459 | |
Ratnam Rachuri | d53009c | 2015-08-07 13:59:00 +0530 | [diff] [blame] | 5460 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 5461 | if (copy_to_user(priv_data.buf, &extra, len)) { |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 5462 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5463 | "%s: failed to copy data to user buffer", __func__); |
| 5464 | ret = -EFAULT; |
| 5465 | goto exit; |
| 5466 | } |
| 5467 | } |
| 5468 | else if (strncmp(command, "SETCCKMIE", 9) == 0) |
| 5469 | { |
| 5470 | tANI_U8 *value = command; |
| 5471 | tANI_U8 *cckmIe = NULL; |
| 5472 | tANI_U8 cckmIeLen = 0; |
| 5473 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 5474 | |
| 5475 | status = hdd_parse_get_cckm_ie(value, &cckmIe, &cckmIeLen); |
| 5476 | if (eHAL_STATUS_SUCCESS != status) |
| 5477 | { |
| 5478 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5479 | "%s: Failed to parse cckm ie data", __func__); |
| 5480 | ret = -EINVAL; |
| 5481 | goto exit; |
| 5482 | } |
| 5483 | |
| 5484 | if (cckmIeLen > DOT11F_IE_RSN_MAX_LEN) |
| 5485 | { |
| 5486 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5487 | "%s: CCKM Ie input length is more than max[%d]", __func__, |
| 5488 | DOT11F_IE_RSN_MAX_LEN); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 5489 | vos_mem_free(cckmIe); |
| 5490 | cckmIe = NULL; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 5491 | ret = -EINVAL; |
| 5492 | goto exit; |
| 5493 | } |
| 5494 | sme_SetCCKMIe((tHalHandle)(pHddCtx->hHal), pAdapter->sessionId, cckmIe, cckmIeLen); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 5495 | vos_mem_free(cckmIe); |
| 5496 | cckmIe = NULL; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 5497 | } |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 5498 | else if (strncmp(command, "CCXBEACONREQ", 12) == 0) |
| 5499 | { |
| 5500 | tANI_U8 *value = command; |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 5501 | tCsrEseBeaconReq eseBcnReq; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 5502 | eHalStatus status = eHAL_STATUS_SUCCESS; |
Srinivas Girigowda | 0c6d7fe | 2014-05-28 18:18:10 -0700 | [diff] [blame] | 5503 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 5504 | status = hdd_parse_ese_beacon_req(value, &eseBcnReq); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 5505 | if (eHAL_STATUS_SUCCESS != status) |
| 5506 | { |
| 5507 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 5508 | "%s: Failed to parse ese beacon req", __func__); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 5509 | ret = -EINVAL; |
| 5510 | goto exit; |
| 5511 | } |
Srinivas Girigowda | 0c6d7fe | 2014-05-28 18:18:10 -0700 | [diff] [blame] | 5512 | if (!hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) { |
| 5513 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Not associated")); |
| 5514 | hdd_indicateEseBcnReportNoResults (pAdapter, |
| 5515 | eseBcnReq.bcnReq[0].measurementToken, |
| 5516 | 0x02, //BIT(1) set for measurement done |
| 5517 | 0); // no BSS |
| 5518 | goto exit; |
| 5519 | } |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 5520 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 5521 | status = sme_SetEseBeaconRequest((tHalHandle)(pHddCtx->hHal), pAdapter->sessionId, &eseBcnReq); |
| 5522 | if (eHAL_STATUS_SUCCESS != status) |
| 5523 | { |
| 5524 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5525 | "%s: sme_SetEseBeaconRequest failed (%d)", __func__, status); |
| 5526 | ret = -EINVAL; |
| 5527 | goto exit; |
| 5528 | } |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 5529 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 5530 | #endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */ |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 5531 | else if (strncmp(command, "GETBCNMISSRATE", 14) == 0) |
| 5532 | { |
| 5533 | eHalStatus status; |
| 5534 | char buf[32], len; |
| 5535 | long waitRet; |
| 5536 | bcnMissRateContext_t getBcnMissRateCtx; |
| 5537 | |
| 5538 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 5539 | |
| 5540 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 5541 | { |
| 5542 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 5543 | FL("GETBCNMISSRATE: STA is not in connected state")); |
| 5544 | ret = -1; |
| 5545 | goto exit; |
| 5546 | } |
| 5547 | |
| 5548 | init_completion(&(getBcnMissRateCtx.completion)); |
| 5549 | getBcnMissRateCtx.magic = BCN_MISS_RATE_CONTEXT_MAGIC; |
| 5550 | |
| 5551 | status = sme_getBcnMissRate((tHalHandle)(pHddCtx->hHal), |
| 5552 | pAdapter->sessionId, |
| 5553 | (void *)getBcnMissRateCB, |
| 5554 | (void *)(&getBcnMissRateCtx)); |
| 5555 | if( eHAL_STATUS_SUCCESS != status) |
| 5556 | { |
| 5557 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 5558 | FL("GETBCNMISSRATE: fail to post WDA cmd")); |
| 5559 | ret = -EINVAL; |
| 5560 | goto exit; |
| 5561 | } |
| 5562 | |
| 5563 | waitRet = wait_for_completion_interruptible_timeout |
| 5564 | (&getBcnMissRateCtx.completion, BCN_MISS_RATE_TIME); |
| 5565 | if(waitRet <= 0) |
| 5566 | { |
| 5567 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5568 | FL("failed to wait on bcnMissRateComp %d"), ret); |
| 5569 | |
| 5570 | //Make magic number to zero so that callback is not called. |
| 5571 | spin_lock(&hdd_context_lock); |
| 5572 | getBcnMissRateCtx.magic = 0x0; |
| 5573 | spin_unlock(&hdd_context_lock); |
| 5574 | ret = -EINVAL; |
| 5575 | goto exit; |
| 5576 | } |
| 5577 | |
| 5578 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 5579 | FL("GETBCNMISSRATE: bcnMissRate: %d"), gbcnMissRate); |
| 5580 | |
| 5581 | len = snprintf(buf, sizeof(buf), "GETBCNMISSRATE %d", gbcnMissRate); |
| 5582 | if (copy_to_user(priv_data.buf, &buf, len + 1)) |
| 5583 | { |
| 5584 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5585 | "%s: failed to copy data to user buffer", __func__); |
| 5586 | ret = -EFAULT; |
| 5587 | goto exit; |
| 5588 | } |
| 5589 | ret = len; |
| 5590 | } |
Atul Mittal | 87ec242 | 2014-09-24 13:12:50 +0530 | [diff] [blame] | 5591 | #ifdef FEATURE_WLAN_TDLS |
| 5592 | else if (strncmp(command, "TDLSSECONDARYCHANNELOFFSET", 26) == 0) { |
| 5593 | tANI_U8 *value = command; |
| 5594 | int set_value; |
| 5595 | /* Move pointer to ahead of TDLSOFFCH*/ |
| 5596 | value += 26; |
c_manjee | bbc4021 | 2015-12-08 13:52:59 +0530 | [diff] [blame] | 5597 | if (!(sscanf(value, "%d", &set_value))) { |
| 5598 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5599 | FL("No input identified")); |
| 5600 | ret = -EINVAL; |
| 5601 | goto exit; |
| 5602 | } |
| 5603 | |
Atul Mittal | 87ec242 | 2014-09-24 13:12:50 +0530 | [diff] [blame] | 5604 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5605 | "%s: Tdls offchannel offset:%d", |
| 5606 | __func__, set_value); |
| 5607 | ret = iw_set_tdlssecoffchanneloffset(pHddCtx, set_value); |
| 5608 | if (ret < 0) |
| 5609 | { |
| 5610 | ret = -EINVAL; |
| 5611 | goto exit; |
| 5612 | } |
| 5613 | |
| 5614 | } else if (strncmp(command, "TDLSOFFCHANNELMODE", 18) == 0) { |
| 5615 | tANI_U8 *value = command; |
| 5616 | int set_value; |
| 5617 | /* Move pointer to ahead of tdlsoffchnmode*/ |
| 5618 | value += 18; |
c_manjee | 8232389 | 2015-12-08 12:40:34 +0530 | [diff] [blame] | 5619 | ret = sscanf(value, "%d", &set_value); |
| 5620 | if (ret != 1) { |
| 5621 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5622 | FL("No input identified")); |
| 5623 | ret = -EINVAL; |
| 5624 | goto exit; |
| 5625 | } |
Atul Mittal | 87ec242 | 2014-09-24 13:12:50 +0530 | [diff] [blame] | 5626 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5627 | "%s: Tdls offchannel mode:%d", |
| 5628 | __func__, set_value); |
| 5629 | ret = iw_set_tdlsoffchannelmode(pAdapter, set_value); |
| 5630 | if (ret < 0) |
| 5631 | { |
| 5632 | ret = -EINVAL; |
| 5633 | goto exit; |
| 5634 | } |
| 5635 | } else if (strncmp(command, "TDLSOFFCHANNEL", 14) == 0) { |
| 5636 | tANI_U8 *value = command; |
| 5637 | int set_value; |
| 5638 | /* Move pointer to ahead of TDLSOFFCH*/ |
| 5639 | value += 14; |
c_manjee | f6ccaf5 | 2015-12-08 11:52:11 +0530 | [diff] [blame] | 5640 | ret = sscanf(value, "%d", &set_value); |
| 5641 | if (ret != 1) { |
| 5642 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5643 | "Wrong value is given for hdd_set_tdls_offchannel"); |
| 5644 | ret = -EINVAL; |
| 5645 | goto exit; |
| 5646 | } |
| 5647 | |
Atul Mittal | 87ec242 | 2014-09-24 13:12:50 +0530 | [diff] [blame] | 5648 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5649 | "%s: Tdls offchannel num: %d", |
| 5650 | __func__, set_value); |
| 5651 | ret = iw_set_tdlsoffchannel(pHddCtx, set_value); |
| 5652 | if (ret < 0) |
| 5653 | { |
| 5654 | ret = -EINVAL; |
| 5655 | goto exit; |
| 5656 | } |
| 5657 | } |
| 5658 | #endif |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 5659 | else if (strncmp(command, "GETFWSTATS", 10) == 0) |
| 5660 | { |
| 5661 | eHalStatus status; |
| 5662 | char *buf = NULL; |
| 5663 | char len; |
| 5664 | long waitRet; |
| 5665 | fwStatsContext_t fwStatsCtx; |
Abhishek Singh | 08aa776 | 2014-12-16 13:59:03 +0530 | [diff] [blame] | 5666 | tSirFwStatsResult *fwStatsRsp = &(pAdapter->fwStatsRsp); |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 5667 | tANI_U8 *ptr = command; |
| 5668 | int stats = *(ptr + 11) - '0'; |
| 5669 | |
| 5670 | hddLog(VOS_TRACE_LEVEL_INFO, FL("stats = %d "),stats); |
| 5671 | if (!IS_FEATURE_FW_STATS_ENABLE) |
| 5672 | { |
| 5673 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 5674 | FL("Get Firmware stats feature not supported")); |
| 5675 | ret = -EINVAL; |
| 5676 | goto exit; |
| 5677 | } |
| 5678 | |
| 5679 | if (FW_STATS_MAX <= stats || 0 >= stats) |
| 5680 | { |
| 5681 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 5682 | FL(" stats %d not supported"),stats); |
| 5683 | ret = -EINVAL; |
| 5684 | goto exit; |
| 5685 | } |
| 5686 | |
| 5687 | init_completion(&(fwStatsCtx.completion)); |
| 5688 | fwStatsCtx.magic = FW_STATS_CONTEXT_MAGIC; |
| 5689 | fwStatsCtx.pAdapter = pAdapter; |
| 5690 | fwStatsRsp->type = 0; |
| 5691 | status = sme_GetFwStats( (tHalHandle)pHddCtx->hHal, stats, |
Abhishek Singh | 08aa776 | 2014-12-16 13:59:03 +0530 | [diff] [blame] | 5692 | &fwStatsCtx, hdd_FWStatisCB); |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 5693 | if (eHAL_STATUS_SUCCESS != status) |
| 5694 | { |
| 5695 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5696 | FL(" fail to post WDA cmd status = %d"), status); |
| 5697 | ret = -EINVAL; |
| 5698 | goto exit; |
| 5699 | } |
| 5700 | waitRet = wait_for_completion_timeout |
| 5701 | (&(fwStatsCtx.completion), FW_STATE_WAIT_TIME); |
| 5702 | if (waitRet <= 0) |
| 5703 | { |
| 5704 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5705 | FL("failed to wait on GwtFwstats")); |
| 5706 | //Make magic number to zero so that callback is not executed. |
| 5707 | spin_lock(&hdd_context_lock); |
| 5708 | fwStatsCtx.magic = 0x0; |
| 5709 | spin_unlock(&hdd_context_lock); |
| 5710 | ret = -EINVAL; |
| 5711 | goto exit; |
| 5712 | } |
| 5713 | if (fwStatsRsp->type) |
| 5714 | { |
| 5715 | buf = kmalloc(FW_STATE_RSP_LEN, GFP_KERNEL); |
| 5716 | if (!buf) |
| 5717 | { |
| 5718 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5719 | FL(" failed to allocate memory")); |
| 5720 | ret = -ENOMEM; |
| 5721 | goto exit; |
| 5722 | } |
| 5723 | switch( fwStatsRsp->type ) |
| 5724 | { |
| 5725 | case FW_UBSP_STATS: |
| 5726 | { |
| 5727 | len = snprintf(buf, FW_STATE_RSP_LEN, |
| 5728 | "GETFWSTATS: ubsp_enter_cnt %d ubsp_jump_ddr_cnt %d", |
Abhishek Singh | 08aa776 | 2014-12-16 13:59:03 +0530 | [diff] [blame] | 5729 | fwStatsRsp->fwStatsData.ubspStats.ubsp_enter_cnt, |
| 5730 | fwStatsRsp->fwStatsData.ubspStats.ubsp_jump_ddr_cnt); |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 5731 | } |
| 5732 | break; |
| 5733 | default: |
| 5734 | { |
| 5735 | hddLog(VOS_TRACE_LEVEL_ERROR, FL( "No handling for stats type %d"),fwStatsRsp->type); |
| 5736 | ret = -EFAULT; |
| 5737 | kfree(buf); |
| 5738 | goto exit; |
| 5739 | } |
| 5740 | } |
| 5741 | if (copy_to_user(priv_data.buf, buf, len + 1)) |
| 5742 | { |
| 5743 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5744 | FL(" failed to copy data to user buffer")); |
| 5745 | ret = -EFAULT; |
| 5746 | kfree(buf); |
| 5747 | goto exit; |
| 5748 | } |
| 5749 | ret = len; |
| 5750 | kfree(buf); |
| 5751 | } |
| 5752 | else |
| 5753 | { |
| 5754 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5755 | FL("failed to fetch the stats")); |
| 5756 | ret = -EFAULT; |
| 5757 | goto exit; |
| 5758 | } |
| 5759 | |
| 5760 | } |
Agarwal Ashish | 8bd53ae | 2015-06-12 18:03:45 +0530 | [diff] [blame] | 5761 | else if (strncasecmp(command, "SET_FCC_CHANNEL", 15) == 0) |
| 5762 | { |
| 5763 | /* |
| 5764 | * this command wld be called by user-space when it detects WLAN |
| 5765 | * ON after airplane mode is set. When APM is set, WLAN turns off. |
| 5766 | * But it can be turned back on. Otherwise; when APM is turned back |
| 5767 | * off, WLAN wld turn back on. So at that point the command is |
| 5768 | * expected to come down. 0 means disable, 1 means enable. The |
| 5769 | * constraint is removed when parameter 1 is set or different |
| 5770 | * country code is set |
| 5771 | */ |
| 5772 | ret = hdd_cmd_setFccChannel(pHddCtx, command, 15); |
| 5773 | } |
Mahesh A Saptasagar | beca12c | 2015-09-07 16:21:06 +0530 | [diff] [blame] | 5774 | else if (strncasecmp(command, "DISABLE_CA_EVENT", 16) == 0) |
| 5775 | { |
| 5776 | ret = hdd_enable_disable_ca_event(pHddCtx, command, 16); |
| 5777 | } |
Madan Mohan Koyyalamudi | f9bdd4e | 2012-10-30 18:05:03 -0700 | [diff] [blame] | 5778 | else { |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 5779 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 5780 | TRACE_CODE_HDD_UNSUPPORTED_IOCTL, |
| 5781 | pAdapter->sessionId, 0)); |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 5782 | hddLog( VOS_TRACE_LEVEL_WARN, FL("Unsupported GUI command %s"), |
| 5783 | command); |
Madan Mohan Koyyalamudi | f9bdd4e | 2012-10-30 18:05:03 -0700 | [diff] [blame] | 5784 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5785 | } |
| 5786 | exit: |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 5787 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5788 | if (command) |
| 5789 | { |
| 5790 | kfree(command); |
| 5791 | } |
| 5792 | return ret; |
| 5793 | } |
| 5794 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 5795 | #ifdef CONFIG_COMPAT |
| 5796 | static int hdd_driver_compat_ioctl(hdd_adapter_t *pAdapter, struct ifreq *ifr) |
| 5797 | { |
| 5798 | struct { |
| 5799 | compat_uptr_t buf; |
| 5800 | int used_len; |
| 5801 | int total_len; |
| 5802 | } compat_priv_data; |
| 5803 | hdd_priv_data_t priv_data; |
| 5804 | int ret = 0; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 5805 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 5806 | /* |
| 5807 | * Note that pAdapter and ifr have already been verified by caller, |
| 5808 | * and HDD context has also been validated |
| 5809 | */ |
| 5810 | if (copy_from_user(&compat_priv_data, ifr->ifr_data, |
| 5811 | sizeof(compat_priv_data))) { |
| 5812 | ret = -EFAULT; |
| 5813 | goto exit; |
| 5814 | } |
| 5815 | priv_data.buf = compat_ptr(compat_priv_data.buf); |
| 5816 | priv_data.used_len = compat_priv_data.used_len; |
| 5817 | priv_data.total_len = compat_priv_data.total_len; |
| 5818 | ret = hdd_driver_command(pAdapter, &priv_data); |
| 5819 | exit: |
| 5820 | return ret; |
| 5821 | } |
| 5822 | #else /* CONFIG_COMPAT */ |
| 5823 | static int hdd_driver_compat_ioctl(hdd_adapter_t *pAdapter, struct ifreq *ifr) |
| 5824 | { |
| 5825 | /* will never be invoked */ |
| 5826 | return 0; |
| 5827 | } |
| 5828 | #endif /* CONFIG_COMPAT */ |
| 5829 | |
| 5830 | static int hdd_driver_ioctl(hdd_adapter_t *pAdapter, struct ifreq *ifr) |
| 5831 | { |
| 5832 | hdd_priv_data_t priv_data; |
| 5833 | int ret = 0; |
| 5834 | |
| 5835 | /* |
| 5836 | * Note that pAdapter and ifr have already been verified by caller, |
| 5837 | * and HDD context has also been validated |
| 5838 | */ |
| 5839 | if (copy_from_user(&priv_data, ifr->ifr_data, sizeof(priv_data))) { |
| 5840 | ret = -EFAULT; |
| 5841 | } else { |
| 5842 | ret = hdd_driver_command(pAdapter, &priv_data); |
| 5843 | } |
| 5844 | return ret; |
| 5845 | } |
| 5846 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 5847 | int __hdd_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 5848 | { |
| 5849 | hdd_adapter_t *pAdapter; |
| 5850 | hdd_context_t *pHddCtx; |
| 5851 | int ret; |
| 5852 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 5853 | ENTER(); |
| 5854 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 5855 | pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5856 | if (NULL == pAdapter) { |
| 5857 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 5858 | "%s: HDD adapter context is Null", __func__); |
| 5859 | ret = -ENODEV; |
| 5860 | goto exit; |
| 5861 | } |
| 5862 | if (dev != pAdapter->dev) { |
| 5863 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 5864 | "%s: HDD adapter/dev inconsistency", __func__); |
| 5865 | ret = -ENODEV; |
| 5866 | goto exit; |
| 5867 | } |
| 5868 | |
| 5869 | if ((!ifr) || (!ifr->ifr_data)) { |
| 5870 | ret = -EINVAL; |
| 5871 | goto exit; |
| 5872 | } |
| 5873 | |
| 5874 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 5875 | ret = wlan_hdd_validate_context(pHddCtx); |
| 5876 | if (ret) { |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 5877 | ret = -EBUSY; |
| 5878 | goto exit; |
| 5879 | } |
| 5880 | |
| 5881 | switch (cmd) { |
| 5882 | case (SIOCDEVPRIVATE + 1): |
| 5883 | if (is_compat_task()) |
| 5884 | ret = hdd_driver_compat_ioctl(pAdapter, ifr); |
| 5885 | else |
| 5886 | ret = hdd_driver_ioctl(pAdapter, ifr); |
| 5887 | break; |
| 5888 | default: |
| 5889 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unknown ioctl %d", |
| 5890 | __func__, cmd); |
| 5891 | ret = -EINVAL; |
| 5892 | break; |
| 5893 | } |
| 5894 | exit: |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 5895 | EXIT(); |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 5896 | return ret; |
| 5897 | } |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 5898 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 5899 | int hdd_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) |
| 5900 | { |
| 5901 | int ret; |
| 5902 | |
| 5903 | vos_ssr_protect(__func__); |
| 5904 | ret = __hdd_ioctl(dev, ifr, cmd); |
| 5905 | vos_ssr_unprotect(__func__); |
| 5906 | |
| 5907 | return ret; |
| 5908 | } |
| 5909 | |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 5910 | int hdd_mon_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) |
| 5911 | { |
| 5912 | return 0; |
| 5913 | } |
| 5914 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 5915 | #if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 5916 | /**--------------------------------------------------------------------------- |
| 5917 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 5918 | \brief hdd_parse_ese_beacon_req() - Parse ese beacon request |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 5919 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 5920 | This function parses the ese beacon request passed in the format |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 5921 | CCXBEACONREQ<space><Number of fields><space><Measurement token> |
| 5922 | <space>Channel 1<space>Scan Mode <space>Meas Duration<space>Channel N |
| 5923 | <space>Scan Mode N<space>Meas Duration N |
| 5924 | if the Number of bcn req fields (N) does not match with the actual number of fields passed |
| 5925 | then take N. |
| 5926 | <Meas Token><Channel><Scan Mode> and <Meas Duration> are treated as one pair |
| 5927 | For example, CCXBEACONREQ 2 1 1 1 30 2 44 0 40. |
| 5928 | This function does not take care of removing duplicate channels from the list |
| 5929 | |
| 5930 | \param - pValue Pointer to data |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 5931 | \param - pEseBcnReq output pointer to store parsed ie information |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 5932 | |
| 5933 | \return - 0 for success non-zero for failure |
| 5934 | |
| 5935 | --------------------------------------------------------------------------*/ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 5936 | static VOS_STATUS hdd_parse_ese_beacon_req(tANI_U8 *pValue, |
| 5937 | tCsrEseBeaconReq *pEseBcnReq) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 5938 | { |
| 5939 | tANI_U8 *inPtr = pValue; |
| 5940 | int tempInt = 0; |
| 5941 | int j = 0, i = 0, v = 0; |
| 5942 | char buf[32]; |
| 5943 | |
| 5944 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 5945 | /*no argument after the command*/ |
| 5946 | if (NULL == inPtr) |
| 5947 | { |
| 5948 | return -EINVAL; |
| 5949 | } |
| 5950 | /*no space after the command*/ |
| 5951 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 5952 | { |
| 5953 | return -EINVAL; |
| 5954 | } |
| 5955 | |
| 5956 | /*removing empty spaces*/ |
| 5957 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
| 5958 | |
| 5959 | /*no argument followed by spaces*/ |
| 5960 | if ('\0' == *inPtr) return -EINVAL; |
| 5961 | |
| 5962 | /*getting the first argument ie measurement token*/ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 5963 | v = sscanf(inPtr, "%31s ", buf); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 5964 | if (1 != v) return -EINVAL; |
| 5965 | |
| 5966 | v = kstrtos32(buf, 10, &tempInt); |
| 5967 | if ( v < 0) return -EINVAL; |
| 5968 | |
Srinivas Girigowda | 725a88e | 2016-03-31 19:24:25 +0530 | [diff] [blame] | 5969 | tempInt = VOS_MIN(tempInt, SIR_ESE_MAX_MEAS_IE_REQS); |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 5970 | pEseBcnReq->numBcnReqIe = tempInt; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 5971 | |
Srinivas Girigowda | 725a88e | 2016-03-31 19:24:25 +0530 | [diff] [blame] | 5972 | hddLog(LOG1, "Number of Bcn Req Ie fields: %d", pEseBcnReq->numBcnReqIe); |
| 5973 | |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 5974 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 5975 | for (j = 0; j < (pEseBcnReq->numBcnReqIe); j++) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 5976 | { |
| 5977 | for (i = 0; i < 4; i++) |
| 5978 | { |
| 5979 | /*inPtr pointing to the beginning of first space after number of ie fields*/ |
| 5980 | inPtr = strpbrk( inPtr, " " ); |
| 5981 | /*no ie data after the number of ie fields argument*/ |
| 5982 | if (NULL == inPtr) return -EINVAL; |
| 5983 | |
| 5984 | /*removing empty space*/ |
| 5985 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
| 5986 | |
| 5987 | /*no ie data after the number of ie fields argument and spaces*/ |
| 5988 | if ( '\0' == *inPtr ) return -EINVAL; |
| 5989 | |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 5990 | v = sscanf(inPtr, "%31s ", buf); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 5991 | if (1 != v) return -EINVAL; |
| 5992 | |
| 5993 | v = kstrtos32(buf, 10, &tempInt); |
| 5994 | if (v < 0) return -EINVAL; |
| 5995 | |
| 5996 | switch (i) |
| 5997 | { |
| 5998 | case 0: /* Measurement token */ |
| 5999 | if (tempInt <= 0) |
| 6000 | { |
| 6001 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6002 | "Invalid Measurement Token(%d)", tempInt); |
| 6003 | return -EINVAL; |
| 6004 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 6005 | pEseBcnReq->bcnReq[j].measurementToken = tempInt; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 6006 | break; |
| 6007 | |
| 6008 | case 1: /* Channel number */ |
| 6009 | if ((tempInt <= 0) || |
| 6010 | (tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX)) |
| 6011 | { |
| 6012 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6013 | "Invalid Channel Number(%d)", tempInt); |
| 6014 | return -EINVAL; |
| 6015 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 6016 | pEseBcnReq->bcnReq[j].channel = tempInt; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 6017 | break; |
| 6018 | |
| 6019 | case 2: /* Scan mode */ |
Varun Reddy Yeturu | 0b18d5a | 2013-12-04 11:42:23 -0800 | [diff] [blame] | 6020 | if ((tempInt < eSIR_PASSIVE_SCAN) || (tempInt > eSIR_BEACON_TABLE)) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 6021 | { |
| 6022 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6023 | "Invalid Scan Mode(%d) Expected{0|1|2}", tempInt); |
| 6024 | return -EINVAL; |
| 6025 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 6026 | pEseBcnReq->bcnReq[j].scanMode= tempInt; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 6027 | break; |
| 6028 | |
| 6029 | case 3: /* Measurement duration */ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 6030 | if (((tempInt <= 0) && (pEseBcnReq->bcnReq[j].scanMode != eSIR_BEACON_TABLE)) || |
| 6031 | ((tempInt < 0) && (pEseBcnReq->bcnReq[j].scanMode == eSIR_BEACON_TABLE))) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 6032 | { |
| 6033 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6034 | "Invalid Measurement Duration(%d)", tempInt); |
| 6035 | return -EINVAL; |
| 6036 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 6037 | pEseBcnReq->bcnReq[j].measurementDuration = tempInt; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 6038 | break; |
| 6039 | } |
| 6040 | } |
| 6041 | } |
| 6042 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 6043 | for (j = 0; j < pEseBcnReq->numBcnReqIe; j++) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 6044 | { |
| 6045 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Arun Kumar Khandavalli | e876821 | 2014-02-17 16:43:34 +0530 | [diff] [blame] | 6046 | "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] | 6047 | j, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 6048 | pEseBcnReq->bcnReq[j].measurementToken, |
| 6049 | pEseBcnReq->bcnReq[j].channel, |
| 6050 | pEseBcnReq->bcnReq[j].scanMode, |
| 6051 | pEseBcnReq->bcnReq[j].measurementDuration); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 6052 | } |
| 6053 | |
| 6054 | return VOS_STATUS_SUCCESS; |
| 6055 | } |
| 6056 | |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 6057 | static void hdd_GetTsmStatsCB( tAniTrafStrmMetrics tsmMetrics, const tANI_U32 staId, void *pContext ) |
| 6058 | { |
| 6059 | struct statsContext *pStatsContext = NULL; |
| 6060 | hdd_adapter_t *pAdapter = NULL; |
| 6061 | |
| 6062 | if (NULL == pContext) |
| 6063 | { |
| 6064 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6065 | "%s: Bad param, pContext [%p]", |
| 6066 | __func__, pContext); |
| 6067 | return; |
| 6068 | } |
| 6069 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 6070 | /* there is a race condition that exists between this callback |
| 6071 | function and the caller since the caller could time out either |
| 6072 | before or while this code is executing. we use a spinlock to |
| 6073 | serialize these actions */ |
| 6074 | spin_lock(&hdd_context_lock); |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 6075 | |
| 6076 | pStatsContext = pContext; |
| 6077 | pAdapter = pStatsContext->pAdapter; |
| 6078 | if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic)) |
| 6079 | { |
| 6080 | /* the caller presumably timed out so there is nothing we can do */ |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 6081 | spin_unlock(&hdd_context_lock); |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 6082 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 6083 | "%s: Invalid context, pAdapter [%p] magic [%08x]", |
| 6084 | __func__, pAdapter, pStatsContext->magic); |
| 6085 | return; |
| 6086 | } |
| 6087 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 6088 | /* context is valid so caller is still waiting */ |
| 6089 | |
| 6090 | /* paranoia: invalidate the magic */ |
| 6091 | pStatsContext->magic = 0; |
| 6092 | |
| 6093 | /* copy over the tsm stats */ |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 6094 | pAdapter->tsmStats.UplinkPktQueueDly = tsmMetrics.UplinkPktQueueDly; |
| 6095 | vos_mem_copy(pAdapter->tsmStats.UplinkPktQueueDlyHist, |
| 6096 | tsmMetrics.UplinkPktQueueDlyHist, |
| 6097 | sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist)/ |
| 6098 | sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist[0])); |
| 6099 | pAdapter->tsmStats.UplinkPktTxDly = tsmMetrics.UplinkPktTxDly; |
| 6100 | pAdapter->tsmStats.UplinkPktLoss = tsmMetrics.UplinkPktLoss; |
| 6101 | pAdapter->tsmStats.UplinkPktCount = tsmMetrics.UplinkPktCount; |
| 6102 | pAdapter->tsmStats.RoamingCount = tsmMetrics.RoamingCount; |
| 6103 | pAdapter->tsmStats.RoamingDly = tsmMetrics.RoamingDly; |
| 6104 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 6105 | /* notify the caller */ |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 6106 | complete(&pStatsContext->completion); |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 6107 | |
| 6108 | /* serialization is complete */ |
| 6109 | spin_unlock(&hdd_context_lock); |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 6110 | } |
| 6111 | |
| 6112 | |
| 6113 | |
| 6114 | static VOS_STATUS hdd_get_tsm_stats(hdd_adapter_t *pAdapter, const tANI_U8 tid, |
| 6115 | tAniTrafStrmMetrics* pTsmMetrics) |
| 6116 | { |
| 6117 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 6118 | eHalStatus hstatus; |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 6119 | VOS_STATUS vstatus = VOS_STATUS_SUCCESS; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 6120 | long lrc; |
| 6121 | struct statsContext context; |
| 6122 | hdd_context_t *pHddCtx = NULL; |
| 6123 | |
| 6124 | if (NULL == pAdapter) |
| 6125 | { |
| 6126 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: pAdapter is NULL", __func__); |
| 6127 | return VOS_STATUS_E_FAULT; |
| 6128 | } |
| 6129 | |
| 6130 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 6131 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 6132 | |
| 6133 | /* we are connected prepare our callback context */ |
| 6134 | init_completion(&context.completion); |
| 6135 | context.pAdapter = pAdapter; |
| 6136 | context.magic = STATS_CONTEXT_MAGIC; |
| 6137 | |
| 6138 | /* query tsm stats */ |
| 6139 | hstatus = sme_GetTsmStats(pHddCtx->hHal, hdd_GetTsmStatsCB, |
| 6140 | pHddStaCtx->conn_info.staId[ 0 ], |
| 6141 | pHddStaCtx->conn_info.bssId, |
| 6142 | &context, pHddCtx->pvosContext, tid); |
| 6143 | |
| 6144 | if (eHAL_STATUS_SUCCESS != hstatus) |
| 6145 | { |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 6146 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unable to retrieve statistics", |
| 6147 | __func__); |
| 6148 | vstatus = VOS_STATUS_E_FAULT; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 6149 | } |
| 6150 | else |
| 6151 | { |
| 6152 | /* request was sent -- wait for the response */ |
| 6153 | lrc = wait_for_completion_interruptible_timeout(&context.completion, |
| 6154 | msecs_to_jiffies(WLAN_WAIT_TIME_STATS)); |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 6155 | if (lrc <= 0) |
| 6156 | { |
| 6157 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6158 | "%s: SME %s while retrieving statistics", |
| 6159 | __func__, (0 == lrc) ? "timeout" : "interrupt"); |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 6160 | vstatus = VOS_STATUS_E_TIMEOUT; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 6161 | } |
| 6162 | } |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 6163 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 6164 | /* either we never sent a request, we sent a request and received a |
| 6165 | response or we sent a request and timed out. if we never sent a |
| 6166 | request or if we sent a request and got a response, we want to |
| 6167 | clear the magic out of paranoia. if we timed out there is a |
| 6168 | race condition such that the callback function could be |
| 6169 | executing at the same time we are. of primary concern is if the |
| 6170 | callback function had already verified the "magic" but had not |
| 6171 | yet set the completion variable when a timeout occurred. we |
| 6172 | serialize these activities by invalidating the magic while |
| 6173 | holding a shared spinlock which will cause us to block if the |
| 6174 | callback is currently executing */ |
| 6175 | spin_lock(&hdd_context_lock); |
| 6176 | context.magic = 0; |
| 6177 | spin_unlock(&hdd_context_lock); |
| 6178 | |
| 6179 | if (VOS_STATUS_SUCCESS == vstatus) |
| 6180 | { |
| 6181 | pTsmMetrics->UplinkPktQueueDly = pAdapter->tsmStats.UplinkPktQueueDly; |
| 6182 | vos_mem_copy(pTsmMetrics->UplinkPktQueueDlyHist, |
| 6183 | pAdapter->tsmStats.UplinkPktQueueDlyHist, |
| 6184 | sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist)/ |
| 6185 | sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist[0])); |
| 6186 | pTsmMetrics->UplinkPktTxDly = pAdapter->tsmStats.UplinkPktTxDly; |
| 6187 | pTsmMetrics->UplinkPktLoss = pAdapter->tsmStats.UplinkPktLoss; |
| 6188 | pTsmMetrics->UplinkPktCount = pAdapter->tsmStats.UplinkPktCount; |
| 6189 | pTsmMetrics->RoamingCount = pAdapter->tsmStats.RoamingCount; |
| 6190 | pTsmMetrics->RoamingDly = pAdapter->tsmStats.RoamingDly; |
| 6191 | } |
| 6192 | return vstatus; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 6193 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 6194 | #endif /*FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */ |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 6195 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 6196 | #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] | 6197 | void hdd_getBand_helper(hdd_context_t *pHddCtx, int *pBand) |
| 6198 | { |
| 6199 | eCsrBand band = -1; |
| 6200 | sme_GetFreqBand((tHalHandle)(pHddCtx->hHal), &band); |
| 6201 | switch (band) |
| 6202 | { |
| 6203 | case eCSR_BAND_ALL: |
| 6204 | *pBand = WLAN_HDD_UI_BAND_AUTO; |
| 6205 | break; |
| 6206 | |
| 6207 | case eCSR_BAND_24: |
| 6208 | *pBand = WLAN_HDD_UI_BAND_2_4_GHZ; |
| 6209 | break; |
| 6210 | |
| 6211 | case eCSR_BAND_5G: |
| 6212 | *pBand = WLAN_HDD_UI_BAND_5_GHZ; |
| 6213 | break; |
| 6214 | |
| 6215 | default: |
| 6216 | hddLog( VOS_TRACE_LEVEL_WARN, "%s: Invalid Band %d", __func__, band); |
| 6217 | *pBand = -1; |
| 6218 | break; |
| 6219 | } |
| 6220 | } |
| 6221 | |
| 6222 | /**--------------------------------------------------------------------------- |
| 6223 | |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 6224 | \brief hdd_parse_send_action_frame_data() - HDD Parse send action frame data |
| 6225 | |
| 6226 | This function parses the send action frame data passed in the format |
| 6227 | SENDACTIONFRAME<space><bssid><space><channel><space><dwelltime><space><data> |
| 6228 | |
Srinivas Girigowda | 5607685 | 2013-08-20 14:00:50 -0700 | [diff] [blame] | 6229 | \param - pValue Pointer to input data |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 6230 | \param - pTargetApBssid Pointer to target Ap bssid |
| 6231 | \param - pChannel Pointer to the Target AP channel |
| 6232 | \param - pDwellTime Pointer to the time to stay off-channel after transmitting action frame |
| 6233 | \param - pBuf Pointer to data |
| 6234 | \param - pBufLen Pointer to data length |
| 6235 | |
| 6236 | \return - 0 for success non-zero for failure |
| 6237 | |
| 6238 | --------------------------------------------------------------------------*/ |
| 6239 | VOS_STATUS hdd_parse_send_action_frame_data(tANI_U8 *pValue, tANI_U8 *pTargetApBssid, tANI_U8 *pChannel, |
| 6240 | tANI_U8 *pDwellTime, tANI_U8 **pBuf, tANI_U8 *pBufLen) |
| 6241 | { |
| 6242 | tANI_U8 *inPtr = pValue; |
| 6243 | tANI_U8 *dataEnd; |
| 6244 | int tempInt; |
| 6245 | int j = 0; |
| 6246 | int i = 0; |
| 6247 | int v = 0; |
| 6248 | tANI_U8 tempBuf[32]; |
| 6249 | tANI_U8 tempByte = 0; |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 6250 | /* 12 hexa decimal digits, 5 ':' and '\0' */ |
| 6251 | tANI_U8 macAddress[18]; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 6252 | |
| 6253 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 6254 | /*no argument after the command*/ |
| 6255 | if (NULL == inPtr) |
| 6256 | { |
| 6257 | return -EINVAL; |
| 6258 | } |
| 6259 | |
| 6260 | /*no space after the command*/ |
| 6261 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 6262 | { |
| 6263 | return -EINVAL; |
| 6264 | } |
| 6265 | |
| 6266 | /*removing empty spaces*/ |
| 6267 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 6268 | |
| 6269 | /*no argument followed by spaces*/ |
| 6270 | if ('\0' == *inPtr) |
| 6271 | { |
| 6272 | return -EINVAL; |
| 6273 | } |
| 6274 | |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 6275 | v = sscanf(inPtr, "%17s", macAddress); |
| 6276 | if (!((1 == v) && hdd_is_valid_mac_address(macAddress))) |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 6277 | { |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 6278 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6279 | "Invalid MAC address or All hex inputs are not read (%d)", v); |
| 6280 | return -EINVAL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 6281 | } |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 6282 | |
| 6283 | pTargetApBssid[0] = hdd_parse_hex(macAddress[0]) << 4 | hdd_parse_hex(macAddress[1]); |
| 6284 | pTargetApBssid[1] = hdd_parse_hex(macAddress[3]) << 4 | hdd_parse_hex(macAddress[4]); |
| 6285 | pTargetApBssid[2] = hdd_parse_hex(macAddress[6]) << 4 | hdd_parse_hex(macAddress[7]); |
| 6286 | pTargetApBssid[3] = hdd_parse_hex(macAddress[9]) << 4 | hdd_parse_hex(macAddress[10]); |
| 6287 | pTargetApBssid[4] = hdd_parse_hex(macAddress[12]) << 4 | hdd_parse_hex(macAddress[13]); |
| 6288 | 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] | 6289 | |
| 6290 | /* point to the next argument */ |
| 6291 | inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE); |
| 6292 | /*no argument after the command*/ |
| 6293 | if (NULL == inPtr) return -EINVAL; |
| 6294 | |
| 6295 | /*removing empty spaces*/ |
| 6296 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 6297 | |
| 6298 | /*no argument followed by spaces*/ |
| 6299 | if ('\0' == *inPtr) |
| 6300 | { |
| 6301 | return -EINVAL; |
| 6302 | } |
| 6303 | |
| 6304 | /*getting the next argument ie the channel number */ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 6305 | v = sscanf(inPtr, "%31s ", tempBuf); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 6306 | if (1 != v) return -EINVAL; |
| 6307 | |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 6308 | v = kstrtos32(tempBuf, 10, &tempInt); |
Agarwal Ashish | 353b3a8 | 2014-04-08 14:55:11 +0530 | [diff] [blame] | 6309 | if ( v < 0 || tempInt <= 0 || tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX ) |
Kiet Lam | be150c2 | 2013-11-21 16:30:32 +0530 | [diff] [blame] | 6310 | return -EINVAL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 6311 | |
| 6312 | *pChannel = tempInt; |
| 6313 | |
| 6314 | /* point to the next argument */ |
| 6315 | inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE); |
| 6316 | /*no argument after the command*/ |
| 6317 | if (NULL == inPtr) return -EINVAL; |
| 6318 | /*removing empty spaces*/ |
| 6319 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 6320 | |
| 6321 | /*no argument followed by spaces*/ |
| 6322 | if ('\0' == *inPtr) |
| 6323 | { |
| 6324 | return -EINVAL; |
| 6325 | } |
| 6326 | |
| 6327 | /*getting the next argument ie the dwell time */ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 6328 | v = sscanf(inPtr, "%31s ", tempBuf); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 6329 | if (1 != v) return -EINVAL; |
| 6330 | |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 6331 | v = kstrtos32(tempBuf, 10, &tempInt); |
Srinivas Girigowda | 5a6e067 | 2014-01-09 14:42:57 -0800 | [diff] [blame] | 6332 | if ( v < 0 || tempInt < 0) return -EINVAL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 6333 | |
| 6334 | *pDwellTime = tempInt; |
| 6335 | |
| 6336 | /* point to the next argument */ |
| 6337 | inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE); |
| 6338 | /*no argument after the command*/ |
| 6339 | if (NULL == inPtr) return -EINVAL; |
| 6340 | /*removing empty spaces*/ |
| 6341 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 6342 | |
| 6343 | /*no argument followed by spaces*/ |
| 6344 | if ('\0' == *inPtr) |
| 6345 | { |
| 6346 | return -EINVAL; |
| 6347 | } |
| 6348 | |
| 6349 | /* find the length of data */ |
| 6350 | dataEnd = inPtr; |
| 6351 | while(('\0' != *dataEnd) ) |
| 6352 | { |
| 6353 | dataEnd++; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 6354 | } |
Kiet Lam | be150c2 | 2013-11-21 16:30:32 +0530 | [diff] [blame] | 6355 | *pBufLen = dataEnd - inPtr ; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 6356 | if ( *pBufLen <= 0) return -EINVAL; |
| 6357 | |
Srinivas Girigowda | b5ae85d | 2013-06-03 10:51:45 -0700 | [diff] [blame] | 6358 | /* Allocate the number of bytes based on the number of input characters |
| 6359 | whether it is even or odd. |
| 6360 | if the number of input characters are even, then we need N/2 byte. |
| 6361 | if the number of input characters are odd, then we need do (N+1)/2 to |
| 6362 | compensate rounding off. |
| 6363 | For example, if N = 18, then (18 + 1)/2 = 9 bytes are enough. |
| 6364 | If N = 19, then we need 10 bytes, hence (19 + 1)/2 = 10 bytes */ |
| 6365 | *pBuf = vos_mem_malloc((*pBufLen + 1)/2); |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 6366 | if (NULL == *pBuf) |
| 6367 | { |
| 6368 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 6369 | "%s: vos_mem_alloc failed ", __func__); |
| 6370 | return -EINVAL; |
| 6371 | } |
| 6372 | |
| 6373 | /* the buffer received from the upper layer is character buffer, |
| 6374 | we need to prepare the buffer taking 2 characters in to a U8 hex decimal number |
| 6375 | for example 7f0000f0...form a buffer to contain 7f in 0th location, 00 in 1st |
| 6376 | and f0 in 3rd location */ |
| 6377 | for (i = 0, j = 0; j < *pBufLen; j += 2) |
| 6378 | { |
Kiet Lam | be150c2 | 2013-11-21 16:30:32 +0530 | [diff] [blame] | 6379 | if( j+1 == *pBufLen) |
| 6380 | { |
| 6381 | tempByte = hdd_parse_hex(inPtr[j]); |
| 6382 | } |
| 6383 | else |
| 6384 | { |
| 6385 | tempByte = (hdd_parse_hex(inPtr[j]) << 4) | (hdd_parse_hex(inPtr[j + 1])); |
| 6386 | } |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 6387 | (*pBuf)[i++] = tempByte; |
| 6388 | } |
| 6389 | *pBufLen = i; |
| 6390 | return VOS_STATUS_SUCCESS; |
| 6391 | } |
| 6392 | |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 6393 | /**--------------------------------------------------------------------------- |
| 6394 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 6395 | \brief hdd_parse_channellist() - HDD Parse channel list |
| 6396 | |
| 6397 | This function parses the channel list passed in the format |
| 6398 | 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] | 6399 | if the Number of channels (N) does not match with the actual number of channels passed |
| 6400 | then take the minimum of N and count of (Ch1, Ch2, ...Ch M) |
| 6401 | For example, if SETROAMSCANCHANNELS 3 36 40 44 48, only 36, 40 and 44 shall be taken. |
| 6402 | If SETROAMSCANCHANNELS 5 36 40 44 48, ignore 5 and take 36, 40, 44 and 48. |
| 6403 | 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] | 6404 | |
| 6405 | \param - pValue Pointer to input channel list |
| 6406 | \param - ChannelList Pointer to local output array to record channel list |
| 6407 | \param - pNumChannels Pointer to number of roam scan channels |
| 6408 | |
| 6409 | \return - 0 for success non-zero for failure |
| 6410 | |
| 6411 | --------------------------------------------------------------------------*/ |
| 6412 | VOS_STATUS hdd_parse_channellist(tANI_U8 *pValue, tANI_U8 *pChannelList, tANI_U8 *pNumChannels) |
| 6413 | { |
| 6414 | tANI_U8 *inPtr = pValue; |
| 6415 | int tempInt; |
| 6416 | int j = 0; |
| 6417 | int v = 0; |
| 6418 | char buf[32]; |
| 6419 | |
| 6420 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 6421 | /*no argument after the command*/ |
| 6422 | if (NULL == inPtr) |
| 6423 | { |
| 6424 | return -EINVAL; |
| 6425 | } |
| 6426 | |
| 6427 | /*no space after the command*/ |
| 6428 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 6429 | { |
| 6430 | return -EINVAL; |
| 6431 | } |
| 6432 | |
| 6433 | /*removing empty spaces*/ |
Jeff Johnson | a1f9afb | 2013-04-03 09:13:31 -0700 | [diff] [blame] | 6434 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 6435 | |
| 6436 | /*no argument followed by spaces*/ |
| 6437 | if ('\0' == *inPtr) |
| 6438 | { |
| 6439 | return -EINVAL; |
| 6440 | } |
| 6441 | |
| 6442 | /*getting the first argument ie the number of channels*/ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 6443 | v = sscanf(inPtr, "%31s ", buf); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 6444 | if (1 != v) return -EINVAL; |
| 6445 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 6446 | v = kstrtos32(buf, 10, &tempInt); |
Jeff Johnson | a1f9afb | 2013-04-03 09:13:31 -0700 | [diff] [blame] | 6447 | if ((v < 0) || |
| 6448 | (tempInt <= 0) || |
| 6449 | (tempInt > WNI_CFG_VALID_CHANNEL_LIST_LEN)) |
| 6450 | { |
| 6451 | return -EINVAL; |
| 6452 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 6453 | |
| 6454 | *pNumChannels = tempInt; |
| 6455 | |
| 6456 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
| 6457 | "Number of channels are: %d", *pNumChannels); |
| 6458 | |
| 6459 | for (j = 0; j < (*pNumChannels); j++) |
| 6460 | { |
| 6461 | /*inPtr pointing to the beginning of first space after number of channels*/ |
| 6462 | inPtr = strpbrk( inPtr, " " ); |
| 6463 | /*no channel list after the number of channels argument*/ |
| 6464 | if (NULL == inPtr) |
| 6465 | { |
Srinivas Girigowda | cf9a9b4 | 2013-03-21 11:55:24 -0700 | [diff] [blame] | 6466 | if (0 != j) |
| 6467 | { |
| 6468 | *pNumChannels = j; |
| 6469 | return VOS_STATUS_SUCCESS; |
| 6470 | } |
| 6471 | else |
| 6472 | { |
| 6473 | return -EINVAL; |
| 6474 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 6475 | } |
| 6476 | |
| 6477 | /*removing empty space*/ |
Jeff Johnson | a1f9afb | 2013-04-03 09:13:31 -0700 | [diff] [blame] | 6478 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 6479 | |
| 6480 | /*no channel list after the number of channels argument and spaces*/ |
| 6481 | if ( '\0' == *inPtr ) |
| 6482 | { |
Srinivas Girigowda | cf9a9b4 | 2013-03-21 11:55:24 -0700 | [diff] [blame] | 6483 | if (0 != j) |
| 6484 | { |
| 6485 | *pNumChannels = j; |
| 6486 | return VOS_STATUS_SUCCESS; |
| 6487 | } |
| 6488 | else |
| 6489 | { |
| 6490 | return -EINVAL; |
| 6491 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 6492 | } |
| 6493 | |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 6494 | v = sscanf(inPtr, "%31s ", buf); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 6495 | if (1 != v) return -EINVAL; |
| 6496 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 6497 | v = kstrtos32(buf, 10, &tempInt); |
Jeff Johnson | a1f9afb | 2013-04-03 09:13:31 -0700 | [diff] [blame] | 6498 | if ((v < 0) || |
| 6499 | (tempInt <= 0) || |
| 6500 | (tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX)) |
| 6501 | { |
| 6502 | return -EINVAL; |
| 6503 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 6504 | pChannelList[j] = tempInt; |
| 6505 | |
| 6506 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
| 6507 | "Channel %d added to preferred channel list", |
| 6508 | pChannelList[j] ); |
| 6509 | } |
| 6510 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 6511 | return VOS_STATUS_SUCCESS; |
| 6512 | } |
| 6513 | |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 6514 | |
| 6515 | /**--------------------------------------------------------------------------- |
| 6516 | |
| 6517 | \brief hdd_parse_reassoc_command_data() - HDD Parse reassoc command data |
| 6518 | |
| 6519 | This function parses the reasoc command data passed in the format |
| 6520 | REASSOC<space><bssid><space><channel> |
| 6521 | |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 6522 | \param - pValue Pointer to input data (its a NUL terminated string) |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 6523 | \param - pTargetApBssid Pointer to target Ap bssid |
| 6524 | \param - pChannel Pointer to the Target AP channel |
| 6525 | |
| 6526 | \return - 0 for success non-zero for failure |
| 6527 | |
| 6528 | --------------------------------------------------------------------------*/ |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 6529 | VOS_STATUS hdd_parse_reassoc_command_data(tANI_U8 *pValue, |
| 6530 | tANI_U8 *pTargetApBssid, tANI_U8 *pChannel) |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 6531 | { |
| 6532 | tANI_U8 *inPtr = pValue; |
| 6533 | int tempInt; |
| 6534 | int v = 0; |
| 6535 | tANI_U8 tempBuf[32]; |
Kiet Lam | aa8e15a | 2014-02-11 23:30:06 -0800 | [diff] [blame] | 6536 | /* 12 hexa decimal digits, 5 ':' and '\0' */ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 6537 | tANI_U8 macAddress[18]; |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 6538 | |
| 6539 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 6540 | /*no argument after the command*/ |
| 6541 | if (NULL == inPtr) |
| 6542 | { |
| 6543 | return -EINVAL; |
| 6544 | } |
| 6545 | |
| 6546 | /*no space after the command*/ |
| 6547 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 6548 | { |
| 6549 | return -EINVAL; |
| 6550 | } |
| 6551 | |
| 6552 | /*removing empty spaces*/ |
| 6553 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 6554 | |
| 6555 | /*no argument followed by spaces*/ |
| 6556 | if ('\0' == *inPtr) |
| 6557 | { |
| 6558 | return -EINVAL; |
| 6559 | } |
| 6560 | |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 6561 | v = sscanf(inPtr, "%17s", macAddress); |
| 6562 | if (!((1 == v) && hdd_is_valid_mac_address(macAddress))) |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 6563 | { |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 6564 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6565 | "Invalid MAC address or All hex inputs are not read (%d)", v); |
| 6566 | return -EINVAL; |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 6567 | } |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 6568 | |
| 6569 | pTargetApBssid[0] = hdd_parse_hex(macAddress[0]) << 4 | hdd_parse_hex(macAddress[1]); |
| 6570 | pTargetApBssid[1] = hdd_parse_hex(macAddress[3]) << 4 | hdd_parse_hex(macAddress[4]); |
| 6571 | pTargetApBssid[2] = hdd_parse_hex(macAddress[6]) << 4 | hdd_parse_hex(macAddress[7]); |
| 6572 | pTargetApBssid[3] = hdd_parse_hex(macAddress[9]) << 4 | hdd_parse_hex(macAddress[10]); |
| 6573 | pTargetApBssid[4] = hdd_parse_hex(macAddress[12]) << 4 | hdd_parse_hex(macAddress[13]); |
| 6574 | 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] | 6575 | |
| 6576 | /* point to the next argument */ |
| 6577 | inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE); |
| 6578 | /*no argument after the command*/ |
| 6579 | if (NULL == inPtr) return -EINVAL; |
| 6580 | |
| 6581 | /*removing empty spaces*/ |
| 6582 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 6583 | |
| 6584 | /*no argument followed by spaces*/ |
| 6585 | if ('\0' == *inPtr) |
| 6586 | { |
| 6587 | return -EINVAL; |
| 6588 | } |
| 6589 | |
| 6590 | /*getting the next argument ie the channel number */ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 6591 | v = sscanf(inPtr, "%31s ", tempBuf); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 6592 | if (1 != v) return -EINVAL; |
| 6593 | |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 6594 | v = kstrtos32(tempBuf, 10, &tempInt); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 6595 | if ((v < 0) || |
Padma, Santhosh Kumar | 0fa809b | 2014-11-13 14:56:56 +0530 | [diff] [blame] | 6596 | (tempInt < 0) || |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 6597 | (tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX)) |
| 6598 | { |
| 6599 | return -EINVAL; |
| 6600 | } |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 6601 | |
| 6602 | *pChannel = tempInt; |
| 6603 | return VOS_STATUS_SUCCESS; |
| 6604 | } |
| 6605 | |
| 6606 | #endif |
| 6607 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 6608 | #if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD) |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 6609 | /**--------------------------------------------------------------------------- |
| 6610 | |
| 6611 | \brief hdd_parse_get_cckm_ie() - HDD Parse and fetch the CCKM IE |
| 6612 | |
| 6613 | This function parses the SETCCKM IE command |
| 6614 | SETCCKMIE<space><ie data> |
| 6615 | |
| 6616 | \param - pValue Pointer to input data |
| 6617 | \param - pCckmIe Pointer to output cckm Ie |
| 6618 | \param - pCckmIeLen Pointer to output cckm ie length |
| 6619 | |
| 6620 | \return - 0 for success non-zero for failure |
| 6621 | |
| 6622 | --------------------------------------------------------------------------*/ |
| 6623 | VOS_STATUS hdd_parse_get_cckm_ie(tANI_U8 *pValue, tANI_U8 **pCckmIe, |
| 6624 | tANI_U8 *pCckmIeLen) |
| 6625 | { |
| 6626 | tANI_U8 *inPtr = pValue; |
| 6627 | tANI_U8 *dataEnd; |
| 6628 | int j = 0; |
| 6629 | int i = 0; |
| 6630 | tANI_U8 tempByte = 0; |
| 6631 | |
| 6632 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 6633 | /*no argument after the command*/ |
| 6634 | if (NULL == inPtr) |
| 6635 | { |
| 6636 | return -EINVAL; |
| 6637 | } |
| 6638 | |
| 6639 | /*no space after the command*/ |
| 6640 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 6641 | { |
| 6642 | return -EINVAL; |
| 6643 | } |
| 6644 | |
| 6645 | /*removing empty spaces*/ |
| 6646 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 6647 | |
| 6648 | /*no argument followed by spaces*/ |
| 6649 | if ('\0' == *inPtr) |
| 6650 | { |
| 6651 | return -EINVAL; |
| 6652 | } |
| 6653 | |
| 6654 | /* find the length of data */ |
| 6655 | dataEnd = inPtr; |
| 6656 | while(('\0' != *dataEnd) ) |
| 6657 | { |
| 6658 | dataEnd++; |
| 6659 | ++(*pCckmIeLen); |
| 6660 | } |
| 6661 | if ( *pCckmIeLen <= 0) return -EINVAL; |
| 6662 | |
| 6663 | /* Allocate the number of bytes based on the number of input characters |
| 6664 | whether it is even or odd. |
| 6665 | if the number of input characters are even, then we need N/2 byte. |
| 6666 | if the number of input characters are odd, then we need do (N+1)/2 to |
| 6667 | compensate rounding off. |
| 6668 | For example, if N = 18, then (18 + 1)/2 = 9 bytes are enough. |
| 6669 | If N = 19, then we need 10 bytes, hence (19 + 1)/2 = 10 bytes */ |
| 6670 | *pCckmIe = vos_mem_malloc((*pCckmIeLen + 1)/2); |
| 6671 | if (NULL == *pCckmIe) |
| 6672 | { |
| 6673 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 6674 | "%s: vos_mem_alloc failed ", __func__); |
| 6675 | return -EINVAL; |
| 6676 | } |
| 6677 | vos_mem_zero(*pCckmIe, (*pCckmIeLen + 1)/2); |
| 6678 | /* the buffer received from the upper layer is character buffer, |
| 6679 | we need to prepare the buffer taking 2 characters in to a U8 hex decimal number |
| 6680 | for example 7f0000f0...form a buffer to contain 7f in 0th location, 00 in 1st |
| 6681 | and f0 in 3rd location */ |
| 6682 | for (i = 0, j = 0; j < *pCckmIeLen; j += 2) |
| 6683 | { |
| 6684 | tempByte = (hdd_parse_hex(inPtr[j]) << 4) | (hdd_parse_hex(inPtr[j + 1])); |
| 6685 | (*pCckmIe)[i++] = tempByte; |
| 6686 | } |
| 6687 | *pCckmIeLen = i; |
| 6688 | |
| 6689 | return VOS_STATUS_SUCCESS; |
| 6690 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 6691 | #endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */ |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 6692 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6693 | /**--------------------------------------------------------------------------- |
| 6694 | |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 6695 | \brief hdd_is_valid_mac_address() - Validate MAC address |
| 6696 | |
| 6697 | This function validates whether the given MAC address is valid or not |
| 6698 | Expected MAC address is of the format XX:XX:XX:XX:XX:XX |
| 6699 | where X is the hexa decimal digit character and separated by ':' |
| 6700 | This algorithm works even if MAC address is not separated by ':' |
| 6701 | |
| 6702 | This code checks given input string mac contains exactly 12 hexadecimal digits. |
| 6703 | and a separator colon : appears in the input string only after |
| 6704 | an even number of hex digits. |
| 6705 | |
| 6706 | \param - pMacAddr pointer to the input MAC address |
| 6707 | \return - 1 for valid and 0 for invalid |
| 6708 | |
| 6709 | --------------------------------------------------------------------------*/ |
| 6710 | |
| 6711 | v_BOOL_t hdd_is_valid_mac_address(const tANI_U8 *pMacAddr) |
| 6712 | { |
| 6713 | int xdigit = 0; |
| 6714 | int separator = 0; |
| 6715 | while (*pMacAddr) |
| 6716 | { |
| 6717 | if (isxdigit(*pMacAddr)) |
| 6718 | { |
| 6719 | xdigit++; |
| 6720 | } |
| 6721 | else if (':' == *pMacAddr) |
| 6722 | { |
| 6723 | if (0 == xdigit || ((xdigit / 2) - 1) != separator) |
| 6724 | break; |
| 6725 | |
| 6726 | ++separator; |
| 6727 | } |
| 6728 | else |
| 6729 | { |
| 6730 | separator = -1; |
| 6731 | /* Invalid MAC found */ |
| 6732 | return 0; |
| 6733 | } |
| 6734 | ++pMacAddr; |
| 6735 | } |
| 6736 | return (xdigit == 12 && (separator == 5 || separator == 0)); |
| 6737 | } |
| 6738 | |
| 6739 | /**--------------------------------------------------------------------------- |
| 6740 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 6741 | \brief __hdd_open() - HDD Open function |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6742 | |
| 6743 | \param - dev Pointer to net_device structure |
| 6744 | |
| 6745 | \return - 0 for success non-zero for failure |
| 6746 | |
| 6747 | --------------------------------------------------------------------------*/ |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 6748 | int __hdd_open(struct net_device *dev) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6749 | { |
| 6750 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 6751 | hdd_context_t *pHddCtx; |
| 6752 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 6753 | VOS_STATUS status; |
| 6754 | v_BOOL_t in_standby = TRUE; |
| 6755 | |
| 6756 | if (NULL == pAdapter) |
| 6757 | { |
| 6758 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Agarwal Ashish | 971c288 | 2013-10-30 20:11:12 +0530 | [diff] [blame] | 6759 | "%s: pAdapter is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6760 | return -ENODEV; |
| 6761 | } |
| 6762 | |
| 6763 | pHddCtx = (hdd_context_t*)pAdapter->pHddCtx; |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 6764 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_OPEN_REQUEST, |
| 6765 | pAdapter->sessionId, pAdapter->device_mode)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6766 | if (NULL == pHddCtx) |
| 6767 | { |
| 6768 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 6769 | "%s: HDD context is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6770 | return -ENODEV; |
| 6771 | } |
| 6772 | |
| 6773 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 6774 | while ( (NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status) ) |
| 6775 | { |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 6776 | if (test_bit(DEVICE_IFACE_OPENED, &pAdapterNode->pAdapter->event_flags)) |
| 6777 | { |
| 6778 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: chip already out of standby", |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 6779 | __func__); |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 6780 | in_standby = FALSE; |
| 6781 | break; |
| 6782 | } |
| 6783 | else |
| 6784 | { |
| 6785 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 6786 | pAdapterNode = pNext; |
| 6787 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6788 | } |
| 6789 | |
| 6790 | if (TRUE == in_standby) |
| 6791 | { |
| 6792 | if (VOS_STATUS_SUCCESS != wlan_hdd_exit_lowpower(pHddCtx, pAdapter)) |
| 6793 | { |
| 6794 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failed to bring " |
| 6795 | "wlan out of power save", __func__); |
| 6796 | return -EINVAL; |
| 6797 | } |
| 6798 | } |
| 6799 | |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 6800 | set_bit(DEVICE_IFACE_OPENED, &pAdapter->event_flags); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6801 | if (hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) |
| 6802 | { |
| 6803 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 6804 | "%s: Enabling Tx Queues", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6805 | /* Enable TX queues only when we are connected */ |
Padma, Santhosh Kumar | 9dacb5c | 2014-12-17 19:22:56 +0530 | [diff] [blame] | 6806 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6807 | netif_tx_start_all_queues(dev); |
| 6808 | } |
| 6809 | |
| 6810 | return 0; |
| 6811 | } |
| 6812 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 6813 | /**--------------------------------------------------------------------------- |
| 6814 | |
| 6815 | \brief hdd_open() - Wrapper function for __hdd_open to protect it from SSR |
| 6816 | |
| 6817 | This is called in response to ifconfig up |
| 6818 | |
| 6819 | \param - dev Pointer to net_device structure |
| 6820 | |
| 6821 | \return - 0 for success non-zero for failure |
| 6822 | |
| 6823 | --------------------------------------------------------------------------*/ |
| 6824 | int hdd_open(struct net_device *dev) |
| 6825 | { |
| 6826 | int ret; |
| 6827 | |
| 6828 | vos_ssr_protect(__func__); |
| 6829 | ret = __hdd_open(dev); |
| 6830 | vos_ssr_unprotect(__func__); |
| 6831 | |
| 6832 | return ret; |
| 6833 | } |
| 6834 | |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 6835 | int __hdd_mon_open (struct net_device *dev) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6836 | { |
| 6837 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 6838 | |
| 6839 | if(pAdapter == NULL) { |
| 6840 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 6841 | "%s: HDD adapter context is Null", __func__); |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 6842 | return -EINVAL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6843 | } |
| 6844 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6845 | return 0; |
| 6846 | } |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 6847 | |
| 6848 | int hdd_mon_open (struct net_device *dev) |
| 6849 | { |
| 6850 | int ret; |
| 6851 | |
| 6852 | vos_ssr_protect(__func__); |
| 6853 | ret = __hdd_mon_open(dev); |
| 6854 | vos_ssr_unprotect(__func__); |
| 6855 | |
| 6856 | return ret; |
| 6857 | } |
| 6858 | |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 6859 | int hdd_mon_stop(struct net_device *dev) |
| 6860 | { |
| 6861 | return 0; |
| 6862 | } |
| 6863 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6864 | /**--------------------------------------------------------------------------- |
| 6865 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 6866 | \brief __hdd_stop() - HDD stop function |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6867 | |
| 6868 | \param - dev Pointer to net_device structure |
| 6869 | |
| 6870 | \return - 0 for success non-zero for failure |
| 6871 | |
| 6872 | --------------------------------------------------------------------------*/ |
| 6873 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 6874 | int __hdd_stop (struct net_device *dev) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6875 | { |
Vinay Krishna Eranna | 90f4353 | 2014-10-27 16:45:54 +0530 | [diff] [blame] | 6876 | int ret = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6877 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 6878 | hdd_context_t *pHddCtx; |
| 6879 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 6880 | VOS_STATUS status; |
| 6881 | v_BOOL_t enter_standby = TRUE; |
| 6882 | |
| 6883 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6884 | if (NULL == pAdapter) |
| 6885 | { |
| 6886 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Agarwal Ashish | 971c288 | 2013-10-30 20:11:12 +0530 | [diff] [blame] | 6887 | "%s: pAdapter is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6888 | return -ENODEV; |
| 6889 | } |
Sachin Ahuja | 9b4958f | 2015-01-15 21:37:00 +0530 | [diff] [blame] | 6890 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_STOP_REQUEST, |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 6891 | pAdapter->sessionId, pAdapter->device_mode)); |
Vinay Krishna Eranna | 90f4353 | 2014-10-27 16:45:54 +0530 | [diff] [blame] | 6892 | |
| 6893 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 6894 | ret = wlan_hdd_validate_context(pHddCtx); |
| 6895 | if (ret) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6896 | { |
Vinay Krishna Eranna | 90f4353 | 2014-10-27 16:45:54 +0530 | [diff] [blame] | 6897 | return ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6898 | } |
| 6899 | |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 6900 | /* Nothing to be done if the interface is not opened */ |
| 6901 | if (VOS_FALSE == test_bit(DEVICE_IFACE_OPENED, &pAdapter->event_flags)) |
| 6902 | { |
| 6903 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6904 | "%s: NETDEV Interface is not OPENED", __func__); |
| 6905 | return -ENODEV; |
| 6906 | } |
| 6907 | |
| 6908 | /* Make sure the interface is marked as closed */ |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 6909 | clear_bit(DEVICE_IFACE_OPENED, &pAdapter->event_flags); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6910 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disabling OS Tx queues", __func__); |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 6911 | |
| 6912 | /* Disable TX on the interface, after this hard_start_xmit() will not |
| 6913 | * be called on that interface |
| 6914 | */ |
Padma, Santhosh Kumar | 9dacb5c | 2014-12-17 19:22:56 +0530 | [diff] [blame] | 6915 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6916 | netif_tx_disable(pAdapter->dev); |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 6917 | |
| 6918 | /* Mark the interface status as "down" for outside world */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6919 | netif_carrier_off(pAdapter->dev); |
| 6920 | |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 6921 | /* The interface is marked as down for outside world (aka kernel) |
| 6922 | * But the driver is pretty much alive inside. The driver needs to |
| 6923 | * tear down the existing connection on the netdev (session) |
| 6924 | * cleanup the data pipes and wait until the control plane is stabilized |
| 6925 | * for this interface. The call also needs to wait until the above |
| 6926 | * mentioned actions are completed before returning to the caller. |
| 6927 | * Notice that the hdd_stop_adapter is requested not to close the session |
| 6928 | * That is intentional to be able to scan if it is a STA/P2P interface |
| 6929 | */ |
| 6930 | hdd_stop_adapter(pHddCtx, pAdapter, VOS_FALSE); |
Mahesh A Saptasagar | 02e36e8 | 2015-01-14 20:39:19 +0530 | [diff] [blame] | 6931 | #ifdef FEATURE_WLAN_TDLS |
| 6932 | mutex_lock(&pHddCtx->tdls_lock); |
| 6933 | #endif |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 6934 | /* DeInit the adapter. This ensures datapath cleanup as well */ |
c_hpothu | 002231a | 2015-02-05 14:58:51 +0530 | [diff] [blame] | 6935 | hdd_deinit_adapter(pHddCtx, pAdapter, TRUE); |
Mahesh A Saptasagar | 02e36e8 | 2015-01-14 20:39:19 +0530 | [diff] [blame] | 6936 | #ifdef FEATURE_WLAN_TDLS |
| 6937 | mutex_unlock(&pHddCtx->tdls_lock); |
| 6938 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6939 | /* SoftAP ifaces should never go in power save mode |
| 6940 | making sure same here. */ |
| 6941 | if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode ) |
| 6942 | || (WLAN_HDD_MONITOR == pAdapter->device_mode ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6943 | || (WLAN_HDD_P2P_GO == pAdapter->device_mode ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6944 | ) |
| 6945 | { |
| 6946 | /* SoftAP mode, so return from here */ |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6947 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 6948 | "%s: In SAP MODE", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6949 | EXIT(); |
| 6950 | return 0; |
| 6951 | } |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 6952 | /* Find if any iface is up. If any iface is up then can't put device to |
| 6953 | * sleep/power save mode |
| 6954 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6955 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 6956 | while ( (NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status) ) |
| 6957 | { |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 6958 | if (test_bit(DEVICE_IFACE_OPENED, &pAdapterNode->pAdapter->event_flags)) |
| 6959 | { |
| 6960 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Still other ifaces are up cannot " |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 6961 | "put device to sleep", __func__); |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 6962 | enter_standby = FALSE; |
| 6963 | break; |
| 6964 | } |
| 6965 | else |
| 6966 | { |
| 6967 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 6968 | pAdapterNode = pNext; |
| 6969 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6970 | } |
| 6971 | |
| 6972 | if (TRUE == enter_standby) |
| 6973 | { |
| 6974 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: All Interfaces are Down " |
| 6975 | "entering standby", __func__); |
| 6976 | if (VOS_STATUS_SUCCESS != wlan_hdd_enter_lowpower(pHddCtx)) |
| 6977 | { |
| 6978 | /*log and return success*/ |
| 6979 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failed to put " |
| 6980 | "wlan in power save", __func__); |
| 6981 | } |
| 6982 | } |
| 6983 | |
| 6984 | EXIT(); |
| 6985 | return 0; |
| 6986 | } |
| 6987 | |
| 6988 | /**--------------------------------------------------------------------------- |
| 6989 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 6990 | \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] | 6991 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 6992 | This is called in response to ifconfig down |
| 6993 | |
| 6994 | \param - dev Pointer to net_device structure |
| 6995 | |
| 6996 | \return - 0 for success non-zero for failure |
| 6997 | -----------------------------------------------------------------------------*/ |
| 6998 | int hdd_stop (struct net_device *dev) |
| 6999 | { |
| 7000 | int ret; |
| 7001 | |
| 7002 | vos_ssr_protect(__func__); |
| 7003 | ret = __hdd_stop(dev); |
| 7004 | vos_ssr_unprotect(__func__); |
| 7005 | |
| 7006 | return ret; |
| 7007 | } |
| 7008 | |
| 7009 | /**--------------------------------------------------------------------------- |
| 7010 | |
| 7011 | \brief __hdd_uninit() - HDD uninit function |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7012 | |
| 7013 | \param - dev Pointer to net_device structure |
| 7014 | |
| 7015 | \return - void |
| 7016 | |
| 7017 | --------------------------------------------------------------------------*/ |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 7018 | static void __hdd_uninit (struct net_device *dev) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7019 | { |
| 7020 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Mahesh A Saptasagar | 02e36e8 | 2015-01-14 20:39:19 +0530 | [diff] [blame] | 7021 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7022 | ENTER(); |
| 7023 | |
| 7024 | do |
| 7025 | { |
| 7026 | if (NULL == pAdapter) |
| 7027 | { |
| 7028 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 7029 | "%s: NULL pAdapter", __func__); |
| 7030 | break; |
| 7031 | } |
| 7032 | |
| 7033 | if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) |
| 7034 | { |
| 7035 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 7036 | "%s: Invalid magic", __func__); |
| 7037 | break; |
| 7038 | } |
Mahesh A Saptasagar | 02e36e8 | 2015-01-14 20:39:19 +0530 | [diff] [blame] | 7039 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 7040 | if (NULL == pHddCtx) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7041 | { |
| 7042 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 7043 | "%s: NULL pHddCtx", __func__); |
| 7044 | break; |
| 7045 | } |
| 7046 | |
| 7047 | if (dev != pAdapter->dev) |
| 7048 | { |
| 7049 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 7050 | "%s: Invalid device reference", __func__); |
| 7051 | /* we haven't validated all cases so let this go for now */ |
| 7052 | } |
Mahesh A Saptasagar | 02e36e8 | 2015-01-14 20:39:19 +0530 | [diff] [blame] | 7053 | #ifdef FEATURE_WLAN_TDLS |
| 7054 | mutex_lock(&pHddCtx->tdls_lock); |
| 7055 | #endif |
c_hpothu | 002231a | 2015-02-05 14:58:51 +0530 | [diff] [blame] | 7056 | hdd_deinit_adapter(pHddCtx, pAdapter, TRUE); |
Mahesh A Saptasagar | 02e36e8 | 2015-01-14 20:39:19 +0530 | [diff] [blame] | 7057 | #ifdef FEATURE_WLAN_TDLS |
| 7058 | mutex_unlock(&pHddCtx->tdls_lock); |
| 7059 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7060 | |
| 7061 | /* after uninit our adapter structure will no longer be valid */ |
| 7062 | pAdapter->dev = NULL; |
| 7063 | pAdapter->magic = 0; |
Manjeet Singh | 47ee847 | 2016-04-11 11:57:18 +0530 | [diff] [blame] | 7064 | pAdapter->pHddCtx = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7065 | } while (0); |
| 7066 | |
| 7067 | EXIT(); |
| 7068 | } |
| 7069 | |
| 7070 | /**--------------------------------------------------------------------------- |
| 7071 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 7072 | \brief hdd_uninit() - Wrapper function to protect __hdd_uninit from SSR |
| 7073 | |
| 7074 | This is called during the netdev unregister to uninitialize all data |
| 7075 | associated with the device |
| 7076 | |
| 7077 | \param - dev Pointer to net_device structure |
| 7078 | |
| 7079 | \return - void |
| 7080 | |
| 7081 | --------------------------------------------------------------------------*/ |
| 7082 | static void hdd_uninit (struct net_device *dev) |
| 7083 | { |
| 7084 | vos_ssr_protect(__func__); |
| 7085 | __hdd_uninit(dev); |
| 7086 | vos_ssr_unprotect(__func__); |
| 7087 | } |
| 7088 | |
| 7089 | /**--------------------------------------------------------------------------- |
| 7090 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7091 | \brief hdd_release_firmware() - |
| 7092 | |
| 7093 | This function calls the release firmware API to free the firmware buffer. |
| 7094 | |
| 7095 | \param - pFileName Pointer to the File Name. |
| 7096 | pCtx - Pointer to the adapter . |
| 7097 | |
| 7098 | |
| 7099 | \return - 0 for success, non zero for failure |
| 7100 | |
| 7101 | --------------------------------------------------------------------------*/ |
| 7102 | |
| 7103 | VOS_STATUS hdd_release_firmware(char *pFileName,v_VOID_t *pCtx) |
| 7104 | { |
| 7105 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 7106 | hdd_context_t *pHddCtx = (hdd_context_t*)pCtx; |
| 7107 | ENTER(); |
| 7108 | |
| 7109 | |
| 7110 | if (!strcmp(WLAN_FW_FILE, pFileName)) { |
| 7111 | |
| 7112 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"%s: Loaded firmware file is %s",__func__,pFileName); |
| 7113 | |
| 7114 | if(pHddCtx->fw) { |
| 7115 | release_firmware(pHddCtx->fw); |
| 7116 | pHddCtx->fw = NULL; |
| 7117 | } |
| 7118 | else |
| 7119 | status = VOS_STATUS_E_FAILURE; |
| 7120 | } |
| 7121 | else if (!strcmp(WLAN_NV_FILE,pFileName)) { |
| 7122 | if(pHddCtx->nv) { |
| 7123 | release_firmware(pHddCtx->nv); |
| 7124 | pHddCtx->nv = NULL; |
| 7125 | } |
| 7126 | else |
| 7127 | status = VOS_STATUS_E_FAILURE; |
| 7128 | |
| 7129 | } |
| 7130 | |
| 7131 | EXIT(); |
| 7132 | return status; |
| 7133 | } |
| 7134 | |
| 7135 | /**--------------------------------------------------------------------------- |
| 7136 | |
| 7137 | \brief hdd_request_firmware() - |
| 7138 | |
| 7139 | This function reads the firmware file using the request firmware |
| 7140 | API and returns the the firmware data and the firmware file size. |
| 7141 | |
| 7142 | \param - pfileName - Pointer to the file name. |
| 7143 | - pCtx - Pointer to the adapter . |
| 7144 | - ppfw_data - Pointer to the pointer of the firmware data. |
| 7145 | - pSize - Pointer to the file size. |
| 7146 | |
| 7147 | \return - VOS_STATUS_SUCCESS for success, VOS_STATUS_E_FAILURE for failure |
| 7148 | |
| 7149 | --------------------------------------------------------------------------*/ |
| 7150 | |
| 7151 | |
| 7152 | VOS_STATUS hdd_request_firmware(char *pfileName,v_VOID_t *pCtx,v_VOID_t **ppfw_data, v_SIZE_t *pSize) |
| 7153 | { |
| 7154 | int status; |
| 7155 | VOS_STATUS retval = VOS_STATUS_SUCCESS; |
| 7156 | hdd_context_t *pHddCtx = (hdd_context_t*)pCtx; |
| 7157 | ENTER(); |
| 7158 | |
| 7159 | if( (!strcmp(WLAN_FW_FILE, pfileName)) ) { |
| 7160 | |
| 7161 | status = request_firmware(&pHddCtx->fw, pfileName, pHddCtx->parent_dev); |
| 7162 | |
| 7163 | if(status || !pHddCtx->fw || !pHddCtx->fw->data) { |
| 7164 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Firmware %s download failed", |
| 7165 | __func__, pfileName); |
| 7166 | retval = VOS_STATUS_E_FAILURE; |
| 7167 | } |
| 7168 | |
| 7169 | else { |
| 7170 | *ppfw_data = (v_VOID_t *)pHddCtx->fw->data; |
| 7171 | *pSize = pHddCtx->fw->size; |
| 7172 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Firmware size = %d", |
| 7173 | __func__, *pSize); |
| 7174 | } |
| 7175 | } |
| 7176 | else if(!strcmp(WLAN_NV_FILE, pfileName)) { |
| 7177 | |
| 7178 | status = request_firmware(&pHddCtx->nv, pfileName, pHddCtx->parent_dev); |
| 7179 | |
| 7180 | if(status || !pHddCtx->nv || !pHddCtx->nv->data) { |
| 7181 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: nv %s download failed", |
| 7182 | __func__, pfileName); |
| 7183 | retval = VOS_STATUS_E_FAILURE; |
| 7184 | } |
| 7185 | |
| 7186 | else { |
| 7187 | *ppfw_data = (v_VOID_t *)pHddCtx->nv->data; |
| 7188 | *pSize = pHddCtx->nv->size; |
| 7189 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: nv file size = %d", |
| 7190 | __func__, *pSize); |
| 7191 | } |
| 7192 | } |
| 7193 | |
| 7194 | EXIT(); |
| 7195 | return retval; |
| 7196 | } |
| 7197 | /**--------------------------------------------------------------------------- |
| 7198 | \brief hdd_full_pwr_cbk() - HDD full power callbackfunction |
| 7199 | |
| 7200 | This is the function invoked by SME to inform the result of a full power |
| 7201 | request issued by HDD |
| 7202 | |
| 7203 | \param - callbackcontext - Pointer to cookie |
| 7204 | status - result of request |
| 7205 | |
| 7206 | \return - None |
| 7207 | |
| 7208 | --------------------------------------------------------------------------*/ |
| 7209 | void hdd_full_pwr_cbk(void *callbackContext, eHalStatus status) |
| 7210 | { |
| 7211 | hdd_context_t *pHddCtx = (hdd_context_t*)callbackContext; |
| 7212 | |
Madan Mohan Koyyalamudi | 8bdd311 | 2012-09-24 13:55:14 -0700 | [diff] [blame] | 7213 | 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] | 7214 | if(&pHddCtx->full_pwr_comp_var) |
| 7215 | { |
| 7216 | complete(&pHddCtx->full_pwr_comp_var); |
| 7217 | } |
| 7218 | } |
| 7219 | |
Abhishek Singh | 00b7197 | 2016-01-07 10:51:04 +0530 | [diff] [blame] | 7220 | #ifdef WLAN_FEATURE_RMC |
| 7221 | static void hdd_tx_fail_ind_callback(v_U8_t *MacAddr, v_U8_t seqNo) |
| 7222 | { |
| 7223 | int payload_len; |
| 7224 | struct sk_buff *skb; |
| 7225 | struct nlmsghdr *nlh; |
| 7226 | v_U8_t *data; |
| 7227 | |
| 7228 | payload_len = ETH_ALEN; |
| 7229 | |
| 7230 | if (0 == cesium_pid) |
| 7231 | { |
| 7232 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: cesium process not registered", |
| 7233 | __func__); |
| 7234 | return; |
| 7235 | } |
| 7236 | |
| 7237 | if ((skb = nlmsg_new(payload_len,GFP_ATOMIC)) == NULL) |
| 7238 | { |
| 7239 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 7240 | "%s: nlmsg_new() failed for msg size[%d]", |
| 7241 | __func__, NLMSG_SPACE(payload_len)); |
| 7242 | return; |
| 7243 | } |
| 7244 | |
| 7245 | nlh = nlmsg_put(skb, cesium_pid, seqNo, 0, payload_len, NLM_F_REQUEST); |
| 7246 | |
| 7247 | if (NULL == nlh) |
| 7248 | { |
| 7249 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 7250 | "%s: nlmsg_put() failed for msg size[%d]", |
| 7251 | __func__, NLMSG_SPACE(payload_len)); |
| 7252 | |
| 7253 | kfree_skb(skb); |
| 7254 | return; |
| 7255 | } |
| 7256 | |
| 7257 | data = nlmsg_data(nlh); |
| 7258 | memcpy(data, MacAddr, ETH_ALEN); |
| 7259 | |
| 7260 | if (nlmsg_unicast(cesium_nl_srv_sock, skb, cesium_pid) < 0) |
| 7261 | { |
| 7262 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: nlmsg_unicast() failed for msg size[%d]", |
| 7263 | __func__, NLMSG_SPACE(payload_len)); |
| 7264 | } |
| 7265 | |
| 7266 | return; |
| 7267 | } |
| 7268 | |
| 7269 | /**--------------------------------------------------------------------------- |
| 7270 | \brief hdd_ParseuserParams - return a pointer to the next argument |
| 7271 | |
| 7272 | \return - status |
| 7273 | |
| 7274 | --------------------------------------------------------------------------*/ |
| 7275 | static int hdd_ParseUserParams(tANI_U8 *pValue, tANI_U8 **ppArg) |
| 7276 | { |
| 7277 | tANI_U8 *pVal; |
| 7278 | |
| 7279 | pVal = strchr(pValue, ' '); |
| 7280 | |
| 7281 | if (NULL == pVal) |
| 7282 | { |
| 7283 | /* no argument remains */ |
| 7284 | return -EINVAL; |
| 7285 | } |
| 7286 | else if (SPACE_ASCII_VALUE != *pVal) |
| 7287 | { |
| 7288 | /* no space after the current argument */ |
| 7289 | return -EINVAL; |
| 7290 | } |
| 7291 | |
| 7292 | pVal++; |
| 7293 | |
| 7294 | /* remove empty spaces */ |
| 7295 | while ((SPACE_ASCII_VALUE == *pVal) && ('\0' != *pVal)) |
| 7296 | { |
| 7297 | pVal++; |
| 7298 | } |
| 7299 | |
| 7300 | /* no argument followed by spaces */ |
| 7301 | if ('\0' == *pVal) |
| 7302 | { |
| 7303 | return -EINVAL; |
| 7304 | } |
| 7305 | |
| 7306 | *ppArg = pVal; |
| 7307 | |
| 7308 | return 0; |
| 7309 | } |
| 7310 | |
| 7311 | /**---------------------------------------------------------------------------- |
| 7312 | \brief hdd_ParseIBSSTXFailEventParams - Parse params for SETIBSSTXFAILEVENT |
| 7313 | |
| 7314 | \return - status |
| 7315 | |
| 7316 | ------------------------------------------------------------------------------*/ |
| 7317 | static int hdd_ParseIBSSTXFailEventParams(tANI_U8 *pValue, |
| 7318 | tANI_U8 *tx_fail_count, |
| 7319 | tANI_U16 *pid) |
| 7320 | { |
| 7321 | tANI_U8 *param = NULL; |
| 7322 | int ret; |
| 7323 | |
| 7324 | ret = hdd_ParseUserParams(pValue, ¶m); |
| 7325 | |
| 7326 | if (0 == ret && NULL != param) |
| 7327 | { |
| 7328 | if (1 != sscanf(param, "%hhu", tx_fail_count)) |
| 7329 | { |
| 7330 | ret = -EINVAL; |
| 7331 | goto done; |
| 7332 | } |
| 7333 | } |
| 7334 | else |
| 7335 | { |
| 7336 | goto done; |
| 7337 | } |
| 7338 | |
| 7339 | if (0 == *tx_fail_count) |
| 7340 | { |
| 7341 | *pid = 0; |
| 7342 | goto done; |
| 7343 | } |
| 7344 | |
| 7345 | pValue = param; |
| 7346 | pValue++; |
| 7347 | |
| 7348 | ret = hdd_ParseUserParams(pValue, ¶m); |
| 7349 | |
| 7350 | if (0 == ret) |
| 7351 | { |
| 7352 | if (1 != sscanf(param, "%hu", pid)) |
| 7353 | { |
| 7354 | ret = -EINVAL; |
| 7355 | goto done; |
| 7356 | } |
| 7357 | } |
| 7358 | else |
| 7359 | { |
| 7360 | goto done; |
| 7361 | } |
| 7362 | |
| 7363 | done: |
| 7364 | return ret; |
| 7365 | } |
| 7366 | |
| 7367 | static int hdd_open_cesium_nl_sock() |
| 7368 | { |
| 7369 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 7370 | struct netlink_kernel_cfg cfg = { |
| 7371 | .groups = WLAN_NLINK_MCAST_GRP_ID, |
| 7372 | .input = NULL |
| 7373 | }; |
| 7374 | #endif |
| 7375 | int ret = 0; |
| 7376 | |
| 7377 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 7378 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 7379 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)) |
| 7380 | THIS_MODULE, |
| 7381 | #endif |
| 7382 | &cfg); |
| 7383 | #else |
| 7384 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 7385 | WLAN_NLINK_MCAST_GRP_ID, NULL, NULL, THIS_MODULE); |
| 7386 | #endif |
| 7387 | |
| 7388 | if (cesium_nl_srv_sock == NULL) |
| 7389 | { |
| 7390 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7391 | "NLINK: cesium netlink_kernel_create failed"); |
| 7392 | ret = -ECONNREFUSED; |
| 7393 | } |
| 7394 | |
| 7395 | return ret; |
| 7396 | } |
| 7397 | |
| 7398 | static void hdd_close_cesium_nl_sock() |
| 7399 | { |
| 7400 | if (NULL != cesium_nl_srv_sock) |
| 7401 | { |
| 7402 | netlink_kernel_release(cesium_nl_srv_sock); |
| 7403 | cesium_nl_srv_sock = NULL; |
| 7404 | } |
| 7405 | } |
| 7406 | #endif /* WLAN_FEATURE_RMC */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7407 | /**--------------------------------------------------------------------------- |
| 7408 | |
| 7409 | \brief hdd_req_bmps_cbk() - HDD Request BMPS callback function |
| 7410 | |
| 7411 | This is the function invoked by SME to inform the result of BMPS |
| 7412 | request issued by HDD |
| 7413 | |
| 7414 | \param - callbackcontext - Pointer to cookie |
| 7415 | status - result of request |
| 7416 | |
| 7417 | \return - None |
| 7418 | |
| 7419 | --------------------------------------------------------------------------*/ |
| 7420 | void hdd_req_bmps_cbk(void *callbackContext, eHalStatus status) |
| 7421 | { |
| 7422 | |
| 7423 | struct completion *completion_var = (struct completion*) callbackContext; |
| 7424 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 7425 | hddLog(VOS_TRACE_LEVEL_ERROR, "HDD BMPS request Callback, status = %d", status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7426 | if(completion_var != NULL) |
| 7427 | { |
| 7428 | complete(completion_var); |
| 7429 | } |
| 7430 | } |
| 7431 | |
| 7432 | /**--------------------------------------------------------------------------- |
| 7433 | |
| 7434 | \brief hdd_get_cfg_file_size() - |
| 7435 | |
| 7436 | This function reads the configuration file using the request firmware |
| 7437 | API and returns the configuration file size. |
| 7438 | |
| 7439 | \param - pCtx - Pointer to the adapter . |
| 7440 | - pFileName - Pointer to the file name. |
| 7441 | - pBufSize - Pointer to the buffer size. |
| 7442 | |
| 7443 | \return - 0 for success, non zero for failure |
| 7444 | |
| 7445 | --------------------------------------------------------------------------*/ |
| 7446 | |
| 7447 | VOS_STATUS hdd_get_cfg_file_size(v_VOID_t *pCtx, char *pFileName, v_SIZE_t *pBufSize) |
| 7448 | { |
| 7449 | int status; |
| 7450 | hdd_context_t *pHddCtx = (hdd_context_t*)pCtx; |
| 7451 | |
| 7452 | ENTER(); |
| 7453 | |
| 7454 | status = request_firmware(&pHddCtx->fw, pFileName, pHddCtx->parent_dev); |
| 7455 | |
| 7456 | if(status || !pHddCtx->fw || !pHddCtx->fw->data) { |
| 7457 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: CFG download failed",__func__); |
| 7458 | status = VOS_STATUS_E_FAILURE; |
| 7459 | } |
| 7460 | else { |
| 7461 | *pBufSize = pHddCtx->fw->size; |
| 7462 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: CFG size = %d", __func__, *pBufSize); |
| 7463 | release_firmware(pHddCtx->fw); |
| 7464 | pHddCtx->fw = NULL; |
| 7465 | } |
| 7466 | |
| 7467 | EXIT(); |
| 7468 | return VOS_STATUS_SUCCESS; |
| 7469 | } |
| 7470 | |
| 7471 | /**--------------------------------------------------------------------------- |
| 7472 | |
| 7473 | \brief hdd_read_cfg_file() - |
| 7474 | |
| 7475 | This function reads the configuration file using the request firmware |
| 7476 | API and returns the cfg data and the buffer size of the configuration file. |
| 7477 | |
| 7478 | \param - pCtx - Pointer to the adapter . |
| 7479 | - pFileName - Pointer to the file name. |
| 7480 | - pBuffer - Pointer to the data buffer. |
| 7481 | - pBufSize - Pointer to the buffer size. |
| 7482 | |
| 7483 | \return - 0 for success, non zero for failure |
| 7484 | |
| 7485 | --------------------------------------------------------------------------*/ |
| 7486 | |
| 7487 | VOS_STATUS hdd_read_cfg_file(v_VOID_t *pCtx, char *pFileName, |
| 7488 | v_VOID_t *pBuffer, v_SIZE_t *pBufSize) |
| 7489 | { |
| 7490 | int status; |
| 7491 | hdd_context_t *pHddCtx = (hdd_context_t*)pCtx; |
| 7492 | |
| 7493 | ENTER(); |
| 7494 | |
| 7495 | status = request_firmware(&pHddCtx->fw, pFileName, pHddCtx->parent_dev); |
| 7496 | |
| 7497 | if(status || !pHddCtx->fw || !pHddCtx->fw->data) { |
| 7498 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: CFG download failed",__func__); |
| 7499 | return VOS_STATUS_E_FAILURE; |
| 7500 | } |
| 7501 | else { |
| 7502 | if(*pBufSize != pHddCtx->fw->size) { |
| 7503 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Caller sets invalid CFG " |
| 7504 | "file size", __func__); |
| 7505 | release_firmware(pHddCtx->fw); |
| 7506 | pHddCtx->fw = NULL; |
| 7507 | return VOS_STATUS_E_FAILURE; |
| 7508 | } |
| 7509 | else { |
| 7510 | if(pBuffer) { |
| 7511 | vos_mem_copy(pBuffer,pHddCtx->fw->data,*pBufSize); |
| 7512 | } |
| 7513 | release_firmware(pHddCtx->fw); |
| 7514 | pHddCtx->fw = NULL; |
| 7515 | } |
| 7516 | } |
| 7517 | |
| 7518 | EXIT(); |
| 7519 | |
| 7520 | return VOS_STATUS_SUCCESS; |
| 7521 | } |
| 7522 | |
| 7523 | /**--------------------------------------------------------------------------- |
| 7524 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 7525 | \brief __hdd_set_mac_address() - |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7526 | |
| 7527 | This function sets the user specified mac address using |
| 7528 | the command ifconfig wlanX hw ether <mac adress>. |
| 7529 | |
| 7530 | \param - dev - Pointer to the net device. |
| 7531 | - addr - Pointer to the sockaddr. |
| 7532 | \return - 0 for success, non zero for failure |
| 7533 | |
| 7534 | --------------------------------------------------------------------------*/ |
| 7535 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 7536 | static int __hdd_set_mac_address(struct net_device *dev, void *addr) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7537 | { |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 7538 | hdd_adapter_t *pAdapter; |
| 7539 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7540 | struct sockaddr *psta_mac_addr = addr; |
| 7541 | eHalStatus halStatus = eHAL_STATUS_SUCCESS; |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 7542 | int ret = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7543 | |
| 7544 | ENTER(); |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 7545 | pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7546 | if (NULL == pAdapter) |
| 7547 | { |
| 7548 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7549 | "%s: Adapter is NULL",__func__); |
| 7550 | return -EINVAL; |
| 7551 | } |
| 7552 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 7553 | ret = wlan_hdd_validate_context(pHddCtx); |
| 7554 | if (0 != ret) |
| 7555 | { |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 7556 | return ret; |
| 7557 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7558 | |
| 7559 | memcpy(&pAdapter->macAddressCurrent, psta_mac_addr->sa_data, ETH_ALEN); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7560 | memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN); |
| 7561 | |
| 7562 | EXIT(); |
| 7563 | return halStatus; |
| 7564 | } |
| 7565 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 7566 | /**--------------------------------------------------------------------------- |
| 7567 | |
| 7568 | \brief hdd_set_mac_address() - |
| 7569 | |
| 7570 | Wrapper function to protect __hdd_set_mac_address() function from ssr |
| 7571 | |
| 7572 | \param - dev - Pointer to the net device. |
| 7573 | - addr - Pointer to the sockaddr. |
| 7574 | \return - 0 for success, non zero for failure |
| 7575 | |
| 7576 | --------------------------------------------------------------------------*/ |
| 7577 | static int hdd_set_mac_address(struct net_device *dev, void *addr) |
| 7578 | { |
| 7579 | int ret; |
| 7580 | |
| 7581 | vos_ssr_protect(__func__); |
| 7582 | ret = __hdd_set_mac_address(dev, addr); |
| 7583 | vos_ssr_unprotect(__func__); |
| 7584 | |
| 7585 | return ret; |
| 7586 | } |
| 7587 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7588 | tANI_U8* wlan_hdd_get_intf_addr(hdd_context_t* pHddCtx) |
| 7589 | { |
| 7590 | int i; |
| 7591 | for ( i = 0; i < VOS_MAX_CONCURRENCY_PERSONA; i++) |
| 7592 | { |
Abhishek Singh | eb18378 | 2014-02-06 13:37:21 +0530 | [diff] [blame] | 7593 | if( 0 == ((pHddCtx->cfg_ini->intfAddrMask) & (1 << i)) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7594 | break; |
| 7595 | } |
| 7596 | |
| 7597 | if( VOS_MAX_CONCURRENCY_PERSONA == i) |
| 7598 | return NULL; |
| 7599 | |
| 7600 | pHddCtx->cfg_ini->intfAddrMask |= (1 << i); |
| 7601 | return &pHddCtx->cfg_ini->intfMacAddr[i].bytes[0]; |
| 7602 | } |
| 7603 | |
| 7604 | void wlan_hdd_release_intf_addr(hdd_context_t* pHddCtx, tANI_U8* releaseAddr) |
| 7605 | { |
| 7606 | int i; |
| 7607 | for ( i = 0; i < VOS_MAX_CONCURRENCY_PERSONA; i++) |
| 7608 | { |
| 7609 | if ( !memcmp(releaseAddr, &pHddCtx->cfg_ini->intfMacAddr[i].bytes[0], 6) ) |
| 7610 | { |
| 7611 | pHddCtx->cfg_ini->intfAddrMask &= ~(1 << i); |
| 7612 | break; |
| 7613 | } |
| 7614 | } |
| 7615 | return; |
| 7616 | } |
| 7617 | |
| 7618 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)) |
| 7619 | static struct net_device_ops wlan_drv_ops = { |
| 7620 | .ndo_open = hdd_open, |
| 7621 | .ndo_stop = hdd_stop, |
| 7622 | .ndo_uninit = hdd_uninit, |
| 7623 | .ndo_start_xmit = hdd_hard_start_xmit, |
| 7624 | .ndo_tx_timeout = hdd_tx_timeout, |
| 7625 | .ndo_get_stats = hdd_stats, |
| 7626 | .ndo_do_ioctl = hdd_ioctl, |
| 7627 | .ndo_set_mac_address = hdd_set_mac_address, |
| 7628 | .ndo_select_queue = hdd_select_queue, |
| 7629 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 7630 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(3,1,0)) |
| 7631 | .ndo_set_rx_mode = hdd_set_multicast_list, |
| 7632 | #else |
| 7633 | .ndo_set_multicast_list = hdd_set_multicast_list, |
| 7634 | #endif //LINUX_VERSION_CODE |
| 7635 | #endif |
| 7636 | }; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7637 | static struct net_device_ops wlan_mon_drv_ops = { |
| 7638 | .ndo_open = hdd_mon_open, |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 7639 | .ndo_stop = hdd_mon_stop, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7640 | .ndo_uninit = hdd_uninit, |
| 7641 | .ndo_start_xmit = hdd_mon_hard_start_xmit, |
| 7642 | .ndo_tx_timeout = hdd_tx_timeout, |
| 7643 | .ndo_get_stats = hdd_stats, |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 7644 | .ndo_do_ioctl = hdd_mon_ioctl, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7645 | .ndo_set_mac_address = hdd_set_mac_address, |
| 7646 | }; |
Mahesh A Saptasagar | 305e263 | 2015-03-04 12:57:33 +0530 | [diff] [blame] | 7647 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7648 | #endif |
| 7649 | |
| 7650 | void hdd_set_station_ops( struct net_device *pWlanDev ) |
| 7651 | { |
| 7652 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7653 | pWlanDev->netdev_ops = &wlan_drv_ops; |
| 7654 | #else |
| 7655 | pWlanDev->open = hdd_open; |
| 7656 | pWlanDev->stop = hdd_stop; |
| 7657 | pWlanDev->uninit = hdd_uninit; |
| 7658 | pWlanDev->hard_start_xmit = NULL; |
| 7659 | pWlanDev->tx_timeout = hdd_tx_timeout; |
| 7660 | pWlanDev->get_stats = hdd_stats; |
| 7661 | pWlanDev->do_ioctl = hdd_ioctl; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7662 | pWlanDev->set_mac_address = hdd_set_mac_address; |
| 7663 | #endif |
| 7664 | } |
| 7665 | |
Katya Nigam | 1fd2440 | 2015-02-16 14:52:19 +0530 | [diff] [blame] | 7666 | void hdd_set_ibss_ops( hdd_adapter_t *pAdapter ) |
| 7667 | { |
| 7668 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)) |
| 7669 | wlan_drv_ops.ndo_start_xmit = hdd_ibss_hard_start_xmit; |
| 7670 | #else |
| 7671 | pAdapter->dev->hard_start_xmit = hdd_ibss_hard_start_xmit; |
| 7672 | #endif |
| 7673 | } |
| 7674 | |
Jeff Johnson | eed415b | 2013-01-18 16:11:20 -0800 | [diff] [blame] | 7675 | 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] | 7676 | { |
| 7677 | struct net_device *pWlanDev = NULL; |
| 7678 | hdd_adapter_t *pAdapter = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7679 | /* |
| 7680 | * cfg80211 initialization and registration.... |
| 7681 | */ |
Anand N Sunkad | c34abbd | 2015-07-29 09:52:59 +0530 | [diff] [blame] | 7682 | pWlanDev = alloc_netdev_mq(sizeof( hdd_adapter_t ), name, |
| 7683 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)) |
| 7684 | NET_NAME_UNKNOWN, |
| 7685 | #endif |
| 7686 | ether_setup, NUM_TX_QUEUES); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7687 | if(pWlanDev != NULL) |
| 7688 | { |
| 7689 | |
| 7690 | //Save the pointer to the net_device in the HDD adapter |
| 7691 | pAdapter = (hdd_adapter_t*) netdev_priv( pWlanDev ); |
| 7692 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7693 | vos_mem_zero( pAdapter, sizeof( hdd_adapter_t ) ); |
| 7694 | |
| 7695 | pAdapter->dev = pWlanDev; |
| 7696 | pAdapter->pHddCtx = pHddCtx; |
| 7697 | pAdapter->magic = WLAN_HDD_ADAPTER_MAGIC; |
Agarwal Ashish | 47d1811 | 2014-08-04 19:55:07 +0530 | [diff] [blame] | 7698 | spin_lock_init(&pAdapter->lock_for_active_session); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7699 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 7700 | #ifdef FEATURE_WLAN_BATCH_SCAN |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 7701 | pAdapter->pBatchScanRsp = NULL; |
| 7702 | pAdapter->numScanList = 0; |
Rajeev Kumar | 20140c1 | 2013-10-21 19:39:02 -0700 | [diff] [blame] | 7703 | pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STOPPED; |
Kiet Lam | aa8e15a | 2014-02-11 23:30:06 -0800 | [diff] [blame] | 7704 | pAdapter->prev_batch_id = 0; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 7705 | mutex_init(&pAdapter->hdd_batch_scan_lock); |
| 7706 | #endif |
| 7707 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7708 | pAdapter->isLinkUpSvcNeeded = FALSE; |
| 7709 | pAdapter->higherDtimTransition = eANI_BOOLEAN_TRUE; |
| 7710 | //Init the net_device structure |
| 7711 | strlcpy(pWlanDev->name, name, IFNAMSIZ); |
| 7712 | |
| 7713 | vos_mem_copy(pWlanDev->dev_addr, (void *)macAddr, sizeof(tSirMacAddr)); |
| 7714 | vos_mem_copy( pAdapter->macAddressCurrent.bytes, macAddr, sizeof(tSirMacAddr)); |
| 7715 | pWlanDev->watchdog_timeo = HDD_TX_TIMEOUT; |
| 7716 | pWlanDev->hard_header_len += LIBRA_HW_NEEDED_HEADROOM; |
| 7717 | |
| 7718 | hdd_set_station_ops( pAdapter->dev ); |
| 7719 | |
| 7720 | pWlanDev->destructor = free_netdev; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7721 | pWlanDev->ieee80211_ptr = &pAdapter->wdev ; |
| 7722 | pAdapter->wdev.wiphy = pHddCtx->wiphy; |
| 7723 | pAdapter->wdev.netdev = pWlanDev; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7724 | /* set pWlanDev's parent to underlying device */ |
| 7725 | SET_NETDEV_DEV(pWlanDev, pHddCtx->parent_dev); |
Kumar Anand | 82c009f | 2014-05-29 00:29:42 -0700 | [diff] [blame] | 7726 | |
| 7727 | hdd_wmm_init( pAdapter ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7728 | } |
| 7729 | |
| 7730 | return pAdapter; |
| 7731 | } |
| 7732 | |
| 7733 | VOS_STATUS hdd_register_interface( hdd_adapter_t *pAdapter, tANI_U8 rtnl_lock_held ) |
| 7734 | { |
| 7735 | struct net_device *pWlanDev = pAdapter->dev; |
| 7736 | //hdd_station_ctx_t *pHddStaCtx = &pAdapter->sessionCtx.station; |
| 7737 | //hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
| 7738 | //eHalStatus halStatus = eHAL_STATUS_SUCCESS; |
| 7739 | |
| 7740 | if( rtnl_lock_held ) |
| 7741 | { |
Madan Mohan Koyyalamudi | d8ac866 | 2012-11-06 19:04:56 -0800 | [diff] [blame] | 7742 | if (strnchr(pWlanDev->name, strlen(pWlanDev->name), '%')) { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7743 | if( dev_alloc_name(pWlanDev, pWlanDev->name) < 0 ) |
| 7744 | { |
| 7745 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s:Failed:dev_alloc_name",__func__); |
| 7746 | return VOS_STATUS_E_FAILURE; |
| 7747 | } |
| 7748 | } |
| 7749 | if (register_netdevice(pWlanDev)) |
| 7750 | { |
| 7751 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s:Failed:register_netdev",__func__); |
| 7752 | return VOS_STATUS_E_FAILURE; |
| 7753 | } |
| 7754 | } |
| 7755 | else |
| 7756 | { |
| 7757 | if(register_netdev(pWlanDev)) |
| 7758 | { |
| 7759 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failed:register_netdev",__func__); |
| 7760 | return VOS_STATUS_E_FAILURE; |
| 7761 | } |
| 7762 | } |
| 7763 | set_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags); |
| 7764 | |
| 7765 | return VOS_STATUS_SUCCESS; |
| 7766 | } |
| 7767 | |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 7768 | static eHalStatus hdd_smeCloseSessionCallback(void *pContext) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7769 | { |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 7770 | hdd_adapter_t *pAdapter = pContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7771 | |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 7772 | if (NULL == pAdapter) |
| 7773 | { |
| 7774 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: NULL pAdapter", __func__); |
| 7775 | return eHAL_STATUS_INVALID_PARAMETER; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7776 | } |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 7777 | |
| 7778 | if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) |
| 7779 | { |
| 7780 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Invalid magic", __func__); |
| 7781 | return eHAL_STATUS_NOT_INITIALIZED; |
| 7782 | } |
| 7783 | |
| 7784 | clear_bit(SME_SESSION_OPENED, &pAdapter->event_flags); |
| 7785 | |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 7786 | #ifndef WLAN_OPEN_SOURCE |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 7787 | /* need to make sure all of our scheduled work has completed. |
| 7788 | * This callback is called from MC thread context, so it is safe to |
| 7789 | * to call below flush workqueue API from here. |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 7790 | * |
| 7791 | * Even though this is called from MC thread context, if there is a faulty |
| 7792 | * work item in the system, that can hang this call forever. So flushing |
| 7793 | * this global work queue is not safe; and now we make sure that |
| 7794 | * individual work queues are stopped correctly. But the cancel work queue |
| 7795 | * is a GPL only API, so the proprietary version of the driver would still |
| 7796 | * rely on the global work queue flush. |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 7797 | */ |
| 7798 | flush_scheduled_work(); |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 7799 | #endif |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 7800 | |
| 7801 | /* We can be blocked while waiting for scheduled work to be |
| 7802 | * flushed, and the adapter structure can potentially be freed, in |
| 7803 | * which case the magic will have been reset. So make sure the |
| 7804 | * magic is still good, and hence the adapter structure is still |
| 7805 | * valid, before signaling completion */ |
| 7806 | if (WLAN_HDD_ADAPTER_MAGIC == pAdapter->magic) |
| 7807 | { |
| 7808 | complete(&pAdapter->session_close_comp_var); |
| 7809 | } |
| 7810 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7811 | return eHAL_STATUS_SUCCESS; |
| 7812 | } |
Manjeet Singh | 47ee847 | 2016-04-11 11:57:18 +0530 | [diff] [blame] | 7813 | /** |
| 7814 | * hdd_close_tx_queues() - close tx queues |
| 7815 | * @hdd_ctx: hdd global context |
| 7816 | * |
| 7817 | * Return: None |
| 7818 | */ |
| 7819 | static void hdd_close_tx_queues(hdd_context_t *hdd_ctx) |
| 7820 | { |
| 7821 | VOS_STATUS status; |
| 7822 | hdd_adapter_t *adapter; |
| 7823 | hdd_adapter_list_node_t *adapter_node = NULL, *next_adapter = NULL; |
| 7824 | /* Not validating hdd_ctx as it's already done by the caller */ |
| 7825 | ENTER(); |
| 7826 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
| 7827 | while (NULL != adapter_node && VOS_STATUS_SUCCESS == status) { |
| 7828 | adapter = adapter_node->pAdapter; |
| 7829 | if (adapter && adapter->dev) { |
| 7830 | netif_tx_disable (adapter->dev); |
| 7831 | netif_carrier_off(adapter->dev); |
| 7832 | } |
| 7833 | status = hdd_get_next_adapter(hdd_ctx, adapter_node, |
| 7834 | &next_adapter); |
| 7835 | adapter_node = next_adapter; |
| 7836 | } |
| 7837 | EXIT(); |
| 7838 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7839 | |
| 7840 | VOS_STATUS hdd_init_station_mode( hdd_adapter_t *pAdapter ) |
| 7841 | { |
| 7842 | struct net_device *pWlanDev = pAdapter->dev; |
| 7843 | hdd_station_ctx_t *pHddStaCtx = &pAdapter->sessionCtx.station; |
| 7844 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
| 7845 | eHalStatus halStatus = eHAL_STATUS_SUCCESS; |
| 7846 | VOS_STATUS status = VOS_STATUS_E_FAILURE; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7847 | long rc = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7848 | |
Nirav Shah | 7e3c813 | 2015-06-22 23:51:42 +0530 | [diff] [blame] | 7849 | spin_lock_init( &pAdapter->sta_hash_lock); |
| 7850 | pAdapter->is_sta_id_hash_initialized = VOS_FALSE; |
| 7851 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7852 | INIT_COMPLETION(pAdapter->session_open_comp_var); |
Kiran Kumar Lokere | 0ad5cd3 | 2013-06-25 11:26:22 -0700 | [diff] [blame] | 7853 | sme_SetCurrDeviceMode(pHddCtx->hHal, pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7854 | //Open a SME session for future operation |
| 7855 | halStatus = sme_OpenSession( pHddCtx->hHal, hdd_smeRoamCallback, pAdapter, |
Kiran Kumar Lokere | 0ad5cd3 | 2013-06-25 11:26:22 -0700 | [diff] [blame] | 7856 | (tANI_U8 *)&pAdapter->macAddressCurrent, &pAdapter->sessionId); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7857 | if ( !HAL_STATUS_SUCCESS( halStatus ) ) |
| 7858 | { |
| 7859 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 7860 | "sme_OpenSession() failed with status code %08d [x%08x]", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7861 | halStatus, halStatus ); |
| 7862 | status = VOS_STATUS_E_FAILURE; |
| 7863 | goto error_sme_open; |
| 7864 | } |
| 7865 | |
| 7866 | //Block on a completion variable. Can't wait forever though. |
Vinay Krishna Eranna | 0fe2e7c | 2014-04-09 21:32:08 +0530 | [diff] [blame] | 7867 | rc = wait_for_completion_timeout( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7868 | &pAdapter->session_open_comp_var, |
| 7869 | msecs_to_jiffies(WLAN_WAIT_TIME_SESSIONOPENCLOSE)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7870 | if (rc <= 0) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7871 | { |
| 7872 | hddLog(VOS_TRACE_LEVEL_FATAL, |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7873 | "Session is not opened within timeout period code %ld", rc ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7874 | status = VOS_STATUS_E_FAILURE; |
| 7875 | goto error_sme_open; |
| 7876 | } |
| 7877 | |
| 7878 | // Register wireless extensions |
| 7879 | if( eHAL_STATUS_SUCCESS != (halStatus = hdd_register_wext(pWlanDev))) |
| 7880 | { |
| 7881 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 7882 | "hdd_register_wext() failed with status code %08d [x%08x]", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7883 | halStatus, halStatus ); |
| 7884 | status = VOS_STATUS_E_FAILURE; |
| 7885 | goto error_register_wext; |
| 7886 | } |
Katya Nigam | 1fd2440 | 2015-02-16 14:52:19 +0530 | [diff] [blame] | 7887 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7888 | //Safe to register the hard_start_xmit function again |
Katya Nigam | 1fd2440 | 2015-02-16 14:52:19 +0530 | [diff] [blame] | 7889 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)) |
| 7890 | wlan_drv_ops.ndo_start_xmit = hdd_hard_start_xmit; |
| 7891 | #else |
| 7892 | pWlanDev->hard_start_xmit = hdd_hard_start_xmit; |
| 7893 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7894 | |
| 7895 | //Set the Connection State to Not Connected |
Abhishek Singh | f4669da | 2014-05-26 15:07:49 +0530 | [diff] [blame] | 7896 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 7897 | "%s: Set HDD connState to eConnectionState_NotConnected", |
| 7898 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7899 | pHddStaCtx->conn_info.connState = eConnectionState_NotConnected; |
| 7900 | |
| 7901 | //Set the default operation channel |
| 7902 | pHddStaCtx->conn_info.operationChannel = pHddCtx->cfg_ini->OperatingChannel; |
| 7903 | |
| 7904 | /* Make the default Auth Type as OPEN*/ |
| 7905 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 7906 | |
| 7907 | if( VOS_STATUS_SUCCESS != ( status = hdd_init_tx_rx( pAdapter ) ) ) |
| 7908 | { |
| 7909 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 7910 | "hdd_init_tx_rx() failed with status code %08d [x%08x]", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7911 | status, status ); |
| 7912 | goto error_init_txrx; |
| 7913 | } |
| 7914 | |
| 7915 | set_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags); |
| 7916 | |
| 7917 | if( VOS_STATUS_SUCCESS != ( status = hdd_wmm_adapter_init( pAdapter ) ) ) |
| 7918 | { |
| 7919 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 7920 | "hdd_wmm_adapter_init() failed with status code %08d [x%08x]", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7921 | status, status ); |
| 7922 | goto error_wmm_init; |
| 7923 | } |
| 7924 | |
| 7925 | set_bit(WMM_INIT_DONE, &pAdapter->event_flags); |
| 7926 | |
| 7927 | return VOS_STATUS_SUCCESS; |
| 7928 | |
| 7929 | error_wmm_init: |
| 7930 | clear_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags); |
| 7931 | hdd_deinit_tx_rx(pAdapter); |
| 7932 | error_init_txrx: |
| 7933 | hdd_UnregisterWext(pWlanDev); |
| 7934 | error_register_wext: |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 7935 | if (test_bit(SME_SESSION_OPENED, &pAdapter->event_flags)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7936 | { |
| 7937 | INIT_COMPLETION(pAdapter->session_close_comp_var); |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 7938 | if (eHAL_STATUS_SUCCESS == sme_CloseSession(pHddCtx->hHal, |
Agrawal Ashish | 5a3522c | 2016-03-02 15:08:28 +0530 | [diff] [blame] | 7939 | pAdapter->sessionId, FALSE, VOS_TRUE, |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 7940 | hdd_smeCloseSessionCallback, pAdapter)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7941 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7942 | unsigned long rc; |
| 7943 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7944 | //Block on a completion variable. Can't wait forever though. |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7945 | rc = wait_for_completion_timeout( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7946 | &pAdapter->session_close_comp_var, |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 7947 | msecs_to_jiffies(WLAN_WAIT_TIME_SESSIONOPENCLOSE)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7948 | if (rc <= 0) |
| 7949 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 7950 | FL("Session is not opened within timeout period code %ld"), rc); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7951 | } |
| 7952 | } |
| 7953 | error_sme_open: |
| 7954 | return status; |
| 7955 | } |
| 7956 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7957 | void hdd_cleanup_actionframe( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter ) |
| 7958 | { |
| 7959 | hdd_cfg80211_state_t *cfgState; |
| 7960 | |
| 7961 | cfgState = WLAN_HDD_GET_CFG_STATE_PTR( pAdapter ); |
| 7962 | |
| 7963 | if( NULL != cfgState->buf ) |
| 7964 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7965 | long rc; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7966 | INIT_COMPLETION(pAdapter->tx_action_cnf_event); |
| 7967 | rc = wait_for_completion_interruptible_timeout( |
| 7968 | &pAdapter->tx_action_cnf_event, |
| 7969 | msecs_to_jiffies(ACTION_FRAME_TX_TIMEOUT)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7970 | if (rc <= 0) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7971 | { |
Deepthi Gowri | 91b3e9c | 2015-08-25 13:14:58 +0530 | [diff] [blame] | 7972 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7973 | "%s ERROR: HDD Wait for Action Confirmation Failed!! %ld" |
| 7974 | , __func__, rc); |
| 7975 | |
| 7976 | // Inform tx status as FAILURE to upper layer and free cfgState->buf |
| 7977 | hdd_sendActionCnf( pAdapter, FALSE ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7978 | } |
| 7979 | } |
| 7980 | return; |
| 7981 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7982 | |
c_hpothu | 002231a | 2015-02-05 14:58:51 +0530 | [diff] [blame] | 7983 | 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] | 7984 | { |
| 7985 | ENTER(); |
| 7986 | switch ( pAdapter->device_mode ) |
| 7987 | { |
Katya Nigam | 1fd2440 | 2015-02-16 14:52:19 +0530 | [diff] [blame] | 7988 | case WLAN_HDD_IBSS: |
| 7989 | { |
| 7990 | if(test_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags)) |
| 7991 | { |
| 7992 | hdd_ibss_deinit_tx_rx( pAdapter ); |
| 7993 | clear_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags); |
| 7994 | } |
| 7995 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7996 | case WLAN_HDD_INFRA_STATION: |
| 7997 | case WLAN_HDD_P2P_CLIENT: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7998 | case WLAN_HDD_P2P_DEVICE: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7999 | { |
| 8000 | if(test_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags)) |
| 8001 | { |
| 8002 | hdd_deinit_tx_rx( pAdapter ); |
| 8003 | clear_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags); |
| 8004 | } |
| 8005 | |
| 8006 | if(test_bit(WMM_INIT_DONE, &pAdapter->event_flags)) |
| 8007 | { |
| 8008 | hdd_wmm_adapter_close( pAdapter ); |
| 8009 | clear_bit(WMM_INIT_DONE, &pAdapter->event_flags); |
| 8010 | } |
| 8011 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8012 | hdd_cleanup_actionframe(pHddCtx, pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8013 | break; |
| 8014 | } |
| 8015 | |
| 8016 | case WLAN_HDD_SOFTAP: |
| 8017 | case WLAN_HDD_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8018 | { |
Madan Mohan Koyyalamudi | 8c6dec8 | 2013-09-26 15:56:13 +0530 | [diff] [blame] | 8019 | |
| 8020 | if (test_bit(WMM_INIT_DONE, &pAdapter->event_flags)) |
| 8021 | { |
| 8022 | hdd_wmm_adapter_close( pAdapter ); |
| 8023 | clear_bit(WMM_INIT_DONE, &pAdapter->event_flags); |
| 8024 | } |
| 8025 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8026 | hdd_cleanup_actionframe(pHddCtx, pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8027 | |
c_hpothu | 002231a | 2015-02-05 14:58:51 +0530 | [diff] [blame] | 8028 | hdd_unregister_hostapd(pAdapter, rtnl_held); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8029 | hdd_set_conparam( 0 ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8030 | break; |
| 8031 | } |
| 8032 | |
| 8033 | case WLAN_HDD_MONITOR: |
| 8034 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8035 | if(test_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags)) |
| 8036 | { |
| 8037 | hdd_deinit_tx_rx( pAdapter ); |
| 8038 | clear_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags); |
| 8039 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8040 | break; |
| 8041 | } |
| 8042 | |
| 8043 | |
| 8044 | default: |
| 8045 | break; |
| 8046 | } |
| 8047 | |
| 8048 | EXIT(); |
| 8049 | } |
| 8050 | |
| 8051 | void hdd_cleanup_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter, tANI_U8 rtnl_held ) |
| 8052 | { |
Mingcheng Zhu | 87f22fc | 2014-01-30 19:23:32 -0800 | [diff] [blame] | 8053 | struct net_device *pWlanDev = NULL; |
Srinivas, Dasari | 693dfc5 | 2013-12-27 17:29:09 +0530 | [diff] [blame] | 8054 | |
| 8055 | ENTER(); |
| 8056 | if (NULL == pAdapter) |
| 8057 | { |
| 8058 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8059 | "%s: HDD adapter is Null", __func__); |
| 8060 | return; |
| 8061 | } |
| 8062 | |
| 8063 | pWlanDev = pAdapter->dev; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8064 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 8065 | #ifdef FEATURE_WLAN_BATCH_SCAN |
Srinivas, Dasari | 693dfc5 | 2013-12-27 17:29:09 +0530 | [diff] [blame] | 8066 | if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
| 8067 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 8068 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Srinivas, Dasari | 693dfc5 | 2013-12-27 17:29:09 +0530 | [diff] [blame] | 8069 | || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE) |
| 8070 | ) |
| 8071 | { |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 8072 | if (pAdapter) |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 8073 | { |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 8074 | if (eHDD_BATCH_SCAN_STATE_STARTED == pAdapter->batchScanState) |
| 8075 | { |
| 8076 | hdd_deinit_batch_scan(pAdapter); |
| 8077 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 8078 | } |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 8079 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 8080 | #endif |
| 8081 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8082 | if(test_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags)) { |
| 8083 | if( rtnl_held ) |
| 8084 | { |
| 8085 | unregister_netdevice(pWlanDev); |
| 8086 | } |
| 8087 | else |
| 8088 | { |
| 8089 | unregister_netdev(pWlanDev); |
| 8090 | } |
| 8091 | // note that the pAdapter is no longer valid at this point |
| 8092 | // since the memory has been reclaimed |
| 8093 | } |
| 8094 | |
Srinivas, Dasari | 693dfc5 | 2013-12-27 17:29:09 +0530 | [diff] [blame] | 8095 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8096 | } |
| 8097 | |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 8098 | void hdd_set_pwrparams(hdd_context_t *pHddCtx) |
| 8099 | { |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 8100 | VOS_STATUS status; |
| 8101 | hdd_adapter_t *pAdapter = NULL; |
| 8102 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 8103 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 8104 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 8105 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 8106 | /*loop through all adapters.*/ |
| 8107 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 8108 | { |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 8109 | pAdapter = pAdapterNode->pAdapter; |
| 8110 | if ( (WLAN_HDD_INFRA_STATION != pAdapter->device_mode) |
| 8111 | && (WLAN_HDD_P2P_CLIENT != pAdapter->device_mode) ) |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 8112 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 8113 | { // we skip this registration for modes other than STA and P2P client modes. |
| 8114 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 8115 | pAdapterNode = pNext; |
| 8116 | continue; |
| 8117 | } |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 8118 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 8119 | //Apply Dynamic DTIM For P2P |
| 8120 | //Only if ignoreDynamicDtimInP2pMode is not set in ini |
| 8121 | if ((pHddCtx->cfg_ini->enableDynamicDTIM || |
| 8122 | pHddCtx->cfg_ini->enableModulatedDTIM) && |
| 8123 | ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
| 8124 | ((WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) && |
| 8125 | !(pHddCtx->cfg_ini->ignoreDynamicDtimInP2pMode))) && |
| 8126 | (eANI_BOOLEAN_TRUE == pAdapter->higherDtimTransition) && |
| 8127 | (eConnectionState_Associated == |
| 8128 | (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) && |
| 8129 | (pHddCtx->cfg_ini->fIsBmpsEnabled)) |
| 8130 | { |
| 8131 | tSirSetPowerParamsReq powerRequest = { 0 }; |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 8132 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 8133 | powerRequest.uIgnoreDTIM = 1; |
| 8134 | powerRequest.uMaxLIModulatedDTIM = pHddCtx->cfg_ini->fMaxLIModulatedDTIM; |
| 8135 | |
| 8136 | if (pHddCtx->cfg_ini->enableModulatedDTIM) |
| 8137 | { |
| 8138 | powerRequest.uDTIMPeriod = pHddCtx->cfg_ini->enableModulatedDTIM; |
| 8139 | powerRequest.uListenInterval = pHddCtx->hdd_actual_LI_value; |
| 8140 | } |
| 8141 | else |
| 8142 | { |
| 8143 | powerRequest.uListenInterval = pHddCtx->cfg_ini->enableDynamicDTIM; |
| 8144 | } |
| 8145 | |
| 8146 | /* Update ignoreDTIM and ListedInterval in CFG to remain at the DTIM |
| 8147 | * specified during Enter/Exit BMPS when LCD off*/ |
| 8148 | ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IGNORE_DTIM, powerRequest.uIgnoreDTIM, |
| 8149 | NULL, eANI_BOOLEAN_FALSE); |
| 8150 | ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_LISTEN_INTERVAL, powerRequest.uListenInterval, |
| 8151 | NULL, eANI_BOOLEAN_FALSE); |
| 8152 | |
| 8153 | /* switch to the DTIM specified in cfg.ini */ |
| 8154 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Abhishek Singh | 1e390cf | 2015-10-27 13:45:17 +0530 | [diff] [blame] | 8155 | "Switch to DTIM %d Listen interval %d", |
| 8156 | powerRequest.uDTIMPeriod, |
| 8157 | powerRequest.uListenInterval); |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 8158 | sme_SetPowerParams( pHddCtx->hHal, &powerRequest, TRUE); |
| 8159 | break; |
| 8160 | |
| 8161 | } |
| 8162 | |
| 8163 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 8164 | pAdapterNode = pNext; |
| 8165 | } |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 8166 | } |
| 8167 | |
| 8168 | void hdd_reset_pwrparams(hdd_context_t *pHddCtx) |
| 8169 | { |
| 8170 | /*Switch back to DTIM 1*/ |
| 8171 | tSirSetPowerParamsReq powerRequest = { 0 }; |
| 8172 | |
| 8173 | powerRequest.uIgnoreDTIM = pHddCtx->hdd_actual_ignore_DTIM_value; |
| 8174 | powerRequest.uListenInterval = pHddCtx->hdd_actual_LI_value; |
Yue Ma | c24062f | 2013-05-13 17:01:29 -0700 | [diff] [blame] | 8175 | powerRequest.uMaxLIModulatedDTIM = pHddCtx->cfg_ini->fMaxLIModulatedDTIM; |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 8176 | |
| 8177 | /* Update ignoreDTIM and ListedInterval in CFG with default values */ |
| 8178 | ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IGNORE_DTIM, powerRequest.uIgnoreDTIM, |
| 8179 | NULL, eANI_BOOLEAN_FALSE); |
| 8180 | ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_LISTEN_INTERVAL, powerRequest.uListenInterval, |
| 8181 | NULL, eANI_BOOLEAN_FALSE); |
| 8182 | |
| 8183 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8184 | "Switch to DTIM%d",powerRequest.uListenInterval); |
| 8185 | sme_SetPowerParams( pHddCtx->hHal, &powerRequest, TRUE); |
| 8186 | |
| 8187 | } |
| 8188 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8189 | VOS_STATUS hdd_enable_bmps_imps(hdd_context_t *pHddCtx) |
| 8190 | { |
| 8191 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
Sushant Kaushik | 4928e54 | 2014-12-29 15:25:54 +0530 | [diff] [blame] | 8192 | if (WLAN_HDD_IS_UNLOAD_IN_PROGRESS(pHddCtx)) |
| 8193 | { |
| 8194 | hddLog( LOGE, FL("Wlan Unload in progress")); |
| 8195 | return VOS_STATUS_E_PERM; |
| 8196 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8197 | if(pHddCtx->cfg_ini->fIsBmpsEnabled) |
| 8198 | { |
| 8199 | sme_EnablePowerSave(pHddCtx->hHal, ePMC_BEACON_MODE_POWER_SAVE); |
| 8200 | } |
| 8201 | |
| 8202 | if(pHddCtx->cfg_ini->fIsAutoBmpsTimerEnabled) |
| 8203 | { |
| 8204 | sme_StartAutoBmpsTimer(pHddCtx->hHal); |
| 8205 | } |
| 8206 | |
| 8207 | if (pHddCtx->cfg_ini->fIsImpsEnabled) |
| 8208 | { |
| 8209 | sme_EnablePowerSave (pHddCtx->hHal, ePMC_IDLE_MODE_POWER_SAVE); |
| 8210 | } |
| 8211 | |
| 8212 | return status; |
| 8213 | } |
| 8214 | |
| 8215 | VOS_STATUS hdd_disable_bmps_imps(hdd_context_t *pHddCtx, tANI_U8 session_type) |
| 8216 | { |
| 8217 | hdd_adapter_t *pAdapter = NULL; |
| 8218 | eHalStatus halStatus; |
| 8219 | VOS_STATUS status = VOS_STATUS_E_INVAL; |
| 8220 | v_BOOL_t disableBmps = FALSE; |
| 8221 | v_BOOL_t disableImps = FALSE; |
| 8222 | |
| 8223 | switch(session_type) |
| 8224 | { |
| 8225 | case WLAN_HDD_INFRA_STATION: |
| 8226 | case WLAN_HDD_SOFTAP: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8227 | case WLAN_HDD_P2P_CLIENT: |
| 8228 | case WLAN_HDD_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8229 | //Exit BMPS -> Is Sta/P2P Client is already connected |
| 8230 | pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 8231 | if((NULL != pAdapter)&& |
| 8232 | hdd_connIsConnected( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) |
| 8233 | { |
| 8234 | disableBmps = TRUE; |
| 8235 | } |
| 8236 | |
| 8237 | pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT); |
| 8238 | if((NULL != pAdapter)&& |
| 8239 | hdd_connIsConnected( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) |
| 8240 | { |
| 8241 | disableBmps = TRUE; |
| 8242 | } |
| 8243 | |
| 8244 | //Exit both Bmps and Imps incase of Go/SAP Mode |
| 8245 | if((WLAN_HDD_SOFTAP == session_type) || |
| 8246 | (WLAN_HDD_P2P_GO == session_type)) |
| 8247 | { |
| 8248 | disableBmps = TRUE; |
| 8249 | disableImps = TRUE; |
| 8250 | } |
| 8251 | |
| 8252 | if(TRUE == disableImps) |
| 8253 | { |
| 8254 | if (pHddCtx->cfg_ini->fIsImpsEnabled) |
| 8255 | { |
| 8256 | sme_DisablePowerSave (pHddCtx->hHal, ePMC_IDLE_MODE_POWER_SAVE); |
| 8257 | } |
| 8258 | } |
| 8259 | |
| 8260 | if(TRUE == disableBmps) |
| 8261 | { |
| 8262 | if(pHddCtx->cfg_ini->fIsBmpsEnabled) |
| 8263 | { |
| 8264 | halStatus = sme_DisablePowerSave(pHddCtx->hHal, ePMC_BEACON_MODE_POWER_SAVE); |
| 8265 | |
| 8266 | if(eHAL_STATUS_SUCCESS != halStatus) |
| 8267 | { |
| 8268 | status = VOS_STATUS_E_FAILURE; |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 8269 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Fail to Disable Power Save", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8270 | VOS_ASSERT(0); |
| 8271 | return status; |
| 8272 | } |
| 8273 | } |
| 8274 | |
| 8275 | if(pHddCtx->cfg_ini->fIsAutoBmpsTimerEnabled) |
| 8276 | { |
| 8277 | halStatus = sme_StopAutoBmpsTimer(pHddCtx->hHal); |
| 8278 | |
| 8279 | if(eHAL_STATUS_SUCCESS != halStatus) |
| 8280 | { |
| 8281 | status = VOS_STATUS_E_FAILURE; |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 8282 | 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] | 8283 | VOS_ASSERT(0); |
| 8284 | return status; |
| 8285 | } |
| 8286 | } |
| 8287 | } |
| 8288 | |
| 8289 | if((TRUE == disableBmps) || |
| 8290 | (TRUE == disableImps)) |
| 8291 | { |
| 8292 | /* Now, get the chip into Full Power now */ |
| 8293 | INIT_COMPLETION(pHddCtx->full_pwr_comp_var); |
| 8294 | halStatus = sme_RequestFullPower(pHddCtx->hHal, hdd_full_pwr_cbk, |
| 8295 | pHddCtx, eSME_FULL_PWR_NEEDED_BY_HDD); |
| 8296 | |
| 8297 | if(halStatus != eHAL_STATUS_SUCCESS) |
| 8298 | { |
| 8299 | if(halStatus == eHAL_STATUS_PMC_PENDING) |
| 8300 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8301 | long ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8302 | //Block on a completion variable. Can't wait forever though |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8303 | ret = wait_for_completion_interruptible_timeout( |
| 8304 | &pHddCtx->full_pwr_comp_var, |
| 8305 | msecs_to_jiffies(1000)); |
| 8306 | if (ret <= 0) |
| 8307 | { |
| 8308 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8309 | "%s: wait on full_pwr_comp_var failed %ld", |
| 8310 | __func__, ret); |
| 8311 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8312 | } |
| 8313 | else |
| 8314 | { |
| 8315 | status = VOS_STATUS_E_FAILURE; |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 8316 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Request for Full Power failed", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8317 | VOS_ASSERT(0); |
| 8318 | return status; |
| 8319 | } |
| 8320 | } |
| 8321 | |
| 8322 | status = VOS_STATUS_SUCCESS; |
| 8323 | } |
| 8324 | |
| 8325 | break; |
| 8326 | } |
| 8327 | return status; |
| 8328 | } |
Hanumantha Reddy Pothula | 91cdd7f | 2015-09-03 21:25:16 +0530 | [diff] [blame] | 8329 | |
| 8330 | void hdd_monPostMsgCb(tANI_U32 *magic, struct completion *cmpVar) |
| 8331 | { |
| 8332 | if (magic == NULL || cmpVar == NULL) { |
| 8333 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8334 | FL("invalid arguments %p %p"), magic, cmpVar); |
| 8335 | return; |
| 8336 | } |
| 8337 | if (*magic != MON_MODE_MSG_MAGIC) { |
| 8338 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8339 | FL("maic: %x"), *magic); |
| 8340 | return; |
| 8341 | } |
| 8342 | |
| 8343 | complete(cmpVar); |
| 8344 | return; |
| 8345 | } |
| 8346 | |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 8347 | void hdd_init_mon_mode (hdd_adapter_t *pAdapter) |
| 8348 | { |
| 8349 | hdd_mon_ctx_t *pMonCtx = NULL; |
| 8350 | pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter); |
| 8351 | |
| 8352 | pMonCtx->state = 0; |
| 8353 | pMonCtx->ChannelNo = 1; |
| 8354 | pMonCtx->ChannelBW = 20; |
Katya Nigam | d7d3a1f | 2015-06-11 14:04:24 +0530 | [diff] [blame] | 8355 | pMonCtx->crcCheckEnabled = 1; |
| 8356 | pMonCtx->typeSubtypeBitmap = 0xFFFF00000000; |
| 8357 | pMonCtx->is80211to803ConReq = 1; |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 8358 | pMonCtx->numOfMacFilters = 0; |
| 8359 | } |
| 8360 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8361 | |
| 8362 | 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] | 8363 | const char *iface_name, tSirMacAddr macAddr, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8364 | tANI_U8 rtnl_held ) |
| 8365 | { |
| 8366 | hdd_adapter_t *pAdapter = NULL; |
| 8367 | hdd_adapter_list_node_t *pHddAdapterNode = NULL; |
| 8368 | VOS_STATUS status = VOS_STATUS_E_FAILURE; |
| 8369 | VOS_STATUS exitbmpsStatus; |
| 8370 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 8371 | 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] | 8372 | |
Nirav Shah | 436658f | 2014-02-28 17:05:45 +0530 | [diff] [blame] | 8373 | if(macAddr == NULL) |
| 8374 | { |
| 8375 | /* Not received valid macAddr */ |
| 8376 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8377 | "%s:Unable to add virtual intf: Not able to get" |
| 8378 | "valid mac address",__func__); |
| 8379 | return NULL; |
| 8380 | } |
| 8381 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8382 | //Disable BMPS incase of Concurrency |
| 8383 | exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx, session_type); |
| 8384 | |
| 8385 | if(VOS_STATUS_E_FAILURE == exitbmpsStatus) |
| 8386 | { |
| 8387 | //Fail to Exit BMPS |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8388 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Fail to Exit BMPS", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8389 | VOS_ASSERT(0); |
| 8390 | return NULL; |
| 8391 | } |
| 8392 | |
| 8393 | switch(session_type) |
| 8394 | { |
| 8395 | case WLAN_HDD_INFRA_STATION: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8396 | case WLAN_HDD_P2P_CLIENT: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8397 | case WLAN_HDD_P2P_DEVICE: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8398 | { |
| 8399 | pAdapter = hdd_alloc_station_adapter( pHddCtx, macAddr, iface_name ); |
| 8400 | |
| 8401 | if( NULL == pAdapter ) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8402 | { |
| 8403 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 8404 | FL("failed to allocate adapter for session %d"), session_type); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8405 | return NULL; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8406 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8407 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 8408 | #ifdef FEATURE_WLAN_TDLS |
| 8409 | /* A Mutex Lock is introduced while changing/initializing the mode to |
| 8410 | * protect the concurrent access for the Adapters by TDLS module. |
| 8411 | */ |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 8412 | mutex_lock(&pHddCtx->tdls_lock); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 8413 | #endif |
| 8414 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8415 | pAdapter->wdev.iftype = (session_type == WLAN_HDD_P2P_CLIENT) ? |
| 8416 | NL80211_IFTYPE_P2P_CLIENT: |
| 8417 | NL80211_IFTYPE_STATION; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8418 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8419 | pAdapter->device_mode = session_type; |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 8420 | #ifdef FEATURE_WLAN_TDLS |
| 8421 | mutex_unlock(&pHddCtx->tdls_lock); |
| 8422 | #endif |
Sunil Dutt | 66485cb | 2013-12-19 19:05:03 +0530 | [diff] [blame] | 8423 | |
Mahesh A Saptasagar | 67ab922 | 2015-10-21 15:38:41 +0530 | [diff] [blame] | 8424 | hdd_initialize_adapter_common(pAdapter); |
Sunil Dutt | 66485cb | 2013-12-19 19:05:03 +0530 | [diff] [blame] | 8425 | status = hdd_init_station_mode( pAdapter ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8426 | if( VOS_STATUS_SUCCESS != status ) |
| 8427 | goto err_free_netdev; |
| 8428 | |
| 8429 | status = hdd_register_interface( pAdapter, rtnl_held ); |
| 8430 | if( VOS_STATUS_SUCCESS != status ) |
| 8431 | { |
Mahesh A Saptasagar | 02e36e8 | 2015-01-14 20:39:19 +0530 | [diff] [blame] | 8432 | #ifdef FEATURE_WLAN_TDLS |
| 8433 | mutex_lock(&pHddCtx->tdls_lock); |
| 8434 | #endif |
c_hpothu | 002231a | 2015-02-05 14:58:51 +0530 | [diff] [blame] | 8435 | hdd_deinit_adapter(pHddCtx, pAdapter, rtnl_held); |
Mahesh A Saptasagar | 02e36e8 | 2015-01-14 20:39:19 +0530 | [diff] [blame] | 8436 | #ifdef FEATURE_WLAN_TDLS |
| 8437 | mutex_unlock(&pHddCtx->tdls_lock); |
| 8438 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8439 | goto err_free_netdev; |
| 8440 | } |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 8441 | |
Vinay Krishna Eranna | 4d055d4 | 2013-12-17 17:02:01 +0530 | [diff] [blame] | 8442 | // Workqueue which gets scheduled in IPv4 notification callback. |
Anand N Sunkad | dc63c79 | 2015-06-03 14:33:24 +0530 | [diff] [blame] | 8443 | vos_init_work(&pAdapter->ipv4NotifierWorkQueue, hdd_ipv4_notifier_work_queue); |
Vinay Krishna Eranna | 4d055d4 | 2013-12-17 17:02:01 +0530 | [diff] [blame] | 8444 | |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 8445 | #ifdef WLAN_NS_OFFLOAD |
| 8446 | // Workqueue which gets scheduled in IPv6 notification callback. |
Anand N Sunkad | dc63c79 | 2015-06-03 14:33:24 +0530 | [diff] [blame] | 8447 | vos_init_work(&pAdapter->ipv6NotifierWorkQueue, hdd_ipv6_notifier_work_queue); |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 8448 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8449 | //Stop the Interface TX queue. |
Padma, Santhosh Kumar | 9dacb5c | 2014-12-17 19:22:56 +0530 | [diff] [blame] | 8450 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8451 | netif_tx_disable(pAdapter->dev); |
| 8452 | //netif_tx_disable(pWlanDev); |
| 8453 | netif_carrier_off(pAdapter->dev); |
| 8454 | |
Ganesh Kondabattini | babfb49 | 2014-12-17 20:25:29 +0530 | [diff] [blame] | 8455 | if (WLAN_HDD_P2P_CLIENT == session_type || |
| 8456 | WLAN_HDD_P2P_DEVICE == session_type) |
| 8457 | { |
| 8458 | /* Initialize the work queue to defer the |
| 8459 | * back to back RoC request */ |
Anand N Sunkad | dc63c79 | 2015-06-03 14:33:24 +0530 | [diff] [blame] | 8460 | vos_init_delayed_work(&pAdapter->roc_work, |
Ganesh Kondabattini | babfb49 | 2014-12-17 20:25:29 +0530 | [diff] [blame] | 8461 | hdd_p2p_roc_work_queue); |
| 8462 | } |
| 8463 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8464 | break; |
| 8465 | } |
| 8466 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8467 | case WLAN_HDD_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8468 | case WLAN_HDD_SOFTAP: |
| 8469 | { |
| 8470 | pAdapter = hdd_wlan_create_ap_dev( pHddCtx, macAddr, (tANI_U8 *)iface_name ); |
| 8471 | if( NULL == pAdapter ) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8472 | { |
| 8473 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 8474 | FL("failed to allocate adapter for session %d"), session_type); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8475 | return NULL; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8476 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8477 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8478 | pAdapter->wdev.iftype = (session_type == WLAN_HDD_SOFTAP) ? |
| 8479 | NL80211_IFTYPE_AP: |
| 8480 | NL80211_IFTYPE_P2P_GO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8481 | pAdapter->device_mode = session_type; |
| 8482 | |
Mahesh A Saptasagar | 67ab922 | 2015-10-21 15:38:41 +0530 | [diff] [blame] | 8483 | hdd_initialize_adapter_common(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8484 | status = hdd_init_ap_mode(pAdapter); |
| 8485 | if( VOS_STATUS_SUCCESS != status ) |
| 8486 | goto err_free_netdev; |
| 8487 | |
Nirav Shah | 7e3c813 | 2015-06-22 23:51:42 +0530 | [diff] [blame] | 8488 | status = hdd_sta_id_hash_attach(pAdapter); |
| 8489 | if (VOS_STATUS_SUCCESS != status) |
| 8490 | { |
| 8491 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 8492 | FL("failed to attach hash for session %d"), session_type); |
| 8493 | hdd_deinit_adapter(pHddCtx, pAdapter, rtnl_held); |
| 8494 | goto err_free_netdev; |
| 8495 | } |
| 8496 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8497 | status = hdd_register_hostapd( pAdapter, rtnl_held ); |
| 8498 | if( VOS_STATUS_SUCCESS != status ) |
| 8499 | { |
c_hpothu | 002231a | 2015-02-05 14:58:51 +0530 | [diff] [blame] | 8500 | hdd_deinit_adapter(pHddCtx, pAdapter, rtnl_held); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8501 | goto err_free_netdev; |
| 8502 | } |
Padma, Santhosh Kumar | 9dacb5c | 2014-12-17 19:22:56 +0530 | [diff] [blame] | 8503 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8504 | netif_tx_disable(pAdapter->dev); |
| 8505 | netif_carrier_off(pAdapter->dev); |
| 8506 | |
| 8507 | hdd_set_conparam( 1 ); |
Ganesh Kondabattini | babfb49 | 2014-12-17 20:25:29 +0530 | [diff] [blame] | 8508 | |
| 8509 | if (WLAN_HDD_P2P_GO == session_type) |
| 8510 | { |
| 8511 | /* Initialize the work queue to |
| 8512 | * defer the back to back RoC request */ |
| 8513 | INIT_DELAYED_WORK(&pAdapter->roc_work, |
| 8514 | hdd_p2p_roc_work_queue); |
| 8515 | } |
Bhargav Shah | d071591 | 2015-10-01 18:17:37 +0530 | [diff] [blame] | 8516 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8517 | break; |
| 8518 | } |
| 8519 | case WLAN_HDD_MONITOR: |
| 8520 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8521 | pAdapter = hdd_alloc_station_adapter( pHddCtx, macAddr, iface_name ); |
| 8522 | if( NULL == pAdapter ) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8523 | { |
| 8524 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 8525 | FL("failed to allocate adapter for session %d"), session_type); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8526 | return NULL; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8527 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8528 | |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 8529 | // Register wireless extensions |
| 8530 | if( VOS_STATUS_SUCCESS != (status = hdd_register_wext(pAdapter->dev))) |
| 8531 | { |
| 8532 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 8533 | "hdd_register_wext() failed with status code %08d [x%08x]", |
| 8534 | status, status ); |
| 8535 | status = VOS_STATUS_E_FAILURE; |
| 8536 | } |
| 8537 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8538 | pAdapter->wdev.iftype = NL80211_IFTYPE_MONITOR; |
| 8539 | pAdapter->device_mode = session_type; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8540 | #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29) |
| 8541 | pAdapter->dev->netdev_ops = &wlan_mon_drv_ops; |
| 8542 | #else |
| 8543 | pAdapter->dev->open = hdd_mon_open; |
| 8544 | pAdapter->dev->hard_start_xmit = hdd_mon_hard_start_xmit; |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 8545 | pAdapter->dev->stop = hdd_mon_stop; |
| 8546 | pAdapter->dev->do_ioctl = hdd_mon_ioctl; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8547 | #endif |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 8548 | status = hdd_register_interface( pAdapter, rtnl_held ); |
| 8549 | hdd_init_mon_mode( pAdapter ); |
Mahesh A Saptasagar | 67ab922 | 2015-10-21 15:38:41 +0530 | [diff] [blame] | 8550 | hdd_initialize_adapter_common(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8551 | hdd_init_tx_rx( pAdapter ); |
| 8552 | set_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags); |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 8553 | //Stop the Interface TX queue. |
| 8554 | netif_tx_disable(pAdapter->dev); |
| 8555 | netif_carrier_off(pAdapter->dev); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8556 | } |
| 8557 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8558 | case WLAN_HDD_FTM: |
| 8559 | { |
| 8560 | pAdapter = hdd_alloc_station_adapter( pHddCtx, macAddr, iface_name ); |
| 8561 | |
| 8562 | if( NULL == pAdapter ) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8563 | { |
| 8564 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 8565 | FL("failed to allocate adapter for session %d"), session_type); |
| 8566 | return NULL; |
| 8567 | } |
| 8568 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8569 | /* Assign NL80211_IFTYPE_STATION as interface type to resolve Kernel Warning |
| 8570 | * message while loading driver in FTM mode. */ |
| 8571 | pAdapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 8572 | pAdapter->device_mode = session_type; |
| 8573 | status = hdd_register_interface( pAdapter, rtnl_held ); |
Madan Mohan Koyyalamudi | f89ac9f | 2013-09-19 16:58:12 +0530 | [diff] [blame] | 8574 | |
Mahesh A Saptasagar | 67ab922 | 2015-10-21 15:38:41 +0530 | [diff] [blame] | 8575 | hdd_initialize_adapter_common(pAdapter); |
Madan Mohan Koyyalamudi | f89ac9f | 2013-09-19 16:58:12 +0530 | [diff] [blame] | 8576 | hdd_init_tx_rx( pAdapter ); |
| 8577 | |
| 8578 | //Stop the Interface TX queue. |
Padma, Santhosh Kumar | 9dacb5c | 2014-12-17 19:22:56 +0530 | [diff] [blame] | 8579 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues")); |
Madan Mohan Koyyalamudi | f89ac9f | 2013-09-19 16:58:12 +0530 | [diff] [blame] | 8580 | netif_tx_disable(pAdapter->dev); |
| 8581 | netif_carrier_off(pAdapter->dev); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8582 | } |
| 8583 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8584 | default: |
| 8585 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8586 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s Invalid session type %d", |
| 8587 | __func__, session_type); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8588 | VOS_ASSERT(0); |
| 8589 | return NULL; |
| 8590 | } |
| 8591 | } |
| 8592 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8593 | if( VOS_STATUS_SUCCESS == status ) |
| 8594 | { |
Mahesh A Saptasagar | 67ab922 | 2015-10-21 15:38:41 +0530 | [diff] [blame] | 8595 | //Add it to the hdd's session list. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8596 | pHddAdapterNode = vos_mem_malloc( sizeof( hdd_adapter_list_node_t ) ); |
| 8597 | if( NULL == pHddAdapterNode ) |
| 8598 | { |
| 8599 | status = VOS_STATUS_E_NOMEM; |
| 8600 | } |
| 8601 | else |
| 8602 | { |
| 8603 | pHddAdapterNode->pAdapter = pAdapter; |
| 8604 | status = hdd_add_adapter_back ( pHddCtx, |
| 8605 | pHddAdapterNode ); |
| 8606 | } |
| 8607 | } |
| 8608 | |
| 8609 | if( VOS_STATUS_SUCCESS != status ) |
| 8610 | { |
| 8611 | if( NULL != pAdapter ) |
| 8612 | { |
| 8613 | hdd_cleanup_adapter( pHddCtx, pAdapter, rtnl_held ); |
| 8614 | pAdapter = NULL; |
| 8615 | } |
| 8616 | if( NULL != pHddAdapterNode ) |
| 8617 | { |
| 8618 | vos_mem_free( pHddAdapterNode ); |
| 8619 | } |
| 8620 | |
| 8621 | goto resume_bmps; |
| 8622 | } |
| 8623 | |
| 8624 | if(VOS_STATUS_SUCCESS == status) |
| 8625 | { |
| 8626 | wlan_hdd_set_concurrency_mode(pHddCtx, session_type); |
| 8627 | |
Madan Mohan Koyyalamudi | 96dd30d | 2012-10-05 17:24:51 -0700 | [diff] [blame] | 8628 | //Initialize the WoWL service |
| 8629 | if(!hdd_init_wowl(pAdapter)) |
| 8630 | { |
| 8631 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hdd_init_wowl failed",__func__); |
| 8632 | goto err_free_netdev; |
| 8633 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8634 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8635 | return pAdapter; |
| 8636 | |
| 8637 | err_free_netdev: |
| 8638 | free_netdev(pAdapter->dev); |
| 8639 | wlan_hdd_release_intf_addr( pHddCtx, |
| 8640 | pAdapter->macAddressCurrent.bytes ); |
| 8641 | |
| 8642 | resume_bmps: |
| 8643 | //If bmps disabled enable it |
| 8644 | if(VOS_STATUS_SUCCESS == exitbmpsStatus) |
| 8645 | { |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 8646 | if (pHddCtx->hdd_wlan_suspended) |
| 8647 | { |
| 8648 | hdd_set_pwrparams(pHddCtx); |
| 8649 | } |
| 8650 | hdd_enable_bmps_imps(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8651 | } |
| 8652 | return NULL; |
| 8653 | } |
| 8654 | |
| 8655 | VOS_STATUS hdd_close_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter, |
| 8656 | tANI_U8 rtnl_held ) |
| 8657 | { |
| 8658 | hdd_adapter_list_node_t *pAdapterNode, *pCurrent, *pNext; |
| 8659 | VOS_STATUS status; |
| 8660 | |
| 8661 | status = hdd_get_front_adapter ( pHddCtx, &pCurrent ); |
| 8662 | if( VOS_STATUS_SUCCESS != status ) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8663 | { |
| 8664 | hddLog(VOS_TRACE_LEVEL_WARN,"%s: adapter list empty %d", |
| 8665 | __func__, status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8666 | return status; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8667 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8668 | |
| 8669 | while ( pCurrent->pAdapter != pAdapter ) |
| 8670 | { |
| 8671 | status = hdd_get_next_adapter ( pHddCtx, pCurrent, &pNext ); |
| 8672 | if( VOS_STATUS_SUCCESS != status ) |
| 8673 | break; |
| 8674 | |
| 8675 | pCurrent = pNext; |
| 8676 | } |
| 8677 | pAdapterNode = pCurrent; |
| 8678 | if( VOS_STATUS_SUCCESS == status ) |
| 8679 | { |
| 8680 | wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode); |
| 8681 | hdd_cleanup_adapter( pHddCtx, pAdapterNode->pAdapter, rtnl_held ); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 8682 | |
| 8683 | #ifdef FEATURE_WLAN_TDLS |
| 8684 | |
| 8685 | /* A Mutex Lock is introduced while changing/initializing the mode to |
| 8686 | * protect the concurrent access for the Adapters by TDLS module. |
| 8687 | */ |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 8688 | mutex_lock(&pHddCtx->tdls_lock); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 8689 | #endif |
| 8690 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8691 | hdd_remove_adapter( pHddCtx, pAdapterNode ); |
| 8692 | vos_mem_free( pAdapterNode ); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 8693 | pAdapterNode = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8694 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 8695 | #ifdef FEATURE_WLAN_TDLS |
| 8696 | mutex_unlock(&pHddCtx->tdls_lock); |
| 8697 | #endif |
| 8698 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8699 | |
| 8700 | /* 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] | 8701 | if ((!vos_concurrent_open_sessions_running()) && |
| 8702 | ((pHddCtx->no_of_open_sessions[VOS_STA_MODE] >= 1) || |
| 8703 | (pHddCtx->no_of_open_sessions[VOS_P2P_CLIENT_MODE] >= 1))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8704 | { |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 8705 | if (pHddCtx->hdd_wlan_suspended) |
| 8706 | { |
| 8707 | hdd_set_pwrparams(pHddCtx); |
| 8708 | } |
| 8709 | hdd_enable_bmps_imps(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8710 | } |
| 8711 | |
| 8712 | return VOS_STATUS_SUCCESS; |
| 8713 | } |
| 8714 | |
| 8715 | return VOS_STATUS_E_FAILURE; |
| 8716 | } |
| 8717 | |
| 8718 | VOS_STATUS hdd_close_all_adapters( hdd_context_t *pHddCtx ) |
| 8719 | { |
| 8720 | hdd_adapter_list_node_t *pHddAdapterNode; |
| 8721 | VOS_STATUS status; |
| 8722 | |
| 8723 | ENTER(); |
| 8724 | |
| 8725 | do |
| 8726 | { |
| 8727 | status = hdd_remove_front_adapter( pHddCtx, &pHddAdapterNode ); |
| 8728 | if( pHddAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 8729 | { |
| 8730 | hdd_cleanup_adapter( pHddCtx, pHddAdapterNode->pAdapter, FALSE ); |
| 8731 | vos_mem_free( pHddAdapterNode ); |
| 8732 | } |
| 8733 | }while( NULL != pHddAdapterNode && VOS_STATUS_E_EMPTY != status ); |
| 8734 | |
| 8735 | EXIT(); |
| 8736 | |
| 8737 | return VOS_STATUS_SUCCESS; |
| 8738 | } |
| 8739 | |
| 8740 | void wlan_hdd_reset_prob_rspies(hdd_adapter_t* pHostapdAdapter) |
| 8741 | { |
| 8742 | v_U8_t addIE[1] = {0}; |
| 8743 | |
| 8744 | if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 8745 | WNI_CFG_PROBE_RSP_ADDNIE_DATA1,(tANI_U8*)addIE, 0, NULL, |
| 8746 | eANI_BOOLEAN_FALSE) ) |
| 8747 | { |
| 8748 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 8749 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8750 | } |
| 8751 | |
| 8752 | if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 8753 | WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL, |
| 8754 | eANI_BOOLEAN_FALSE) ) |
| 8755 | { |
| 8756 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 8757 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8758 | } |
| 8759 | |
| 8760 | if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 8761 | WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL, |
| 8762 | eANI_BOOLEAN_FALSE) ) |
| 8763 | { |
| 8764 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 8765 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8766 | } |
| 8767 | } |
| 8768 | |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 8769 | VOS_STATUS hdd_stop_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter, |
| 8770 | const v_BOOL_t bCloseSession ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8771 | { |
| 8772 | eHalStatus halStatus = eHAL_STATUS_SUCCESS; |
| 8773 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Kaushik, Sushant | 4975a57 | 2014-10-21 16:07:48 +0530 | [diff] [blame] | 8774 | hdd_scaninfo_t *pScanInfo = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8775 | union iwreq_data wrqu; |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 8776 | v_U8_t retry = 0; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8777 | long ret; |
Nirav Shah | 7e3c813 | 2015-06-22 23:51:42 +0530 | [diff] [blame] | 8778 | VOS_STATUS status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8779 | |
Anand N Sunkad | 26d71b9 | 2014-12-24 18:08:22 +0530 | [diff] [blame] | 8780 | if (pHddCtx->isLogpInProgress) { |
| 8781 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8782 | "%s:LOGP in Progress. Ignore!!!",__func__); |
| 8783 | return VOS_STATUS_E_FAILURE; |
| 8784 | } |
| 8785 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8786 | ENTER(); |
Vinay Krishna Eranna | f97ef5c | 2014-12-26 17:47:19 +0530 | [diff] [blame] | 8787 | |
Kaushik, Sushant | 4975a57 | 2014-10-21 16:07:48 +0530 | [diff] [blame] | 8788 | pScanInfo = &pHddCtx->scan_info; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8789 | switch(pAdapter->device_mode) |
| 8790 | { |
Nirav Shah | 0cf4d89 | 2015-11-05 16:27:27 +0530 | [diff] [blame] | 8791 | case WLAN_HDD_IBSS: |
| 8792 | if ( VOS_TRUE == bCloseSession ) |
| 8793 | { |
| 8794 | status = hdd_sta_id_hash_detach(pAdapter); |
| 8795 | if (status != VOS_STATUS_SUCCESS) |
| 8796 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8797 | FL("sta id hash detach failed")); |
| 8798 | } |
| 8799 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8800 | case WLAN_HDD_INFRA_STATION: |
| 8801 | case WLAN_HDD_P2P_CLIENT: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8802 | case WLAN_HDD_P2P_DEVICE: |
Vinay Krishna Eranna | b09d3e7 | 2014-03-26 21:23:55 +0530 | [diff] [blame] | 8803 | { |
| 8804 | hdd_station_ctx_t *pstation = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Mahesh A Saptasagar | e4d05d4 | 2015-07-02 16:17:20 +0530 | [diff] [blame] | 8805 | #ifdef FEATURE_WLAN_TDLS |
| 8806 | mutex_lock(&pHddCtx->tdls_lock); |
| 8807 | wlan_hdd_tdls_exit(pAdapter, TRUE); |
| 8808 | mutex_unlock(&pHddCtx->tdls_lock); |
| 8809 | #endif |
Vinay Krishna Eranna | b09d3e7 | 2014-03-26 21:23:55 +0530 | [diff] [blame] | 8810 | if( hdd_connIsConnected(pstation) || |
| 8811 | (pstation->conn_info.connState == eConnectionState_Connecting) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8812 | { |
| 8813 | if (pWextState->roamProfile.BSSType == eCSR_BSS_TYPE_START_IBSS) |
| 8814 | halStatus = sme_RoamDisconnect(pHddCtx->hHal, |
| 8815 | pAdapter->sessionId, |
| 8816 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
| 8817 | else |
| 8818 | halStatus = sme_RoamDisconnect(pHddCtx->hHal, |
| 8819 | pAdapter->sessionId, |
| 8820 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
Abhishek Singh | 7b52ed5 | 2016-02-11 17:45:54 +0530 | [diff] [blame] | 8821 | /* Success implies disconnect command got queued up successfully |
| 8822 | * Or cmd not queued as scan for SSID is in progress |
| 8823 | */ |
| 8824 | if((eHAL_STATUS_SUCCESS == halStatus) || |
| 8825 | (eHAL_STATUS_CMD_NOT_QUEUED == halStatus)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8826 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8827 | ret = wait_for_completion_interruptible_timeout( |
| 8828 | &pAdapter->disconnect_comp_var, |
| 8829 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
Abhishek Singh | 7b52ed5 | 2016-02-11 17:45:54 +0530 | [diff] [blame] | 8830 | if (ret <= 0 && |
| 8831 | (eHAL_STATUS_CMD_NOT_QUEUED != halStatus)) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8832 | { |
| 8833 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8834 | "%s: wait on disconnect_comp_var failed %ld", |
| 8835 | __func__, ret); |
| 8836 | } |
| 8837 | } |
| 8838 | else |
| 8839 | { |
| 8840 | hddLog(LOGE, "%s: failed to post disconnect event to SME", |
| 8841 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8842 | } |
| 8843 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 8844 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 8845 | memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN); |
| 8846 | wireless_send_event(pAdapter->dev, SIOCGIWAP, &wrqu, NULL); |
| 8847 | } |
Vinay Krishna Eranna | b09d3e7 | 2014-03-26 21:23:55 +0530 | [diff] [blame] | 8848 | else if(pstation->conn_info.connState == |
| 8849 | eConnectionState_Disconnecting) |
| 8850 | { |
| 8851 | ret = wait_for_completion_interruptible_timeout( |
| 8852 | &pAdapter->disconnect_comp_var, |
| 8853 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 8854 | if (ret <= 0) |
| 8855 | { |
| 8856 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8857 | FL("wait on disconnect_comp_var failed %ld"), ret); |
| 8858 | } |
| 8859 | } |
Kaushik, Sushant | 4975a57 | 2014-10-21 16:07:48 +0530 | [diff] [blame] | 8860 | else if(pScanInfo != NULL && pHddCtx->scan_info.mScanPending) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8861 | { |
Mahesh A Saptasagar | 0b61dcc | 2016-02-15 14:23:38 +0530 | [diff] [blame] | 8862 | wlan_hdd_scan_abort(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8863 | } |
Abhishek Singh | 3ac179b | 2015-09-21 10:01:34 +0530 | [diff] [blame] | 8864 | if ((pAdapter->device_mode != WLAN_HDD_INFRA_STATION) && |
| 8865 | (pAdapter->device_mode != WLAN_HDD_IBSS)) |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 8866 | { |
| 8867 | while (pAdapter->is_roc_inprogress) |
| 8868 | { |
| 8869 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8870 | "%s: ROC in progress for session %d!!!", |
| 8871 | __func__, pAdapter->sessionId); |
| 8872 | // waiting for ROC to expire |
| 8873 | msleep(500); |
| 8874 | /* In GO present case , if retry exceeds 3, |
| 8875 | it means something went wrong. */ |
| 8876 | if ( retry++ > MAX_WAIT_FOR_ROC_COMPLETION ) |
| 8877 | { |
| 8878 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8879 | "%s: ROC completion is not received.!!!", __func__); |
Deepthi Gowri | 7049825 | 2015-01-20 15:56:45 +0530 | [diff] [blame] | 8880 | if (eHAL_STATUS_SUCCESS != |
| 8881 | sme_CancelRemainOnChannel( WLAN_HDD_GET_HAL_CTX( pAdapter), |
| 8882 | pAdapter->sessionId )) |
| 8883 | { |
| 8884 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8885 | FL("Failed to Cancel Remain on Channel")); |
| 8886 | } |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 8887 | wait_for_completion_interruptible_timeout( |
| 8888 | &pAdapter->cancel_rem_on_chan_var, |
| 8889 | msecs_to_jiffies(WAIT_CANCEL_REM_CHAN)); |
| 8890 | break; |
| 8891 | } |
| 8892 | } |
Anand N Sunkad | dc63c79 | 2015-06-03 14:33:24 +0530 | [diff] [blame] | 8893 | vos_flush_delayed_work(&pAdapter->roc_work); |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 8894 | } |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 8895 | #ifdef WLAN_NS_OFFLOAD |
Anand N Sunkad | dc63c79 | 2015-06-03 14:33:24 +0530 | [diff] [blame] | 8896 | vos_flush_work(&pAdapter->ipv6NotifierWorkQueue); |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 8897 | #endif |
Vinay Krishna Eranna | f97ef5c | 2014-12-26 17:47:19 +0530 | [diff] [blame] | 8898 | |
Anand N Sunkad | dc63c79 | 2015-06-03 14:33:24 +0530 | [diff] [blame] | 8899 | vos_flush_work(&pAdapter->ipv4NotifierWorkQueue); |
Vinay Krishna Eranna | f97ef5c | 2014-12-26 17:47:19 +0530 | [diff] [blame] | 8900 | |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 8901 | /* It is possible that the caller of this function does not |
| 8902 | * wish to close the session |
| 8903 | */ |
| 8904 | if (VOS_TRUE == bCloseSession && |
| 8905 | test_bit(SME_SESSION_OPENED, &pAdapter->event_flags)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8906 | { |
| 8907 | INIT_COMPLETION(pAdapter->session_close_comp_var); |
| 8908 | if (eHAL_STATUS_SUCCESS == |
Agrawal Ashish | 5a3522c | 2016-03-02 15:08:28 +0530 | [diff] [blame] | 8909 | sme_CloseSession(pHddCtx->hHal, pAdapter->sessionId, FALSE, |
| 8910 | VOS_FALSE, hdd_smeCloseSessionCallback, pAdapter)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8911 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8912 | unsigned long ret; |
| 8913 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8914 | //Block on a completion variable. Can't wait forever though. |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8915 | ret = wait_for_completion_timeout( |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 8916 | &pAdapter->session_close_comp_var, |
| 8917 | msecs_to_jiffies(WLAN_WAIT_TIME_SESSIONOPENCLOSE)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8918 | if ( 0 >= ret) |
| 8919 | { |
| 8920 | hddLog(LOGE, "%s: failure waiting for session_close_comp_var %ld", |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 8921 | __func__, ret); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8922 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8923 | } |
| 8924 | } |
Vinay Krishna Eranna | b09d3e7 | 2014-03-26 21:23:55 +0530 | [diff] [blame] | 8925 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8926 | break; |
| 8927 | |
| 8928 | case WLAN_HDD_SOFTAP: |
| 8929 | case WLAN_HDD_P2P_GO: |
Nirav Shah | 0cf4d89 | 2015-11-05 16:27:27 +0530 | [diff] [blame] | 8930 | if ( VOS_TRUE == bCloseSession ) |
| 8931 | { |
| 8932 | status = hdd_sta_id_hash_detach(pAdapter); |
| 8933 | if (status != VOS_STATUS_SUCCESS) |
| 8934 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8935 | FL("sta id hash detach failed")); |
| 8936 | } |
| 8937 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8938 | //Any softap specific cleanup here... |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 8939 | if (pAdapter->device_mode == WLAN_HDD_P2P_GO) { |
| 8940 | while (pAdapter->is_roc_inprogress) { |
| 8941 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8942 | "%s: ROC in progress for session %d!!!", |
| 8943 | __func__, pAdapter->sessionId); |
| 8944 | msleep(500); |
| 8945 | if ( retry++ > MAX_WAIT_FOR_ROC_COMPLETION ) { |
| 8946 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8947 | "%s: ROC completion is not received.!!!", __func__); |
| 8948 | WLANSAP_CancelRemainOnChannel( |
| 8949 | (WLAN_HDD_GET_CTX(pAdapter))->pvosContext); |
| 8950 | wait_for_completion_interruptible_timeout( |
| 8951 | &pAdapter->cancel_rem_on_chan_var, |
| 8952 | msecs_to_jiffies(WAIT_CANCEL_REM_CHAN)); |
| 8953 | break; |
| 8954 | } |
| 8955 | } |
Ganesh Kondabattini | babfb49 | 2014-12-17 20:25:29 +0530 | [diff] [blame] | 8956 | |
Anand N Sunkad | dc63c79 | 2015-06-03 14:33:24 +0530 | [diff] [blame] | 8957 | vos_flush_delayed_work(&pAdapter->roc_work); |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 8958 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8959 | mutex_lock(&pHddCtx->sap_lock); |
| 8960 | if (test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags)) |
| 8961 | { |
| 8962 | VOS_STATUS status; |
| 8963 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 8964 | |
| 8965 | //Stop Bss. |
| 8966 | status = WLANSAP_StopBss(pHddCtx->pvosContext); |
| 8967 | if (VOS_IS_STATUS_SUCCESS(status)) |
| 8968 | { |
| 8969 | hdd_hostapd_state_t *pHostapdState = |
| 8970 | WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 8971 | |
| 8972 | status = vos_wait_single_event(&pHostapdState->vosEvent, 10000); |
| 8973 | |
| 8974 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 8975 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8976 | hddLog(LOGE, "%s: failure waiting for WLANSAP_StopBss %d", |
| 8977 | __func__, status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8978 | } |
| 8979 | } |
| 8980 | else |
| 8981 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 8982 | hddLog(LOGE, "%s: failure in WLANSAP_StopBss", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8983 | } |
| 8984 | clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags); |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 8985 | wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8986 | |
| 8987 | if (eHAL_STATUS_FAILURE == |
| 8988 | ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, |
| 8989 | 0, NULL, eANI_BOOLEAN_FALSE)) |
| 8990 | { |
| 8991 | hddLog(LOGE, |
| 8992 | "%s: Failed to set WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 8993 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8994 | } |
| 8995 | |
| 8996 | if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal, |
| 8997 | WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL, |
| 8998 | eANI_BOOLEAN_FALSE) ) |
| 8999 | { |
| 9000 | hddLog(LOGE, |
| 9001 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM"); |
| 9002 | } |
| 9003 | |
| 9004 | // Reset WNI_CFG_PROBE_RSP Flags |
| 9005 | wlan_hdd_reset_prob_rspies(pAdapter); |
| 9006 | kfree(pAdapter->sessionCtx.ap.beacon); |
| 9007 | pAdapter->sessionCtx.ap.beacon = NULL; |
| 9008 | } |
| 9009 | mutex_unlock(&pHddCtx->sap_lock); |
| 9010 | break; |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 9011 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9012 | case WLAN_HDD_MONITOR: |
| 9013 | break; |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 9014 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9015 | default: |
| 9016 | break; |
| 9017 | } |
| 9018 | |
| 9019 | EXIT(); |
| 9020 | return VOS_STATUS_SUCCESS; |
| 9021 | } |
| 9022 | |
| 9023 | VOS_STATUS hdd_stop_all_adapters( hdd_context_t *pHddCtx ) |
| 9024 | { |
| 9025 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 9026 | VOS_STATUS status; |
| 9027 | hdd_adapter_t *pAdapter; |
| 9028 | |
| 9029 | ENTER(); |
| 9030 | |
| 9031 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 9032 | |
| 9033 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 9034 | { |
| 9035 | pAdapter = pAdapterNode->pAdapter; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9036 | |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 9037 | hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9038 | |
| 9039 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 9040 | pAdapterNode = pNext; |
| 9041 | } |
| 9042 | |
| 9043 | EXIT(); |
| 9044 | |
| 9045 | return VOS_STATUS_SUCCESS; |
| 9046 | } |
| 9047 | |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 9048 | |
| 9049 | #ifdef FEATURE_WLAN_BATCH_SCAN |
| 9050 | /**--------------------------------------------------------------------------- |
| 9051 | |
| 9052 | \brief hdd_deinit_batch_scan () - This function cleans up batch scan data |
| 9053 | structures |
| 9054 | |
| 9055 | \param - pAdapter Pointer to HDD adapter |
| 9056 | |
| 9057 | \return - None |
| 9058 | |
| 9059 | --------------------------------------------------------------------------*/ |
| 9060 | void hdd_deinit_batch_scan(hdd_adapter_t *pAdapter) |
| 9061 | { |
| 9062 | tHddBatchScanRsp *pNode; |
| 9063 | tHddBatchScanRsp *pPrev; |
| 9064 | |
Siddharth Bhal | b3e9b79 | 2014-02-24 15:14:16 +0530 | [diff] [blame] | 9065 | if (NULL == pAdapter) |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 9066 | { |
Siddharth Bhal | b3e9b79 | 2014-02-24 15:14:16 +0530 | [diff] [blame] | 9067 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 9068 | "%s: Adapter context is Null", __func__); |
| 9069 | return; |
| 9070 | } |
| 9071 | |
| 9072 | pNode = pAdapter->pBatchScanRsp; |
| 9073 | while (pNode) |
| 9074 | { |
| 9075 | pPrev = pNode; |
| 9076 | pNode = pNode->pNext; |
| 9077 | vos_mem_free((v_VOID_t * )pPrev); |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 9078 | } |
| 9079 | |
| 9080 | pAdapter->pBatchScanRsp = NULL; |
| 9081 | pAdapter->numScanList = 0; |
| 9082 | pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STOPPED; |
| 9083 | pAdapter->prev_batch_id = 0; |
| 9084 | |
| 9085 | return; |
| 9086 | } |
| 9087 | #endif |
| 9088 | |
| 9089 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9090 | VOS_STATUS hdd_reset_all_adapters( hdd_context_t *pHddCtx ) |
| 9091 | { |
| 9092 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 9093 | VOS_STATUS status; |
| 9094 | hdd_adapter_t *pAdapter; |
| 9095 | |
| 9096 | ENTER(); |
| 9097 | |
| 9098 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 9099 | |
| 9100 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 9101 | { |
| 9102 | pAdapter = pAdapterNode->pAdapter; |
Padma, Santhosh Kumar | 9dacb5c | 2014-12-17 19:22:56 +0530 | [diff] [blame] | 9103 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9104 | netif_tx_disable(pAdapter->dev); |
| 9105 | netif_carrier_off(pAdapter->dev); |
| 9106 | |
Srinivas Girigowda | 66c05eb | 2013-07-14 13:06:01 -0700 | [diff] [blame] | 9107 | pAdapter->sessionCtx.station.hdd_ReassocScenario = VOS_FALSE; |
| 9108 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9109 | hdd_deinit_tx_rx(pAdapter); |
Agarwal Ashish | 6267caa | 2014-08-06 19:16:21 +0530 | [diff] [blame] | 9110 | |
Katya Nigam | 1fd2440 | 2015-02-16 14:52:19 +0530 | [diff] [blame] | 9111 | if(pAdapter->device_mode == WLAN_HDD_IBSS ) |
| 9112 | hdd_ibss_deinit_tx_rx(pAdapter); |
| 9113 | |
Nirav Shah | 7e3c813 | 2015-06-22 23:51:42 +0530 | [diff] [blame] | 9114 | status = hdd_sta_id_hash_detach(pAdapter); |
| 9115 | if (status != VOS_STATUS_SUCCESS) |
| 9116 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 9117 | FL("sta id hash detach failed for session id %d"), |
| 9118 | pAdapter->sessionId); |
| 9119 | |
Agarwal Ashish | 6267caa | 2014-08-06 19:16:21 +0530 | [diff] [blame] | 9120 | wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode); |
| 9121 | |
Madan Mohan Koyyalamudi | 8c6dec8 | 2013-09-26 15:56:13 +0530 | [diff] [blame] | 9122 | if (test_bit(WMM_INIT_DONE, &pAdapter->event_flags)) |
| 9123 | { |
| 9124 | hdd_wmm_adapter_close( pAdapter ); |
| 9125 | clear_bit(WMM_INIT_DONE, &pAdapter->event_flags); |
| 9126 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9127 | |
Siddharth Bhal | 2db319d | 2014-12-03 12:37:18 +0530 | [diff] [blame] | 9128 | if (test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags)) |
| 9129 | { |
| 9130 | clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags); |
| 9131 | } |
| 9132 | |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 9133 | #ifdef FEATURE_WLAN_BATCH_SCAN |
| 9134 | if (eHDD_BATCH_SCAN_STATE_STARTED == pAdapter->batchScanState) |
| 9135 | { |
| 9136 | hdd_deinit_batch_scan(pAdapter); |
| 9137 | } |
| 9138 | #endif |
| 9139 | |
Mahesh A Saptasagar | f5b8eff | 2015-01-31 01:07:07 +0530 | [diff] [blame] | 9140 | #ifdef FEATURE_WLAN_TDLS |
| 9141 | mutex_lock(&pHddCtx->tdls_lock); |
Pradeep Reddy POTTETI | 2d4d5c4 | 2015-03-03 14:34:19 +0530 | [diff] [blame] | 9142 | wlan_hdd_tdls_exit(pAdapter, TRUE); |
Mahesh A Saptasagar | f5b8eff | 2015-01-31 01:07:07 +0530 | [diff] [blame] | 9143 | mutex_unlock(&pHddCtx->tdls_lock); |
| 9144 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9145 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 9146 | pAdapterNode = pNext; |
| 9147 | } |
| 9148 | |
| 9149 | EXIT(); |
| 9150 | |
| 9151 | return VOS_STATUS_SUCCESS; |
| 9152 | } |
| 9153 | |
| 9154 | VOS_STATUS hdd_start_all_adapters( hdd_context_t *pHddCtx ) |
| 9155 | { |
| 9156 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 9157 | VOS_STATUS status; |
| 9158 | hdd_adapter_t *pAdapter; |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 9159 | eConnectionState connState; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9160 | |
| 9161 | ENTER(); |
| 9162 | |
| 9163 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 9164 | |
| 9165 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 9166 | { |
| 9167 | pAdapter = pAdapterNode->pAdapter; |
| 9168 | |
Kumar Anand | 82c009f | 2014-05-29 00:29:42 -0700 | [diff] [blame] | 9169 | hdd_wmm_init( pAdapter ); |
| 9170 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9171 | switch(pAdapter->device_mode) |
| 9172 | { |
| 9173 | case WLAN_HDD_INFRA_STATION: |
| 9174 | case WLAN_HDD_P2P_CLIENT: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9175 | case WLAN_HDD_P2P_DEVICE: |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 9176 | |
| 9177 | connState = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState; |
| 9178 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9179 | hdd_init_station_mode(pAdapter); |
| 9180 | /* Open the gates for HDD to receive Wext commands */ |
| 9181 | pAdapter->isLinkUpSvcNeeded = FALSE; |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 9182 | pHddCtx->scan_info.mScanPending = FALSE; |
| 9183 | pHddCtx->scan_info.waitScanResult = FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9184 | |
| 9185 | //Trigger the initial scan |
Mukul Sharma | e74e42c | 2015-08-06 23:55:49 +0530 | [diff] [blame] | 9186 | if (!pHddCtx->isLogpInProgress) |
| 9187 | hdd_wlan_initial_scan(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9188 | |
| 9189 | //Indicate disconnect event to supplicant if associated previously |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 9190 | if (eConnectionState_Associated == connState || |
| 9191 | eConnectionState_IbssConnected == connState ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9192 | { |
| 9193 | union iwreq_data wrqu; |
| 9194 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 9195 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 9196 | memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN); |
| 9197 | wireless_send_event(pAdapter->dev, SIOCGIWAP, &wrqu, NULL); |
Srinivas Girigowda | 66c05eb | 2013-07-14 13:06:01 -0700 | [diff] [blame] | 9198 | pAdapter->sessionCtx.station.hdd_ReassocScenario = VOS_FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9199 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9200 | /* indicate disconnected event to nl80211 */ |
Mahesh A Saptasagar | 9ff4bcc | 2016-06-01 17:17:50 +0530 | [diff] [blame] | 9201 | wlan_hdd_cfg80211_indicate_disconnect(pAdapter->dev, false, |
Mahesh A Saptasagar | b5a1514 | 2016-05-25 11:27:43 +0530 | [diff] [blame] | 9202 | WLAN_REASON_UNSPECIFIED); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9203 | } |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 9204 | else if (eConnectionState_Connecting == connState) |
| 9205 | { |
| 9206 | /* |
| 9207 | * Indicate connect failure to supplicant if we were in the |
| 9208 | * process of connecting |
| 9209 | */ |
| 9210 | cfg80211_connect_result(pAdapter->dev, NULL, |
| 9211 | NULL, 0, NULL, 0, |
| 9212 | WLAN_STATUS_ASSOC_DENIED_UNSPEC, |
| 9213 | GFP_KERNEL); |
| 9214 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9215 | break; |
| 9216 | |
| 9217 | case WLAN_HDD_SOFTAP: |
| 9218 | /* softAP can handle SSR */ |
| 9219 | break; |
| 9220 | |
| 9221 | case WLAN_HDD_P2P_GO: |
Sameer Thalappil | edf0d79 | 2013-08-09 14:31:03 -0700 | [diff] [blame] | 9222 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s [SSR] send stop ap to supplicant", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9223 | __func__); |
Sameer Thalappil | edf0d79 | 2013-08-09 14:31:03 -0700 | [diff] [blame] | 9224 | cfg80211_ap_stopped(pAdapter->dev, GFP_KERNEL); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9225 | break; |
| 9226 | |
| 9227 | case WLAN_HDD_MONITOR: |
| 9228 | /* monitor interface start */ |
| 9229 | break; |
| 9230 | default: |
| 9231 | break; |
| 9232 | } |
| 9233 | |
| 9234 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 9235 | pAdapterNode = pNext; |
| 9236 | } |
| 9237 | |
| 9238 | EXIT(); |
| 9239 | |
| 9240 | return VOS_STATUS_SUCCESS; |
| 9241 | } |
| 9242 | |
| 9243 | VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx ) |
| 9244 | { |
| 9245 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 9246 | hdd_adapter_t *pAdapter; |
| 9247 | VOS_STATUS status; |
| 9248 | v_U32_t roamId; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 9249 | long ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9250 | |
| 9251 | ENTER(); |
| 9252 | |
| 9253 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 9254 | |
| 9255 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 9256 | { |
| 9257 | pAdapter = pAdapterNode->pAdapter; |
| 9258 | |
| 9259 | if( (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
| 9260 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ) |
| 9261 | { |
| 9262 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 9263 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 9264 | |
Abhishek Singh | f4669da | 2014-05-26 15:07:49 +0530 | [diff] [blame] | 9265 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 9266 | "%s: Set HDD connState to eConnectionState_NotConnected", |
| 9267 | __func__); |
Ganesh Kondabattini | 0433841 | 2015-09-14 15:39:09 +0530 | [diff] [blame] | 9268 | spin_lock_bh(&pAdapter->lock_for_active_session); |
| 9269 | if (eConnectionState_Associated == pHddStaCtx->conn_info.connState) |
| 9270 | { |
| 9271 | wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode); |
| 9272 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9273 | pHddStaCtx->conn_info.connState = eConnectionState_NotConnected; |
Ganesh Kondabattini | 0433841 | 2015-09-14 15:39:09 +0530 | [diff] [blame] | 9274 | spin_unlock_bh(&pAdapter->lock_for_active_session); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9275 | init_completion(&pAdapter->disconnect_comp_var); |
| 9276 | sme_RoamDisconnect(pHddCtx->hHal, pAdapter->sessionId, |
| 9277 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
| 9278 | |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 9279 | ret = wait_for_completion_interruptible_timeout( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9280 | &pAdapter->disconnect_comp_var, |
| 9281 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 9282 | if (0 >= ret) |
| 9283 | hddLog(LOGE, "%s: failure waiting for disconnect_comp_var %ld", |
| 9284 | __func__, ret); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9285 | |
| 9286 | pWextState->roamProfile.csrPersona = pAdapter->device_mode; |
| 9287 | pHddCtx->isAmpAllowed = VOS_FALSE; |
| 9288 | sme_RoamConnect(pHddCtx->hHal, |
| 9289 | pAdapter->sessionId, &(pWextState->roamProfile), |
| 9290 | &roamId); |
| 9291 | } |
| 9292 | |
| 9293 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 9294 | pAdapterNode = pNext; |
| 9295 | } |
| 9296 | |
| 9297 | EXIT(); |
| 9298 | |
| 9299 | return VOS_STATUS_SUCCESS; |
| 9300 | } |
| 9301 | |
Sudhir Sattayappa Kohalli | 90e4c75 | 2013-03-21 14:25:04 -0700 | [diff] [blame] | 9302 | void hdd_dump_concurrency_info(hdd_context_t *pHddCtx) |
| 9303 | { |
| 9304 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 9305 | VOS_STATUS status; |
| 9306 | hdd_adapter_t *pAdapter; |
| 9307 | hdd_station_ctx_t *pHddStaCtx; |
| 9308 | hdd_ap_ctx_t *pHddApCtx; |
| 9309 | hdd_hostapd_state_t * pHostapdState; |
| 9310 | tCsrBssid staBssid = { 0 }, p2pBssid = { 0 }, apBssid = { 0 }; |
| 9311 | v_U8_t staChannel = 0, p2pChannel = 0, apChannel = 0; |
| 9312 | const char *p2pMode = "DEV"; |
| 9313 | const char *ccMode = "Standalone"; |
Sudhir Sattayappa Kohalli | 90e4c75 | 2013-03-21 14:25:04 -0700 | [diff] [blame] | 9314 | |
| 9315 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 9316 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 9317 | { |
| 9318 | pAdapter = pAdapterNode->pAdapter; |
| 9319 | switch (pAdapter->device_mode) { |
| 9320 | case WLAN_HDD_INFRA_STATION: |
| 9321 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 9322 | if (eConnectionState_Associated == pHddStaCtx->conn_info.connState) { |
| 9323 | staChannel = pHddStaCtx->conn_info.operationChannel; |
| 9324 | memcpy(staBssid, pHddStaCtx->conn_info.bssId, sizeof(staBssid)); |
| 9325 | } |
| 9326 | break; |
| 9327 | case WLAN_HDD_P2P_CLIENT: |
| 9328 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 9329 | if (eConnectionState_Associated == pHddStaCtx->conn_info.connState) { |
| 9330 | p2pChannel = pHddStaCtx->conn_info.operationChannel; |
| 9331 | memcpy(p2pBssid, pHddStaCtx->conn_info.bssId, sizeof(p2pBssid)); |
| 9332 | p2pMode = "CLI"; |
| 9333 | } |
| 9334 | break; |
| 9335 | case WLAN_HDD_P2P_GO: |
| 9336 | pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
| 9337 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 9338 | if (pHostapdState->bssState == BSS_START && pHostapdState->vosStatus==VOS_STATUS_SUCCESS) { |
| 9339 | p2pChannel = pHddApCtx->operatingChannel; |
| 9340 | memcpy(p2pBssid, pAdapter->macAddressCurrent.bytes, sizeof(p2pBssid)); |
| 9341 | } |
| 9342 | p2pMode = "GO"; |
| 9343 | break; |
| 9344 | case WLAN_HDD_SOFTAP: |
| 9345 | pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
| 9346 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 9347 | if (pHostapdState->bssState == BSS_START && pHostapdState->vosStatus==VOS_STATUS_SUCCESS) { |
| 9348 | apChannel = pHddApCtx->operatingChannel; |
| 9349 | memcpy(apBssid, pAdapter->macAddressCurrent.bytes, sizeof(apBssid)); |
| 9350 | } |
| 9351 | break; |
| 9352 | default: |
| 9353 | break; |
| 9354 | } |
| 9355 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 9356 | pAdapterNode = pNext; |
| 9357 | } |
| 9358 | if (staChannel > 0 && (apChannel > 0 || p2pChannel > 0)) { |
| 9359 | ccMode = (p2pChannel==staChannel||apChannel==staChannel) ? "SCC" : "MCC"; |
| 9360 | } |
Sushant Kaushik | dc3184b | 2015-10-09 12:00:21 +0530 | [diff] [blame] | 9361 | hddLog(VOS_TRACE_LEVEL_ERROR, "wlan(%d) " MAC_ADDRESS_STR " %s", |
Sudhir Sattayappa Kohalli | 90e4c75 | 2013-03-21 14:25:04 -0700 | [diff] [blame] | 9362 | staChannel, MAC_ADDR_ARRAY(staBssid), ccMode); |
| 9363 | if (p2pChannel > 0) { |
Sushant Kaushik | dc3184b | 2015-10-09 12:00:21 +0530 | [diff] [blame] | 9364 | hddLog(VOS_TRACE_LEVEL_ERROR, "p2p-%s(%d) " MAC_ADDRESS_STR, |
Sudhir Sattayappa Kohalli | 90e4c75 | 2013-03-21 14:25:04 -0700 | [diff] [blame] | 9365 | p2pMode, p2pChannel, MAC_ADDR_ARRAY(p2pBssid)); |
| 9366 | } |
| 9367 | if (apChannel > 0) { |
Sushant Kaushik | dc3184b | 2015-10-09 12:00:21 +0530 | [diff] [blame] | 9368 | hddLog(VOS_TRACE_LEVEL_ERROR, "AP(%d) " MAC_ADDRESS_STR, |
Sudhir Sattayappa Kohalli | 90e4c75 | 2013-03-21 14:25:04 -0700 | [diff] [blame] | 9369 | apChannel, MAC_ADDR_ARRAY(apBssid)); |
| 9370 | } |
| 9371 | |
| 9372 | if (p2pChannel > 0 && apChannel > 0) { |
| 9373 | hddLog(VOS_TRACE_LEVEL_ERROR, "Error concurrent SAP %d and P2P %d which is not support", apChannel, p2pChannel); |
| 9374 | } |
| 9375 | } |
| 9376 | |
Madan Mohan Koyyalamudi | b5da533 | 2012-10-15 17:23:21 -0700 | [diff] [blame] | 9377 | bool hdd_is_ssr_required( void) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9378 | { |
Madan Mohan Koyyalamudi | b5da533 | 2012-10-15 17:23:21 -0700 | [diff] [blame] | 9379 | return (isSsrRequired == HDD_SSR_REQUIRED); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9380 | } |
| 9381 | |
Madan Mohan Koyyalamudi | b5da533 | 2012-10-15 17:23:21 -0700 | [diff] [blame] | 9382 | /* Once SSR is disabled then it cannot be set. */ |
| 9383 | void hdd_set_ssr_required( e_hdd_ssr_required value) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9384 | { |
Madan Mohan Koyyalamudi | b5da533 | 2012-10-15 17:23:21 -0700 | [diff] [blame] | 9385 | if (HDD_SSR_DISABLED == isSsrRequired) |
| 9386 | return; |
| 9387 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9388 | isSsrRequired = value; |
| 9389 | } |
| 9390 | |
Hema Aparna Medicharla | 6b4d4f3 | 2015-06-23 04:09:12 +0530 | [diff] [blame] | 9391 | void hdd_set_pre_close( hdd_context_t *pHddCtx) |
| 9392 | { |
| 9393 | sme_PreClose(pHddCtx->hHal); |
| 9394 | } |
| 9395 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9396 | VOS_STATUS hdd_get_front_adapter( hdd_context_t *pHddCtx, |
| 9397 | hdd_adapter_list_node_t** ppAdapterNode) |
| 9398 | { |
| 9399 | VOS_STATUS status; |
Mukul Sharma | ae1266d | 2015-06-26 15:29:53 +0530 | [diff] [blame] | 9400 | spin_lock_bh(&pHddCtx->hddAdapters.lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9401 | status = hdd_list_peek_front ( &pHddCtx->hddAdapters, |
| 9402 | (hdd_list_node_t**) ppAdapterNode ); |
Mukul Sharma | ae1266d | 2015-06-26 15:29:53 +0530 | [diff] [blame] | 9403 | spin_unlock_bh(&pHddCtx->hddAdapters.lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9404 | return status; |
| 9405 | } |
| 9406 | |
| 9407 | VOS_STATUS hdd_get_next_adapter( hdd_context_t *pHddCtx, |
| 9408 | hdd_adapter_list_node_t* pAdapterNode, |
| 9409 | hdd_adapter_list_node_t** pNextAdapterNode) |
| 9410 | { |
| 9411 | VOS_STATUS status; |
Mukul Sharma | ae1266d | 2015-06-26 15:29:53 +0530 | [diff] [blame] | 9412 | spin_lock_bh(&pHddCtx->hddAdapters.lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9413 | status = hdd_list_peek_next ( &pHddCtx->hddAdapters, |
| 9414 | (hdd_list_node_t*) pAdapterNode, |
| 9415 | (hdd_list_node_t**)pNextAdapterNode ); |
| 9416 | |
Mukul Sharma | ae1266d | 2015-06-26 15:29:53 +0530 | [diff] [blame] | 9417 | spin_unlock_bh(&pHddCtx->hddAdapters.lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9418 | return status; |
| 9419 | } |
| 9420 | |
| 9421 | VOS_STATUS hdd_remove_adapter( hdd_context_t *pHddCtx, |
| 9422 | hdd_adapter_list_node_t* pAdapterNode) |
| 9423 | { |
| 9424 | VOS_STATUS status; |
Mukul Sharma | ae1266d | 2015-06-26 15:29:53 +0530 | [diff] [blame] | 9425 | spin_lock_bh(&pHddCtx->hddAdapters.lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9426 | status = hdd_list_remove_node ( &pHddCtx->hddAdapters, |
| 9427 | &pAdapterNode->node ); |
Mukul Sharma | ae1266d | 2015-06-26 15:29:53 +0530 | [diff] [blame] | 9428 | spin_unlock_bh(&pHddCtx->hddAdapters.lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9429 | return status; |
| 9430 | } |
| 9431 | |
| 9432 | VOS_STATUS hdd_remove_front_adapter( hdd_context_t *pHddCtx, |
| 9433 | hdd_adapter_list_node_t** ppAdapterNode) |
| 9434 | { |
| 9435 | VOS_STATUS status; |
Mukul Sharma | ae1266d | 2015-06-26 15:29:53 +0530 | [diff] [blame] | 9436 | spin_lock_bh(&pHddCtx->hddAdapters.lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9437 | status = hdd_list_remove_front( &pHddCtx->hddAdapters, |
| 9438 | (hdd_list_node_t**) ppAdapterNode ); |
Mukul Sharma | ae1266d | 2015-06-26 15:29:53 +0530 | [diff] [blame] | 9439 | spin_unlock_bh(&pHddCtx->hddAdapters.lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9440 | return status; |
| 9441 | } |
| 9442 | |
| 9443 | VOS_STATUS hdd_add_adapter_back( hdd_context_t *pHddCtx, |
| 9444 | hdd_adapter_list_node_t* pAdapterNode) |
| 9445 | { |
| 9446 | VOS_STATUS status; |
Mukul Sharma | ae1266d | 2015-06-26 15:29:53 +0530 | [diff] [blame] | 9447 | spin_lock_bh(&pHddCtx->hddAdapters.lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9448 | status = hdd_list_insert_back ( &pHddCtx->hddAdapters, |
| 9449 | (hdd_list_node_t*) pAdapterNode ); |
Mukul Sharma | ae1266d | 2015-06-26 15:29:53 +0530 | [diff] [blame] | 9450 | spin_unlock_bh(&pHddCtx->hddAdapters.lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9451 | return status; |
| 9452 | } |
| 9453 | |
| 9454 | VOS_STATUS hdd_add_adapter_front( hdd_context_t *pHddCtx, |
| 9455 | hdd_adapter_list_node_t* pAdapterNode) |
| 9456 | { |
| 9457 | VOS_STATUS status; |
Mukul Sharma | ae1266d | 2015-06-26 15:29:53 +0530 | [diff] [blame] | 9458 | spin_lock_bh(&pHddCtx->hddAdapters.lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9459 | status = hdd_list_insert_front ( &pHddCtx->hddAdapters, |
| 9460 | (hdd_list_node_t*) pAdapterNode ); |
Mukul Sharma | ae1266d | 2015-06-26 15:29:53 +0530 | [diff] [blame] | 9461 | spin_unlock_bh(&pHddCtx->hddAdapters.lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9462 | return status; |
| 9463 | } |
| 9464 | |
| 9465 | hdd_adapter_t * hdd_get_adapter_by_macaddr( hdd_context_t *pHddCtx, |
| 9466 | tSirMacAddr macAddr ) |
| 9467 | { |
| 9468 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 9469 | hdd_adapter_t *pAdapter; |
| 9470 | VOS_STATUS status; |
| 9471 | |
| 9472 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 9473 | |
| 9474 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 9475 | { |
| 9476 | pAdapter = pAdapterNode->pAdapter; |
| 9477 | |
| 9478 | if( pAdapter && vos_mem_compare( pAdapter->macAddressCurrent.bytes, |
| 9479 | macAddr, sizeof(tSirMacAddr) ) ) |
| 9480 | { |
| 9481 | return pAdapter; |
| 9482 | } |
| 9483 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 9484 | pAdapterNode = pNext; |
| 9485 | } |
| 9486 | |
| 9487 | return NULL; |
| 9488 | |
| 9489 | } |
| 9490 | |
| 9491 | hdd_adapter_t * hdd_get_adapter_by_name( hdd_context_t *pHddCtx, tANI_U8 *name ) |
| 9492 | { |
| 9493 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 9494 | hdd_adapter_t *pAdapter; |
| 9495 | VOS_STATUS status; |
| 9496 | |
| 9497 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 9498 | |
| 9499 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 9500 | { |
| 9501 | pAdapter = pAdapterNode->pAdapter; |
| 9502 | |
| 9503 | if( pAdapter && !strncmp( pAdapter->dev->name, (const char *)name, |
| 9504 | IFNAMSIZ ) ) |
| 9505 | { |
| 9506 | return pAdapter; |
| 9507 | } |
| 9508 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 9509 | pAdapterNode = pNext; |
| 9510 | } |
| 9511 | |
| 9512 | return NULL; |
| 9513 | |
| 9514 | } |
| 9515 | |
Ganesh Kondabattini | cbfdc39 | 2015-09-11 19:12:59 +0530 | [diff] [blame] | 9516 | hdd_adapter_t *hdd_get_adapter_by_sme_session_id( hdd_context_t *pHddCtx, |
| 9517 | tANI_U32 sme_session_id ) |
| 9518 | { |
| 9519 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 9520 | hdd_adapter_t *pAdapter; |
| 9521 | VOS_STATUS vos_status; |
| 9522 | |
| 9523 | |
| 9524 | vos_status = hdd_get_front_adapter( pHddCtx, &pAdapterNode); |
| 9525 | |
| 9526 | while ((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == vos_status)) |
| 9527 | { |
| 9528 | pAdapter = pAdapterNode->pAdapter; |
| 9529 | |
| 9530 | if (pAdapter->sessionId == sme_session_id) |
| 9531 | return pAdapter; |
| 9532 | |
| 9533 | vos_status = hdd_get_next_adapter(pHddCtx, pAdapterNode, &pNext); |
| 9534 | pAdapterNode = pNext; |
| 9535 | } |
| 9536 | |
| 9537 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9538 | "%s: sme_session_id %d does not exist with host", |
| 9539 | __func__, sme_session_id); |
| 9540 | |
| 9541 | return NULL; |
| 9542 | } |
| 9543 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9544 | hdd_adapter_t * hdd_get_adapter( hdd_context_t *pHddCtx, device_mode_t mode ) |
| 9545 | { |
| 9546 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 9547 | hdd_adapter_t *pAdapter; |
| 9548 | VOS_STATUS status; |
| 9549 | |
| 9550 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 9551 | |
| 9552 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 9553 | { |
| 9554 | pAdapter = pAdapterNode->pAdapter; |
| 9555 | |
| 9556 | if( pAdapter && (mode == pAdapter->device_mode) ) |
| 9557 | { |
| 9558 | return pAdapter; |
| 9559 | } |
| 9560 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 9561 | pAdapterNode = pNext; |
| 9562 | } |
| 9563 | |
| 9564 | return NULL; |
| 9565 | |
| 9566 | } |
| 9567 | |
| 9568 | //Remove this function later |
| 9569 | hdd_adapter_t * hdd_get_mon_adapter( hdd_context_t *pHddCtx ) |
| 9570 | { |
| 9571 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 9572 | hdd_adapter_t *pAdapter; |
| 9573 | VOS_STATUS status; |
| 9574 | |
| 9575 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 9576 | |
| 9577 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 9578 | { |
| 9579 | pAdapter = pAdapterNode->pAdapter; |
| 9580 | |
| 9581 | if( pAdapter && WLAN_HDD_MONITOR == pAdapter->device_mode ) |
| 9582 | { |
| 9583 | return pAdapter; |
| 9584 | } |
| 9585 | |
| 9586 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 9587 | pAdapterNode = pNext; |
| 9588 | } |
| 9589 | |
| 9590 | return NULL; |
| 9591 | |
| 9592 | } |
| 9593 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9594 | /**--------------------------------------------------------------------------- |
| 9595 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 9596 | \brief hdd_get_operating_channel() - |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9597 | |
| 9598 | This API returns the operating channel of the requested device mode |
| 9599 | |
| 9600 | \param - pHddCtx - Pointer to the HDD context. |
| 9601 | - mode - Device mode for which operating channel is required |
| 9602 | suported modes - WLAN_HDD_INFRA_STATION, WLAN_HDD_P2P_CLIENT |
| 9603 | WLAN_HDD_SOFTAP, WLAN_HDD_P2P_GO. |
| 9604 | \return - channel number. "0" id the requested device is not found OR it is not connected. |
| 9605 | --------------------------------------------------------------------------*/ |
| 9606 | v_U8_t hdd_get_operating_channel( hdd_context_t *pHddCtx, device_mode_t mode ) |
| 9607 | { |
| 9608 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 9609 | VOS_STATUS status; |
| 9610 | hdd_adapter_t *pAdapter; |
| 9611 | v_U8_t operatingChannel = 0; |
| 9612 | |
| 9613 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 9614 | |
| 9615 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 9616 | { |
| 9617 | pAdapter = pAdapterNode->pAdapter; |
| 9618 | |
| 9619 | if( mode == pAdapter->device_mode ) |
| 9620 | { |
| 9621 | switch(pAdapter->device_mode) |
| 9622 | { |
| 9623 | case WLAN_HDD_INFRA_STATION: |
| 9624 | case WLAN_HDD_P2P_CLIENT: |
| 9625 | if( hdd_connIsConnected( WLAN_HDD_GET_STATION_CTX_PTR( pAdapter )) ) |
| 9626 | operatingChannel = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.operationChannel; |
| 9627 | break; |
| 9628 | case WLAN_HDD_SOFTAP: |
| 9629 | case WLAN_HDD_P2P_GO: |
| 9630 | /*softap connection info */ |
| 9631 | if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags)) |
| 9632 | operatingChannel = (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->operatingChannel; |
| 9633 | break; |
| 9634 | default: |
| 9635 | break; |
| 9636 | } |
| 9637 | |
| 9638 | break; //Found the device of interest. break the loop |
| 9639 | } |
| 9640 | |
| 9641 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 9642 | pAdapterNode = pNext; |
| 9643 | } |
| 9644 | return operatingChannel; |
| 9645 | } |
| 9646 | |
| 9647 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 9648 | /**--------------------------------------------------------------------------- |
| 9649 | |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 9650 | \brief __hdd_set_multicast_list() - |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9651 | |
| 9652 | This used to set the multicast address list. |
| 9653 | |
| 9654 | \param - dev - Pointer to the WLAN device. |
| 9655 | - skb - Pointer to OS packet (sk_buff). |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 9656 | \return - success/fail |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9657 | |
| 9658 | --------------------------------------------------------------------------*/ |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 9659 | static void __hdd_set_multicast_list(struct net_device *dev) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9660 | { |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 9661 | hdd_adapter_t *pAdapter; |
| 9662 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9663 | int mc_count; |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 9664 | int i = 0, ret = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9665 | struct netdev_hw_addr *ha; |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 9666 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 9667 | ENTER(); |
| 9668 | |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 9669 | pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 9670 | if (NULL == pAdapter) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9671 | { |
| 9672 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 9673 | "%s: Adapter context is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9674 | return; |
| 9675 | } |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 9676 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 9677 | ret = wlan_hdd_validate_context(pHddCtx); |
| 9678 | if (0 != ret) |
| 9679 | { |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 9680 | return; |
| 9681 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9682 | if (dev->flags & IFF_ALLMULTI) |
| 9683 | { |
| 9684 | hddLog(VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 9685 | "%s: allow all multicast frames", __func__); |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 9686 | pAdapter->mc_addr_list.mc_cnt = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9687 | } |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 9688 | else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9689 | { |
| 9690 | mc_count = netdev_mc_count(dev); |
| 9691 | hddLog(VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 9692 | "%s: mc_count = %u", __func__, mc_count); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9693 | if (mc_count > WLAN_HDD_MAX_MC_ADDR_LIST) |
| 9694 | { |
| 9695 | hddLog(VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 9696 | "%s: No free filter available; allow all multicast frames", __func__); |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 9697 | pAdapter->mc_addr_list.mc_cnt = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9698 | return; |
| 9699 | } |
| 9700 | |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 9701 | pAdapter->mc_addr_list.mc_cnt = mc_count; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9702 | |
| 9703 | netdev_for_each_mc_addr(ha, dev) { |
| 9704 | if (i == mc_count) |
| 9705 | break; |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 9706 | memset(&(pAdapter->mc_addr_list.addr[i][0]), 0, ETH_ALEN); |
| 9707 | memcpy(&(pAdapter->mc_addr_list.addr[i][0]), ha->addr, ETH_ALEN); |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 9708 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: mlist[%d] = "MAC_ADDRESS_STR, |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 9709 | __func__, i, |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 9710 | MAC_ADDR_ARRAY(pAdapter->mc_addr_list.addr[i])); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9711 | i++; |
| 9712 | } |
| 9713 | } |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 9714 | |
Ganesh Kondabattini | fb37e65 | 2015-10-09 15:46:47 +0530 | [diff] [blame] | 9715 | if (pHddCtx->hdd_wlan_suspended) |
| 9716 | { |
| 9717 | /* |
| 9718 | * Configure the Mcast address list to FW |
| 9719 | * If wlan is already in suspend mode |
| 9720 | */ |
| 9721 | wlan_hdd_set_mc_addr_list(pAdapter, TRUE); |
| 9722 | } |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 9723 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9724 | return; |
| 9725 | } |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 9726 | |
| 9727 | static void hdd_set_multicast_list(struct net_device *dev) |
| 9728 | { |
| 9729 | vos_ssr_protect(__func__); |
| 9730 | __hdd_set_multicast_list(dev); |
| 9731 | vos_ssr_unprotect(__func__); |
| 9732 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9733 | #endif |
| 9734 | |
| 9735 | /**--------------------------------------------------------------------------- |
| 9736 | |
| 9737 | \brief hdd_select_queue() - |
| 9738 | |
| 9739 | This function is registered with the Linux OS for network |
| 9740 | core to decide which queue to use first. |
| 9741 | |
| 9742 | \param - dev - Pointer to the WLAN device. |
| 9743 | - skb - Pointer to OS packet (sk_buff). |
| 9744 | \return - ac, Queue Index/access category corresponding to UP in IP header |
| 9745 | |
| 9746 | --------------------------------------------------------------------------*/ |
| 9747 | v_U16_t hdd_select_queue(struct net_device *dev, |
Anand N Sunkad | e9adb1b | 2015-07-29 09:56:45 +0530 | [diff] [blame] | 9748 | struct sk_buff *skb |
| 9749 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0)) |
| 9750 | , void *accel_priv |
| 9751 | #endif |
| 9752 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) |
| 9753 | , select_queue_fallback_t fallback |
| 9754 | #endif |
| 9755 | ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9756 | { |
| 9757 | return hdd_wmm_select_queue(dev, skb); |
| 9758 | } |
| 9759 | |
| 9760 | |
| 9761 | /**--------------------------------------------------------------------------- |
| 9762 | |
| 9763 | \brief hdd_wlan_initial_scan() - |
| 9764 | |
| 9765 | This function triggers the initial scan |
| 9766 | |
| 9767 | \param - pAdapter - Pointer to the HDD adapter. |
| 9768 | |
| 9769 | --------------------------------------------------------------------------*/ |
| 9770 | void hdd_wlan_initial_scan(hdd_adapter_t *pAdapter) |
| 9771 | { |
| 9772 | tCsrScanRequest scanReq; |
| 9773 | tCsrChannelInfo channelInfo; |
| 9774 | eHalStatus halStatus; |
Jeff Johnson | 0279779 | 2013-10-26 19:17:13 -0700 | [diff] [blame] | 9775 | tANI_U32 scanId; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9776 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 9777 | |
| 9778 | vos_mem_zero(&scanReq, sizeof(tCsrScanRequest)); |
| 9779 | vos_mem_set(&scanReq.bssid, sizeof(tCsrBssid), 0xff); |
| 9780 | scanReq.BSSType = eCSR_BSS_TYPE_ANY; |
| 9781 | |
| 9782 | if(sme_Is11dSupported(pHddCtx->hHal)) |
| 9783 | { |
| 9784 | halStatus = sme_ScanGetBaseChannels( pHddCtx->hHal, &channelInfo ); |
| 9785 | if ( HAL_STATUS_SUCCESS( halStatus ) ) |
| 9786 | { |
| 9787 | scanReq.ChannelInfo.ChannelList = vos_mem_malloc(channelInfo.numOfChannels); |
| 9788 | if( !scanReq.ChannelInfo.ChannelList ) |
| 9789 | { |
| 9790 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s kmalloc failed", __func__); |
| 9791 | vos_mem_free(channelInfo.ChannelList); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 9792 | channelInfo.ChannelList = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9793 | return; |
| 9794 | } |
| 9795 | vos_mem_copy(scanReq.ChannelInfo.ChannelList, channelInfo.ChannelList, |
| 9796 | channelInfo.numOfChannels); |
| 9797 | scanReq.ChannelInfo.numOfChannels = channelInfo.numOfChannels; |
| 9798 | vos_mem_free(channelInfo.ChannelList); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 9799 | channelInfo.ChannelList = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9800 | } |
| 9801 | |
| 9802 | scanReq.scanType = eSIR_PASSIVE_SCAN; |
| 9803 | scanReq.requestType = eCSR_SCAN_REQUEST_11D_SCAN; |
| 9804 | scanReq.maxChnTime = pHddCtx->cfg_ini->nPassiveMaxChnTime; |
| 9805 | scanReq.minChnTime = pHddCtx->cfg_ini->nPassiveMinChnTime; |
| 9806 | } |
| 9807 | else |
| 9808 | { |
| 9809 | scanReq.scanType = eSIR_ACTIVE_SCAN; |
| 9810 | scanReq.requestType = eCSR_SCAN_REQUEST_FULL_SCAN; |
| 9811 | scanReq.maxChnTime = pHddCtx->cfg_ini->nActiveMaxChnTime; |
| 9812 | scanReq.minChnTime = pHddCtx->cfg_ini->nActiveMinChnTime; |
| 9813 | } |
| 9814 | |
| 9815 | halStatus = sme_ScanRequest(pHddCtx->hHal, pAdapter->sessionId, &scanReq, &scanId, NULL, NULL); |
| 9816 | if ( !HAL_STATUS_SUCCESS( halStatus ) ) |
| 9817 | { |
| 9818 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_ScanRequest failed status code %d", |
| 9819 | __func__, halStatus ); |
| 9820 | } |
| 9821 | |
| 9822 | if(sme_Is11dSupported(pHddCtx->hHal)) |
| 9823 | vos_mem_free(scanReq.ChannelInfo.ChannelList); |
| 9824 | } |
| 9825 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9826 | /**--------------------------------------------------------------------------- |
| 9827 | |
| 9828 | \brief hdd_full_power_callback() - HDD full power callback function |
| 9829 | |
| 9830 | This is the function invoked by SME to inform the result of a full power |
| 9831 | request issued by HDD |
| 9832 | |
| 9833 | \param - callbackcontext - Pointer to cookie |
| 9834 | \param - status - result of request |
| 9835 | |
| 9836 | \return - None |
| 9837 | |
| 9838 | --------------------------------------------------------------------------*/ |
| 9839 | static void hdd_full_power_callback(void *callbackContext, eHalStatus status) |
| 9840 | { |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 9841 | struct statsContext *pContext = callbackContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9842 | |
| 9843 | hddLog(VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 9844 | "%s: context = %p, status = %d", __func__, pContext, status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9845 | |
| 9846 | if (NULL == callbackContext) |
| 9847 | { |
| 9848 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 9849 | "%s: Bad param, context [%p]", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 9850 | __func__, callbackContext); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9851 | return; |
| 9852 | } |
| 9853 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 9854 | /* there is a race condition that exists between this callback |
| 9855 | function and the caller since the caller could time out either |
| 9856 | before or while this code is executing. we use a spinlock to |
| 9857 | serialize these actions */ |
| 9858 | spin_lock(&hdd_context_lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9859 | |
| 9860 | if (POWER_CONTEXT_MAGIC != pContext->magic) |
| 9861 | { |
| 9862 | /* the caller presumably timed out so there is nothing we can do */ |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 9863 | spin_unlock(&hdd_context_lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9864 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 9865 | "%s: Invalid context, magic [%08x]", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 9866 | __func__, pContext->magic); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9867 | return; |
| 9868 | } |
| 9869 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 9870 | /* context is valid so caller is still waiting */ |
| 9871 | |
| 9872 | /* paranoia: invalidate the magic */ |
| 9873 | pContext->magic = 0; |
| 9874 | |
| 9875 | /* notify the caller */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9876 | complete(&pContext->completion); |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 9877 | |
| 9878 | /* serialization is complete */ |
| 9879 | spin_unlock(&hdd_context_lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9880 | } |
| 9881 | |
Katya Nigam | f0511f6 | 2015-05-05 16:40:57 +0530 | [diff] [blame] | 9882 | void wlan_hdd_mon_set_typesubtype( hdd_mon_ctx_t *pMonCtx,int type) |
| 9883 | { |
| 9884 | pMonCtx->typeSubtypeBitmap = 0; |
| 9885 | if( type%10 ) /* Management Packets */ |
| 9886 | pMonCtx->typeSubtypeBitmap |= 0xFFFF; |
| 9887 | type/=10; |
| 9888 | if( type%10 ) /* Control Packets */ |
| 9889 | pMonCtx->typeSubtypeBitmap |= 0xFFFF0000; |
| 9890 | type/=10; |
| 9891 | if( type%10 ) /* Data Packets */ |
| 9892 | pMonCtx->typeSubtypeBitmap |= 0xFFFF00000000; |
| 9893 | } |
| 9894 | |
Hanumantha Reddy Pothula | 91cdd7f | 2015-09-03 21:25:16 +0530 | [diff] [blame] | 9895 | VOS_STATUS wlan_hdd_mon_postMsg(tANI_U32 *magic, struct completion *cmpVar, |
| 9896 | hdd_mon_ctx_t *pMonCtx , void* callback) |
Katya Nigam | f0511f6 | 2015-05-05 16:40:57 +0530 | [diff] [blame] | 9897 | { |
| 9898 | vos_msg_t monMsg; |
Hanumantha Reddy Pothula | 91cdd7f | 2015-09-03 21:25:16 +0530 | [diff] [blame] | 9899 | tSirMonModeReq *pMonModeReq; |
Katya Nigam | f0511f6 | 2015-05-05 16:40:57 +0530 | [diff] [blame] | 9900 | |
Hanumantha Reddy Pothula | 91cdd7f | 2015-09-03 21:25:16 +0530 | [diff] [blame] | 9901 | if (MON_MODE_START == pMonCtx->state) |
| 9902 | monMsg.type = WDA_MON_START_REQ; |
| 9903 | else if (MON_MODE_STOP == pMonCtx->state) |
| 9904 | monMsg.type = WDA_MON_STOP_REQ; |
| 9905 | else { |
| 9906 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 9907 | FL("invalid monitor state %d"), pMonCtx->state); |
Katya Nigam | f0511f6 | 2015-05-05 16:40:57 +0530 | [diff] [blame] | 9908 | return VOS_STATUS_E_FAILURE; |
| 9909 | } |
| 9910 | |
Hanumantha Reddy Pothula | 91cdd7f | 2015-09-03 21:25:16 +0530 | [diff] [blame] | 9911 | pMonModeReq = vos_mem_malloc(sizeof(tSirMonModeReq)); |
| 9912 | if (pMonModeReq == NULL) { |
| 9913 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 9914 | FL("fail to allocate memory for monitor mode req")); |
| 9915 | return VOS_STATUS_E_FAILURE; |
| 9916 | } |
Katya Nigam | f0511f6 | 2015-05-05 16:40:57 +0530 | [diff] [blame] | 9917 | |
Hanumantha Reddy Pothula | 91cdd7f | 2015-09-03 21:25:16 +0530 | [diff] [blame] | 9918 | pMonModeReq->magic = magic; |
| 9919 | pMonModeReq->cmpVar = cmpVar; |
| 9920 | pMonModeReq->data = pMonCtx; |
| 9921 | pMonModeReq->callback = callback; |
Katya Nigam | f0511f6 | 2015-05-05 16:40:57 +0530 | [diff] [blame] | 9922 | |
Katya Nigam | f0511f6 | 2015-05-05 16:40:57 +0530 | [diff] [blame] | 9923 | monMsg.reserved = 0; |
Hanumantha Reddy Pothula | 91cdd7f | 2015-09-03 21:25:16 +0530 | [diff] [blame] | 9924 | monMsg.bodyptr = pMonModeReq; |
Katya Nigam | f0511f6 | 2015-05-05 16:40:57 +0530 | [diff] [blame] | 9925 | monMsg.bodyval = 0; |
| 9926 | |
| 9927 | if (VOS_STATUS_SUCCESS != vos_mq_post_message( |
| 9928 | VOS_MODULE_ID_WDA,(vos_msg_t *)&monMsg)) { |
| 9929 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: : Failed to post Msg to HAL",__func__); |
Hanumantha Reddy Pothula | 91cdd7f | 2015-09-03 21:25:16 +0530 | [diff] [blame] | 9930 | vos_mem_free(pMonModeReq); |
Katya Nigam | f0511f6 | 2015-05-05 16:40:57 +0530 | [diff] [blame] | 9931 | } |
Hanumantha Reddy Pothula | 91cdd7f | 2015-09-03 21:25:16 +0530 | [diff] [blame] | 9932 | return VOS_STATUS_SUCCESS; |
Katya Nigam | f0511f6 | 2015-05-05 16:40:57 +0530 | [diff] [blame] | 9933 | } |
| 9934 | |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 9935 | void wlan_hdd_mon_close(hdd_context_t *pHddCtx) |
| 9936 | { |
| 9937 | VOS_STATUS vosStatus; |
| 9938 | v_CONTEXT_t pVosContext = pHddCtx->pvosContext; |
Hanumantha Reddy Pothula | 91cdd7f | 2015-09-03 21:25:16 +0530 | [diff] [blame] | 9939 | long ret; |
| 9940 | hdd_mon_ctx_t *pMonCtx = NULL; |
| 9941 | v_U32_t magic; |
| 9942 | struct completion cmpVar; |
Hanumantha Reddy Pothula | c99bc06 | 2015-09-08 14:59:26 +0530 | [diff] [blame] | 9943 | |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 9944 | hdd_adapter_t *pAdapter = hdd_get_adapter(pHddCtx,WLAN_HDD_MONITOR); |
| 9945 | if(pAdapter == NULL || pVosContext == NULL) |
| 9946 | { |
| 9947 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:pAdapter is NULL",__func__); |
| 9948 | return ; |
| 9949 | } |
Katya Nigam | f0511f6 | 2015-05-05 16:40:57 +0530 | [diff] [blame] | 9950 | |
Hanumantha Reddy Pothula | 91cdd7f | 2015-09-03 21:25:16 +0530 | [diff] [blame] | 9951 | pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter); |
| 9952 | if (pMonCtx!= NULL && pMonCtx->state == MON_MODE_START) { |
| 9953 | pMonCtx->state = MON_MODE_STOP; |
| 9954 | magic = MON_MODE_MSG_MAGIC; |
| 9955 | init_completion(&cmpVar); |
| 9956 | if (VOS_STATUS_SUCCESS != |
| 9957 | wlan_hdd_mon_postMsg(&magic, &cmpVar, |
| 9958 | pMonCtx, hdd_monPostMsgCb)) { |
| 9959 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9960 | FL("failed to post MON MODE REQ")); |
| 9961 | pMonCtx->state = MON_MODE_START; |
| 9962 | magic = 0; |
| 9963 | return; |
| 9964 | } |
| 9965 | ret = wait_for_completion_timeout(&cmpVar, MON_MODE_MSG_TIMEOUT); |
| 9966 | magic = 0; |
| 9967 | if (ret <= 0 ) { |
| 9968 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9969 | FL("timeout on monitor mode completion %ld"), ret); |
| 9970 | } |
| 9971 | } |
| 9972 | |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 9973 | hdd_UnregisterWext(pAdapter->dev); |
| 9974 | |
| 9975 | vos_mon_stop( pVosContext ); |
| 9976 | |
| 9977 | vosStatus = vos_sched_close( pVosContext ); |
| 9978 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) { |
| 9979 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, |
| 9980 | "%s: Failed to close VOSS Scheduler",__func__); |
| 9981 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) ); |
| 9982 | } |
| 9983 | |
| 9984 | vosStatus = vos_nv_close(); |
| 9985 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) |
| 9986 | { |
| 9987 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 9988 | "%s: Failed to close NV", __func__); |
| 9989 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) ); |
| 9990 | } |
| 9991 | |
| 9992 | vos_close(pVosContext); |
| 9993 | |
| 9994 | #ifdef WLAN_KD_READY_NOTIFIER |
| 9995 | nl_srv_exit(pHddCtx->ptt_pid); |
| 9996 | #else |
| 9997 | nl_srv_exit(); |
| 9998 | #endif |
| 9999 | |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 10000 | hdd_close_all_adapters( pHddCtx ); |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 10001 | } |
Agrawal Ashish | 33ec71e | 2015-11-26 20:20:58 +0530 | [diff] [blame] | 10002 | /** |
| 10003 | * hdd_wlan_free_wiphy_channels - free Channel pointer for wiphy |
| 10004 | * @ wiphy: the wiphy to validate against |
| 10005 | * |
| 10006 | * Return: void |
| 10007 | */ |
| 10008 | void hdd_wlan_free_wiphy_channels(struct wiphy *wiphy) |
| 10009 | { |
| 10010 | int i =0; |
| 10011 | for (i = 0; i < IEEE80211_NUM_BANDS; i++) |
| 10012 | { |
| 10013 | if (NULL != wiphy->bands[i] && |
| 10014 | (NULL != wiphy->bands[i]->channels)) |
| 10015 | { |
| 10016 | vos_mem_free(wiphy->bands[i]->channels); |
| 10017 | wiphy->bands[i]->channels = NULL; |
| 10018 | } |
| 10019 | } |
| 10020 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10021 | /**--------------------------------------------------------------------------- |
| 10022 | |
| 10023 | \brief hdd_wlan_exit() - HDD WLAN exit function |
| 10024 | |
| 10025 | This is the driver exit point (invoked during rmmod) |
| 10026 | |
| 10027 | \param - pHddCtx - Pointer to the HDD Context |
| 10028 | |
| 10029 | \return - None |
| 10030 | |
| 10031 | --------------------------------------------------------------------------*/ |
| 10032 | void hdd_wlan_exit(hdd_context_t *pHddCtx) |
| 10033 | { |
| 10034 | eHalStatus halStatus; |
| 10035 | v_CONTEXT_t pVosContext = pHddCtx->pvosContext; |
| 10036 | VOS_STATUS vosStatus; |
Gopichand Nakkala | 66923aa | 2013-03-06 23:17:24 +0530 | [diff] [blame] | 10037 | struct wiphy *wiphy = pHddCtx->wiphy; |
Mingcheng Zhu | 87f22fc | 2014-01-30 19:23:32 -0800 | [diff] [blame] | 10038 | hdd_adapter_t* pAdapter = NULL; |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 10039 | struct statsContext powerContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10040 | long lrc; |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 10041 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10042 | |
| 10043 | ENTER(); |
| 10044 | |
Vinay Krishna Eranna | f97ef5c | 2014-12-26 17:47:19 +0530 | [diff] [blame] | 10045 | |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 10046 | if (VOS_MONITOR_MODE == hdd_get_conparam()) |
| 10047 | { |
| 10048 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: MONITOR MODE",__func__); |
| 10049 | wlan_hdd_mon_close(pHddCtx); |
Hanumantha Reddy Pothula | c99bc06 | 2015-09-08 14:59:26 +0530 | [diff] [blame] | 10050 | goto free_hdd_ctx; |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 10051 | } |
| 10052 | else if (VOS_FTM_MODE != hdd_get_conparam()) |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 10053 | { |
| 10054 | // Unloading, restart logic is no more required. |
| 10055 | wlan_hdd_restart_deinit(pHddCtx); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10056 | |
Agarwal Ashish | b20e0ff | 2014-12-17 22:50:19 +0530 | [diff] [blame] | 10057 | #ifdef FEATURE_WLAN_TDLS |
| 10058 | /* At the time of driver unloading; if tdls connection is present; |
| 10059 | * hdd_rx_packet_cbk calls wlan_hdd_tdls_find_peer. |
| 10060 | * wlan_hdd_tdls_find_peer always checks for valid context; |
| 10061 | * as load/unload in progress there can be a race condition. |
| 10062 | * hdd_rx_packet_cbk calls wlan_hdd_tdls_find_peer only |
| 10063 | * when tdls state is enabled. |
| 10064 | * As soon as driver set load/unload flag; tdls flag also needs |
| 10065 | * to be disabled so that hdd_rx_packet_cbk won't call |
| 10066 | * wlan_hdd_tdls_find_peer. |
| 10067 | */ |
Masti, Narayanraddi | 20494af | 2015-12-17 20:56:42 +0530 | [diff] [blame] | 10068 | wlan_hdd_tdls_set_mode(pHddCtx, eTDLS_SUPPORT_DISABLED, FALSE, |
| 10069 | HDD_SET_TDLS_MODE_SOURCE_USER); |
Agarwal Ashish | b20e0ff | 2014-12-17 22:50:19 +0530 | [diff] [blame] | 10070 | #endif |
| 10071 | |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 10072 | vosStatus = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 10073 | while (NULL != pAdapterNode && VOS_STATUS_E_EMPTY != vosStatus) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10074 | { |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 10075 | pAdapter = pAdapterNode->pAdapter; |
| 10076 | if (NULL != pAdapter) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10077 | { |
Mahesh A Saptasagar | 305e263 | 2015-03-04 12:57:33 +0530 | [diff] [blame] | 10078 | /* Disable TX on the interface, after this hard_start_xmit() will |
| 10079 | * not be called on that interface |
| 10080 | */ |
| 10081 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues")); |
| 10082 | netif_tx_disable(pAdapter->dev); |
| 10083 | |
| 10084 | /* Mark the interface status as "down" for outside world */ |
| 10085 | netif_carrier_off(pAdapter->dev); |
| 10086 | |
Agarwal Ashish | 9ffa5b9 | 2014-11-18 21:07:02 +0530 | [diff] [blame] | 10087 | /* DeInit the adapter. This ensures that all data packets |
| 10088 | * are freed. |
| 10089 | */ |
Mahesh A Saptasagar | 02e36e8 | 2015-01-14 20:39:19 +0530 | [diff] [blame] | 10090 | #ifdef FEATURE_WLAN_TDLS |
| 10091 | mutex_lock(&pHddCtx->tdls_lock); |
| 10092 | #endif |
c_hpothu | 002231a | 2015-02-05 14:58:51 +0530 | [diff] [blame] | 10093 | hdd_deinit_adapter(pHddCtx, pAdapter, FALSE); |
Mahesh A Saptasagar | 02e36e8 | 2015-01-14 20:39:19 +0530 | [diff] [blame] | 10094 | #ifdef FEATURE_WLAN_TDLS |
| 10095 | mutex_unlock(&pHddCtx->tdls_lock); |
| 10096 | #endif |
Masti, Narayanraddi | 2637846 | 2016-01-05 18:20:28 +0530 | [diff] [blame] | 10097 | vos_flush_delayed_work(&pHddCtx->scan_ctxt.scan_work); |
| 10098 | |
| 10099 | wlan_hdd_init_deinit_defer_scan_context(&pHddCtx->scan_ctxt); |
Agarwal Ashish | 9ffa5b9 | 2014-11-18 21:07:02 +0530 | [diff] [blame] | 10100 | |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 10101 | if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode || |
| 10102 | WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) |
| 10103 | { |
| 10104 | wlan_hdd_cfg80211_deregister_frames(pAdapter); |
| 10105 | hdd_UnregisterWext(pAdapter->dev); |
| 10106 | } |
Kaushik, Sushant | 4975a57 | 2014-10-21 16:07:48 +0530 | [diff] [blame] | 10107 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10108 | } |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 10109 | vosStatus = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 10110 | pAdapterNode = pNext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10111 | } |
mukul sharma | bab477d | 2015-06-11 17:14:55 +0530 | [diff] [blame] | 10112 | |
Kaushik, Sushant | 4975a57 | 2014-10-21 16:07:48 +0530 | [diff] [blame] | 10113 | // Cancel any outstanding scan requests. We are about to close all |
| 10114 | // of our adapters, but an adapter structure is what SME passes back |
| 10115 | // to our callback function. Hence if there are any outstanding scan |
| 10116 | // requests then there is a race condition between when the adapter |
| 10117 | // is closed and when the callback is invoked.We try to resolve that |
| 10118 | // race condition here by canceling any outstanding scans before we |
| 10119 | // close the adapters. |
| 10120 | // Note that the scans may be cancelled in an asynchronous manner, |
| 10121 | // so ideally there needs to be some kind of synchronization. Rather |
| 10122 | // than introduce a new synchronization here, we will utilize the |
| 10123 | // fact that we are about to Request Full Power, and since that is |
| 10124 | // synchronized, the expectation is that by the time Request Full |
| 10125 | // Power has completed all scans will be cancelled. |
| 10126 | if (pHddCtx->scan_info.mScanPending) |
| 10127 | { |
Hema Aparna Medicharla | f05f6cd | 2015-01-21 14:44:19 +0530 | [diff] [blame] | 10128 | if(NULL != pAdapter) |
| 10129 | { |
| 10130 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 10131 | FL("abort scan mode: %d sessionId: %d"), |
| 10132 | pAdapter->device_mode, |
| 10133 | pAdapter->sessionId); |
| 10134 | } |
| 10135 | hdd_abort_mac_scan(pHddCtx, |
| 10136 | pHddCtx->scan_info.sessionId, |
| 10137 | eCSR_SCAN_ABORT_DEFAULT); |
Kaushik, Sushant | 4975a57 | 2014-10-21 16:07:48 +0530 | [diff] [blame] | 10138 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10139 | } |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 10140 | else |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 10141 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 10142 | hddLog(VOS_TRACE_LEVEL_INFO,"%s: FTM MODE",__func__); |
Hanumantha Reddy Pothula | 45af96b | 2015-02-12 16:07:58 +0530 | [diff] [blame] | 10143 | if (pHddCtx->ftm.ftm_state == WLAN_FTM_STARTING) |
| 10144 | { |
| 10145 | INIT_COMPLETION(pHddCtx->ftm.startCmpVar); |
| 10146 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 10147 | "%s: in middle of FTM START", __func__); |
| 10148 | lrc = wait_for_completion_timeout(&pHddCtx->ftm.startCmpVar, |
| 10149 | msecs_to_jiffies(20000)); |
| 10150 | if(!lrc) |
| 10151 | { |
| 10152 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 10153 | "%s: timedout on ftmStartCmpVar fatal error", __func__); |
| 10154 | } |
| 10155 | } |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 10156 | wlan_hdd_ftm_close(pHddCtx); |
| 10157 | goto free_hdd_ctx; |
| 10158 | } |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 10159 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10160 | /* DeRegister with platform driver as client for Suspend/Resume */ |
| 10161 | vosStatus = hddDeregisterPmOps(pHddCtx); |
| 10162 | if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) ) |
| 10163 | { |
| 10164 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddDeregisterPmOps failed",__func__); |
| 10165 | VOS_ASSERT(0); |
| 10166 | } |
| 10167 | |
| 10168 | vosStatus = hddDevTmUnregisterNotifyCallback(pHddCtx); |
| 10169 | if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) ) |
| 10170 | { |
| 10171 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddDevTmUnregisterNotifyCallback failed",__func__); |
| 10172 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10173 | |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 10174 | //Stop the traffic monitor timer |
| 10175 | if ( VOS_TIMER_STATE_RUNNING == |
| 10176 | vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)) |
| 10177 | { |
| 10178 | vos_timer_stop(&pHddCtx->tx_rx_trafficTmr); |
| 10179 | } |
| 10180 | |
| 10181 | // Destroy the traffic monitor timer |
| 10182 | if (!VOS_IS_STATUS_SUCCESS(vos_timer_destroy( |
| 10183 | &pHddCtx->tx_rx_trafficTmr))) |
| 10184 | { |
| 10185 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 10186 | "%s: Cannot deallocate Traffic monitor timer", __func__); |
| 10187 | } |
| 10188 | |
Bhargav Shah | d071591 | 2015-10-01 18:17:37 +0530 | [diff] [blame] | 10189 | if (VOS_TIMER_STATE_RUNNING == |
| 10190 | vos_timer_getCurrentState(&pHddCtx->delack_timer)) { |
| 10191 | vos_timer_stop(&pHddCtx->delack_timer); |
| 10192 | } |
| 10193 | |
| 10194 | if (!VOS_IS_STATUS_SUCCESS(vos_timer_destroy( |
| 10195 | &pHddCtx->delack_timer))) { |
| 10196 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 10197 | "%s: Cannot deallocate Bus bandwidth timer", __func__); |
| 10198 | } |
| 10199 | |
Masti, Narayanraddi | 44b0db0 | 2015-12-22 11:54:35 +0530 | [diff] [blame] | 10200 | if (VOS_TIMER_STATE_RUNNING == |
| 10201 | vos_timer_getCurrentState(&pHddCtx->tdls_source_timer)) { |
| 10202 | vos_timer_stop(&pHddCtx->tdls_source_timer); |
| 10203 | } |
| 10204 | |
| 10205 | vos_timer_destroy(&pHddCtx->tdls_source_timer); |
| 10206 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10207 | //Disable IMPS/BMPS as we do not want the device to enter any power |
| 10208 | //save mode during shutdown |
| 10209 | sme_DisablePowerSave(pHddCtx->hHal, ePMC_IDLE_MODE_POWER_SAVE); |
| 10210 | sme_DisablePowerSave(pHddCtx->hHal, ePMC_BEACON_MODE_POWER_SAVE); |
| 10211 | sme_DisablePowerSave(pHddCtx->hHal, ePMC_UAPSD_MODE_POWER_SAVE); |
| 10212 | |
| 10213 | //Ensure that device is in full power as we will touch H/W during vos_Stop |
| 10214 | init_completion(&powerContext.completion); |
| 10215 | powerContext.magic = POWER_CONTEXT_MAGIC; |
| 10216 | |
| 10217 | halStatus = sme_RequestFullPower(pHddCtx->hHal, hdd_full_power_callback, |
| 10218 | &powerContext, eSME_FULL_PWR_NEEDED_BY_HDD); |
| 10219 | |
| 10220 | if (eHAL_STATUS_SUCCESS != halStatus) |
| 10221 | { |
| 10222 | if (eHAL_STATUS_PMC_PENDING == halStatus) |
| 10223 | { |
| 10224 | /* request was sent -- wait for the response */ |
| 10225 | lrc = wait_for_completion_interruptible_timeout( |
| 10226 | &powerContext.completion, |
| 10227 | msecs_to_jiffies(WLAN_WAIT_TIME_POWER)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10228 | if (lrc <= 0) |
| 10229 | { |
| 10230 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s while requesting full power", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 10231 | __func__, (0 == lrc) ? "timeout" : "interrupt"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10232 | } |
| 10233 | } |
| 10234 | else |
| 10235 | { |
| 10236 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 10237 | "%s: Request for Full Power failed, status %d", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 10238 | __func__, halStatus); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10239 | /* continue -- need to clean up as much as possible */ |
| 10240 | } |
| 10241 | } |
Hanumantha Reddy Pothula | 81b42b2 | 2015-05-12 13:52:00 +0530 | [diff] [blame] | 10242 | if ((eHAL_STATUS_SUCCESS == halStatus) || |
| 10243 | (eHAL_STATUS_PMC_PENDING == halStatus && lrc > 0)) |
| 10244 | { |
| 10245 | /* This will issue a dump command which will clean up |
| 10246 | BTQM queues and unblock MC thread */ |
| 10247 | vos_fwDumpReq(274, 0, 0, 0, 0, 1); |
| 10248 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10249 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 10250 | /* either we never sent a request, we sent a request and received a |
| 10251 | response or we sent a request and timed out. if we never sent a |
| 10252 | request or if we sent a request and got a response, we want to |
| 10253 | clear the magic out of paranoia. if we timed out there is a |
| 10254 | race condition such that the callback function could be |
| 10255 | executing at the same time we are. of primary concern is if the |
| 10256 | callback function had already verified the "magic" but had not |
| 10257 | yet set the completion variable when a timeout occurred. we |
| 10258 | serialize these activities by invalidating the magic while |
| 10259 | holding a shared spinlock which will cause us to block if the |
| 10260 | callback is currently executing */ |
| 10261 | spin_lock(&hdd_context_lock); |
| 10262 | powerContext.magic = 0; |
| 10263 | spin_unlock(&hdd_context_lock); |
| 10264 | |
Hema Aparna Medicharla | a6cf65e | 2015-06-01 16:23:28 +0530 | [diff] [blame] | 10265 | /* If Device is shutdown, no point for SME to wait for responses |
| 10266 | from device. Pre Close SME */ |
| 10267 | if(wcnss_device_is_shutdown()) |
| 10268 | { |
| 10269 | sme_PreClose(pHddCtx->hHal); |
| 10270 | } |
Yue Ma | 0d4891e | 2013-08-06 17:01:45 -0700 | [diff] [blame] | 10271 | hdd_debugfs_exit(pHddCtx); |
| 10272 | |
Ratheesh S P | 35ed8b1 | 2015-04-27 14:01:07 +0530 | [diff] [blame] | 10273 | #ifdef WLAN_NS_OFFLOAD |
Ratheesh S P | 36dbc93 | 2015-08-07 14:28:57 +0530 | [diff] [blame] | 10274 | hddLog(LOG1, FL("Unregister IPv6 notifier")); |
Ratheesh S P | 35ed8b1 | 2015-04-27 14:01:07 +0530 | [diff] [blame] | 10275 | unregister_inet6addr_notifier(&pHddCtx->ipv6_notifier); |
| 10276 | #endif |
Ratheesh S P | 36dbc93 | 2015-08-07 14:28:57 +0530 | [diff] [blame] | 10277 | hddLog(LOG1, FL("Unregister IPv4 notifier")); |
Ratheesh S P | 35ed8b1 | 2015-04-27 14:01:07 +0530 | [diff] [blame] | 10278 | unregister_inetaddr_notifier(&pHddCtx->ipv4_notifier); |
| 10279 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10280 | // Unregister the Net Device Notifier |
| 10281 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 10282 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10283 | hdd_stop_all_adapters( pHddCtx ); |
| 10284 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10285 | #ifdef WLAN_BTAMP_FEATURE |
| 10286 | vosStatus = WLANBAP_Stop(pVosContext); |
| 10287 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) |
| 10288 | { |
| 10289 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 10290 | "%s: Failed to stop BAP",__func__); |
| 10291 | } |
| 10292 | #endif //WLAN_BTAMP_FEATURE |
| 10293 | |
| 10294 | //Stop all the modules |
| 10295 | vosStatus = vos_stop( pVosContext ); |
| 10296 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) |
| 10297 | { |
| 10298 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 10299 | "%s: Failed to stop VOSS",__func__); |
| 10300 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) ); |
Hanumantha Reddy Pothula | bd9601a | 2016-02-12 13:22:27 +0530 | [diff] [blame] | 10301 | if (isSsrPanicOnFailure()) |
| 10302 | VOS_BUG(0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10303 | } |
| 10304 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10305 | //This requires pMac access, Call this before vos_close(). |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10306 | hdd_unregister_mcast_bcast_filter(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10307 | |
| 10308 | //Close the scheduler before calling vos_close to make sure no thread is |
| 10309 | // scheduled after the each module close is called i.e after all the data |
| 10310 | // structures are freed. |
| 10311 | vosStatus = vos_sched_close( pVosContext ); |
| 10312 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) { |
| 10313 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, |
| 10314 | "%s: Failed to close VOSS Scheduler",__func__); |
| 10315 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) ); |
| 10316 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10317 | #ifdef WLAN_FEATURE_HOLD_RX_WAKELOCK |
| 10318 | /* Destroy the wake lock */ |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 10319 | vos_wake_lock_destroy(&pHddCtx->rx_wake_lock); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10320 | #endif |
Madan Mohan Koyyalamudi | 69fc3ad | 2012-11-28 16:04:56 -0800 | [diff] [blame] | 10321 | /* Destroy the wake lock */ |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 10322 | vos_wake_lock_destroy(&pHddCtx->sap_wake_lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10323 | |
Mihir Shete | 7a24b5f | 2013-12-21 12:18:31 +0530 | [diff] [blame] | 10324 | #ifdef CONFIG_ENABLE_LINUX_REG |
| 10325 | vosStatus = vos_nv_close(); |
| 10326 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) |
| 10327 | { |
| 10328 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 10329 | "%s: Failed to close NV", __func__); |
| 10330 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) ); |
| 10331 | } |
| 10332 | #endif |
| 10333 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10334 | //Close VOSS |
| 10335 | //This frees pMac(HAL) context. There should not be any call that requires pMac access after this. |
| 10336 | vos_close(pVosContext); |
| 10337 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10338 | //Close Watchdog |
| 10339 | if(pHddCtx->cfg_ini->fIsLogpEnabled) |
| 10340 | vos_watchdog_close(pVosContext); |
| 10341 | |
Gopichand Nakkala | a035848 | 2013-06-12 17:05:47 +0530 | [diff] [blame] | 10342 | //Clean up HDD Nlink Service |
| 10343 | send_btc_nlink_msg(WLAN_MODULE_DOWN_IND, 0); |
Gopichand Nakkala | a035848 | 2013-06-12 17:05:47 +0530 | [diff] [blame] | 10344 | |
Manjeet Singh | 47ee847 | 2016-04-11 11:57:18 +0530 | [diff] [blame] | 10345 | hdd_close_tx_queues(pHddCtx); |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 10346 | wlan_free_fwr_mem_dump_buffer(); |
| 10347 | memdump_deinit(); |
| 10348 | |
Vinay Krishna Eranna | d938c42 | 2014-03-10 17:14:21 +0530 | [diff] [blame] | 10349 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 10350 | if (pHddCtx->cfg_ini->wlanLoggingEnable) |
Vinay Krishna Eranna | d938c42 | 2014-03-10 17:14:21 +0530 | [diff] [blame] | 10351 | { |
| 10352 | wlan_logging_sock_deactivate_svc(); |
| 10353 | } |
| 10354 | #endif |
| 10355 | |
Vinay Krishna Eranna | ef30b52 | 2014-08-26 17:48:16 +0530 | [diff] [blame] | 10356 | #ifdef WLAN_KD_READY_NOTIFIER |
| 10357 | nl_srv_exit(pHddCtx->ptt_pid); |
| 10358 | #else |
| 10359 | nl_srv_exit(); |
| 10360 | #endif /* WLAN_KD_READY_NOTIFIER */ |
| 10361 | |
Abhishek Singh | 00b7197 | 2016-01-07 10:51:04 +0530 | [diff] [blame] | 10362 | #ifdef WLAN_FEATURE_RMC |
| 10363 | hdd_close_cesium_nl_sock(); |
| 10364 | #endif /* WLAN_FEATURE_RMC */ |
Vinay Krishna Eranna | ef30b52 | 2014-08-26 17:48:16 +0530 | [diff] [blame] | 10365 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10366 | hdd_close_all_adapters( pHddCtx ); |
| 10367 | |
Padma, Santhosh Kumar | 9cd3833 | 2015-11-17 12:18:10 +0530 | [diff] [blame] | 10368 | vos_flush_delayed_work(&pHddCtx->spoof_mac_addr_work); |
| 10369 | |
Hanumantha Reddy Pothula | 97f9bc9 | 2015-08-10 17:21:20 +0530 | [diff] [blame] | 10370 | free_hdd_ctx: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10371 | /* free the power on lock from platform driver */ |
| 10372 | if (free_riva_power_on_lock("wlan")) |
| 10373 | { |
| 10374 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to free power on lock", |
| 10375 | __func__); |
| 10376 | } |
| 10377 | |
c_hpothu | 78c7b60 | 2014-05-17 17:35:49 +0530 | [diff] [blame] | 10378 | //Free up dynamically allocated members inside HDD Adapter |
| 10379 | if (pHddCtx->cfg_ini) |
| 10380 | { |
| 10381 | kfree(pHddCtx->cfg_ini); |
| 10382 | pHddCtx->cfg_ini= NULL; |
| 10383 | } |
| 10384 | |
Hanumantha Reddy Pothula | 6fe221c | 2016-01-28 15:01:09 +0530 | [diff] [blame] | 10385 | /* FTM/MONITOR mode, WIPHY did not registered |
Leo Chang | f04ddad | 2013-09-18 13:46:38 -0700 | [diff] [blame] | 10386 | If un-register here, system crash will happen */ |
Hanumantha Reddy Pothula | 6fe221c | 2016-01-28 15:01:09 +0530 | [diff] [blame] | 10387 | if (!(VOS_FTM_MODE == hdd_get_conparam() || |
| 10388 | VOS_MONITOR_MODE == hdd_get_conparam())) |
Leo Chang | f04ddad | 2013-09-18 13:46:38 -0700 | [diff] [blame] | 10389 | { |
| 10390 | wiphy_unregister(wiphy) ; |
Agrawal Ashish | 33ec71e | 2015-11-26 20:20:58 +0530 | [diff] [blame] | 10391 | hdd_wlan_free_wiphy_channels(wiphy); |
Leo Chang | f04ddad | 2013-09-18 13:46:38 -0700 | [diff] [blame] | 10392 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10393 | wiphy_free(wiphy) ; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10394 | if (hdd_is_ssr_required()) |
| 10395 | { |
| 10396 | /* WDI timeout had happened during unload, so SSR is needed here */ |
Madan Mohan Koyyalamudi | 3246f5b | 2012-10-15 15:40:02 -0700 | [diff] [blame] | 10397 | subsystem_restart("wcnss"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10398 | msleep(5000); |
| 10399 | } |
| 10400 | hdd_set_ssr_required (VOS_FALSE); |
| 10401 | } |
| 10402 | |
| 10403 | |
| 10404 | /**--------------------------------------------------------------------------- |
| 10405 | |
| 10406 | \brief hdd_update_config_from_nv() - Function to update the contents of |
| 10407 | the running configuration with parameters taken from NV storage |
| 10408 | |
| 10409 | \param - pHddCtx - Pointer to the HDD global context |
| 10410 | |
| 10411 | \return - VOS_STATUS_SUCCESS if successful |
| 10412 | |
| 10413 | --------------------------------------------------------------------------*/ |
| 10414 | static VOS_STATUS hdd_update_config_from_nv(hdd_context_t* pHddCtx) |
| 10415 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10416 | v_BOOL_t itemIsValid = VOS_FALSE; |
| 10417 | VOS_STATUS status; |
| 10418 | v_MACADDR_t macFromNV[VOS_MAX_CONCURRENCY_PERSONA]; |
| 10419 | v_U8_t macLoop; |
| 10420 | |
| 10421 | /*If the NV is valid then get the macaddress from nv else get it from qcom_cfg.ini*/ |
| 10422 | status = vos_nv_getValidity(VNV_FIELD_IMAGE, &itemIsValid); |
| 10423 | if(status != VOS_STATUS_SUCCESS) |
| 10424 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 10425 | hddLog(VOS_TRACE_LEVEL_ERROR," vos_nv_getValidity() failed"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10426 | return VOS_STATUS_E_FAILURE; |
| 10427 | } |
| 10428 | |
| 10429 | if (itemIsValid == VOS_TRUE) |
| 10430 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 10431 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH," Reading the Macaddress from NV"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10432 | status = vos_nv_readMultiMacAddress((v_U8_t *)&macFromNV[0].bytes[0], |
| 10433 | VOS_MAX_CONCURRENCY_PERSONA); |
| 10434 | if(status != VOS_STATUS_SUCCESS) |
| 10435 | { |
| 10436 | /* Get MAC from NV fail, not update CFG info |
| 10437 | * INI MAC value will be used for MAC setting */ |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 10438 | hddLog(VOS_TRACE_LEVEL_ERROR," vos_nv_readMacAddress() failed"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10439 | return VOS_STATUS_E_FAILURE; |
| 10440 | } |
| 10441 | |
| 10442 | /* If first MAC is not valid, treat all others are not valid |
| 10443 | * Then all MACs will be got from ini file */ |
| 10444 | if(vos_is_macaddr_zero(&macFromNV[0])) |
| 10445 | { |
| 10446 | /* MAC address in NV file is not configured yet */ |
| 10447 | hddLog(VOS_TRACE_LEVEL_WARN, "Invalid MAC in NV file"); |
| 10448 | return VOS_STATUS_E_INVAL; |
| 10449 | } |
| 10450 | |
| 10451 | /* Get MAC address from NV, update CFG info */ |
| 10452 | for(macLoop = 0; macLoop < VOS_MAX_CONCURRENCY_PERSONA; macLoop++) |
| 10453 | { |
| 10454 | if(vos_is_macaddr_zero(&macFromNV[macLoop])) |
| 10455 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 10456 | 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] | 10457 | /* This MAC is not valid, skip it |
| 10458 | * This MAC will be got from ini file */ |
| 10459 | } |
| 10460 | else |
| 10461 | { |
| 10462 | vos_mem_copy((v_U8_t *)&pHddCtx->cfg_ini->intfMacAddr[macLoop].bytes[0], |
| 10463 | (v_U8_t *)&macFromNV[macLoop].bytes[0], |
| 10464 | VOS_MAC_ADDR_SIZE); |
| 10465 | } |
| 10466 | } |
| 10467 | } |
| 10468 | else |
| 10469 | { |
| 10470 | hddLog(VOS_TRACE_LEVEL_ERROR, "NV ITEM, MAC Not valid"); |
| 10471 | return VOS_STATUS_E_FAILURE; |
| 10472 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10473 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10474 | |
| 10475 | return VOS_STATUS_SUCCESS; |
| 10476 | } |
| 10477 | |
| 10478 | /**--------------------------------------------------------------------------- |
| 10479 | |
| 10480 | \brief hdd_post_voss_start_config() - HDD post voss start config helper |
| 10481 | |
| 10482 | \param - pAdapter - Pointer to the HDD |
| 10483 | |
| 10484 | \return - None |
| 10485 | |
| 10486 | --------------------------------------------------------------------------*/ |
| 10487 | VOS_STATUS hdd_post_voss_start_config(hdd_context_t* pHddCtx) |
| 10488 | { |
| 10489 | eHalStatus halStatus; |
| 10490 | v_U32_t listenInterval; |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 10491 | tANI_U32 ignoreDtim; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10492 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10493 | |
| 10494 | // Send ready indication to the HDD. This will kick off the MAC |
| 10495 | // into a 'running' state and should kick off an initial scan. |
| 10496 | halStatus = sme_HDDReadyInd( pHddCtx->hHal ); |
| 10497 | if ( !HAL_STATUS_SUCCESS( halStatus ) ) |
| 10498 | { |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 10499 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: sme_HDDReadyInd() failed with status " |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10500 | "code %08d [x%08x]",__func__, halStatus, halStatus ); |
| 10501 | return VOS_STATUS_E_FAILURE; |
| 10502 | } |
| 10503 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 10504 | // Set default LI and ignoreDtim into HDD context, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10505 | // otherwise under some race condition, HDD will set 0 LI value into RIVA, |
| 10506 | // And RIVA will crash |
| 10507 | wlan_cfgGetInt(pHddCtx->hHal, WNI_CFG_LISTEN_INTERVAL, &listenInterval); |
| 10508 | pHddCtx->hdd_actual_LI_value = listenInterval; |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 10509 | wlan_cfgGetInt(pHddCtx->hHal, WNI_CFG_IGNORE_DTIM, &ignoreDtim); |
| 10510 | pHddCtx->hdd_actual_ignore_DTIM_value = ignoreDtim; |
| 10511 | |
| 10512 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10513 | return VOS_STATUS_SUCCESS; |
| 10514 | } |
| 10515 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10516 | /* wake lock APIs for HDD */ |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 10517 | void hdd_prevent_suspend(uint32_t reason) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10518 | { |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 10519 | |
| 10520 | vos_wake_lock_acquire(&wlan_wake_lock, reason); |
| 10521 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10522 | } |
| 10523 | |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 10524 | void hdd_allow_suspend(uint32_t reason) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10525 | { |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 10526 | |
| 10527 | vos_wake_lock_release(&wlan_wake_lock, reason); |
| 10528 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10529 | } |
| 10530 | |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 10531 | void hdd_prevent_suspend_timeout(v_U32_t timeout, uint32_t reason) |
Madan Mohan Koyyalamudi | 10d83a9 | 2012-09-28 15:47:05 -0700 | [diff] [blame] | 10532 | { |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 10533 | |
| 10534 | vos_wake_lock_timeout_release(&wlan_wake_lock, timeout, |
| 10535 | reason); |
| 10536 | |
Madan Mohan Koyyalamudi | 10d83a9 | 2012-09-28 15:47:05 -0700 | [diff] [blame] | 10537 | } |
| 10538 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10539 | /**--------------------------------------------------------------------------- |
| 10540 | |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 10541 | \brief hdd_exchange_version_and_caps() - HDD function to exchange version and capability |
| 10542 | information between Host and Riva |
| 10543 | |
| 10544 | This function gets reported version of FW |
| 10545 | It also finds the version of Riva headers used to compile the host |
| 10546 | It compares the above two and prints a warning if they are different |
| 10547 | It gets the SW and HW version string |
| 10548 | Finally, it exchanges capabilities between host and Riva i.e. host and riva exchange a msg |
| 10549 | indicating the features they support through a bitmap |
| 10550 | |
| 10551 | \param - pHddCtx - Pointer to HDD context |
| 10552 | |
| 10553 | \return - void |
| 10554 | |
| 10555 | --------------------------------------------------------------------------*/ |
| 10556 | |
| 10557 | void hdd_exchange_version_and_caps(hdd_context_t *pHddCtx) |
| 10558 | { |
| 10559 | |
| 10560 | tSirVersionType versionCompiled; |
| 10561 | tSirVersionType versionReported; |
| 10562 | tSirVersionString versionString; |
| 10563 | tANI_U8 fwFeatCapsMsgSupported = 0; |
| 10564 | VOS_STATUS vstatus; |
| 10565 | |
Mingcheng Zhu | 87f22fc | 2014-01-30 19:23:32 -0800 | [diff] [blame] | 10566 | memset(&versionCompiled, 0, sizeof(versionCompiled)); |
| 10567 | memset(&versionReported, 0, sizeof(versionReported)); |
| 10568 | |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 10569 | /* retrieve and display WCNSS version information */ |
| 10570 | do { |
| 10571 | |
| 10572 | vstatus = sme_GetWcnssWlanCompiledVersion(pHddCtx->hHal, |
| 10573 | &versionCompiled); |
| 10574 | if (!VOS_IS_STATUS_SUCCESS(vstatus)) |
| 10575 | { |
| 10576 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 10577 | "%s: unable to retrieve WCNSS WLAN compiled version", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 10578 | __func__); |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 10579 | break; |
| 10580 | } |
| 10581 | |
| 10582 | vstatus = sme_GetWcnssWlanReportedVersion(pHddCtx->hHal, |
| 10583 | &versionReported); |
| 10584 | if (!VOS_IS_STATUS_SUCCESS(vstatus)) |
| 10585 | { |
| 10586 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 10587 | "%s: unable to retrieve WCNSS WLAN reported version", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 10588 | __func__); |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 10589 | break; |
| 10590 | } |
| 10591 | |
| 10592 | if ((versionCompiled.major != versionReported.major) || |
| 10593 | (versionCompiled.minor != versionReported.minor) || |
| 10594 | (versionCompiled.version != versionReported.version) || |
| 10595 | (versionCompiled.revision != versionReported.revision)) |
| 10596 | { |
| 10597 | pr_err("%s: WCNSS WLAN Version %u.%u.%u.%u, " |
| 10598 | "Host expected %u.%u.%u.%u\n", |
| 10599 | WLAN_MODULE_NAME, |
| 10600 | (int)versionReported.major, |
| 10601 | (int)versionReported.minor, |
| 10602 | (int)versionReported.version, |
| 10603 | (int)versionReported.revision, |
| 10604 | (int)versionCompiled.major, |
| 10605 | (int)versionCompiled.minor, |
| 10606 | (int)versionCompiled.version, |
| 10607 | (int)versionCompiled.revision); |
| 10608 | } |
| 10609 | else |
| 10610 | { |
| 10611 | pr_info("%s: WCNSS WLAN version %u.%u.%u.%u\n", |
| 10612 | WLAN_MODULE_NAME, |
| 10613 | (int)versionReported.major, |
| 10614 | (int)versionReported.minor, |
| 10615 | (int)versionReported.version, |
| 10616 | (int)versionReported.revision); |
| 10617 | } |
| 10618 | |
| 10619 | vstatus = sme_GetWcnssSoftwareVersion(pHddCtx->hHal, |
| 10620 | versionString, |
| 10621 | sizeof(versionString)); |
| 10622 | if (!VOS_IS_STATUS_SUCCESS(vstatus)) |
| 10623 | { |
| 10624 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 10625 | "%s: unable to retrieve WCNSS software version string", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 10626 | __func__); |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 10627 | break; |
| 10628 | } |
| 10629 | |
| 10630 | pr_info("%s: WCNSS software version %s\n", |
| 10631 | WLAN_MODULE_NAME, versionString); |
Sushant Kaushik | 084f659 | 2015-09-10 13:11:56 +0530 | [diff] [blame] | 10632 | vos_mem_copy(pHddCtx->fw_Version, versionString, sizeof(versionString)); |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 10633 | |
| 10634 | vstatus = sme_GetWcnssHardwareVersion(pHddCtx->hHal, |
| 10635 | versionString, |
| 10636 | sizeof(versionString)); |
| 10637 | if (!VOS_IS_STATUS_SUCCESS(vstatus)) |
| 10638 | { |
| 10639 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 10640 | "%s: unable to retrieve WCNSS hardware version string", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 10641 | __func__); |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 10642 | break; |
| 10643 | } |
| 10644 | |
| 10645 | pr_info("%s: WCNSS hardware version %s\n", |
| 10646 | WLAN_MODULE_NAME, versionString); |
| 10647 | |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 10648 | /* 1.Check if FW version is greater than 0.1.1.0. Only then send host-FW capability exchange message |
| 10649 | 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] | 10650 | send the message only if it the riva is 1.1 |
| 10651 | minor numbers for different riva branches: |
| 10652 | 0 -> (1.0)Mainline Build |
| 10653 | 1 -> (1.1)Mainline Build |
| 10654 | 2->(1.04) Stability Build |
| 10655 | */ |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 10656 | if (((versionReported.major>0) || (versionReported.minor>1) || |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 10657 | ((versionReported.minor>=1) && (versionReported.version>=1))) |
| 10658 | && ((versionReported.major == 1) && (versionReported.minor >= 1))) |
| 10659 | fwFeatCapsMsgSupported = 1; |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 10660 | |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 10661 | if (fwFeatCapsMsgSupported) |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 10662 | { |
| 10663 | #ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE |
| 10664 | if(!pHddCtx->cfg_ini->fEnableActiveModeOffload) |
| 10665 | sme_disableFeatureCapablity(WLANACTIVE_OFFLOAD); |
| 10666 | #endif |
Ravi Joshi | d2ca7c4 | 2013-07-23 08:37:49 -0700 | [diff] [blame] | 10667 | /* Indicate if IBSS heartbeat monitoring needs to be offloaded */ |
| 10668 | if (!pHddCtx->cfg_ini->enableIbssHeartBeatOffload) |
| 10669 | { |
| 10670 | sme_disableFeatureCapablity(IBSS_HEARTBEAT_OFFLOAD); |
| 10671 | } |
| 10672 | |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 10673 | sme_featureCapsExchange(pHddCtx->hHal); |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 10674 | } |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 10675 | |
| 10676 | } while (0); |
| 10677 | |
| 10678 | } |
Neelansh Mittal | edafed2 | 2014-09-04 18:54:39 +0530 | [diff] [blame] | 10679 | void wlan_hdd_send_svc_nlink_msg(int type, void *data, int len) |
| 10680 | { |
| 10681 | struct sk_buff *skb; |
| 10682 | struct nlmsghdr *nlh; |
| 10683 | tAniMsgHdr *ani_hdr; |
Hanumantha Reddy Pothula | cf2c7ea | 2015-04-27 14:50:47 +0530 | [diff] [blame] | 10684 | int flags = GFP_KERNEL; |
Bhargav shah | 23c9494 | 2015-10-13 12:48:35 +0530 | [diff] [blame] | 10685 | void *nl_data = NULL; |
Neelansh Mittal | edafed2 | 2014-09-04 18:54:39 +0530 | [diff] [blame] | 10686 | |
Hanumantha Reddy Pothula | cf2c7ea | 2015-04-27 14:50:47 +0530 | [diff] [blame] | 10687 | if (in_interrupt() || irqs_disabled() || in_atomic()) |
| 10688 | flags = GFP_ATOMIC; |
| 10689 | |
| 10690 | skb = alloc_skb(NLMSG_SPACE(WLAN_NL_MAX_PAYLOAD), flags); |
Neelansh Mittal | edafed2 | 2014-09-04 18:54:39 +0530 | [diff] [blame] | 10691 | |
| 10692 | if(skb == NULL) { |
| 10693 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10694 | "%s: alloc_skb failed", __func__); |
| 10695 | return; |
| 10696 | } |
| 10697 | |
| 10698 | nlh = (struct nlmsghdr *)skb->data; |
| 10699 | nlh->nlmsg_pid = 0; /* from kernel */ |
| 10700 | nlh->nlmsg_flags = 0; |
| 10701 | nlh->nlmsg_seq = 0; |
| 10702 | nlh->nlmsg_type = WLAN_NL_MSG_SVC; |
| 10703 | |
| 10704 | ani_hdr = NLMSG_DATA(nlh); |
| 10705 | ani_hdr->type = type; |
| 10706 | |
| 10707 | switch(type) { |
| 10708 | case WLAN_SVC_SAP_RESTART_IND: |
| 10709 | ani_hdr->length = 0; |
| 10710 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr))); |
| 10711 | skb_put(skb, NLMSG_SPACE(sizeof(tAniMsgHdr))); |
| 10712 | break; |
Bhargav Shah | d071591 | 2015-10-01 18:17:37 +0530 | [diff] [blame] | 10713 | case WLAN_SVC_WLAN_TP_IND: |
| 10714 | ani_hdr->length = len; |
| 10715 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr) |
| 10716 | + len)); |
| 10717 | nl_data = (char *)ani_hdr + sizeof(tAniMsgHdr); |
| 10718 | memcpy(nl_data, data, len); |
| 10719 | skb_put(skb, NLMSG_SPACE(sizeof(tAniMsgHdr) + len)); |
| 10720 | break; |
Bhargav shah | 23c9494 | 2015-10-13 12:48:35 +0530 | [diff] [blame] | 10721 | case WLAN_MSG_RPS_ENABLE_IND: |
| 10722 | ani_hdr->length = len; |
| 10723 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr) + len)); |
| 10724 | nl_data = (char *)ani_hdr + sizeof(tAniMsgHdr); |
| 10725 | memcpy(nl_data, data, len); |
| 10726 | skb_put(skb, NLMSG_SPACE(sizeof(tAniMsgHdr) + len)); |
| 10727 | break; |
Neelansh Mittal | edafed2 | 2014-09-04 18:54:39 +0530 | [diff] [blame] | 10728 | default: |
| 10729 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10730 | "Attempt to send unknown nlink message %d", type); |
| 10731 | kfree_skb(skb); |
| 10732 | return; |
| 10733 | } |
| 10734 | |
| 10735 | nl_srv_bcast(skb); |
| 10736 | |
| 10737 | return; |
| 10738 | } |
| 10739 | |
Bhargav Shah | d071591 | 2015-10-01 18:17:37 +0530 | [diff] [blame] | 10740 | /** |
| 10741 | * hdd_request_tcp_delack() - Find the Delack value based on RX packet |
| 10742 | * @pHddCtx: Valid Global HDD context pointer |
| 10743 | * @rx_packets: Number of RX packet in perticular time |
| 10744 | * |
| 10745 | * Based on the RX packet this function calculate next value of tcp delack. |
| 10746 | * This function compare rx packet value to high and low threshold limit. |
| 10747 | * |
| 10748 | * Return: void |
| 10749 | */ |
| 10750 | void hdd_request_tcp_delack(hdd_context_t *pHddCtx, uint64_t rx_packets) |
| 10751 | { |
| 10752 | /* average of rx_packets and prev_rx is taken so that |
| 10753 | bus width doesnot fluctuate much */ |
| 10754 | uint64_t temp_rx = (rx_packets + pHddCtx->prev_rx)/2; |
| 10755 | TP_IND_TYPE next_rx_level = pHddCtx->cur_rx_level; |
Neelansh Mittal | edafed2 | 2014-09-04 18:54:39 +0530 | [diff] [blame] | 10756 | |
Bhargav Shah | d071591 | 2015-10-01 18:17:37 +0530 | [diff] [blame] | 10757 | pHddCtx->prev_rx = rx_packets; |
| 10758 | if (temp_rx > pHddCtx->cfg_ini->tcpDelAckThresholdHigh) |
| 10759 | next_rx_level = TP_IND_HIGH; |
| 10760 | else if (temp_rx <= pHddCtx->cfg_ini->tcpDelAckThresholdLow) |
| 10761 | next_rx_level = TP_IND_LOW; |
| 10762 | |
| 10763 | hdd_set_delack_value(pHddCtx, next_rx_level); |
| 10764 | } |
| 10765 | |
| 10766 | #define HDD_BW_GET_DIFF(x, y) ((x) >= (y) ? (x) - (y) : (ULONG_MAX - (y) + (x))) |
| 10767 | |
| 10768 | /** |
| 10769 | * hdd_tcp_delack_compute_function() - get link status |
| 10770 | * @priv: Valid Global HDD context pointer |
| 10771 | * |
| 10772 | * This function find number of RX packet during timer life span. |
| 10773 | * It request tcp delack with number of RX packet and re-configure delack timer |
| 10774 | * for tcpDelAckComputeInterval timer interval. |
| 10775 | * |
| 10776 | * Return: void |
| 10777 | */ |
| 10778 | void hdd_tcp_delack_compute_function(void *priv) |
| 10779 | { |
| 10780 | hdd_context_t *pHddCtx = (hdd_context_t *)priv; |
| 10781 | hdd_adapter_t *pAdapter = NULL; |
| 10782 | v_U32_t rx_packets = 0; |
| 10783 | hdd_adapter_list_node_t *pAdapterNode = NULL; |
| 10784 | VOS_STATUS status = 0; |
| 10785 | |
| 10786 | for (status = hdd_get_front_adapter(pHddCtx, &pAdapterNode); |
| 10787 | NULL != pAdapterNode && VOS_STATUS_SUCCESS == status; |
| 10788 | status = hdd_get_next_adapter(pHddCtx, pAdapterNode, &pAdapterNode)) { |
| 10789 | if ((pAdapter = pAdapterNode->pAdapter) == NULL) |
| 10790 | continue; |
| 10791 | |
| 10792 | rx_packets += HDD_BW_GET_DIFF(pAdapter->stats.rx_packets, |
| 10793 | pAdapter->prev_rx_packets); |
| 10794 | pAdapter->prev_rx_packets = pAdapter->stats.rx_packets; |
| 10795 | } |
| 10796 | |
| 10797 | hdd_request_tcp_delack(pHddCtx, rx_packets); |
| 10798 | |
| 10799 | vos_timer_start(&pHddCtx->delack_timer, |
| 10800 | pHddCtx->cfg_ini->tcpDelAckComputeInterval); |
| 10801 | } |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 10802 | |
| 10803 | /**--------------------------------------------------------------------------- |
| 10804 | |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 10805 | \brief hdd_is_5g_supported() - HDD function to know if hardware supports 5GHz |
| 10806 | |
| 10807 | \param - pHddCtx - Pointer to the hdd context |
| 10808 | |
| 10809 | \return - true if hardware supports 5GHz |
| 10810 | |
| 10811 | --------------------------------------------------------------------------*/ |
Vinay Krishna Eranna | facf5e2 | 2014-02-24 13:16:25 +0530 | [diff] [blame] | 10812 | boolean hdd_is_5g_supported(hdd_context_t * pHddCtx) |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 10813 | { |
| 10814 | /* If wcnss_wlan_iris_xo_mode() returns WCNSS_XO_48MHZ(1); |
| 10815 | * then hardware support 5Ghz. |
| 10816 | */ |
| 10817 | if (WCNSS_XO_48MHZ == wcnss_wlan_iris_xo_mode()) |
| 10818 | { |
Ratheesh S P | 36dbc93 | 2015-08-07 14:28:57 +0530 | [diff] [blame] | 10819 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Hardware supports 5Ghz", __func__); |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 10820 | return true; |
| 10821 | } |
| 10822 | else |
| 10823 | { |
Ratheesh S P | 36dbc93 | 2015-08-07 14:28:57 +0530 | [diff] [blame] | 10824 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Hardware doesn't supports 5Ghz", |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 10825 | __func__); |
| 10826 | return false; |
| 10827 | } |
| 10828 | } |
| 10829 | |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 10830 | /**--------------------------------------------------------------------------- |
| 10831 | |
| 10832 | \brief hdd_generate_iface_mac_addr_auto() - HDD Mac Interface Auto |
| 10833 | generate function |
| 10834 | |
| 10835 | This is generate the random mac address for WLAN interface |
| 10836 | |
| 10837 | \param - pHddCtx - Pointer to HDD context |
| 10838 | idx - Start interface index to get auto |
| 10839 | generated mac addr. |
| 10840 | mac_addr - Mac address |
| 10841 | |
| 10842 | \return - 0 for success, < 0 for failure |
| 10843 | |
| 10844 | --------------------------------------------------------------------------*/ |
| 10845 | |
| 10846 | static int hdd_generate_iface_mac_addr_auto(hdd_context_t *pHddCtx, |
| 10847 | int idx, v_MACADDR_t mac_addr) |
| 10848 | { |
| 10849 | int i; |
| 10850 | unsigned int serialno; |
| 10851 | serialno = wcnss_get_serial_number(); |
| 10852 | |
| 10853 | if (0 != serialno) |
| 10854 | { |
| 10855 | /* MAC address has 3 bytes of OUI so we have a maximum of 3 |
| 10856 | bytes of the serial number that can be used to generate |
| 10857 | the other 3 bytes of the MAC address. Mask off all but |
| 10858 | the lower 3 bytes (this will also make sure we don't |
| 10859 | overflow in the next step) */ |
| 10860 | serialno &= 0x00FFFFFF; |
| 10861 | |
| 10862 | /* we need a unique address for each session */ |
| 10863 | serialno *= VOS_MAX_CONCURRENCY_PERSONA; |
| 10864 | |
| 10865 | /* autogen other Mac addresses */ |
| 10866 | for (i = idx; i < VOS_MAX_CONCURRENCY_PERSONA; i++) |
| 10867 | { |
| 10868 | /* start with the entire default address */ |
| 10869 | pHddCtx->cfg_ini->intfMacAddr[i] = mac_addr; |
| 10870 | /* then replace the lower 3 bytes */ |
| 10871 | pHddCtx->cfg_ini->intfMacAddr[i].bytes[3] = (serialno >> 16) & 0xFF; |
| 10872 | pHddCtx->cfg_ini->intfMacAddr[i].bytes[4] = (serialno >> 8) & 0xFF; |
| 10873 | pHddCtx->cfg_ini->intfMacAddr[i].bytes[5] = serialno & 0xFF; |
| 10874 | |
| 10875 | serialno++; |
| 10876 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 10877 | "%s: Derived Mac Addr: " |
| 10878 | MAC_ADDRESS_STR, __func__, |
| 10879 | MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[i].bytes)); |
| 10880 | } |
| 10881 | |
| 10882 | } |
| 10883 | else |
| 10884 | { |
| 10885 | hddLog(LOGE, FL("Failed to Get Serial NO")); |
| 10886 | return -1; |
| 10887 | } |
| 10888 | return 0; |
| 10889 | } |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 10890 | |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 10891 | int wlan_hdd_mon_open(hdd_context_t *pHddCtx) |
| 10892 | { |
| 10893 | VOS_STATUS status; |
| 10894 | v_CONTEXT_t pVosContext= NULL; |
| 10895 | hdd_adapter_t *pAdapter= NULL; |
| 10896 | |
| 10897 | pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL); |
| 10898 | |
| 10899 | if (NULL == pVosContext) |
| 10900 | { |
| 10901 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10902 | "%s: Trying to open VOSS without a PreOpen", __func__); |
| 10903 | VOS_ASSERT(0); |
| 10904 | return VOS_STATUS_E_FAILURE; |
| 10905 | } |
| 10906 | |
| 10907 | status = vos_nv_open(); |
| 10908 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 10909 | { |
| 10910 | /* NV module cannot be initialized */ |
| 10911 | hddLog( VOS_TRACE_LEVEL_FATAL, |
| 10912 | "%s: vos_nv_open failed", __func__); |
| 10913 | return VOS_STATUS_E_FAILURE; |
| 10914 | } |
| 10915 | |
| 10916 | status = vos_init_wiphy_from_nv_bin(); |
| 10917 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 10918 | { |
| 10919 | /* NV module cannot be initialized */ |
| 10920 | hddLog( VOS_TRACE_LEVEL_FATAL, |
| 10921 | "%s: vos_init_wiphy failed", __func__); |
| 10922 | goto err_vos_nv_close; |
| 10923 | } |
| 10924 | |
| 10925 | status = vos_open( &pVosContext, pHddCtx->parent_dev); |
| 10926 | if ( !VOS_IS_STATUS_SUCCESS( status )) |
| 10927 | { |
| 10928 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: vos_open failed", __func__); |
| 10929 | goto err_vos_nv_close; |
| 10930 | } |
| 10931 | |
| 10932 | status = vos_mon_start( pVosContext ); |
| 10933 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 10934 | { |
| 10935 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: vos_start failed",__func__); |
| 10936 | goto err_vosclose; |
| 10937 | } |
| 10938 | |
| 10939 | WLANTL_SetMonRxCbk( pVosContext, hdd_rx_packet_monitor_cbk ); |
| 10940 | WDA_featureCapsExchange(pVosContext); |
| 10941 | wcnss_wlan_set_drvdata(pHddCtx->parent_dev, pHddCtx); |
| 10942 | |
| 10943 | pAdapter = hdd_open_adapter( pHddCtx, WLAN_HDD_MONITOR, "wlan%d", |
| 10944 | wlan_hdd_get_intf_addr(pHddCtx), FALSE ); |
| 10945 | if( pAdapter == NULL ) |
| 10946 | { |
| 10947 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: hdd_open_adapter failed", __func__); |
| 10948 | goto err_close_adapter; |
| 10949 | } |
| 10950 | |
| 10951 | //Initialize the nlink service |
| 10952 | if(nl_srv_init() != 0) |
| 10953 | { |
| 10954 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: nl_srv_init failed", __func__); |
| 10955 | goto err_close_adapter; |
| 10956 | } |
| 10957 | return VOS_STATUS_SUCCESS; |
| 10958 | |
| 10959 | err_close_adapter: |
| 10960 | hdd_close_all_adapters( pHddCtx ); |
| 10961 | vos_mon_stop( pVosContext ); |
| 10962 | err_vosclose: |
| 10963 | status = vos_sched_close( pVosContext ); |
| 10964 | if (!VOS_IS_STATUS_SUCCESS(status)) { |
| 10965 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, |
| 10966 | "%s: Failed to close VOSS Scheduler", __func__); |
| 10967 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( status ) ); |
| 10968 | } |
| 10969 | vos_close(pVosContext ); |
| 10970 | |
| 10971 | err_vos_nv_close: |
| 10972 | vos_nv_close(); |
| 10973 | |
| 10974 | return status; |
| 10975 | } |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 10976 | /**--------------------------------------------------------------------------- |
| 10977 | |
Mihir Shete | fc7ff5b | 2014-01-27 11:30:05 +0530 | [diff] [blame] | 10978 | \brief hdd_11d_scan_done - callback to be executed when 11d scan is |
| 10979 | completed to flush out the scan results |
| 10980 | |
| 10981 | 11d scan is done during driver load and is a passive scan on all |
| 10982 | channels supported by the device, 11d scans may find some APs on |
| 10983 | frequencies which are forbidden to be used in the regulatory domain |
| 10984 | the device is operating in. If these APs are notified to the supplicant |
| 10985 | it may try to connect to these APs, thus flush out all the scan results |
| 10986 | which are present in SME after 11d scan is done. |
| 10987 | |
| 10988 | \return - eHalStatus |
| 10989 | |
| 10990 | --------------------------------------------------------------------------*/ |
| 10991 | static eHalStatus hdd_11d_scan_done(tHalHandle halHandle, void *pContext, |
| 10992 | tANI_U32 scanId, eCsrScanStatus status) |
| 10993 | { |
| 10994 | ENTER(); |
| 10995 | |
| 10996 | sme_ScanFlushResult(halHandle, 0); |
| 10997 | |
| 10998 | EXIT(); |
| 10999 | |
| 11000 | return eHAL_STATUS_SUCCESS; |
| 11001 | } |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 11002 | /**--------------------------------------------------------------------------- |
| 11003 | |
| 11004 | \brief hdd_init_frame_logging_done - callback to be executed when mgmt frame |
| 11005 | logging is completed successfully. |
| 11006 | |
| 11007 | \return - None |
| 11008 | |
| 11009 | --------------------------------------------------------------------------*/ |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 11010 | void hdd_init_frame_logging_done(void *fwlogInitCbContext, tAniLoggingInitRsp *pRsp) |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 11011 | { |
Siddharth Bhal | d1be97f | 2015-05-27 22:39:59 +0530 | [diff] [blame] | 11012 | hdd_context_t* pHddCtx = (hdd_context_t*)fwlogInitCbContext; |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 11013 | |
| 11014 | if (NULL == pHddCtx) |
| 11015 | { |
| 11016 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 11017 | "%s: HDD context is NULL",__func__); |
| 11018 | return; |
| 11019 | } |
| 11020 | |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 11021 | if ((pRsp->status == VOS_STATUS_SUCCESS) && |
Mahesh A Saptasagar | fabb1a0 | 2015-06-29 12:17:04 +0530 | [diff] [blame] | 11022 | (TRUE == pHddCtx->cfg_ini->enableMgmtLogging)) |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 11023 | { |
| 11024 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Mgmt Frame Logging init successful")); |
| 11025 | pHddCtx->mgmt_frame_logging = TRUE; |
| 11026 | } |
| 11027 | else |
| 11028 | { |
| 11029 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Mgmt Frame Logging init not success")); |
| 11030 | pHddCtx->mgmt_frame_logging = FALSE; |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 11031 | return; |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 11032 | } |
| 11033 | |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 11034 | /*Check feature supported by FW*/ |
| 11035 | if(TRUE == sme_IsFeatureSupportedByFW(MEMORY_DUMP_SUPPORTED)) |
| 11036 | { |
| 11037 | //Store fwr mem dump size given by firmware. |
| 11038 | wlan_store_fwr_mem_dump_size(pRsp->fw_mem_dump_max_size); |
| 11039 | } |
| 11040 | else |
| 11041 | { |
| 11042 | wlan_store_fwr_mem_dump_size(0); |
| 11043 | } |
| 11044 | |
| 11045 | |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 11046 | } |
| 11047 | /**--------------------------------------------------------------------------- |
| 11048 | |
| 11049 | \brief hdd_init_frame_logging - function to initialize frame logging. |
| 11050 | Currently only Mgmt Frames are logged in both TX |
| 11051 | and Rx direction and are sent to userspace |
| 11052 | application using logger thread when queried. |
| 11053 | |
| 11054 | \return - None |
| 11055 | |
| 11056 | --------------------------------------------------------------------------*/ |
Siddharth Bhal | d1be97f | 2015-05-27 22:39:59 +0530 | [diff] [blame] | 11057 | void hdd_init_frame_logging(hdd_context_t* pHddCtx) |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 11058 | { |
| 11059 | eHalStatus halStatus = eHAL_STATUS_FAILURE; |
Sreelakshmi Konamki | d8784d9 | 2016-04-14 14:59:13 +0530 | [diff] [blame] | 11060 | tSirFWLoggingInitParam wlanFWLoggingInitParam = {0}; |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 11061 | |
Siddharth Bhal | d1be97f | 2015-05-27 22:39:59 +0530 | [diff] [blame] | 11062 | if (TRUE != sme_IsFeatureSupportedByFW(MGMT_FRAME_LOGGING) && |
| 11063 | TRUE != sme_IsFeatureSupportedByFW(LOGGING_ENHANCEMENT)) |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 11064 | { |
| 11065 | hddLog(VOS_TRACE_LEVEL_INFO, FL("MGMT_FRAME_LOGGING not supp by FW")); |
| 11066 | return; |
| 11067 | } |
| 11068 | |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 11069 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Configuring %s %s %s %s Logging",__func__, |
Siddharth Bhal | d1be97f | 2015-05-27 22:39:59 +0530 | [diff] [blame] | 11070 | pHddCtx->cfg_ini->enableFWLogging?"FW Log,":"", |
| 11071 | pHddCtx->cfg_ini->enableContFWLogging ? "Cont FW log,":"", |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 11072 | pHddCtx->cfg_ini->enableMgmtLogging ? "Mgmt Pkt Log":"", |
| 11073 | pHddCtx->cfg_ini->enableFwrMemDump ? "Fw Mem dump":""); |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 11074 | |
Siddharth Bhal | d1be97f | 2015-05-27 22:39:59 +0530 | [diff] [blame] | 11075 | if (pHddCtx->cfg_ini->enableFWLogging || |
| 11076 | pHddCtx->cfg_ini->enableContFWLogging) |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 11077 | { |
Sreelakshmi Konamki | d8784d9 | 2016-04-14 14:59:13 +0530 | [diff] [blame] | 11078 | wlanFWLoggingInitParam.enableFlag |= WLAN_QXDM_LOG_EN; |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 11079 | } |
| 11080 | |
Sushant Kaushik | 4680490 | 2015-07-08 14:46:03 +0530 | [diff] [blame] | 11081 | if (pHddCtx->cfg_ini->enableMgmtLogging) |
| 11082 | { |
Sreelakshmi Konamki | d8784d9 | 2016-04-14 14:59:13 +0530 | [diff] [blame] | 11083 | wlanFWLoggingInitParam.enableFlag |= WLAN_FRAME_LOG_EN; |
Sushant Kaushik | 4680490 | 2015-07-08 14:46:03 +0530 | [diff] [blame] | 11084 | } |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 11085 | if (pHddCtx->cfg_ini->enableBMUHWtracing) |
| 11086 | { |
Sreelakshmi Konamki | d8784d9 | 2016-04-14 14:59:13 +0530 | [diff] [blame] | 11087 | wlanFWLoggingInitParam.enableFlag |= WLAN_BMUHW_TRACE_LOG_EN; |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 11088 | } |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 11089 | if(pHddCtx->cfg_ini->enableFwrMemDump && |
| 11090 | (TRUE == sme_IsFeatureSupportedByFW(MEMORY_DUMP_SUPPORTED))) |
| 11091 | { |
Sreelakshmi Konamki | d8784d9 | 2016-04-14 14:59:13 +0530 | [diff] [blame] | 11092 | wlanFWLoggingInitParam.enableFlag |= WLAN_FW_MEM_DUMP_EN; |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 11093 | } |
Sreelakshmi Konamki | d8784d9 | 2016-04-14 14:59:13 +0530 | [diff] [blame] | 11094 | if( wlanFWLoggingInitParam.enableFlag == 0 ) |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 11095 | { |
| 11096 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Logging not enabled", __func__); |
| 11097 | return; |
| 11098 | } |
Sreelakshmi Konamki | d8784d9 | 2016-04-14 14:59:13 +0530 | [diff] [blame] | 11099 | wlanFWLoggingInitParam.frameType = WLAN_FRAME_LOGGING_FRAMETYPE_MGMT; |
| 11100 | wlanFWLoggingInitParam.frameSize = WLAN_MGMT_LOGGING_FRAMESIZE_128BYTES; |
| 11101 | wlanFWLoggingInitParam.bufferMode = WLAN_FRAME_LOGGING_BUFFERMODE_CIRCULAR; |
| 11102 | wlanFWLoggingInitParam.continuousFrameLogging = |
Siddharth Bhal | d1be97f | 2015-05-27 22:39:59 +0530 | [diff] [blame] | 11103 | pHddCtx->cfg_ini->enableContFWLogging; |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 11104 | |
Sreelakshmi Konamki | d8784d9 | 2016-04-14 14:59:13 +0530 | [diff] [blame] | 11105 | wlanFWLoggingInitParam.enableFlag &= ~WLAN_DPU_TXP_LOG_EN; |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 11106 | |
Sreelakshmi Konamki | d8784d9 | 2016-04-14 14:59:13 +0530 | [diff] [blame] | 11107 | wlanFWLoggingInitParam.minLogBufferSize = |
Siddharth Bhal | d1be97f | 2015-05-27 22:39:59 +0530 | [diff] [blame] | 11108 | pHddCtx->cfg_ini->minLoggingBufferSize; |
Sreelakshmi Konamki | d8784d9 | 2016-04-14 14:59:13 +0530 | [diff] [blame] | 11109 | wlanFWLoggingInitParam.maxLogBufferSize = |
Siddharth Bhal | d1be97f | 2015-05-27 22:39:59 +0530 | [diff] [blame] | 11110 | pHddCtx->cfg_ini->maxLoggingBufferSize; |
Sreelakshmi Konamki | d8784d9 | 2016-04-14 14:59:13 +0530 | [diff] [blame] | 11111 | wlanFWLoggingInitParam.fwlogInitCallback = hdd_init_frame_logging_done; |
| 11112 | wlanFWLoggingInitParam.fwlogInitCbContext= pHddCtx; |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 11113 | |
Sreelakshmi Konamki | d8784d9 | 2016-04-14 14:59:13 +0530 | [diff] [blame] | 11114 | halStatus = sme_InitMgmtFrameLogging(pHddCtx->hHal, &wlanFWLoggingInitParam); |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 11115 | |
| 11116 | if (eHAL_STATUS_SUCCESS != halStatus) |
| 11117 | { |
Sreelakshmi Konamki | d8784d9 | 2016-04-14 14:59:13 +0530 | [diff] [blame] | 11118 | hddLog(LOGE, FL("sme_InitMgmtFrameLogging failed, returned %d"), |
| 11119 | halStatus); |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 11120 | } |
| 11121 | |
| 11122 | return; |
| 11123 | } |
Mihir Shete | fc7ff5b | 2014-01-27 11:30:05 +0530 | [diff] [blame] | 11124 | |
Bhargav shah | 23c9494 | 2015-10-13 12:48:35 +0530 | [diff] [blame] | 11125 | static void hdd_dp_util_send_rps_ind(hdd_context_t *hdd_ctxt) |
| 11126 | { |
| 11127 | hdd_adapter_t *adapter; |
| 11128 | hdd_adapter_list_node_t *adapter_node, *next; |
| 11129 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 11130 | struct wlan_rps_data rps_data; |
| 11131 | int count; |
| 11132 | |
| 11133 | if(!hdd_ctxt->cfg_ini->rps_mask) |
| 11134 | { |
| 11135 | return; |
| 11136 | } |
| 11137 | |
| 11138 | for (count=0; count < WLAN_SVC_IFACE_NUM_QUEUES; count++) |
| 11139 | { |
| 11140 | rps_data.cpu_map[count] = hdd_ctxt->cfg_ini->rps_mask; |
| 11141 | } |
| 11142 | |
| 11143 | rps_data.num_queues = WLAN_SVC_IFACE_NUM_QUEUES; |
| 11144 | |
| 11145 | hddLog(LOG1, FL("0x%x 0x%x 0x%x 0x%x 0x%x 0x%x"), |
| 11146 | rps_data.cpu_map[0], rps_data.cpu_map[1],rps_data.cpu_map[2], |
| 11147 | rps_data.cpu_map[3], rps_data.cpu_map[4], rps_data.cpu_map[5]); |
| 11148 | |
| 11149 | status = hdd_get_front_adapter (hdd_ctxt, &adapter_node); |
| 11150 | |
| 11151 | while (NULL != adapter_node && VOS_STATUS_SUCCESS == status) |
| 11152 | { |
| 11153 | adapter = adapter_node->pAdapter; |
| 11154 | if (NULL != adapter) { |
| 11155 | strlcpy(rps_data.ifname, adapter->dev->name, |
| 11156 | sizeof(rps_data.ifname)); |
| 11157 | wlan_hdd_send_svc_nlink_msg(WLAN_MSG_RPS_ENABLE_IND, |
| 11158 | (void *)&rps_data,sizeof(rps_data)); |
| 11159 | } |
| 11160 | status = hdd_get_next_adapter (hdd_ctxt, adapter_node, &next); |
| 11161 | adapter_node = next; |
| 11162 | } |
| 11163 | } |
| 11164 | |
Masti, Narayanraddi | 2637846 | 2016-01-05 18:20:28 +0530 | [diff] [blame] | 11165 | void wlan_hdd_schedule_defer_scan(struct work_struct *work) |
| 11166 | { |
| 11167 | scan_context_t *scan_ctx = |
| 11168 | container_of(work, scan_context_t, scan_work.work); |
| 11169 | |
| 11170 | if (NULL == scan_ctx) |
| 11171 | { |
| 11172 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 11173 | FL("scan_ctx is NULL")); |
| 11174 | return; |
| 11175 | } |
| 11176 | |
| 11177 | if (unlikely(TDLS_CTX_MAGIC != scan_ctx->magic)) |
| 11178 | return; |
| 11179 | |
| 11180 | scan_ctx->attempt++; |
| 11181 | |
| 11182 | wlan_hdd_cfg80211_scan(scan_ctx->wiphy, |
| 11183 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 11184 | scan_ctx->dev, |
| 11185 | #endif |
| 11186 | scan_ctx->scan_request); |
| 11187 | } |
| 11188 | |
| 11189 | int wlan_hdd_copy_defer_scan_context(hdd_context_t *pHddCtx, |
| 11190 | struct wiphy *wiphy, |
| 11191 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 11192 | struct net_device *dev, |
| 11193 | #endif |
| 11194 | struct cfg80211_scan_request *request) |
| 11195 | { |
| 11196 | scan_context_t *scan_ctx; |
| 11197 | |
| 11198 | ENTER(); |
| 11199 | if (0 != (wlan_hdd_validate_context(pHddCtx))) |
| 11200 | { |
| 11201 | return -1; |
| 11202 | } |
| 11203 | |
| 11204 | scan_ctx = &pHddCtx->scan_ctxt; |
| 11205 | |
| 11206 | scan_ctx->wiphy = wiphy; |
| 11207 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 11208 | scan_ctx->dev = dev; |
| 11209 | #endif |
| 11210 | |
| 11211 | scan_ctx->scan_request = request; |
| 11212 | |
| 11213 | EXIT(); |
| 11214 | return 0; |
| 11215 | } |
| 11216 | |
| 11217 | void wlan_hdd_defer_scan_init_work(hdd_context_t *pHddCtx, |
| 11218 | struct wiphy *wiphy, |
| 11219 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 11220 | struct net_device *dev, |
| 11221 | #endif |
| 11222 | struct cfg80211_scan_request *request, |
| 11223 | unsigned long delay) |
| 11224 | { |
| 11225 | if (TDLS_CTX_MAGIC != pHddCtx->scan_ctxt.magic) |
| 11226 | { |
| 11227 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 11228 | wlan_hdd_copy_defer_scan_context(pHddCtx, wiphy, dev, request); |
| 11229 | #else |
| 11230 | wlan_hdd_copy_defer_scan_context(pHddCtx, wiphy, request); |
| 11231 | #endif |
| 11232 | pHddCtx->scan_ctxt.attempt = 0; |
| 11233 | pHddCtx->scan_ctxt.magic = TDLS_CTX_MAGIC; |
| 11234 | } |
| 11235 | schedule_delayed_work(&pHddCtx->scan_ctxt.scan_work, delay); |
| 11236 | } |
| 11237 | |
| 11238 | void wlan_hdd_init_deinit_defer_scan_context(scan_context_t *scan_ctx) |
| 11239 | { |
| 11240 | scan_ctx->magic = 0; |
| 11241 | scan_ctx->attempt = 0; |
| 11242 | scan_ctx->reject = 0; |
| 11243 | scan_ctx->scan_request = NULL; |
| 11244 | |
| 11245 | return; |
| 11246 | } |
| 11247 | |
Mihir Shete | fc7ff5b | 2014-01-27 11:30:05 +0530 | [diff] [blame] | 11248 | /**--------------------------------------------------------------------------- |
| 11249 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11250 | \brief hdd_wlan_startup() - HDD init function |
| 11251 | |
| 11252 | This is the driver startup code executed once a WLAN device has been detected |
| 11253 | |
| 11254 | \param - dev - Pointer to the underlying device |
| 11255 | |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 11256 | \return - 0 for success, < 0 for failure |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11257 | |
| 11258 | --------------------------------------------------------------------------*/ |
| 11259 | |
| 11260 | int hdd_wlan_startup(struct device *dev ) |
| 11261 | { |
| 11262 | VOS_STATUS status; |
| 11263 | hdd_adapter_t *pAdapter = NULL; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 11264 | hdd_adapter_t *pP2pAdapter = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11265 | hdd_context_t *pHddCtx = NULL; |
| 11266 | v_CONTEXT_t pVosContext= NULL; |
| 11267 | #ifdef WLAN_BTAMP_FEATURE |
| 11268 | VOS_STATUS vStatus = VOS_STATUS_SUCCESS; |
| 11269 | WLANBAP_ConfigType btAmpConfig; |
| 11270 | hdd_config_t *pConfig; |
| 11271 | #endif |
| 11272 | int ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11273 | struct wiphy *wiphy; |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 11274 | v_MACADDR_t mac_addr; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11275 | |
| 11276 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11277 | /* |
| 11278 | * cfg80211: wiphy allocation |
| 11279 | */ |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 11280 | wiphy = wlan_hdd_cfg80211_wiphy_alloc(sizeof(hdd_context_t)) ; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11281 | |
| 11282 | if(wiphy == NULL) |
| 11283 | { |
| 11284 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: cfg80211 init failed", __func__); |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 11285 | return -EIO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11286 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11287 | pHddCtx = wiphy_priv(wiphy); |
| 11288 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11289 | //Initialize the adapter context to zeros. |
| 11290 | vos_mem_zero(pHddCtx, sizeof( hdd_context_t )); |
| 11291 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11292 | pHddCtx->wiphy = wiphy; |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 11293 | hdd_prevent_suspend(WIFI_POWER_EVENT_WAKELOCK_DRIVER_INIT); |
Mihir Shete | 1815629 | 2014-03-11 15:38:30 +0530 | [diff] [blame] | 11294 | pHddCtx->isLoadUnloadInProgress = WLAN_HDD_LOAD_IN_PROGRESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11295 | |
| 11296 | vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, TRUE); |
| 11297 | |
Siddharth Bhal | cd92b78 | 2015-06-29 12:25:40 +0530 | [diff] [blame] | 11298 | /* register for riva power on lock to platform driver |
| 11299 | * Locking power early to ensure FW doesn't reset by kernel while |
| 11300 | * host driver is busy initializing itself */ |
| 11301 | if (req_riva_power_on_lock("wlan")) |
| 11302 | { |
| 11303 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: req riva power on lock failed", |
| 11304 | __func__); |
| 11305 | goto err_free_hdd_context; |
| 11306 | } |
| 11307 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11308 | /*Get vos context here bcoz vos_open requires it*/ |
| 11309 | pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL); |
| 11310 | |
Madan Mohan Koyyalamudi | 0b78e15 | 2012-11-28 15:46:51 -0800 | [diff] [blame] | 11311 | if(pVosContext == NULL) |
| 11312 | { |
| 11313 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Failed vos_get_global_context",__func__); |
| 11314 | goto err_free_hdd_context; |
| 11315 | } |
| 11316 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11317 | //Save the Global VOSS context in adapter context for future. |
| 11318 | pHddCtx->pvosContext = pVosContext; |
| 11319 | |
| 11320 | //Save the adapter context in global context for future. |
| 11321 | ((VosContextType*)(pVosContext))->pHDDContext = (v_VOID_t*)pHddCtx; |
| 11322 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11323 | pHddCtx->parent_dev = dev; |
| 11324 | |
| 11325 | init_completion(&pHddCtx->full_pwr_comp_var); |
| 11326 | init_completion(&pHddCtx->standby_comp_var); |
| 11327 | init_completion(&pHddCtx->req_bmps_comp_var); |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 11328 | init_completion(&pHddCtx->scan_info.scan_req_completion_event); |
Madan Mohan Koyyalamudi | f4e8100 | 2012-11-13 10:46:38 -0800 | [diff] [blame] | 11329 | init_completion(&pHddCtx->scan_info.abortscan_event_var); |
Kiet Lam | 46b8e4e | 2013-11-06 21:49:53 +0530 | [diff] [blame] | 11330 | init_completion(&pHddCtx->wiphy_channel_update_event); |
Arun Kumar Khandavalli | e0b046d | 2014-03-01 21:54:25 +0530 | [diff] [blame] | 11331 | init_completion(&pHddCtx->ssr_comp_var); |
Mahesh A Saptasagar | 67ab922 | 2015-10-21 15:38:41 +0530 | [diff] [blame] | 11332 | init_completion(&pHddCtx->mc_sus_event_var); |
| 11333 | init_completion(&pHddCtx->tx_sus_event_var); |
| 11334 | init_completion(&pHddCtx->rx_sus_event_var); |
| 11335 | |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 11336 | |
mukul sharma | 4bd8d2e | 2015-08-13 20:33:25 +0530 | [diff] [blame] | 11337 | hdd_init_ll_stats_ctx(pHddCtx); |
| 11338 | |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 11339 | #ifdef CONFIG_ENABLE_LINUX_REG |
Amar Singhal | fddc28c | 2013-09-05 13:03:40 -0700 | [diff] [blame] | 11340 | init_completion(&pHddCtx->linux_reg_req); |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 11341 | #else |
| 11342 | init_completion(&pHddCtx->driver_crda_req); |
| 11343 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11344 | |
Padma, Santhosh Kumar | a1aa4a3 | 2015-06-19 19:00:46 +0530 | [diff] [blame] | 11345 | #ifdef WLAN_FEATURE_EXTSCAN |
| 11346 | init_completion(&pHddCtx->ext_scan_context.response_event); |
| 11347 | #endif /* WLAN_FEATURE_EXTSCAN */ |
| 11348 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 11349 | spin_lock_init(&pHddCtx->schedScan_lock); |
| 11350 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11351 | hdd_list_init( &pHddCtx->hddAdapters, MAX_NUMBER_OF_ADAPTERS ); |
| 11352 | |
Padma, Santhosh Kumar | 9cd3833 | 2015-11-17 12:18:10 +0530 | [diff] [blame] | 11353 | vos_init_delayed_work(&pHddCtx->spoof_mac_addr_work, |
| 11354 | hdd_processSpoofMacAddrRequest); |
| 11355 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 11356 | #ifdef FEATURE_WLAN_TDLS |
| 11357 | /* tdls_lock is initialized before an hdd_open_adapter ( which is |
| 11358 | * invoked by other instances also) to protect the concurrent |
| 11359 | * access for the Adapters by TDLS module. |
| 11360 | */ |
| 11361 | mutex_init(&pHddCtx->tdls_lock); |
| 11362 | #endif |
Siddharth Bhal | 7697221 | 2014-10-15 16:22:51 +0530 | [diff] [blame] | 11363 | mutex_init(&pHddCtx->spoofMacAddr.macSpoofingLock); |
Mukul Sharma | 1fd6efd | 2015-02-14 00:29:14 +0530 | [diff] [blame] | 11364 | mutex_init(&pHddCtx->wmmLock); |
| 11365 | |
Srinivas Girigowda | 8bf64cb | 2015-09-30 19:50:09 +0530 | [diff] [blame] | 11366 | hdd_init_offloaded_packets_ctx(pHddCtx); |
Agarwal Ashish | 1f42287 | 2014-07-22 00:11:55 +0530 | [diff] [blame] | 11367 | /* By default Strict Regulatory For FCC should be false */ |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 11368 | |
Agarwal Ashish | 1f42287 | 2014-07-22 00:11:55 +0530 | [diff] [blame] | 11369 | pHddCtx->nEnableStrictRegulatoryForFCC = FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11370 | // Load all config first as TL config is needed during vos_open |
| 11371 | pHddCtx->cfg_ini = (hdd_config_t*) kmalloc(sizeof(hdd_config_t), GFP_KERNEL); |
| 11372 | if(pHddCtx->cfg_ini == NULL) |
| 11373 | { |
| 11374 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Failed kmalloc hdd_config_t",__func__); |
| 11375 | goto err_free_hdd_context; |
| 11376 | } |
| 11377 | |
| 11378 | vos_mem_zero(pHddCtx->cfg_ini, sizeof( hdd_config_t )); |
| 11379 | |
| 11380 | // Read and parse the qcom_cfg.ini file |
| 11381 | status = hdd_parse_config_ini( pHddCtx ); |
| 11382 | if ( VOS_STATUS_SUCCESS != status ) |
| 11383 | { |
| 11384 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: error parsing %s", |
| 11385 | __func__, WLAN_INI_FILE); |
| 11386 | goto err_config; |
| 11387 | } |
Arif Hussain | d521891 | 2013-12-05 01:10:55 -0800 | [diff] [blame] | 11388 | #ifdef MEMORY_DEBUG |
| 11389 | if (pHddCtx->cfg_ini->IsMemoryDebugSupportEnabled) |
| 11390 | vos_mem_init(); |
| 11391 | |
| 11392 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: gEnableMemoryDebug=%d", |
| 11393 | __func__, pHddCtx->cfg_ini->IsMemoryDebugSupportEnabled); |
| 11394 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11395 | |
Gopichand Nakkala | b8f0f1a | 2013-05-23 18:19:48 +0530 | [diff] [blame] | 11396 | /* INI has been read, initialise the configuredMcastBcastFilter with |
| 11397 | * INI value as this will serve as the default value |
| 11398 | */ |
| 11399 | pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting; |
| 11400 | hddLog(VOS_TRACE_LEVEL_INFO, "Setting configuredMcastBcastFilter: %d", |
| 11401 | pHddCtx->cfg_ini->mcastBcastFilterSetting); |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 11402 | |
| 11403 | if (false == hdd_is_5g_supported(pHddCtx)) |
| 11404 | { |
| 11405 | //5Ghz is not supported. |
| 11406 | if (1 != pHddCtx->cfg_ini->nBandCapability) |
| 11407 | { |
| 11408 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 11409 | "%s: Setting pHddCtx->cfg_ini->nBandCapability = 1", __func__); |
| 11410 | pHddCtx->cfg_ini->nBandCapability = 1; |
| 11411 | } |
| 11412 | } |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 11413 | |
| 11414 | /* If SNR Monitoring is enabled, FW has to parse all beacons |
| 11415 | * for calcaluting and storing the average SNR, so set Nth beacon |
| 11416 | * filter to 1 to enable FW to parse all the beaocons |
| 11417 | */ |
| 11418 | if (1 == pHddCtx->cfg_ini->fEnableSNRMonitoring) |
| 11419 | { |
| 11420 | /* The log level is deliberately set to WARN as overriding |
| 11421 | * nthBeaconFilter to 1 will increase power cosumption and this |
| 11422 | * might just prove helpful to detect the power issue. |
| 11423 | */ |
| 11424 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 11425 | "%s: Setting pHddCtx->cfg_ini->nthBeaconFilter = 1", __func__); |
| 11426 | pHddCtx->cfg_ini->nthBeaconFilter = 1; |
| 11427 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11428 | /* |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 11429 | * cfg80211: Initialization ... |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11430 | */ |
Manjunathappa Prakash | eec4ddf | 2014-01-13 18:23:51 -0800 | [diff] [blame] | 11431 | if (VOS_FTM_MODE != hdd_get_conparam()) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11432 | { |
Manjunathappa Prakash | eec4ddf | 2014-01-13 18:23:51 -0800 | [diff] [blame] | 11433 | if (0 < wlan_hdd_cfg80211_init(dev, wiphy, pHddCtx->cfg_ini)) |
| 11434 | { |
| 11435 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 11436 | "%s: wlan_hdd_cfg80211_init return failure", __func__); |
| 11437 | goto err_config; |
| 11438 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11439 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11440 | |
Varun Reddy Yeturu | 587e680 | 2013-01-24 12:21:41 -0800 | [diff] [blame] | 11441 | // Update VOS trace levels based upon the cfg.ini |
| 11442 | hdd_vos_trace_enable(VOS_MODULE_ID_BAP, |
| 11443 | pHddCtx->cfg_ini->vosTraceEnableBAP); |
| 11444 | hdd_vos_trace_enable(VOS_MODULE_ID_TL, |
| 11445 | pHddCtx->cfg_ini->vosTraceEnableTL); |
| 11446 | hdd_vos_trace_enable(VOS_MODULE_ID_WDI, |
| 11447 | pHddCtx->cfg_ini->vosTraceEnableWDI); |
| 11448 | hdd_vos_trace_enable(VOS_MODULE_ID_HDD, |
| 11449 | pHddCtx->cfg_ini->vosTraceEnableHDD); |
| 11450 | hdd_vos_trace_enable(VOS_MODULE_ID_SME, |
| 11451 | pHddCtx->cfg_ini->vosTraceEnableSME); |
| 11452 | hdd_vos_trace_enable(VOS_MODULE_ID_PE, |
| 11453 | pHddCtx->cfg_ini->vosTraceEnablePE); |
Katya Nigam | 70d6833 | 2013-09-16 16:49:45 +0530 | [diff] [blame] | 11454 | hdd_vos_trace_enable(VOS_MODULE_ID_PMC, |
| 11455 | pHddCtx->cfg_ini->vosTraceEnablePMC); |
Varun Reddy Yeturu | 587e680 | 2013-01-24 12:21:41 -0800 | [diff] [blame] | 11456 | hdd_vos_trace_enable(VOS_MODULE_ID_WDA, |
| 11457 | pHddCtx->cfg_ini->vosTraceEnableWDA); |
| 11458 | hdd_vos_trace_enable(VOS_MODULE_ID_SYS, |
| 11459 | pHddCtx->cfg_ini->vosTraceEnableSYS); |
| 11460 | hdd_vos_trace_enable(VOS_MODULE_ID_VOSS, |
| 11461 | pHddCtx->cfg_ini->vosTraceEnableVOSS); |
Varun Reddy Yeturu | 587e680 | 2013-01-24 12:21:41 -0800 | [diff] [blame] | 11462 | hdd_vos_trace_enable(VOS_MODULE_ID_SAP, |
| 11463 | pHddCtx->cfg_ini->vosTraceEnableSAP); |
| 11464 | hdd_vos_trace_enable(VOS_MODULE_ID_HDD_SOFTAP, |
| 11465 | pHddCtx->cfg_ini->vosTraceEnableHDDSAP); |
Varun Reddy Yeturu | 587e680 | 2013-01-24 12:21:41 -0800 | [diff] [blame] | 11466 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11467 | // Update WDI trace levels based upon the cfg.ini |
| 11468 | hdd_wdi_trace_enable(eWLAN_MODULE_DAL, |
| 11469 | pHddCtx->cfg_ini->wdiTraceEnableDAL); |
| 11470 | hdd_wdi_trace_enable(eWLAN_MODULE_DAL_CTRL, |
| 11471 | pHddCtx->cfg_ini->wdiTraceEnableCTL); |
| 11472 | hdd_wdi_trace_enable(eWLAN_MODULE_DAL_DATA, |
| 11473 | pHddCtx->cfg_ini->wdiTraceEnableDAT); |
| 11474 | hdd_wdi_trace_enable(eWLAN_MODULE_PAL, |
| 11475 | pHddCtx->cfg_ini->wdiTraceEnablePAL); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11476 | |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 11477 | if (VOS_FTM_MODE == hdd_get_conparam()) |
| 11478 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11479 | if ( VOS_STATUS_SUCCESS != wlan_hdd_ftm_open(pHddCtx) ) |
| 11480 | { |
| 11481 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: wlan_hdd_ftm_open Failed",__func__); |
| 11482 | goto err_free_hdd_context; |
| 11483 | } |
| 11484 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: FTM driver loaded success fully",__func__); |
Sachin Ahuja | 38ef5e0 | 2015-03-13 17:31:16 +0530 | [diff] [blame] | 11485 | pHddCtx->isLoadUnloadInProgress = WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS; |
c_hpothu | 2de0ef6 | 2014-04-15 16:16:15 +0530 | [diff] [blame] | 11486 | vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, FALSE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11487 | return VOS_STATUS_SUCCESS; |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 11488 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11489 | |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 11490 | if( VOS_MONITOR_MODE == hdd_get_conparam()) |
| 11491 | { |
| 11492 | if ( VOS_STATUS_SUCCESS != wlan_hdd_mon_open(pHddCtx)) |
| 11493 | { |
| 11494 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: wlan_hdd_mon_open Failed",__func__); |
| 11495 | goto err_free_hdd_context; |
| 11496 | } |
| 11497 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Driver loaded in Monitor Mode",__func__); |
| 11498 | pHddCtx->isLoadUnloadInProgress = WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS; |
| 11499 | vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, FALSE); |
| 11500 | return VOS_STATUS_SUCCESS; |
| 11501 | } |
| 11502 | |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 11503 | //Open watchdog module |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11504 | if(pHddCtx->cfg_ini->fIsLogpEnabled) |
| 11505 | { |
| 11506 | status = vos_watchdog_open(pVosContext, |
| 11507 | &((VosContextType*)pVosContext)->vosWatchdog, sizeof(VosWatchdogContext)); |
| 11508 | |
| 11509 | if(!VOS_IS_STATUS_SUCCESS( status )) |
| 11510 | { |
| 11511 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: vos_watchdog_open failed",__func__); |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 11512 | goto err_wdclose; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11513 | } |
| 11514 | } |
| 11515 | |
| 11516 | pHddCtx->isLogpInProgress = FALSE; |
| 11517 | vos_set_logp_in_progress(VOS_MODULE_ID_VOSS, FALSE); |
| 11518 | |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 11519 | #ifdef CONFIG_ENABLE_LINUX_REG |
Amar Singhal | 0a40223 | 2013-10-11 20:57:16 -0700 | [diff] [blame] | 11520 | /* initialize the NV module. This is required so that |
| 11521 | we can initialize the channel information in wiphy |
| 11522 | from the NV.bin data. The channel information in |
| 11523 | wiphy needs to be initialized before wiphy registration */ |
| 11524 | |
| 11525 | status = vos_nv_open(); |
| 11526 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 11527 | { |
| 11528 | /* NV module cannot be initialized */ |
| 11529 | hddLog( VOS_TRACE_LEVEL_FATAL, |
| 11530 | "%s: vos_nv_open failed", __func__); |
Vinay Krishna Eranna | 2025d89 | 2014-09-18 16:51:42 +0530 | [diff] [blame] | 11531 | goto err_wdclose; |
Amar Singhal | 0a40223 | 2013-10-11 20:57:16 -0700 | [diff] [blame] | 11532 | } |
| 11533 | |
| 11534 | status = vos_init_wiphy_from_nv_bin(); |
| 11535 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 11536 | { |
| 11537 | /* NV module cannot be initialized */ |
| 11538 | hddLog( VOS_TRACE_LEVEL_FATAL, |
| 11539 | "%s: vos_init_wiphy failed", __func__); |
| 11540 | goto err_vos_nv_close; |
| 11541 | } |
| 11542 | |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 11543 | #endif |
Mahesh A Saptasagar | c3ed012 | 2016-01-19 16:45:11 +0530 | [diff] [blame] | 11544 | //Initialize the nlink service |
| 11545 | if(nl_srv_init() != 0) |
| 11546 | { |
| 11547 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: nl_srv_init failed", __func__); |
| 11548 | goto err_vos_nv_close; |
| 11549 | } |
| 11550 | |
| 11551 | #ifdef WLAN_KD_READY_NOTIFIER |
| 11552 | pHddCtx->kd_nl_init = 1; |
| 11553 | #endif /* WLAN_KD_READY_NOTIFIER */ |
| 11554 | |
Girish Gowli | bf0e1ab | 2015-01-19 16:05:16 +0530 | [diff] [blame] | 11555 | vos_set_roam_delay_stats_enabled(pHddCtx->cfg_ini->gEnableRoamDelayStats); |
Arun Kumar Khandavalli | ebb1948 | 2014-03-25 13:56:53 +0530 | [diff] [blame] | 11556 | status = vos_open( &pVosContext, pHddCtx->parent_dev); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11557 | if ( !VOS_IS_STATUS_SUCCESS( status )) |
| 11558 | { |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 11559 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: vos_open failed", __func__); |
Mahesh A Saptasagar | c3ed012 | 2016-01-19 16:45:11 +0530 | [diff] [blame] | 11560 | goto err_nl_srv; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11561 | } |
| 11562 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11563 | pHddCtx->hHal = (tHalHandle)vos_get_context( VOS_MODULE_ID_SME, pVosContext ); |
| 11564 | |
| 11565 | if ( NULL == pHddCtx->hHal ) |
| 11566 | { |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 11567 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: HAL context is null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11568 | goto err_vosclose; |
| 11569 | } |
| 11570 | |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 11571 | status = vos_preStart( pHddCtx->pvosContext ); |
| 11572 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 11573 | { |
| 11574 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: vos_preStart failed", __func__); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 11575 | goto err_vosclose; |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 11576 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 11577 | |
Arif Hussain | eaf6860 | 2013-12-30 23:10:44 -0800 | [diff] [blame] | 11578 | if (0 == enable_dfs_chan_scan || 1 == enable_dfs_chan_scan) |
| 11579 | { |
| 11580 | pHddCtx->cfg_ini->enableDFSChnlScan = enable_dfs_chan_scan; |
| 11581 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: module enable_dfs_chan_scan set to %d", |
| 11582 | __func__, enable_dfs_chan_scan); |
| 11583 | } |
| 11584 | if (0 == enable_11d || 1 == enable_11d) |
| 11585 | { |
| 11586 | pHddCtx->cfg_ini->Is11dSupportEnabled = enable_11d; |
| 11587 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: module enable_11d set to %d", |
| 11588 | __func__, enable_11d); |
| 11589 | } |
| 11590 | |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 11591 | /* Note that the vos_preStart() sequence triggers the cfg download. |
| 11592 | The cfg download must occur before we update the SME config |
| 11593 | since the SME config operation must access the cfg database */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11594 | status = hdd_set_sme_config( pHddCtx ); |
| 11595 | |
| 11596 | if ( VOS_STATUS_SUCCESS != status ) |
| 11597 | { |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 11598 | 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] | 11599 | goto err_vosclose; |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 11600 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11601 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11602 | /* In the integrated architecture we update the configuration from |
| 11603 | the INI file and from NV before vOSS has been started so that |
| 11604 | the final contents are available to send down to the cCPU */ |
| 11605 | |
| 11606 | // Apply the cfg.ini to cfg.dat |
| 11607 | if (FALSE == hdd_update_config_dat(pHddCtx)) |
| 11608 | { |
| 11609 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: config update failed",__func__ ); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 11610 | goto err_vosclose; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11611 | } |
| 11612 | |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 11613 | // Get mac addr from platform driver |
| 11614 | ret = wcnss_get_wlan_mac_address((char*)&mac_addr.bytes); |
| 11615 | |
| 11616 | if ((0 == ret) && (!vos_is_macaddr_zero(&mac_addr))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11617 | { |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 11618 | /* Store the mac addr for first interface */ |
| 11619 | pHddCtx->cfg_ini->intfMacAddr[0] = mac_addr; |
| 11620 | |
| 11621 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 11622 | "%s: WLAN Mac Addr: " |
| 11623 | MAC_ADDRESS_STR, __func__, |
| 11624 | MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[0].bytes)); |
| 11625 | |
| 11626 | /* Here, passing Arg2 as 1 because we do not want to change the |
| 11627 | last 3 bytes (means non OUI bytes) of first interface mac |
| 11628 | addr. |
| 11629 | */ |
| 11630 | if (0 != hdd_generate_iface_mac_addr_auto(pHddCtx, 1, mac_addr)) |
| 11631 | { |
| 11632 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 11633 | "%s: Failed to generate wlan interface mac addr " |
| 11634 | "using MAC from ini file ", __func__); |
| 11635 | } |
| 11636 | } |
| 11637 | else if (VOS_STATUS_SUCCESS != hdd_update_config_from_nv(pHddCtx)) |
| 11638 | { |
| 11639 | // Apply the NV to cfg.dat |
| 11640 | /* Prima Update MAC address only at here */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11641 | #ifdef WLAN_AUTOGEN_MACADDR_FEATURE |
| 11642 | /* There was not a valid set of MAC Addresses in NV. See if the |
| 11643 | default addresses were modified by the cfg.ini settings. If so, |
| 11644 | we'll use them, but if not, we'll autogenerate a set of MAC |
| 11645 | addresses based upon the device serial number */ |
| 11646 | |
| 11647 | static const v_MACADDR_t default_address = |
| 11648 | {{0x00, 0x0A, 0xF5, 0x89, 0x89, 0xFF}}; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11649 | |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 11650 | if (0 == memcmp(&default_address, &pHddCtx->cfg_ini->intfMacAddr[0], |
| 11651 | sizeof(default_address))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11652 | { |
| 11653 | /* cfg.ini has the default address, invoke autogen logic */ |
| 11654 | |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 11655 | /* Here, passing Arg2 as 0 because we want to change the |
| 11656 | last 3 bytes (means non OUI bytes) of all the interfaces |
| 11657 | mac addr. |
| 11658 | */ |
| 11659 | if (0 != hdd_generate_iface_mac_addr_auto(pHddCtx, 0, |
| 11660 | default_address)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11661 | { |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 11662 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 11663 | "%s: Failed to generate wlan interface mac addr " |
| 11664 | "using MAC from ini file " MAC_ADDRESS_STR, __func__, |
| 11665 | MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[0].bytes)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11666 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11667 | } |
| 11668 | else |
| 11669 | #endif //WLAN_AUTOGEN_MACADDR_FEATURE |
| 11670 | { |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 11671 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11672 | "%s: Invalid MAC address in NV, using MAC from ini file " |
| 11673 | MAC_ADDRESS_STR, __func__, |
| 11674 | MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[0].bytes)); |
| 11675 | } |
| 11676 | } |
| 11677 | { |
| 11678 | eHalStatus halStatus; |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 11679 | |
| 11680 | /* Set the MAC Address Currently this is used by HAL to |
| 11681 | * add self sta. Remove this once self sta is added as |
| 11682 | * part of session open. |
| 11683 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11684 | halStatus = cfgSetStr( pHddCtx->hHal, WNI_CFG_STA_ID, |
| 11685 | (v_U8_t *)&pHddCtx->cfg_ini->intfMacAddr[0], |
| 11686 | sizeof( pHddCtx->cfg_ini->intfMacAddr[0]) ); |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 11687 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11688 | if (!HAL_STATUS_SUCCESS( halStatus )) |
| 11689 | { |
| 11690 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failed to set MAC Address. " |
| 11691 | "HALStatus is %08d [x%08x]",__func__, halStatus, halStatus ); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 11692 | goto err_vosclose; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11693 | } |
| 11694 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11695 | |
| 11696 | /*Start VOSS which starts up the SME/MAC/HAL modules and everything else |
| 11697 | Note: Firmware image will be read and downloaded inside vos_start API */ |
| 11698 | status = vos_start( pHddCtx->pvosContext ); |
| 11699 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 11700 | { |
| 11701 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: vos_start failed",__func__); |
Hanumantha Reddy Pothula | bd9601a | 2016-02-12 13:22:27 +0530 | [diff] [blame] | 11702 | if (isSsrPanicOnFailure()) |
| 11703 | VOS_BUG(0); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 11704 | goto err_vosclose; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11705 | } |
| 11706 | |
Leo Chang | 6cec3e2 | 2014-01-21 15:33:49 -0800 | [diff] [blame] | 11707 | #ifdef FEATURE_WLAN_CH_AVOID |
| 11708 | /* Plug in avoid channel notification callback |
| 11709 | * This should happen before ADD_SELF_STA |
| 11710 | * 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] | 11711 | |
| 11712 | /* check the Channel Avoidance is enabled */ |
| 11713 | if (TRUE == pHddCtx->cfg_ini->fenableCHAvoidance) |
| 11714 | { |
| 11715 | sme_AddChAvoidCallback(pHddCtx->hHal, |
| 11716 | hdd_hostapd_ch_avoid_cb); |
| 11717 | } |
Leo Chang | 6cec3e2 | 2014-01-21 15:33:49 -0800 | [diff] [blame] | 11718 | #endif /* FEATURE_WLAN_CH_AVOID */ |
| 11719 | |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 11720 | /* Exchange capability info between Host and FW and also get versioning info from FW */ |
| 11721 | hdd_exchange_version_and_caps(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11722 | |
Agarwal Ashish | ad9281b | 2014-06-10 14:57:30 +0530 | [diff] [blame] | 11723 | #ifdef CONFIG_ENABLE_LINUX_REG |
| 11724 | status = wlan_hdd_init_channels(pHddCtx); |
| 11725 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 11726 | { |
| 11727 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: wlan_hdd_init_channels failed", |
| 11728 | __func__); |
| 11729 | goto err_vosstop; |
| 11730 | } |
| 11731 | #endif |
| 11732 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11733 | status = hdd_post_voss_start_config( pHddCtx ); |
| 11734 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 11735 | { |
| 11736 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hdd_post_voss_start_config failed", |
| 11737 | __func__); |
| 11738 | goto err_vosstop; |
| 11739 | } |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 11740 | |
| 11741 | #ifndef CONFIG_ENABLE_LINUX_REG |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 11742 | wlan_hdd_cfg80211_update_reg_info( wiphy ); |
| 11743 | |
| 11744 | /* registration of wiphy dev with cfg80211 */ |
| 11745 | if (0 > wlan_hdd_cfg80211_register(wiphy)) |
| 11746 | { |
| 11747 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__); |
| 11748 | goto err_vosstop; |
| 11749 | } |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 11750 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11751 | |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 11752 | #ifdef CONFIG_ENABLE_LINUX_REG |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 11753 | /* registration of wiphy dev with cfg80211 */ |
| 11754 | if (0 > wlan_hdd_cfg80211_register(wiphy)) |
| 11755 | { |
| 11756 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__); |
| 11757 | goto err_vosstop; |
| 11758 | } |
| 11759 | |
Agarwal Ashish | 6db9d53 | 2014-09-30 18:19:10 +0530 | [diff] [blame] | 11760 | status = wlan_hdd_init_channels_for_cc(pHddCtx, INIT); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 11761 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 11762 | { |
| 11763 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: wlan_hdd_init_channels_for_cc failed", |
| 11764 | __func__); |
| 11765 | goto err_unregister_wiphy; |
| 11766 | } |
| 11767 | #endif |
| 11768 | |
c_hpothu | 4a298be | 2014-12-22 21:12:51 +0530 | [diff] [blame] | 11769 | wcnss_wlan_set_drvdata(pHddCtx->parent_dev, pHddCtx); |
| 11770 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11771 | if (VOS_STA_SAP_MODE == hdd_get_conparam()) |
| 11772 | { |
| 11773 | pAdapter = hdd_open_adapter( pHddCtx, WLAN_HDD_SOFTAP, "softap.%d", |
| 11774 | wlan_hdd_get_intf_addr(pHddCtx), FALSE ); |
| 11775 | } |
| 11776 | else |
| 11777 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11778 | pAdapter = hdd_open_adapter( pHddCtx, WLAN_HDD_INFRA_STATION, "wlan%d", |
| 11779 | wlan_hdd_get_intf_addr(pHddCtx), FALSE ); |
| 11780 | if (pAdapter != NULL) |
| 11781 | { |
Katya Nigam | a7d81d7 | 2014-11-12 12:44:34 +0530 | [diff] [blame] | 11782 | 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] | 11783 | { |
Gopichand Nakkala | 49f96f6 | 2013-02-06 14:38:17 +0530 | [diff] [blame] | 11784 | vos_mem_copy( pHddCtx->p2pDeviceAddress.bytes, |
| 11785 | pHddCtx->cfg_ini->intfMacAddr[0].bytes, |
| 11786 | sizeof(tSirMacAddr)); |
Madan Mohan Koyyalamudi | edfc1b7 | 2012-10-18 20:25:55 -0700 | [diff] [blame] | 11787 | |
Gopichand Nakkala | 49f96f6 | 2013-02-06 14:38:17 +0530 | [diff] [blame] | 11788 | /* Generate the P2P Device Address. This consists of the device's |
| 11789 | * primary MAC address with the locally administered bit set. |
| 11790 | */ |
| 11791 | pHddCtx->p2pDeviceAddress.bytes[0] |= 0x02; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 11792 | } |
| 11793 | else |
| 11794 | { |
Gopichand Nakkala | 49f96f6 | 2013-02-06 14:38:17 +0530 | [diff] [blame] | 11795 | tANI_U8* p2p_dev_addr = wlan_hdd_get_intf_addr(pHddCtx); |
| 11796 | if (p2p_dev_addr != NULL) |
| 11797 | { |
| 11798 | vos_mem_copy(&pHddCtx->p2pDeviceAddress.bytes[0], |
| 11799 | p2p_dev_addr, VOS_MAC_ADDR_SIZE); |
| 11800 | } |
| 11801 | else |
| 11802 | { |
| 11803 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 11804 | "%s: Failed to allocate mac_address for p2p_device", |
| 11805 | __func__); |
| 11806 | goto err_close_adapter; |
| 11807 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11808 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 11809 | |
| 11810 | pP2pAdapter = hdd_open_adapter( pHddCtx, WLAN_HDD_P2P_DEVICE, "p2p%d", |
| 11811 | &pHddCtx->p2pDeviceAddress.bytes[0], FALSE ); |
| 11812 | if ( NULL == pP2pAdapter ) |
| 11813 | { |
| 11814 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 11815 | "%s: Failed to do hdd_open_adapter for P2P Device Interface", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 11816 | __func__); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 11817 | goto err_close_adapter; |
| 11818 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 11819 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11820 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11821 | |
| 11822 | if( pAdapter == NULL ) |
| 11823 | { |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 11824 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: hdd_open_adapter failed", __func__); |
| 11825 | goto err_close_adapter; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11826 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 11827 | |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 11828 | if (country_code) |
| 11829 | { |
| 11830 | eHalStatus ret; |
Arif Hussain | cb60708 | 2013-12-20 11:57:42 -0800 | [diff] [blame] | 11831 | INIT_COMPLETION(pAdapter->change_country_code); |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 11832 | hdd_checkandupdate_dfssetting(pAdapter, country_code); |
| 11833 | #ifndef CONFIG_ENABLE_LINUX_REG |
| 11834 | hdd_checkandupdate_phymode(pAdapter, country_code); |
| 11835 | #endif |
Arif Hussain | eaf6860 | 2013-12-30 23:10:44 -0800 | [diff] [blame] | 11836 | ret = sme_ChangeCountryCode(pHddCtx->hHal, |
| 11837 | (void *)(tSmeChangeCountryCallback) |
| 11838 | wlan_hdd_change_country_code_callback, |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 11839 | country_code, |
| 11840 | pAdapter, pHddCtx->pvosContext, |
Abhishek Singh | a306a44 | 2013-11-07 18:39:01 +0530 | [diff] [blame] | 11841 | eSIR_TRUE, eSIR_TRUE); |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 11842 | if (eHAL_STATUS_SUCCESS == ret) |
| 11843 | { |
Arif Hussain | cb60708 | 2013-12-20 11:57:42 -0800 | [diff] [blame] | 11844 | ret = wait_for_completion_interruptible_timeout( |
| 11845 | &pAdapter->change_country_code, |
| 11846 | msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY)); |
| 11847 | |
| 11848 | if (0 >= ret) |
| 11849 | { |
| 11850 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 11851 | "%s: SME while setting country code timed out", __func__); |
| 11852 | } |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 11853 | } |
| 11854 | else |
| 11855 | { |
Arif Hussain | cb60708 | 2013-12-20 11:57:42 -0800 | [diff] [blame] | 11856 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 11857 | "%s: SME Change Country code from module param fail ret=%d", |
| 11858 | __func__, ret); |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 11859 | } |
| 11860 | } |
| 11861 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11862 | #ifdef WLAN_BTAMP_FEATURE |
| 11863 | vStatus = WLANBAP_Open(pVosContext); |
| 11864 | if(!VOS_IS_STATUS_SUCCESS(vStatus)) |
| 11865 | { |
| 11866 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 11867 | "%s: Failed to open BAP",__func__); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 11868 | goto err_close_adapter; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11869 | } |
| 11870 | |
| 11871 | vStatus = BSL_Init(pVosContext); |
| 11872 | if(!VOS_IS_STATUS_SUCCESS(vStatus)) |
| 11873 | { |
| 11874 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 11875 | "%s: Failed to Init BSL",__func__); |
| 11876 | goto err_bap_close; |
| 11877 | } |
| 11878 | vStatus = WLANBAP_Start(pVosContext); |
| 11879 | if (!VOS_IS_STATUS_SUCCESS(vStatus)) |
| 11880 | { |
| 11881 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 11882 | "%s: Failed to start TL",__func__); |
| 11883 | goto err_bap_close; |
| 11884 | } |
| 11885 | |
| 11886 | pConfig = pHddCtx->cfg_ini; |
| 11887 | btAmpConfig.ucPreferredChannel = pConfig->preferredChannel; |
| 11888 | status = WLANBAP_SetConfig(&btAmpConfig); |
| 11889 | |
| 11890 | #endif //WLAN_BTAMP_FEATURE |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 11891 | |
Mihir Shete | 9c23877 | 2014-10-15 14:35:16 +0530 | [diff] [blame] | 11892 | /* |
| 11893 | * UapsdMask is 0xf if U-APSD is enbaled for all AC's... |
| 11894 | * The value of CFG_QOS_WMM_UAPSD_MASK_DEFAULT is 0xaa(Magic Value) |
| 11895 | * which is greater than 0xf. So the below check is safe to make |
| 11896 | * sure that there is no entry for UapsdMask in the ini |
| 11897 | */ |
| 11898 | if (CFG_QOS_WMM_UAPSD_MASK_DEFAULT == pHddCtx->cfg_ini->UapsdMask) |
| 11899 | { |
| 11900 | if(IS_DYNAMIC_WMM_PS_ENABLED) |
| 11901 | { |
| 11902 | hddLog(VOS_TRACE_LEVEL_DEBUG,"%s: Enable UAPSD for VI & VO", |
| 11903 | __func__); |
| 11904 | pHddCtx->cfg_ini->UapsdMask = |
| 11905 | CFG_QOS_WMM_UAPSD_MASK_DYMANIC_WMM_PS_DEFAULT; |
| 11906 | } |
| 11907 | else |
| 11908 | { |
| 11909 | hddLog(VOS_TRACE_LEVEL_DEBUG,"%s: Do not enable UAPSD", |
| 11910 | __func__); |
| 11911 | pHddCtx->cfg_ini->UapsdMask = |
| 11912 | CFG_QOS_WMM_UAPSD_MASK_LEGACY_WMM_PS_DEFAULT; |
| 11913 | } |
| 11914 | } |
| 11915 | |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 11916 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 11917 | if(!(IS_ROAM_SCAN_OFFLOAD_FEATURE_ENABLE)) |
| 11918 | { |
| 11919 | hddLog(VOS_TRACE_LEVEL_DEBUG,"%s: ROAM_SCAN_OFFLOAD Feature not supported",__func__); |
| 11920 | pHddCtx->cfg_ini->isRoamOffloadScanEnabled = 0; |
| 11921 | sme_UpdateRoamScanOffloadEnabled((tHalHandle)(pHddCtx->hHal), |
| 11922 | pHddCtx->cfg_ini->isRoamOffloadScanEnabled); |
| 11923 | } |
| 11924 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11925 | |
Agarwal Ashish | 4b87f92 | 2014-06-18 03:03:21 +0530 | [diff] [blame] | 11926 | wlan_hdd_tdls_init(pHddCtx); |
| 11927 | |
Masti, Narayanraddi | 2637846 | 2016-01-05 18:20:28 +0530 | [diff] [blame] | 11928 | wlan_hdd_init_deinit_defer_scan_context(&pHddCtx->scan_ctxt); |
| 11929 | |
| 11930 | vos_init_delayed_work(&pHddCtx->scan_ctxt.scan_work, |
| 11931 | wlan_hdd_schedule_defer_scan); |
| 11932 | |
Mihir Shete | fc7ff5b | 2014-01-27 11:30:05 +0530 | [diff] [blame] | 11933 | sme_Register11dScanDoneCallback(pHddCtx->hHal, hdd_11d_scan_done); |
| 11934 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11935 | /* Register with platform driver as client for Suspend/Resume */ |
| 11936 | status = hddRegisterPmOps(pHddCtx); |
| 11937 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 11938 | { |
| 11939 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddRegisterPmOps failed",__func__); |
| 11940 | #ifdef WLAN_BTAMP_FEATURE |
| 11941 | goto err_bap_stop; |
| 11942 | #else |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 11943 | goto err_close_adapter; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11944 | #endif //WLAN_BTAMP_FEATURE |
| 11945 | } |
| 11946 | |
Yue Ma | 0d4891e | 2013-08-06 17:01:45 -0700 | [diff] [blame] | 11947 | /* Open debugfs interface */ |
| 11948 | if (VOS_STATUS_SUCCESS != hdd_debugfs_init(pAdapter)) |
| 11949 | { |
| 11950 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 11951 | "%s: hdd_debugfs_init failed!", __func__); |
Yue Ma | 0d4891e | 2013-08-06 17:01:45 -0700 | [diff] [blame] | 11952 | } |
| 11953 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11954 | /* Register TM level change handler function to the platform */ |
| 11955 | status = hddDevTmRegisterNotifyCallback(pHddCtx); |
| 11956 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 11957 | { |
| 11958 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddDevTmRegisterNotifyCallback failed",__func__); |
| 11959 | goto err_unregister_pmops; |
| 11960 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11961 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11962 | // register net device notifier for device change notification |
| 11963 | ret = register_netdevice_notifier(&hdd_netdev_notifier); |
| 11964 | |
| 11965 | if(ret < 0) |
| 11966 | { |
| 11967 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: register_netdevice_notifier failed",__func__); |
Siddharth Bhal | cd92b78 | 2015-06-29 12:25:40 +0530 | [diff] [blame] | 11968 | goto err_unregister_pmops; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11969 | } |
| 11970 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11971 | //Initialize the BTC service |
| 11972 | if(btc_activate_service(pHddCtx) != 0) |
| 11973 | { |
| 11974 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: btc_activate_service failed",__func__); |
Mahesh A Saptasagar | c3ed012 | 2016-01-19 16:45:11 +0530 | [diff] [blame] | 11975 | goto err_reg_netdev; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11976 | } |
| 11977 | |
Padma, Santhosh Kumar | 2762e9d | 2015-10-20 15:02:57 +0530 | [diff] [blame] | 11978 | #ifdef FEATURE_OEM_DATA_SUPPORT |
| 11979 | //Initialize the OEM service |
| 11980 | if (oem_activate_service(pHddCtx) != 0) |
| 11981 | { |
| 11982 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 11983 | "%s: oem_activate_service failed", __func__); |
Mahesh A Saptasagar | c3ed012 | 2016-01-19 16:45:11 +0530 | [diff] [blame] | 11984 | goto err_reg_netdev; |
Padma, Santhosh Kumar | 2762e9d | 2015-10-20 15:02:57 +0530 | [diff] [blame] | 11985 | } |
| 11986 | #endif |
| 11987 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11988 | #ifdef PTT_SOCK_SVC_ENABLE |
| 11989 | //Initialize the PTT service |
| 11990 | if(ptt_sock_activate_svc(pHddCtx) != 0) |
| 11991 | { |
| 11992 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: ptt_sock_activate_svc failed",__func__); |
Mahesh A Saptasagar | c3ed012 | 2016-01-19 16:45:11 +0530 | [diff] [blame] | 11993 | goto err_reg_netdev; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11994 | } |
| 11995 | #endif |
| 11996 | |
Abhishek Singh | 00b7197 | 2016-01-07 10:51:04 +0530 | [diff] [blame] | 11997 | #ifdef WLAN_FEATURE_RMC |
| 11998 | if (hdd_open_cesium_nl_sock() < 0) |
| 11999 | { |
| 12000 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hdd_open_cesium_nl_sock failed", __func__); |
| 12001 | goto err_reg_netdev; |
| 12002 | } |
| 12003 | #endif |
| 12004 | |
Vinay Krishna Eranna | d938c42 | 2014-03-10 17:14:21 +0530 | [diff] [blame] | 12005 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 12006 | if(pHddCtx->cfg_ini && pHddCtx->cfg_ini->wlanLoggingEnable) |
| 12007 | { |
Deepthi Gowri | 78083a3 | 2014-11-04 12:55:51 +0530 | [diff] [blame] | 12008 | if(wlan_logging_sock_activate_svc( |
| 12009 | pHddCtx->cfg_ini->wlanLoggingFEToConsole, |
Sushant Kaushik | 3320057 | 2015-08-05 16:46:20 +0530 | [diff] [blame] | 12010 | pHddCtx->cfg_ini->wlanLoggingNumBuf, |
| 12011 | pHddCtx->cfg_ini->wlanPerPktStatsLogEnable, |
| 12012 | pHddCtx->cfg_ini->wlanPerPktStatsNumBuf)) |
Deepthi Gowri | 78083a3 | 2014-11-04 12:55:51 +0530 | [diff] [blame] | 12013 | { |
| 12014 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wlan_logging_sock_activate_svc" |
| 12015 | " failed", __func__); |
Mahesh A Saptasagar | c3ed012 | 2016-01-19 16:45:11 +0530 | [diff] [blame] | 12016 | goto err_reg_netdev; |
Deepthi Gowri | 78083a3 | 2014-11-04 12:55:51 +0530 | [diff] [blame] | 12017 | } |
| 12018 | //TODO: To Remove enableDhcpDebug and use gEnableDebugLog for |
| 12019 | //EAPOL and DHCP |
Sachin Ahuja | 8c65f38 | 2014-12-12 15:34:21 +0530 | [diff] [blame] | 12020 | if (!pHddCtx->cfg_ini->gEnableDebugLog) |
| 12021 | pHddCtx->cfg_ini->gEnableDebugLog = |
Sushant Kaushik | 6e4e2bc | 2015-10-05 17:23:07 +0530 | [diff] [blame] | 12022 | VOS_PKT_PROTO_TYPE_EAPOL | VOS_PKT_PROTO_TYPE_DHCP | |
| 12023 | VOS_PKT_PROTO_TYPE_ARP; |
Vinay Krishna Eranna | d938c42 | 2014-03-10 17:14:21 +0530 | [diff] [blame] | 12024 | } |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 12025 | |
Siddharth Bhal | d1be97f | 2015-05-27 22:39:59 +0530 | [diff] [blame] | 12026 | if (pHddCtx->cfg_ini->wlanLoggingEnable && |
| 12027 | (pHddCtx->cfg_ini->enableFWLogging || |
Siddharth Bhal | db96323 | 2015-06-25 19:34:35 +0530 | [diff] [blame] | 12028 | pHddCtx->cfg_ini->enableMgmtLogging || |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 12029 | pHddCtx->cfg_ini->enableContFWLogging || |
| 12030 | pHddCtx->cfg_ini->enableFwrMemDump ) |
| 12031 | ) |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 12032 | { |
Siddharth Bhal | d1be97f | 2015-05-27 22:39:59 +0530 | [diff] [blame] | 12033 | hdd_init_frame_logging(pHddCtx); |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 12034 | } |
| 12035 | else |
| 12036 | { |
Siddharth Bhal | d1be97f | 2015-05-27 22:39:59 +0530 | [diff] [blame] | 12037 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Logging disabled in ini")); |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 12038 | } |
| 12039 | |
Vinay Krishna Eranna | d938c42 | 2014-03-10 17:14:21 +0530 | [diff] [blame] | 12040 | #endif |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 12041 | |
| 12042 | |
Sushant Kaushik | 215778f | 2015-05-21 14:05:36 +0530 | [diff] [blame] | 12043 | if (vos_is_multicast_logging()) |
| 12044 | wlan_logging_set_log_level(); |
| 12045 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12046 | hdd_register_mcast_bcast_filter(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12047 | if (VOS_STA_SAP_MODE != hdd_get_conparam()) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12048 | { |
Madan Mohan Koyyalamudi | c537df2 | 2012-10-22 15:07:08 -0700 | [diff] [blame] | 12049 | /* Action frame registered in one adapter which will |
| 12050 | * applicable to all interfaces |
| 12051 | */ |
Agarwal Ashish | 8fa0e9a | 2014-05-23 00:40:12 +0530 | [diff] [blame] | 12052 | wlan_hdd_cfg80211_register_frames(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12053 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12054 | |
| 12055 | mutex_init(&pHddCtx->sap_lock); |
Mahesh A Saptasagar | 6062794 | 2014-10-13 13:55:14 +0530 | [diff] [blame] | 12056 | mutex_init(&pHddCtx->roc_lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12057 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 12058 | #ifdef WLAN_FEATURE_HOLD_RX_WAKELOCK |
| 12059 | /* Initialize the wake lcok */ |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 12060 | vos_wake_lock_init(&pHddCtx->rx_wake_lock, |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 12061 | "qcom_rx_wakelock"); |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 12062 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 12063 | #endif |
Madan Mohan Koyyalamudi | 69fc3ad | 2012-11-28 16:04:56 -0800 | [diff] [blame] | 12064 | /* Initialize the wake lcok */ |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 12065 | vos_wake_lock_init(&pHddCtx->sap_wake_lock, |
Madan Mohan Koyyalamudi | 69fc3ad | 2012-11-28 16:04:56 -0800 | [diff] [blame] | 12066 | "qcom_sap_wakelock"); |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 12067 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 12068 | |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 12069 | vos_event_init(&pHddCtx->scan_info.scan_finished_event); |
| 12070 | pHddCtx->scan_info.scan_pending_option = WEXT_SCAN_PENDING_GIVEUP; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12071 | |
Katya Nigam | 5c306ea | 2014-06-19 15:39:54 +0530 | [diff] [blame] | 12072 | pHddCtx->isLoadUnloadInProgress = WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12073 | vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, FALSE); |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 12074 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_DRIVER_INIT); |
Katya Nigam | 5c306ea | 2014-06-19 15:39:54 +0530 | [diff] [blame] | 12075 | |
| 12076 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 12077 | /*SME must send channel update configuration to RIVA*/ |
| 12078 | sme_UpdateChannelConfig(pHddCtx->hHal); |
| 12079 | #endif |
Abhishek Singh | f644b27 | 2014-08-21 02:59:39 +0530 | [diff] [blame] | 12080 | /* Send the update default channel list to the FW*/ |
| 12081 | sme_UpdateChannelList(pHddCtx->hHal); |
Mukul Sharma | 4506394 | 2015-04-01 20:07:59 +0530 | [diff] [blame] | 12082 | |
| 12083 | /* Fwr capabilities received, Set the Dot11 mode */ |
Abhishek Singh | 41ebce1 | 2016-02-03 10:43:21 +0530 | [diff] [blame] | 12084 | sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 12085 | hdd_cfg_xlate_to_csr_phy_mode(pHddCtx->cfg_ini->dot11Mode)); |
Mukul Sharma | 4506394 | 2015-04-01 20:07:59 +0530 | [diff] [blame] | 12086 | sme_SetDefDot11Mode(pHddCtx->hHal); |
| 12087 | |
Abhishek Singh | a306a44 | 2013-11-07 18:39:01 +0530 | [diff] [blame] | 12088 | #ifndef CONFIG_ENABLE_LINUX_REG |
| 12089 | /*updating wiphy so that regulatory user hints can be processed*/ |
| 12090 | if (wiphy) |
| 12091 | { |
| 12092 | regulatory_hint(wiphy, "00"); |
| 12093 | } |
| 12094 | #endif |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 12095 | // Initialize the restart logic |
| 12096 | wlan_hdd_restart_init(pHddCtx); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 12097 | |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 12098 | //Register the traffic monitor timer now |
| 12099 | if ( pHddCtx->cfg_ini->dynSplitscan) |
| 12100 | { |
| 12101 | vos_timer_init(&pHddCtx->tx_rx_trafficTmr, |
| 12102 | VOS_TIMER_TYPE_SW, |
| 12103 | hdd_tx_rx_pkt_cnt_stat_timer_handler, |
| 12104 | (void *)pHddCtx); |
| 12105 | } |
Srinivas Dasari | 030bad3 | 2015-02-18 23:23:54 +0530 | [diff] [blame] | 12106 | wlan_hdd_cfg80211_nan_init(pHddCtx); |
| 12107 | |
Bhargav Shah | d071591 | 2015-10-01 18:17:37 +0530 | [diff] [blame] | 12108 | mutex_init(&pHddCtx->cur_rx_level_lock); |
| 12109 | vos_timer_init(&pHddCtx->delack_timer, VOS_TIMER_TYPE_SW, |
| 12110 | hdd_tcp_delack_compute_function,(void *)pHddCtx); |
Masti, Narayanraddi | 44b0db0 | 2015-12-22 11:54:35 +0530 | [diff] [blame] | 12111 | vos_timer_init(&pHddCtx->tdls_source_timer, VOS_TIMER_TYPE_SW, |
| 12112 | wlan_hdd_change_tdls_mode, (void *)pHddCtx); |
Bhargav Shah | d071591 | 2015-10-01 18:17:37 +0530 | [diff] [blame] | 12113 | |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 12114 | #ifdef WLAN_FEATURE_EXTSCAN |
| 12115 | sme_EXTScanRegisterCallback(pHddCtx->hHal, |
| 12116 | wlan_hdd_cfg80211_extscan_callback, |
| 12117 | pHddCtx); |
| 12118 | #endif /* WLAN_FEATURE_EXTSCAN */ |
Vinay Krishna Eranna | f97ef5c | 2014-12-26 17:47:19 +0530 | [diff] [blame] | 12119 | |
Padma, Santhosh Kumar | 2ccac21 | 2015-10-20 17:27:27 +0530 | [diff] [blame] | 12120 | #ifdef FEATURE_OEM_DATA_SUPPORT |
| 12121 | sme_OemDataRegisterCallback(pHddCtx->hHal, |
| 12122 | wlan_hdd_cfg80211_oemdata_callback, |
| 12123 | pHddCtx); |
| 12124 | #endif /* FEATURE_OEM_DATA_SUPPORT */ |
| 12125 | |
Gupta, Kapil | 7c34b32 | 2015-09-30 13:12:35 +0530 | [diff] [blame] | 12126 | sme_set_rssi_threshold_breached_cb(pHddCtx->hHal, hdd_rssi_threshold_breached_cb); |
Vinay Krishna Eranna | f97ef5c | 2014-12-26 17:47:19 +0530 | [diff] [blame] | 12127 | #ifdef WLAN_NS_OFFLOAD |
| 12128 | // Register IPv6 notifier to notify if any change in IP |
| 12129 | // So that we can reconfigure the offload parameters |
| 12130 | pHddCtx->ipv6_notifier.notifier_call = wlan_hdd_ipv6_changed; |
| 12131 | ret = register_inet6addr_notifier(&pHddCtx->ipv6_notifier); |
| 12132 | if (ret) |
| 12133 | { |
Ratheesh S P | 36dbc93 | 2015-08-07 14:28:57 +0530 | [diff] [blame] | 12134 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to register IPv6 notifier")); |
Vinay Krishna Eranna | f97ef5c | 2014-12-26 17:47:19 +0530 | [diff] [blame] | 12135 | } |
| 12136 | else |
| 12137 | { |
Ratheesh S P | 36dbc93 | 2015-08-07 14:28:57 +0530 | [diff] [blame] | 12138 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Registered IPv6 notifier")); |
Vinay Krishna Eranna | f97ef5c | 2014-12-26 17:47:19 +0530 | [diff] [blame] | 12139 | } |
| 12140 | #endif |
| 12141 | |
| 12142 | // Register IPv4 notifier to notify if any change in IP |
| 12143 | // So that we can reconfigure the offload parameters |
| 12144 | pHddCtx->ipv4_notifier.notifier_call = wlan_hdd_ipv4_changed; |
| 12145 | ret = register_inetaddr_notifier(&pHddCtx->ipv4_notifier); |
| 12146 | if (ret) |
| 12147 | { |
Ratheesh S P | 36dbc93 | 2015-08-07 14:28:57 +0530 | [diff] [blame] | 12148 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to register IPv4 notifier")); |
Vinay Krishna Eranna | f97ef5c | 2014-12-26 17:47:19 +0530 | [diff] [blame] | 12149 | } |
| 12150 | else |
| 12151 | { |
Ratheesh S P | 36dbc93 | 2015-08-07 14:28:57 +0530 | [diff] [blame] | 12152 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Registered IPv4 notifier")); |
Vinay Krishna Eranna | f97ef5c | 2014-12-26 17:47:19 +0530 | [diff] [blame] | 12153 | } |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 12154 | /*Fw mem dump procfs initialization*/ |
| 12155 | memdump_init(); |
Bhargav shah | 23c9494 | 2015-10-13 12:48:35 +0530 | [diff] [blame] | 12156 | hdd_dp_util_send_rps_ind(pHddCtx); |
Vinay Krishna Eranna | f97ef5c | 2014-12-26 17:47:19 +0530 | [diff] [blame] | 12157 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12158 | goto success; |
| 12159 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12160 | err_reg_netdev: |
| 12161 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 12162 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12163 | err_unregister_pmops: |
| 12164 | hddDevTmUnregisterNotifyCallback(pHddCtx); |
| 12165 | hddDeregisterPmOps(pHddCtx); |
| 12166 | |
Yue Ma | 0d4891e | 2013-08-06 17:01:45 -0700 | [diff] [blame] | 12167 | hdd_debugfs_exit(pHddCtx); |
| 12168 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12169 | #ifdef WLAN_BTAMP_FEATURE |
| 12170 | err_bap_stop: |
| 12171 | WLANBAP_Stop(pVosContext); |
| 12172 | #endif |
| 12173 | |
| 12174 | #ifdef WLAN_BTAMP_FEATURE |
| 12175 | err_bap_close: |
| 12176 | WLANBAP_Close(pVosContext); |
| 12177 | #endif |
| 12178 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12179 | err_close_adapter: |
| 12180 | hdd_close_all_adapters( pHddCtx ); |
Mahesh A Saptasagar | 9ecefe4 | 2014-07-15 18:43:49 +0530 | [diff] [blame] | 12181 | #ifdef CONFIG_ENABLE_LINUX_REG |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 12182 | err_unregister_wiphy: |
Mahesh A Saptasagar | 9ecefe4 | 2014-07-15 18:43:49 +0530 | [diff] [blame] | 12183 | #endif |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 12184 | wiphy_unregister(wiphy) ; |
Agrawal Ashish | 33ec71e | 2015-11-26 20:20:58 +0530 | [diff] [blame] | 12185 | hdd_wlan_free_wiphy_channels(wiphy); |
| 12186 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12187 | err_vosstop: |
| 12188 | vos_stop(pVosContext); |
| 12189 | |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 12190 | err_vosclose: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12191 | status = vos_sched_close( pVosContext ); |
| 12192 | if (!VOS_IS_STATUS_SUCCESS(status)) { |
| 12193 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, |
| 12194 | "%s: Failed to close VOSS Scheduler", __func__); |
| 12195 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( status ) ); |
| 12196 | } |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 12197 | vos_close(pVosContext ); |
| 12198 | |
Mahesh A Saptasagar | c3ed012 | 2016-01-19 16:45:11 +0530 | [diff] [blame] | 12199 | err_nl_srv: |
| 12200 | #ifdef WLAN_KD_READY_NOTIFIER |
| 12201 | nl_srv_exit(pHddCtx->ptt_pid); |
| 12202 | #else |
| 12203 | nl_srv_exit(); |
| 12204 | #endif /* WLAN_KD_READY_NOTIFIER */ |
Amar Singhal | 0a40223 | 2013-10-11 20:57:16 -0700 | [diff] [blame] | 12205 | err_vos_nv_close: |
| 12206 | |
c_hpothu | e6a3628 | 2014-03-19 12:27:38 +0530 | [diff] [blame] | 12207 | #ifdef CONFIG_ENABLE_LINUX_REG |
Amar Singhal | 0a40223 | 2013-10-11 20:57:16 -0700 | [diff] [blame] | 12208 | vos_nv_close(); |
| 12209 | |
c_hpothu | 70f8d81 | 2014-03-22 22:59:23 +0530 | [diff] [blame] | 12210 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12211 | |
| 12212 | err_wdclose: |
| 12213 | if(pHddCtx->cfg_ini->fIsLogpEnabled) |
| 12214 | vos_watchdog_close(pVosContext); |
| 12215 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12216 | err_config: |
| 12217 | kfree(pHddCtx->cfg_ini); |
| 12218 | pHddCtx->cfg_ini= NULL; |
| 12219 | |
| 12220 | err_free_hdd_context: |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 12221 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_DRIVER_INIT); |
Siddharth Bhal | cd92b78 | 2015-06-29 12:25:40 +0530 | [diff] [blame] | 12222 | free_riva_power_on_lock("wlan"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12223 | wiphy_free(wiphy) ; |
| 12224 | //kfree(wdev) ; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12225 | VOS_BUG(1); |
| 12226 | |
Madan Mohan Koyyalamudi | d57ae63 | 2012-11-06 18:42:48 -0800 | [diff] [blame] | 12227 | if (hdd_is_ssr_required()) |
| 12228 | { |
| 12229 | /* WDI timeout had happened during load, so SSR is needed here */ |
| 12230 | subsystem_restart("wcnss"); |
| 12231 | msleep(5000); |
| 12232 | } |
| 12233 | hdd_set_ssr_required (VOS_FALSE); |
| 12234 | |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 12235 | return -EIO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12236 | |
| 12237 | success: |
| 12238 | EXIT(); |
| 12239 | return 0; |
| 12240 | } |
| 12241 | |
| 12242 | /**--------------------------------------------------------------------------- |
| 12243 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 12244 | \brief hdd_driver_init() - Core Driver Init Function |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12245 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 12246 | This is the driver entry point - called in different timeline depending |
| 12247 | on whether the driver is statically or dynamically linked |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12248 | |
| 12249 | \param - None |
| 12250 | |
| 12251 | \return - 0 for success, non zero for failure |
| 12252 | |
| 12253 | --------------------------------------------------------------------------*/ |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 12254 | static int hdd_driver_init( void) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12255 | { |
| 12256 | VOS_STATUS status; |
| 12257 | v_CONTEXT_t pVosContext = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12258 | struct device *dev = NULL; |
| 12259 | int ret_status = 0; |
Sameer Thalappil | f58d7ec | 2013-04-25 20:17:12 -0700 | [diff] [blame] | 12260 | #ifdef HAVE_WCNSS_CAL_DOWNLOAD |
| 12261 | int max_retries = 0; |
| 12262 | #endif |
Siddharth Bhal | c7e79b6 | 2014-10-10 22:37:38 +0530 | [diff] [blame] | 12263 | #ifdef HAVE_CBC_DONE |
| 12264 | int max_cbc_retries = 0; |
| 12265 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12266 | |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 12267 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 12268 | wlan_logging_sock_init_svc(); |
| 12269 | #endif |
| 12270 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12271 | ENTER(); |
| 12272 | |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 12273 | vos_wake_lock_init(&wlan_wake_lock, "wlan"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12274 | |
| 12275 | pr_info("%s: loading driver v%s\n", WLAN_MODULE_NAME, |
| 12276 | QWLAN_VERSIONSTR TIMER_MANAGER_STR MEMORY_DEBUG_STR); |
| 12277 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12278 | #ifdef ANI_BUS_TYPE_PCI |
| 12279 | |
| 12280 | dev = wcnss_wlan_get_device(); |
| 12281 | |
| 12282 | #endif // ANI_BUS_TYPE_PCI |
| 12283 | |
| 12284 | #ifdef ANI_BUS_TYPE_PLATFORM |
Sameer Thalappil | f58d7ec | 2013-04-25 20:17:12 -0700 | [diff] [blame] | 12285 | |
| 12286 | #ifdef HAVE_WCNSS_CAL_DOWNLOAD |
| 12287 | /* wait until WCNSS driver downloads NV */ |
| 12288 | while (!wcnss_device_ready() && 5 >= ++max_retries) { |
| 12289 | msleep(1000); |
| 12290 | } |
Siddharth Bhal | c7e79b6 | 2014-10-10 22:37:38 +0530 | [diff] [blame] | 12291 | |
Sameer Thalappil | f58d7ec | 2013-04-25 20:17:12 -0700 | [diff] [blame] | 12292 | if (max_retries >= 5) { |
| 12293 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: WCNSS driver not ready", __func__); |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 12294 | vos_wake_lock_destroy(&wlan_wake_lock); |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 12295 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 12296 | wlan_logging_sock_deinit_svc(); |
| 12297 | #endif |
| 12298 | |
Sameer Thalappil | f58d7ec | 2013-04-25 20:17:12 -0700 | [diff] [blame] | 12299 | return -ENODEV; |
| 12300 | } |
| 12301 | #endif |
| 12302 | |
Siddharth Bhal | c7e79b6 | 2014-10-10 22:37:38 +0530 | [diff] [blame] | 12303 | #ifdef HAVE_CBC_DONE |
| 12304 | while (!wcnss_cbc_complete() && 10 >= ++max_cbc_retries) { |
| 12305 | msleep(1000); |
| 12306 | } |
| 12307 | if (max_cbc_retries >= 10) { |
| 12308 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s:CBC not completed", __func__); |
| 12309 | } |
| 12310 | #endif |
| 12311 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12312 | dev = wcnss_wlan_get_device(); |
| 12313 | #endif // ANI_BUS_TYPE_PLATFORM |
| 12314 | |
| 12315 | |
| 12316 | do { |
| 12317 | if (NULL == dev) { |
| 12318 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: WLAN device not found!!",__func__); |
| 12319 | ret_status = -1; |
| 12320 | break; |
| 12321 | } |
| 12322 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12323 | #ifdef TIMER_MANAGER |
| 12324 | vos_timer_manager_init(); |
| 12325 | #endif |
| 12326 | |
| 12327 | /* Preopen VOSS so that it is ready to start at least SAL */ |
| 12328 | status = vos_preOpen(&pVosContext); |
| 12329 | |
| 12330 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 12331 | { |
| 12332 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Failed to preOpen VOSS", __func__); |
| 12333 | ret_status = -1; |
| 12334 | break; |
| 12335 | } |
| 12336 | |
Sushant Kaushik | 02beb35 | 2015-06-04 15:15:01 +0530 | [diff] [blame] | 12337 | hddTraceInit(); |
Padma, Santhosh Kumar | 9093b20 | 2015-07-21 15:37:38 +0530 | [diff] [blame] | 12338 | hdd_register_debug_callback(); |
| 12339 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 12340 | #ifndef MODULE |
| 12341 | /* For statically linked driver, call hdd_set_conparam to update curr_con_mode |
| 12342 | */ |
| 12343 | hdd_set_conparam((v_UINT_t)con_mode); |
| 12344 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12345 | |
| 12346 | // Call our main init function |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 12347 | if (hdd_wlan_startup(dev)) |
| 12348 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12349 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: WLAN Driver Initialization failed", |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 12350 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12351 | vos_preClose( &pVosContext ); |
| 12352 | ret_status = -1; |
| 12353 | break; |
| 12354 | } |
| 12355 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12356 | } while (0); |
| 12357 | |
| 12358 | if (0 != ret_status) |
| 12359 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12360 | #ifdef TIMER_MANAGER |
| 12361 | vos_timer_exit(); |
| 12362 | #endif |
| 12363 | #ifdef MEMORY_DEBUG |
| 12364 | vos_mem_exit(); |
| 12365 | #endif |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 12366 | vos_wake_lock_destroy(&wlan_wake_lock); |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 12367 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 12368 | wlan_logging_sock_deinit_svc(); |
| 12369 | #endif |
| 12370 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12371 | pr_err("%s: driver load failure\n", WLAN_MODULE_NAME); |
| 12372 | } |
| 12373 | else |
| 12374 | { |
| 12375 | //Send WLAN UP indication to Nlink Service |
| 12376 | send_btc_nlink_msg(WLAN_MODULE_UP_IND, 0); |
| 12377 | |
| 12378 | pr_info("%s: driver loaded\n", WLAN_MODULE_NAME); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12379 | } |
| 12380 | |
| 12381 | EXIT(); |
| 12382 | |
| 12383 | return ret_status; |
| 12384 | } |
| 12385 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 12386 | /**--------------------------------------------------------------------------- |
| 12387 | |
| 12388 | \brief hdd_module_init() - Init Function |
| 12389 | |
| 12390 | This is the driver entry point (invoked when module is loaded using insmod) |
| 12391 | |
| 12392 | \param - None |
| 12393 | |
| 12394 | \return - 0 for success, non zero for failure |
| 12395 | |
| 12396 | --------------------------------------------------------------------------*/ |
| 12397 | #ifdef MODULE |
| 12398 | static int __init hdd_module_init ( void) |
| 12399 | { |
| 12400 | return hdd_driver_init(); |
| 12401 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 12402 | #else /* #ifdef MODULE */ |
| 12403 | static int __init hdd_module_init ( void) |
| 12404 | { |
| 12405 | /* Driver initialization is delayed to fwpath_changed_handler */ |
| 12406 | return 0; |
| 12407 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 12408 | #endif /* #ifdef MODULE */ |
| 12409 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12410 | |
| 12411 | /**--------------------------------------------------------------------------- |
| 12412 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 12413 | \brief hdd_driver_exit() - Exit function |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12414 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 12415 | This is the driver exit point (invoked when module is unloaded using rmmod |
| 12416 | or con_mode was changed by userspace) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12417 | |
| 12418 | \param - None |
| 12419 | |
| 12420 | \return - None |
| 12421 | |
| 12422 | --------------------------------------------------------------------------*/ |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 12423 | static void hdd_driver_exit(void) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12424 | { |
| 12425 | hdd_context_t *pHddCtx = NULL; |
| 12426 | v_CONTEXT_t pVosContext = NULL; |
Agarwal Ashish | 5e41479 | 2014-06-08 15:25:23 +0530 | [diff] [blame] | 12427 | v_REGDOMAIN_t regId; |
Arun Kumar Khandavalli | e0b046d | 2014-03-01 21:54:25 +0530 | [diff] [blame] | 12428 | unsigned long rc = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12429 | |
| 12430 | pr_info("%s: unloading driver v%s\n", WLAN_MODULE_NAME, QWLAN_VERSIONSTR); |
| 12431 | |
| 12432 | //Get the global vos context |
| 12433 | pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL); |
| 12434 | |
| 12435 | if(!pVosContext) |
| 12436 | { |
| 12437 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Global VOS context is Null", __func__); |
| 12438 | goto done; |
| 12439 | } |
| 12440 | |
| 12441 | //Get the HDD context. |
| 12442 | pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext ); |
| 12443 | |
| 12444 | if(!pHddCtx) |
| 12445 | { |
| 12446 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: module exit called before probe",__func__); |
| 12447 | } |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 12448 | else if (VOS_MONITOR_MODE == hdd_get_conparam()) |
| 12449 | { |
| 12450 | hddLog(VOS_TRACE_LEVEL_INFO,"%s: MONITOR MODE",__func__); |
| 12451 | pHddCtx->isLoadUnloadInProgress = WLAN_HDD_UNLOAD_IN_PROGRESS; |
| 12452 | vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, TRUE); |
| 12453 | hdd_wlan_exit(pHddCtx); |
| 12454 | vos_preClose( &pVosContext ); |
| 12455 | goto done; |
| 12456 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12457 | else |
| 12458 | { |
Siddharth Bhal | 2e5871b | 2015-03-24 16:20:51 +0530 | [diff] [blame] | 12459 | /* We wait for active entry threads to exit from driver |
| 12460 | * by waiting until rtnl_lock is available. |
| 12461 | */ |
| 12462 | rtnl_lock(); |
| 12463 | rtnl_unlock(); |
| 12464 | |
Siddharth Bhal | 3c29dca | 2015-02-19 00:41:40 +0530 | [diff] [blame] | 12465 | INIT_COMPLETION(pHddCtx->ssr_comp_var); |
| 12466 | if ((pHddCtx->isLogpInProgress) && (FALSE == |
| 12467 | vos_is_wlan_in_badState(VOS_MODULE_ID_HDD, NULL))) |
| 12468 | { |
Siddharth Bhal | a204f57 | 2015-01-17 02:03:36 +0530 | [diff] [blame] | 12469 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Siddharth Bhal | 3c29dca | 2015-02-19 00:41:40 +0530 | [diff] [blame] | 12470 | "%s:SSR in Progress; block rmmod !!!", __func__); |
Siddharth Bhal | a204f57 | 2015-01-17 02:03:36 +0530 | [diff] [blame] | 12471 | rc = wait_for_completion_timeout(&pHddCtx->ssr_comp_var, |
| 12472 | msecs_to_jiffies(30000)); |
| 12473 | if(!rc) |
| 12474 | { |
| 12475 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 12476 | "%s:SSR timedout, fatal error", __func__); |
| 12477 | VOS_BUG(0); |
| 12478 | } |
| 12479 | } |
| 12480 | |
Siddharth Bhal | 3c29dca | 2015-02-19 00:41:40 +0530 | [diff] [blame] | 12481 | pHddCtx->isLoadUnloadInProgress = WLAN_HDD_UNLOAD_IN_PROGRESS; |
| 12482 | vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, TRUE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12483 | |
c_hpothu | 8adb97b | 2014-12-08 19:38:20 +0530 | [diff] [blame] | 12484 | /* Driver Need to send country code 00 in below condition |
| 12485 | * 1) If gCountryCodePriority is set to 1; and last country |
| 12486 | * code set is through 11d. This needs to be done in case |
| 12487 | * when NV country code is 00. |
| 12488 | * This Needs to be done as when kernel store last country |
| 12489 | * code and if stored country code is not through 11d, |
| 12490 | * in sme_HandleChangeCountryCodeByUser we will disable 11d |
| 12491 | * in next load/unload as soon as we get any country through |
| 12492 | * 11d. In sme_HandleChangeCountryCodeByUser |
| 12493 | * pMsg->countryCode will be last countryCode and |
| 12494 | * pMac->scan.countryCode11d will be country through 11d so |
| 12495 | * due to mismatch driver will disable 11d. |
| 12496 | * |
| 12497 | */ |
Agarwal Ashish | 8db3988 | 2014-07-30 21:56:07 +0530 | [diff] [blame] | 12498 | |
c_hpothu | 8adb97b | 2014-12-08 19:38:20 +0530 | [diff] [blame] | 12499 | if ((eANI_BOOLEAN_TRUE == sme_Is11dCountrycode(pHddCtx->hHal) && |
Agarwal Ashish | 8dcd286 | 2014-07-25 11:58:52 +0530 | [diff] [blame] | 12500 | pHddCtx->cfg_ini->fSupplicantCountryCodeHasPriority && |
Abhishek Singh | 2a70596 | 2014-10-30 14:47:28 +0530 | [diff] [blame] | 12501 | sme_Is11dSupported(pHddCtx->hHal))) |
c_hpothu | 8adb97b | 2014-12-08 19:38:20 +0530 | [diff] [blame] | 12502 | { |
| 12503 | hddLog(VOS_TRACE_LEVEL_INFO, |
Agarwal Ashish | 8dcd286 | 2014-07-25 11:58:52 +0530 | [diff] [blame] | 12504 | FL("CountryCode 00 is being set while unloading driver")); |
c_hpothu | 8adb97b | 2014-12-08 19:38:20 +0530 | [diff] [blame] | 12505 | vos_nv_getRegDomainFromCountryCode(®Id , "00", COUNTRY_USER); |
| 12506 | } |
Agarwal Ashish | 5e41479 | 2014-06-08 15:25:23 +0530 | [diff] [blame] | 12507 | |
c_hpothu | 8adb97b | 2014-12-08 19:38:20 +0530 | [diff] [blame] | 12508 | //Do all the cleanup before deregistering the driver |
| 12509 | hdd_wlan_exit(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12510 | } |
| 12511 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12512 | vos_preClose( &pVosContext ); |
| 12513 | |
| 12514 | #ifdef TIMER_MANAGER |
| 12515 | vos_timer_exit(); |
| 12516 | #endif |
| 12517 | #ifdef MEMORY_DEBUG |
| 12518 | vos_mem_exit(); |
| 12519 | #endif |
| 12520 | |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 12521 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 12522 | wlan_logging_sock_deinit_svc(); |
| 12523 | #endif |
| 12524 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12525 | done: |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 12526 | vos_wake_lock_destroy(&wlan_wake_lock); |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 12527 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12528 | pr_info("%s: driver unloaded\n", WLAN_MODULE_NAME); |
| 12529 | } |
| 12530 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 12531 | /**--------------------------------------------------------------------------- |
| 12532 | |
| 12533 | \brief hdd_module_exit() - Exit function |
| 12534 | |
| 12535 | This is the driver exit point (invoked when module is unloaded using rmmod) |
| 12536 | |
| 12537 | \param - None |
| 12538 | |
| 12539 | \return - None |
| 12540 | |
| 12541 | --------------------------------------------------------------------------*/ |
| 12542 | static void __exit hdd_module_exit(void) |
| 12543 | { |
| 12544 | hdd_driver_exit(); |
| 12545 | } |
| 12546 | |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 12547 | #ifdef MODULE |
| 12548 | static int fwpath_changed_handler(const char *kmessage, |
| 12549 | struct kernel_param *kp) |
| 12550 | { |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 12551 | return param_set_copystring(kmessage, kp); |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 12552 | } |
| 12553 | |
| 12554 | static int con_mode_handler(const char *kmessage, |
| 12555 | struct kernel_param *kp) |
| 12556 | { |
Madan Mohan Koyyalamudi | f2f8d8b | 2012-10-11 17:06:59 -0700 | [diff] [blame] | 12557 | return param_set_int(kmessage, kp); |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 12558 | } |
| 12559 | #else /* #ifdef MODULE */ |
| 12560 | /**--------------------------------------------------------------------------- |
| 12561 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 12562 | \brief kickstart_driver |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 12563 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 12564 | This is the driver entry point |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 12565 | - delayed driver initialization when driver is statically linked |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 12566 | - invoked when module parameter fwpath is modified from userspace to signal |
| 12567 | initializing the WLAN driver or when con_mode is modified from userspace |
| 12568 | to signal a switch in operating mode |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 12569 | |
| 12570 | \return - 0 for success, non zero for failure |
| 12571 | |
| 12572 | --------------------------------------------------------------------------*/ |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 12573 | static int kickstart_driver(void) |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 12574 | { |
Madan Mohan Koyyalamudi | 62e6005 | 2012-10-05 14:27:22 -0700 | [diff] [blame] | 12575 | int ret_status; |
| 12576 | |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 12577 | if (!wlan_hdd_inited) { |
Madan Mohan Koyyalamudi | 62e6005 | 2012-10-05 14:27:22 -0700 | [diff] [blame] | 12578 | ret_status = hdd_driver_init(); |
| 12579 | wlan_hdd_inited = ret_status ? 0 : 1; |
| 12580 | return ret_status; |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 12581 | } |
| 12582 | |
| 12583 | hdd_driver_exit(); |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 12584 | |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 12585 | msleep(200); |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 12586 | |
Madan Mohan Koyyalamudi | 62e6005 | 2012-10-05 14:27:22 -0700 | [diff] [blame] | 12587 | ret_status = hdd_driver_init(); |
| 12588 | wlan_hdd_inited = ret_status ? 0 : 1; |
| 12589 | return ret_status; |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 12590 | } |
| 12591 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12592 | /**--------------------------------------------------------------------------- |
| 12593 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 12594 | \brief fwpath_changed_handler() - Handler Function |
| 12595 | |
| 12596 | Handle changes to the fwpath parameter |
| 12597 | |
| 12598 | \return - 0 for success, non zero for failure |
| 12599 | |
| 12600 | --------------------------------------------------------------------------*/ |
| 12601 | static int fwpath_changed_handler(const char *kmessage, |
| 12602 | struct kernel_param *kp) |
| 12603 | { |
| 12604 | int ret; |
| 12605 | |
| 12606 | ret = param_set_copystring(kmessage, kp); |
| 12607 | if (0 == ret) |
| 12608 | ret = kickstart_driver(); |
| 12609 | return ret; |
| 12610 | } |
| 12611 | |
| 12612 | /**--------------------------------------------------------------------------- |
| 12613 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 12614 | \brief con_mode_handler() - |
| 12615 | |
| 12616 | Handler function for module param con_mode when it is changed by userspace |
| 12617 | Dynamically linked - do nothing |
| 12618 | Statically linked - exit and init driver, as in rmmod and insmod |
| 12619 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 12620 | \param - |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 12621 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 12622 | \return - |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 12623 | |
| 12624 | --------------------------------------------------------------------------*/ |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 12625 | 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] | 12626 | { |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 12627 | int ret; |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 12628 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 12629 | ret = param_set_int(kmessage, kp); |
| 12630 | if (0 == ret) |
| 12631 | ret = kickstart_driver(); |
| 12632 | return ret; |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 12633 | } |
| 12634 | #endif /* #ifdef MODULE */ |
| 12635 | |
| 12636 | /**--------------------------------------------------------------------------- |
| 12637 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12638 | \brief hdd_get_conparam() - |
| 12639 | |
| 12640 | This is the driver exit point (invoked when module is unloaded using rmmod) |
| 12641 | |
| 12642 | \param - None |
| 12643 | |
| 12644 | \return - tVOS_CON_MODE |
| 12645 | |
| 12646 | --------------------------------------------------------------------------*/ |
| 12647 | tVOS_CON_MODE hdd_get_conparam ( void ) |
| 12648 | { |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 12649 | #ifdef MODULE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12650 | return (tVOS_CON_MODE)con_mode; |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 12651 | #else |
| 12652 | return (tVOS_CON_MODE)curr_con_mode; |
| 12653 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12654 | } |
| 12655 | void hdd_set_conparam ( v_UINT_t newParam ) |
| 12656 | { |
| 12657 | con_mode = newParam; |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 12658 | #ifndef MODULE |
| 12659 | curr_con_mode = con_mode; |
| 12660 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12661 | } |
| 12662 | /**--------------------------------------------------------------------------- |
| 12663 | |
| 12664 | \brief hdd_softap_sta_deauth() - function |
| 12665 | |
| 12666 | This to take counter measure to handle deauth req from HDD |
| 12667 | |
| 12668 | \param - pAdapter - Pointer to the HDD |
| 12669 | |
| 12670 | \param - enable - boolean value |
| 12671 | |
| 12672 | \return - None |
| 12673 | |
| 12674 | --------------------------------------------------------------------------*/ |
| 12675 | |
Hanumantha Reddy Pothula | bfd06f7 | 2014-10-31 14:03:37 +0530 | [diff] [blame] | 12676 | VOS_STATUS hdd_softap_sta_deauth(hdd_adapter_t *pAdapter, |
| 12677 | struct tagCsrDelStaParams *pDelStaParams) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12678 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12679 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 12680 | VOS_STATUS vosStatus = VOS_STATUS_E_FAULT; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12681 | |
| 12682 | ENTER(); |
| 12683 | |
Rajesh Chauhan | 18488fc | 2013-08-22 10:15:03 -0700 | [diff] [blame] | 12684 | hddLog(LOG1, "hdd_softap_sta_deauth:(%p, false)", |
| 12685 | (WLAN_HDD_GET_CTX(pAdapter))->pvosContext); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12686 | |
| 12687 | //Ignore request to deauth bcmc station |
Hanumantha Reddy Pothula | bfd06f7 | 2014-10-31 14:03:37 +0530 | [diff] [blame] | 12688 | if (pDelStaParams->peerMacAddr[0] & 0x1) |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 12689 | return vosStatus; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12690 | |
Hanumantha Reddy Pothula | bfd06f7 | 2014-10-31 14:03:37 +0530 | [diff] [blame] | 12691 | vosStatus = WLANSAP_DeauthSta(pVosContext, pDelStaParams); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12692 | |
| 12693 | EXIT(); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 12694 | return vosStatus; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12695 | } |
| 12696 | |
| 12697 | /**--------------------------------------------------------------------------- |
| 12698 | |
Rashmi Ramanna | 1f0948d | 2014-08-28 15:33:48 +0530 | [diff] [blame] | 12699 | \brief hdd_del_all_sta() - function |
| 12700 | |
| 12701 | This function removes all the stations associated on stopping AP/P2P GO. |
| 12702 | |
| 12703 | \param - pAdapter - Pointer to the HDD |
| 12704 | |
| 12705 | \return - None |
| 12706 | |
| 12707 | --------------------------------------------------------------------------*/ |
| 12708 | |
| 12709 | int hdd_del_all_sta(hdd_adapter_t *pAdapter) |
| 12710 | { |
| 12711 | v_U16_t i; |
| 12712 | VOS_STATUS vos_status; |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 12713 | v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
| 12714 | ptSapContext pSapCtx = NULL; |
| 12715 | pSapCtx = VOS_GET_SAP_CB(pVosContext); |
| 12716 | if(pSapCtx == NULL){ |
| 12717 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 12718 | FL("psapCtx is NULL")); |
| 12719 | return 1; |
| 12720 | } |
Rashmi Ramanna | 1f0948d | 2014-08-28 15:33:48 +0530 | [diff] [blame] | 12721 | ENTER(); |
| 12722 | |
| 12723 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 12724 | "%s: Delete all STAs associated.",__func__); |
| 12725 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
| 12726 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
| 12727 | ) |
| 12728 | { |
| 12729 | for(i = 0; i < WLAN_MAX_STA_COUNT; i++) |
| 12730 | { |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 12731 | if ((pSapCtx->aStaInfo[i].isUsed) && |
| 12732 | (!pSapCtx->aStaInfo[i].isDeauthInProgress)) |
Rashmi Ramanna | 1f0948d | 2014-08-28 15:33:48 +0530 | [diff] [blame] | 12733 | { |
Hanumantha Reddy Pothula | bfd06f7 | 2014-10-31 14:03:37 +0530 | [diff] [blame] | 12734 | struct tagCsrDelStaParams delStaParams; |
| 12735 | |
| 12736 | WLANSAP_PopulateDelStaParams( |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 12737 | pSapCtx->aStaInfo[i].macAddrSTA.bytes, |
Sushant Kaushik | 4cd28f6 | 2014-12-26 14:23:50 +0530 | [diff] [blame] | 12738 | eSIR_MAC_DEAUTH_LEAVING_BSS_REASON, |
| 12739 | SIR_MAC_MGMT_DEAUTH >> 4, |
Hanumantha Reddy Pothula | bfd06f7 | 2014-10-31 14:03:37 +0530 | [diff] [blame] | 12740 | &delStaParams); |
| 12741 | vos_status = hdd_softap_sta_deauth(pAdapter, &delStaParams); |
Rashmi Ramanna | 1f0948d | 2014-08-28 15:33:48 +0530 | [diff] [blame] | 12742 | if (VOS_IS_STATUS_SUCCESS(vos_status)) |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 12743 | pSapCtx->aStaInfo[i].isDeauthInProgress = TRUE; |
Rashmi Ramanna | 1f0948d | 2014-08-28 15:33:48 +0530 | [diff] [blame] | 12744 | } |
| 12745 | } |
| 12746 | } |
| 12747 | |
| 12748 | EXIT(); |
| 12749 | return 0; |
| 12750 | } |
| 12751 | |
| 12752 | /**--------------------------------------------------------------------------- |
| 12753 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12754 | \brief hdd_softap_sta_disassoc() - function |
| 12755 | |
| 12756 | This to take counter measure to handle deauth req from HDD |
| 12757 | |
| 12758 | \param - pAdapter - Pointer to the HDD |
| 12759 | |
| 12760 | \param - enable - boolean value |
| 12761 | |
| 12762 | \return - None |
| 12763 | |
| 12764 | --------------------------------------------------------------------------*/ |
| 12765 | |
| 12766 | void hdd_softap_sta_disassoc(hdd_adapter_t *pAdapter,v_U8_t *pDestMacAddress) |
| 12767 | { |
| 12768 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
| 12769 | |
| 12770 | ENTER(); |
| 12771 | |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 12772 | 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] | 12773 | |
| 12774 | //Ignore request to disassoc bcmc station |
| 12775 | if( pDestMacAddress[0] & 0x1 ) |
| 12776 | return; |
| 12777 | |
| 12778 | WLANSAP_DisassocSta(pVosContext,pDestMacAddress); |
| 12779 | } |
| 12780 | |
| 12781 | void hdd_softap_tkip_mic_fail_counter_measure(hdd_adapter_t *pAdapter,v_BOOL_t enable) |
| 12782 | { |
| 12783 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
| 12784 | |
| 12785 | ENTER(); |
| 12786 | |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 12787 | 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] | 12788 | |
| 12789 | WLANSAP_SetCounterMeasure(pVosContext, (v_BOOL_t)enable); |
| 12790 | } |
| 12791 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12792 | /**--------------------------------------------------------------------------- |
| 12793 | * |
| 12794 | * \brief hdd_get__concurrency_mode() - |
| 12795 | * |
| 12796 | * |
| 12797 | * \param - None |
| 12798 | * |
| 12799 | * \return - CONCURRENCY MODE |
| 12800 | * |
| 12801 | * --------------------------------------------------------------------------*/ |
| 12802 | tVOS_CONCURRENCY_MODE hdd_get_concurrency_mode ( void ) |
| 12803 | { |
| 12804 | v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL ); |
| 12805 | hdd_context_t *pHddCtx; |
| 12806 | |
| 12807 | if (NULL != pVosContext) |
| 12808 | { |
| 12809 | pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext); |
| 12810 | if (NULL != pHddCtx) |
| 12811 | { |
| 12812 | return (tVOS_CONCURRENCY_MODE)pHddCtx->concurrency_mode; |
| 12813 | } |
| 12814 | } |
| 12815 | |
| 12816 | /* we are in an invalid state :( */ |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 12817 | hddLog(LOGE, "%s: Invalid context", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12818 | return VOS_STA; |
| 12819 | } |
Sushant Kaushik | abb7ee6 | 2014-07-18 16:20:12 +0530 | [diff] [blame] | 12820 | v_BOOL_t |
| 12821 | wlan_hdd_is_GO_power_collapse_allowed (hdd_context_t* pHddCtx) |
| 12822 | { |
| 12823 | hdd_adapter_t *pAdapter = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12824 | |
Sushant Kaushik | abb7ee6 | 2014-07-18 16:20:12 +0530 | [diff] [blame] | 12825 | pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_GO); |
| 12826 | if (pAdapter == NULL) |
| 12827 | { |
| 12828 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 12829 | FL("GO doesn't exist")); |
| 12830 | return TRUE; |
| 12831 | } |
| 12832 | if (test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags)) |
| 12833 | { |
| 12834 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 12835 | FL("GO started")); |
| 12836 | return TRUE; |
| 12837 | } |
| 12838 | else |
| 12839 | /* wait till GO changes its interface to p2p device */ |
| 12840 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 12841 | FL("Del_bss called, avoid apps suspend")); |
| 12842 | return FALSE; |
| 12843 | |
| 12844 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12845 | /* Decide whether to allow/not the apps power collapse. |
| 12846 | * Allow apps power collapse if we are in connected state. |
| 12847 | * if not, allow only if we are in IMPS */ |
| 12848 | v_BOOL_t hdd_is_apps_power_collapse_allowed(hdd_context_t* pHddCtx) |
| 12849 | { |
| 12850 | tPmcState pmcState = pmcGetPmcState(pHddCtx->hHal); |
Srikant Kuppa | fef66a7 | 2013-01-30 17:32:44 -0800 | [diff] [blame] | 12851 | tANI_BOOLEAN scanRspPending = csrNeighborRoamScanRspPending(pHddCtx->hHal); |
Srinivas Girigowda | a553c46 | 2013-03-07 19:42:52 -0800 | [diff] [blame] | 12852 | tANI_BOOLEAN inMiddleOfRoaming = csrNeighborMiddleOfRoaming(pHddCtx->hHal); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12853 | hdd_config_t *pConfig = pHddCtx->cfg_ini; |
| 12854 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 12855 | hdd_adapter_t *pAdapter = NULL; |
| 12856 | VOS_STATUS status; |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 12857 | tVOS_CONCURRENCY_MODE concurrent_state = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12858 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12859 | if (VOS_STA_SAP_MODE == hdd_get_conparam()) |
| 12860 | return TRUE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12861 | |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 12862 | concurrent_state = hdd_get_concurrency_mode(); |
| 12863 | |
Sushant Kaushik | abb7ee6 | 2014-07-18 16:20:12 +0530 | [diff] [blame] | 12864 | if ((concurrent_state == (VOS_STA | VOS_P2P_GO)) && |
| 12865 | !(wlan_hdd_is_GO_power_collapse_allowed(pHddCtx))) |
| 12866 | return FALSE; |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 12867 | #ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE |
Sushant Kaushik | abb7ee6 | 2014-07-18 16:20:12 +0530 | [diff] [blame] | 12868 | |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 12869 | if(((concurrent_state == (VOS_STA | VOS_P2P_CLIENT)) || |
Sushant Kaushik | abb7ee6 | 2014-07-18 16:20:12 +0530 | [diff] [blame] | 12870 | (concurrent_state == (VOS_STA | VOS_P2P_GO)))&& |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 12871 | (IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)) |
| 12872 | return TRUE; |
| 12873 | #endif |
| 12874 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12875 | /*loop through all adapters. TBD fix for Concurrency */ |
| 12876 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 12877 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 12878 | { |
| 12879 | pAdapter = pAdapterNode->pAdapter; |
| 12880 | if ( (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) |
| 12881 | || (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ) |
| 12882 | { |
Srikant Kuppa | fef66a7 | 2013-01-30 17:32:44 -0800 | [diff] [blame] | 12883 | if (((pConfig->fIsImpsEnabled || pConfig->fIsBmpsEnabled) |
c_hpothu | 4e8faac | 2014-05-16 17:38:44 +0530 | [diff] [blame] | 12884 | && (pmcState != IMPS && pmcState != BMPS && pmcState != UAPSD |
c_hpothu | 1c6957d | 2015-01-06 18:19:47 +0530 | [diff] [blame] | 12885 | && pmcState != STOPPED && pmcState != STANDBY && |
| 12886 | pmcState != WOWL)) || |
Srinivas Girigowda | a553c46 | 2013-03-07 19:42:52 -0800 | [diff] [blame] | 12887 | (eANI_BOOLEAN_TRUE == scanRspPending) || |
| 12888 | (eANI_BOOLEAN_TRUE == inMiddleOfRoaming)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12889 | { |
Mukul Sharma | 4be8842 | 2015-03-09 20:29:07 +0530 | [diff] [blame] | 12890 | if(pmcState == FULL_POWER && |
| 12891 | sme_IsCoexScoIndicationSet(pHddCtx->hHal)) |
| 12892 | { |
| 12893 | /* |
| 12894 | * When SCO indication comes from Coex module , host will |
| 12895 | * enter in to full power mode, but this should not prevent |
| 12896 | * apps processor power collapse. |
| 12897 | */ |
| 12898 | hddLog(LOG1, |
| 12899 | FL("Allow apps power collapse" |
| 12900 | "even when sco indication is set")); |
| 12901 | return TRUE; |
| 12902 | } |
Srikant Kuppa | fef66a7 | 2013-01-30 17:32:44 -0800 | [diff] [blame] | 12903 | hddLog( LOGE, "%s: do not allow APPS power collapse-" |
Srinivas Girigowda | a553c46 | 2013-03-07 19:42:52 -0800 | [diff] [blame] | 12904 | "pmcState = %d scanRspPending = %d inMiddleOfRoaming = %d", |
| 12905 | __func__, pmcState, scanRspPending, inMiddleOfRoaming ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12906 | return FALSE; |
| 12907 | } |
| 12908 | } |
| 12909 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 12910 | pAdapterNode = pNext; |
| 12911 | } |
| 12912 | return TRUE; |
| 12913 | } |
| 12914 | |
Madan Mohan Koyyalamudi | c72a4d6 | 2012-11-08 14:59:34 -0800 | [diff] [blame] | 12915 | /* Decides whether to send suspend notification to Riva |
| 12916 | * if any adapter is in BMPS; then it is required */ |
| 12917 | v_BOOL_t hdd_is_suspend_notify_allowed(hdd_context_t* pHddCtx) |
| 12918 | { |
| 12919 | tPmcState pmcState = pmcGetPmcState(pHddCtx->hHal); |
| 12920 | hdd_config_t *pConfig = pHddCtx->cfg_ini; |
| 12921 | |
| 12922 | if (pConfig->fIsBmpsEnabled && (pmcState == BMPS)) |
| 12923 | { |
| 12924 | return TRUE; |
| 12925 | } |
| 12926 | return FALSE; |
| 12927 | } |
| 12928 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12929 | void wlan_hdd_set_concurrency_mode(hdd_context_t *pHddCtx, tVOS_CON_MODE mode) |
| 12930 | { |
| 12931 | switch(mode) |
| 12932 | { |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 12933 | case VOS_STA_MODE: |
| 12934 | case VOS_P2P_CLIENT_MODE: |
| 12935 | case VOS_P2P_GO_MODE: |
| 12936 | case VOS_STA_SAP_MODE: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 12937 | pHddCtx->concurrency_mode |= (1 << mode); |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 12938 | pHddCtx->no_of_open_sessions[mode]++; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12939 | break; |
| 12940 | default: |
| 12941 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12942 | } |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 12943 | hddLog(VOS_TRACE_LEVEL_INFO, FL("concurrency_mode = 0x%x " |
| 12944 | "Number of open sessions for mode %d = %d"), |
| 12945 | pHddCtx->concurrency_mode, mode, |
| 12946 | pHddCtx->no_of_open_sessions[mode]); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12947 | } |
| 12948 | |
| 12949 | |
| 12950 | void wlan_hdd_clear_concurrency_mode(hdd_context_t *pHddCtx, tVOS_CON_MODE mode) |
| 12951 | { |
| 12952 | switch(mode) |
| 12953 | { |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 12954 | case VOS_STA_MODE: |
| 12955 | case VOS_P2P_CLIENT_MODE: |
| 12956 | case VOS_P2P_GO_MODE: |
| 12957 | case VOS_STA_SAP_MODE: |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 12958 | pHddCtx->no_of_open_sessions[mode]--; |
| 12959 | if (!(pHddCtx->no_of_open_sessions[mode])) |
| 12960 | pHddCtx->concurrency_mode &= (~(1 << mode)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12961 | break; |
| 12962 | default: |
| 12963 | break; |
| 12964 | } |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 12965 | hddLog(VOS_TRACE_LEVEL_INFO, FL("concurrency_mode = 0x%x " |
| 12966 | "Number of open sessions for mode %d = %d"), |
| 12967 | pHddCtx->concurrency_mode, mode, pHddCtx->no_of_open_sessions[mode]); |
| 12968 | |
| 12969 | } |
| 12970 | /**--------------------------------------------------------------------------- |
| 12971 | * |
| 12972 | * \brief wlan_hdd_incr_active_session() |
| 12973 | * |
| 12974 | * This function increments the number of active sessions |
| 12975 | * maintained per device mode |
| 12976 | * Incase of STA/P2P CLI/IBSS upon connection indication it is incremented |
| 12977 | * Incase of SAP/P2P GO upon bss start it is incremented |
| 12978 | * |
| 12979 | * \param pHddCtx - HDD Context |
| 12980 | * \param mode - device mode |
| 12981 | * |
| 12982 | * \return - None |
| 12983 | * |
| 12984 | * --------------------------------------------------------------------------*/ |
| 12985 | void wlan_hdd_incr_active_session(hdd_context_t *pHddCtx, tVOS_CON_MODE mode) |
| 12986 | { |
| 12987 | switch (mode) { |
| 12988 | case VOS_STA_MODE: |
| 12989 | case VOS_P2P_CLIENT_MODE: |
| 12990 | case VOS_P2P_GO_MODE: |
| 12991 | case VOS_STA_SAP_MODE: |
| 12992 | pHddCtx->no_of_active_sessions[mode]++; |
| 12993 | break; |
| 12994 | default: |
| 12995 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Not Expected Mode %d"), mode); |
| 12996 | break; |
| 12997 | } |
| 12998 | hddLog(VOS_TRACE_LEVEL_INFO, FL("No.# of active sessions for mode %d = %d"), |
| 12999 | mode, |
| 13000 | pHddCtx->no_of_active_sessions[mode]); |
| 13001 | } |
| 13002 | |
| 13003 | /**--------------------------------------------------------------------------- |
| 13004 | * |
| 13005 | * \brief wlan_hdd_decr_active_session() |
| 13006 | * |
| 13007 | * This function decrements the number of active sessions |
| 13008 | * maintained per device mode |
| 13009 | * Incase of STA/P2P CLI/IBSS upon disconnection it is decremented |
| 13010 | * Incase of SAP/P2P GO upon bss stop it is decremented |
| 13011 | * |
| 13012 | * \param pHddCtx - HDD Context |
| 13013 | * \param mode - device mode |
| 13014 | * |
| 13015 | * \return - None |
| 13016 | * |
| 13017 | * --------------------------------------------------------------------------*/ |
| 13018 | void wlan_hdd_decr_active_session(hdd_context_t *pHddCtx, tVOS_CON_MODE mode) |
| 13019 | { |
Bhargav Shah | d071591 | 2015-10-01 18:17:37 +0530 | [diff] [blame] | 13020 | |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 13021 | switch (mode) { |
| 13022 | case VOS_STA_MODE: |
| 13023 | case VOS_P2P_CLIENT_MODE: |
| 13024 | case VOS_P2P_GO_MODE: |
| 13025 | case VOS_STA_SAP_MODE: |
Agarwal Ashish | 5325f52 | 2014-08-06 00:58:44 +0530 | [diff] [blame] | 13026 | if (pHddCtx->no_of_active_sessions[mode] > 0) |
| 13027 | pHddCtx->no_of_active_sessions[mode]--; |
| 13028 | else |
| 13029 | hddLog(VOS_TRACE_LEVEL_INFO, FL(" No.# of Active sessions" |
| 13030 | "is already Zero")); |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 13031 | break; |
| 13032 | default: |
| 13033 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Not Expected Mode %d"), mode); |
| 13034 | break; |
| 13035 | } |
| 13036 | hddLog(VOS_TRACE_LEVEL_INFO, FL("No.# of active sessions for mode %d = %d"), |
| 13037 | mode, |
| 13038 | pHddCtx->no_of_active_sessions[mode]); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13039 | } |
| 13040 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 13041 | /**--------------------------------------------------------------------------- |
| 13042 | * |
| 13043 | * \brief wlan_hdd_restart_init |
| 13044 | * |
| 13045 | * This function initalizes restart timer/flag. An internal function. |
| 13046 | * |
| 13047 | * \param - pHddCtx |
| 13048 | * |
| 13049 | * \return - None |
| 13050 | * |
| 13051 | * --------------------------------------------------------------------------*/ |
| 13052 | |
| 13053 | static void wlan_hdd_restart_init(hdd_context_t *pHddCtx) |
| 13054 | { |
| 13055 | /* Initialize */ |
| 13056 | pHddCtx->hdd_restart_retries = 0; |
| 13057 | atomic_set(&pHddCtx->isRestartInProgress, 0); |
| 13058 | vos_timer_init(&pHddCtx->hdd_restart_timer, |
| 13059 | VOS_TIMER_TYPE_SW, |
| 13060 | wlan_hdd_restart_timer_cb, |
| 13061 | pHddCtx); |
| 13062 | } |
| 13063 | /**--------------------------------------------------------------------------- |
| 13064 | * |
| 13065 | * \brief wlan_hdd_restart_deinit |
| 13066 | * |
| 13067 | * This function cleans up the resources used. An internal function. |
| 13068 | * |
| 13069 | * \param - pHddCtx |
| 13070 | * |
| 13071 | * \return - None |
| 13072 | * |
| 13073 | * --------------------------------------------------------------------------*/ |
| 13074 | |
| 13075 | static void wlan_hdd_restart_deinit(hdd_context_t* pHddCtx) |
| 13076 | { |
| 13077 | |
| 13078 | VOS_STATUS vos_status; |
| 13079 | /* Block any further calls */ |
| 13080 | atomic_set(&pHddCtx->isRestartInProgress, 1); |
| 13081 | /* Cleanup */ |
| 13082 | vos_status = vos_timer_stop( &pHddCtx->hdd_restart_timer ); |
| 13083 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 13084 | hddLog(LOGE, FL("Failed to stop HDD restart timer")); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 13085 | vos_status = vos_timer_destroy(&pHddCtx->hdd_restart_timer); |
| 13086 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 13087 | hddLog(LOGE, FL("Failed to destroy HDD restart timer")); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 13088 | |
| 13089 | } |
| 13090 | |
| 13091 | /**--------------------------------------------------------------------------- |
| 13092 | * |
| 13093 | * \brief wlan_hdd_framework_restart |
| 13094 | * |
| 13095 | * This function uses a cfg80211 API to start a framework initiated WLAN |
| 13096 | * driver module unload/load. |
| 13097 | * |
| 13098 | * Also this API keep retrying (WLAN_HDD_RESTART_RETRY_MAX_CNT). |
| 13099 | * |
| 13100 | * |
| 13101 | * \param - pHddCtx |
| 13102 | * |
| 13103 | * \return - VOS_STATUS_SUCCESS: Success |
| 13104 | * VOS_STATUS_E_EMPTY: Adapter is Empty |
| 13105 | * VOS_STATUS_E_NOMEM: No memory |
| 13106 | |
| 13107 | * --------------------------------------------------------------------------*/ |
| 13108 | |
| 13109 | static VOS_STATUS wlan_hdd_framework_restart(hdd_context_t *pHddCtx) |
| 13110 | { |
| 13111 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 13112 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
Madan Mohan Koyyalamudi | fc19e44 | 2013-05-09 18:24:08 -0700 | [diff] [blame] | 13113 | int len = (sizeof (struct ieee80211_mgmt)); |
| 13114 | struct ieee80211_mgmt *mgmt = NULL; |
| 13115 | |
| 13116 | /* Prepare the DEAUTH managment frame with reason code */ |
| 13117 | mgmt = kzalloc(len, GFP_KERNEL); |
| 13118 | if(mgmt == NULL) |
| 13119 | { |
| 13120 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 13121 | "%s: memory allocation failed (%d bytes)", __func__, len); |
| 13122 | return VOS_STATUS_E_NOMEM; |
| 13123 | } |
| 13124 | mgmt->u.deauth.reason_code = WLAN_REASON_DISASSOC_LOW_ACK; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 13125 | |
| 13126 | /* Iterate over all adapters/devices */ |
| 13127 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
Hanumantha Reddy Pothula | da0fe36 | 2015-02-27 18:37:03 +0530 | [diff] [blame] | 13128 | if ((NULL == pAdapterNode) || (VOS_STATUS_SUCCESS != status)) |
| 13129 | { |
| 13130 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 13131 | FL("fail to get adapter: %p %d"), pAdapterNode, status); |
| 13132 | goto end; |
| 13133 | } |
| 13134 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 13135 | do |
| 13136 | { |
Hanumantha Reddy Pothula | da0fe36 | 2015-02-27 18:37:03 +0530 | [diff] [blame] | 13137 | if(pAdapterNode->pAdapter && |
| 13138 | WLAN_HDD_ADAPTER_MAGIC == pAdapterNode->pAdapter->magic) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 13139 | { |
| 13140 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 13141 | "restarting the driver(intf:\'%s\' mode:%d :try %d)", |
| 13142 | pAdapterNode->pAdapter->dev->name, |
| 13143 | pAdapterNode->pAdapter->device_mode, |
| 13144 | pHddCtx->hdd_restart_retries + 1); |
Madan Mohan Koyyalamudi | fc19e44 | 2013-05-09 18:24:08 -0700 | [diff] [blame] | 13145 | /* |
| 13146 | * CFG80211 event to restart the driver |
| 13147 | * |
| 13148 | * 'cfg80211_send_unprot_deauth' sends a |
| 13149 | * NL80211_CMD_UNPROT_DEAUTHENTICATE event to supplicant at any state |
| 13150 | * of SME(Linux Kernel) state machine. |
| 13151 | * |
| 13152 | * Reason code WLAN_REASON_DISASSOC_LOW_ACK is currently used to restart |
| 13153 | * the driver. |
| 13154 | * |
| 13155 | */ |
Abhishek Singh | 00b7197 | 2016-01-07 10:51:04 +0530 | [diff] [blame] | 13156 | |
Anand N Sunkad | e9adb1b | 2015-07-29 09:56:45 +0530 | [diff] [blame] | 13157 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 13158 | cfg80211_rx_unprot_mlme_mgmt(pAdapterNode->pAdapter->dev, (u_int8_t*)mgmt, len); |
| 13159 | #else |
Madan Mohan Koyyalamudi | fc19e44 | 2013-05-09 18:24:08 -0700 | [diff] [blame] | 13160 | cfg80211_send_unprot_deauth(pAdapterNode->pAdapter->dev, (u_int8_t*)mgmt, len ); |
Anand N Sunkad | e9adb1b | 2015-07-29 09:56:45 +0530 | [diff] [blame] | 13161 | #endif |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 13162 | } |
| 13163 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 13164 | pAdapterNode = pNext; |
| 13165 | } while((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status)); |
| 13166 | |
Hanumantha Reddy Pothula | da0fe36 | 2015-02-27 18:37:03 +0530 | [diff] [blame] | 13167 | end: |
Madan Mohan Koyyalamudi | fc19e44 | 2013-05-09 18:24:08 -0700 | [diff] [blame] | 13168 | /* Free the allocated management frame */ |
| 13169 | kfree(mgmt); |
| 13170 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 13171 | /* Retry until we unload or reach max count */ |
| 13172 | if(++pHddCtx->hdd_restart_retries < WLAN_HDD_RESTART_RETRY_MAX_CNT) |
| 13173 | vos_timer_start(&pHddCtx->hdd_restart_timer, WLAN_HDD_RESTART_RETRY_DELAY_MS); |
| 13174 | |
| 13175 | return status; |
| 13176 | |
| 13177 | } |
| 13178 | /**--------------------------------------------------------------------------- |
| 13179 | * |
| 13180 | * \brief wlan_hdd_restart_timer_cb |
| 13181 | * |
| 13182 | * Restart timer callback. An internal function. |
| 13183 | * |
| 13184 | * \param - User data: |
| 13185 | * |
| 13186 | * \return - None |
| 13187 | * |
| 13188 | * --------------------------------------------------------------------------*/ |
| 13189 | |
| 13190 | void wlan_hdd_restart_timer_cb(v_PVOID_t usrDataForCallback) |
| 13191 | { |
| 13192 | hdd_context_t *pHddCtx = usrDataForCallback; |
| 13193 | wlan_hdd_framework_restart(pHddCtx); |
| 13194 | return; |
| 13195 | |
| 13196 | } |
| 13197 | |
| 13198 | |
| 13199 | /**--------------------------------------------------------------------------- |
| 13200 | * |
| 13201 | * \brief wlan_hdd_restart_driver |
| 13202 | * |
| 13203 | * This function sends an event to supplicant to restart the WLAN driver. |
| 13204 | * |
| 13205 | * This function is called from vos_wlanRestart. |
| 13206 | * |
| 13207 | * \param - pHddCtx |
| 13208 | * |
| 13209 | * \return - VOS_STATUS_SUCCESS: Success |
| 13210 | * VOS_STATUS_E_EMPTY: Adapter is Empty |
| 13211 | * VOS_STATUS_E_ALREADY: Request already in progress |
| 13212 | |
| 13213 | * --------------------------------------------------------------------------*/ |
| 13214 | VOS_STATUS wlan_hdd_restart_driver(hdd_context_t *pHddCtx) |
| 13215 | { |
| 13216 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 13217 | |
| 13218 | /* A tight check to make sure reentrancy */ |
| 13219 | if(atomic_xchg(&pHddCtx->isRestartInProgress, 1)) |
| 13220 | { |
Mihir Shete | fd52865 | 2014-06-23 19:07:50 +0530 | [diff] [blame] | 13221 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 13222 | "%s: WLAN restart is already in progress", __func__); |
| 13223 | |
| 13224 | return VOS_STATUS_E_ALREADY; |
| 13225 | } |
Sameer Thalappil | 0c164f5 | 2013-03-28 15:27:56 -0700 | [diff] [blame] | 13226 | /* Send reset FIQ to WCNSS to invoke SSR. */ |
Madan Mohan Koyyalamudi | e388b34 | 2012-11-08 15:03:16 -0800 | [diff] [blame] | 13227 | #ifdef HAVE_WCNSS_RESET_INTR |
Siddharth Bhal | 864e7e8 | 2015-04-07 20:07:24 +0530 | [diff] [blame] | 13228 | wcnss_reset_fiq(TRUE); |
Madan Mohan Koyyalamudi | bb8f017 | 2012-09-28 15:36:06 -0700 | [diff] [blame] | 13229 | #endif |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 13230 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 13231 | return status; |
| 13232 | } |
| 13233 | |
Bhargav Shah | d071591 | 2015-10-01 18:17:37 +0530 | [diff] [blame] | 13234 | /** |
| 13235 | * hdd_get_total_sessions() - provide total number of active sessions |
| 13236 | * @pHddCtx: Valid Global HDD context pointer |
| 13237 | * |
| 13238 | * This function iterates through pAdaptors and find the number of all active |
| 13239 | * sessions. This active sessions includes connected sta, p2p client and number |
| 13240 | * of client connected to sap/p2p go. |
| 13241 | * |
| 13242 | * Return: Total number of active sessions. |
| 13243 | */ |
| 13244 | v_U8_t hdd_get_total_sessions(hdd_context_t *pHddCtx) |
| 13245 | { |
| 13246 | v_U8_t active_session = 0; |
| 13247 | hdd_station_ctx_t *pHddStaCtx; |
| 13248 | hdd_adapter_list_node_t *pAdapterNode, *pNext; |
| 13249 | hdd_adapter_t *pAdapter; |
| 13250 | VOS_STATUS status; |
| 13251 | |
| 13252 | status = hdd_get_front_adapter(pHddCtx, &pAdapterNode); |
| 13253 | while (NULL != pAdapterNode && VOS_STATUS_SUCCESS == status) { |
| 13254 | pAdapter = pAdapterNode->pAdapter; |
| 13255 | switch (pAdapter->device_mode) { |
| 13256 | case VOS_STA_MODE: |
| 13257 | case VOS_P2P_CLIENT_MODE: |
| 13258 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 13259 | if(eConnectionState_Associated == pHddStaCtx->conn_info.connState) |
| 13260 | active_session += 1; |
| 13261 | break; |
| 13262 | case VOS_STA_SAP_MODE: |
| 13263 | case VOS_P2P_GO_MODE: |
| 13264 | active_session += hdd_softap_get_connected_sta(pAdapter); |
| 13265 | break; |
| 13266 | default: |
| 13267 | break; |
| 13268 | } |
| 13269 | |
| 13270 | status = hdd_get_next_adapter(pHddCtx, pAdapterNode, &pNext); |
| 13271 | pAdapterNode = pNext; |
| 13272 | } |
| 13273 | |
| 13274 | return active_session; |
| 13275 | } |
| 13276 | |
| 13277 | /** |
| 13278 | * hdd_set_delack_value() - Set delack value |
| 13279 | * @pHddCtx: Valid Global HDD context pointer |
| 13280 | * @next_rx_level: Value to set for delack |
| 13281 | * |
| 13282 | * This function compare present value and next value of delack. If the both |
| 13283 | * are diffrent then it sets next value . |
| 13284 | * |
| 13285 | * Return: void. |
| 13286 | */ |
| 13287 | void hdd_set_delack_value(hdd_context_t *pHddCtx, v_U32_t next_rx_level) |
| 13288 | { |
| 13289 | if (pHddCtx->cur_rx_level != next_rx_level) { |
| 13290 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_DEBUG, |
| 13291 | "%s: TCP DELACK trigger level %d", |
| 13292 | __func__, next_rx_level); |
| 13293 | mutex_lock(&pHddCtx->cur_rx_level_lock); |
| 13294 | pHddCtx->cur_rx_level = next_rx_level; |
| 13295 | mutex_unlock(&pHddCtx->cur_rx_level_lock); |
| 13296 | wlan_hdd_send_svc_nlink_msg(WLAN_SVC_WLAN_TP_IND, &next_rx_level, |
| 13297 | sizeof(next_rx_level)); |
| 13298 | } |
| 13299 | } |
| 13300 | |
| 13301 | /** |
| 13302 | * hdd_set_default_stop_delack_timer() - Start delack timer |
| 13303 | * @pHddCtx: Valid Global HDD context pointer |
| 13304 | * |
| 13305 | * This function stop delack timer and set delack value to default.. |
| 13306 | * |
| 13307 | * Return: void. |
| 13308 | */ |
| 13309 | |
| 13310 | void hdd_set_default_stop_delack_timer(hdd_context_t *pHddCtx) |
| 13311 | { |
| 13312 | if (VOS_TIMER_STATE_RUNNING != |
| 13313 | vos_timer_getCurrentState(&pHddCtx->delack_timer)) { |
| 13314 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_DEBUG, |
| 13315 | "%s: Can not stop timer", __func__); |
| 13316 | return; |
| 13317 | } |
| 13318 | |
| 13319 | vos_timer_stop(&pHddCtx->delack_timer); |
| 13320 | hdd_set_delack_value(pHddCtx, TP_IND_LOW); |
| 13321 | } |
| 13322 | |
| 13323 | /** |
| 13324 | * hdd_start_delack_timer() - Start delack timer |
| 13325 | * @pHddCtx: Valid Global HDD context pointer |
| 13326 | * |
| 13327 | * This function starts the delack timer for tcpDelAckComputeInterval time |
| 13328 | * interval.The default timer value is 2 second. |
| 13329 | * |
| 13330 | * Return: void. |
| 13331 | */ |
| 13332 | void hdd_start_delack_timer(hdd_context_t *pHddCtx) |
| 13333 | { |
| 13334 | if (VOS_TIMER_STATE_RUNNING == |
| 13335 | vos_timer_getCurrentState(&pHddCtx->delack_timer)) { |
| 13336 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_DEBUG, |
| 13337 | "%s: Timer is already running", __func__); |
| 13338 | return; |
| 13339 | } |
| 13340 | |
| 13341 | vos_timer_start(&pHddCtx->delack_timer, |
| 13342 | pHddCtx->cfg_ini->tcpDelAckComputeInterval); |
| 13343 | } |
| 13344 | |
| 13345 | /** |
| 13346 | * hdd_update_prev_rx_packet_count() - Update previous rx packet count |
| 13347 | * @pHddCtx: Valid Global HDD context pointer |
| 13348 | * |
| 13349 | * This function updates the prev_rx_packets count from the corresponding |
| 13350 | * pAdapter states. This prev_rx_packets will diffed with the packet count |
| 13351 | * at the end of delack timer. That can give number of RX packet is spacific |
| 13352 | * time. |
| 13353 | * |
| 13354 | * Return: void. |
| 13355 | */ |
| 13356 | void hdd_update_prev_rx_packet_count(hdd_context_t *pHddCtx) |
| 13357 | { |
| 13358 | hdd_adapter_list_node_t *pAdapterNode, *pNext; |
| 13359 | hdd_adapter_t *pAdapter; |
| 13360 | VOS_STATUS status; |
| 13361 | |
| 13362 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 13363 | while (NULL != pAdapterNode && VOS_STATUS_SUCCESS == status) { |
| 13364 | pAdapter = pAdapterNode->pAdapter; |
| 13365 | pAdapter->prev_rx_packets = pAdapter->stats.rx_packets; |
| 13366 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 13367 | pAdapterNode = pNext; |
| 13368 | } |
| 13369 | } |
| 13370 | |
| 13371 | /** |
| 13372 | * hdd_manage_delack_timer() - start\stop delack timer |
| 13373 | * @pHddCtx: Valid Global HDD context pointer |
| 13374 | * |
| 13375 | * This function check the number of concerent session present, it starts the |
| 13376 | * delack timer if only one session is present. |
| 13377 | * In the case of BT_COEX and TDLS mode it blindly stop delack functionality. |
| 13378 | * |
| 13379 | * Return: void. |
| 13380 | */ |
| 13381 | void hdd_manage_delack_timer(hdd_context_t *pHddCtx) |
| 13382 | { |
| 13383 | uint8_t sessions; |
| 13384 | |
| 13385 | if (!pHddCtx->cfg_ini->enable_delack) { |
| 13386 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_DEBUG, |
| 13387 | "%s: TCP DELACK is not enabled", __func__); |
| 13388 | return; |
| 13389 | } |
| 13390 | |
| 13391 | /* Blindly stop timer of BTCOEX and TDLS Session is up */ |
| 13392 | if (pHddCtx->mode != 0) { |
| 13393 | hdd_set_default_stop_delack_timer(pHddCtx); |
| 13394 | return; |
| 13395 | } |
| 13396 | |
| 13397 | sessions = hdd_get_total_sessions(pHddCtx); |
| 13398 | if (sessions == 1) { |
| 13399 | hdd_update_prev_rx_packet_count(pHddCtx); |
| 13400 | hdd_start_delack_timer(pHddCtx); |
| 13401 | } else { |
| 13402 | hdd_set_default_stop_delack_timer(pHddCtx); |
| 13403 | } |
| 13404 | } |
| 13405 | |
Mihir Shete | e1093ba | 2014-01-21 20:13:32 +0530 | [diff] [blame] | 13406 | /**--------------------------------------------------------------------------- |
| 13407 | * |
| 13408 | * \brief wlan_hdd_init_channels |
| 13409 | * |
| 13410 | * This function is used to initialize the channel list in CSR |
| 13411 | * |
| 13412 | * This function is called from hdd_wlan_startup |
| 13413 | * |
| 13414 | * \param - pHddCtx: HDD context |
| 13415 | * |
| 13416 | * \return - VOS_STATUS_SUCCESS: Success |
| 13417 | * VOS_STATUS_E_FAULT: Failure reported by SME |
| 13418 | |
| 13419 | * --------------------------------------------------------------------------*/ |
| 13420 | static VOS_STATUS wlan_hdd_init_channels(hdd_context_t *pHddCtx) |
| 13421 | { |
| 13422 | eHalStatus status; |
| 13423 | |
| 13424 | status = sme_InitChannels(pHddCtx->hHal); |
| 13425 | if (HAL_STATUS_SUCCESS(status)) |
| 13426 | { |
| 13427 | return VOS_STATUS_SUCCESS; |
| 13428 | } |
| 13429 | else |
| 13430 | { |
| 13431 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Channel initialization failed(%d)", |
| 13432 | __func__, status); |
| 13433 | return VOS_STATUS_E_FAULT; |
| 13434 | } |
| 13435 | } |
| 13436 | |
Mihir Shete | 0420645 | 2014-11-20 17:50:58 +0530 | [diff] [blame] | 13437 | #ifdef CONFIG_ENABLE_LINUX_REG |
Agarwal Ashish | 6db9d53 | 2014-09-30 18:19:10 +0530 | [diff] [blame] | 13438 | 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] | 13439 | { |
| 13440 | eHalStatus status; |
| 13441 | |
Agarwal Ashish | 6db9d53 | 2014-09-30 18:19:10 +0530 | [diff] [blame] | 13442 | status = sme_InitChannelsForCC(pHddCtx->hHal, init); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 13443 | if (HAL_STATUS_SUCCESS(status)) |
| 13444 | { |
| 13445 | return VOS_STATUS_SUCCESS; |
| 13446 | } |
| 13447 | else |
| 13448 | { |
| 13449 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Issue reg hint failed(%d)", |
| 13450 | __func__, status); |
| 13451 | return VOS_STATUS_E_FAULT; |
| 13452 | } |
| 13453 | } |
Mihir Shete | 0420645 | 2014-11-20 17:50:58 +0530 | [diff] [blame] | 13454 | #endif |
Sudhir Sattayappa Kohalli | b1d8c3a | 2013-06-18 14:47:20 -0700 | [diff] [blame] | 13455 | /* |
| 13456 | * API to find if there is any STA or P2P-Client is connected |
| 13457 | */ |
| 13458 | VOS_STATUS hdd_issta_p2p_clientconnected(hdd_context_t *pHddCtx) |
| 13459 | { |
| 13460 | return sme_isSta_p2p_clientConnected(pHddCtx->hHal); |
| 13461 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 13462 | |
Mihir Shete | e2ae82a | 2015-03-16 14:08:49 +0530 | [diff] [blame] | 13463 | |
| 13464 | /* |
| 13465 | * API to find if the firmware will send logs using DXE channel |
| 13466 | */ |
| 13467 | v_U8_t hdd_is_fw_logging_enabled(void) |
| 13468 | { |
| 13469 | hdd_context_t *pHddCtx; |
| 13470 | |
| 13471 | pHddCtx = vos_get_context(VOS_MODULE_ID_HDD, |
| 13472 | vos_get_global_context(VOS_MODULE_ID_HDD, NULL)); |
| 13473 | |
Sachin Ahuja | 084313e | 2015-05-21 17:57:10 +0530 | [diff] [blame] | 13474 | return (pHddCtx && pHddCtx->cfg_ini->enableMgmtLogging); |
Mihir Shete | e2ae82a | 2015-03-16 14:08:49 +0530 | [diff] [blame] | 13475 | } |
| 13476 | |
Agarwal Ashish | 57e8437 | 2014-12-05 18:26:53 +0530 | [diff] [blame] | 13477 | /* |
Mihir Shete | be94ebb | 2015-05-26 12:07:14 +0530 | [diff] [blame] | 13478 | * API to find if the firmware will send trace logs using DXE channel |
| 13479 | */ |
| 13480 | v_U8_t hdd_is_fw_ev_logging_enabled(void) |
| 13481 | { |
| 13482 | hdd_context_t *pHddCtx; |
| 13483 | |
| 13484 | pHddCtx = vos_get_context(VOS_MODULE_ID_HDD, |
| 13485 | vos_get_global_context(VOS_MODULE_ID_HDD, NULL)); |
| 13486 | |
| 13487 | return (pHddCtx && pHddCtx->cfg_ini->enableFWLogging); |
| 13488 | } |
| 13489 | /* |
Agarwal Ashish | 57e8437 | 2014-12-05 18:26:53 +0530 | [diff] [blame] | 13490 | * API to find if there is any session connected |
| 13491 | */ |
| 13492 | VOS_STATUS hdd_is_any_session_connected(hdd_context_t *pHddCtx) |
| 13493 | { |
| 13494 | return sme_is_any_session_connected(pHddCtx->hHal); |
| 13495 | } |
| 13496 | |
| 13497 | |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 13498 | int wlan_hdd_scan_abort(hdd_adapter_t *pAdapter) |
| 13499 | { |
| 13500 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 13501 | hdd_scaninfo_t *pScanInfo = NULL; |
Girish Gowli | 4bf7a63 | 2014-06-12 13:42:11 +0530 | [diff] [blame] | 13502 | long status = 0; |
c_hpothu | a3d45d5 | 2015-01-05 14:11:17 +0530 | [diff] [blame] | 13503 | tSirAbortScanStatus abortScanStatus; |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 13504 | |
| 13505 | pScanInfo = &pHddCtx->scan_info; |
Ratnam Rachuri | c768113 | 2015-06-30 10:35:13 +0530 | [diff] [blame] | 13506 | INIT_COMPLETION(pScanInfo->abortscan_event_var); |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 13507 | if (pScanInfo->mScanPending) |
| 13508 | { |
c_hpothu | a3d45d5 | 2015-01-05 14:11:17 +0530 | [diff] [blame] | 13509 | abortScanStatus = hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId, |
| 13510 | eCSR_SCAN_ABORT_DEFAULT); |
| 13511 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 13512 | FL("abortScanStatus: %d"), abortScanStatus); |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 13513 | |
c_hpothu | a3d45d5 | 2015-01-05 14:11:17 +0530 | [diff] [blame] | 13514 | /* If there is active scan command lets wait for the completion else |
| 13515 | * there is no need to wait as scan command might be in the SME pending |
| 13516 | * command list. |
| 13517 | */ |
| 13518 | if (abortScanStatus == eSIR_ABORT_ACTIVE_SCAN_LIST_NOT_EMPTY) |
| 13519 | { |
c_hpothu | a3d45d5 | 2015-01-05 14:11:17 +0530 | [diff] [blame] | 13520 | status = wait_for_completion_interruptible_timeout( |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 13521 | &pScanInfo->abortscan_event_var, |
| 13522 | msecs_to_jiffies(5000)); |
c_hpothu | a3d45d5 | 2015-01-05 14:11:17 +0530 | [diff] [blame] | 13523 | if (0 >= status) |
| 13524 | { |
| 13525 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Girish Gowli | 4bf7a63 | 2014-06-12 13:42:11 +0530 | [diff] [blame] | 13526 | "%s: Timeout or Interrupt occurred while waiting for abort" |
| 13527 | "scan, status- %ld", __func__, status); |
c_hpothu | a3d45d5 | 2015-01-05 14:11:17 +0530 | [diff] [blame] | 13528 | return -ETIMEDOUT; |
| 13529 | } |
| 13530 | } |
| 13531 | else if (abortScanStatus == eSIR_ABORT_SCAN_FAILURE) |
| 13532 | { |
| 13533 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 13534 | FL("hdd_abort_mac_scan failed")); |
| 13535 | return -VOS_STATUS_E_FAILURE; |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 13536 | } |
| 13537 | } |
Girish Gowli | 4bf7a63 | 2014-06-12 13:42:11 +0530 | [diff] [blame] | 13538 | return 0; |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 13539 | } |
| 13540 | |
Abhishek Singh | 7d624e1 | 2015-11-30 14:29:27 +0530 | [diff] [blame] | 13541 | /** |
| 13542 | * hdd_indicate_mgmt_frame() - Wrapper to indicate management frame to |
| 13543 | * user space |
| 13544 | * @frame_ind: Management frame data to be informed. |
| 13545 | * |
| 13546 | * This function is used to indicate management frame to |
| 13547 | * user space |
| 13548 | * |
| 13549 | * Return: None |
| 13550 | * |
| 13551 | */ |
| 13552 | void hdd_indicate_mgmt_frame(tSirSmeMgmtFrameInd *frame_ind) |
| 13553 | { |
| 13554 | hdd_context_t *hdd_ctx = NULL; |
| 13555 | hdd_adapter_t *adapter = NULL; |
| 13556 | v_CONTEXT_t vos_context = NULL; |
| 13557 | |
| 13558 | /* Get the global VOSS context.*/ |
| 13559 | vos_context = vos_get_global_context(VOS_MODULE_ID_SYS, NULL); |
| 13560 | if (!vos_context) { |
| 13561 | hddLog(LOGE, FL("Global VOS context is Null")); |
| 13562 | return; |
| 13563 | } |
| 13564 | /* Get the HDD context.*/ |
| 13565 | hdd_ctx = |
| 13566 | (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, vos_context ); |
| 13567 | |
| 13568 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
| 13569 | { |
| 13570 | return; |
| 13571 | } |
| 13572 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, |
| 13573 | frame_ind->sessionId); |
| 13574 | |
| 13575 | if ((NULL != adapter) && |
| 13576 | (WLAN_HDD_ADAPTER_MAGIC == adapter->magic)) |
| 13577 | __hdd_indicate_mgmt_frame(adapter, |
| 13578 | frame_ind->frameLen, |
| 13579 | frame_ind->frameBuf, |
| 13580 | frame_ind->frameType, |
| 13581 | frame_ind->rxChan, |
| 13582 | frame_ind->rxRssi); |
| 13583 | return; |
| 13584 | |
| 13585 | } |
| 13586 | |
c_hpothu | 225aa7c | 2014-10-22 17:45:13 +0530 | [diff] [blame] | 13587 | VOS_STATUS wlan_hdd_cancel_remain_on_channel(hdd_context_t *pHddCtx) |
| 13588 | { |
| 13589 | hdd_adapter_t *pAdapter; |
| 13590 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 13591 | VOS_STATUS vosStatus; |
| 13592 | |
| 13593 | vosStatus = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 13594 | while (NULL != pAdapterNode && VOS_STATUS_E_EMPTY != vosStatus) |
| 13595 | { |
| 13596 | pAdapter = pAdapterNode->pAdapter; |
| 13597 | if (NULL != pAdapter) |
| 13598 | { |
| 13599 | if (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode || |
| 13600 | WLAN_HDD_P2P_CLIENT == pAdapter->device_mode || |
| 13601 | WLAN_HDD_P2P_GO == pAdapter->device_mode) |
| 13602 | { |
| 13603 | hddLog(LOG1, FL("abort ROC deviceMode: %d"), |
| 13604 | pAdapter->device_mode); |
| 13605 | if (VOS_STATUS_SUCCESS != |
| 13606 | wlan_hdd_cancel_existing_remain_on_channel(pAdapter)) |
| 13607 | { |
| 13608 | hddLog(LOGE, FL("failed to abort ROC")); |
| 13609 | return VOS_STATUS_E_FAILURE; |
| 13610 | } |
| 13611 | } |
| 13612 | } |
| 13613 | vosStatus = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 13614 | pAdapterNode = pNext; |
| 13615 | } |
| 13616 | return VOS_STATUS_SUCCESS; |
| 13617 | } |
Mahesh A Saptasagar | d477b09 | 2015-02-06 15:12:16 +0530 | [diff] [blame] | 13618 | |
Mihir Shete | 0be2877 | 2015-02-17 18:42:14 +0530 | [diff] [blame] | 13619 | hdd_remain_on_chan_ctx_t *hdd_get_remain_on_channel_ctx(hdd_context_t *pHddCtx) |
| 13620 | { |
| 13621 | hdd_adapter_t *pAdapter; |
| 13622 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 13623 | hdd_cfg80211_state_t *cfgState; |
| 13624 | hdd_remain_on_chan_ctx_t *pRemainChanCtx = NULL; |
| 13625 | VOS_STATUS vosStatus; |
| 13626 | |
| 13627 | vosStatus = hdd_get_front_adapter (pHddCtx, &pAdapterNode); |
| 13628 | while (NULL != pAdapterNode && VOS_STATUS_E_EMPTY != vosStatus) |
| 13629 | { |
| 13630 | pAdapter = pAdapterNode->pAdapter; |
| 13631 | if (NULL != pAdapter) |
| 13632 | { |
| 13633 | cfgState = WLAN_HDD_GET_CFG_STATE_PTR(pAdapter); |
| 13634 | pRemainChanCtx = cfgState->remain_on_chan_ctx; |
| 13635 | if (pRemainChanCtx) |
| 13636 | break; |
| 13637 | } |
| 13638 | vosStatus = hdd_get_next_adapter (pHddCtx, pAdapterNode, &pNext); |
| 13639 | pAdapterNode = pNext; |
| 13640 | } |
| 13641 | return pRemainChanCtx; |
| 13642 | } |
| 13643 | |
Padma, Santhosh Kumar | 778d838 | 2015-03-04 17:41:22 +0530 | [diff] [blame] | 13644 | /** |
| 13645 | * wlan_hdd_handle_dfs_chan_scan () - handles disable/enable DFS channels |
| 13646 | * |
| 13647 | * @pHddCtx: HDD context within host driver |
| 13648 | * @dfsScanMode: dfsScanMode passed from ioctl |
| 13649 | * |
| 13650 | */ |
| 13651 | |
| 13652 | VOS_STATUS wlan_hdd_handle_dfs_chan_scan(hdd_context_t *pHddCtx, |
| 13653 | tANI_U8 dfsScanMode) |
| 13654 | { |
| 13655 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 13656 | hdd_adapter_t *pAdapter; |
| 13657 | VOS_STATUS vosStatus; |
| 13658 | hdd_station_ctx_t *pHddStaCtx; |
| 13659 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 13660 | |
| 13661 | if(!pHddCtx) |
| 13662 | { |
| 13663 | hddLog(LOGE, FL("HDD context is Null")); |
| 13664 | return eHAL_STATUS_FAILURE; |
| 13665 | } |
| 13666 | |
| 13667 | if (pHddCtx->scan_info.mScanPending) |
| 13668 | { |
| 13669 | hddLog(LOG1, FL("Aborting scan for sessionId: %d"), |
| 13670 | pHddCtx->scan_info.sessionId); |
| 13671 | hdd_abort_mac_scan(pHddCtx, |
| 13672 | pHddCtx->scan_info.sessionId, |
| 13673 | eCSR_SCAN_ABORT_DEFAULT); |
| 13674 | } |
| 13675 | |
| 13676 | if (!dfsScanMode) |
| 13677 | { |
| 13678 | vosStatus = hdd_get_front_adapter( pHddCtx, &pAdapterNode); |
| 13679 | while ((NULL != pAdapterNode) && |
| 13680 | (VOS_STATUS_SUCCESS == vosStatus)) |
| 13681 | { |
| 13682 | pAdapter = pAdapterNode->pAdapter; |
| 13683 | |
| 13684 | if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) |
| 13685 | { |
| 13686 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 13687 | |
| 13688 | if(!pHddStaCtx) |
| 13689 | { |
| 13690 | hddLog(LOGE, FL("HDD STA context is Null")); |
| 13691 | return eHAL_STATUS_FAILURE; |
| 13692 | } |
| 13693 | |
| 13694 | /* if STA is already connected on DFS channel, |
| 13695 | disconnect immediately*/ |
| 13696 | if (hdd_connIsConnected(pHddStaCtx) && |
| 13697 | (NV_CHANNEL_DFS == |
| 13698 | vos_nv_getChannelEnabledState( |
| 13699 | pHddStaCtx->conn_info.operationChannel))) |
| 13700 | { |
| 13701 | status = sme_RoamDisconnect(pHddCtx->hHal, |
| 13702 | pAdapter->sessionId, |
| 13703 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
| 13704 | hddLog(LOG1, FL("Client connected on DFS channel %d," |
| 13705 | "sme_RoamDisconnect returned with status: %d" |
| 13706 | "for sessionid: %d"), pHddStaCtx->conn_info. |
| 13707 | operationChannel, status, pAdapter->sessionId); |
| 13708 | } |
| 13709 | } |
| 13710 | |
| 13711 | vosStatus = hdd_get_next_adapter(pHddCtx, pAdapterNode, |
| 13712 | &pNext); |
| 13713 | pAdapterNode = pNext; |
| 13714 | } |
| 13715 | } |
| 13716 | |
| 13717 | sme_UpdateDFSScanMode(pHddCtx->hHal, dfsScanMode); |
| 13718 | sme_UpdateDFSRoamMode(pHddCtx->hHal, |
| 13719 | (dfsScanMode != DFS_CHNL_SCAN_DISABLED)); |
| 13720 | |
| 13721 | status = sme_HandleDFSChanScan(pHddCtx->hHal); |
| 13722 | if (!HAL_STATUS_SUCCESS(status)) |
| 13723 | { |
| 13724 | hddLog(LOGE, |
| 13725 | FL("Failed in sme_HandleDFSChanScan (err=%d)"), status); |
| 13726 | return status; |
| 13727 | } |
| 13728 | |
| 13729 | return status; |
| 13730 | } |
| 13731 | |
Nirav Shah | 7e3c813 | 2015-06-22 23:51:42 +0530 | [diff] [blame] | 13732 | static int hdd_log2_ceil(unsigned value) |
| 13733 | { |
| 13734 | /* need to switch to unsigned math so that negative values |
| 13735 | * will right-shift towards 0 instead of -1 |
| 13736 | */ |
| 13737 | unsigned tmp = value; |
| 13738 | int log2 = -1; |
| 13739 | |
| 13740 | if (value == 0) |
| 13741 | return 0; |
| 13742 | |
| 13743 | while (tmp) { |
| 13744 | log2++; |
| 13745 | tmp >>= 1; |
| 13746 | } |
| 13747 | if (1U << log2 != value) |
| 13748 | log2++; |
| 13749 | |
| 13750 | return log2; |
| 13751 | } |
| 13752 | |
| 13753 | /** |
| 13754 | * hdd_sta_id_hash_attach() - initialize sta id to macaddr hash |
| 13755 | * @pAdapter: adapter handle |
| 13756 | * |
| 13757 | * Return: vos status |
| 13758 | */ |
| 13759 | VOS_STATUS hdd_sta_id_hash_attach(hdd_adapter_t *pAdapter) |
| 13760 | { |
| 13761 | int hash_elem, log2, i; |
| 13762 | |
| 13763 | spin_lock_bh( &pAdapter->sta_hash_lock); |
| 13764 | if (pAdapter->is_sta_id_hash_initialized == VOS_TRUE) { |
| 13765 | spin_unlock_bh( &pAdapter->sta_hash_lock); |
| 13766 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 13767 | "%s: hash already attached for session id %d", |
| 13768 | __func__, pAdapter->sessionId); |
| 13769 | return VOS_STATUS_SUCCESS; |
| 13770 | } |
| 13771 | spin_unlock_bh( &pAdapter->sta_hash_lock); |
| 13772 | |
| 13773 | hash_elem = WLAN_MAX_STA_COUNT; |
| 13774 | hash_elem *= HDD_STA_ID_HASH_MULTIPLIER; |
| 13775 | log2 = hdd_log2_ceil(hash_elem); |
| 13776 | hash_elem = 1 << log2; |
| 13777 | |
| 13778 | pAdapter->sta_id_hash.mask = hash_elem - 1; |
| 13779 | pAdapter->sta_id_hash.idx_bits = log2; |
| 13780 | pAdapter->sta_id_hash.bins = |
| 13781 | vos_mem_malloc(hash_elem *sizeof(hdd_list_t)); |
| 13782 | if (!pAdapter->sta_id_hash.bins) { |
| 13783 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 13784 | "%s: malloc failed for session %d", |
| 13785 | __func__, pAdapter->sessionId); |
| 13786 | return VOS_STATUS_E_NOMEM; |
| 13787 | } |
| 13788 | |
| 13789 | for (i = 0; i < hash_elem; i++) |
| 13790 | hdd_list_init(&pAdapter->sta_id_hash.bins[i], WLAN_MAX_STA_COUNT); |
| 13791 | |
| 13792 | spin_lock_bh( &pAdapter->sta_hash_lock); |
| 13793 | pAdapter->is_sta_id_hash_initialized = VOS_TRUE; |
| 13794 | spin_unlock_bh( &pAdapter->sta_hash_lock); |
| 13795 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 13796 | "%s: Station ID Hash attached for session id %d", |
| 13797 | __func__, pAdapter->sessionId); |
| 13798 | |
| 13799 | return VOS_STATUS_SUCCESS; |
| 13800 | } |
| 13801 | |
| 13802 | /** |
| 13803 | * hdd_sta_id_hash_detach() - deinit sta_id to macaddr hash |
| 13804 | * @pAdapter: adapter handle |
| 13805 | * |
| 13806 | * Return: vos status |
| 13807 | */ |
| 13808 | VOS_STATUS hdd_sta_id_hash_detach(hdd_adapter_t *pAdapter) |
| 13809 | { |
| 13810 | int hash_elem, i; |
| 13811 | v_SIZE_t size; |
| 13812 | |
| 13813 | spin_lock_bh( &pAdapter->sta_hash_lock); |
| 13814 | if (pAdapter->is_sta_id_hash_initialized != VOS_TRUE) { |
| 13815 | spin_unlock_bh( &pAdapter->sta_hash_lock); |
| 13816 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 13817 | "%s: hash not initialized for session id %d", |
| 13818 | __func__, pAdapter->sessionId); |
| 13819 | return VOS_STATUS_SUCCESS; |
| 13820 | } |
| 13821 | |
| 13822 | pAdapter->is_sta_id_hash_initialized = VOS_FALSE; |
| 13823 | spin_unlock_bh( &pAdapter->sta_hash_lock); |
| 13824 | |
| 13825 | hash_elem = 1 << pAdapter->sta_id_hash.idx_bits; |
| 13826 | |
| 13827 | /* free all station info*/ |
| 13828 | for (i = 0; i < hash_elem; i++) { |
| 13829 | hdd_list_size(&pAdapter->sta_id_hash.bins[i], &size); |
| 13830 | if (size != 0) { |
| 13831 | VOS_STATUS status; |
| 13832 | hdd_staid_hash_node_t *sta_info_node = NULL; |
| 13833 | hdd_staid_hash_node_t *next_node = NULL; |
| 13834 | status = hdd_list_peek_front ( &pAdapter->sta_id_hash.bins[i], |
| 13835 | (hdd_list_node_t**) &sta_info_node ); |
| 13836 | |
| 13837 | while ( NULL != sta_info_node && VOS_STATUS_SUCCESS == status ) |
| 13838 | { |
| 13839 | status = hdd_list_remove_node( &pAdapter->sta_id_hash.bins[i], |
| 13840 | &sta_info_node->node); |
| 13841 | vos_mem_free(sta_info_node); |
| 13842 | |
| 13843 | status = hdd_list_peek_next (&pAdapter->sta_id_hash.bins[i], |
| 13844 | (hdd_list_node_t*)sta_info_node, |
| 13845 | (hdd_list_node_t**)&next_node); |
| 13846 | sta_info_node = next_node; |
| 13847 | } |
| 13848 | } |
| 13849 | } |
| 13850 | |
| 13851 | vos_mem_free(pAdapter->sta_id_hash.bins); |
| 13852 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 13853 | "%s: Station ID Hash detached for session id %d", |
| 13854 | __func__, pAdapter->sessionId); |
| 13855 | return VOS_STATUS_SUCCESS; |
| 13856 | } |
| 13857 | |
| 13858 | /** |
| 13859 | * hdd_sta_id_hash_calculate_index() - derive index from macaddr |
| 13860 | * @pAdapter: adapter handle |
| 13861 | * @mac_addr_in: input mac address |
| 13862 | * |
| 13863 | * Return: index derived from mac address |
| 13864 | */ |
| 13865 | int hdd_sta_id_hash_calculate_index(hdd_adapter_t *pAdapter, |
| 13866 | v_MACADDR_t *mac_addr_in) |
| 13867 | { |
| 13868 | uint16 index; |
| 13869 | struct hdd_align_mac_addr_t * mac_addr = |
| 13870 | (struct hdd_align_mac_addr_t *)mac_addr_in; |
| 13871 | |
| 13872 | index = mac_addr->bytes_ab ^ |
| 13873 | mac_addr->bytes_cd ^ mac_addr->bytes_ef; |
| 13874 | index ^= index >> pAdapter->sta_id_hash.idx_bits; |
| 13875 | index &= pAdapter->sta_id_hash.mask; |
| 13876 | return index; |
| 13877 | } |
| 13878 | |
| 13879 | /** |
| 13880 | * hdd_sta_id_hash_add_entry() - add entry in hash |
| 13881 | * @pAdapter: adapter handle |
| 13882 | * @sta_id: station id |
| 13883 | * @mac_addr: mac address |
| 13884 | * |
| 13885 | * Return: vos status |
| 13886 | */ |
| 13887 | VOS_STATUS hdd_sta_id_hash_add_entry(hdd_adapter_t *pAdapter, |
| 13888 | v_U8_t sta_id, v_MACADDR_t *mac_addr) |
| 13889 | { |
| 13890 | uint16 index; |
| 13891 | hdd_staid_hash_node_t *sta_info_node = NULL; |
| 13892 | |
Nirav Shah | 7e3c813 | 2015-06-22 23:51:42 +0530 | [diff] [blame] | 13893 | index = hdd_sta_id_hash_calculate_index(pAdapter, mac_addr); |
| 13894 | sta_info_node = vos_mem_malloc(sizeof(hdd_staid_hash_node_t)); |
| 13895 | if (!sta_info_node) { |
Nirav Shah | 7e3c813 | 2015-06-22 23:51:42 +0530 | [diff] [blame] | 13896 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 13897 | "%s: malloc failed", __func__); |
| 13898 | return VOS_STATUS_E_NOMEM; |
| 13899 | } |
| 13900 | |
| 13901 | sta_info_node->sta_id = sta_id; |
| 13902 | vos_mem_copy(&sta_info_node->mac_addr, mac_addr, sizeof(v_MACADDR_t)); |
| 13903 | |
Nirav Shah | 303ed5c | 2015-08-24 10:29:25 +0530 | [diff] [blame] | 13904 | spin_lock_bh( &pAdapter->sta_hash_lock); |
| 13905 | if (pAdapter->is_sta_id_hash_initialized != VOS_TRUE) { |
| 13906 | spin_unlock_bh( &pAdapter->sta_hash_lock); |
| 13907 | vos_mem_free(sta_info_node); |
| 13908 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 13909 | "%s: hash is not initialized for session id %d", |
| 13910 | __func__, pAdapter->sessionId); |
| 13911 | return VOS_STATUS_E_FAILURE; |
| 13912 | } |
| 13913 | |
Nirav Shah | 7e3c813 | 2015-06-22 23:51:42 +0530 | [diff] [blame] | 13914 | hdd_list_insert_back ( &pAdapter->sta_id_hash.bins[index], |
| 13915 | (hdd_list_node_t*) sta_info_node ); |
| 13916 | spin_unlock_bh( &pAdapter->sta_hash_lock); |
| 13917 | return VOS_STATUS_SUCCESS; |
| 13918 | } |
| 13919 | |
| 13920 | /** |
| 13921 | * hdd_sta_id_hash_remove_entry() - remove entry from hash |
| 13922 | * @pAdapter: adapter handle |
| 13923 | * @sta_id: station id |
| 13924 | * @mac_addr: mac address |
| 13925 | * |
| 13926 | * Return: vos status |
| 13927 | */ |
| 13928 | VOS_STATUS hdd_sta_id_hash_remove_entry(hdd_adapter_t *pAdapter, |
| 13929 | v_U8_t sta_id, v_MACADDR_t *mac_addr) |
| 13930 | { |
| 13931 | uint16 index; |
| 13932 | VOS_STATUS status; |
| 13933 | hdd_staid_hash_node_t *sta_info_node = NULL; |
| 13934 | hdd_staid_hash_node_t *next_node = NULL; |
| 13935 | |
| 13936 | spin_lock_bh( &pAdapter->sta_hash_lock); |
| 13937 | if (pAdapter->is_sta_id_hash_initialized != VOS_TRUE) { |
| 13938 | spin_unlock_bh( &pAdapter->sta_hash_lock); |
| 13939 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 13940 | "%s: hash is not initialized for session id %d", |
| 13941 | __func__, pAdapter->sessionId); |
| 13942 | return VOS_STATUS_E_FAILURE; |
| 13943 | } |
| 13944 | |
| 13945 | index = hdd_sta_id_hash_calculate_index(pAdapter, mac_addr); |
| 13946 | status = hdd_list_peek_front ( &pAdapter->sta_id_hash.bins[index], |
| 13947 | (hdd_list_node_t**) &sta_info_node ); |
| 13948 | |
| 13949 | while ( NULL != sta_info_node && VOS_STATUS_SUCCESS == status ) |
| 13950 | { |
| 13951 | if (sta_info_node->sta_id == sta_id) { |
| 13952 | status = hdd_list_remove_node( &pAdapter->sta_id_hash.bins[index], |
| 13953 | &sta_info_node->node); |
| 13954 | vos_mem_free(sta_info_node); |
| 13955 | break; |
| 13956 | } |
| 13957 | status = hdd_list_peek_next (&pAdapter->sta_id_hash.bins[index], |
| 13958 | (hdd_list_node_t*)sta_info_node, (hdd_list_node_t**)&next_node); |
| 13959 | sta_info_node = next_node; |
| 13960 | } |
| 13961 | spin_unlock_bh( &pAdapter->sta_hash_lock); |
| 13962 | return status; |
| 13963 | } |
| 13964 | |
| 13965 | /** |
| 13966 | * hdd_sta_id_find_from_mac_addr() - find sta id from mac address |
| 13967 | * @pAdapter: adapter handle |
| 13968 | * @mac_addr_in: mac address |
| 13969 | * |
| 13970 | * Return: station id |
| 13971 | */ |
| 13972 | int hdd_sta_id_find_from_mac_addr(hdd_adapter_t *pAdapter, |
| 13973 | v_MACADDR_t *mac_addr_in) |
| 13974 | { |
| 13975 | uint8 is_found = 0; |
| 13976 | uint8 sta_id = HDD_WLAN_INVALID_STA_ID; |
| 13977 | uint16 index; |
| 13978 | VOS_STATUS status; |
| 13979 | hdd_staid_hash_node_t *sta_info_node = NULL; |
| 13980 | hdd_staid_hash_node_t *next_node = NULL; |
| 13981 | |
| 13982 | spin_lock_bh( &pAdapter->sta_hash_lock); |
| 13983 | if (pAdapter->is_sta_id_hash_initialized != VOS_TRUE) { |
| 13984 | spin_unlock_bh( &pAdapter->sta_hash_lock); |
Bhargav Shah | ce3b32c | 2015-08-10 12:29:24 +0530 | [diff] [blame] | 13985 | hddLog(VOS_TRACE_LEVEL_INFO, |
Nirav Shah | 7e3c813 | 2015-06-22 23:51:42 +0530 | [diff] [blame] | 13986 | FL("hash is not initialized for session id %d"), |
| 13987 | pAdapter->sessionId); |
| 13988 | return HDD_WLAN_INVALID_STA_ID; |
| 13989 | } |
| 13990 | |
| 13991 | index = hdd_sta_id_hash_calculate_index(pAdapter, mac_addr_in); |
| 13992 | status = hdd_list_peek_front ( &pAdapter->sta_id_hash.bins[index], |
| 13993 | (hdd_list_node_t**) &sta_info_node ); |
| 13994 | |
| 13995 | while ( NULL != sta_info_node && VOS_STATUS_SUCCESS == status ) |
| 13996 | { |
| 13997 | if (vos_mem_compare(&sta_info_node->mac_addr, |
| 13998 | mac_addr_in, sizeof(v_MACADDR_t))) { |
| 13999 | is_found = 1; |
| 14000 | sta_id = sta_info_node->sta_id; |
| 14001 | break; |
| 14002 | } |
| 14003 | status = hdd_list_peek_next (&pAdapter->sta_id_hash.bins[index], |
| 14004 | (hdd_list_node_t*)sta_info_node, |
| 14005 | (hdd_list_node_t**)&next_node); |
| 14006 | sta_info_node = next_node; |
| 14007 | } |
| 14008 | spin_unlock_bh( &pAdapter->sta_hash_lock); |
| 14009 | return sta_id; |
| 14010 | } |
| 14011 | |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 14012 | /*FW memory dump feature*/ |
| 14013 | /** |
| 14014 | * This structure hold information about the /proc file |
| 14015 | * |
| 14016 | */ |
| 14017 | static struct proc_dir_entry *proc_file, *proc_dir; |
| 14018 | |
| 14019 | /** |
| 14020 | * memdump_read() - perform read operation in memory dump proc file |
| 14021 | * |
| 14022 | * @file - handle for the proc file. |
| 14023 | * @buf - pointer to user space buffer. |
| 14024 | * @count - number of bytes to be read. |
| 14025 | * @pos - offset in the from buffer. |
| 14026 | * |
| 14027 | * This function performs read operation for the memory dump proc file. |
| 14028 | * |
| 14029 | * Return: number of bytes read on success, error code otherwise. |
| 14030 | */ |
| 14031 | static ssize_t memdump_read(struct file *file, char __user *buf, |
| 14032 | size_t count, loff_t *pos) |
| 14033 | { |
| 14034 | int status; |
| 14035 | hdd_context_t *hdd_ctx = (hdd_context_t *)PDE_DATA(file_inode(file)); |
| 14036 | size_t ret_count; |
c_manjee | f149564 | 2015-10-13 18:35:01 +0530 | [diff] [blame] | 14037 | loff_t bytes_left; |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 14038 | ENTER(); |
| 14039 | |
| 14040 | hddLog(LOG1, FL("Read req for size:%zu pos:%llu"), count, *pos); |
| 14041 | status = wlan_hdd_validate_context(hdd_ctx); |
| 14042 | if (0 != status) { |
| 14043 | return -EINVAL; |
| 14044 | } |
| 14045 | |
| 14046 | if (!wlan_fwr_mem_dump_test_and_set_read_allowed_bit()) { |
| 14047 | hddLog(LOGE, FL("Current mem dump request timed out/failed")); |
| 14048 | return -EINVAL; |
| 14049 | } |
| 14050 | |
| 14051 | /* run fs_read_handler in an atomic context*/ |
| 14052 | vos_ssr_protect(__func__); |
c_manjee | f149564 | 2015-10-13 18:35:01 +0530 | [diff] [blame] | 14053 | ret_count = wlan_fwr_mem_dump_fsread_handler( buf, count, pos, &bytes_left); |
| 14054 | if(bytes_left == 0) |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 14055 | { |
| 14056 | /*Free the fwr mem dump buffer */ |
| 14057 | wlan_free_fwr_mem_dump_buffer(); |
| 14058 | wlan_set_fwr_mem_dump_state(FW_MEM_DUMP_IDLE); |
c_manjee | f149564 | 2015-10-13 18:35:01 +0530 | [diff] [blame] | 14059 | ret_count=0; |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 14060 | } |
| 14061 | /*if SSR/unload code is waiting for memdump_read to finish,signal it*/ |
| 14062 | vos_ssr_unprotect(__func__); |
| 14063 | EXIT(); |
| 14064 | return ret_count; |
| 14065 | } |
| 14066 | |
| 14067 | /** |
| 14068 | * struct memdump_fops - file operations for memory dump feature |
| 14069 | * @read - read function for memory dump operation. |
| 14070 | * |
| 14071 | * This structure initialize the file operation handle for memory |
| 14072 | * dump feature |
| 14073 | */ |
| 14074 | static const struct file_operations memdump_fops = { |
| 14075 | read: memdump_read |
| 14076 | }; |
| 14077 | |
| 14078 | /* |
| 14079 | * wlan_hdd_fw_mem_dump_cb : callback for Fw mem dump request |
| 14080 | * To be passed by HDD to WDA and called upon receiving of response |
| 14081 | * from firmware |
| 14082 | * @fwMemDumpReqContext : memory dump request context |
| 14083 | * @dump_rsp : dump response from HAL |
| 14084 | * Returns none |
| 14085 | */ |
| 14086 | void wlan_hdd_fw_mem_dump_cb(void *fwMemDumpReqContext, |
| 14087 | tAniFwrDumpRsp *dump_rsp) |
| 14088 | { |
c_manjee | f149564 | 2015-10-13 18:35:01 +0530 | [diff] [blame] | 14089 | struct hdd_fw_mem_dump_req_ctx *pHddFwMemDumpCtx = (struct hdd_fw_mem_dump_req_ctx *)fwMemDumpReqContext; |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 14090 | |
c_manjee | f149564 | 2015-10-13 18:35:01 +0530 | [diff] [blame] | 14091 | ENTER(); |
| 14092 | spin_lock(&hdd_context_lock); |
| 14093 | if(!pHddFwMemDumpCtx || (FW_MEM_DUMP_MAGIC != pHddFwMemDumpCtx->magic)) { |
| 14094 | spin_unlock(&hdd_context_lock); |
| 14095 | return; |
| 14096 | } |
| 14097 | /* report the status to requesting function and free mem.*/ |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 14098 | if (dump_rsp->dump_status != eHAL_STATUS_SUCCESS) { |
c_manjee | f149564 | 2015-10-13 18:35:01 +0530 | [diff] [blame] | 14099 | hddLog(LOGE, FL("fw dump request declined by fwr")); |
| 14100 | //set the request completion variable |
| 14101 | complete(&(pHddFwMemDumpCtx->req_completion)); |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 14102 | //Free the allocated fwr dump |
| 14103 | wlan_free_fwr_mem_dump_buffer(); |
| 14104 | wlan_set_fwr_mem_dump_state(FW_MEM_DUMP_IDLE); |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 14105 | } |
c_manjee | f149564 | 2015-10-13 18:35:01 +0530 | [diff] [blame] | 14106 | else { |
| 14107 | hddLog(LOG1, FL("fw dump request accepted by fwr")); |
| 14108 | /* register the HDD callback which will be called by SVC */ |
| 14109 | wlan_set_svc_fw_mem_dump_req_cb((void*)wlan_hdd_fw_mem_dump_req_cb,(void*)pHddFwMemDumpCtx); |
| 14110 | } |
| 14111 | spin_unlock(&hdd_context_lock); |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 14112 | EXIT(); |
| 14113 | |
| 14114 | } |
| 14115 | |
| 14116 | /** |
| 14117 | * memdump_procfs_remove() - Remove file/dir under procfs for memory dump |
| 14118 | * |
| 14119 | * This function removes file/dir under proc file system that was |
| 14120 | * processing firmware memory dump |
| 14121 | * |
| 14122 | * Return: None |
| 14123 | */ |
| 14124 | static void memdump_procfs_remove(void) |
| 14125 | { |
| 14126 | remove_proc_entry(PROCFS_MEMDUMP_NAME, proc_dir); |
| 14127 | hddLog(LOG1 , FL("/proc/%s/%s removed\n"), |
| 14128 | PROCFS_MEMDUMP_DIR, PROCFS_MEMDUMP_NAME); |
| 14129 | remove_proc_entry(PROCFS_MEMDUMP_DIR, NULL); |
| 14130 | hddLog(LOG1 , FL("/proc/%s removed\n"), PROCFS_MEMDUMP_DIR); |
| 14131 | } |
| 14132 | |
| 14133 | /** |
| 14134 | * memdump_procfs_init() - Initialize procfs for memory dump |
| 14135 | * |
| 14136 | * @vos_ctx - Global vos context. |
| 14137 | * |
| 14138 | * This function create file under proc file system to be used later for |
| 14139 | * processing firmware memory dump |
| 14140 | * |
| 14141 | * Return: 0 on success, error code otherwise. |
| 14142 | */ |
| 14143 | static int memdump_procfs_init(void *vos_ctx) |
| 14144 | { |
| 14145 | hdd_context_t *hdd_ctx; |
| 14146 | |
| 14147 | hdd_ctx = vos_get_context(VOS_MODULE_ID_HDD, vos_ctx); |
| 14148 | if (!hdd_ctx) { |
| 14149 | hddLog(LOGE , FL("Invalid HDD context")); |
| 14150 | return -EINVAL; |
| 14151 | } |
| 14152 | |
| 14153 | proc_dir = proc_mkdir(PROCFS_MEMDUMP_DIR, NULL); |
| 14154 | if (proc_dir == NULL) { |
| 14155 | remove_proc_entry(PROCFS_MEMDUMP_DIR, NULL); |
| 14156 | hddLog(LOGE , FL("Error: Could not initialize /proc/%s"), |
| 14157 | PROCFS_MEMDUMP_DIR); |
| 14158 | return -ENOMEM; |
| 14159 | } |
| 14160 | |
| 14161 | proc_file = proc_create_data(PROCFS_MEMDUMP_NAME, |
| 14162 | S_IRUSR | S_IWUSR, proc_dir, |
| 14163 | &memdump_fops, hdd_ctx); |
| 14164 | if (proc_file == NULL) { |
| 14165 | remove_proc_entry(PROCFS_MEMDUMP_NAME, proc_dir); |
| 14166 | hddLog(LOGE , FL("Error: Could not initialize /proc/%s"), |
| 14167 | PROCFS_MEMDUMP_NAME); |
| 14168 | return -ENOMEM; |
| 14169 | } |
| 14170 | |
| 14171 | hddLog(LOG1 , FL("/proc/%s/%s created"), |
| 14172 | PROCFS_MEMDUMP_DIR, PROCFS_MEMDUMP_NAME); |
| 14173 | |
| 14174 | return 0; |
| 14175 | } |
| 14176 | |
| 14177 | /** |
| 14178 | * memdump_init() - Initialization function for memory dump feature |
| 14179 | * |
| 14180 | * This function creates proc file for memdump feature and registers |
| 14181 | * HDD callback function with SME. |
| 14182 | * |
| 14183 | * Return - 0 on success, error otherwise |
| 14184 | */ |
| 14185 | int memdump_init(void) |
| 14186 | { |
| 14187 | hdd_context_t *hdd_ctx; |
| 14188 | void *vos_ctx; |
| 14189 | int status = 0; |
| 14190 | |
| 14191 | vos_ctx = vos_get_global_context(VOS_MODULE_ID_SYS, NULL); |
| 14192 | if (!vos_ctx) { |
| 14193 | hddLog(LOGE, FL("Invalid VOS context")); |
| 14194 | return -EINVAL; |
| 14195 | } |
| 14196 | |
| 14197 | hdd_ctx = vos_get_context(VOS_MODULE_ID_HDD, vos_ctx); |
| 14198 | if (!hdd_ctx) { |
| 14199 | hddLog(LOGE , FL("Invalid HDD context")); |
| 14200 | return -EINVAL; |
| 14201 | } |
| 14202 | |
| 14203 | status = memdump_procfs_init(vos_ctx); |
| 14204 | if (status) { |
| 14205 | hddLog(LOGE , FL("Failed to create proc file")); |
| 14206 | return status; |
| 14207 | } |
| 14208 | |
| 14209 | return 0; |
| 14210 | } |
| 14211 | |
| 14212 | /** |
| 14213 | * memdump_deinit() - De initialize memdump feature |
| 14214 | * |
| 14215 | * This function removes proc file created for memdump feature. |
| 14216 | * |
| 14217 | * Return: None |
| 14218 | */ |
| 14219 | int memdump_deinit(void) |
| 14220 | { |
| 14221 | hdd_context_t *hdd_ctx; |
| 14222 | void *vos_ctx; |
| 14223 | |
| 14224 | vos_ctx = vos_get_global_context(VOS_MODULE_ID_SYS, NULL); |
| 14225 | if (!vos_ctx) { |
| 14226 | hddLog(LOGE, FL("Invalid VOS context")); |
| 14227 | return -EINVAL; |
| 14228 | } |
| 14229 | |
| 14230 | hdd_ctx = vos_get_context(VOS_MODULE_ID_HDD, vos_ctx); |
| 14231 | if(!hdd_ctx) { |
| 14232 | hddLog(LOGE , FL("Invalid HDD context")); |
| 14233 | return -EINVAL; |
| 14234 | } |
| 14235 | |
| 14236 | memdump_procfs_remove(); |
| 14237 | return 0; |
| 14238 | } |
| 14239 | |
| 14240 | /** |
| 14241 | * wlan_hdd_fw_mem_dump_req(pHddCtx) - common API(cfg80211/ioctl) for requesting fw mem dump to SME |
| 14242 | * Return: HAL status |
| 14243 | */ |
| 14244 | |
| 14245 | int wlan_hdd_fw_mem_dump_req(hdd_context_t * pHddCtx) |
| 14246 | { |
| 14247 | tAniFwrDumpReq fw_mem_dump_req={0}; |
c_manjee | f149564 | 2015-10-13 18:35:01 +0530 | [diff] [blame] | 14248 | struct hdd_fw_mem_dump_req_ctx fw_mem_dump_ctx; |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 14249 | eHalStatus status = eHAL_STATUS_FAILURE; |
Abhishek Singh | 4eca982 | 2015-12-09 18:07:34 +0530 | [diff] [blame] | 14250 | int ret=0, result; |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 14251 | ENTER(); |
c_manjee | f149564 | 2015-10-13 18:35:01 +0530 | [diff] [blame] | 14252 | |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 14253 | /*Check whether a dump request is already going on |
| 14254 | *Caution this function will free previously held memory if new dump request is allowed*/ |
| 14255 | if (!wlan_fwr_mem_dump_test_and_set_write_allowed_bit()) { |
| 14256 | hddLog(LOGE, FL("Fw memdump already in progress")); |
| 14257 | return -EBUSY; |
| 14258 | } |
| 14259 | //Allocate memory for fw mem dump buffer |
| 14260 | ret = wlan_fwr_mem_dump_buffer_allocation(); |
| 14261 | if(ret == -EFAULT) |
| 14262 | { |
| 14263 | hddLog(LOGE, FL("Fwr mem dump not supported by FW")); |
| 14264 | return ret; |
| 14265 | } |
| 14266 | if (0 != ret) { |
| 14267 | hddLog(LOGE, FL("Fwr mem Allocation failed")); |
| 14268 | return -ENOMEM; |
| 14269 | } |
c_manjee | f149564 | 2015-10-13 18:35:01 +0530 | [diff] [blame] | 14270 | init_completion(&fw_mem_dump_ctx.req_completion); |
| 14271 | fw_mem_dump_ctx.magic = FW_MEM_DUMP_MAGIC; |
| 14272 | fw_mem_dump_ctx.status = false; |
| 14273 | |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 14274 | fw_mem_dump_req.fwMemDumpReqCallback = wlan_hdd_fw_mem_dump_cb; |
c_manjee | f149564 | 2015-10-13 18:35:01 +0530 | [diff] [blame] | 14275 | fw_mem_dump_req.fwMemDumpReqContext = &fw_mem_dump_ctx; |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 14276 | status = sme_FwMemDumpReq(pHddCtx->hHal, &fw_mem_dump_req); |
| 14277 | if(eHAL_STATUS_SUCCESS != status) |
| 14278 | { |
| 14279 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 14280 | "%s: fw_mem_dump_req failed ", __func__); |
| 14281 | wlan_free_fwr_mem_dump_buffer(); |
c_manjee | f149564 | 2015-10-13 18:35:01 +0530 | [diff] [blame] | 14282 | ret = -EFAULT; |
| 14283 | goto cleanup; |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 14284 | } |
c_manjee | f149564 | 2015-10-13 18:35:01 +0530 | [diff] [blame] | 14285 | /*wait for fw mem dump completion to send event to userspace*/ |
Abhishek Singh | 4eca982 | 2015-12-09 18:07:34 +0530 | [diff] [blame] | 14286 | result = |
| 14287 | wait_for_completion_timeout(&fw_mem_dump_ctx.req_completion, |
| 14288 | msecs_to_jiffies(FW_MEM_DUMP_TIMEOUT_MS)); |
| 14289 | if (0 >= result ) |
c_manjee | f149564 | 2015-10-13 18:35:01 +0530 | [diff] [blame] | 14290 | { |
| 14291 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Abhishek Singh | 4eca982 | 2015-12-09 18:07:34 +0530 | [diff] [blame] | 14292 | "%s: fw_mem_dump_req timeout %d ", __func__,result); |
| 14293 | ret = -ETIMEDOUT; |
c_manjee | f149564 | 2015-10-13 18:35:01 +0530 | [diff] [blame] | 14294 | } |
| 14295 | cleanup: |
| 14296 | spin_lock(&hdd_context_lock); |
| 14297 | fw_mem_dump_ctx.magic = 0; |
Abhishek Singh | 4eca982 | 2015-12-09 18:07:34 +0530 | [diff] [blame] | 14298 | if(!ret && !fw_mem_dump_ctx.status) |
| 14299 | ret = -EFAULT; |
c_manjee | f149564 | 2015-10-13 18:35:01 +0530 | [diff] [blame] | 14300 | spin_unlock(&hdd_context_lock); |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 14301 | |
c_manjee | f149564 | 2015-10-13 18:35:01 +0530 | [diff] [blame] | 14302 | EXIT(); |
Abhishek Singh | 4eca982 | 2015-12-09 18:07:34 +0530 | [diff] [blame] | 14303 | return ret; |
c_manjee | f149564 | 2015-10-13 18:35:01 +0530 | [diff] [blame] | 14304 | } |
| 14305 | |
| 14306 | /** |
| 14307 | * HDD callback which will be called by SVC to indicate mem dump completion. |
| 14308 | */ |
| 14309 | void wlan_hdd_fw_mem_dump_req_cb(struct hdd_fw_mem_dump_req_ctx* pHddFwMemDumpCtx) |
| 14310 | { |
| 14311 | if (!pHddFwMemDumpCtx) { |
| 14312 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 14313 | "%s: HDD context not valid ", __func__); |
| 14314 | return; |
| 14315 | } |
| 14316 | spin_lock(&hdd_context_lock); |
| 14317 | /* check the req magic and set status */ |
| 14318 | if (pHddFwMemDumpCtx->magic == FW_MEM_DUMP_MAGIC) |
| 14319 | { |
| 14320 | pHddFwMemDumpCtx->status = true; |
| 14321 | //signal the completion |
| 14322 | complete(&(pHddFwMemDumpCtx->req_completion)); |
| 14323 | } |
| 14324 | else |
| 14325 | { |
| 14326 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 14327 | "%s: fw mem dump request possible timeout ", __func__); |
| 14328 | } |
| 14329 | spin_unlock(&hdd_context_lock); |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 14330 | } |
| 14331 | |
Mahesh A Saptasagar | 67ab922 | 2015-10-21 15:38:41 +0530 | [diff] [blame] | 14332 | void hdd_initialize_adapter_common(hdd_adapter_t *pAdapter) |
| 14333 | { |
| 14334 | if (NULL == pAdapter) |
| 14335 | { |
| 14336 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: pAdapter is NULL ", __func__); |
| 14337 | return; |
| 14338 | } |
| 14339 | init_completion(&pAdapter->session_open_comp_var); |
| 14340 | init_completion(&pAdapter->session_close_comp_var); |
| 14341 | init_completion(&pAdapter->disconnect_comp_var); |
| 14342 | init_completion(&pAdapter->linkup_event_var); |
| 14343 | init_completion(&pAdapter->cancel_rem_on_chan_var); |
| 14344 | init_completion(&pAdapter->rem_on_chan_ready_event); |
| 14345 | init_completion(&pAdapter->pno_comp_var); |
| 14346 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 14347 | init_completion(&pAdapter->offchannel_tx_event); |
| 14348 | #endif |
| 14349 | init_completion(&pAdapter->tx_action_cnf_event); |
| 14350 | #ifdef FEATURE_WLAN_TDLS |
| 14351 | init_completion(&pAdapter->tdls_add_station_comp); |
| 14352 | init_completion(&pAdapter->tdls_del_station_comp); |
| 14353 | init_completion(&pAdapter->tdls_mgmt_comp); |
| 14354 | init_completion(&pAdapter->tdls_link_establish_req_comp); |
| 14355 | #endif |
| 14356 | |
| 14357 | #ifdef WLAN_FEATURE_RMC |
| 14358 | init_completion(&pAdapter->ibss_peer_info_comp); |
| 14359 | #endif /* WLAN_FEATURE_RMC */ |
| 14360 | init_completion(&pAdapter->ula_complete); |
| 14361 | init_completion(&pAdapter->change_country_code); |
| 14362 | |
| 14363 | #ifdef FEATURE_WLAN_BATCH_SCAN |
| 14364 | init_completion(&pAdapter->hdd_set_batch_scan_req_var); |
| 14365 | init_completion(&pAdapter->hdd_get_batch_scan_req_var); |
| 14366 | #endif |
| 14367 | |
| 14368 | return; |
| 14369 | } |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 14370 | |
| 14371 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14372 | //Register the module init/exit functions |
| 14373 | module_init(hdd_module_init); |
| 14374 | module_exit(hdd_module_exit); |
| 14375 | |
| 14376 | MODULE_LICENSE("Dual BSD/GPL"); |
| 14377 | MODULE_AUTHOR("Qualcomm Atheros, Inc."); |
| 14378 | MODULE_DESCRIPTION("WLAN HOST DEVICE DRIVER"); |
| 14379 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 14380 | module_param_call(con_mode, con_mode_handler, param_get_int, &con_mode, |
| 14381 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 14382 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 14383 | module_param_call(fwpath, fwpath_changed_handler, param_get_string, &fwpath, |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 14384 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 14385 | |
| 14386 | module_param(enable_dfs_chan_scan, int, |
| 14387 | S_IRUSR | S_IRGRP | S_IROTH); |
| 14388 | |
| 14389 | module_param(enable_11d, int, |
| 14390 | S_IRUSR | S_IRGRP | S_IROTH); |
| 14391 | |
| 14392 | module_param(country_code, charp, |
| 14393 | S_IRUSR | S_IRGRP | S_IROTH); |