Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
Rajeev Kumar Sirasanagandla | a74e122 | 2018-01-09 17:38:55 +0530 | [diff] [blame] | 2 | * Copyright (c) 2012-2018 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 | |
Selvaraj, Sridhar | 5aff1ed | 2016-06-18 01:26:23 +0530 | [diff] [blame] | 216 | /* |
| 217 | * Android DRIVER command structures |
| 218 | */ |
| 219 | struct android_wifi_reassoc_params { |
| 220 | unsigned char bssid[18]; |
| 221 | int channel; |
| 222 | }; |
| 223 | |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 224 | static vos_wake_lock_t wlan_wake_lock; |
| 225 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 226 | /* set when SSR is needed after unload */ |
Madan Mohan Koyyalamudi | b5da533 | 2012-10-15 17:23:21 -0700 | [diff] [blame] | 227 | static e_hdd_ssr_required isSsrRequired = HDD_SSR_NOT_REQUIRED; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 228 | |
| 229 | //internal function declaration |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 230 | static VOS_STATUS wlan_hdd_framework_restart(hdd_context_t *pHddCtx); |
| 231 | static void wlan_hdd_restart_init(hdd_context_t *pHddCtx); |
| 232 | static void wlan_hdd_restart_deinit(hdd_context_t *pHddCtx); |
Abhishek Singh | 00b7197 | 2016-01-07 10:51:04 +0530 | [diff] [blame] | 233 | |
| 234 | #ifdef WLAN_FEATURE_RMC |
| 235 | static void hdd_tx_fail_ind_callback(v_U8_t *MacAddr, v_U8_t seqNo); |
| 236 | |
| 237 | static int hdd_open_cesium_nl_sock(void); |
| 238 | static void hdd_close_cesium_nl_sock(void); |
| 239 | static struct sock *cesium_nl_srv_sock; |
| 240 | static v_U16_t cesium_pid; |
| 241 | |
| 242 | static int hdd_ParseIBSSTXFailEventParams(tANI_U8 *pValue, |
| 243 | tANI_U8 *tx_fail_count, |
| 244 | tANI_U16 *pid); |
| 245 | |
| 246 | static int hdd_ParseUserParams(tANI_U8 *pValue, tANI_U8 **ppArg); |
| 247 | |
| 248 | #endif /* WLAN_FEATURE_RMC */ |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 249 | void wlan_hdd_restart_timer_cb(v_PVOID_t usrDataForCallback); |
Sameer Thalappil | 45931fb | 2013-02-01 11:18:05 -0800 | [diff] [blame] | 250 | void hdd_set_wlan_suspend_mode(bool suspend); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 251 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 252 | v_U16_t hdd_select_queue(struct net_device *dev, |
Anand N Sunkad | e9adb1b | 2015-07-29 09:56:45 +0530 | [diff] [blame] | 253 | struct sk_buff *skb |
| 254 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0)) |
| 255 | , void *accel_priv |
| 256 | #endif |
| 257 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) |
| 258 | , select_queue_fallback_t fallback |
| 259 | #endif |
| 260 | ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 261 | |
| 262 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 263 | static void hdd_set_multicast_list(struct net_device *dev); |
| 264 | #endif |
| 265 | |
| 266 | void hdd_wlan_initial_scan(hdd_adapter_t *pAdapter); |
| 267 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 268 | #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] | 269 | void hdd_getBand_helper(hdd_context_t *pHddCtx, int *pBand); |
| 270 | 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] | 271 | static VOS_STATUS hdd_parse_send_action_frame_data(tANI_U8 *pValue, tANI_U8 *pTargetApBssid, |
| 272 | tANI_U8 *pChannel, tANI_U8 *pDwellTime, |
| 273 | tANI_U8 **pBuf, tANI_U8 *pBufLen); |
Selvaraj, Sridhar | 5aff1ed | 2016-06-18 01:26:23 +0530 | [diff] [blame] | 274 | static int hdd_parse_reassoc_command_v1_data(const tANI_U8 *pValue, |
| 275 | tANI_U8 *pTargetApBssid, tANI_U8 *pChannel); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 276 | #endif |
Ratheesh S P | 2128041 | 2015-05-19 14:21:52 +0530 | [diff] [blame] | 277 | |
| 278 | /* Store WLAN driver info in a global variable such that crash debugger |
| 279 | can extract it from driver debug symbol and crashdump for post processing */ |
| 280 | tANI_U8 g_wlan_driver[ ] = "pronto_driver"; |
| 281 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 282 | #if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD) |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 283 | 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] | 284 | #endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */ |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 285 | |
Mihir Shete | e1093ba | 2014-01-21 20:13:32 +0530 | [diff] [blame] | 286 | static VOS_STATUS wlan_hdd_init_channels(hdd_context_t *pHddCtx); |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 287 | const char * hdd_device_modetoString(v_U8_t device_mode) |
| 288 | { |
| 289 | switch(device_mode) |
| 290 | { |
| 291 | CASE_RETURN_STRING( WLAN_HDD_INFRA_STATION ); |
| 292 | CASE_RETURN_STRING( WLAN_HDD_SOFTAP ); |
| 293 | CASE_RETURN_STRING( WLAN_HDD_P2P_CLIENT ); |
| 294 | CASE_RETURN_STRING( WLAN_HDD_P2P_GO ); |
| 295 | CASE_RETURN_STRING( WLAN_HDD_MONITOR); |
| 296 | CASE_RETURN_STRING( WLAN_HDD_FTM ); |
| 297 | CASE_RETURN_STRING( WLAN_HDD_IBSS ); |
| 298 | CASE_RETURN_STRING( WLAN_HDD_P2P_DEVICE ); |
| 299 | default: |
| 300 | return "device_mode Unknown"; |
| 301 | } |
| 302 | } |
Mihir Shete | e1093ba | 2014-01-21 20:13:32 +0530 | [diff] [blame] | 303 | |
Mukul Sharma | a78cf6b | 2015-02-24 16:59:01 +0530 | [diff] [blame] | 304 | static int __hdd_netdev_notifier_call(struct notifier_block * nb, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 305 | unsigned long state, |
| 306 | void *ndev) |
| 307 | { |
| 308 | struct net_device *dev = ndev; |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 309 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 27cee45 | 2013-03-27 11:10:24 -0700 | [diff] [blame] | 310 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 311 | #ifdef WLAN_BTAMP_FEATURE |
| 312 | VOS_STATUS status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 313 | #endif |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 314 | long result; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 315 | |
| 316 | //Make sure that this callback corresponds to our device. |
Jeff Johnson | 27cee45 | 2013-03-27 11:10:24 -0700 | [diff] [blame] | 317 | if ((strncmp(dev->name, "wlan", 4)) && |
Amar Singhal | 4c723bd | 2013-03-25 18:14:15 -0700 | [diff] [blame] | 318 | (strncmp(dev->name, "p2p", 3))) |
| 319 | return NOTIFY_DONE; |
| 320 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 321 | if (!dev->ieee80211_ptr) |
Jeff Johnson | 27cee45 | 2013-03-27 11:10:24 -0700 | [diff] [blame] | 322 | return NOTIFY_DONE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 323 | |
Jeff Johnson | 27cee45 | 2013-03-27 11:10:24 -0700 | [diff] [blame] | 324 | if (NULL == pAdapter) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 325 | { |
Jeff Johnson | a8a1a48 | 2012-12-12 16:49:33 -0800 | [diff] [blame] | 326 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: HDD Adapter Null Pointer", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 327 | VOS_ASSERT(0); |
| 328 | return NOTIFY_DONE; |
| 329 | } |
| 330 | |
Jeff Johnson | 27cee45 | 2013-03-27 11:10:24 -0700 | [diff] [blame] | 331 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 332 | if (NULL == pHddCtx) |
| 333 | { |
| 334 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: HDD Context Null Pointer", __func__); |
| 335 | VOS_ASSERT(0); |
| 336 | return NOTIFY_DONE; |
| 337 | } |
Sameer Thalappil | 1406797 | 2014-01-23 14:54:54 -0800 | [diff] [blame] | 338 | if (pHddCtx->isLogpInProgress) |
| 339 | return NOTIFY_DONE; |
| 340 | |
Jeff Johnson | 27cee45 | 2013-03-27 11:10:24 -0700 | [diff] [blame] | 341 | |
| 342 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s New Net Device State = %lu", |
| 343 | __func__, dev->name, state); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 344 | |
| 345 | switch (state) { |
| 346 | case NETDEV_REGISTER: |
| 347 | break; |
| 348 | |
| 349 | case NETDEV_UNREGISTER: |
| 350 | break; |
| 351 | |
| 352 | case NETDEV_UP: |
| 353 | break; |
| 354 | |
| 355 | case NETDEV_DOWN: |
| 356 | break; |
| 357 | |
| 358 | case NETDEV_CHANGE: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 359 | if(TRUE == pAdapter->isLinkUpSvcNeeded) |
| 360 | complete(&pAdapter->linkup_event_var); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 361 | break; |
| 362 | |
| 363 | case NETDEV_GOING_DOWN: |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 364 | result = wlan_hdd_scan_abort(pAdapter); |
Girish Gowli | 4bf7a63 | 2014-06-12 13:42:11 +0530 | [diff] [blame] | 365 | if (result < 0) |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 366 | { |
| 367 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 368 | "%s: Timeout occurred while waiting for abortscan %ld", |
| 369 | __func__, result); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 370 | } |
| 371 | else |
| 372 | { |
| 373 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 374 | "%s: Scan Abort Successful" , __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 375 | } |
| 376 | #ifdef WLAN_BTAMP_FEATURE |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 377 | 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] | 378 | status = WLANBAP_StopAmp(); |
| 379 | if(VOS_STATUS_SUCCESS != status ) |
| 380 | { |
| 381 | pHddCtx->isAmpAllowed = VOS_TRUE; |
| 382 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 383 | "%s: Failed to stop AMP", __func__); |
| 384 | } |
| 385 | else |
| 386 | { |
| 387 | //a state m/c implementation in PAL is TBD to avoid this delay |
| 388 | msleep(500); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 389 | if ( pHddCtx->isAmpAllowed ) |
| 390 | { |
| 391 | WLANBAP_DeregisterFromHCI(); |
| 392 | pHddCtx->isAmpAllowed = VOS_FALSE; |
| 393 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 394 | } |
| 395 | #endif //WLAN_BTAMP_FEATURE |
| 396 | break; |
| 397 | |
| 398 | default: |
| 399 | break; |
| 400 | } |
| 401 | |
| 402 | return NOTIFY_DONE; |
| 403 | } |
| 404 | |
Mukul Sharma | a78cf6b | 2015-02-24 16:59:01 +0530 | [diff] [blame] | 405 | static int hdd_netdev_notifier_call(struct notifier_block * nb, |
| 406 | unsigned long state, |
| 407 | void *ndev) |
| 408 | { |
| 409 | int ret; |
| 410 | vos_ssr_protect(__func__); |
| 411 | ret = __hdd_netdev_notifier_call( nb, state, ndev); |
| 412 | vos_ssr_unprotect(__func__); |
| 413 | return ret; |
| 414 | } |
| 415 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 416 | struct notifier_block hdd_netdev_notifier = { |
| 417 | .notifier_call = hdd_netdev_notifier_call, |
| 418 | }; |
| 419 | |
| 420 | /*--------------------------------------------------------------------------- |
| 421 | * Function definitions |
| 422 | *-------------------------------------------------------------------------*/ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 423 | void hdd_unregister_mcast_bcast_filter(hdd_context_t *pHddCtx); |
| 424 | void hdd_register_mcast_bcast_filter(hdd_context_t *pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 425 | //variable to hold the insmod parameters |
Madan Mohan Koyyalamudi | dfd6aa8 | 2012-10-18 20:18:43 -0700 | [diff] [blame] | 426 | static int con_mode; |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 427 | #ifndef MODULE |
| 428 | /* current con_mode - used only for statically linked driver |
| 429 | * con_mode is changed by userspace to indicate a mode change which will |
| 430 | * result in calling the module exit and init functions. The module |
| 431 | * exit function will clean up based on the value of con_mode prior to it |
| 432 | * being changed by userspace. So curr_con_mode records the current con_mode |
| 433 | * for exit when con_mode becomes the next mode for init |
| 434 | */ |
Madan Mohan Koyyalamudi | dfd6aa8 | 2012-10-18 20:18:43 -0700 | [diff] [blame] | 435 | static int curr_con_mode; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 436 | #endif |
| 437 | |
Srinivas Girigowda | 8bf64cb | 2015-09-30 19:50:09 +0530 | [diff] [blame] | 438 | #ifdef WLAN_FEATURE_OFFLOAD_PACKETS |
| 439 | /** |
| 440 | * hdd_init_offloaded_packets_ctx() - Initialize offload packets context |
| 441 | * @hdd_ctx: hdd global context |
| 442 | * |
| 443 | * Return: none |
| 444 | */ |
| 445 | static void hdd_init_offloaded_packets_ctx(hdd_context_t *hdd_ctx) |
| 446 | { |
| 447 | uint8_t i; |
| 448 | |
| 449 | mutex_init(&hdd_ctx->op_ctx.op_lock); |
| 450 | for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++) |
| 451 | { |
| 452 | hdd_ctx->op_ctx.op_table[i].request_id = 0; |
| 453 | hdd_ctx->op_ctx.op_table[i].pattern_id = i; |
| 454 | } |
| 455 | } |
| 456 | #else |
| 457 | static void hdd_init_offloaded_packets_ctx(hdd_context_t *hdd_ctx) |
| 458 | { |
| 459 | } |
| 460 | #endif |
| 461 | |
Varun Reddy Yeturu | 587e680 | 2013-01-24 12:21:41 -0800 | [diff] [blame] | 462 | /**--------------------------------------------------------------------------- |
| 463 | |
| 464 | \brief hdd_vos_trace_enable() - Configure initial VOS Trace enable |
| 465 | |
| 466 | Called immediately after the cfg.ini is read in order to configure |
| 467 | the desired trace levels. |
| 468 | |
| 469 | \param - moduleId - module whose trace level is being configured |
| 470 | \param - bitmask - bitmask of log levels to be enabled |
| 471 | |
| 472 | \return - void |
| 473 | |
| 474 | --------------------------------------------------------------------------*/ |
| 475 | static void hdd_vos_trace_enable(VOS_MODULE_ID moduleId, v_U32_t bitmask) |
| 476 | { |
| 477 | wpt_tracelevel level; |
| 478 | |
| 479 | /* if the bitmask is the default value, then a bitmask was not |
| 480 | specified in cfg.ini, so leave the logging level alone (it |
| 481 | will remain at the "compiled in" default value) */ |
| 482 | if (CFG_VOS_TRACE_ENABLE_DEFAULT == bitmask) |
| 483 | { |
| 484 | return; |
| 485 | } |
| 486 | |
| 487 | /* a mask was specified. start by disabling all logging */ |
| 488 | vos_trace_setValue(moduleId, VOS_TRACE_LEVEL_NONE, 0); |
| 489 | |
| 490 | /* now cycle through the bitmask until all "set" bits are serviced */ |
| 491 | level = VOS_TRACE_LEVEL_FATAL; |
| 492 | while (0 != bitmask) |
| 493 | { |
| 494 | if (bitmask & 1) |
| 495 | { |
| 496 | vos_trace_setValue(moduleId, level, 1); |
| 497 | } |
| 498 | level++; |
| 499 | bitmask >>= 1; |
| 500 | } |
| 501 | } |
| 502 | |
| 503 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 504 | /**--------------------------------------------------------------------------- |
| 505 | |
| 506 | \brief hdd_wdi_trace_enable() - Configure initial WDI Trace enable |
| 507 | |
| 508 | Called immediately after the cfg.ini is read in order to configure |
| 509 | the desired trace levels in the WDI. |
| 510 | |
| 511 | \param - moduleId - module whose trace level is being configured |
| 512 | \param - bitmask - bitmask of log levels to be enabled |
| 513 | |
| 514 | \return - void |
| 515 | |
| 516 | --------------------------------------------------------------------------*/ |
| 517 | static void hdd_wdi_trace_enable(wpt_moduleid moduleId, v_U32_t bitmask) |
| 518 | { |
| 519 | wpt_tracelevel level; |
| 520 | |
| 521 | /* if the bitmask is the default value, then a bitmask was not |
| 522 | specified in cfg.ini, so leave the logging level alone (it |
| 523 | will remain at the "compiled in" default value) */ |
| 524 | if (CFG_WDI_TRACE_ENABLE_DEFAULT == bitmask) |
| 525 | { |
| 526 | return; |
| 527 | } |
| 528 | |
| 529 | /* a mask was specified. start by disabling all logging */ |
| 530 | wpalTraceSetLevel(moduleId, eWLAN_PAL_TRACE_LEVEL_NONE, 0); |
| 531 | |
| 532 | /* now cycle through the bitmask until all "set" bits are serviced */ |
| 533 | level = eWLAN_PAL_TRACE_LEVEL_FATAL; |
| 534 | while (0 != bitmask) |
| 535 | { |
| 536 | if (bitmask & 1) |
| 537 | { |
| 538 | wpalTraceSetLevel(moduleId, level, 1); |
| 539 | } |
| 540 | level++; |
| 541 | bitmask >>= 1; |
| 542 | } |
| 543 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 544 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 545 | /* |
| 546 | * FUNCTION: wlan_hdd_validate_context |
| 547 | * This function is used to check the HDD context |
| 548 | */ |
| 549 | int wlan_hdd_validate_context(hdd_context_t *pHddCtx) |
| 550 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 551 | |
| 552 | if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini) |
| 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, |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 555 | "%s: HDD context is Null", __func__); |
| 556 | return -ENODEV; |
| 557 | } |
| 558 | |
| 559 | if (pHddCtx->isLogpInProgress) |
| 560 | { |
Mahesh A Saptasagar | 886997a | 2015-03-04 13:15:51 +0530 | [diff] [blame] | 561 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
c_hpothu | 8adb97b | 2014-12-08 19:38:20 +0530 | [diff] [blame] | 562 | "%s: LOGP %s. Ignore!!", __func__, |
| 563 | vos_is_wlan_in_badState(VOS_MODULE_ID_HDD, NULL) |
| 564 | ?"failed":"in Progress"); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 565 | return -EAGAIN; |
| 566 | } |
| 567 | |
Mihir Shete | 1815629 | 2014-03-11 15:38:30 +0530 | [diff] [blame] | 568 | if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx)) |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 569 | { |
Mahesh A Saptasagar | 886997a | 2015-03-04 13:15:51 +0530 | [diff] [blame] | 570 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 571 | "%s: Unloading/Loading in Progress. Ignore!!!", __func__); |
| 572 | return -EAGAIN; |
| 573 | } |
| 574 | return 0; |
| 575 | } |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 576 | #ifdef CONFIG_ENABLE_LINUX_REG |
| 577 | void hdd_checkandupdate_phymode( hdd_context_t *pHddCtx) |
| 578 | { |
| 579 | hdd_adapter_t *pAdapter = NULL; |
| 580 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 581 | eCsrPhyMode phyMode; |
| 582 | hdd_config_t *cfg_param = NULL; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 583 | |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 584 | if (NULL == pHddCtx) |
| 585 | { |
| 586 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 587 | "HDD Context is null !!"); |
| 588 | return ; |
| 589 | } |
| 590 | |
| 591 | pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 592 | if (NULL == pAdapter) |
| 593 | { |
| 594 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 595 | "pAdapter is null !!"); |
| 596 | return ; |
| 597 | } |
| 598 | |
| 599 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 600 | if (NULL == pHddStaCtx) |
| 601 | { |
| 602 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 603 | "pHddStaCtx is null !!"); |
| 604 | return ; |
| 605 | } |
| 606 | |
| 607 | cfg_param = pHddCtx->cfg_ini; |
| 608 | if (NULL == cfg_param) |
| 609 | { |
| 610 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 611 | "cfg_params not available !!"); |
| 612 | return ; |
| 613 | } |
| 614 | |
| 615 | phyMode = sme_GetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter)); |
| 616 | |
| 617 | if (!pHddCtx->isVHT80Allowed) |
| 618 | { |
| 619 | if ((eCSR_DOT11_MODE_AUTO == phyMode) || |
| 620 | (eCSR_DOT11_MODE_11ac == phyMode) || |
| 621 | (eCSR_DOT11_MODE_11ac_ONLY == phyMode)) |
| 622 | { |
| 623 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 624 | "Setting phymode to 11n!!"); |
| 625 | sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_DOT11_MODE_11n); |
| 626 | } |
| 627 | } |
| 628 | else |
| 629 | { |
| 630 | /*New country Supports 11ac as well resetting value back from .ini*/ |
| 631 | sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 632 | hdd_cfg_xlate_to_csr_phy_mode(cfg_param->dot11Mode)); |
| 633 | return ; |
| 634 | } |
| 635 | |
| 636 | if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) && |
| 637 | ((eCSR_CFG_DOT11_MODE_11AC_ONLY == pHddStaCtx->conn_info.dot11Mode) || |
| 638 | (eCSR_CFG_DOT11_MODE_11AC == pHddStaCtx->conn_info.dot11Mode))) |
| 639 | { |
| 640 | VOS_STATUS vosStatus; |
| 641 | |
| 642 | // need to issue a disconnect to CSR. |
| 643 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 644 | vosStatus = sme_RoamDisconnect(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 645 | pAdapter->sessionId, |
| 646 | eCSR_DISCONNECT_REASON_UNSPECIFIED ); |
| 647 | |
| 648 | if (VOS_STATUS_SUCCESS == vosStatus) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 649 | { |
| 650 | long ret; |
| 651 | |
| 652 | ret = wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var, |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 653 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 654 | if (0 >= ret) |
| 655 | hddLog(LOGE, FL("failure waiting for disconnect_comp_var %ld"), |
| 656 | ret); |
| 657 | } |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 658 | |
| 659 | } |
| 660 | } |
| 661 | #else |
Gopichand Nakkala | dacbcb5 | 2013-04-18 16:41:54 +0530 | [diff] [blame] | 662 | void hdd_checkandupdate_phymode( hdd_adapter_t *pAdapter, char *country_code) |
| 663 | { |
| 664 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 665 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 666 | hdd_config_t *cfg_param; |
| 667 | eCsrPhyMode phyMode; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 668 | long ret; |
Gopichand Nakkala | dacbcb5 | 2013-04-18 16:41:54 +0530 | [diff] [blame] | 669 | |
| 670 | if (NULL == pHddCtx) |
| 671 | { |
| 672 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 673 | "HDD Context is null !!"); |
| 674 | return ; |
| 675 | } |
| 676 | |
| 677 | cfg_param = pHddCtx->cfg_ini; |
| 678 | |
| 679 | if (NULL == cfg_param) |
| 680 | { |
| 681 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 682 | "cfg_params not available !!"); |
| 683 | return ; |
| 684 | } |
| 685 | |
| 686 | phyMode = sme_GetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter)); |
| 687 | |
| 688 | if (NULL != strstr(cfg_param->listOfNon11acCountryCode, country_code)) |
| 689 | { |
| 690 | if ((eCSR_DOT11_MODE_AUTO == phyMode) || |
| 691 | (eCSR_DOT11_MODE_11ac == phyMode) || |
| 692 | (eCSR_DOT11_MODE_11ac_ONLY == phyMode)) |
| 693 | { |
| 694 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 695 | "Setting phymode to 11n!!"); |
| 696 | sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_DOT11_MODE_11n); |
| 697 | } |
| 698 | } |
| 699 | else |
| 700 | { |
| 701 | /*New country Supports 11ac as well resetting value back from .ini*/ |
| 702 | sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 703 | hdd_cfg_xlate_to_csr_phy_mode(cfg_param->dot11Mode)); |
| 704 | return ; |
| 705 | } |
| 706 | |
| 707 | if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) && |
| 708 | ((eCSR_CFG_DOT11_MODE_11AC_ONLY == pHddStaCtx->conn_info.dot11Mode) || |
| 709 | (eCSR_CFG_DOT11_MODE_11AC == pHddStaCtx->conn_info.dot11Mode))) |
| 710 | { |
| 711 | VOS_STATUS vosStatus; |
| 712 | |
| 713 | // need to issue a disconnect to CSR. |
| 714 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 715 | vosStatus = sme_RoamDisconnect(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 716 | pAdapter->sessionId, |
| 717 | eCSR_DISCONNECT_REASON_UNSPECIFIED ); |
| 718 | |
| 719 | if (VOS_STATUS_SUCCESS == vosStatus) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 720 | { |
| 721 | ret = wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var, |
Gopichand Nakkala | dacbcb5 | 2013-04-18 16:41:54 +0530 | [diff] [blame] | 722 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 723 | if (ret <= 0) |
| 724 | { |
| 725 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 726 | "wait on disconnect_comp_var is failed %ld", ret); |
| 727 | } |
| 728 | } |
Gopichand Nakkala | dacbcb5 | 2013-04-18 16:41:54 +0530 | [diff] [blame] | 729 | |
| 730 | } |
| 731 | } |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 732 | #endif //CONFIG_ENABLE_LINUX_REG |
Gopichand Nakkala | dacbcb5 | 2013-04-18 16:41:54 +0530 | [diff] [blame] | 733 | |
Tushnim Bhattacharyya | 9cdf608 | 2013-04-21 16:33:30 -0700 | [diff] [blame] | 734 | void hdd_checkandupdate_dfssetting( hdd_adapter_t *pAdapter, char *country_code) |
| 735 | { |
| 736 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 737 | hdd_config_t *cfg_param; |
| 738 | |
| 739 | if (NULL == pHddCtx) |
| 740 | { |
| 741 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 742 | "HDD Context is null !!"); |
| 743 | return ; |
| 744 | } |
| 745 | |
| 746 | cfg_param = pHddCtx->cfg_ini; |
| 747 | |
| 748 | if (NULL == cfg_param) |
| 749 | { |
| 750 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 751 | "cfg_params not available !!"); |
| 752 | return ; |
| 753 | } |
| 754 | |
Agarwal Ashish | 738843c | 2014-09-25 12:27:56 +0530 | [diff] [blame] | 755 | if (NULL != strstr(cfg_param->listOfNonDfsCountryCode, country_code) || |
| 756 | pHddCtx->disable_dfs_flag == TRUE) |
Tushnim Bhattacharyya | 9cdf608 | 2013-04-21 16:33:30 -0700 | [diff] [blame] | 757 | { |
| 758 | /*New country doesn't support DFS */ |
| 759 | sme_UpdateDfsSetting(WLAN_HDD_GET_HAL_CTX(pAdapter), 0); |
| 760 | } |
Tushnim Bhattacharyya | 9cdf608 | 2013-04-21 16:33:30 -0700 | [diff] [blame] | 761 | |
| 762 | } |
| 763 | |
Abhishek Singh | 00b7197 | 2016-01-07 10:51:04 +0530 | [diff] [blame] | 764 | #ifdef WLAN_FEATURE_RMC |
| 765 | static int hdd_parse_setrmcenable_command(tANI_U8 *pValue, tANI_U8 *pRmcEnable) |
| 766 | { |
| 767 | tANI_U8 *inPtr = pValue; |
| 768 | int tempInt; |
| 769 | int v = 0; |
| 770 | char buf[32]; |
| 771 | *pRmcEnable = 0; |
| 772 | |
| 773 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 774 | /*no argument after the command*/ |
| 775 | if (NULL == inPtr) |
| 776 | { |
| 777 | return 0; |
| 778 | } |
| 779 | |
| 780 | /*no space after the command*/ |
| 781 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 782 | { |
| 783 | return 0; |
| 784 | } |
| 785 | |
| 786 | /*removing empty spaces*/ |
| 787 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
| 788 | |
| 789 | /*no argument followed by spaces*/ |
| 790 | if ('\0' == *inPtr) |
| 791 | { |
| 792 | return 0; |
| 793 | } |
| 794 | |
| 795 | /* getting the first argument which enables or disables RMC |
| 796 | * for input IP v4 address*/ |
Ashish Kumar Dhanotiya | 54d31a3 | 2017-08-04 17:12:44 +0530 | [diff] [blame] | 797 | sscanf(inPtr, "%31s ", buf); |
Abhishek Singh | 00b7197 | 2016-01-07 10:51:04 +0530 | [diff] [blame] | 798 | v = kstrtos32(buf, 10, &tempInt); |
| 799 | if ( v < 0) |
| 800 | { |
| 801 | return -EINVAL; |
| 802 | } |
| 803 | |
| 804 | *pRmcEnable = tempInt; |
| 805 | |
| 806 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 807 | "ucRmcEnable: %d", *pRmcEnable); |
| 808 | |
| 809 | return 0; |
| 810 | } |
| 811 | |
| 812 | /* Function header left blank Intentionally */ |
| 813 | static int hdd_parse_setrmcactionperiod_command(tANI_U8 *pValue, |
| 814 | tANI_U32 *pActionPeriod) |
| 815 | { |
| 816 | tANI_U8 *inPtr = pValue; |
| 817 | int tempInt; |
| 818 | int v = 0; |
| 819 | char buf[32]; |
| 820 | *pActionPeriod = 0; |
| 821 | |
| 822 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 823 | /*no argument after the command*/ |
| 824 | if (NULL == inPtr) |
| 825 | { |
| 826 | return -EINVAL; |
| 827 | } |
| 828 | |
| 829 | /*no space after the command*/ |
| 830 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 831 | { |
| 832 | return -EINVAL; |
| 833 | } |
| 834 | |
| 835 | /*removing empty spaces*/ |
| 836 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
| 837 | |
| 838 | /*no argument followed by spaces*/ |
| 839 | if ('\0' == *inPtr) |
| 840 | { |
| 841 | return 0; |
| 842 | } |
| 843 | |
| 844 | /* getting the first argument which enables or disables RMC |
| 845 | * for input IP v4 address*/ |
Ashish Kumar Dhanotiya | 54d31a3 | 2017-08-04 17:12:44 +0530 | [diff] [blame] | 846 | sscanf(inPtr, "%31s ", buf); |
Abhishek Singh | 00b7197 | 2016-01-07 10:51:04 +0530 | [diff] [blame] | 847 | v = kstrtos32(buf, 10, &tempInt); |
| 848 | if ( v < 0) |
| 849 | { |
| 850 | return -EINVAL; |
| 851 | } |
| 852 | |
| 853 | /* Range checking for passed paramter */ |
| 854 | if (tempInt < WNI_CFG_RMC_ACTION_PERIOD_FREQUENCY_STAMIN || |
| 855 | tempInt > WNI_CFG_RMC_ACTION_PERIOD_FREQUENCY_STAMAX) |
| 856 | { |
| 857 | return -EINVAL; |
| 858 | } |
| 859 | |
| 860 | *pActionPeriod = tempInt; |
| 861 | |
| 862 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 863 | "uActionPeriod: %d", *pActionPeriod); |
| 864 | |
| 865 | return 0; |
| 866 | } |
| 867 | |
| 868 | /* Function header left blank Intentionally */ |
| 869 | static int hdd_parse_setrmcrate_command(tANI_U8 *pValue, |
| 870 | tANI_U32 *pRate, tTxrateinfoflags *pTxFlags) |
| 871 | { |
| 872 | tANI_U8 *inPtr = pValue; |
| 873 | int tempInt; |
| 874 | int v = 0; |
| 875 | char buf[32]; |
| 876 | *pRate = 0; |
| 877 | *pTxFlags = 0; |
| 878 | |
| 879 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 880 | /*no argument after the command*/ |
| 881 | if (NULL == inPtr) |
| 882 | { |
| 883 | return -EINVAL; |
| 884 | } |
| 885 | |
| 886 | /*no space after the command*/ |
| 887 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 888 | { |
| 889 | return -EINVAL; |
| 890 | } |
| 891 | |
| 892 | /*removing empty spaces*/ |
| 893 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
| 894 | |
| 895 | /*no argument followed by spaces*/ |
| 896 | if ('\0' == *inPtr) |
| 897 | { |
| 898 | return 0; |
| 899 | } |
| 900 | |
| 901 | /* |
| 902 | * getting the first argument which sets multicast rate. |
| 903 | */ |
Ashish Kumar Dhanotiya | 06f9f20 | 2017-08-04 15:26:27 +0530 | [diff] [blame] | 904 | sscanf(inPtr, "%31s ", buf); |
Abhishek Singh | 00b7197 | 2016-01-07 10:51:04 +0530 | [diff] [blame] | 905 | v = kstrtos32(buf, 10, &tempInt); |
| 906 | if ( v < 0) |
| 907 | { |
| 908 | return -EINVAL; |
| 909 | } |
| 910 | |
| 911 | /* |
| 912 | * Validate the multicast rate. |
| 913 | */ |
| 914 | switch (tempInt) |
| 915 | { |
| 916 | default: |
| 917 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
| 918 | "Unsupported rate: %d", tempInt); |
| 919 | return -EINVAL; |
| 920 | case 0: |
| 921 | case 6: |
| 922 | case 9: |
| 923 | case 12: |
| 924 | case 18: |
| 925 | case 24: |
| 926 | case 36: |
| 927 | case 48: |
| 928 | case 54: |
| 929 | *pTxFlags = eHAL_TX_RATE_LEGACY; |
| 930 | *pRate = tempInt * 10; |
| 931 | break; |
| 932 | case 65: |
| 933 | *pTxFlags = eHAL_TX_RATE_HT20; |
| 934 | *pRate = tempInt * 10; |
| 935 | break; |
| 936 | case 72: |
| 937 | *pTxFlags = eHAL_TX_RATE_HT20 | eHAL_TX_RATE_SGI; |
| 938 | *pRate = 722; /* fractional rate 72.2 Mbps */ |
| 939 | break; |
| 940 | } |
| 941 | |
| 942 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 943 | "Rate: %d", *pRate); |
| 944 | |
| 945 | return 0; |
| 946 | } |
| 947 | |
| 948 | /**--------------------------------------------------------------------------- |
| 949 | |
| 950 | \brief hdd_cfg80211_get_ibss_peer_info_cb() - Callback function for IBSS |
| 951 | Peer Info request |
| 952 | |
| 953 | This is an asynchronous callback function from SME when the peer info |
| 954 | is received |
| 955 | |
| 956 | \pUserData -> Adapter private data |
| 957 | \pPeerInfoRsp -> Peer info response |
| 958 | |
| 959 | \return - 0 for success non-zero for failure |
| 960 | --------------------------------------------------------------------------*/ |
| 961 | static void |
| 962 | hdd_cfg80211_get_ibss_peer_info_cb(v_VOID_t *pUserData, v_VOID_t *pPeerInfoRsp) |
| 963 | { |
| 964 | hdd_adapter_t *pAdapter = (hdd_adapter_t *)pUserData; |
| 965 | tSirPeerInfoRspParams *pPeerInfo = (tSirPeerInfoRspParams *)pPeerInfoRsp; |
| 966 | hdd_station_ctx_t *pStaCtx; |
| 967 | v_U8_t i; |
| 968 | |
| 969 | /*Sanity check*/ |
| 970 | if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)) |
| 971 | { |
| 972 | hddLog(LOGE, |
| 973 | FL("invalid adapter or adapter has invalid magic")); |
| 974 | return; |
| 975 | } |
| 976 | |
| 977 | pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 978 | if (NULL != pStaCtx && NULL != pPeerInfo && |
| 979 | eHAL_STATUS_SUCCESS == pPeerInfo->status) |
| 980 | { |
| 981 | pStaCtx->ibss_peer_info.status = pPeerInfo->status; |
| 982 | pStaCtx->ibss_peer_info.numIBSSPeers = pPeerInfo->numPeers; |
| 983 | |
| 984 | /* Paranoia check */ |
| 985 | if (pPeerInfo->numPeers < HDD_MAX_NUM_IBSS_STA) |
| 986 | { |
| 987 | for (i = 0; i < pPeerInfo->numPeers; i++) |
| 988 | { |
| 989 | memcpy(&pStaCtx->ibss_peer_info.ibssPeerList[i], |
| 990 | &pPeerInfo->peerInfoParams[i], |
| 991 | sizeof(hdd_ibss_peer_info_params_t)); |
| 992 | } |
| 993 | hddLog(LOG1, |
| 994 | FL("Peer Info copied in HDD")); |
| 995 | } |
| 996 | else |
| 997 | { |
| 998 | hddLog(LOGE, |
| 999 | FL(" Number of peers %d returned is more than limit %d"), |
| 1000 | pPeerInfo->numPeers, HDD_MAX_NUM_IBSS_STA); |
| 1001 | } |
| 1002 | } |
| 1003 | else |
| 1004 | { |
| 1005 | hddLog(LOG1, |
| 1006 | FL("peerInfo returned is NULL")); |
| 1007 | } |
| 1008 | |
| 1009 | complete(&pAdapter->ibss_peer_info_comp); |
| 1010 | } |
| 1011 | |
| 1012 | /**--------------------------------------------------------------------------- |
| 1013 | |
| 1014 | \brief hdd_cfg80211_get_ibss_peer_info_all() - |
| 1015 | |
| 1016 | Request function to get IBSS peer info from lower layers |
| 1017 | |
| 1018 | \pAdapter -> Adapter context |
| 1019 | |
| 1020 | \return - 0 for success non-zero for failure |
| 1021 | --------------------------------------------------------------------------*/ |
| 1022 | static |
| 1023 | VOS_STATUS hdd_cfg80211_get_ibss_peer_info_all(hdd_adapter_t *pAdapter) |
| 1024 | { |
| 1025 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 1026 | long status; |
| 1027 | VOS_STATUS retStatus = VOS_STATUS_E_FAILURE; |
| 1028 | |
| 1029 | INIT_COMPLETION(pAdapter->ibss_peer_info_comp); |
| 1030 | |
| 1031 | retStatus = sme_RequestIBSSPeerInfo(hHal, pAdapter, |
| 1032 | hdd_cfg80211_get_ibss_peer_info_cb, |
| 1033 | VOS_TRUE, 0xFF); |
| 1034 | |
| 1035 | if (VOS_STATUS_SUCCESS == retStatus) |
| 1036 | { |
| 1037 | status = wait_for_completion_interruptible_timeout |
| 1038 | (&pAdapter->ibss_peer_info_comp, |
| 1039 | msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT)); |
| 1040 | |
| 1041 | /* status will be 0 if timed out */ |
| 1042 | if (status <= 0) |
| 1043 | { |
| 1044 | hddLog(VOS_TRACE_LEVEL_WARN, "%s: Warning: IBSS_PEER_INFO_TIMEOUT %ld", |
| 1045 | __func__, status); |
| 1046 | retStatus = VOS_STATUS_E_FAILURE; |
| 1047 | return retStatus; |
| 1048 | } |
| 1049 | } |
| 1050 | else |
| 1051 | { |
| 1052 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 1053 | "%s: Warning: sme_RequestIBSSPeerInfo Request failed", __func__); |
| 1054 | } |
| 1055 | |
| 1056 | return retStatus; |
| 1057 | } |
| 1058 | |
| 1059 | /**--------------------------------------------------------------------------- |
| 1060 | |
| 1061 | \brief hdd_cfg80211_get_ibss_peer_info() - |
| 1062 | |
| 1063 | Request function to get IBSS peer info from lower layers |
| 1064 | |
| 1065 | \pAdapter -> Adapter context |
| 1066 | \staIdx -> Sta index for which the peer info is requested |
| 1067 | |
| 1068 | \return - 0 for success non-zero for failure |
| 1069 | --------------------------------------------------------------------------*/ |
| 1070 | static VOS_STATUS |
| 1071 | hdd_cfg80211_get_ibss_peer_info(hdd_adapter_t *pAdapter, v_U8_t staIdx) |
| 1072 | { |
| 1073 | long status; |
| 1074 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 1075 | VOS_STATUS retStatus = VOS_STATUS_E_FAILURE; |
| 1076 | |
| 1077 | INIT_COMPLETION(pAdapter->ibss_peer_info_comp); |
| 1078 | |
| 1079 | retStatus = sme_RequestIBSSPeerInfo(hHal, pAdapter, |
| 1080 | hdd_cfg80211_get_ibss_peer_info_cb, |
| 1081 | VOS_FALSE, staIdx); |
| 1082 | |
| 1083 | if (VOS_STATUS_SUCCESS == retStatus) |
| 1084 | { |
| 1085 | status = wait_for_completion_interruptible_timeout |
| 1086 | (&pAdapter->ibss_peer_info_comp, |
| 1087 | msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT)); |
| 1088 | |
| 1089 | /* status = 0 on timeout */ |
| 1090 | if (status <= 0) |
| 1091 | { |
| 1092 | hddLog(VOS_TRACE_LEVEL_WARN, "%s: Warning: IBSS_PEER_INFO_TIMEOUT %ld", |
| 1093 | __func__, status); |
| 1094 | retStatus = VOS_STATUS_E_FAILURE; |
| 1095 | return retStatus; |
| 1096 | } |
| 1097 | } |
| 1098 | else |
| 1099 | { |
| 1100 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 1101 | "%s: Warning: sme_RequestIBSSPeerInfo Request failed", __func__); |
| 1102 | } |
| 1103 | |
| 1104 | return retStatus; |
| 1105 | } |
| 1106 | |
| 1107 | /* Function header left blank Intentionally */ |
| 1108 | VOS_STATUS |
| 1109 | hdd_parse_get_ibss_peer_info(tANI_U8 *pValue, v_MACADDR_t *pPeerMacAddr) |
| 1110 | { |
| 1111 | tANI_U8 *inPtr = pValue; |
| 1112 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 1113 | |
| 1114 | /*no argument after the command*/ |
| 1115 | if (NULL == inPtr) |
| 1116 | { |
| 1117 | return VOS_STATUS_E_FAILURE;; |
| 1118 | } |
| 1119 | |
| 1120 | /*no space after the command*/ |
| 1121 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 1122 | { |
| 1123 | return VOS_STATUS_E_FAILURE;; |
| 1124 | } |
| 1125 | |
| 1126 | /*removing empty spaces*/ |
| 1127 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 1128 | |
| 1129 | /*no argument followed by spaces*/ |
| 1130 | if ('\0' == *inPtr) |
| 1131 | { |
| 1132 | return VOS_STATUS_E_FAILURE;; |
| 1133 | } |
| 1134 | |
| 1135 | /*getting the first argument ie the peer mac address */ |
| 1136 | if (inPtr[2] != ':' || inPtr[5] != ':' || inPtr[8] != ':' || |
| 1137 | inPtr[11] != ':' || inPtr[14] != ':') |
| 1138 | { |
| 1139 | return VOS_STATUS_E_FAILURE;; |
| 1140 | } |
| 1141 | sscanf(inPtr, "%2x:%2x:%2x:%2x:%2x:%2x", |
| 1142 | (unsigned int *)&pPeerMacAddr->bytes[0], |
| 1143 | (unsigned int *)&pPeerMacAddr->bytes[1], |
| 1144 | (unsigned int *)&pPeerMacAddr->bytes[2], |
| 1145 | (unsigned int *)&pPeerMacAddr->bytes[3], |
| 1146 | (unsigned int *)&pPeerMacAddr->bytes[4], |
| 1147 | (unsigned int *)&pPeerMacAddr->bytes[5]); |
| 1148 | |
| 1149 | /* The command buffer seems to be fine */ |
| 1150 | return VOS_STATUS_SUCCESS; |
| 1151 | } |
| 1152 | |
| 1153 | /* Function header left blank Intentionally */ |
| 1154 | static int hdd_parse_set_ibss_oui_data_command(tANI_U8 *command, tANI_U8 *ie, |
| 1155 | tANI_U32 limit) |
| 1156 | { |
| 1157 | tANI_U8 len; |
| 1158 | tANI_U8 data; |
| 1159 | |
| 1160 | /* skip white space */ |
| 1161 | while ((SPACE_ASCII_VALUE == *command) && ('\0' != *command)) |
| 1162 | { |
| 1163 | command++; |
| 1164 | limit--; |
| 1165 | } |
| 1166 | |
| 1167 | /* skip element id and element length */ |
| 1168 | len = 2; |
| 1169 | |
| 1170 | /* extract oui */ |
| 1171 | while ((SPACE_ASCII_VALUE != *command) && ('\0' != *command) && |
| 1172 | (limit > 1)) |
| 1173 | { |
| 1174 | /* Convert ASCII to decimal */ |
| 1175 | data = ((*command -'0') << 4) | (*(command + 1) - '0'); |
| 1176 | ie[len++] = data; |
| 1177 | command += 2; |
| 1178 | limit -= 2; |
| 1179 | } |
| 1180 | |
| 1181 | /* skip white space */ |
| 1182 | while ((SPACE_ASCII_VALUE == *command) && ('\0' != *command)) |
| 1183 | { |
| 1184 | command++; |
| 1185 | limit--; |
| 1186 | } |
| 1187 | |
| 1188 | /* extract data */ |
| 1189 | while ((SPACE_ASCII_VALUE != *command) && ('\0' != *command) && |
| 1190 | (limit > 1)) |
| 1191 | { |
| 1192 | /* Convert ASCII to decimal */ |
| 1193 | data = ((*command -'0') << 4) | (*(command + 1) - '0'); |
| 1194 | ie[len++] = data; |
| 1195 | command += 2; |
| 1196 | limit -= 2; |
| 1197 | } |
| 1198 | |
| 1199 | /* fill element id and element length */ |
| 1200 | ie[0] = IE_EID_VENDOR; |
| 1201 | ie[1] = len - 2; |
| 1202 | |
| 1203 | return len; |
| 1204 | } |
| 1205 | |
| 1206 | static tANI_U32 hdd_find_ibss_wpa_ie_pos(tANI_U8 *addIePtr, tANI_U32 addIeLen) |
| 1207 | { |
| 1208 | tANI_U32 ieLenPresent = 0; |
| 1209 | int left = addIeLen; |
| 1210 | v_U8_t *ptr = addIePtr; |
| 1211 | v_U8_t elem_id,elem_len; |
| 1212 | |
| 1213 | while(left >= 2) |
| 1214 | { |
| 1215 | elem_id = ptr[0]; |
| 1216 | elem_len = ptr[1]; |
| 1217 | left -= 2; |
| 1218 | if(elem_len > left) |
| 1219 | { |
| 1220 | hddLog(LOGE, |
| 1221 | FL("****Invalid elem_len=%d left=%d*****"), |
| 1222 | elem_len,left); |
| 1223 | return 0; |
| 1224 | } |
| 1225 | if ((elem_id == IE_EID_VENDOR) && |
| 1226 | (left >= WPA_OUI_TYPE_SIZE)) |
| 1227 | { |
| 1228 | if (!memcmp(&ptr[2], WPA_OUI_TYPE, |
| 1229 | WPA_OUI_TYPE_SIZE)) |
| 1230 | { |
| 1231 | ieLenPresent += elem_len + 2; |
| 1232 | return ieLenPresent; |
| 1233 | } |
| 1234 | } |
| 1235 | ieLenPresent += (elem_len + 2); |
| 1236 | left -= elem_len; |
| 1237 | ptr += (elem_len + 2); |
| 1238 | } |
| 1239 | return 0; |
| 1240 | } |
| 1241 | |
| 1242 | #endif /* WLAN_FEATURE_RMC */ |
| 1243 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1244 | #ifdef FEATURE_WLAN_BATCH_SCAN |
| 1245 | |
| 1246 | /**--------------------------------------------------------------------------- |
| 1247 | |
| 1248 | \brief hdd_extract_assigned_int_from_str() - Extracts assigned integer from |
| 1249 | input string |
| 1250 | |
| 1251 | This function extracts assigned integer from string in below format: |
| 1252 | "STRING=10" : extracts integer 10 from this string |
| 1253 | |
| 1254 | \param - pInPtr Pointer to input string |
| 1255 | \param - base Base for string to int conversion(10 for decimal 16 for hex) |
| 1256 | \param - pOutPtr Pointer to variable in which extracted integer needs to be |
| 1257 | assigned |
| 1258 | \param - pLastArg to tell whether it is last arguement in input string or |
| 1259 | not |
| 1260 | |
| 1261 | \return - NULL for failure cases |
| 1262 | pointer to next arguement in input string for success cases |
| 1263 | --------------------------------------------------------------------------*/ |
| 1264 | static tANI_U8 * |
| 1265 | hdd_extract_assigned_int_from_str |
| 1266 | ( |
| 1267 | tANI_U8 *pInPtr, |
| 1268 | tANI_U8 base, |
| 1269 | tANI_U32 *pOutPtr, |
| 1270 | tANI_U8 *pLastArg |
| 1271 | ) |
| 1272 | { |
| 1273 | int tempInt; |
| 1274 | int v = 0; |
| 1275 | char buf[32]; |
| 1276 | int val = 0; |
| 1277 | *pLastArg = FALSE; |
| 1278 | |
| 1279 | pInPtr = strnchr(pInPtr, strlen(pInPtr), EQUALS_TO_ASCII_VALUE); |
| 1280 | if (NULL == pInPtr) |
| 1281 | { |
| 1282 | return NULL; |
| 1283 | } |
| 1284 | |
| 1285 | pInPtr++; |
| 1286 | |
| 1287 | while ((SPACE_ASCII_VALUE == *pInPtr) && ('\0' != *pInPtr)) pInPtr++; |
| 1288 | |
| 1289 | val = sscanf(pInPtr, "%32s ", buf); |
| 1290 | if (val < 0 && val > strlen(pInPtr)) |
| 1291 | { |
| 1292 | return NULL; |
| 1293 | } |
| 1294 | pInPtr += val; |
| 1295 | v = kstrtos32(buf, base, &tempInt); |
| 1296 | if (v < 0) |
| 1297 | { |
| 1298 | return NULL; |
| 1299 | } |
Rajeev Kumar | 4d93d84 | 2014-01-02 18:31:21 -0800 | [diff] [blame] | 1300 | if (tempInt < 0) |
| 1301 | { |
| 1302 | tempInt = 0; |
| 1303 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1304 | *pOutPtr = tempInt; |
| 1305 | |
| 1306 | pInPtr = strnchr(pInPtr, strlen(pInPtr), SPACE_ASCII_VALUE); |
| 1307 | if (NULL == pInPtr) |
| 1308 | { |
| 1309 | *pLastArg = TRUE; |
| 1310 | return NULL; |
| 1311 | } |
| 1312 | while ((SPACE_ASCII_VALUE == *pInPtr) && ('\0' != *pInPtr)) pInPtr++; |
| 1313 | |
| 1314 | return pInPtr; |
| 1315 | } |
| 1316 | |
| 1317 | /**--------------------------------------------------------------------------- |
| 1318 | |
| 1319 | \brief hdd_extract_assigned_char_from_str() - Extracts assigned char from |
| 1320 | input string |
| 1321 | |
| 1322 | This function extracts assigned character from string in below format: |
| 1323 | "STRING=A" : extracts char 'A' from this string |
| 1324 | |
| 1325 | \param - pInPtr Pointer to input string |
| 1326 | \param - pOutPtr Pointer to variable in which extracted char needs to be |
| 1327 | assigned |
| 1328 | \param - pLastArg to tell whether it is last arguement in input string or |
| 1329 | not |
| 1330 | |
| 1331 | \return - NULL for failure cases |
| 1332 | pointer to next arguement in input string for success cases |
| 1333 | --------------------------------------------------------------------------*/ |
| 1334 | static tANI_U8 * |
| 1335 | hdd_extract_assigned_char_from_str |
| 1336 | ( |
| 1337 | tANI_U8 *pInPtr, |
| 1338 | tANI_U8 *pOutPtr, |
| 1339 | tANI_U8 *pLastArg |
| 1340 | ) |
| 1341 | { |
| 1342 | *pLastArg = FALSE; |
| 1343 | |
| 1344 | pInPtr = strnchr(pInPtr, strlen(pInPtr), EQUALS_TO_ASCII_VALUE); |
| 1345 | if (NULL == pInPtr) |
| 1346 | { |
| 1347 | return NULL; |
| 1348 | } |
| 1349 | |
| 1350 | pInPtr++; |
| 1351 | |
| 1352 | while ((SPACE_ASCII_VALUE == *pInPtr) && ('\0' != *pInPtr)) pInPtr++; |
| 1353 | |
| 1354 | *pOutPtr = *pInPtr; |
| 1355 | |
| 1356 | pInPtr = strnchr(pInPtr, strlen(pInPtr), SPACE_ASCII_VALUE); |
| 1357 | if (NULL == pInPtr) |
| 1358 | { |
| 1359 | *pLastArg = TRUE; |
| 1360 | return NULL; |
| 1361 | } |
| 1362 | while ((SPACE_ASCII_VALUE == *pInPtr) && ('\0' != *pInPtr)) pInPtr++; |
| 1363 | |
| 1364 | return pInPtr; |
| 1365 | } |
| 1366 | |
| 1367 | |
| 1368 | /**--------------------------------------------------------------------------- |
| 1369 | |
| 1370 | \brief hdd_parse_set_batchscan_command () - HDD parse set batch scan command |
| 1371 | |
| 1372 | This function parses set batch scan command in below format: |
| 1373 | WLS_BATCHING_SET <space> followed by below arguements |
| 1374 | "SCANFREQ=XX" : Optional defaults to 30 sec |
| 1375 | "MSCAN=XX" : Required number of scans to attempt to batch |
| 1376 | "BESTN=XX" : Best Network (RSSI) defaults to 16 |
| 1377 | "CHANNEL=<X,Y>" : optional defaults to all channels, can list 'A'or` B. |
| 1378 | A. implies only 5 GHz , B. implies only 2.4GHz |
| 1379 | "RTT=X" : optional defaults to 0 |
| 1380 | returns the MIN of MSCAN or the max # of scans firmware can cache or -1 on |
| 1381 | error |
| 1382 | |
| 1383 | For example input commands: |
| 1384 | 1) WLS_BATCHING_SET SCANFREQ=60 MSCAN=10 BESTN=20 CHANNEL=A RTT=0 -> This is |
| 1385 | translated into set batch scan with following parameters: |
| 1386 | a) Frequence 60 seconds |
| 1387 | b) Batch 10 scans together |
| 1388 | c) Best RSSI to be 20 |
| 1389 | d) 5GHz band only |
| 1390 | e) RTT is equal to 0 |
| 1391 | |
| 1392 | \param - pValue Pointer to input channel list |
| 1393 | \param - pHddSetBatchScanReq Pointer to HDD batch scan request structure |
| 1394 | |
| 1395 | \return - 0 for success non-zero for failure |
| 1396 | |
| 1397 | --------------------------------------------------------------------------*/ |
| 1398 | static int |
| 1399 | hdd_parse_set_batchscan_command |
| 1400 | ( |
| 1401 | tANI_U8 *pValue, |
| 1402 | tSirSetBatchScanReq *pHddSetBatchScanReq |
| 1403 | ) |
| 1404 | { |
| 1405 | tANI_U8 *inPtr = pValue; |
| 1406 | tANI_U8 val = 0; |
| 1407 | tANI_U8 lastArg = 0; |
Abhishek Singh | 00b7197 | 2016-01-07 10:51:04 +0530 | [diff] [blame] | 1408 | tANI_U32 nScanFreq = HDD_SET_BATCH_SCAN_DEFAULT_FREQ; |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 1409 | tANI_U32 nMscan; |
Abhishek Singh | 00b7197 | 2016-01-07 10:51:04 +0530 | [diff] [blame] | 1410 | tANI_U32 nBestN = HDD_SET_BATCH_SCAN_BEST_NETWORK; |
| 1411 | tANI_U8 ucRfBand = HDD_SET_BATCH_SCAN_DEFAULT_BAND; |
| 1412 | tANI_U32 nRtt = 0; |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 1413 | tANI_U32 temp; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1414 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1415 | /*go to space after WLS_BATCHING_SET command*/ |
| 1416 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 1417 | /*no argument after the command*/ |
| 1418 | if (NULL == inPtr) |
| 1419 | { |
| 1420 | return -EINVAL; |
| 1421 | } |
| 1422 | |
| 1423 | /*no space after the command*/ |
| 1424 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 1425 | { |
| 1426 | return -EINVAL; |
| 1427 | } |
| 1428 | |
| 1429 | /*removing empty spaces*/ |
| 1430 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
| 1431 | |
| 1432 | /*no argument followed by spaces*/ |
| 1433 | if ('\0' == *inPtr) |
| 1434 | { |
| 1435 | return -EINVAL; |
| 1436 | } |
| 1437 | |
| 1438 | /*check and parse SCANFREQ*/ |
| 1439 | if ((strncmp(inPtr, "SCANFREQ", 8) == 0)) |
| 1440 | { |
| 1441 | inPtr = hdd_extract_assigned_int_from_str(inPtr, 10, |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 1442 | &temp, &lastArg); |
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 | if (0 != temp) |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 1445 | { |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 1446 | nScanFreq = temp; |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 1447 | } |
| 1448 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1449 | if ( (NULL == inPtr) || (TRUE == lastArg)) |
| 1450 | { |
| 1451 | return -EINVAL; |
| 1452 | } |
| 1453 | } |
| 1454 | |
| 1455 | /*check and parse MSCAN*/ |
| 1456 | if ((strncmp(inPtr, "MSCAN", 5) == 0)) |
| 1457 | { |
| 1458 | inPtr = hdd_extract_assigned_int_from_str(inPtr, 10, |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 1459 | &nMscan, &lastArg); |
| 1460 | |
| 1461 | if (0 == nMscan) |
| 1462 | { |
| 1463 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1464 | "invalid MSCAN=%d", nMscan); |
| 1465 | return -EINVAL; |
| 1466 | } |
| 1467 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1468 | if (TRUE == lastArg) |
| 1469 | { |
| 1470 | goto done; |
| 1471 | } |
| 1472 | else if (NULL == inPtr) |
| 1473 | { |
| 1474 | return -EINVAL; |
| 1475 | } |
| 1476 | } |
| 1477 | else |
| 1478 | { |
| 1479 | return -EINVAL; |
| 1480 | } |
| 1481 | |
| 1482 | /*check and parse BESTN*/ |
| 1483 | if ((strncmp(inPtr, "BESTN", 5) == 0)) |
| 1484 | { |
| 1485 | inPtr = hdd_extract_assigned_int_from_str(inPtr, 10, |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 1486 | &temp, &lastArg); |
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 | if (0 != temp) |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 1489 | { |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 1490 | nBestN = temp; |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 1491 | } |
| 1492 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1493 | if (TRUE == lastArg) |
| 1494 | { |
| 1495 | goto done; |
| 1496 | } |
| 1497 | else if (NULL == inPtr) |
| 1498 | { |
| 1499 | return -EINVAL; |
| 1500 | } |
| 1501 | } |
| 1502 | |
| 1503 | /*check and parse CHANNEL*/ |
| 1504 | if ((strncmp(inPtr, "CHANNEL", 7) == 0)) |
| 1505 | { |
| 1506 | inPtr = hdd_extract_assigned_char_from_str(inPtr, &val, &lastArg); |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 1507 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1508 | if (('A' == val) || ('a' == val)) |
| 1509 | { |
c_hpothu | ebf8973 | 2014-02-25 13:00:24 +0530 | [diff] [blame] | 1510 | ucRfBand = HDD_SET_BATCH_SCAN_5GHz_BAND_ONLY; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1511 | } |
| 1512 | else if (('B' == val) || ('b' == val)) |
| 1513 | { |
c_hpothu | ebf8973 | 2014-02-25 13:00:24 +0530 | [diff] [blame] | 1514 | ucRfBand = HDD_SET_BATCH_SCAN_24GHz_BAND_ONLY; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1515 | } |
| 1516 | else |
| 1517 | { |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 1518 | ucRfBand = HDD_SET_BATCH_SCAN_DEFAULT_BAND; |
| 1519 | } |
| 1520 | |
| 1521 | if (TRUE == lastArg) |
| 1522 | { |
| 1523 | goto done; |
| 1524 | } |
| 1525 | else if (NULL == inPtr) |
| 1526 | { |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1527 | return -EINVAL; |
| 1528 | } |
| 1529 | } |
| 1530 | |
| 1531 | /*check and parse RTT*/ |
| 1532 | if ((strncmp(inPtr, "RTT", 3) == 0)) |
| 1533 | { |
| 1534 | inPtr = hdd_extract_assigned_int_from_str(inPtr, 10, |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 1535 | &nRtt, &lastArg); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1536 | if (TRUE == lastArg) |
| 1537 | { |
| 1538 | goto done; |
| 1539 | } |
| 1540 | if (NULL == inPtr) |
| 1541 | { |
| 1542 | return -EINVAL; |
| 1543 | } |
| 1544 | } |
| 1545 | |
| 1546 | |
| 1547 | done: |
| 1548 | |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 1549 | pHddSetBatchScanReq->scanFrequency = nScanFreq; |
| 1550 | pHddSetBatchScanReq->numberOfScansToBatch = nMscan; |
| 1551 | pHddSetBatchScanReq->bestNetwork = nBestN; |
| 1552 | pHddSetBatchScanReq->rfBand = ucRfBand; |
| 1553 | pHddSetBatchScanReq->rtt = nRtt; |
| 1554 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1555 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1556 | "Received WLS_BATCHING_SET with SCANFREQ=%d " |
| 1557 | "MSCAN=%d BESTN=%d CHANNEL=%d RTT=%d", |
| 1558 | pHddSetBatchScanReq->scanFrequency, |
| 1559 | pHddSetBatchScanReq->numberOfScansToBatch, |
| 1560 | pHddSetBatchScanReq->bestNetwork, |
| 1561 | pHddSetBatchScanReq->rfBand, |
| 1562 | pHddSetBatchScanReq->rtt); |
| 1563 | |
| 1564 | return 0; |
| 1565 | }/*End of hdd_parse_set_batchscan_command*/ |
| 1566 | |
| 1567 | /**--------------------------------------------------------------------------- |
| 1568 | |
| 1569 | \brief hdd_set_batch_scan_req_callback () - This function is called after |
| 1570 | receiving set batch scan response from FW and it saves set batch scan |
| 1571 | response data FW to HDD context and sets the completion event on |
| 1572 | which hdd_ioctl is waiting |
| 1573 | |
| 1574 | \param - callbackContext Pointer to HDD adapter |
| 1575 | \param - pRsp Pointer to set batch scan response data received from FW |
| 1576 | |
| 1577 | \return - nothing |
| 1578 | |
| 1579 | --------------------------------------------------------------------------*/ |
| 1580 | static void hdd_set_batch_scan_req_callback |
| 1581 | ( |
| 1582 | void *callbackContext, |
| 1583 | tSirSetBatchScanRsp *pRsp |
| 1584 | ) |
| 1585 | { |
| 1586 | hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext; |
| 1587 | tSirSetBatchScanRsp *pHddSetBatchScanRsp; |
| 1588 | |
| 1589 | /*sanity check*/ |
| 1590 | if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) |
| 1591 | { |
| 1592 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1593 | "%s: Invalid pAdapter magic", __func__); |
| 1594 | VOS_ASSERT(0); |
| 1595 | return; |
| 1596 | } |
| 1597 | pHddSetBatchScanRsp = &pAdapter->hddSetBatchScanRsp; |
| 1598 | |
| 1599 | /*save set batch scan response*/ |
| 1600 | pHddSetBatchScanRsp->nScansToBatch = pRsp->nScansToBatch; |
| 1601 | |
| 1602 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
| 1603 | "Received set batch scan rsp from FW with nScansToBatch=%d", |
| 1604 | pHddSetBatchScanRsp->nScansToBatch); |
| 1605 | |
| 1606 | pAdapter->hdd_wait_for_set_batch_scan_rsp = FALSE; |
| 1607 | complete(&pAdapter->hdd_set_batch_scan_req_var); |
| 1608 | |
| 1609 | return; |
| 1610 | }/*End of hdd_set_batch_scan_req_callback*/ |
| 1611 | |
| 1612 | |
| 1613 | /**--------------------------------------------------------------------------- |
| 1614 | |
| 1615 | \brief hdd_populate_batch_scan_rsp_queue () - This function stores AP meta |
| 1616 | info in hdd batch scan response queue |
| 1617 | |
| 1618 | \param - pAdapter Pointer to hdd adapter |
| 1619 | \param - pAPMetaInfo Pointer to access point meta info |
| 1620 | \param - scanId scan ID of batch scan response |
| 1621 | \param - isLastAp tells whether AP is last AP in batch scan response or not |
| 1622 | |
| 1623 | \return - nothing |
| 1624 | |
| 1625 | --------------------------------------------------------------------------*/ |
| 1626 | static void hdd_populate_batch_scan_rsp_queue( hdd_adapter_t* pAdapter, |
| 1627 | tpSirBatchScanNetworkInfo pApMetaInfo, tANI_U32 scanId, v_BOOL_t isLastAp) |
| 1628 | { |
| 1629 | tHddBatchScanRsp *pHead; |
| 1630 | tHddBatchScanRsp *pNode; |
| 1631 | tHddBatchScanRsp *pPrev; |
| 1632 | tHddBatchScanRsp *pTemp; |
| 1633 | tANI_U8 ssidLen; |
| 1634 | |
| 1635 | /*head of hdd batch scan response queue*/ |
| 1636 | pHead = pAdapter->pBatchScanRsp; |
| 1637 | |
| 1638 | pNode = (tHddBatchScanRsp *)vos_mem_malloc(sizeof(tHddBatchScanRsp)); |
| 1639 | if (NULL == pNode) |
| 1640 | { |
| 1641 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1642 | "%s: Could not allocate memory", __func__); |
| 1643 | VOS_ASSERT(0); |
| 1644 | return; |
| 1645 | } |
| 1646 | |
| 1647 | vos_mem_copy(pNode->ApInfo.bssid, pApMetaInfo->bssid, |
| 1648 | sizeof(pNode->ApInfo.bssid)); |
| 1649 | ssidLen = strlen(pApMetaInfo->ssid); |
| 1650 | if (SIR_MAX_SSID_SIZE < ssidLen) |
| 1651 | { |
| 1652 | /*invalid scan result*/ |
| 1653 | vos_mem_free(pNode); |
| 1654 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1655 | "%s: Invalid AP meta info ssidlen %d", __func__, ssidLen); |
| 1656 | return; |
| 1657 | } |
| 1658 | vos_mem_copy(pNode->ApInfo.ssid, pApMetaInfo->ssid, ssidLen); |
| 1659 | /*null terminate ssid*/ |
| 1660 | pNode->ApInfo.ssid[ssidLen] = '\0'; |
| 1661 | pNode->ApInfo.ch = pApMetaInfo->ch; |
| 1662 | pNode->ApInfo.rssi = pApMetaInfo->rssi; |
| 1663 | pNode->ApInfo.age = pApMetaInfo->timestamp; |
| 1664 | pNode->ApInfo.batchId = scanId; |
| 1665 | pNode->ApInfo.isLastAp = isLastAp; |
| 1666 | |
| 1667 | pNode->pNext = NULL; |
| 1668 | if (NULL == pHead) |
| 1669 | { |
| 1670 | pAdapter->pBatchScanRsp = pNode; |
| 1671 | } |
| 1672 | else |
| 1673 | { |
| 1674 | pTemp = pHead; |
| 1675 | while (NULL != pTemp) |
| 1676 | { |
| 1677 | pPrev = pTemp; |
| 1678 | pTemp = pTemp->pNext; |
| 1679 | } |
| 1680 | pPrev->pNext = pNode; |
| 1681 | } |
| 1682 | |
| 1683 | return; |
| 1684 | }/*End of hdd_populate_batch_scan_rsp_queue*/ |
| 1685 | |
| 1686 | /**--------------------------------------------------------------------------- |
| 1687 | |
| 1688 | \brief hdd_batch_scan_result_ind_callback () - This function is called after |
| 1689 | receiving batch scan response indication from FW. It saves get batch scan |
| 1690 | response data in HDD batch scan response queue. This callback sets the |
| 1691 | completion event on which hdd_ioctl is waiting only after getting complete |
| 1692 | batch scan response data from FW |
| 1693 | |
| 1694 | \param - callbackContext Pointer to HDD adapter |
| 1695 | \param - pRsp Pointer to get batch scan response data received from FW |
| 1696 | |
| 1697 | \return - nothing |
| 1698 | |
| 1699 | --------------------------------------------------------------------------*/ |
| 1700 | static void hdd_batch_scan_result_ind_callback |
| 1701 | ( |
| 1702 | void *callbackContext, |
| 1703 | void *pRsp |
| 1704 | ) |
| 1705 | { |
| 1706 | v_BOOL_t isLastAp; |
| 1707 | tANI_U32 numApMetaInfo; |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1708 | tANI_U32 numNetworkInScanList; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1709 | tANI_U32 numberScanList; |
| 1710 | tANI_U32 nextScanListOffset; |
| 1711 | tANI_U32 nextApMetaInfoOffset; |
| 1712 | hdd_adapter_t* pAdapter; |
| 1713 | tpSirBatchScanList pScanList; |
| 1714 | tpSirBatchScanNetworkInfo pApMetaInfo; |
| 1715 | tpSirBatchScanResultIndParam pBatchScanRsp;/*batch scan rsp data from FW*/ |
| 1716 | tSirSetBatchScanReq *pReq; |
| 1717 | |
| 1718 | pAdapter = (hdd_adapter_t *)callbackContext; |
| 1719 | /*sanity check*/ |
Rajeev Kumar | 5286bb9 | 2013-12-05 11:52:10 -0800 | [diff] [blame] | 1720 | if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)) |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1721 | { |
| 1722 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1723 | "%s: Invalid pAdapter magic", __func__); |
| 1724 | VOS_ASSERT(0); |
| 1725 | return; |
| 1726 | } |
| 1727 | |
| 1728 | /*initialize locals*/ |
| 1729 | pReq = &pAdapter->hddSetBatchScanReq; |
| 1730 | pBatchScanRsp = (tpSirBatchScanResultIndParam)pRsp; |
| 1731 | isLastAp = FALSE; |
| 1732 | numApMetaInfo = 0; |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1733 | numNetworkInScanList = 0; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1734 | numberScanList = 0; |
| 1735 | nextScanListOffset = 0; |
| 1736 | nextApMetaInfoOffset = 0; |
| 1737 | pScanList = NULL; |
| 1738 | pApMetaInfo = NULL; |
| 1739 | |
| 1740 | if ((NULL == pBatchScanRsp) || (NULL == pReq)) |
| 1741 | { |
| 1742 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | c135a9a | 2017-09-19 08:37:24 -0700 | [diff] [blame] | 1743 | "%s: pBatchScanRsp is %pK pReq %pK", __func__, pBatchScanRsp, pReq); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1744 | isLastAp = TRUE; |
| 1745 | goto done; |
| 1746 | } |
| 1747 | |
| 1748 | pAdapter->numScanList = numberScanList = pBatchScanRsp->numScanLists; |
| 1749 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1750 | "Batch scan rsp: numberScalList %d", numberScanList); |
| 1751 | |
| 1752 | if ((!numberScanList) || (numberScanList > pReq->numberOfScansToBatch)) |
| 1753 | { |
| 1754 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1755 | "%s: numberScanList %d", __func__, numberScanList); |
| 1756 | isLastAp = TRUE; |
| 1757 | goto done; |
| 1758 | } |
| 1759 | |
| 1760 | while (numberScanList) |
| 1761 | { |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1762 | pScanList = (tpSirBatchScanList)((tANI_U8 *)pBatchScanRsp->scanResults + |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1763 | nextScanListOffset); |
| 1764 | if (NULL == pScanList) |
| 1765 | { |
| 1766 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | c135a9a | 2017-09-19 08:37:24 -0700 | [diff] [blame] | 1767 | "%s: pScanList is %pK", __func__, pScanList); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1768 | isLastAp = TRUE; |
| 1769 | goto done; |
| 1770 | } |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1771 | numNetworkInScanList = numApMetaInfo = pScanList->numNetworksInScanList; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1772 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1773 | "Batch scan rsp: numApMetaInfo %d scanId %d", |
| 1774 | numApMetaInfo, pScanList->scanId); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1775 | |
| 1776 | if ((!numApMetaInfo) || (numApMetaInfo > pReq->bestNetwork)) |
| 1777 | { |
| 1778 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1779 | "%s: numApMetaInfo %d", __func__, numApMetaInfo); |
| 1780 | isLastAp = TRUE; |
| 1781 | goto done; |
| 1782 | } |
| 1783 | |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1784 | /*Initialize next AP meta info offset for next scan list*/ |
| 1785 | nextApMetaInfoOffset = 0; |
| 1786 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1787 | while (numApMetaInfo) |
| 1788 | { |
| 1789 | pApMetaInfo = (tpSirBatchScanNetworkInfo)(pScanList->scanList + |
| 1790 | nextApMetaInfoOffset); |
| 1791 | if (NULL == pApMetaInfo) |
| 1792 | { |
| 1793 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | c135a9a | 2017-09-19 08:37:24 -0700 | [diff] [blame] | 1794 | "%s: pApMetaInfo is %pK", __func__, pApMetaInfo); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1795 | isLastAp = TRUE; |
| 1796 | goto done; |
| 1797 | } |
| 1798 | /*calculate AP age*/ |
| 1799 | pApMetaInfo->timestamp = |
| 1800 | pBatchScanRsp->timestamp - pApMetaInfo->timestamp; |
| 1801 | |
| 1802 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
Arif Hussain | a7c8e41 | 2013-11-20 11:06:42 -0800 | [diff] [blame] | 1803 | "%s: bssId "MAC_ADDRESS_STR |
| 1804 | " ch %d rssi %d timestamp %d", __func__, |
| 1805 | MAC_ADDR_ARRAY(pApMetaInfo->bssid), |
| 1806 | pApMetaInfo->ch, pApMetaInfo->rssi, |
| 1807 | pApMetaInfo->timestamp); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1808 | |
| 1809 | /*mark last AP in batch scan response*/ |
| 1810 | if ((TRUE == pBatchScanRsp->isLastResult) && |
| 1811 | (1 == numberScanList) && (1 == numApMetaInfo)) |
| 1812 | { |
| 1813 | isLastAp = TRUE; |
| 1814 | } |
| 1815 | |
| 1816 | mutex_lock(&pAdapter->hdd_batch_scan_lock); |
| 1817 | /*store batch scan repsonse in hdd queue*/ |
| 1818 | hdd_populate_batch_scan_rsp_queue(pAdapter, pApMetaInfo, |
| 1819 | pScanList->scanId, isLastAp); |
| 1820 | mutex_unlock(&pAdapter->hdd_batch_scan_lock); |
| 1821 | |
| 1822 | nextApMetaInfoOffset += sizeof(tSirBatchScanNetworkInfo); |
| 1823 | numApMetaInfo--; |
| 1824 | } |
| 1825 | |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1826 | nextScanListOffset += ((sizeof(tSirBatchScanList) - sizeof(tANI_U8)) |
| 1827 | + (sizeof(tSirBatchScanNetworkInfo) |
| 1828 | * numNetworkInScanList)); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1829 | numberScanList--; |
| 1830 | } |
| 1831 | |
| 1832 | done: |
| 1833 | |
| 1834 | /*notify hdd_ioctl only if complete batch scan rsp is received and it was |
| 1835 | requested from hdd_ioctl*/ |
| 1836 | if ((TRUE == pAdapter->hdd_wait_for_get_batch_scan_rsp) && |
| 1837 | (TRUE == isLastAp)) |
| 1838 | { |
| 1839 | pAdapter->hdd_wait_for_get_batch_scan_rsp = FALSE; |
| 1840 | complete(&pAdapter->hdd_get_batch_scan_req_var); |
| 1841 | } |
| 1842 | |
| 1843 | return; |
| 1844 | }/*End of hdd_batch_scan_result_ind_callback*/ |
| 1845 | |
| 1846 | /**--------------------------------------------------------------------------- |
| 1847 | |
| 1848 | \brief hdd_format_batch_scan_rsp () - This function formats batch scan |
| 1849 | response as per batch scan FR request format by putting proper markers |
| 1850 | |
| 1851 | \param - pDest pointer to destination buffer |
| 1852 | \param - cur_len current length |
| 1853 | \param - tot_len total remaining size which can be written to user space |
| 1854 | \param - pApMetaInfo Pointer to get batch scan response AP meta info |
| 1855 | \param - pAdapter Pointer to HDD adapter |
| 1856 | |
| 1857 | \return - ret no of characters written |
| 1858 | |
| 1859 | --------------------------------------------------------------------------*/ |
| 1860 | static tANI_U32 |
| 1861 | hdd_format_batch_scan_rsp |
| 1862 | ( |
| 1863 | tANI_U8 *pDest, |
| 1864 | tANI_U32 cur_len, |
| 1865 | tANI_U32 tot_len, |
| 1866 | tHddBatchScanRsp *pApMetaInfo, |
| 1867 | hdd_adapter_t* pAdapter |
| 1868 | ) |
| 1869 | { |
| 1870 | tANI_U32 ret = 0; |
| 1871 | tANI_U32 rem_len = 0; |
| 1872 | tANI_U8 temp_len = 0; |
| 1873 | tANI_U8 temp_total_len = 0; |
| 1874 | tANI_U8 temp[HDD_BATCH_SCAN_AP_META_INFO_SIZE]; |
| 1875 | tANI_U8 *pTemp = temp; |
| 1876 | |
| 1877 | /*Batch scan reponse needs to be returned to user space in |
| 1878 | following format: |
| 1879 | "scancount=X\n" where X is the number of scans in current batch |
| 1880 | batch |
| 1881 | "trunc\n" optional present if current scan truncated |
| 1882 | "bssid=XX:XX:XX:XX:XX:XX\n" |
| 1883 | "ssid=XXXX\n" |
| 1884 | "freq=X\n" frequency in Mhz |
| 1885 | "level=XX\n" |
| 1886 | "age=X\n" ms |
| 1887 | "dist=X\n" cm (-1 if not available) |
| 1888 | "errror=X\n" (-1if not available) |
| 1889 | "====\n" (end of ap marker) |
| 1890 | "####\n" (end of scan marker) |
| 1891 | "----\n" (end of results)*/ |
| 1892 | /*send scan result in above format to user space based on |
| 1893 | available length*/ |
| 1894 | /*The GET response may have more data than the driver can return in its |
| 1895 | buffer. In that case the buffer should be filled to the nearest complete |
| 1896 | scan, ending with "%%%%".Subsequent callsshould return the remaining data |
| 1897 | starting with the next scan (optional .trunc\n., .apcount=X\n., etc). |
| 1898 | The final buffer should end with "----\n"*/ |
| 1899 | |
| 1900 | /*sanity*/ |
| 1901 | if (cur_len > tot_len) |
| 1902 | { |
| 1903 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1904 | "%s: invaid cur_len %d tot_len %d", __func__, cur_len, tot_len); |
| 1905 | return 0; |
| 1906 | } |
| 1907 | else |
| 1908 | { |
| 1909 | rem_len = (tot_len - cur_len); |
| 1910 | } |
| 1911 | |
| 1912 | /*end scan marker*/ |
| 1913 | if (pApMetaInfo->ApInfo.batchId != pAdapter->prev_batch_id) |
| 1914 | { |
| 1915 | temp_len = snprintf(pTemp, sizeof(temp), "####\n"); |
| 1916 | pTemp += temp_len; |
| 1917 | temp_total_len += temp_len; |
| 1918 | } |
| 1919 | |
| 1920 | /*bssid*/ |
| 1921 | temp_len = snprintf(pTemp, sizeof(temp), |
| 1922 | "bssid=0x%x:0x%x:0x%x:0x%x:0x%x:0x%x\n", |
| 1923 | pApMetaInfo->ApInfo.bssid[0], pApMetaInfo->ApInfo.bssid[1], |
| 1924 | pApMetaInfo->ApInfo.bssid[2], pApMetaInfo->ApInfo.bssid[3], |
| 1925 | pApMetaInfo->ApInfo.bssid[4], pApMetaInfo->ApInfo.bssid[5]); |
| 1926 | pTemp += temp_len; |
| 1927 | temp_total_len += temp_len; |
| 1928 | |
| 1929 | /*ssid*/ |
| 1930 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "ssid=%s\n", |
| 1931 | pApMetaInfo->ApInfo.ssid); |
| 1932 | pTemp += temp_len; |
| 1933 | temp_total_len += temp_len; |
| 1934 | |
| 1935 | /*freq*/ |
| 1936 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "freq=%d\n", |
Rajeev Kumar | c40f751 | 2013-11-04 14:13:23 -0800 | [diff] [blame] | 1937 | sme_ChnToFreq(pApMetaInfo->ApInfo.ch)); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1938 | pTemp += temp_len; |
| 1939 | temp_total_len += temp_len; |
| 1940 | |
| 1941 | /*level*/ |
| 1942 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "level=%d\n", |
| 1943 | pApMetaInfo->ApInfo.rssi); |
| 1944 | pTemp += temp_len; |
| 1945 | temp_total_len += temp_len; |
| 1946 | |
| 1947 | /*age*/ |
Jeff Johnson | 0279779 | 2013-10-26 19:17:13 -0700 | [diff] [blame] | 1948 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "age=%d\n", |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1949 | pApMetaInfo->ApInfo.age); |
| 1950 | pTemp += temp_len; |
| 1951 | temp_total_len += temp_len; |
| 1952 | |
| 1953 | /*dist*/ |
| 1954 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "dist=-1\n"); |
| 1955 | pTemp += temp_len; |
| 1956 | temp_total_len += temp_len; |
| 1957 | |
| 1958 | /*error*/ |
| 1959 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "error=-1\n"); |
| 1960 | pTemp += temp_len; |
| 1961 | temp_total_len += temp_len; |
| 1962 | |
| 1963 | /*end AP marker*/ |
| 1964 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "====\n"); |
| 1965 | pTemp += temp_len; |
| 1966 | temp_total_len += temp_len; |
| 1967 | |
| 1968 | /*last AP in batch scan response*/ |
| 1969 | if(TRUE == pApMetaInfo->ApInfo.isLastAp) |
| 1970 | { |
| 1971 | /*end scan marker*/ |
| 1972 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "####\n"); |
| 1973 | pTemp += temp_len; |
| 1974 | temp_total_len += temp_len; |
| 1975 | |
| 1976 | /*end batch scan result marker*/ |
| 1977 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "----\n"); |
| 1978 | pTemp += temp_len; |
| 1979 | temp_total_len += temp_len; |
Kiet Lam | aa8e15a | 2014-02-11 23:30:06 -0800 | [diff] [blame] | 1980 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1981 | } |
| 1982 | |
| 1983 | if (temp_total_len < rem_len) |
| 1984 | { |
| 1985 | ret = temp_total_len + 1; |
| 1986 | strlcpy(pDest, temp, ret); |
| 1987 | pAdapter->isTruncated = FALSE; |
| 1988 | } |
| 1989 | else |
| 1990 | { |
| 1991 | pAdapter->isTruncated = TRUE; |
| 1992 | if (rem_len >= strlen("%%%%")) |
| 1993 | { |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 1994 | ret = snprintf(pDest, sizeof(temp), "%%%%"); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1995 | } |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 1996 | else |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1997 | { |
| 1998 | ret = 0; |
| 1999 | } |
| 2000 | } |
| 2001 | |
| 2002 | return ret; |
| 2003 | |
| 2004 | }/*End of hdd_format_batch_scan_rsp*/ |
| 2005 | |
| 2006 | /**--------------------------------------------------------------------------- |
| 2007 | |
| 2008 | \brief hdd_populate_user_batch_scan_rsp() - This function populates user data |
| 2009 | buffer starting with head of hdd batch scan response queue |
| 2010 | |
| 2011 | \param - pAdapter Pointer to HDD adapter |
| 2012 | \param - pDest Pointer to user data buffer |
| 2013 | \param - cur_len current offset in user buffer |
| 2014 | \param - rem_len remaining no of bytes in user buffer |
| 2015 | |
| 2016 | \return - number of bytes written in user buffer |
| 2017 | |
| 2018 | --------------------------------------------------------------------------*/ |
| 2019 | |
| 2020 | tANI_U32 hdd_populate_user_batch_scan_rsp |
| 2021 | ( |
| 2022 | hdd_adapter_t* pAdapter, |
| 2023 | tANI_U8 *pDest, |
| 2024 | tANI_U32 cur_len, |
| 2025 | tANI_U32 rem_len |
| 2026 | ) |
| 2027 | { |
| 2028 | tHddBatchScanRsp *pHead; |
| 2029 | tHddBatchScanRsp *pPrev; |
| 2030 | tANI_U32 len; |
| 2031 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 2032 | pAdapter->isTruncated = FALSE; |
| 2033 | |
| 2034 | /*head of hdd batch scan response queue*/ |
| 2035 | pHead = pAdapter->pBatchScanRsp; |
| 2036 | while (pHead) |
| 2037 | { |
| 2038 | len = hdd_format_batch_scan_rsp(pDest, cur_len, rem_len, pHead, |
| 2039 | pAdapter); |
| 2040 | pDest += len; |
Rajeev Kumar | 292d2bb | 2013-10-23 15:01:44 -0700 | [diff] [blame] | 2041 | pDest--; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 2042 | cur_len += len; |
| 2043 | if(TRUE == pAdapter->isTruncated) |
| 2044 | { |
| 2045 | /*result is truncated return rest of scan rsp in next req*/ |
| 2046 | cur_len = rem_len; |
| 2047 | break; |
| 2048 | } |
| 2049 | pPrev = pHead; |
| 2050 | pHead = pHead->pNext; |
| 2051 | pAdapter->pBatchScanRsp = pHead; |
Rajeev Kumar | be17d8b | 2014-01-10 15:39:45 -0800 | [diff] [blame] | 2052 | if (TRUE == pPrev->ApInfo.isLastAp) |
| 2053 | { |
| 2054 | pAdapter->prev_batch_id = 0; |
| 2055 | } |
| 2056 | else |
| 2057 | { |
| 2058 | pAdapter->prev_batch_id = pPrev->ApInfo.batchId; |
| 2059 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 2060 | vos_mem_free(pPrev); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 2061 | pPrev = NULL; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 2062 | } |
| 2063 | |
| 2064 | return cur_len; |
| 2065 | }/*End of hdd_populate_user_batch_scan_rsp*/ |
| 2066 | |
| 2067 | /**--------------------------------------------------------------------------- |
| 2068 | |
| 2069 | \brief hdd_return_batch_scan_rsp_to_user () - This function returns batch |
| 2070 | scan response data from HDD queue to user space |
| 2071 | It does following in detail: |
| 2072 | a) if HDD has enough data in its queue then it 1st copies data to user |
| 2073 | space and then send get batch scan indication message to FW. In this |
| 2074 | case it does not wait on any event and batch scan response data will |
| 2075 | be populated in HDD response queue in MC thread context after receiving |
| 2076 | indication from FW |
| 2077 | b) else send get batch scan indication message to FW and wait on an event |
| 2078 | which will be set once HDD receives complete batch scan response from |
| 2079 | FW and then this function returns batch scan response to user space |
| 2080 | |
| 2081 | \param - pAdapter Pointer to HDD adapter |
| 2082 | \param - pPrivData Pointer to priv_data |
| 2083 | |
| 2084 | \return - 0 for success -EFAULT for failure |
| 2085 | |
| 2086 | --------------------------------------------------------------------------*/ |
| 2087 | |
| 2088 | int hdd_return_batch_scan_rsp_to_user |
| 2089 | ( |
| 2090 | hdd_adapter_t* pAdapter, |
| 2091 | hdd_priv_data_t *pPrivData, |
| 2092 | tANI_U8 *command |
| 2093 | ) |
| 2094 | { |
| 2095 | tANI_U8 *pDest; |
| 2096 | tANI_U32 count = 0; |
| 2097 | tANI_U32 len = 0; |
| 2098 | tANI_U32 cur_len = 0; |
| 2099 | tANI_U32 rem_len = 0; |
| 2100 | eHalStatus halStatus; |
| 2101 | unsigned long rc; |
| 2102 | tSirTriggerBatchScanResultInd *pReq; |
| 2103 | |
| 2104 | pReq = &pAdapter->hddTriggerBatchScanResultInd; |
| 2105 | pReq->param = 0;/*batch scan client*/ |
| 2106 | pDest = (tANI_U8 *)(command + pPrivData->used_len); |
| 2107 | pAdapter->hdd_wait_for_get_batch_scan_rsp = FALSE; |
| 2108 | |
| 2109 | cur_len = pPrivData->used_len; |
| 2110 | if (pPrivData->total_len > pPrivData->used_len) |
| 2111 | { |
| 2112 | rem_len = pPrivData->total_len - pPrivData->used_len; |
| 2113 | } |
| 2114 | else |
| 2115 | { |
| 2116 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2117 | "%s: Invalid user data buffer total_len %d used_len %d", |
| 2118 | __func__, pPrivData->total_len, pPrivData->used_len); |
| 2119 | return -EFAULT; |
| 2120 | } |
| 2121 | |
| 2122 | mutex_lock(&pAdapter->hdd_batch_scan_lock); |
| 2123 | len = hdd_populate_user_batch_scan_rsp(pAdapter, pDest, |
| 2124 | cur_len, rem_len); |
| 2125 | mutex_unlock(&pAdapter->hdd_batch_scan_lock); |
| 2126 | |
| 2127 | /*enough scan result available in cache to return to user space or |
| 2128 | scan result needs to be fetched 1st from fw and then return*/ |
Rajeev Kumar | 99db626 | 2013-11-11 15:23:36 -0800 | [diff] [blame] | 2129 | if (len == cur_len) |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 2130 | { |
| 2131 | pAdapter->hdd_wait_for_get_batch_scan_rsp = TRUE; |
| 2132 | halStatus = sme_TriggerBatchScanResultInd( |
| 2133 | WLAN_HDD_GET_HAL_CTX(pAdapter), pReq, |
| 2134 | pAdapter->sessionId, hdd_batch_scan_result_ind_callback, |
| 2135 | pAdapter); |
| 2136 | if ( eHAL_STATUS_SUCCESS == halStatus ) |
| 2137 | { |
| 2138 | if (TRUE == pAdapter->hdd_wait_for_get_batch_scan_rsp) |
| 2139 | { |
| 2140 | INIT_COMPLETION(pAdapter->hdd_get_batch_scan_req_var); |
| 2141 | rc = wait_for_completion_timeout( |
| 2142 | &pAdapter->hdd_get_batch_scan_req_var, |
| 2143 | msecs_to_jiffies(HDD_GET_BATCH_SCAN_RSP_TIME_OUT)); |
Abhishek Singh | 00b7197 | 2016-01-07 10:51:04 +0530 | [diff] [blame] | 2144 | if (0 >= rc) |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 2145 | { |
| 2146 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Abhishek Singh | 00b7197 | 2016-01-07 10:51:04 +0530 | [diff] [blame] | 2147 | "%s: wait on hdd_get_batch_scan_req_var failed %ld", |
| 2148 | __func__, rc); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 2149 | return -EFAULT; |
| 2150 | } |
| 2151 | } |
| 2152 | |
| 2153 | len = snprintf(pDest, HDD_BATCH_SCAN_AP_META_INFO_SIZE, |
Jeff Johnson | 0279779 | 2013-10-26 19:17:13 -0700 | [diff] [blame] | 2154 | "scancount=%u\n", pAdapter->numScanList); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 2155 | pDest += len; |
| 2156 | cur_len += len; |
| 2157 | |
| 2158 | mutex_lock(&pAdapter->hdd_batch_scan_lock); |
| 2159 | len = hdd_populate_user_batch_scan_rsp(pAdapter, pDest, |
| 2160 | cur_len, rem_len); |
| 2161 | mutex_unlock(&pAdapter->hdd_batch_scan_lock); |
| 2162 | |
| 2163 | count = 0; |
| 2164 | len = (len - pPrivData->used_len); |
| 2165 | pDest = (command + pPrivData->used_len); |
| 2166 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Rajeev Kumar | 99db626 | 2013-11-11 15:23:36 -0800 | [diff] [blame] | 2167 | "NEW BATCH SCAN RESULT:"); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 2168 | while(count < len) |
| 2169 | { |
| 2170 | printk("%c", *(pDest + count)); |
| 2171 | count++; |
| 2172 | } |
| 2173 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2174 | "%s: copy %d data to user buffer", __func__, len); |
| 2175 | if (copy_to_user(pPrivData->buf, pDest, len)) |
| 2176 | { |
| 2177 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2178 | "%s: failed to copy data to user buffer", __func__); |
| 2179 | return -EFAULT; |
| 2180 | } |
| 2181 | } |
| 2182 | else |
| 2183 | { |
| 2184 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2185 | "sme_GetBatchScanScan returned failure halStatus %d", |
| 2186 | halStatus); |
| 2187 | return -EINVAL; |
| 2188 | } |
| 2189 | } |
| 2190 | else |
| 2191 | { |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 2192 | count = 0; |
| 2193 | len = (len - pPrivData->used_len); |
| 2194 | pDest = (command + pPrivData->used_len); |
| 2195 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Rajeev Kumar | 99db626 | 2013-11-11 15:23:36 -0800 | [diff] [blame] | 2196 | "REMAINING TRUNCATED BATCH SCAN RESULT:"); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 2197 | while(count < len) |
| 2198 | { |
| 2199 | printk("%c", *(pDest + count)); |
| 2200 | count++; |
| 2201 | } |
Rajeev Kumar | 99db626 | 2013-11-11 15:23:36 -0800 | [diff] [blame] | 2202 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2203 | "%s: copy %d data to user buffer", __func__, len); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 2204 | if (copy_to_user(pPrivData->buf, pDest, len)) |
| 2205 | { |
| 2206 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2207 | "%s: failed to copy data to user buffer", __func__); |
| 2208 | return -EFAULT; |
| 2209 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 2210 | } |
| 2211 | |
| 2212 | return 0; |
| 2213 | } /*End of hdd_return_batch_scan_rsp_to_user*/ |
| 2214 | |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 2215 | /**--------------------------------------------------------------------------- |
| 2216 | |
| 2217 | \brief hdd_handle_batch_scan_ioctl () - This function handles WLS_BATCHING |
| 2218 | IOCTLs from user space. Following BATCH SCAN DEV IOCTs are handled: |
| 2219 | WLS_BATCHING VERSION |
| 2220 | WLS_BATCHING SET |
| 2221 | WLS_BATCHING GET |
| 2222 | WLS_BATCHING STOP |
| 2223 | |
| 2224 | \param - pAdapter Pointer to HDD adapter |
| 2225 | \param - pPrivdata Pointer to priv_data |
| 2226 | \param - command Pointer to command |
| 2227 | |
| 2228 | \return - 0 for success -EFAULT for failure |
| 2229 | |
| 2230 | --------------------------------------------------------------------------*/ |
| 2231 | |
| 2232 | int hdd_handle_batch_scan_ioctl |
| 2233 | ( |
| 2234 | hdd_adapter_t *pAdapter, |
| 2235 | hdd_priv_data_t *pPrivdata, |
| 2236 | tANI_U8 *command |
| 2237 | ) |
| 2238 | { |
| 2239 | int ret = 0; |
Yue Ma | e36e355 | 2014-03-05 17:06:20 -0800 | [diff] [blame] | 2240 | hdd_context_t *pHddCtx; |
| 2241 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2242 | ENTER(); |
| 2243 | |
Yue Ma | e36e355 | 2014-03-05 17:06:20 -0800 | [diff] [blame] | 2244 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2245 | ret = wlan_hdd_validate_context(pHddCtx); |
| 2246 | if (ret) |
| 2247 | { |
Yue Ma | e36e355 | 2014-03-05 17:06:20 -0800 | [diff] [blame] | 2248 | goto exit; |
| 2249 | } |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 2250 | |
| 2251 | if (strncmp(command, "WLS_BATCHING VERSION", 20) == 0) |
| 2252 | { |
| 2253 | char extra[32]; |
| 2254 | tANI_U8 len = 0; |
| 2255 | tANI_U8 version = HDD_BATCH_SCAN_VERSION; |
| 2256 | |
| 2257 | if (FALSE == sme_IsFeatureSupportedByFW(BATCH_SCAN)) |
| 2258 | { |
| 2259 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2260 | "%s: Batch scan feature is not supported by FW", __func__); |
| 2261 | ret = -EINVAL; |
| 2262 | goto exit; |
| 2263 | } |
| 2264 | |
| 2265 | len = scnprintf(extra, sizeof(extra), "WLS_BATCHING_VERSION %d", |
| 2266 | version); |
| 2267 | if (copy_to_user(pPrivdata->buf, &extra, len + 1)) |
| 2268 | { |
| 2269 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2270 | "%s: failed to copy data to user buffer", __func__); |
| 2271 | ret = -EFAULT; |
| 2272 | goto exit; |
| 2273 | } |
| 2274 | ret = HDD_BATCH_SCAN_VERSION; |
| 2275 | } |
| 2276 | else if (strncmp(command, "WLS_BATCHING SET", 16) == 0) |
| 2277 | { |
| 2278 | int status; |
| 2279 | tANI_U8 *value = (command + 16); |
| 2280 | eHalStatus halStatus; |
| 2281 | unsigned long rc; |
| 2282 | tSirSetBatchScanReq *pReq = &pAdapter->hddSetBatchScanReq; |
| 2283 | tSirSetBatchScanRsp *pRsp = &pAdapter->hddSetBatchScanRsp; |
| 2284 | |
| 2285 | if (FALSE == sme_IsFeatureSupportedByFW(BATCH_SCAN)) |
| 2286 | { |
| 2287 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2288 | "%s: Batch scan feature is not supported by FW", __func__); |
| 2289 | ret = -EINVAL; |
| 2290 | goto exit; |
| 2291 | } |
| 2292 | |
| 2293 | if ((WLAN_HDD_INFRA_STATION != pAdapter->device_mode) && |
| 2294 | (WLAN_HDD_P2P_CLIENT != pAdapter->device_mode) && |
| 2295 | (WLAN_HDD_P2P_GO != pAdapter->device_mode) && |
| 2296 | (WLAN_HDD_P2P_DEVICE != pAdapter->device_mode)) |
| 2297 | { |
| 2298 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 2299 | "Received WLS_BATCHING SET command in invalid mode %s (%d) " |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 2300 | "WLS_BATCHING_SET is only allowed in infra STA/P2P client mode", |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 2301 | hdd_device_modetoString(pAdapter->device_mode), |
| 2302 | pAdapter->device_mode); |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 2303 | ret = -EINVAL; |
| 2304 | goto exit; |
| 2305 | } |
| 2306 | |
| 2307 | status = hdd_parse_set_batchscan_command(value, pReq); |
| 2308 | if (status) |
| 2309 | { |
| 2310 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2311 | "Invalid WLS_BATCHING SET command"); |
| 2312 | ret = -EINVAL; |
| 2313 | goto exit; |
| 2314 | } |
| 2315 | |
| 2316 | |
| 2317 | pAdapter->hdd_wait_for_set_batch_scan_rsp = TRUE; |
| 2318 | halStatus = sme_SetBatchScanReq(WLAN_HDD_GET_HAL_CTX(pAdapter), pReq, |
| 2319 | pAdapter->sessionId, hdd_set_batch_scan_req_callback, |
| 2320 | pAdapter); |
| 2321 | |
| 2322 | if ( eHAL_STATUS_SUCCESS == halStatus ) |
| 2323 | { |
Mahesh A Saptasagar | 5f56817 | 2014-05-14 17:02:33 +0530 | [diff] [blame] | 2324 | char extra[32]; |
| 2325 | tANI_U8 len = 0; |
| 2326 | tANI_U8 mScan = 0; |
| 2327 | |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 2328 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2329 | "sme_SetBatchScanReq returned success halStatus %d", |
| 2330 | halStatus); |
| 2331 | if (TRUE == pAdapter->hdd_wait_for_set_batch_scan_rsp) |
| 2332 | { |
| 2333 | INIT_COMPLETION(pAdapter->hdd_set_batch_scan_req_var); |
| 2334 | rc = wait_for_completion_timeout( |
| 2335 | &pAdapter->hdd_set_batch_scan_req_var, |
| 2336 | msecs_to_jiffies(HDD_SET_BATCH_SCAN_REQ_TIME_OUT)); |
| 2337 | if (0 == rc) |
| 2338 | { |
| 2339 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2340 | "%s: Timeout waiting for set batch scan to complete", |
| 2341 | __func__); |
| 2342 | ret = -EINVAL; |
| 2343 | goto exit; |
| 2344 | } |
| 2345 | } |
| 2346 | if ( !pRsp->nScansToBatch ) |
| 2347 | { |
| 2348 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2349 | "%s: Received set batch scan failure response from FW", |
| 2350 | __func__); |
| 2351 | ret = -EINVAL; |
| 2352 | goto exit; |
| 2353 | } |
| 2354 | /*As per the Batch Scan Framework API we should return the MIN of |
| 2355 | either MSCAN or the max # of scans firmware can cache*/ |
Mahesh A Saptasagar | 5f56817 | 2014-05-14 17:02:33 +0530 | [diff] [blame] | 2356 | mScan = MIN(pReq->numberOfScansToBatch , pRsp->nScansToBatch); |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 2357 | |
| 2358 | pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STARTED; |
| 2359 | |
| 2360 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2361 | "%s: request MSCAN %d response MSCAN %d ret %d", |
Mahesh A Saptasagar | 5f56817 | 2014-05-14 17:02:33 +0530 | [diff] [blame] | 2362 | __func__, pReq->numberOfScansToBatch, pRsp->nScansToBatch, mScan); |
| 2363 | len = scnprintf(extra, sizeof(extra), "%d", mScan); |
| 2364 | if (copy_to_user(pPrivdata->buf, &extra, len + 1)) |
| 2365 | { |
| 2366 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2367 | "%s: failed to copy MSCAN value to user buffer", __func__); |
| 2368 | ret = -EFAULT; |
| 2369 | goto exit; |
| 2370 | } |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 2371 | } |
| 2372 | else |
| 2373 | { |
| 2374 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2375 | "sme_SetBatchScanReq returned failure halStatus %d", |
| 2376 | halStatus); |
| 2377 | ret = -EINVAL; |
| 2378 | goto exit; |
| 2379 | } |
| 2380 | } |
| 2381 | else if (strncmp(command, "WLS_BATCHING STOP", 17) == 0) |
| 2382 | { |
| 2383 | eHalStatus halStatus; |
| 2384 | tSirStopBatchScanInd *pInd = &pAdapter->hddStopBatchScanInd; |
| 2385 | pInd->param = 0; |
| 2386 | |
| 2387 | if (FALSE == sme_IsFeatureSupportedByFW(BATCH_SCAN)) |
| 2388 | { |
| 2389 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2390 | "%s: Batch scan feature is not supported by FW", __func__); |
| 2391 | ret = -EINVAL; |
| 2392 | goto exit; |
| 2393 | } |
| 2394 | |
| 2395 | if (eHDD_BATCH_SCAN_STATE_STARTED != pAdapter->batchScanState) |
| 2396 | { |
Deepthi Gowri | bfd1713 | 2014-11-14 17:59:04 +0530 | [diff] [blame] | 2397 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 2398 | "Batch scan is not yet enabled batch scan state %d", |
| 2399 | pAdapter->batchScanState); |
| 2400 | ret = -EINVAL; |
| 2401 | goto exit; |
| 2402 | } |
| 2403 | |
Kiet Lam | aa8e15a | 2014-02-11 23:30:06 -0800 | [diff] [blame] | 2404 | mutex_lock(&pAdapter->hdd_batch_scan_lock); |
| 2405 | hdd_deinit_batch_scan(pAdapter); |
| 2406 | mutex_unlock(&pAdapter->hdd_batch_scan_lock); |
| 2407 | |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 2408 | pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STOPPED; |
| 2409 | |
| 2410 | halStatus = sme_StopBatchScanInd(WLAN_HDD_GET_HAL_CTX(pAdapter), pInd, |
| 2411 | pAdapter->sessionId); |
| 2412 | if ( eHAL_STATUS_SUCCESS == halStatus ) |
| 2413 | { |
| 2414 | ret = 0; |
| 2415 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2416 | "sme_StopBatchScanInd returned success halStatus %d", |
| 2417 | halStatus); |
| 2418 | } |
| 2419 | else |
| 2420 | { |
| 2421 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2422 | "sme_StopBatchScanInd returned failure halStatus %d", |
| 2423 | halStatus); |
| 2424 | ret = -EINVAL; |
| 2425 | goto exit; |
| 2426 | } |
| 2427 | } |
| 2428 | else if (strncmp(command, "WLS_BATCHING GET", 16) == 0) |
| 2429 | { |
| 2430 | tANI_U32 remain_len; |
| 2431 | |
| 2432 | if (FALSE == sme_IsFeatureSupportedByFW(BATCH_SCAN)) |
| 2433 | { |
| 2434 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2435 | "%s: Batch scan feature is not supported by FW", __func__); |
| 2436 | ret = -EINVAL; |
| 2437 | goto exit; |
| 2438 | } |
| 2439 | |
| 2440 | if (eHDD_BATCH_SCAN_STATE_STARTED != pAdapter->batchScanState) |
| 2441 | { |
Deepthi Gowri | bfd1713 | 2014-11-14 17:59:04 +0530 | [diff] [blame] | 2442 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 2443 | "Batch scan is not yet enabled could not return results" |
| 2444 | "Batch Scan state %d", |
| 2445 | pAdapter->batchScanState); |
| 2446 | ret = -EINVAL; |
| 2447 | goto exit; |
| 2448 | } |
| 2449 | |
| 2450 | pPrivdata->used_len = 16; |
| 2451 | remain_len = pPrivdata->total_len - pPrivdata->used_len; |
| 2452 | if (remain_len < pPrivdata->total_len) |
| 2453 | { |
| 2454 | /*Clear previous batch scan response data if any*/ |
| 2455 | vos_mem_zero((tANI_U8 *)(command + pPrivdata->used_len), remain_len); |
| 2456 | } |
| 2457 | else |
| 2458 | { |
| 2459 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2460 | "Invalid total length from user space can't fetch batch" |
| 2461 | " scan response total_len %d used_len %d remain len %d", |
| 2462 | pPrivdata->total_len, pPrivdata->used_len, remain_len); |
| 2463 | ret = -EINVAL; |
| 2464 | goto exit; |
| 2465 | } |
| 2466 | ret = hdd_return_batch_scan_rsp_to_user(pAdapter, pPrivdata, command); |
| 2467 | } |
| 2468 | |
| 2469 | exit: |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2470 | EXIT(); |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 2471 | return ret; |
| 2472 | } |
| 2473 | |
| 2474 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 2475 | #endif/*End of FEATURE_WLAN_BATCH_SCAN*/ |
| 2476 | |
Selvaraj, Sridhar | 5aff1ed | 2016-06-18 01:26:23 +0530 | [diff] [blame] | 2477 | #if defined(WLAN_FEATURE_VOWIFI_11R) || defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR) |
| 2478 | /** |
| 2479 | * hdd_assign_handoff_src_reassoc - Set handoff source as REASSOC |
| 2480 | * to Handoff request |
| 2481 | * @handoffInfo: Pointer to Handoff request |
| 2482 | * @src: enum of handoff_src |
| 2483 | * Return: None |
| 2484 | */ |
| 2485 | #ifndef QCA_WIFI_ISOC |
| 2486 | static inline void hdd_assign_handoff_src_reassoc(tCsrHandoffRequest |
| 2487 | *handoffInfo, handoff_src src) |
| 2488 | { |
| 2489 | handoffInfo->src = src; |
| 2490 | } |
| 2491 | #else |
| 2492 | static inline void hdd_assign_handoff_src_reassoc(tCsrHandoffRequest |
| 2493 | *handoffInfo, handoff_src src) |
| 2494 | { |
| 2495 | } |
| 2496 | #endif |
| 2497 | |
| 2498 | /** |
Selvaraj, Sridhar | 4fa1523 | 2016-06-18 12:27:25 +0530 | [diff] [blame] | 2499 | * hdd_reassoc() - perform a user space-directed reassoc |
Selvaraj, Sridhar | 5aff1ed | 2016-06-18 01:26:23 +0530 | [diff] [blame] | 2500 | * |
| 2501 | * @pAdapter: Adapter upon which the command was received |
| 2502 | * @bssid: BSSID with which to reassociate |
| 2503 | * @channel: channel upon which to reassociate |
Selvaraj, Sridhar | 4fa1523 | 2016-06-18 12:27:25 +0530 | [diff] [blame] | 2504 | * @src: The source for the trigger of this action |
Selvaraj, Sridhar | 5aff1ed | 2016-06-18 01:26:23 +0530 | [diff] [blame] | 2505 | * |
| 2506 | * Return: 0 for success non-zero for failure |
| 2507 | */ |
| 2508 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
Selvaraj, Sridhar | 8ecb419 | 2016-06-23 17:50:49 +0530 | [diff] [blame] | 2509 | int hdd_reassoc(hdd_adapter_t *pAdapter, const tANI_U8 *bssid, |
Selvaraj, Sridhar | 4fa1523 | 2016-06-18 12:27:25 +0530 | [diff] [blame] | 2510 | const tANI_U8 channel, const handoff_src src) |
Selvaraj, Sridhar | 5aff1ed | 2016-06-18 01:26:23 +0530 | [diff] [blame] | 2511 | { |
| 2512 | hdd_station_ctx_t *pHddStaCtx; |
| 2513 | tCsrHandoffRequest handoffInfo; |
| 2514 | hdd_context_t *pHddCtx = NULL; |
| 2515 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2516 | |
| 2517 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 2518 | |
| 2519 | /* if not associated, no need to proceed with reassoc */ |
| 2520 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) { |
| 2521 | hddLog(LOG1, FL("Not associated")); |
| 2522 | return -EINVAL; |
| 2523 | } |
| 2524 | |
| 2525 | /* if the target bssid is same as currently associated AP, |
| 2526 | then no need to proceed with reassoc */ |
| 2527 | if (!memcmp(bssid, pHddStaCtx->conn_info.bssId, sizeof(tSirMacAddr))) { |
| 2528 | hddLog(LOG1, FL("Reassoc BSSID is same as currently associated AP bssid")); |
| 2529 | return -EINVAL; |
| 2530 | } |
| 2531 | |
| 2532 | /* Check channel number is a valid channel number */ |
| 2533 | if (VOS_STATUS_SUCCESS != |
| 2534 | wlan_hdd_validate_operation_channel(pAdapter, channel)) { |
| 2535 | hddLog(LOGE, FL("Invalid Channel %d"), channel); |
| 2536 | return -EINVAL; |
| 2537 | } |
| 2538 | |
| 2539 | /* Proceed with reassoc */ |
| 2540 | handoffInfo.channel = channel; |
Selvaraj, Sridhar | 4fa1523 | 2016-06-18 12:27:25 +0530 | [diff] [blame] | 2541 | hdd_assign_handoff_src_reassoc(&handoffInfo, src); |
Selvaraj, Sridhar | 5aff1ed | 2016-06-18 01:26:23 +0530 | [diff] [blame] | 2542 | memcpy(handoffInfo.bssid, bssid, sizeof(tSirMacAddr)); |
| 2543 | sme_HandoffRequest(pHddCtx->hHal, &handoffInfo); |
| 2544 | return 0; |
| 2545 | } |
| 2546 | #else |
Selvaraj, Sridhar | 8ecb419 | 2016-06-23 17:50:49 +0530 | [diff] [blame] | 2547 | int hdd_reassoc(hdd_adapter_t *pAdapter, const tANI_U8 *bssid, |
Selvaraj, Sridhar | 4fa1523 | 2016-06-18 12:27:25 +0530 | [diff] [blame] | 2548 | const tANI_U8 channel, const handoff_src src) |
Selvaraj, Sridhar | 5aff1ed | 2016-06-18 01:26:23 +0530 | [diff] [blame] | 2549 | { |
| 2550 | return -EPERM; |
| 2551 | } |
| 2552 | #endif |
| 2553 | |
| 2554 | /** |
| 2555 | * hdd_parse_reassoc_v1() - parse version 1 of the REASSOC command |
| 2556 | * This function parses the v1 REASSOC command with the format |
| 2557 | * REASSOC xx:xx:xx:xx:xx:xx CH where "xx:xx:xx:xx:xx:xx" is the |
| 2558 | * Hex-ASCII representation of the BSSID and CH is the ASCII |
| 2559 | * representation of the channel. For example |
| 2560 | * REASSOC 00:0a:0b:11:22:33 48 |
| 2561 | * |
| 2562 | * @pAdapter: Adapter upon which the command was received |
| 2563 | * @command: ASCII text command that was received |
| 2564 | * |
| 2565 | * Return: 0 for success non-zero for failure |
| 2566 | */ |
| 2567 | static int |
| 2568 | hdd_parse_reassoc_v1(hdd_adapter_t *pAdapter, const char *command) |
| 2569 | { |
| 2570 | tANI_U8 channel = 0; |
| 2571 | tSirMacAddr bssid; |
| 2572 | int ret; |
| 2573 | |
| 2574 | ret = hdd_parse_reassoc_command_v1_data(command, bssid, &channel); |
| 2575 | if (ret) |
| 2576 | hddLog(LOGE, FL("Failed to parse reassoc command data")); |
| 2577 | else |
Selvaraj, Sridhar | 4fa1523 | 2016-06-18 12:27:25 +0530 | [diff] [blame] | 2578 | ret = hdd_reassoc(pAdapter, bssid, channel, REASSOC); |
Selvaraj, Sridhar | 5aff1ed | 2016-06-18 01:26:23 +0530 | [diff] [blame] | 2579 | |
| 2580 | return ret; |
| 2581 | } |
| 2582 | |
| 2583 | /** |
| 2584 | * hdd_parse_reassoc_v2() - parse version 2 of the REASSOC command |
| 2585 | * This function parses the v2 REASSOC command with the format |
| 2586 | * REASSOC <android_wifi_reassoc_params> |
| 2587 | * |
| 2588 | * @pAdapter: Adapter upon which the command was received |
| 2589 | * @command: command that was received, ASCII command followed |
| 2590 | * by binary data |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 2591 | * @total_len: Total length of the command received |
Selvaraj, Sridhar | 5aff1ed | 2016-06-18 01:26:23 +0530 | [diff] [blame] | 2592 | * |
| 2593 | * Return: 0 for success non-zero for failure |
| 2594 | */ |
| 2595 | static int |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 2596 | hdd_parse_reassoc_v2(hdd_adapter_t *pAdapter, const char *command, |
| 2597 | int total_len) |
Selvaraj, Sridhar | 5aff1ed | 2016-06-18 01:26:23 +0530 | [diff] [blame] | 2598 | { |
| 2599 | struct android_wifi_reassoc_params params; |
| 2600 | tSirMacAddr bssid; |
| 2601 | int ret; |
| 2602 | |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 2603 | if (total_len < sizeof(params) + 8) { |
| 2604 | hddLog(LOGE, FL("Invalid command length")); |
| 2605 | return -EINVAL; |
| 2606 | } |
| 2607 | |
Selvaraj, Sridhar | 5aff1ed | 2016-06-18 01:26:23 +0530 | [diff] [blame] | 2608 | /* The params are located after "REASSOC " */ |
| 2609 | memcpy(¶ms, command + 8, sizeof(params)); |
| 2610 | |
| 2611 | if (!mac_pton(params.bssid, (u8 *)&bssid)) { |
| 2612 | hddLog(LOGE, FL("MAC address parsing failed")); |
| 2613 | ret = -EINVAL; |
| 2614 | } else { |
Selvaraj, Sridhar | 4fa1523 | 2016-06-18 12:27:25 +0530 | [diff] [blame] | 2615 | ret = hdd_reassoc(pAdapter, bssid, params.channel, REASSOC); |
Selvaraj, Sridhar | 5aff1ed | 2016-06-18 01:26:23 +0530 | [diff] [blame] | 2616 | } |
| 2617 | return ret; |
| 2618 | } |
| 2619 | |
| 2620 | /** |
| 2621 | * hdd_parse_reassoc() - parse the REASSOC command |
| 2622 | * There are two different versions of the REASSOC command.Version 1 |
| 2623 | * of the command contains a parameter list that is ASCII characters |
| 2624 | * whereas version 2 contains a combination of ASCII and binary |
| 2625 | * payload. Determine if a version 1 or a version 2 command is being |
| 2626 | * parsed by examining the parameters, and then dispatch the parser |
| 2627 | * that is appropriate for the command. |
| 2628 | * |
| 2629 | * @pAdapter: Adapter upon which the command was received |
| 2630 | * @command: command that was received |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 2631 | * @total_len: Total length of the command received |
Selvaraj, Sridhar | 5aff1ed | 2016-06-18 01:26:23 +0530 | [diff] [blame] | 2632 | * |
| 2633 | * Return: 0 for success non-zero for failure |
| 2634 | */ |
| 2635 | static int |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 2636 | hdd_parse_reassoc(hdd_adapter_t *pAdapter, const char *command, int total_len) |
Selvaraj, Sridhar | 5aff1ed | 2016-06-18 01:26:23 +0530 | [diff] [blame] | 2637 | { |
| 2638 | int ret; |
| 2639 | |
| 2640 | /* |
| 2641 | * both versions start with "REASSOC" |
| 2642 | * v1 has a bssid and channel # as an ASCII string |
| 2643 | * REASSOC xx:xx:xx:xx:xx:xx CH |
| 2644 | * v2 has a C struct |
| 2645 | * REASSOC <binary c struct> |
| 2646 | * |
| 2647 | * The first field in the v2 struct is also the bssid in ASCII. |
| 2648 | * But in the case of a v2 message the BSSID is NUL-terminated. |
| 2649 | * Hence we can peek at that offset to see if this is V1 or V2 |
| 2650 | * REASSOC xx:xx:xx:xx:xx:xx* |
| 2651 | * 1111111111222222 |
| 2652 | * 01234567890123456789012345 |
| 2653 | */ |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 2654 | |
| 2655 | if (total_len < 26) { |
| 2656 | hddLog(LOGE, FL("Invalid command (total_len=%d)"), total_len); |
| 2657 | return -EINVAL; |
| 2658 | } |
| 2659 | |
Selvaraj, Sridhar | 5aff1ed | 2016-06-18 01:26:23 +0530 | [diff] [blame] | 2660 | if (command[25]) |
| 2661 | ret = hdd_parse_reassoc_v1(pAdapter, command); |
| 2662 | else |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 2663 | ret = hdd_parse_reassoc_v2(pAdapter, command, total_len); |
Selvaraj, Sridhar | 5aff1ed | 2016-06-18 01:26:23 +0530 | [diff] [blame] | 2664 | |
| 2665 | return ret; |
| 2666 | } |
| 2667 | #endif /* WLAN_FEATURE_VOWIFI_11R || FEATURE_WLAN_ESE FEATURE_WLAN_LFR */ |
| 2668 | |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 2669 | static void getBcnMissRateCB(VOS_STATUS status, int bcnMissRate, void *data) |
| 2670 | { |
c_hpothu | 39eb1e3 | 2014-06-26 16:31:50 +0530 | [diff] [blame] | 2671 | bcnMissRateContext_t *pCBCtx; |
| 2672 | |
| 2673 | if (NULL == data) |
| 2674 | { |
| 2675 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("argument data is NULL")); |
| 2676 | return; |
| 2677 | } |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 2678 | |
| 2679 | /* there is a race condition that exists between this callback |
| 2680 | function and the caller since the caller could time out either |
| 2681 | before or while this code is executing. we use a spinlock to |
| 2682 | serialize these actions */ |
| 2683 | spin_lock(&hdd_context_lock); |
| 2684 | |
c_hpothu | 39eb1e3 | 2014-06-26 16:31:50 +0530 | [diff] [blame] | 2685 | pCBCtx = (bcnMissRateContext_t *)data; |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 2686 | gbcnMissRate = -1; |
| 2687 | |
c_hpothu | 39eb1e3 | 2014-06-26 16:31:50 +0530 | [diff] [blame] | 2688 | if (pCBCtx->magic != BCN_MISS_RATE_CONTEXT_MAGIC) |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 2689 | { |
| 2690 | hddLog(VOS_TRACE_LEVEL_ERROR, |
c_hpothu | 39eb1e3 | 2014-06-26 16:31:50 +0530 | [diff] [blame] | 2691 | FL("invalid context magic: %08x"), pCBCtx->magic); |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 2692 | spin_unlock(&hdd_context_lock); |
| 2693 | return ; |
| 2694 | } |
| 2695 | |
| 2696 | if (VOS_STATUS_SUCCESS == status) |
| 2697 | { |
c_hpothu | 39eb1e3 | 2014-06-26 16:31:50 +0530 | [diff] [blame] | 2698 | gbcnMissRate = bcnMissRate; |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 2699 | } |
c_hpothu | 39eb1e3 | 2014-06-26 16:31:50 +0530 | [diff] [blame] | 2700 | else |
| 2701 | { |
| 2702 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("failed to get bcnMissRate")); |
| 2703 | } |
| 2704 | |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 2705 | complete(&(pCBCtx->completion)); |
| 2706 | spin_unlock(&hdd_context_lock); |
| 2707 | |
| 2708 | return; |
| 2709 | } |
| 2710 | |
Abhishek Singh | 08aa776 | 2014-12-16 13:59:03 +0530 | [diff] [blame] | 2711 | void hdd_FWStatisCB( VOS_STATUS status, |
| 2712 | tSirFwStatsResult *fwStatsResult, void *pContext ) |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 2713 | { |
| 2714 | fwStatsContext_t *fwStatsCtx; |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 2715 | hdd_adapter_t *pAdapter; |
| 2716 | |
| 2717 | hddLog(VOS_TRACE_LEVEL_INFO, FL(" with status = %d"),status); |
| 2718 | |
Abhishek Singh | 08aa776 | 2014-12-16 13:59:03 +0530 | [diff] [blame] | 2719 | if (NULL == pContext) |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 2720 | { |
| 2721 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("argument data is NULL")); |
| 2722 | return; |
| 2723 | } |
| 2724 | /* there is a race condition that exists between this callback |
| 2725 | function and the caller since the caller could time out either |
| 2726 | before or while this code is executing. we use a spinlock to |
| 2727 | serialize these actions */ |
| 2728 | spin_lock(&hdd_context_lock); |
Abhishek Singh | 08aa776 | 2014-12-16 13:59:03 +0530 | [diff] [blame] | 2729 | fwStatsCtx = (fwStatsContext_t *) pContext; |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 2730 | if (fwStatsCtx->magic != FW_STATS_CONTEXT_MAGIC) |
| 2731 | { |
| 2732 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2733 | FL("invalid context magic: %08x"), fwStatsCtx->magic); |
| 2734 | spin_unlock(&hdd_context_lock); |
| 2735 | return; |
| 2736 | } |
| 2737 | pAdapter = fwStatsCtx->pAdapter; |
| 2738 | if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)) |
| 2739 | { |
| 2740 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2741 | FL("pAdapter returned is NULL or invalid")); |
| 2742 | spin_unlock(&hdd_context_lock); |
| 2743 | return; |
| 2744 | } |
| 2745 | pAdapter->fwStatsRsp.type = 0; |
Abhishek Singh | 08aa776 | 2014-12-16 13:59:03 +0530 | [diff] [blame] | 2746 | if ((VOS_STATUS_SUCCESS == status) && (NULL != fwStatsResult)) |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 2747 | { |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 2748 | switch( fwStatsResult->type ) |
| 2749 | { |
| 2750 | case FW_UBSP_STATS: |
| 2751 | { |
Abhishek Singh | 08aa776 | 2014-12-16 13:59:03 +0530 | [diff] [blame] | 2752 | memcpy(&pAdapter->fwStatsRsp,fwStatsResult,sizeof(tSirFwStatsResult)); |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 2753 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 2754 | FL("ubsp_enter_cnt = %d ubsp_jump_ddr_cnt = %d"), |
Abhishek Singh | 08aa776 | 2014-12-16 13:59:03 +0530 | [diff] [blame] | 2755 | pAdapter->fwStatsRsp.fwStatsData.ubspStats.ubsp_enter_cnt, |
| 2756 | pAdapter->fwStatsRsp.fwStatsData.ubspStats.ubsp_jump_ddr_cnt); |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 2757 | } |
| 2758 | break; |
| 2759 | default: |
| 2760 | { |
| 2761 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2762 | FL(" No handling for stats type %d"),fwStatsResult->type); |
| 2763 | } |
| 2764 | } |
| 2765 | } |
| 2766 | complete(&(fwStatsCtx->completion)); |
| 2767 | spin_unlock(&hdd_context_lock); |
| 2768 | return; |
| 2769 | } |
| 2770 | |
jge | 3556720 | 2017-06-21 16:39:38 +0800 | [diff] [blame] | 2771 | /* |
| 2772 | *hdd_parse_setmaxtxpower_command() - HDD Parse MAXTXPOWER command |
| 2773 | *@pValue Pointer to MAXTXPOWER command |
| 2774 | *@pTxPower Pointer to tx power |
| 2775 | * |
| 2776 | *This function parses the MAXTXPOWER command passed in the format |
| 2777 | * MAXTXPOWER<space>X(Tx power in dbm) |
| 2778 | * For example input commands: |
| 2779 | * 1) MAXTXPOWER -8 -> This is translated into set max TX power to -8 dbm |
| 2780 | * 2) MAXTXPOWER -23 -> This is translated into set max TX power to -23 dbm |
| 2781 | * |
| 2782 | *return - 0 for success non-zero for failure |
| 2783 | */ |
| 2784 | static int hdd_parse_setmaxtxpower_command(unsigned char *pValue, int *pTxPower) |
| 2785 | { |
| 2786 | unsigned char *inPtr = pValue; |
| 2787 | int tempInt; |
| 2788 | int v = 0; |
| 2789 | *pTxPower = 0; |
| 2790 | |
| 2791 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 2792 | /* no argument after the command */ |
| 2793 | if (NULL == inPtr) |
| 2794 | return -EINVAL; |
| 2795 | /* no space after the command */ |
| 2796 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 2797 | return -EINVAL; |
| 2798 | |
| 2799 | /* removing empty spaces */ |
| 2800 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
| 2801 | |
| 2802 | /* no argument followed by spaces */ |
| 2803 | if ('\0' == *inPtr) |
| 2804 | return 0; |
| 2805 | |
| 2806 | v = kstrtos32(inPtr, 10, &tempInt); |
| 2807 | |
| 2808 | /* Range checking for passed parameter */ |
| 2809 | if ((tempInt < HDD_MIN_TX_POWER) || (tempInt > HDD_MAX_TX_POWER)) |
| 2810 | return -EINVAL; |
| 2811 | |
| 2812 | *pTxPower = tempInt; |
| 2813 | |
| 2814 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2815 | "SETMAXTXPOWER: %d", *pTxPower); |
| 2816 | |
| 2817 | return 0; |
| 2818 | } |
| 2819 | |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2820 | static int hdd_get_dwell_time(hdd_config_t *pCfg, tANI_U8 *command, char *extra, tANI_U8 n, tANI_U8 *len) |
| 2821 | { |
| 2822 | int ret = 0; |
| 2823 | |
| 2824 | if (!pCfg || !command || !extra || !len) |
| 2825 | { |
| 2826 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2827 | "%s: argument passsed for GETDWELLTIME is incorrect", __func__); |
| 2828 | ret = -EINVAL; |
| 2829 | return ret; |
| 2830 | } |
| 2831 | |
| 2832 | if (strncmp(command, "GETDWELLTIME ACTIVE MAX", 23) == 0) |
| 2833 | { |
| 2834 | *len = scnprintf(extra, n, "GETDWELLTIME ACTIVE MAX %u\n", |
| 2835 | (int)pCfg->nActiveMaxChnTime); |
| 2836 | return ret; |
| 2837 | } |
| 2838 | else if (strncmp(command, "GETDWELLTIME ACTIVE MIN", 23) == 0) |
| 2839 | { |
| 2840 | *len = scnprintf(extra, n, "GETDWELLTIME ACTIVE MIN %u\n", |
| 2841 | (int)pCfg->nActiveMinChnTime); |
| 2842 | return ret; |
| 2843 | } |
| 2844 | else if (strncmp(command, "GETDWELLTIME PASSIVE MAX", 24) == 0) |
| 2845 | { |
| 2846 | *len = scnprintf(extra, n, "GETDWELLTIME PASSIVE MAX %u\n", |
| 2847 | (int)pCfg->nPassiveMaxChnTime); |
| 2848 | return ret; |
| 2849 | } |
| 2850 | else if (strncmp(command, "GETDWELLTIME PASSIVE MIN", 24) == 0) |
| 2851 | { |
| 2852 | *len = scnprintf(extra, n, "GETDWELLTIME PASSIVE MIN %u\n", |
| 2853 | (int)pCfg->nPassiveMinChnTime); |
| 2854 | return ret; |
| 2855 | } |
Rajesh Babu Prathipati | 0fd227e | 2014-07-05 12:50:00 +0530 | [diff] [blame] | 2856 | else if (strncmp(command, "GETDWELLTIME", 12) == 0) |
| 2857 | { |
| 2858 | *len = scnprintf(extra, n, "GETDWELLTIME %u \n", |
| 2859 | (int)pCfg->nActiveMaxChnTime); |
| 2860 | return ret; |
| 2861 | } |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2862 | else |
| 2863 | { |
| 2864 | ret = -EINVAL; |
| 2865 | } |
| 2866 | |
| 2867 | return ret; |
| 2868 | } |
| 2869 | |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 2870 | int hdd_drv_cmd_validate(tANI_U8 *command, int len) |
| 2871 | { |
| 2872 | if (command[len] != ' ') |
| 2873 | return -EINVAL; |
| 2874 | |
| 2875 | return 0; |
| 2876 | } |
| 2877 | |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2878 | static int hdd_set_dwell_time(hdd_adapter_t *pAdapter, tANI_U8 *command) |
| 2879 | { |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 2880 | tHalHandle hHal; |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2881 | hdd_config_t *pCfg; |
| 2882 | tANI_U8 *value = command; |
| 2883 | int val = 0, ret = 0, temp = 0; |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 2884 | tSmeConfigParams smeConfig; |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2885 | |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 2886 | if (!pAdapter || !command || !(pCfg = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini) |
| 2887 | || !(hHal = (WLAN_HDD_GET_HAL_CTX(pAdapter)))) |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2888 | { |
| 2889 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2890 | "%s: argument passed for SETDWELLTIME is incorrect", __func__); |
| 2891 | ret = -EINVAL; |
| 2892 | return ret; |
| 2893 | } |
| 2894 | |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 2895 | vos_mem_zero(&smeConfig, sizeof(smeConfig)); |
| 2896 | sme_GetConfigParam(hHal, &smeConfig); |
| 2897 | |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2898 | if (strncmp(command, "SETDWELLTIME ACTIVE MAX", 23) == 0 ) |
| 2899 | { |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 2900 | if (hdd_drv_cmd_validate(command, 23)) |
| 2901 | return -EINVAL; |
| 2902 | |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2903 | value = value + 24; |
| 2904 | temp = kstrtou32(value, 10, &val); |
| 2905 | if (temp != 0 || val < CFG_ACTIVE_MAX_CHANNEL_TIME_MIN || |
| 2906 | val > CFG_ACTIVE_MAX_CHANNEL_TIME_MAX ) |
| 2907 | { |
| 2908 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2909 | "%s: argument passed for SETDWELLTIME ACTIVE MAX is incorrect", __func__); |
| 2910 | ret = -EFAULT; |
| 2911 | return ret; |
| 2912 | } |
| 2913 | pCfg->nActiveMaxChnTime = val; |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 2914 | smeConfig.csrConfig.nActiveMaxChnTime = val; |
| 2915 | sme_UpdateConfig(hHal, &smeConfig); |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2916 | } |
| 2917 | else if (strncmp(command, "SETDWELLTIME ACTIVE MIN", 23) == 0) |
| 2918 | { |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 2919 | if (hdd_drv_cmd_validate(command, 23)) |
| 2920 | return -EINVAL; |
| 2921 | |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2922 | value = value + 24; |
| 2923 | temp = kstrtou32(value, 10, &val); |
| 2924 | if (temp !=0 || val < CFG_ACTIVE_MIN_CHANNEL_TIME_MIN || |
| 2925 | val > CFG_ACTIVE_MIN_CHANNEL_TIME_MAX ) |
| 2926 | { |
| 2927 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2928 | "%s: argument passsed for SETDWELLTIME ACTIVE MIN is incorrect", __func__); |
| 2929 | ret = -EFAULT; |
| 2930 | return ret; |
| 2931 | } |
| 2932 | pCfg->nActiveMinChnTime = val; |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 2933 | smeConfig.csrConfig.nActiveMinChnTime = val; |
| 2934 | sme_UpdateConfig(hHal, &smeConfig); |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2935 | } |
| 2936 | else if (strncmp(command, "SETDWELLTIME PASSIVE MAX", 24) == 0) |
| 2937 | { |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 2938 | if (hdd_drv_cmd_validate(command, 24)) |
| 2939 | return -EINVAL; |
| 2940 | |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2941 | value = value + 25; |
| 2942 | temp = kstrtou32(value, 10, &val); |
| 2943 | if (temp != 0 || val < CFG_PASSIVE_MAX_CHANNEL_TIME_MIN || |
| 2944 | val > CFG_PASSIVE_MAX_CHANNEL_TIME_MAX ) |
| 2945 | { |
| 2946 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2947 | "%s: argument passed for SETDWELLTIME PASSIVE MAX is incorrect", __func__); |
| 2948 | ret = -EFAULT; |
| 2949 | return ret; |
| 2950 | } |
| 2951 | pCfg->nPassiveMaxChnTime = val; |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 2952 | smeConfig.csrConfig.nPassiveMaxChnTime = val; |
| 2953 | sme_UpdateConfig(hHal, &smeConfig); |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2954 | } |
| 2955 | else if (strncmp(command, "SETDWELLTIME PASSIVE MIN", 24) == 0) |
| 2956 | { |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 2957 | if (hdd_drv_cmd_validate(command, 24)) |
| 2958 | return -EINVAL; |
| 2959 | |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2960 | value = value + 25; |
| 2961 | temp = kstrtou32(value, 10, &val); |
| 2962 | if (temp != 0 || val < CFG_PASSIVE_MIN_CHANNEL_TIME_MIN || |
| 2963 | val > CFG_PASSIVE_MIN_CHANNEL_TIME_MAX ) |
| 2964 | { |
| 2965 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2966 | "%s: argument passed for SETDWELLTIME PASSIVE MIN is incorrect", __func__); |
| 2967 | ret = -EFAULT; |
| 2968 | return ret; |
| 2969 | } |
| 2970 | pCfg->nPassiveMinChnTime = val; |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 2971 | smeConfig.csrConfig.nPassiveMinChnTime = val; |
| 2972 | sme_UpdateConfig(hHal, &smeConfig); |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2973 | } |
Rajesh Babu Prathipati | 0fd227e | 2014-07-05 12:50:00 +0530 | [diff] [blame] | 2974 | else if (strncmp(command, "SETDWELLTIME", 12) == 0) |
| 2975 | { |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 2976 | if (hdd_drv_cmd_validate(command, 12)) |
| 2977 | return -EINVAL; |
| 2978 | |
Rajesh Babu Prathipati | 0fd227e | 2014-07-05 12:50:00 +0530 | [diff] [blame] | 2979 | value = value + 13; |
| 2980 | temp = kstrtou32(value, 10, &val); |
| 2981 | if (temp != 0 || val < CFG_ACTIVE_MAX_CHANNEL_TIME_MIN || |
| 2982 | val > CFG_ACTIVE_MAX_CHANNEL_TIME_MAX ) |
| 2983 | { |
| 2984 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2985 | "%s: argument passed for SETDWELLTIME is incorrect", __func__); |
| 2986 | ret = -EFAULT; |
| 2987 | return ret; |
| 2988 | } |
| 2989 | pCfg->nActiveMaxChnTime = val; |
| 2990 | smeConfig.csrConfig.nActiveMaxChnTime = val; |
| 2991 | sme_UpdateConfig(hHal, &smeConfig); |
| 2992 | } |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2993 | else |
| 2994 | { |
| 2995 | ret = -EINVAL; |
| 2996 | } |
| 2997 | |
| 2998 | return ret; |
| 2999 | } |
Agarwal Ashish | 8bd53ae | 2015-06-12 18:03:45 +0530 | [diff] [blame] | 3000 | static int hdd_cmd_setFccChannel(hdd_context_t *pHddCtx, tANI_U8 *cmd, |
| 3001 | tANI_U8 cmd_len) |
| 3002 | { |
| 3003 | tANI_U8 *value; |
| 3004 | tANI_U8 fcc_constraint; |
| 3005 | |
| 3006 | eHalStatus status; |
| 3007 | int ret = 0; |
| 3008 | value = cmd + cmd_len + 1; |
| 3009 | |
| 3010 | ret = kstrtou8(value, 10, &fcc_constraint); |
| 3011 | if ((ret < 0) || (fcc_constraint > 1)) { |
| 3012 | /* |
| 3013 | * If the input value is greater than max value of datatype, |
| 3014 | * then also it is a failure |
| 3015 | */ |
| 3016 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3017 | "%s: value out of range", __func__); |
| 3018 | return -EINVAL; |
| 3019 | } |
| 3020 | |
Agrawal Ashish | 842eea8 | 2016-02-04 17:56:16 +0530 | [diff] [blame] | 3021 | status = sme_handleSetFccChannel(pHddCtx->hHal, fcc_constraint, |
| 3022 | pHddCtx->scan_info.mScanPending); |
Agarwal Ashish | 8bd53ae | 2015-06-12 18:03:45 +0530 | [diff] [blame] | 3023 | if (status != eHAL_STATUS_SUCCESS) |
| 3024 | ret = -EPERM; |
| 3025 | |
| 3026 | return ret; |
| 3027 | } |
| 3028 | |
Mahesh A Saptasagar | beca12c | 2015-09-07 16:21:06 +0530 | [diff] [blame] | 3029 | /**--------------------------------------------------------------------------- |
Agarwal Ashish | 8bd53ae | 2015-06-12 18:03:45 +0530 | [diff] [blame] | 3030 | |
Mahesh A Saptasagar | beca12c | 2015-09-07 16:21:06 +0530 | [diff] [blame] | 3031 | \brief hdd_enable_disable_ca_event() - When Host sends IOCTL (enabled), |
| 3032 | FW will send *ONE* CA ind to Host(even though it is duplicate). |
| 3033 | When Host send IOCTL (disable), FW doesn't perform any action. |
| 3034 | Whenever any change in CA *and* WLAN is in SAP/P2P-GO mode, FW |
| 3035 | sends CA ind to host. (regard less of IOCTL status) |
| 3036 | \param - pHddCtx - HDD context |
| 3037 | \param - command - command received from framework |
| 3038 | \param - cmd_len - len of the command |
| 3039 | |
| 3040 | \return - 0 on success, appropriate error values on failure. |
| 3041 | |
| 3042 | --------------------------------------------------------------------------*/ |
| 3043 | int hdd_enable_disable_ca_event(hdd_context_t *pHddCtx, tANI_U8* command, tANI_U8 cmd_len) |
| 3044 | { |
| 3045 | tANI_U8 set_value; |
| 3046 | int ret = 0; |
| 3047 | eHalStatus status; |
| 3048 | |
| 3049 | ret = wlan_hdd_validate_context(pHddCtx); |
| 3050 | if (0 != ret) |
| 3051 | { |
| 3052 | ret = -EINVAL; |
| 3053 | goto exit; |
| 3054 | } |
| 3055 | |
| 3056 | if (pHddCtx->cfg_ini->gOptimizeCAevent == 0) |
| 3057 | { |
| 3058 | hddLog(VOS_TRACE_LEVEL_ERROR, "Enable gOptimizeCAevent" |
| 3059 | " ini param to control channel avooidance indication"); |
| 3060 | ret = 0; |
| 3061 | goto exit; |
| 3062 | } |
| 3063 | |
| 3064 | set_value = command[cmd_len + 1] - '0'; |
| 3065 | status = sme_enableDisableChanAvoidIndEvent(pHddCtx->hHal, set_value); |
| 3066 | if (status != eHAL_STATUS_SUCCESS) |
| 3067 | { |
| 3068 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failed to send" |
| 3069 | " enableDisableChanAoidance command to SME\n", __func__); |
| 3070 | ret = -EINVAL; |
| 3071 | } |
| 3072 | |
| 3073 | exit: |
| 3074 | return ret; |
| 3075 | } |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 3076 | |
Selvaraj, Sridhar | 3714c4d | 2016-06-22 15:19:12 +0530 | [diff] [blame] | 3077 | /** |
| 3078 | * wlan_hdd_fastreassoc_handoff_request() - Post Handoff request to SME |
| 3079 | * @pHddCtx: Pointer to the HDD context |
| 3080 | * @channel: channel to reassociate |
| 3081 | * @targetApBssid: Target AP/BSSID to reassociate |
| 3082 | * |
| 3083 | * Return: None |
| 3084 | */ |
| 3085 | #if defined(WLAN_FEATURE_ROAM_SCAN_OFFLOAD) && !defined(QCA_WIFI_ISOC) |
| 3086 | static void wlan_hdd_fastreassoc_handoff_request(hdd_context_t *pHddCtx, |
| 3087 | uint8_t channel, tSirMacAddr targetApBssid) |
| 3088 | { |
| 3089 | tCsrHandoffRequest handoffInfo; |
| 3090 | handoffInfo.channel = channel; |
| 3091 | handoffInfo.src = FASTREASSOC; |
| 3092 | vos_mem_copy(handoffInfo.bssid, targetApBssid, sizeof(tSirMacAddr)); |
| 3093 | sme_HandoffRequest(pHddCtx->hHal, &handoffInfo); |
| 3094 | } |
| 3095 | #else |
| 3096 | static void wlan_hdd_fastreassoc_handoff_request(hdd_context_t *pHddCtx, |
| 3097 | uint8_t channel, tSirMacAddr targetApBssid) |
| 3098 | { |
| 3099 | } |
| 3100 | #endif |
| 3101 | |
| 3102 | /** |
| 3103 | * csr_fastroam_neighbor_ap_event() - Function to trigger scan/roam |
| 3104 | * @pAdapter: Pointer to HDD adapter |
| 3105 | * @channel: Channel to scan/roam |
| 3106 | * @targetApBssid: BSSID to roam |
| 3107 | * |
| 3108 | * Return: None |
| 3109 | */ |
| 3110 | #ifdef QCA_WIFI_ISOC |
| 3111 | static void csr_fastroam_neighbor_ap_event(hdd_adapter_t *pAdapter, |
| 3112 | uint8_t channel, tSirMacAddr targetApBssid) |
| 3113 | { |
| 3114 | smeIssueFastRoamNeighborAPEvent(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 3115 | &targetApBssid[0], eSME_ROAM_TRIGGER_SCAN, channel); |
| 3116 | } |
| 3117 | #else |
| 3118 | static void csr_fastroam_neighbor_ap_event(hdd_adapter_t *pAdapter, |
| 3119 | uint8_t channel, tSirMacAddr targetApBssid) |
| 3120 | { |
| 3121 | } |
| 3122 | #endif |
| 3123 | |
| 3124 | /** |
| 3125 | * wlan_hdd_handle_fastreassoc() - Handle fastreassoc command |
| 3126 | * @pAdapter: pointer to hdd adapter |
| 3127 | * @command: pointer to the command received |
| 3128 | * |
| 3129 | * Return: VOS_STATUS enum |
| 3130 | */ |
| 3131 | static VOS_STATUS wlan_hdd_handle_fastreassoc(hdd_adapter_t *pAdapter, |
| 3132 | uint8_t *command) |
| 3133 | { |
| 3134 | tANI_U8 *value = command; |
| 3135 | tANI_U8 channel = 0; |
| 3136 | tSirMacAddr targetApBssid; |
Selvaraj, Sridhar | 3714c4d | 2016-06-22 15:19:12 +0530 | [diff] [blame] | 3137 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 3138 | hdd_context_t *pHddCtx = NULL; |
Selvaraj, Sridhar | 5aff1ed | 2016-06-18 01:26:23 +0530 | [diff] [blame] | 3139 | int ret; |
Selvaraj, Sridhar | 349b8fe | 2017-01-18 13:11:25 +0530 | [diff] [blame] | 3140 | tCsrRoamModifyProfileFields mod_profile_fields; |
| 3141 | uint32_t roam_id = 0; |
Selvaraj, Sridhar | 3714c4d | 2016-06-22 15:19:12 +0530 | [diff] [blame] | 3142 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3143 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 3144 | |
| 3145 | /* if not associated, no need to proceed with reassoc */ |
| 3146 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) { |
| 3147 | hddLog(LOG1, FL("Not associated!")); |
| 3148 | return eHAL_STATUS_FAILURE; |
| 3149 | } |
| 3150 | |
Selvaraj, Sridhar | 5aff1ed | 2016-06-18 01:26:23 +0530 | [diff] [blame] | 3151 | ret = hdd_parse_reassoc_command_v1_data(value, targetApBssid, &channel); |
| 3152 | if (ret) { |
Selvaraj, Sridhar | 3714c4d | 2016-06-22 15:19:12 +0530 | [diff] [blame] | 3153 | hddLog(LOGE, FL("Failed to parse reassoc command data")); |
| 3154 | return eHAL_STATUS_FAILURE; |
| 3155 | } |
| 3156 | |
| 3157 | /* if the target bssid is same as currently associated AP, |
| 3158 | then no need to proceed with reassoc */ |
| 3159 | if (vos_mem_compare(targetApBssid, |
| 3160 | pHddStaCtx->conn_info.bssId, |
| 3161 | sizeof(tSirMacAddr))) { |
Selvaraj, Sridhar | 349b8fe | 2017-01-18 13:11:25 +0530 | [diff] [blame] | 3162 | sme_GetModifyProfileFields(pHddCtx->hHal, pAdapter->sessionId, |
| 3163 | &mod_profile_fields); |
| 3164 | sme_RoamReassoc(pHddCtx->hHal, pAdapter->sessionId, NULL, |
| 3165 | mod_profile_fields, &roam_id, 1); |
Selvaraj, Sridhar | 3714c4d | 2016-06-22 15:19:12 +0530 | [diff] [blame] | 3166 | hddLog(LOG1, FL("Reassoc BSSID is same as currently associated AP bssid")); |
Selvaraj, Sridhar | 349b8fe | 2017-01-18 13:11:25 +0530 | [diff] [blame] | 3167 | return eHAL_STATUS_SUCCESS; |
Selvaraj, Sridhar | 3714c4d | 2016-06-22 15:19:12 +0530 | [diff] [blame] | 3168 | } |
| 3169 | |
| 3170 | /* Check channel number is a valid channel number */ |
| 3171 | if (VOS_STATUS_SUCCESS != |
| 3172 | wlan_hdd_validate_operation_channel(pAdapter, channel)) { |
| 3173 | hddLog(LOGE, FL("Invalid Channel [%d]"), channel); |
| 3174 | return eHAL_STATUS_FAILURE; |
| 3175 | } |
| 3176 | |
| 3177 | /* Proceed with reassoc */ |
| 3178 | wlan_hdd_fastreassoc_handoff_request(pHddCtx, channel, targetApBssid); |
| 3179 | |
| 3180 | /* Proceed with scan/roam */ |
| 3181 | csr_fastroam_neighbor_ap_event(pAdapter, channel, targetApBssid); |
| 3182 | |
| 3183 | return eHAL_STATUS_SUCCESS; |
| 3184 | } |
| 3185 | |
| 3186 | /** |
| 3187 | * hdd_assign_reassoc_handoff - Set handoff source as REASSOC |
| 3188 | * @handoffInfo: Pointer to the csr Handoff Request. |
| 3189 | * |
| 3190 | * Return: None |
| 3191 | */ |
| 3192 | #ifndef QCA_WIFI_ISOC |
| 3193 | static inline void hdd_assign_reassoc_handoff(tCsrHandoffRequest *handoffInfo) |
| 3194 | { |
| 3195 | handoffInfo->src = REASSOC; |
| 3196 | } |
| 3197 | #else |
| 3198 | static inline void hdd_assign_reassoc_handoff(tCsrHandoffRequest *handoffInfo) |
| 3199 | { |
| 3200 | } |
| 3201 | #endif |
| 3202 | |
Ashish Kumar Dhanotiya | 32d092b | 2018-02-20 21:43:57 +0530 | [diff] [blame] | 3203 | /** |
| 3204 | * wlan_hdd_free_cache_channels() - Free the cache channels list |
| 3205 | * @hdd_ctx: Pointer to HDD context |
| 3206 | * |
| 3207 | * Return: None |
| 3208 | */ |
| 3209 | |
| 3210 | static void wlan_hdd_free_cache_channels(hdd_context_t *hdd_ctx) |
| 3211 | { |
| 3212 | mutex_lock(&hdd_ctx->cache_channel_lock); |
| 3213 | hdd_ctx->orginal_channels->num_channels = 0; |
| 3214 | vos_mem_free(hdd_ctx->orginal_channels->channel_info); |
| 3215 | hdd_ctx->orginal_channels->channel_info = NULL; |
| 3216 | vos_mem_free(hdd_ctx->orginal_channels); |
| 3217 | hdd_ctx->orginal_channels = NULL; |
| 3218 | mutex_unlock(&hdd_ctx->cache_channel_lock); |
| 3219 | } |
| 3220 | |
| 3221 | /** |
| 3222 | * hdd_alloc_chan_cache() - Allocate the memory to cache the channel |
| 3223 | * info for the channels received in command SET_DISABLE_CHANNEL_LIST |
| 3224 | * @hdd_ctx: Pointer to HDD context |
| 3225 | * @num_chan: Number of channels for which memory needs to |
| 3226 | * be allocated |
| 3227 | * |
| 3228 | * Return: 0 on success and error code on failure |
| 3229 | */ |
| 3230 | |
| 3231 | int hdd_alloc_chan_cache(hdd_context_t *hdd_ctx, int num_chan) |
| 3232 | { |
| 3233 | if (NULL == hdd_ctx->orginal_channels) { |
| 3234 | hdd_ctx->orginal_channels = |
| 3235 | vos_mem_malloc(sizeof(struct hdd_cache_channels)); |
| 3236 | if (NULL == hdd_ctx->orginal_channels) { |
| 3237 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3238 | "In %s, VOS_MALLOC_ERR", __func__); |
| 3239 | return -EINVAL; |
| 3240 | } |
| 3241 | hdd_ctx->orginal_channels->num_channels = num_chan; |
| 3242 | hdd_ctx->orginal_channels->channel_info = |
| 3243 | vos_mem_malloc(num_chan * |
| 3244 | sizeof(struct hdd_cache_channel_info)); |
| 3245 | if (NULL == hdd_ctx->orginal_channels->channel_info) { |
| 3246 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3247 | "In %s, VOS_MALLOC_ERR", __func__); |
| 3248 | hdd_ctx->orginal_channels->num_channels = 0; |
| 3249 | vos_mem_free(hdd_ctx->orginal_channels); |
| 3250 | hdd_ctx->orginal_channels = NULL; |
| 3251 | return -EINVAL; |
| 3252 | } |
| 3253 | } else { |
| 3254 | /* Same command comes multiple times */ |
| 3255 | struct hdd_cache_channel_info *temp_chan_info; |
| 3256 | |
| 3257 | if (hdd_ctx->orginal_channels->num_channels + num_chan > |
| 3258 | MAX_CHANNEL) { |
| 3259 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3260 | "%s: Invalid Number of channel received", |
| 3261 | __func__); |
| 3262 | return -EINVAL; |
| 3263 | } |
| 3264 | |
| 3265 | temp_chan_info = vos_mem_malloc(( |
| 3266 | hdd_ctx->orginal_channels-> |
| 3267 | num_channels + num_chan) * |
| 3268 | sizeof(struct hdd_cache_channel_info)); |
| 3269 | if (NULL == temp_chan_info) { |
| 3270 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3271 | "In %s, VOS_MALLOC_ERR", |
| 3272 | __func__); |
| 3273 | return -EINVAL; |
| 3274 | } |
| 3275 | |
| 3276 | vos_mem_copy(temp_chan_info, hdd_ctx->orginal_channels-> |
| 3277 | channel_info, hdd_ctx->orginal_channels-> |
| 3278 | num_channels * |
| 3279 | sizeof(struct hdd_cache_channel_info)); |
| 3280 | |
| 3281 | hdd_ctx->orginal_channels->num_channels += num_chan; |
| 3282 | vos_mem_free(hdd_ctx->orginal_channels->channel_info); |
| 3283 | hdd_ctx->orginal_channels->channel_info = temp_chan_info; |
| 3284 | temp_chan_info = NULL; |
| 3285 | } |
| 3286 | return 0; |
| 3287 | |
| 3288 | } |
| 3289 | |
| 3290 | |
| 3291 | int hdd_parse_disable_chan_cmd(hdd_adapter_t *adapter, tANI_U8 *ptr) |
| 3292 | { |
| 3293 | v_PVOID_t pvosGCtx = vos_get_global_context(VOS_MODULE_ID_HDD, NULL); |
| 3294 | hdd_context_t *hdd_ctx = vos_get_context(VOS_MODULE_ID_HDD, pvosGCtx); |
| 3295 | tANI_U8 *param; |
| 3296 | int j, tempInt, index = 0, ret = 0; |
| 3297 | |
| 3298 | if (NULL == pvosGCtx) { |
| 3299 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 3300 | "VOS Global Context is NULL"); |
| 3301 | return -EINVAL; |
| 3302 | } |
| 3303 | |
| 3304 | if (NULL == hdd_ctx) { |
| 3305 | hddLog(VOS_TRACE_LEVEL_FATAL, "HDD Context is NULL"); |
| 3306 | return -EINVAL; |
| 3307 | } |
| 3308 | |
| 3309 | param = strchr(ptr, ' '); |
| 3310 | /*no argument after the command*/ |
| 3311 | if (NULL == param) |
| 3312 | return -EINVAL; |
| 3313 | |
| 3314 | /*no space after the command*/ |
| 3315 | else if (SPACE_ASCII_VALUE != *param) |
| 3316 | return -EINVAL; |
| 3317 | |
| 3318 | param++; |
| 3319 | |
| 3320 | /*removing empty spaces*/ |
| 3321 | while ((SPACE_ASCII_VALUE == *param) && ('\0' != *param)) |
| 3322 | param++; |
| 3323 | |
| 3324 | /*no argument followed by spaces*/ |
| 3325 | if ('\0' == *param) |
| 3326 | return -EINVAL; |
| 3327 | |
| 3328 | /*getting the first argument ie the number of channels*/ |
| 3329 | if (sscanf(param, "%d ", &tempInt) != 1) { |
| 3330 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3331 | "%s: Cannot get number of channels from input", |
| 3332 | __func__); |
| 3333 | return -EINVAL; |
| 3334 | } |
| 3335 | |
| 3336 | if (tempInt < 0 || tempInt > MAX_CHANNEL) { |
| 3337 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3338 | "%s: Invalid Number of channel received", __func__); |
| 3339 | return -EINVAL; |
| 3340 | } |
| 3341 | |
| 3342 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, |
| 3343 | "%s: Number of channel to disable are: %d", |
| 3344 | __func__, tempInt); |
| 3345 | |
| 3346 | if (!tempInt) { |
| 3347 | if (!wlan_hdd_restore_channels(hdd_ctx)) { |
| 3348 | /* |
| 3349 | * Free the cache channels only when the command is |
| 3350 | * received with num channels as 0 |
| 3351 | */ |
| 3352 | wlan_hdd_free_cache_channels(hdd_ctx); |
| 3353 | } |
| 3354 | return 0; |
| 3355 | } |
| 3356 | |
| 3357 | mutex_lock(&hdd_ctx->cache_channel_lock); |
| 3358 | if (hdd_alloc_chan_cache(hdd_ctx, tempInt)) { |
| 3359 | ret = -ENOMEM; |
| 3360 | goto parse_done; |
| 3361 | } |
| 3362 | index = hdd_ctx->orginal_channels->num_channels - tempInt; |
| 3363 | |
| 3364 | for (j = index; j < hdd_ctx->orginal_channels->num_channels; j++) { |
| 3365 | /* |
| 3366 | * param pointing to the beginning of first space |
| 3367 | * after number of channels |
| 3368 | */ |
| 3369 | param = strpbrk(param, " "); |
| 3370 | /*no channel list after the number of channels argument*/ |
| 3371 | if (NULL == param) { |
| 3372 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3373 | "%s, Invalid No of channel provided in the list", |
| 3374 | __func__); |
| 3375 | ret = -EINVAL; |
| 3376 | goto parse_done; |
| 3377 | } |
| 3378 | |
| 3379 | param++; |
| 3380 | |
| 3381 | /*removing empty space*/ |
| 3382 | while ((SPACE_ASCII_VALUE == *param) && ('\0' != *param)) |
| 3383 | param++; |
| 3384 | |
| 3385 | if ('\0' == *param) { |
| 3386 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3387 | "%s, No channel is provided in the list", |
| 3388 | __func__); |
| 3389 | ret = -EINVAL; |
| 3390 | goto parse_done; |
| 3391 | |
| 3392 | } |
| 3393 | |
| 3394 | if (sscanf(param, "%d ", &tempInt) != 1) { |
| 3395 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3396 | "%s: Cannot read channel number", |
| 3397 | __func__); |
| 3398 | ret = -EINVAL; |
| 3399 | goto parse_done; |
| 3400 | |
| 3401 | } |
| 3402 | |
| 3403 | if (!IS_CHANNEL_VALID(tempInt)) { |
| 3404 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3405 | "%s: Invalid channel number received", |
| 3406 | __func__); |
| 3407 | ret = -EINVAL; |
| 3408 | goto parse_done; |
| 3409 | |
| 3410 | } |
| 3411 | |
| 3412 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: channel[%d] = %d", __func__, |
| 3413 | j, tempInt); |
| 3414 | hdd_ctx->orginal_channels->channel_info[j].channel_num = |
| 3415 | tempInt; |
| 3416 | } |
| 3417 | |
| 3418 | /*extra arguments check*/ |
| 3419 | param = strchr(param, ' '); |
| 3420 | if (NULL != param) { |
| 3421 | while ((SPACE_ASCII_VALUE == *param) && ('\0' != *param)) |
| 3422 | param++; |
| 3423 | |
| 3424 | if ('\0' != *param) { |
| 3425 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3426 | "%s: Invalid argument received", __func__); |
| 3427 | ret = -EINVAL; |
| 3428 | goto parse_done; |
| 3429 | } |
| 3430 | } |
| 3431 | |
| 3432 | parse_done: |
| 3433 | mutex_unlock(&hdd_ctx->cache_channel_lock); |
| 3434 | EXIT(); |
| 3435 | |
| 3436 | return ret; |
| 3437 | } |
| 3438 | |
Hanumanth Reddy Pothula | 8ae38bb | 2018-03-07 18:59:30 +0530 | [diff] [blame] | 3439 | int hdd_get_disable_ch_list(hdd_context_t *hdd_ctx, tANI_U8 *buf, |
| 3440 | tANI_U8 buf_len) |
| 3441 | { |
| 3442 | struct hdd_cache_channel_info *ch_list; |
| 3443 | unsigned char i, num_ch; |
| 3444 | int len = 0; |
| 3445 | |
| 3446 | mutex_lock(&hdd_ctx->cache_channel_lock); |
| 3447 | if (hdd_ctx->orginal_channels && |
| 3448 | hdd_ctx->orginal_channels->num_channels) { |
| 3449 | num_ch = hdd_ctx->orginal_channels->num_channels; |
| 3450 | |
| 3451 | if (num_ch == 0) { |
| 3452 | mutex_unlock(&hdd_ctx->cache_channel_lock); |
| 3453 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3454 | FL("no disable channels programed")); |
| 3455 | return 0; |
| 3456 | } |
| 3457 | |
| 3458 | len = scnprintf(buf, buf_len, "%s %hhu", |
| 3459 | "GET_DISABLE_CHANNEL_LIST", num_ch); |
| 3460 | |
| 3461 | ch_list = hdd_ctx->orginal_channels->channel_info; |
| 3462 | if (!ch_list) { |
| 3463 | mutex_unlock(&hdd_ctx->cache_channel_lock); |
| 3464 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3465 | FL("disable channel list is NULL")); |
| 3466 | return 0; |
| 3467 | } |
| 3468 | |
| 3469 | for (i = 0; (i < num_ch) && len <= buf_len; i++) { |
| 3470 | len += scnprintf(buf + len, buf_len - len, |
| 3471 | " %d", ch_list[i].channel_num); |
| 3472 | } |
| 3473 | } |
| 3474 | mutex_unlock(&hdd_ctx->cache_channel_lock); |
| 3475 | |
| 3476 | return len; |
| 3477 | } |
| 3478 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 3479 | static int hdd_driver_command(hdd_adapter_t *pAdapter, |
| 3480 | hdd_priv_data_t *ppriv_data) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3481 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3482 | hdd_priv_data_t priv_data; |
| 3483 | tANI_U8 *command = NULL; |
Kaushik, Sushant | 9612244 | 2014-10-21 16:40:18 +0530 | [diff] [blame] | 3484 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 3485 | hdd_scaninfo_t *pScanInfo = NULL; |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 3486 | int ret = 0; |
Kaushik, Sushant | 9612244 | 2014-10-21 16:40:18 +0530 | [diff] [blame] | 3487 | int status; |
Anand N Sunkad | e9adb1b | 2015-07-29 09:56:45 +0530 | [diff] [blame] | 3488 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) |
| 3489 | struct cfg80211_mgmt_tx_params params; |
| 3490 | #endif |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 3491 | |
| 3492 | ENTER(); |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 3493 | /* |
| 3494 | * Note that valid pointers are provided by caller |
| 3495 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3496 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 3497 | /* copy to local struct to avoid numerous changes to legacy code */ |
| 3498 | priv_data = *ppriv_data; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3499 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 3500 | if (priv_data.total_len <= 0 || |
| 3501 | priv_data.total_len > WLAN_PRIV_DATA_MAX_LEN) |
Sameer Thalappil | 8ef3a0e | 2013-04-05 14:36:04 -0700 | [diff] [blame] | 3502 | { |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 3503 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 3504 | "%s:invalid priv_data.total_len(%d)!!!", __func__, |
| 3505 | priv_data.total_len); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 3506 | ret = -EINVAL; |
| 3507 | goto exit; |
| 3508 | } |
Kaushik, Sushant | 9612244 | 2014-10-21 16:40:18 +0530 | [diff] [blame] | 3509 | status = wlan_hdd_validate_context(pHddCtx); |
| 3510 | if (0 != status) |
| 3511 | { |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 3512 | ret = -EINVAL; |
| 3513 | goto exit; |
Kaushik, Sushant | 9612244 | 2014-10-21 16:40:18 +0530 | [diff] [blame] | 3514 | } |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 3515 | /* Allocate +1 for '\0' */ |
| 3516 | command = kmalloc(priv_data.total_len + 1, GFP_KERNEL); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3517 | if (!command) |
| 3518 | { |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 3519 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3520 | "%s: failed to allocate memory", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3521 | ret = -ENOMEM; |
| 3522 | goto exit; |
| 3523 | } |
| 3524 | |
| 3525 | if (copy_from_user(command, priv_data.buf, priv_data.total_len)) |
| 3526 | { |
| 3527 | ret = -EFAULT; |
| 3528 | goto exit; |
| 3529 | } |
| 3530 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 3531 | /* Make sure the command is NUL-terminated */ |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 3532 | command[priv_data.total_len] = '\0'; |
| 3533 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 3534 | /* at one time the following block of code was conditional. braces |
| 3535 | * have been retained to avoid re-indenting the legacy code |
| 3536 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3537 | { |
| 3538 | hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx; |
| 3539 | |
| 3540 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | f9bdd4e | 2012-10-30 18:05:03 -0700 | [diff] [blame] | 3541 | "%s: Received %s cmd from Wi-Fi GUI***", __func__, command); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3542 | |
| 3543 | if (strncmp(command, "P2P_DEV_ADDR", 12) == 0 ) |
| 3544 | { |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 3545 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 3546 | TRACE_CODE_HDD_P2P_DEV_ADDR_IOCTL, |
| 3547 | pAdapter->sessionId, (unsigned) |
| 3548 | (*(pHddCtx->p2pDeviceAddress.bytes+2)<<24 | |
| 3549 | *(pHddCtx->p2pDeviceAddress.bytes+3)<<16 | |
| 3550 | *(pHddCtx->p2pDeviceAddress.bytes+4)<<8 | |
| 3551 | *(pHddCtx->p2pDeviceAddress.bytes+5)))); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3552 | if (copy_to_user(priv_data.buf, pHddCtx->p2pDeviceAddress.bytes, |
| 3553 | sizeof(tSirMacAddr))) |
| 3554 | { |
| 3555 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 3556 | "%s: failed to copy data to user buffer", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3557 | ret = -EFAULT; |
| 3558 | } |
| 3559 | } |
Amar Singhal | 0974e40 | 2013-02-12 14:27:46 -0800 | [diff] [blame] | 3560 | else if(strncmp(command, "SETBAND", 7) == 0) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3561 | { |
Amar Singhal | 0974e40 | 2013-02-12 14:27:46 -0800 | [diff] [blame] | 3562 | tANI_U8 *ptr = command ; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3563 | |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 3564 | ret = hdd_drv_cmd_validate(command, 7); |
| 3565 | if (ret) |
| 3566 | goto exit; |
| 3567 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3568 | /* Change band request received */ |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3569 | |
| 3570 | /* First 8 bytes will have "SETBAND " and |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3571 | * 9 byte will have band setting value */ |
Madan Mohan Koyyalamudi | 8bdd311 | 2012-09-24 13:55:14 -0700 | [diff] [blame] | 3572 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Amar Singhal | 0974e40 | 2013-02-12 14:27:46 -0800 | [diff] [blame] | 3573 | "%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] | 3574 | if(VOS_FTM_MODE != hdd_get_conparam()) |
| 3575 | { |
| 3576 | /* Change band request received */ |
| 3577 | ret = hdd_setBand_helper(pAdapter->dev, ptr); |
| 3578 | if(ret < 0) |
| 3579 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 3580 | "%s: failed to set band ret=%d", __func__, ret); |
| 3581 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3582 | } |
Kiet Lam | f040f47 | 2013-11-20 21:15:23 +0530 | [diff] [blame] | 3583 | else if(strncmp(command, "SETWMMPS", 8) == 0) |
| 3584 | { |
| 3585 | tANI_U8 *ptr = command; |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 3586 | |
| 3587 | ret = hdd_drv_cmd_validate(command, 8); |
| 3588 | if (ret) |
| 3589 | goto exit; |
| 3590 | |
Kiet Lam | f040f47 | 2013-11-20 21:15:23 +0530 | [diff] [blame] | 3591 | ret = hdd_wmmps_helper(pAdapter, ptr); |
| 3592 | } |
Agarwal Ashish | ef54a18 | 2014-12-16 15:07:31 +0530 | [diff] [blame] | 3593 | |
| 3594 | else if(strncmp(command, "TDLSSCAN", 8) == 0) |
| 3595 | { |
| 3596 | tANI_U8 *ptr = command; |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 3597 | |
| 3598 | ret = hdd_drv_cmd_validate(command, 8); |
| 3599 | if (ret) |
| 3600 | goto exit; |
| 3601 | |
Agarwal Ashish | ef54a18 | 2014-12-16 15:07:31 +0530 | [diff] [blame] | 3602 | ret = hdd_set_tdls_scan_type(pAdapter, ptr); |
| 3603 | } |
| 3604 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 3605 | else if ( strncasecmp(command, "COUNTRY", 7) == 0 ) |
| 3606 | { |
| 3607 | char *country_code; |
| 3608 | |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 3609 | ret = hdd_drv_cmd_validate(command, 7); |
| 3610 | if (ret) |
| 3611 | goto exit; |
| 3612 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 3613 | country_code = command + 8; |
Tushnim Bhattacharyya | 9cdf608 | 2013-04-21 16:33:30 -0700 | [diff] [blame] | 3614 | |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 3615 | INIT_COMPLETION(pAdapter->change_country_code); |
Tushnim Bhattacharyya | 9cdf608 | 2013-04-21 16:33:30 -0700 | [diff] [blame] | 3616 | hdd_checkandupdate_dfssetting(pAdapter, country_code); |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 3617 | #ifndef CONFIG_ENABLE_LINUX_REG |
Gopichand Nakkala | dacbcb5 | 2013-04-18 16:41:54 +0530 | [diff] [blame] | 3618 | hdd_checkandupdate_phymode(pAdapter, country_code); |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 3619 | #endif |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 3620 | ret = (int)sme_ChangeCountryCode(pHddCtx->hHal, |
| 3621 | (void *)(tSmeChangeCountryCallback) |
| 3622 | wlan_hdd_change_country_code_callback, |
Abhishek Singh | a306a44 | 2013-11-07 18:39:01 +0530 | [diff] [blame] | 3623 | country_code, pAdapter, pHddCtx->pvosContext, eSIR_TRUE, eSIR_TRUE); |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 3624 | if (eHAL_STATUS_SUCCESS == ret) |
| 3625 | { |
| 3626 | ret = wait_for_completion_interruptible_timeout( |
| 3627 | &pAdapter->change_country_code, |
| 3628 | msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY)); |
| 3629 | if (0 >= ret) |
| 3630 | { |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 3631 | 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] | 3632 | __func__, ret); |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 3633 | } |
| 3634 | } |
| 3635 | else |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 3636 | { |
| 3637 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 3638 | "%s: SME Change Country code fail ret=%d", __func__, ret); |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 3639 | ret = -EINVAL; |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 3640 | } |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 3641 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 3642 | } |
| 3643 | /* |
| 3644 | command should be a string having format |
| 3645 | SET_SAP_CHANNEL_LIST <num of channels> <the channels seperated by spaces> |
| 3646 | */ |
Amar Singhal | 0974e40 | 2013-02-12 14:27:46 -0800 | [diff] [blame] | 3647 | else if(strncmp(command, "SET_SAP_CHANNEL_LIST", 20) == 0) |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 3648 | { |
Amar Singhal | 0974e40 | 2013-02-12 14:27:46 -0800 | [diff] [blame] | 3649 | tANI_U8 *ptr = command; |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 3650 | |
| 3651 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 3652 | " Received Command to Set Preferred Channels for SAP in %s", __func__); |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 3653 | |
Mahesh Kumar Kalikot Veetil | 2aad8d8 | 2013-02-07 12:31:28 -0800 | [diff] [blame] | 3654 | ret = sapSetPreferredChannel(ptr); |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 3655 | } |
Sameer Thalappil | 45931fb | 2013-02-01 11:18:05 -0800 | [diff] [blame] | 3656 | else if(strncmp(command, "SETSUSPENDMODE", 14) == 0) |
| 3657 | { |
| 3658 | int suspend = 0; |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 3659 | tANI_U8 *ptr; |
| 3660 | |
| 3661 | ret = hdd_drv_cmd_validate(command, 14); |
| 3662 | if (ret) |
| 3663 | goto exit; |
| 3664 | |
| 3665 | ptr = (tANI_U8*)command + 15; |
Sameer Thalappil | 45931fb | 2013-02-01 11:18:05 -0800 | [diff] [blame] | 3666 | |
| 3667 | suspend = *ptr - '0'; |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 3668 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 3669 | TRACE_CODE_HDD_SETSUSPENDMODE_IOCTL, |
| 3670 | pAdapter->sessionId, suspend)); |
Sameer Thalappil | 45931fb | 2013-02-01 11:18:05 -0800 | [diff] [blame] | 3671 | hdd_set_wlan_suspend_mode(suspend); |
| 3672 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3673 | #ifdef WLAN_FEATURE_NEIGHBOR_ROAMING |
| 3674 | else if (strncmp(command, "SETROAMTRIGGER", 14) == 0) |
| 3675 | { |
| 3676 | tANI_U8 *value = command; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 3677 | tANI_S8 rssi = 0; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3678 | tANI_U8 lookUpThreshold = CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_DEFAULT; |
| 3679 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 3680 | |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 3681 | ret = hdd_drv_cmd_validate(command, 14); |
| 3682 | if (ret) |
| 3683 | goto exit; |
| 3684 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3685 | /* Move pointer to ahead of SETROAMTRIGGER<delimiter> */ |
| 3686 | value = value + 15; |
| 3687 | |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 3688 | /* Convert the value from ascii to integer */ |
| 3689 | ret = kstrtos8(value, 10, &rssi); |
| 3690 | if (ret < 0) |
| 3691 | { |
| 3692 | /* If the input value is greater than max value of datatype, then also |
| 3693 | kstrtou8 fails */ |
| 3694 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3695 | "%s: kstrtou8 failed Input value may be out of range[%d - %d]", |
Srinivas Girigowda | fa7157d | 2013-10-31 10:14:22 -0700 | [diff] [blame] | 3696 | __func__, |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 3697 | CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MIN, |
| 3698 | CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MAX); |
| 3699 | ret = -EINVAL; |
| 3700 | goto exit; |
| 3701 | } |
| 3702 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3703 | lookUpThreshold = abs(rssi); |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 3704 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3705 | if ((lookUpThreshold < CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MIN) || |
| 3706 | (lookUpThreshold > CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MAX)) |
| 3707 | { |
| 3708 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3709 | "Neighbor lookup threshold value %d is out of range" |
| 3710 | " (Min: %d Max: %d)", lookUpThreshold, |
| 3711 | CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MIN, |
| 3712 | CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MAX); |
| 3713 | ret = -EINVAL; |
| 3714 | goto exit; |
| 3715 | } |
| 3716 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 3717 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 3718 | TRACE_CODE_HDD_SETROAMTRIGGER_IOCTL, |
| 3719 | pAdapter->sessionId, lookUpThreshold)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3720 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3721 | "%s: Received Command to Set Roam trigger" |
| 3722 | " (Neighbor lookup threshold) = %d", __func__, lookUpThreshold); |
| 3723 | |
| 3724 | pHddCtx->cfg_ini->nNeighborLookupRssiThreshold = lookUpThreshold; |
| 3725 | status = sme_setNeighborLookupRssiThreshold((tHalHandle)(pHddCtx->hHal), lookUpThreshold); |
| 3726 | if (eHAL_STATUS_SUCCESS != status) |
| 3727 | { |
| 3728 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3729 | "%s: Failed to set roam trigger, try again", __func__); |
| 3730 | ret = -EPERM; |
| 3731 | goto exit; |
| 3732 | } |
| 3733 | |
| 3734 | /* Set Reassoc threshold to (lookup rssi threshold + 5 dBm) */ |
mukul sharma | d6e1fdd | 2014-06-23 19:19:09 +0530 | [diff] [blame] | 3735 | pHddCtx->cfg_ini->nNeighborReassocRssiThreshold = lookUpThreshold + 5; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3736 | sme_setNeighborReassocRssiThreshold((tHalHandle)(pHddCtx->hHal), lookUpThreshold + 5); |
| 3737 | } |
| 3738 | else if (strncmp(command, "GETROAMTRIGGER", 14) == 0) |
| 3739 | { |
| 3740 | tANI_U8 lookUpThreshold = sme_getNeighborLookupRssiThreshold((tHalHandle)(pHddCtx->hHal)); |
| 3741 | int rssi = (-1) * lookUpThreshold; |
| 3742 | char extra[32]; |
| 3743 | tANI_U8 len = 0; |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 3744 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 3745 | TRACE_CODE_HDD_GETROAMTRIGGER_IOCTL, |
| 3746 | pAdapter->sessionId, lookUpThreshold)); |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3747 | len = scnprintf(extra, sizeof(extra), "%s %d", command, rssi); |
Srinivas Girigowda | 9171923 | 2015-07-13 15:10:10 +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 | de69741 | 2013-02-14 16:31:48 -0800 | [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, "SETROAMSCANPERIOD", 17) == 0) |
| 3758 | { |
| 3759 | tANI_U8 *value = command; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 3760 | tANI_U8 roamScanPeriod = 0; |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3761 | tANI_U16 neighborEmptyScanRefreshPeriod = CFG_EMPTY_SCAN_REFRESH_PERIOD_DEFAULT; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 3762 | |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 3763 | ret = hdd_drv_cmd_validate(command, 17); |
| 3764 | if (ret) |
| 3765 | goto exit; |
| 3766 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3767 | /* input refresh period is in terms of seconds */ |
| 3768 | /* Move pointer to ahead of SETROAMSCANPERIOD<delimiter> */ |
| 3769 | value = value + 18; |
| 3770 | /* Convert the value from ascii to integer */ |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 3771 | ret = kstrtou8(value, 10, &roamScanPeriod); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3772 | if (ret < 0) |
| 3773 | { |
| 3774 | /* 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] | 3775 | kstrtou8 fails */ |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3776 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 3777 | "%s: kstrtou8 failed Input value may be out of range[%d - %d]", |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3778 | __func__, |
Srinivas Girigowda | b8edd1e | 2013-03-19 11:42:08 -0700 | [diff] [blame] | 3779 | (CFG_EMPTY_SCAN_REFRESH_PERIOD_MIN/1000), |
| 3780 | (CFG_EMPTY_SCAN_REFRESH_PERIOD_MAX/1000)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3781 | ret = -EINVAL; |
| 3782 | goto exit; |
| 3783 | } |
| 3784 | |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 3785 | if ((roamScanPeriod < (CFG_EMPTY_SCAN_REFRESH_PERIOD_MIN/1000)) || |
| 3786 | (roamScanPeriod > (CFG_EMPTY_SCAN_REFRESH_PERIOD_MAX/1000))) |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3787 | { |
| 3788 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 3789 | "Roam scan period value %d is out of range" |
| 3790 | " (Min: %d Max: %d)", roamScanPeriod, |
Srinivas Girigowda | b8edd1e | 2013-03-19 11:42:08 -0700 | [diff] [blame] | 3791 | (CFG_EMPTY_SCAN_REFRESH_PERIOD_MIN/1000), |
| 3792 | (CFG_EMPTY_SCAN_REFRESH_PERIOD_MAX/1000)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3793 | ret = -EINVAL; |
| 3794 | goto exit; |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 3795 | } |
| 3796 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 3797 | TRACE_CODE_HDD_SETROAMSCANPERIOD_IOCTL, |
| 3798 | pAdapter->sessionId, roamScanPeriod)); |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 3799 | neighborEmptyScanRefreshPeriod = roamScanPeriod * 1000; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3800 | |
| 3801 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3802 | "%s: Received Command to Set roam scan period" |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 3803 | " (Empty Scan refresh period) = %d", __func__, roamScanPeriod); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3804 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3805 | pHddCtx->cfg_ini->nEmptyScanRefreshPeriod = neighborEmptyScanRefreshPeriod; |
| 3806 | sme_UpdateEmptyScanRefreshPeriod((tHalHandle)(pHddCtx->hHal), neighborEmptyScanRefreshPeriod); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3807 | } |
| 3808 | else if (strncmp(command, "GETROAMSCANPERIOD", 17) == 0) |
| 3809 | { |
| 3810 | tANI_U16 nEmptyScanRefreshPeriod = sme_getEmptyScanRefreshPeriod((tHalHandle)(pHddCtx->hHal)); |
| 3811 | char extra[32]; |
| 3812 | tANI_U8 len = 0; |
| 3813 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 3814 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 3815 | TRACE_CODE_HDD_GETROAMSCANPERIOD_IOCTL, |
| 3816 | pAdapter->sessionId, nEmptyScanRefreshPeriod)); |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3817 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3818 | "GETROAMSCANPERIOD", (nEmptyScanRefreshPeriod/1000)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3819 | /* Returned value is in units of seconds */ |
Ratnam Rachuri | a72ba11 | 2015-07-17 13:27:03 +0530 | [diff] [blame] | 3820 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 3821 | if (copy_to_user(priv_data.buf, &extra, len)) { |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3822 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3823 | "%s: failed to copy data to user buffer", __func__); |
| 3824 | ret = -EFAULT; |
| 3825 | goto exit; |
| 3826 | } |
| 3827 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3828 | else if (strncmp(command, "SETROAMSCANREFRESHPERIOD", 24) == 0) |
| 3829 | { |
| 3830 | tANI_U8 *value = command; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 3831 | tANI_U8 roamScanRefreshPeriod = 0; |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3832 | tANI_U16 neighborScanRefreshPeriod = CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_DEFAULT; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 3833 | |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 3834 | ret = hdd_drv_cmd_validate(command, 24); |
| 3835 | if (ret) |
| 3836 | goto exit; |
| 3837 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3838 | /* input refresh period is in terms of seconds */ |
| 3839 | /* Move pointer to ahead of SETROAMSCANREFRESHPERIOD<delimiter> */ |
| 3840 | value = value + 25; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 3841 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3842 | /* Convert the value from ascii to integer */ |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 3843 | ret = kstrtou8(value, 10, &roamScanRefreshPeriod); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3844 | if (ret < 0) |
| 3845 | { |
| 3846 | /* 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] | 3847 | kstrtou8 fails */ |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3848 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 3849 | "%s: kstrtou8 failed Input value may be out of range[%d - %d]", |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3850 | __func__, |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3851 | (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MIN/1000), |
| 3852 | (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MAX/1000)); |
| 3853 | ret = -EINVAL; |
| 3854 | goto exit; |
| 3855 | } |
| 3856 | |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 3857 | if ((roamScanRefreshPeriod < (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MIN/1000)) || |
| 3858 | (roamScanRefreshPeriod > (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MAX/1000))) |
| 3859 | { |
| 3860 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3861 | "Neighbor scan results refresh period value %d is out of range" |
| 3862 | " (Min: %d Max: %d)", roamScanRefreshPeriod, |
| 3863 | (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MIN/1000), |
| 3864 | (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MAX/1000)); |
| 3865 | ret = -EINVAL; |
| 3866 | goto exit; |
| 3867 | } |
| 3868 | neighborScanRefreshPeriod = roamScanRefreshPeriod * 1000; |
| 3869 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3870 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3871 | "%s: Received Command to Set roam scan refresh period" |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 3872 | " (Scan refresh period) = %d", __func__, roamScanRefreshPeriod); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3873 | |
| 3874 | pHddCtx->cfg_ini->nNeighborResultsRefreshPeriod = neighborScanRefreshPeriod; |
| 3875 | sme_setNeighborScanRefreshPeriod((tHalHandle)(pHddCtx->hHal), neighborScanRefreshPeriod); |
| 3876 | } |
| 3877 | else if (strncmp(command, "GETROAMSCANREFRESHPERIOD", 24) == 0) |
| 3878 | { |
| 3879 | tANI_U16 value = sme_getNeighborScanRefreshPeriod((tHalHandle)(pHddCtx->hHal)); |
| 3880 | char extra[32]; |
| 3881 | tANI_U8 len = 0; |
| 3882 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3883 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3884 | "GETROAMSCANREFRESHPERIOD", (value/1000)); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3885 | /* Returned value is in units of seconds */ |
Ratnam Rachuri | 2c9d670 | 2015-07-17 13:25:16 +0530 | [diff] [blame] | 3886 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 3887 | if (copy_to_user(priv_data.buf, &extra, len)) { |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 3888 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3889 | "%s: failed to copy data to user buffer", __func__); |
| 3890 | ret = -EFAULT; |
| 3891 | goto exit; |
| 3892 | } |
| 3893 | } |
Varun Reddy Yeturu | 6d99ac8 | 2013-05-08 14:15:35 -0700 | [diff] [blame] | 3894 | #ifdef FEATURE_WLAN_LFR |
| 3895 | /* SETROAMMODE */ |
| 3896 | else if (strncmp(command, "SETROAMMODE", SIZE_OF_SETROAMMODE) == 0) |
| 3897 | { |
| 3898 | tANI_U8 *value = command; |
| 3899 | tANI_BOOLEAN roamMode = CFG_LFR_FEATURE_ENABLED_DEFAULT; |
| 3900 | |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 3901 | if (pHddCtx->concurrency_mode == VOS_STA_MON) { |
| 3902 | hddLog(LOGE, |
| 3903 | FL("Roaming is always disabled in STA + MON concurrency")); |
| 3904 | ret = -EINVAL; |
| 3905 | goto exit; |
| 3906 | } |
| 3907 | |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 3908 | ret = hdd_drv_cmd_validate(command, SIZE_OF_SETROAMMODE); |
| 3909 | if (ret) |
| 3910 | goto exit; |
| 3911 | |
Varun Reddy Yeturu | 6d99ac8 | 2013-05-08 14:15:35 -0700 | [diff] [blame] | 3912 | /* Move pointer to ahead of SETROAMMODE<delimiter> */ |
| 3913 | value = value + SIZE_OF_SETROAMMODE + 1; |
| 3914 | |
| 3915 | /* Convert the value from ascii to integer */ |
| 3916 | ret = kstrtou8(value, SIZE_OF_SETROAMMODE, &roamMode); |
| 3917 | if (ret < 0) |
| 3918 | { |
| 3919 | /* If the input value is greater than max value of datatype, then also |
| 3920 | kstrtou8 fails */ |
| 3921 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3922 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 3923 | CFG_LFR_FEATURE_ENABLED_MIN, |
| 3924 | CFG_LFR_FEATURE_ENABLED_MAX); |
| 3925 | ret = -EINVAL; |
| 3926 | goto exit; |
| 3927 | } |
| 3928 | if ((roamMode < CFG_LFR_FEATURE_ENABLED_MIN) || |
| 3929 | (roamMode > CFG_LFR_FEATURE_ENABLED_MAX)) |
| 3930 | { |
| 3931 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3932 | "Roam Mode value %d is out of range" |
| 3933 | " (Min: %d Max: %d)", roamMode, |
| 3934 | CFG_LFR_FEATURE_ENABLED_MIN, |
| 3935 | CFG_LFR_FEATURE_ENABLED_MAX); |
| 3936 | ret = -EINVAL; |
| 3937 | goto exit; |
| 3938 | } |
| 3939 | |
| 3940 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3941 | "%s: Received Command to Set Roam Mode = %d", __func__, roamMode); |
| 3942 | /* |
| 3943 | * Note that |
| 3944 | * SETROAMMODE 0 is to enable LFR while |
| 3945 | * SETROAMMODE 1 is to disable LFR, but |
| 3946 | * NotifyIsFastRoamIniFeatureEnabled 0/1 is to enable/disable. |
| 3947 | * So, we have to invert the value to call sme_UpdateIsFastRoamIniFeatureEnabled. |
| 3948 | */ |
| 3949 | if (CFG_LFR_FEATURE_ENABLED_MIN == roamMode) |
| 3950 | roamMode = CFG_LFR_FEATURE_ENABLED_MAX; /* Roam enable */ |
| 3951 | else |
| 3952 | roamMode = CFG_LFR_FEATURE_ENABLED_MIN; /* Roam disable */ |
| 3953 | |
| 3954 | pHddCtx->cfg_ini->isFastRoamIniFeatureEnabled = roamMode; |
| 3955 | sme_UpdateIsFastRoamIniFeatureEnabled((tHalHandle)(pHddCtx->hHal), roamMode); |
| 3956 | } |
| 3957 | /* GETROAMMODE */ |
Mahesh A Saptasagar | ec7d109 | 2015-04-02 13:41:34 +0530 | [diff] [blame] | 3958 | else if (strncmp(command, "GETROAMMODE", SIZE_OF_GETROAMMODE) == 0) |
Varun Reddy Yeturu | 6d99ac8 | 2013-05-08 14:15:35 -0700 | [diff] [blame] | 3959 | { |
| 3960 | tANI_BOOLEAN roamMode = sme_getIsLfrFeatureEnabled((tHalHandle)(pHddCtx->hHal)); |
| 3961 | char extra[32]; |
| 3962 | tANI_U8 len = 0; |
| 3963 | |
| 3964 | /* |
| 3965 | * roamMode value shall be inverted because the sementics is different. |
| 3966 | */ |
| 3967 | if (CFG_LFR_FEATURE_ENABLED_MIN == roamMode) |
| 3968 | roamMode = CFG_LFR_FEATURE_ENABLED_MAX; |
| 3969 | else |
| 3970 | roamMode = CFG_LFR_FEATURE_ENABLED_MIN; |
| 3971 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 3972 | len = scnprintf(extra, sizeof(extra), "%s %d", command, roamMode); |
Ratnam Rachuri | 28693eb | 2015-07-17 13:23:42 +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 | 6d99ac8 | 2013-05-08 14:15:35 -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 | #endif |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3982 | #endif |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 3983 | #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] | 3984 | else if (strncmp(command, "SETROAMDELTA", 12) == 0) |
| 3985 | { |
| 3986 | tANI_U8 *value = command; |
| 3987 | tANI_U8 roamRssiDiff = CFG_ROAM_RSSI_DIFF_DEFAULT; |
| 3988 | |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 3989 | ret = hdd_drv_cmd_validate(command, 12); |
| 3990 | if (ret) |
| 3991 | goto exit; |
| 3992 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3993 | /* Move pointer to ahead of SETROAMDELTA<delimiter> */ |
| 3994 | value = value + 13; |
| 3995 | /* Convert the value from ascii to integer */ |
| 3996 | ret = kstrtou8(value, 10, &roamRssiDiff); |
| 3997 | if (ret < 0) |
| 3998 | { |
| 3999 | /* If the input value is greater than max value of datatype, then also |
| 4000 | kstrtou8 fails */ |
| 4001 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4002 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 4003 | CFG_ROAM_RSSI_DIFF_MIN, |
| 4004 | CFG_ROAM_RSSI_DIFF_MAX); |
| 4005 | ret = -EINVAL; |
| 4006 | goto exit; |
| 4007 | } |
| 4008 | |
| 4009 | if ((roamRssiDiff < CFG_ROAM_RSSI_DIFF_MIN) || |
| 4010 | (roamRssiDiff > CFG_ROAM_RSSI_DIFF_MAX)) |
| 4011 | { |
| 4012 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4013 | "Roam rssi diff value %d is out of range" |
| 4014 | " (Min: %d Max: %d)", roamRssiDiff, |
| 4015 | CFG_ROAM_RSSI_DIFF_MIN, |
| 4016 | CFG_ROAM_RSSI_DIFF_MAX); |
| 4017 | ret = -EINVAL; |
| 4018 | goto exit; |
| 4019 | } |
| 4020 | |
| 4021 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4022 | "%s: Received Command to Set roam rssi diff = %d", __func__, roamRssiDiff); |
| 4023 | |
| 4024 | pHddCtx->cfg_ini->RoamRssiDiff = roamRssiDiff; |
| 4025 | sme_UpdateRoamRssiDiff((tHalHandle)(pHddCtx->hHal), roamRssiDiff); |
| 4026 | } |
Mahesh A Saptasagar | ec7d109 | 2015-04-02 13:41:34 +0530 | [diff] [blame] | 4027 | else if (strncmp(command, "GETROAMDELTA", 12) == 0) |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4028 | { |
| 4029 | tANI_U8 roamRssiDiff = sme_getRoamRssiDiff((tHalHandle)(pHddCtx->hHal)); |
| 4030 | char extra[32]; |
| 4031 | tANI_U8 len = 0; |
| 4032 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 4033 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 4034 | TRACE_CODE_HDD_GETROAMDELTA_IOCTL, |
| 4035 | pAdapter->sessionId, roamRssiDiff)); |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 4036 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 4037 | command, roamRssiDiff); |
Ratnam Rachuri | 22a3b40 | 2015-07-17 13:21:49 +0530 | [diff] [blame] | 4038 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 4039 | if (copy_to_user(priv_data.buf, &extra, len)) { |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4040 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4041 | "%s: failed to copy data to user buffer", __func__); |
| 4042 | ret = -EFAULT; |
| 4043 | goto exit; |
| 4044 | } |
| 4045 | } |
| 4046 | #endif |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4047 | #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] | 4048 | else if (strncmp(command, "GETBAND", 7) == 0) |
| 4049 | { |
| 4050 | int band = -1; |
| 4051 | char extra[32]; |
| 4052 | tANI_U8 len = 0; |
| 4053 | hdd_getBand_helper(pHddCtx, &band); |
| 4054 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 4055 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 4056 | TRACE_CODE_HDD_GETBAND_IOCTL, |
| 4057 | pAdapter->sessionId, band)); |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 4058 | len = scnprintf(extra, sizeof(extra), "%s %d", command, band); |
Ratnam Rachuri | 5213959 | 2015-07-17 13:17:29 +0530 | [diff] [blame] | 4059 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 4060 | if (copy_to_user(priv_data.buf, &extra, len)) { |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4061 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4062 | "%s: failed to copy data to user buffer", __func__); |
| 4063 | ret = -EFAULT; |
| 4064 | goto exit; |
| 4065 | } |
| 4066 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4067 | else if (strncmp(command, "SETROAMSCANCHANNELS", 19) == 0) |
| 4068 | { |
| 4069 | tANI_U8 *value = command; |
| 4070 | tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0}; |
| 4071 | tANI_U8 numChannels = 0; |
| 4072 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 4073 | |
| 4074 | status = hdd_parse_channellist(value, ChannelList, &numChannels); |
| 4075 | if (eHAL_STATUS_SUCCESS != status) |
| 4076 | { |
| 4077 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4078 | "%s: Failed to parse channel list information", __func__); |
| 4079 | ret = -EINVAL; |
| 4080 | goto exit; |
| 4081 | } |
| 4082 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 4083 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 4084 | TRACE_CODE_HDD_SETROAMSCANCHANNELS_IOCTL, |
| 4085 | pAdapter->sessionId, numChannels)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4086 | if (numChannels > WNI_CFG_VALID_CHANNEL_LIST_LEN) |
| 4087 | { |
| 4088 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4089 | "%s: number of channels (%d) supported exceeded max (%d)", __func__, |
| 4090 | numChannels, WNI_CFG_VALID_CHANNEL_LIST_LEN); |
| 4091 | ret = -EINVAL; |
| 4092 | goto exit; |
| 4093 | } |
| 4094 | status = sme_ChangeRoamScanChannelList((tHalHandle)(pHddCtx->hHal), ChannelList, |
| 4095 | numChannels); |
| 4096 | if (eHAL_STATUS_SUCCESS != status) |
| 4097 | { |
| 4098 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4099 | "%s: Failed to update channel list information", __func__); |
| 4100 | ret = -EINVAL; |
| 4101 | goto exit; |
| 4102 | } |
| 4103 | } |
| 4104 | else if (strncmp(command, "GETROAMSCANCHANNELS", 19) == 0) |
| 4105 | { |
| 4106 | tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0}; |
| 4107 | tANI_U8 numChannels = 0; |
Jeff Johnson | 51b6778 | 2013-04-05 12:35:41 -0700 | [diff] [blame] | 4108 | tANI_U8 j = 0; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4109 | char extra[128] = {0}; |
Jeff Johnson | 51b6778 | 2013-04-05 12:35:41 -0700 | [diff] [blame] | 4110 | int len; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4111 | |
| 4112 | if (eHAL_STATUS_SUCCESS != sme_getRoamScanChannelList( (tHalHandle)(pHddCtx->hHal), |
| 4113 | ChannelList, &numChannels )) |
| 4114 | { |
| 4115 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 4116 | "%s: failed to get roam scan channel list", __func__); |
| 4117 | ret = -EFAULT; |
| 4118 | goto exit; |
| 4119 | } |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 4120 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 4121 | TRACE_CODE_HDD_GETROAMSCANCHANNELS_IOCTL, |
| 4122 | pAdapter->sessionId, numChannels)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4123 | /* output channel list is of the format |
| 4124 | [Number of roam scan channels][Channel1][Channel2]... */ |
| 4125 | /* copy the number of channels in the 0th index */ |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 4126 | len = scnprintf(extra, sizeof(extra), "%s %d", command, numChannels); |
Sushant Kaushik | a08ca19 | 2015-09-16 15:52:04 +0530 | [diff] [blame] | 4127 | for (j = 0; (j < numChannels) && len <= sizeof(extra); j++) |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4128 | { |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 4129 | len += scnprintf(extra + len, sizeof(extra) - len, " %d", |
| 4130 | ChannelList[j]); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4131 | } |
| 4132 | |
Sushant Kaushik | c9b8be5 | 2015-07-15 16:41:27 +0530 | [diff] [blame] | 4133 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 4134 | if (copy_to_user(priv_data.buf, &extra, len)) |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4135 | { |
| 4136 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4137 | "%s: failed to copy data to user buffer", __func__); |
| 4138 | ret = -EFAULT; |
| 4139 | goto exit; |
| 4140 | } |
| 4141 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4142 | else if (strncmp(command, "GETCCXMODE", 10) == 0) |
| 4143 | { |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4144 | tANI_BOOLEAN eseMode = sme_getIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal)); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4145 | char extra[32]; |
| 4146 | tANI_U8 len = 0; |
| 4147 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4148 | /* Check if the features OKC/ESE/11R are supported simultaneously, |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 4149 | then this operation is not permitted (return FAILURE) */ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4150 | if (eseMode && |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 4151 | hdd_is_okc_mode_enabled(pHddCtx) && |
| 4152 | sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal))) |
| 4153 | { |
| 4154 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4155 | "%s: OKC/ESE/11R are supported simultaneously" |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 4156 | " hence this operation is not permitted!", __func__); |
| 4157 | ret = -EPERM; |
| 4158 | goto exit; |
| 4159 | } |
| 4160 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 4161 | len = scnprintf(extra, sizeof(extra), "%s %d", |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4162 | "GETCCXMODE", eseMode); |
Sushant Kaushik | f8abd35 | 2015-07-15 16:37:49 +0530 | [diff] [blame] | 4163 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 4164 | if (copy_to_user(priv_data.buf, &extra, len)) |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4165 | { |
| 4166 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4167 | "%s: failed to copy data to user buffer", __func__); |
| 4168 | ret = -EFAULT; |
| 4169 | goto exit; |
| 4170 | } |
| 4171 | } |
| 4172 | else if (strncmp(command, "GETOKCMODE", 10) == 0) |
| 4173 | { |
| 4174 | tANI_BOOLEAN okcMode = hdd_is_okc_mode_enabled(pHddCtx); |
| 4175 | char extra[32]; |
| 4176 | tANI_U8 len = 0; |
| 4177 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4178 | /* Check if the features OKC/ESE/11R are supported simultaneously, |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 4179 | then this operation is not permitted (return FAILURE) */ |
| 4180 | if (okcMode && |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4181 | sme_getIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal)) && |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 4182 | sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal))) |
| 4183 | { |
| 4184 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4185 | "%s: OKC/ESE/11R are supported simultaneously" |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 4186 | " hence this operation is not permitted!", __func__); |
| 4187 | ret = -EPERM; |
| 4188 | goto exit; |
| 4189 | } |
| 4190 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 4191 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 4192 | "GETOKCMODE", okcMode); |
Sushant Kaushik | bc2fb5c | 2015-07-15 16:43:16 +0530 | [diff] [blame] | 4193 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 4194 | if (copy_to_user(priv_data.buf, &extra, len)) |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4195 | { |
| 4196 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4197 | "%s: failed to copy data to user buffer", __func__); |
| 4198 | ret = -EFAULT; |
| 4199 | goto exit; |
| 4200 | } |
| 4201 | } |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 4202 | else if (strncmp(command, "GETFASTROAM", 11) == 0) |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4203 | { |
| 4204 | tANI_BOOLEAN lfrMode = sme_getIsLfrFeatureEnabled((tHalHandle)(pHddCtx->hHal)); |
| 4205 | char extra[32]; |
| 4206 | tANI_U8 len = 0; |
| 4207 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 4208 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 4209 | "GETFASTROAM", lfrMode); |
Sushant Kaushik | 4da7ec9 | 2015-07-15 16:39:32 +0530 | [diff] [blame] | 4210 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 4211 | if (copy_to_user(priv_data.buf, &extra, len)) |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4212 | { |
| 4213 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4214 | "%s: failed to copy data to user buffer", __func__); |
| 4215 | ret = -EFAULT; |
| 4216 | goto exit; |
| 4217 | } |
| 4218 | } |
| 4219 | else if (strncmp(command, "GETFASTTRANSITION", 17) == 0) |
| 4220 | { |
| 4221 | tANI_BOOLEAN ft = sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal)); |
| 4222 | char extra[32]; |
| 4223 | tANI_U8 len = 0; |
| 4224 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 4225 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 4226 | "GETFASTTRANSITION", ft); |
Sushant Kaushik | 231a445 | 2015-07-15 16:23:56 +0530 | [diff] [blame] | 4227 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 4228 | if (copy_to_user(priv_data.buf, &extra, len)) |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4229 | { |
| 4230 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4231 | "%s: failed to copy data to user buffer", __func__); |
| 4232 | ret = -EFAULT; |
| 4233 | goto exit; |
| 4234 | } |
| 4235 | } |
| 4236 | else if (strncmp(command, "SETROAMSCANCHANNELMINTIME", 25) == 0) |
| 4237 | { |
| 4238 | tANI_U8 *value = command; |
| 4239 | tANI_U8 minTime = CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_DEFAULT; |
| 4240 | |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 4241 | ret = hdd_drv_cmd_validate(command, 25); |
| 4242 | if (ret) |
| 4243 | goto exit; |
| 4244 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4245 | /* Move pointer to ahead of SETROAMSCANCHANNELMINTIME<delimiter> */ |
| 4246 | value = value + 26; |
| 4247 | /* Convert the value from ascii to integer */ |
| 4248 | ret = kstrtou8(value, 10, &minTime); |
| 4249 | if (ret < 0) |
| 4250 | { |
| 4251 | /* If the input value is greater than max value of datatype, then also |
| 4252 | kstrtou8 fails */ |
| 4253 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4254 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 4255 | CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MIN, |
| 4256 | CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MAX); |
| 4257 | ret = -EINVAL; |
| 4258 | goto exit; |
| 4259 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4260 | if ((minTime < CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MIN) || |
| 4261 | (minTime > CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MAX)) |
| 4262 | { |
| 4263 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4264 | "scan min channel time value %d is out of range" |
| 4265 | " (Min: %d Max: %d)", minTime, |
| 4266 | CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MIN, |
| 4267 | CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MAX); |
| 4268 | ret = -EINVAL; |
| 4269 | goto exit; |
| 4270 | } |
| 4271 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 4272 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 4273 | TRACE_CODE_HDD_SETROAMSCANCHANNELMINTIME_IOCTL, |
| 4274 | pAdapter->sessionId, minTime)); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4275 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4276 | "%s: Received Command to change channel min time = %d", __func__, minTime); |
| 4277 | |
| 4278 | pHddCtx->cfg_ini->nNeighborScanMinChanTime = minTime; |
| 4279 | sme_setNeighborScanMinChanTime((tHalHandle)(pHddCtx->hHal), minTime); |
| 4280 | } |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4281 | else if (strncmp(command, "SENDACTIONFRAME", 15) == 0) |
| 4282 | { |
| 4283 | tANI_U8 *value = command; |
| 4284 | tANI_U8 channel = 0; |
| 4285 | tANI_U8 dwellTime = 0; |
| 4286 | tANI_U8 bufLen = 0; |
| 4287 | tANI_U8 *buf = NULL; |
| 4288 | tSirMacAddr targetApBssid; |
| 4289 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 4290 | struct ieee80211_channel chan; |
| 4291 | tANI_U8 finalLen = 0; |
| 4292 | tANI_U8 *finalBuf = NULL; |
| 4293 | tANI_U8 temp = 0; |
| 4294 | u64 cookie; |
| 4295 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 4296 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 4297 | |
| 4298 | /* if not associated, no need to send action frame */ |
| 4299 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 4300 | { |
| 4301 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__); |
| 4302 | ret = -EINVAL; |
| 4303 | goto exit; |
| 4304 | } |
| 4305 | |
| 4306 | status = hdd_parse_send_action_frame_data(value, targetApBssid, &channel, |
| 4307 | &dwellTime, &buf, &bufLen); |
| 4308 | if (eHAL_STATUS_SUCCESS != status) |
| 4309 | { |
| 4310 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4311 | "%s: Failed to parse send action frame data", __func__); |
| 4312 | ret = -EINVAL; |
| 4313 | goto exit; |
| 4314 | } |
| 4315 | |
| 4316 | /* if the target bssid is different from currently associated AP, |
| 4317 | then no need to send action frame */ |
| 4318 | if (VOS_TRUE != vos_mem_compare(targetApBssid, |
| 4319 | pHddStaCtx->conn_info.bssId, sizeof(tSirMacAddr))) |
| 4320 | { |
| 4321 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:STA is not associated to this AP!",__func__); |
| 4322 | ret = -EINVAL; |
Jeff Johnson | 11c3315 | 2013-04-16 17:52:40 -0700 | [diff] [blame] | 4323 | vos_mem_free(buf); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 4324 | buf = NULL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4325 | goto exit; |
| 4326 | } |
| 4327 | |
| 4328 | /* if the channel number is different from operating channel then |
| 4329 | no need to send action frame */ |
| 4330 | if (channel != pHddStaCtx->conn_info.operationChannel) |
| 4331 | { |
| 4332 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4333 | "%s: channel(%d) is different from operating channel(%d)", |
| 4334 | __func__, channel, pHddStaCtx->conn_info.operationChannel); |
| 4335 | ret = -EINVAL; |
Jeff Johnson | 11c3315 | 2013-04-16 17:52:40 -0700 | [diff] [blame] | 4336 | vos_mem_free(buf); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 4337 | buf = NULL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4338 | goto exit; |
| 4339 | } |
| 4340 | chan.center_freq = sme_ChnToFreq(channel); |
| 4341 | |
| 4342 | finalLen = bufLen + 24; |
| 4343 | finalBuf = vos_mem_malloc(finalLen); |
| 4344 | if (NULL == finalBuf) |
| 4345 | { |
| 4346 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:memory allocation failed",__func__); |
| 4347 | ret = -ENOMEM; |
Jeff Johnson | 11c3315 | 2013-04-16 17:52:40 -0700 | [diff] [blame] | 4348 | vos_mem_free(buf); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 4349 | buf = NULL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4350 | goto exit; |
| 4351 | } |
| 4352 | vos_mem_zero(finalBuf, finalLen); |
| 4353 | |
| 4354 | /* Fill subtype */ |
| 4355 | temp = SIR_MAC_MGMT_ACTION << 4; |
| 4356 | vos_mem_copy(finalBuf + 0, &temp, sizeof(temp)); |
| 4357 | |
| 4358 | /* Fill type */ |
| 4359 | temp = SIR_MAC_MGMT_FRAME; |
| 4360 | vos_mem_copy(finalBuf + 2, &temp, sizeof(temp)); |
| 4361 | |
| 4362 | /* Fill destination address (bssid of the AP) */ |
| 4363 | vos_mem_copy(finalBuf + 4, targetApBssid, sizeof(targetApBssid)); |
| 4364 | |
Srinivas Girigowda | b27c019 | 2013-06-03 10:19:56 -0700 | [diff] [blame] | 4365 | /* Fill source address (STA mac address) */ |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4366 | vos_mem_copy(finalBuf + 10, pAdapter->macAddressCurrent.bytes, sizeof(pAdapter->macAddressCurrent.bytes)); |
| 4367 | |
Srinivas Girigowda | b27c019 | 2013-06-03 10:19:56 -0700 | [diff] [blame] | 4368 | /* Fill BSSID (AP mac address) */ |
| 4369 | vos_mem_copy(finalBuf + 16, targetApBssid, sizeof(targetApBssid)); |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4370 | |
| 4371 | /* Fill received buffer from 24th address */ |
| 4372 | vos_mem_copy(finalBuf + 24, buf, bufLen); |
| 4373 | |
Jeff Johnson | 11c3315 | 2013-04-16 17:52:40 -0700 | [diff] [blame] | 4374 | /* done with the parsed buffer */ |
| 4375 | vos_mem_free(buf); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 4376 | buf = NULL; |
Jeff Johnson | 11c3315 | 2013-04-16 17:52:40 -0700 | [diff] [blame] | 4377 | |
Anand N Sunkad | e9adb1b | 2015-07-29 09:56:45 +0530 | [diff] [blame] | 4378 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) |
| 4379 | params.chan = &chan; |
| 4380 | params.offchan = 0; |
| 4381 | params.wait = dwellTime; |
| 4382 | params.buf = finalBuf; |
| 4383 | params.len = finalLen; |
| 4384 | params.no_cck = 1; |
| 4385 | params.dont_wait_for_ack = 1; |
| 4386 | ret = wlan_hdd_mgmt_tx(NULL, &pAdapter->wdev, ¶ms, &cookie); |
| 4387 | #else |
DARAM SUDHA | 39eede6 | 2014-02-12 11:16:40 +0530 | [diff] [blame] | 4388 | wlan_hdd_mgmt_tx( NULL, |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 4389 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 4390 | &(pAdapter->wdev), |
| 4391 | #else |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 4392 | pAdapter->dev, |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 4393 | #endif |
| 4394 | &chan, 0, |
| 4395 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)) |
| 4396 | NL80211_CHAN_HT20, 1, |
| 4397 | #endif |
| 4398 | dwellTime, finalBuf, finalLen, 1, |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4399 | 1, &cookie ); |
Anand N Sunkad | e9adb1b | 2015-07-29 09:56:45 +0530 | [diff] [blame] | 4400 | #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)*/ |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4401 | vos_mem_free(finalBuf); |
| 4402 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4403 | else if (strncmp(command, "GETROAMSCANCHANNELMINTIME", 25) == 0) |
| 4404 | { |
| 4405 | tANI_U16 val = sme_getNeighborScanMinChanTime((tHalHandle)(pHddCtx->hHal)); |
| 4406 | char extra[32]; |
| 4407 | tANI_U8 len = 0; |
| 4408 | |
| 4409 | /* value is interms of msec */ |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 4410 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 4411 | "GETROAMSCANCHANNELMINTIME", val); |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 4412 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 4413 | TRACE_CODE_HDD_GETROAMSCANCHANNELMINTIME_IOCTL, |
| 4414 | pAdapter->sessionId, val)); |
Sushant Kaushik | bb8c52c | 2015-07-15 16:36:23 +0530 | [diff] [blame] | 4415 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 4416 | if (copy_to_user(priv_data.buf, &extra, len)) |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4417 | { |
| 4418 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4419 | "%s: failed to copy data to user buffer", __func__); |
| 4420 | ret = -EFAULT; |
| 4421 | goto exit; |
| 4422 | } |
| 4423 | } |
| 4424 | else if (strncmp(command, "SETSCANCHANNELTIME", 18) == 0) |
| 4425 | { |
| 4426 | tANI_U8 *value = command; |
Varun Reddy Yeturu | 3885a66 | 2013-06-19 07:10:37 -0700 | [diff] [blame] | 4427 | tANI_U16 maxTime = CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_DEFAULT; |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4428 | |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 4429 | ret = hdd_drv_cmd_validate(command, 18); |
| 4430 | if (ret) |
| 4431 | goto exit; |
| 4432 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4433 | /* Move pointer to ahead of SETSCANCHANNELTIME<delimiter> */ |
| 4434 | value = value + 19; |
| 4435 | /* Convert the value from ascii to integer */ |
Varun Reddy Yeturu | 3885a66 | 2013-06-19 07:10:37 -0700 | [diff] [blame] | 4436 | ret = kstrtou16(value, 10, &maxTime); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4437 | if (ret < 0) |
| 4438 | { |
| 4439 | /* 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] | 4440 | kstrtou16 fails */ |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4441 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Varun Reddy Yeturu | 3885a66 | 2013-06-19 07:10:37 -0700 | [diff] [blame] | 4442 | "%s: kstrtou16 failed range [%d - %d]", __func__, |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4443 | CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MIN, |
| 4444 | CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MAX); |
| 4445 | ret = -EINVAL; |
| 4446 | goto exit; |
| 4447 | } |
| 4448 | |
| 4449 | if ((maxTime < CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MIN) || |
| 4450 | (maxTime > CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MAX)) |
| 4451 | { |
| 4452 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4453 | "lfr mode value %d is out of range" |
| 4454 | " (Min: %d Max: %d)", maxTime, |
| 4455 | CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MIN, |
| 4456 | CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MAX); |
| 4457 | ret = -EINVAL; |
| 4458 | goto exit; |
| 4459 | } |
| 4460 | |
| 4461 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4462 | "%s: Received Command to change channel max time = %d", __func__, maxTime); |
| 4463 | |
| 4464 | pHddCtx->cfg_ini->nNeighborScanMaxChanTime = maxTime; |
| 4465 | sme_setNeighborScanMaxChanTime((tHalHandle)(pHddCtx->hHal), maxTime); |
| 4466 | } |
| 4467 | else if (strncmp(command, "GETSCANCHANNELTIME", 18) == 0) |
| 4468 | { |
| 4469 | tANI_U16 val = sme_getNeighborScanMaxChanTime((tHalHandle)(pHddCtx->hHal)); |
| 4470 | char extra[32]; |
| 4471 | tANI_U8 len = 0; |
| 4472 | |
| 4473 | /* value is interms of msec */ |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 4474 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 4475 | "GETSCANCHANNELTIME", val); |
Ratheesh S P | acbfa93 | 2015-07-16 15:27:18 +0530 | [diff] [blame] | 4476 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 4477 | if (copy_to_user(priv_data.buf, &extra, len)) |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4478 | { |
| 4479 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4480 | "%s: failed to copy data to user buffer", __func__); |
| 4481 | ret = -EFAULT; |
| 4482 | goto exit; |
| 4483 | } |
| 4484 | } |
| 4485 | else if (strncmp(command, "SETSCANHOMETIME", 15) == 0) |
| 4486 | { |
| 4487 | tANI_U8 *value = command; |
| 4488 | tANI_U16 val = CFG_NEIGHBOR_SCAN_TIMER_PERIOD_DEFAULT; |
| 4489 | |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 4490 | ret = hdd_drv_cmd_validate(command, 15); |
| 4491 | if (ret) |
| 4492 | goto exit; |
| 4493 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4494 | /* Move pointer to ahead of SETSCANHOMETIME<delimiter> */ |
| 4495 | value = value + 16; |
| 4496 | /* Convert the value from ascii to integer */ |
| 4497 | ret = kstrtou16(value, 10, &val); |
| 4498 | if (ret < 0) |
| 4499 | { |
| 4500 | /* If the input value is greater than max value of datatype, then also |
| 4501 | kstrtou16 fails */ |
| 4502 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4503 | "%s: kstrtou16 failed range [%d - %d]", __func__, |
| 4504 | CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MIN, |
| 4505 | CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MAX); |
| 4506 | ret = -EINVAL; |
| 4507 | goto exit; |
| 4508 | } |
| 4509 | |
| 4510 | if ((val < CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MIN) || |
| 4511 | (val > CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MAX)) |
| 4512 | { |
| 4513 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4514 | "scan home time value %d is out of range" |
| 4515 | " (Min: %d Max: %d)", val, |
| 4516 | CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MIN, |
| 4517 | CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MAX); |
| 4518 | ret = -EINVAL; |
| 4519 | goto exit; |
| 4520 | } |
| 4521 | |
| 4522 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4523 | "%s: Received Command to change scan home time = %d", __func__, val); |
| 4524 | |
| 4525 | pHddCtx->cfg_ini->nNeighborScanPeriod = val; |
| 4526 | sme_setNeighborScanPeriod((tHalHandle)(pHddCtx->hHal), val); |
| 4527 | } |
| 4528 | else if (strncmp(command, "GETSCANHOMETIME", 15) == 0) |
| 4529 | { |
| 4530 | tANI_U16 val = sme_getNeighborScanPeriod((tHalHandle)(pHddCtx->hHal)); |
| 4531 | char extra[32]; |
| 4532 | tANI_U8 len = 0; |
| 4533 | |
| 4534 | /* value is interms of msec */ |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 4535 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 4536 | "GETSCANHOMETIME", val); |
Ratheesh S P | 728d7c6 | 2015-07-16 15:38:58 +0530 | [diff] [blame] | 4537 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 4538 | if (copy_to_user(priv_data.buf, &extra, len)) |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4539 | { |
| 4540 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4541 | "%s: failed to copy data to user buffer", __func__); |
| 4542 | ret = -EFAULT; |
| 4543 | goto exit; |
| 4544 | } |
| 4545 | } |
| 4546 | else if (strncmp(command, "SETROAMINTRABAND", 16) == 0) |
| 4547 | { |
| 4548 | tANI_U8 *value = command; |
| 4549 | tANI_U8 val = CFG_ROAM_INTRA_BAND_DEFAULT; |
| 4550 | |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 4551 | ret = hdd_drv_cmd_validate(command, 16); |
| 4552 | if (ret) |
| 4553 | goto exit; |
| 4554 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4555 | /* Move pointer to ahead of SETROAMINTRABAND<delimiter> */ |
| 4556 | value = value + 17; |
| 4557 | /* Convert the value from ascii to integer */ |
| 4558 | ret = kstrtou8(value, 10, &val); |
| 4559 | if (ret < 0) |
| 4560 | { |
| 4561 | /* If the input value is greater than max value of datatype, then also |
| 4562 | kstrtou8 fails */ |
| 4563 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4564 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 4565 | CFG_ROAM_INTRA_BAND_MIN, |
| 4566 | CFG_ROAM_INTRA_BAND_MAX); |
| 4567 | ret = -EINVAL; |
| 4568 | goto exit; |
| 4569 | } |
| 4570 | |
| 4571 | if ((val < CFG_ROAM_INTRA_BAND_MIN) || |
| 4572 | (val > CFG_ROAM_INTRA_BAND_MAX)) |
| 4573 | { |
| 4574 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4575 | "intra band mode value %d is out of range" |
| 4576 | " (Min: %d Max: %d)", val, |
| 4577 | CFG_ROAM_INTRA_BAND_MIN, |
| 4578 | CFG_ROAM_INTRA_BAND_MAX); |
| 4579 | ret = -EINVAL; |
| 4580 | goto exit; |
| 4581 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4582 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4583 | "%s: Received Command to change intra band = %d", __func__, val); |
| 4584 | |
| 4585 | pHddCtx->cfg_ini->nRoamIntraBand = val; |
| 4586 | sme_setRoamIntraBand((tHalHandle)(pHddCtx->hHal), val); |
| 4587 | } |
| 4588 | else if (strncmp(command, "GETROAMINTRABAND", 16) == 0) |
| 4589 | { |
| 4590 | tANI_U16 val = sme_getRoamIntraBand((tHalHandle)(pHddCtx->hHal)); |
| 4591 | char extra[32]; |
| 4592 | tANI_U8 len = 0; |
| 4593 | |
| 4594 | /* value is interms of msec */ |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 4595 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 4596 | "GETROAMINTRABAND", val); |
Ratheesh S P | 2dd2a3e | 2015-07-16 15:34:23 +0530 | [diff] [blame] | 4597 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 4598 | if (copy_to_user(priv_data.buf, &extra, len)) |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4599 | { |
| 4600 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4601 | "%s: failed to copy data to user buffer", __func__); |
| 4602 | ret = -EFAULT; |
| 4603 | goto exit; |
| 4604 | } |
| 4605 | } |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 4606 | else if (strncmp(command, "SETSCANNPROBES", 14) == 0) |
| 4607 | { |
| 4608 | tANI_U8 *value = command; |
| 4609 | tANI_U8 nProbes = CFG_ROAM_SCAN_N_PROBES_DEFAULT; |
| 4610 | |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 4611 | ret = hdd_drv_cmd_validate(command, 14); |
| 4612 | if (ret) |
| 4613 | goto exit; |
| 4614 | |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 4615 | /* Move pointer to ahead of SETSCANNPROBES<delimiter> */ |
| 4616 | value = value + 15; |
| 4617 | /* Convert the value from ascii to integer */ |
| 4618 | ret = kstrtou8(value, 10, &nProbes); |
| 4619 | if (ret < 0) |
| 4620 | { |
| 4621 | /* If the input value is greater than max value of datatype, then also |
| 4622 | kstrtou8 fails */ |
| 4623 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4624 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 4625 | CFG_ROAM_SCAN_N_PROBES_MIN, |
| 4626 | CFG_ROAM_SCAN_N_PROBES_MAX); |
| 4627 | ret = -EINVAL; |
| 4628 | goto exit; |
| 4629 | } |
| 4630 | |
| 4631 | if ((nProbes < CFG_ROAM_SCAN_N_PROBES_MIN) || |
| 4632 | (nProbes > CFG_ROAM_SCAN_N_PROBES_MAX)) |
| 4633 | { |
| 4634 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4635 | "NProbes value %d is out of range" |
| 4636 | " (Min: %d Max: %d)", nProbes, |
| 4637 | CFG_ROAM_SCAN_N_PROBES_MIN, |
| 4638 | CFG_ROAM_SCAN_N_PROBES_MAX); |
| 4639 | ret = -EINVAL; |
| 4640 | goto exit; |
| 4641 | } |
| 4642 | |
| 4643 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4644 | "%s: Received Command to Set nProbes = %d", __func__, nProbes); |
| 4645 | |
| 4646 | pHddCtx->cfg_ini->nProbes = nProbes; |
| 4647 | sme_UpdateRoamScanNProbes((tHalHandle)(pHddCtx->hHal), nProbes); |
| 4648 | } |
Mahesh A Saptasagar | ec7d109 | 2015-04-02 13:41:34 +0530 | [diff] [blame] | 4649 | else if (strncmp(command, "GETSCANNPROBES", 14) == 0) |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 4650 | { |
| 4651 | tANI_U8 val = sme_getRoamScanNProbes((tHalHandle)(pHddCtx->hHal)); |
| 4652 | char extra[32]; |
| 4653 | tANI_U8 len = 0; |
| 4654 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 4655 | len = scnprintf(extra, sizeof(extra), "%s %d", command, val); |
Ratnam Rachuri | 6da525d | 2015-08-07 13:55:54 +0530 | [diff] [blame] | 4656 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 4657 | if (copy_to_user(priv_data.buf, &extra, len)) { |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 4658 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4659 | "%s: failed to copy data to user buffer", __func__); |
| 4660 | ret = -EFAULT; |
| 4661 | goto exit; |
| 4662 | } |
| 4663 | } |
| 4664 | else if (strncmp(command, "SETSCANHOMEAWAYTIME", 19) == 0) |
| 4665 | { |
| 4666 | tANI_U8 *value = command; |
| 4667 | tANI_U16 homeAwayTime = CFG_ROAM_SCAN_HOME_AWAY_TIME_DEFAULT; |
| 4668 | |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 4669 | ret = hdd_drv_cmd_validate(command, 19); |
| 4670 | if (ret) |
| 4671 | goto exit; |
| 4672 | |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 4673 | /* Move pointer to ahead of SETSCANHOMEAWAYTIME<delimiter> */ |
| 4674 | /* input value is in units of msec */ |
| 4675 | value = value + 20; |
| 4676 | /* Convert the value from ascii to integer */ |
| 4677 | ret = kstrtou16(value, 10, &homeAwayTime); |
| 4678 | if (ret < 0) |
| 4679 | { |
| 4680 | /* If the input value is greater than max value of datatype, then also |
| 4681 | kstrtou8 fails */ |
| 4682 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4683 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 4684 | CFG_ROAM_SCAN_HOME_AWAY_TIME_MIN, |
| 4685 | CFG_ROAM_SCAN_HOME_AWAY_TIME_MAX); |
| 4686 | ret = -EINVAL; |
| 4687 | goto exit; |
| 4688 | } |
| 4689 | |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 4690 | if ((homeAwayTime < CFG_ROAM_SCAN_HOME_AWAY_TIME_MIN) || |
| 4691 | (homeAwayTime > CFG_ROAM_SCAN_HOME_AWAY_TIME_MAX)) |
| 4692 | { |
| 4693 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4694 | "homeAwayTime value %d is out of range" |
| 4695 | " (Min: %d Max: %d)", homeAwayTime, |
| 4696 | CFG_ROAM_SCAN_HOME_AWAY_TIME_MIN, |
| 4697 | CFG_ROAM_SCAN_HOME_AWAY_TIME_MAX); |
| 4698 | ret = -EINVAL; |
| 4699 | goto exit; |
| 4700 | } |
| 4701 | |
| 4702 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4703 | "%s: Received Command to Set scan away time = %d", __func__, homeAwayTime); |
Srinivas Girigowda | 6cf0b82 | 2013-06-27 14:00:20 -0700 | [diff] [blame] | 4704 | if (pHddCtx->cfg_ini->nRoamScanHomeAwayTime != homeAwayTime) |
| 4705 | { |
| 4706 | pHddCtx->cfg_ini->nRoamScanHomeAwayTime = homeAwayTime; |
| 4707 | sme_UpdateRoamScanHomeAwayTime((tHalHandle)(pHddCtx->hHal), homeAwayTime, eANI_BOOLEAN_TRUE); |
| 4708 | } |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 4709 | } |
Mahesh A Saptasagar | ec7d109 | 2015-04-02 13:41:34 +0530 | [diff] [blame] | 4710 | else if (strncmp(command, "GETSCANHOMEAWAYTIME", 19) == 0) |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 4711 | { |
| 4712 | tANI_U16 val = sme_getRoamScanHomeAwayTime((tHalHandle)(pHddCtx->hHal)); |
| 4713 | char extra[32]; |
| 4714 | tANI_U8 len = 0; |
| 4715 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 4716 | len = scnprintf(extra, sizeof(extra), "%s %d", command, val); |
Ratnam Rachuri | 51a5ad1 | 2015-08-07 14:06:37 +0530 | [diff] [blame] | 4717 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 4718 | if (copy_to_user(priv_data.buf, &extra, len)) { |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 4719 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4720 | "%s: failed to copy data to user buffer", __func__); |
| 4721 | ret = -EFAULT; |
| 4722 | goto exit; |
| 4723 | } |
| 4724 | } |
| 4725 | else if (strncmp(command, "REASSOC", 7) == 0) |
| 4726 | { |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 4727 | ret = hdd_drv_cmd_validate(command, 7); |
| 4728 | if (ret) |
| 4729 | goto exit; |
| 4730 | |
| 4731 | ret = hdd_parse_reassoc(pAdapter, command, priv_data.total_len); |
Selvaraj, Sridhar | 5aff1ed | 2016-06-18 01:26:23 +0530 | [diff] [blame] | 4732 | if (!ret) |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 4733 | goto exit; |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 4734 | } |
Srinivas Girigowda | ad34ca9 | 2013-10-22 10:54:29 -0700 | [diff] [blame] | 4735 | else if (strncmp(command, "SETWESMODE", 10) == 0) |
| 4736 | { |
| 4737 | tANI_U8 *value = command; |
| 4738 | tANI_BOOLEAN wesMode = CFG_ENABLE_WES_MODE_NAME_DEFAULT; |
| 4739 | |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 4740 | ret = hdd_drv_cmd_validate(command, 10); |
| 4741 | if (ret) |
| 4742 | goto exit; |
| 4743 | |
Srinivas Girigowda | ad34ca9 | 2013-10-22 10:54:29 -0700 | [diff] [blame] | 4744 | /* Move pointer to ahead of SETWESMODE<delimiter> */ |
| 4745 | value = value + 11; |
| 4746 | /* Convert the value from ascii to integer */ |
| 4747 | ret = kstrtou8(value, 10, &wesMode); |
| 4748 | if (ret < 0) |
| 4749 | { |
| 4750 | /* If the input value is greater than max value of datatype, then also |
| 4751 | kstrtou8 fails */ |
| 4752 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4753 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 4754 | CFG_ENABLE_WES_MODE_NAME_MIN, |
| 4755 | CFG_ENABLE_WES_MODE_NAME_MAX); |
| 4756 | ret = -EINVAL; |
| 4757 | goto exit; |
| 4758 | } |
| 4759 | |
| 4760 | if ((wesMode < CFG_ENABLE_WES_MODE_NAME_MIN) || |
| 4761 | (wesMode > CFG_ENABLE_WES_MODE_NAME_MAX)) |
| 4762 | { |
| 4763 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4764 | "WES Mode value %d is out of range" |
| 4765 | " (Min: %d Max: %d)", wesMode, |
| 4766 | CFG_ENABLE_WES_MODE_NAME_MIN, |
| 4767 | CFG_ENABLE_WES_MODE_NAME_MAX); |
| 4768 | ret = -EINVAL; |
| 4769 | goto exit; |
| 4770 | } |
| 4771 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4772 | "%s: Received Command to Set WES Mode rssi diff = %d", __func__, wesMode); |
| 4773 | |
| 4774 | pHddCtx->cfg_ini->isWESModeEnabled = wesMode; |
| 4775 | sme_UpdateWESMode((tHalHandle)(pHddCtx->hHal), wesMode); |
| 4776 | } |
Mahesh A Saptasagar | ec7d109 | 2015-04-02 13:41:34 +0530 | [diff] [blame] | 4777 | else if (strncmp(command, "GETWESMODE", 10) == 0) |
Srinivas Girigowda | ad34ca9 | 2013-10-22 10:54:29 -0700 | [diff] [blame] | 4778 | { |
| 4779 | tANI_BOOLEAN wesMode = sme_GetWESMode((tHalHandle)(pHddCtx->hHal)); |
| 4780 | char extra[32]; |
| 4781 | tANI_U8 len = 0; |
| 4782 | |
Arif Hussain | 826d941 | 2013-11-12 16:44:54 -0800 | [diff] [blame] | 4783 | len = scnprintf(extra, sizeof(extra), "%s %d", command, wesMode); |
Ratnam Rachuri | 8fe90c6 | 2015-08-07 14:03:26 +0530 | [diff] [blame] | 4784 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 4785 | if (copy_to_user(priv_data.buf, &extra, len)) { |
Srinivas Girigowda | ad34ca9 | 2013-10-22 10:54:29 -0700 | [diff] [blame] | 4786 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4787 | "%s: failed to copy data to user buffer", __func__); |
| 4788 | ret = -EFAULT; |
| 4789 | goto exit; |
| 4790 | } |
| 4791 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4792 | #endif /* WLAN_FEATURE_VOWIFI_11R || FEATURE_WLAN_ESE || FEATURE_WLAN_LFR */ |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4793 | #ifdef FEATURE_WLAN_LFR |
| 4794 | else if (strncmp(command, "SETFASTROAM", 11) == 0) |
| 4795 | { |
| 4796 | tANI_U8 *value = command; |
| 4797 | tANI_U8 lfrMode = CFG_LFR_FEATURE_ENABLED_DEFAULT; |
| 4798 | |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 4799 | if (pHddCtx->concurrency_mode == VOS_STA_MON) { |
| 4800 | hddLog(LOGE, |
| 4801 | FL("Roaming is always disabled in STA + MON concurrency")); |
| 4802 | ret = -EINVAL; |
| 4803 | goto exit; |
| 4804 | } |
| 4805 | |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 4806 | ret = hdd_drv_cmd_validate(command, 11); |
| 4807 | if (ret) |
| 4808 | goto exit; |
| 4809 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4810 | /* Move pointer to ahead of SETFASTROAM<delimiter> */ |
| 4811 | value = value + 12; |
| 4812 | /* Convert the value from ascii to integer */ |
| 4813 | ret = kstrtou8(value, 10, &lfrMode); |
| 4814 | if (ret < 0) |
| 4815 | { |
| 4816 | /* If the input value is greater than max value of datatype, then also |
| 4817 | kstrtou8 fails */ |
| 4818 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4819 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 4820 | CFG_LFR_FEATURE_ENABLED_MIN, |
| 4821 | CFG_LFR_FEATURE_ENABLED_MAX); |
| 4822 | ret = -EINVAL; |
| 4823 | goto exit; |
| 4824 | } |
| 4825 | |
| 4826 | if ((lfrMode < CFG_LFR_FEATURE_ENABLED_MIN) || |
| 4827 | (lfrMode > CFG_LFR_FEATURE_ENABLED_MAX)) |
| 4828 | { |
| 4829 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4830 | "lfr mode value %d is out of range" |
| 4831 | " (Min: %d Max: %d)", lfrMode, |
| 4832 | CFG_LFR_FEATURE_ENABLED_MIN, |
| 4833 | CFG_LFR_FEATURE_ENABLED_MAX); |
| 4834 | ret = -EINVAL; |
| 4835 | goto exit; |
| 4836 | } |
| 4837 | |
| 4838 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4839 | "%s: Received Command to change lfr mode = %d", __func__, lfrMode); |
| 4840 | |
| 4841 | pHddCtx->cfg_ini->isFastRoamIniFeatureEnabled = lfrMode; |
| 4842 | sme_UpdateIsFastRoamIniFeatureEnabled((tHalHandle)(pHddCtx->hHal), lfrMode); |
| 4843 | } |
| 4844 | #endif |
| 4845 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 4846 | else if (strncmp(command, "SETFASTTRANSITION", 17) == 0) |
| 4847 | { |
| 4848 | tANI_U8 *value = command; |
| 4849 | tANI_U8 ft = CFG_FAST_TRANSITION_ENABLED_NAME_DEFAULT; |
| 4850 | |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 4851 | ret = hdd_drv_cmd_validate(command, 17); |
| 4852 | if (ret) |
| 4853 | goto exit; |
| 4854 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4855 | /* Move pointer to ahead of SETFASTROAM<delimiter> */ |
| 4856 | value = value + 18; |
| 4857 | /* Convert the value from ascii to integer */ |
| 4858 | ret = kstrtou8(value, 10, &ft); |
| 4859 | if (ret < 0) |
| 4860 | { |
| 4861 | /* If the input value is greater than max value of datatype, then also |
| 4862 | kstrtou8 fails */ |
| 4863 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4864 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 4865 | CFG_FAST_TRANSITION_ENABLED_NAME_MIN, |
| 4866 | CFG_FAST_TRANSITION_ENABLED_NAME_MAX); |
| 4867 | ret = -EINVAL; |
| 4868 | goto exit; |
| 4869 | } |
| 4870 | |
| 4871 | if ((ft < CFG_FAST_TRANSITION_ENABLED_NAME_MIN) || |
| 4872 | (ft > CFG_FAST_TRANSITION_ENABLED_NAME_MAX)) |
| 4873 | { |
| 4874 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4875 | "ft mode value %d is out of range" |
| 4876 | " (Min: %d Max: %d)", ft, |
| 4877 | CFG_FAST_TRANSITION_ENABLED_NAME_MIN, |
| 4878 | CFG_FAST_TRANSITION_ENABLED_NAME_MAX); |
| 4879 | ret = -EINVAL; |
| 4880 | goto exit; |
| 4881 | } |
| 4882 | |
| 4883 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4884 | "%s: Received Command to change ft mode = %d", __func__, ft); |
| 4885 | |
| 4886 | pHddCtx->cfg_ini->isFastTransitionEnabled = ft; |
| 4887 | sme_UpdateFastTransitionEnabled((tHalHandle)(pHddCtx->hHal), ft); |
| 4888 | } |
Padma, Santhosh Kumar | 778d838 | 2015-03-04 17:41:22 +0530 | [diff] [blame] | 4889 | else if (strncmp(command, "SETDFSSCANMODE", 14) == 0) |
| 4890 | { |
| 4891 | tANI_U8 *value = command; |
| 4892 | tANI_U8 dfsScanMode = DFS_CHNL_SCAN_ENABLED_NORMAL; |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 4893 | |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 4894 | ret = hdd_drv_cmd_validate(command, 14); |
| 4895 | if (ret) |
| 4896 | goto exit; |
| 4897 | |
Padma, Santhosh Kumar | 778d838 | 2015-03-04 17:41:22 +0530 | [diff] [blame] | 4898 | /* Move pointer to ahead of SETDFSSCANMODE<delimiter> */ |
| 4899 | value = value + 15; |
| 4900 | /* Convert the value from ascii to integer */ |
| 4901 | ret = kstrtou8(value, 10, &dfsScanMode); |
| 4902 | if (ret < 0) |
| 4903 | { |
| 4904 | /* If the input value is greater than max value of |
| 4905 | datatype, then also kstrtou8 fails |
| 4906 | */ |
| 4907 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4908 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 4909 | CFG_ENABLE_DFS_CHNL_SCAN_MIN, |
| 4910 | CFG_ENABLE_DFS_CHNL_SCAN_MAX); |
| 4911 | ret = -EINVAL; |
| 4912 | goto exit; |
| 4913 | } |
| 4914 | |
| 4915 | if ((dfsScanMode < CFG_ENABLE_DFS_CHNL_SCAN_MIN) || |
| 4916 | (dfsScanMode > CFG_ENABLE_DFS_CHNL_SCAN_MAX)) |
| 4917 | { |
| 4918 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4919 | "dfsScanMode value %d is out of range" |
| 4920 | " (Min: %d Max: %d)", dfsScanMode, |
| 4921 | CFG_ENABLE_DFS_CHNL_SCAN_MIN, |
| 4922 | CFG_ENABLE_DFS_CHNL_SCAN_MAX); |
| 4923 | ret = -EINVAL; |
| 4924 | goto exit; |
| 4925 | } |
| 4926 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4927 | "%s: Received Command to Set DFS Scan Mode = %d", |
| 4928 | __func__, dfsScanMode); |
| 4929 | |
| 4930 | ret = wlan_hdd_handle_dfs_chan_scan(pHddCtx, dfsScanMode); |
| 4931 | } |
| 4932 | else if (strncmp(command, "GETDFSSCANMODE", 14) == 0) |
| 4933 | { |
| 4934 | tANI_U8 dfsScanMode = sme_GetDFSScanMode(pHddCtx->hHal); |
| 4935 | char extra[32]; |
| 4936 | tANI_U8 len = 0; |
| 4937 | |
| 4938 | len = scnprintf(extra, sizeof(extra), "%s %d", command, dfsScanMode); |
Ratheesh S P | 767224e | 2015-07-16 15:35:51 +0530 | [diff] [blame] | 4939 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 4940 | if (copy_to_user(priv_data.buf, &extra, len)) |
Padma, Santhosh Kumar | 778d838 | 2015-03-04 17:41:22 +0530 | [diff] [blame] | 4941 | { |
| 4942 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4943 | "%s: failed to copy data to user buffer", __func__); |
| 4944 | ret = -EFAULT; |
| 4945 | goto exit; |
| 4946 | } |
| 4947 | } |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 4948 | else if (strncmp(command, "FASTREASSOC", 11) == 0) |
| 4949 | { |
Selvaraj, Sridhar | 3714c4d | 2016-06-22 15:19:12 +0530 | [diff] [blame] | 4950 | ret = wlan_hdd_handle_fastreassoc(pAdapter, command); |
| 4951 | if (!ret) |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 4952 | goto exit; |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 4953 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4954 | #endif |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4955 | #ifdef FEATURE_WLAN_ESE |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4956 | else if (strncmp(command, "SETCCXMODE", 10) == 0) |
| 4957 | { |
| 4958 | tANI_U8 *value = command; |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4959 | tANI_U8 eseMode = CFG_ESE_FEATURE_ENABLED_DEFAULT; |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4960 | |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 4961 | ret = hdd_drv_cmd_validate(command, 10); |
| 4962 | if (ret) |
| 4963 | goto exit; |
| 4964 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4965 | /* Check if the features OKC/ESE/11R are supported simultaneously, |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 4966 | then this operation is not permitted (return FAILURE) */ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4967 | if (sme_getIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal)) && |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 4968 | hdd_is_okc_mode_enabled(pHddCtx) && |
| 4969 | sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal))) |
| 4970 | { |
| 4971 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4972 | "%s: OKC/ESE/11R are supported simultaneously" |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 4973 | " hence this operation is not permitted!", __func__); |
| 4974 | ret = -EPERM; |
| 4975 | goto exit; |
| 4976 | } |
| 4977 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4978 | /* Move pointer to ahead of SETCCXMODE<delimiter> */ |
| 4979 | value = value + 11; |
| 4980 | /* Convert the value from ascii to integer */ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4981 | ret = kstrtou8(value, 10, &eseMode); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4982 | if (ret < 0) |
| 4983 | { |
| 4984 | /* If the input value is greater than max value of datatype, then also |
| 4985 | kstrtou8 fails */ |
| 4986 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4987 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4988 | CFG_ESE_FEATURE_ENABLED_MIN, |
| 4989 | CFG_ESE_FEATURE_ENABLED_MAX); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4990 | ret = -EINVAL; |
| 4991 | goto exit; |
| 4992 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4993 | if ((eseMode < CFG_ESE_FEATURE_ENABLED_MIN) || |
| 4994 | (eseMode > CFG_ESE_FEATURE_ENABLED_MAX)) |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4995 | { |
| 4996 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4997 | "Ese mode value %d is out of range" |
| 4998 | " (Min: %d Max: %d)", eseMode, |
| 4999 | CFG_ESE_FEATURE_ENABLED_MIN, |
| 5000 | CFG_ESE_FEATURE_ENABLED_MAX); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 5001 | ret = -EINVAL; |
| 5002 | goto exit; |
| 5003 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 5004 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 5005 | "%s: Received Command to change ese mode = %d", __func__, eseMode); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 5006 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 5007 | pHddCtx->cfg_ini->isEseIniFeatureEnabled = eseMode; |
| 5008 | sme_UpdateIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal), eseMode); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 5009 | } |
| 5010 | #endif |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 5011 | else if (strncmp(command, "SETROAMSCANCONTROL", 18) == 0) |
| 5012 | { |
| 5013 | tANI_U8 *value = command; |
| 5014 | tANI_BOOLEAN roamScanControl = 0; |
| 5015 | |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 5016 | ret = hdd_drv_cmd_validate(command, 18); |
| 5017 | if (ret) |
| 5018 | goto exit; |
| 5019 | |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 5020 | /* Move pointer to ahead of SETROAMSCANCONTROL<delimiter> */ |
| 5021 | value = value + 19; |
| 5022 | /* Convert the value from ascii to integer */ |
| 5023 | ret = kstrtou8(value, 10, &roamScanControl); |
| 5024 | if (ret < 0) |
| 5025 | { |
| 5026 | /* If the input value is greater than max value of datatype, then also |
| 5027 | kstrtou8 fails */ |
| 5028 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5029 | "%s: kstrtou8 failed ", __func__); |
| 5030 | ret = -EINVAL; |
| 5031 | goto exit; |
| 5032 | } |
| 5033 | |
| 5034 | if (0 != roamScanControl) |
| 5035 | { |
| 5036 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5037 | "roam scan control invalid value = %d", |
| 5038 | roamScanControl); |
| 5039 | ret = -EINVAL; |
| 5040 | goto exit; |
| 5041 | } |
| 5042 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5043 | "%s: Received Command to Set roam scan control = %d", __func__, roamScanControl); |
| 5044 | |
| 5045 | sme_SetRoamScanControl((tHalHandle)(pHddCtx->hHal), roamScanControl); |
| 5046 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 5047 | #ifdef FEATURE_WLAN_OKC |
| 5048 | else if (strncmp(command, "SETOKCMODE", 10) == 0) |
| 5049 | { |
| 5050 | tANI_U8 *value = command; |
| 5051 | tANI_U8 okcMode = CFG_OKC_FEATURE_ENABLED_DEFAULT; |
| 5052 | |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 5053 | ret = hdd_drv_cmd_validate(command, 10); |
| 5054 | if (ret) |
| 5055 | goto exit; |
| 5056 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 5057 | /* Check if the features OKC/ESE/11R are supported simultaneously, |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 5058 | then this operation is not permitted (return FAILURE) */ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 5059 | if (sme_getIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal)) && |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 5060 | hdd_is_okc_mode_enabled(pHddCtx) && |
| 5061 | sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal))) |
| 5062 | { |
| 5063 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 5064 | "%s: OKC/ESE/11R are supported simultaneously" |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 5065 | " hence this operation is not permitted!", __func__); |
| 5066 | ret = -EPERM; |
| 5067 | goto exit; |
| 5068 | } |
| 5069 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 5070 | /* Move pointer to ahead of SETOKCMODE<delimiter> */ |
| 5071 | value = value + 11; |
| 5072 | /* Convert the value from ascii to integer */ |
| 5073 | ret = kstrtou8(value, 10, &okcMode); |
| 5074 | if (ret < 0) |
| 5075 | { |
| 5076 | /* If the input value is greater than max value of datatype, then also |
| 5077 | kstrtou8 fails */ |
| 5078 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5079 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 5080 | CFG_OKC_FEATURE_ENABLED_MIN, |
| 5081 | CFG_OKC_FEATURE_ENABLED_MAX); |
| 5082 | ret = -EINVAL; |
| 5083 | goto exit; |
| 5084 | } |
| 5085 | |
| 5086 | if ((okcMode < CFG_OKC_FEATURE_ENABLED_MIN) || |
| 5087 | (okcMode > CFG_OKC_FEATURE_ENABLED_MAX)) |
| 5088 | { |
| 5089 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5090 | "Okc mode value %d is out of range" |
| 5091 | " (Min: %d Max: %d)", okcMode, |
| 5092 | CFG_OKC_FEATURE_ENABLED_MIN, |
| 5093 | CFG_OKC_FEATURE_ENABLED_MAX); |
| 5094 | ret = -EINVAL; |
| 5095 | goto exit; |
| 5096 | } |
| 5097 | |
| 5098 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5099 | "%s: Received Command to change okc mode = %d", __func__, okcMode); |
| 5100 | |
| 5101 | pHddCtx->cfg_ini->isOkcIniFeatureEnabled = okcMode; |
| 5102 | } |
Srinivas Girigowda | ad34ca9 | 2013-10-22 10:54:29 -0700 | [diff] [blame] | 5103 | #endif /* FEATURE_WLAN_OKC */ |
Mahesh A Saptasagar | ec7d109 | 2015-04-02 13:41:34 +0530 | [diff] [blame] | 5104 | else if (strncmp(command, "GETROAMSCANCONTROL", 18) == 0) |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 5105 | { |
| 5106 | tANI_BOOLEAN roamScanControl = sme_GetRoamScanControl((tHalHandle)(pHddCtx->hHal)); |
| 5107 | char extra[32]; |
| 5108 | tANI_U8 len = 0; |
| 5109 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 5110 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 5111 | command, roamScanControl); |
Ratnam Rachuri | 083ada8 | 2015-08-07 14:01:05 +0530 | [diff] [blame] | 5112 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 5113 | if (copy_to_user(priv_data.buf, &extra, len)) { |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 5114 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5115 | "%s: failed to copy data to user buffer", __func__); |
| 5116 | ret = -EFAULT; |
| 5117 | goto exit; |
| 5118 | } |
| 5119 | } |
Gopichand Nakkala | 227c7f3 | 2013-06-26 22:44:57 +0530 | [diff] [blame] | 5120 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 5121 | else if (strncmp(command, "ENABLE_PKTFILTER_IPV6", 21) == 0) |
| 5122 | { |
| 5123 | tANI_U8 filterType = 0; |
| 5124 | tANI_U8 *value = command; |
| 5125 | |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 5126 | ret = hdd_drv_cmd_validate(command, 21); |
| 5127 | if (ret) |
| 5128 | goto exit; |
| 5129 | |
Gopichand Nakkala | 227c7f3 | 2013-06-26 22:44:57 +0530 | [diff] [blame] | 5130 | /* Move pointer to ahead of ENABLE_PKTFILTER_IPV6<delimiter> */ |
| 5131 | value = value + 22; |
| 5132 | |
| 5133 | /* Convert the value from ascii to integer */ |
| 5134 | ret = kstrtou8(value, 10, &filterType); |
| 5135 | if (ret < 0) |
| 5136 | { |
| 5137 | /* If the input value is greater than max value of datatype, |
| 5138 | * then also kstrtou8 fails |
| 5139 | */ |
| 5140 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5141 | "%s: kstrtou8 failed range ", __func__); |
| 5142 | ret = -EINVAL; |
| 5143 | goto exit; |
| 5144 | } |
| 5145 | |
| 5146 | if (filterType != 0 && filterType != 1) |
| 5147 | { |
| 5148 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5149 | "%s: Accepted Values are 0 and 1 ", __func__); |
| 5150 | ret = -EINVAL; |
| 5151 | goto exit; |
| 5152 | } |
| 5153 | wlan_hdd_setIPv6Filter(WLAN_HDD_GET_CTX(pAdapter), filterType, |
| 5154 | pAdapter->sessionId); |
| 5155 | } |
| 5156 | #endif |
Sundaresan Ramachandran | 76e48e8 | 2013-07-15 13:07:17 +0530 | [diff] [blame] | 5157 | else if (strncmp(command, "BTCOEXMODE", 10) == 0 ) |
| 5158 | { |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 5159 | char *dhcpPhase; |
Satyanarayana Dash | 1faea4f | 2014-09-22 16:21:04 +0530 | [diff] [blame] | 5160 | int ret; |
| 5161 | |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 5162 | ret = hdd_drv_cmd_validate(command, 10); |
| 5163 | if (ret) |
| 5164 | goto exit; |
| 5165 | |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 5166 | dhcpPhase = command + 11; |
| 5167 | if ('1' == *dhcpPhase) |
Sundaresan Ramachandran | 76e48e8 | 2013-07-15 13:07:17 +0530 | [diff] [blame] | 5168 | { |
Deepthi Gowri | bfd1713 | 2014-11-14 17:59:04 +0530 | [diff] [blame] | 5169 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 5170 | FL("send DHCP START indication")); |
c_hpothu | 9b781ba | 2013-12-30 20:57:45 +0530 | [diff] [blame] | 5171 | |
| 5172 | pHddCtx->btCoexModeSet = TRUE; |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 5173 | |
Satyanarayana Dash | 1faea4f | 2014-09-22 16:21:04 +0530 | [diff] [blame] | 5174 | ret = wlan_hdd_scan_abort(pAdapter); |
| 5175 | if (ret < 0) |
| 5176 | { |
| 5177 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5178 | FL("failed to abort existing scan %d"), ret); |
| 5179 | } |
| 5180 | |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 5181 | sme_DHCPStartInd(pHddCtx->hHal, pAdapter->device_mode, |
| 5182 | pAdapter->sessionId); |
Sundaresan Ramachandran | 76e48e8 | 2013-07-15 13:07:17 +0530 | [diff] [blame] | 5183 | } |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 5184 | else if ('2' == *dhcpPhase) |
Sundaresan Ramachandran | 76e48e8 | 2013-07-15 13:07:17 +0530 | [diff] [blame] | 5185 | { |
Deepthi Gowri | bfd1713 | 2014-11-14 17:59:04 +0530 | [diff] [blame] | 5186 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 5187 | FL("send DHCP STOP indication")); |
c_hpothu | 9b781ba | 2013-12-30 20:57:45 +0530 | [diff] [blame] | 5188 | |
| 5189 | pHddCtx->btCoexModeSet = FALSE; |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 5190 | |
| 5191 | sme_DHCPStopInd(pHddCtx->hHal, pAdapter->device_mode, |
| 5192 | pAdapter->sessionId); |
Sundaresan Ramachandran | 76e48e8 | 2013-07-15 13:07:17 +0530 | [diff] [blame] | 5193 | } |
| 5194 | } |
Jeff Johnson | f54df2c | 2013-07-24 11:43:39 -0700 | [diff] [blame] | 5195 | else if (strncmp(command, "SCAN-ACTIVE", 11) == 0) |
| 5196 | { |
Abhishek Singh | 58749d6 | 2016-02-03 15:27:20 +0530 | [diff] [blame] | 5197 | hddLog(LOG1, |
| 5198 | FL("making default scan to ACTIVE")); |
c_hpothu | dbefd3e | 2014-04-28 15:59:47 +0530 | [diff] [blame] | 5199 | pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN; |
Jeff Johnson | f54df2c | 2013-07-24 11:43:39 -0700 | [diff] [blame] | 5200 | } |
| 5201 | else if (strncmp(command, "SCAN-PASSIVE", 12) == 0) |
| 5202 | { |
Abhishek Singh | 58749d6 | 2016-02-03 15:27:20 +0530 | [diff] [blame] | 5203 | hddLog(LOG1, |
| 5204 | FL("making default scan to PASSIVE")); |
c_hpothu | dbefd3e | 2014-04-28 15:59:47 +0530 | [diff] [blame] | 5205 | pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN; |
Jeff Johnson | f54df2c | 2013-07-24 11:43:39 -0700 | [diff] [blame] | 5206 | } |
Hanumantha Reddy Pothula | 212243c | 2013-08-01 17:28:31 +0530 | [diff] [blame] | 5207 | else if (strncmp(command, "GETDWELLTIME", 12) == 0) |
| 5208 | { |
| 5209 | hdd_config_t *pCfg = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini; |
| 5210 | char extra[32]; |
| 5211 | tANI_U8 len = 0; |
| 5212 | |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 5213 | memset(extra, 0, sizeof(extra)); |
| 5214 | ret = hdd_get_dwell_time(pCfg, command, extra, sizeof(extra), &len); |
Ratnam Rachuri | 12d5d46 | 2015-08-07 14:10:23 +0530 | [diff] [blame] | 5215 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 5216 | if (ret != 0 || copy_to_user(priv_data.buf, &extra, len)) { |
Hanumantha Reddy Pothula | 212243c | 2013-08-01 17:28:31 +0530 | [diff] [blame] | 5217 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5218 | "%s: failed to copy data to user buffer", __func__); |
| 5219 | ret = -EFAULT; |
| 5220 | goto exit; |
| 5221 | } |
| 5222 | ret = len; |
| 5223 | } |
| 5224 | else if (strncmp(command, "SETDWELLTIME", 12) == 0) |
| 5225 | { |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 5226 | ret = hdd_set_dwell_time(pAdapter, command); |
Hanumantha Reddy Pothula | 212243c | 2013-08-01 17:28:31 +0530 | [diff] [blame] | 5227 | } |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 5228 | else if ( strncasecmp(command, "MIRACAST", 8) == 0 ) |
| 5229 | { |
| 5230 | tANI_U8 filterType = 0; |
| 5231 | tANI_U8 *value; |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 5232 | |
| 5233 | ret = hdd_drv_cmd_validate(command, 8); |
| 5234 | if (ret) |
| 5235 | goto exit; |
| 5236 | |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 5237 | value = command + 9; |
| 5238 | |
| 5239 | /* Convert the value from ascii to integer */ |
| 5240 | ret = kstrtou8(value, 10, &filterType); |
| 5241 | if (ret < 0) |
| 5242 | { |
| 5243 | /* If the input value is greater than max value of datatype, |
| 5244 | * then also kstrtou8 fails |
| 5245 | */ |
| 5246 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5247 | "%s: kstrtou8 failed range ", __func__); |
| 5248 | ret = -EINVAL; |
| 5249 | goto exit; |
| 5250 | } |
| 5251 | if ((filterType < WLAN_HDD_DRIVER_MIRACAST_CFG_MIN_VAL ) || |
| 5252 | (filterType > WLAN_HDD_DRIVER_MIRACAST_CFG_MAX_VAL)) |
| 5253 | { |
| 5254 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5255 | "%s: Accepted Values are 0 to 2. 0-Disabled, 1-Source," |
| 5256 | " 2-Sink ", __func__); |
| 5257 | ret = -EINVAL; |
| 5258 | goto exit; |
| 5259 | } |
| 5260 | //Filtertype value should be either 0-Disabled, 1-Source, 2-sink |
| 5261 | pHddCtx->drvr_miracast = filterType; |
Kaushik, Sushant | 9612244 | 2014-10-21 16:40:18 +0530 | [diff] [blame] | 5262 | pScanInfo = &pHddCtx->scan_info; |
| 5263 | if (filterType && pScanInfo != NULL && |
| 5264 | pHddCtx->scan_info.mScanPending) |
| 5265 | { |
| 5266 | /*Miracast Session started. Abort Scan */ |
| 5267 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5268 | "%s, Aborting Scan For Miracast",__func__); |
| 5269 | hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId, |
| 5270 | eCSR_SCAN_ABORT_DEFAULT); |
| 5271 | } |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 5272 | hdd_tx_rx_pkt_cnt_stat_timer_handler(pHddCtx); |
Ganesh Kondabattini | 8f6e3b3 | 2014-08-25 16:07:54 +0530 | [diff] [blame] | 5273 | sme_SetMiracastMode(pHddCtx->hHal, pHddCtx->drvr_miracast); |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 5274 | } |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 5275 | else if (strncmp(command, "SETMCRATE", 9) == 0) |
| 5276 | { |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 5277 | tANI_U8 *value = command; |
| 5278 | int targetRate; |
Leo Chang | 1f98cbd | 2013-10-17 15:03:52 -0700 | [diff] [blame] | 5279 | tSirRateUpdateInd *rateUpdate; |
| 5280 | eHalStatus status; |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 5281 | |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 5282 | ret = hdd_drv_cmd_validate(command, 9); |
| 5283 | if (ret) |
| 5284 | goto exit; |
| 5285 | |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 5286 | /* Only valid for SAP mode */ |
| 5287 | if (WLAN_HDD_SOFTAP != pAdapter->device_mode) |
| 5288 | { |
| 5289 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5290 | "%s: SAP mode is not running", __func__); |
| 5291 | ret = -EFAULT; |
| 5292 | goto exit; |
| 5293 | } |
| 5294 | |
| 5295 | /* Move pointer to ahead of SETMCRATE<delimiter> */ |
| 5296 | /* input value is in units of hundred kbps */ |
| 5297 | value = value + 10; |
| 5298 | /* Convert the value from ascii to integer, decimal base */ |
| 5299 | ret = kstrtouint(value, 10, &targetRate); |
| 5300 | |
Leo Chang | 1f98cbd | 2013-10-17 15:03:52 -0700 | [diff] [blame] | 5301 | rateUpdate = (tSirRateUpdateInd *)vos_mem_malloc(sizeof(tSirRateUpdateInd)); |
| 5302 | if (NULL == rateUpdate) |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 5303 | { |
Leo Chang | 1f98cbd | 2013-10-17 15:03:52 -0700 | [diff] [blame] | 5304 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5305 | "%s: SETMCRATE indication alloc fail", __func__); |
| 5306 | ret = -EFAULT; |
| 5307 | goto exit; |
| 5308 | } |
| 5309 | vos_mem_zero(rateUpdate, sizeof(tSirRateUpdateInd )); |
| 5310 | |
| 5311 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5312 | "MC Target rate %d", targetRate); |
| 5313 | /* Ignore unicast */ |
| 5314 | rateUpdate->ucastDataRate = -1; |
| 5315 | rateUpdate->mcastDataRate24GHz = targetRate; |
| 5316 | rateUpdate->mcastDataRate5GHz = targetRate; |
| 5317 | rateUpdate->mcastDataRate24GHzTxFlag = 0; |
| 5318 | rateUpdate->mcastDataRate5GHzTxFlag = 0; |
| 5319 | status = sme_SendRateUpdateInd(pHddCtx->hHal, rateUpdate); |
| 5320 | if (eHAL_STATUS_SUCCESS != status) |
| 5321 | { |
| 5322 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5323 | "%s: SET_MC_RATE failed", __func__); |
| 5324 | vos_mem_free(rateUpdate); |
| 5325 | ret = -EFAULT; |
| 5326 | goto exit; |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 5327 | } |
| 5328 | } |
jge | 3556720 | 2017-06-21 16:39:38 +0800 | [diff] [blame] | 5329 | else if (strncmp(command, "MAXTXPOWER", 10) == 0) |
| 5330 | { |
| 5331 | int status; |
| 5332 | int txPower; |
| 5333 | eHalStatus smeStatus; |
| 5334 | tANI_U8 *value = command; |
| 5335 | tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
| 5336 | tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
| 5337 | |
| 5338 | status = hdd_parse_setmaxtxpower_command(value, &txPower); |
| 5339 | if (status) |
| 5340 | { |
| 5341 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5342 | "Invalid MAXTXPOWER command "); |
| 5343 | ret = -EINVAL; |
| 5344 | goto exit; |
| 5345 | } |
| 5346 | |
| 5347 | hddLog(VOS_TRACE_LEVEL_INFO, "max tx power %d selfMac: " |
| 5348 | MAC_ADDRESS_STR " bssId: " MAC_ADDRESS_STR " ", |
| 5349 | txPower, MAC_ADDR_ARRAY(selfMac), |
| 5350 | MAC_ADDR_ARRAY(bssid)); |
| 5351 | smeStatus = sme_SetMaxTxPower((tHalHandle)(pHddCtx->hHal), |
| 5352 | bssid, selfMac, txPower) ; |
| 5353 | if( smeStatus != eHAL_STATUS_SUCCESS ) |
| 5354 | { |
| 5355 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s:Set max tx power failed", |
| 5356 | __func__); |
| 5357 | ret = -EINVAL; |
| 5358 | goto exit; |
| 5359 | } |
| 5360 | |
| 5361 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set max tx power success", |
| 5362 | __func__); |
| 5363 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 5364 | #ifdef FEATURE_WLAN_BATCH_SCAN |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 5365 | else if (strncmp(command, "WLS_BATCHING", 12) == 0) |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 5366 | { |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 5367 | ret = hdd_handle_batch_scan_ioctl(pAdapter, &priv_data, command); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 5368 | } |
| 5369 | #endif |
Abhishek Singh | 00b7197 | 2016-01-07 10:51:04 +0530 | [diff] [blame] | 5370 | #ifdef WLAN_FEATURE_RMC |
| 5371 | else if ((strncasecmp(command, "SETIBSSBEACONOUIDATA", 20) == 0) && |
| 5372 | (WLAN_HDD_IBSS == pAdapter->device_mode)) |
| 5373 | { |
| 5374 | int i = 0; |
| 5375 | tANI_U8 *ibss_ie; |
| 5376 | tANI_U32 command_len; |
| 5377 | tANI_U8 *value = command; |
| 5378 | tHalHandle hHal = pHddCtx->hHal; |
| 5379 | tpAniSirGlobal pMac = PMAC_STRUCT(hHal); |
| 5380 | tANI_U32 ibss_ie_length; |
| 5381 | tANI_U32 len, present; |
| 5382 | tANI_U8 *addIE; |
| 5383 | tANI_U8 *addIEData; |
| 5384 | |
| 5385 | hddLog(LOG1, |
| 5386 | FL(" received command %s"),((char *) value)); |
| 5387 | /* validate argument of command */ |
| 5388 | if (strlen(value) <= 21) |
| 5389 | { |
| 5390 | hddLog(LOGE, |
| 5391 | FL("No arguements in command length %zu"), strlen(value)); |
| 5392 | ret = -EFAULT; |
| 5393 | goto exit; |
| 5394 | } |
| 5395 | |
| 5396 | /* moving to arguments of commands */ |
| 5397 | value = value + 21; |
| 5398 | command_len = strlen(value); |
| 5399 | |
| 5400 | /* oui_data can't be less than 3 bytes */ |
| 5401 | if (command_len <= (2 * WLAN_HDD_IBSS_MIN_OUI_DATA_LENGTH)) |
| 5402 | { |
| 5403 | hddLog(LOGE, |
| 5404 | FL("Invalid SETIBSSBEACONOUIDATA command length %d"), |
| 5405 | command_len); |
| 5406 | ret = -EFAULT; |
| 5407 | goto exit; |
| 5408 | } |
| 5409 | ibss_ie = vos_mem_malloc(command_len); |
| 5410 | if (!ibss_ie) { |
| 5411 | hddLog(LOGE, |
| 5412 | FL("Could not allocate memory for command length %d"), |
| 5413 | command_len); |
| 5414 | ret = -ENOMEM; |
| 5415 | goto exit; |
| 5416 | } |
| 5417 | vos_mem_zero(ibss_ie, command_len); |
| 5418 | |
| 5419 | ibss_ie_length = hdd_parse_set_ibss_oui_data_command(value, ibss_ie, |
| 5420 | command_len); |
| 5421 | if (ibss_ie_length < (2 * WLAN_HDD_IBSS_MIN_OUI_DATA_LENGTH)) { |
| 5422 | hddLog(LOGE, FL("Could not parse command %s return length %d"), |
| 5423 | value, ibss_ie_length); |
| 5424 | ret = -EFAULT; |
| 5425 | vos_mem_free(ibss_ie); |
| 5426 | goto exit; |
| 5427 | } |
| 5428 | |
| 5429 | hddLog(LOG1, FL("ibss_ie length %d ibss_ie:"), ibss_ie_length); |
| 5430 | while (i < ibss_ie_length) |
| 5431 | hddLog(LOG1, FL("0x%x"), ibss_ie[i++]); |
| 5432 | |
| 5433 | /* Populate Vendor IE in Beacon */ |
| 5434 | if ((ccmCfgGetInt(hHal, |
| 5435 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, |
| 5436 | &present)) != eHAL_STATUS_SUCCESS) |
| 5437 | { |
| 5438 | hddLog(LOGE, |
| 5439 | FL("unable to ftch WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG")); |
| 5440 | ret = -EFAULT; |
| 5441 | vos_mem_free(ibss_ie); |
| 5442 | goto exit; |
| 5443 | } |
| 5444 | |
| 5445 | addIE = vos_mem_malloc(WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA_LEN); |
| 5446 | if (!addIE) { |
| 5447 | hddLog(LOGE, |
| 5448 | FL("Could not allocate memory for command length %d"), |
| 5449 | command_len); |
| 5450 | vos_mem_free(ibss_ie); |
| 5451 | ret = -ENOMEM; |
| 5452 | goto exit; |
| 5453 | } |
| 5454 | vos_mem_zero(addIE, WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA_LEN); |
| 5455 | |
| 5456 | if (present) |
| 5457 | { |
| 5458 | if ((wlan_cfgGetStrLen(pMac, |
| 5459 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, &len)) != eSIR_SUCCESS) |
| 5460 | { |
| 5461 | hddLog(LOGE, |
| 5462 | FL("unable to fetch WNI_CFG_PROBE_RSP_BCN_ADDNIE_LEN")); |
| 5463 | ret = -EFAULT; |
| 5464 | vos_mem_free(ibss_ie); |
| 5465 | vos_mem_free(addIE); |
| 5466 | goto exit; |
| 5467 | } |
| 5468 | |
| 5469 | if (len <= WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA_LEN && len && |
| 5470 | ((len + ibss_ie_length) <= |
| 5471 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA_LEN)) |
| 5472 | { |
| 5473 | if ((ccmCfgGetStr(hHal, |
| 5474 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, addIE, &len)) |
| 5475 | != eHAL_STATUS_SUCCESS) |
| 5476 | { |
| 5477 | hddLog(LOGE, |
| 5478 | FL("unable to fetch WNI_PROBE_RSP_BCN_ADDNIE_DATA")); |
| 5479 | ret = -EFAULT; |
| 5480 | vos_mem_free(ibss_ie); |
| 5481 | vos_mem_free(addIE); |
| 5482 | goto exit; |
| 5483 | } |
| 5484 | else |
| 5485 | { |
| 5486 | /* Curruntly only WPA IE is added before Vendor IE |
| 5487 | * so we can blindly place the Vendor IE after WPA |
| 5488 | * IE. If no WPA IE found replace all with Vendor IE. |
| 5489 | */ |
| 5490 | len = hdd_find_ibss_wpa_ie_pos(addIE, len); |
| 5491 | } |
| 5492 | } |
| 5493 | else |
| 5494 | { |
| 5495 | hddLog(LOGE, |
| 5496 | FL("IE len exceed limit len %d,ibss_ie_length %d "), |
| 5497 | len, ibss_ie_length); |
| 5498 | ret = -EFAULT; |
| 5499 | vos_mem_free(addIE); |
| 5500 | vos_mem_free(ibss_ie); |
| 5501 | goto exit; |
| 5502 | } |
| 5503 | } |
| 5504 | else { |
| 5505 | len = 0; |
| 5506 | } |
| 5507 | |
| 5508 | vos_mem_copy (addIE + len , ibss_ie, ibss_ie_length); |
| 5509 | len += ibss_ie_length; |
| 5510 | |
| 5511 | if (ccmCfgSetStr(hHal, |
| 5512 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, addIE, len, NULL, |
| 5513 | eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS) |
| 5514 | { |
| 5515 | hddLog(LOGE, |
| 5516 | FL("unable to set WNI_CFG_PRBE_RSP_BCN_ADDNIE_DATA")); |
| 5517 | ret = -EFAULT; |
| 5518 | vos_mem_free(ibss_ie); |
| 5519 | vos_mem_free(addIE); |
| 5520 | goto exit; |
| 5521 | } |
| 5522 | vos_mem_free(addIE); |
| 5523 | if (ccmCfgSetInt(hHal, |
| 5524 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL, |
| 5525 | eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS) |
| 5526 | { |
| 5527 | hddLog(LOGE, |
| 5528 | FL("unble to set WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG")); |
| 5529 | ret = -EFAULT; |
| 5530 | vos_mem_free(ibss_ie); |
| 5531 | goto exit; |
| 5532 | } |
| 5533 | |
| 5534 | /* Populate Vendor IE in probe resp */ |
| 5535 | if ((ccmCfgGetInt(hHal, |
| 5536 | WNI_CFG_PROBE_RSP_ADDNIE_FLAG, |
| 5537 | &present)) != eHAL_STATUS_SUCCESS) |
| 5538 | { |
| 5539 | hddLog(LOGE, |
| 5540 | FL("unable to fetch WNI_CFG_PROBE_RSP_ADDNIE_FLAG")); |
| 5541 | ret = -EFAULT; |
| 5542 | vos_mem_free(ibss_ie); |
| 5543 | goto exit; |
| 5544 | } |
| 5545 | |
| 5546 | addIEData = vos_mem_malloc(WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN); |
| 5547 | if (!addIEData) { |
| 5548 | hddLog(LOGE, |
| 5549 | FL("Could not allocate memory for command length %d"), |
| 5550 | command_len); |
| 5551 | vos_mem_free(ibss_ie); |
| 5552 | ret = -ENOMEM; |
| 5553 | goto exit; |
| 5554 | } |
| 5555 | vos_mem_zero(addIEData, WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN); |
| 5556 | |
| 5557 | if (present) { |
| 5558 | if (eSIR_SUCCESS != wlan_cfgGetStrLen(pMac, |
| 5559 | WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &len)) { |
| 5560 | hddLog(LOGE, |
| 5561 | FL("unable to fetch WNI_CFG_PROBE_RSP_ADDNIE_DATA1")); |
| 5562 | ret = -EFAULT; |
| 5563 | vos_mem_free(ibss_ie); |
| 5564 | vos_mem_free(addIEData); |
| 5565 | goto exit; |
| 5566 | } |
| 5567 | if (len < WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN && len && |
| 5568 | (ibss_ie_length + len) <= |
| 5569 | WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN) { |
| 5570 | |
| 5571 | if ((ccmCfgGetStr(hHal, |
| 5572 | WNI_CFG_PROBE_RSP_ADDNIE_DATA1, addIEData, &len)) |
| 5573 | != eHAL_STATUS_SUCCESS) { |
| 5574 | hddLog(LOGE, |
| 5575 | FL("unable fetch WNI_CFG_PROBE_RSP_ADDNIE_DATA1")); |
| 5576 | ret = -EFAULT; |
| 5577 | vos_mem_free(ibss_ie); |
| 5578 | vos_mem_free(addIEData); |
| 5579 | goto exit; |
| 5580 | } |
| 5581 | else { |
| 5582 | /* Curruntly only WPA IE is added before Vendor IE |
| 5583 | * so we can blindly place the Vendor IE after WPA |
| 5584 | * IE. If no WPA IE found replace all with Vendor IE. |
| 5585 | */ |
| 5586 | len = hdd_find_ibss_wpa_ie_pos(addIEData, len); |
| 5587 | } |
| 5588 | } |
| 5589 | else |
| 5590 | { |
| 5591 | hddLog(LOGE, |
| 5592 | FL("IE len exceed limit len %d,ibss_ie_length %d "), |
| 5593 | len, ibss_ie_length); |
| 5594 | ret = -EFAULT; |
| 5595 | vos_mem_free(addIEData); |
| 5596 | vos_mem_free(ibss_ie); |
| 5597 | goto exit; |
| 5598 | } |
| 5599 | } /* probe rsp ADD IE present */ |
| 5600 | else { |
| 5601 | /* probe rsp add IE is not present */ |
| 5602 | len = 0; |
| 5603 | } |
| 5604 | |
| 5605 | vos_mem_copy(addIEData +len , ibss_ie, ibss_ie_length); |
| 5606 | len += ibss_ie_length; |
| 5607 | |
| 5608 | vos_mem_free(ibss_ie); |
| 5609 | |
| 5610 | if (ccmCfgSetStr(hHal, |
| 5611 | WNI_CFG_PROBE_RSP_ADDNIE_DATA1, |
| 5612 | (tANI_U8*)(addIEData), |
| 5613 | len, NULL, |
| 5614 | eANI_BOOLEAN_FALSE) |
| 5615 | == eHAL_STATUS_FAILURE) { |
| 5616 | hddLog(LOGE, |
| 5617 | FL("unable to copy to WNI_CFG_PROBE_RSP_ADDNIE_DATA1")); |
| 5618 | ret = -EFAULT; |
| 5619 | vos_mem_free(addIEData); |
| 5620 | goto exit; |
| 5621 | } |
| 5622 | vos_mem_free(addIEData); |
| 5623 | if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 5624 | WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL, |
| 5625 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 5626 | { |
| 5627 | hddLog(LOGE, |
| 5628 | FL("unable to copy WNI_CFG_PROBE_RSP_ADDNIE_FLAG")); |
| 5629 | ret = -EFAULT; |
| 5630 | goto exit; |
| 5631 | } |
| 5632 | } |
| 5633 | else if (strncasecmp(command, "SETRMCENABLE", 12) == 0) |
| 5634 | { |
| 5635 | tANI_U8 *value = command; |
| 5636 | tANI_U8 ucRmcEnable = 0; |
| 5637 | int status; |
| 5638 | |
| 5639 | if ((WLAN_HDD_IBSS != pAdapter->device_mode) && |
| 5640 | (WLAN_HDD_SOFTAP != pAdapter->device_mode)) |
| 5641 | { |
| 5642 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5643 | "Received SETRMCENABLE command in invalid mode %d " |
| 5644 | "SETRMCENABLE command is only allowed in IBSS or SOFTAP mode", |
| 5645 | pAdapter->device_mode); |
| 5646 | ret = -EINVAL; |
| 5647 | goto exit; |
| 5648 | } |
| 5649 | |
| 5650 | status = hdd_parse_setrmcenable_command(value, &ucRmcEnable); |
| 5651 | if (status) |
| 5652 | { |
| 5653 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5654 | "Invalid SETRMCENABLE command "); |
| 5655 | ret = -EINVAL; |
| 5656 | goto exit; |
| 5657 | } |
| 5658 | |
| 5659 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5660 | "%s: ucRmcEnable %d ", __func__, ucRmcEnable); |
| 5661 | |
| 5662 | if (TRUE == ucRmcEnable) |
| 5663 | { |
| 5664 | status = sme_EnableRMC( (tHalHandle)(pHddCtx->hHal), |
| 5665 | pAdapter->sessionId ); |
| 5666 | } |
| 5667 | else if(FALSE == ucRmcEnable) |
| 5668 | { |
| 5669 | status = sme_DisableRMC( (tHalHandle)(pHddCtx->hHal), |
| 5670 | pAdapter->sessionId ); |
| 5671 | } |
| 5672 | else |
| 5673 | { |
| 5674 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5675 | "Invalid SETRMCENABLE command %d", ucRmcEnable); |
| 5676 | ret = -EINVAL; |
| 5677 | goto exit; |
| 5678 | } |
| 5679 | |
| 5680 | if (VOS_STATUS_SUCCESS != status) |
| 5681 | { |
| 5682 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5683 | "%s: SETRMC %d failed status %d", __func__, ucRmcEnable, |
| 5684 | status); |
| 5685 | ret = -EINVAL; |
| 5686 | goto exit; |
| 5687 | } |
| 5688 | } |
| 5689 | else if (strncasecmp(command, "SETRMCACTIONPERIOD", 18) == 0) |
| 5690 | { |
| 5691 | tANI_U8 *value = command; |
| 5692 | tANI_U32 uActionPeriod = 0; |
| 5693 | int status; |
| 5694 | |
| 5695 | if ((WLAN_HDD_IBSS != pAdapter->device_mode) && |
| 5696 | (WLAN_HDD_SOFTAP != pAdapter->device_mode)) |
| 5697 | { |
| 5698 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5699 | "Received SETRMC command in invalid mode %d " |
| 5700 | "SETRMC command is only allowed in IBSS or SOFTAP mode", |
| 5701 | pAdapter->device_mode); |
| 5702 | ret = -EINVAL; |
| 5703 | goto exit; |
| 5704 | } |
| 5705 | |
| 5706 | status = hdd_parse_setrmcactionperiod_command(value, &uActionPeriod); |
| 5707 | if (status) |
| 5708 | { |
| 5709 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5710 | "Invalid SETRMCACTIONPERIOD command "); |
| 5711 | ret = -EINVAL; |
| 5712 | goto exit; |
| 5713 | } |
| 5714 | |
| 5715 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5716 | "%s: uActionPeriod %d ", __func__, uActionPeriod); |
| 5717 | |
| 5718 | if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_RMC_ACTION_PERIOD_FREQUENCY, |
| 5719 | uActionPeriod, NULL, eANI_BOOLEAN_FALSE)) |
| 5720 | { |
| 5721 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5722 | "%s: Could not set SETRMCACTIONPERIOD %d", __func__, uActionPeriod); |
| 5723 | ret = -EINVAL; |
| 5724 | goto exit; |
| 5725 | } |
| 5726 | |
| 5727 | } |
| 5728 | else if (strncasecmp(command, "GETIBSSPEERINFOALL", 18) == 0) |
| 5729 | { |
| 5730 | /* Peer Info All Command */ |
| 5731 | int status = eHAL_STATUS_SUCCESS; |
| 5732 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 5733 | char *extra = NULL; |
| 5734 | int idx = 0, length = 0; |
| 5735 | v_MACADDR_t *macAddr; |
| 5736 | v_U32_t txRateMbps = 0, numOfBytestoPrint = 0; |
| 5737 | |
| 5738 | if (WLAN_HDD_IBSS == pAdapter->device_mode) |
| 5739 | { |
| 5740 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 5741 | } |
| 5742 | else |
| 5743 | { |
| 5744 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5745 | "%s: pAdapter is not valid for this device mode", |
| 5746 | __func__); |
| 5747 | ret = -EINVAL; |
| 5748 | goto exit; |
| 5749 | } |
| 5750 | |
| 5751 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5752 | "%s: Received GETIBSSPEERINFOALL Command", __func__); |
| 5753 | |
| 5754 | |
| 5755 | /* Handle the command */ |
| 5756 | status = hdd_cfg80211_get_ibss_peer_info_all(pAdapter); |
| 5757 | if (VOS_STATUS_SUCCESS == status) |
| 5758 | { |
| 5759 | /* The variable extra needed to be allocated on the heap since |
| 5760 | * amount of memory required to copy the data for 32 devices |
| 5761 | * exceeds the size of 1024 bytes of default stack size. On |
| 5762 | * 64 bit devices, the default max stack size of 2048 bytes |
| 5763 | */ |
| 5764 | extra = kmalloc(WLAN_MAX_BUF_SIZE, GFP_KERNEL); |
| 5765 | |
| 5766 | if (NULL == extra) |
| 5767 | { |
| 5768 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5769 | "%s:kmalloc failed", __func__); |
| 5770 | ret = -EINVAL; |
| 5771 | goto exit; |
| 5772 | } |
| 5773 | |
| 5774 | /* Copy number of stations */ |
| 5775 | length = scnprintf( extra, WLAN_MAX_BUF_SIZE, "%d ", |
| 5776 | pHddStaCtx->ibss_peer_info.numIBSSPeers); |
| 5777 | numOfBytestoPrint = length; |
| 5778 | for (idx = 0; idx < pHddStaCtx->ibss_peer_info.numIBSSPeers; idx++) |
| 5779 | { |
| 5780 | macAddr = |
| 5781 | hdd_wlan_get_ibss_mac_addr_from_staid(pAdapter, |
| 5782 | pHddStaCtx->ibss_peer_info.ibssPeerList[idx].staIdx); |
| 5783 | if (NULL != macAddr) |
| 5784 | { |
| 5785 | txRateMbps = |
| 5786 | ((pHddStaCtx->ibss_peer_info.ibssPeerList[idx].txRate)*500*1000)/1000000; |
| 5787 | |
| 5788 | length += scnprintf( (extra + length), WLAN_MAX_BUF_SIZE - length, |
| 5789 | "%02x:%02x:%02x:%02x:%02x:%02x %d %d ", |
| 5790 | macAddr->bytes[0], macAddr->bytes[1], macAddr->bytes[2], |
| 5791 | macAddr->bytes[3], macAddr->bytes[4], macAddr->bytes[5], |
| 5792 | (int)txRateMbps, |
| 5793 | (int)pHddStaCtx->ibss_peer_info.ibssPeerList[idx].rssi); |
| 5794 | } |
| 5795 | else |
| 5796 | { |
| 5797 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5798 | "%s: MAC ADDR is NULL for staIdx: %d", __func__, |
| 5799 | pHddStaCtx->ibss_peer_info.ibssPeerList[idx].staIdx); |
| 5800 | } |
| 5801 | |
| 5802 | /* |
| 5803 | * VOS_TRACE() macro has limitation of 512 bytes for the print |
| 5804 | * buffer. Hence printing the data in two chunks. The first chunk |
| 5805 | * will have the data for 16 devices and the second chunk will |
| 5806 | * have the rest. |
| 5807 | */ |
| 5808 | if (idx < NUM_OF_STA_DATA_TO_PRINT) |
| 5809 | { |
| 5810 | numOfBytestoPrint = length; |
| 5811 | } |
| 5812 | } |
| 5813 | |
| 5814 | /* |
| 5815 | * Copy the data back into buffer, if the data to copy is |
| 5816 | * morethan 512 bytes than we will split the data and do |
| 5817 | * it in two shots |
| 5818 | */ |
| 5819 | if (copy_to_user(priv_data.buf, extra, numOfBytestoPrint)) |
| 5820 | { |
| 5821 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5822 | "%s: Copy into user data buffer failed ", __func__); |
| 5823 | ret = -EFAULT; |
| 5824 | kfree(extra); |
| 5825 | goto exit; |
| 5826 | } |
| 5827 | priv_data.buf[numOfBytestoPrint] = '\0'; |
| 5828 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, |
| 5829 | "%s", priv_data.buf); |
| 5830 | |
| 5831 | if (length > numOfBytestoPrint) |
| 5832 | { |
| 5833 | if (copy_to_user(priv_data.buf + numOfBytestoPrint, |
| 5834 | extra + numOfBytestoPrint, |
| 5835 | length - numOfBytestoPrint + 1)) |
| 5836 | { |
| 5837 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5838 | "%s: Copy into user data buffer failed ", __func__); |
| 5839 | ret = -EFAULT; |
| 5840 | kfree(extra); |
| 5841 | goto exit; |
| 5842 | } |
| 5843 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, |
| 5844 | "%s", &priv_data.buf[numOfBytestoPrint]); |
| 5845 | } |
| 5846 | |
| 5847 | /* Free temporary buffer */ |
| 5848 | kfree(extra); |
| 5849 | } |
| 5850 | |
| 5851 | else |
| 5852 | { |
| 5853 | /* Command failed, log error */ |
| 5854 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5855 | "%s: GETIBSSPEERINFOALL command failed with status code %d", |
| 5856 | __func__, status); |
| 5857 | ret = -EINVAL; |
| 5858 | goto exit; |
| 5859 | } |
| 5860 | ret = 0; |
| 5861 | } |
| 5862 | else if(strncasecmp(command, "GETIBSSPEERINFO", 15) == 0) |
| 5863 | { |
| 5864 | /* Peer Info <Peer Addr> command */ |
| 5865 | tANI_U8 *value = command; |
| 5866 | VOS_STATUS status; |
| 5867 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 5868 | char extra[128] = { 0 }; |
| 5869 | v_U32_t length = 0; |
| 5870 | v_U8_t staIdx = 0; |
| 5871 | v_U32_t txRateMbps = 0; |
| 5872 | v_MACADDR_t peerMacAddr; |
| 5873 | |
| 5874 | if (WLAN_HDD_IBSS == pAdapter->device_mode) |
| 5875 | { |
| 5876 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 5877 | } |
| 5878 | else |
| 5879 | { |
| 5880 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5881 | "%s: pAdapter is not valid for this device mode", |
| 5882 | __func__); |
| 5883 | ret = -EINVAL; |
| 5884 | goto exit; |
| 5885 | } |
| 5886 | |
| 5887 | /* if there are no peers, no need to continue with the command */ |
| 5888 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5889 | "%s: Received GETIBSSPEERINFO Command", __func__); |
| 5890 | |
| 5891 | if (eConnectionState_IbssConnected != pHddStaCtx->conn_info.connState) |
| 5892 | { |
| 5893 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5894 | "%s:No IBSS Peers coalesced", __func__); |
| 5895 | ret = -EINVAL; |
| 5896 | goto exit; |
| 5897 | } |
| 5898 | |
| 5899 | /* Parse the incoming command buffer */ |
| 5900 | status = hdd_parse_get_ibss_peer_info(value, &peerMacAddr); |
| 5901 | if (VOS_STATUS_SUCCESS != status) |
| 5902 | { |
| 5903 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5904 | "%s: Invalid GETIBSSPEERINFO command", __func__); |
| 5905 | ret = -EINVAL; |
| 5906 | goto exit; |
| 5907 | } |
| 5908 | |
| 5909 | /* Get station index for the peer mac address */ |
| 5910 | hdd_Ibss_GetStaId(pHddStaCtx, &peerMacAddr, &staIdx); |
| 5911 | |
| 5912 | if (staIdx > HDD_MAX_NUM_IBSS_STA) |
| 5913 | { |
| 5914 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5915 | "%s: Invalid StaIdx %d returned", __func__, staIdx); |
| 5916 | ret = -EINVAL; |
| 5917 | goto exit; |
| 5918 | } |
| 5919 | |
| 5920 | /* Handle the command */ |
| 5921 | status = hdd_cfg80211_get_ibss_peer_info(pAdapter, staIdx); |
| 5922 | if (VOS_STATUS_SUCCESS == status) |
| 5923 | { |
| 5924 | v_U32_t txRate = pHddStaCtx->ibss_peer_info.ibssPeerList[0].txRate; |
| 5925 | txRateMbps = (txRate * 500 * 1000)/1000000; |
| 5926 | |
| 5927 | length = scnprintf( extra, sizeof(extra), "%d %d", (int)txRateMbps, |
| 5928 | (int)pHddStaCtx->ibss_peer_info.ibssPeerList[0].rssi); |
| 5929 | |
| 5930 | /* Copy the data back into buffer */ |
| 5931 | if (copy_to_user(priv_data.buf, &extra, length+ 1)) |
| 5932 | { |
| 5933 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5934 | "%s: copy data to user buffer failed GETIBSSPEERINFO command", |
| 5935 | __func__); |
| 5936 | ret = -EFAULT; |
| 5937 | goto exit; |
| 5938 | } |
| 5939 | } |
| 5940 | else |
| 5941 | { |
| 5942 | /* Command failed, log error */ |
| 5943 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5944 | "%s: GETIBSSPEERINFO command failed with status code %d", |
| 5945 | __func__, status); |
| 5946 | ret = -EINVAL; |
| 5947 | goto exit; |
| 5948 | } |
| 5949 | |
| 5950 | /* Success ! */ |
| 5951 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, |
| 5952 | "%s", priv_data.buf); |
| 5953 | ret = 0; |
| 5954 | } |
| 5955 | else if (strncasecmp(command, "SETRMCTXRATE", 12) == 0) |
| 5956 | { |
| 5957 | tANI_U8 *value = command; |
| 5958 | tANI_U32 uRate = 0; |
| 5959 | tTxrateinfoflags txFlags = 0; |
| 5960 | tSirRateUpdateInd *rateUpdateParams; |
| 5961 | int status; |
| 5962 | |
| 5963 | if ((WLAN_HDD_IBSS != pAdapter->device_mode) && |
| 5964 | (WLAN_HDD_SOFTAP != pAdapter->device_mode)) |
| 5965 | { |
| 5966 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5967 | "Received SETRMCTXRATE command in invalid mode %d " |
| 5968 | "SETRMC command is only allowed in IBSS or SOFTAP mode", |
| 5969 | pAdapter->device_mode); |
| 5970 | ret = -EINVAL; |
| 5971 | goto exit; |
| 5972 | } |
| 5973 | |
| 5974 | status = hdd_parse_setrmcrate_command(value, &uRate, &txFlags); |
| 5975 | if (status) |
| 5976 | { |
| 5977 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5978 | "Invalid SETRMCTXRATE command "); |
| 5979 | ret = -EINVAL; |
| 5980 | goto exit; |
| 5981 | } |
| 5982 | |
| 5983 | rateUpdateParams = vos_mem_malloc(sizeof(tSirRateUpdateInd)); |
| 5984 | if (NULL == rateUpdateParams) |
| 5985 | { |
| 5986 | ret = -EINVAL; |
| 5987 | goto exit; |
| 5988 | } |
| 5989 | |
| 5990 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5991 | "%s: uRate %d ", __func__, uRate); |
| 5992 | |
| 5993 | vos_mem_zero(rateUpdateParams, sizeof(tSirRateUpdateInd )); |
| 5994 | |
| 5995 | /* -1 implies ignore this param */ |
| 5996 | rateUpdateParams->ucastDataRate = -1; |
| 5997 | |
| 5998 | /* |
| 5999 | * Fill the user specifieed RMC rate param |
| 6000 | * and the derived tx flags. |
| 6001 | */ |
| 6002 | rateUpdateParams->rmcDataRate = uRate; |
| 6003 | rateUpdateParams->rmcDataRateTxFlag = txFlags; |
| 6004 | |
| 6005 | status = sme_SendRateUpdateInd((tHalHandle)(pHddCtx->hHal), rateUpdateParams); |
| 6006 | } |
| 6007 | else if (strncasecmp(command, "SETIBSSTXFAILEVENT", 18) == 0 ) |
| 6008 | { |
| 6009 | char *value; |
| 6010 | tANI_U8 tx_fail_count = 0; |
| 6011 | tANI_U16 pid = 0; |
| 6012 | |
| 6013 | value = command; |
| 6014 | |
| 6015 | ret = hdd_ParseIBSSTXFailEventParams(value, &tx_fail_count, &pid); |
| 6016 | |
| 6017 | if (0 != ret) |
| 6018 | { |
| 6019 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6020 | "%s: Failed to parse SETIBSSTXFAILEVENT arguments", |
| 6021 | __func__); |
| 6022 | goto exit; |
| 6023 | } |
| 6024 | |
| 6025 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: tx_fail_cnt=%hhu, pid=%hu", |
| 6026 | __func__, tx_fail_count, pid); |
| 6027 | |
| 6028 | if (0 == tx_fail_count) |
| 6029 | { |
| 6030 | // Disable TX Fail Indication |
| 6031 | if (eHAL_STATUS_SUCCESS == |
| 6032 | sme_TXFailMonitorStartStopInd(pHddCtx->hHal, |
| 6033 | tx_fail_count, |
| 6034 | NULL)) |
| 6035 | { |
| 6036 | cesium_pid = 0; |
| 6037 | } |
| 6038 | else |
| 6039 | { |
| 6040 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6041 | "%s: failed to disable TX Fail Event ", __func__); |
| 6042 | ret = -EINVAL; |
| 6043 | } |
| 6044 | } |
| 6045 | else |
| 6046 | { |
| 6047 | if (eHAL_STATUS_SUCCESS == |
| 6048 | sme_TXFailMonitorStartStopInd(pHddCtx->hHal, |
| 6049 | tx_fail_count, |
| 6050 | (void*)hdd_tx_fail_ind_callback)) |
| 6051 | { |
| 6052 | cesium_pid = pid; |
| 6053 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 6054 | "%s: Registered Cesium pid %u", __func__, |
| 6055 | cesium_pid); |
| 6056 | } |
| 6057 | else |
| 6058 | { |
| 6059 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6060 | "%s: Failed to enable TX Fail Monitoring", __func__); |
| 6061 | ret = -EINVAL; |
| 6062 | } |
| 6063 | } |
| 6064 | } |
| 6065 | |
| 6066 | #endif /* WLAN_FEATURE_RMC */ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 6067 | #if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD) |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 6068 | else if (strncmp(command, "SETCCXROAMSCANCHANNELS", 22) == 0) |
| 6069 | { |
| 6070 | tANI_U8 *value = command; |
| 6071 | tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0}; |
| 6072 | tANI_U8 numChannels = 0; |
| 6073 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 6074 | |
| 6075 | status = hdd_parse_channellist(value, ChannelList, &numChannels); |
| 6076 | if (eHAL_STATUS_SUCCESS != status) |
| 6077 | { |
| 6078 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6079 | "%s: Failed to parse channel list information", __func__); |
| 6080 | ret = -EINVAL; |
| 6081 | goto exit; |
| 6082 | } |
| 6083 | |
| 6084 | if (numChannels > WNI_CFG_VALID_CHANNEL_LIST_LEN) |
| 6085 | { |
| 6086 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6087 | "%s: number of channels (%d) supported exceeded max (%d)", __func__, |
| 6088 | numChannels, WNI_CFG_VALID_CHANNEL_LIST_LEN); |
| 6089 | ret = -EINVAL; |
| 6090 | goto exit; |
| 6091 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 6092 | status = sme_SetEseRoamScanChannelList((tHalHandle)(pHddCtx->hHal), |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 6093 | ChannelList, |
| 6094 | numChannels); |
| 6095 | if (eHAL_STATUS_SUCCESS != status) |
| 6096 | { |
| 6097 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6098 | "%s: Failed to update channel list information", __func__); |
| 6099 | ret = -EINVAL; |
| 6100 | goto exit; |
| 6101 | } |
| 6102 | } |
| 6103 | else if (strncmp(command, "GETTSMSTATS", 11) == 0) |
| 6104 | { |
| 6105 | tANI_U8 *value = command; |
| 6106 | char extra[128] = {0}; |
| 6107 | int len = 0; |
| 6108 | tANI_U8 tid = 0; |
| 6109 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 6110 | tAniTrafStrmMetrics tsmMetrics; |
| 6111 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 6112 | |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 6113 | ret = hdd_drv_cmd_validate(command, 11); |
| 6114 | if (ret) |
| 6115 | goto exit; |
| 6116 | |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 6117 | /* if not associated, return error */ |
| 6118 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 6119 | { |
| 6120 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:Not associated!",__func__); |
| 6121 | ret = -EINVAL; |
| 6122 | goto exit; |
| 6123 | } |
| 6124 | |
| 6125 | /* Move pointer to ahead of GETTSMSTATS<delimiter> */ |
| 6126 | value = value + 12; |
| 6127 | /* Convert the value from ascii to integer */ |
| 6128 | ret = kstrtou8(value, 10, &tid); |
| 6129 | if (ret < 0) |
| 6130 | { |
| 6131 | /* If the input value is greater than max value of datatype, then also |
| 6132 | kstrtou8 fails */ |
| 6133 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6134 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 6135 | TID_MIN_VALUE, |
| 6136 | TID_MAX_VALUE); |
| 6137 | ret = -EINVAL; |
| 6138 | goto exit; |
| 6139 | } |
| 6140 | |
| 6141 | if ((tid < TID_MIN_VALUE) || (tid > TID_MAX_VALUE)) |
| 6142 | { |
| 6143 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6144 | "tid value %d is out of range" |
| 6145 | " (Min: %d Max: %d)", tid, |
| 6146 | TID_MIN_VALUE, |
| 6147 | TID_MAX_VALUE); |
| 6148 | ret = -EINVAL; |
| 6149 | goto exit; |
| 6150 | } |
| 6151 | |
| 6152 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 6153 | "%s: Received Command to get tsm stats tid = %d", __func__, tid); |
| 6154 | |
| 6155 | if (VOS_STATUS_SUCCESS != hdd_get_tsm_stats(pAdapter, tid, &tsmMetrics)) |
| 6156 | { |
| 6157 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6158 | "%s: failed to get tsm stats", __func__); |
| 6159 | ret = -EFAULT; |
| 6160 | goto exit; |
| 6161 | } |
| 6162 | |
| 6163 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 6164 | "UplinkPktQueueDly(%d)\n" |
| 6165 | "UplinkPktQueueDlyHist[0](%d)\n" |
| 6166 | "UplinkPktQueueDlyHist[1](%d)\n" |
| 6167 | "UplinkPktQueueDlyHist[2](%d)\n" |
| 6168 | "UplinkPktQueueDlyHist[3](%d)\n" |
Arun Kumar Khandavalli | e876821 | 2014-02-17 16:43:34 +0530 | [diff] [blame] | 6169 | "UplinkPktTxDly(%u)\n" |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 6170 | "UplinkPktLoss(%d)\n" |
| 6171 | "UplinkPktCount(%d)\n" |
| 6172 | "RoamingCount(%d)\n" |
| 6173 | "RoamingDly(%d)", tsmMetrics.UplinkPktQueueDly, |
| 6174 | tsmMetrics.UplinkPktQueueDlyHist[0], |
| 6175 | tsmMetrics.UplinkPktQueueDlyHist[1], |
| 6176 | tsmMetrics.UplinkPktQueueDlyHist[2], |
| 6177 | tsmMetrics.UplinkPktQueueDlyHist[3], |
| 6178 | tsmMetrics.UplinkPktTxDly, tsmMetrics.UplinkPktLoss, |
| 6179 | tsmMetrics.UplinkPktCount, tsmMetrics.RoamingCount, tsmMetrics.RoamingDly); |
| 6180 | |
| 6181 | /* Output TSM stats is of the format |
| 6182 | GETTSMSTATS [PktQueueDly] [PktQueueDlyHist[0]]:[PktQueueDlyHist[1]] ...[RoamingDly] |
| 6183 | eg., GETTSMSTATS 10 1:0:0:161 20 1 17 8 39800 */ |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 6184 | 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] | 6185 | tsmMetrics.UplinkPktQueueDly, tsmMetrics.UplinkPktQueueDlyHist[0], |
| 6186 | tsmMetrics.UplinkPktQueueDlyHist[1], tsmMetrics.UplinkPktQueueDlyHist[2], |
| 6187 | tsmMetrics.UplinkPktQueueDlyHist[3], tsmMetrics.UplinkPktTxDly, |
| 6188 | tsmMetrics.UplinkPktLoss, tsmMetrics.UplinkPktCount, tsmMetrics.RoamingCount, |
| 6189 | tsmMetrics.RoamingDly); |
| 6190 | |
Ratnam Rachuri | d53009c | 2015-08-07 13:59:00 +0530 | [diff] [blame] | 6191 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 6192 | if (copy_to_user(priv_data.buf, &extra, len)) { |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 6193 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6194 | "%s: failed to copy data to user buffer", __func__); |
| 6195 | ret = -EFAULT; |
| 6196 | goto exit; |
| 6197 | } |
| 6198 | } |
| 6199 | else if (strncmp(command, "SETCCKMIE", 9) == 0) |
| 6200 | { |
| 6201 | tANI_U8 *value = command; |
| 6202 | tANI_U8 *cckmIe = NULL; |
| 6203 | tANI_U8 cckmIeLen = 0; |
| 6204 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 6205 | |
| 6206 | status = hdd_parse_get_cckm_ie(value, &cckmIe, &cckmIeLen); |
| 6207 | if (eHAL_STATUS_SUCCESS != status) |
| 6208 | { |
| 6209 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6210 | "%s: Failed to parse cckm ie data", __func__); |
| 6211 | ret = -EINVAL; |
| 6212 | goto exit; |
| 6213 | } |
| 6214 | |
| 6215 | if (cckmIeLen > DOT11F_IE_RSN_MAX_LEN) |
| 6216 | { |
| 6217 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6218 | "%s: CCKM Ie input length is more than max[%d]", __func__, |
| 6219 | DOT11F_IE_RSN_MAX_LEN); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 6220 | vos_mem_free(cckmIe); |
| 6221 | cckmIe = NULL; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 6222 | ret = -EINVAL; |
| 6223 | goto exit; |
| 6224 | } |
| 6225 | sme_SetCCKMIe((tHalHandle)(pHddCtx->hHal), pAdapter->sessionId, cckmIe, cckmIeLen); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 6226 | vos_mem_free(cckmIe); |
| 6227 | cckmIe = NULL; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 6228 | } |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 6229 | else if (strncmp(command, "CCXBEACONREQ", 12) == 0) |
| 6230 | { |
| 6231 | tANI_U8 *value = command; |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 6232 | tCsrEseBeaconReq eseBcnReq; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 6233 | eHalStatus status = eHAL_STATUS_SUCCESS; |
Srinivas Girigowda | 0c6d7fe | 2014-05-28 18:18:10 -0700 | [diff] [blame] | 6234 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 6235 | status = hdd_parse_ese_beacon_req(value, &eseBcnReq); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 6236 | if (eHAL_STATUS_SUCCESS != status) |
| 6237 | { |
| 6238 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 6239 | "%s: Failed to parse ese beacon req", __func__); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 6240 | ret = -EINVAL; |
| 6241 | goto exit; |
| 6242 | } |
Srinivas Girigowda | 0c6d7fe | 2014-05-28 18:18:10 -0700 | [diff] [blame] | 6243 | if (!hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) { |
| 6244 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Not associated")); |
| 6245 | hdd_indicateEseBcnReportNoResults (pAdapter, |
| 6246 | eseBcnReq.bcnReq[0].measurementToken, |
| 6247 | 0x02, //BIT(1) set for measurement done |
| 6248 | 0); // no BSS |
| 6249 | goto exit; |
| 6250 | } |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 6251 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 6252 | status = sme_SetEseBeaconRequest((tHalHandle)(pHddCtx->hHal), pAdapter->sessionId, &eseBcnReq); |
| 6253 | if (eHAL_STATUS_SUCCESS != status) |
| 6254 | { |
| 6255 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6256 | "%s: sme_SetEseBeaconRequest failed (%d)", __func__, status); |
| 6257 | ret = -EINVAL; |
| 6258 | goto exit; |
| 6259 | } |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 6260 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 6261 | #endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */ |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 6262 | else if (strncmp(command, "GETBCNMISSRATE", 14) == 0) |
| 6263 | { |
| 6264 | eHalStatus status; |
| 6265 | char buf[32], len; |
| 6266 | long waitRet; |
| 6267 | bcnMissRateContext_t getBcnMissRateCtx; |
| 6268 | |
| 6269 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 6270 | |
| 6271 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 6272 | { |
| 6273 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 6274 | FL("GETBCNMISSRATE: STA is not in connected state")); |
| 6275 | ret = -1; |
| 6276 | goto exit; |
| 6277 | } |
| 6278 | |
| 6279 | init_completion(&(getBcnMissRateCtx.completion)); |
| 6280 | getBcnMissRateCtx.magic = BCN_MISS_RATE_CONTEXT_MAGIC; |
| 6281 | |
| 6282 | status = sme_getBcnMissRate((tHalHandle)(pHddCtx->hHal), |
| 6283 | pAdapter->sessionId, |
| 6284 | (void *)getBcnMissRateCB, |
| 6285 | (void *)(&getBcnMissRateCtx)); |
| 6286 | if( eHAL_STATUS_SUCCESS != status) |
| 6287 | { |
| 6288 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6289 | FL("GETBCNMISSRATE: fail to post WDA cmd")); |
| 6290 | ret = -EINVAL; |
| 6291 | goto exit; |
| 6292 | } |
| 6293 | |
| 6294 | waitRet = wait_for_completion_interruptible_timeout |
| 6295 | (&getBcnMissRateCtx.completion, BCN_MISS_RATE_TIME); |
| 6296 | if(waitRet <= 0) |
| 6297 | { |
| 6298 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6299 | FL("failed to wait on bcnMissRateComp %d"), ret); |
| 6300 | |
| 6301 | //Make magic number to zero so that callback is not called. |
| 6302 | spin_lock(&hdd_context_lock); |
| 6303 | getBcnMissRateCtx.magic = 0x0; |
| 6304 | spin_unlock(&hdd_context_lock); |
| 6305 | ret = -EINVAL; |
| 6306 | goto exit; |
| 6307 | } |
| 6308 | |
| 6309 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6310 | FL("GETBCNMISSRATE: bcnMissRate: %d"), gbcnMissRate); |
| 6311 | |
| 6312 | len = snprintf(buf, sizeof(buf), "GETBCNMISSRATE %d", gbcnMissRate); |
| 6313 | if (copy_to_user(priv_data.buf, &buf, len + 1)) |
| 6314 | { |
| 6315 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6316 | "%s: failed to copy data to user buffer", __func__); |
| 6317 | ret = -EFAULT; |
| 6318 | goto exit; |
| 6319 | } |
| 6320 | ret = len; |
| 6321 | } |
Atul Mittal | 87ec242 | 2014-09-24 13:12:50 +0530 | [diff] [blame] | 6322 | #ifdef FEATURE_WLAN_TDLS |
| 6323 | else if (strncmp(command, "TDLSSECONDARYCHANNELOFFSET", 26) == 0) { |
| 6324 | tANI_U8 *value = command; |
| 6325 | int set_value; |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 6326 | |
| 6327 | ret = hdd_drv_cmd_validate(command, 26); |
| 6328 | if (ret) |
| 6329 | goto exit; |
| 6330 | |
Atul Mittal | 87ec242 | 2014-09-24 13:12:50 +0530 | [diff] [blame] | 6331 | /* Move pointer to ahead of TDLSOFFCH*/ |
| 6332 | value += 26; |
c_manjee | bbc4021 | 2015-12-08 13:52:59 +0530 | [diff] [blame] | 6333 | if (!(sscanf(value, "%d", &set_value))) { |
| 6334 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 6335 | FL("No input identified")); |
| 6336 | ret = -EINVAL; |
| 6337 | goto exit; |
| 6338 | } |
| 6339 | |
Atul Mittal | 87ec242 | 2014-09-24 13:12:50 +0530 | [diff] [blame] | 6340 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 6341 | "%s: Tdls offchannel offset:%d", |
| 6342 | __func__, set_value); |
| 6343 | ret = iw_set_tdlssecoffchanneloffset(pHddCtx, set_value); |
| 6344 | if (ret < 0) |
| 6345 | { |
| 6346 | ret = -EINVAL; |
| 6347 | goto exit; |
| 6348 | } |
| 6349 | |
| 6350 | } else if (strncmp(command, "TDLSOFFCHANNELMODE", 18) == 0) { |
| 6351 | tANI_U8 *value = command; |
| 6352 | int set_value; |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 6353 | |
| 6354 | ret = hdd_drv_cmd_validate(command, 18); |
| 6355 | if (ret) |
| 6356 | goto exit; |
| 6357 | |
Atul Mittal | 87ec242 | 2014-09-24 13:12:50 +0530 | [diff] [blame] | 6358 | /* Move pointer to ahead of tdlsoffchnmode*/ |
| 6359 | value += 18; |
c_manjee | 8232389 | 2015-12-08 12:40:34 +0530 | [diff] [blame] | 6360 | ret = sscanf(value, "%d", &set_value); |
| 6361 | if (ret != 1) { |
| 6362 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 6363 | FL("No input identified")); |
| 6364 | ret = -EINVAL; |
| 6365 | goto exit; |
| 6366 | } |
Atul Mittal | 87ec242 | 2014-09-24 13:12:50 +0530 | [diff] [blame] | 6367 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 6368 | "%s: Tdls offchannel mode:%d", |
| 6369 | __func__, set_value); |
| 6370 | ret = iw_set_tdlsoffchannelmode(pAdapter, set_value); |
| 6371 | if (ret < 0) |
| 6372 | { |
| 6373 | ret = -EINVAL; |
| 6374 | goto exit; |
| 6375 | } |
| 6376 | } else if (strncmp(command, "TDLSOFFCHANNEL", 14) == 0) { |
| 6377 | tANI_U8 *value = command; |
| 6378 | int set_value; |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 6379 | |
| 6380 | ret = hdd_drv_cmd_validate(command, 14); |
| 6381 | if (ret) |
| 6382 | goto exit; |
| 6383 | |
Atul Mittal | 87ec242 | 2014-09-24 13:12:50 +0530 | [diff] [blame] | 6384 | /* Move pointer to ahead of TDLSOFFCH*/ |
| 6385 | value += 14; |
c_manjee | f6ccaf5 | 2015-12-08 11:52:11 +0530 | [diff] [blame] | 6386 | ret = sscanf(value, "%d", &set_value); |
| 6387 | if (ret != 1) { |
| 6388 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6389 | "Wrong value is given for hdd_set_tdls_offchannel"); |
| 6390 | ret = -EINVAL; |
| 6391 | goto exit; |
| 6392 | } |
| 6393 | |
Atul Mittal | 87ec242 | 2014-09-24 13:12:50 +0530 | [diff] [blame] | 6394 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 6395 | "%s: Tdls offchannel num: %d", |
| 6396 | __func__, set_value); |
| 6397 | ret = iw_set_tdlsoffchannel(pHddCtx, set_value); |
| 6398 | if (ret < 0) |
| 6399 | { |
| 6400 | ret = -EINVAL; |
| 6401 | goto exit; |
| 6402 | } |
| 6403 | } |
| 6404 | #endif |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 6405 | else if (strncmp(command, "GETFWSTATS", 10) == 0) |
| 6406 | { |
| 6407 | eHalStatus status; |
| 6408 | char *buf = NULL; |
| 6409 | char len; |
| 6410 | long waitRet; |
| 6411 | fwStatsContext_t fwStatsCtx; |
Abhishek Singh | 08aa776 | 2014-12-16 13:59:03 +0530 | [diff] [blame] | 6412 | tSirFwStatsResult *fwStatsRsp = &(pAdapter->fwStatsRsp); |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 6413 | tANI_U8 *ptr = command; |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 6414 | int stats; |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 6415 | |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 6416 | ret = hdd_drv_cmd_validate(command, 10); |
| 6417 | if (ret) |
| 6418 | goto exit; |
| 6419 | |
| 6420 | stats = *(ptr + 11) - '0'; |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 6421 | hddLog(VOS_TRACE_LEVEL_INFO, FL("stats = %d "),stats); |
| 6422 | if (!IS_FEATURE_FW_STATS_ENABLE) |
| 6423 | { |
| 6424 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6425 | FL("Get Firmware stats feature not supported")); |
| 6426 | ret = -EINVAL; |
| 6427 | goto exit; |
| 6428 | } |
| 6429 | |
| 6430 | if (FW_STATS_MAX <= stats || 0 >= stats) |
| 6431 | { |
| 6432 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6433 | FL(" stats %d not supported"),stats); |
| 6434 | ret = -EINVAL; |
| 6435 | goto exit; |
| 6436 | } |
| 6437 | |
| 6438 | init_completion(&(fwStatsCtx.completion)); |
| 6439 | fwStatsCtx.magic = FW_STATS_CONTEXT_MAGIC; |
| 6440 | fwStatsCtx.pAdapter = pAdapter; |
| 6441 | fwStatsRsp->type = 0; |
| 6442 | status = sme_GetFwStats( (tHalHandle)pHddCtx->hHal, stats, |
Abhishek Singh | 08aa776 | 2014-12-16 13:59:03 +0530 | [diff] [blame] | 6443 | &fwStatsCtx, hdd_FWStatisCB); |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 6444 | if (eHAL_STATUS_SUCCESS != status) |
| 6445 | { |
| 6446 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6447 | FL(" fail to post WDA cmd status = %d"), status); |
| 6448 | ret = -EINVAL; |
| 6449 | goto exit; |
| 6450 | } |
| 6451 | waitRet = wait_for_completion_timeout |
| 6452 | (&(fwStatsCtx.completion), FW_STATE_WAIT_TIME); |
| 6453 | if (waitRet <= 0) |
| 6454 | { |
| 6455 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6456 | FL("failed to wait on GwtFwstats")); |
| 6457 | //Make magic number to zero so that callback is not executed. |
| 6458 | spin_lock(&hdd_context_lock); |
| 6459 | fwStatsCtx.magic = 0x0; |
| 6460 | spin_unlock(&hdd_context_lock); |
| 6461 | ret = -EINVAL; |
| 6462 | goto exit; |
| 6463 | } |
| 6464 | if (fwStatsRsp->type) |
| 6465 | { |
| 6466 | buf = kmalloc(FW_STATE_RSP_LEN, GFP_KERNEL); |
| 6467 | if (!buf) |
| 6468 | { |
| 6469 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6470 | FL(" failed to allocate memory")); |
| 6471 | ret = -ENOMEM; |
| 6472 | goto exit; |
| 6473 | } |
| 6474 | switch( fwStatsRsp->type ) |
| 6475 | { |
| 6476 | case FW_UBSP_STATS: |
| 6477 | { |
| 6478 | len = snprintf(buf, FW_STATE_RSP_LEN, |
| 6479 | "GETFWSTATS: ubsp_enter_cnt %d ubsp_jump_ddr_cnt %d", |
Abhishek Singh | 08aa776 | 2014-12-16 13:59:03 +0530 | [diff] [blame] | 6480 | fwStatsRsp->fwStatsData.ubspStats.ubsp_enter_cnt, |
| 6481 | fwStatsRsp->fwStatsData.ubspStats.ubsp_jump_ddr_cnt); |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 6482 | } |
| 6483 | break; |
| 6484 | default: |
| 6485 | { |
| 6486 | hddLog(VOS_TRACE_LEVEL_ERROR, FL( "No handling for stats type %d"),fwStatsRsp->type); |
| 6487 | ret = -EFAULT; |
| 6488 | kfree(buf); |
| 6489 | goto exit; |
| 6490 | } |
| 6491 | } |
| 6492 | if (copy_to_user(priv_data.buf, buf, len + 1)) |
| 6493 | { |
| 6494 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6495 | FL(" failed to copy data to user buffer")); |
| 6496 | ret = -EFAULT; |
| 6497 | kfree(buf); |
| 6498 | goto exit; |
| 6499 | } |
| 6500 | ret = len; |
| 6501 | kfree(buf); |
| 6502 | } |
| 6503 | else |
| 6504 | { |
| 6505 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6506 | FL("failed to fetch the stats")); |
| 6507 | ret = -EFAULT; |
| 6508 | goto exit; |
| 6509 | } |
| 6510 | |
| 6511 | } |
Agarwal Ashish | 8bd53ae | 2015-06-12 18:03:45 +0530 | [diff] [blame] | 6512 | else if (strncasecmp(command, "SET_FCC_CHANNEL", 15) == 0) |
| 6513 | { |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 6514 | ret = hdd_drv_cmd_validate(command, 15); |
| 6515 | if (ret) |
| 6516 | goto exit; |
| 6517 | |
Agarwal Ashish | 8bd53ae | 2015-06-12 18:03:45 +0530 | [diff] [blame] | 6518 | /* |
| 6519 | * this command wld be called by user-space when it detects WLAN |
| 6520 | * ON after airplane mode is set. When APM is set, WLAN turns off. |
| 6521 | * But it can be turned back on. Otherwise; when APM is turned back |
| 6522 | * off, WLAN wld turn back on. So at that point the command is |
| 6523 | * expected to come down. 0 means disable, 1 means enable. The |
| 6524 | * constraint is removed when parameter 1 is set or different |
| 6525 | * country code is set |
| 6526 | */ |
| 6527 | ret = hdd_cmd_setFccChannel(pHddCtx, command, 15); |
| 6528 | } |
Mahesh A Saptasagar | beca12c | 2015-09-07 16:21:06 +0530 | [diff] [blame] | 6529 | else if (strncasecmp(command, "DISABLE_CA_EVENT", 16) == 0) |
| 6530 | { |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 6531 | ret = hdd_drv_cmd_validate(command, 16); |
| 6532 | if (ret) |
| 6533 | goto exit; |
| 6534 | |
Mahesh A Saptasagar | beca12c | 2015-09-07 16:21:06 +0530 | [diff] [blame] | 6535 | ret = hdd_enable_disable_ca_event(pHddCtx, command, 16); |
| 6536 | } |
Ashish Kumar Dhanotiya | 32d092b | 2018-02-20 21:43:57 +0530 | [diff] [blame] | 6537 | /* |
| 6538 | * command should be a string having format |
| 6539 | * SET_DISABLE_CHANNEL_LIST <num of channels> |
| 6540 | * <channels separated by spaces> |
| 6541 | */ |
| 6542 | else if (strncmp(command, "SET_DISABLE_CHANNEL_LIST", 24) == 0) { |
| 6543 | tANI_U8 *ptr = command; |
| 6544 | ret = hdd_drv_cmd_validate(command, 24); |
| 6545 | if (ret) |
| 6546 | goto exit; |
| 6547 | |
| 6548 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 6549 | " Received Command to disable Channels %s", |
| 6550 | __func__); |
| 6551 | ret = hdd_parse_disable_chan_cmd(pAdapter, ptr); |
| 6552 | if (ret) |
| 6553 | goto exit; |
| 6554 | } |
Hanumanth Reddy Pothula | 8ae38bb | 2018-03-07 18:59:30 +0530 | [diff] [blame] | 6555 | else if (strncmp(command, "GET_DISABLE_CHANNEL_LIST", 24) == 0) { |
| 6556 | char extra[128] = {0}; |
| 6557 | int len; |
Ashish Kumar Dhanotiya | 32d092b | 2018-02-20 21:43:57 +0530 | [diff] [blame] | 6558 | |
Hanumanth Reddy Pothula | 8ae38bb | 2018-03-07 18:59:30 +0530 | [diff] [blame] | 6559 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 6560 | " Received Command to get disable Channels list %s", |
| 6561 | __func__); |
| 6562 | |
| 6563 | len = hdd_get_disable_ch_list(pHddCtx, extra, sizeof(extra)); |
| 6564 | if (len == 0) { |
| 6565 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 6566 | FL("disable channel list are not yet programed")); |
| 6567 | ret = -EINVAL; |
| 6568 | goto exit; |
| 6569 | } |
| 6570 | |
| 6571 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 6572 | if (copy_to_user(priv_data.buf, &extra, len)) { |
| 6573 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6574 | "%s: failed to copy data to user buffer", __func__); |
| 6575 | ret = -EFAULT; |
| 6576 | goto exit; |
| 6577 | } |
| 6578 | |
| 6579 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 6580 | FL("data:%s"), extra); |
| 6581 | } |
Madan Mohan Koyyalamudi | f9bdd4e | 2012-10-30 18:05:03 -0700 | [diff] [blame] | 6582 | else { |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 6583 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 6584 | TRACE_CODE_HDD_UNSUPPORTED_IOCTL, |
| 6585 | pAdapter->sessionId, 0)); |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 6586 | hddLog( VOS_TRACE_LEVEL_WARN, FL("Unsupported GUI command %s"), |
| 6587 | command); |
Madan Mohan Koyyalamudi | f9bdd4e | 2012-10-30 18:05:03 -0700 | [diff] [blame] | 6588 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6589 | } |
| 6590 | exit: |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 6591 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6592 | if (command) |
| 6593 | { |
| 6594 | kfree(command); |
| 6595 | } |
| 6596 | return ret; |
| 6597 | } |
| 6598 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 6599 | #ifdef CONFIG_COMPAT |
| 6600 | static int hdd_driver_compat_ioctl(hdd_adapter_t *pAdapter, struct ifreq *ifr) |
| 6601 | { |
| 6602 | struct { |
| 6603 | compat_uptr_t buf; |
| 6604 | int used_len; |
| 6605 | int total_len; |
| 6606 | } compat_priv_data; |
| 6607 | hdd_priv_data_t priv_data; |
| 6608 | int ret = 0; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 6609 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 6610 | /* |
| 6611 | * Note that pAdapter and ifr have already been verified by caller, |
| 6612 | * and HDD context has also been validated |
| 6613 | */ |
| 6614 | if (copy_from_user(&compat_priv_data, ifr->ifr_data, |
| 6615 | sizeof(compat_priv_data))) { |
| 6616 | ret = -EFAULT; |
| 6617 | goto exit; |
| 6618 | } |
| 6619 | priv_data.buf = compat_ptr(compat_priv_data.buf); |
| 6620 | priv_data.used_len = compat_priv_data.used_len; |
| 6621 | priv_data.total_len = compat_priv_data.total_len; |
| 6622 | ret = hdd_driver_command(pAdapter, &priv_data); |
| 6623 | exit: |
| 6624 | return ret; |
| 6625 | } |
| 6626 | #else /* CONFIG_COMPAT */ |
| 6627 | static int hdd_driver_compat_ioctl(hdd_adapter_t *pAdapter, struct ifreq *ifr) |
| 6628 | { |
| 6629 | /* will never be invoked */ |
| 6630 | return 0; |
| 6631 | } |
| 6632 | #endif /* CONFIG_COMPAT */ |
| 6633 | |
| 6634 | static int hdd_driver_ioctl(hdd_adapter_t *pAdapter, struct ifreq *ifr) |
| 6635 | { |
| 6636 | hdd_priv_data_t priv_data; |
| 6637 | int ret = 0; |
| 6638 | |
| 6639 | /* |
| 6640 | * Note that pAdapter and ifr have already been verified by caller, |
| 6641 | * and HDD context has also been validated |
| 6642 | */ |
| 6643 | if (copy_from_user(&priv_data, ifr->ifr_data, sizeof(priv_data))) { |
| 6644 | ret = -EFAULT; |
| 6645 | } else { |
| 6646 | ret = hdd_driver_command(pAdapter, &priv_data); |
| 6647 | } |
| 6648 | return ret; |
| 6649 | } |
| 6650 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 6651 | int __hdd_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 6652 | { |
| 6653 | hdd_adapter_t *pAdapter; |
| 6654 | hdd_context_t *pHddCtx; |
| 6655 | int ret; |
| 6656 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 6657 | ENTER(); |
| 6658 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 6659 | pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 6660 | if (NULL == pAdapter) { |
| 6661 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 6662 | "%s: HDD adapter context is Null", __func__); |
| 6663 | ret = -ENODEV; |
| 6664 | goto exit; |
| 6665 | } |
| 6666 | if (dev != pAdapter->dev) { |
| 6667 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 6668 | "%s: HDD adapter/dev inconsistency", __func__); |
| 6669 | ret = -ENODEV; |
| 6670 | goto exit; |
| 6671 | } |
| 6672 | |
| 6673 | if ((!ifr) || (!ifr->ifr_data)) { |
| 6674 | ret = -EINVAL; |
| 6675 | goto exit; |
| 6676 | } |
| 6677 | |
| 6678 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 6679 | ret = wlan_hdd_validate_context(pHddCtx); |
| 6680 | if (ret) { |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 6681 | ret = -EBUSY; |
| 6682 | goto exit; |
| 6683 | } |
| 6684 | |
| 6685 | switch (cmd) { |
| 6686 | case (SIOCDEVPRIVATE + 1): |
| 6687 | if (is_compat_task()) |
| 6688 | ret = hdd_driver_compat_ioctl(pAdapter, ifr); |
| 6689 | else |
| 6690 | ret = hdd_driver_ioctl(pAdapter, ifr); |
| 6691 | break; |
| 6692 | default: |
| 6693 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unknown ioctl %d", |
| 6694 | __func__, cmd); |
| 6695 | ret = -EINVAL; |
| 6696 | break; |
| 6697 | } |
| 6698 | exit: |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 6699 | EXIT(); |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 6700 | return ret; |
| 6701 | } |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 6702 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 6703 | int hdd_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) |
| 6704 | { |
| 6705 | int ret; |
| 6706 | |
| 6707 | vos_ssr_protect(__func__); |
| 6708 | ret = __hdd_ioctl(dev, ifr, cmd); |
| 6709 | vos_ssr_unprotect(__func__); |
| 6710 | |
| 6711 | return ret; |
| 6712 | } |
| 6713 | |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 6714 | int hdd_mon_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) |
| 6715 | { |
| 6716 | return 0; |
| 6717 | } |
| 6718 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 6719 | #if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 6720 | /**--------------------------------------------------------------------------- |
| 6721 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 6722 | \brief hdd_parse_ese_beacon_req() - Parse ese beacon request |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 6723 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 6724 | This function parses the ese beacon request passed in the format |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 6725 | CCXBEACONREQ<space><Number of fields><space><Measurement token> |
| 6726 | <space>Channel 1<space>Scan Mode <space>Meas Duration<space>Channel N |
| 6727 | <space>Scan Mode N<space>Meas Duration N |
| 6728 | if the Number of bcn req fields (N) does not match with the actual number of fields passed |
| 6729 | then take N. |
| 6730 | <Meas Token><Channel><Scan Mode> and <Meas Duration> are treated as one pair |
| 6731 | For example, CCXBEACONREQ 2 1 1 1 30 2 44 0 40. |
| 6732 | This function does not take care of removing duplicate channels from the list |
| 6733 | |
| 6734 | \param - pValue Pointer to data |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 6735 | \param - pEseBcnReq output pointer to store parsed ie information |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 6736 | |
| 6737 | \return - 0 for success non-zero for failure |
| 6738 | |
| 6739 | --------------------------------------------------------------------------*/ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 6740 | static VOS_STATUS hdd_parse_ese_beacon_req(tANI_U8 *pValue, |
| 6741 | tCsrEseBeaconReq *pEseBcnReq) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 6742 | { |
| 6743 | tANI_U8 *inPtr = pValue; |
Arun Khandavalli | 9f3b483 | 2016-06-30 16:58:38 +0530 | [diff] [blame] | 6744 | uint8_t input = 0; |
| 6745 | uint32_t tempInt = 0; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 6746 | int j = 0, i = 0, v = 0; |
| 6747 | char buf[32]; |
| 6748 | |
| 6749 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 6750 | /*no argument after the command*/ |
| 6751 | if (NULL == inPtr) |
| 6752 | { |
| 6753 | return -EINVAL; |
| 6754 | } |
| 6755 | /*no space after the command*/ |
| 6756 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 6757 | { |
| 6758 | return -EINVAL; |
| 6759 | } |
| 6760 | |
| 6761 | /*removing empty spaces*/ |
| 6762 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
| 6763 | |
| 6764 | /*no argument followed by spaces*/ |
| 6765 | if ('\0' == *inPtr) return -EINVAL; |
| 6766 | |
| 6767 | /*getting the first argument ie measurement token*/ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 6768 | v = sscanf(inPtr, "%31s ", buf); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 6769 | if (1 != v) return -EINVAL; |
| 6770 | |
Arun Khandavalli | 9f3b483 | 2016-06-30 16:58:38 +0530 | [diff] [blame] | 6771 | v = kstrtos8(buf, 10, &input); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 6772 | if ( v < 0) return -EINVAL; |
| 6773 | |
Arun Khandavalli | 9f3b483 | 2016-06-30 16:58:38 +0530 | [diff] [blame] | 6774 | input = VOS_MIN(input, SIR_ESE_MAX_MEAS_IE_REQS); |
| 6775 | pEseBcnReq->numBcnReqIe = input; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 6776 | |
Srinivas Girigowda | 725a88e | 2016-03-31 19:24:25 +0530 | [diff] [blame] | 6777 | hddLog(LOG1, "Number of Bcn Req Ie fields: %d", pEseBcnReq->numBcnReqIe); |
| 6778 | |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 6779 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 6780 | for (j = 0; j < (pEseBcnReq->numBcnReqIe); j++) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 6781 | { |
| 6782 | for (i = 0; i < 4; i++) |
| 6783 | { |
| 6784 | /*inPtr pointing to the beginning of first space after number of ie fields*/ |
| 6785 | inPtr = strpbrk( inPtr, " " ); |
| 6786 | /*no ie data after the number of ie fields argument*/ |
| 6787 | if (NULL == inPtr) return -EINVAL; |
| 6788 | |
| 6789 | /*removing empty space*/ |
| 6790 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
| 6791 | |
| 6792 | /*no ie data after the number of ie fields argument and spaces*/ |
| 6793 | if ( '\0' == *inPtr ) return -EINVAL; |
| 6794 | |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 6795 | v = sscanf(inPtr, "%31s ", buf); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 6796 | if (1 != v) return -EINVAL; |
| 6797 | |
Arun Khandavalli | 9f3b483 | 2016-06-30 16:58:38 +0530 | [diff] [blame] | 6798 | v = kstrtou32(buf, 10, &tempInt); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 6799 | if (v < 0) return -EINVAL; |
| 6800 | |
| 6801 | switch (i) |
| 6802 | { |
| 6803 | case 0: /* Measurement token */ |
Arun Khandavalli | 9f3b483 | 2016-06-30 16:58:38 +0530 | [diff] [blame] | 6804 | if (!tempInt) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 6805 | { |
| 6806 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Arun Khandavalli | 9f3b483 | 2016-06-30 16:58:38 +0530 | [diff] [blame] | 6807 | "Invalid Measurement Token: %u", tempInt); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 6808 | return -EINVAL; |
| 6809 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 6810 | pEseBcnReq->bcnReq[j].measurementToken = tempInt; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 6811 | break; |
| 6812 | |
| 6813 | case 1: /* Channel number */ |
Arun Khandavalli | 9f3b483 | 2016-06-30 16:58:38 +0530 | [diff] [blame] | 6814 | if ((!tempInt) || |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 6815 | (tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX)) |
| 6816 | { |
| 6817 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Arun Khandavalli | 9f3b483 | 2016-06-30 16:58:38 +0530 | [diff] [blame] | 6818 | "Invalid Channel Number: %u", tempInt); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 6819 | return -EINVAL; |
| 6820 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 6821 | pEseBcnReq->bcnReq[j].channel = tempInt; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 6822 | break; |
| 6823 | |
| 6824 | case 2: /* Scan mode */ |
Varun Reddy Yeturu | 0b18d5a | 2013-12-04 11:42:23 -0800 | [diff] [blame] | 6825 | if ((tempInt < eSIR_PASSIVE_SCAN) || (tempInt > eSIR_BEACON_TABLE)) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 6826 | { |
| 6827 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Arun Khandavalli | 9f3b483 | 2016-06-30 16:58:38 +0530 | [diff] [blame] | 6828 | "Invalid Scan Mode(%u) Expected{0|1|2}", tempInt); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 6829 | return -EINVAL; |
| 6830 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 6831 | pEseBcnReq->bcnReq[j].scanMode= tempInt; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 6832 | break; |
| 6833 | |
| 6834 | case 3: /* Measurement duration */ |
Arun Khandavalli | 9f3b483 | 2016-06-30 16:58:38 +0530 | [diff] [blame] | 6835 | if (((!tempInt) && (pEseBcnReq->bcnReq[j].scanMode != eSIR_BEACON_TABLE)) || |
| 6836 | ((pEseBcnReq->bcnReq[j].scanMode == eSIR_BEACON_TABLE))) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 6837 | { |
| 6838 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Arun Khandavalli | 9f3b483 | 2016-06-30 16:58:38 +0530 | [diff] [blame] | 6839 | "Invalid Measurement Duration: %u", tempInt); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 6840 | return -EINVAL; |
| 6841 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 6842 | pEseBcnReq->bcnReq[j].measurementDuration = tempInt; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 6843 | break; |
| 6844 | } |
| 6845 | } |
| 6846 | } |
| 6847 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 6848 | for (j = 0; j < pEseBcnReq->numBcnReqIe; j++) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 6849 | { |
| 6850 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Arun Kumar Khandavalli | e876821 | 2014-02-17 16:43:34 +0530 | [diff] [blame] | 6851 | "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] | 6852 | j, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 6853 | pEseBcnReq->bcnReq[j].measurementToken, |
| 6854 | pEseBcnReq->bcnReq[j].channel, |
| 6855 | pEseBcnReq->bcnReq[j].scanMode, |
| 6856 | pEseBcnReq->bcnReq[j].measurementDuration); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 6857 | } |
| 6858 | |
| 6859 | return VOS_STATUS_SUCCESS; |
| 6860 | } |
| 6861 | |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 6862 | static void hdd_GetTsmStatsCB( tAniTrafStrmMetrics tsmMetrics, const tANI_U32 staId, void *pContext ) |
| 6863 | { |
| 6864 | struct statsContext *pStatsContext = NULL; |
| 6865 | hdd_adapter_t *pAdapter = NULL; |
| 6866 | |
| 6867 | if (NULL == pContext) |
| 6868 | { |
| 6869 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | c135a9a | 2017-09-19 08:37:24 -0700 | [diff] [blame] | 6870 | "%s: Bad param, pContext [%pK]", |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 6871 | __func__, pContext); |
| 6872 | return; |
| 6873 | } |
| 6874 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 6875 | /* there is a race condition that exists between this callback |
| 6876 | function and the caller since the caller could time out either |
| 6877 | before or while this code is executing. we use a spinlock to |
| 6878 | serialize these actions */ |
| 6879 | spin_lock(&hdd_context_lock); |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 6880 | |
| 6881 | pStatsContext = pContext; |
| 6882 | pAdapter = pStatsContext->pAdapter; |
| 6883 | if ((NULL == pAdapter) || (STATS_CONTEXT_MAGIC != pStatsContext->magic)) |
| 6884 | { |
| 6885 | /* the caller presumably timed out so there is nothing we can do */ |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 6886 | spin_unlock(&hdd_context_lock); |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 6887 | hddLog(VOS_TRACE_LEVEL_WARN, |
Jeff Johnson | c135a9a | 2017-09-19 08:37:24 -0700 | [diff] [blame] | 6888 | "%s: Invalid context, pAdapter [%pK] magic [%08x]", |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 6889 | __func__, pAdapter, pStatsContext->magic); |
| 6890 | return; |
| 6891 | } |
| 6892 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 6893 | /* context is valid so caller is still waiting */ |
| 6894 | |
| 6895 | /* paranoia: invalidate the magic */ |
| 6896 | pStatsContext->magic = 0; |
| 6897 | |
| 6898 | /* copy over the tsm stats */ |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 6899 | pAdapter->tsmStats.UplinkPktQueueDly = tsmMetrics.UplinkPktQueueDly; |
| 6900 | vos_mem_copy(pAdapter->tsmStats.UplinkPktQueueDlyHist, |
| 6901 | tsmMetrics.UplinkPktQueueDlyHist, |
| 6902 | sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist)/ |
| 6903 | sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist[0])); |
| 6904 | pAdapter->tsmStats.UplinkPktTxDly = tsmMetrics.UplinkPktTxDly; |
| 6905 | pAdapter->tsmStats.UplinkPktLoss = tsmMetrics.UplinkPktLoss; |
| 6906 | pAdapter->tsmStats.UplinkPktCount = tsmMetrics.UplinkPktCount; |
| 6907 | pAdapter->tsmStats.RoamingCount = tsmMetrics.RoamingCount; |
| 6908 | pAdapter->tsmStats.RoamingDly = tsmMetrics.RoamingDly; |
| 6909 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 6910 | /* notify the caller */ |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 6911 | complete(&pStatsContext->completion); |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 6912 | |
| 6913 | /* serialization is complete */ |
| 6914 | spin_unlock(&hdd_context_lock); |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 6915 | } |
| 6916 | |
| 6917 | |
| 6918 | |
| 6919 | static VOS_STATUS hdd_get_tsm_stats(hdd_adapter_t *pAdapter, const tANI_U8 tid, |
| 6920 | tAniTrafStrmMetrics* pTsmMetrics) |
| 6921 | { |
| 6922 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 6923 | eHalStatus hstatus; |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 6924 | VOS_STATUS vstatus = VOS_STATUS_SUCCESS; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 6925 | long lrc; |
| 6926 | struct statsContext context; |
| 6927 | hdd_context_t *pHddCtx = NULL; |
| 6928 | |
| 6929 | if (NULL == pAdapter) |
| 6930 | { |
| 6931 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: pAdapter is NULL", __func__); |
| 6932 | return VOS_STATUS_E_FAULT; |
| 6933 | } |
| 6934 | |
| 6935 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 6936 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 6937 | |
| 6938 | /* we are connected prepare our callback context */ |
| 6939 | init_completion(&context.completion); |
| 6940 | context.pAdapter = pAdapter; |
| 6941 | context.magic = STATS_CONTEXT_MAGIC; |
| 6942 | |
| 6943 | /* query tsm stats */ |
| 6944 | hstatus = sme_GetTsmStats(pHddCtx->hHal, hdd_GetTsmStatsCB, |
| 6945 | pHddStaCtx->conn_info.staId[ 0 ], |
| 6946 | pHddStaCtx->conn_info.bssId, |
| 6947 | &context, pHddCtx->pvosContext, tid); |
| 6948 | |
| 6949 | if (eHAL_STATUS_SUCCESS != hstatus) |
| 6950 | { |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 6951 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unable to retrieve statistics", |
| 6952 | __func__); |
| 6953 | vstatus = VOS_STATUS_E_FAULT; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 6954 | } |
| 6955 | else |
| 6956 | { |
| 6957 | /* request was sent -- wait for the response */ |
| 6958 | lrc = wait_for_completion_interruptible_timeout(&context.completion, |
| 6959 | msecs_to_jiffies(WLAN_WAIT_TIME_STATS)); |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 6960 | if (lrc <= 0) |
| 6961 | { |
| 6962 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6963 | "%s: SME %s while retrieving statistics", |
| 6964 | __func__, (0 == lrc) ? "timeout" : "interrupt"); |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 6965 | vstatus = VOS_STATUS_E_TIMEOUT; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 6966 | } |
| 6967 | } |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 6968 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 6969 | /* either we never sent a request, we sent a request and received a |
| 6970 | response or we sent a request and timed out. if we never sent a |
| 6971 | request or if we sent a request and got a response, we want to |
| 6972 | clear the magic out of paranoia. if we timed out there is a |
| 6973 | race condition such that the callback function could be |
| 6974 | executing at the same time we are. of primary concern is if the |
| 6975 | callback function had already verified the "magic" but had not |
| 6976 | yet set the completion variable when a timeout occurred. we |
| 6977 | serialize these activities by invalidating the magic while |
| 6978 | holding a shared spinlock which will cause us to block if the |
| 6979 | callback is currently executing */ |
| 6980 | spin_lock(&hdd_context_lock); |
| 6981 | context.magic = 0; |
| 6982 | spin_unlock(&hdd_context_lock); |
| 6983 | |
| 6984 | if (VOS_STATUS_SUCCESS == vstatus) |
| 6985 | { |
| 6986 | pTsmMetrics->UplinkPktQueueDly = pAdapter->tsmStats.UplinkPktQueueDly; |
| 6987 | vos_mem_copy(pTsmMetrics->UplinkPktQueueDlyHist, |
| 6988 | pAdapter->tsmStats.UplinkPktQueueDlyHist, |
| 6989 | sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist)/ |
| 6990 | sizeof(pAdapter->tsmStats.UplinkPktQueueDlyHist[0])); |
| 6991 | pTsmMetrics->UplinkPktTxDly = pAdapter->tsmStats.UplinkPktTxDly; |
| 6992 | pTsmMetrics->UplinkPktLoss = pAdapter->tsmStats.UplinkPktLoss; |
| 6993 | pTsmMetrics->UplinkPktCount = pAdapter->tsmStats.UplinkPktCount; |
| 6994 | pTsmMetrics->RoamingCount = pAdapter->tsmStats.RoamingCount; |
| 6995 | pTsmMetrics->RoamingDly = pAdapter->tsmStats.RoamingDly; |
| 6996 | } |
| 6997 | return vstatus; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 6998 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 6999 | #endif /*FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */ |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 7000 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 7001 | #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] | 7002 | void hdd_getBand_helper(hdd_context_t *pHddCtx, int *pBand) |
| 7003 | { |
| 7004 | eCsrBand band = -1; |
| 7005 | sme_GetFreqBand((tHalHandle)(pHddCtx->hHal), &band); |
| 7006 | switch (band) |
| 7007 | { |
| 7008 | case eCSR_BAND_ALL: |
| 7009 | *pBand = WLAN_HDD_UI_BAND_AUTO; |
| 7010 | break; |
| 7011 | |
| 7012 | case eCSR_BAND_24: |
| 7013 | *pBand = WLAN_HDD_UI_BAND_2_4_GHZ; |
| 7014 | break; |
| 7015 | |
| 7016 | case eCSR_BAND_5G: |
| 7017 | *pBand = WLAN_HDD_UI_BAND_5_GHZ; |
| 7018 | break; |
| 7019 | |
| 7020 | default: |
| 7021 | hddLog( VOS_TRACE_LEVEL_WARN, "%s: Invalid Band %d", __func__, band); |
| 7022 | *pBand = -1; |
| 7023 | break; |
| 7024 | } |
| 7025 | } |
| 7026 | |
| 7027 | /**--------------------------------------------------------------------------- |
| 7028 | |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 7029 | \brief hdd_parse_send_action_frame_data() - HDD Parse send action frame data |
| 7030 | |
| 7031 | This function parses the send action frame data passed in the format |
| 7032 | SENDACTIONFRAME<space><bssid><space><channel><space><dwelltime><space><data> |
| 7033 | |
Srinivas Girigowda | 5607685 | 2013-08-20 14:00:50 -0700 | [diff] [blame] | 7034 | \param - pValue Pointer to input data |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 7035 | \param - pTargetApBssid Pointer to target Ap bssid |
| 7036 | \param - pChannel Pointer to the Target AP channel |
| 7037 | \param - pDwellTime Pointer to the time to stay off-channel after transmitting action frame |
| 7038 | \param - pBuf Pointer to data |
| 7039 | \param - pBufLen Pointer to data length |
| 7040 | |
| 7041 | \return - 0 for success non-zero for failure |
| 7042 | |
| 7043 | --------------------------------------------------------------------------*/ |
| 7044 | VOS_STATUS hdd_parse_send_action_frame_data(tANI_U8 *pValue, tANI_U8 *pTargetApBssid, tANI_U8 *pChannel, |
| 7045 | tANI_U8 *pDwellTime, tANI_U8 **pBuf, tANI_U8 *pBufLen) |
| 7046 | { |
| 7047 | tANI_U8 *inPtr = pValue; |
| 7048 | tANI_U8 *dataEnd; |
| 7049 | int tempInt; |
| 7050 | int j = 0; |
| 7051 | int i = 0; |
| 7052 | int v = 0; |
| 7053 | tANI_U8 tempBuf[32]; |
| 7054 | tANI_U8 tempByte = 0; |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 7055 | /* 12 hexa decimal digits, 5 ':' and '\0' */ |
| 7056 | tANI_U8 macAddress[18]; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 7057 | |
| 7058 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 7059 | /*no argument after the command*/ |
| 7060 | if (NULL == inPtr) |
| 7061 | { |
| 7062 | return -EINVAL; |
| 7063 | } |
| 7064 | |
| 7065 | /*no space after the command*/ |
| 7066 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 7067 | { |
| 7068 | return -EINVAL; |
| 7069 | } |
| 7070 | |
| 7071 | /*removing empty spaces*/ |
| 7072 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 7073 | |
| 7074 | /*no argument followed by spaces*/ |
| 7075 | if ('\0' == *inPtr) |
| 7076 | { |
| 7077 | return -EINVAL; |
| 7078 | } |
| 7079 | |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 7080 | v = sscanf(inPtr, "%17s", macAddress); |
| 7081 | if (!((1 == v) && hdd_is_valid_mac_address(macAddress))) |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 7082 | { |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 7083 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7084 | "Invalid MAC address or All hex inputs are not read (%d)", v); |
| 7085 | return -EINVAL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 7086 | } |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 7087 | |
| 7088 | pTargetApBssid[0] = hdd_parse_hex(macAddress[0]) << 4 | hdd_parse_hex(macAddress[1]); |
| 7089 | pTargetApBssid[1] = hdd_parse_hex(macAddress[3]) << 4 | hdd_parse_hex(macAddress[4]); |
| 7090 | pTargetApBssid[2] = hdd_parse_hex(macAddress[6]) << 4 | hdd_parse_hex(macAddress[7]); |
| 7091 | pTargetApBssid[3] = hdd_parse_hex(macAddress[9]) << 4 | hdd_parse_hex(macAddress[10]); |
| 7092 | pTargetApBssid[4] = hdd_parse_hex(macAddress[12]) << 4 | hdd_parse_hex(macAddress[13]); |
| 7093 | 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] | 7094 | |
| 7095 | /* point to the next argument */ |
| 7096 | inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE); |
| 7097 | /*no argument after the command*/ |
| 7098 | if (NULL == inPtr) return -EINVAL; |
| 7099 | |
| 7100 | /*removing empty spaces*/ |
| 7101 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 7102 | |
| 7103 | /*no argument followed by spaces*/ |
| 7104 | if ('\0' == *inPtr) |
| 7105 | { |
| 7106 | return -EINVAL; |
| 7107 | } |
| 7108 | |
| 7109 | /*getting the next argument ie the channel number */ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 7110 | v = sscanf(inPtr, "%31s ", tempBuf); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 7111 | if (1 != v) return -EINVAL; |
| 7112 | |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 7113 | v = kstrtos32(tempBuf, 10, &tempInt); |
Agarwal Ashish | 353b3a8 | 2014-04-08 14:55:11 +0530 | [diff] [blame] | 7114 | if ( v < 0 || tempInt <= 0 || tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX ) |
Kiet Lam | be150c2 | 2013-11-21 16:30:32 +0530 | [diff] [blame] | 7115 | return -EINVAL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 7116 | |
| 7117 | *pChannel = tempInt; |
| 7118 | |
| 7119 | /* point to the next argument */ |
| 7120 | inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE); |
| 7121 | /*no argument after the command*/ |
| 7122 | if (NULL == inPtr) return -EINVAL; |
| 7123 | /*removing empty spaces*/ |
| 7124 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 7125 | |
| 7126 | /*no argument followed by spaces*/ |
| 7127 | if ('\0' == *inPtr) |
| 7128 | { |
| 7129 | return -EINVAL; |
| 7130 | } |
| 7131 | |
| 7132 | /*getting the next argument ie the dwell time */ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 7133 | v = sscanf(inPtr, "%31s ", tempBuf); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 7134 | if (1 != v) return -EINVAL; |
| 7135 | |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 7136 | v = kstrtos32(tempBuf, 10, &tempInt); |
Srinivas Girigowda | 5a6e067 | 2014-01-09 14:42:57 -0800 | [diff] [blame] | 7137 | if ( v < 0 || tempInt < 0) return -EINVAL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 7138 | |
| 7139 | *pDwellTime = tempInt; |
| 7140 | |
| 7141 | /* point to the next argument */ |
| 7142 | inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE); |
| 7143 | /*no argument after the command*/ |
| 7144 | if (NULL == inPtr) return -EINVAL; |
| 7145 | /*removing empty spaces*/ |
| 7146 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 7147 | |
| 7148 | /*no argument followed by spaces*/ |
| 7149 | if ('\0' == *inPtr) |
| 7150 | { |
| 7151 | return -EINVAL; |
| 7152 | } |
| 7153 | |
| 7154 | /* find the length of data */ |
| 7155 | dataEnd = inPtr; |
| 7156 | while(('\0' != *dataEnd) ) |
| 7157 | { |
| 7158 | dataEnd++; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 7159 | } |
Kiet Lam | be150c2 | 2013-11-21 16:30:32 +0530 | [diff] [blame] | 7160 | *pBufLen = dataEnd - inPtr ; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 7161 | if ( *pBufLen <= 0) return -EINVAL; |
| 7162 | |
Srinivas Girigowda | b5ae85d | 2013-06-03 10:51:45 -0700 | [diff] [blame] | 7163 | /* Allocate the number of bytes based on the number of input characters |
| 7164 | whether it is even or odd. |
| 7165 | if the number of input characters are even, then we need N/2 byte. |
| 7166 | if the number of input characters are odd, then we need do (N+1)/2 to |
| 7167 | compensate rounding off. |
| 7168 | For example, if N = 18, then (18 + 1)/2 = 9 bytes are enough. |
| 7169 | If N = 19, then we need 10 bytes, hence (19 + 1)/2 = 10 bytes */ |
| 7170 | *pBuf = vos_mem_malloc((*pBufLen + 1)/2); |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 7171 | if (NULL == *pBuf) |
| 7172 | { |
| 7173 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 7174 | "%s: vos_mem_alloc failed ", __func__); |
| 7175 | return -EINVAL; |
| 7176 | } |
| 7177 | |
| 7178 | /* the buffer received from the upper layer is character buffer, |
| 7179 | we need to prepare the buffer taking 2 characters in to a U8 hex decimal number |
| 7180 | for example 7f0000f0...form a buffer to contain 7f in 0th location, 00 in 1st |
| 7181 | and f0 in 3rd location */ |
| 7182 | for (i = 0, j = 0; j < *pBufLen; j += 2) |
| 7183 | { |
Kiet Lam | be150c2 | 2013-11-21 16:30:32 +0530 | [diff] [blame] | 7184 | if( j+1 == *pBufLen) |
| 7185 | { |
| 7186 | tempByte = hdd_parse_hex(inPtr[j]); |
| 7187 | } |
| 7188 | else |
| 7189 | { |
| 7190 | tempByte = (hdd_parse_hex(inPtr[j]) << 4) | (hdd_parse_hex(inPtr[j + 1])); |
| 7191 | } |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 7192 | (*pBuf)[i++] = tempByte; |
| 7193 | } |
| 7194 | *pBufLen = i; |
| 7195 | return VOS_STATUS_SUCCESS; |
| 7196 | } |
| 7197 | |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 7198 | /**--------------------------------------------------------------------------- |
| 7199 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 7200 | \brief hdd_parse_channellist() - HDD Parse channel list |
| 7201 | |
| 7202 | This function parses the channel list passed in the format |
| 7203 | 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] | 7204 | if the Number of channels (N) does not match with the actual number of channels passed |
| 7205 | then take the minimum of N and count of (Ch1, Ch2, ...Ch M) |
| 7206 | For example, if SETROAMSCANCHANNELS 3 36 40 44 48, only 36, 40 and 44 shall be taken. |
| 7207 | If SETROAMSCANCHANNELS 5 36 40 44 48, ignore 5 and take 36, 40, 44 and 48. |
| 7208 | 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] | 7209 | |
| 7210 | \param - pValue Pointer to input channel list |
| 7211 | \param - ChannelList Pointer to local output array to record channel list |
| 7212 | \param - pNumChannels Pointer to number of roam scan channels |
| 7213 | |
| 7214 | \return - 0 for success non-zero for failure |
| 7215 | |
| 7216 | --------------------------------------------------------------------------*/ |
| 7217 | VOS_STATUS hdd_parse_channellist(tANI_U8 *pValue, tANI_U8 *pChannelList, tANI_U8 *pNumChannels) |
| 7218 | { |
| 7219 | tANI_U8 *inPtr = pValue; |
| 7220 | int tempInt; |
| 7221 | int j = 0; |
| 7222 | int v = 0; |
| 7223 | char buf[32]; |
| 7224 | |
| 7225 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 7226 | /*no argument after the command*/ |
| 7227 | if (NULL == inPtr) |
| 7228 | { |
| 7229 | return -EINVAL; |
| 7230 | } |
| 7231 | |
| 7232 | /*no space after the command*/ |
| 7233 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 7234 | { |
| 7235 | return -EINVAL; |
| 7236 | } |
| 7237 | |
| 7238 | /*removing empty spaces*/ |
Jeff Johnson | a1f9afb | 2013-04-03 09:13:31 -0700 | [diff] [blame] | 7239 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 7240 | |
| 7241 | /*no argument followed by spaces*/ |
| 7242 | if ('\0' == *inPtr) |
| 7243 | { |
| 7244 | return -EINVAL; |
| 7245 | } |
| 7246 | |
| 7247 | /*getting the first argument ie the number of channels*/ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 7248 | v = sscanf(inPtr, "%31s ", buf); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 7249 | if (1 != v) return -EINVAL; |
| 7250 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 7251 | v = kstrtos32(buf, 10, &tempInt); |
Jeff Johnson | a1f9afb | 2013-04-03 09:13:31 -0700 | [diff] [blame] | 7252 | if ((v < 0) || |
| 7253 | (tempInt <= 0) || |
| 7254 | (tempInt > WNI_CFG_VALID_CHANNEL_LIST_LEN)) |
| 7255 | { |
| 7256 | return -EINVAL; |
| 7257 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 7258 | |
| 7259 | *pNumChannels = tempInt; |
| 7260 | |
| 7261 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
| 7262 | "Number of channels are: %d", *pNumChannels); |
| 7263 | |
| 7264 | for (j = 0; j < (*pNumChannels); j++) |
| 7265 | { |
| 7266 | /*inPtr pointing to the beginning of first space after number of channels*/ |
| 7267 | inPtr = strpbrk( inPtr, " " ); |
| 7268 | /*no channel list after the number of channels argument*/ |
| 7269 | if (NULL == inPtr) |
| 7270 | { |
Srinivas Girigowda | cf9a9b4 | 2013-03-21 11:55:24 -0700 | [diff] [blame] | 7271 | if (0 != j) |
| 7272 | { |
| 7273 | *pNumChannels = j; |
| 7274 | return VOS_STATUS_SUCCESS; |
| 7275 | } |
| 7276 | else |
| 7277 | { |
| 7278 | return -EINVAL; |
| 7279 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 7280 | } |
| 7281 | |
| 7282 | /*removing empty space*/ |
Jeff Johnson | a1f9afb | 2013-04-03 09:13:31 -0700 | [diff] [blame] | 7283 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 7284 | |
| 7285 | /*no channel list after the number of channels argument and spaces*/ |
| 7286 | if ( '\0' == *inPtr ) |
| 7287 | { |
Srinivas Girigowda | cf9a9b4 | 2013-03-21 11:55:24 -0700 | [diff] [blame] | 7288 | if (0 != j) |
| 7289 | { |
| 7290 | *pNumChannels = j; |
| 7291 | return VOS_STATUS_SUCCESS; |
| 7292 | } |
| 7293 | else |
| 7294 | { |
| 7295 | return -EINVAL; |
| 7296 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 7297 | } |
| 7298 | |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 7299 | v = sscanf(inPtr, "%31s ", buf); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 7300 | if (1 != v) return -EINVAL; |
| 7301 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 7302 | v = kstrtos32(buf, 10, &tempInt); |
Jeff Johnson | a1f9afb | 2013-04-03 09:13:31 -0700 | [diff] [blame] | 7303 | if ((v < 0) || |
| 7304 | (tempInt <= 0) || |
| 7305 | (tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX)) |
| 7306 | { |
| 7307 | return -EINVAL; |
| 7308 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 7309 | pChannelList[j] = tempInt; |
| 7310 | |
| 7311 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
| 7312 | "Channel %d added to preferred channel list", |
| 7313 | pChannelList[j] ); |
| 7314 | } |
| 7315 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 7316 | return VOS_STATUS_SUCCESS; |
| 7317 | } |
| 7318 | |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 7319 | |
Selvaraj, Sridhar | 5aff1ed | 2016-06-18 01:26:23 +0530 | [diff] [blame] | 7320 | /** |
| 7321 | * hdd_parse_reassoc_command_v1_data() - HDD Parse reassoc command data |
| 7322 | * This function parses the reasoc command data passed in the format |
| 7323 | * REASSOC<space><bssid><space><channel> |
| 7324 | * |
| 7325 | * @pValue: Pointer to input data (its a NUL terminated string) |
| 7326 | * @pTargetApBssid: Pointer to target Ap bssid |
| 7327 | * @pChannel: Pointer to the Target AP channel |
| 7328 | * |
| 7329 | * Return: 0 for success non-zero for failure |
| 7330 | */ |
| 7331 | static int hdd_parse_reassoc_command_v1_data(const tANI_U8 *pValue, |
| 7332 | tANI_U8 *pTargetApBssid, tANI_U8 *pChannel) |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 7333 | { |
Selvaraj, Sridhar | 5aff1ed | 2016-06-18 01:26:23 +0530 | [diff] [blame] | 7334 | const tANI_U8 *inPtr = pValue; |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 7335 | int tempInt; |
| 7336 | int v = 0; |
| 7337 | tANI_U8 tempBuf[32]; |
Kiet Lam | aa8e15a | 2014-02-11 23:30:06 -0800 | [diff] [blame] | 7338 | /* 12 hexa decimal digits, 5 ':' and '\0' */ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 7339 | tANI_U8 macAddress[18]; |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 7340 | |
| 7341 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 7342 | /*no argument after the command*/ |
| 7343 | if (NULL == inPtr) |
| 7344 | { |
| 7345 | return -EINVAL; |
| 7346 | } |
| 7347 | |
| 7348 | /*no space after the command*/ |
| 7349 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 7350 | { |
| 7351 | return -EINVAL; |
| 7352 | } |
| 7353 | |
| 7354 | /*removing empty spaces*/ |
| 7355 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 7356 | |
| 7357 | /*no argument followed by spaces*/ |
| 7358 | if ('\0' == *inPtr) |
| 7359 | { |
| 7360 | return -EINVAL; |
| 7361 | } |
| 7362 | |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 7363 | v = sscanf(inPtr, "%17s", macAddress); |
| 7364 | if (!((1 == v) && hdd_is_valid_mac_address(macAddress))) |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 7365 | { |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 7366 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7367 | "Invalid MAC address or All hex inputs are not read (%d)", v); |
| 7368 | return -EINVAL; |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 7369 | } |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 7370 | |
| 7371 | pTargetApBssid[0] = hdd_parse_hex(macAddress[0]) << 4 | hdd_parse_hex(macAddress[1]); |
| 7372 | pTargetApBssid[1] = hdd_parse_hex(macAddress[3]) << 4 | hdd_parse_hex(macAddress[4]); |
| 7373 | pTargetApBssid[2] = hdd_parse_hex(macAddress[6]) << 4 | hdd_parse_hex(macAddress[7]); |
| 7374 | pTargetApBssid[3] = hdd_parse_hex(macAddress[9]) << 4 | hdd_parse_hex(macAddress[10]); |
| 7375 | pTargetApBssid[4] = hdd_parse_hex(macAddress[12]) << 4 | hdd_parse_hex(macAddress[13]); |
| 7376 | 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] | 7377 | |
| 7378 | /* point to the next argument */ |
| 7379 | inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE); |
| 7380 | /*no argument after the command*/ |
| 7381 | if (NULL == inPtr) return -EINVAL; |
| 7382 | |
| 7383 | /*removing empty spaces*/ |
| 7384 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 7385 | |
| 7386 | /*no argument followed by spaces*/ |
| 7387 | if ('\0' == *inPtr) |
| 7388 | { |
| 7389 | return -EINVAL; |
| 7390 | } |
| 7391 | |
| 7392 | /*getting the next argument ie the channel number */ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 7393 | v = sscanf(inPtr, "%31s ", tempBuf); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 7394 | if (1 != v) return -EINVAL; |
| 7395 | |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 7396 | v = kstrtos32(tempBuf, 10, &tempInt); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 7397 | if ((v < 0) || |
Padma, Santhosh Kumar | 0fa809b | 2014-11-13 14:56:56 +0530 | [diff] [blame] | 7398 | (tempInt < 0) || |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 7399 | (tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX)) |
| 7400 | { |
| 7401 | return -EINVAL; |
| 7402 | } |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 7403 | |
| 7404 | *pChannel = tempInt; |
| 7405 | return VOS_STATUS_SUCCESS; |
| 7406 | } |
| 7407 | |
| 7408 | #endif |
| 7409 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 7410 | #if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD) |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 7411 | /**--------------------------------------------------------------------------- |
| 7412 | |
| 7413 | \brief hdd_parse_get_cckm_ie() - HDD Parse and fetch the CCKM IE |
| 7414 | |
| 7415 | This function parses the SETCCKM IE command |
| 7416 | SETCCKMIE<space><ie data> |
| 7417 | |
| 7418 | \param - pValue Pointer to input data |
| 7419 | \param - pCckmIe Pointer to output cckm Ie |
| 7420 | \param - pCckmIeLen Pointer to output cckm ie length |
| 7421 | |
| 7422 | \return - 0 for success non-zero for failure |
| 7423 | |
| 7424 | --------------------------------------------------------------------------*/ |
| 7425 | VOS_STATUS hdd_parse_get_cckm_ie(tANI_U8 *pValue, tANI_U8 **pCckmIe, |
| 7426 | tANI_U8 *pCckmIeLen) |
| 7427 | { |
| 7428 | tANI_U8 *inPtr = pValue; |
| 7429 | tANI_U8 *dataEnd; |
| 7430 | int j = 0; |
| 7431 | int i = 0; |
| 7432 | tANI_U8 tempByte = 0; |
| 7433 | |
| 7434 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 7435 | /*no argument after the command*/ |
| 7436 | if (NULL == inPtr) |
| 7437 | { |
| 7438 | return -EINVAL; |
| 7439 | } |
| 7440 | |
| 7441 | /*no space after the command*/ |
| 7442 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 7443 | { |
| 7444 | return -EINVAL; |
| 7445 | } |
| 7446 | |
| 7447 | /*removing empty spaces*/ |
| 7448 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 7449 | |
| 7450 | /*no argument followed by spaces*/ |
| 7451 | if ('\0' == *inPtr) |
| 7452 | { |
| 7453 | return -EINVAL; |
| 7454 | } |
| 7455 | |
| 7456 | /* find the length of data */ |
| 7457 | dataEnd = inPtr; |
| 7458 | while(('\0' != *dataEnd) ) |
| 7459 | { |
| 7460 | dataEnd++; |
| 7461 | ++(*pCckmIeLen); |
| 7462 | } |
| 7463 | if ( *pCckmIeLen <= 0) return -EINVAL; |
| 7464 | |
| 7465 | /* Allocate the number of bytes based on the number of input characters |
| 7466 | whether it is even or odd. |
| 7467 | if the number of input characters are even, then we need N/2 byte. |
| 7468 | if the number of input characters are odd, then we need do (N+1)/2 to |
| 7469 | compensate rounding off. |
| 7470 | For example, if N = 18, then (18 + 1)/2 = 9 bytes are enough. |
| 7471 | If N = 19, then we need 10 bytes, hence (19 + 1)/2 = 10 bytes */ |
| 7472 | *pCckmIe = vos_mem_malloc((*pCckmIeLen + 1)/2); |
| 7473 | if (NULL == *pCckmIe) |
| 7474 | { |
| 7475 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 7476 | "%s: vos_mem_alloc failed ", __func__); |
| 7477 | return -EINVAL; |
| 7478 | } |
| 7479 | vos_mem_zero(*pCckmIe, (*pCckmIeLen + 1)/2); |
| 7480 | /* the buffer received from the upper layer is character buffer, |
| 7481 | we need to prepare the buffer taking 2 characters in to a U8 hex decimal number |
| 7482 | for example 7f0000f0...form a buffer to contain 7f in 0th location, 00 in 1st |
| 7483 | and f0 in 3rd location */ |
| 7484 | for (i = 0, j = 0; j < *pCckmIeLen; j += 2) |
| 7485 | { |
| 7486 | tempByte = (hdd_parse_hex(inPtr[j]) << 4) | (hdd_parse_hex(inPtr[j + 1])); |
| 7487 | (*pCckmIe)[i++] = tempByte; |
| 7488 | } |
| 7489 | *pCckmIeLen = i; |
| 7490 | |
| 7491 | return VOS_STATUS_SUCCESS; |
| 7492 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 7493 | #endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */ |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 7494 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7495 | /**--------------------------------------------------------------------------- |
| 7496 | |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 7497 | \brief hdd_is_valid_mac_address() - Validate MAC address |
| 7498 | |
| 7499 | This function validates whether the given MAC address is valid or not |
| 7500 | Expected MAC address is of the format XX:XX:XX:XX:XX:XX |
| 7501 | where X is the hexa decimal digit character and separated by ':' |
| 7502 | This algorithm works even if MAC address is not separated by ':' |
| 7503 | |
| 7504 | This code checks given input string mac contains exactly 12 hexadecimal digits. |
| 7505 | and a separator colon : appears in the input string only after |
| 7506 | an even number of hex digits. |
| 7507 | |
| 7508 | \param - pMacAddr pointer to the input MAC address |
| 7509 | \return - 1 for valid and 0 for invalid |
| 7510 | |
| 7511 | --------------------------------------------------------------------------*/ |
| 7512 | |
| 7513 | v_BOOL_t hdd_is_valid_mac_address(const tANI_U8 *pMacAddr) |
| 7514 | { |
| 7515 | int xdigit = 0; |
| 7516 | int separator = 0; |
| 7517 | while (*pMacAddr) |
| 7518 | { |
| 7519 | if (isxdigit(*pMacAddr)) |
| 7520 | { |
| 7521 | xdigit++; |
| 7522 | } |
| 7523 | else if (':' == *pMacAddr) |
| 7524 | { |
| 7525 | if (0 == xdigit || ((xdigit / 2) - 1) != separator) |
| 7526 | break; |
| 7527 | |
| 7528 | ++separator; |
| 7529 | } |
| 7530 | else |
| 7531 | { |
| 7532 | separator = -1; |
| 7533 | /* Invalid MAC found */ |
| 7534 | return 0; |
| 7535 | } |
| 7536 | ++pMacAddr; |
| 7537 | } |
| 7538 | return (xdigit == 12 && (separator == 5 || separator == 0)); |
| 7539 | } |
| 7540 | |
| 7541 | /**--------------------------------------------------------------------------- |
| 7542 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 7543 | \brief __hdd_open() - HDD Open function |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7544 | |
| 7545 | \param - dev Pointer to net_device structure |
| 7546 | |
| 7547 | \return - 0 for success non-zero for failure |
| 7548 | |
| 7549 | --------------------------------------------------------------------------*/ |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 7550 | int __hdd_open(struct net_device *dev) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7551 | { |
| 7552 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7553 | hdd_context_t *pHddCtx; |
| 7554 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7555 | VOS_STATUS status; |
| 7556 | v_BOOL_t in_standby = TRUE; |
| 7557 | |
| 7558 | if (NULL == pAdapter) |
| 7559 | { |
| 7560 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Agarwal Ashish | 971c288 | 2013-10-30 20:11:12 +0530 | [diff] [blame] | 7561 | "%s: pAdapter is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7562 | return -ENODEV; |
| 7563 | } |
| 7564 | |
| 7565 | pHddCtx = (hdd_context_t*)pAdapter->pHddCtx; |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 7566 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_OPEN_REQUEST, |
| 7567 | pAdapter->sessionId, pAdapter->device_mode)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7568 | if (NULL == pHddCtx) |
| 7569 | { |
| 7570 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7571 | "%s: HDD context is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7572 | return -ENODEV; |
| 7573 | } |
| 7574 | |
| 7575 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7576 | while ( (NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status) ) |
| 7577 | { |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 7578 | if (test_bit(DEVICE_IFACE_OPENED, &pAdapterNode->pAdapter->event_flags)) |
| 7579 | { |
| 7580 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: chip already out of standby", |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 7581 | __func__); |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 7582 | in_standby = FALSE; |
| 7583 | break; |
| 7584 | } |
| 7585 | else |
| 7586 | { |
| 7587 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7588 | pAdapterNode = pNext; |
| 7589 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7590 | } |
| 7591 | |
| 7592 | if (TRUE == in_standby) |
| 7593 | { |
| 7594 | if (VOS_STATUS_SUCCESS != wlan_hdd_exit_lowpower(pHddCtx, pAdapter)) |
| 7595 | { |
| 7596 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failed to bring " |
| 7597 | "wlan out of power save", __func__); |
| 7598 | return -EINVAL; |
| 7599 | } |
| 7600 | } |
| 7601 | |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 7602 | set_bit(DEVICE_IFACE_OPENED, &pAdapter->event_flags); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7603 | if (hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) |
| 7604 | { |
| 7605 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7606 | "%s: Enabling Tx Queues", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7607 | /* Enable TX queues only when we are connected */ |
Padma, Santhosh Kumar | 9dacb5c | 2014-12-17 19:22:56 +0530 | [diff] [blame] | 7608 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7609 | netif_tx_start_all_queues(dev); |
| 7610 | } |
| 7611 | |
| 7612 | return 0; |
| 7613 | } |
| 7614 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 7615 | /**--------------------------------------------------------------------------- |
| 7616 | |
| 7617 | \brief hdd_open() - Wrapper function for __hdd_open to protect it from SSR |
| 7618 | |
| 7619 | This is called in response to ifconfig up |
| 7620 | |
| 7621 | \param - dev Pointer to net_device structure |
| 7622 | |
| 7623 | \return - 0 for success non-zero for failure |
| 7624 | |
| 7625 | --------------------------------------------------------------------------*/ |
| 7626 | int hdd_open(struct net_device *dev) |
| 7627 | { |
| 7628 | int ret; |
| 7629 | |
| 7630 | vos_ssr_protect(__func__); |
| 7631 | ret = __hdd_open(dev); |
| 7632 | vos_ssr_unprotect(__func__); |
| 7633 | |
| 7634 | return ret; |
| 7635 | } |
| 7636 | |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 7637 | int __hdd_mon_open (struct net_device *dev) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7638 | { |
| 7639 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 7640 | hdd_adapter_t *sta_adapter; |
| 7641 | hdd_context_t *hdd_ctx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7642 | |
| 7643 | if(pAdapter == NULL) { |
| 7644 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7645 | "%s: HDD adapter context is Null", __func__); |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 7646 | return -EINVAL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7647 | } |
| 7648 | |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 7649 | if (vos_get_concurrency_mode() != VOS_STA_MON) |
| 7650 | return 0; |
| 7651 | |
| 7652 | hdd_ctx = WLAN_HDD_GET_CTX(pAdapter); |
| 7653 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 7654 | return -EINVAL; |
| 7655 | |
| 7656 | sta_adapter = hdd_get_adapter(hdd_ctx, WLAN_HDD_INFRA_STATION); |
| 7657 | if (!sta_adapter) { |
| 7658 | hddLog(LOGE, FL("No valid STA interface")); |
| 7659 | return -EINVAL; |
| 7660 | } |
| 7661 | |
| 7662 | if (!test_bit(DEVICE_IFACE_OPENED, &sta_adapter->event_flags)) { |
| 7663 | hddLog(LOGE, FL("STA Interface is not OPENED")); |
| 7664 | return -EINVAL; |
| 7665 | } |
| 7666 | |
| 7667 | set_bit(DEVICE_IFACE_OPENED, &pAdapter->event_flags); |
| 7668 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7669 | return 0; |
| 7670 | } |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 7671 | |
| 7672 | int hdd_mon_open (struct net_device *dev) |
| 7673 | { |
| 7674 | int ret; |
| 7675 | |
| 7676 | vos_ssr_protect(__func__); |
| 7677 | ret = __hdd_mon_open(dev); |
| 7678 | vos_ssr_unprotect(__func__); |
| 7679 | |
| 7680 | return ret; |
| 7681 | } |
| 7682 | |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 7683 | int __hdd_mon_stop (struct net_device *dev) |
| 7684 | { |
| 7685 | hdd_adapter_t *mon_adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7686 | hdd_context_t *hdd_ctx; |
| 7687 | |
| 7688 | if (vos_get_concurrency_mode() != VOS_STA_MON) |
| 7689 | return 0; |
| 7690 | |
| 7691 | if(!mon_adapter) { |
| 7692 | hddLog(LOGE, FL("HDD adapter is Null")); |
| 7693 | return -EINVAL; |
| 7694 | } |
| 7695 | |
| 7696 | hdd_ctx = WLAN_HDD_GET_CTX(mon_adapter); |
| 7697 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 7698 | return -EINVAL; |
| 7699 | |
| 7700 | if (!test_bit(DEVICE_IFACE_OPENED, &mon_adapter->event_flags)) { |
| 7701 | hddLog(LOGE, FL("NETDEV Interface is not OPENED")); |
| 7702 | return -ENODEV; |
| 7703 | } |
| 7704 | |
| 7705 | clear_bit(DEVICE_IFACE_OPENED, &mon_adapter->event_flags); |
| 7706 | hdd_stop_adapter(hdd_ctx, mon_adapter, VOS_FALSE); |
| 7707 | |
| 7708 | return 0; |
| 7709 | } |
| 7710 | |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 7711 | int hdd_mon_stop(struct net_device *dev) |
| 7712 | { |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 7713 | int ret; |
| 7714 | |
| 7715 | vos_ssr_protect(__func__); |
| 7716 | ret = __hdd_mon_stop(dev); |
| 7717 | vos_ssr_unprotect(__func__); |
| 7718 | |
| 7719 | return ret; |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 7720 | } |
| 7721 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7722 | /**--------------------------------------------------------------------------- |
| 7723 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 7724 | \brief __hdd_stop() - HDD stop function |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7725 | |
| 7726 | \param - dev Pointer to net_device structure |
| 7727 | |
| 7728 | \return - 0 for success non-zero for failure |
| 7729 | |
| 7730 | --------------------------------------------------------------------------*/ |
| 7731 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 7732 | int __hdd_stop (struct net_device *dev) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7733 | { |
Vinay Krishna Eranna | 90f4353 | 2014-10-27 16:45:54 +0530 | [diff] [blame] | 7734 | int ret = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7735 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7736 | hdd_context_t *pHddCtx; |
| 7737 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 7738 | VOS_STATUS status; |
| 7739 | v_BOOL_t enter_standby = TRUE; |
| 7740 | |
| 7741 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7742 | if (NULL == pAdapter) |
| 7743 | { |
| 7744 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Agarwal Ashish | 971c288 | 2013-10-30 20:11:12 +0530 | [diff] [blame] | 7745 | "%s: pAdapter is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7746 | return -ENODEV; |
| 7747 | } |
Sachin Ahuja | 9b4958f | 2015-01-15 21:37:00 +0530 | [diff] [blame] | 7748 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_STOP_REQUEST, |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 7749 | pAdapter->sessionId, pAdapter->device_mode)); |
Vinay Krishna Eranna | 90f4353 | 2014-10-27 16:45:54 +0530 | [diff] [blame] | 7750 | |
| 7751 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 7752 | ret = wlan_hdd_validate_context(pHddCtx); |
| 7753 | if (ret) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7754 | { |
Vinay Krishna Eranna | 90f4353 | 2014-10-27 16:45:54 +0530 | [diff] [blame] | 7755 | return ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7756 | } |
| 7757 | |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 7758 | /* Nothing to be done if the interface is not opened */ |
| 7759 | if (VOS_FALSE == test_bit(DEVICE_IFACE_OPENED, &pAdapter->event_flags)) |
| 7760 | { |
| 7761 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7762 | "%s: NETDEV Interface is not OPENED", __func__); |
| 7763 | return -ENODEV; |
| 7764 | } |
| 7765 | |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 7766 | if (pHddCtx->concurrency_mode == VOS_STA_MON) { |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 7767 | /* |
Rajeev Kumar Sirasanagandla | a74e122 | 2018-01-09 17:38:55 +0530 | [diff] [blame] | 7768 | * In STA + Monitor mode concurrency, no point in running |
| 7769 | * capture on monitor interface, when STA interface is stopped |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 7770 | */ |
Rajeev Kumar Sirasanagandla | a74e122 | 2018-01-09 17:38:55 +0530 | [diff] [blame] | 7771 | wlan_hdd_stop_mon(pHddCtx, true); |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 7772 | } |
| 7773 | |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 7774 | /* Make sure the interface is marked as closed */ |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 7775 | clear_bit(DEVICE_IFACE_OPENED, &pAdapter->event_flags); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7776 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disabling OS Tx queues", __func__); |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 7777 | |
| 7778 | /* Disable TX on the interface, after this hard_start_xmit() will not |
| 7779 | * be called on that interface |
| 7780 | */ |
Padma, Santhosh Kumar | 9dacb5c | 2014-12-17 19:22:56 +0530 | [diff] [blame] | 7781 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7782 | netif_tx_disable(pAdapter->dev); |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 7783 | |
| 7784 | /* Mark the interface status as "down" for outside world */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7785 | netif_carrier_off(pAdapter->dev); |
| 7786 | |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 7787 | /* The interface is marked as down for outside world (aka kernel) |
| 7788 | * But the driver is pretty much alive inside. The driver needs to |
| 7789 | * tear down the existing connection on the netdev (session) |
| 7790 | * cleanup the data pipes and wait until the control plane is stabilized |
| 7791 | * for this interface. The call also needs to wait until the above |
| 7792 | * mentioned actions are completed before returning to the caller. |
| 7793 | * Notice that the hdd_stop_adapter is requested not to close the session |
| 7794 | * That is intentional to be able to scan if it is a STA/P2P interface |
| 7795 | */ |
| 7796 | hdd_stop_adapter(pHddCtx, pAdapter, VOS_FALSE); |
Mahesh A Saptasagar | 02e36e8 | 2015-01-14 20:39:19 +0530 | [diff] [blame] | 7797 | #ifdef FEATURE_WLAN_TDLS |
| 7798 | mutex_lock(&pHddCtx->tdls_lock); |
| 7799 | #endif |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 7800 | /* DeInit the adapter. This ensures datapath cleanup as well */ |
c_hpothu | 002231a | 2015-02-05 14:58:51 +0530 | [diff] [blame] | 7801 | hdd_deinit_adapter(pHddCtx, pAdapter, TRUE); |
Mahesh A Saptasagar | 02e36e8 | 2015-01-14 20:39:19 +0530 | [diff] [blame] | 7802 | #ifdef FEATURE_WLAN_TDLS |
| 7803 | mutex_unlock(&pHddCtx->tdls_lock); |
| 7804 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7805 | /* SoftAP ifaces should never go in power save mode |
| 7806 | making sure same here. */ |
| 7807 | if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7808 | || (WLAN_HDD_P2P_GO == pAdapter->device_mode ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7809 | ) |
| 7810 | { |
| 7811 | /* SoftAP mode, so return from here */ |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7812 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 7813 | "%s: In SAP MODE", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7814 | EXIT(); |
| 7815 | return 0; |
| 7816 | } |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 7817 | /* Find if any iface is up. If any iface is up then can't put device to |
| 7818 | * sleep/power save mode |
| 7819 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7820 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 7821 | while ( (NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status) ) |
| 7822 | { |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 7823 | if (test_bit(DEVICE_IFACE_OPENED, &pAdapterNode->pAdapter->event_flags)) |
| 7824 | { |
| 7825 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Still other ifaces are up cannot " |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 7826 | "put device to sleep", __func__); |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 7827 | enter_standby = FALSE; |
| 7828 | break; |
| 7829 | } |
| 7830 | else |
| 7831 | { |
| 7832 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 7833 | pAdapterNode = pNext; |
| 7834 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7835 | } |
| 7836 | |
| 7837 | if (TRUE == enter_standby) |
| 7838 | { |
| 7839 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: All Interfaces are Down " |
| 7840 | "entering standby", __func__); |
| 7841 | if (VOS_STATUS_SUCCESS != wlan_hdd_enter_lowpower(pHddCtx)) |
| 7842 | { |
| 7843 | /*log and return success*/ |
| 7844 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failed to put " |
| 7845 | "wlan in power save", __func__); |
| 7846 | } |
| 7847 | } |
| 7848 | |
| 7849 | EXIT(); |
| 7850 | return 0; |
| 7851 | } |
| 7852 | |
| 7853 | /**--------------------------------------------------------------------------- |
| 7854 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 7855 | \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] | 7856 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 7857 | This is called in response to ifconfig down |
| 7858 | |
| 7859 | \param - dev Pointer to net_device structure |
| 7860 | |
| 7861 | \return - 0 for success non-zero for failure |
| 7862 | -----------------------------------------------------------------------------*/ |
| 7863 | int hdd_stop (struct net_device *dev) |
| 7864 | { |
| 7865 | int ret; |
| 7866 | |
| 7867 | vos_ssr_protect(__func__); |
| 7868 | ret = __hdd_stop(dev); |
| 7869 | vos_ssr_unprotect(__func__); |
| 7870 | |
| 7871 | return ret; |
| 7872 | } |
| 7873 | |
| 7874 | /**--------------------------------------------------------------------------- |
| 7875 | |
| 7876 | \brief __hdd_uninit() - HDD uninit function |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7877 | |
| 7878 | \param - dev Pointer to net_device structure |
| 7879 | |
| 7880 | \return - void |
| 7881 | |
| 7882 | --------------------------------------------------------------------------*/ |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 7883 | static void __hdd_uninit (struct net_device *dev) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7884 | { |
| 7885 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Mahesh A Saptasagar | 02e36e8 | 2015-01-14 20:39:19 +0530 | [diff] [blame] | 7886 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7887 | ENTER(); |
| 7888 | |
| 7889 | do |
| 7890 | { |
| 7891 | if (NULL == pAdapter) |
| 7892 | { |
| 7893 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 7894 | "%s: NULL pAdapter", __func__); |
| 7895 | break; |
| 7896 | } |
| 7897 | |
| 7898 | if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) |
| 7899 | { |
| 7900 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 7901 | "%s: Invalid magic", __func__); |
| 7902 | break; |
| 7903 | } |
Mahesh A Saptasagar | 02e36e8 | 2015-01-14 20:39:19 +0530 | [diff] [blame] | 7904 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 7905 | if (NULL == pHddCtx) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7906 | { |
| 7907 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 7908 | "%s: NULL pHddCtx", __func__); |
| 7909 | break; |
| 7910 | } |
| 7911 | |
| 7912 | if (dev != pAdapter->dev) |
| 7913 | { |
| 7914 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 7915 | "%s: Invalid device reference", __func__); |
| 7916 | /* we haven't validated all cases so let this go for now */ |
| 7917 | } |
Mahesh A Saptasagar | 02e36e8 | 2015-01-14 20:39:19 +0530 | [diff] [blame] | 7918 | #ifdef FEATURE_WLAN_TDLS |
| 7919 | mutex_lock(&pHddCtx->tdls_lock); |
| 7920 | #endif |
c_hpothu | 002231a | 2015-02-05 14:58:51 +0530 | [diff] [blame] | 7921 | hdd_deinit_adapter(pHddCtx, pAdapter, TRUE); |
Mahesh A Saptasagar | 02e36e8 | 2015-01-14 20:39:19 +0530 | [diff] [blame] | 7922 | #ifdef FEATURE_WLAN_TDLS |
| 7923 | mutex_unlock(&pHddCtx->tdls_lock); |
| 7924 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7925 | |
| 7926 | /* after uninit our adapter structure will no longer be valid */ |
| 7927 | pAdapter->dev = NULL; |
| 7928 | pAdapter->magic = 0; |
Manjeet Singh | 47ee847 | 2016-04-11 11:57:18 +0530 | [diff] [blame] | 7929 | pAdapter->pHddCtx = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7930 | } while (0); |
| 7931 | |
| 7932 | EXIT(); |
| 7933 | } |
| 7934 | |
| 7935 | /**--------------------------------------------------------------------------- |
| 7936 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 7937 | \brief hdd_uninit() - Wrapper function to protect __hdd_uninit from SSR |
| 7938 | |
| 7939 | This is called during the netdev unregister to uninitialize all data |
| 7940 | associated with the device |
| 7941 | |
| 7942 | \param - dev Pointer to net_device structure |
| 7943 | |
| 7944 | \return - void |
| 7945 | |
| 7946 | --------------------------------------------------------------------------*/ |
| 7947 | static void hdd_uninit (struct net_device *dev) |
| 7948 | { |
| 7949 | vos_ssr_protect(__func__); |
| 7950 | __hdd_uninit(dev); |
| 7951 | vos_ssr_unprotect(__func__); |
| 7952 | } |
| 7953 | |
| 7954 | /**--------------------------------------------------------------------------- |
| 7955 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7956 | \brief hdd_release_firmware() - |
| 7957 | |
| 7958 | This function calls the release firmware API to free the firmware buffer. |
| 7959 | |
| 7960 | \param - pFileName Pointer to the File Name. |
| 7961 | pCtx - Pointer to the adapter . |
| 7962 | |
| 7963 | |
| 7964 | \return - 0 for success, non zero for failure |
| 7965 | |
| 7966 | --------------------------------------------------------------------------*/ |
| 7967 | |
| 7968 | VOS_STATUS hdd_release_firmware(char *pFileName,v_VOID_t *pCtx) |
| 7969 | { |
| 7970 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 7971 | hdd_context_t *pHddCtx = (hdd_context_t*)pCtx; |
| 7972 | ENTER(); |
| 7973 | |
| 7974 | |
| 7975 | if (!strcmp(WLAN_FW_FILE, pFileName)) { |
| 7976 | |
| 7977 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"%s: Loaded firmware file is %s",__func__,pFileName); |
| 7978 | |
| 7979 | if(pHddCtx->fw) { |
| 7980 | release_firmware(pHddCtx->fw); |
| 7981 | pHddCtx->fw = NULL; |
| 7982 | } |
| 7983 | else |
| 7984 | status = VOS_STATUS_E_FAILURE; |
| 7985 | } |
| 7986 | else if (!strcmp(WLAN_NV_FILE,pFileName)) { |
| 7987 | if(pHddCtx->nv) { |
| 7988 | release_firmware(pHddCtx->nv); |
| 7989 | pHddCtx->nv = NULL; |
| 7990 | } |
| 7991 | else |
| 7992 | status = VOS_STATUS_E_FAILURE; |
| 7993 | |
| 7994 | } |
| 7995 | |
| 7996 | EXIT(); |
| 7997 | return status; |
| 7998 | } |
| 7999 | |
| 8000 | /**--------------------------------------------------------------------------- |
| 8001 | |
| 8002 | \brief hdd_request_firmware() - |
| 8003 | |
| 8004 | This function reads the firmware file using the request firmware |
| 8005 | API and returns the the firmware data and the firmware file size. |
| 8006 | |
| 8007 | \param - pfileName - Pointer to the file name. |
| 8008 | - pCtx - Pointer to the adapter . |
| 8009 | - ppfw_data - Pointer to the pointer of the firmware data. |
| 8010 | - pSize - Pointer to the file size. |
| 8011 | |
| 8012 | \return - VOS_STATUS_SUCCESS for success, VOS_STATUS_E_FAILURE for failure |
| 8013 | |
| 8014 | --------------------------------------------------------------------------*/ |
| 8015 | |
| 8016 | |
| 8017 | VOS_STATUS hdd_request_firmware(char *pfileName,v_VOID_t *pCtx,v_VOID_t **ppfw_data, v_SIZE_t *pSize) |
| 8018 | { |
| 8019 | int status; |
| 8020 | VOS_STATUS retval = VOS_STATUS_SUCCESS; |
| 8021 | hdd_context_t *pHddCtx = (hdd_context_t*)pCtx; |
| 8022 | ENTER(); |
| 8023 | |
| 8024 | if( (!strcmp(WLAN_FW_FILE, pfileName)) ) { |
| 8025 | |
| 8026 | status = request_firmware(&pHddCtx->fw, pfileName, pHddCtx->parent_dev); |
| 8027 | |
| 8028 | if(status || !pHddCtx->fw || !pHddCtx->fw->data) { |
| 8029 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Firmware %s download failed", |
| 8030 | __func__, pfileName); |
| 8031 | retval = VOS_STATUS_E_FAILURE; |
| 8032 | } |
| 8033 | |
| 8034 | else { |
| 8035 | *ppfw_data = (v_VOID_t *)pHddCtx->fw->data; |
| 8036 | *pSize = pHddCtx->fw->size; |
| 8037 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Firmware size = %d", |
| 8038 | __func__, *pSize); |
| 8039 | } |
| 8040 | } |
| 8041 | else if(!strcmp(WLAN_NV_FILE, pfileName)) { |
| 8042 | |
| 8043 | status = request_firmware(&pHddCtx->nv, pfileName, pHddCtx->parent_dev); |
| 8044 | |
| 8045 | if(status || !pHddCtx->nv || !pHddCtx->nv->data) { |
| 8046 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: nv %s download failed", |
| 8047 | __func__, pfileName); |
| 8048 | retval = VOS_STATUS_E_FAILURE; |
| 8049 | } |
| 8050 | |
| 8051 | else { |
| 8052 | *ppfw_data = (v_VOID_t *)pHddCtx->nv->data; |
| 8053 | *pSize = pHddCtx->nv->size; |
| 8054 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: nv file size = %d", |
| 8055 | __func__, *pSize); |
| 8056 | } |
| 8057 | } |
| 8058 | |
| 8059 | EXIT(); |
| 8060 | return retval; |
| 8061 | } |
| 8062 | /**--------------------------------------------------------------------------- |
| 8063 | \brief hdd_full_pwr_cbk() - HDD full power callbackfunction |
| 8064 | |
| 8065 | This is the function invoked by SME to inform the result of a full power |
| 8066 | request issued by HDD |
| 8067 | |
| 8068 | \param - callbackcontext - Pointer to cookie |
| 8069 | status - result of request |
| 8070 | |
| 8071 | \return - None |
| 8072 | |
| 8073 | --------------------------------------------------------------------------*/ |
| 8074 | void hdd_full_pwr_cbk(void *callbackContext, eHalStatus status) |
| 8075 | { |
| 8076 | hdd_context_t *pHddCtx = (hdd_context_t*)callbackContext; |
| 8077 | |
Madan Mohan Koyyalamudi | 8bdd311 | 2012-09-24 13:55:14 -0700 | [diff] [blame] | 8078 | 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] | 8079 | if(&pHddCtx->full_pwr_comp_var) |
| 8080 | { |
| 8081 | complete(&pHddCtx->full_pwr_comp_var); |
| 8082 | } |
| 8083 | } |
| 8084 | |
Abhishek Singh | 00b7197 | 2016-01-07 10:51:04 +0530 | [diff] [blame] | 8085 | #ifdef WLAN_FEATURE_RMC |
| 8086 | static void hdd_tx_fail_ind_callback(v_U8_t *MacAddr, v_U8_t seqNo) |
| 8087 | { |
| 8088 | int payload_len; |
| 8089 | struct sk_buff *skb; |
| 8090 | struct nlmsghdr *nlh; |
| 8091 | v_U8_t *data; |
| 8092 | |
| 8093 | payload_len = ETH_ALEN; |
| 8094 | |
| 8095 | if (0 == cesium_pid) |
| 8096 | { |
| 8097 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: cesium process not registered", |
| 8098 | __func__); |
| 8099 | return; |
| 8100 | } |
| 8101 | |
| 8102 | if ((skb = nlmsg_new(payload_len,GFP_ATOMIC)) == NULL) |
| 8103 | { |
| 8104 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8105 | "%s: nlmsg_new() failed for msg size[%d]", |
| 8106 | __func__, NLMSG_SPACE(payload_len)); |
| 8107 | return; |
| 8108 | } |
| 8109 | |
| 8110 | nlh = nlmsg_put(skb, cesium_pid, seqNo, 0, payload_len, NLM_F_REQUEST); |
| 8111 | |
| 8112 | if (NULL == nlh) |
| 8113 | { |
| 8114 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8115 | "%s: nlmsg_put() failed for msg size[%d]", |
| 8116 | __func__, NLMSG_SPACE(payload_len)); |
| 8117 | |
| 8118 | kfree_skb(skb); |
| 8119 | return; |
| 8120 | } |
| 8121 | |
| 8122 | data = nlmsg_data(nlh); |
| 8123 | memcpy(data, MacAddr, ETH_ALEN); |
| 8124 | |
| 8125 | if (nlmsg_unicast(cesium_nl_srv_sock, skb, cesium_pid) < 0) |
| 8126 | { |
| 8127 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: nlmsg_unicast() failed for msg size[%d]", |
| 8128 | __func__, NLMSG_SPACE(payload_len)); |
| 8129 | } |
| 8130 | |
| 8131 | return; |
| 8132 | } |
| 8133 | |
| 8134 | /**--------------------------------------------------------------------------- |
| 8135 | \brief hdd_ParseuserParams - return a pointer to the next argument |
| 8136 | |
| 8137 | \return - status |
| 8138 | |
| 8139 | --------------------------------------------------------------------------*/ |
| 8140 | static int hdd_ParseUserParams(tANI_U8 *pValue, tANI_U8 **ppArg) |
| 8141 | { |
| 8142 | tANI_U8 *pVal; |
| 8143 | |
| 8144 | pVal = strchr(pValue, ' '); |
| 8145 | |
| 8146 | if (NULL == pVal) |
| 8147 | { |
| 8148 | /* no argument remains */ |
| 8149 | return -EINVAL; |
| 8150 | } |
| 8151 | else if (SPACE_ASCII_VALUE != *pVal) |
| 8152 | { |
| 8153 | /* no space after the current argument */ |
| 8154 | return -EINVAL; |
| 8155 | } |
| 8156 | |
| 8157 | pVal++; |
| 8158 | |
| 8159 | /* remove empty spaces */ |
| 8160 | while ((SPACE_ASCII_VALUE == *pVal) && ('\0' != *pVal)) |
| 8161 | { |
| 8162 | pVal++; |
| 8163 | } |
| 8164 | |
| 8165 | /* no argument followed by spaces */ |
| 8166 | if ('\0' == *pVal) |
| 8167 | { |
| 8168 | return -EINVAL; |
| 8169 | } |
| 8170 | |
| 8171 | *ppArg = pVal; |
| 8172 | |
| 8173 | return 0; |
| 8174 | } |
| 8175 | |
| 8176 | /**---------------------------------------------------------------------------- |
| 8177 | \brief hdd_ParseIBSSTXFailEventParams - Parse params for SETIBSSTXFAILEVENT |
| 8178 | |
| 8179 | \return - status |
| 8180 | |
| 8181 | ------------------------------------------------------------------------------*/ |
| 8182 | static int hdd_ParseIBSSTXFailEventParams(tANI_U8 *pValue, |
| 8183 | tANI_U8 *tx_fail_count, |
| 8184 | tANI_U16 *pid) |
| 8185 | { |
| 8186 | tANI_U8 *param = NULL; |
| 8187 | int ret; |
| 8188 | |
| 8189 | ret = hdd_ParseUserParams(pValue, ¶m); |
| 8190 | |
| 8191 | if (0 == ret && NULL != param) |
| 8192 | { |
| 8193 | if (1 != sscanf(param, "%hhu", tx_fail_count)) |
| 8194 | { |
| 8195 | ret = -EINVAL; |
| 8196 | goto done; |
| 8197 | } |
| 8198 | } |
| 8199 | else |
| 8200 | { |
| 8201 | goto done; |
| 8202 | } |
| 8203 | |
| 8204 | if (0 == *tx_fail_count) |
| 8205 | { |
| 8206 | *pid = 0; |
| 8207 | goto done; |
| 8208 | } |
| 8209 | |
| 8210 | pValue = param; |
| 8211 | pValue++; |
| 8212 | |
| 8213 | ret = hdd_ParseUserParams(pValue, ¶m); |
| 8214 | |
| 8215 | if (0 == ret) |
| 8216 | { |
| 8217 | if (1 != sscanf(param, "%hu", pid)) |
| 8218 | { |
| 8219 | ret = -EINVAL; |
| 8220 | goto done; |
| 8221 | } |
| 8222 | } |
| 8223 | else |
| 8224 | { |
| 8225 | goto done; |
| 8226 | } |
| 8227 | |
| 8228 | done: |
| 8229 | return ret; |
| 8230 | } |
| 8231 | |
| 8232 | static int hdd_open_cesium_nl_sock() |
| 8233 | { |
| 8234 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 8235 | struct netlink_kernel_cfg cfg = { |
| 8236 | .groups = WLAN_NLINK_MCAST_GRP_ID, |
| 8237 | .input = NULL |
| 8238 | }; |
| 8239 | #endif |
| 8240 | int ret = 0; |
| 8241 | |
| 8242 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 8243 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 8244 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)) |
| 8245 | THIS_MODULE, |
| 8246 | #endif |
| 8247 | &cfg); |
| 8248 | #else |
| 8249 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 8250 | WLAN_NLINK_MCAST_GRP_ID, NULL, NULL, THIS_MODULE); |
| 8251 | #endif |
| 8252 | |
| 8253 | if (cesium_nl_srv_sock == NULL) |
| 8254 | { |
| 8255 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8256 | "NLINK: cesium netlink_kernel_create failed"); |
| 8257 | ret = -ECONNREFUSED; |
| 8258 | } |
| 8259 | |
| 8260 | return ret; |
| 8261 | } |
| 8262 | |
| 8263 | static void hdd_close_cesium_nl_sock() |
| 8264 | { |
| 8265 | if (NULL != cesium_nl_srv_sock) |
| 8266 | { |
| 8267 | netlink_kernel_release(cesium_nl_srv_sock); |
| 8268 | cesium_nl_srv_sock = NULL; |
| 8269 | } |
| 8270 | } |
| 8271 | #endif /* WLAN_FEATURE_RMC */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8272 | /**--------------------------------------------------------------------------- |
| 8273 | |
| 8274 | \brief hdd_req_bmps_cbk() - HDD Request BMPS callback function |
| 8275 | |
| 8276 | This is the function invoked by SME to inform the result of BMPS |
| 8277 | request issued by HDD |
| 8278 | |
| 8279 | \param - callbackcontext - Pointer to cookie |
| 8280 | status - result of request |
| 8281 | |
| 8282 | \return - None |
| 8283 | |
| 8284 | --------------------------------------------------------------------------*/ |
| 8285 | void hdd_req_bmps_cbk(void *callbackContext, eHalStatus status) |
| 8286 | { |
| 8287 | |
| 8288 | struct completion *completion_var = (struct completion*) callbackContext; |
| 8289 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 8290 | hddLog(VOS_TRACE_LEVEL_ERROR, "HDD BMPS request Callback, status = %d", status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8291 | if(completion_var != NULL) |
| 8292 | { |
| 8293 | complete(completion_var); |
| 8294 | } |
| 8295 | } |
| 8296 | |
| 8297 | /**--------------------------------------------------------------------------- |
| 8298 | |
| 8299 | \brief hdd_get_cfg_file_size() - |
| 8300 | |
| 8301 | This function reads the configuration file using the request firmware |
| 8302 | API and returns the configuration file size. |
| 8303 | |
| 8304 | \param - pCtx - Pointer to the adapter . |
| 8305 | - pFileName - Pointer to the file name. |
| 8306 | - pBufSize - Pointer to the buffer size. |
| 8307 | |
| 8308 | \return - 0 for success, non zero for failure |
| 8309 | |
| 8310 | --------------------------------------------------------------------------*/ |
| 8311 | |
| 8312 | VOS_STATUS hdd_get_cfg_file_size(v_VOID_t *pCtx, char *pFileName, v_SIZE_t *pBufSize) |
| 8313 | { |
| 8314 | int status; |
| 8315 | hdd_context_t *pHddCtx = (hdd_context_t*)pCtx; |
| 8316 | |
| 8317 | ENTER(); |
| 8318 | |
| 8319 | status = request_firmware(&pHddCtx->fw, pFileName, pHddCtx->parent_dev); |
| 8320 | |
| 8321 | if(status || !pHddCtx->fw || !pHddCtx->fw->data) { |
| 8322 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: CFG download failed",__func__); |
| 8323 | status = VOS_STATUS_E_FAILURE; |
| 8324 | } |
| 8325 | else { |
| 8326 | *pBufSize = pHddCtx->fw->size; |
| 8327 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: CFG size = %d", __func__, *pBufSize); |
| 8328 | release_firmware(pHddCtx->fw); |
| 8329 | pHddCtx->fw = NULL; |
| 8330 | } |
| 8331 | |
| 8332 | EXIT(); |
| 8333 | return VOS_STATUS_SUCCESS; |
| 8334 | } |
| 8335 | |
| 8336 | /**--------------------------------------------------------------------------- |
| 8337 | |
| 8338 | \brief hdd_read_cfg_file() - |
| 8339 | |
| 8340 | This function reads the configuration file using the request firmware |
| 8341 | API and returns the cfg data and the buffer size of the configuration file. |
| 8342 | |
| 8343 | \param - pCtx - Pointer to the adapter . |
| 8344 | - pFileName - Pointer to the file name. |
| 8345 | - pBuffer - Pointer to the data buffer. |
| 8346 | - pBufSize - Pointer to the buffer size. |
| 8347 | |
| 8348 | \return - 0 for success, non zero for failure |
| 8349 | |
| 8350 | --------------------------------------------------------------------------*/ |
| 8351 | |
| 8352 | VOS_STATUS hdd_read_cfg_file(v_VOID_t *pCtx, char *pFileName, |
| 8353 | v_VOID_t *pBuffer, v_SIZE_t *pBufSize) |
| 8354 | { |
| 8355 | int status; |
| 8356 | hdd_context_t *pHddCtx = (hdd_context_t*)pCtx; |
| 8357 | |
| 8358 | ENTER(); |
| 8359 | |
| 8360 | status = request_firmware(&pHddCtx->fw, pFileName, pHddCtx->parent_dev); |
| 8361 | |
| 8362 | if(status || !pHddCtx->fw || !pHddCtx->fw->data) { |
| 8363 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: CFG download failed",__func__); |
| 8364 | return VOS_STATUS_E_FAILURE; |
| 8365 | } |
| 8366 | else { |
| 8367 | if(*pBufSize != pHddCtx->fw->size) { |
| 8368 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Caller sets invalid CFG " |
| 8369 | "file size", __func__); |
| 8370 | release_firmware(pHddCtx->fw); |
| 8371 | pHddCtx->fw = NULL; |
| 8372 | return VOS_STATUS_E_FAILURE; |
| 8373 | } |
| 8374 | else { |
| 8375 | if(pBuffer) { |
| 8376 | vos_mem_copy(pBuffer,pHddCtx->fw->data,*pBufSize); |
| 8377 | } |
| 8378 | release_firmware(pHddCtx->fw); |
| 8379 | pHddCtx->fw = NULL; |
| 8380 | } |
| 8381 | } |
| 8382 | |
| 8383 | EXIT(); |
| 8384 | |
| 8385 | return VOS_STATUS_SUCCESS; |
| 8386 | } |
| 8387 | |
| 8388 | /**--------------------------------------------------------------------------- |
| 8389 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 8390 | \brief __hdd_set_mac_address() - |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8391 | |
| 8392 | This function sets the user specified mac address using |
| 8393 | the command ifconfig wlanX hw ether <mac adress>. |
| 8394 | |
| 8395 | \param - dev - Pointer to the net device. |
| 8396 | - addr - Pointer to the sockaddr. |
| 8397 | \return - 0 for success, non zero for failure |
| 8398 | |
| 8399 | --------------------------------------------------------------------------*/ |
| 8400 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 8401 | static int __hdd_set_mac_address(struct net_device *dev, void *addr) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8402 | { |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 8403 | hdd_adapter_t *pAdapter; |
| 8404 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8405 | struct sockaddr *psta_mac_addr = addr; |
| 8406 | eHalStatus halStatus = eHAL_STATUS_SUCCESS; |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 8407 | int ret = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8408 | |
| 8409 | ENTER(); |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 8410 | pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 8411 | if (NULL == pAdapter) |
| 8412 | { |
| 8413 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8414 | "%s: Adapter is NULL",__func__); |
| 8415 | return -EINVAL; |
| 8416 | } |
| 8417 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 8418 | ret = wlan_hdd_validate_context(pHddCtx); |
| 8419 | if (0 != ret) |
| 8420 | { |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 8421 | return ret; |
| 8422 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8423 | |
| 8424 | memcpy(&pAdapter->macAddressCurrent, psta_mac_addr->sa_data, ETH_ALEN); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8425 | memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN); |
| 8426 | |
| 8427 | EXIT(); |
| 8428 | return halStatus; |
| 8429 | } |
| 8430 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 8431 | /**--------------------------------------------------------------------------- |
| 8432 | |
| 8433 | \brief hdd_set_mac_address() - |
| 8434 | |
| 8435 | Wrapper function to protect __hdd_set_mac_address() function from ssr |
| 8436 | |
| 8437 | \param - dev - Pointer to the net device. |
| 8438 | - addr - Pointer to the sockaddr. |
| 8439 | \return - 0 for success, non zero for failure |
| 8440 | |
| 8441 | --------------------------------------------------------------------------*/ |
| 8442 | static int hdd_set_mac_address(struct net_device *dev, void *addr) |
| 8443 | { |
| 8444 | int ret; |
| 8445 | |
| 8446 | vos_ssr_protect(__func__); |
| 8447 | ret = __hdd_set_mac_address(dev, addr); |
| 8448 | vos_ssr_unprotect(__func__); |
| 8449 | |
| 8450 | return ret; |
| 8451 | } |
| 8452 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8453 | tANI_U8* wlan_hdd_get_intf_addr(hdd_context_t* pHddCtx) |
| 8454 | { |
| 8455 | int i; |
| 8456 | for ( i = 0; i < VOS_MAX_CONCURRENCY_PERSONA; i++) |
| 8457 | { |
Abhishek Singh | eb18378 | 2014-02-06 13:37:21 +0530 | [diff] [blame] | 8458 | if( 0 == ((pHddCtx->cfg_ini->intfAddrMask) & (1 << i)) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8459 | break; |
| 8460 | } |
| 8461 | |
| 8462 | if( VOS_MAX_CONCURRENCY_PERSONA == i) |
| 8463 | return NULL; |
| 8464 | |
| 8465 | pHddCtx->cfg_ini->intfAddrMask |= (1 << i); |
| 8466 | return &pHddCtx->cfg_ini->intfMacAddr[i].bytes[0]; |
| 8467 | } |
| 8468 | |
| 8469 | void wlan_hdd_release_intf_addr(hdd_context_t* pHddCtx, tANI_U8* releaseAddr) |
| 8470 | { |
| 8471 | int i; |
| 8472 | for ( i = 0; i < VOS_MAX_CONCURRENCY_PERSONA; i++) |
| 8473 | { |
| 8474 | if ( !memcmp(releaseAddr, &pHddCtx->cfg_ini->intfMacAddr[i].bytes[0], 6) ) |
| 8475 | { |
| 8476 | pHddCtx->cfg_ini->intfAddrMask &= ~(1 << i); |
| 8477 | break; |
| 8478 | } |
| 8479 | } |
| 8480 | return; |
| 8481 | } |
| 8482 | |
| 8483 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)) |
| 8484 | static struct net_device_ops wlan_drv_ops = { |
| 8485 | .ndo_open = hdd_open, |
| 8486 | .ndo_stop = hdd_stop, |
| 8487 | .ndo_uninit = hdd_uninit, |
| 8488 | .ndo_start_xmit = hdd_hard_start_xmit, |
| 8489 | .ndo_tx_timeout = hdd_tx_timeout, |
| 8490 | .ndo_get_stats = hdd_stats, |
| 8491 | .ndo_do_ioctl = hdd_ioctl, |
| 8492 | .ndo_set_mac_address = hdd_set_mac_address, |
| 8493 | .ndo_select_queue = hdd_select_queue, |
| 8494 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 8495 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(3,1,0)) |
| 8496 | .ndo_set_rx_mode = hdd_set_multicast_list, |
| 8497 | #else |
| 8498 | .ndo_set_multicast_list = hdd_set_multicast_list, |
| 8499 | #endif //LINUX_VERSION_CODE |
| 8500 | #endif |
| 8501 | }; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8502 | static struct net_device_ops wlan_mon_drv_ops = { |
| 8503 | .ndo_open = hdd_mon_open, |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 8504 | .ndo_stop = hdd_mon_stop, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8505 | .ndo_uninit = hdd_uninit, |
| 8506 | .ndo_start_xmit = hdd_mon_hard_start_xmit, |
| 8507 | .ndo_tx_timeout = hdd_tx_timeout, |
| 8508 | .ndo_get_stats = hdd_stats, |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 8509 | .ndo_do_ioctl = hdd_mon_ioctl, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8510 | .ndo_set_mac_address = hdd_set_mac_address, |
| 8511 | }; |
Mahesh A Saptasagar | 305e263 | 2015-03-04 12:57:33 +0530 | [diff] [blame] | 8512 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8513 | #endif |
| 8514 | |
| 8515 | void hdd_set_station_ops( struct net_device *pWlanDev ) |
| 8516 | { |
| 8517 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8518 | pWlanDev->netdev_ops = &wlan_drv_ops; |
| 8519 | #else |
| 8520 | pWlanDev->open = hdd_open; |
| 8521 | pWlanDev->stop = hdd_stop; |
| 8522 | pWlanDev->uninit = hdd_uninit; |
| 8523 | pWlanDev->hard_start_xmit = NULL; |
| 8524 | pWlanDev->tx_timeout = hdd_tx_timeout; |
| 8525 | pWlanDev->get_stats = hdd_stats; |
| 8526 | pWlanDev->do_ioctl = hdd_ioctl; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8527 | pWlanDev->set_mac_address = hdd_set_mac_address; |
| 8528 | #endif |
| 8529 | } |
| 8530 | |
Katya Nigam | 1fd2440 | 2015-02-16 14:52:19 +0530 | [diff] [blame] | 8531 | void hdd_set_ibss_ops( hdd_adapter_t *pAdapter ) |
| 8532 | { |
| 8533 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)) |
| 8534 | wlan_drv_ops.ndo_start_xmit = hdd_ibss_hard_start_xmit; |
| 8535 | #else |
| 8536 | pAdapter->dev->hard_start_xmit = hdd_ibss_hard_start_xmit; |
| 8537 | #endif |
| 8538 | } |
| 8539 | |
Jeff Johnson | eed415b | 2013-01-18 16:11:20 -0800 | [diff] [blame] | 8540 | 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] | 8541 | { |
| 8542 | struct net_device *pWlanDev = NULL; |
| 8543 | hdd_adapter_t *pAdapter = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8544 | /* |
| 8545 | * cfg80211 initialization and registration.... |
| 8546 | */ |
Anand N Sunkad | c34abbd | 2015-07-29 09:52:59 +0530 | [diff] [blame] | 8547 | pWlanDev = alloc_netdev_mq(sizeof( hdd_adapter_t ), name, |
| 8548 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)) |
| 8549 | NET_NAME_UNKNOWN, |
| 8550 | #endif |
| 8551 | ether_setup, NUM_TX_QUEUES); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8552 | if(pWlanDev != NULL) |
| 8553 | { |
| 8554 | |
| 8555 | //Save the pointer to the net_device in the HDD adapter |
| 8556 | pAdapter = (hdd_adapter_t*) netdev_priv( pWlanDev ); |
| 8557 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8558 | vos_mem_zero( pAdapter, sizeof( hdd_adapter_t ) ); |
| 8559 | |
| 8560 | pAdapter->dev = pWlanDev; |
| 8561 | pAdapter->pHddCtx = pHddCtx; |
| 8562 | pAdapter->magic = WLAN_HDD_ADAPTER_MAGIC; |
Agarwal Ashish | 47d1811 | 2014-08-04 19:55:07 +0530 | [diff] [blame] | 8563 | spin_lock_init(&pAdapter->lock_for_active_session); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8564 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 8565 | #ifdef FEATURE_WLAN_BATCH_SCAN |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 8566 | pAdapter->pBatchScanRsp = NULL; |
| 8567 | pAdapter->numScanList = 0; |
Rajeev Kumar | 20140c1 | 2013-10-21 19:39:02 -0700 | [diff] [blame] | 8568 | pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STOPPED; |
Kiet Lam | aa8e15a | 2014-02-11 23:30:06 -0800 | [diff] [blame] | 8569 | pAdapter->prev_batch_id = 0; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 8570 | mutex_init(&pAdapter->hdd_batch_scan_lock); |
| 8571 | #endif |
| 8572 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8573 | pAdapter->isLinkUpSvcNeeded = FALSE; |
| 8574 | pAdapter->higherDtimTransition = eANI_BOOLEAN_TRUE; |
| 8575 | //Init the net_device structure |
| 8576 | strlcpy(pWlanDev->name, name, IFNAMSIZ); |
| 8577 | |
| 8578 | vos_mem_copy(pWlanDev->dev_addr, (void *)macAddr, sizeof(tSirMacAddr)); |
| 8579 | vos_mem_copy( pAdapter->macAddressCurrent.bytes, macAddr, sizeof(tSirMacAddr)); |
| 8580 | pWlanDev->watchdog_timeo = HDD_TX_TIMEOUT; |
| 8581 | pWlanDev->hard_header_len += LIBRA_HW_NEEDED_HEADROOM; |
| 8582 | |
| 8583 | hdd_set_station_ops( pAdapter->dev ); |
| 8584 | |
| 8585 | pWlanDev->destructor = free_netdev; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8586 | pWlanDev->ieee80211_ptr = &pAdapter->wdev ; |
| 8587 | pAdapter->wdev.wiphy = pHddCtx->wiphy; |
| 8588 | pAdapter->wdev.netdev = pWlanDev; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8589 | /* set pWlanDev's parent to underlying device */ |
| 8590 | SET_NETDEV_DEV(pWlanDev, pHddCtx->parent_dev); |
Kumar Anand | 82c009f | 2014-05-29 00:29:42 -0700 | [diff] [blame] | 8591 | |
| 8592 | hdd_wmm_init( pAdapter ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8593 | } |
| 8594 | |
| 8595 | return pAdapter; |
| 8596 | } |
| 8597 | |
| 8598 | VOS_STATUS hdd_register_interface( hdd_adapter_t *pAdapter, tANI_U8 rtnl_lock_held ) |
| 8599 | { |
| 8600 | struct net_device *pWlanDev = pAdapter->dev; |
| 8601 | //hdd_station_ctx_t *pHddStaCtx = &pAdapter->sessionCtx.station; |
| 8602 | //hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
| 8603 | //eHalStatus halStatus = eHAL_STATUS_SUCCESS; |
| 8604 | |
| 8605 | if( rtnl_lock_held ) |
| 8606 | { |
Madan Mohan Koyyalamudi | d8ac866 | 2012-11-06 19:04:56 -0800 | [diff] [blame] | 8607 | if (strnchr(pWlanDev->name, strlen(pWlanDev->name), '%')) { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8608 | if( dev_alloc_name(pWlanDev, pWlanDev->name) < 0 ) |
| 8609 | { |
| 8610 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s:Failed:dev_alloc_name",__func__); |
| 8611 | return VOS_STATUS_E_FAILURE; |
| 8612 | } |
| 8613 | } |
| 8614 | if (register_netdevice(pWlanDev)) |
| 8615 | { |
| 8616 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s:Failed:register_netdev",__func__); |
| 8617 | return VOS_STATUS_E_FAILURE; |
| 8618 | } |
| 8619 | } |
| 8620 | else |
| 8621 | { |
| 8622 | if(register_netdev(pWlanDev)) |
| 8623 | { |
| 8624 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failed:register_netdev",__func__); |
| 8625 | return VOS_STATUS_E_FAILURE; |
| 8626 | } |
| 8627 | } |
| 8628 | set_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags); |
| 8629 | |
| 8630 | return VOS_STATUS_SUCCESS; |
| 8631 | } |
| 8632 | |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 8633 | static eHalStatus hdd_smeCloseSessionCallback(void *pContext) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8634 | { |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 8635 | hdd_adapter_t *pAdapter = pContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8636 | |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 8637 | if (NULL == pAdapter) |
| 8638 | { |
| 8639 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: NULL pAdapter", __func__); |
| 8640 | return eHAL_STATUS_INVALID_PARAMETER; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8641 | } |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 8642 | |
| 8643 | if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) |
| 8644 | { |
| 8645 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Invalid magic", __func__); |
| 8646 | return eHAL_STATUS_NOT_INITIALIZED; |
| 8647 | } |
| 8648 | |
| 8649 | clear_bit(SME_SESSION_OPENED, &pAdapter->event_flags); |
| 8650 | |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 8651 | #ifndef WLAN_OPEN_SOURCE |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 8652 | /* need to make sure all of our scheduled work has completed. |
| 8653 | * This callback is called from MC thread context, so it is safe to |
| 8654 | * to call below flush workqueue API from here. |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 8655 | * |
| 8656 | * Even though this is called from MC thread context, if there is a faulty |
| 8657 | * work item in the system, that can hang this call forever. So flushing |
| 8658 | * this global work queue is not safe; and now we make sure that |
| 8659 | * individual work queues are stopped correctly. But the cancel work queue |
| 8660 | * is a GPL only API, so the proprietary version of the driver would still |
| 8661 | * rely on the global work queue flush. |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 8662 | */ |
| 8663 | flush_scheduled_work(); |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 8664 | #endif |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 8665 | |
| 8666 | /* We can be blocked while waiting for scheduled work to be |
| 8667 | * flushed, and the adapter structure can potentially be freed, in |
| 8668 | * which case the magic will have been reset. So make sure the |
| 8669 | * magic is still good, and hence the adapter structure is still |
| 8670 | * valid, before signaling completion */ |
| 8671 | if (WLAN_HDD_ADAPTER_MAGIC == pAdapter->magic) |
| 8672 | { |
| 8673 | complete(&pAdapter->session_close_comp_var); |
| 8674 | } |
| 8675 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8676 | return eHAL_STATUS_SUCCESS; |
| 8677 | } |
Manjeet Singh | 47ee847 | 2016-04-11 11:57:18 +0530 | [diff] [blame] | 8678 | /** |
| 8679 | * hdd_close_tx_queues() - close tx queues |
| 8680 | * @hdd_ctx: hdd global context |
| 8681 | * |
| 8682 | * Return: None |
| 8683 | */ |
| 8684 | static void hdd_close_tx_queues(hdd_context_t *hdd_ctx) |
| 8685 | { |
| 8686 | VOS_STATUS status; |
| 8687 | hdd_adapter_t *adapter; |
| 8688 | hdd_adapter_list_node_t *adapter_node = NULL, *next_adapter = NULL; |
| 8689 | /* Not validating hdd_ctx as it's already done by the caller */ |
| 8690 | ENTER(); |
| 8691 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
| 8692 | while (NULL != adapter_node && VOS_STATUS_SUCCESS == status) { |
| 8693 | adapter = adapter_node->pAdapter; |
| 8694 | if (adapter && adapter->dev) { |
| 8695 | netif_tx_disable (adapter->dev); |
| 8696 | netif_carrier_off(adapter->dev); |
| 8697 | } |
| 8698 | status = hdd_get_next_adapter(hdd_ctx, adapter_node, |
| 8699 | &next_adapter); |
| 8700 | adapter_node = next_adapter; |
| 8701 | } |
| 8702 | EXIT(); |
| 8703 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8704 | |
| 8705 | VOS_STATUS hdd_init_station_mode( hdd_adapter_t *pAdapter ) |
| 8706 | { |
| 8707 | struct net_device *pWlanDev = pAdapter->dev; |
| 8708 | hdd_station_ctx_t *pHddStaCtx = &pAdapter->sessionCtx.station; |
| 8709 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
| 8710 | eHalStatus halStatus = eHAL_STATUS_SUCCESS; |
| 8711 | VOS_STATUS status = VOS_STATUS_E_FAILURE; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8712 | long rc = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8713 | |
Nirav Shah | 7e3c813 | 2015-06-22 23:51:42 +0530 | [diff] [blame] | 8714 | spin_lock_init( &pAdapter->sta_hash_lock); |
| 8715 | pAdapter->is_sta_id_hash_initialized = VOS_FALSE; |
| 8716 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8717 | INIT_COMPLETION(pAdapter->session_open_comp_var); |
Kiran Kumar Lokere | 0ad5cd3 | 2013-06-25 11:26:22 -0700 | [diff] [blame] | 8718 | sme_SetCurrDeviceMode(pHddCtx->hHal, pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8719 | //Open a SME session for future operation |
| 8720 | halStatus = sme_OpenSession( pHddCtx->hHal, hdd_smeRoamCallback, pAdapter, |
Kiran Kumar Lokere | 0ad5cd3 | 2013-06-25 11:26:22 -0700 | [diff] [blame] | 8721 | (tANI_U8 *)&pAdapter->macAddressCurrent, &pAdapter->sessionId); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8722 | if ( !HAL_STATUS_SUCCESS( halStatus ) ) |
| 8723 | { |
| 8724 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 8725 | "sme_OpenSession() failed with status code %08d [x%08x]", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8726 | halStatus, halStatus ); |
| 8727 | status = VOS_STATUS_E_FAILURE; |
| 8728 | goto error_sme_open; |
| 8729 | } |
| 8730 | |
| 8731 | //Block on a completion variable. Can't wait forever though. |
Vinay Krishna Eranna | 0fe2e7c | 2014-04-09 21:32:08 +0530 | [diff] [blame] | 8732 | rc = wait_for_completion_timeout( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8733 | &pAdapter->session_open_comp_var, |
| 8734 | msecs_to_jiffies(WLAN_WAIT_TIME_SESSIONOPENCLOSE)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8735 | if (rc <= 0) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8736 | { |
| 8737 | hddLog(VOS_TRACE_LEVEL_FATAL, |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8738 | "Session is not opened within timeout period code %ld", rc ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8739 | status = VOS_STATUS_E_FAILURE; |
| 8740 | goto error_sme_open; |
| 8741 | } |
| 8742 | |
| 8743 | // Register wireless extensions |
| 8744 | if( eHAL_STATUS_SUCCESS != (halStatus = hdd_register_wext(pWlanDev))) |
| 8745 | { |
| 8746 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 8747 | "hdd_register_wext() failed with status code %08d [x%08x]", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8748 | halStatus, halStatus ); |
| 8749 | status = VOS_STATUS_E_FAILURE; |
| 8750 | goto error_register_wext; |
| 8751 | } |
Katya Nigam | 1fd2440 | 2015-02-16 14:52:19 +0530 | [diff] [blame] | 8752 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8753 | //Safe to register the hard_start_xmit function again |
Katya Nigam | 1fd2440 | 2015-02-16 14:52:19 +0530 | [diff] [blame] | 8754 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)) |
| 8755 | wlan_drv_ops.ndo_start_xmit = hdd_hard_start_xmit; |
| 8756 | #else |
| 8757 | pWlanDev->hard_start_xmit = hdd_hard_start_xmit; |
| 8758 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8759 | |
| 8760 | //Set the Connection State to Not Connected |
Abhishek Singh | f4669da | 2014-05-26 15:07:49 +0530 | [diff] [blame] | 8761 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 8762 | "%s: Set HDD connState to eConnectionState_NotConnected", |
| 8763 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8764 | pHddStaCtx->conn_info.connState = eConnectionState_NotConnected; |
| 8765 | |
| 8766 | //Set the default operation channel |
| 8767 | pHddStaCtx->conn_info.operationChannel = pHddCtx->cfg_ini->OperatingChannel; |
| 8768 | |
| 8769 | /* Make the default Auth Type as OPEN*/ |
| 8770 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 8771 | |
| 8772 | if( VOS_STATUS_SUCCESS != ( status = hdd_init_tx_rx( pAdapter ) ) ) |
| 8773 | { |
| 8774 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 8775 | "hdd_init_tx_rx() failed with status code %08d [x%08x]", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8776 | status, status ); |
| 8777 | goto error_init_txrx; |
| 8778 | } |
| 8779 | |
| 8780 | set_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags); |
| 8781 | |
| 8782 | if( VOS_STATUS_SUCCESS != ( status = hdd_wmm_adapter_init( pAdapter ) ) ) |
| 8783 | { |
| 8784 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 8785 | "hdd_wmm_adapter_init() failed with status code %08d [x%08x]", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8786 | status, status ); |
| 8787 | goto error_wmm_init; |
| 8788 | } |
| 8789 | |
| 8790 | set_bit(WMM_INIT_DONE, &pAdapter->event_flags); |
| 8791 | |
| 8792 | return VOS_STATUS_SUCCESS; |
| 8793 | |
| 8794 | error_wmm_init: |
| 8795 | clear_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags); |
| 8796 | hdd_deinit_tx_rx(pAdapter); |
| 8797 | error_init_txrx: |
| 8798 | hdd_UnregisterWext(pWlanDev); |
| 8799 | error_register_wext: |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 8800 | if (test_bit(SME_SESSION_OPENED, &pAdapter->event_flags)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8801 | { |
| 8802 | INIT_COMPLETION(pAdapter->session_close_comp_var); |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 8803 | if (eHAL_STATUS_SUCCESS == sme_CloseSession(pHddCtx->hHal, |
Agrawal Ashish | 5a3522c | 2016-03-02 15:08:28 +0530 | [diff] [blame] | 8804 | pAdapter->sessionId, FALSE, VOS_TRUE, |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 8805 | hdd_smeCloseSessionCallback, pAdapter)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8806 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8807 | unsigned long rc; |
| 8808 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8809 | //Block on a completion variable. Can't wait forever though. |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8810 | rc = wait_for_completion_timeout( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8811 | &pAdapter->session_close_comp_var, |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 8812 | msecs_to_jiffies(WLAN_WAIT_TIME_SESSIONOPENCLOSE)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8813 | if (rc <= 0) |
| 8814 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8815 | FL("Session is not opened within timeout period code %ld"), rc); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8816 | } |
| 8817 | } |
| 8818 | error_sme_open: |
| 8819 | return status; |
| 8820 | } |
| 8821 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8822 | void hdd_cleanup_actionframe( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter ) |
| 8823 | { |
| 8824 | hdd_cfg80211_state_t *cfgState; |
| 8825 | |
| 8826 | cfgState = WLAN_HDD_GET_CFG_STATE_PTR( pAdapter ); |
| 8827 | |
| 8828 | if( NULL != cfgState->buf ) |
| 8829 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8830 | long rc; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8831 | INIT_COMPLETION(pAdapter->tx_action_cnf_event); |
| 8832 | rc = wait_for_completion_interruptible_timeout( |
| 8833 | &pAdapter->tx_action_cnf_event, |
| 8834 | msecs_to_jiffies(ACTION_FRAME_TX_TIMEOUT)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8835 | if (rc <= 0) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8836 | { |
Deepthi Gowri | 91b3e9c | 2015-08-25 13:14:58 +0530 | [diff] [blame] | 8837 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8838 | "%s ERROR: HDD Wait for Action Confirmation Failed!! %ld" |
| 8839 | , __func__, rc); |
| 8840 | |
| 8841 | // Inform tx status as FAILURE to upper layer and free cfgState->buf |
| 8842 | hdd_sendActionCnf( pAdapter, FALSE ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8843 | } |
| 8844 | } |
| 8845 | return; |
| 8846 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8847 | |
c_hpothu | 002231a | 2015-02-05 14:58:51 +0530 | [diff] [blame] | 8848 | 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] | 8849 | { |
| 8850 | ENTER(); |
| 8851 | switch ( pAdapter->device_mode ) |
| 8852 | { |
Katya Nigam | 1fd2440 | 2015-02-16 14:52:19 +0530 | [diff] [blame] | 8853 | case WLAN_HDD_IBSS: |
| 8854 | { |
| 8855 | if(test_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags)) |
| 8856 | { |
| 8857 | hdd_ibss_deinit_tx_rx( pAdapter ); |
| 8858 | clear_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags); |
| 8859 | } |
| 8860 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8861 | case WLAN_HDD_INFRA_STATION: |
| 8862 | case WLAN_HDD_P2P_CLIENT: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8863 | case WLAN_HDD_P2P_DEVICE: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8864 | { |
| 8865 | if(test_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags)) |
| 8866 | { |
| 8867 | hdd_deinit_tx_rx( pAdapter ); |
| 8868 | clear_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags); |
| 8869 | } |
| 8870 | |
| 8871 | if(test_bit(WMM_INIT_DONE, &pAdapter->event_flags)) |
| 8872 | { |
| 8873 | hdd_wmm_adapter_close( pAdapter ); |
| 8874 | clear_bit(WMM_INIT_DONE, &pAdapter->event_flags); |
| 8875 | } |
| 8876 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8877 | hdd_cleanup_actionframe(pHddCtx, pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8878 | break; |
| 8879 | } |
| 8880 | |
| 8881 | case WLAN_HDD_SOFTAP: |
| 8882 | case WLAN_HDD_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8883 | { |
Madan Mohan Koyyalamudi | 8c6dec8 | 2013-09-26 15:56:13 +0530 | [diff] [blame] | 8884 | |
| 8885 | if (test_bit(WMM_INIT_DONE, &pAdapter->event_flags)) |
| 8886 | { |
| 8887 | hdd_wmm_adapter_close( pAdapter ); |
| 8888 | clear_bit(WMM_INIT_DONE, &pAdapter->event_flags); |
| 8889 | } |
| 8890 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8891 | hdd_cleanup_actionframe(pHddCtx, pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8892 | |
c_hpothu | 002231a | 2015-02-05 14:58:51 +0530 | [diff] [blame] | 8893 | hdd_unregister_hostapd(pAdapter, rtnl_held); |
Agrawal Ashish | a0584d4 | 2016-09-29 13:03:45 +0530 | [diff] [blame] | 8894 | /* set con_mode to STA only when no SAP concurrency mode */ |
| 8895 | if (!(hdd_get_concurrency_mode() & (VOS_SAP | VOS_P2P_GO))) |
| 8896 | hdd_set_conparam(0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8897 | break; |
| 8898 | } |
| 8899 | |
| 8900 | case WLAN_HDD_MONITOR: |
| 8901 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8902 | if(test_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags)) |
| 8903 | { |
| 8904 | hdd_deinit_tx_rx( pAdapter ); |
| 8905 | clear_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags); |
| 8906 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8907 | break; |
| 8908 | } |
| 8909 | |
| 8910 | |
| 8911 | default: |
| 8912 | break; |
| 8913 | } |
| 8914 | |
| 8915 | EXIT(); |
| 8916 | } |
| 8917 | |
| 8918 | void hdd_cleanup_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter, tANI_U8 rtnl_held ) |
| 8919 | { |
Mingcheng Zhu | 87f22fc | 2014-01-30 19:23:32 -0800 | [diff] [blame] | 8920 | struct net_device *pWlanDev = NULL; |
Srinivas, Dasari | 693dfc5 | 2013-12-27 17:29:09 +0530 | [diff] [blame] | 8921 | |
| 8922 | ENTER(); |
| 8923 | if (NULL == pAdapter) |
| 8924 | { |
| 8925 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8926 | "%s: HDD adapter is Null", __func__); |
| 8927 | return; |
| 8928 | } |
| 8929 | |
| 8930 | pWlanDev = pAdapter->dev; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8931 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 8932 | #ifdef FEATURE_WLAN_BATCH_SCAN |
Srinivas, Dasari | 693dfc5 | 2013-12-27 17:29:09 +0530 | [diff] [blame] | 8933 | if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
| 8934 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 8935 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Srinivas, Dasari | 693dfc5 | 2013-12-27 17:29:09 +0530 | [diff] [blame] | 8936 | || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE) |
| 8937 | ) |
| 8938 | { |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 8939 | if (pAdapter) |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 8940 | { |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 8941 | if (eHDD_BATCH_SCAN_STATE_STARTED == pAdapter->batchScanState) |
| 8942 | { |
| 8943 | hdd_deinit_batch_scan(pAdapter); |
| 8944 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 8945 | } |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 8946 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 8947 | #endif |
| 8948 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8949 | if(test_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags)) { |
| 8950 | if( rtnl_held ) |
| 8951 | { |
| 8952 | unregister_netdevice(pWlanDev); |
| 8953 | } |
| 8954 | else |
| 8955 | { |
| 8956 | unregister_netdev(pWlanDev); |
| 8957 | } |
| 8958 | // note that the pAdapter is no longer valid at this point |
| 8959 | // since the memory has been reclaimed |
| 8960 | } |
| 8961 | |
Srinivas, Dasari | 693dfc5 | 2013-12-27 17:29:09 +0530 | [diff] [blame] | 8962 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8963 | } |
| 8964 | |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 8965 | void hdd_set_pwrparams(hdd_context_t *pHddCtx) |
| 8966 | { |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 8967 | VOS_STATUS status; |
| 8968 | hdd_adapter_t *pAdapter = NULL; |
| 8969 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 8970 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 8971 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 8972 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 8973 | /*loop through all adapters.*/ |
| 8974 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 8975 | { |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 8976 | pAdapter = pAdapterNode->pAdapter; |
| 8977 | if ( (WLAN_HDD_INFRA_STATION != pAdapter->device_mode) |
| 8978 | && (WLAN_HDD_P2P_CLIENT != pAdapter->device_mode) ) |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 8979 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 8980 | { // we skip this registration for modes other than STA and P2P client modes. |
| 8981 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 8982 | pAdapterNode = pNext; |
| 8983 | continue; |
| 8984 | } |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 8985 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 8986 | //Apply Dynamic DTIM For P2P |
| 8987 | //Only if ignoreDynamicDtimInP2pMode is not set in ini |
| 8988 | if ((pHddCtx->cfg_ini->enableDynamicDTIM || |
| 8989 | pHddCtx->cfg_ini->enableModulatedDTIM) && |
| 8990 | ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
| 8991 | ((WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) && |
| 8992 | !(pHddCtx->cfg_ini->ignoreDynamicDtimInP2pMode))) && |
| 8993 | (eANI_BOOLEAN_TRUE == pAdapter->higherDtimTransition) && |
| 8994 | (eConnectionState_Associated == |
| 8995 | (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) && |
| 8996 | (pHddCtx->cfg_ini->fIsBmpsEnabled)) |
| 8997 | { |
| 8998 | tSirSetPowerParamsReq powerRequest = { 0 }; |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 8999 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 9000 | powerRequest.uIgnoreDTIM = 1; |
| 9001 | powerRequest.uMaxLIModulatedDTIM = pHddCtx->cfg_ini->fMaxLIModulatedDTIM; |
| 9002 | |
| 9003 | if (pHddCtx->cfg_ini->enableModulatedDTIM) |
| 9004 | { |
| 9005 | powerRequest.uDTIMPeriod = pHddCtx->cfg_ini->enableModulatedDTIM; |
| 9006 | powerRequest.uListenInterval = pHddCtx->hdd_actual_LI_value; |
| 9007 | } |
| 9008 | else |
| 9009 | { |
| 9010 | powerRequest.uListenInterval = pHddCtx->cfg_ini->enableDynamicDTIM; |
| 9011 | } |
| 9012 | |
| 9013 | /* Update ignoreDTIM and ListedInterval in CFG to remain at the DTIM |
| 9014 | * specified during Enter/Exit BMPS when LCD off*/ |
| 9015 | ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IGNORE_DTIM, powerRequest.uIgnoreDTIM, |
| 9016 | NULL, eANI_BOOLEAN_FALSE); |
| 9017 | ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_LISTEN_INTERVAL, powerRequest.uListenInterval, |
| 9018 | NULL, eANI_BOOLEAN_FALSE); |
| 9019 | |
| 9020 | /* switch to the DTIM specified in cfg.ini */ |
| 9021 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Abhishek Singh | 1e390cf | 2015-10-27 13:45:17 +0530 | [diff] [blame] | 9022 | "Switch to DTIM %d Listen interval %d", |
| 9023 | powerRequest.uDTIMPeriod, |
| 9024 | powerRequest.uListenInterval); |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 9025 | sme_SetPowerParams( pHddCtx->hHal, &powerRequest, TRUE); |
| 9026 | break; |
| 9027 | |
| 9028 | } |
| 9029 | |
| 9030 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 9031 | pAdapterNode = pNext; |
| 9032 | } |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 9033 | } |
| 9034 | |
| 9035 | void hdd_reset_pwrparams(hdd_context_t *pHddCtx) |
| 9036 | { |
| 9037 | /*Switch back to DTIM 1*/ |
| 9038 | tSirSetPowerParamsReq powerRequest = { 0 }; |
| 9039 | |
| 9040 | powerRequest.uIgnoreDTIM = pHddCtx->hdd_actual_ignore_DTIM_value; |
| 9041 | powerRequest.uListenInterval = pHddCtx->hdd_actual_LI_value; |
Yue Ma | c24062f | 2013-05-13 17:01:29 -0700 | [diff] [blame] | 9042 | powerRequest.uMaxLIModulatedDTIM = pHddCtx->cfg_ini->fMaxLIModulatedDTIM; |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 9043 | |
| 9044 | /* Update ignoreDTIM and ListedInterval in CFG with default values */ |
| 9045 | ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IGNORE_DTIM, powerRequest.uIgnoreDTIM, |
| 9046 | NULL, eANI_BOOLEAN_FALSE); |
| 9047 | ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_LISTEN_INTERVAL, powerRequest.uListenInterval, |
| 9048 | NULL, eANI_BOOLEAN_FALSE); |
| 9049 | |
| 9050 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 9051 | "Switch to DTIM%d",powerRequest.uListenInterval); |
| 9052 | sme_SetPowerParams( pHddCtx->hHal, &powerRequest, TRUE); |
| 9053 | |
| 9054 | } |
| 9055 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9056 | VOS_STATUS hdd_enable_bmps_imps(hdd_context_t *pHddCtx) |
| 9057 | { |
| 9058 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
Sushant Kaushik | 4928e54 | 2014-12-29 15:25:54 +0530 | [diff] [blame] | 9059 | if (WLAN_HDD_IS_UNLOAD_IN_PROGRESS(pHddCtx)) |
| 9060 | { |
| 9061 | hddLog( LOGE, FL("Wlan Unload in progress")); |
| 9062 | return VOS_STATUS_E_PERM; |
| 9063 | } |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 9064 | |
| 9065 | if (wlan_hdd_check_monitor_state(pHddCtx)) { |
| 9066 | hddLog(LOG1, FL("Monitor mode is started, cannot enable BMPS")); |
| 9067 | return VOS_STATUS_SUCCESS; |
| 9068 | } |
| 9069 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9070 | if(pHddCtx->cfg_ini->fIsBmpsEnabled) |
| 9071 | { |
| 9072 | sme_EnablePowerSave(pHddCtx->hHal, ePMC_BEACON_MODE_POWER_SAVE); |
| 9073 | } |
| 9074 | |
| 9075 | if(pHddCtx->cfg_ini->fIsAutoBmpsTimerEnabled) |
| 9076 | { |
| 9077 | sme_StartAutoBmpsTimer(pHddCtx->hHal); |
| 9078 | } |
| 9079 | |
| 9080 | if (pHddCtx->cfg_ini->fIsImpsEnabled) |
| 9081 | { |
| 9082 | sme_EnablePowerSave (pHddCtx->hHal, ePMC_IDLE_MODE_POWER_SAVE); |
| 9083 | } |
| 9084 | |
| 9085 | return status; |
| 9086 | } |
| 9087 | |
| 9088 | VOS_STATUS hdd_disable_bmps_imps(hdd_context_t *pHddCtx, tANI_U8 session_type) |
| 9089 | { |
| 9090 | hdd_adapter_t *pAdapter = NULL; |
| 9091 | eHalStatus halStatus; |
| 9092 | VOS_STATUS status = VOS_STATUS_E_INVAL; |
| 9093 | v_BOOL_t disableBmps = FALSE; |
| 9094 | v_BOOL_t disableImps = FALSE; |
| 9095 | |
| 9096 | switch(session_type) |
| 9097 | { |
| 9098 | case WLAN_HDD_INFRA_STATION: |
| 9099 | case WLAN_HDD_SOFTAP: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9100 | case WLAN_HDD_P2P_CLIENT: |
| 9101 | case WLAN_HDD_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9102 | //Exit BMPS -> Is Sta/P2P Client is already connected |
| 9103 | pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 9104 | if((NULL != pAdapter)&& |
| 9105 | hdd_connIsConnected( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) |
| 9106 | { |
| 9107 | disableBmps = TRUE; |
| 9108 | } |
| 9109 | |
| 9110 | pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT); |
| 9111 | if((NULL != pAdapter)&& |
| 9112 | hdd_connIsConnected( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) |
| 9113 | { |
| 9114 | disableBmps = TRUE; |
| 9115 | } |
| 9116 | |
| 9117 | //Exit both Bmps and Imps incase of Go/SAP Mode |
| 9118 | if((WLAN_HDD_SOFTAP == session_type) || |
| 9119 | (WLAN_HDD_P2P_GO == session_type)) |
| 9120 | { |
| 9121 | disableBmps = TRUE; |
| 9122 | disableImps = TRUE; |
| 9123 | } |
| 9124 | |
| 9125 | if(TRUE == disableImps) |
| 9126 | { |
| 9127 | if (pHddCtx->cfg_ini->fIsImpsEnabled) |
| 9128 | { |
| 9129 | sme_DisablePowerSave (pHddCtx->hHal, ePMC_IDLE_MODE_POWER_SAVE); |
| 9130 | } |
| 9131 | } |
| 9132 | |
| 9133 | if(TRUE == disableBmps) |
| 9134 | { |
| 9135 | if(pHddCtx->cfg_ini->fIsBmpsEnabled) |
| 9136 | { |
| 9137 | halStatus = sme_DisablePowerSave(pHddCtx->hHal, ePMC_BEACON_MODE_POWER_SAVE); |
| 9138 | |
| 9139 | if(eHAL_STATUS_SUCCESS != halStatus) |
| 9140 | { |
| 9141 | status = VOS_STATUS_E_FAILURE; |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 9142 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Fail to Disable Power Save", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9143 | VOS_ASSERT(0); |
| 9144 | return status; |
| 9145 | } |
| 9146 | } |
| 9147 | |
| 9148 | if(pHddCtx->cfg_ini->fIsAutoBmpsTimerEnabled) |
| 9149 | { |
| 9150 | halStatus = sme_StopAutoBmpsTimer(pHddCtx->hHal); |
| 9151 | |
| 9152 | if(eHAL_STATUS_SUCCESS != halStatus) |
| 9153 | { |
| 9154 | status = VOS_STATUS_E_FAILURE; |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 9155 | 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] | 9156 | VOS_ASSERT(0); |
| 9157 | return status; |
| 9158 | } |
| 9159 | } |
| 9160 | } |
| 9161 | |
| 9162 | if((TRUE == disableBmps) || |
| 9163 | (TRUE == disableImps)) |
| 9164 | { |
| 9165 | /* Now, get the chip into Full Power now */ |
| 9166 | INIT_COMPLETION(pHddCtx->full_pwr_comp_var); |
| 9167 | halStatus = sme_RequestFullPower(pHddCtx->hHal, hdd_full_pwr_cbk, |
| 9168 | pHddCtx, eSME_FULL_PWR_NEEDED_BY_HDD); |
| 9169 | |
| 9170 | if(halStatus != eHAL_STATUS_SUCCESS) |
| 9171 | { |
| 9172 | if(halStatus == eHAL_STATUS_PMC_PENDING) |
| 9173 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 9174 | long ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9175 | //Block on a completion variable. Can't wait forever though |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 9176 | ret = wait_for_completion_interruptible_timeout( |
| 9177 | &pHddCtx->full_pwr_comp_var, |
| 9178 | msecs_to_jiffies(1000)); |
| 9179 | if (ret <= 0) |
| 9180 | { |
| 9181 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 9182 | "%s: wait on full_pwr_comp_var failed %ld", |
| 9183 | __func__, ret); |
| 9184 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9185 | } |
| 9186 | else |
| 9187 | { |
| 9188 | status = VOS_STATUS_E_FAILURE; |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 9189 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Request for Full Power failed", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9190 | VOS_ASSERT(0); |
| 9191 | return status; |
| 9192 | } |
| 9193 | } |
| 9194 | |
| 9195 | status = VOS_STATUS_SUCCESS; |
| 9196 | } |
| 9197 | |
| 9198 | break; |
| 9199 | } |
| 9200 | return status; |
| 9201 | } |
Hanumantha Reddy Pothula | 91cdd7f | 2015-09-03 21:25:16 +0530 | [diff] [blame] | 9202 | |
| 9203 | void hdd_monPostMsgCb(tANI_U32 *magic, struct completion *cmpVar) |
| 9204 | { |
| 9205 | if (magic == NULL || cmpVar == NULL) { |
| 9206 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | c135a9a | 2017-09-19 08:37:24 -0700 | [diff] [blame] | 9207 | FL("invalid arguments %pK %pK"), magic, cmpVar); |
Hanumantha Reddy Pothula | 91cdd7f | 2015-09-03 21:25:16 +0530 | [diff] [blame] | 9208 | return; |
| 9209 | } |
| 9210 | if (*magic != MON_MODE_MSG_MAGIC) { |
| 9211 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9212 | FL("maic: %x"), *magic); |
| 9213 | return; |
| 9214 | } |
| 9215 | |
| 9216 | complete(cmpVar); |
| 9217 | return; |
| 9218 | } |
| 9219 | |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 9220 | void hdd_init_mon_mode (hdd_adapter_t *pAdapter) |
| 9221 | { |
| 9222 | hdd_mon_ctx_t *pMonCtx = NULL; |
| 9223 | pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter); |
| 9224 | |
| 9225 | pMonCtx->state = 0; |
| 9226 | pMonCtx->ChannelNo = 1; |
| 9227 | pMonCtx->ChannelBW = 20; |
Katya Nigam | d7d3a1f | 2015-06-11 14:04:24 +0530 | [diff] [blame] | 9228 | pMonCtx->crcCheckEnabled = 1; |
| 9229 | pMonCtx->typeSubtypeBitmap = 0xFFFF00000000; |
| 9230 | pMonCtx->is80211to803ConReq = 1; |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 9231 | pMonCtx->numOfMacFilters = 0; |
| 9232 | } |
| 9233 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9234 | |
| 9235 | 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] | 9236 | const char *iface_name, tSirMacAddr macAddr, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9237 | tANI_U8 rtnl_held ) |
| 9238 | { |
| 9239 | hdd_adapter_t *pAdapter = NULL; |
| 9240 | hdd_adapter_list_node_t *pHddAdapterNode = NULL; |
| 9241 | VOS_STATUS status = VOS_STATUS_E_FAILURE; |
| 9242 | VOS_STATUS exitbmpsStatus; |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 9243 | v_CONTEXT_t pVosContext = NULL; |
| 9244 | |
| 9245 | /* No need to check for NULL, reaching this step |
| 9246 | * means vos context is initialized |
| 9247 | */ |
| 9248 | pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9249 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 9250 | 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] | 9251 | |
Nirav Shah | 436658f | 2014-02-28 17:05:45 +0530 | [diff] [blame] | 9252 | if(macAddr == NULL) |
| 9253 | { |
| 9254 | /* Not received valid macAddr */ |
| 9255 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9256 | "%s:Unable to add virtual intf: Not able to get" |
| 9257 | "valid mac address",__func__); |
| 9258 | return NULL; |
| 9259 | } |
| 9260 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9261 | //Disable BMPS incase of Concurrency |
| 9262 | exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx, session_type); |
| 9263 | |
| 9264 | if(VOS_STATUS_E_FAILURE == exitbmpsStatus) |
| 9265 | { |
| 9266 | //Fail to Exit BMPS |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 9267 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Fail to Exit BMPS", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9268 | VOS_ASSERT(0); |
| 9269 | return NULL; |
| 9270 | } |
| 9271 | |
| 9272 | switch(session_type) |
| 9273 | { |
| 9274 | case WLAN_HDD_INFRA_STATION: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9275 | case WLAN_HDD_P2P_CLIENT: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9276 | case WLAN_HDD_P2P_DEVICE: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9277 | { |
| 9278 | pAdapter = hdd_alloc_station_adapter( pHddCtx, macAddr, iface_name ); |
| 9279 | |
| 9280 | if( NULL == pAdapter ) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 9281 | { |
| 9282 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 9283 | FL("failed to allocate adapter for session %d"), session_type); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9284 | return NULL; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 9285 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9286 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 9287 | #ifdef FEATURE_WLAN_TDLS |
| 9288 | /* A Mutex Lock is introduced while changing/initializing the mode to |
| 9289 | * protect the concurrent access for the Adapters by TDLS module. |
| 9290 | */ |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 9291 | mutex_lock(&pHddCtx->tdls_lock); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 9292 | #endif |
| 9293 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9294 | pAdapter->wdev.iftype = (session_type == WLAN_HDD_P2P_CLIENT) ? |
| 9295 | NL80211_IFTYPE_P2P_CLIENT: |
| 9296 | NL80211_IFTYPE_STATION; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9297 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9298 | pAdapter->device_mode = session_type; |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 9299 | #ifdef FEATURE_WLAN_TDLS |
| 9300 | mutex_unlock(&pHddCtx->tdls_lock); |
| 9301 | #endif |
Sunil Dutt | 66485cb | 2013-12-19 19:05:03 +0530 | [diff] [blame] | 9302 | |
Mahesh A Saptasagar | 67ab922 | 2015-10-21 15:38:41 +0530 | [diff] [blame] | 9303 | hdd_initialize_adapter_common(pAdapter); |
Sunil Dutt | 66485cb | 2013-12-19 19:05:03 +0530 | [diff] [blame] | 9304 | status = hdd_init_station_mode( pAdapter ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9305 | if( VOS_STATUS_SUCCESS != status ) |
| 9306 | goto err_free_netdev; |
| 9307 | |
| 9308 | status = hdd_register_interface( pAdapter, rtnl_held ); |
| 9309 | if( VOS_STATUS_SUCCESS != status ) |
| 9310 | { |
Mahesh A Saptasagar | 02e36e8 | 2015-01-14 20:39:19 +0530 | [diff] [blame] | 9311 | #ifdef FEATURE_WLAN_TDLS |
| 9312 | mutex_lock(&pHddCtx->tdls_lock); |
| 9313 | #endif |
c_hpothu | 002231a | 2015-02-05 14:58:51 +0530 | [diff] [blame] | 9314 | hdd_deinit_adapter(pHddCtx, pAdapter, rtnl_held); |
Mahesh A Saptasagar | 02e36e8 | 2015-01-14 20:39:19 +0530 | [diff] [blame] | 9315 | #ifdef FEATURE_WLAN_TDLS |
| 9316 | mutex_unlock(&pHddCtx->tdls_lock); |
| 9317 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9318 | goto err_free_netdev; |
| 9319 | } |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 9320 | |
Vinay Krishna Eranna | 4d055d4 | 2013-12-17 17:02:01 +0530 | [diff] [blame] | 9321 | // Workqueue which gets scheduled in IPv4 notification callback. |
Anand N Sunkad | dc63c79 | 2015-06-03 14:33:24 +0530 | [diff] [blame] | 9322 | vos_init_work(&pAdapter->ipv4NotifierWorkQueue, hdd_ipv4_notifier_work_queue); |
Vinay Krishna Eranna | 4d055d4 | 2013-12-17 17:02:01 +0530 | [diff] [blame] | 9323 | |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 9324 | #ifdef WLAN_NS_OFFLOAD |
| 9325 | // Workqueue which gets scheduled in IPv6 notification callback. |
Anand N Sunkad | dc63c79 | 2015-06-03 14:33:24 +0530 | [diff] [blame] | 9326 | vos_init_work(&pAdapter->ipv6NotifierWorkQueue, hdd_ipv6_notifier_work_queue); |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 9327 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9328 | //Stop the Interface TX queue. |
Padma, Santhosh Kumar | 9dacb5c | 2014-12-17 19:22:56 +0530 | [diff] [blame] | 9329 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9330 | netif_tx_disable(pAdapter->dev); |
| 9331 | //netif_tx_disable(pWlanDev); |
| 9332 | netif_carrier_off(pAdapter->dev); |
| 9333 | |
Ganesh Kondabattini | babfb49 | 2014-12-17 20:25:29 +0530 | [diff] [blame] | 9334 | if (WLAN_HDD_P2P_CLIENT == session_type || |
| 9335 | WLAN_HDD_P2P_DEVICE == session_type) |
| 9336 | { |
| 9337 | /* Initialize the work queue to defer the |
| 9338 | * back to back RoC request */ |
Anand N Sunkad | dc63c79 | 2015-06-03 14:33:24 +0530 | [diff] [blame] | 9339 | vos_init_delayed_work(&pAdapter->roc_work, |
Ganesh Kondabattini | babfb49 | 2014-12-17 20:25:29 +0530 | [diff] [blame] | 9340 | hdd_p2p_roc_work_queue); |
| 9341 | } |
| 9342 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9343 | break; |
| 9344 | } |
| 9345 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9346 | case WLAN_HDD_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9347 | case WLAN_HDD_SOFTAP: |
| 9348 | { |
| 9349 | pAdapter = hdd_wlan_create_ap_dev( pHddCtx, macAddr, (tANI_U8 *)iface_name ); |
| 9350 | if( NULL == pAdapter ) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 9351 | { |
| 9352 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 9353 | FL("failed to allocate adapter for session %d"), session_type); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9354 | return NULL; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 9355 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9356 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9357 | pAdapter->wdev.iftype = (session_type == WLAN_HDD_SOFTAP) ? |
| 9358 | NL80211_IFTYPE_AP: |
| 9359 | NL80211_IFTYPE_P2P_GO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9360 | pAdapter->device_mode = session_type; |
| 9361 | |
Mahesh A Saptasagar | 67ab922 | 2015-10-21 15:38:41 +0530 | [diff] [blame] | 9362 | hdd_initialize_adapter_common(pAdapter); |
Hanumanth Reddy Pothula | 15bc0fa | 2017-02-03 17:24:17 +0530 | [diff] [blame] | 9363 | status = hdd_init_ap_mode(pAdapter, false); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9364 | if( VOS_STATUS_SUCCESS != status ) |
| 9365 | goto err_free_netdev; |
| 9366 | |
Nirav Shah | 7e3c813 | 2015-06-22 23:51:42 +0530 | [diff] [blame] | 9367 | status = hdd_sta_id_hash_attach(pAdapter); |
| 9368 | if (VOS_STATUS_SUCCESS != status) |
| 9369 | { |
| 9370 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 9371 | FL("failed to attach hash for session %d"), session_type); |
| 9372 | hdd_deinit_adapter(pHddCtx, pAdapter, rtnl_held); |
| 9373 | goto err_free_netdev; |
| 9374 | } |
| 9375 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9376 | status = hdd_register_hostapd( pAdapter, rtnl_held ); |
| 9377 | if( VOS_STATUS_SUCCESS != status ) |
| 9378 | { |
c_hpothu | 002231a | 2015-02-05 14:58:51 +0530 | [diff] [blame] | 9379 | hdd_deinit_adapter(pHddCtx, pAdapter, rtnl_held); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9380 | goto err_free_netdev; |
| 9381 | } |
Padma, Santhosh Kumar | 9dacb5c | 2014-12-17 19:22:56 +0530 | [diff] [blame] | 9382 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9383 | netif_tx_disable(pAdapter->dev); |
| 9384 | netif_carrier_off(pAdapter->dev); |
| 9385 | |
| 9386 | hdd_set_conparam( 1 ); |
Ganesh Kondabattini | babfb49 | 2014-12-17 20:25:29 +0530 | [diff] [blame] | 9387 | |
Hanumanth Reddy Pothula | b4537b8 | 2018-03-02 12:20:38 +0530 | [diff] [blame] | 9388 | // Workqueue which gets scheduled in IPv4 notification callback. |
| 9389 | vos_init_work(&pAdapter->ipv4NotifierWorkQueue, |
| 9390 | hdd_ipv4_notifier_work_queue); |
| 9391 | |
| 9392 | #ifdef WLAN_NS_OFFLOAD |
| 9393 | // Workqueue which gets scheduled in IPv6 notification callback. |
| 9394 | vos_init_work(&pAdapter->ipv6NotifierWorkQueue, |
| 9395 | hdd_ipv6_notifier_work_queue); |
| 9396 | #endif |
| 9397 | |
Ganesh Kondabattini | babfb49 | 2014-12-17 20:25:29 +0530 | [diff] [blame] | 9398 | if (WLAN_HDD_P2P_GO == session_type) |
| 9399 | { |
| 9400 | /* Initialize the work queue to |
| 9401 | * defer the back to back RoC request */ |
| 9402 | INIT_DELAYED_WORK(&pAdapter->roc_work, |
| 9403 | hdd_p2p_roc_work_queue); |
| 9404 | } |
Bhargav Shah | d071591 | 2015-10-01 18:17:37 +0530 | [diff] [blame] | 9405 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9406 | break; |
| 9407 | } |
| 9408 | case WLAN_HDD_MONITOR: |
| 9409 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9410 | pAdapter = hdd_alloc_station_adapter( pHddCtx, macAddr, iface_name ); |
| 9411 | if( NULL == pAdapter ) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 9412 | { |
| 9413 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 9414 | FL("failed to allocate adapter for session %d"), session_type); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9415 | return NULL; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 9416 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9417 | |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 9418 | pAdapter->device_mode = session_type; |
| 9419 | pAdapter->wdev.iftype = NL80211_IFTYPE_MONITOR; |
| 9420 | |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 9421 | // Register wireless extensions |
| 9422 | if( VOS_STATUS_SUCCESS != (status = hdd_register_wext(pAdapter->dev))) |
| 9423 | { |
| 9424 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 9425 | "hdd_register_wext() failed with status code %08d [x%08x]", |
| 9426 | status, status ); |
| 9427 | status = VOS_STATUS_E_FAILURE; |
| 9428 | } |
| 9429 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9430 | #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29) |
| 9431 | pAdapter->dev->netdev_ops = &wlan_mon_drv_ops; |
| 9432 | #else |
| 9433 | pAdapter->dev->open = hdd_mon_open; |
| 9434 | pAdapter->dev->hard_start_xmit = hdd_mon_hard_start_xmit; |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 9435 | pAdapter->dev->stop = hdd_mon_stop; |
| 9436 | pAdapter->dev->do_ioctl = hdd_mon_ioctl; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9437 | #endif |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 9438 | hdd_init_mon_mode( pAdapter ); |
Mahesh A Saptasagar | 67ab922 | 2015-10-21 15:38:41 +0530 | [diff] [blame] | 9439 | hdd_initialize_adapter_common(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9440 | hdd_init_tx_rx( pAdapter ); |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 9441 | |
| 9442 | if (VOS_MONITOR_MODE != hdd_get_conparam()) |
| 9443 | WLANTL_SetMonRxCbk( pVosContext, hdd_rx_packet_monitor_cbk ); |
| 9444 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9445 | set_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags); |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 9446 | status = hdd_register_interface( pAdapter, rtnl_held ); |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 9447 | //Stop the Interface TX queue. |
| 9448 | netif_tx_disable(pAdapter->dev); |
| 9449 | netif_carrier_off(pAdapter->dev); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9450 | } |
| 9451 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9452 | case WLAN_HDD_FTM: |
| 9453 | { |
| 9454 | pAdapter = hdd_alloc_station_adapter( pHddCtx, macAddr, iface_name ); |
| 9455 | |
| 9456 | if( NULL == pAdapter ) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 9457 | { |
| 9458 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 9459 | FL("failed to allocate adapter for session %d"), session_type); |
| 9460 | return NULL; |
| 9461 | } |
| 9462 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9463 | /* Assign NL80211_IFTYPE_STATION as interface type to resolve Kernel Warning |
| 9464 | * message while loading driver in FTM mode. */ |
| 9465 | pAdapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 9466 | pAdapter->device_mode = session_type; |
| 9467 | status = hdd_register_interface( pAdapter, rtnl_held ); |
Madan Mohan Koyyalamudi | f89ac9f | 2013-09-19 16:58:12 +0530 | [diff] [blame] | 9468 | |
Mahesh A Saptasagar | 67ab922 | 2015-10-21 15:38:41 +0530 | [diff] [blame] | 9469 | hdd_initialize_adapter_common(pAdapter); |
Madan Mohan Koyyalamudi | f89ac9f | 2013-09-19 16:58:12 +0530 | [diff] [blame] | 9470 | hdd_init_tx_rx( pAdapter ); |
| 9471 | |
| 9472 | //Stop the Interface TX queue. |
Padma, Santhosh Kumar | 9dacb5c | 2014-12-17 19:22:56 +0530 | [diff] [blame] | 9473 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues")); |
Madan Mohan Koyyalamudi | f89ac9f | 2013-09-19 16:58:12 +0530 | [diff] [blame] | 9474 | netif_tx_disable(pAdapter->dev); |
| 9475 | netif_carrier_off(pAdapter->dev); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9476 | } |
| 9477 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9478 | default: |
| 9479 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 9480 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s Invalid session type %d", |
| 9481 | __func__, session_type); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9482 | VOS_ASSERT(0); |
| 9483 | return NULL; |
| 9484 | } |
| 9485 | } |
| 9486 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9487 | if( VOS_STATUS_SUCCESS == status ) |
| 9488 | { |
Mahesh A Saptasagar | 67ab922 | 2015-10-21 15:38:41 +0530 | [diff] [blame] | 9489 | //Add it to the hdd's session list. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9490 | pHddAdapterNode = vos_mem_malloc( sizeof( hdd_adapter_list_node_t ) ); |
| 9491 | if( NULL == pHddAdapterNode ) |
| 9492 | { |
| 9493 | status = VOS_STATUS_E_NOMEM; |
| 9494 | } |
| 9495 | else |
| 9496 | { |
| 9497 | pHddAdapterNode->pAdapter = pAdapter; |
| 9498 | status = hdd_add_adapter_back ( pHddCtx, |
| 9499 | pHddAdapterNode ); |
| 9500 | } |
| 9501 | } |
| 9502 | |
| 9503 | if( VOS_STATUS_SUCCESS != status ) |
| 9504 | { |
| 9505 | if( NULL != pAdapter ) |
| 9506 | { |
| 9507 | hdd_cleanup_adapter( pHddCtx, pAdapter, rtnl_held ); |
| 9508 | pAdapter = NULL; |
| 9509 | } |
| 9510 | if( NULL != pHddAdapterNode ) |
| 9511 | { |
| 9512 | vos_mem_free( pHddAdapterNode ); |
| 9513 | } |
| 9514 | |
| 9515 | goto resume_bmps; |
| 9516 | } |
| 9517 | |
| 9518 | if(VOS_STATUS_SUCCESS == status) |
| 9519 | { |
| 9520 | wlan_hdd_set_concurrency_mode(pHddCtx, session_type); |
Madan Mohan Koyyalamudi | 96dd30d | 2012-10-05 17:24:51 -0700 | [diff] [blame] | 9521 | //Initialize the WoWL service |
| 9522 | if(!hdd_init_wowl(pAdapter)) |
| 9523 | { |
| 9524 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hdd_init_wowl failed",__func__); |
| 9525 | goto err_free_netdev; |
| 9526 | } |
Manjeet Singh | 3ed7924 | 2017-01-11 19:04:32 +0530 | [diff] [blame] | 9527 | //Initialize the TSF capture data |
| 9528 | wlan_hdd_tsf_init(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9529 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9530 | return pAdapter; |
| 9531 | |
| 9532 | err_free_netdev: |
| 9533 | free_netdev(pAdapter->dev); |
| 9534 | wlan_hdd_release_intf_addr( pHddCtx, |
| 9535 | pAdapter->macAddressCurrent.bytes ); |
| 9536 | |
| 9537 | resume_bmps: |
| 9538 | //If bmps disabled enable it |
| 9539 | if(VOS_STATUS_SUCCESS == exitbmpsStatus) |
| 9540 | { |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 9541 | if (pHddCtx->hdd_wlan_suspended) |
| 9542 | { |
| 9543 | hdd_set_pwrparams(pHddCtx); |
| 9544 | } |
| 9545 | hdd_enable_bmps_imps(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9546 | } |
| 9547 | return NULL; |
| 9548 | } |
| 9549 | |
| 9550 | VOS_STATUS hdd_close_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter, |
| 9551 | tANI_U8 rtnl_held ) |
| 9552 | { |
| 9553 | hdd_adapter_list_node_t *pAdapterNode, *pCurrent, *pNext; |
| 9554 | VOS_STATUS status; |
| 9555 | |
| 9556 | status = hdd_get_front_adapter ( pHddCtx, &pCurrent ); |
| 9557 | if( VOS_STATUS_SUCCESS != status ) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 9558 | { |
| 9559 | hddLog(VOS_TRACE_LEVEL_WARN,"%s: adapter list empty %d", |
| 9560 | __func__, status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9561 | return status; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 9562 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9563 | |
| 9564 | while ( pCurrent->pAdapter != pAdapter ) |
| 9565 | { |
| 9566 | status = hdd_get_next_adapter ( pHddCtx, pCurrent, &pNext ); |
| 9567 | if( VOS_STATUS_SUCCESS != status ) |
| 9568 | break; |
| 9569 | |
| 9570 | pCurrent = pNext; |
| 9571 | } |
| 9572 | pAdapterNode = pCurrent; |
| 9573 | if( VOS_STATUS_SUCCESS == status ) |
| 9574 | { |
| 9575 | wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode); |
| 9576 | hdd_cleanup_adapter( pHddCtx, pAdapterNode->pAdapter, rtnl_held ); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 9577 | |
| 9578 | #ifdef FEATURE_WLAN_TDLS |
| 9579 | |
| 9580 | /* A Mutex Lock is introduced while changing/initializing the mode to |
| 9581 | * protect the concurrent access for the Adapters by TDLS module. |
| 9582 | */ |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 9583 | mutex_lock(&pHddCtx->tdls_lock); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 9584 | #endif |
| 9585 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9586 | hdd_remove_adapter( pHddCtx, pAdapterNode ); |
| 9587 | vos_mem_free( pAdapterNode ); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 9588 | pAdapterNode = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9589 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 9590 | #ifdef FEATURE_WLAN_TDLS |
| 9591 | mutex_unlock(&pHddCtx->tdls_lock); |
| 9592 | #endif |
| 9593 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9594 | |
| 9595 | /* 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] | 9596 | if ((!vos_concurrent_open_sessions_running()) && |
| 9597 | ((pHddCtx->no_of_open_sessions[VOS_STA_MODE] >= 1) || |
| 9598 | (pHddCtx->no_of_open_sessions[VOS_P2P_CLIENT_MODE] >= 1))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9599 | { |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 9600 | if (pHddCtx->hdd_wlan_suspended) |
| 9601 | { |
| 9602 | hdd_set_pwrparams(pHddCtx); |
| 9603 | } |
| 9604 | hdd_enable_bmps_imps(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9605 | } |
| 9606 | |
| 9607 | return VOS_STATUS_SUCCESS; |
| 9608 | } |
| 9609 | |
| 9610 | return VOS_STATUS_E_FAILURE; |
| 9611 | } |
| 9612 | |
| 9613 | VOS_STATUS hdd_close_all_adapters( hdd_context_t *pHddCtx ) |
| 9614 | { |
| 9615 | hdd_adapter_list_node_t *pHddAdapterNode; |
| 9616 | VOS_STATUS status; |
| 9617 | |
| 9618 | ENTER(); |
| 9619 | |
| 9620 | do |
| 9621 | { |
| 9622 | status = hdd_remove_front_adapter( pHddCtx, &pHddAdapterNode ); |
| 9623 | if( pHddAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 9624 | { |
| 9625 | hdd_cleanup_adapter( pHddCtx, pHddAdapterNode->pAdapter, FALSE ); |
| 9626 | vos_mem_free( pHddAdapterNode ); |
| 9627 | } |
| 9628 | }while( NULL != pHddAdapterNode && VOS_STATUS_E_EMPTY != status ); |
| 9629 | |
| 9630 | EXIT(); |
| 9631 | |
| 9632 | return VOS_STATUS_SUCCESS; |
| 9633 | } |
| 9634 | |
| 9635 | void wlan_hdd_reset_prob_rspies(hdd_adapter_t* pHostapdAdapter) |
| 9636 | { |
| 9637 | v_U8_t addIE[1] = {0}; |
| 9638 | |
| 9639 | if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 9640 | WNI_CFG_PROBE_RSP_ADDNIE_DATA1,(tANI_U8*)addIE, 0, NULL, |
| 9641 | eANI_BOOLEAN_FALSE) ) |
| 9642 | { |
| 9643 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 9644 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9645 | } |
| 9646 | |
| 9647 | if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 9648 | WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL, |
| 9649 | eANI_BOOLEAN_FALSE) ) |
| 9650 | { |
| 9651 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 9652 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9653 | } |
| 9654 | |
| 9655 | if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 9656 | WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL, |
| 9657 | eANI_BOOLEAN_FALSE) ) |
| 9658 | { |
| 9659 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 9660 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9661 | } |
| 9662 | } |
| 9663 | |
Anurag Chouhan | 8302600 | 2016-12-13 22:46:21 +0530 | [diff] [blame] | 9664 | VOS_STATUS hdd_cleanup_ap_events(hdd_adapter_t *adapter) |
| 9665 | { |
| 9666 | #ifdef DHCP_SERVER_OFFLOAD |
| 9667 | vos_event_destroy(&adapter->dhcp_status.vos_event); |
| 9668 | #endif |
Anurag Chouhan | 0b29de0 | 2016-12-16 13:18:40 +0530 | [diff] [blame] | 9669 | #ifdef MDNS_OFFLOAD |
| 9670 | vos_event_destroy(&adapter->mdns_status.vos_event); |
| 9671 | #endif |
Anurag Chouhan | 8302600 | 2016-12-13 22:46:21 +0530 | [diff] [blame] | 9672 | return VOS_STATUS_SUCCESS; |
| 9673 | } |
| 9674 | |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 9675 | int wlan_hdd_stop_mon(hdd_context_t *hdd_ctx, bool wait) |
| 9676 | { |
| 9677 | hdd_mon_ctx_t *mon_ctx; |
| 9678 | long ret; |
| 9679 | v_U32_t magic; |
| 9680 | struct completion cmp_var; |
| 9681 | void (*func_ptr)(tANI_U32 *magic, struct completion *cmpVar) = NULL; |
| 9682 | hdd_adapter_t *adapter; |
| 9683 | |
| 9684 | adapter = hdd_get_adapter(hdd_ctx, WLAN_HDD_MONITOR); |
| 9685 | if (!adapter) { |
| 9686 | hddLog(LOGE, FL("Invalid STA + MON mode")); |
| 9687 | return -EINVAL; |
| 9688 | } |
| 9689 | |
| 9690 | mon_ctx = WLAN_HDD_GET_MONITOR_CTX_PTR(adapter); |
| 9691 | if (!mon_ctx) |
| 9692 | return 0; |
| 9693 | |
| 9694 | if (mon_ctx->state != MON_MODE_START) |
| 9695 | return 0; |
| 9696 | |
| 9697 | mon_ctx->state = MON_MODE_STOP; |
| 9698 | if (wait) { |
| 9699 | func_ptr = hdd_monPostMsgCb; |
| 9700 | magic = MON_MODE_MSG_MAGIC; |
| 9701 | init_completion(&cmp_var); |
| 9702 | } |
| 9703 | |
| 9704 | if (VOS_STATUS_SUCCESS != wlan_hdd_mon_postMsg(&magic, &cmp_var, |
| 9705 | mon_ctx, |
| 9706 | hdd_monPostMsgCb)) { |
| 9707 | hddLog(LOGE, FL("failed to stop MON MODE")); |
| 9708 | mon_ctx->state = MON_MODE_START; |
| 9709 | magic = 0; |
| 9710 | return -EINVAL; |
| 9711 | } |
| 9712 | |
| 9713 | if (!wait) |
| 9714 | goto bmps_roaming; |
| 9715 | |
| 9716 | ret = wait_for_completion_timeout(&cmp_var, MON_MODE_MSG_TIMEOUT); |
| 9717 | magic = 0; |
| 9718 | if (ret <= 0 ) { |
| 9719 | hddLog(LOGE, |
| 9720 | FL("timeout on stop monitor mode completion %ld"), ret); |
| 9721 | return -EINVAL; |
| 9722 | } |
| 9723 | |
| 9724 | bmps_roaming: |
| 9725 | hddLog(LOG1, FL("Enable BMPS")); |
| 9726 | hdd_enable_bmps_imps(hdd_ctx); |
| 9727 | hdd_restore_roaming(hdd_ctx); |
| 9728 | |
| 9729 | return 0; |
| 9730 | } |
| 9731 | |
| 9732 | bool wlan_hdd_check_monitor_state(hdd_context_t *hdd_ctx) |
| 9733 | { |
| 9734 | hdd_adapter_t *mon_adapter; |
| 9735 | hdd_mon_ctx_t *mon_ctx; |
| 9736 | |
| 9737 | if (hdd_ctx->concurrency_mode != VOS_STA_MON) |
| 9738 | return false; |
| 9739 | |
| 9740 | mon_adapter = hdd_get_adapter(hdd_ctx, WLAN_HDD_MONITOR); |
| 9741 | if (!mon_adapter) { |
| 9742 | hddLog(LOGE, FL("Invalid concurrency mode")); |
| 9743 | return false; |
| 9744 | } |
| 9745 | |
| 9746 | mon_ctx = WLAN_HDD_GET_MONITOR_CTX_PTR(mon_adapter); |
| 9747 | if (mon_ctx->state == MON_MODE_START) |
| 9748 | return true; |
| 9749 | |
| 9750 | return false; |
| 9751 | } |
| 9752 | |
| 9753 | int wlan_hdd_check_and_stop_mon(hdd_adapter_t *sta_adapter, bool wait) |
| 9754 | { |
| 9755 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(sta_adapter); |
| 9756 | |
| 9757 | if ((sta_adapter->device_mode != WLAN_HDD_INFRA_STATION) || |
| 9758 | !wlan_hdd_check_monitor_state(hdd_ctx)) |
| 9759 | return 0; |
| 9760 | |
| 9761 | if (wlan_hdd_stop_mon(hdd_ctx, wait)) |
| 9762 | return -EINVAL; |
| 9763 | |
| 9764 | return 0; |
| 9765 | } |
| 9766 | |
| 9767 | void hdd_disable_roaming(hdd_context_t *hdd_ctx) |
| 9768 | { |
| 9769 | if (!hdd_ctx) |
| 9770 | return; |
| 9771 | |
| 9772 | if (!hdd_ctx->cfg_ini->isFastRoamIniFeatureEnabled) { |
| 9773 | hdd_ctx->roaming_ini_original = CFG_LFR_FEATURE_ENABLED_MIN; |
| 9774 | return; |
| 9775 | } |
| 9776 | |
| 9777 | hddLog(LOG1, FL("Disable driver and firmware roaming")); |
| 9778 | |
| 9779 | hdd_ctx->roaming_ini_original = |
| 9780 | hdd_ctx->cfg_ini->isFastRoamIniFeatureEnabled; |
| 9781 | |
| 9782 | hdd_ctx->cfg_ini->isFastRoamIniFeatureEnabled = |
| 9783 | CFG_LFR_FEATURE_ENABLED_MIN; |
| 9784 | |
| 9785 | sme_UpdateIsFastRoamIniFeatureEnabled(hdd_ctx->hHal, |
| 9786 | CFG_LFR_FEATURE_ENABLED_MIN); |
| 9787 | } |
| 9788 | |
| 9789 | void hdd_restore_roaming(hdd_context_t *hdd_ctx) |
| 9790 | { |
| 9791 | if (!hdd_ctx->roaming_ini_original) |
| 9792 | return; |
| 9793 | |
| 9794 | hddLog(LOG1, FL("Enable driver and firmware roaming")); |
| 9795 | |
| 9796 | hdd_ctx->cfg_ini->isFastRoamIniFeatureEnabled = |
| 9797 | CFG_LFR_FEATURE_ENABLED_MAX; |
| 9798 | |
| 9799 | hdd_ctx->roaming_ini_original = CFG_LFR_FEATURE_ENABLED_MIN; |
| 9800 | |
| 9801 | sme_UpdateIsFastRoamIniFeatureEnabled(hdd_ctx->hHal, |
| 9802 | CFG_LFR_FEATURE_ENABLED_MAX); |
| 9803 | } |
Anurag Chouhan | 8302600 | 2016-12-13 22:46:21 +0530 | [diff] [blame] | 9804 | |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 9805 | VOS_STATUS hdd_stop_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter, |
| 9806 | const v_BOOL_t bCloseSession ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9807 | { |
| 9808 | eHalStatus halStatus = eHAL_STATUS_SUCCESS; |
| 9809 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Kaushik, Sushant | 4975a57 | 2014-10-21 16:07:48 +0530 | [diff] [blame] | 9810 | hdd_scaninfo_t *pScanInfo = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9811 | union iwreq_data wrqu; |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 9812 | v_U8_t retry = 0; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 9813 | long ret; |
Nirav Shah | 7e3c813 | 2015-06-22 23:51:42 +0530 | [diff] [blame] | 9814 | VOS_STATUS status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9815 | |
Anand N Sunkad | 26d71b9 | 2014-12-24 18:08:22 +0530 | [diff] [blame] | 9816 | if (pHddCtx->isLogpInProgress) { |
| 9817 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 9818 | "%s:LOGP in Progress. Ignore!!!",__func__); |
| 9819 | return VOS_STATUS_E_FAILURE; |
| 9820 | } |
| 9821 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9822 | ENTER(); |
Vinay Krishna Eranna | f97ef5c | 2014-12-26 17:47:19 +0530 | [diff] [blame] | 9823 | |
Kaushik, Sushant | 4975a57 | 2014-10-21 16:07:48 +0530 | [diff] [blame] | 9824 | pScanInfo = &pHddCtx->scan_info; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9825 | switch(pAdapter->device_mode) |
| 9826 | { |
Nirav Shah | 0cf4d89 | 2015-11-05 16:27:27 +0530 | [diff] [blame] | 9827 | case WLAN_HDD_IBSS: |
| 9828 | if ( VOS_TRUE == bCloseSession ) |
| 9829 | { |
| 9830 | status = hdd_sta_id_hash_detach(pAdapter); |
| 9831 | if (status != VOS_STATUS_SUCCESS) |
| 9832 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 9833 | FL("sta id hash detach failed")); |
| 9834 | } |
| 9835 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9836 | case WLAN_HDD_INFRA_STATION: |
| 9837 | case WLAN_HDD_P2P_CLIENT: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9838 | case WLAN_HDD_P2P_DEVICE: |
Vinay Krishna Eranna | b09d3e7 | 2014-03-26 21:23:55 +0530 | [diff] [blame] | 9839 | { |
| 9840 | 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] | 9841 | #ifdef FEATURE_WLAN_TDLS |
| 9842 | mutex_lock(&pHddCtx->tdls_lock); |
| 9843 | wlan_hdd_tdls_exit(pAdapter, TRUE); |
| 9844 | mutex_unlock(&pHddCtx->tdls_lock); |
| 9845 | #endif |
Vinay Krishna Eranna | b09d3e7 | 2014-03-26 21:23:55 +0530 | [diff] [blame] | 9846 | if( hdd_connIsConnected(pstation) || |
| 9847 | (pstation->conn_info.connState == eConnectionState_Connecting) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9848 | { |
Abhishek Singh | e21a521 | 2017-06-09 09:42:58 +0530 | [diff] [blame] | 9849 | /* |
| 9850 | * Indicate sme of disconnect so that in progress connection |
| 9851 | * or preauth can be aborted. |
| 9852 | */ |
| 9853 | sme_abortConnection(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 9854 | pAdapter->sessionId); |
Abhishek Singh | 99f17b8 | 2017-02-06 16:57:56 +0530 | [diff] [blame] | 9855 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9856 | if (pWextState->roamProfile.BSSType == eCSR_BSS_TYPE_START_IBSS) |
| 9857 | halStatus = sme_RoamDisconnect(pHddCtx->hHal, |
| 9858 | pAdapter->sessionId, |
| 9859 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
| 9860 | else |
| 9861 | halStatus = sme_RoamDisconnect(pHddCtx->hHal, |
| 9862 | pAdapter->sessionId, |
| 9863 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
Abhishek Singh | 7b52ed5 | 2016-02-11 17:45:54 +0530 | [diff] [blame] | 9864 | /* Success implies disconnect command got queued up successfully |
| 9865 | * Or cmd not queued as scan for SSID is in progress |
| 9866 | */ |
| 9867 | if((eHAL_STATUS_SUCCESS == halStatus) || |
| 9868 | (eHAL_STATUS_CMD_NOT_QUEUED == halStatus)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9869 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 9870 | ret = wait_for_completion_interruptible_timeout( |
| 9871 | &pAdapter->disconnect_comp_var, |
| 9872 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
Abhishek Singh | 7b52ed5 | 2016-02-11 17:45:54 +0530 | [diff] [blame] | 9873 | if (ret <= 0 && |
| 9874 | (eHAL_STATUS_CMD_NOT_QUEUED != halStatus)) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 9875 | { |
| 9876 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 9877 | "%s: wait on disconnect_comp_var failed %ld", |
| 9878 | __func__, ret); |
| 9879 | } |
| 9880 | } |
| 9881 | else |
| 9882 | { |
| 9883 | hddLog(LOGE, "%s: failed to post disconnect event to SME", |
| 9884 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9885 | } |
| 9886 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 9887 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 9888 | memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN); |
| 9889 | wireless_send_event(pAdapter->dev, SIOCGIWAP, &wrqu, NULL); |
| 9890 | } |
Vinay Krishna Eranna | b09d3e7 | 2014-03-26 21:23:55 +0530 | [diff] [blame] | 9891 | else if(pstation->conn_info.connState == |
| 9892 | eConnectionState_Disconnecting) |
| 9893 | { |
| 9894 | ret = wait_for_completion_interruptible_timeout( |
| 9895 | &pAdapter->disconnect_comp_var, |
| 9896 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 9897 | if (ret <= 0) |
| 9898 | { |
| 9899 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 9900 | FL("wait on disconnect_comp_var failed %ld"), ret); |
| 9901 | } |
| 9902 | } |
Sachin Ahuja | 27dd240 | 2016-08-01 20:30:31 +0530 | [diff] [blame] | 9903 | if(pScanInfo != NULL && pHddCtx->scan_info.mScanPending) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9904 | { |
Mahesh A Saptasagar | 0b61dcc | 2016-02-15 14:23:38 +0530 | [diff] [blame] | 9905 | wlan_hdd_scan_abort(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9906 | } |
Abhishek Singh | 3ac179b | 2015-09-21 10:01:34 +0530 | [diff] [blame] | 9907 | if ((pAdapter->device_mode != WLAN_HDD_INFRA_STATION) && |
| 9908 | (pAdapter->device_mode != WLAN_HDD_IBSS)) |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 9909 | { |
| 9910 | while (pAdapter->is_roc_inprogress) |
| 9911 | { |
| 9912 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9913 | "%s: ROC in progress for session %d!!!", |
| 9914 | __func__, pAdapter->sessionId); |
| 9915 | // waiting for ROC to expire |
| 9916 | msleep(500); |
| 9917 | /* In GO present case , if retry exceeds 3, |
| 9918 | it means something went wrong. */ |
| 9919 | if ( retry++ > MAX_WAIT_FOR_ROC_COMPLETION ) |
| 9920 | { |
| 9921 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9922 | "%s: ROC completion is not received.!!!", __func__); |
Deepthi Gowri | 7049825 | 2015-01-20 15:56:45 +0530 | [diff] [blame] | 9923 | if (eHAL_STATUS_SUCCESS != |
| 9924 | sme_CancelRemainOnChannel( WLAN_HDD_GET_HAL_CTX( pAdapter), |
| 9925 | pAdapter->sessionId )) |
| 9926 | { |
| 9927 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9928 | FL("Failed to Cancel Remain on Channel")); |
| 9929 | } |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 9930 | wait_for_completion_interruptible_timeout( |
| 9931 | &pAdapter->cancel_rem_on_chan_var, |
| 9932 | msecs_to_jiffies(WAIT_CANCEL_REM_CHAN)); |
| 9933 | break; |
| 9934 | } |
| 9935 | } |
Anand N Sunkad | dc63c79 | 2015-06-03 14:33:24 +0530 | [diff] [blame] | 9936 | vos_flush_delayed_work(&pAdapter->roc_work); |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 9937 | } |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 9938 | #ifdef WLAN_NS_OFFLOAD |
Anand N Sunkad | dc63c79 | 2015-06-03 14:33:24 +0530 | [diff] [blame] | 9939 | vos_flush_work(&pAdapter->ipv6NotifierWorkQueue); |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 9940 | #endif |
Vinay Krishna Eranna | f97ef5c | 2014-12-26 17:47:19 +0530 | [diff] [blame] | 9941 | |
Anand N Sunkad | dc63c79 | 2015-06-03 14:33:24 +0530 | [diff] [blame] | 9942 | vos_flush_work(&pAdapter->ipv4NotifierWorkQueue); |
Vinay Krishna Eranna | f97ef5c | 2014-12-26 17:47:19 +0530 | [diff] [blame] | 9943 | |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 9944 | /* It is possible that the caller of this function does not |
| 9945 | * wish to close the session |
| 9946 | */ |
| 9947 | if (VOS_TRUE == bCloseSession && |
| 9948 | test_bit(SME_SESSION_OPENED, &pAdapter->event_flags)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9949 | { |
| 9950 | INIT_COMPLETION(pAdapter->session_close_comp_var); |
| 9951 | if (eHAL_STATUS_SUCCESS == |
Agrawal Ashish | 5a3522c | 2016-03-02 15:08:28 +0530 | [diff] [blame] | 9952 | sme_CloseSession(pHddCtx->hHal, pAdapter->sessionId, FALSE, |
| 9953 | VOS_FALSE, hdd_smeCloseSessionCallback, pAdapter)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9954 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 9955 | unsigned long ret; |
| 9956 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9957 | //Block on a completion variable. Can't wait forever though. |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 9958 | ret = wait_for_completion_timeout( |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 9959 | &pAdapter->session_close_comp_var, |
| 9960 | msecs_to_jiffies(WLAN_WAIT_TIME_SESSIONOPENCLOSE)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 9961 | if ( 0 >= ret) |
| 9962 | { |
| 9963 | hddLog(LOGE, "%s: failure waiting for session_close_comp_var %ld", |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 9964 | __func__, ret); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 9965 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9966 | } |
| 9967 | } |
Vinay Krishna Eranna | b09d3e7 | 2014-03-26 21:23:55 +0530 | [diff] [blame] | 9968 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9969 | break; |
| 9970 | |
| 9971 | case WLAN_HDD_SOFTAP: |
| 9972 | case WLAN_HDD_P2P_GO: |
Nirav Shah | 0cf4d89 | 2015-11-05 16:27:27 +0530 | [diff] [blame] | 9973 | if ( VOS_TRUE == bCloseSession ) |
| 9974 | { |
| 9975 | status = hdd_sta_id_hash_detach(pAdapter); |
| 9976 | if (status != VOS_STATUS_SUCCESS) |
| 9977 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 9978 | FL("sta id hash detach failed")); |
| 9979 | } |
| 9980 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9981 | //Any softap specific cleanup here... |
Anurag Chouhan | 8302600 | 2016-12-13 22:46:21 +0530 | [diff] [blame] | 9982 | hdd_cleanup_ap_events(pAdapter); |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 9983 | if (pAdapter->device_mode == WLAN_HDD_P2P_GO) { |
| 9984 | while (pAdapter->is_roc_inprogress) { |
| 9985 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9986 | "%s: ROC in progress for session %d!!!", |
| 9987 | __func__, pAdapter->sessionId); |
| 9988 | msleep(500); |
| 9989 | if ( retry++ > MAX_WAIT_FOR_ROC_COMPLETION ) { |
| 9990 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9991 | "%s: ROC completion is not received.!!!", __func__); |
| 9992 | WLANSAP_CancelRemainOnChannel( |
| 9993 | (WLAN_HDD_GET_CTX(pAdapter))->pvosContext); |
| 9994 | wait_for_completion_interruptible_timeout( |
| 9995 | &pAdapter->cancel_rem_on_chan_var, |
| 9996 | msecs_to_jiffies(WAIT_CANCEL_REM_CHAN)); |
| 9997 | break; |
| 9998 | } |
| 9999 | } |
Ganesh Kondabattini | babfb49 | 2014-12-17 20:25:29 +0530 | [diff] [blame] | 10000 | |
Anand N Sunkad | dc63c79 | 2015-06-03 14:33:24 +0530 | [diff] [blame] | 10001 | vos_flush_delayed_work(&pAdapter->roc_work); |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 10002 | } |
Agrawal Ashish | 17ef508 | 2016-10-17 18:33:21 +0530 | [diff] [blame] | 10003 | #ifdef SAP_AUTH_OFFLOAD |
| 10004 | if (pHddCtx->cfg_ini->enable_sap_auth_offload) |
| 10005 | hdd_set_sap_auth_offload(pAdapter, FALSE); |
| 10006 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10007 | mutex_lock(&pHddCtx->sap_lock); |
| 10008 | if (test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags)) |
| 10009 | { |
| 10010 | VOS_STATUS status; |
| 10011 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 10012 | |
| 10013 | //Stop Bss. |
| 10014 | status = WLANSAP_StopBss(pHddCtx->pvosContext); |
| 10015 | if (VOS_IS_STATUS_SUCCESS(status)) |
| 10016 | { |
| 10017 | hdd_hostapd_state_t *pHostapdState = |
| 10018 | WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 10019 | |
| 10020 | status = vos_wait_single_event(&pHostapdState->vosEvent, 10000); |
| 10021 | |
| 10022 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 10023 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 10024 | hddLog(LOGE, "%s: failure waiting for WLANSAP_StopBss %d", |
| 10025 | __func__, status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10026 | } |
| 10027 | } |
| 10028 | else |
| 10029 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 10030 | hddLog(LOGE, "%s: failure in WLANSAP_StopBss", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10031 | } |
| 10032 | clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags); |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 10033 | wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10034 | |
| 10035 | if (eHAL_STATUS_FAILURE == |
| 10036 | ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, |
| 10037 | 0, NULL, eANI_BOOLEAN_FALSE)) |
| 10038 | { |
| 10039 | hddLog(LOGE, |
| 10040 | "%s: Failed to set WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 10041 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10042 | } |
| 10043 | |
| 10044 | if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal, |
| 10045 | WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL, |
| 10046 | eANI_BOOLEAN_FALSE) ) |
| 10047 | { |
| 10048 | hddLog(LOGE, |
| 10049 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM"); |
| 10050 | } |
| 10051 | |
| 10052 | // Reset WNI_CFG_PROBE_RSP Flags |
| 10053 | wlan_hdd_reset_prob_rspies(pAdapter); |
| 10054 | kfree(pAdapter->sessionCtx.ap.beacon); |
| 10055 | pAdapter->sessionCtx.ap.beacon = NULL; |
| 10056 | } |
| 10057 | mutex_unlock(&pHddCtx->sap_lock); |
Hanumanth Reddy Pothula | b4537b8 | 2018-03-02 12:20:38 +0530 | [diff] [blame] | 10058 | |
| 10059 | #ifdef WLAN_NS_OFFLOAD |
| 10060 | vos_flush_work(&pAdapter->ipv6NotifierWorkQueue); |
| 10061 | #endif |
| 10062 | vos_flush_work(&pAdapter->ipv4NotifierWorkQueue); |
| 10063 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10064 | break; |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 10065 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10066 | case WLAN_HDD_MONITOR: |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 10067 | if (VOS_MONITOR_MODE != hdd_get_conparam()) |
| 10068 | wlan_hdd_stop_mon(pHddCtx, true); |
| 10069 | break; |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 10070 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10071 | default: |
| 10072 | break; |
| 10073 | } |
| 10074 | |
| 10075 | EXIT(); |
| 10076 | return VOS_STATUS_SUCCESS; |
| 10077 | } |
| 10078 | |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 10079 | /** |
| 10080 | * wlan_hdd_restart_sap() - to restart SAP in driver internally |
| 10081 | * @ap_adapter: - Pointer to SAP hdd_adapter_t structure |
| 10082 | * |
| 10083 | * wlan_hdd_restart_sap first delete SAP and do cleanup. |
| 10084 | * After that WLANSAP_StartBss start re-start process of SAP. |
| 10085 | * |
| 10086 | * Return: None |
| 10087 | */ |
| 10088 | static void wlan_hdd_restart_sap(hdd_adapter_t *ap_adapter) |
| 10089 | { |
| 10090 | hdd_ap_ctx_t *pHddApCtx; |
| 10091 | hdd_hostapd_state_t *pHostapdState; |
| 10092 | VOS_STATUS vos_status; |
| 10093 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(ap_adapter); |
Rajeev Kumar Sirasanagandla | 5b21a9c | 2018-01-08 17:05:11 +0530 | [diff] [blame] | 10094 | #ifdef USE_CFG80211_DEL_STA_V2 |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 10095 | struct station_del_parameters delStaParams; |
| 10096 | #endif |
| 10097 | tsap_Config_t *pConfig; |
| 10098 | |
| 10099 | pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 10100 | pConfig = &pHddApCtx->sapConfig; |
| 10101 | |
| 10102 | mutex_lock(&pHddCtx->sap_lock); |
| 10103 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
Rajeev Kumar Sirasanagandla | 5b21a9c | 2018-01-08 17:05:11 +0530 | [diff] [blame] | 10104 | #ifdef USE_CFG80211_DEL_STA_V2 |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 10105 | delStaParams.mac = NULL; |
| 10106 | delStaParams.subtype = SIR_MAC_MGMT_DEAUTH >> 4; |
| 10107 | delStaParams.reason_code = eCsrForcedDeauthSta; |
| 10108 | wlan_hdd_cfg80211_del_station(ap_adapter->wdev.wiphy, ap_adapter->dev, |
| 10109 | &delStaParams); |
| 10110 | #else |
| 10111 | wlan_hdd_cfg80211_del_station(ap_adapter->wdev.wiphy, ap_adapter->dev, |
| 10112 | NULL); |
| 10113 | #endif |
| 10114 | hdd_cleanup_actionframe(pHddCtx, ap_adapter); |
| 10115 | |
| 10116 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
| 10117 | vos_event_reset(&pHostapdState->vosEvent); |
| 10118 | |
| 10119 | if (VOS_STATUS_SUCCESS == WLANSAP_StopBss(pHddCtx->pvosContext)) { |
| 10120 | vos_status = vos_wait_single_event(&pHostapdState->vosEvent, |
| 10121 | 10000); |
| 10122 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) { |
| 10123 | hddLog(LOGE, FL("SAP Stop Failed")); |
| 10124 | goto end; |
| 10125 | } |
| 10126 | } |
| 10127 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
| 10128 | wlan_hdd_decr_active_session(pHddCtx, ap_adapter->device_mode); |
| 10129 | hddLog(LOG1, FL("SAP Stop Success")); |
| 10130 | |
| 10131 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
| 10132 | hddLog(LOGE, FL("SAP Not able to set AP IEs")); |
| 10133 | goto end; |
| 10134 | } |
| 10135 | |
| 10136 | if (WLANSAP_StartBss(pHddCtx->pvosContext, hdd_hostapd_SAPEventCB, |
| 10137 | pConfig, (v_PVOID_t)ap_adapter->dev) != VOS_STATUS_SUCCESS) { |
| 10138 | hddLog(LOGE, FL("SAP Start Bss fail")); |
| 10139 | goto end; |
| 10140 | } |
| 10141 | |
| 10142 | hddLog(LOG1, FL("Waiting for SAP to start")); |
| 10143 | vos_status = vos_wait_single_event(&pHostapdState->vosEvent, 10000); |
| 10144 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) { |
| 10145 | hddLog(LOGE, FL("SAP Start failed")); |
| 10146 | goto end; |
| 10147 | } |
| 10148 | hddLog(LOG1, FL("SAP Start Success")); |
| 10149 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
| 10150 | wlan_hdd_incr_active_session(pHddCtx, ap_adapter->device_mode); |
| 10151 | pHostapdState->bCommit = TRUE; |
Anurag Chouhan | b2951ae | 2017-03-12 13:41:35 +0530 | [diff] [blame] | 10152 | if (!VOS_IS_STATUS_SUCCESS(hdd_dhcp_mdns_offload(ap_adapter))) { |
| 10153 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("DHCP/MDNS offload Failed!!")); |
| 10154 | vos_event_reset(&pHostapdState->vosEvent); |
| 10155 | if (VOS_STATUS_SUCCESS == WLANSAP_StopBss(pHddCtx->pvosContext)) { |
| 10156 | vos_status = vos_wait_single_event(&pHostapdState->vosEvent, |
| 10157 | 10000); |
| 10158 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) { |
| 10159 | hddLog(LOGE, FL("SAP Stop Failed")); |
| 10160 | goto end; |
| 10161 | } |
| 10162 | } |
| 10163 | } |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 10164 | } |
| 10165 | end: |
| 10166 | mutex_unlock(&pHddCtx->sap_lock); |
| 10167 | return; |
| 10168 | } |
| 10169 | |
| 10170 | /** |
| 10171 | * __hdd_sap_restart_handle() - to handle restarting of SAP |
| 10172 | * @work: name of the work |
| 10173 | * |
| 10174 | * Purpose of this function is to trigger sap start. this function |
| 10175 | * will be called from workqueue. |
| 10176 | * |
| 10177 | * Return: void. |
| 10178 | */ |
| 10179 | static void __hdd_sap_restart_handle(struct work_struct *work) |
| 10180 | { |
| 10181 | hdd_adapter_t *sap_adapter; |
| 10182 | hdd_context_t *hdd_ctx = container_of(work, |
| 10183 | hdd_context_t, |
| 10184 | sap_start_work); |
| 10185 | if (0 != wlan_hdd_validate_context(hdd_ctx)) { |
| 10186 | vos_ssr_unprotect(__func__); |
| 10187 | return; |
| 10188 | } |
| 10189 | sap_adapter = hdd_get_adapter(hdd_ctx, |
| 10190 | WLAN_HDD_SOFTAP); |
| 10191 | if (sap_adapter == NULL) { |
| 10192 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10193 | FL("sap_adapter is NULL")); |
| 10194 | vos_ssr_unprotect(__func__); |
| 10195 | return; |
| 10196 | } |
| 10197 | |
| 10198 | if (hdd_ctx->is_ch_avoid_in_progress) { |
| 10199 | sap_adapter->sessionCtx.ap.sapConfig.channel = AUTO_CHANNEL_SELECT; |
| 10200 | wlan_hdd_restart_sap(sap_adapter); |
| 10201 | hdd_change_ch_avoidance_status(hdd_ctx, false); |
| 10202 | } |
Agrawal Ashish | 574b3e6 | 2017-02-09 18:58:34 +0530 | [diff] [blame] | 10203 | if (hdd_ctx->cfg_ini->enable_sap_auth_offload) |
| 10204 | wlan_hdd_restart_sap(sap_adapter); |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 10205 | } |
| 10206 | |
| 10207 | /** |
| 10208 | * hdd_sap_restart_handle() - to handle restarting of SAP |
| 10209 | * @work: name of the work |
| 10210 | * |
| 10211 | * Purpose of this function is to trigger sap start. this function |
| 10212 | * will be called from workqueue. |
| 10213 | * |
| 10214 | * Return: void. |
| 10215 | */ |
| 10216 | static void hdd_sap_restart_handle(struct work_struct *work) |
| 10217 | { |
| 10218 | vos_ssr_protect(__func__); |
| 10219 | __hdd_sap_restart_handle(work); |
| 10220 | vos_ssr_unprotect(__func__); |
| 10221 | } |
| 10222 | |
| 10223 | |
Abhishek Singh | 78c691f | 2017-11-30 13:48:44 +0530 | [diff] [blame] | 10224 | /** |
| 10225 | * __hdd_force_scc_with_ecsa_handle() - to handle force scc using ecsa |
| 10226 | * @work: name of the work |
| 10227 | * |
| 10228 | * Purpose of this function is to force SCC using ECSA. This function |
| 10229 | * will be called from workqueue. |
| 10230 | * |
| 10231 | * Return: void. |
| 10232 | */ |
| 10233 | static void |
| 10234 | __hdd_force_scc_with_ecsa_handle(struct work_struct *work) |
| 10235 | { |
| 10236 | hdd_adapter_t *sap_adapter; |
| 10237 | hdd_station_ctx_t *sta_ctx; |
| 10238 | hdd_adapter_t *sta_adapter; |
Ganesh Kondabattini | 3655a6d | 2018-01-08 20:25:39 +0530 | [diff] [blame] | 10239 | ptSapContext sap_ctx = NULL; |
| 10240 | v_CONTEXT_t vos_ctx; |
| 10241 | tANI_U8 target_channel; |
| 10242 | tsap_Config_t *sap_config; |
| 10243 | bool sta_sap_scc_on_dfs_chan; |
| 10244 | eNVChannelEnabledType chan_state; |
Abhishek Singh | 78c691f | 2017-11-30 13:48:44 +0530 | [diff] [blame] | 10245 | hdd_context_t *hdd_ctx = container_of(to_delayed_work(work), |
| 10246 | hdd_context_t, |
| 10247 | ecsa_chan_change_work); |
| 10248 | |
| 10249 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 10250 | return; |
| 10251 | |
| 10252 | sap_adapter = hdd_get_adapter(hdd_ctx, |
| 10253 | WLAN_HDD_SOFTAP); |
| 10254 | if (!sap_adapter) { |
| 10255 | hddLog(LOGE, FL("sap_adapter is NULL")); |
| 10256 | return; |
| 10257 | } |
| 10258 | |
Ganesh Kondabattini | 3655a6d | 2018-01-08 20:25:39 +0530 | [diff] [blame] | 10259 | vos_ctx = hdd_ctx->pvosContext; |
| 10260 | if (!vos_ctx) { |
| 10261 | hddLog(LOGE, FL("vos_ctx is NULL")); |
| 10262 | return; |
| 10263 | } |
| 10264 | |
| 10265 | sap_ctx = VOS_GET_SAP_CB(vos_ctx); |
| 10266 | if (!sap_ctx) { |
| 10267 | hddLog(LOGE, FL("sap_ctx is NULL")); |
| 10268 | return; |
| 10269 | } |
| 10270 | |
| 10271 | sap_config = &sap_adapter->sessionCtx.ap.sapConfig; |
| 10272 | |
| 10273 | sta_sap_scc_on_dfs_chan = hdd_is_sta_sap_scc_allowed_on_dfs_chan(hdd_ctx); |
| 10274 | |
Abhishek Singh | 78c691f | 2017-11-30 13:48:44 +0530 | [diff] [blame] | 10275 | sta_adapter = hdd_get_adapter(hdd_ctx, |
| 10276 | WLAN_HDD_INFRA_STATION); |
| 10277 | if (!sta_adapter) { |
| 10278 | hddLog(LOGE, FL("sta_adapter is NULL")); |
| 10279 | return; |
| 10280 | } |
Abhishek Singh | 78c691f | 2017-11-30 13:48:44 +0530 | [diff] [blame] | 10281 | |
Abhishek Singh | 10e17cf | 2018-03-12 14:34:22 +0530 | [diff] [blame] | 10282 | if (wlansap_chk_n_set_chan_change_in_progress(sap_ctx)) |
Abhishek Singh | 78c691f | 2017-11-30 13:48:44 +0530 | [diff] [blame] | 10283 | return; |
Abhishek Singh | 10e17cf | 2018-03-12 14:34:22 +0530 | [diff] [blame] | 10284 | INIT_COMPLETION(sap_ctx->ecsa_info.chan_switch_comp); |
| 10285 | |
| 10286 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(sta_adapter); |
| 10287 | if (sta_ctx->conn_info.connState != eConnectionState_Associated) { |
| 10288 | if (sta_ctx->conn_info.connState == eConnectionState_NotConnected) { |
| 10289 | chan_state = vos_nv_getChannelEnabledState(sap_ctx->channel); |
| 10290 | hddLog(LOG1, FL("sta not in connected state %d, sta_sap_scc_on_dfs_chan %d, chan_state %d"), |
| 10291 | sta_ctx->conn_info.connState, sta_sap_scc_on_dfs_chan, |
| 10292 | chan_state); |
| 10293 | if (sta_sap_scc_on_dfs_chan && |
| 10294 | (chan_state == NV_CHANNEL_DFS)) { |
| 10295 | hddLog(LOGE, FL("Switch SAP to user configured channel")); |
| 10296 | target_channel = sap_config->user_config_channel; |
| 10297 | goto switch_channel; |
| 10298 | } |
| 10299 | } |
| 10300 | goto abort; |
Abhishek Singh | 78c691f | 2017-11-30 13:48:44 +0530 | [diff] [blame] | 10301 | } |
| 10302 | |
Ganesh Kondabattini | 3655a6d | 2018-01-08 20:25:39 +0530 | [diff] [blame] | 10303 | target_channel = sta_ctx->conn_info.operationChannel; |
| 10304 | switch_channel: |
| 10305 | hddLog(LOGE, FL("Switch SAP to %d channel"), |
| 10306 | target_channel); |
Abhishek Singh | 10e17cf | 2018-03-12 14:34:22 +0530 | [diff] [blame] | 10307 | if (!wlansap_set_channel_change(vos_ctx, target_channel, true)) |
| 10308 | return; |
| 10309 | |
| 10310 | abort: |
| 10311 | wlansap_reset_chan_change_in_progress(sap_ctx); |
| 10312 | complete(&sap_ctx->ecsa_info.chan_switch_comp); |
Abhishek Singh | 78c691f | 2017-11-30 13:48:44 +0530 | [diff] [blame] | 10313 | } |
| 10314 | |
| 10315 | /** |
| 10316 | * hdd_force_scc_with_ecsa_handle() - to handle force scc using ecsa |
| 10317 | * @work: name of the work |
| 10318 | * |
| 10319 | * Purpose of this function is to force SCC using ECSA. This function |
| 10320 | * will be called from workqueue. |
| 10321 | * |
| 10322 | * Return: void. |
| 10323 | */ |
| 10324 | static void |
| 10325 | hdd_force_scc_with_ecsa_handle(struct work_struct *work) |
| 10326 | { |
| 10327 | vos_ssr_protect(__func__); |
| 10328 | __hdd_force_scc_with_ecsa_handle(work); |
| 10329 | vos_ssr_unprotect(__func__); |
| 10330 | } |
| 10331 | |
Abhishek Singh | 10e17cf | 2018-03-12 14:34:22 +0530 | [diff] [blame] | 10332 | int hdd_wait_for_ecsa_complete(hdd_context_t *hdd_ctx) |
| 10333 | { |
| 10334 | int ret; |
| 10335 | ptSapContext sap_ctx = NULL; |
| 10336 | v_CONTEXT_t vos_ctx; |
| 10337 | |
| 10338 | vos_ctx = hdd_ctx->pvosContext; |
| 10339 | if (!vos_ctx) { |
| 10340 | hddLog(LOGE, FL("vos_ctx is NULL")); |
| 10341 | return 0; |
| 10342 | } |
| 10343 | |
| 10344 | sap_ctx = VOS_GET_SAP_CB(vos_ctx); |
| 10345 | if (!sap_ctx) { |
| 10346 | hddLog(LOG1, FL("sap_ctx is NULL")); |
| 10347 | return 0; |
| 10348 | } |
| 10349 | if(!sap_ctx->isSapSessionOpen) { |
| 10350 | hddLog(LOG1, FL("sap session not opened, SAP in state %d"), |
| 10351 | sap_ctx->sapsMachine); |
| 10352 | return 0; |
| 10353 | } |
| 10354 | |
| 10355 | if (!wlansap_get_change_in_progress(sap_ctx)) { |
| 10356 | hddLog(LOG1, FL("channel switch not in progress")); |
| 10357 | return 0; |
| 10358 | } |
| 10359 | ret = wait_for_completion_timeout(&sap_ctx->ecsa_info.chan_switch_comp, |
| 10360 | msecs_to_jiffies(HDD_SAP_CHAN_CNG_WAIT_TIME)); |
| 10361 | if (!ret) |
| 10362 | { |
| 10363 | hddLog(LOGE, FL("Timeout waiting for SAP channel switch")); |
| 10364 | return ret; |
| 10365 | } |
| 10366 | |
| 10367 | return 0; |
| 10368 | } |
| 10369 | |
| 10370 | |
Ganesh Kondabattini | 3655a6d | 2018-01-08 20:25:39 +0530 | [diff] [blame] | 10371 | /** |
| 10372 | * hdd_is_sta_sap_scc_allowed_on_dfs_chan() - check if sta+sap scc allowed on |
| 10373 | * dfs chan |
| 10374 | * @hdd_ctx: pointer to hdd context |
| 10375 | * |
| 10376 | * This function used to check if sta+sap scc allowed on DFS channel. |
| 10377 | * |
| 10378 | * Return: None |
| 10379 | */ |
| 10380 | bool hdd_is_sta_sap_scc_allowed_on_dfs_chan(hdd_context_t *hdd_ctx) |
| 10381 | { |
| 10382 | if (hdd_ctx->cfg_ini->force_scc_with_ecsa && |
| 10383 | hdd_ctx->cfg_ini->sta_sap_scc_on_dfs_chan) |
| 10384 | return true; |
| 10385 | else |
| 10386 | return false; |
| 10387 | } |
| 10388 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10389 | VOS_STATUS hdd_stop_all_adapters( hdd_context_t *pHddCtx ) |
| 10390 | { |
| 10391 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 10392 | VOS_STATUS status; |
| 10393 | hdd_adapter_t *pAdapter; |
| 10394 | |
| 10395 | ENTER(); |
| 10396 | |
| 10397 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 10398 | |
| 10399 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 10400 | { |
| 10401 | pAdapter = pAdapterNode->pAdapter; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10402 | |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 10403 | hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10404 | |
| 10405 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 10406 | pAdapterNode = pNext; |
| 10407 | } |
| 10408 | |
| 10409 | EXIT(); |
| 10410 | |
| 10411 | return VOS_STATUS_SUCCESS; |
| 10412 | } |
| 10413 | |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 10414 | |
| 10415 | #ifdef FEATURE_WLAN_BATCH_SCAN |
| 10416 | /**--------------------------------------------------------------------------- |
| 10417 | |
| 10418 | \brief hdd_deinit_batch_scan () - This function cleans up batch scan data |
| 10419 | structures |
| 10420 | |
| 10421 | \param - pAdapter Pointer to HDD adapter |
| 10422 | |
| 10423 | \return - None |
| 10424 | |
| 10425 | --------------------------------------------------------------------------*/ |
| 10426 | void hdd_deinit_batch_scan(hdd_adapter_t *pAdapter) |
| 10427 | { |
| 10428 | tHddBatchScanRsp *pNode; |
| 10429 | tHddBatchScanRsp *pPrev; |
| 10430 | |
Siddharth Bhal | b3e9b79 | 2014-02-24 15:14:16 +0530 | [diff] [blame] | 10431 | if (NULL == pAdapter) |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 10432 | { |
Siddharth Bhal | b3e9b79 | 2014-02-24 15:14:16 +0530 | [diff] [blame] | 10433 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 10434 | "%s: Adapter context is Null", __func__); |
| 10435 | return; |
| 10436 | } |
| 10437 | |
| 10438 | pNode = pAdapter->pBatchScanRsp; |
| 10439 | while (pNode) |
| 10440 | { |
| 10441 | pPrev = pNode; |
| 10442 | pNode = pNode->pNext; |
| 10443 | vos_mem_free((v_VOID_t * )pPrev); |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 10444 | } |
| 10445 | |
| 10446 | pAdapter->pBatchScanRsp = NULL; |
| 10447 | pAdapter->numScanList = 0; |
| 10448 | pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STOPPED; |
| 10449 | pAdapter->prev_batch_id = 0; |
| 10450 | |
| 10451 | return; |
| 10452 | } |
| 10453 | #endif |
| 10454 | |
| 10455 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10456 | VOS_STATUS hdd_reset_all_adapters( hdd_context_t *pHddCtx ) |
| 10457 | { |
| 10458 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 10459 | VOS_STATUS status; |
| 10460 | hdd_adapter_t *pAdapter; |
| 10461 | |
| 10462 | ENTER(); |
| 10463 | |
| 10464 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 10465 | |
| 10466 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 10467 | { |
| 10468 | pAdapter = pAdapterNode->pAdapter; |
Padma, Santhosh Kumar | 9dacb5c | 2014-12-17 19:22:56 +0530 | [diff] [blame] | 10469 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10470 | netif_tx_disable(pAdapter->dev); |
Hanumanth Reddy Pothula | d864f31 | 2017-01-18 16:16:08 +0530 | [diff] [blame] | 10471 | |
| 10472 | if (pHddCtx->cfg_ini->sap_internal_restart && |
| 10473 | pAdapter->device_mode == WLAN_HDD_SOFTAP) { |
| 10474 | hddLog(LOG1, FL("driver supports sap restart")); |
| 10475 | vos_flush_work(&pHddCtx->sap_start_work); |
| 10476 | hdd_sap_indicate_disconnect_for_sta(pAdapter); |
| 10477 | hdd_cleanup_actionframe(pHddCtx, pAdapter); |
Hanumanth Reddy Pothula | 15bc0fa | 2017-02-03 17:24:17 +0530 | [diff] [blame] | 10478 | hdd_softap_deinit_tx_rx(pAdapter, true); |
| 10479 | hdd_sap_destroy_timers(pAdapter); |
Hanumanth Reddy Pothula | d864f31 | 2017-01-18 16:16:08 +0530 | [diff] [blame] | 10480 | } else { |
| 10481 | netif_carrier_off(pAdapter->dev); |
| 10482 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10483 | |
Srinivas Girigowda | 66c05eb | 2013-07-14 13:06:01 -0700 | [diff] [blame] | 10484 | pAdapter->sessionCtx.station.hdd_ReassocScenario = VOS_FALSE; |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 10485 | pAdapter->sessionCtx.monitor.state = MON_MODE_STOP; |
Srinivas Girigowda | 66c05eb | 2013-07-14 13:06:01 -0700 | [diff] [blame] | 10486 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10487 | hdd_deinit_tx_rx(pAdapter); |
Agarwal Ashish | 6267caa | 2014-08-06 19:16:21 +0530 | [diff] [blame] | 10488 | |
Katya Nigam | 1fd2440 | 2015-02-16 14:52:19 +0530 | [diff] [blame] | 10489 | if(pAdapter->device_mode == WLAN_HDD_IBSS ) |
| 10490 | hdd_ibss_deinit_tx_rx(pAdapter); |
| 10491 | |
Nirav Shah | 7e3c813 | 2015-06-22 23:51:42 +0530 | [diff] [blame] | 10492 | status = hdd_sta_id_hash_detach(pAdapter); |
| 10493 | if (status != VOS_STATUS_SUCCESS) |
| 10494 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 10495 | FL("sta id hash detach failed for session id %d"), |
| 10496 | pAdapter->sessionId); |
| 10497 | |
Agarwal Ashish | 6267caa | 2014-08-06 19:16:21 +0530 | [diff] [blame] | 10498 | wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode); |
| 10499 | |
Madan Mohan Koyyalamudi | 8c6dec8 | 2013-09-26 15:56:13 +0530 | [diff] [blame] | 10500 | if (test_bit(WMM_INIT_DONE, &pAdapter->event_flags)) |
| 10501 | { |
| 10502 | hdd_wmm_adapter_close( pAdapter ); |
| 10503 | clear_bit(WMM_INIT_DONE, &pAdapter->event_flags); |
| 10504 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10505 | |
Siddharth Bhal | 2db319d | 2014-12-03 12:37:18 +0530 | [diff] [blame] | 10506 | if (test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags)) |
| 10507 | { |
| 10508 | clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags); |
| 10509 | } |
| 10510 | |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 10511 | #ifdef FEATURE_WLAN_BATCH_SCAN |
| 10512 | if (eHDD_BATCH_SCAN_STATE_STARTED == pAdapter->batchScanState) |
| 10513 | { |
| 10514 | hdd_deinit_batch_scan(pAdapter); |
| 10515 | } |
| 10516 | #endif |
| 10517 | |
Mahesh A Saptasagar | f5b8eff | 2015-01-31 01:07:07 +0530 | [diff] [blame] | 10518 | #ifdef FEATURE_WLAN_TDLS |
| 10519 | mutex_lock(&pHddCtx->tdls_lock); |
Pradeep Reddy POTTETI | 2d4d5c4 | 2015-03-03 14:34:19 +0530 | [diff] [blame] | 10520 | wlan_hdd_tdls_exit(pAdapter, TRUE); |
Mahesh A Saptasagar | f5b8eff | 2015-01-31 01:07:07 +0530 | [diff] [blame] | 10521 | mutex_unlock(&pHddCtx->tdls_lock); |
| 10522 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10523 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 10524 | pAdapterNode = pNext; |
| 10525 | } |
| 10526 | |
| 10527 | EXIT(); |
| 10528 | |
| 10529 | return VOS_STATUS_SUCCESS; |
| 10530 | } |
| 10531 | |
Abhishek Singh | bbe0b2a | 2016-12-05 11:57:36 +0530 | [diff] [blame] | 10532 | /** |
Abhishek Singh | 5a597e6 | 2016-12-05 15:16:30 +0530 | [diff] [blame] | 10533 | * hdd_get_bss_entry() - Get the bss entry matching the chan, bssid and ssid |
| 10534 | * @wiphy: wiphy |
| 10535 | * @channel: channel of the BSS to find |
| 10536 | * @bssid: bssid of the BSS to find |
| 10537 | * @ssid: ssid of the BSS to find |
| 10538 | * @ssid_len: ssid len of of the BSS to find |
| 10539 | * |
| 10540 | * The API is a wrapper to get bss from kernel matching the chan, |
| 10541 | * bssid and ssid |
| 10542 | * |
| 10543 | * Return: Void |
| 10544 | */ |
| 10545 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)) \ |
| 10546 | && !defined(WITH_BACKPORTS) && !defined(IEEE80211_PRIVACY) |
| 10547 | |
| 10548 | struct cfg80211_bss* hdd_get_bss_entry(struct wiphy *wiphy, |
| 10549 | struct ieee80211_channel *channel, |
| 10550 | const u8 *bssid, |
| 10551 | const u8 *ssid, size_t ssid_len) |
| 10552 | { |
| 10553 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 10554 | ssid, ssid_len, |
| 10555 | WLAN_CAPABILITY_ESS, |
| 10556 | WLAN_CAPABILITY_ESS); |
| 10557 | } |
| 10558 | #else |
| 10559 | struct cfg80211_bss* hdd_get_bss_entry(struct wiphy *wiphy, |
| 10560 | struct ieee80211_channel *channel, |
| 10561 | const u8 *bssid, |
| 10562 | const u8 *ssid, size_t ssid_len) |
| 10563 | { |
| 10564 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 10565 | ssid, ssid_len, |
| 10566 | IEEE80211_BSS_TYPE_ESS, |
| 10567 | IEEE80211_PRIVACY_ANY); |
| 10568 | } |
| 10569 | #endif |
| 10570 | |
Rajeev Kumar Sirasanagandla | 5b21a9c | 2018-01-08 17:05:11 +0530 | [diff] [blame] | 10571 | #if defined(CFG80211_CONNECT_BSS) || \ |
| 10572 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)) |
| 10573 | |
| 10574 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) || \ |
| 10575 | defined (CFG80211_CONNECT_TIMEOUT_REASON_CODE) |
| 10576 | /** |
| 10577 | * hdd_connect_bss() - helper function to send connection status to supplicant |
| 10578 | * @dev: network device |
| 10579 | * @bssid: bssid to which we want to associate |
| 10580 | * @bss: information about connected bss |
| 10581 | * @req_ie: Request Information Element |
| 10582 | * @req_ie_len: len of the req IE |
| 10583 | * @resp_ie: Response IE |
| 10584 | * @resp_ie_len: len of ht response IE |
| 10585 | * @status: status |
| 10586 | * @gfp: Kernel Flag |
| 10587 | * |
| 10588 | * This is a helper function to send connection status to supplicant |
| 10589 | * and gets invoked from wrapper API |
| 10590 | * |
| 10591 | * Return: Void |
| 10592 | */ |
| 10593 | static void hdd_connect_bss(struct net_device *dev, |
| 10594 | const u8 *bssid, |
| 10595 | struct cfg80211_bss *bss, |
| 10596 | const u8 *req_ie, |
| 10597 | size_t req_ie_len, |
| 10598 | const u8 *resp_ie, |
| 10599 | size_t resp_ie_len, |
| 10600 | u16 status, |
| 10601 | gfp_t gfp) |
| 10602 | { |
| 10603 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 10604 | resp_ie, resp_ie_len, status, gfp, NL80211_TIMEOUT_UNSPECIFIED); |
| 10605 | } |
| 10606 | #else |
| 10607 | /** |
| 10608 | * hdd_connect_bss() - helper function to send connection status to supplicant |
| 10609 | * @dev: network device |
| 10610 | * @bssid: bssid to which we want to associate |
| 10611 | * @bss: information about connected bss |
| 10612 | * @req_ie: Request Information Element |
| 10613 | * @req_ie_len: len of the req IE |
| 10614 | * @resp_ie: Response IE |
| 10615 | * @resp_ie_len: len of ht response IE |
| 10616 | * @status: status |
| 10617 | * @gfp: Kernel Flag |
| 10618 | * |
| 10619 | * This is a helper function to send connection status to supplicant |
| 10620 | * and gets invoked from wrapper API |
| 10621 | * |
| 10622 | * Return: Void |
| 10623 | */ |
| 10624 | static void hdd_connect_bss(struct net_device *dev, |
| 10625 | const u8 *bssid, |
| 10626 | struct cfg80211_bss *bss, |
| 10627 | const u8 *req_ie, |
| 10628 | size_t req_ie_len, |
| 10629 | const u8 *resp_ie, |
| 10630 | size_t resp_ie_len, |
| 10631 | u16 status, |
| 10632 | gfp_t gfp) |
| 10633 | { |
| 10634 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 10635 | resp_ie, resp_ie_len, status, gfp); |
| 10636 | } |
| 10637 | #endif |
| 10638 | |
Abhishek Singh | 5a597e6 | 2016-12-05 15:16:30 +0530 | [diff] [blame] | 10639 | /** |
Abhishek Singh | bbe0b2a | 2016-12-05 11:57:36 +0530 | [diff] [blame] | 10640 | * hdd_connect_result() - API to send connection status to supplicant |
| 10641 | * @dev: network device |
| 10642 | * @bssid: bssid to which we want to associate |
| 10643 | * @roam_info: information about connected bss |
| 10644 | * @req_ie: Request Information Element |
| 10645 | * @req_ie_len: len of the req IE |
| 10646 | * @resp_ie: Response IE |
| 10647 | * @resp_ie_len: len of ht response IE |
| 10648 | * @status: status |
| 10649 | * @gfp: Kernel Flag |
| 10650 | * |
| 10651 | * The API is a wrapper to send connection status to supplicant |
| 10652 | * |
| 10653 | * Return: Void |
| 10654 | */ |
Abhishek Singh | bbe0b2a | 2016-12-05 11:57:36 +0530 | [diff] [blame] | 10655 | void hdd_connect_result(struct net_device *dev, |
| 10656 | const u8 *bssid, |
| 10657 | tCsrRoamInfo *roam_info, |
| 10658 | const u8 *req_ie, |
| 10659 | size_t req_ie_len, |
| 10660 | const u8 *resp_ie, |
| 10661 | size_t resp_ie_len, |
| 10662 | u16 status, |
| 10663 | gfp_t gfp) |
| 10664 | { |
| 10665 | hdd_adapter_t *padapter = (hdd_adapter_t *) netdev_priv(dev); |
| 10666 | struct cfg80211_bss *bss = NULL; |
| 10667 | |
| 10668 | if (WLAN_STATUS_SUCCESS == status) { |
| 10669 | struct ieee80211_channel *chan; |
| 10670 | int freq; |
| 10671 | int chan_no = roam_info->pBssDesc->channelId;; |
| 10672 | |
| 10673 | if (chan_no <= 14) |
| 10674 | freq = ieee80211_channel_to_frequency(chan_no, |
Rajeev Kumar Sirasanagandla | 5b21a9c | 2018-01-08 17:05:11 +0530 | [diff] [blame] | 10675 | HDD_NL80211_BAND_2GHZ); |
Abhishek Singh | bbe0b2a | 2016-12-05 11:57:36 +0530 | [diff] [blame] | 10676 | else |
| 10677 | freq = ieee80211_channel_to_frequency(chan_no, |
Rajeev Kumar Sirasanagandla | 5b21a9c | 2018-01-08 17:05:11 +0530 | [diff] [blame] | 10678 | HDD_NL80211_BAND_5GHZ); |
Abhishek Singh | bbe0b2a | 2016-12-05 11:57:36 +0530 | [diff] [blame] | 10679 | |
| 10680 | chan = ieee80211_get_channel(padapter->wdev.wiphy, freq); |
Abhishek Singh | 5a597e6 | 2016-12-05 15:16:30 +0530 | [diff] [blame] | 10681 | bss = hdd_get_bss_entry(padapter->wdev.wiphy, |
| 10682 | chan, bssid, |
| 10683 | roam_info->u.pConnectedProfile->SSID.ssId, |
| 10684 | roam_info->u.pConnectedProfile->SSID.length); |
Abhishek Singh | bbe0b2a | 2016-12-05 11:57:36 +0530 | [diff] [blame] | 10685 | } |
| 10686 | |
Rajeev Kumar Sirasanagandla | 5b21a9c | 2018-01-08 17:05:11 +0530 | [diff] [blame] | 10687 | hdd_connect_bss(dev, bssid, bss, req_ie, req_ie_len, resp_ie, resp_ie_len, |
| 10688 | status, gfp); |
Abhishek Singh | bbe0b2a | 2016-12-05 11:57:36 +0530 | [diff] [blame] | 10689 | } |
| 10690 | #else |
Rajeev Kumar Sirasanagandla | 5b21a9c | 2018-01-08 17:05:11 +0530 | [diff] [blame] | 10691 | /** |
| 10692 | * hdd_connect_result() - API to send connection status to supplicant |
| 10693 | * @dev: network device |
| 10694 | * @bssid: bssid to which we want to associate |
| 10695 | * @roam_info: information about connected bss |
| 10696 | * @req_ie: Request Information Element |
| 10697 | * @req_ie_len: len of the req IE |
| 10698 | * @resp_ie: Response IE |
| 10699 | * @resp_ie_len: len of ht response IE |
| 10700 | * @status: status |
| 10701 | * @gfp: Kernel Flag |
| 10702 | * |
| 10703 | * The API is a wrapper to send connection status to supplicant |
| 10704 | * |
| 10705 | * Return: Void |
| 10706 | */ |
Abhishek Singh | bbe0b2a | 2016-12-05 11:57:36 +0530 | [diff] [blame] | 10707 | void hdd_connect_result(struct net_device *dev, |
| 10708 | const u8 *bssid, |
| 10709 | tCsrRoamInfo *roam_info, |
| 10710 | const u8 *req_ie, |
| 10711 | size_t req_ie_len, |
| 10712 | const u8 * resp_ie, |
| 10713 | size_t resp_ie_len, |
| 10714 | u16 status, |
| 10715 | gfp_t gfp) |
| 10716 | { |
| 10717 | cfg80211_connect_result(dev, bssid, req_ie, req_ie_len, |
| 10718 | resp_ie, resp_ie_len, status, gfp); |
| 10719 | } |
| 10720 | #endif |
| 10721 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10722 | VOS_STATUS hdd_start_all_adapters( hdd_context_t *pHddCtx ) |
| 10723 | { |
| 10724 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 10725 | VOS_STATUS status; |
| 10726 | hdd_adapter_t *pAdapter; |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 10727 | eConnectionState connState; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10728 | |
| 10729 | ENTER(); |
| 10730 | |
| 10731 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 10732 | |
| 10733 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 10734 | { |
| 10735 | pAdapter = pAdapterNode->pAdapter; |
| 10736 | |
Kumar Anand | 82c009f | 2014-05-29 00:29:42 -0700 | [diff] [blame] | 10737 | hdd_wmm_init( pAdapter ); |
| 10738 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10739 | switch(pAdapter->device_mode) |
| 10740 | { |
| 10741 | case WLAN_HDD_INFRA_STATION: |
| 10742 | case WLAN_HDD_P2P_CLIENT: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10743 | case WLAN_HDD_P2P_DEVICE: |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 10744 | |
| 10745 | connState = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState; |
| 10746 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10747 | hdd_init_station_mode(pAdapter); |
| 10748 | /* Open the gates for HDD to receive Wext commands */ |
| 10749 | pAdapter->isLinkUpSvcNeeded = FALSE; |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 10750 | pHddCtx->scan_info.mScanPending = FALSE; |
| 10751 | pHddCtx->scan_info.waitScanResult = FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10752 | |
| 10753 | //Trigger the initial scan |
Mukul Sharma | e74e42c | 2015-08-06 23:55:49 +0530 | [diff] [blame] | 10754 | if (!pHddCtx->isLogpInProgress) |
| 10755 | hdd_wlan_initial_scan(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10756 | |
| 10757 | //Indicate disconnect event to supplicant if associated previously |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 10758 | if (eConnectionState_Associated == connState || |
| 10759 | eConnectionState_IbssConnected == connState ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10760 | { |
| 10761 | union iwreq_data wrqu; |
| 10762 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 10763 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 10764 | memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN); |
| 10765 | wireless_send_event(pAdapter->dev, SIOCGIWAP, &wrqu, NULL); |
Srinivas Girigowda | 66c05eb | 2013-07-14 13:06:01 -0700 | [diff] [blame] | 10766 | pAdapter->sessionCtx.station.hdd_ReassocScenario = VOS_FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10767 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10768 | /* indicate disconnected event to nl80211 */ |
Mahesh A Saptasagar | 9ff4bcc | 2016-06-01 17:17:50 +0530 | [diff] [blame] | 10769 | wlan_hdd_cfg80211_indicate_disconnect(pAdapter->dev, false, |
Mahesh A Saptasagar | b5a1514 | 2016-05-25 11:27:43 +0530 | [diff] [blame] | 10770 | WLAN_REASON_UNSPECIFIED); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10771 | } |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 10772 | else if (eConnectionState_Connecting == connState) |
| 10773 | { |
| 10774 | /* |
| 10775 | * Indicate connect failure to supplicant if we were in the |
| 10776 | * process of connecting |
| 10777 | */ |
Abhishek Singh | bbe0b2a | 2016-12-05 11:57:36 +0530 | [diff] [blame] | 10778 | hdd_connect_result(pAdapter->dev, NULL, NULL, |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 10779 | NULL, 0, NULL, 0, |
| 10780 | WLAN_STATUS_ASSOC_DENIED_UNSPEC, |
| 10781 | GFP_KERNEL); |
| 10782 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10783 | break; |
| 10784 | |
| 10785 | case WLAN_HDD_SOFTAP: |
Hanumanth Reddy Pothula | d864f31 | 2017-01-18 16:16:08 +0530 | [diff] [blame] | 10786 | if (pHddCtx->cfg_ini->sap_internal_restart) { |
Hanumanth Reddy Pothula | 15bc0fa | 2017-02-03 17:24:17 +0530 | [diff] [blame] | 10787 | hdd_init_ap_mode(pAdapter, true); |
Hanumanth Reddy Pothula | d864f31 | 2017-01-18 16:16:08 +0530 | [diff] [blame] | 10788 | status = hdd_sta_id_hash_attach(pAdapter); |
| 10789 | if (VOS_STATUS_SUCCESS != status) |
| 10790 | { |
| 10791 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 10792 | FL("failed to attach hash for")); |
| 10793 | } |
| 10794 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10795 | break; |
| 10796 | |
| 10797 | case WLAN_HDD_P2P_GO: |
Sameer Thalappil | edf0d79 | 2013-08-09 14:31:03 -0700 | [diff] [blame] | 10798 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s [SSR] send stop ap to supplicant", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10799 | __func__); |
Sameer Thalappil | edf0d79 | 2013-08-09 14:31:03 -0700 | [diff] [blame] | 10800 | cfg80211_ap_stopped(pAdapter->dev, GFP_KERNEL); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10801 | break; |
| 10802 | |
| 10803 | case WLAN_HDD_MONITOR: |
| 10804 | /* monitor interface start */ |
| 10805 | break; |
| 10806 | default: |
| 10807 | break; |
| 10808 | } |
| 10809 | |
| 10810 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 10811 | pAdapterNode = pNext; |
| 10812 | } |
| 10813 | |
| 10814 | EXIT(); |
| 10815 | |
| 10816 | return VOS_STATUS_SUCCESS; |
| 10817 | } |
| 10818 | |
| 10819 | VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx ) |
| 10820 | { |
| 10821 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 10822 | hdd_adapter_t *pAdapter; |
| 10823 | VOS_STATUS status; |
| 10824 | v_U32_t roamId; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 10825 | long ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10826 | |
| 10827 | ENTER(); |
| 10828 | |
| 10829 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 10830 | |
| 10831 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 10832 | { |
| 10833 | pAdapter = pAdapterNode->pAdapter; |
| 10834 | |
| 10835 | if( (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
| 10836 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ) |
| 10837 | { |
| 10838 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 10839 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 10840 | |
Abhishek Singh | f4669da | 2014-05-26 15:07:49 +0530 | [diff] [blame] | 10841 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 10842 | "%s: Set HDD connState to eConnectionState_NotConnected", |
| 10843 | __func__); |
Ganesh Kondabattini | 0433841 | 2015-09-14 15:39:09 +0530 | [diff] [blame] | 10844 | spin_lock_bh(&pAdapter->lock_for_active_session); |
| 10845 | if (eConnectionState_Associated == pHddStaCtx->conn_info.connState) |
| 10846 | { |
| 10847 | wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode); |
| 10848 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10849 | pHddStaCtx->conn_info.connState = eConnectionState_NotConnected; |
Ganesh Kondabattini | 0433841 | 2015-09-14 15:39:09 +0530 | [diff] [blame] | 10850 | spin_unlock_bh(&pAdapter->lock_for_active_session); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10851 | init_completion(&pAdapter->disconnect_comp_var); |
| 10852 | sme_RoamDisconnect(pHddCtx->hHal, pAdapter->sessionId, |
| 10853 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
| 10854 | |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 10855 | ret = wait_for_completion_interruptible_timeout( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10856 | &pAdapter->disconnect_comp_var, |
| 10857 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 10858 | if (0 >= ret) |
| 10859 | hddLog(LOGE, "%s: failure waiting for disconnect_comp_var %ld", |
| 10860 | __func__, ret); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10861 | |
| 10862 | pWextState->roamProfile.csrPersona = pAdapter->device_mode; |
| 10863 | pHddCtx->isAmpAllowed = VOS_FALSE; |
| 10864 | sme_RoamConnect(pHddCtx->hHal, |
| 10865 | pAdapter->sessionId, &(pWextState->roamProfile), |
| 10866 | &roamId); |
| 10867 | } |
| 10868 | |
| 10869 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 10870 | pAdapterNode = pNext; |
| 10871 | } |
| 10872 | |
| 10873 | EXIT(); |
| 10874 | |
| 10875 | return VOS_STATUS_SUCCESS; |
| 10876 | } |
| 10877 | |
Sudhir Sattayappa Kohalli | 90e4c75 | 2013-03-21 14:25:04 -0700 | [diff] [blame] | 10878 | void hdd_dump_concurrency_info(hdd_context_t *pHddCtx) |
| 10879 | { |
| 10880 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 10881 | VOS_STATUS status; |
| 10882 | hdd_adapter_t *pAdapter; |
| 10883 | hdd_station_ctx_t *pHddStaCtx; |
| 10884 | hdd_ap_ctx_t *pHddApCtx; |
| 10885 | hdd_hostapd_state_t * pHostapdState; |
| 10886 | tCsrBssid staBssid = { 0 }, p2pBssid = { 0 }, apBssid = { 0 }; |
| 10887 | v_U8_t staChannel = 0, p2pChannel = 0, apChannel = 0; |
| 10888 | const char *p2pMode = "DEV"; |
| 10889 | const char *ccMode = "Standalone"; |
Sudhir Sattayappa Kohalli | 90e4c75 | 2013-03-21 14:25:04 -0700 | [diff] [blame] | 10890 | |
| 10891 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 10892 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 10893 | { |
| 10894 | pAdapter = pAdapterNode->pAdapter; |
| 10895 | switch (pAdapter->device_mode) { |
| 10896 | case WLAN_HDD_INFRA_STATION: |
| 10897 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 10898 | if (eConnectionState_Associated == pHddStaCtx->conn_info.connState) { |
| 10899 | staChannel = pHddStaCtx->conn_info.operationChannel; |
| 10900 | memcpy(staBssid, pHddStaCtx->conn_info.bssId, sizeof(staBssid)); |
| 10901 | } |
| 10902 | break; |
| 10903 | case WLAN_HDD_P2P_CLIENT: |
| 10904 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 10905 | if (eConnectionState_Associated == pHddStaCtx->conn_info.connState) { |
| 10906 | p2pChannel = pHddStaCtx->conn_info.operationChannel; |
| 10907 | memcpy(p2pBssid, pHddStaCtx->conn_info.bssId, sizeof(p2pBssid)); |
| 10908 | p2pMode = "CLI"; |
| 10909 | } |
| 10910 | break; |
| 10911 | case WLAN_HDD_P2P_GO: |
| 10912 | pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
| 10913 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 10914 | if (pHostapdState->bssState == BSS_START && pHostapdState->vosStatus==VOS_STATUS_SUCCESS) { |
| 10915 | p2pChannel = pHddApCtx->operatingChannel; |
| 10916 | memcpy(p2pBssid, pAdapter->macAddressCurrent.bytes, sizeof(p2pBssid)); |
| 10917 | } |
| 10918 | p2pMode = "GO"; |
| 10919 | break; |
| 10920 | case WLAN_HDD_SOFTAP: |
| 10921 | pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
| 10922 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 10923 | if (pHostapdState->bssState == BSS_START && pHostapdState->vosStatus==VOS_STATUS_SUCCESS) { |
| 10924 | apChannel = pHddApCtx->operatingChannel; |
| 10925 | memcpy(apBssid, pAdapter->macAddressCurrent.bytes, sizeof(apBssid)); |
| 10926 | } |
| 10927 | break; |
| 10928 | default: |
| 10929 | break; |
| 10930 | } |
| 10931 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 10932 | pAdapterNode = pNext; |
| 10933 | } |
| 10934 | if (staChannel > 0 && (apChannel > 0 || p2pChannel > 0)) { |
| 10935 | ccMode = (p2pChannel==staChannel||apChannel==staChannel) ? "SCC" : "MCC"; |
| 10936 | } |
Yeshwanth Sriram Guntuka | 0004c0b | 2017-12-06 14:43:49 +0530 | [diff] [blame] | 10937 | hddLog(VOS_TRACE_LEVEL_ERROR, "wlan(%d) " MAC_ADDRESS_STR " %s", |
| 10938 | staChannel, MAC_ADDR_ARRAY(staBssid), ccMode); |
Sudhir Sattayappa Kohalli | 90e4c75 | 2013-03-21 14:25:04 -0700 | [diff] [blame] | 10939 | if (p2pChannel > 0) { |
Sushant Kaushik | dc3184b | 2015-10-09 12:00:21 +0530 | [diff] [blame] | 10940 | hddLog(VOS_TRACE_LEVEL_ERROR, "p2p-%s(%d) " MAC_ADDRESS_STR, |
Sudhir Sattayappa Kohalli | 90e4c75 | 2013-03-21 14:25:04 -0700 | [diff] [blame] | 10941 | p2pMode, p2pChannel, MAC_ADDR_ARRAY(p2pBssid)); |
| 10942 | } |
| 10943 | if (apChannel > 0) { |
Sushant Kaushik | dc3184b | 2015-10-09 12:00:21 +0530 | [diff] [blame] | 10944 | hddLog(VOS_TRACE_LEVEL_ERROR, "AP(%d) " MAC_ADDRESS_STR, |
Sudhir Sattayappa Kohalli | 90e4c75 | 2013-03-21 14:25:04 -0700 | [diff] [blame] | 10945 | apChannel, MAC_ADDR_ARRAY(apBssid)); |
| 10946 | } |
| 10947 | |
| 10948 | if (p2pChannel > 0 && apChannel > 0) { |
| 10949 | hddLog(VOS_TRACE_LEVEL_ERROR, "Error concurrent SAP %d and P2P %d which is not support", apChannel, p2pChannel); |
| 10950 | } |
| 10951 | } |
| 10952 | |
Madan Mohan Koyyalamudi | b5da533 | 2012-10-15 17:23:21 -0700 | [diff] [blame] | 10953 | bool hdd_is_ssr_required( void) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10954 | { |
Madan Mohan Koyyalamudi | b5da533 | 2012-10-15 17:23:21 -0700 | [diff] [blame] | 10955 | return (isSsrRequired == HDD_SSR_REQUIRED); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10956 | } |
| 10957 | |
Madan Mohan Koyyalamudi | b5da533 | 2012-10-15 17:23:21 -0700 | [diff] [blame] | 10958 | /* Once SSR is disabled then it cannot be set. */ |
| 10959 | void hdd_set_ssr_required( e_hdd_ssr_required value) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10960 | { |
Madan Mohan Koyyalamudi | b5da533 | 2012-10-15 17:23:21 -0700 | [diff] [blame] | 10961 | if (HDD_SSR_DISABLED == isSsrRequired) |
| 10962 | return; |
| 10963 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10964 | isSsrRequired = value; |
| 10965 | } |
| 10966 | |
Hema Aparna Medicharla | 6b4d4f3 | 2015-06-23 04:09:12 +0530 | [diff] [blame] | 10967 | void hdd_set_pre_close( hdd_context_t *pHddCtx) |
| 10968 | { |
| 10969 | sme_PreClose(pHddCtx->hHal); |
| 10970 | } |
| 10971 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10972 | VOS_STATUS hdd_get_front_adapter( hdd_context_t *pHddCtx, |
| 10973 | hdd_adapter_list_node_t** ppAdapterNode) |
| 10974 | { |
| 10975 | VOS_STATUS status; |
Mukul Sharma | ae1266d | 2015-06-26 15:29:53 +0530 | [diff] [blame] | 10976 | spin_lock_bh(&pHddCtx->hddAdapters.lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10977 | status = hdd_list_peek_front ( &pHddCtx->hddAdapters, |
| 10978 | (hdd_list_node_t**) ppAdapterNode ); |
Mukul Sharma | ae1266d | 2015-06-26 15:29:53 +0530 | [diff] [blame] | 10979 | spin_unlock_bh(&pHddCtx->hddAdapters.lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10980 | return status; |
| 10981 | } |
| 10982 | |
| 10983 | VOS_STATUS hdd_get_next_adapter( hdd_context_t *pHddCtx, |
| 10984 | hdd_adapter_list_node_t* pAdapterNode, |
| 10985 | hdd_adapter_list_node_t** pNextAdapterNode) |
| 10986 | { |
| 10987 | VOS_STATUS status; |
Mukul Sharma | ae1266d | 2015-06-26 15:29:53 +0530 | [diff] [blame] | 10988 | spin_lock_bh(&pHddCtx->hddAdapters.lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10989 | status = hdd_list_peek_next ( &pHddCtx->hddAdapters, |
| 10990 | (hdd_list_node_t*) pAdapterNode, |
| 10991 | (hdd_list_node_t**)pNextAdapterNode ); |
| 10992 | |
Mukul Sharma | ae1266d | 2015-06-26 15:29:53 +0530 | [diff] [blame] | 10993 | spin_unlock_bh(&pHddCtx->hddAdapters.lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10994 | return status; |
| 10995 | } |
| 10996 | |
| 10997 | VOS_STATUS hdd_remove_adapter( hdd_context_t *pHddCtx, |
| 10998 | hdd_adapter_list_node_t* pAdapterNode) |
| 10999 | { |
| 11000 | VOS_STATUS status; |
Mukul Sharma | ae1266d | 2015-06-26 15:29:53 +0530 | [diff] [blame] | 11001 | spin_lock_bh(&pHddCtx->hddAdapters.lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11002 | status = hdd_list_remove_node ( &pHddCtx->hddAdapters, |
| 11003 | &pAdapterNode->node ); |
Mukul Sharma | ae1266d | 2015-06-26 15:29:53 +0530 | [diff] [blame] | 11004 | spin_unlock_bh(&pHddCtx->hddAdapters.lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11005 | return status; |
| 11006 | } |
| 11007 | |
| 11008 | VOS_STATUS hdd_remove_front_adapter( hdd_context_t *pHddCtx, |
| 11009 | hdd_adapter_list_node_t** ppAdapterNode) |
| 11010 | { |
| 11011 | VOS_STATUS status; |
Mukul Sharma | ae1266d | 2015-06-26 15:29:53 +0530 | [diff] [blame] | 11012 | spin_lock_bh(&pHddCtx->hddAdapters.lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11013 | status = hdd_list_remove_front( &pHddCtx->hddAdapters, |
| 11014 | (hdd_list_node_t**) ppAdapterNode ); |
Mukul Sharma | ae1266d | 2015-06-26 15:29:53 +0530 | [diff] [blame] | 11015 | spin_unlock_bh(&pHddCtx->hddAdapters.lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11016 | return status; |
| 11017 | } |
| 11018 | |
| 11019 | VOS_STATUS hdd_add_adapter_back( hdd_context_t *pHddCtx, |
| 11020 | hdd_adapter_list_node_t* pAdapterNode) |
| 11021 | { |
| 11022 | VOS_STATUS status; |
Mukul Sharma | ae1266d | 2015-06-26 15:29:53 +0530 | [diff] [blame] | 11023 | spin_lock_bh(&pHddCtx->hddAdapters.lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11024 | status = hdd_list_insert_back ( &pHddCtx->hddAdapters, |
| 11025 | (hdd_list_node_t*) pAdapterNode ); |
Mukul Sharma | ae1266d | 2015-06-26 15:29:53 +0530 | [diff] [blame] | 11026 | spin_unlock_bh(&pHddCtx->hddAdapters.lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11027 | return status; |
| 11028 | } |
| 11029 | |
| 11030 | VOS_STATUS hdd_add_adapter_front( hdd_context_t *pHddCtx, |
| 11031 | hdd_adapter_list_node_t* pAdapterNode) |
| 11032 | { |
| 11033 | VOS_STATUS status; |
Mukul Sharma | ae1266d | 2015-06-26 15:29:53 +0530 | [diff] [blame] | 11034 | spin_lock_bh(&pHddCtx->hddAdapters.lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11035 | status = hdd_list_insert_front ( &pHddCtx->hddAdapters, |
| 11036 | (hdd_list_node_t*) pAdapterNode ); |
Mukul Sharma | ae1266d | 2015-06-26 15:29:53 +0530 | [diff] [blame] | 11037 | spin_unlock_bh(&pHddCtx->hddAdapters.lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11038 | return status; |
| 11039 | } |
| 11040 | |
| 11041 | hdd_adapter_t * hdd_get_adapter_by_macaddr( hdd_context_t *pHddCtx, |
| 11042 | tSirMacAddr macAddr ) |
| 11043 | { |
| 11044 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 11045 | hdd_adapter_t *pAdapter; |
| 11046 | VOS_STATUS status; |
| 11047 | |
| 11048 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 11049 | |
| 11050 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 11051 | { |
| 11052 | pAdapter = pAdapterNode->pAdapter; |
| 11053 | |
| 11054 | if( pAdapter && vos_mem_compare( pAdapter->macAddressCurrent.bytes, |
| 11055 | macAddr, sizeof(tSirMacAddr) ) ) |
| 11056 | { |
| 11057 | return pAdapter; |
| 11058 | } |
| 11059 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 11060 | pAdapterNode = pNext; |
| 11061 | } |
| 11062 | |
| 11063 | return NULL; |
| 11064 | |
| 11065 | } |
| 11066 | |
| 11067 | hdd_adapter_t * hdd_get_adapter_by_name( hdd_context_t *pHddCtx, tANI_U8 *name ) |
| 11068 | { |
| 11069 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 11070 | hdd_adapter_t *pAdapter; |
| 11071 | VOS_STATUS status; |
| 11072 | |
| 11073 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 11074 | |
| 11075 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 11076 | { |
| 11077 | pAdapter = pAdapterNode->pAdapter; |
| 11078 | |
| 11079 | if( pAdapter && !strncmp( pAdapter->dev->name, (const char *)name, |
| 11080 | IFNAMSIZ ) ) |
| 11081 | { |
| 11082 | return pAdapter; |
| 11083 | } |
| 11084 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 11085 | pAdapterNode = pNext; |
| 11086 | } |
| 11087 | |
| 11088 | return NULL; |
| 11089 | |
| 11090 | } |
| 11091 | |
Ganesh Kondabattini | cbfdc39 | 2015-09-11 19:12:59 +0530 | [diff] [blame] | 11092 | hdd_adapter_t *hdd_get_adapter_by_sme_session_id( hdd_context_t *pHddCtx, |
| 11093 | tANI_U32 sme_session_id ) |
| 11094 | { |
| 11095 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 11096 | hdd_adapter_t *pAdapter; |
| 11097 | VOS_STATUS vos_status; |
| 11098 | |
| 11099 | |
| 11100 | vos_status = hdd_get_front_adapter( pHddCtx, &pAdapterNode); |
| 11101 | |
| 11102 | while ((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == vos_status)) |
| 11103 | { |
| 11104 | pAdapter = pAdapterNode->pAdapter; |
| 11105 | |
| 11106 | if (pAdapter->sessionId == sme_session_id) |
| 11107 | return pAdapter; |
| 11108 | |
| 11109 | vos_status = hdd_get_next_adapter(pHddCtx, pAdapterNode, &pNext); |
| 11110 | pAdapterNode = pNext; |
| 11111 | } |
| 11112 | |
| 11113 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 11114 | "%s: sme_session_id %d does not exist with host", |
| 11115 | __func__, sme_session_id); |
| 11116 | |
| 11117 | return NULL; |
| 11118 | } |
| 11119 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11120 | hdd_adapter_t * hdd_get_adapter( hdd_context_t *pHddCtx, device_mode_t mode ) |
| 11121 | { |
| 11122 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 11123 | hdd_adapter_t *pAdapter; |
| 11124 | VOS_STATUS status; |
| 11125 | |
| 11126 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 11127 | |
| 11128 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 11129 | { |
| 11130 | pAdapter = pAdapterNode->pAdapter; |
| 11131 | |
| 11132 | if( pAdapter && (mode == pAdapter->device_mode) ) |
| 11133 | { |
| 11134 | return pAdapter; |
| 11135 | } |
| 11136 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 11137 | pAdapterNode = pNext; |
| 11138 | } |
| 11139 | |
| 11140 | return NULL; |
| 11141 | |
| 11142 | } |
| 11143 | |
| 11144 | //Remove this function later |
| 11145 | hdd_adapter_t * hdd_get_mon_adapter( hdd_context_t *pHddCtx ) |
| 11146 | { |
| 11147 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 11148 | hdd_adapter_t *pAdapter; |
| 11149 | VOS_STATUS status; |
| 11150 | |
| 11151 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 11152 | |
| 11153 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 11154 | { |
| 11155 | pAdapter = pAdapterNode->pAdapter; |
| 11156 | |
| 11157 | if( pAdapter && WLAN_HDD_MONITOR == pAdapter->device_mode ) |
| 11158 | { |
| 11159 | return pAdapter; |
| 11160 | } |
| 11161 | |
| 11162 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 11163 | pAdapterNode = pNext; |
| 11164 | } |
| 11165 | |
| 11166 | return NULL; |
| 11167 | |
| 11168 | } |
| 11169 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11170 | /**--------------------------------------------------------------------------- |
| 11171 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 11172 | \brief hdd_get_operating_channel() - |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11173 | |
| 11174 | This API returns the operating channel of the requested device mode |
| 11175 | |
| 11176 | \param - pHddCtx - Pointer to the HDD context. |
| 11177 | - mode - Device mode for which operating channel is required |
| 11178 | suported modes - WLAN_HDD_INFRA_STATION, WLAN_HDD_P2P_CLIENT |
| 11179 | WLAN_HDD_SOFTAP, WLAN_HDD_P2P_GO. |
| 11180 | \return - channel number. "0" id the requested device is not found OR it is not connected. |
| 11181 | --------------------------------------------------------------------------*/ |
| 11182 | v_U8_t hdd_get_operating_channel( hdd_context_t *pHddCtx, device_mode_t mode ) |
| 11183 | { |
| 11184 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 11185 | VOS_STATUS status; |
| 11186 | hdd_adapter_t *pAdapter; |
| 11187 | v_U8_t operatingChannel = 0; |
| 11188 | |
| 11189 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 11190 | |
| 11191 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 11192 | { |
| 11193 | pAdapter = pAdapterNode->pAdapter; |
| 11194 | |
| 11195 | if( mode == pAdapter->device_mode ) |
| 11196 | { |
| 11197 | switch(pAdapter->device_mode) |
| 11198 | { |
| 11199 | case WLAN_HDD_INFRA_STATION: |
| 11200 | case WLAN_HDD_P2P_CLIENT: |
| 11201 | if( hdd_connIsConnected( WLAN_HDD_GET_STATION_CTX_PTR( pAdapter )) ) |
| 11202 | operatingChannel = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.operationChannel; |
| 11203 | break; |
| 11204 | case WLAN_HDD_SOFTAP: |
| 11205 | case WLAN_HDD_P2P_GO: |
| 11206 | /*softap connection info */ |
| 11207 | if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags)) |
| 11208 | operatingChannel = (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->operatingChannel; |
| 11209 | break; |
| 11210 | default: |
| 11211 | break; |
| 11212 | } |
| 11213 | |
| 11214 | break; //Found the device of interest. break the loop |
| 11215 | } |
| 11216 | |
| 11217 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 11218 | pAdapterNode = pNext; |
| 11219 | } |
| 11220 | return operatingChannel; |
| 11221 | } |
| 11222 | |
| 11223 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 11224 | /**--------------------------------------------------------------------------- |
| 11225 | |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 11226 | \brief __hdd_set_multicast_list() - |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11227 | |
| 11228 | This used to set the multicast address list. |
| 11229 | |
| 11230 | \param - dev - Pointer to the WLAN device. |
| 11231 | - skb - Pointer to OS packet (sk_buff). |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 11232 | \return - success/fail |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11233 | |
| 11234 | --------------------------------------------------------------------------*/ |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 11235 | static void __hdd_set_multicast_list(struct net_device *dev) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11236 | { |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 11237 | hdd_adapter_t *pAdapter; |
| 11238 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11239 | int mc_count; |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 11240 | int i = 0, ret = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11241 | struct netdev_hw_addr *ha; |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 11242 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 11243 | ENTER(); |
| 11244 | |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 11245 | pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 11246 | if (NULL == pAdapter) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11247 | { |
| 11248 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 11249 | "%s: Adapter context is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11250 | return; |
| 11251 | } |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 11252 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 11253 | ret = wlan_hdd_validate_context(pHddCtx); |
| 11254 | if (0 != ret) |
| 11255 | { |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 11256 | return; |
| 11257 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11258 | if (dev->flags & IFF_ALLMULTI) |
| 11259 | { |
| 11260 | hddLog(VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 11261 | "%s: allow all multicast frames", __func__); |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 11262 | pAdapter->mc_addr_list.mc_cnt = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11263 | } |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 11264 | else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11265 | { |
| 11266 | mc_count = netdev_mc_count(dev); |
| 11267 | hddLog(VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 11268 | "%s: mc_count = %u", __func__, mc_count); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11269 | if (mc_count > WLAN_HDD_MAX_MC_ADDR_LIST) |
| 11270 | { |
| 11271 | hddLog(VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 11272 | "%s: No free filter available; allow all multicast frames", __func__); |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 11273 | pAdapter->mc_addr_list.mc_cnt = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11274 | return; |
| 11275 | } |
| 11276 | |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 11277 | pAdapter->mc_addr_list.mc_cnt = mc_count; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11278 | |
| 11279 | netdev_for_each_mc_addr(ha, dev) { |
| 11280 | if (i == mc_count) |
| 11281 | break; |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 11282 | memset(&(pAdapter->mc_addr_list.addr[i][0]), 0, ETH_ALEN); |
| 11283 | memcpy(&(pAdapter->mc_addr_list.addr[i][0]), ha->addr, ETH_ALEN); |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 11284 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: mlist[%d] = "MAC_ADDRESS_STR, |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 11285 | __func__, i, |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 11286 | MAC_ADDR_ARRAY(pAdapter->mc_addr_list.addr[i])); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11287 | i++; |
| 11288 | } |
| 11289 | } |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 11290 | |
Ganesh Kondabattini | fb37e65 | 2015-10-09 15:46:47 +0530 | [diff] [blame] | 11291 | if (pHddCtx->hdd_wlan_suspended) |
| 11292 | { |
| 11293 | /* |
| 11294 | * Configure the Mcast address list to FW |
| 11295 | * If wlan is already in suspend mode |
| 11296 | */ |
| 11297 | wlan_hdd_set_mc_addr_list(pAdapter, TRUE); |
| 11298 | } |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 11299 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11300 | return; |
| 11301 | } |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 11302 | |
| 11303 | static void hdd_set_multicast_list(struct net_device *dev) |
| 11304 | { |
| 11305 | vos_ssr_protect(__func__); |
| 11306 | __hdd_set_multicast_list(dev); |
| 11307 | vos_ssr_unprotect(__func__); |
| 11308 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11309 | #endif |
| 11310 | |
| 11311 | /**--------------------------------------------------------------------------- |
| 11312 | |
| 11313 | \brief hdd_select_queue() - |
| 11314 | |
| 11315 | This function is registered with the Linux OS for network |
| 11316 | core to decide which queue to use first. |
| 11317 | |
| 11318 | \param - dev - Pointer to the WLAN device. |
| 11319 | - skb - Pointer to OS packet (sk_buff). |
| 11320 | \return - ac, Queue Index/access category corresponding to UP in IP header |
| 11321 | |
| 11322 | --------------------------------------------------------------------------*/ |
| 11323 | v_U16_t hdd_select_queue(struct net_device *dev, |
Anand N Sunkad | e9adb1b | 2015-07-29 09:56:45 +0530 | [diff] [blame] | 11324 | struct sk_buff *skb |
| 11325 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0)) |
| 11326 | , void *accel_priv |
| 11327 | #endif |
| 11328 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) |
| 11329 | , select_queue_fallback_t fallback |
| 11330 | #endif |
| 11331 | ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11332 | { |
| 11333 | return hdd_wmm_select_queue(dev, skb); |
| 11334 | } |
| 11335 | |
| 11336 | |
| 11337 | /**--------------------------------------------------------------------------- |
| 11338 | |
| 11339 | \brief hdd_wlan_initial_scan() - |
| 11340 | |
| 11341 | This function triggers the initial scan |
| 11342 | |
| 11343 | \param - pAdapter - Pointer to the HDD adapter. |
| 11344 | |
| 11345 | --------------------------------------------------------------------------*/ |
| 11346 | void hdd_wlan_initial_scan(hdd_adapter_t *pAdapter) |
| 11347 | { |
| 11348 | tCsrScanRequest scanReq; |
| 11349 | tCsrChannelInfo channelInfo; |
| 11350 | eHalStatus halStatus; |
Jeff Johnson | 0279779 | 2013-10-26 19:17:13 -0700 | [diff] [blame] | 11351 | tANI_U32 scanId; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11352 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 11353 | |
| 11354 | vos_mem_zero(&scanReq, sizeof(tCsrScanRequest)); |
| 11355 | vos_mem_set(&scanReq.bssid, sizeof(tCsrBssid), 0xff); |
| 11356 | scanReq.BSSType = eCSR_BSS_TYPE_ANY; |
| 11357 | |
| 11358 | if(sme_Is11dSupported(pHddCtx->hHal)) |
| 11359 | { |
| 11360 | halStatus = sme_ScanGetBaseChannels( pHddCtx->hHal, &channelInfo ); |
| 11361 | if ( HAL_STATUS_SUCCESS( halStatus ) ) |
| 11362 | { |
| 11363 | scanReq.ChannelInfo.ChannelList = vos_mem_malloc(channelInfo.numOfChannels); |
| 11364 | if( !scanReq.ChannelInfo.ChannelList ) |
| 11365 | { |
| 11366 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s kmalloc failed", __func__); |
| 11367 | vos_mem_free(channelInfo.ChannelList); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 11368 | channelInfo.ChannelList = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11369 | return; |
| 11370 | } |
| 11371 | vos_mem_copy(scanReq.ChannelInfo.ChannelList, channelInfo.ChannelList, |
| 11372 | channelInfo.numOfChannels); |
| 11373 | scanReq.ChannelInfo.numOfChannels = channelInfo.numOfChannels; |
| 11374 | vos_mem_free(channelInfo.ChannelList); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 11375 | channelInfo.ChannelList = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11376 | } |
| 11377 | |
| 11378 | scanReq.scanType = eSIR_PASSIVE_SCAN; |
| 11379 | scanReq.requestType = eCSR_SCAN_REQUEST_11D_SCAN; |
| 11380 | scanReq.maxChnTime = pHddCtx->cfg_ini->nPassiveMaxChnTime; |
| 11381 | scanReq.minChnTime = pHddCtx->cfg_ini->nPassiveMinChnTime; |
| 11382 | } |
| 11383 | else |
| 11384 | { |
| 11385 | scanReq.scanType = eSIR_ACTIVE_SCAN; |
| 11386 | scanReq.requestType = eCSR_SCAN_REQUEST_FULL_SCAN; |
| 11387 | scanReq.maxChnTime = pHddCtx->cfg_ini->nActiveMaxChnTime; |
| 11388 | scanReq.minChnTime = pHddCtx->cfg_ini->nActiveMinChnTime; |
| 11389 | } |
| 11390 | |
| 11391 | halStatus = sme_ScanRequest(pHddCtx->hHal, pAdapter->sessionId, &scanReq, &scanId, NULL, NULL); |
| 11392 | if ( !HAL_STATUS_SUCCESS( halStatus ) ) |
| 11393 | { |
| 11394 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_ScanRequest failed status code %d", |
| 11395 | __func__, halStatus ); |
| 11396 | } |
| 11397 | |
| 11398 | if(sme_Is11dSupported(pHddCtx->hHal)) |
| 11399 | vos_mem_free(scanReq.ChannelInfo.ChannelList); |
| 11400 | } |
| 11401 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11402 | /**--------------------------------------------------------------------------- |
| 11403 | |
| 11404 | \brief hdd_full_power_callback() - HDD full power callback function |
| 11405 | |
| 11406 | This is the function invoked by SME to inform the result of a full power |
| 11407 | request issued by HDD |
| 11408 | |
| 11409 | \param - callbackcontext - Pointer to cookie |
| 11410 | \param - status - result of request |
| 11411 | |
| 11412 | \return - None |
| 11413 | |
| 11414 | --------------------------------------------------------------------------*/ |
| 11415 | static void hdd_full_power_callback(void *callbackContext, eHalStatus status) |
| 11416 | { |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 11417 | struct statsContext *pContext = callbackContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11418 | |
| 11419 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | c135a9a | 2017-09-19 08:37:24 -0700 | [diff] [blame] | 11420 | "%s: context = %pK, status = %d", __func__, pContext, status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11421 | |
| 11422 | if (NULL == callbackContext) |
| 11423 | { |
| 11424 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | c135a9a | 2017-09-19 08:37:24 -0700 | [diff] [blame] | 11425 | "%s: Bad param, context [%pK]", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 11426 | __func__, callbackContext); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11427 | return; |
| 11428 | } |
| 11429 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 11430 | /* there is a race condition that exists between this callback |
| 11431 | function and the caller since the caller could time out either |
| 11432 | before or while this code is executing. we use a spinlock to |
| 11433 | serialize these actions */ |
| 11434 | spin_lock(&hdd_context_lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11435 | |
| 11436 | if (POWER_CONTEXT_MAGIC != pContext->magic) |
| 11437 | { |
| 11438 | /* the caller presumably timed out so there is nothing we can do */ |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 11439 | spin_unlock(&hdd_context_lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11440 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 11441 | "%s: Invalid context, magic [%08x]", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 11442 | __func__, pContext->magic); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11443 | return; |
| 11444 | } |
| 11445 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 11446 | /* context is valid so caller is still waiting */ |
| 11447 | |
| 11448 | /* paranoia: invalidate the magic */ |
| 11449 | pContext->magic = 0; |
| 11450 | |
| 11451 | /* notify the caller */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11452 | complete(&pContext->completion); |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 11453 | |
| 11454 | /* serialization is complete */ |
| 11455 | spin_unlock(&hdd_context_lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11456 | } |
| 11457 | |
Katya Nigam | f0511f6 | 2015-05-05 16:40:57 +0530 | [diff] [blame] | 11458 | void wlan_hdd_mon_set_typesubtype( hdd_mon_ctx_t *pMonCtx,int type) |
| 11459 | { |
| 11460 | pMonCtx->typeSubtypeBitmap = 0; |
| 11461 | if( type%10 ) /* Management Packets */ |
| 11462 | pMonCtx->typeSubtypeBitmap |= 0xFFFF; |
| 11463 | type/=10; |
| 11464 | if( type%10 ) /* Control Packets */ |
| 11465 | pMonCtx->typeSubtypeBitmap |= 0xFFFF0000; |
| 11466 | type/=10; |
| 11467 | if( type%10 ) /* Data Packets */ |
| 11468 | pMonCtx->typeSubtypeBitmap |= 0xFFFF00000000; |
| 11469 | } |
| 11470 | |
Hanumantha Reddy Pothula | 91cdd7f | 2015-09-03 21:25:16 +0530 | [diff] [blame] | 11471 | VOS_STATUS wlan_hdd_mon_postMsg(tANI_U32 *magic, struct completion *cmpVar, |
| 11472 | hdd_mon_ctx_t *pMonCtx , void* callback) |
Katya Nigam | f0511f6 | 2015-05-05 16:40:57 +0530 | [diff] [blame] | 11473 | { |
| 11474 | vos_msg_t monMsg; |
Hanumantha Reddy Pothula | 91cdd7f | 2015-09-03 21:25:16 +0530 | [diff] [blame] | 11475 | tSirMonModeReq *pMonModeReq; |
Katya Nigam | f0511f6 | 2015-05-05 16:40:57 +0530 | [diff] [blame] | 11476 | |
Hanumantha Reddy Pothula | 91cdd7f | 2015-09-03 21:25:16 +0530 | [diff] [blame] | 11477 | if (MON_MODE_START == pMonCtx->state) |
| 11478 | monMsg.type = WDA_MON_START_REQ; |
| 11479 | else if (MON_MODE_STOP == pMonCtx->state) |
| 11480 | monMsg.type = WDA_MON_STOP_REQ; |
| 11481 | else { |
| 11482 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 11483 | FL("invalid monitor state %d"), pMonCtx->state); |
Katya Nigam | f0511f6 | 2015-05-05 16:40:57 +0530 | [diff] [blame] | 11484 | return VOS_STATUS_E_FAILURE; |
| 11485 | } |
| 11486 | |
Hanumantha Reddy Pothula | 91cdd7f | 2015-09-03 21:25:16 +0530 | [diff] [blame] | 11487 | pMonModeReq = vos_mem_malloc(sizeof(tSirMonModeReq)); |
| 11488 | if (pMonModeReq == NULL) { |
| 11489 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 11490 | FL("fail to allocate memory for monitor mode req")); |
| 11491 | return VOS_STATUS_E_FAILURE; |
| 11492 | } |
Katya Nigam | f0511f6 | 2015-05-05 16:40:57 +0530 | [diff] [blame] | 11493 | |
Hanumantha Reddy Pothula | 91cdd7f | 2015-09-03 21:25:16 +0530 | [diff] [blame] | 11494 | pMonModeReq->magic = magic; |
| 11495 | pMonModeReq->cmpVar = cmpVar; |
| 11496 | pMonModeReq->data = pMonCtx; |
| 11497 | pMonModeReq->callback = callback; |
Katya Nigam | f0511f6 | 2015-05-05 16:40:57 +0530 | [diff] [blame] | 11498 | |
Katya Nigam | f0511f6 | 2015-05-05 16:40:57 +0530 | [diff] [blame] | 11499 | monMsg.reserved = 0; |
Hanumantha Reddy Pothula | 91cdd7f | 2015-09-03 21:25:16 +0530 | [diff] [blame] | 11500 | monMsg.bodyptr = pMonModeReq; |
Katya Nigam | f0511f6 | 2015-05-05 16:40:57 +0530 | [diff] [blame] | 11501 | monMsg.bodyval = 0; |
| 11502 | |
| 11503 | if (VOS_STATUS_SUCCESS != vos_mq_post_message( |
| 11504 | VOS_MODULE_ID_WDA,(vos_msg_t *)&monMsg)) { |
| 11505 | 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] | 11506 | vos_mem_free(pMonModeReq); |
Katya Nigam | f0511f6 | 2015-05-05 16:40:57 +0530 | [diff] [blame] | 11507 | } |
Hanumantha Reddy Pothula | 91cdd7f | 2015-09-03 21:25:16 +0530 | [diff] [blame] | 11508 | return VOS_STATUS_SUCCESS; |
Katya Nigam | f0511f6 | 2015-05-05 16:40:57 +0530 | [diff] [blame] | 11509 | } |
| 11510 | |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 11511 | void wlan_hdd_mon_close(hdd_context_t *pHddCtx) |
| 11512 | { |
| 11513 | VOS_STATUS vosStatus; |
| 11514 | v_CONTEXT_t pVosContext = pHddCtx->pvosContext; |
Hanumantha Reddy Pothula | 91cdd7f | 2015-09-03 21:25:16 +0530 | [diff] [blame] | 11515 | long ret; |
| 11516 | hdd_mon_ctx_t *pMonCtx = NULL; |
| 11517 | v_U32_t magic; |
| 11518 | struct completion cmpVar; |
Hanumantha Reddy Pothula | c99bc06 | 2015-09-08 14:59:26 +0530 | [diff] [blame] | 11519 | |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 11520 | hdd_adapter_t *pAdapter = hdd_get_adapter(pHddCtx,WLAN_HDD_MONITOR); |
| 11521 | if(pAdapter == NULL || pVosContext == NULL) |
| 11522 | { |
| 11523 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:pAdapter is NULL",__func__); |
| 11524 | return ; |
| 11525 | } |
Katya Nigam | f0511f6 | 2015-05-05 16:40:57 +0530 | [diff] [blame] | 11526 | |
Hanumantha Reddy Pothula | 91cdd7f | 2015-09-03 21:25:16 +0530 | [diff] [blame] | 11527 | pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter); |
| 11528 | if (pMonCtx!= NULL && pMonCtx->state == MON_MODE_START) { |
| 11529 | pMonCtx->state = MON_MODE_STOP; |
| 11530 | magic = MON_MODE_MSG_MAGIC; |
| 11531 | init_completion(&cmpVar); |
| 11532 | if (VOS_STATUS_SUCCESS != |
| 11533 | wlan_hdd_mon_postMsg(&magic, &cmpVar, |
| 11534 | pMonCtx, hdd_monPostMsgCb)) { |
| 11535 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 11536 | FL("failed to post MON MODE REQ")); |
| 11537 | pMonCtx->state = MON_MODE_START; |
| 11538 | magic = 0; |
| 11539 | return; |
| 11540 | } |
| 11541 | ret = wait_for_completion_timeout(&cmpVar, MON_MODE_MSG_TIMEOUT); |
| 11542 | magic = 0; |
| 11543 | if (ret <= 0 ) { |
| 11544 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 11545 | FL("timeout on monitor mode completion %ld"), ret); |
| 11546 | } |
| 11547 | } |
| 11548 | |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 11549 | hdd_UnregisterWext(pAdapter->dev); |
| 11550 | |
| 11551 | vos_mon_stop( pVosContext ); |
| 11552 | |
| 11553 | vosStatus = vos_sched_close( pVosContext ); |
| 11554 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) { |
| 11555 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, |
| 11556 | "%s: Failed to close VOSS Scheduler",__func__); |
| 11557 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) ); |
| 11558 | } |
| 11559 | |
| 11560 | vosStatus = vos_nv_close(); |
| 11561 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) |
| 11562 | { |
| 11563 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 11564 | "%s: Failed to close NV", __func__); |
| 11565 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) ); |
| 11566 | } |
| 11567 | |
| 11568 | vos_close(pVosContext); |
| 11569 | |
| 11570 | #ifdef WLAN_KD_READY_NOTIFIER |
| 11571 | nl_srv_exit(pHddCtx->ptt_pid); |
| 11572 | #else |
| 11573 | nl_srv_exit(); |
| 11574 | #endif |
| 11575 | |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 11576 | hdd_close_all_adapters( pHddCtx ); |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 11577 | } |
Agrawal Ashish | 33ec71e | 2015-11-26 20:20:58 +0530 | [diff] [blame] | 11578 | /** |
| 11579 | * hdd_wlan_free_wiphy_channels - free Channel pointer for wiphy |
| 11580 | * @ wiphy: the wiphy to validate against |
| 11581 | * |
| 11582 | * Return: void |
| 11583 | */ |
| 11584 | void hdd_wlan_free_wiphy_channels(struct wiphy *wiphy) |
| 11585 | { |
| 11586 | int i =0; |
Rajeev Kumar Sirasanagandla | 5b21a9c | 2018-01-08 17:05:11 +0530 | [diff] [blame] | 11587 | for (i = 0; i < HDD_NUM_NL80211_BANDS; i++) |
Agrawal Ashish | 33ec71e | 2015-11-26 20:20:58 +0530 | [diff] [blame] | 11588 | { |
| 11589 | if (NULL != wiphy->bands[i] && |
| 11590 | (NULL != wiphy->bands[i]->channels)) |
| 11591 | { |
| 11592 | vos_mem_free(wiphy->bands[i]->channels); |
| 11593 | wiphy->bands[i]->channels = NULL; |
| 11594 | } |
| 11595 | } |
| 11596 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11597 | /**--------------------------------------------------------------------------- |
| 11598 | |
| 11599 | \brief hdd_wlan_exit() - HDD WLAN exit function |
| 11600 | |
| 11601 | This is the driver exit point (invoked during rmmod) |
| 11602 | |
| 11603 | \param - pHddCtx - Pointer to the HDD Context |
| 11604 | |
| 11605 | \return - None |
| 11606 | |
| 11607 | --------------------------------------------------------------------------*/ |
| 11608 | void hdd_wlan_exit(hdd_context_t *pHddCtx) |
| 11609 | { |
| 11610 | eHalStatus halStatus; |
| 11611 | v_CONTEXT_t pVosContext = pHddCtx->pvosContext; |
| 11612 | VOS_STATUS vosStatus; |
Gopichand Nakkala | 66923aa | 2013-03-06 23:17:24 +0530 | [diff] [blame] | 11613 | struct wiphy *wiphy = pHddCtx->wiphy; |
Mingcheng Zhu | 87f22fc | 2014-01-30 19:23:32 -0800 | [diff] [blame] | 11614 | hdd_adapter_t* pAdapter = NULL; |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 11615 | struct statsContext powerContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11616 | long lrc; |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 11617 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11618 | |
| 11619 | ENTER(); |
| 11620 | |
Vinay Krishna Eranna | f97ef5c | 2014-12-26 17:47:19 +0530 | [diff] [blame] | 11621 | |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 11622 | if (VOS_MONITOR_MODE == hdd_get_conparam()) |
| 11623 | { |
| 11624 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: MONITOR MODE",__func__); |
| 11625 | wlan_hdd_mon_close(pHddCtx); |
Hanumantha Reddy Pothula | c99bc06 | 2015-09-08 14:59:26 +0530 | [diff] [blame] | 11626 | goto free_hdd_ctx; |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 11627 | } |
| 11628 | else if (VOS_FTM_MODE != hdd_get_conparam()) |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 11629 | { |
| 11630 | // Unloading, restart logic is no more required. |
| 11631 | wlan_hdd_restart_deinit(pHddCtx); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 11632 | |
Agarwal Ashish | b20e0ff | 2014-12-17 22:50:19 +0530 | [diff] [blame] | 11633 | #ifdef FEATURE_WLAN_TDLS |
| 11634 | /* At the time of driver unloading; if tdls connection is present; |
| 11635 | * hdd_rx_packet_cbk calls wlan_hdd_tdls_find_peer. |
| 11636 | * wlan_hdd_tdls_find_peer always checks for valid context; |
| 11637 | * as load/unload in progress there can be a race condition. |
| 11638 | * hdd_rx_packet_cbk calls wlan_hdd_tdls_find_peer only |
| 11639 | * when tdls state is enabled. |
| 11640 | * As soon as driver set load/unload flag; tdls flag also needs |
| 11641 | * to be disabled so that hdd_rx_packet_cbk won't call |
| 11642 | * wlan_hdd_tdls_find_peer. |
| 11643 | */ |
Masti, Narayanraddi | 20494af | 2015-12-17 20:56:42 +0530 | [diff] [blame] | 11644 | wlan_hdd_tdls_set_mode(pHddCtx, eTDLS_SUPPORT_DISABLED, FALSE, |
| 11645 | HDD_SET_TDLS_MODE_SOURCE_USER); |
Agarwal Ashish | b20e0ff | 2014-12-17 22:50:19 +0530 | [diff] [blame] | 11646 | #endif |
| 11647 | |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 11648 | vosStatus = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 11649 | while (NULL != pAdapterNode && VOS_STATUS_E_EMPTY != vosStatus) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11650 | { |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 11651 | pAdapter = pAdapterNode->pAdapter; |
| 11652 | if (NULL != pAdapter) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11653 | { |
Mahesh A Saptasagar | 305e263 | 2015-03-04 12:57:33 +0530 | [diff] [blame] | 11654 | /* Disable TX on the interface, after this hard_start_xmit() will |
| 11655 | * not be called on that interface |
| 11656 | */ |
| 11657 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues")); |
| 11658 | netif_tx_disable(pAdapter->dev); |
| 11659 | |
| 11660 | /* Mark the interface status as "down" for outside world */ |
| 11661 | netif_carrier_off(pAdapter->dev); |
| 11662 | |
Agarwal Ashish | 9ffa5b9 | 2014-11-18 21:07:02 +0530 | [diff] [blame] | 11663 | /* DeInit the adapter. This ensures that all data packets |
| 11664 | * are freed. |
| 11665 | */ |
Mahesh A Saptasagar | 02e36e8 | 2015-01-14 20:39:19 +0530 | [diff] [blame] | 11666 | #ifdef FEATURE_WLAN_TDLS |
| 11667 | mutex_lock(&pHddCtx->tdls_lock); |
| 11668 | #endif |
c_hpothu | 002231a | 2015-02-05 14:58:51 +0530 | [diff] [blame] | 11669 | hdd_deinit_adapter(pHddCtx, pAdapter, FALSE); |
Mahesh A Saptasagar | 02e36e8 | 2015-01-14 20:39:19 +0530 | [diff] [blame] | 11670 | #ifdef FEATURE_WLAN_TDLS |
| 11671 | mutex_unlock(&pHddCtx->tdls_lock); |
| 11672 | #endif |
Masti, Narayanraddi | 2637846 | 2016-01-05 18:20:28 +0530 | [diff] [blame] | 11673 | vos_flush_delayed_work(&pHddCtx->scan_ctxt.scan_work); |
| 11674 | |
| 11675 | wlan_hdd_init_deinit_defer_scan_context(&pHddCtx->scan_ctxt); |
Agarwal Ashish | 9ffa5b9 | 2014-11-18 21:07:02 +0530 | [diff] [blame] | 11676 | |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 11677 | if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode || |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 11678 | WLAN_HDD_P2P_CLIENT == pAdapter->device_mode || |
| 11679 | WLAN_HDD_MONITOR == pAdapter->device_mode) |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 11680 | { |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 11681 | if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode || |
| 11682 | WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) |
| 11683 | wlan_hdd_cfg80211_deregister_frames(pAdapter); |
| 11684 | |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 11685 | hdd_UnregisterWext(pAdapter->dev); |
| 11686 | } |
Kaushik, Sushant | 4975a57 | 2014-10-21 16:07:48 +0530 | [diff] [blame] | 11687 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11688 | } |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 11689 | vosStatus = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 11690 | pAdapterNode = pNext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11691 | } |
mukul sharma | bab477d | 2015-06-11 17:14:55 +0530 | [diff] [blame] | 11692 | |
Kaushik, Sushant | 4975a57 | 2014-10-21 16:07:48 +0530 | [diff] [blame] | 11693 | // Cancel any outstanding scan requests. We are about to close all |
| 11694 | // of our adapters, but an adapter structure is what SME passes back |
| 11695 | // to our callback function. Hence if there are any outstanding scan |
| 11696 | // requests then there is a race condition between when the adapter |
| 11697 | // is closed and when the callback is invoked.We try to resolve that |
| 11698 | // race condition here by canceling any outstanding scans before we |
| 11699 | // close the adapters. |
| 11700 | // Note that the scans may be cancelled in an asynchronous manner, |
| 11701 | // so ideally there needs to be some kind of synchronization. Rather |
| 11702 | // than introduce a new synchronization here, we will utilize the |
| 11703 | // fact that we are about to Request Full Power, and since that is |
| 11704 | // synchronized, the expectation is that by the time Request Full |
| 11705 | // Power has completed all scans will be cancelled. |
| 11706 | if (pHddCtx->scan_info.mScanPending) |
| 11707 | { |
Hema Aparna Medicharla | f05f6cd | 2015-01-21 14:44:19 +0530 | [diff] [blame] | 11708 | if(NULL != pAdapter) |
| 11709 | { |
| 11710 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 11711 | FL("abort scan mode: %d sessionId: %d"), |
| 11712 | pAdapter->device_mode, |
| 11713 | pAdapter->sessionId); |
| 11714 | } |
| 11715 | hdd_abort_mac_scan(pHddCtx, |
| 11716 | pHddCtx->scan_info.sessionId, |
| 11717 | eCSR_SCAN_ABORT_DEFAULT); |
Kaushik, Sushant | 4975a57 | 2014-10-21 16:07:48 +0530 | [diff] [blame] | 11718 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11719 | } |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 11720 | else |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 11721 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 11722 | hddLog(VOS_TRACE_LEVEL_INFO,"%s: FTM MODE",__func__); |
Hanumantha Reddy Pothula | 45af96b | 2015-02-12 16:07:58 +0530 | [diff] [blame] | 11723 | if (pHddCtx->ftm.ftm_state == WLAN_FTM_STARTING) |
| 11724 | { |
| 11725 | INIT_COMPLETION(pHddCtx->ftm.startCmpVar); |
| 11726 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 11727 | "%s: in middle of FTM START", __func__); |
| 11728 | lrc = wait_for_completion_timeout(&pHddCtx->ftm.startCmpVar, |
| 11729 | msecs_to_jiffies(20000)); |
| 11730 | if(!lrc) |
| 11731 | { |
| 11732 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 11733 | "%s: timedout on ftmStartCmpVar fatal error", __func__); |
| 11734 | } |
| 11735 | } |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 11736 | wlan_hdd_ftm_close(pHddCtx); |
| 11737 | goto free_hdd_ctx; |
| 11738 | } |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 11739 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11740 | /* DeRegister with platform driver as client for Suspend/Resume */ |
| 11741 | vosStatus = hddDeregisterPmOps(pHddCtx); |
| 11742 | if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) ) |
| 11743 | { |
| 11744 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddDeregisterPmOps failed",__func__); |
| 11745 | VOS_ASSERT(0); |
| 11746 | } |
| 11747 | |
| 11748 | vosStatus = hddDevTmUnregisterNotifyCallback(pHddCtx); |
| 11749 | if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) ) |
| 11750 | { |
| 11751 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddDevTmUnregisterNotifyCallback failed",__func__); |
| 11752 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11753 | |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 11754 | //Stop the traffic monitor timer |
Mahesh A Saptasagar | d461e43 | 2016-07-20 15:01:40 +0530 | [diff] [blame] | 11755 | if ((pHddCtx->cfg_ini->dynSplitscan) && (VOS_TIMER_STATE_RUNNING == |
| 11756 | vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr))) |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 11757 | { |
| 11758 | vos_timer_stop(&pHddCtx->tx_rx_trafficTmr); |
| 11759 | } |
| 11760 | |
| 11761 | // Destroy the traffic monitor timer |
Mahesh A Saptasagar | d461e43 | 2016-07-20 15:01:40 +0530 | [diff] [blame] | 11762 | if ((pHddCtx->cfg_ini->dynSplitscan) && |
| 11763 | (!VOS_IS_STATUS_SUCCESS(vos_timer_destroy( |
| 11764 | &pHddCtx->tx_rx_trafficTmr)))) |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 11765 | { |
| 11766 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 11767 | "%s: Cannot deallocate Traffic monitor timer", __func__); |
| 11768 | } |
| 11769 | |
Bhargav Shah | d071591 | 2015-10-01 18:17:37 +0530 | [diff] [blame] | 11770 | if (VOS_TIMER_STATE_RUNNING == |
| 11771 | vos_timer_getCurrentState(&pHddCtx->delack_timer)) { |
| 11772 | vos_timer_stop(&pHddCtx->delack_timer); |
| 11773 | } |
| 11774 | |
| 11775 | if (!VOS_IS_STATUS_SUCCESS(vos_timer_destroy( |
| 11776 | &pHddCtx->delack_timer))) { |
| 11777 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 11778 | "%s: Cannot deallocate Bus bandwidth timer", __func__); |
| 11779 | } |
| 11780 | |
Masti, Narayanraddi | 44b0db0 | 2015-12-22 11:54:35 +0530 | [diff] [blame] | 11781 | if (VOS_TIMER_STATE_RUNNING == |
| 11782 | vos_timer_getCurrentState(&pHddCtx->tdls_source_timer)) { |
| 11783 | vos_timer_stop(&pHddCtx->tdls_source_timer); |
| 11784 | } |
| 11785 | |
Abhishek Singh | 8a3e4dc | 2017-01-02 10:39:18 +0530 | [diff] [blame] | 11786 | vos_set_snoc_high_freq_voting(false); |
| 11787 | |
Masti, Narayanraddi | 44b0db0 | 2015-12-22 11:54:35 +0530 | [diff] [blame] | 11788 | vos_timer_destroy(&pHddCtx->tdls_source_timer); |
| 11789 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11790 | //Disable IMPS/BMPS as we do not want the device to enter any power |
| 11791 | //save mode during shutdown |
| 11792 | sme_DisablePowerSave(pHddCtx->hHal, ePMC_IDLE_MODE_POWER_SAVE); |
| 11793 | sme_DisablePowerSave(pHddCtx->hHal, ePMC_BEACON_MODE_POWER_SAVE); |
| 11794 | sme_DisablePowerSave(pHddCtx->hHal, ePMC_UAPSD_MODE_POWER_SAVE); |
| 11795 | |
| 11796 | //Ensure that device is in full power as we will touch H/W during vos_Stop |
| 11797 | init_completion(&powerContext.completion); |
| 11798 | powerContext.magic = POWER_CONTEXT_MAGIC; |
| 11799 | |
| 11800 | halStatus = sme_RequestFullPower(pHddCtx->hHal, hdd_full_power_callback, |
| 11801 | &powerContext, eSME_FULL_PWR_NEEDED_BY_HDD); |
| 11802 | |
| 11803 | if (eHAL_STATUS_SUCCESS != halStatus) |
| 11804 | { |
| 11805 | if (eHAL_STATUS_PMC_PENDING == halStatus) |
| 11806 | { |
| 11807 | /* request was sent -- wait for the response */ |
| 11808 | lrc = wait_for_completion_interruptible_timeout( |
| 11809 | &powerContext.completion, |
| 11810 | msecs_to_jiffies(WLAN_WAIT_TIME_POWER)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11811 | if (lrc <= 0) |
| 11812 | { |
| 11813 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s while requesting full power", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 11814 | __func__, (0 == lrc) ? "timeout" : "interrupt"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11815 | } |
| 11816 | } |
| 11817 | else |
| 11818 | { |
| 11819 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 11820 | "%s: Request for Full Power failed, status %d", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 11821 | __func__, halStatus); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11822 | /* continue -- need to clean up as much as possible */ |
| 11823 | } |
| 11824 | } |
Hanumantha Reddy Pothula | 81b42b2 | 2015-05-12 13:52:00 +0530 | [diff] [blame] | 11825 | if ((eHAL_STATUS_SUCCESS == halStatus) || |
| 11826 | (eHAL_STATUS_PMC_PENDING == halStatus && lrc > 0)) |
| 11827 | { |
| 11828 | /* This will issue a dump command which will clean up |
| 11829 | BTQM queues and unblock MC thread */ |
| 11830 | vos_fwDumpReq(274, 0, 0, 0, 0, 1); |
| 11831 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11832 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 11833 | /* either we never sent a request, we sent a request and received a |
| 11834 | response or we sent a request and timed out. if we never sent a |
| 11835 | request or if we sent a request and got a response, we want to |
| 11836 | clear the magic out of paranoia. if we timed out there is a |
| 11837 | race condition such that the callback function could be |
| 11838 | executing at the same time we are. of primary concern is if the |
| 11839 | callback function had already verified the "magic" but had not |
| 11840 | yet set the completion variable when a timeout occurred. we |
| 11841 | serialize these activities by invalidating the magic while |
| 11842 | holding a shared spinlock which will cause us to block if the |
| 11843 | callback is currently executing */ |
| 11844 | spin_lock(&hdd_context_lock); |
| 11845 | powerContext.magic = 0; |
| 11846 | spin_unlock(&hdd_context_lock); |
| 11847 | |
Hema Aparna Medicharla | a6cf65e | 2015-06-01 16:23:28 +0530 | [diff] [blame] | 11848 | /* If Device is shutdown, no point for SME to wait for responses |
| 11849 | from device. Pre Close SME */ |
| 11850 | if(wcnss_device_is_shutdown()) |
| 11851 | { |
| 11852 | sme_PreClose(pHddCtx->hHal); |
| 11853 | } |
Yue Ma | 0d4891e | 2013-08-06 17:01:45 -0700 | [diff] [blame] | 11854 | hdd_debugfs_exit(pHddCtx); |
| 11855 | |
Ratheesh S P | 35ed8b1 | 2015-04-27 14:01:07 +0530 | [diff] [blame] | 11856 | #ifdef WLAN_NS_OFFLOAD |
Ratheesh S P | 36dbc93 | 2015-08-07 14:28:57 +0530 | [diff] [blame] | 11857 | hddLog(LOG1, FL("Unregister IPv6 notifier")); |
Ratheesh S P | 35ed8b1 | 2015-04-27 14:01:07 +0530 | [diff] [blame] | 11858 | unregister_inet6addr_notifier(&pHddCtx->ipv6_notifier); |
| 11859 | #endif |
Ratheesh S P | 36dbc93 | 2015-08-07 14:28:57 +0530 | [diff] [blame] | 11860 | hddLog(LOG1, FL("Unregister IPv4 notifier")); |
Ratheesh S P | 35ed8b1 | 2015-04-27 14:01:07 +0530 | [diff] [blame] | 11861 | unregister_inetaddr_notifier(&pHddCtx->ipv4_notifier); |
| 11862 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11863 | // Unregister the Net Device Notifier |
| 11864 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 11865 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11866 | hdd_stop_all_adapters( pHddCtx ); |
| 11867 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11868 | #ifdef WLAN_BTAMP_FEATURE |
| 11869 | vosStatus = WLANBAP_Stop(pVosContext); |
| 11870 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) |
| 11871 | { |
| 11872 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 11873 | "%s: Failed to stop BAP",__func__); |
| 11874 | } |
| 11875 | #endif //WLAN_BTAMP_FEATURE |
| 11876 | |
| 11877 | //Stop all the modules |
| 11878 | vosStatus = vos_stop( pVosContext ); |
| 11879 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) |
| 11880 | { |
| 11881 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 11882 | "%s: Failed to stop VOSS",__func__); |
| 11883 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) ); |
Hanumantha Reddy Pothula | bd9601a | 2016-02-12 13:22:27 +0530 | [diff] [blame] | 11884 | if (isSsrPanicOnFailure()) |
| 11885 | VOS_BUG(0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11886 | } |
| 11887 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11888 | //This requires pMac access, Call this before vos_close(). |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11889 | hdd_unregister_mcast_bcast_filter(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11890 | |
| 11891 | //Close the scheduler before calling vos_close to make sure no thread is |
| 11892 | // scheduled after the each module close is called i.e after all the data |
| 11893 | // structures are freed. |
| 11894 | vosStatus = vos_sched_close( pVosContext ); |
| 11895 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) { |
| 11896 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, |
| 11897 | "%s: Failed to close VOSS Scheduler",__func__); |
| 11898 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) ); |
| 11899 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 11900 | #ifdef WLAN_FEATURE_HOLD_RX_WAKELOCK |
| 11901 | /* Destroy the wake lock */ |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 11902 | vos_wake_lock_destroy(&pHddCtx->rx_wake_lock); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 11903 | #endif |
Madan Mohan Koyyalamudi | 69fc3ad | 2012-11-28 16:04:56 -0800 | [diff] [blame] | 11904 | /* Destroy the wake lock */ |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 11905 | vos_wake_lock_destroy(&pHddCtx->sap_wake_lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11906 | |
Mihir Shete | 7a24b5f | 2013-12-21 12:18:31 +0530 | [diff] [blame] | 11907 | #ifdef CONFIG_ENABLE_LINUX_REG |
| 11908 | vosStatus = vos_nv_close(); |
| 11909 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) |
| 11910 | { |
| 11911 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 11912 | "%s: Failed to close NV", __func__); |
| 11913 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) ); |
| 11914 | } |
| 11915 | #endif |
| 11916 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11917 | //Close VOSS |
| 11918 | //This frees pMac(HAL) context. There should not be any call that requires pMac access after this. |
| 11919 | vos_close(pVosContext); |
| 11920 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11921 | //Close Watchdog |
| 11922 | if(pHddCtx->cfg_ini->fIsLogpEnabled) |
| 11923 | vos_watchdog_close(pVosContext); |
| 11924 | |
Gopichand Nakkala | a035848 | 2013-06-12 17:05:47 +0530 | [diff] [blame] | 11925 | //Clean up HDD Nlink Service |
| 11926 | send_btc_nlink_msg(WLAN_MODULE_DOWN_IND, 0); |
Gopichand Nakkala | a035848 | 2013-06-12 17:05:47 +0530 | [diff] [blame] | 11927 | |
Manjeet Singh | 47ee847 | 2016-04-11 11:57:18 +0530 | [diff] [blame] | 11928 | hdd_close_tx_queues(pHddCtx); |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 11929 | wlan_free_fwr_mem_dump_buffer(); |
| 11930 | memdump_deinit(); |
| 11931 | |
Vinay Krishna Eranna | d938c42 | 2014-03-10 17:14:21 +0530 | [diff] [blame] | 11932 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 11933 | if (pHddCtx->cfg_ini->wlanLoggingEnable) |
Vinay Krishna Eranna | d938c42 | 2014-03-10 17:14:21 +0530 | [diff] [blame] | 11934 | { |
| 11935 | wlan_logging_sock_deactivate_svc(); |
| 11936 | } |
| 11937 | #endif |
| 11938 | |
Vinay Krishna Eranna | ef30b52 | 2014-08-26 17:48:16 +0530 | [diff] [blame] | 11939 | #ifdef WLAN_KD_READY_NOTIFIER |
| 11940 | nl_srv_exit(pHddCtx->ptt_pid); |
| 11941 | #else |
| 11942 | nl_srv_exit(); |
| 11943 | #endif /* WLAN_KD_READY_NOTIFIER */ |
| 11944 | |
Abhishek Singh | 00b7197 | 2016-01-07 10:51:04 +0530 | [diff] [blame] | 11945 | #ifdef WLAN_FEATURE_RMC |
| 11946 | hdd_close_cesium_nl_sock(); |
| 11947 | #endif /* WLAN_FEATURE_RMC */ |
Vinay Krishna Eranna | ef30b52 | 2014-08-26 17:48:16 +0530 | [diff] [blame] | 11948 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11949 | hdd_close_all_adapters( pHddCtx ); |
| 11950 | |
Padma, Santhosh Kumar | 9cd3833 | 2015-11-17 12:18:10 +0530 | [diff] [blame] | 11951 | vos_flush_delayed_work(&pHddCtx->spoof_mac_addr_work); |
Abhishek Singh | 78c691f | 2017-11-30 13:48:44 +0530 | [diff] [blame] | 11952 | vos_flush_delayed_work(&pHddCtx->ecsa_chan_change_work); |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 11953 | vos_flush_work(&pHddCtx->sap_start_work); |
Padma, Santhosh Kumar | 9cd3833 | 2015-11-17 12:18:10 +0530 | [diff] [blame] | 11954 | |
Hanumantha Reddy Pothula | 97f9bc9 | 2015-08-10 17:21:20 +0530 | [diff] [blame] | 11955 | free_hdd_ctx: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11956 | /* free the power on lock from platform driver */ |
| 11957 | if (free_riva_power_on_lock("wlan")) |
| 11958 | { |
| 11959 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to free power on lock", |
| 11960 | __func__); |
| 11961 | } |
| 11962 | |
c_hpothu | 78c7b60 | 2014-05-17 17:35:49 +0530 | [diff] [blame] | 11963 | //Free up dynamically allocated members inside HDD Adapter |
| 11964 | if (pHddCtx->cfg_ini) |
| 11965 | { |
| 11966 | kfree(pHddCtx->cfg_ini); |
| 11967 | pHddCtx->cfg_ini= NULL; |
| 11968 | } |
| 11969 | |
Hanumantha Reddy Pothula | 6fe221c | 2016-01-28 15:01:09 +0530 | [diff] [blame] | 11970 | /* FTM/MONITOR mode, WIPHY did not registered |
Leo Chang | f04ddad | 2013-09-18 13:46:38 -0700 | [diff] [blame] | 11971 | If un-register here, system crash will happen */ |
Hanumantha Reddy Pothula | 6fe221c | 2016-01-28 15:01:09 +0530 | [diff] [blame] | 11972 | if (!(VOS_FTM_MODE == hdd_get_conparam() || |
| 11973 | VOS_MONITOR_MODE == hdd_get_conparam())) |
Leo Chang | f04ddad | 2013-09-18 13:46:38 -0700 | [diff] [blame] | 11974 | { |
| 11975 | wiphy_unregister(wiphy) ; |
Agrawal Ashish | 33ec71e | 2015-11-26 20:20:58 +0530 | [diff] [blame] | 11976 | hdd_wlan_free_wiphy_channels(wiphy); |
Leo Chang | f04ddad | 2013-09-18 13:46:38 -0700 | [diff] [blame] | 11977 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11978 | wiphy_free(wiphy) ; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11979 | if (hdd_is_ssr_required()) |
| 11980 | { |
| 11981 | /* WDI timeout had happened during unload, so SSR is needed here */ |
Madan Mohan Koyyalamudi | 3246f5b | 2012-10-15 15:40:02 -0700 | [diff] [blame] | 11982 | subsystem_restart("wcnss"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11983 | msleep(5000); |
| 11984 | } |
| 11985 | hdd_set_ssr_required (VOS_FALSE); |
| 11986 | } |
| 11987 | |
| 11988 | |
| 11989 | /**--------------------------------------------------------------------------- |
| 11990 | |
| 11991 | \brief hdd_update_config_from_nv() - Function to update the contents of |
| 11992 | the running configuration with parameters taken from NV storage |
| 11993 | |
| 11994 | \param - pHddCtx - Pointer to the HDD global context |
| 11995 | |
| 11996 | \return - VOS_STATUS_SUCCESS if successful |
| 11997 | |
| 11998 | --------------------------------------------------------------------------*/ |
| 11999 | static VOS_STATUS hdd_update_config_from_nv(hdd_context_t* pHddCtx) |
| 12000 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12001 | v_BOOL_t itemIsValid = VOS_FALSE; |
| 12002 | VOS_STATUS status; |
| 12003 | v_MACADDR_t macFromNV[VOS_MAX_CONCURRENCY_PERSONA]; |
| 12004 | v_U8_t macLoop; |
| 12005 | |
| 12006 | /*If the NV is valid then get the macaddress from nv else get it from qcom_cfg.ini*/ |
| 12007 | status = vos_nv_getValidity(VNV_FIELD_IMAGE, &itemIsValid); |
| 12008 | if(status != VOS_STATUS_SUCCESS) |
| 12009 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 12010 | hddLog(VOS_TRACE_LEVEL_ERROR," vos_nv_getValidity() failed"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12011 | return VOS_STATUS_E_FAILURE; |
| 12012 | } |
| 12013 | |
| 12014 | if (itemIsValid == VOS_TRUE) |
| 12015 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 12016 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH," Reading the Macaddress from NV"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12017 | status = vos_nv_readMultiMacAddress((v_U8_t *)&macFromNV[0].bytes[0], |
| 12018 | VOS_MAX_CONCURRENCY_PERSONA); |
| 12019 | if(status != VOS_STATUS_SUCCESS) |
| 12020 | { |
| 12021 | /* Get MAC from NV fail, not update CFG info |
| 12022 | * INI MAC value will be used for MAC setting */ |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 12023 | hddLog(VOS_TRACE_LEVEL_ERROR," vos_nv_readMacAddress() failed"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12024 | return VOS_STATUS_E_FAILURE; |
| 12025 | } |
| 12026 | |
| 12027 | /* If first MAC is not valid, treat all others are not valid |
| 12028 | * Then all MACs will be got from ini file */ |
| 12029 | if(vos_is_macaddr_zero(&macFromNV[0])) |
| 12030 | { |
| 12031 | /* MAC address in NV file is not configured yet */ |
| 12032 | hddLog(VOS_TRACE_LEVEL_WARN, "Invalid MAC in NV file"); |
| 12033 | return VOS_STATUS_E_INVAL; |
| 12034 | } |
| 12035 | |
| 12036 | /* Get MAC address from NV, update CFG info */ |
| 12037 | for(macLoop = 0; macLoop < VOS_MAX_CONCURRENCY_PERSONA; macLoop++) |
| 12038 | { |
| 12039 | if(vos_is_macaddr_zero(&macFromNV[macLoop])) |
| 12040 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 12041 | 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] | 12042 | /* This MAC is not valid, skip it |
| 12043 | * This MAC will be got from ini file */ |
| 12044 | } |
| 12045 | else |
| 12046 | { |
| 12047 | vos_mem_copy((v_U8_t *)&pHddCtx->cfg_ini->intfMacAddr[macLoop].bytes[0], |
| 12048 | (v_U8_t *)&macFromNV[macLoop].bytes[0], |
| 12049 | VOS_MAC_ADDR_SIZE); |
| 12050 | } |
| 12051 | } |
| 12052 | } |
| 12053 | else |
| 12054 | { |
| 12055 | hddLog(VOS_TRACE_LEVEL_ERROR, "NV ITEM, MAC Not valid"); |
| 12056 | return VOS_STATUS_E_FAILURE; |
| 12057 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12058 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12059 | |
| 12060 | return VOS_STATUS_SUCCESS; |
| 12061 | } |
| 12062 | |
| 12063 | /**--------------------------------------------------------------------------- |
| 12064 | |
| 12065 | \brief hdd_post_voss_start_config() - HDD post voss start config helper |
| 12066 | |
| 12067 | \param - pAdapter - Pointer to the HDD |
| 12068 | |
| 12069 | \return - None |
| 12070 | |
| 12071 | --------------------------------------------------------------------------*/ |
| 12072 | VOS_STATUS hdd_post_voss_start_config(hdd_context_t* pHddCtx) |
| 12073 | { |
| 12074 | eHalStatus halStatus; |
| 12075 | v_U32_t listenInterval; |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 12076 | tANI_U32 ignoreDtim; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12077 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12078 | |
| 12079 | // Send ready indication to the HDD. This will kick off the MAC |
| 12080 | // into a 'running' state and should kick off an initial scan. |
| 12081 | halStatus = sme_HDDReadyInd( pHddCtx->hHal ); |
| 12082 | if ( !HAL_STATUS_SUCCESS( halStatus ) ) |
| 12083 | { |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 12084 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: sme_HDDReadyInd() failed with status " |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12085 | "code %08d [x%08x]",__func__, halStatus, halStatus ); |
| 12086 | return VOS_STATUS_E_FAILURE; |
| 12087 | } |
| 12088 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 12089 | // Set default LI and ignoreDtim into HDD context, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12090 | // otherwise under some race condition, HDD will set 0 LI value into RIVA, |
| 12091 | // And RIVA will crash |
| 12092 | wlan_cfgGetInt(pHddCtx->hHal, WNI_CFG_LISTEN_INTERVAL, &listenInterval); |
| 12093 | pHddCtx->hdd_actual_LI_value = listenInterval; |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 12094 | wlan_cfgGetInt(pHddCtx->hHal, WNI_CFG_IGNORE_DTIM, &ignoreDtim); |
| 12095 | pHddCtx->hdd_actual_ignore_DTIM_value = ignoreDtim; |
| 12096 | |
| 12097 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12098 | return VOS_STATUS_SUCCESS; |
| 12099 | } |
| 12100 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12101 | /* wake lock APIs for HDD */ |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 12102 | void hdd_prevent_suspend(uint32_t reason) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12103 | { |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 12104 | |
| 12105 | vos_wake_lock_acquire(&wlan_wake_lock, reason); |
| 12106 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12107 | } |
| 12108 | |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 12109 | void hdd_allow_suspend(uint32_t reason) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12110 | { |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 12111 | |
| 12112 | vos_wake_lock_release(&wlan_wake_lock, reason); |
| 12113 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12114 | } |
| 12115 | |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 12116 | 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] | 12117 | { |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 12118 | |
| 12119 | vos_wake_lock_timeout_release(&wlan_wake_lock, timeout, |
| 12120 | reason); |
| 12121 | |
Madan Mohan Koyyalamudi | 10d83a9 | 2012-09-28 15:47:05 -0700 | [diff] [blame] | 12122 | } |
| 12123 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12124 | /**--------------------------------------------------------------------------- |
| 12125 | |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 12126 | \brief hdd_exchange_version_and_caps() - HDD function to exchange version and capability |
| 12127 | information between Host and Riva |
| 12128 | |
| 12129 | This function gets reported version of FW |
| 12130 | It also finds the version of Riva headers used to compile the host |
| 12131 | It compares the above two and prints a warning if they are different |
| 12132 | It gets the SW and HW version string |
| 12133 | Finally, it exchanges capabilities between host and Riva i.e. host and riva exchange a msg |
| 12134 | indicating the features they support through a bitmap |
| 12135 | |
| 12136 | \param - pHddCtx - Pointer to HDD context |
| 12137 | |
| 12138 | \return - void |
| 12139 | |
| 12140 | --------------------------------------------------------------------------*/ |
| 12141 | |
| 12142 | void hdd_exchange_version_and_caps(hdd_context_t *pHddCtx) |
| 12143 | { |
| 12144 | |
| 12145 | tSirVersionType versionCompiled; |
| 12146 | tSirVersionType versionReported; |
| 12147 | tSirVersionString versionString; |
| 12148 | tANI_U8 fwFeatCapsMsgSupported = 0; |
| 12149 | VOS_STATUS vstatus; |
| 12150 | |
Mingcheng Zhu | 87f22fc | 2014-01-30 19:23:32 -0800 | [diff] [blame] | 12151 | memset(&versionCompiled, 0, sizeof(versionCompiled)); |
| 12152 | memset(&versionReported, 0, sizeof(versionReported)); |
| 12153 | |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 12154 | /* retrieve and display WCNSS version information */ |
| 12155 | do { |
| 12156 | |
| 12157 | vstatus = sme_GetWcnssWlanCompiledVersion(pHddCtx->hHal, |
| 12158 | &versionCompiled); |
| 12159 | if (!VOS_IS_STATUS_SUCCESS(vstatus)) |
| 12160 | { |
| 12161 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 12162 | "%s: unable to retrieve WCNSS WLAN compiled version", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 12163 | __func__); |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 12164 | break; |
| 12165 | } |
| 12166 | |
| 12167 | vstatus = sme_GetWcnssWlanReportedVersion(pHddCtx->hHal, |
| 12168 | &versionReported); |
| 12169 | if (!VOS_IS_STATUS_SUCCESS(vstatus)) |
| 12170 | { |
| 12171 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 12172 | "%s: unable to retrieve WCNSS WLAN reported version", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 12173 | __func__); |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 12174 | break; |
| 12175 | } |
| 12176 | |
| 12177 | if ((versionCompiled.major != versionReported.major) || |
| 12178 | (versionCompiled.minor != versionReported.minor) || |
| 12179 | (versionCompiled.version != versionReported.version) || |
| 12180 | (versionCompiled.revision != versionReported.revision)) |
| 12181 | { |
| 12182 | pr_err("%s: WCNSS WLAN Version %u.%u.%u.%u, " |
| 12183 | "Host expected %u.%u.%u.%u\n", |
| 12184 | WLAN_MODULE_NAME, |
| 12185 | (int)versionReported.major, |
| 12186 | (int)versionReported.minor, |
| 12187 | (int)versionReported.version, |
| 12188 | (int)versionReported.revision, |
| 12189 | (int)versionCompiled.major, |
| 12190 | (int)versionCompiled.minor, |
| 12191 | (int)versionCompiled.version, |
| 12192 | (int)versionCompiled.revision); |
| 12193 | } |
| 12194 | else |
| 12195 | { |
| 12196 | pr_info("%s: WCNSS WLAN version %u.%u.%u.%u\n", |
| 12197 | WLAN_MODULE_NAME, |
| 12198 | (int)versionReported.major, |
| 12199 | (int)versionReported.minor, |
| 12200 | (int)versionReported.version, |
| 12201 | (int)versionReported.revision); |
| 12202 | } |
| 12203 | |
| 12204 | vstatus = sme_GetWcnssSoftwareVersion(pHddCtx->hHal, |
| 12205 | versionString, |
| 12206 | sizeof(versionString)); |
| 12207 | if (!VOS_IS_STATUS_SUCCESS(vstatus)) |
| 12208 | { |
| 12209 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 12210 | "%s: unable to retrieve WCNSS software version string", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 12211 | __func__); |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 12212 | break; |
| 12213 | } |
| 12214 | |
| 12215 | pr_info("%s: WCNSS software version %s\n", |
| 12216 | WLAN_MODULE_NAME, versionString); |
Sushant Kaushik | 084f659 | 2015-09-10 13:11:56 +0530 | [diff] [blame] | 12217 | vos_mem_copy(pHddCtx->fw_Version, versionString, sizeof(versionString)); |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 12218 | |
| 12219 | vstatus = sme_GetWcnssHardwareVersion(pHddCtx->hHal, |
| 12220 | versionString, |
| 12221 | sizeof(versionString)); |
| 12222 | if (!VOS_IS_STATUS_SUCCESS(vstatus)) |
| 12223 | { |
| 12224 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 12225 | "%s: unable to retrieve WCNSS hardware version string", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 12226 | __func__); |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 12227 | break; |
| 12228 | } |
| 12229 | |
| 12230 | pr_info("%s: WCNSS hardware version %s\n", |
| 12231 | WLAN_MODULE_NAME, versionString); |
| 12232 | |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 12233 | /* 1.Check if FW version is greater than 0.1.1.0. Only then send host-FW capability exchange message |
| 12234 | 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] | 12235 | send the message only if it the riva is 1.1 |
| 12236 | minor numbers for different riva branches: |
| 12237 | 0 -> (1.0)Mainline Build |
| 12238 | 1 -> (1.1)Mainline Build |
| 12239 | 2->(1.04) Stability Build |
| 12240 | */ |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 12241 | if (((versionReported.major>0) || (versionReported.minor>1) || |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 12242 | ((versionReported.minor>=1) && (versionReported.version>=1))) |
| 12243 | && ((versionReported.major == 1) && (versionReported.minor >= 1))) |
| 12244 | fwFeatCapsMsgSupported = 1; |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 12245 | |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 12246 | if (fwFeatCapsMsgSupported) |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 12247 | { |
| 12248 | #ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE |
| 12249 | if(!pHddCtx->cfg_ini->fEnableActiveModeOffload) |
| 12250 | sme_disableFeatureCapablity(WLANACTIVE_OFFLOAD); |
| 12251 | #endif |
Ravi Joshi | d2ca7c4 | 2013-07-23 08:37:49 -0700 | [diff] [blame] | 12252 | /* Indicate if IBSS heartbeat monitoring needs to be offloaded */ |
| 12253 | if (!pHddCtx->cfg_ini->enableIbssHeartBeatOffload) |
| 12254 | { |
| 12255 | sme_disableFeatureCapablity(IBSS_HEARTBEAT_OFFLOAD); |
| 12256 | } |
| 12257 | |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 12258 | sme_featureCapsExchange(pHddCtx->hHal); |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 12259 | } |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 12260 | |
| 12261 | } while (0); |
| 12262 | |
| 12263 | } |
Neelansh Mittal | edafed2 | 2014-09-04 18:54:39 +0530 | [diff] [blame] | 12264 | void wlan_hdd_send_svc_nlink_msg(int type, void *data, int len) |
| 12265 | { |
| 12266 | struct sk_buff *skb; |
| 12267 | struct nlmsghdr *nlh; |
| 12268 | tAniMsgHdr *ani_hdr; |
Hanumantha Reddy Pothula | cf2c7ea | 2015-04-27 14:50:47 +0530 | [diff] [blame] | 12269 | int flags = GFP_KERNEL; |
Bhargav shah | 23c9494 | 2015-10-13 12:48:35 +0530 | [diff] [blame] | 12270 | void *nl_data = NULL; |
Neelansh Mittal | edafed2 | 2014-09-04 18:54:39 +0530 | [diff] [blame] | 12271 | |
Hanumantha Reddy Pothula | cf2c7ea | 2015-04-27 14:50:47 +0530 | [diff] [blame] | 12272 | if (in_interrupt() || irqs_disabled() || in_atomic()) |
| 12273 | flags = GFP_ATOMIC; |
| 12274 | |
| 12275 | skb = alloc_skb(NLMSG_SPACE(WLAN_NL_MAX_PAYLOAD), flags); |
Neelansh Mittal | edafed2 | 2014-09-04 18:54:39 +0530 | [diff] [blame] | 12276 | |
| 12277 | if(skb == NULL) { |
| 12278 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 12279 | "%s: alloc_skb failed", __func__); |
| 12280 | return; |
| 12281 | } |
| 12282 | |
| 12283 | nlh = (struct nlmsghdr *)skb->data; |
| 12284 | nlh->nlmsg_pid = 0; /* from kernel */ |
| 12285 | nlh->nlmsg_flags = 0; |
| 12286 | nlh->nlmsg_seq = 0; |
| 12287 | nlh->nlmsg_type = WLAN_NL_MSG_SVC; |
| 12288 | |
| 12289 | ani_hdr = NLMSG_DATA(nlh); |
| 12290 | ani_hdr->type = type; |
| 12291 | |
| 12292 | switch(type) { |
| 12293 | case WLAN_SVC_SAP_RESTART_IND: |
| 12294 | ani_hdr->length = 0; |
| 12295 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr))); |
| 12296 | skb_put(skb, NLMSG_SPACE(sizeof(tAniMsgHdr))); |
| 12297 | break; |
Bhargav Shah | d071591 | 2015-10-01 18:17:37 +0530 | [diff] [blame] | 12298 | case WLAN_SVC_WLAN_TP_IND: |
| 12299 | ani_hdr->length = len; |
| 12300 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr) |
| 12301 | + len)); |
| 12302 | nl_data = (char *)ani_hdr + sizeof(tAniMsgHdr); |
| 12303 | memcpy(nl_data, data, len); |
| 12304 | skb_put(skb, NLMSG_SPACE(sizeof(tAniMsgHdr) + len)); |
| 12305 | break; |
Bhargav shah | 23c9494 | 2015-10-13 12:48:35 +0530 | [diff] [blame] | 12306 | case WLAN_MSG_RPS_ENABLE_IND: |
| 12307 | ani_hdr->length = len; |
| 12308 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr) + len)); |
| 12309 | nl_data = (char *)ani_hdr + sizeof(tAniMsgHdr); |
| 12310 | memcpy(nl_data, data, len); |
| 12311 | skb_put(skb, NLMSG_SPACE(sizeof(tAniMsgHdr) + len)); |
| 12312 | break; |
Neelansh Mittal | edafed2 | 2014-09-04 18:54:39 +0530 | [diff] [blame] | 12313 | default: |
| 12314 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 12315 | "Attempt to send unknown nlink message %d", type); |
| 12316 | kfree_skb(skb); |
| 12317 | return; |
| 12318 | } |
| 12319 | |
| 12320 | nl_srv_bcast(skb); |
| 12321 | |
| 12322 | return; |
| 12323 | } |
| 12324 | |
Bhargav Shah | d071591 | 2015-10-01 18:17:37 +0530 | [diff] [blame] | 12325 | /** |
| 12326 | * hdd_request_tcp_delack() - Find the Delack value based on RX packet |
| 12327 | * @pHddCtx: Valid Global HDD context pointer |
| 12328 | * @rx_packets: Number of RX packet in perticular time |
| 12329 | * |
| 12330 | * Based on the RX packet this function calculate next value of tcp delack. |
| 12331 | * This function compare rx packet value to high and low threshold limit. |
| 12332 | * |
| 12333 | * Return: void |
| 12334 | */ |
| 12335 | void hdd_request_tcp_delack(hdd_context_t *pHddCtx, uint64_t rx_packets) |
| 12336 | { |
| 12337 | /* average of rx_packets and prev_rx is taken so that |
| 12338 | bus width doesnot fluctuate much */ |
| 12339 | uint64_t temp_rx = (rx_packets + pHddCtx->prev_rx)/2; |
| 12340 | TP_IND_TYPE next_rx_level = pHddCtx->cur_rx_level; |
Neelansh Mittal | edafed2 | 2014-09-04 18:54:39 +0530 | [diff] [blame] | 12341 | |
Bhargav Shah | d071591 | 2015-10-01 18:17:37 +0530 | [diff] [blame] | 12342 | pHddCtx->prev_rx = rx_packets; |
| 12343 | if (temp_rx > pHddCtx->cfg_ini->tcpDelAckThresholdHigh) |
| 12344 | next_rx_level = TP_IND_HIGH; |
| 12345 | else if (temp_rx <= pHddCtx->cfg_ini->tcpDelAckThresholdLow) |
| 12346 | next_rx_level = TP_IND_LOW; |
| 12347 | |
| 12348 | hdd_set_delack_value(pHddCtx, next_rx_level); |
| 12349 | } |
| 12350 | |
| 12351 | #define HDD_BW_GET_DIFF(x, y) ((x) >= (y) ? (x) - (y) : (ULONG_MAX - (y) + (x))) |
| 12352 | |
| 12353 | /** |
| 12354 | * hdd_tcp_delack_compute_function() - get link status |
| 12355 | * @priv: Valid Global HDD context pointer |
| 12356 | * |
| 12357 | * This function find number of RX packet during timer life span. |
| 12358 | * It request tcp delack with number of RX packet and re-configure delack timer |
| 12359 | * for tcpDelAckComputeInterval timer interval. |
| 12360 | * |
| 12361 | * Return: void |
| 12362 | */ |
| 12363 | void hdd_tcp_delack_compute_function(void *priv) |
| 12364 | { |
| 12365 | hdd_context_t *pHddCtx = (hdd_context_t *)priv; |
| 12366 | hdd_adapter_t *pAdapter = NULL; |
| 12367 | v_U32_t rx_packets = 0; |
| 12368 | hdd_adapter_list_node_t *pAdapterNode = NULL; |
| 12369 | VOS_STATUS status = 0; |
| 12370 | |
| 12371 | for (status = hdd_get_front_adapter(pHddCtx, &pAdapterNode); |
| 12372 | NULL != pAdapterNode && VOS_STATUS_SUCCESS == status; |
| 12373 | status = hdd_get_next_adapter(pHddCtx, pAdapterNode, &pAdapterNode)) { |
| 12374 | if ((pAdapter = pAdapterNode->pAdapter) == NULL) |
| 12375 | continue; |
| 12376 | |
| 12377 | rx_packets += HDD_BW_GET_DIFF(pAdapter->stats.rx_packets, |
| 12378 | pAdapter->prev_rx_packets); |
| 12379 | pAdapter->prev_rx_packets = pAdapter->stats.rx_packets; |
| 12380 | } |
| 12381 | |
| 12382 | hdd_request_tcp_delack(pHddCtx, rx_packets); |
| 12383 | |
| 12384 | vos_timer_start(&pHddCtx->delack_timer, |
| 12385 | pHddCtx->cfg_ini->tcpDelAckComputeInterval); |
| 12386 | } |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 12387 | |
| 12388 | /**--------------------------------------------------------------------------- |
| 12389 | |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 12390 | \brief hdd_is_5g_supported() - HDD function to know if hardware supports 5GHz |
| 12391 | |
| 12392 | \param - pHddCtx - Pointer to the hdd context |
| 12393 | |
| 12394 | \return - true if hardware supports 5GHz |
| 12395 | |
| 12396 | --------------------------------------------------------------------------*/ |
Vinay Krishna Eranna | facf5e2 | 2014-02-24 13:16:25 +0530 | [diff] [blame] | 12397 | boolean hdd_is_5g_supported(hdd_context_t * pHddCtx) |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 12398 | { |
| 12399 | /* If wcnss_wlan_iris_xo_mode() returns WCNSS_XO_48MHZ(1); |
| 12400 | * then hardware support 5Ghz. |
| 12401 | */ |
| 12402 | if (WCNSS_XO_48MHZ == wcnss_wlan_iris_xo_mode()) |
| 12403 | { |
Ratheesh S P | 36dbc93 | 2015-08-07 14:28:57 +0530 | [diff] [blame] | 12404 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Hardware supports 5Ghz", __func__); |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 12405 | return true; |
| 12406 | } |
| 12407 | else |
| 12408 | { |
Ratheesh S P | 36dbc93 | 2015-08-07 14:28:57 +0530 | [diff] [blame] | 12409 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Hardware doesn't supports 5Ghz", |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 12410 | __func__); |
| 12411 | return false; |
| 12412 | } |
| 12413 | } |
| 12414 | |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 12415 | /**--------------------------------------------------------------------------- |
| 12416 | |
| 12417 | \brief hdd_generate_iface_mac_addr_auto() - HDD Mac Interface Auto |
| 12418 | generate function |
| 12419 | |
| 12420 | This is generate the random mac address for WLAN interface |
| 12421 | |
| 12422 | \param - pHddCtx - Pointer to HDD context |
| 12423 | idx - Start interface index to get auto |
| 12424 | generated mac addr. |
| 12425 | mac_addr - Mac address |
| 12426 | |
| 12427 | \return - 0 for success, < 0 for failure |
| 12428 | |
| 12429 | --------------------------------------------------------------------------*/ |
| 12430 | |
| 12431 | static int hdd_generate_iface_mac_addr_auto(hdd_context_t *pHddCtx, |
| 12432 | int idx, v_MACADDR_t mac_addr) |
| 12433 | { |
| 12434 | int i; |
| 12435 | unsigned int serialno; |
| 12436 | serialno = wcnss_get_serial_number(); |
| 12437 | |
| 12438 | if (0 != serialno) |
| 12439 | { |
| 12440 | /* MAC address has 3 bytes of OUI so we have a maximum of 3 |
| 12441 | bytes of the serial number that can be used to generate |
| 12442 | the other 3 bytes of the MAC address. Mask off all but |
| 12443 | the lower 3 bytes (this will also make sure we don't |
| 12444 | overflow in the next step) */ |
| 12445 | serialno &= 0x00FFFFFF; |
| 12446 | |
| 12447 | /* we need a unique address for each session */ |
| 12448 | serialno *= VOS_MAX_CONCURRENCY_PERSONA; |
| 12449 | |
| 12450 | /* autogen other Mac addresses */ |
| 12451 | for (i = idx; i < VOS_MAX_CONCURRENCY_PERSONA; i++) |
| 12452 | { |
| 12453 | /* start with the entire default address */ |
| 12454 | pHddCtx->cfg_ini->intfMacAddr[i] = mac_addr; |
| 12455 | /* then replace the lower 3 bytes */ |
| 12456 | pHddCtx->cfg_ini->intfMacAddr[i].bytes[3] = (serialno >> 16) & 0xFF; |
| 12457 | pHddCtx->cfg_ini->intfMacAddr[i].bytes[4] = (serialno >> 8) & 0xFF; |
| 12458 | pHddCtx->cfg_ini->intfMacAddr[i].bytes[5] = serialno & 0xFF; |
| 12459 | |
Nachiket Kukade | de2e24f | 2017-09-25 16:24:27 +0530 | [diff] [blame] | 12460 | if (0 == memcmp(&pHddCtx->cfg_ini->intfMacAddr[i].bytes[0], |
| 12461 | &mac_addr.bytes[0], VOS_MAC_ADDR_SIZE)) |
| 12462 | pHddCtx->cfg_ini->intfMacAddr[i].bytes[5] += |
| 12463 | VOS_MAX_CONCURRENCY_PERSONA; |
| 12464 | |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 12465 | serialno++; |
| 12466 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 12467 | "%s: Derived Mac Addr: " |
| 12468 | MAC_ADDRESS_STR, __func__, |
| 12469 | MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[i].bytes)); |
| 12470 | } |
| 12471 | |
| 12472 | } |
| 12473 | else |
| 12474 | { |
| 12475 | hddLog(LOGE, FL("Failed to Get Serial NO")); |
| 12476 | return -1; |
| 12477 | } |
| 12478 | return 0; |
| 12479 | } |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 12480 | |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 12481 | int wlan_hdd_mon_open(hdd_context_t *pHddCtx) |
| 12482 | { |
| 12483 | VOS_STATUS status; |
| 12484 | v_CONTEXT_t pVosContext= NULL; |
| 12485 | hdd_adapter_t *pAdapter= NULL; |
| 12486 | |
| 12487 | pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL); |
| 12488 | |
| 12489 | if (NULL == pVosContext) |
| 12490 | { |
| 12491 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 12492 | "%s: Trying to open VOSS without a PreOpen", __func__); |
| 12493 | VOS_ASSERT(0); |
| 12494 | return VOS_STATUS_E_FAILURE; |
| 12495 | } |
| 12496 | |
| 12497 | status = vos_nv_open(); |
| 12498 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 12499 | { |
| 12500 | /* NV module cannot be initialized */ |
| 12501 | hddLog( VOS_TRACE_LEVEL_FATAL, |
| 12502 | "%s: vos_nv_open failed", __func__); |
| 12503 | return VOS_STATUS_E_FAILURE; |
| 12504 | } |
| 12505 | |
| 12506 | status = vos_init_wiphy_from_nv_bin(); |
| 12507 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 12508 | { |
| 12509 | /* NV module cannot be initialized */ |
| 12510 | hddLog( VOS_TRACE_LEVEL_FATAL, |
| 12511 | "%s: vos_init_wiphy failed", __func__); |
| 12512 | goto err_vos_nv_close; |
| 12513 | } |
| 12514 | |
| 12515 | status = vos_open( &pVosContext, pHddCtx->parent_dev); |
| 12516 | if ( !VOS_IS_STATUS_SUCCESS( status )) |
| 12517 | { |
| 12518 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: vos_open failed", __func__); |
| 12519 | goto err_vos_nv_close; |
| 12520 | } |
| 12521 | |
| 12522 | status = vos_mon_start( pVosContext ); |
| 12523 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 12524 | { |
| 12525 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: vos_start failed",__func__); |
| 12526 | goto err_vosclose; |
| 12527 | } |
| 12528 | |
| 12529 | WLANTL_SetMonRxCbk( pVosContext, hdd_rx_packet_monitor_cbk ); |
| 12530 | WDA_featureCapsExchange(pVosContext); |
| 12531 | wcnss_wlan_set_drvdata(pHddCtx->parent_dev, pHddCtx); |
| 12532 | |
| 12533 | pAdapter = hdd_open_adapter( pHddCtx, WLAN_HDD_MONITOR, "wlan%d", |
| 12534 | wlan_hdd_get_intf_addr(pHddCtx), FALSE ); |
| 12535 | if( pAdapter == NULL ) |
| 12536 | { |
| 12537 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: hdd_open_adapter failed", __func__); |
| 12538 | goto err_close_adapter; |
| 12539 | } |
| 12540 | |
| 12541 | //Initialize the nlink service |
| 12542 | if(nl_srv_init() != 0) |
| 12543 | { |
| 12544 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: nl_srv_init failed", __func__); |
| 12545 | goto err_close_adapter; |
| 12546 | } |
| 12547 | return VOS_STATUS_SUCCESS; |
| 12548 | |
| 12549 | err_close_adapter: |
| 12550 | hdd_close_all_adapters( pHddCtx ); |
| 12551 | vos_mon_stop( pVosContext ); |
| 12552 | err_vosclose: |
| 12553 | status = vos_sched_close( pVosContext ); |
| 12554 | if (!VOS_IS_STATUS_SUCCESS(status)) { |
| 12555 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, |
| 12556 | "%s: Failed to close VOSS Scheduler", __func__); |
| 12557 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( status ) ); |
| 12558 | } |
| 12559 | vos_close(pVosContext ); |
| 12560 | |
| 12561 | err_vos_nv_close: |
| 12562 | vos_nv_close(); |
| 12563 | |
| 12564 | return status; |
| 12565 | } |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 12566 | /**--------------------------------------------------------------------------- |
| 12567 | |
Mihir Shete | fc7ff5b | 2014-01-27 11:30:05 +0530 | [diff] [blame] | 12568 | \brief hdd_11d_scan_done - callback to be executed when 11d scan is |
| 12569 | completed to flush out the scan results |
| 12570 | |
| 12571 | 11d scan is done during driver load and is a passive scan on all |
| 12572 | channels supported by the device, 11d scans may find some APs on |
| 12573 | frequencies which are forbidden to be used in the regulatory domain |
| 12574 | the device is operating in. If these APs are notified to the supplicant |
| 12575 | it may try to connect to these APs, thus flush out all the scan results |
| 12576 | which are present in SME after 11d scan is done. |
| 12577 | |
| 12578 | \return - eHalStatus |
| 12579 | |
| 12580 | --------------------------------------------------------------------------*/ |
| 12581 | static eHalStatus hdd_11d_scan_done(tHalHandle halHandle, void *pContext, |
| 12582 | tANI_U32 scanId, eCsrScanStatus status) |
| 12583 | { |
| 12584 | ENTER(); |
| 12585 | |
| 12586 | sme_ScanFlushResult(halHandle, 0); |
| 12587 | |
| 12588 | EXIT(); |
| 12589 | |
| 12590 | return eHAL_STATUS_SUCCESS; |
| 12591 | } |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 12592 | /**--------------------------------------------------------------------------- |
| 12593 | |
| 12594 | \brief hdd_init_frame_logging_done - callback to be executed when mgmt frame |
| 12595 | logging is completed successfully. |
| 12596 | |
| 12597 | \return - None |
| 12598 | |
| 12599 | --------------------------------------------------------------------------*/ |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 12600 | void hdd_init_frame_logging_done(void *fwlogInitCbContext, tAniLoggingInitRsp *pRsp) |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 12601 | { |
Siddharth Bhal | d1be97f | 2015-05-27 22:39:59 +0530 | [diff] [blame] | 12602 | hdd_context_t* pHddCtx = (hdd_context_t*)fwlogInitCbContext; |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 12603 | |
| 12604 | if (NULL == pHddCtx) |
| 12605 | { |
| 12606 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 12607 | "%s: HDD context is NULL",__func__); |
| 12608 | return; |
| 12609 | } |
| 12610 | |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 12611 | if ((pRsp->status == VOS_STATUS_SUCCESS) && |
Mahesh A Saptasagar | fabb1a0 | 2015-06-29 12:17:04 +0530 | [diff] [blame] | 12612 | (TRUE == pHddCtx->cfg_ini->enableMgmtLogging)) |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 12613 | { |
| 12614 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Mgmt Frame Logging init successful")); |
| 12615 | pHddCtx->mgmt_frame_logging = TRUE; |
| 12616 | } |
| 12617 | else |
| 12618 | { |
| 12619 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Mgmt Frame Logging init not success")); |
| 12620 | pHddCtx->mgmt_frame_logging = FALSE; |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 12621 | return; |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 12622 | } |
| 12623 | |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 12624 | /*Check feature supported by FW*/ |
| 12625 | if(TRUE == sme_IsFeatureSupportedByFW(MEMORY_DUMP_SUPPORTED)) |
| 12626 | { |
| 12627 | //Store fwr mem dump size given by firmware. |
| 12628 | wlan_store_fwr_mem_dump_size(pRsp->fw_mem_dump_max_size); |
| 12629 | } |
| 12630 | else |
| 12631 | { |
| 12632 | wlan_store_fwr_mem_dump_size(0); |
| 12633 | } |
| 12634 | |
| 12635 | |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 12636 | } |
| 12637 | /**--------------------------------------------------------------------------- |
| 12638 | |
| 12639 | \brief hdd_init_frame_logging - function to initialize frame logging. |
| 12640 | Currently only Mgmt Frames are logged in both TX |
| 12641 | and Rx direction and are sent to userspace |
| 12642 | application using logger thread when queried. |
| 12643 | |
| 12644 | \return - None |
| 12645 | |
| 12646 | --------------------------------------------------------------------------*/ |
Siddharth Bhal | d1be97f | 2015-05-27 22:39:59 +0530 | [diff] [blame] | 12647 | void hdd_init_frame_logging(hdd_context_t* pHddCtx) |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 12648 | { |
| 12649 | eHalStatus halStatus = eHAL_STATUS_FAILURE; |
Sreelakshmi Konamki | d8784d9 | 2016-04-14 14:59:13 +0530 | [diff] [blame] | 12650 | tSirFWLoggingInitParam wlanFWLoggingInitParam = {0}; |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 12651 | |
Siddharth Bhal | d1be97f | 2015-05-27 22:39:59 +0530 | [diff] [blame] | 12652 | if (TRUE != sme_IsFeatureSupportedByFW(MGMT_FRAME_LOGGING) && |
| 12653 | TRUE != sme_IsFeatureSupportedByFW(LOGGING_ENHANCEMENT)) |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 12654 | { |
| 12655 | hddLog(VOS_TRACE_LEVEL_INFO, FL("MGMT_FRAME_LOGGING not supp by FW")); |
| 12656 | return; |
| 12657 | } |
| 12658 | |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 12659 | 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] | 12660 | pHddCtx->cfg_ini->enableFWLogging?"FW Log,":"", |
| 12661 | pHddCtx->cfg_ini->enableContFWLogging ? "Cont FW log,":"", |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 12662 | pHddCtx->cfg_ini->enableMgmtLogging ? "Mgmt Pkt Log":"", |
| 12663 | pHddCtx->cfg_ini->enableFwrMemDump ? "Fw Mem dump":""); |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 12664 | |
Siddharth Bhal | d1be97f | 2015-05-27 22:39:59 +0530 | [diff] [blame] | 12665 | if (pHddCtx->cfg_ini->enableFWLogging || |
| 12666 | pHddCtx->cfg_ini->enableContFWLogging) |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 12667 | { |
Sreelakshmi Konamki | d8784d9 | 2016-04-14 14:59:13 +0530 | [diff] [blame] | 12668 | wlanFWLoggingInitParam.enableFlag |= WLAN_QXDM_LOG_EN; |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 12669 | } |
| 12670 | |
Sushant Kaushik | 4680490 | 2015-07-08 14:46:03 +0530 | [diff] [blame] | 12671 | if (pHddCtx->cfg_ini->enableMgmtLogging) |
| 12672 | { |
Sreelakshmi Konamki | d8784d9 | 2016-04-14 14:59:13 +0530 | [diff] [blame] | 12673 | wlanFWLoggingInitParam.enableFlag |= WLAN_FRAME_LOG_EN; |
Sushant Kaushik | 4680490 | 2015-07-08 14:46:03 +0530 | [diff] [blame] | 12674 | } |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 12675 | if (pHddCtx->cfg_ini->enableBMUHWtracing) |
| 12676 | { |
Sreelakshmi Konamki | d8784d9 | 2016-04-14 14:59:13 +0530 | [diff] [blame] | 12677 | wlanFWLoggingInitParam.enableFlag |= WLAN_BMUHW_TRACE_LOG_EN; |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 12678 | } |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 12679 | if(pHddCtx->cfg_ini->enableFwrMemDump && |
| 12680 | (TRUE == sme_IsFeatureSupportedByFW(MEMORY_DUMP_SUPPORTED))) |
| 12681 | { |
Sreelakshmi Konamki | d8784d9 | 2016-04-14 14:59:13 +0530 | [diff] [blame] | 12682 | wlanFWLoggingInitParam.enableFlag |= WLAN_FW_MEM_DUMP_EN; |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 12683 | } |
Sreelakshmi Konamki | d8784d9 | 2016-04-14 14:59:13 +0530 | [diff] [blame] | 12684 | if( wlanFWLoggingInitParam.enableFlag == 0 ) |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 12685 | { |
| 12686 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Logging not enabled", __func__); |
| 12687 | return; |
| 12688 | } |
Sreelakshmi Konamki | d8784d9 | 2016-04-14 14:59:13 +0530 | [diff] [blame] | 12689 | wlanFWLoggingInitParam.frameType = WLAN_FRAME_LOGGING_FRAMETYPE_MGMT; |
| 12690 | wlanFWLoggingInitParam.frameSize = WLAN_MGMT_LOGGING_FRAMESIZE_128BYTES; |
| 12691 | wlanFWLoggingInitParam.bufferMode = WLAN_FRAME_LOGGING_BUFFERMODE_CIRCULAR; |
| 12692 | wlanFWLoggingInitParam.continuousFrameLogging = |
Siddharth Bhal | d1be97f | 2015-05-27 22:39:59 +0530 | [diff] [blame] | 12693 | pHddCtx->cfg_ini->enableContFWLogging; |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 12694 | |
Sreelakshmi Konamki | d8784d9 | 2016-04-14 14:59:13 +0530 | [diff] [blame] | 12695 | wlanFWLoggingInitParam.enableFlag &= ~WLAN_DPU_TXP_LOG_EN; |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 12696 | |
Sreelakshmi Konamki | d8784d9 | 2016-04-14 14:59:13 +0530 | [diff] [blame] | 12697 | wlanFWLoggingInitParam.minLogBufferSize = |
Siddharth Bhal | d1be97f | 2015-05-27 22:39:59 +0530 | [diff] [blame] | 12698 | pHddCtx->cfg_ini->minLoggingBufferSize; |
Sreelakshmi Konamki | d8784d9 | 2016-04-14 14:59:13 +0530 | [diff] [blame] | 12699 | wlanFWLoggingInitParam.maxLogBufferSize = |
Siddharth Bhal | d1be97f | 2015-05-27 22:39:59 +0530 | [diff] [blame] | 12700 | pHddCtx->cfg_ini->maxLoggingBufferSize; |
Sreelakshmi Konamki | d8784d9 | 2016-04-14 14:59:13 +0530 | [diff] [blame] | 12701 | wlanFWLoggingInitParam.fwlogInitCallback = hdd_init_frame_logging_done; |
| 12702 | wlanFWLoggingInitParam.fwlogInitCbContext= pHddCtx; |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 12703 | |
Sreelakshmi Konamki | d8784d9 | 2016-04-14 14:59:13 +0530 | [diff] [blame] | 12704 | halStatus = sme_InitMgmtFrameLogging(pHddCtx->hHal, &wlanFWLoggingInitParam); |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 12705 | |
| 12706 | if (eHAL_STATUS_SUCCESS != halStatus) |
| 12707 | { |
Sreelakshmi Konamki | d8784d9 | 2016-04-14 14:59:13 +0530 | [diff] [blame] | 12708 | hddLog(LOGE, FL("sme_InitMgmtFrameLogging failed, returned %d"), |
| 12709 | halStatus); |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 12710 | } |
| 12711 | |
| 12712 | return; |
| 12713 | } |
Mihir Shete | fc7ff5b | 2014-01-27 11:30:05 +0530 | [diff] [blame] | 12714 | |
Bhargav shah | 23c9494 | 2015-10-13 12:48:35 +0530 | [diff] [blame] | 12715 | static void hdd_dp_util_send_rps_ind(hdd_context_t *hdd_ctxt) |
| 12716 | { |
| 12717 | hdd_adapter_t *adapter; |
| 12718 | hdd_adapter_list_node_t *adapter_node, *next; |
| 12719 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 12720 | struct wlan_rps_data rps_data; |
| 12721 | int count; |
| 12722 | |
| 12723 | if(!hdd_ctxt->cfg_ini->rps_mask) |
| 12724 | { |
| 12725 | return; |
| 12726 | } |
| 12727 | |
| 12728 | for (count=0; count < WLAN_SVC_IFACE_NUM_QUEUES; count++) |
| 12729 | { |
| 12730 | rps_data.cpu_map[count] = hdd_ctxt->cfg_ini->rps_mask; |
| 12731 | } |
| 12732 | |
| 12733 | rps_data.num_queues = WLAN_SVC_IFACE_NUM_QUEUES; |
| 12734 | |
| 12735 | hddLog(LOG1, FL("0x%x 0x%x 0x%x 0x%x 0x%x 0x%x"), |
| 12736 | rps_data.cpu_map[0], rps_data.cpu_map[1],rps_data.cpu_map[2], |
| 12737 | rps_data.cpu_map[3], rps_data.cpu_map[4], rps_data.cpu_map[5]); |
| 12738 | |
| 12739 | status = hdd_get_front_adapter (hdd_ctxt, &adapter_node); |
| 12740 | |
| 12741 | while (NULL != adapter_node && VOS_STATUS_SUCCESS == status) |
| 12742 | { |
| 12743 | adapter = adapter_node->pAdapter; |
| 12744 | if (NULL != adapter) { |
| 12745 | strlcpy(rps_data.ifname, adapter->dev->name, |
| 12746 | sizeof(rps_data.ifname)); |
| 12747 | wlan_hdd_send_svc_nlink_msg(WLAN_MSG_RPS_ENABLE_IND, |
| 12748 | (void *)&rps_data,sizeof(rps_data)); |
| 12749 | } |
| 12750 | status = hdd_get_next_adapter (hdd_ctxt, adapter_node, &next); |
| 12751 | adapter_node = next; |
| 12752 | } |
| 12753 | } |
| 12754 | |
Masti, Narayanraddi | 2637846 | 2016-01-05 18:20:28 +0530 | [diff] [blame] | 12755 | void wlan_hdd_schedule_defer_scan(struct work_struct *work) |
| 12756 | { |
| 12757 | scan_context_t *scan_ctx = |
| 12758 | container_of(work, scan_context_t, scan_work.work); |
| 12759 | |
| 12760 | if (NULL == scan_ctx) |
| 12761 | { |
| 12762 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 12763 | FL("scan_ctx is NULL")); |
| 12764 | return; |
| 12765 | } |
| 12766 | |
| 12767 | if (unlikely(TDLS_CTX_MAGIC != scan_ctx->magic)) |
| 12768 | return; |
| 12769 | |
| 12770 | scan_ctx->attempt++; |
| 12771 | |
| 12772 | wlan_hdd_cfg80211_scan(scan_ctx->wiphy, |
| 12773 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 12774 | scan_ctx->dev, |
| 12775 | #endif |
| 12776 | scan_ctx->scan_request); |
| 12777 | } |
| 12778 | |
| 12779 | int wlan_hdd_copy_defer_scan_context(hdd_context_t *pHddCtx, |
| 12780 | struct wiphy *wiphy, |
| 12781 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 12782 | struct net_device *dev, |
| 12783 | #endif |
| 12784 | struct cfg80211_scan_request *request) |
| 12785 | { |
| 12786 | scan_context_t *scan_ctx; |
| 12787 | |
| 12788 | ENTER(); |
| 12789 | if (0 != (wlan_hdd_validate_context(pHddCtx))) |
| 12790 | { |
| 12791 | return -1; |
| 12792 | } |
| 12793 | |
| 12794 | scan_ctx = &pHddCtx->scan_ctxt; |
| 12795 | |
| 12796 | scan_ctx->wiphy = wiphy; |
| 12797 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 12798 | scan_ctx->dev = dev; |
| 12799 | #endif |
| 12800 | |
| 12801 | scan_ctx->scan_request = request; |
| 12802 | |
| 12803 | EXIT(); |
| 12804 | return 0; |
| 12805 | } |
| 12806 | |
| 12807 | void wlan_hdd_defer_scan_init_work(hdd_context_t *pHddCtx, |
| 12808 | struct wiphy *wiphy, |
| 12809 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 12810 | struct net_device *dev, |
| 12811 | #endif |
| 12812 | struct cfg80211_scan_request *request, |
| 12813 | unsigned long delay) |
| 12814 | { |
| 12815 | if (TDLS_CTX_MAGIC != pHddCtx->scan_ctxt.magic) |
| 12816 | { |
| 12817 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 12818 | wlan_hdd_copy_defer_scan_context(pHddCtx, wiphy, dev, request); |
| 12819 | #else |
| 12820 | wlan_hdd_copy_defer_scan_context(pHddCtx, wiphy, request); |
| 12821 | #endif |
| 12822 | pHddCtx->scan_ctxt.attempt = 0; |
| 12823 | pHddCtx->scan_ctxt.magic = TDLS_CTX_MAGIC; |
| 12824 | } |
| 12825 | schedule_delayed_work(&pHddCtx->scan_ctxt.scan_work, delay); |
| 12826 | } |
| 12827 | |
| 12828 | void wlan_hdd_init_deinit_defer_scan_context(scan_context_t *scan_ctx) |
| 12829 | { |
| 12830 | scan_ctx->magic = 0; |
| 12831 | scan_ctx->attempt = 0; |
| 12832 | scan_ctx->reject = 0; |
| 12833 | scan_ctx->scan_request = NULL; |
| 12834 | |
| 12835 | return; |
| 12836 | } |
| 12837 | |
Mihir Shete | fc7ff5b | 2014-01-27 11:30:05 +0530 | [diff] [blame] | 12838 | /**--------------------------------------------------------------------------- |
| 12839 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12840 | \brief hdd_wlan_startup() - HDD init function |
| 12841 | |
| 12842 | This is the driver startup code executed once a WLAN device has been detected |
| 12843 | |
| 12844 | \param - dev - Pointer to the underlying device |
| 12845 | |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 12846 | \return - 0 for success, < 0 for failure |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12847 | |
| 12848 | --------------------------------------------------------------------------*/ |
| 12849 | |
| 12850 | int hdd_wlan_startup(struct device *dev ) |
| 12851 | { |
| 12852 | VOS_STATUS status; |
| 12853 | hdd_adapter_t *pAdapter = NULL; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 12854 | hdd_adapter_t *pP2pAdapter = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12855 | hdd_context_t *pHddCtx = NULL; |
| 12856 | v_CONTEXT_t pVosContext= NULL; |
| 12857 | #ifdef WLAN_BTAMP_FEATURE |
| 12858 | VOS_STATUS vStatus = VOS_STATUS_SUCCESS; |
| 12859 | WLANBAP_ConfigType btAmpConfig; |
| 12860 | hdd_config_t *pConfig; |
| 12861 | #endif |
| 12862 | int ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12863 | struct wiphy *wiphy; |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 12864 | v_MACADDR_t mac_addr; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12865 | |
| 12866 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12867 | /* |
| 12868 | * cfg80211: wiphy allocation |
| 12869 | */ |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 12870 | wiphy = wlan_hdd_cfg80211_wiphy_alloc(sizeof(hdd_context_t)) ; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12871 | |
| 12872 | if(wiphy == NULL) |
| 12873 | { |
| 12874 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: cfg80211 init failed", __func__); |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 12875 | return -EIO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12876 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12877 | pHddCtx = wiphy_priv(wiphy); |
| 12878 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12879 | //Initialize the adapter context to zeros. |
| 12880 | vos_mem_zero(pHddCtx, sizeof( hdd_context_t )); |
| 12881 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12882 | pHddCtx->wiphy = wiphy; |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 12883 | hdd_prevent_suspend(WIFI_POWER_EVENT_WAKELOCK_DRIVER_INIT); |
Mihir Shete | 1815629 | 2014-03-11 15:38:30 +0530 | [diff] [blame] | 12884 | pHddCtx->isLoadUnloadInProgress = WLAN_HDD_LOAD_IN_PROGRESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12885 | |
| 12886 | vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, TRUE); |
| 12887 | |
Siddharth Bhal | cd92b78 | 2015-06-29 12:25:40 +0530 | [diff] [blame] | 12888 | /* register for riva power on lock to platform driver |
| 12889 | * Locking power early to ensure FW doesn't reset by kernel while |
| 12890 | * host driver is busy initializing itself */ |
| 12891 | if (req_riva_power_on_lock("wlan")) |
| 12892 | { |
| 12893 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: req riva power on lock failed", |
| 12894 | __func__); |
| 12895 | goto err_free_hdd_context; |
| 12896 | } |
| 12897 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12898 | /*Get vos context here bcoz vos_open requires it*/ |
| 12899 | pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL); |
| 12900 | |
Madan Mohan Koyyalamudi | 0b78e15 | 2012-11-28 15:46:51 -0800 | [diff] [blame] | 12901 | if(pVosContext == NULL) |
| 12902 | { |
| 12903 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Failed vos_get_global_context",__func__); |
| 12904 | goto err_free_hdd_context; |
| 12905 | } |
| 12906 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12907 | //Save the Global VOSS context in adapter context for future. |
| 12908 | pHddCtx->pvosContext = pVosContext; |
| 12909 | |
| 12910 | //Save the adapter context in global context for future. |
| 12911 | ((VosContextType*)(pVosContext))->pHDDContext = (v_VOID_t*)pHddCtx; |
| 12912 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12913 | pHddCtx->parent_dev = dev; |
Sreelakshmi Konamki | f0646d5 | 2016-12-09 12:35:31 +0530 | [diff] [blame] | 12914 | pHddCtx->last_scan_reject_session_id = 0xFF; |
| 12915 | pHddCtx->last_scan_reject_reason = 0; |
Sreelakshmi Konamki | 20ebed9 | 2016-10-27 12:13:30 +0530 | [diff] [blame] | 12916 | pHddCtx->last_scan_reject_timestamp = 0; |
Abhishek Singh | e4b1256 | 2017-06-20 16:53:39 +0530 | [diff] [blame] | 12917 | pHddCtx->scan_reject_cnt = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12918 | |
| 12919 | init_completion(&pHddCtx->full_pwr_comp_var); |
| 12920 | init_completion(&pHddCtx->standby_comp_var); |
| 12921 | init_completion(&pHddCtx->req_bmps_comp_var); |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 12922 | init_completion(&pHddCtx->scan_info.scan_req_completion_event); |
Madan Mohan Koyyalamudi | f4e8100 | 2012-11-13 10:46:38 -0800 | [diff] [blame] | 12923 | init_completion(&pHddCtx->scan_info.abortscan_event_var); |
Kiet Lam | 46b8e4e | 2013-11-06 21:49:53 +0530 | [diff] [blame] | 12924 | init_completion(&pHddCtx->wiphy_channel_update_event); |
Arun Kumar Khandavalli | e0b046d | 2014-03-01 21:54:25 +0530 | [diff] [blame] | 12925 | init_completion(&pHddCtx->ssr_comp_var); |
Mahesh A Saptasagar | 67ab922 | 2015-10-21 15:38:41 +0530 | [diff] [blame] | 12926 | init_completion(&pHddCtx->mc_sus_event_var); |
| 12927 | init_completion(&pHddCtx->tx_sus_event_var); |
| 12928 | init_completion(&pHddCtx->rx_sus_event_var); |
| 12929 | |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 12930 | |
mukul sharma | 4bd8d2e | 2015-08-13 20:33:25 +0530 | [diff] [blame] | 12931 | hdd_init_ll_stats_ctx(pHddCtx); |
Anurag Chouhan | 6ee8154 | 2017-02-09 18:09:27 +0530 | [diff] [blame] | 12932 | hdd_init_nud_stats_ctx(pHddCtx); |
mukul sharma | 4bd8d2e | 2015-08-13 20:33:25 +0530 | [diff] [blame] | 12933 | |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 12934 | #ifdef CONFIG_ENABLE_LINUX_REG |
Amar Singhal | fddc28c | 2013-09-05 13:03:40 -0700 | [diff] [blame] | 12935 | init_completion(&pHddCtx->linux_reg_req); |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 12936 | #else |
| 12937 | init_completion(&pHddCtx->driver_crda_req); |
| 12938 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12939 | |
Padma, Santhosh Kumar | a1aa4a3 | 2015-06-19 19:00:46 +0530 | [diff] [blame] | 12940 | #ifdef WLAN_FEATURE_EXTSCAN |
| 12941 | init_completion(&pHddCtx->ext_scan_context.response_event); |
| 12942 | #endif /* WLAN_FEATURE_EXTSCAN */ |
| 12943 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 12944 | spin_lock_init(&pHddCtx->schedScan_lock); |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 12945 | vos_spin_lock_init(&pHddCtx->sap_update_info_lock); |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 12946 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12947 | hdd_list_init( &pHddCtx->hddAdapters, MAX_NUMBER_OF_ADAPTERS ); |
| 12948 | |
Padma, Santhosh Kumar | 9cd3833 | 2015-11-17 12:18:10 +0530 | [diff] [blame] | 12949 | vos_init_delayed_work(&pHddCtx->spoof_mac_addr_work, |
| 12950 | hdd_processSpoofMacAddrRequest); |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 12951 | vos_init_work(&pHddCtx->sap_start_work, hdd_sap_restart_handle); |
Abhishek Singh | 78c691f | 2017-11-30 13:48:44 +0530 | [diff] [blame] | 12952 | vos_init_delayed_work(&pHddCtx->ecsa_chan_change_work, |
| 12953 | hdd_force_scc_with_ecsa_handle); |
Padma, Santhosh Kumar | 9cd3833 | 2015-11-17 12:18:10 +0530 | [diff] [blame] | 12954 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 12955 | #ifdef FEATURE_WLAN_TDLS |
| 12956 | /* tdls_lock is initialized before an hdd_open_adapter ( which is |
| 12957 | * invoked by other instances also) to protect the concurrent |
| 12958 | * access for the Adapters by TDLS module. |
| 12959 | */ |
| 12960 | mutex_init(&pHddCtx->tdls_lock); |
| 12961 | #endif |
Siddharth Bhal | 7697221 | 2014-10-15 16:22:51 +0530 | [diff] [blame] | 12962 | mutex_init(&pHddCtx->spoofMacAddr.macSpoofingLock); |
Mukul Sharma | 1fd6efd | 2015-02-14 00:29:14 +0530 | [diff] [blame] | 12963 | mutex_init(&pHddCtx->wmmLock); |
| 12964 | |
Srinivas Girigowda | 8bf64cb | 2015-09-30 19:50:09 +0530 | [diff] [blame] | 12965 | hdd_init_offloaded_packets_ctx(pHddCtx); |
Agarwal Ashish | 1f42287 | 2014-07-22 00:11:55 +0530 | [diff] [blame] | 12966 | /* By default Strict Regulatory For FCC should be false */ |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 12967 | |
Agarwal Ashish | 1f42287 | 2014-07-22 00:11:55 +0530 | [diff] [blame] | 12968 | pHddCtx->nEnableStrictRegulatoryForFCC = FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12969 | // Load all config first as TL config is needed during vos_open |
| 12970 | pHddCtx->cfg_ini = (hdd_config_t*) kmalloc(sizeof(hdd_config_t), GFP_KERNEL); |
| 12971 | if(pHddCtx->cfg_ini == NULL) |
| 12972 | { |
| 12973 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Failed kmalloc hdd_config_t",__func__); |
| 12974 | goto err_free_hdd_context; |
| 12975 | } |
| 12976 | |
| 12977 | vos_mem_zero(pHddCtx->cfg_ini, sizeof( hdd_config_t )); |
| 12978 | |
| 12979 | // Read and parse the qcom_cfg.ini file |
| 12980 | status = hdd_parse_config_ini( pHddCtx ); |
| 12981 | if ( VOS_STATUS_SUCCESS != status ) |
| 12982 | { |
| 12983 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: error parsing %s", |
| 12984 | __func__, WLAN_INI_FILE); |
| 12985 | goto err_config; |
| 12986 | } |
Arif Hussain | d521891 | 2013-12-05 01:10:55 -0800 | [diff] [blame] | 12987 | #ifdef MEMORY_DEBUG |
| 12988 | if (pHddCtx->cfg_ini->IsMemoryDebugSupportEnabled) |
| 12989 | vos_mem_init(); |
| 12990 | |
| 12991 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: gEnableMemoryDebug=%d", |
| 12992 | __func__, pHddCtx->cfg_ini->IsMemoryDebugSupportEnabled); |
| 12993 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12994 | |
Gopichand Nakkala | b8f0f1a | 2013-05-23 18:19:48 +0530 | [diff] [blame] | 12995 | /* INI has been read, initialise the configuredMcastBcastFilter with |
| 12996 | * INI value as this will serve as the default value |
| 12997 | */ |
| 12998 | pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting; |
| 12999 | hddLog(VOS_TRACE_LEVEL_INFO, "Setting configuredMcastBcastFilter: %d", |
| 13000 | pHddCtx->cfg_ini->mcastBcastFilterSetting); |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 13001 | |
| 13002 | if (false == hdd_is_5g_supported(pHddCtx)) |
| 13003 | { |
| 13004 | //5Ghz is not supported. |
| 13005 | if (1 != pHddCtx->cfg_ini->nBandCapability) |
| 13006 | { |
| 13007 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 13008 | "%s: Setting pHddCtx->cfg_ini->nBandCapability = 1", __func__); |
| 13009 | pHddCtx->cfg_ini->nBandCapability = 1; |
| 13010 | } |
| 13011 | } |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 13012 | |
| 13013 | /* If SNR Monitoring is enabled, FW has to parse all beacons |
| 13014 | * for calcaluting and storing the average SNR, so set Nth beacon |
| 13015 | * filter to 1 to enable FW to parse all the beaocons |
| 13016 | */ |
| 13017 | if (1 == pHddCtx->cfg_ini->fEnableSNRMonitoring) |
| 13018 | { |
| 13019 | /* The log level is deliberately set to WARN as overriding |
| 13020 | * nthBeaconFilter to 1 will increase power cosumption and this |
| 13021 | * might just prove helpful to detect the power issue. |
| 13022 | */ |
| 13023 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 13024 | "%s: Setting pHddCtx->cfg_ini->nthBeaconFilter = 1", __func__); |
| 13025 | pHddCtx->cfg_ini->nthBeaconFilter = 1; |
| 13026 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13027 | /* |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 13028 | * cfg80211: Initialization ... |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13029 | */ |
Manjeet Singh | 61016fa | 2016-12-02 11:10:19 +0530 | [diff] [blame] | 13030 | if (0 < wlan_hdd_cfg80211_init(dev, wiphy, pHddCtx->cfg_ini)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13031 | { |
Manjeet Singh | 61016fa | 2016-12-02 11:10:19 +0530 | [diff] [blame] | 13032 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 13033 | "%s: wlan_hdd_cfg80211_init return failure", __func__); |
| 13034 | goto err_config; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13035 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13036 | |
Varun Reddy Yeturu | 587e680 | 2013-01-24 12:21:41 -0800 | [diff] [blame] | 13037 | // Update VOS trace levels based upon the cfg.ini |
| 13038 | hdd_vos_trace_enable(VOS_MODULE_ID_BAP, |
| 13039 | pHddCtx->cfg_ini->vosTraceEnableBAP); |
| 13040 | hdd_vos_trace_enable(VOS_MODULE_ID_TL, |
| 13041 | pHddCtx->cfg_ini->vosTraceEnableTL); |
| 13042 | hdd_vos_trace_enable(VOS_MODULE_ID_WDI, |
| 13043 | pHddCtx->cfg_ini->vosTraceEnableWDI); |
| 13044 | hdd_vos_trace_enable(VOS_MODULE_ID_HDD, |
| 13045 | pHddCtx->cfg_ini->vosTraceEnableHDD); |
| 13046 | hdd_vos_trace_enable(VOS_MODULE_ID_SME, |
| 13047 | pHddCtx->cfg_ini->vosTraceEnableSME); |
| 13048 | hdd_vos_trace_enable(VOS_MODULE_ID_PE, |
| 13049 | pHddCtx->cfg_ini->vosTraceEnablePE); |
Katya Nigam | 70d6833 | 2013-09-16 16:49:45 +0530 | [diff] [blame] | 13050 | hdd_vos_trace_enable(VOS_MODULE_ID_PMC, |
| 13051 | pHddCtx->cfg_ini->vosTraceEnablePMC); |
Varun Reddy Yeturu | 587e680 | 2013-01-24 12:21:41 -0800 | [diff] [blame] | 13052 | hdd_vos_trace_enable(VOS_MODULE_ID_WDA, |
| 13053 | pHddCtx->cfg_ini->vosTraceEnableWDA); |
| 13054 | hdd_vos_trace_enable(VOS_MODULE_ID_SYS, |
| 13055 | pHddCtx->cfg_ini->vosTraceEnableSYS); |
| 13056 | hdd_vos_trace_enable(VOS_MODULE_ID_VOSS, |
| 13057 | pHddCtx->cfg_ini->vosTraceEnableVOSS); |
Varun Reddy Yeturu | 587e680 | 2013-01-24 12:21:41 -0800 | [diff] [blame] | 13058 | hdd_vos_trace_enable(VOS_MODULE_ID_SAP, |
| 13059 | pHddCtx->cfg_ini->vosTraceEnableSAP); |
| 13060 | hdd_vos_trace_enable(VOS_MODULE_ID_HDD_SOFTAP, |
| 13061 | pHddCtx->cfg_ini->vosTraceEnableHDDSAP); |
Varun Reddy Yeturu | 587e680 | 2013-01-24 12:21:41 -0800 | [diff] [blame] | 13062 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13063 | // Update WDI trace levels based upon the cfg.ini |
| 13064 | hdd_wdi_trace_enable(eWLAN_MODULE_DAL, |
| 13065 | pHddCtx->cfg_ini->wdiTraceEnableDAL); |
| 13066 | hdd_wdi_trace_enable(eWLAN_MODULE_DAL_CTRL, |
| 13067 | pHddCtx->cfg_ini->wdiTraceEnableCTL); |
| 13068 | hdd_wdi_trace_enable(eWLAN_MODULE_DAL_DATA, |
| 13069 | pHddCtx->cfg_ini->wdiTraceEnableDAT); |
| 13070 | hdd_wdi_trace_enable(eWLAN_MODULE_PAL, |
| 13071 | pHddCtx->cfg_ini->wdiTraceEnablePAL); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13072 | |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 13073 | if (VOS_FTM_MODE == hdd_get_conparam()) |
| 13074 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13075 | if ( VOS_STATUS_SUCCESS != wlan_hdd_ftm_open(pHddCtx) ) |
| 13076 | { |
| 13077 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: wlan_hdd_ftm_open Failed",__func__); |
| 13078 | goto err_free_hdd_context; |
| 13079 | } |
| 13080 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: FTM driver loaded success fully",__func__); |
Sachin Ahuja | 38ef5e0 | 2015-03-13 17:31:16 +0530 | [diff] [blame] | 13081 | pHddCtx->isLoadUnloadInProgress = WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS; |
c_hpothu | 2de0ef6 | 2014-04-15 16:16:15 +0530 | [diff] [blame] | 13082 | vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, FALSE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13083 | return VOS_STATUS_SUCCESS; |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 13084 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13085 | |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 13086 | if( VOS_MONITOR_MODE == hdd_get_conparam()) |
| 13087 | { |
| 13088 | if ( VOS_STATUS_SUCCESS != wlan_hdd_mon_open(pHddCtx)) |
| 13089 | { |
| 13090 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: wlan_hdd_mon_open Failed",__func__); |
| 13091 | goto err_free_hdd_context; |
| 13092 | } |
| 13093 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Driver loaded in Monitor Mode",__func__); |
| 13094 | pHddCtx->isLoadUnloadInProgress = WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS; |
| 13095 | vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, FALSE); |
| 13096 | return VOS_STATUS_SUCCESS; |
| 13097 | } |
| 13098 | |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 13099 | //Open watchdog module |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13100 | if(pHddCtx->cfg_ini->fIsLogpEnabled) |
| 13101 | { |
| 13102 | status = vos_watchdog_open(pVosContext, |
| 13103 | &((VosContextType*)pVosContext)->vosWatchdog, sizeof(VosWatchdogContext)); |
| 13104 | |
| 13105 | if(!VOS_IS_STATUS_SUCCESS( status )) |
| 13106 | { |
| 13107 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: vos_watchdog_open failed",__func__); |
Ashish Kumar Dhanotiya | 532bdef | 2017-05-09 17:31:59 +0530 | [diff] [blame] | 13108 | goto err_config; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13109 | } |
| 13110 | } |
| 13111 | |
| 13112 | pHddCtx->isLogpInProgress = FALSE; |
| 13113 | vos_set_logp_in_progress(VOS_MODULE_ID_VOSS, FALSE); |
| 13114 | |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 13115 | #ifdef CONFIG_ENABLE_LINUX_REG |
Amar Singhal | 0a40223 | 2013-10-11 20:57:16 -0700 | [diff] [blame] | 13116 | /* initialize the NV module. This is required so that |
| 13117 | we can initialize the channel information in wiphy |
| 13118 | from the NV.bin data. The channel information in |
| 13119 | wiphy needs to be initialized before wiphy registration */ |
| 13120 | |
| 13121 | status = vos_nv_open(); |
| 13122 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 13123 | { |
| 13124 | /* NV module cannot be initialized */ |
| 13125 | hddLog( VOS_TRACE_LEVEL_FATAL, |
| 13126 | "%s: vos_nv_open failed", __func__); |
Vinay Krishna Eranna | 2025d89 | 2014-09-18 16:51:42 +0530 | [diff] [blame] | 13127 | goto err_wdclose; |
Amar Singhal | 0a40223 | 2013-10-11 20:57:16 -0700 | [diff] [blame] | 13128 | } |
| 13129 | |
| 13130 | status = vos_init_wiphy_from_nv_bin(); |
| 13131 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 13132 | { |
| 13133 | /* NV module cannot be initialized */ |
| 13134 | hddLog( VOS_TRACE_LEVEL_FATAL, |
| 13135 | "%s: vos_init_wiphy failed", __func__); |
| 13136 | goto err_vos_nv_close; |
| 13137 | } |
| 13138 | |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 13139 | #endif |
Mahesh A Saptasagar | c3ed012 | 2016-01-19 16:45:11 +0530 | [diff] [blame] | 13140 | //Initialize the nlink service |
| 13141 | if(nl_srv_init() != 0) |
| 13142 | { |
| 13143 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: nl_srv_init failed", __func__); |
| 13144 | goto err_vos_nv_close; |
| 13145 | } |
| 13146 | |
| 13147 | #ifdef WLAN_KD_READY_NOTIFIER |
| 13148 | pHddCtx->kd_nl_init = 1; |
| 13149 | #endif /* WLAN_KD_READY_NOTIFIER */ |
| 13150 | |
Girish Gowli | bf0e1ab | 2015-01-19 16:05:16 +0530 | [diff] [blame] | 13151 | vos_set_roam_delay_stats_enabled(pHddCtx->cfg_ini->gEnableRoamDelayStats); |
Arun Kumar Khandavalli | ebb1948 | 2014-03-25 13:56:53 +0530 | [diff] [blame] | 13152 | status = vos_open( &pVosContext, pHddCtx->parent_dev); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13153 | if ( !VOS_IS_STATUS_SUCCESS( status )) |
| 13154 | { |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 13155 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: vos_open failed", __func__); |
Mahesh A Saptasagar | c3ed012 | 2016-01-19 16:45:11 +0530 | [diff] [blame] | 13156 | goto err_nl_srv; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13157 | } |
| 13158 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13159 | pHddCtx->hHal = (tHalHandle)vos_get_context( VOS_MODULE_ID_SME, pVosContext ); |
| 13160 | |
| 13161 | if ( NULL == pHddCtx->hHal ) |
| 13162 | { |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 13163 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: HAL context is null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13164 | goto err_vosclose; |
| 13165 | } |
| 13166 | |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 13167 | status = vos_preStart( pHddCtx->pvosContext ); |
| 13168 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 13169 | { |
| 13170 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: vos_preStart failed", __func__); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 13171 | goto err_vosclose; |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 13172 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 13173 | |
Arif Hussain | eaf6860 | 2013-12-30 23:10:44 -0800 | [diff] [blame] | 13174 | if (0 == enable_dfs_chan_scan || 1 == enable_dfs_chan_scan) |
| 13175 | { |
| 13176 | pHddCtx->cfg_ini->enableDFSChnlScan = enable_dfs_chan_scan; |
| 13177 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: module enable_dfs_chan_scan set to %d", |
| 13178 | __func__, enable_dfs_chan_scan); |
| 13179 | } |
| 13180 | if (0 == enable_11d || 1 == enable_11d) |
| 13181 | { |
| 13182 | pHddCtx->cfg_ini->Is11dSupportEnabled = enable_11d; |
| 13183 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: module enable_11d set to %d", |
| 13184 | __func__, enable_11d); |
| 13185 | } |
| 13186 | |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 13187 | /* Note that the vos_preStart() sequence triggers the cfg download. |
| 13188 | The cfg download must occur before we update the SME config |
| 13189 | since the SME config operation must access the cfg database */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13190 | status = hdd_set_sme_config( pHddCtx ); |
| 13191 | |
| 13192 | if ( VOS_STATUS_SUCCESS != status ) |
| 13193 | { |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 13194 | 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] | 13195 | goto err_vosclose; |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 13196 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13197 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13198 | /* In the integrated architecture we update the configuration from |
| 13199 | the INI file and from NV before vOSS has been started so that |
| 13200 | the final contents are available to send down to the cCPU */ |
| 13201 | |
| 13202 | // Apply the cfg.ini to cfg.dat |
| 13203 | if (FALSE == hdd_update_config_dat(pHddCtx)) |
| 13204 | { |
| 13205 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: config update failed",__func__ ); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 13206 | goto err_vosclose; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13207 | } |
| 13208 | |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 13209 | // Get mac addr from platform driver |
| 13210 | ret = wcnss_get_wlan_mac_address((char*)&mac_addr.bytes); |
| 13211 | |
| 13212 | if ((0 == ret) && (!vos_is_macaddr_zero(&mac_addr))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13213 | { |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 13214 | /* Store the mac addr for first interface */ |
| 13215 | pHddCtx->cfg_ini->intfMacAddr[0] = mac_addr; |
| 13216 | |
| 13217 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 13218 | "%s: WLAN Mac Addr: " |
| 13219 | MAC_ADDRESS_STR, __func__, |
| 13220 | MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[0].bytes)); |
| 13221 | |
| 13222 | /* Here, passing Arg2 as 1 because we do not want to change the |
| 13223 | last 3 bytes (means non OUI bytes) of first interface mac |
| 13224 | addr. |
| 13225 | */ |
| 13226 | if (0 != hdd_generate_iface_mac_addr_auto(pHddCtx, 1, mac_addr)) |
| 13227 | { |
| 13228 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 13229 | "%s: Failed to generate wlan interface mac addr " |
| 13230 | "using MAC from ini file ", __func__); |
| 13231 | } |
| 13232 | } |
| 13233 | else if (VOS_STATUS_SUCCESS != hdd_update_config_from_nv(pHddCtx)) |
| 13234 | { |
| 13235 | // Apply the NV to cfg.dat |
| 13236 | /* Prima Update MAC address only at here */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13237 | #ifdef WLAN_AUTOGEN_MACADDR_FEATURE |
| 13238 | /* There was not a valid set of MAC Addresses in NV. See if the |
| 13239 | default addresses were modified by the cfg.ini settings. If so, |
| 13240 | we'll use them, but if not, we'll autogenerate a set of MAC |
| 13241 | addresses based upon the device serial number */ |
| 13242 | |
| 13243 | static const v_MACADDR_t default_address = |
| 13244 | {{0x00, 0x0A, 0xF5, 0x89, 0x89, 0xFF}}; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13245 | |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 13246 | if (0 == memcmp(&default_address, &pHddCtx->cfg_ini->intfMacAddr[0], |
| 13247 | sizeof(default_address))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13248 | { |
| 13249 | /* cfg.ini has the default address, invoke autogen logic */ |
| 13250 | |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 13251 | /* Here, passing Arg2 as 0 because we want to change the |
| 13252 | last 3 bytes (means non OUI bytes) of all the interfaces |
| 13253 | mac addr. |
| 13254 | */ |
| 13255 | if (0 != hdd_generate_iface_mac_addr_auto(pHddCtx, 0, |
| 13256 | default_address)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13257 | { |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 13258 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 13259 | "%s: Failed to generate wlan interface mac addr " |
| 13260 | "using MAC from ini file " MAC_ADDRESS_STR, __func__, |
| 13261 | MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[0].bytes)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13262 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13263 | } |
| 13264 | else |
| 13265 | #endif //WLAN_AUTOGEN_MACADDR_FEATURE |
| 13266 | { |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 13267 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13268 | "%s: Invalid MAC address in NV, using MAC from ini file " |
| 13269 | MAC_ADDRESS_STR, __func__, |
| 13270 | MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[0].bytes)); |
| 13271 | } |
| 13272 | } |
| 13273 | { |
| 13274 | eHalStatus halStatus; |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 13275 | |
| 13276 | /* Set the MAC Address Currently this is used by HAL to |
| 13277 | * add self sta. Remove this once self sta is added as |
| 13278 | * part of session open. |
| 13279 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13280 | halStatus = cfgSetStr( pHddCtx->hHal, WNI_CFG_STA_ID, |
| 13281 | (v_U8_t *)&pHddCtx->cfg_ini->intfMacAddr[0], |
| 13282 | sizeof( pHddCtx->cfg_ini->intfMacAddr[0]) ); |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 13283 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13284 | if (!HAL_STATUS_SUCCESS( halStatus )) |
| 13285 | { |
| 13286 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failed to set MAC Address. " |
| 13287 | "HALStatus is %08d [x%08x]",__func__, halStatus, halStatus ); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 13288 | goto err_vosclose; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13289 | } |
| 13290 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13291 | |
| 13292 | /*Start VOSS which starts up the SME/MAC/HAL modules and everything else |
| 13293 | Note: Firmware image will be read and downloaded inside vos_start API */ |
| 13294 | status = vos_start( pHddCtx->pvosContext ); |
| 13295 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 13296 | { |
| 13297 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: vos_start failed",__func__); |
Hanumantha Reddy Pothula | bd9601a | 2016-02-12 13:22:27 +0530 | [diff] [blame] | 13298 | if (isSsrPanicOnFailure()) |
| 13299 | VOS_BUG(0); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 13300 | goto err_vosclose; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13301 | } |
| 13302 | |
Leo Chang | 6cec3e2 | 2014-01-21 15:33:49 -0800 | [diff] [blame] | 13303 | #ifdef FEATURE_WLAN_CH_AVOID |
| 13304 | /* Plug in avoid channel notification callback |
| 13305 | * This should happen before ADD_SELF_STA |
| 13306 | * 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] | 13307 | |
| 13308 | /* check the Channel Avoidance is enabled */ |
| 13309 | if (TRUE == pHddCtx->cfg_ini->fenableCHAvoidance) |
| 13310 | { |
| 13311 | sme_AddChAvoidCallback(pHddCtx->hHal, |
| 13312 | hdd_hostapd_ch_avoid_cb); |
| 13313 | } |
Leo Chang | 6cec3e2 | 2014-01-21 15:33:49 -0800 | [diff] [blame] | 13314 | #endif /* FEATURE_WLAN_CH_AVOID */ |
| 13315 | |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 13316 | /* Exchange capability info between Host and FW and also get versioning info from FW */ |
| 13317 | hdd_exchange_version_and_caps(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13318 | |
Agarwal Ashish | ad9281b | 2014-06-10 14:57:30 +0530 | [diff] [blame] | 13319 | #ifdef CONFIG_ENABLE_LINUX_REG |
| 13320 | status = wlan_hdd_init_channels(pHddCtx); |
| 13321 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 13322 | { |
| 13323 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: wlan_hdd_init_channels failed", |
| 13324 | __func__); |
| 13325 | goto err_vosstop; |
| 13326 | } |
| 13327 | #endif |
| 13328 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13329 | status = hdd_post_voss_start_config( pHddCtx ); |
| 13330 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 13331 | { |
| 13332 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hdd_post_voss_start_config failed", |
| 13333 | __func__); |
| 13334 | goto err_vosstop; |
| 13335 | } |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 13336 | |
| 13337 | #ifndef CONFIG_ENABLE_LINUX_REG |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 13338 | wlan_hdd_cfg80211_update_reg_info( wiphy ); |
| 13339 | |
| 13340 | /* registration of wiphy dev with cfg80211 */ |
| 13341 | if (0 > wlan_hdd_cfg80211_register(wiphy)) |
| 13342 | { |
| 13343 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__); |
| 13344 | goto err_vosstop; |
| 13345 | } |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 13346 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13347 | |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 13348 | #ifdef CONFIG_ENABLE_LINUX_REG |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 13349 | /* registration of wiphy dev with cfg80211 */ |
| 13350 | if (0 > wlan_hdd_cfg80211_register(wiphy)) |
| 13351 | { |
| 13352 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__); |
| 13353 | goto err_vosstop; |
| 13354 | } |
| 13355 | |
Agarwal Ashish | 6db9d53 | 2014-09-30 18:19:10 +0530 | [diff] [blame] | 13356 | status = wlan_hdd_init_channels_for_cc(pHddCtx, INIT); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 13357 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 13358 | { |
| 13359 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: wlan_hdd_init_channels_for_cc failed", |
| 13360 | __func__); |
| 13361 | goto err_unregister_wiphy; |
| 13362 | } |
| 13363 | #endif |
| 13364 | |
c_hpothu | 4a298be | 2014-12-22 21:12:51 +0530 | [diff] [blame] | 13365 | wcnss_wlan_set_drvdata(pHddCtx->parent_dev, pHddCtx); |
| 13366 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13367 | if (VOS_STA_SAP_MODE == hdd_get_conparam()) |
| 13368 | { |
| 13369 | pAdapter = hdd_open_adapter( pHddCtx, WLAN_HDD_SOFTAP, "softap.%d", |
| 13370 | wlan_hdd_get_intf_addr(pHddCtx), FALSE ); |
| 13371 | } |
| 13372 | else |
| 13373 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13374 | pAdapter = hdd_open_adapter( pHddCtx, WLAN_HDD_INFRA_STATION, "wlan%d", |
| 13375 | wlan_hdd_get_intf_addr(pHddCtx), FALSE ); |
| 13376 | if (pAdapter != NULL) |
| 13377 | { |
Katya Nigam | a7d81d7 | 2014-11-12 12:44:34 +0530 | [diff] [blame] | 13378 | 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] | 13379 | { |
Gopichand Nakkala | 49f96f6 | 2013-02-06 14:38:17 +0530 | [diff] [blame] | 13380 | vos_mem_copy( pHddCtx->p2pDeviceAddress.bytes, |
| 13381 | pHddCtx->cfg_ini->intfMacAddr[0].bytes, |
| 13382 | sizeof(tSirMacAddr)); |
Madan Mohan Koyyalamudi | edfc1b7 | 2012-10-18 20:25:55 -0700 | [diff] [blame] | 13383 | |
Gopichand Nakkala | 49f96f6 | 2013-02-06 14:38:17 +0530 | [diff] [blame] | 13384 | /* Generate the P2P Device Address. This consists of the device's |
| 13385 | * primary MAC address with the locally administered bit set. |
| 13386 | */ |
| 13387 | pHddCtx->p2pDeviceAddress.bytes[0] |= 0x02; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 13388 | } |
| 13389 | else |
| 13390 | { |
Gopichand Nakkala | 49f96f6 | 2013-02-06 14:38:17 +0530 | [diff] [blame] | 13391 | tANI_U8* p2p_dev_addr = wlan_hdd_get_intf_addr(pHddCtx); |
| 13392 | if (p2p_dev_addr != NULL) |
| 13393 | { |
| 13394 | vos_mem_copy(&pHddCtx->p2pDeviceAddress.bytes[0], |
| 13395 | p2p_dev_addr, VOS_MAC_ADDR_SIZE); |
| 13396 | } |
| 13397 | else |
| 13398 | { |
| 13399 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 13400 | "%s: Failed to allocate mac_address for p2p_device", |
| 13401 | __func__); |
| 13402 | goto err_close_adapter; |
| 13403 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13404 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 13405 | |
| 13406 | pP2pAdapter = hdd_open_adapter( pHddCtx, WLAN_HDD_P2P_DEVICE, "p2p%d", |
| 13407 | &pHddCtx->p2pDeviceAddress.bytes[0], FALSE ); |
| 13408 | if ( NULL == pP2pAdapter ) |
| 13409 | { |
| 13410 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 13411 | "%s: Failed to do hdd_open_adapter for P2P Device Interface", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 13412 | __func__); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 13413 | goto err_close_adapter; |
| 13414 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 13415 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13416 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13417 | |
| 13418 | if( pAdapter == NULL ) |
| 13419 | { |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 13420 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: hdd_open_adapter failed", __func__); |
| 13421 | goto err_close_adapter; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13422 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 13423 | |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 13424 | if (country_code) |
| 13425 | { |
| 13426 | eHalStatus ret; |
Arif Hussain | cb60708 | 2013-12-20 11:57:42 -0800 | [diff] [blame] | 13427 | INIT_COMPLETION(pAdapter->change_country_code); |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 13428 | hdd_checkandupdate_dfssetting(pAdapter, country_code); |
| 13429 | #ifndef CONFIG_ENABLE_LINUX_REG |
| 13430 | hdd_checkandupdate_phymode(pAdapter, country_code); |
| 13431 | #endif |
Arif Hussain | eaf6860 | 2013-12-30 23:10:44 -0800 | [diff] [blame] | 13432 | ret = sme_ChangeCountryCode(pHddCtx->hHal, |
| 13433 | (void *)(tSmeChangeCountryCallback) |
| 13434 | wlan_hdd_change_country_code_callback, |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 13435 | country_code, |
| 13436 | pAdapter, pHddCtx->pvosContext, |
Abhishek Singh | a306a44 | 2013-11-07 18:39:01 +0530 | [diff] [blame] | 13437 | eSIR_TRUE, eSIR_TRUE); |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 13438 | if (eHAL_STATUS_SUCCESS == ret) |
| 13439 | { |
Arif Hussain | cb60708 | 2013-12-20 11:57:42 -0800 | [diff] [blame] | 13440 | ret = wait_for_completion_interruptible_timeout( |
| 13441 | &pAdapter->change_country_code, |
| 13442 | msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY)); |
| 13443 | |
| 13444 | if (0 >= ret) |
| 13445 | { |
| 13446 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 13447 | "%s: SME while setting country code timed out", __func__); |
| 13448 | } |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 13449 | } |
| 13450 | else |
| 13451 | { |
Arif Hussain | cb60708 | 2013-12-20 11:57:42 -0800 | [diff] [blame] | 13452 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 13453 | "%s: SME Change Country code from module param fail ret=%d", |
| 13454 | __func__, ret); |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 13455 | } |
| 13456 | } |
| 13457 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13458 | #ifdef WLAN_BTAMP_FEATURE |
| 13459 | vStatus = WLANBAP_Open(pVosContext); |
| 13460 | if(!VOS_IS_STATUS_SUCCESS(vStatus)) |
| 13461 | { |
| 13462 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 13463 | "%s: Failed to open BAP",__func__); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 13464 | goto err_close_adapter; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13465 | } |
| 13466 | |
| 13467 | vStatus = BSL_Init(pVosContext); |
| 13468 | if(!VOS_IS_STATUS_SUCCESS(vStatus)) |
| 13469 | { |
| 13470 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 13471 | "%s: Failed to Init BSL",__func__); |
| 13472 | goto err_bap_close; |
| 13473 | } |
| 13474 | vStatus = WLANBAP_Start(pVosContext); |
| 13475 | if (!VOS_IS_STATUS_SUCCESS(vStatus)) |
| 13476 | { |
| 13477 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 13478 | "%s: Failed to start TL",__func__); |
| 13479 | goto err_bap_close; |
| 13480 | } |
| 13481 | |
| 13482 | pConfig = pHddCtx->cfg_ini; |
| 13483 | btAmpConfig.ucPreferredChannel = pConfig->preferredChannel; |
| 13484 | status = WLANBAP_SetConfig(&btAmpConfig); |
| 13485 | |
| 13486 | #endif //WLAN_BTAMP_FEATURE |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 13487 | |
Mihir Shete | 9c23877 | 2014-10-15 14:35:16 +0530 | [diff] [blame] | 13488 | /* |
| 13489 | * UapsdMask is 0xf if U-APSD is enbaled for all AC's... |
| 13490 | * The value of CFG_QOS_WMM_UAPSD_MASK_DEFAULT is 0xaa(Magic Value) |
| 13491 | * which is greater than 0xf. So the below check is safe to make |
| 13492 | * sure that there is no entry for UapsdMask in the ini |
| 13493 | */ |
| 13494 | if (CFG_QOS_WMM_UAPSD_MASK_DEFAULT == pHddCtx->cfg_ini->UapsdMask) |
| 13495 | { |
| 13496 | if(IS_DYNAMIC_WMM_PS_ENABLED) |
| 13497 | { |
| 13498 | hddLog(VOS_TRACE_LEVEL_DEBUG,"%s: Enable UAPSD for VI & VO", |
| 13499 | __func__); |
| 13500 | pHddCtx->cfg_ini->UapsdMask = |
| 13501 | CFG_QOS_WMM_UAPSD_MASK_DYMANIC_WMM_PS_DEFAULT; |
| 13502 | } |
| 13503 | else |
| 13504 | { |
| 13505 | hddLog(VOS_TRACE_LEVEL_DEBUG,"%s: Do not enable UAPSD", |
| 13506 | __func__); |
| 13507 | pHddCtx->cfg_ini->UapsdMask = |
| 13508 | CFG_QOS_WMM_UAPSD_MASK_LEGACY_WMM_PS_DEFAULT; |
| 13509 | } |
| 13510 | } |
| 13511 | |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 13512 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 13513 | if(!(IS_ROAM_SCAN_OFFLOAD_FEATURE_ENABLE)) |
| 13514 | { |
| 13515 | hddLog(VOS_TRACE_LEVEL_DEBUG,"%s: ROAM_SCAN_OFFLOAD Feature not supported",__func__); |
| 13516 | pHddCtx->cfg_ini->isRoamOffloadScanEnabled = 0; |
| 13517 | sme_UpdateRoamScanOffloadEnabled((tHalHandle)(pHddCtx->hHal), |
| 13518 | pHddCtx->cfg_ini->isRoamOffloadScanEnabled); |
| 13519 | } |
| 13520 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13521 | |
Agarwal Ashish | 4b87f92 | 2014-06-18 03:03:21 +0530 | [diff] [blame] | 13522 | wlan_hdd_tdls_init(pHddCtx); |
| 13523 | |
Masti, Narayanraddi | 2637846 | 2016-01-05 18:20:28 +0530 | [diff] [blame] | 13524 | wlan_hdd_init_deinit_defer_scan_context(&pHddCtx->scan_ctxt); |
| 13525 | |
| 13526 | vos_init_delayed_work(&pHddCtx->scan_ctxt.scan_work, |
| 13527 | wlan_hdd_schedule_defer_scan); |
| 13528 | |
Mihir Shete | fc7ff5b | 2014-01-27 11:30:05 +0530 | [diff] [blame] | 13529 | sme_Register11dScanDoneCallback(pHddCtx->hHal, hdd_11d_scan_done); |
| 13530 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13531 | /* Register with platform driver as client for Suspend/Resume */ |
| 13532 | status = hddRegisterPmOps(pHddCtx); |
| 13533 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 13534 | { |
| 13535 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddRegisterPmOps failed",__func__); |
| 13536 | #ifdef WLAN_BTAMP_FEATURE |
| 13537 | goto err_bap_stop; |
| 13538 | #else |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 13539 | goto err_close_adapter; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13540 | #endif //WLAN_BTAMP_FEATURE |
| 13541 | } |
| 13542 | |
Yue Ma | 0d4891e | 2013-08-06 17:01:45 -0700 | [diff] [blame] | 13543 | /* Open debugfs interface */ |
| 13544 | if (VOS_STATUS_SUCCESS != hdd_debugfs_init(pAdapter)) |
| 13545 | { |
| 13546 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 13547 | "%s: hdd_debugfs_init failed!", __func__); |
Yue Ma | 0d4891e | 2013-08-06 17:01:45 -0700 | [diff] [blame] | 13548 | } |
| 13549 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13550 | /* Register TM level change handler function to the platform */ |
| 13551 | status = hddDevTmRegisterNotifyCallback(pHddCtx); |
| 13552 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 13553 | { |
| 13554 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddDevTmRegisterNotifyCallback failed",__func__); |
| 13555 | goto err_unregister_pmops; |
| 13556 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13557 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13558 | // register net device notifier for device change notification |
| 13559 | ret = register_netdevice_notifier(&hdd_netdev_notifier); |
| 13560 | |
| 13561 | if(ret < 0) |
| 13562 | { |
| 13563 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: register_netdevice_notifier failed",__func__); |
Siddharth Bhal | cd92b78 | 2015-06-29 12:25:40 +0530 | [diff] [blame] | 13564 | goto err_unregister_pmops; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13565 | } |
| 13566 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13567 | //Initialize the BTC service |
| 13568 | if(btc_activate_service(pHddCtx) != 0) |
| 13569 | { |
| 13570 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: btc_activate_service failed",__func__); |
Mahesh A Saptasagar | c3ed012 | 2016-01-19 16:45:11 +0530 | [diff] [blame] | 13571 | goto err_reg_netdev; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13572 | } |
| 13573 | |
Padma, Santhosh Kumar | 2762e9d | 2015-10-20 15:02:57 +0530 | [diff] [blame] | 13574 | #ifdef FEATURE_OEM_DATA_SUPPORT |
| 13575 | //Initialize the OEM service |
| 13576 | if (oem_activate_service(pHddCtx) != 0) |
| 13577 | { |
| 13578 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 13579 | "%s: oem_activate_service failed", __func__); |
Hanumanth Reddy Pothula | 13789c4 | 2017-09-12 15:18:13 +0530 | [diff] [blame] | 13580 | goto err_btc_activate_service; |
Padma, Santhosh Kumar | 2762e9d | 2015-10-20 15:02:57 +0530 | [diff] [blame] | 13581 | } |
| 13582 | #endif |
| 13583 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13584 | #ifdef PTT_SOCK_SVC_ENABLE |
| 13585 | //Initialize the PTT service |
| 13586 | if(ptt_sock_activate_svc(pHddCtx) != 0) |
| 13587 | { |
| 13588 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: ptt_sock_activate_svc failed",__func__); |
Hanumanth Reddy Pothula | 13789c4 | 2017-09-12 15:18:13 +0530 | [diff] [blame] | 13589 | goto err_oem_activate_service; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13590 | } |
| 13591 | #endif |
| 13592 | |
Abhishek Singh | 00b7197 | 2016-01-07 10:51:04 +0530 | [diff] [blame] | 13593 | #ifdef WLAN_FEATURE_RMC |
| 13594 | if (hdd_open_cesium_nl_sock() < 0) |
| 13595 | { |
| 13596 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hdd_open_cesium_nl_sock failed", __func__); |
Hanumanth Reddy Pothula | 13789c4 | 2017-09-12 15:18:13 +0530 | [diff] [blame] | 13597 | goto err_ptt_sock_activate_svc; |
Abhishek Singh | 00b7197 | 2016-01-07 10:51:04 +0530 | [diff] [blame] | 13598 | } |
| 13599 | #endif |
| 13600 | |
Vinay Krishna Eranna | d938c42 | 2014-03-10 17:14:21 +0530 | [diff] [blame] | 13601 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 13602 | if(pHddCtx->cfg_ini && pHddCtx->cfg_ini->wlanLoggingEnable) |
| 13603 | { |
Deepthi Gowri | 78083a3 | 2014-11-04 12:55:51 +0530 | [diff] [blame] | 13604 | if(wlan_logging_sock_activate_svc( |
| 13605 | pHddCtx->cfg_ini->wlanLoggingFEToConsole, |
Sushant Kaushik | 3320057 | 2015-08-05 16:46:20 +0530 | [diff] [blame] | 13606 | pHddCtx->cfg_ini->wlanLoggingNumBuf, |
| 13607 | pHddCtx->cfg_ini->wlanPerPktStatsLogEnable, |
| 13608 | pHddCtx->cfg_ini->wlanPerPktStatsNumBuf)) |
Deepthi Gowri | 78083a3 | 2014-11-04 12:55:51 +0530 | [diff] [blame] | 13609 | { |
| 13610 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wlan_logging_sock_activate_svc" |
| 13611 | " failed", __func__); |
Hanumanth Reddy Pothula | 13789c4 | 2017-09-12 15:18:13 +0530 | [diff] [blame] | 13612 | goto err_open_cesium_nl_sock; |
Deepthi Gowri | 78083a3 | 2014-11-04 12:55:51 +0530 | [diff] [blame] | 13613 | } |
| 13614 | //TODO: To Remove enableDhcpDebug and use gEnableDebugLog for |
| 13615 | //EAPOL and DHCP |
Sachin Ahuja | 8c65f38 | 2014-12-12 15:34:21 +0530 | [diff] [blame] | 13616 | if (!pHddCtx->cfg_ini->gEnableDebugLog) |
| 13617 | pHddCtx->cfg_ini->gEnableDebugLog = |
Sushant Kaushik | 6e4e2bc | 2015-10-05 17:23:07 +0530 | [diff] [blame] | 13618 | VOS_PKT_PROTO_TYPE_EAPOL | VOS_PKT_PROTO_TYPE_DHCP | |
| 13619 | VOS_PKT_PROTO_TYPE_ARP; |
Vinay Krishna Eranna | d938c42 | 2014-03-10 17:14:21 +0530 | [diff] [blame] | 13620 | } |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 13621 | |
Siddharth Bhal | d1be97f | 2015-05-27 22:39:59 +0530 | [diff] [blame] | 13622 | if (pHddCtx->cfg_ini->wlanLoggingEnable && |
| 13623 | (pHddCtx->cfg_ini->enableFWLogging || |
Siddharth Bhal | db96323 | 2015-06-25 19:34:35 +0530 | [diff] [blame] | 13624 | pHddCtx->cfg_ini->enableMgmtLogging || |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 13625 | pHddCtx->cfg_ini->enableContFWLogging || |
| 13626 | pHddCtx->cfg_ini->enableFwrMemDump ) |
| 13627 | ) |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 13628 | { |
Siddharth Bhal | d1be97f | 2015-05-27 22:39:59 +0530 | [diff] [blame] | 13629 | hdd_init_frame_logging(pHddCtx); |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 13630 | } |
| 13631 | else |
| 13632 | { |
Siddharth Bhal | d1be97f | 2015-05-27 22:39:59 +0530 | [diff] [blame] | 13633 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Logging disabled in ini")); |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 13634 | } |
| 13635 | |
Vinay Krishna Eranna | d938c42 | 2014-03-10 17:14:21 +0530 | [diff] [blame] | 13636 | #endif |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 13637 | |
Agrawal Ashish | 17ef508 | 2016-10-17 18:33:21 +0530 | [diff] [blame] | 13638 | #ifdef SAP_AUTH_OFFLOAD |
| 13639 | if (!sme_IsFeatureSupportedByFW(SAP_OFFLOADS)) |
| 13640 | { |
| 13641 | hddLog(VOS_TRACE_LEVEL_INFO, FL(" SAP AUTH OFFLOAD not supp by FW")); |
| 13642 | pHddCtx->cfg_ini->enable_sap_auth_offload = 0; |
| 13643 | } |
| 13644 | #endif |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 13645 | |
Sushant Kaushik | 215778f | 2015-05-21 14:05:36 +0530 | [diff] [blame] | 13646 | if (vos_is_multicast_logging()) |
| 13647 | wlan_logging_set_log_level(); |
| 13648 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13649 | hdd_register_mcast_bcast_filter(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13650 | if (VOS_STA_SAP_MODE != hdd_get_conparam()) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13651 | { |
Madan Mohan Koyyalamudi | c537df2 | 2012-10-22 15:07:08 -0700 | [diff] [blame] | 13652 | /* Action frame registered in one adapter which will |
| 13653 | * applicable to all interfaces |
| 13654 | */ |
Agarwal Ashish | 8fa0e9a | 2014-05-23 00:40:12 +0530 | [diff] [blame] | 13655 | wlan_hdd_cfg80211_register_frames(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13656 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13657 | |
| 13658 | mutex_init(&pHddCtx->sap_lock); |
Mahesh A Saptasagar | 6062794 | 2014-10-13 13:55:14 +0530 | [diff] [blame] | 13659 | mutex_init(&pHddCtx->roc_lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13660 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 13661 | #ifdef WLAN_FEATURE_HOLD_RX_WAKELOCK |
| 13662 | /* Initialize the wake lcok */ |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 13663 | vos_wake_lock_init(&pHddCtx->rx_wake_lock, |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 13664 | "qcom_rx_wakelock"); |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 13665 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 13666 | #endif |
Madan Mohan Koyyalamudi | 69fc3ad | 2012-11-28 16:04:56 -0800 | [diff] [blame] | 13667 | /* Initialize the wake lcok */ |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 13668 | vos_wake_lock_init(&pHddCtx->sap_wake_lock, |
Madan Mohan Koyyalamudi | 69fc3ad | 2012-11-28 16:04:56 -0800 | [diff] [blame] | 13669 | "qcom_sap_wakelock"); |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 13670 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 13671 | |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 13672 | vos_event_init(&pHddCtx->scan_info.scan_finished_event); |
| 13673 | pHddCtx->scan_info.scan_pending_option = WEXT_SCAN_PENDING_GIVEUP; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13674 | |
Katya Nigam | 5c306ea | 2014-06-19 15:39:54 +0530 | [diff] [blame] | 13675 | pHddCtx->isLoadUnloadInProgress = WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13676 | vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, FALSE); |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 13677 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_DRIVER_INIT); |
Katya Nigam | 5c306ea | 2014-06-19 15:39:54 +0530 | [diff] [blame] | 13678 | |
| 13679 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 13680 | /*SME must send channel update configuration to RIVA*/ |
| 13681 | sme_UpdateChannelConfig(pHddCtx->hHal); |
| 13682 | #endif |
Abhishek Singh | f644b27 | 2014-08-21 02:59:39 +0530 | [diff] [blame] | 13683 | /* Send the update default channel list to the FW*/ |
| 13684 | sme_UpdateChannelList(pHddCtx->hHal); |
Mukul Sharma | 4506394 | 2015-04-01 20:07:59 +0530 | [diff] [blame] | 13685 | |
| 13686 | /* Fwr capabilities received, Set the Dot11 mode */ |
Abhishek Singh | 41ebce1 | 2016-02-03 10:43:21 +0530 | [diff] [blame] | 13687 | sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 13688 | hdd_cfg_xlate_to_csr_phy_mode(pHddCtx->cfg_ini->dot11Mode)); |
Mukul Sharma | 4506394 | 2015-04-01 20:07:59 +0530 | [diff] [blame] | 13689 | sme_SetDefDot11Mode(pHddCtx->hHal); |
| 13690 | |
Abhishek Singh | a306a44 | 2013-11-07 18:39:01 +0530 | [diff] [blame] | 13691 | #ifndef CONFIG_ENABLE_LINUX_REG |
| 13692 | /*updating wiphy so that regulatory user hints can be processed*/ |
| 13693 | if (wiphy) |
| 13694 | { |
| 13695 | regulatory_hint(wiphy, "00"); |
| 13696 | } |
| 13697 | #endif |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 13698 | // Initialize the restart logic |
| 13699 | wlan_hdd_restart_init(pHddCtx); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 13700 | |
Hanumanth Reddy Pothula | 146bca4 | 2016-11-08 12:01:07 +0530 | [diff] [blame] | 13701 | if (pHddCtx->cfg_ini->fIsLogpEnabled) { |
| 13702 | vos_wdthread_init_timer_work(vos_process_wd_timer); |
| 13703 | /* Initialize the timer to detect thread stuck issues */ |
| 13704 | vos_thread_stuck_timer_init( |
| 13705 | &((VosContextType*)pVosContext)->vosWatchdog); |
| 13706 | } |
| 13707 | |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 13708 | //Register the traffic monitor timer now |
| 13709 | if ( pHddCtx->cfg_ini->dynSplitscan) |
| 13710 | { |
| 13711 | vos_timer_init(&pHddCtx->tx_rx_trafficTmr, |
| 13712 | VOS_TIMER_TYPE_SW, |
| 13713 | hdd_tx_rx_pkt_cnt_stat_timer_handler, |
| 13714 | (void *)pHddCtx); |
| 13715 | } |
Srinivas Dasari | 030bad3 | 2015-02-18 23:23:54 +0530 | [diff] [blame] | 13716 | wlan_hdd_cfg80211_nan_init(pHddCtx); |
| 13717 | |
Bhargav Shah | d071591 | 2015-10-01 18:17:37 +0530 | [diff] [blame] | 13718 | mutex_init(&pHddCtx->cur_rx_level_lock); |
| 13719 | vos_timer_init(&pHddCtx->delack_timer, VOS_TIMER_TYPE_SW, |
| 13720 | hdd_tcp_delack_compute_function,(void *)pHddCtx); |
Masti, Narayanraddi | 44b0db0 | 2015-12-22 11:54:35 +0530 | [diff] [blame] | 13721 | vos_timer_init(&pHddCtx->tdls_source_timer, VOS_TIMER_TYPE_SW, |
| 13722 | wlan_hdd_change_tdls_mode, (void *)pHddCtx); |
Bhargav Shah | d071591 | 2015-10-01 18:17:37 +0530 | [diff] [blame] | 13723 | |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 13724 | #ifdef WLAN_FEATURE_EXTSCAN |
| 13725 | sme_EXTScanRegisterCallback(pHddCtx->hHal, |
| 13726 | wlan_hdd_cfg80211_extscan_callback, |
| 13727 | pHddCtx); |
| 13728 | #endif /* WLAN_FEATURE_EXTSCAN */ |
Vinay Krishna Eranna | f97ef5c | 2014-12-26 17:47:19 +0530 | [diff] [blame] | 13729 | |
Padma, Santhosh Kumar | 2ccac21 | 2015-10-20 17:27:27 +0530 | [diff] [blame] | 13730 | #ifdef FEATURE_OEM_DATA_SUPPORT |
| 13731 | sme_OemDataRegisterCallback(pHddCtx->hHal, |
| 13732 | wlan_hdd_cfg80211_oemdata_callback, |
| 13733 | pHddCtx); |
| 13734 | #endif /* FEATURE_OEM_DATA_SUPPORT */ |
| 13735 | |
Gupta, Kapil | 7c34b32 | 2015-09-30 13:12:35 +0530 | [diff] [blame] | 13736 | 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] | 13737 | #ifdef WLAN_NS_OFFLOAD |
| 13738 | // Register IPv6 notifier to notify if any change in IP |
| 13739 | // So that we can reconfigure the offload parameters |
| 13740 | pHddCtx->ipv6_notifier.notifier_call = wlan_hdd_ipv6_changed; |
| 13741 | ret = register_inet6addr_notifier(&pHddCtx->ipv6_notifier); |
| 13742 | if (ret) |
| 13743 | { |
Ratheesh S P | 36dbc93 | 2015-08-07 14:28:57 +0530 | [diff] [blame] | 13744 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to register IPv6 notifier")); |
Vinay Krishna Eranna | f97ef5c | 2014-12-26 17:47:19 +0530 | [diff] [blame] | 13745 | } |
| 13746 | else |
| 13747 | { |
Ratheesh S P | 36dbc93 | 2015-08-07 14:28:57 +0530 | [diff] [blame] | 13748 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Registered IPv6 notifier")); |
Vinay Krishna Eranna | f97ef5c | 2014-12-26 17:47:19 +0530 | [diff] [blame] | 13749 | } |
| 13750 | #endif |
| 13751 | |
Sravan Kumar Kairam | b0edc61 | 2016-10-26 13:55:24 +0530 | [diff] [blame] | 13752 | vos_mem_set((uint8_t *)&pHddCtx->bad_sta, HDD_MAX_STA_COUNT, 0); |
| 13753 | |
Vinay Krishna Eranna | f97ef5c | 2014-12-26 17:47:19 +0530 | [diff] [blame] | 13754 | // Register IPv4 notifier to notify if any change in IP |
| 13755 | // So that we can reconfigure the offload parameters |
| 13756 | pHddCtx->ipv4_notifier.notifier_call = wlan_hdd_ipv4_changed; |
| 13757 | ret = register_inetaddr_notifier(&pHddCtx->ipv4_notifier); |
| 13758 | if (ret) |
| 13759 | { |
Ratheesh S P | 36dbc93 | 2015-08-07 14:28:57 +0530 | [diff] [blame] | 13760 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to register IPv4 notifier")); |
Vinay Krishna Eranna | f97ef5c | 2014-12-26 17:47:19 +0530 | [diff] [blame] | 13761 | } |
| 13762 | else |
| 13763 | { |
Ratheesh S P | 36dbc93 | 2015-08-07 14:28:57 +0530 | [diff] [blame] | 13764 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Registered IPv4 notifier")); |
Vinay Krishna Eranna | f97ef5c | 2014-12-26 17:47:19 +0530 | [diff] [blame] | 13765 | } |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 13766 | /*Fw mem dump procfs initialization*/ |
| 13767 | memdump_init(); |
Bhargav shah | 23c9494 | 2015-10-13 12:48:35 +0530 | [diff] [blame] | 13768 | hdd_dp_util_send_rps_ind(pHddCtx); |
Vinay Krishna Eranna | f97ef5c | 2014-12-26 17:47:19 +0530 | [diff] [blame] | 13769 | |
Nishank Aggarwal | c11826c | 2016-12-15 18:54:10 +0530 | [diff] [blame] | 13770 | pHddCtx->is_ap_mode_wow_supported = |
| 13771 | sme_IsFeatureSupportedByFW(SAP_MODE_WOW); |
Sravan Kumar Kairam | 091e5b6 | 2017-01-23 14:14:20 +0530 | [diff] [blame] | 13772 | |
Hanumanth Reddy Pothula | e92bcc1 | 2017-05-19 13:56:35 +0530 | [diff] [blame] | 13773 | pHddCtx->is_fatal_event_log_sup = |
| 13774 | sme_IsFeatureSupportedByFW(FATAL_EVENT_LOGGING); |
| 13775 | hddLog(VOS_TRACE_LEVEL_INFO, FL("FATAL_EVENT_LOGGING: %d"), |
| 13776 | pHddCtx->is_fatal_event_log_sup); |
| 13777 | |
Sravan Kumar Kairam | 091e5b6 | 2017-01-23 14:14:20 +0530 | [diff] [blame] | 13778 | hdd_assoc_registerFwdEapolCB(pVosContext); |
| 13779 | |
Ashish Kumar Dhanotiya | 32d092b | 2018-02-20 21:43:57 +0530 | [diff] [blame] | 13780 | mutex_init(&pHddCtx->cache_channel_lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13781 | goto success; |
| 13782 | |
Hanumanth Reddy Pothula | 13789c4 | 2017-09-12 15:18:13 +0530 | [diff] [blame] | 13783 | err_open_cesium_nl_sock: |
| 13784 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 13785 | hdd_close_cesium_nl_sock(); |
| 13786 | #endif |
| 13787 | |
| 13788 | err_ptt_sock_activate_svc: |
| 13789 | #ifdef PTT_SOCK_SVC_ENABLE |
| 13790 | ptt_sock_deactivate_svc(pHddCtx); |
| 13791 | #endif |
| 13792 | |
| 13793 | err_oem_activate_service: |
| 13794 | #ifdef FEATURE_OEM_DATA_SUPPORT |
| 13795 | oem_deactivate_service(); |
| 13796 | #endif |
| 13797 | |
| 13798 | err_btc_activate_service: |
| 13799 | btc_deactivate_service(); |
| 13800 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13801 | err_reg_netdev: |
| 13802 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 13803 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13804 | err_unregister_pmops: |
| 13805 | hddDevTmUnregisterNotifyCallback(pHddCtx); |
| 13806 | hddDeregisterPmOps(pHddCtx); |
| 13807 | |
Yue Ma | 0d4891e | 2013-08-06 17:01:45 -0700 | [diff] [blame] | 13808 | hdd_debugfs_exit(pHddCtx); |
| 13809 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13810 | #ifdef WLAN_BTAMP_FEATURE |
| 13811 | err_bap_stop: |
| 13812 | WLANBAP_Stop(pVosContext); |
| 13813 | #endif |
| 13814 | |
| 13815 | #ifdef WLAN_BTAMP_FEATURE |
| 13816 | err_bap_close: |
| 13817 | WLANBAP_Close(pVosContext); |
| 13818 | #endif |
| 13819 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13820 | err_close_adapter: |
| 13821 | hdd_close_all_adapters( pHddCtx ); |
Mahesh A Saptasagar | 9ecefe4 | 2014-07-15 18:43:49 +0530 | [diff] [blame] | 13822 | #ifdef CONFIG_ENABLE_LINUX_REG |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 13823 | err_unregister_wiphy: |
Mahesh A Saptasagar | 9ecefe4 | 2014-07-15 18:43:49 +0530 | [diff] [blame] | 13824 | #endif |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 13825 | wiphy_unregister(wiphy) ; |
Agrawal Ashish | 33ec71e | 2015-11-26 20:20:58 +0530 | [diff] [blame] | 13826 | hdd_wlan_free_wiphy_channels(wiphy); |
| 13827 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13828 | err_vosstop: |
| 13829 | vos_stop(pVosContext); |
| 13830 | |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 13831 | err_vosclose: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13832 | status = vos_sched_close( pVosContext ); |
| 13833 | if (!VOS_IS_STATUS_SUCCESS(status)) { |
| 13834 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, |
| 13835 | "%s: Failed to close VOSS Scheduler", __func__); |
| 13836 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( status ) ); |
| 13837 | } |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 13838 | vos_close(pVosContext ); |
| 13839 | |
Mahesh A Saptasagar | c3ed012 | 2016-01-19 16:45:11 +0530 | [diff] [blame] | 13840 | err_nl_srv: |
| 13841 | #ifdef WLAN_KD_READY_NOTIFIER |
| 13842 | nl_srv_exit(pHddCtx->ptt_pid); |
| 13843 | #else |
| 13844 | nl_srv_exit(); |
| 13845 | #endif /* WLAN_KD_READY_NOTIFIER */ |
Amar Singhal | 0a40223 | 2013-10-11 20:57:16 -0700 | [diff] [blame] | 13846 | err_vos_nv_close: |
| 13847 | |
c_hpothu | e6a3628 | 2014-03-19 12:27:38 +0530 | [diff] [blame] | 13848 | #ifdef CONFIG_ENABLE_LINUX_REG |
Amar Singhal | 0a40223 | 2013-10-11 20:57:16 -0700 | [diff] [blame] | 13849 | vos_nv_close(); |
| 13850 | |
c_hpothu | 70f8d81 | 2014-03-22 22:59:23 +0530 | [diff] [blame] | 13851 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13852 | |
| 13853 | err_wdclose: |
| 13854 | if(pHddCtx->cfg_ini->fIsLogpEnabled) |
| 13855 | vos_watchdog_close(pVosContext); |
| 13856 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13857 | err_config: |
| 13858 | kfree(pHddCtx->cfg_ini); |
| 13859 | pHddCtx->cfg_ini= NULL; |
| 13860 | |
| 13861 | err_free_hdd_context: |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 13862 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_DRIVER_INIT); |
Siddharth Bhal | cd92b78 | 2015-06-29 12:25:40 +0530 | [diff] [blame] | 13863 | free_riva_power_on_lock("wlan"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13864 | wiphy_free(wiphy) ; |
| 13865 | //kfree(wdev) ; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13866 | VOS_BUG(1); |
| 13867 | |
Madan Mohan Koyyalamudi | d57ae63 | 2012-11-06 18:42:48 -0800 | [diff] [blame] | 13868 | if (hdd_is_ssr_required()) |
| 13869 | { |
| 13870 | /* WDI timeout had happened during load, so SSR is needed here */ |
| 13871 | subsystem_restart("wcnss"); |
| 13872 | msleep(5000); |
| 13873 | } |
| 13874 | hdd_set_ssr_required (VOS_FALSE); |
| 13875 | |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 13876 | return -EIO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13877 | |
| 13878 | success: |
| 13879 | EXIT(); |
| 13880 | return 0; |
| 13881 | } |
| 13882 | |
| 13883 | /**--------------------------------------------------------------------------- |
| 13884 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 13885 | \brief hdd_driver_init() - Core Driver Init Function |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13886 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 13887 | This is the driver entry point - called in different timeline depending |
| 13888 | on whether the driver is statically or dynamically linked |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13889 | |
| 13890 | \param - None |
| 13891 | |
| 13892 | \return - 0 for success, non zero for failure |
| 13893 | |
| 13894 | --------------------------------------------------------------------------*/ |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 13895 | static int hdd_driver_init( void) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13896 | { |
| 13897 | VOS_STATUS status; |
| 13898 | v_CONTEXT_t pVosContext = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13899 | struct device *dev = NULL; |
| 13900 | int ret_status = 0; |
Sameer Thalappil | f58d7ec | 2013-04-25 20:17:12 -0700 | [diff] [blame] | 13901 | #ifdef HAVE_WCNSS_CAL_DOWNLOAD |
| 13902 | int max_retries = 0; |
| 13903 | #endif |
Siddharth Bhal | c7e79b6 | 2014-10-10 22:37:38 +0530 | [diff] [blame] | 13904 | #ifdef HAVE_CBC_DONE |
| 13905 | int max_cbc_retries = 0; |
| 13906 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13907 | |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 13908 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 13909 | wlan_logging_sock_init_svc(); |
| 13910 | #endif |
| 13911 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13912 | ENTER(); |
| 13913 | |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 13914 | vos_wake_lock_init(&wlan_wake_lock, "wlan"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13915 | |
| 13916 | pr_info("%s: loading driver v%s\n", WLAN_MODULE_NAME, |
| 13917 | QWLAN_VERSIONSTR TIMER_MANAGER_STR MEMORY_DEBUG_STR); |
| 13918 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13919 | #ifdef ANI_BUS_TYPE_PCI |
| 13920 | |
| 13921 | dev = wcnss_wlan_get_device(); |
| 13922 | |
| 13923 | #endif // ANI_BUS_TYPE_PCI |
| 13924 | |
| 13925 | #ifdef ANI_BUS_TYPE_PLATFORM |
Sameer Thalappil | f58d7ec | 2013-04-25 20:17:12 -0700 | [diff] [blame] | 13926 | |
| 13927 | #ifdef HAVE_WCNSS_CAL_DOWNLOAD |
| 13928 | /* wait until WCNSS driver downloads NV */ |
Ravi Kumar Bokka | 7a139e6 | 2016-11-17 21:32:55 +0530 | [diff] [blame] | 13929 | while (!wcnss_device_ready() && 10 >= ++max_retries) { |
Sameer Thalappil | f58d7ec | 2013-04-25 20:17:12 -0700 | [diff] [blame] | 13930 | msleep(1000); |
| 13931 | } |
Siddharth Bhal | c7e79b6 | 2014-10-10 22:37:38 +0530 | [diff] [blame] | 13932 | |
Ravi Kumar Bokka | 7a139e6 | 2016-11-17 21:32:55 +0530 | [diff] [blame] | 13933 | if (max_retries >= 10) { |
Sameer Thalappil | f58d7ec | 2013-04-25 20:17:12 -0700 | [diff] [blame] | 13934 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: WCNSS driver not ready", __func__); |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 13935 | vos_wake_lock_destroy(&wlan_wake_lock); |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 13936 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 13937 | wlan_logging_sock_deinit_svc(); |
| 13938 | #endif |
| 13939 | |
Sameer Thalappil | f58d7ec | 2013-04-25 20:17:12 -0700 | [diff] [blame] | 13940 | return -ENODEV; |
| 13941 | } |
| 13942 | #endif |
| 13943 | |
Siddharth Bhal | c7e79b6 | 2014-10-10 22:37:38 +0530 | [diff] [blame] | 13944 | #ifdef HAVE_CBC_DONE |
| 13945 | while (!wcnss_cbc_complete() && 10 >= ++max_cbc_retries) { |
| 13946 | msleep(1000); |
| 13947 | } |
| 13948 | if (max_cbc_retries >= 10) { |
| 13949 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s:CBC not completed", __func__); |
| 13950 | } |
| 13951 | #endif |
| 13952 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13953 | dev = wcnss_wlan_get_device(); |
| 13954 | #endif // ANI_BUS_TYPE_PLATFORM |
| 13955 | |
| 13956 | |
| 13957 | do { |
| 13958 | if (NULL == dev) { |
| 13959 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: WLAN device not found!!",__func__); |
| 13960 | ret_status = -1; |
| 13961 | break; |
| 13962 | } |
| 13963 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13964 | #ifdef TIMER_MANAGER |
| 13965 | vos_timer_manager_init(); |
| 13966 | #endif |
| 13967 | |
| 13968 | /* Preopen VOSS so that it is ready to start at least SAL */ |
| 13969 | status = vos_preOpen(&pVosContext); |
| 13970 | |
| 13971 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 13972 | { |
| 13973 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Failed to preOpen VOSS", __func__); |
| 13974 | ret_status = -1; |
| 13975 | break; |
| 13976 | } |
| 13977 | |
Sushant Kaushik | 02beb35 | 2015-06-04 15:15:01 +0530 | [diff] [blame] | 13978 | hddTraceInit(); |
Padma, Santhosh Kumar | 9093b20 | 2015-07-21 15:37:38 +0530 | [diff] [blame] | 13979 | hdd_register_debug_callback(); |
| 13980 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 13981 | #ifndef MODULE |
| 13982 | /* For statically linked driver, call hdd_set_conparam to update curr_con_mode |
| 13983 | */ |
| 13984 | hdd_set_conparam((v_UINT_t)con_mode); |
| 13985 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13986 | |
| 13987 | // Call our main init function |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 13988 | if (hdd_wlan_startup(dev)) |
| 13989 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13990 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: WLAN Driver Initialization failed", |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 13991 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13992 | vos_preClose( &pVosContext ); |
| 13993 | ret_status = -1; |
| 13994 | break; |
| 13995 | } |
| 13996 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13997 | } while (0); |
| 13998 | |
| 13999 | if (0 != ret_status) |
| 14000 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14001 | #ifdef TIMER_MANAGER |
| 14002 | vos_timer_exit(); |
| 14003 | #endif |
| 14004 | #ifdef MEMORY_DEBUG |
| 14005 | vos_mem_exit(); |
| 14006 | #endif |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 14007 | vos_wake_lock_destroy(&wlan_wake_lock); |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 14008 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 14009 | wlan_logging_sock_deinit_svc(); |
| 14010 | #endif |
| 14011 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14012 | pr_err("%s: driver load failure\n", WLAN_MODULE_NAME); |
| 14013 | } |
| 14014 | else |
| 14015 | { |
| 14016 | //Send WLAN UP indication to Nlink Service |
| 14017 | send_btc_nlink_msg(WLAN_MODULE_UP_IND, 0); |
| 14018 | |
| 14019 | pr_info("%s: driver loaded\n", WLAN_MODULE_NAME); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14020 | } |
| 14021 | |
| 14022 | EXIT(); |
| 14023 | |
| 14024 | return ret_status; |
| 14025 | } |
| 14026 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 14027 | /**--------------------------------------------------------------------------- |
| 14028 | |
| 14029 | \brief hdd_module_init() - Init Function |
| 14030 | |
| 14031 | This is the driver entry point (invoked when module is loaded using insmod) |
| 14032 | |
| 14033 | \param - None |
| 14034 | |
| 14035 | \return - 0 for success, non zero for failure |
| 14036 | |
| 14037 | --------------------------------------------------------------------------*/ |
| 14038 | #ifdef MODULE |
| 14039 | static int __init hdd_module_init ( void) |
| 14040 | { |
| 14041 | return hdd_driver_init(); |
| 14042 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 14043 | #else /* #ifdef MODULE */ |
| 14044 | static int __init hdd_module_init ( void) |
| 14045 | { |
| 14046 | /* Driver initialization is delayed to fwpath_changed_handler */ |
| 14047 | return 0; |
| 14048 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 14049 | #endif /* #ifdef MODULE */ |
| 14050 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14051 | |
| 14052 | /**--------------------------------------------------------------------------- |
| 14053 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 14054 | \brief hdd_driver_exit() - Exit function |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14055 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 14056 | This is the driver exit point (invoked when module is unloaded using rmmod |
| 14057 | or con_mode was changed by userspace) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14058 | |
| 14059 | \param - None |
| 14060 | |
| 14061 | \return - None |
| 14062 | |
| 14063 | --------------------------------------------------------------------------*/ |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 14064 | static void hdd_driver_exit(void) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14065 | { |
| 14066 | hdd_context_t *pHddCtx = NULL; |
| 14067 | v_CONTEXT_t pVosContext = NULL; |
Agarwal Ashish | 5e41479 | 2014-06-08 15:25:23 +0530 | [diff] [blame] | 14068 | v_REGDOMAIN_t regId; |
Arun Kumar Khandavalli | e0b046d | 2014-03-01 21:54:25 +0530 | [diff] [blame] | 14069 | unsigned long rc = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14070 | |
| 14071 | pr_info("%s: unloading driver v%s\n", WLAN_MODULE_NAME, QWLAN_VERSIONSTR); |
| 14072 | |
| 14073 | //Get the global vos context |
| 14074 | pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL); |
| 14075 | |
| 14076 | if(!pVosContext) |
| 14077 | { |
| 14078 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Global VOS context is Null", __func__); |
| 14079 | goto done; |
| 14080 | } |
| 14081 | |
| 14082 | //Get the HDD context. |
| 14083 | pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext ); |
| 14084 | |
| 14085 | if(!pHddCtx) |
| 14086 | { |
| 14087 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: module exit called before probe",__func__); |
| 14088 | } |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 14089 | else if (VOS_MONITOR_MODE == hdd_get_conparam()) |
| 14090 | { |
| 14091 | hddLog(VOS_TRACE_LEVEL_INFO,"%s: MONITOR MODE",__func__); |
| 14092 | pHddCtx->isLoadUnloadInProgress = WLAN_HDD_UNLOAD_IN_PROGRESS; |
| 14093 | vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, TRUE); |
| 14094 | hdd_wlan_exit(pHddCtx); |
| 14095 | vos_preClose( &pVosContext ); |
| 14096 | goto done; |
| 14097 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14098 | else |
| 14099 | { |
Siddharth Bhal | 2e5871b | 2015-03-24 16:20:51 +0530 | [diff] [blame] | 14100 | /* We wait for active entry threads to exit from driver |
| 14101 | * by waiting until rtnl_lock is available. |
| 14102 | */ |
| 14103 | rtnl_lock(); |
| 14104 | rtnl_unlock(); |
| 14105 | |
Siddharth Bhal | 3c29dca | 2015-02-19 00:41:40 +0530 | [diff] [blame] | 14106 | INIT_COMPLETION(pHddCtx->ssr_comp_var); |
| 14107 | if ((pHddCtx->isLogpInProgress) && (FALSE == |
| 14108 | vos_is_wlan_in_badState(VOS_MODULE_ID_HDD, NULL))) |
| 14109 | { |
Siddharth Bhal | a204f57 | 2015-01-17 02:03:36 +0530 | [diff] [blame] | 14110 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Siddharth Bhal | 3c29dca | 2015-02-19 00:41:40 +0530 | [diff] [blame] | 14111 | "%s:SSR in Progress; block rmmod !!!", __func__); |
Siddharth Bhal | a204f57 | 2015-01-17 02:03:36 +0530 | [diff] [blame] | 14112 | rc = wait_for_completion_timeout(&pHddCtx->ssr_comp_var, |
| 14113 | msecs_to_jiffies(30000)); |
| 14114 | if(!rc) |
| 14115 | { |
| 14116 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 14117 | "%s:SSR timedout, fatal error", __func__); |
| 14118 | VOS_BUG(0); |
| 14119 | } |
| 14120 | } |
| 14121 | |
Siddharth Bhal | 3c29dca | 2015-02-19 00:41:40 +0530 | [diff] [blame] | 14122 | pHddCtx->isLoadUnloadInProgress = WLAN_HDD_UNLOAD_IN_PROGRESS; |
| 14123 | vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, TRUE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14124 | |
c_hpothu | 8adb97b | 2014-12-08 19:38:20 +0530 | [diff] [blame] | 14125 | /* Driver Need to send country code 00 in below condition |
| 14126 | * 1) If gCountryCodePriority is set to 1; and last country |
| 14127 | * code set is through 11d. This needs to be done in case |
| 14128 | * when NV country code is 00. |
| 14129 | * This Needs to be done as when kernel store last country |
| 14130 | * code and if stored country code is not through 11d, |
| 14131 | * in sme_HandleChangeCountryCodeByUser we will disable 11d |
| 14132 | * in next load/unload as soon as we get any country through |
| 14133 | * 11d. In sme_HandleChangeCountryCodeByUser |
| 14134 | * pMsg->countryCode will be last countryCode and |
| 14135 | * pMac->scan.countryCode11d will be country through 11d so |
| 14136 | * due to mismatch driver will disable 11d. |
| 14137 | * |
| 14138 | */ |
Agarwal Ashish | 8db3988 | 2014-07-30 21:56:07 +0530 | [diff] [blame] | 14139 | |
c_hpothu | 8adb97b | 2014-12-08 19:38:20 +0530 | [diff] [blame] | 14140 | if ((eANI_BOOLEAN_TRUE == sme_Is11dCountrycode(pHddCtx->hHal) && |
Agarwal Ashish | 8dcd286 | 2014-07-25 11:58:52 +0530 | [diff] [blame] | 14141 | pHddCtx->cfg_ini->fSupplicantCountryCodeHasPriority && |
Abhishek Singh | 2a70596 | 2014-10-30 14:47:28 +0530 | [diff] [blame] | 14142 | sme_Is11dSupported(pHddCtx->hHal))) |
c_hpothu | 8adb97b | 2014-12-08 19:38:20 +0530 | [diff] [blame] | 14143 | { |
| 14144 | hddLog(VOS_TRACE_LEVEL_INFO, |
Agarwal Ashish | 8dcd286 | 2014-07-25 11:58:52 +0530 | [diff] [blame] | 14145 | FL("CountryCode 00 is being set while unloading driver")); |
c_hpothu | 8adb97b | 2014-12-08 19:38:20 +0530 | [diff] [blame] | 14146 | vos_nv_getRegDomainFromCountryCode(®Id , "00", COUNTRY_USER); |
| 14147 | } |
Agarwal Ashish | 5e41479 | 2014-06-08 15:25:23 +0530 | [diff] [blame] | 14148 | |
c_hpothu | 8adb97b | 2014-12-08 19:38:20 +0530 | [diff] [blame] | 14149 | //Do all the cleanup before deregistering the driver |
| 14150 | hdd_wlan_exit(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14151 | } |
| 14152 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14153 | vos_preClose( &pVosContext ); |
| 14154 | |
| 14155 | #ifdef TIMER_MANAGER |
| 14156 | vos_timer_exit(); |
| 14157 | #endif |
| 14158 | #ifdef MEMORY_DEBUG |
| 14159 | vos_mem_exit(); |
| 14160 | #endif |
| 14161 | |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 14162 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 14163 | wlan_logging_sock_deinit_svc(); |
| 14164 | #endif |
| 14165 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14166 | done: |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 14167 | vos_wake_lock_destroy(&wlan_wake_lock); |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 14168 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14169 | pr_info("%s: driver unloaded\n", WLAN_MODULE_NAME); |
| 14170 | } |
| 14171 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 14172 | /**--------------------------------------------------------------------------- |
| 14173 | |
| 14174 | \brief hdd_module_exit() - Exit function |
| 14175 | |
| 14176 | This is the driver exit point (invoked when module is unloaded using rmmod) |
| 14177 | |
| 14178 | \param - None |
| 14179 | |
| 14180 | \return - None |
| 14181 | |
| 14182 | --------------------------------------------------------------------------*/ |
| 14183 | static void __exit hdd_module_exit(void) |
| 14184 | { |
| 14185 | hdd_driver_exit(); |
| 14186 | } |
| 14187 | |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 14188 | #ifdef MODULE |
| 14189 | static int fwpath_changed_handler(const char *kmessage, |
| 14190 | struct kernel_param *kp) |
| 14191 | { |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 14192 | return param_set_copystring(kmessage, kp); |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 14193 | } |
| 14194 | |
| 14195 | static int con_mode_handler(const char *kmessage, |
| 14196 | struct kernel_param *kp) |
| 14197 | { |
Madan Mohan Koyyalamudi | f2f8d8b | 2012-10-11 17:06:59 -0700 | [diff] [blame] | 14198 | return param_set_int(kmessage, kp); |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 14199 | } |
| 14200 | #else /* #ifdef MODULE */ |
| 14201 | /**--------------------------------------------------------------------------- |
| 14202 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 14203 | \brief kickstart_driver |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 14204 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 14205 | This is the driver entry point |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 14206 | - delayed driver initialization when driver is statically linked |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 14207 | - invoked when module parameter fwpath is modified from userspace to signal |
| 14208 | initializing the WLAN driver or when con_mode is modified from userspace |
| 14209 | to signal a switch in operating mode |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 14210 | |
| 14211 | \return - 0 for success, non zero for failure |
| 14212 | |
| 14213 | --------------------------------------------------------------------------*/ |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 14214 | static int kickstart_driver(void) |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 14215 | { |
Madan Mohan Koyyalamudi | 62e6005 | 2012-10-05 14:27:22 -0700 | [diff] [blame] | 14216 | int ret_status; |
| 14217 | |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 14218 | if (!wlan_hdd_inited) { |
Madan Mohan Koyyalamudi | 62e6005 | 2012-10-05 14:27:22 -0700 | [diff] [blame] | 14219 | ret_status = hdd_driver_init(); |
| 14220 | wlan_hdd_inited = ret_status ? 0 : 1; |
| 14221 | return ret_status; |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 14222 | } |
| 14223 | |
| 14224 | hdd_driver_exit(); |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 14225 | |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 14226 | msleep(200); |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 14227 | |
Madan Mohan Koyyalamudi | 62e6005 | 2012-10-05 14:27:22 -0700 | [diff] [blame] | 14228 | ret_status = hdd_driver_init(); |
| 14229 | wlan_hdd_inited = ret_status ? 0 : 1; |
| 14230 | return ret_status; |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 14231 | } |
| 14232 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14233 | /**--------------------------------------------------------------------------- |
| 14234 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 14235 | \brief fwpath_changed_handler() - Handler Function |
| 14236 | |
| 14237 | Handle changes to the fwpath parameter |
| 14238 | |
| 14239 | \return - 0 for success, non zero for failure |
| 14240 | |
| 14241 | --------------------------------------------------------------------------*/ |
| 14242 | static int fwpath_changed_handler(const char *kmessage, |
| 14243 | struct kernel_param *kp) |
| 14244 | { |
| 14245 | int ret; |
| 14246 | |
| 14247 | ret = param_set_copystring(kmessage, kp); |
| 14248 | if (0 == ret) |
| 14249 | ret = kickstart_driver(); |
| 14250 | return ret; |
| 14251 | } |
| 14252 | |
| 14253 | /**--------------------------------------------------------------------------- |
| 14254 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 14255 | \brief con_mode_handler() - |
| 14256 | |
| 14257 | Handler function for module param con_mode when it is changed by userspace |
| 14258 | Dynamically linked - do nothing |
| 14259 | Statically linked - exit and init driver, as in rmmod and insmod |
| 14260 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 14261 | \param - |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 14262 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 14263 | \return - |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 14264 | |
| 14265 | --------------------------------------------------------------------------*/ |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 14266 | 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] | 14267 | { |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 14268 | int ret; |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 14269 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 14270 | ret = param_set_int(kmessage, kp); |
| 14271 | if (0 == ret) |
| 14272 | ret = kickstart_driver(); |
| 14273 | return ret; |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 14274 | } |
| 14275 | #endif /* #ifdef MODULE */ |
| 14276 | |
| 14277 | /**--------------------------------------------------------------------------- |
| 14278 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14279 | \brief hdd_get_conparam() - |
| 14280 | |
| 14281 | This is the driver exit point (invoked when module is unloaded using rmmod) |
| 14282 | |
| 14283 | \param - None |
| 14284 | |
| 14285 | \return - tVOS_CON_MODE |
| 14286 | |
| 14287 | --------------------------------------------------------------------------*/ |
| 14288 | tVOS_CON_MODE hdd_get_conparam ( void ) |
| 14289 | { |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 14290 | #ifdef MODULE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14291 | return (tVOS_CON_MODE)con_mode; |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 14292 | #else |
| 14293 | return (tVOS_CON_MODE)curr_con_mode; |
| 14294 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14295 | } |
| 14296 | void hdd_set_conparam ( v_UINT_t newParam ) |
| 14297 | { |
| 14298 | con_mode = newParam; |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 14299 | #ifndef MODULE |
| 14300 | curr_con_mode = con_mode; |
| 14301 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14302 | } |
| 14303 | /**--------------------------------------------------------------------------- |
| 14304 | |
| 14305 | \brief hdd_softap_sta_deauth() - function |
| 14306 | |
| 14307 | This to take counter measure to handle deauth req from HDD |
| 14308 | |
| 14309 | \param - pAdapter - Pointer to the HDD |
| 14310 | |
| 14311 | \param - enable - boolean value |
| 14312 | |
| 14313 | \return - None |
| 14314 | |
| 14315 | --------------------------------------------------------------------------*/ |
| 14316 | |
Hanumantha Reddy Pothula | bfd06f7 | 2014-10-31 14:03:37 +0530 | [diff] [blame] | 14317 | VOS_STATUS hdd_softap_sta_deauth(hdd_adapter_t *pAdapter, |
| 14318 | struct tagCsrDelStaParams *pDelStaParams) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14319 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14320 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 14321 | VOS_STATUS vosStatus = VOS_STATUS_E_FAULT; |
Hanumanth Reddy Pothula | 5732363 | 2017-12-06 17:55:09 +0530 | [diff] [blame] | 14322 | struct hdd_cache_sta_info *cache_sta_info; |
| 14323 | ptSapContext pSapCtx = VOS_GET_SAP_CB(pVosContext); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14324 | |
| 14325 | ENTER(); |
| 14326 | |
Jeff Johnson | c135a9a | 2017-09-19 08:37:24 -0700 | [diff] [blame] | 14327 | hddLog(LOG1, "hdd_softap_sta_deauth:(%pK, false)", |
Rajesh Chauhan | 18488fc | 2013-08-22 10:15:03 -0700 | [diff] [blame] | 14328 | (WLAN_HDD_GET_CTX(pAdapter))->pvosContext); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14329 | |
Hanumanth Reddy Pothula | 5732363 | 2017-12-06 17:55:09 +0530 | [diff] [blame] | 14330 | if (!pSapCtx) { |
| 14331 | hddLog(LOGE, "sap context is NULL"); |
| 14332 | return vosStatus; |
| 14333 | } |
| 14334 | |
| 14335 | cache_sta_info = hdd_get_cache_stainfo(pSapCtx->cache_sta_info, |
| 14336 | pDelStaParams->peerMacAddr); |
| 14337 | if (cache_sta_info) { |
| 14338 | cache_sta_info->reason_code = pDelStaParams->reason_code; |
| 14339 | cache_sta_info->rx_rate = |
| 14340 | wlan_tl_get_sta_rx_rate(pVosContext, cache_sta_info->ucSTAId); |
| 14341 | WLANTL_GetSAPStaRSSi(pVosContext, cache_sta_info->ucSTAId, |
| 14342 | &cache_sta_info->rssi); |
| 14343 | } |
| 14344 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14345 | //Ignore request to deauth bcmc station |
Hanumantha Reddy Pothula | bfd06f7 | 2014-10-31 14:03:37 +0530 | [diff] [blame] | 14346 | if (pDelStaParams->peerMacAddr[0] & 0x1) |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 14347 | return vosStatus; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14348 | |
Hanumantha Reddy Pothula | bfd06f7 | 2014-10-31 14:03:37 +0530 | [diff] [blame] | 14349 | vosStatus = WLANSAP_DeauthSta(pVosContext, pDelStaParams); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14350 | |
| 14351 | EXIT(); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 14352 | return vosStatus; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14353 | } |
| 14354 | |
| 14355 | /**--------------------------------------------------------------------------- |
| 14356 | |
Rashmi Ramanna | 1f0948d | 2014-08-28 15:33:48 +0530 | [diff] [blame] | 14357 | \brief hdd_del_all_sta() - function |
| 14358 | |
| 14359 | This function removes all the stations associated on stopping AP/P2P GO. |
| 14360 | |
| 14361 | \param - pAdapter - Pointer to the HDD |
| 14362 | |
| 14363 | \return - None |
| 14364 | |
| 14365 | --------------------------------------------------------------------------*/ |
| 14366 | |
| 14367 | int hdd_del_all_sta(hdd_adapter_t *pAdapter) |
| 14368 | { |
| 14369 | v_U16_t i; |
| 14370 | VOS_STATUS vos_status; |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 14371 | v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
| 14372 | ptSapContext pSapCtx = NULL; |
| 14373 | pSapCtx = VOS_GET_SAP_CB(pVosContext); |
| 14374 | if(pSapCtx == NULL){ |
| 14375 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 14376 | FL("psapCtx is NULL")); |
| 14377 | return 1; |
| 14378 | } |
Rashmi Ramanna | 1f0948d | 2014-08-28 15:33:48 +0530 | [diff] [blame] | 14379 | ENTER(); |
| 14380 | |
| 14381 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 14382 | "%s: Delete all STAs associated.",__func__); |
| 14383 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
| 14384 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
| 14385 | ) |
| 14386 | { |
| 14387 | for(i = 0; i < WLAN_MAX_STA_COUNT; i++) |
| 14388 | { |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 14389 | if ((pSapCtx->aStaInfo[i].isUsed) && |
| 14390 | (!pSapCtx->aStaInfo[i].isDeauthInProgress)) |
Rashmi Ramanna | 1f0948d | 2014-08-28 15:33:48 +0530 | [diff] [blame] | 14391 | { |
Hanumantha Reddy Pothula | bfd06f7 | 2014-10-31 14:03:37 +0530 | [diff] [blame] | 14392 | struct tagCsrDelStaParams delStaParams; |
| 14393 | |
| 14394 | WLANSAP_PopulateDelStaParams( |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 14395 | pSapCtx->aStaInfo[i].macAddrSTA.bytes, |
Sushant Kaushik | 4cd28f6 | 2014-12-26 14:23:50 +0530 | [diff] [blame] | 14396 | eSIR_MAC_DEAUTH_LEAVING_BSS_REASON, |
| 14397 | SIR_MAC_MGMT_DEAUTH >> 4, |
Hanumantha Reddy Pothula | bfd06f7 | 2014-10-31 14:03:37 +0530 | [diff] [blame] | 14398 | &delStaParams); |
| 14399 | vos_status = hdd_softap_sta_deauth(pAdapter, &delStaParams); |
Rashmi Ramanna | 1f0948d | 2014-08-28 15:33:48 +0530 | [diff] [blame] | 14400 | if (VOS_IS_STATUS_SUCCESS(vos_status)) |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 14401 | pSapCtx->aStaInfo[i].isDeauthInProgress = TRUE; |
Rashmi Ramanna | 1f0948d | 2014-08-28 15:33:48 +0530 | [diff] [blame] | 14402 | } |
| 14403 | } |
| 14404 | } |
| 14405 | |
| 14406 | EXIT(); |
| 14407 | return 0; |
| 14408 | } |
| 14409 | |
| 14410 | /**--------------------------------------------------------------------------- |
| 14411 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14412 | \brief hdd_softap_sta_disassoc() - function |
| 14413 | |
| 14414 | This to take counter measure to handle deauth req from HDD |
| 14415 | |
| 14416 | \param - pAdapter - Pointer to the HDD |
| 14417 | |
| 14418 | \param - enable - boolean value |
| 14419 | |
| 14420 | \return - None |
| 14421 | |
| 14422 | --------------------------------------------------------------------------*/ |
| 14423 | |
| 14424 | void hdd_softap_sta_disassoc(hdd_adapter_t *pAdapter,v_U8_t *pDestMacAddress) |
| 14425 | { |
Hanumanth Reddy Pothula | 5732363 | 2017-12-06 17:55:09 +0530 | [diff] [blame] | 14426 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
| 14427 | struct hdd_cache_sta_info *cache_sta_info; |
| 14428 | ptSapContext pSapCtx = VOS_GET_SAP_CB(pVosContext); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14429 | |
| 14430 | ENTER(); |
| 14431 | |
Jeff Johnson | c135a9a | 2017-09-19 08:37:24 -0700 | [diff] [blame] | 14432 | hddLog( LOGE, "hdd_softap_sta_disassoc:(%pK, false)", (WLAN_HDD_GET_CTX(pAdapter))->pvosContext); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14433 | |
Hanumanth Reddy Pothula | 5732363 | 2017-12-06 17:55:09 +0530 | [diff] [blame] | 14434 | if (!pSapCtx) { |
| 14435 | hddLog(LOGE, "sap context is NULL"); |
| 14436 | return ; |
| 14437 | } |
| 14438 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14439 | //Ignore request to disassoc bcmc station |
| 14440 | if( pDestMacAddress[0] & 0x1 ) |
| 14441 | return; |
| 14442 | |
Hanumanth Reddy Pothula | 5732363 | 2017-12-06 17:55:09 +0530 | [diff] [blame] | 14443 | cache_sta_info = hdd_get_cache_stainfo(pSapCtx->cache_sta_info, |
| 14444 | pDestMacAddress); |
| 14445 | if (cache_sta_info) { |
| 14446 | cache_sta_info->reason_code = eSIR_MAC_DEAUTH_LEAVING_BSS_REASON; |
| 14447 | cache_sta_info->rx_rate = |
| 14448 | wlan_tl_get_sta_rx_rate(pVosContext, cache_sta_info->ucSTAId); |
| 14449 | WLANTL_GetSAPStaRSSi(pVosContext, cache_sta_info->ucSTAId, |
| 14450 | &cache_sta_info->rssi); |
| 14451 | } |
| 14452 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14453 | WLANSAP_DisassocSta(pVosContext,pDestMacAddress); |
| 14454 | } |
| 14455 | |
| 14456 | void hdd_softap_tkip_mic_fail_counter_measure(hdd_adapter_t *pAdapter,v_BOOL_t enable) |
| 14457 | { |
| 14458 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
| 14459 | |
| 14460 | ENTER(); |
| 14461 | |
Jeff Johnson | c135a9a | 2017-09-19 08:37:24 -0700 | [diff] [blame] | 14462 | hddLog( LOGE, "hdd_softap_tkip_mic_fail_counter_measure:(%pK, false)", (WLAN_HDD_GET_CTX(pAdapter))->pvosContext); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14463 | |
| 14464 | WLANSAP_SetCounterMeasure(pVosContext, (v_BOOL_t)enable); |
| 14465 | } |
| 14466 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14467 | /**--------------------------------------------------------------------------- |
| 14468 | * |
| 14469 | * \brief hdd_get__concurrency_mode() - |
| 14470 | * |
| 14471 | * |
| 14472 | * \param - None |
| 14473 | * |
| 14474 | * \return - CONCURRENCY MODE |
| 14475 | * |
| 14476 | * --------------------------------------------------------------------------*/ |
| 14477 | tVOS_CONCURRENCY_MODE hdd_get_concurrency_mode ( void ) |
| 14478 | { |
| 14479 | v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL ); |
| 14480 | hdd_context_t *pHddCtx; |
| 14481 | |
| 14482 | if (NULL != pVosContext) |
| 14483 | { |
| 14484 | pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext); |
| 14485 | if (NULL != pHddCtx) |
| 14486 | { |
| 14487 | return (tVOS_CONCURRENCY_MODE)pHddCtx->concurrency_mode; |
| 14488 | } |
| 14489 | } |
| 14490 | |
| 14491 | /* we are in an invalid state :( */ |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 14492 | hddLog(LOGE, "%s: Invalid context", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14493 | return VOS_STA; |
| 14494 | } |
Sushant Kaushik | abb7ee6 | 2014-07-18 16:20:12 +0530 | [diff] [blame] | 14495 | v_BOOL_t |
| 14496 | wlan_hdd_is_GO_power_collapse_allowed (hdd_context_t* pHddCtx) |
| 14497 | { |
| 14498 | hdd_adapter_t *pAdapter = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14499 | |
Sushant Kaushik | abb7ee6 | 2014-07-18 16:20:12 +0530 | [diff] [blame] | 14500 | pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_GO); |
| 14501 | if (pAdapter == NULL) |
| 14502 | { |
| 14503 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 14504 | FL("GO doesn't exist")); |
| 14505 | return TRUE; |
| 14506 | } |
| 14507 | if (test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags)) |
| 14508 | { |
| 14509 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 14510 | FL("GO started")); |
| 14511 | return TRUE; |
| 14512 | } |
| 14513 | else |
| 14514 | /* wait till GO changes its interface to p2p device */ |
| 14515 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 14516 | FL("Del_bss called, avoid apps suspend")); |
| 14517 | return FALSE; |
| 14518 | |
| 14519 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14520 | /* Decide whether to allow/not the apps power collapse. |
| 14521 | * Allow apps power collapse if we are in connected state. |
| 14522 | * if not, allow only if we are in IMPS */ |
| 14523 | v_BOOL_t hdd_is_apps_power_collapse_allowed(hdd_context_t* pHddCtx) |
| 14524 | { |
| 14525 | tPmcState pmcState = pmcGetPmcState(pHddCtx->hHal); |
Srikant Kuppa | fef66a7 | 2013-01-30 17:32:44 -0800 | [diff] [blame] | 14526 | tANI_BOOLEAN scanRspPending = csrNeighborRoamScanRspPending(pHddCtx->hHal); |
Srinivas Girigowda | a553c46 | 2013-03-07 19:42:52 -0800 | [diff] [blame] | 14527 | tANI_BOOLEAN inMiddleOfRoaming = csrNeighborMiddleOfRoaming(pHddCtx->hHal); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14528 | hdd_config_t *pConfig = pHddCtx->cfg_ini; |
| 14529 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 14530 | hdd_adapter_t *pAdapter = NULL; |
| 14531 | VOS_STATUS status; |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 14532 | tVOS_CONCURRENCY_MODE concurrent_state = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14533 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14534 | if (VOS_STA_SAP_MODE == hdd_get_conparam()) |
| 14535 | return TRUE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14536 | |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 14537 | concurrent_state = hdd_get_concurrency_mode(); |
| 14538 | |
Sushant Kaushik | abb7ee6 | 2014-07-18 16:20:12 +0530 | [diff] [blame] | 14539 | if ((concurrent_state == (VOS_STA | VOS_P2P_GO)) && |
| 14540 | !(wlan_hdd_is_GO_power_collapse_allowed(pHddCtx))) |
| 14541 | return FALSE; |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 14542 | #ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE |
Sushant Kaushik | abb7ee6 | 2014-07-18 16:20:12 +0530 | [diff] [blame] | 14543 | |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 14544 | if(((concurrent_state == (VOS_STA | VOS_P2P_CLIENT)) || |
Sushant Kaushik | abb7ee6 | 2014-07-18 16:20:12 +0530 | [diff] [blame] | 14545 | (concurrent_state == (VOS_STA | VOS_P2P_GO)))&& |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 14546 | (IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)) |
| 14547 | return TRUE; |
| 14548 | #endif |
| 14549 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14550 | /*loop through all adapters. TBD fix for Concurrency */ |
| 14551 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 14552 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 14553 | { |
| 14554 | pAdapter = pAdapterNode->pAdapter; |
| 14555 | if ( (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) |
| 14556 | || (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ) |
| 14557 | { |
Srikant Kuppa | fef66a7 | 2013-01-30 17:32:44 -0800 | [diff] [blame] | 14558 | if (((pConfig->fIsImpsEnabled || pConfig->fIsBmpsEnabled) |
c_hpothu | 4e8faac | 2014-05-16 17:38:44 +0530 | [diff] [blame] | 14559 | && (pmcState != IMPS && pmcState != BMPS && pmcState != UAPSD |
c_hpothu | 1c6957d | 2015-01-06 18:19:47 +0530 | [diff] [blame] | 14560 | && pmcState != STOPPED && pmcState != STANDBY && |
| 14561 | pmcState != WOWL)) || |
Srinivas Girigowda | a553c46 | 2013-03-07 19:42:52 -0800 | [diff] [blame] | 14562 | (eANI_BOOLEAN_TRUE == scanRspPending) || |
| 14563 | (eANI_BOOLEAN_TRUE == inMiddleOfRoaming)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14564 | { |
Mukul Sharma | 4be8842 | 2015-03-09 20:29:07 +0530 | [diff] [blame] | 14565 | if(pmcState == FULL_POWER && |
| 14566 | sme_IsCoexScoIndicationSet(pHddCtx->hHal)) |
| 14567 | { |
| 14568 | /* |
| 14569 | * When SCO indication comes from Coex module , host will |
| 14570 | * enter in to full power mode, but this should not prevent |
| 14571 | * apps processor power collapse. |
| 14572 | */ |
| 14573 | hddLog(LOG1, |
| 14574 | FL("Allow apps power collapse" |
| 14575 | "even when sco indication is set")); |
| 14576 | return TRUE; |
| 14577 | } |
Srikant Kuppa | fef66a7 | 2013-01-30 17:32:44 -0800 | [diff] [blame] | 14578 | hddLog( LOGE, "%s: do not allow APPS power collapse-" |
Deepthi Gowri | 03a979f | 2016-11-03 15:20:19 +0530 | [diff] [blame] | 14579 | "pmcState = %d scanRspPending = %d " |
| 14580 | "inMiddleOfRoaming = %d connected = %d", |
| 14581 | __func__, pmcState, scanRspPending, |
| 14582 | inMiddleOfRoaming, hdd_connIsConnected( |
| 14583 | WLAN_HDD_GET_STATION_CTX_PTR( pAdapter ))); |
| 14584 | wlan_hdd_get_tdls_stats(pAdapter); |
| 14585 | return FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14586 | } |
| 14587 | } |
| 14588 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 14589 | pAdapterNode = pNext; |
| 14590 | } |
| 14591 | return TRUE; |
| 14592 | } |
| 14593 | |
Madan Mohan Koyyalamudi | c72a4d6 | 2012-11-08 14:59:34 -0800 | [diff] [blame] | 14594 | /* Decides whether to send suspend notification to Riva |
| 14595 | * if any adapter is in BMPS; then it is required */ |
| 14596 | v_BOOL_t hdd_is_suspend_notify_allowed(hdd_context_t* pHddCtx) |
| 14597 | { |
| 14598 | tPmcState pmcState = pmcGetPmcState(pHddCtx->hHal); |
| 14599 | hdd_config_t *pConfig = pHddCtx->cfg_ini; |
| 14600 | |
| 14601 | if (pConfig->fIsBmpsEnabled && (pmcState == BMPS)) |
| 14602 | { |
| 14603 | return TRUE; |
| 14604 | } |
| 14605 | return FALSE; |
| 14606 | } |
| 14607 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14608 | void wlan_hdd_set_concurrency_mode(hdd_context_t *pHddCtx, tVOS_CON_MODE mode) |
| 14609 | { |
| 14610 | switch(mode) |
| 14611 | { |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 14612 | case VOS_STA_MODE: |
| 14613 | case VOS_P2P_CLIENT_MODE: |
| 14614 | case VOS_P2P_GO_MODE: |
| 14615 | case VOS_STA_SAP_MODE: |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 14616 | case VOS_MONITOR_MODE: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 14617 | pHddCtx->concurrency_mode |= (1 << mode); |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 14618 | pHddCtx->no_of_open_sessions[mode]++; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14619 | break; |
| 14620 | default: |
| 14621 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14622 | } |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 14623 | hddLog(VOS_TRACE_LEVEL_INFO, FL("concurrency_mode = 0x%x " |
| 14624 | "Number of open sessions for mode %d = %d"), |
| 14625 | pHddCtx->concurrency_mode, mode, |
| 14626 | pHddCtx->no_of_open_sessions[mode]); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14627 | } |
| 14628 | |
| 14629 | |
| 14630 | void wlan_hdd_clear_concurrency_mode(hdd_context_t *pHddCtx, tVOS_CON_MODE mode) |
| 14631 | { |
| 14632 | switch(mode) |
| 14633 | { |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 14634 | case VOS_STA_MODE: |
| 14635 | case VOS_P2P_CLIENT_MODE: |
| 14636 | case VOS_P2P_GO_MODE: |
| 14637 | case VOS_STA_SAP_MODE: |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 14638 | case VOS_MONITOR_MODE: |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 14639 | pHddCtx->no_of_open_sessions[mode]--; |
| 14640 | if (!(pHddCtx->no_of_open_sessions[mode])) |
| 14641 | pHddCtx->concurrency_mode &= (~(1 << mode)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14642 | break; |
| 14643 | default: |
| 14644 | break; |
| 14645 | } |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 14646 | hddLog(VOS_TRACE_LEVEL_INFO, FL("concurrency_mode = 0x%x " |
| 14647 | "Number of open sessions for mode %d = %d"), |
| 14648 | pHddCtx->concurrency_mode, mode, pHddCtx->no_of_open_sessions[mode]); |
| 14649 | |
| 14650 | } |
| 14651 | /**--------------------------------------------------------------------------- |
| 14652 | * |
| 14653 | * \brief wlan_hdd_incr_active_session() |
| 14654 | * |
| 14655 | * This function increments the number of active sessions |
| 14656 | * maintained per device mode |
| 14657 | * Incase of STA/P2P CLI/IBSS upon connection indication it is incremented |
| 14658 | * Incase of SAP/P2P GO upon bss start it is incremented |
| 14659 | * |
| 14660 | * \param pHddCtx - HDD Context |
| 14661 | * \param mode - device mode |
| 14662 | * |
| 14663 | * \return - None |
| 14664 | * |
| 14665 | * --------------------------------------------------------------------------*/ |
| 14666 | void wlan_hdd_incr_active_session(hdd_context_t *pHddCtx, tVOS_CON_MODE mode) |
| 14667 | { |
| 14668 | switch (mode) { |
| 14669 | case VOS_STA_MODE: |
| 14670 | case VOS_P2P_CLIENT_MODE: |
| 14671 | case VOS_P2P_GO_MODE: |
| 14672 | case VOS_STA_SAP_MODE: |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 14673 | case VOS_MONITOR_MODE: |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 14674 | pHddCtx->no_of_active_sessions[mode]++; |
| 14675 | break; |
| 14676 | default: |
| 14677 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Not Expected Mode %d"), mode); |
| 14678 | break; |
| 14679 | } |
| 14680 | hddLog(VOS_TRACE_LEVEL_INFO, FL("No.# of active sessions for mode %d = %d"), |
| 14681 | mode, |
| 14682 | pHddCtx->no_of_active_sessions[mode]); |
| 14683 | } |
| 14684 | |
| 14685 | /**--------------------------------------------------------------------------- |
| 14686 | * |
| 14687 | * \brief wlan_hdd_decr_active_session() |
| 14688 | * |
| 14689 | * This function decrements the number of active sessions |
| 14690 | * maintained per device mode |
| 14691 | * Incase of STA/P2P CLI/IBSS upon disconnection it is decremented |
| 14692 | * Incase of SAP/P2P GO upon bss stop it is decremented |
| 14693 | * |
| 14694 | * \param pHddCtx - HDD Context |
| 14695 | * \param mode - device mode |
| 14696 | * |
| 14697 | * \return - None |
| 14698 | * |
| 14699 | * --------------------------------------------------------------------------*/ |
| 14700 | void wlan_hdd_decr_active_session(hdd_context_t *pHddCtx, tVOS_CON_MODE mode) |
| 14701 | { |
Bhargav Shah | d071591 | 2015-10-01 18:17:37 +0530 | [diff] [blame] | 14702 | |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 14703 | switch (mode) { |
| 14704 | case VOS_STA_MODE: |
| 14705 | case VOS_P2P_CLIENT_MODE: |
| 14706 | case VOS_P2P_GO_MODE: |
| 14707 | case VOS_STA_SAP_MODE: |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 14708 | case VOS_MONITOR_MODE: |
Agarwal Ashish | 5325f52 | 2014-08-06 00:58:44 +0530 | [diff] [blame] | 14709 | if (pHddCtx->no_of_active_sessions[mode] > 0) |
| 14710 | pHddCtx->no_of_active_sessions[mode]--; |
| 14711 | else |
| 14712 | hddLog(VOS_TRACE_LEVEL_INFO, FL(" No.# of Active sessions" |
| 14713 | "is already Zero")); |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 14714 | break; |
| 14715 | default: |
| 14716 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Not Expected Mode %d"), mode); |
| 14717 | break; |
| 14718 | } |
| 14719 | hddLog(VOS_TRACE_LEVEL_INFO, FL("No.# of active sessions for mode %d = %d"), |
| 14720 | mode, |
| 14721 | pHddCtx->no_of_active_sessions[mode]); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14722 | } |
| 14723 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 14724 | /**--------------------------------------------------------------------------- |
| 14725 | * |
| 14726 | * \brief wlan_hdd_restart_init |
| 14727 | * |
| 14728 | * This function initalizes restart timer/flag. An internal function. |
| 14729 | * |
| 14730 | * \param - pHddCtx |
| 14731 | * |
| 14732 | * \return - None |
| 14733 | * |
| 14734 | * --------------------------------------------------------------------------*/ |
| 14735 | |
| 14736 | static void wlan_hdd_restart_init(hdd_context_t *pHddCtx) |
| 14737 | { |
| 14738 | /* Initialize */ |
| 14739 | pHddCtx->hdd_restart_retries = 0; |
| 14740 | atomic_set(&pHddCtx->isRestartInProgress, 0); |
| 14741 | vos_timer_init(&pHddCtx->hdd_restart_timer, |
| 14742 | VOS_TIMER_TYPE_SW, |
| 14743 | wlan_hdd_restart_timer_cb, |
| 14744 | pHddCtx); |
| 14745 | } |
| 14746 | /**--------------------------------------------------------------------------- |
| 14747 | * |
| 14748 | * \brief wlan_hdd_restart_deinit |
| 14749 | * |
| 14750 | * This function cleans up the resources used. An internal function. |
| 14751 | * |
| 14752 | * \param - pHddCtx |
| 14753 | * |
| 14754 | * \return - None |
| 14755 | * |
| 14756 | * --------------------------------------------------------------------------*/ |
| 14757 | |
| 14758 | static void wlan_hdd_restart_deinit(hdd_context_t* pHddCtx) |
| 14759 | { |
| 14760 | |
| 14761 | VOS_STATUS vos_status; |
| 14762 | /* Block any further calls */ |
| 14763 | atomic_set(&pHddCtx->isRestartInProgress, 1); |
| 14764 | /* Cleanup */ |
| 14765 | vos_status = vos_timer_stop( &pHddCtx->hdd_restart_timer ); |
| 14766 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 14767 | hddLog(LOGE, FL("Failed to stop HDD restart timer")); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 14768 | vos_status = vos_timer_destroy(&pHddCtx->hdd_restart_timer); |
| 14769 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 14770 | hddLog(LOGE, FL("Failed to destroy HDD restart timer")); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 14771 | |
| 14772 | } |
| 14773 | |
| 14774 | /**--------------------------------------------------------------------------- |
| 14775 | * |
| 14776 | * \brief wlan_hdd_framework_restart |
| 14777 | * |
| 14778 | * This function uses a cfg80211 API to start a framework initiated WLAN |
| 14779 | * driver module unload/load. |
| 14780 | * |
| 14781 | * Also this API keep retrying (WLAN_HDD_RESTART_RETRY_MAX_CNT). |
| 14782 | * |
| 14783 | * |
| 14784 | * \param - pHddCtx |
| 14785 | * |
| 14786 | * \return - VOS_STATUS_SUCCESS: Success |
| 14787 | * VOS_STATUS_E_EMPTY: Adapter is Empty |
| 14788 | * VOS_STATUS_E_NOMEM: No memory |
| 14789 | |
| 14790 | * --------------------------------------------------------------------------*/ |
| 14791 | |
| 14792 | static VOS_STATUS wlan_hdd_framework_restart(hdd_context_t *pHddCtx) |
| 14793 | { |
| 14794 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 14795 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
Madan Mohan Koyyalamudi | fc19e44 | 2013-05-09 18:24:08 -0700 | [diff] [blame] | 14796 | int len = (sizeof (struct ieee80211_mgmt)); |
| 14797 | struct ieee80211_mgmt *mgmt = NULL; |
| 14798 | |
| 14799 | /* Prepare the DEAUTH managment frame with reason code */ |
| 14800 | mgmt = kzalloc(len, GFP_KERNEL); |
| 14801 | if(mgmt == NULL) |
| 14802 | { |
| 14803 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 14804 | "%s: memory allocation failed (%d bytes)", __func__, len); |
| 14805 | return VOS_STATUS_E_NOMEM; |
| 14806 | } |
| 14807 | mgmt->u.deauth.reason_code = WLAN_REASON_DISASSOC_LOW_ACK; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 14808 | |
| 14809 | /* Iterate over all adapters/devices */ |
| 14810 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
Hanumantha Reddy Pothula | da0fe36 | 2015-02-27 18:37:03 +0530 | [diff] [blame] | 14811 | if ((NULL == pAdapterNode) || (VOS_STATUS_SUCCESS != status)) |
| 14812 | { |
| 14813 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | c135a9a | 2017-09-19 08:37:24 -0700 | [diff] [blame] | 14814 | FL("fail to get adapter: %pK %d"), pAdapterNode, status); |
Hanumantha Reddy Pothula | da0fe36 | 2015-02-27 18:37:03 +0530 | [diff] [blame] | 14815 | goto end; |
| 14816 | } |
| 14817 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 14818 | do |
| 14819 | { |
Hanumantha Reddy Pothula | da0fe36 | 2015-02-27 18:37:03 +0530 | [diff] [blame] | 14820 | if(pAdapterNode->pAdapter && |
| 14821 | WLAN_HDD_ADAPTER_MAGIC == pAdapterNode->pAdapter->magic) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 14822 | { |
| 14823 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 14824 | "restarting the driver(intf:\'%s\' mode:%d :try %d)", |
| 14825 | pAdapterNode->pAdapter->dev->name, |
| 14826 | pAdapterNode->pAdapter->device_mode, |
| 14827 | pHddCtx->hdd_restart_retries + 1); |
Madan Mohan Koyyalamudi | fc19e44 | 2013-05-09 18:24:08 -0700 | [diff] [blame] | 14828 | /* |
| 14829 | * CFG80211 event to restart the driver |
| 14830 | * |
| 14831 | * 'cfg80211_send_unprot_deauth' sends a |
| 14832 | * NL80211_CMD_UNPROT_DEAUTHENTICATE event to supplicant at any state |
| 14833 | * of SME(Linux Kernel) state machine. |
| 14834 | * |
| 14835 | * Reason code WLAN_REASON_DISASSOC_LOW_ACK is currently used to restart |
| 14836 | * the driver. |
| 14837 | * |
| 14838 | */ |
Abhishek Singh | 00b7197 | 2016-01-07 10:51:04 +0530 | [diff] [blame] | 14839 | |
Anand N Sunkad | e9adb1b | 2015-07-29 09:56:45 +0530 | [diff] [blame] | 14840 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 14841 | cfg80211_rx_unprot_mlme_mgmt(pAdapterNode->pAdapter->dev, (u_int8_t*)mgmt, len); |
| 14842 | #else |
Madan Mohan Koyyalamudi | fc19e44 | 2013-05-09 18:24:08 -0700 | [diff] [blame] | 14843 | 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] | 14844 | #endif |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 14845 | } |
| 14846 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 14847 | pAdapterNode = pNext; |
| 14848 | } while((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status)); |
| 14849 | |
Hanumantha Reddy Pothula | da0fe36 | 2015-02-27 18:37:03 +0530 | [diff] [blame] | 14850 | end: |
Madan Mohan Koyyalamudi | fc19e44 | 2013-05-09 18:24:08 -0700 | [diff] [blame] | 14851 | /* Free the allocated management frame */ |
| 14852 | kfree(mgmt); |
| 14853 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 14854 | /* Retry until we unload or reach max count */ |
| 14855 | if(++pHddCtx->hdd_restart_retries < WLAN_HDD_RESTART_RETRY_MAX_CNT) |
| 14856 | vos_timer_start(&pHddCtx->hdd_restart_timer, WLAN_HDD_RESTART_RETRY_DELAY_MS); |
| 14857 | |
| 14858 | return status; |
| 14859 | |
| 14860 | } |
| 14861 | /**--------------------------------------------------------------------------- |
| 14862 | * |
| 14863 | * \brief wlan_hdd_restart_timer_cb |
| 14864 | * |
| 14865 | * Restart timer callback. An internal function. |
| 14866 | * |
| 14867 | * \param - User data: |
| 14868 | * |
| 14869 | * \return - None |
| 14870 | * |
| 14871 | * --------------------------------------------------------------------------*/ |
| 14872 | |
| 14873 | void wlan_hdd_restart_timer_cb(v_PVOID_t usrDataForCallback) |
| 14874 | { |
| 14875 | hdd_context_t *pHddCtx = usrDataForCallback; |
| 14876 | wlan_hdd_framework_restart(pHddCtx); |
| 14877 | return; |
| 14878 | |
| 14879 | } |
| 14880 | |
| 14881 | |
| 14882 | /**--------------------------------------------------------------------------- |
| 14883 | * |
| 14884 | * \brief wlan_hdd_restart_driver |
| 14885 | * |
| 14886 | * This function sends an event to supplicant to restart the WLAN driver. |
| 14887 | * |
| 14888 | * This function is called from vos_wlanRestart. |
| 14889 | * |
| 14890 | * \param - pHddCtx |
| 14891 | * |
| 14892 | * \return - VOS_STATUS_SUCCESS: Success |
| 14893 | * VOS_STATUS_E_EMPTY: Adapter is Empty |
| 14894 | * VOS_STATUS_E_ALREADY: Request already in progress |
| 14895 | |
| 14896 | * --------------------------------------------------------------------------*/ |
| 14897 | VOS_STATUS wlan_hdd_restart_driver(hdd_context_t *pHddCtx) |
| 14898 | { |
| 14899 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 14900 | |
| 14901 | /* A tight check to make sure reentrancy */ |
| 14902 | if(atomic_xchg(&pHddCtx->isRestartInProgress, 1)) |
| 14903 | { |
Mihir Shete | fd52865 | 2014-06-23 19:07:50 +0530 | [diff] [blame] | 14904 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 14905 | "%s: WLAN restart is already in progress", __func__); |
| 14906 | |
| 14907 | return VOS_STATUS_E_ALREADY; |
| 14908 | } |
Sameer Thalappil | 0c164f5 | 2013-03-28 15:27:56 -0700 | [diff] [blame] | 14909 | /* Send reset FIQ to WCNSS to invoke SSR. */ |
Madan Mohan Koyyalamudi | e388b34 | 2012-11-08 15:03:16 -0800 | [diff] [blame] | 14910 | #ifdef HAVE_WCNSS_RESET_INTR |
Siddharth Bhal | 864e7e8 | 2015-04-07 20:07:24 +0530 | [diff] [blame] | 14911 | wcnss_reset_fiq(TRUE); |
Madan Mohan Koyyalamudi | bb8f017 | 2012-09-28 15:36:06 -0700 | [diff] [blame] | 14912 | #endif |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 14913 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 14914 | return status; |
| 14915 | } |
| 14916 | |
Bhargav Shah | d071591 | 2015-10-01 18:17:37 +0530 | [diff] [blame] | 14917 | /** |
| 14918 | * hdd_get_total_sessions() - provide total number of active sessions |
| 14919 | * @pHddCtx: Valid Global HDD context pointer |
| 14920 | * |
| 14921 | * This function iterates through pAdaptors and find the number of all active |
| 14922 | * sessions. This active sessions includes connected sta, p2p client and number |
| 14923 | * of client connected to sap/p2p go. |
| 14924 | * |
| 14925 | * Return: Total number of active sessions. |
| 14926 | */ |
| 14927 | v_U8_t hdd_get_total_sessions(hdd_context_t *pHddCtx) |
| 14928 | { |
| 14929 | v_U8_t active_session = 0; |
| 14930 | hdd_station_ctx_t *pHddStaCtx; |
| 14931 | hdd_adapter_list_node_t *pAdapterNode, *pNext; |
| 14932 | hdd_adapter_t *pAdapter; |
| 14933 | VOS_STATUS status; |
| 14934 | |
| 14935 | status = hdd_get_front_adapter(pHddCtx, &pAdapterNode); |
| 14936 | while (NULL != pAdapterNode && VOS_STATUS_SUCCESS == status) { |
| 14937 | pAdapter = pAdapterNode->pAdapter; |
| 14938 | switch (pAdapter->device_mode) { |
| 14939 | case VOS_STA_MODE: |
| 14940 | case VOS_P2P_CLIENT_MODE: |
| 14941 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 14942 | if(eConnectionState_Associated == pHddStaCtx->conn_info.connState) |
| 14943 | active_session += 1; |
| 14944 | break; |
| 14945 | case VOS_STA_SAP_MODE: |
| 14946 | case VOS_P2P_GO_MODE: |
| 14947 | active_session += hdd_softap_get_connected_sta(pAdapter); |
| 14948 | break; |
| 14949 | default: |
| 14950 | break; |
| 14951 | } |
| 14952 | |
| 14953 | status = hdd_get_next_adapter(pHddCtx, pAdapterNode, &pNext); |
| 14954 | pAdapterNode = pNext; |
| 14955 | } |
| 14956 | |
| 14957 | return active_session; |
| 14958 | } |
| 14959 | |
| 14960 | /** |
| 14961 | * hdd_set_delack_value() - Set delack value |
| 14962 | * @pHddCtx: Valid Global HDD context pointer |
| 14963 | * @next_rx_level: Value to set for delack |
| 14964 | * |
| 14965 | * This function compare present value and next value of delack. If the both |
| 14966 | * are diffrent then it sets next value . |
| 14967 | * |
| 14968 | * Return: void. |
| 14969 | */ |
| 14970 | void hdd_set_delack_value(hdd_context_t *pHddCtx, v_U32_t next_rx_level) |
| 14971 | { |
| 14972 | if (pHddCtx->cur_rx_level != next_rx_level) { |
| 14973 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_DEBUG, |
| 14974 | "%s: TCP DELACK trigger level %d", |
| 14975 | __func__, next_rx_level); |
| 14976 | mutex_lock(&pHddCtx->cur_rx_level_lock); |
| 14977 | pHddCtx->cur_rx_level = next_rx_level; |
| 14978 | mutex_unlock(&pHddCtx->cur_rx_level_lock); |
| 14979 | wlan_hdd_send_svc_nlink_msg(WLAN_SVC_WLAN_TP_IND, &next_rx_level, |
| 14980 | sizeof(next_rx_level)); |
| 14981 | } |
| 14982 | } |
| 14983 | |
| 14984 | /** |
| 14985 | * hdd_set_default_stop_delack_timer() - Start delack timer |
| 14986 | * @pHddCtx: Valid Global HDD context pointer |
| 14987 | * |
| 14988 | * This function stop delack timer and set delack value to default.. |
| 14989 | * |
| 14990 | * Return: void. |
| 14991 | */ |
| 14992 | |
| 14993 | void hdd_set_default_stop_delack_timer(hdd_context_t *pHddCtx) |
| 14994 | { |
| 14995 | if (VOS_TIMER_STATE_RUNNING != |
| 14996 | vos_timer_getCurrentState(&pHddCtx->delack_timer)) { |
| 14997 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_DEBUG, |
| 14998 | "%s: Can not stop timer", __func__); |
| 14999 | return; |
| 15000 | } |
| 15001 | |
| 15002 | vos_timer_stop(&pHddCtx->delack_timer); |
| 15003 | hdd_set_delack_value(pHddCtx, TP_IND_LOW); |
| 15004 | } |
| 15005 | |
| 15006 | /** |
| 15007 | * hdd_start_delack_timer() - Start delack timer |
| 15008 | * @pHddCtx: Valid Global HDD context pointer |
| 15009 | * |
| 15010 | * This function starts the delack timer for tcpDelAckComputeInterval time |
| 15011 | * interval.The default timer value is 2 second. |
| 15012 | * |
| 15013 | * Return: void. |
| 15014 | */ |
| 15015 | void hdd_start_delack_timer(hdd_context_t *pHddCtx) |
| 15016 | { |
| 15017 | if (VOS_TIMER_STATE_RUNNING == |
| 15018 | vos_timer_getCurrentState(&pHddCtx->delack_timer)) { |
| 15019 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_DEBUG, |
| 15020 | "%s: Timer is already running", __func__); |
| 15021 | return; |
| 15022 | } |
| 15023 | |
| 15024 | vos_timer_start(&pHddCtx->delack_timer, |
| 15025 | pHddCtx->cfg_ini->tcpDelAckComputeInterval); |
| 15026 | } |
| 15027 | |
| 15028 | /** |
| 15029 | * hdd_update_prev_rx_packet_count() - Update previous rx packet count |
| 15030 | * @pHddCtx: Valid Global HDD context pointer |
| 15031 | * |
| 15032 | * This function updates the prev_rx_packets count from the corresponding |
| 15033 | * pAdapter states. This prev_rx_packets will diffed with the packet count |
| 15034 | * at the end of delack timer. That can give number of RX packet is spacific |
| 15035 | * time. |
| 15036 | * |
| 15037 | * Return: void. |
| 15038 | */ |
| 15039 | void hdd_update_prev_rx_packet_count(hdd_context_t *pHddCtx) |
| 15040 | { |
| 15041 | hdd_adapter_list_node_t *pAdapterNode, *pNext; |
| 15042 | hdd_adapter_t *pAdapter; |
| 15043 | VOS_STATUS status; |
| 15044 | |
| 15045 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 15046 | while (NULL != pAdapterNode && VOS_STATUS_SUCCESS == status) { |
| 15047 | pAdapter = pAdapterNode->pAdapter; |
| 15048 | pAdapter->prev_rx_packets = pAdapter->stats.rx_packets; |
| 15049 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 15050 | pAdapterNode = pNext; |
| 15051 | } |
| 15052 | } |
| 15053 | |
| 15054 | /** |
| 15055 | * hdd_manage_delack_timer() - start\stop delack timer |
| 15056 | * @pHddCtx: Valid Global HDD context pointer |
| 15057 | * |
| 15058 | * This function check the number of concerent session present, it starts the |
| 15059 | * delack timer if only one session is present. |
| 15060 | * In the case of BT_COEX and TDLS mode it blindly stop delack functionality. |
| 15061 | * |
| 15062 | * Return: void. |
| 15063 | */ |
| 15064 | void hdd_manage_delack_timer(hdd_context_t *pHddCtx) |
| 15065 | { |
| 15066 | uint8_t sessions; |
| 15067 | |
| 15068 | if (!pHddCtx->cfg_ini->enable_delack) { |
| 15069 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_DEBUG, |
| 15070 | "%s: TCP DELACK is not enabled", __func__); |
| 15071 | return; |
| 15072 | } |
| 15073 | |
| 15074 | /* Blindly stop timer of BTCOEX and TDLS Session is up */ |
| 15075 | if (pHddCtx->mode != 0) { |
| 15076 | hdd_set_default_stop_delack_timer(pHddCtx); |
| 15077 | return; |
| 15078 | } |
| 15079 | |
| 15080 | sessions = hdd_get_total_sessions(pHddCtx); |
| 15081 | if (sessions == 1) { |
| 15082 | hdd_update_prev_rx_packet_count(pHddCtx); |
| 15083 | hdd_start_delack_timer(pHddCtx); |
| 15084 | } else { |
| 15085 | hdd_set_default_stop_delack_timer(pHddCtx); |
| 15086 | } |
| 15087 | } |
| 15088 | |
Mihir Shete | e1093ba | 2014-01-21 20:13:32 +0530 | [diff] [blame] | 15089 | /**--------------------------------------------------------------------------- |
| 15090 | * |
| 15091 | * \brief wlan_hdd_init_channels |
| 15092 | * |
| 15093 | * This function is used to initialize the channel list in CSR |
| 15094 | * |
| 15095 | * This function is called from hdd_wlan_startup |
| 15096 | * |
| 15097 | * \param - pHddCtx: HDD context |
| 15098 | * |
| 15099 | * \return - VOS_STATUS_SUCCESS: Success |
| 15100 | * VOS_STATUS_E_FAULT: Failure reported by SME |
| 15101 | |
| 15102 | * --------------------------------------------------------------------------*/ |
| 15103 | static VOS_STATUS wlan_hdd_init_channels(hdd_context_t *pHddCtx) |
| 15104 | { |
| 15105 | eHalStatus status; |
| 15106 | |
| 15107 | status = sme_InitChannels(pHddCtx->hHal); |
| 15108 | if (HAL_STATUS_SUCCESS(status)) |
| 15109 | { |
| 15110 | return VOS_STATUS_SUCCESS; |
| 15111 | } |
| 15112 | else |
| 15113 | { |
| 15114 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Channel initialization failed(%d)", |
| 15115 | __func__, status); |
| 15116 | return VOS_STATUS_E_FAULT; |
| 15117 | } |
| 15118 | } |
| 15119 | |
Mihir Shete | 0420645 | 2014-11-20 17:50:58 +0530 | [diff] [blame] | 15120 | #ifdef CONFIG_ENABLE_LINUX_REG |
Agarwal Ashish | 6db9d53 | 2014-09-30 18:19:10 +0530 | [diff] [blame] | 15121 | 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] | 15122 | { |
| 15123 | eHalStatus status; |
| 15124 | |
Agarwal Ashish | 6db9d53 | 2014-09-30 18:19:10 +0530 | [diff] [blame] | 15125 | status = sme_InitChannelsForCC(pHddCtx->hHal, init); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 15126 | if (HAL_STATUS_SUCCESS(status)) |
| 15127 | { |
| 15128 | return VOS_STATUS_SUCCESS; |
| 15129 | } |
| 15130 | else |
| 15131 | { |
| 15132 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Issue reg hint failed(%d)", |
| 15133 | __func__, status); |
| 15134 | return VOS_STATUS_E_FAULT; |
| 15135 | } |
| 15136 | } |
Mihir Shete | 0420645 | 2014-11-20 17:50:58 +0530 | [diff] [blame] | 15137 | #endif |
Sudhir Sattayappa Kohalli | b1d8c3a | 2013-06-18 14:47:20 -0700 | [diff] [blame] | 15138 | /* |
| 15139 | * API to find if there is any STA or P2P-Client is connected |
| 15140 | */ |
| 15141 | VOS_STATUS hdd_issta_p2p_clientconnected(hdd_context_t *pHddCtx) |
| 15142 | { |
| 15143 | return sme_isSta_p2p_clientConnected(pHddCtx->hHal); |
| 15144 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 15145 | |
Mihir Shete | e2ae82a | 2015-03-16 14:08:49 +0530 | [diff] [blame] | 15146 | |
| 15147 | /* |
| 15148 | * API to find if the firmware will send logs using DXE channel |
| 15149 | */ |
| 15150 | v_U8_t hdd_is_fw_logging_enabled(void) |
| 15151 | { |
| 15152 | hdd_context_t *pHddCtx; |
| 15153 | |
| 15154 | pHddCtx = vos_get_context(VOS_MODULE_ID_HDD, |
| 15155 | vos_get_global_context(VOS_MODULE_ID_HDD, NULL)); |
| 15156 | |
Sachin Ahuja | 084313e | 2015-05-21 17:57:10 +0530 | [diff] [blame] | 15157 | return (pHddCtx && pHddCtx->cfg_ini->enableMgmtLogging); |
Mihir Shete | e2ae82a | 2015-03-16 14:08:49 +0530 | [diff] [blame] | 15158 | } |
| 15159 | |
Agarwal Ashish | 57e8437 | 2014-12-05 18:26:53 +0530 | [diff] [blame] | 15160 | /* |
Mihir Shete | be94ebb | 2015-05-26 12:07:14 +0530 | [diff] [blame] | 15161 | * API to find if the firmware will send trace logs using DXE channel |
| 15162 | */ |
| 15163 | v_U8_t hdd_is_fw_ev_logging_enabled(void) |
| 15164 | { |
| 15165 | hdd_context_t *pHddCtx; |
| 15166 | |
| 15167 | pHddCtx = vos_get_context(VOS_MODULE_ID_HDD, |
| 15168 | vos_get_global_context(VOS_MODULE_ID_HDD, NULL)); |
| 15169 | |
| 15170 | return (pHddCtx && pHddCtx->cfg_ini->enableFWLogging); |
| 15171 | } |
| 15172 | /* |
Agarwal Ashish | 57e8437 | 2014-12-05 18:26:53 +0530 | [diff] [blame] | 15173 | * API to find if there is any session connected |
| 15174 | */ |
| 15175 | VOS_STATUS hdd_is_any_session_connected(hdd_context_t *pHddCtx) |
| 15176 | { |
| 15177 | return sme_is_any_session_connected(pHddCtx->hHal); |
| 15178 | } |
| 15179 | |
| 15180 | |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 15181 | int wlan_hdd_scan_abort(hdd_adapter_t *pAdapter) |
| 15182 | { |
| 15183 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 15184 | hdd_scaninfo_t *pScanInfo = NULL; |
Girish Gowli | 4bf7a63 | 2014-06-12 13:42:11 +0530 | [diff] [blame] | 15185 | long status = 0; |
c_hpothu | a3d45d5 | 2015-01-05 14:11:17 +0530 | [diff] [blame] | 15186 | tSirAbortScanStatus abortScanStatus; |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 15187 | |
| 15188 | pScanInfo = &pHddCtx->scan_info; |
Ratnam Rachuri | c768113 | 2015-06-30 10:35:13 +0530 | [diff] [blame] | 15189 | INIT_COMPLETION(pScanInfo->abortscan_event_var); |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 15190 | if (pScanInfo->mScanPending) |
| 15191 | { |
c_hpothu | a3d45d5 | 2015-01-05 14:11:17 +0530 | [diff] [blame] | 15192 | abortScanStatus = hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId, |
| 15193 | eCSR_SCAN_ABORT_DEFAULT); |
| 15194 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 15195 | FL("abortScanStatus: %d"), abortScanStatus); |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 15196 | |
c_hpothu | a3d45d5 | 2015-01-05 14:11:17 +0530 | [diff] [blame] | 15197 | /* If there is active scan command lets wait for the completion else |
| 15198 | * there is no need to wait as scan command might be in the SME pending |
| 15199 | * command list. |
| 15200 | */ |
| 15201 | if (abortScanStatus == eSIR_ABORT_ACTIVE_SCAN_LIST_NOT_EMPTY) |
| 15202 | { |
Mukul Sharma | b392b64 | 2017-08-17 17:45:29 +0530 | [diff] [blame] | 15203 | status = wait_for_completion_timeout( |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 15204 | &pScanInfo->abortscan_event_var, |
| 15205 | msecs_to_jiffies(5000)); |
c_hpothu | a3d45d5 | 2015-01-05 14:11:17 +0530 | [diff] [blame] | 15206 | if (0 >= status) |
| 15207 | { |
| 15208 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Girish Gowli | 4bf7a63 | 2014-06-12 13:42:11 +0530 | [diff] [blame] | 15209 | "%s: Timeout or Interrupt occurred while waiting for abort" |
| 15210 | "scan, status- %ld", __func__, status); |
c_hpothu | a3d45d5 | 2015-01-05 14:11:17 +0530 | [diff] [blame] | 15211 | return -ETIMEDOUT; |
| 15212 | } |
| 15213 | } |
| 15214 | else if (abortScanStatus == eSIR_ABORT_SCAN_FAILURE) |
| 15215 | { |
| 15216 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 15217 | FL("hdd_abort_mac_scan failed")); |
| 15218 | return -VOS_STATUS_E_FAILURE; |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 15219 | } |
| 15220 | } |
Girish Gowli | 4bf7a63 | 2014-06-12 13:42:11 +0530 | [diff] [blame] | 15221 | return 0; |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 15222 | } |
| 15223 | |
Abhishek Singh | 7d624e1 | 2015-11-30 14:29:27 +0530 | [diff] [blame] | 15224 | /** |
| 15225 | * hdd_indicate_mgmt_frame() - Wrapper to indicate management frame to |
| 15226 | * user space |
| 15227 | * @frame_ind: Management frame data to be informed. |
| 15228 | * |
| 15229 | * This function is used to indicate management frame to |
| 15230 | * user space |
| 15231 | * |
| 15232 | * Return: None |
| 15233 | * |
| 15234 | */ |
| 15235 | void hdd_indicate_mgmt_frame(tSirSmeMgmtFrameInd *frame_ind) |
| 15236 | { |
| 15237 | hdd_context_t *hdd_ctx = NULL; |
| 15238 | hdd_adapter_t *adapter = NULL; |
| 15239 | v_CONTEXT_t vos_context = NULL; |
| 15240 | |
| 15241 | /* Get the global VOSS context.*/ |
| 15242 | vos_context = vos_get_global_context(VOS_MODULE_ID_SYS, NULL); |
| 15243 | if (!vos_context) { |
| 15244 | hddLog(LOGE, FL("Global VOS context is Null")); |
| 15245 | return; |
| 15246 | } |
| 15247 | /* Get the HDD context.*/ |
| 15248 | hdd_ctx = |
| 15249 | (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, vos_context ); |
| 15250 | |
| 15251 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
| 15252 | { |
| 15253 | return; |
| 15254 | } |
| 15255 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, |
| 15256 | frame_ind->sessionId); |
| 15257 | |
| 15258 | if ((NULL != adapter) && |
| 15259 | (WLAN_HDD_ADAPTER_MAGIC == adapter->magic)) |
| 15260 | __hdd_indicate_mgmt_frame(adapter, |
| 15261 | frame_ind->frameLen, |
| 15262 | frame_ind->frameBuf, |
| 15263 | frame_ind->frameType, |
| 15264 | frame_ind->rxChan, |
| 15265 | frame_ind->rxRssi); |
| 15266 | return; |
| 15267 | |
| 15268 | } |
| 15269 | |
c_hpothu | 225aa7c | 2014-10-22 17:45:13 +0530 | [diff] [blame] | 15270 | VOS_STATUS wlan_hdd_cancel_remain_on_channel(hdd_context_t *pHddCtx) |
| 15271 | { |
| 15272 | hdd_adapter_t *pAdapter; |
| 15273 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 15274 | VOS_STATUS vosStatus; |
| 15275 | |
| 15276 | vosStatus = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 15277 | while (NULL != pAdapterNode && VOS_STATUS_E_EMPTY != vosStatus) |
| 15278 | { |
| 15279 | pAdapter = pAdapterNode->pAdapter; |
| 15280 | if (NULL != pAdapter) |
| 15281 | { |
| 15282 | if (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode || |
| 15283 | WLAN_HDD_P2P_CLIENT == pAdapter->device_mode || |
| 15284 | WLAN_HDD_P2P_GO == pAdapter->device_mode) |
| 15285 | { |
| 15286 | hddLog(LOG1, FL("abort ROC deviceMode: %d"), |
| 15287 | pAdapter->device_mode); |
| 15288 | if (VOS_STATUS_SUCCESS != |
| 15289 | wlan_hdd_cancel_existing_remain_on_channel(pAdapter)) |
| 15290 | { |
| 15291 | hddLog(LOGE, FL("failed to abort ROC")); |
| 15292 | return VOS_STATUS_E_FAILURE; |
| 15293 | } |
| 15294 | } |
| 15295 | } |
| 15296 | vosStatus = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 15297 | pAdapterNode = pNext; |
| 15298 | } |
| 15299 | return VOS_STATUS_SUCCESS; |
| 15300 | } |
Mahesh A Saptasagar | d477b09 | 2015-02-06 15:12:16 +0530 | [diff] [blame] | 15301 | |
Mihir Shete | 0be2877 | 2015-02-17 18:42:14 +0530 | [diff] [blame] | 15302 | hdd_remain_on_chan_ctx_t *hdd_get_remain_on_channel_ctx(hdd_context_t *pHddCtx) |
| 15303 | { |
| 15304 | hdd_adapter_t *pAdapter; |
| 15305 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 15306 | hdd_cfg80211_state_t *cfgState; |
| 15307 | hdd_remain_on_chan_ctx_t *pRemainChanCtx = NULL; |
| 15308 | VOS_STATUS vosStatus; |
| 15309 | |
| 15310 | vosStatus = hdd_get_front_adapter (pHddCtx, &pAdapterNode); |
| 15311 | while (NULL != pAdapterNode && VOS_STATUS_E_EMPTY != vosStatus) |
| 15312 | { |
| 15313 | pAdapter = pAdapterNode->pAdapter; |
| 15314 | if (NULL != pAdapter) |
| 15315 | { |
| 15316 | cfgState = WLAN_HDD_GET_CFG_STATE_PTR(pAdapter); |
| 15317 | pRemainChanCtx = cfgState->remain_on_chan_ctx; |
| 15318 | if (pRemainChanCtx) |
| 15319 | break; |
| 15320 | } |
| 15321 | vosStatus = hdd_get_next_adapter (pHddCtx, pAdapterNode, &pNext); |
| 15322 | pAdapterNode = pNext; |
| 15323 | } |
| 15324 | return pRemainChanCtx; |
| 15325 | } |
| 15326 | |
Padma, Santhosh Kumar | 778d838 | 2015-03-04 17:41:22 +0530 | [diff] [blame] | 15327 | /** |
| 15328 | * wlan_hdd_handle_dfs_chan_scan () - handles disable/enable DFS channels |
| 15329 | * |
| 15330 | * @pHddCtx: HDD context within host driver |
| 15331 | * @dfsScanMode: dfsScanMode passed from ioctl |
| 15332 | * |
| 15333 | */ |
| 15334 | |
| 15335 | VOS_STATUS wlan_hdd_handle_dfs_chan_scan(hdd_context_t *pHddCtx, |
| 15336 | tANI_U8 dfsScanMode) |
| 15337 | { |
| 15338 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 15339 | hdd_adapter_t *pAdapter; |
| 15340 | VOS_STATUS vosStatus; |
| 15341 | hdd_station_ctx_t *pHddStaCtx; |
| 15342 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 15343 | |
| 15344 | if(!pHddCtx) |
| 15345 | { |
| 15346 | hddLog(LOGE, FL("HDD context is Null")); |
| 15347 | return eHAL_STATUS_FAILURE; |
| 15348 | } |
| 15349 | |
| 15350 | if (pHddCtx->scan_info.mScanPending) |
| 15351 | { |
| 15352 | hddLog(LOG1, FL("Aborting scan for sessionId: %d"), |
| 15353 | pHddCtx->scan_info.sessionId); |
| 15354 | hdd_abort_mac_scan(pHddCtx, |
| 15355 | pHddCtx->scan_info.sessionId, |
| 15356 | eCSR_SCAN_ABORT_DEFAULT); |
| 15357 | } |
| 15358 | |
| 15359 | if (!dfsScanMode) |
| 15360 | { |
| 15361 | vosStatus = hdd_get_front_adapter( pHddCtx, &pAdapterNode); |
| 15362 | while ((NULL != pAdapterNode) && |
| 15363 | (VOS_STATUS_SUCCESS == vosStatus)) |
| 15364 | { |
| 15365 | pAdapter = pAdapterNode->pAdapter; |
| 15366 | |
| 15367 | if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) |
| 15368 | { |
| 15369 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 15370 | |
| 15371 | if(!pHddStaCtx) |
| 15372 | { |
| 15373 | hddLog(LOGE, FL("HDD STA context is Null")); |
| 15374 | return eHAL_STATUS_FAILURE; |
| 15375 | } |
| 15376 | |
| 15377 | /* if STA is already connected on DFS channel, |
| 15378 | disconnect immediately*/ |
| 15379 | if (hdd_connIsConnected(pHddStaCtx) && |
| 15380 | (NV_CHANNEL_DFS == |
| 15381 | vos_nv_getChannelEnabledState( |
| 15382 | pHddStaCtx->conn_info.operationChannel))) |
| 15383 | { |
| 15384 | status = sme_RoamDisconnect(pHddCtx->hHal, |
| 15385 | pAdapter->sessionId, |
| 15386 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
| 15387 | hddLog(LOG1, FL("Client connected on DFS channel %d," |
| 15388 | "sme_RoamDisconnect returned with status: %d" |
| 15389 | "for sessionid: %d"), pHddStaCtx->conn_info. |
| 15390 | operationChannel, status, pAdapter->sessionId); |
| 15391 | } |
| 15392 | } |
| 15393 | |
| 15394 | vosStatus = hdd_get_next_adapter(pHddCtx, pAdapterNode, |
| 15395 | &pNext); |
| 15396 | pAdapterNode = pNext; |
| 15397 | } |
| 15398 | } |
| 15399 | |
| 15400 | sme_UpdateDFSScanMode(pHddCtx->hHal, dfsScanMode); |
| 15401 | sme_UpdateDFSRoamMode(pHddCtx->hHal, |
| 15402 | (dfsScanMode != DFS_CHNL_SCAN_DISABLED)); |
| 15403 | |
| 15404 | status = sme_HandleDFSChanScan(pHddCtx->hHal); |
| 15405 | if (!HAL_STATUS_SUCCESS(status)) |
| 15406 | { |
| 15407 | hddLog(LOGE, |
| 15408 | FL("Failed in sme_HandleDFSChanScan (err=%d)"), status); |
| 15409 | return status; |
| 15410 | } |
| 15411 | |
| 15412 | return status; |
| 15413 | } |
| 15414 | |
Nirav Shah | 7e3c813 | 2015-06-22 23:51:42 +0530 | [diff] [blame] | 15415 | static int hdd_log2_ceil(unsigned value) |
| 15416 | { |
| 15417 | /* need to switch to unsigned math so that negative values |
| 15418 | * will right-shift towards 0 instead of -1 |
| 15419 | */ |
| 15420 | unsigned tmp = value; |
| 15421 | int log2 = -1; |
| 15422 | |
| 15423 | if (value == 0) |
| 15424 | return 0; |
| 15425 | |
| 15426 | while (tmp) { |
| 15427 | log2++; |
| 15428 | tmp >>= 1; |
| 15429 | } |
| 15430 | if (1U << log2 != value) |
| 15431 | log2++; |
| 15432 | |
| 15433 | return log2; |
| 15434 | } |
| 15435 | |
| 15436 | /** |
| 15437 | * hdd_sta_id_hash_attach() - initialize sta id to macaddr hash |
| 15438 | * @pAdapter: adapter handle |
| 15439 | * |
| 15440 | * Return: vos status |
| 15441 | */ |
| 15442 | VOS_STATUS hdd_sta_id_hash_attach(hdd_adapter_t *pAdapter) |
| 15443 | { |
| 15444 | int hash_elem, log2, i; |
| 15445 | |
| 15446 | spin_lock_bh( &pAdapter->sta_hash_lock); |
| 15447 | if (pAdapter->is_sta_id_hash_initialized == VOS_TRUE) { |
| 15448 | spin_unlock_bh( &pAdapter->sta_hash_lock); |
| 15449 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 15450 | "%s: hash already attached for session id %d", |
| 15451 | __func__, pAdapter->sessionId); |
| 15452 | return VOS_STATUS_SUCCESS; |
| 15453 | } |
| 15454 | spin_unlock_bh( &pAdapter->sta_hash_lock); |
| 15455 | |
| 15456 | hash_elem = WLAN_MAX_STA_COUNT; |
| 15457 | hash_elem *= HDD_STA_ID_HASH_MULTIPLIER; |
| 15458 | log2 = hdd_log2_ceil(hash_elem); |
| 15459 | hash_elem = 1 << log2; |
| 15460 | |
| 15461 | pAdapter->sta_id_hash.mask = hash_elem - 1; |
| 15462 | pAdapter->sta_id_hash.idx_bits = log2; |
| 15463 | pAdapter->sta_id_hash.bins = |
| 15464 | vos_mem_malloc(hash_elem *sizeof(hdd_list_t)); |
| 15465 | if (!pAdapter->sta_id_hash.bins) { |
| 15466 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 15467 | "%s: malloc failed for session %d", |
| 15468 | __func__, pAdapter->sessionId); |
| 15469 | return VOS_STATUS_E_NOMEM; |
| 15470 | } |
| 15471 | |
| 15472 | for (i = 0; i < hash_elem; i++) |
| 15473 | hdd_list_init(&pAdapter->sta_id_hash.bins[i], WLAN_MAX_STA_COUNT); |
| 15474 | |
| 15475 | spin_lock_bh( &pAdapter->sta_hash_lock); |
| 15476 | pAdapter->is_sta_id_hash_initialized = VOS_TRUE; |
| 15477 | spin_unlock_bh( &pAdapter->sta_hash_lock); |
| 15478 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 15479 | "%s: Station ID Hash attached for session id %d", |
| 15480 | __func__, pAdapter->sessionId); |
| 15481 | |
| 15482 | return VOS_STATUS_SUCCESS; |
| 15483 | } |
| 15484 | |
| 15485 | /** |
| 15486 | * hdd_sta_id_hash_detach() - deinit sta_id to macaddr hash |
| 15487 | * @pAdapter: adapter handle |
| 15488 | * |
| 15489 | * Return: vos status |
| 15490 | */ |
| 15491 | VOS_STATUS hdd_sta_id_hash_detach(hdd_adapter_t *pAdapter) |
| 15492 | { |
| 15493 | int hash_elem, i; |
| 15494 | v_SIZE_t size; |
| 15495 | |
| 15496 | spin_lock_bh( &pAdapter->sta_hash_lock); |
| 15497 | if (pAdapter->is_sta_id_hash_initialized != VOS_TRUE) { |
| 15498 | spin_unlock_bh( &pAdapter->sta_hash_lock); |
| 15499 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 15500 | "%s: hash not initialized for session id %d", |
| 15501 | __func__, pAdapter->sessionId); |
| 15502 | return VOS_STATUS_SUCCESS; |
| 15503 | } |
| 15504 | |
| 15505 | pAdapter->is_sta_id_hash_initialized = VOS_FALSE; |
| 15506 | spin_unlock_bh( &pAdapter->sta_hash_lock); |
| 15507 | |
| 15508 | hash_elem = 1 << pAdapter->sta_id_hash.idx_bits; |
| 15509 | |
| 15510 | /* free all station info*/ |
| 15511 | for (i = 0; i < hash_elem; i++) { |
| 15512 | hdd_list_size(&pAdapter->sta_id_hash.bins[i], &size); |
| 15513 | if (size != 0) { |
| 15514 | VOS_STATUS status; |
| 15515 | hdd_staid_hash_node_t *sta_info_node = NULL; |
| 15516 | hdd_staid_hash_node_t *next_node = NULL; |
| 15517 | status = hdd_list_peek_front ( &pAdapter->sta_id_hash.bins[i], |
| 15518 | (hdd_list_node_t**) &sta_info_node ); |
| 15519 | |
| 15520 | while ( NULL != sta_info_node && VOS_STATUS_SUCCESS == status ) |
| 15521 | { |
| 15522 | status = hdd_list_remove_node( &pAdapter->sta_id_hash.bins[i], |
| 15523 | &sta_info_node->node); |
| 15524 | vos_mem_free(sta_info_node); |
| 15525 | |
| 15526 | status = hdd_list_peek_next (&pAdapter->sta_id_hash.bins[i], |
| 15527 | (hdd_list_node_t*)sta_info_node, |
| 15528 | (hdd_list_node_t**)&next_node); |
| 15529 | sta_info_node = next_node; |
| 15530 | } |
| 15531 | } |
| 15532 | } |
| 15533 | |
| 15534 | vos_mem_free(pAdapter->sta_id_hash.bins); |
| 15535 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 15536 | "%s: Station ID Hash detached for session id %d", |
| 15537 | __func__, pAdapter->sessionId); |
| 15538 | return VOS_STATUS_SUCCESS; |
| 15539 | } |
| 15540 | |
| 15541 | /** |
| 15542 | * hdd_sta_id_hash_calculate_index() - derive index from macaddr |
| 15543 | * @pAdapter: adapter handle |
| 15544 | * @mac_addr_in: input mac address |
| 15545 | * |
| 15546 | * Return: index derived from mac address |
| 15547 | */ |
| 15548 | int hdd_sta_id_hash_calculate_index(hdd_adapter_t *pAdapter, |
| 15549 | v_MACADDR_t *mac_addr_in) |
| 15550 | { |
| 15551 | uint16 index; |
| 15552 | struct hdd_align_mac_addr_t * mac_addr = |
| 15553 | (struct hdd_align_mac_addr_t *)mac_addr_in; |
| 15554 | |
| 15555 | index = mac_addr->bytes_ab ^ |
| 15556 | mac_addr->bytes_cd ^ mac_addr->bytes_ef; |
| 15557 | index ^= index >> pAdapter->sta_id_hash.idx_bits; |
| 15558 | index &= pAdapter->sta_id_hash.mask; |
| 15559 | return index; |
| 15560 | } |
| 15561 | |
| 15562 | /** |
| 15563 | * hdd_sta_id_hash_add_entry() - add entry in hash |
| 15564 | * @pAdapter: adapter handle |
| 15565 | * @sta_id: station id |
| 15566 | * @mac_addr: mac address |
| 15567 | * |
| 15568 | * Return: vos status |
| 15569 | */ |
| 15570 | VOS_STATUS hdd_sta_id_hash_add_entry(hdd_adapter_t *pAdapter, |
| 15571 | v_U8_t sta_id, v_MACADDR_t *mac_addr) |
| 15572 | { |
| 15573 | uint16 index; |
| 15574 | hdd_staid_hash_node_t *sta_info_node = NULL; |
| 15575 | |
Nirav Shah | 7e3c813 | 2015-06-22 23:51:42 +0530 | [diff] [blame] | 15576 | index = hdd_sta_id_hash_calculate_index(pAdapter, mac_addr); |
| 15577 | sta_info_node = vos_mem_malloc(sizeof(hdd_staid_hash_node_t)); |
| 15578 | if (!sta_info_node) { |
Nirav Shah | 7e3c813 | 2015-06-22 23:51:42 +0530 | [diff] [blame] | 15579 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 15580 | "%s: malloc failed", __func__); |
| 15581 | return VOS_STATUS_E_NOMEM; |
| 15582 | } |
| 15583 | |
| 15584 | sta_info_node->sta_id = sta_id; |
| 15585 | vos_mem_copy(&sta_info_node->mac_addr, mac_addr, sizeof(v_MACADDR_t)); |
| 15586 | |
Nirav Shah | 303ed5c | 2015-08-24 10:29:25 +0530 | [diff] [blame] | 15587 | spin_lock_bh( &pAdapter->sta_hash_lock); |
| 15588 | if (pAdapter->is_sta_id_hash_initialized != VOS_TRUE) { |
| 15589 | spin_unlock_bh( &pAdapter->sta_hash_lock); |
| 15590 | vos_mem_free(sta_info_node); |
| 15591 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 15592 | "%s: hash is not initialized for session id %d", |
| 15593 | __func__, pAdapter->sessionId); |
| 15594 | return VOS_STATUS_E_FAILURE; |
| 15595 | } |
| 15596 | |
Nirav Shah | 7e3c813 | 2015-06-22 23:51:42 +0530 | [diff] [blame] | 15597 | hdd_list_insert_back ( &pAdapter->sta_id_hash.bins[index], |
| 15598 | (hdd_list_node_t*) sta_info_node ); |
| 15599 | spin_unlock_bh( &pAdapter->sta_hash_lock); |
| 15600 | return VOS_STATUS_SUCCESS; |
| 15601 | } |
| 15602 | |
| 15603 | /** |
| 15604 | * hdd_sta_id_hash_remove_entry() - remove entry from hash |
| 15605 | * @pAdapter: adapter handle |
| 15606 | * @sta_id: station id |
| 15607 | * @mac_addr: mac address |
| 15608 | * |
| 15609 | * Return: vos status |
| 15610 | */ |
| 15611 | VOS_STATUS hdd_sta_id_hash_remove_entry(hdd_adapter_t *pAdapter, |
| 15612 | v_U8_t sta_id, v_MACADDR_t *mac_addr) |
| 15613 | { |
| 15614 | uint16 index; |
| 15615 | VOS_STATUS status; |
| 15616 | hdd_staid_hash_node_t *sta_info_node = NULL; |
| 15617 | hdd_staid_hash_node_t *next_node = NULL; |
| 15618 | |
| 15619 | spin_lock_bh( &pAdapter->sta_hash_lock); |
| 15620 | if (pAdapter->is_sta_id_hash_initialized != VOS_TRUE) { |
| 15621 | spin_unlock_bh( &pAdapter->sta_hash_lock); |
| 15622 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 15623 | "%s: hash is not initialized for session id %d", |
| 15624 | __func__, pAdapter->sessionId); |
| 15625 | return VOS_STATUS_E_FAILURE; |
| 15626 | } |
| 15627 | |
| 15628 | index = hdd_sta_id_hash_calculate_index(pAdapter, mac_addr); |
| 15629 | status = hdd_list_peek_front ( &pAdapter->sta_id_hash.bins[index], |
| 15630 | (hdd_list_node_t**) &sta_info_node ); |
| 15631 | |
| 15632 | while ( NULL != sta_info_node && VOS_STATUS_SUCCESS == status ) |
| 15633 | { |
| 15634 | if (sta_info_node->sta_id == sta_id) { |
| 15635 | status = hdd_list_remove_node( &pAdapter->sta_id_hash.bins[index], |
| 15636 | &sta_info_node->node); |
| 15637 | vos_mem_free(sta_info_node); |
| 15638 | break; |
| 15639 | } |
| 15640 | status = hdd_list_peek_next (&pAdapter->sta_id_hash.bins[index], |
| 15641 | (hdd_list_node_t*)sta_info_node, (hdd_list_node_t**)&next_node); |
| 15642 | sta_info_node = next_node; |
| 15643 | } |
| 15644 | spin_unlock_bh( &pAdapter->sta_hash_lock); |
| 15645 | return status; |
| 15646 | } |
| 15647 | |
| 15648 | /** |
| 15649 | * hdd_sta_id_find_from_mac_addr() - find sta id from mac address |
| 15650 | * @pAdapter: adapter handle |
| 15651 | * @mac_addr_in: mac address |
| 15652 | * |
| 15653 | * Return: station id |
| 15654 | */ |
| 15655 | int hdd_sta_id_find_from_mac_addr(hdd_adapter_t *pAdapter, |
| 15656 | v_MACADDR_t *mac_addr_in) |
| 15657 | { |
| 15658 | uint8 is_found = 0; |
| 15659 | uint8 sta_id = HDD_WLAN_INVALID_STA_ID; |
| 15660 | uint16 index; |
| 15661 | VOS_STATUS status; |
| 15662 | hdd_staid_hash_node_t *sta_info_node = NULL; |
| 15663 | hdd_staid_hash_node_t *next_node = NULL; |
| 15664 | |
| 15665 | spin_lock_bh( &pAdapter->sta_hash_lock); |
| 15666 | if (pAdapter->is_sta_id_hash_initialized != VOS_TRUE) { |
| 15667 | spin_unlock_bh( &pAdapter->sta_hash_lock); |
Bhargav Shah | ce3b32c | 2015-08-10 12:29:24 +0530 | [diff] [blame] | 15668 | hddLog(VOS_TRACE_LEVEL_INFO, |
Nirav Shah | 7e3c813 | 2015-06-22 23:51:42 +0530 | [diff] [blame] | 15669 | FL("hash is not initialized for session id %d"), |
| 15670 | pAdapter->sessionId); |
| 15671 | return HDD_WLAN_INVALID_STA_ID; |
| 15672 | } |
| 15673 | |
| 15674 | index = hdd_sta_id_hash_calculate_index(pAdapter, mac_addr_in); |
| 15675 | status = hdd_list_peek_front ( &pAdapter->sta_id_hash.bins[index], |
| 15676 | (hdd_list_node_t**) &sta_info_node ); |
| 15677 | |
| 15678 | while ( NULL != sta_info_node && VOS_STATUS_SUCCESS == status ) |
| 15679 | { |
| 15680 | if (vos_mem_compare(&sta_info_node->mac_addr, |
| 15681 | mac_addr_in, sizeof(v_MACADDR_t))) { |
| 15682 | is_found = 1; |
| 15683 | sta_id = sta_info_node->sta_id; |
| 15684 | break; |
| 15685 | } |
| 15686 | status = hdd_list_peek_next (&pAdapter->sta_id_hash.bins[index], |
| 15687 | (hdd_list_node_t*)sta_info_node, |
| 15688 | (hdd_list_node_t**)&next_node); |
| 15689 | sta_info_node = next_node; |
| 15690 | } |
| 15691 | spin_unlock_bh( &pAdapter->sta_hash_lock); |
| 15692 | return sta_id; |
| 15693 | } |
| 15694 | |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 15695 | /*FW memory dump feature*/ |
| 15696 | /** |
| 15697 | * This structure hold information about the /proc file |
| 15698 | * |
| 15699 | */ |
| 15700 | static struct proc_dir_entry *proc_file, *proc_dir; |
| 15701 | |
| 15702 | /** |
| 15703 | * memdump_read() - perform read operation in memory dump proc file |
| 15704 | * |
| 15705 | * @file - handle for the proc file. |
| 15706 | * @buf - pointer to user space buffer. |
| 15707 | * @count - number of bytes to be read. |
| 15708 | * @pos - offset in the from buffer. |
| 15709 | * |
| 15710 | * This function performs read operation for the memory dump proc file. |
| 15711 | * |
| 15712 | * Return: number of bytes read on success, error code otherwise. |
| 15713 | */ |
| 15714 | static ssize_t memdump_read(struct file *file, char __user *buf, |
| 15715 | size_t count, loff_t *pos) |
| 15716 | { |
| 15717 | int status; |
| 15718 | hdd_context_t *hdd_ctx = (hdd_context_t *)PDE_DATA(file_inode(file)); |
| 15719 | size_t ret_count; |
c_manjee | f149564 | 2015-10-13 18:35:01 +0530 | [diff] [blame] | 15720 | loff_t bytes_left; |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 15721 | ENTER(); |
| 15722 | |
| 15723 | hddLog(LOG1, FL("Read req for size:%zu pos:%llu"), count, *pos); |
| 15724 | status = wlan_hdd_validate_context(hdd_ctx); |
| 15725 | if (0 != status) { |
| 15726 | return -EINVAL; |
| 15727 | } |
| 15728 | |
| 15729 | if (!wlan_fwr_mem_dump_test_and_set_read_allowed_bit()) { |
| 15730 | hddLog(LOGE, FL("Current mem dump request timed out/failed")); |
| 15731 | return -EINVAL; |
| 15732 | } |
| 15733 | |
| 15734 | /* run fs_read_handler in an atomic context*/ |
| 15735 | vos_ssr_protect(__func__); |
c_manjee | f149564 | 2015-10-13 18:35:01 +0530 | [diff] [blame] | 15736 | ret_count = wlan_fwr_mem_dump_fsread_handler( buf, count, pos, &bytes_left); |
| 15737 | if(bytes_left == 0) |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 15738 | { |
| 15739 | /*Free the fwr mem dump buffer */ |
| 15740 | wlan_free_fwr_mem_dump_buffer(); |
| 15741 | wlan_set_fwr_mem_dump_state(FW_MEM_DUMP_IDLE); |
c_manjee | f149564 | 2015-10-13 18:35:01 +0530 | [diff] [blame] | 15742 | ret_count=0; |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 15743 | } |
| 15744 | /*if SSR/unload code is waiting for memdump_read to finish,signal it*/ |
| 15745 | vos_ssr_unprotect(__func__); |
| 15746 | EXIT(); |
| 15747 | return ret_count; |
| 15748 | } |
| 15749 | |
| 15750 | /** |
| 15751 | * struct memdump_fops - file operations for memory dump feature |
| 15752 | * @read - read function for memory dump operation. |
| 15753 | * |
| 15754 | * This structure initialize the file operation handle for memory |
| 15755 | * dump feature |
| 15756 | */ |
| 15757 | static const struct file_operations memdump_fops = { |
| 15758 | read: memdump_read |
| 15759 | }; |
| 15760 | |
| 15761 | /* |
| 15762 | * wlan_hdd_fw_mem_dump_cb : callback for Fw mem dump request |
| 15763 | * To be passed by HDD to WDA and called upon receiving of response |
| 15764 | * from firmware |
| 15765 | * @fwMemDumpReqContext : memory dump request context |
| 15766 | * @dump_rsp : dump response from HAL |
| 15767 | * Returns none |
| 15768 | */ |
| 15769 | void wlan_hdd_fw_mem_dump_cb(void *fwMemDumpReqContext, |
| 15770 | tAniFwrDumpRsp *dump_rsp) |
| 15771 | { |
c_manjee | f149564 | 2015-10-13 18:35:01 +0530 | [diff] [blame] | 15772 | 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] | 15773 | |
c_manjee | f149564 | 2015-10-13 18:35:01 +0530 | [diff] [blame] | 15774 | ENTER(); |
| 15775 | spin_lock(&hdd_context_lock); |
| 15776 | if(!pHddFwMemDumpCtx || (FW_MEM_DUMP_MAGIC != pHddFwMemDumpCtx->magic)) { |
| 15777 | spin_unlock(&hdd_context_lock); |
| 15778 | return; |
| 15779 | } |
| 15780 | /* report the status to requesting function and free mem.*/ |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 15781 | if (dump_rsp->dump_status != eHAL_STATUS_SUCCESS) { |
c_manjee | f149564 | 2015-10-13 18:35:01 +0530 | [diff] [blame] | 15782 | hddLog(LOGE, FL("fw dump request declined by fwr")); |
| 15783 | //set the request completion variable |
| 15784 | complete(&(pHddFwMemDumpCtx->req_completion)); |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 15785 | //Free the allocated fwr dump |
| 15786 | wlan_free_fwr_mem_dump_buffer(); |
| 15787 | wlan_set_fwr_mem_dump_state(FW_MEM_DUMP_IDLE); |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 15788 | } |
c_manjee | f149564 | 2015-10-13 18:35:01 +0530 | [diff] [blame] | 15789 | else { |
| 15790 | hddLog(LOG1, FL("fw dump request accepted by fwr")); |
| 15791 | /* register the HDD callback which will be called by SVC */ |
| 15792 | wlan_set_svc_fw_mem_dump_req_cb((void*)wlan_hdd_fw_mem_dump_req_cb,(void*)pHddFwMemDumpCtx); |
| 15793 | } |
| 15794 | spin_unlock(&hdd_context_lock); |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 15795 | EXIT(); |
| 15796 | |
| 15797 | } |
| 15798 | |
| 15799 | /** |
| 15800 | * memdump_procfs_remove() - Remove file/dir under procfs for memory dump |
| 15801 | * |
| 15802 | * This function removes file/dir under proc file system that was |
| 15803 | * processing firmware memory dump |
| 15804 | * |
| 15805 | * Return: None |
| 15806 | */ |
| 15807 | static void memdump_procfs_remove(void) |
| 15808 | { |
| 15809 | remove_proc_entry(PROCFS_MEMDUMP_NAME, proc_dir); |
| 15810 | hddLog(LOG1 , FL("/proc/%s/%s removed\n"), |
| 15811 | PROCFS_MEMDUMP_DIR, PROCFS_MEMDUMP_NAME); |
| 15812 | remove_proc_entry(PROCFS_MEMDUMP_DIR, NULL); |
| 15813 | hddLog(LOG1 , FL("/proc/%s removed\n"), PROCFS_MEMDUMP_DIR); |
| 15814 | } |
| 15815 | |
| 15816 | /** |
| 15817 | * memdump_procfs_init() - Initialize procfs for memory dump |
| 15818 | * |
| 15819 | * @vos_ctx - Global vos context. |
| 15820 | * |
| 15821 | * This function create file under proc file system to be used later for |
| 15822 | * processing firmware memory dump |
| 15823 | * |
| 15824 | * Return: 0 on success, error code otherwise. |
| 15825 | */ |
| 15826 | static int memdump_procfs_init(void *vos_ctx) |
| 15827 | { |
| 15828 | hdd_context_t *hdd_ctx; |
| 15829 | |
| 15830 | hdd_ctx = vos_get_context(VOS_MODULE_ID_HDD, vos_ctx); |
| 15831 | if (!hdd_ctx) { |
| 15832 | hddLog(LOGE , FL("Invalid HDD context")); |
| 15833 | return -EINVAL; |
| 15834 | } |
| 15835 | |
| 15836 | proc_dir = proc_mkdir(PROCFS_MEMDUMP_DIR, NULL); |
| 15837 | if (proc_dir == NULL) { |
| 15838 | remove_proc_entry(PROCFS_MEMDUMP_DIR, NULL); |
| 15839 | hddLog(LOGE , FL("Error: Could not initialize /proc/%s"), |
| 15840 | PROCFS_MEMDUMP_DIR); |
| 15841 | return -ENOMEM; |
| 15842 | } |
| 15843 | |
| 15844 | proc_file = proc_create_data(PROCFS_MEMDUMP_NAME, |
| 15845 | S_IRUSR | S_IWUSR, proc_dir, |
| 15846 | &memdump_fops, hdd_ctx); |
| 15847 | if (proc_file == NULL) { |
| 15848 | remove_proc_entry(PROCFS_MEMDUMP_NAME, proc_dir); |
| 15849 | hddLog(LOGE , FL("Error: Could not initialize /proc/%s"), |
| 15850 | PROCFS_MEMDUMP_NAME); |
| 15851 | return -ENOMEM; |
| 15852 | } |
| 15853 | |
| 15854 | hddLog(LOG1 , FL("/proc/%s/%s created"), |
| 15855 | PROCFS_MEMDUMP_DIR, PROCFS_MEMDUMP_NAME); |
| 15856 | |
| 15857 | return 0; |
| 15858 | } |
| 15859 | |
| 15860 | /** |
| 15861 | * memdump_init() - Initialization function for memory dump feature |
| 15862 | * |
| 15863 | * This function creates proc file for memdump feature and registers |
| 15864 | * HDD callback function with SME. |
| 15865 | * |
| 15866 | * Return - 0 on success, error otherwise |
| 15867 | */ |
| 15868 | int memdump_init(void) |
| 15869 | { |
| 15870 | hdd_context_t *hdd_ctx; |
| 15871 | void *vos_ctx; |
| 15872 | int status = 0; |
| 15873 | |
| 15874 | vos_ctx = vos_get_global_context(VOS_MODULE_ID_SYS, NULL); |
| 15875 | if (!vos_ctx) { |
| 15876 | hddLog(LOGE, FL("Invalid VOS context")); |
| 15877 | return -EINVAL; |
| 15878 | } |
| 15879 | |
| 15880 | hdd_ctx = vos_get_context(VOS_MODULE_ID_HDD, vos_ctx); |
| 15881 | if (!hdd_ctx) { |
| 15882 | hddLog(LOGE , FL("Invalid HDD context")); |
| 15883 | return -EINVAL; |
| 15884 | } |
| 15885 | |
| 15886 | status = memdump_procfs_init(vos_ctx); |
| 15887 | if (status) { |
| 15888 | hddLog(LOGE , FL("Failed to create proc file")); |
| 15889 | return status; |
| 15890 | } |
| 15891 | |
| 15892 | return 0; |
| 15893 | } |
| 15894 | |
| 15895 | /** |
| 15896 | * memdump_deinit() - De initialize memdump feature |
| 15897 | * |
| 15898 | * This function removes proc file created for memdump feature. |
| 15899 | * |
| 15900 | * Return: None |
| 15901 | */ |
| 15902 | int memdump_deinit(void) |
| 15903 | { |
| 15904 | hdd_context_t *hdd_ctx; |
| 15905 | void *vos_ctx; |
| 15906 | |
| 15907 | vos_ctx = vos_get_global_context(VOS_MODULE_ID_SYS, NULL); |
| 15908 | if (!vos_ctx) { |
| 15909 | hddLog(LOGE, FL("Invalid VOS context")); |
| 15910 | return -EINVAL; |
| 15911 | } |
| 15912 | |
| 15913 | hdd_ctx = vos_get_context(VOS_MODULE_ID_HDD, vos_ctx); |
| 15914 | if(!hdd_ctx) { |
| 15915 | hddLog(LOGE , FL("Invalid HDD context")); |
| 15916 | return -EINVAL; |
| 15917 | } |
| 15918 | |
| 15919 | memdump_procfs_remove(); |
| 15920 | return 0; |
| 15921 | } |
| 15922 | |
| 15923 | /** |
| 15924 | * wlan_hdd_fw_mem_dump_req(pHddCtx) - common API(cfg80211/ioctl) for requesting fw mem dump to SME |
| 15925 | * Return: HAL status |
| 15926 | */ |
| 15927 | |
| 15928 | int wlan_hdd_fw_mem_dump_req(hdd_context_t * pHddCtx) |
| 15929 | { |
| 15930 | tAniFwrDumpReq fw_mem_dump_req={0}; |
c_manjee | f149564 | 2015-10-13 18:35:01 +0530 | [diff] [blame] | 15931 | struct hdd_fw_mem_dump_req_ctx fw_mem_dump_ctx; |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 15932 | eHalStatus status = eHAL_STATUS_FAILURE; |
Abhishek Singh | 4eca982 | 2015-12-09 18:07:34 +0530 | [diff] [blame] | 15933 | int ret=0, result; |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 15934 | ENTER(); |
c_manjee | f149564 | 2015-10-13 18:35:01 +0530 | [diff] [blame] | 15935 | |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 15936 | /*Check whether a dump request is already going on |
| 15937 | *Caution this function will free previously held memory if new dump request is allowed*/ |
| 15938 | if (!wlan_fwr_mem_dump_test_and_set_write_allowed_bit()) { |
| 15939 | hddLog(LOGE, FL("Fw memdump already in progress")); |
| 15940 | return -EBUSY; |
| 15941 | } |
| 15942 | //Allocate memory for fw mem dump buffer |
| 15943 | ret = wlan_fwr_mem_dump_buffer_allocation(); |
| 15944 | if(ret == -EFAULT) |
| 15945 | { |
| 15946 | hddLog(LOGE, FL("Fwr mem dump not supported by FW")); |
| 15947 | return ret; |
| 15948 | } |
| 15949 | if (0 != ret) { |
| 15950 | hddLog(LOGE, FL("Fwr mem Allocation failed")); |
| 15951 | return -ENOMEM; |
| 15952 | } |
c_manjee | f149564 | 2015-10-13 18:35:01 +0530 | [diff] [blame] | 15953 | init_completion(&fw_mem_dump_ctx.req_completion); |
| 15954 | fw_mem_dump_ctx.magic = FW_MEM_DUMP_MAGIC; |
| 15955 | fw_mem_dump_ctx.status = false; |
| 15956 | |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 15957 | fw_mem_dump_req.fwMemDumpReqCallback = wlan_hdd_fw_mem_dump_cb; |
c_manjee | f149564 | 2015-10-13 18:35:01 +0530 | [diff] [blame] | 15958 | fw_mem_dump_req.fwMemDumpReqContext = &fw_mem_dump_ctx; |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 15959 | status = sme_FwMemDumpReq(pHddCtx->hHal, &fw_mem_dump_req); |
| 15960 | if(eHAL_STATUS_SUCCESS != status) |
| 15961 | { |
| 15962 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 15963 | "%s: fw_mem_dump_req failed ", __func__); |
| 15964 | wlan_free_fwr_mem_dump_buffer(); |
c_manjee | f149564 | 2015-10-13 18:35:01 +0530 | [diff] [blame] | 15965 | ret = -EFAULT; |
| 15966 | goto cleanup; |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 15967 | } |
c_manjee | f149564 | 2015-10-13 18:35:01 +0530 | [diff] [blame] | 15968 | /*wait for fw mem dump completion to send event to userspace*/ |
Abhishek Singh | 4eca982 | 2015-12-09 18:07:34 +0530 | [diff] [blame] | 15969 | result = |
| 15970 | wait_for_completion_timeout(&fw_mem_dump_ctx.req_completion, |
| 15971 | msecs_to_jiffies(FW_MEM_DUMP_TIMEOUT_MS)); |
| 15972 | if (0 >= result ) |
c_manjee | f149564 | 2015-10-13 18:35:01 +0530 | [diff] [blame] | 15973 | { |
| 15974 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Abhishek Singh | 4eca982 | 2015-12-09 18:07:34 +0530 | [diff] [blame] | 15975 | "%s: fw_mem_dump_req timeout %d ", __func__,result); |
| 15976 | ret = -ETIMEDOUT; |
c_manjee | f149564 | 2015-10-13 18:35:01 +0530 | [diff] [blame] | 15977 | } |
| 15978 | cleanup: |
| 15979 | spin_lock(&hdd_context_lock); |
| 15980 | fw_mem_dump_ctx.magic = 0; |
Abhishek Singh | 4eca982 | 2015-12-09 18:07:34 +0530 | [diff] [blame] | 15981 | if(!ret && !fw_mem_dump_ctx.status) |
| 15982 | ret = -EFAULT; |
c_manjee | f149564 | 2015-10-13 18:35:01 +0530 | [diff] [blame] | 15983 | spin_unlock(&hdd_context_lock); |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 15984 | |
c_manjee | f149564 | 2015-10-13 18:35:01 +0530 | [diff] [blame] | 15985 | EXIT(); |
Abhishek Singh | 4eca982 | 2015-12-09 18:07:34 +0530 | [diff] [blame] | 15986 | return ret; |
c_manjee | f149564 | 2015-10-13 18:35:01 +0530 | [diff] [blame] | 15987 | } |
| 15988 | |
| 15989 | /** |
| 15990 | * HDD callback which will be called by SVC to indicate mem dump completion. |
| 15991 | */ |
| 15992 | void wlan_hdd_fw_mem_dump_req_cb(struct hdd_fw_mem_dump_req_ctx* pHddFwMemDumpCtx) |
| 15993 | { |
| 15994 | if (!pHddFwMemDumpCtx) { |
| 15995 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 15996 | "%s: HDD context not valid ", __func__); |
| 15997 | return; |
| 15998 | } |
| 15999 | spin_lock(&hdd_context_lock); |
| 16000 | /* check the req magic and set status */ |
| 16001 | if (pHddFwMemDumpCtx->magic == FW_MEM_DUMP_MAGIC) |
| 16002 | { |
| 16003 | pHddFwMemDumpCtx->status = true; |
| 16004 | //signal the completion |
| 16005 | complete(&(pHddFwMemDumpCtx->req_completion)); |
| 16006 | } |
| 16007 | else |
| 16008 | { |
| 16009 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 16010 | "%s: fw mem dump request possible timeout ", __func__); |
| 16011 | } |
| 16012 | spin_unlock(&hdd_context_lock); |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 16013 | } |
| 16014 | |
Mahesh A Saptasagar | 67ab922 | 2015-10-21 15:38:41 +0530 | [diff] [blame] | 16015 | void hdd_initialize_adapter_common(hdd_adapter_t *pAdapter) |
| 16016 | { |
| 16017 | if (NULL == pAdapter) |
| 16018 | { |
| 16019 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: pAdapter is NULL ", __func__); |
| 16020 | return; |
| 16021 | } |
| 16022 | init_completion(&pAdapter->session_open_comp_var); |
| 16023 | init_completion(&pAdapter->session_close_comp_var); |
| 16024 | init_completion(&pAdapter->disconnect_comp_var); |
| 16025 | init_completion(&pAdapter->linkup_event_var); |
| 16026 | init_completion(&pAdapter->cancel_rem_on_chan_var); |
| 16027 | init_completion(&pAdapter->rem_on_chan_ready_event); |
| 16028 | init_completion(&pAdapter->pno_comp_var); |
| 16029 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 16030 | init_completion(&pAdapter->offchannel_tx_event); |
| 16031 | #endif |
| 16032 | init_completion(&pAdapter->tx_action_cnf_event); |
| 16033 | #ifdef FEATURE_WLAN_TDLS |
| 16034 | init_completion(&pAdapter->tdls_add_station_comp); |
| 16035 | init_completion(&pAdapter->tdls_del_station_comp); |
| 16036 | init_completion(&pAdapter->tdls_mgmt_comp); |
| 16037 | init_completion(&pAdapter->tdls_link_establish_req_comp); |
| 16038 | #endif |
| 16039 | |
| 16040 | #ifdef WLAN_FEATURE_RMC |
| 16041 | init_completion(&pAdapter->ibss_peer_info_comp); |
| 16042 | #endif /* WLAN_FEATURE_RMC */ |
| 16043 | init_completion(&pAdapter->ula_complete); |
| 16044 | init_completion(&pAdapter->change_country_code); |
| 16045 | |
| 16046 | #ifdef FEATURE_WLAN_BATCH_SCAN |
| 16047 | init_completion(&pAdapter->hdd_set_batch_scan_req_var); |
| 16048 | init_completion(&pAdapter->hdd_get_batch_scan_req_var); |
| 16049 | #endif |
Kapil Gupta | 2b44acb | 2016-12-30 16:49:51 +0530 | [diff] [blame] | 16050 | init_completion(&pAdapter->wlan_suspend_comp_var); |
Mahesh A Saptasagar | 67ab922 | 2015-10-21 15:38:41 +0530 | [diff] [blame] | 16051 | |
| 16052 | return; |
| 16053 | } |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 16054 | |
Anurag Chouhan | 0b29de0 | 2016-12-16 13:18:40 +0530 | [diff] [blame] | 16055 | #ifdef MDNS_OFFLOAD |
| 16056 | |
| 16057 | /** |
| 16058 | * hdd_mdns_enable_offload_done() - mdns enable offload response api |
| 16059 | * @padapter: holds adapter |
| 16060 | * @status: response status |
| 16061 | * |
| 16062 | * Return - None |
| 16063 | */ |
| 16064 | void hdd_mdns_enable_offload_done(void *padapter, VOS_STATUS status) |
| 16065 | { |
| 16066 | hdd_adapter_t* adapter = (hdd_adapter_t*) padapter; |
| 16067 | |
| 16068 | ENTER(); |
| 16069 | |
| 16070 | if (NULL == adapter) |
| 16071 | { |
| 16072 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 16073 | "%s: adapter is NULL",__func__); |
| 16074 | return; |
| 16075 | } |
| 16076 | |
| 16077 | adapter->mdns_status.mdns_enable_status = status; |
| 16078 | vos_event_set(&adapter->mdns_status.vos_event); |
| 16079 | return; |
| 16080 | } |
| 16081 | |
| 16082 | /** |
| 16083 | * hdd_mdns_fqdn_offload_done() - mdns fqdn offload response api |
| 16084 | * @padapter: holds adapter |
| 16085 | * @status: responce status |
| 16086 | * |
| 16087 | * Return - None |
| 16088 | */ |
| 16089 | void hdd_mdns_fqdn_offload_done(void *padapter, VOS_STATUS status) |
| 16090 | { |
| 16091 | hdd_adapter_t* adapter = (hdd_adapter_t*) padapter; |
| 16092 | |
| 16093 | ENTER(); |
| 16094 | |
| 16095 | if (NULL == adapter) |
| 16096 | { |
| 16097 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 16098 | "%s: adapter is NULL",__func__); |
| 16099 | return; |
| 16100 | } |
| 16101 | |
| 16102 | adapter->mdns_status.mdns_fqdn_status = status; |
| 16103 | return; |
| 16104 | } |
| 16105 | |
| 16106 | /** |
| 16107 | * hdd_mdns_resp_offload_done() - mdns resp offload response api |
| 16108 | * @padapter: holds adapter |
| 16109 | * @status: responce status |
| 16110 | * |
| 16111 | * Return - None |
| 16112 | */ |
| 16113 | void hdd_mdns_resp_offload_done(void *padapter, VOS_STATUS status) |
| 16114 | { |
| 16115 | hdd_adapter_t* adapter = (hdd_adapter_t*) padapter; |
| 16116 | |
| 16117 | ENTER(); |
| 16118 | |
| 16119 | if (NULL == adapter) |
| 16120 | { |
| 16121 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 16122 | "%s: adapter is NULL",__func__); |
| 16123 | return; |
| 16124 | } |
| 16125 | |
| 16126 | adapter->mdns_status.mdns_resp_status = status; |
| 16127 | return; |
| 16128 | } |
| 16129 | |
| 16130 | /** |
| 16131 | * wlan_hdd_mdns_process_response_dname() - Process mDNS domain name |
| 16132 | * @response: Pointer to a struct hdd_mdns_resp_info |
| 16133 | * @resp_info: Pointer to a struct tSirMDNSResponseInfo |
| 16134 | * |
| 16135 | * This function will pack the whole domain name without compression. It will |
| 16136 | * add the leading len for each field and add zero length octet to terminate |
| 16137 | * the domain name. |
| 16138 | * |
| 16139 | * Return: Return boolean. TRUE for success, FALSE for fail. |
| 16140 | */ |
| 16141 | static bool |
| 16142 | wlan_hdd_mdns_process_response_dname(struct hdd_mdns_resp_info *response, |
| 16143 | sir_mdns_resp_info resp_info) |
| 16144 | { |
| 16145 | uint8_t num; |
| 16146 | uint16_t idx; |
| 16147 | uint8_t len = 0; |
| 16148 | |
| 16149 | if ((response == NULL) || (response->data == NULL) || |
| 16150 | (response->offset == NULL)) { |
| 16151 | hddLog(LOGE, FL("Either data or offset in response is NULL!")); |
| 16152 | return FALSE; |
| 16153 | } |
| 16154 | |
| 16155 | if ((resp_info == NULL) || |
| 16156 | (resp_info->resp_len >= MAX_MDNS_RESP_LEN)) { |
| 16157 | hddLog(LOGE, FL("resp_len exceeds %d!"), MAX_MDNS_RESP_LEN); |
| 16158 | return FALSE; |
| 16159 | } |
| 16160 | |
| 16161 | for (num = 0; num < response->num_entries; num++) { |
| 16162 | response->offset[num] = |
| 16163 | resp_info->resp_len + MDNS_HEADER_LEN; |
| 16164 | idx = num * MAX_LEN_DOMAINNAME_FIELD; |
| 16165 | len = strlen((char *)&response->data[idx]); |
| 16166 | if ((resp_info->resp_len + len + 1) >= MAX_MDNS_RESP_LEN) { |
| 16167 | hddLog(LOGE, FL("resp_len exceeds %d!"), |
| 16168 | MAX_MDNS_RESP_LEN); |
| 16169 | return FALSE; |
| 16170 | } |
| 16171 | resp_info->resp_data[resp_info->resp_len] = len; |
| 16172 | resp_info->resp_len++; |
| 16173 | vos_mem_copy(&resp_info->resp_data[resp_info->resp_len], |
| 16174 | &response->data[idx], len); |
| 16175 | resp_info->resp_len += len; |
| 16176 | } |
| 16177 | |
| 16178 | /* The domain name terminates with the zero length octet */ |
| 16179 | if (num == response->num_entries) { |
| 16180 | if (resp_info->resp_len >= MAX_MDNS_RESP_LEN) { |
| 16181 | hddLog(LOGE, FL("resp_len exceeds %d!"), |
| 16182 | MAX_MDNS_RESP_LEN); |
| 16183 | return FALSE; |
| 16184 | } |
| 16185 | resp_info->resp_data[resp_info->resp_len] = 0; |
| 16186 | resp_info->resp_len++; |
| 16187 | } |
| 16188 | |
| 16189 | return TRUE; |
| 16190 | } |
| 16191 | |
| 16192 | /** |
| 16193 | * wlan_hdd_mdns_format_response_u16() - Form uint16_t response data |
| 16194 | * @value: The uint16_t value is formed to the struct tSirMDNSResponseInfo |
| 16195 | * @resp_info: Pointer to a struct tSirMDNSResponseInfo |
| 16196 | * |
| 16197 | * Return: None |
| 16198 | */ |
| 16199 | static void wlan_hdd_mdns_format_response_u16(uint16_t value, |
| 16200 | sir_mdns_resp_info resp_info) |
| 16201 | { |
| 16202 | uint8_t val_u8; |
| 16203 | |
| 16204 | if ((resp_info == NULL) || (resp_info->resp_data == NULL)) |
| 16205 | return; |
| 16206 | val_u8 = (value & 0xff00) >> 8; |
| 16207 | resp_info->resp_data[resp_info->resp_len++] = val_u8; |
| 16208 | val_u8 = value & 0xff; |
| 16209 | resp_info->resp_data[resp_info->resp_len++] = val_u8; |
| 16210 | } |
| 16211 | |
| 16212 | /** |
| 16213 | * wlan_hdd_mdns_format_response_u32() - Form uint32_t response data |
| 16214 | * @value: The uint32_t value is formed to the struct tSirMDNSResponseInfo |
| 16215 | * @resp_info: Pointer to a struct tSirMDNSResponseInfo |
| 16216 | * |
| 16217 | * Return: None |
| 16218 | */ |
| 16219 | static void wlan_hdd_mdns_format_response_u32(uint32_t value, |
| 16220 | sir_mdns_resp_info resp_info) |
| 16221 | { |
| 16222 | uint8_t val_u8; |
| 16223 | |
| 16224 | if ((resp_info == NULL) || (resp_info->resp_data == NULL)) |
| 16225 | return; |
| 16226 | val_u8 = (value & 0xff000000) >> 24; |
| 16227 | resp_info->resp_data[resp_info->resp_len++] = val_u8; |
| 16228 | val_u8 = (value & 0xff0000) >> 16; |
| 16229 | resp_info->resp_data[resp_info->resp_len++] = val_u8; |
| 16230 | val_u8 = (value & 0xff00) >> 8; |
| 16231 | resp_info->resp_data[resp_info->resp_len++] = val_u8; |
| 16232 | val_u8 = value & 0xff; |
| 16233 | resp_info->resp_data[resp_info->resp_len++] = val_u8; |
| 16234 | } |
| 16235 | |
| 16236 | /** |
| 16237 | * wlan_hdd_mdns_process_response_misc() - Process misc info in mDNS response |
| 16238 | * @resp_type: Response type for mDNS |
| 16239 | * @resp_info: Pointer to a struct tSirMDNSResponseInfo |
| 16240 | * |
| 16241 | * This function will pack the response type, class and TTL (Time To Live). |
| 16242 | * |
| 16243 | * Return: Return boolean. TRUE for success, FALSE for fail. |
| 16244 | */ |
| 16245 | static bool wlan_hdd_mdns_process_response_misc(uint16_t resp_type, |
| 16246 | sir_mdns_resp_info resp_info) |
| 16247 | { |
| 16248 | uint16_t len; |
| 16249 | |
| 16250 | if (resp_info == NULL) { |
| 16251 | hddLog(LOGE, FL("resp_info is NULL!")); |
| 16252 | return FALSE; |
| 16253 | } |
| 16254 | |
| 16255 | len = resp_info->resp_len + (2 * sizeof(uint16_t) + sizeof(uint32_t)); |
| 16256 | if (len >= MAX_MDNS_RESP_LEN) { |
| 16257 | hddLog(LOGE, FL("resp_len exceeds %d!"), MAX_MDNS_RESP_LEN); |
| 16258 | return FALSE; |
| 16259 | } |
| 16260 | |
| 16261 | /* Fill Type, Class, TTL */ |
| 16262 | wlan_hdd_mdns_format_response_u16(resp_type, resp_info); |
| 16263 | wlan_hdd_mdns_format_response_u16(MDNS_CLASS, resp_info); |
| 16264 | wlan_hdd_mdns_format_response_u32(MDNS_TTL, resp_info); |
| 16265 | |
| 16266 | return TRUE; |
| 16267 | } |
| 16268 | |
| 16269 | /** |
| 16270 | * wlan_hdd_mdns_compress_data() - Compress the domain name in mDNS response |
| 16271 | * @resp_info: Pointer to a struct tSirMDNSResponseInfo |
| 16272 | * @response_dst: The response which domain name is compressed. |
| 16273 | * @response_src: The response which domain name is matched with response_dst. |
| 16274 | * Its offset is used for data compression. |
| 16275 | * @num_matched: The number of matched entries between response_dst and |
| 16276 | * response_src |
| 16277 | * |
| 16278 | * This function will form the different fields of domain name in response_dst |
| 16279 | * if any. Then use the offset of the matched domain name in response_src to |
| 16280 | * compress the matched domain name. |
| 16281 | * |
| 16282 | * Return: Return boolean. TRUE for success, FALSE for fail. |
| 16283 | */ |
| 16284 | static bool |
| 16285 | wlan_hdd_mdns_compress_data(sir_mdns_resp_info resp_info, |
| 16286 | struct hdd_mdns_resp_info *response_dst, |
| 16287 | struct hdd_mdns_resp_info *response_src, |
| 16288 | uint8_t num_matched) |
| 16289 | { |
| 16290 | uint8_t num, num_diff; |
| 16291 | uint16_t value, idx; |
| 16292 | uint8_t len = 0; |
| 16293 | |
| 16294 | if ((response_src == NULL) || (response_dst == NULL) || |
| 16295 | (resp_info == NULL)) { |
| 16296 | hddLog(LOGE, FL("response info is NULL!")); |
| 16297 | return FALSE; |
| 16298 | } |
| 16299 | |
| 16300 | if (response_dst->num_entries < num_matched) { |
| 16301 | hddLog(LOGE, FL("num_entries is less than num_matched!")); |
| 16302 | return FALSE; |
| 16303 | } |
| 16304 | |
| 16305 | if (resp_info->resp_len >= MAX_MDNS_RESP_LEN) { |
| 16306 | hddLog(LOGE, FL("resp_len exceeds %d!"), MAX_MDNS_RESP_LEN); |
| 16307 | return FALSE; |
| 16308 | } |
| 16309 | |
| 16310 | num_diff = response_dst->num_entries - num_matched; |
| 16311 | if ((num_diff > 0) && (response_dst->data == NULL)) { |
| 16312 | hddLog(LOGE, FL("response_dst->data is NULL!")); |
| 16313 | return FALSE; |
| 16314 | } |
| 16315 | |
| 16316 | /* |
| 16317 | * Handle the unmatched string at the beginning |
| 16318 | * Store the length of octets and the octets |
| 16319 | */ |
| 16320 | for (num = 0; num < num_diff; num++) { |
| 16321 | response_dst->offset[num] = |
| 16322 | resp_info->resp_len + MDNS_HEADER_LEN; |
| 16323 | idx = num * MAX_LEN_DOMAINNAME_FIELD; |
| 16324 | len = strlen((char *)&response_dst->data[idx]); |
| 16325 | if ((resp_info->resp_len + len + 1) >= MAX_MDNS_RESP_LEN) { |
| 16326 | hddLog(LOGE, FL("resp_len exceeds %d!"), |
| 16327 | MAX_MDNS_RESP_LEN); |
| 16328 | return FALSE; |
| 16329 | } |
| 16330 | resp_info->resp_data[resp_info->resp_len] = len; |
| 16331 | resp_info->resp_len++; |
| 16332 | vos_mem_copy(&resp_info->resp_data[resp_info->resp_len], |
| 16333 | &response_dst->data[idx], len); |
| 16334 | resp_info->resp_len += len; |
| 16335 | } |
| 16336 | /* |
| 16337 | * Handle the matched string from the end |
| 16338 | * Just keep the offset and mask the leading two bit |
| 16339 | */ |
| 16340 | if (response_src->num_entries >= num_matched) { |
| 16341 | num_diff = response_src->num_entries - num_matched; |
| 16342 | value = response_src->offset[num_diff]; |
| 16343 | if (value > 0) { |
| 16344 | value |= 0xc000; |
| 16345 | if ((resp_info->resp_len + sizeof(uint16_t)) >= |
| 16346 | MAX_MDNS_RESP_LEN) { |
| 16347 | hddLog(LOGE, FL("resp_len exceeds %d!"), |
| 16348 | MAX_MDNS_RESP_LEN); |
| 16349 | return FALSE; |
| 16350 | } |
| 16351 | wlan_hdd_mdns_format_response_u16(value, resp_info); |
| 16352 | return TRUE; |
| 16353 | } |
| 16354 | } |
| 16355 | return FALSE; |
| 16356 | } |
| 16357 | |
| 16358 | /** |
| 16359 | * wlan_hdd_mdns_reset_response() - Reset the response info |
| 16360 | * @response: The response which info is reset. |
| 16361 | * |
| 16362 | * Return: None |
| 16363 | */ |
| 16364 | static void wlan_hdd_mdns_reset_response(struct hdd_mdns_resp_info *response) |
| 16365 | { |
| 16366 | if (response == NULL) |
| 16367 | return; |
| 16368 | response->num_entries = 0; |
| 16369 | response->data = NULL; |
| 16370 | response->offset = NULL; |
| 16371 | } |
| 16372 | |
| 16373 | /** |
| 16374 | * wlan_hdd_mdns_init_response() - Initialize the response info |
| 16375 | * @response: The response which info is initiatized. |
| 16376 | * @resp_dname: The domain name string which might be tokenized. |
| 16377 | * |
| 16378 | * This function will allocate the memory for both response->data and |
| 16379 | * response->offset. Besides, it will also tokenize the domain name to some |
| 16380 | * entries and fill response->num_entries with the num of entries. |
| 16381 | * |
| 16382 | * Return: Return boolean. TRUE for success, FALSE for fail. |
| 16383 | */ |
| 16384 | static bool wlan_hdd_mdns_init_response(struct hdd_mdns_resp_info *response, |
| 16385 | uint8_t *resp_dname, char separator) |
| 16386 | { |
| 16387 | uint16_t size; |
| 16388 | |
| 16389 | if ((resp_dname == NULL) || (response == NULL)) { |
| 16390 | hddLog(LOGE, FL("resp_dname or response is NULL!")); |
| 16391 | return FALSE; |
| 16392 | } |
| 16393 | |
| 16394 | size = MAX_NUM_FIELD_DOMAINNAME * MAX_LEN_DOMAINNAME_FIELD; |
| 16395 | response->data = vos_mem_malloc(size); |
| 16396 | if (response->data) { |
| 16397 | vos_mem_zero(response->data, size); |
| 16398 | if (VOS_STATUS_SUCCESS != |
| 16399 | hdd_string_to_string_array((char *)resp_dname, |
| 16400 | response->data, |
| 16401 | separator, |
| 16402 | &response->num_entries, |
| 16403 | MAX_NUM_FIELD_DOMAINNAME, |
| 16404 | MAX_LEN_DOMAINNAME_FIELD)) { |
| 16405 | hddLog(LOGE, FL("hdd_string_to_string_array fail!")); |
| 16406 | goto err_init_resp; |
| 16407 | } |
| 16408 | |
| 16409 | if ((response->num_entries > 0) && |
| 16410 | (strlen((char *)&response->data[0]) > 0)) { |
| 16411 | size = sizeof(uint16_t) * response->num_entries; |
| 16412 | response->offset = vos_mem_malloc(size); |
| 16413 | if (response->offset) { |
| 16414 | vos_mem_zero(response->offset, size); |
| 16415 | return TRUE; |
| 16416 | } |
| 16417 | } |
| 16418 | } |
| 16419 | |
| 16420 | err_init_resp: |
| 16421 | if (response->data) |
| 16422 | vos_mem_free(response->data); |
| 16423 | wlan_hdd_mdns_reset_response(response); |
| 16424 | return FALSE; |
| 16425 | } |
| 16426 | |
| 16427 | /** |
| 16428 | * wlan_hdd_mdns_find_entries_from_end() - Find the matched entries |
| 16429 | * @response1: The response info is used to be compared. |
| 16430 | * @response2: The response info is used to be compared. |
| 16431 | * |
| 16432 | * This function will find the matched entries from the end. |
| 16433 | * |
| 16434 | * Return: Return the number of the matched entries. |
| 16435 | */ |
| 16436 | static uint8_t |
| 16437 | wlan_hdd_mdns_find_entries_from_end(struct hdd_mdns_resp_info *response1, |
| 16438 | struct hdd_mdns_resp_info *response2) |
| 16439 | { |
| 16440 | uint8_t min, len1, i; |
| 16441 | uint16_t num1, num2; |
| 16442 | uint8_t num_matched = 0; |
| 16443 | |
| 16444 | min = VOS_MIN(response1->num_entries, response2->num_entries); |
| 16445 | |
| 16446 | for (i = 1; i <= min; i++) { |
| 16447 | num1 = (response1->num_entries - i); |
| 16448 | num1 *= MAX_LEN_DOMAINNAME_FIELD; |
| 16449 | num2 = (response2->num_entries - i); |
| 16450 | num2 *= MAX_LEN_DOMAINNAME_FIELD; |
| 16451 | len1 = strlen((char *)&response1->data[num1]); |
| 16452 | |
| 16453 | if ((len1 == 0) || |
| 16454 | (len1 != strlen((char *)&response2->data[num2]))) |
| 16455 | break; |
| 16456 | if (memcmp(&response1->data[num1], |
| 16457 | &response2->data[num2], len1)) |
| 16458 | break; |
| 16459 | else |
| 16460 | num_matched++; |
| 16461 | } |
| 16462 | |
| 16463 | return num_matched; |
| 16464 | } |
| 16465 | |
| 16466 | /** |
| 16467 | * wlan_hdd_mdns_find_max() - Find the maximum number of the matched entries |
| 16468 | * @matchedlist: Pointer to the array of struct hdd_mdns_resp_matched |
| 16469 | * @numlist: The number of the elements in the array matchedlist. |
| 16470 | * |
| 16471 | * Find the max number of the matched entries among the array matchedlist. |
| 16472 | * |
| 16473 | * Return: None |
| 16474 | */ |
| 16475 | static void wlan_hdd_mdns_find_max(struct hdd_mdns_resp_matched *matchedlist, |
| 16476 | uint8_t numlist) |
| 16477 | { |
| 16478 | int j; |
| 16479 | struct hdd_mdns_resp_matched tmp; |
| 16480 | |
| 16481 | /* At least two values are used for sorting */ |
| 16482 | if ((numlist < 2) || (matchedlist == NULL)) { |
| 16483 | hddLog(LOGE, FL("At least two values are used for sorting!")); |
| 16484 | return; |
| 16485 | } |
| 16486 | |
| 16487 | for (j = 0; j < numlist-1; j++) { |
| 16488 | if (matchedlist[j].num_matched > |
| 16489 | matchedlist[j+1].num_matched) { |
| 16490 | vos_mem_copy(&tmp, &matchedlist[j], |
| 16491 | sizeof(struct hdd_mdns_resp_matched)); |
| 16492 | vos_mem_copy(&matchedlist[j], &matchedlist[j+1], |
| 16493 | sizeof(struct hdd_mdns_resp_matched)); |
| 16494 | vos_mem_copy(&matchedlist[j+1], &tmp, |
| 16495 | sizeof(struct hdd_mdns_resp_matched)); |
| 16496 | } |
| 16497 | } |
| 16498 | } |
| 16499 | |
| 16500 | /** |
| 16501 | * wlan_hdd_mdns_pack_response_type_a() - Pack Type A response |
| 16502 | * @ini_config: Pointer to the struct hdd_config_t |
| 16503 | * @resp_info: Pointer to the struct tSirMDNSResponseInfo |
| 16504 | * @resptype_a: Pointer to the struct hdd_mdns_resp_info of Type A |
| 16505 | * |
| 16506 | * Type A response include QName, response type, class, TTL and Ipv4. |
| 16507 | * |
| 16508 | * Return: Return boolean. TRUE for success, FALSE for fail. |
| 16509 | */ |
| 16510 | static bool |
| 16511 | wlan_hdd_mdns_pack_response_type_a(hdd_config_t *ini_config, |
| 16512 | sir_mdns_resp_info resp_info, |
| 16513 | struct hdd_mdns_resp_info *resptype_a) |
| 16514 | { |
| 16515 | uint16_t value; |
| 16516 | uint32_t len; |
| 16517 | |
| 16518 | ENTER(); |
| 16519 | if ((ini_config == NULL) || (resp_info == NULL) || |
| 16520 | (resptype_a == NULL)) { |
| 16521 | hddLog(LOGE, FL("ini_config or response info is NULL!")); |
| 16522 | return FALSE; |
| 16523 | } |
| 16524 | |
| 16525 | /* No Type A response */ |
| 16526 | if (strlen((char *)ini_config->mdns_resp_type_a) <= 0) |
| 16527 | return TRUE; |
| 16528 | |
| 16529 | /* Wrong response is assigned, just ignore this response */ |
| 16530 | if (!wlan_hdd_mdns_init_response(resptype_a, |
| 16531 | ini_config->mdns_resp_type_a, '.')) |
| 16532 | return TRUE; |
| 16533 | |
| 16534 | /* Process response domain name */ |
| 16535 | if (!wlan_hdd_mdns_process_response_dname(resptype_a, resp_info)) { |
| 16536 | hddLog(LOGE, FL("Fail to process mDNS response (%d)!"), |
| 16537 | MDNS_TYPE_A); |
| 16538 | return FALSE; |
| 16539 | } |
| 16540 | |
| 16541 | /* Process response Type, Class, TTL */ |
| 16542 | if (!wlan_hdd_mdns_process_response_misc(MDNS_TYPE_A, resp_info)) { |
| 16543 | hddLog(LOGE, FL("Fail to process mDNS misc response (%d)!"), |
| 16544 | MDNS_TYPE_A); |
| 16545 | return FALSE; |
| 16546 | } |
| 16547 | |
| 16548 | /* Process response RDLength, RData */ |
| 16549 | len = sizeof(uint16_t) + sizeof(uint32_t); |
| 16550 | len += resp_info->resp_len; |
| 16551 | if (len >= MAX_MDNS_RESP_LEN) { |
| 16552 | hddLog(LOGE, FL("resp_len exceeds %d!"), MAX_MDNS_RESP_LEN); |
| 16553 | return FALSE; |
| 16554 | } |
| 16555 | value = sizeof(uint32_t); |
| 16556 | wlan_hdd_mdns_format_response_u16(value, resp_info); |
| 16557 | wlan_hdd_mdns_format_response_u32(ini_config->mdns_resp_type_a_ipv4, |
| 16558 | resp_info); |
| 16559 | |
| 16560 | EXIT(); |
| 16561 | return TRUE; |
| 16562 | } |
| 16563 | |
| 16564 | /** |
| 16565 | * wlan_hdd_mdns_pack_response_type_txt() - Pack Type Txt response |
| 16566 | * @ini_config: Pointer to the struct hdd_config_t |
| 16567 | * @resp_info: Pointer to the struct tSirMDNSResponseInfo |
| 16568 | * @resptype_txt: Pointer to the struct hdd_mdns_resp_info of Type txt |
| 16569 | * @resptype_a: Pointer to the struct hdd_mdns_resp_info of Type A |
| 16570 | * |
| 16571 | * Type Txt response include QName, response type, class, TTL and text content. |
| 16572 | * Also, it will find the matched QName from resptype_A and compress the data. |
| 16573 | * |
| 16574 | * Return: Return boolean. TRUE for success, FALSE for fail. |
| 16575 | */ |
| 16576 | static bool |
| 16577 | wlan_hdd_mdns_pack_response_type_txt(hdd_config_t *ini_config, |
| 16578 | sir_mdns_resp_info resp_info, |
| 16579 | struct hdd_mdns_resp_info *resptype_txt, |
| 16580 | struct hdd_mdns_resp_info *resptype_a) |
| 16581 | { |
| 16582 | uint8_t num_matched; |
| 16583 | uint8_t num; |
| 16584 | uint16_t idx; |
| 16585 | uint16_t value = 0; |
| 16586 | uint32_t len; |
| 16587 | uint32_t total_len; |
| 16588 | bool status; |
| 16589 | struct hdd_mdns_resp_info resptype_content; |
| 16590 | |
| 16591 | ENTER(); |
| 16592 | |
| 16593 | if ((ini_config == NULL) || (resp_info == NULL) || |
| 16594 | (resptype_txt == NULL)) { |
| 16595 | hddLog(LOGE, FL("ini_config or response info is NULL!")); |
| 16596 | return FALSE; |
| 16597 | } |
| 16598 | |
| 16599 | /* No Type Txt response */ |
| 16600 | if (strlen((char *)ini_config->mdns_resp_type_txt) <= 0) |
| 16601 | return TRUE; |
| 16602 | |
| 16603 | /* Wrong response is assigned, just ignore this response */ |
| 16604 | if (!wlan_hdd_mdns_init_response(resptype_txt, |
| 16605 | ini_config->mdns_resp_type_txt, '.')) |
| 16606 | return TRUE; |
| 16607 | |
| 16608 | /* |
| 16609 | * For data compression |
| 16610 | * Check if any strings are matched with Type A response |
| 16611 | */ |
| 16612 | if (resptype_a && (resptype_a->num_entries > 0)) { |
| 16613 | num_matched = wlan_hdd_mdns_find_entries_from_end(resptype_txt, |
| 16614 | resptype_a); |
| 16615 | if (num_matched > 0) { |
| 16616 | if (!wlan_hdd_mdns_compress_data(resp_info, |
| 16617 | resptype_txt, resptype_a, num_matched)) { |
| 16618 | hddLog(LOGE, FL("Fail to compress mDNS " |
| 16619 | "response (%d)!"), MDNS_TYPE_TXT); |
| 16620 | return FALSE; |
| 16621 | } |
| 16622 | } else { |
| 16623 | /* |
| 16624 | * num_matched is zero. Error! |
| 16625 | * At least ".local" is needed. |
| 16626 | */ |
| 16627 | hddLog(LOGE, FL("No matched string! Fail to pack mDNS " |
| 16628 | "response (%d)!"), MDNS_TYPE_TXT); |
| 16629 | return FALSE; |
| 16630 | } |
| 16631 | } else { |
| 16632 | /* no TypeA response, so show the whole data */ |
| 16633 | if (!wlan_hdd_mdns_process_response_dname(resptype_txt, |
| 16634 | resp_info)) { |
| 16635 | hddLog(LOGE, FL("Fail to process mDNS response (%d)!"), |
| 16636 | MDNS_TYPE_TXT); |
| 16637 | return FALSE; |
| 16638 | } |
| 16639 | } |
| 16640 | |
| 16641 | /* Process response Type, Class, TTL */ |
| 16642 | if (!wlan_hdd_mdns_process_response_misc(MDNS_TYPE_TXT, resp_info)) { |
| 16643 | hddLog(LOGE, FL("Fail to process mDNS misc response (%d)!"), |
| 16644 | MDNS_TYPE_TXT); |
| 16645 | return FALSE; |
| 16646 | } |
| 16647 | |
| 16648 | /* |
| 16649 | * Process response RDLength, RData. |
| 16650 | * TypeTxt RData include len. |
| 16651 | */ |
| 16652 | status = wlan_hdd_mdns_init_response(&resptype_content, |
| 16653 | ini_config->mdns_resp_type_txt_content, |
| 16654 | '/'); |
| 16655 | if (status == FALSE) { |
| 16656 | hddLog(LOGE, FL("wlan_hdd_mdns_init_response FAIL")); |
| 16657 | return FALSE; |
| 16658 | } |
| 16659 | |
| 16660 | for (num = 0; num < resptype_content.num_entries; num++) { |
| 16661 | idx = num * MAX_LEN_DOMAINNAME_FIELD; |
| 16662 | value += strlen((char *)&resptype_content.data[idx]); |
| 16663 | } |
| 16664 | |
| 16665 | /* content len is uint16_t */ |
| 16666 | total_len = sizeof(uint16_t); |
| 16667 | total_len += resp_info->resp_len + value + |
| 16668 | resptype_content.num_entries; |
| 16669 | |
| 16670 | if (total_len >= MAX_MDNS_RESP_LEN) { |
| 16671 | hddLog(LOGE, FL("resp_len exceeds %d!"), MAX_MDNS_RESP_LEN); |
| 16672 | return FALSE; |
| 16673 | } |
| 16674 | wlan_hdd_mdns_format_response_u16(value + resptype_content.num_entries, |
| 16675 | resp_info); |
| 16676 | |
| 16677 | for (num = 0; num < resptype_content.num_entries; num++) { |
| 16678 | idx = num * MAX_LEN_DOMAINNAME_FIELD; |
| 16679 | len = strlen((char *)&resptype_content.data[idx]); |
| 16680 | resp_info->resp_data[resp_info->resp_len] = len; |
| 16681 | resp_info->resp_len++; |
| 16682 | |
| 16683 | vos_mem_copy(&resp_info->resp_data[resp_info->resp_len], |
| 16684 | &resptype_content.data[idx], len); |
| 16685 | |
| 16686 | resp_info->resp_len += len; |
| 16687 | hddLog(LOG1, FL("index = %d, len = %d, str = %s"), |
| 16688 | num, len, &resptype_content.data[idx]); |
| 16689 | } |
| 16690 | |
| 16691 | EXIT(); |
| 16692 | return TRUE; |
| 16693 | } |
| 16694 | |
| 16695 | /** |
| 16696 | * wlan_hdd_mdns_pack_response_type_ptr_dname() - Pack Type PTR domain name |
| 16697 | * @ini_config: Pointer to the struct hdd_config_t |
| 16698 | * @resp_info: Pointer to the struct tSirMDNSResponseInfo |
| 16699 | * @resptype_ptr_dn: Pointer to the struct hdd_mdns_resp_info of Type Ptr |
| 16700 | * domain name |
| 16701 | * @resptype_ptr: Pointer to the struct hdd_mdns_resp_info of Type Ptr |
| 16702 | * @resptype_txt: Pointer to the struct hdd_mdns_resp_info of Type Txt |
| 16703 | * @resptype_a: Pointer to the struct hdd_mdns_resp_info of Type A |
| 16704 | * |
| 16705 | * The Type Ptr response include Type PTR domain name in its data field. |
| 16706 | * Also, it will find the matched QName from the existing resptype_ptr, |
| 16707 | * resptype_txt, resptype_a and then compress the data. |
| 16708 | * |
| 16709 | * Return: Return boolean. TRUE for success, FALSE for fail. |
| 16710 | */ |
| 16711 | static bool |
| 16712 | wlan_hdd_mdns_pack_response_type_ptr_dname(hdd_config_t *ini_config, |
| 16713 | sir_mdns_resp_info resp_info, |
| 16714 | struct hdd_mdns_resp_info *resptype_ptr_dn, |
| 16715 | struct hdd_mdns_resp_info *resptype_ptr, |
| 16716 | struct hdd_mdns_resp_info *resptype_txt, |
| 16717 | struct hdd_mdns_resp_info *resptype_a) |
| 16718 | { |
| 16719 | uint8_t num_matched, numlist, size; |
| 16720 | struct hdd_mdns_resp_matched matchedlist[MAX_MDNS_RESP_TYPE-1]; |
| 16721 | struct hdd_mdns_resp_info *resp; |
| 16722 | |
| 16723 | if ((ini_config == NULL) || (resp_info == NULL) || |
| 16724 | (resptype_ptr == NULL) || (resptype_ptr_dn == NULL)) { |
| 16725 | hddLog(LOGE, FL("ini_config or response info is NULL!")); |
| 16726 | return FALSE; |
| 16727 | } |
| 16728 | |
| 16729 | /* No Type Ptr domain name response */ |
| 16730 | if (strlen((char *)ini_config->mdns_resp_type_ptr_dname) <= 0) |
| 16731 | return TRUE; |
| 16732 | |
| 16733 | /* Wrong response is assigned, just ignore this response */ |
| 16734 | if (!wlan_hdd_mdns_init_response(resptype_ptr_dn, |
| 16735 | ini_config->mdns_resp_type_ptr_dname, '.')) |
| 16736 | return TRUE; |
| 16737 | |
| 16738 | /* |
| 16739 | * For data compression |
| 16740 | * Check if any strings are matched with previous |
| 16741 | * response. |
| 16742 | */ |
| 16743 | numlist = 0; |
| 16744 | size = (MAX_MDNS_RESP_TYPE-1); |
| 16745 | size *= sizeof(struct hdd_mdns_resp_matched); |
| 16746 | vos_mem_zero(matchedlist, size); |
| 16747 | num_matched = wlan_hdd_mdns_find_entries_from_end(resptype_ptr_dn, |
| 16748 | resptype_ptr); |
| 16749 | if (num_matched > 0) { |
| 16750 | matchedlist[numlist].num_matched = num_matched; |
| 16751 | matchedlist[numlist].type = MDNS_TYPE_PTR; |
| 16752 | numlist++; |
| 16753 | } |
| 16754 | if (resptype_txt && (resptype_txt->num_entries > 0)) { |
| 16755 | num_matched = wlan_hdd_mdns_find_entries_from_end( |
| 16756 | resptype_ptr_dn, resptype_txt); |
| 16757 | if (num_matched > 0) { |
| 16758 | matchedlist[numlist].num_matched = num_matched; |
| 16759 | matchedlist[numlist].type = MDNS_TYPE_TXT; |
| 16760 | numlist++; |
| 16761 | } |
| 16762 | } |
| 16763 | if (resptype_a && (resptype_a->num_entries > 0)) { |
| 16764 | num_matched = wlan_hdd_mdns_find_entries_from_end( |
| 16765 | resptype_ptr_dn,resptype_a); |
| 16766 | if (num_matched > 0) { |
| 16767 | matchedlist[numlist].num_matched = num_matched; |
| 16768 | matchedlist[numlist].type = MDNS_TYPE_A; |
| 16769 | numlist++; |
| 16770 | } |
| 16771 | } |
| 16772 | if (numlist > 0) { |
| 16773 | if (numlist > 1) |
| 16774 | wlan_hdd_mdns_find_max(matchedlist, numlist); |
| 16775 | resp = NULL; |
| 16776 | switch (matchedlist[numlist-1].type) { |
| 16777 | case MDNS_TYPE_A: |
| 16778 | resp = resptype_a; |
| 16779 | break; |
| 16780 | case MDNS_TYPE_TXT: |
| 16781 | resp = resptype_txt; |
| 16782 | break; |
| 16783 | case MDNS_TYPE_PTR: |
| 16784 | resp = resptype_ptr; |
| 16785 | break; |
| 16786 | default: |
| 16787 | hddLog(LOGE, FL("Fail to compress mDNS response " |
| 16788 | "(%d)!"), MDNS_TYPE_PTR_DNAME); |
| 16789 | return FALSE; |
| 16790 | } |
| 16791 | num_matched = matchedlist[numlist-1].num_matched; |
| 16792 | if (!wlan_hdd_mdns_compress_data(resp_info, resptype_ptr_dn, |
| 16793 | resp, num_matched)) { |
| 16794 | hddLog(LOGE, FL("Fail to compress mDNS response " |
| 16795 | "(%d)!"), MDNS_TYPE_PTR_DNAME); |
| 16796 | return FALSE; |
| 16797 | } |
| 16798 | } else { |
| 16799 | /* num = 0 -> no matched string */ |
| 16800 | if (!wlan_hdd_mdns_process_response_dname(resptype_ptr_dn, |
| 16801 | resp_info)) { |
| 16802 | hddLog(LOGE, FL("Fail to process mDNS response (%d)!"), |
| 16803 | MDNS_TYPE_PTR_DNAME); |
| 16804 | return FALSE; |
| 16805 | } |
| 16806 | } |
| 16807 | |
| 16808 | return TRUE; |
| 16809 | } |
| 16810 | |
| 16811 | /** |
| 16812 | * wlan_hdd_mdns_pack_response_type_ptr() - Pack Type PTR response |
| 16813 | * @ini_config: Pointer to the struct hdd_config_t |
| 16814 | * @resp_info: Pointer to the struct tSirMDNSResponseInfo |
| 16815 | * @resptype_ptr: Pointer to the struct hdd_mdns_resp_info of Type Ptr |
| 16816 | * @resptype_ptr_dn: Pointer to the struct hdd_mdns_resp_info of Type Ptr |
| 16817 | * domain name |
| 16818 | * @resptype_txt: Pointer to the struct hdd_mdns_resp_info of Type Txt |
| 16819 | * @resptype_a: Pointer to the struct hdd_mdns_resp_info of Type A |
| 16820 | * |
| 16821 | * The Type Ptr response include QName, response type, class, TTL and |
| 16822 | * Type PTR domain name. Also, it will find the matched QName from the |
| 16823 | * existing resptype_txt, resptype_a and then compress the data. |
| 16824 | * |
| 16825 | * Return: Return boolean. TRUE for success, FALSE for fail. |
| 16826 | */ |
| 16827 | static bool |
| 16828 | wlan_hdd_mdns_pack_response_type_ptr(hdd_config_t *ini_config, |
| 16829 | sir_mdns_resp_info resp_info, |
| 16830 | struct hdd_mdns_resp_info *resptype_ptr, |
| 16831 | struct hdd_mdns_resp_info *resptype_ptr_dn, |
| 16832 | struct hdd_mdns_resp_info *resptype_txt, |
| 16833 | struct hdd_mdns_resp_info *resptype_a) |
| 16834 | { |
| 16835 | uint8_t num_matched, num_matched1; |
| 16836 | uint16_t value; |
| 16837 | uint8_t val_u8; |
| 16838 | uint32_t offset_data_len, len; |
| 16839 | |
| 16840 | ENTER(); |
| 16841 | if ((ini_config == NULL) || (resp_info == NULL) || |
| 16842 | (resptype_ptr == NULL) || (resptype_ptr_dn == NULL)) { |
| 16843 | hddLog(LOGE, FL("ini_config or response info is NULL!")); |
| 16844 | return FALSE; |
| 16845 | } |
| 16846 | |
| 16847 | /* No Type Ptr response */ |
| 16848 | if (strlen((char *)ini_config->mdns_resp_type_ptr) <= 0) |
| 16849 | return TRUE; |
| 16850 | |
| 16851 | /* Wrong response is assigned, just ignore this response */ |
| 16852 | if (!wlan_hdd_mdns_init_response(resptype_ptr, |
| 16853 | ini_config->mdns_resp_type_ptr, '.')) |
| 16854 | return TRUE; |
| 16855 | |
| 16856 | /* |
| 16857 | * For data compression |
| 16858 | * Check if any strings are matched with Type A response |
| 16859 | */ |
| 16860 | num_matched = 0; |
| 16861 | num_matched1 = 0; |
| 16862 | if (resptype_a && (resptype_a->num_entries > 0)) { |
| 16863 | num_matched = wlan_hdd_mdns_find_entries_from_end(resptype_ptr, |
| 16864 | resptype_a); |
| 16865 | } |
| 16866 | if (resptype_txt && (resptype_txt->num_entries > 0)) { |
| 16867 | num_matched1 = wlan_hdd_mdns_find_entries_from_end( |
| 16868 | resptype_ptr, resptype_txt); |
| 16869 | } |
| 16870 | if ((num_matched != num_matched1) || |
| 16871 | ((num_matched > 0) && (num_matched1 > 0))) { |
| 16872 | if (num_matched >= num_matched1) { |
| 16873 | if (!wlan_hdd_mdns_compress_data(resp_info, |
| 16874 | resptype_ptr, resptype_a, num_matched)) { |
| 16875 | hddLog(LOGE, FL("Fail to compress mDNS " |
| 16876 | "response (%d)!"), MDNS_TYPE_PTR); |
| 16877 | return FALSE; |
| 16878 | } |
| 16879 | } else { |
| 16880 | /* num_matched is less than num_matched1 */ |
| 16881 | if (!wlan_hdd_mdns_compress_data(resp_info, |
| 16882 | resptype_ptr, resptype_txt, num_matched1)) { |
| 16883 | hddLog(LOGE, FL("Fail to compress mDNS " |
| 16884 | "response (%d)!"), MDNS_TYPE_PTR); |
| 16885 | return FALSE; |
| 16886 | } |
| 16887 | } |
| 16888 | } else { |
| 16889 | /* |
| 16890 | * Both num_matched and num_matched1 are zero. |
| 16891 | * no TypeA & TypeTxt |
| 16892 | */ |
| 16893 | if (!wlan_hdd_mdns_process_response_dname(resptype_ptr, |
| 16894 | resp_info)) { |
| 16895 | hddLog(LOGE, FL("Fail to process mDNS response (%d)!"), |
| 16896 | MDNS_TYPE_PTR); |
| 16897 | return FALSE; |
| 16898 | } |
| 16899 | } |
| 16900 | |
| 16901 | /* Process response Type, Class, TTL */ |
| 16902 | if (!wlan_hdd_mdns_process_response_misc(MDNS_TYPE_PTR, resp_info)) { |
| 16903 | hddLog(LOGE, FL("Fail to process mDNS misc response (%d)!"), |
| 16904 | MDNS_TYPE_PTR); |
| 16905 | return FALSE; |
| 16906 | } |
| 16907 | |
| 16908 | /* |
| 16909 | * Process response RDLength, RData (Ptr domain name) |
| 16910 | * Save the offset of RData length |
| 16911 | */ |
| 16912 | offset_data_len = resp_info->resp_len; |
| 16913 | resp_info->resp_len += sizeof(uint16_t); |
| 16914 | |
| 16915 | if (!wlan_hdd_mdns_pack_response_type_ptr_dname(ini_config, resp_info, |
| 16916 | resptype_ptr_dn, resptype_ptr, |
| 16917 | resptype_txt, resptype_a)) { |
| 16918 | return FALSE; |
| 16919 | } |
| 16920 | /* Set the RData length */ |
| 16921 | len = offset_data_len + sizeof(uint16_t); |
| 16922 | if ((resptype_ptr_dn->num_entries > 0) && |
| 16923 | (resp_info->resp_len > len)) { |
| 16924 | value = resp_info->resp_len - len; |
| 16925 | val_u8 = (value & 0xff00) >> 8; |
| 16926 | resp_info->resp_data[offset_data_len] = val_u8; |
| 16927 | val_u8 = value & 0xff; |
| 16928 | resp_info->resp_data[offset_data_len+1] = val_u8; |
| 16929 | } else { |
| 16930 | hddLog(LOGE, FL("Fail to process mDNS response (%d)!"), |
| 16931 | MDNS_TYPE_PTR); |
| 16932 | return FALSE; |
| 16933 | } |
| 16934 | |
| 16935 | EXIT(); |
| 16936 | return TRUE; |
| 16937 | } |
| 16938 | |
| 16939 | /** |
| 16940 | * wlan_hdd_mdns_pack_response_type_srv_target()- Pack Type Service Target |
| 16941 | * @ini_config: Pointer to the struct hdd_config_t |
| 16942 | * @resp_info: Pointer to the struct tSirMDNSResponseInfo |
| 16943 | * @resptype_srv_tgt: Pointer to the struct hdd_mdns_resp_info of Type Srv |
| 16944 | * target |
| 16945 | * @resptype_srv: Pointer to the struct hdd_mdns_resp_info of Type Srv |
| 16946 | * @resptype_ptr: Pointer to the struct hdd_mdns_resp_info of Type Ptr |
| 16947 | * @resptype_ptr_dn: Pointer to the struct hdd_mdns_resp_info of Type Ptr |
| 16948 | * domain name |
| 16949 | * @resptype_txt: Pointer to the struct hdd_mdns_resp_info of Type Txt |
| 16950 | * @resptype_a: Pointer to the struct hdd_mdns_resp_info of Type A |
| 16951 | * |
| 16952 | * The Type service target is one of the data field in the Type SRV response. |
| 16953 | * Also, it will find the matched QName from the existing resptype_srv, |
| 16954 | * resptype_ptr, resptype_ptr_dn, resptype_txt, resptype_a and then compress |
| 16955 | * the data. |
| 16956 | * |
| 16957 | * Return: Return boolean. TRUE for success, FALSE for fail. |
| 16958 | */ |
| 16959 | static bool |
| 16960 | wlan_hdd_mdns_pack_response_type_srv_target(hdd_config_t *ini_config, |
| 16961 | sir_mdns_resp_info resp_info, |
| 16962 | struct hdd_mdns_resp_info *resptype_srv_tgt, |
| 16963 | struct hdd_mdns_resp_info *resptype_srv, |
| 16964 | struct hdd_mdns_resp_info *resptype_ptr, |
| 16965 | struct hdd_mdns_resp_info *resptype_ptr_dn, |
| 16966 | struct hdd_mdns_resp_info *resptype_txt, |
| 16967 | struct hdd_mdns_resp_info *resptype_a) |
| 16968 | { |
| 16969 | uint8_t num_matched, num, size; |
| 16970 | struct hdd_mdns_resp_matched matchedlist[MAX_MDNS_RESP_TYPE-1]; |
| 16971 | struct hdd_mdns_resp_info *resp; |
| 16972 | |
| 16973 | if ((ini_config == NULL) || (resp_info == NULL) || |
| 16974 | (resptype_srv == NULL) || (resptype_srv_tgt == NULL)) { |
| 16975 | hddLog(LOGE, FL("ini_config or response info is NULL!")); |
| 16976 | return FALSE; |
| 16977 | } |
| 16978 | |
| 16979 | /* No Type Srv Target response */ |
| 16980 | if (strlen((char *)ini_config->mdns_resp_type_srv_target) <= 0) |
| 16981 | return TRUE; |
| 16982 | |
| 16983 | /* Wrong response is assigned, just ignore this response */ |
| 16984 | if (!wlan_hdd_mdns_init_response(resptype_srv_tgt, |
| 16985 | ini_config->mdns_resp_type_srv_target, '.')) |
| 16986 | return TRUE; |
| 16987 | |
| 16988 | /* |
| 16989 | * For data compression |
| 16990 | * Check if any strings are matched with previous response. |
| 16991 | */ |
| 16992 | num = 0; |
| 16993 | size = (MAX_MDNS_RESP_TYPE-1); |
| 16994 | size *= sizeof(struct hdd_mdns_resp_matched); |
| 16995 | vos_mem_zero(matchedlist, size); |
| 16996 | num_matched = wlan_hdd_mdns_find_entries_from_end(resptype_srv_tgt, |
| 16997 | resptype_srv); |
| 16998 | if (num_matched > 0) { |
| 16999 | matchedlist[num].num_matched = num_matched; |
| 17000 | matchedlist[num].type = MDNS_TYPE_SRV; |
| 17001 | num++; |
| 17002 | } |
| 17003 | if (resptype_ptr && (resptype_ptr->num_entries > 0)) { |
| 17004 | if (resptype_ptr_dn && (resptype_ptr_dn->num_entries > 0)) { |
| 17005 | num_matched = wlan_hdd_mdns_find_entries_from_end( |
| 17006 | resptype_srv_tgt, resptype_ptr_dn); |
| 17007 | if (num_matched > 0) { |
| 17008 | matchedlist[num].num_matched = num_matched; |
| 17009 | matchedlist[num].type = MDNS_TYPE_PTR_DNAME; |
| 17010 | num++; |
| 17011 | } |
| 17012 | } |
| 17013 | num_matched = wlan_hdd_mdns_find_entries_from_end( |
| 17014 | resptype_srv_tgt, resptype_ptr); |
| 17015 | if (num_matched > 0) { |
| 17016 | matchedlist[num].num_matched = num_matched; |
| 17017 | matchedlist[num].type = MDNS_TYPE_PTR; |
| 17018 | num++; |
| 17019 | } |
| 17020 | } |
| 17021 | if (resptype_txt && (resptype_txt->num_entries > 0)) { |
| 17022 | num_matched = wlan_hdd_mdns_find_entries_from_end( |
| 17023 | resptype_srv_tgt, resptype_txt); |
| 17024 | if (num_matched > 0) { |
| 17025 | matchedlist[num].num_matched = num_matched; |
| 17026 | matchedlist[num].type = MDNS_TYPE_TXT; |
| 17027 | num++; |
| 17028 | } |
| 17029 | } |
| 17030 | if (resptype_a && (resptype_a->num_entries > 0)) { |
| 17031 | num_matched = wlan_hdd_mdns_find_entries_from_end( |
| 17032 | resptype_srv_tgt, resptype_a); |
| 17033 | if (num_matched > 0) { |
| 17034 | matchedlist[num].num_matched = num_matched; |
| 17035 | matchedlist[num].type = MDNS_TYPE_A; |
| 17036 | num++; |
| 17037 | } |
| 17038 | } |
| 17039 | if (num > 0) { |
| 17040 | if (num > 1) |
| 17041 | wlan_hdd_mdns_find_max(matchedlist, num); |
| 17042 | resp = NULL; |
| 17043 | switch (matchedlist[num-1].type) { |
| 17044 | case MDNS_TYPE_A: |
| 17045 | resp = resptype_a; |
| 17046 | break; |
| 17047 | case MDNS_TYPE_TXT: |
| 17048 | resp = resptype_txt; |
| 17049 | break; |
| 17050 | case MDNS_TYPE_PTR: |
| 17051 | resp = resptype_ptr; |
| 17052 | break; |
| 17053 | case MDNS_TYPE_PTR_DNAME: |
| 17054 | resp = resptype_ptr_dn; |
| 17055 | break; |
| 17056 | case MDNS_TYPE_SRV: |
| 17057 | resp = resptype_srv; |
| 17058 | break; |
| 17059 | default: |
| 17060 | hddLog(LOGE, FL("Fail to compress mDNS response " |
| 17061 | "(%d)!"), MDNS_TYPE_SRV_TARGET); |
| 17062 | return FALSE; |
| 17063 | } |
| 17064 | num_matched = matchedlist[num-1].num_matched; |
| 17065 | if (!wlan_hdd_mdns_compress_data(resp_info, resptype_srv_tgt, |
| 17066 | resp, num_matched)) { |
| 17067 | hddLog(LOGE, FL("Fail to compress mDNS response " |
| 17068 | "(%d)!"), MDNS_TYPE_SRV_TARGET); |
| 17069 | return FALSE; |
| 17070 | } |
| 17071 | } else { |
| 17072 | /* num = 0 -> no matched string */ |
| 17073 | if (!wlan_hdd_mdns_process_response_dname(resptype_srv_tgt, |
| 17074 | resp_info)) { |
| 17075 | hddLog(LOGE, FL("Fail to process mDNS response (%d)!"), |
| 17076 | MDNS_TYPE_SRV_TARGET); |
| 17077 | return FALSE; |
| 17078 | } |
| 17079 | } |
| 17080 | |
| 17081 | return TRUE; |
| 17082 | } |
| 17083 | |
| 17084 | /** |
| 17085 | * wlan_hdd_mdns_pack_response_type_srv()- Pack Type Service response |
| 17086 | * @ini_config: Pointer to the struct hdd_config_t |
| 17087 | * @resp_info: Pointer to the struct tSirMDNSResponseInfo |
| 17088 | * @resptype_srv: Pointer to the struct hdd_mdns_resp_info of Type Srv |
| 17089 | * @resptype_srv_tgt: Pointer to the struct hdd_mdns_resp_info of Type Srv |
| 17090 | * target |
| 17091 | * @resptype_ptr: Pointer to the struct hdd_mdns_resp_info of Type Ptr |
| 17092 | * @resptype_ptr_dn: Pointer to the struct hdd_mdns_resp_info of Type Ptr |
| 17093 | * domain name |
| 17094 | * @resptype_txt: Pointer to the struct hdd_mdns_resp_info of Type Txt |
| 17095 | * @resptype_a: Pointer to the struct hdd_mdns_resp_info of Type A |
| 17096 | * |
| 17097 | * The Type SRV (Service) response include QName, response type, class, TTL |
| 17098 | * and four kinds of data fields. Also, it will find the matched QName from |
| 17099 | * the existing resptype_ptr, resptype_ptr_dn, resptype_txt, resptype_a and |
| 17100 | * then compress the data. |
| 17101 | * |
| 17102 | * Return: Return boolean. TRUE for success, FALSE for fail. |
| 17103 | */ |
| 17104 | static bool |
| 17105 | wlan_hdd_mdns_pack_response_type_srv(hdd_config_t *ini_config, |
| 17106 | sir_mdns_resp_info resp_info, |
| 17107 | struct hdd_mdns_resp_info *resptype_srv, |
| 17108 | struct hdd_mdns_resp_info *resptype_srv_tgt, |
| 17109 | struct hdd_mdns_resp_info *resptype_ptr, |
| 17110 | struct hdd_mdns_resp_info *resptype_ptr_dn, |
| 17111 | struct hdd_mdns_resp_info *resptype_txt, |
| 17112 | struct hdd_mdns_resp_info *resptype_a) |
| 17113 | { |
| 17114 | uint8_t num_matched, num, size; |
| 17115 | uint16_t value; |
| 17116 | uint8_t val_u8; |
| 17117 | uint32_t offset_data_len, len; |
| 17118 | struct hdd_mdns_resp_info *resp; |
| 17119 | struct hdd_mdns_resp_matched matchedlist[MAX_MDNS_RESP_TYPE-1]; |
| 17120 | |
| 17121 | ENTER(); |
| 17122 | |
| 17123 | if ((ini_config == NULL) || (resp_info == NULL) || |
| 17124 | (resptype_srv == NULL) || (resptype_srv_tgt == NULL)) { |
| 17125 | hddLog(LOGE, FL("ini_config or response info is NULL!")); |
| 17126 | return FALSE; |
| 17127 | } |
| 17128 | |
| 17129 | /* No Type Srv response */ |
| 17130 | if (strlen((char *)ini_config->mdns_resp_type_srv) <= 0) |
| 17131 | return TRUE; |
| 17132 | |
| 17133 | /* Wrong response is assigned, just ignore this response */ |
| 17134 | if (!wlan_hdd_mdns_init_response(resptype_srv, |
| 17135 | ini_config->mdns_resp_type_srv, '.')) |
| 17136 | return TRUE; |
| 17137 | |
| 17138 | /* |
| 17139 | * For data compression |
| 17140 | * Check if any strings are matched with Type A response |
| 17141 | */ |
| 17142 | num = 0; |
| 17143 | size = (MAX_MDNS_RESP_TYPE-1); |
| 17144 | size *= sizeof(struct hdd_mdns_resp_matched); |
| 17145 | vos_mem_zero(matchedlist, size); |
| 17146 | if (resptype_ptr && (resptype_ptr->num_entries > 0)) { |
| 17147 | if (resptype_ptr_dn && (resptype_ptr_dn->num_entries > 0)) { |
| 17148 | num_matched = wlan_hdd_mdns_find_entries_from_end( |
| 17149 | resptype_srv, |
| 17150 | resptype_ptr_dn); |
| 17151 | if (num_matched > 0) { |
| 17152 | matchedlist[num].num_matched = num_matched; |
| 17153 | matchedlist[num].type = MDNS_TYPE_PTR_DNAME; |
| 17154 | num++; |
| 17155 | } |
| 17156 | } |
| 17157 | num_matched = wlan_hdd_mdns_find_entries_from_end(resptype_srv, |
| 17158 | resptype_ptr); |
| 17159 | if (num_matched > 0) { |
| 17160 | matchedlist[num].num_matched = num_matched; |
| 17161 | matchedlist[num].type = MDNS_TYPE_PTR; |
| 17162 | num++; |
| 17163 | } |
| 17164 | } |
| 17165 | if (resptype_txt && (resptype_txt->num_entries > 0)) { |
| 17166 | num_matched = wlan_hdd_mdns_find_entries_from_end(resptype_srv, |
| 17167 | resptype_txt); |
| 17168 | if (num_matched > 0) { |
| 17169 | matchedlist[num].num_matched =num_matched; |
| 17170 | matchedlist[num].type = MDNS_TYPE_TXT; |
| 17171 | num++; |
| 17172 | } |
| 17173 | } |
| 17174 | if (resptype_a && (resptype_a->num_entries > 0)) { |
| 17175 | num_matched = wlan_hdd_mdns_find_entries_from_end(resptype_srv, |
| 17176 | resptype_a); |
| 17177 | if (num_matched > 0) { |
| 17178 | matchedlist[num].num_matched = num_matched; |
| 17179 | matchedlist[num].type = MDNS_TYPE_A; |
| 17180 | num++; |
| 17181 | } |
| 17182 | } |
| 17183 | if (num > 0) { |
| 17184 | if (num > 1) |
| 17185 | wlan_hdd_mdns_find_max(matchedlist, num); |
| 17186 | resp = NULL; |
| 17187 | switch (matchedlist[num-1].type) { |
| 17188 | case MDNS_TYPE_A: |
| 17189 | resp = resptype_a; |
| 17190 | break; |
| 17191 | case MDNS_TYPE_TXT: |
| 17192 | resp = resptype_txt; |
| 17193 | break; |
| 17194 | case MDNS_TYPE_PTR: |
| 17195 | resp = resptype_ptr; |
| 17196 | break; |
| 17197 | case MDNS_TYPE_PTR_DNAME: |
| 17198 | resp = resptype_ptr_dn; |
| 17199 | break; |
| 17200 | default: |
| 17201 | hddLog(LOGE, FL("Fail to compress mDNS response " |
| 17202 | "(%d)!"), MDNS_TYPE_SRV); |
| 17203 | return FALSE; |
| 17204 | } |
| 17205 | num_matched = matchedlist[num-1].num_matched; |
| 17206 | if (!wlan_hdd_mdns_compress_data(resp_info, resptype_srv, |
| 17207 | resp, num_matched)) { |
| 17208 | hddLog(LOGE, FL("Fail to compress mDNS response " |
| 17209 | "(%d)!"), MDNS_TYPE_SRV); |
| 17210 | return FALSE; |
| 17211 | } |
| 17212 | } else { |
| 17213 | /* num = 0 -> no matched string */ |
| 17214 | if (!wlan_hdd_mdns_process_response_dname(resptype_srv, |
| 17215 | resp_info)) { |
| 17216 | hddLog(LOGE, FL("Fail to process mDNS response (%d)!"), |
| 17217 | MDNS_TYPE_SRV); |
| 17218 | return FALSE; |
| 17219 | } |
| 17220 | } |
| 17221 | |
| 17222 | /* Process response Type, Class, TTL */ |
| 17223 | if (!wlan_hdd_mdns_process_response_misc(MDNS_TYPE_SRV, resp_info)) { |
| 17224 | hddLog(LOGE, FL("Fail to process mDNS misc response (%d)!"), |
| 17225 | MDNS_TYPE_SRV); |
| 17226 | return FALSE; |
| 17227 | } |
| 17228 | |
| 17229 | /* |
| 17230 | * Process response RDLength, RData (Srv target name) |
| 17231 | * Save the offset of RData length |
| 17232 | */ |
| 17233 | offset_data_len = resp_info->resp_len; |
| 17234 | resp_info->resp_len += sizeof(uint16_t); |
| 17235 | |
| 17236 | len = resp_info->resp_len + (3 * sizeof(uint16_t)); |
| 17237 | if (len >= MAX_MDNS_RESP_LEN) { |
| 17238 | hddLog(LOGE, FL("resp_len exceeds %d!"), MAX_MDNS_RESP_LEN); |
| 17239 | return FALSE; |
| 17240 | } |
| 17241 | |
| 17242 | /* set Srv Priority */ |
| 17243 | value = ini_config->mdns_resp_type_srv_priority; |
| 17244 | wlan_hdd_mdns_format_response_u16(value, resp_info); |
| 17245 | /* set Srv Weight */ |
| 17246 | value = ini_config->mdns_resp_type_srv_weight; |
| 17247 | wlan_hdd_mdns_format_response_u16(value, resp_info); |
| 17248 | /* set Srv Port */ |
| 17249 | value = ini_config->mdns_resp_type_srv_port; |
| 17250 | wlan_hdd_mdns_format_response_u16(value, resp_info); |
| 17251 | |
| 17252 | if (!wlan_hdd_mdns_pack_response_type_srv_target(ini_config, resp_info, |
| 17253 | resptype_srv_tgt, resptype_srv, |
| 17254 | resptype_ptr, resptype_ptr_dn, |
| 17255 | resptype_txt, resptype_a)) { |
| 17256 | return FALSE; |
| 17257 | } |
| 17258 | /* Set the RData length */ |
| 17259 | len = offset_data_len + sizeof(uint16_t); |
| 17260 | if ((resptype_srv_tgt->num_entries > 0) && |
| 17261 | (resp_info->resp_len > len)) { |
| 17262 | value = resp_info->resp_len - len; |
| 17263 | val_u8 = (value & 0xff00) >> 8; |
| 17264 | resp_info->resp_data[offset_data_len] = val_u8; |
| 17265 | val_u8 = value & 0xff; |
| 17266 | resp_info->resp_data[offset_data_len+1] = val_u8; |
| 17267 | } else { |
| 17268 | hddLog(LOGE, FL("Fail to process mDNS response (%d)!"), |
| 17269 | MDNS_TYPE_SRV); |
| 17270 | return FALSE; |
| 17271 | } |
| 17272 | |
| 17273 | EXIT(); |
| 17274 | return TRUE; |
| 17275 | } |
| 17276 | |
| 17277 | /** |
| 17278 | * wlan_hdd_mdns_free_mem() - Free the allocated memory |
| 17279 | * @response: Pointer to the struct hdd_mdns_resp_info |
| 17280 | * |
| 17281 | * Return: None |
| 17282 | */ |
| 17283 | static void wlan_hdd_mdns_free_mem(struct hdd_mdns_resp_info *response) |
| 17284 | { |
| 17285 | if (response && response->data) |
| 17286 | vos_mem_free(response->data); |
| 17287 | if (response && response->offset) |
| 17288 | vos_mem_free(response->offset); |
| 17289 | } |
| 17290 | |
| 17291 | /** |
| 17292 | * wlan_hdd_mdns_pack_response() - Pack mDNS response |
| 17293 | * @ini_config: Pointer to the struct hdd_config_t |
| 17294 | * @resp_info: Pointer to the struct tSirMDNSResponseInfo |
| 17295 | * |
| 17296 | * This function will pack four types of responses (Type A, Type Txt, Type Ptr |
| 17297 | * and Type Service). Each response contains QName, response type, class, TTL |
| 17298 | * and data fields. |
| 17299 | * |
| 17300 | * Return: Return boolean. TRUE for success, FALSE for fail. |
| 17301 | */ |
| 17302 | static bool wlan_hdd_mdns_pack_response(hdd_config_t *ini_config, |
| 17303 | sir_mdns_resp_info resp_info) |
| 17304 | { |
| 17305 | struct hdd_mdns_resp_info resptype_a, resptype_txt; |
| 17306 | struct hdd_mdns_resp_info resptype_ptr, resptype_ptr_dn; |
| 17307 | struct hdd_mdns_resp_info resptype_srv, resptype_srv_tgt; |
| 17308 | uint32_t num_res_records = 0; |
| 17309 | bool status = FALSE; |
| 17310 | |
| 17311 | ENTER(); |
| 17312 | |
| 17313 | wlan_hdd_mdns_reset_response(&resptype_a); |
| 17314 | wlan_hdd_mdns_reset_response(&resptype_txt); |
| 17315 | wlan_hdd_mdns_reset_response(&resptype_ptr); |
| 17316 | wlan_hdd_mdns_reset_response(&resptype_ptr_dn); |
| 17317 | wlan_hdd_mdns_reset_response(&resptype_srv); |
| 17318 | wlan_hdd_mdns_reset_response(&resptype_srv_tgt); |
| 17319 | |
| 17320 | resp_info->resp_len = 0; |
| 17321 | |
| 17322 | /* Process Type A response */ |
| 17323 | if (!wlan_hdd_mdns_pack_response_type_a(ini_config, resp_info, |
| 17324 | &resptype_a)) |
| 17325 | goto err_resptype_a; |
| 17326 | |
| 17327 | if ((resptype_a.num_entries > 0) && |
| 17328 | (strlen((char *)&resptype_a.data[0]) > 0)) |
| 17329 | num_res_records++; |
| 17330 | |
| 17331 | /* Process Type TXT response */ |
| 17332 | if (!wlan_hdd_mdns_pack_response_type_txt(ini_config, resp_info, |
| 17333 | &resptype_txt, &resptype_a)) |
| 17334 | goto err_resptype_txt; |
| 17335 | |
| 17336 | if ((resptype_txt.num_entries > 0) && |
| 17337 | (strlen((char *)&resptype_txt.data[0]) > 0)) |
| 17338 | num_res_records++; |
| 17339 | |
| 17340 | /* Process Type PTR response */ |
| 17341 | if (!wlan_hdd_mdns_pack_response_type_ptr(ini_config, resp_info, |
| 17342 | &resptype_ptr, &resptype_ptr_dn, |
| 17343 | &resptype_txt, &resptype_a)) |
| 17344 | goto err_resptype_ptr; |
| 17345 | |
| 17346 | if ((resptype_ptr.num_entries > 0) && |
| 17347 | (strlen((char *)&resptype_ptr.data[0]) > 0)) |
| 17348 | num_res_records++; |
| 17349 | |
| 17350 | /* Process Type SRV response */ |
| 17351 | if (!wlan_hdd_mdns_pack_response_type_srv(ini_config, resp_info, |
| 17352 | &resptype_srv, &resptype_srv_tgt, |
| 17353 | &resptype_ptr, &resptype_ptr_dn, |
| 17354 | &resptype_txt, &resptype_a)) |
| 17355 | goto err_resptype_srv; |
| 17356 | |
| 17357 | if ((resptype_srv.num_entries > 0) && |
| 17358 | (strlen((char *)&resptype_srv.data[0]) > 0)) |
| 17359 | num_res_records++; |
| 17360 | |
| 17361 | resp_info->resourceRecord_count = num_res_records; |
| 17362 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, |
| 17363 | "%s: Pack mDNS response data successfully!", __func__); |
| 17364 | status = TRUE; |
| 17365 | |
| 17366 | err_resptype_srv: |
| 17367 | wlan_hdd_mdns_free_mem(&resptype_srv); |
| 17368 | wlan_hdd_mdns_free_mem(&resptype_srv_tgt); |
| 17369 | |
| 17370 | err_resptype_ptr: |
| 17371 | wlan_hdd_mdns_free_mem(&resptype_ptr); |
| 17372 | wlan_hdd_mdns_free_mem(&resptype_ptr_dn); |
| 17373 | |
| 17374 | err_resptype_txt: |
| 17375 | wlan_hdd_mdns_free_mem(&resptype_txt); |
| 17376 | |
| 17377 | err_resptype_a: |
| 17378 | wlan_hdd_mdns_free_mem(&resptype_a); |
| 17379 | |
| 17380 | EXIT(); |
| 17381 | return status; |
| 17382 | } |
| 17383 | |
| 17384 | /** |
| 17385 | * wlan_hdd_set_mdns_offload() - Enable mDNS offload |
| 17386 | * @hostapd_adapter: Pointer to the struct hdd_adapter_t |
| 17387 | * |
| 17388 | * This function will set FQDN/unique FQDN (full qualified domain name) |
| 17389 | * and the mDNS response. Then send them to SME. |
| 17390 | * |
| 17391 | * Return: Return boolean. TRUE for success, FALSE for fail. |
| 17392 | */ |
| 17393 | bool wlan_hdd_set_mdns_offload(hdd_adapter_t *hostapd_adapter) |
| 17394 | { |
| 17395 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(hostapd_adapter); |
| 17396 | sir_mdns_offload_info mdns_offload_info; |
| 17397 | sir_mdns_fqdn_info mdns_fqdn_info; |
| 17398 | sir_mdns_resp_info mdns_resp_info; |
| 17399 | uint32_t fqdn_len, ufqdn_len; |
| 17400 | |
| 17401 | ENTER(); |
| 17402 | |
| 17403 | /* 1. Prepare the MDNS fqdn request to send to SME */ |
| 17404 | fqdn_len = strlen(hdd_ctx->cfg_ini->mdns_fqdn); |
| 17405 | ufqdn_len = strlen(hdd_ctx->cfg_ini->mdns_uniquefqdn); |
| 17406 | if ((fqdn_len == 0) && (ufqdn_len == 0)) { |
| 17407 | hddLog(LOGE, FL("No mDNS FQDN or UFQDN is assigned fqdn_len %d," |
| 17408 | "ufqdn_len %d!"), fqdn_len, ufqdn_len); |
| 17409 | return FALSE; |
| 17410 | } |
| 17411 | |
| 17412 | mdns_fqdn_info = vos_mem_malloc(sizeof(*mdns_fqdn_info)); |
| 17413 | if (NULL == mdns_fqdn_info) { |
| 17414 | hddLog(LOGE, FL("could not allocate tSirMDNSFqdnInfo!")); |
| 17415 | return FALSE; |
| 17416 | } |
| 17417 | /* MDNS fqdn request */ |
| 17418 | if (fqdn_len > 0) { |
| 17419 | vos_mem_zero(mdns_fqdn_info, sizeof(*mdns_fqdn_info)); |
| 17420 | mdns_fqdn_info->bss_idx = hostapd_adapter->sessionId; |
| 17421 | mdns_fqdn_info->fqdn_type = MDNS_FQDN_TYPE_GENERAL; |
| 17422 | mdns_fqdn_info->fqdn_len = fqdn_len; |
| 17423 | mdns_fqdn_info->mdns_fqdn_callback = hdd_mdns_fqdn_offload_done; |
| 17424 | mdns_fqdn_info->mdns_fqdn_cb_context = hostapd_adapter; |
| 17425 | vos_mem_copy(mdns_fqdn_info->fqdn_data, |
| 17426 | hdd_ctx->cfg_ini->mdns_fqdn, |
| 17427 | mdns_fqdn_info->fqdn_len); |
| 17428 | |
| 17429 | if (eHAL_STATUS_SUCCESS != |
| 17430 | sme_set_mdns_fqdn(hdd_ctx->hHal, mdns_fqdn_info)) { |
| 17431 | hddLog(LOGE, FL("sme_set_mdns_fqdn fail!")); |
| 17432 | vos_mem_free(mdns_fqdn_info); |
| 17433 | return FALSE; |
| 17434 | } |
| 17435 | } |
| 17436 | /* MDNS unique fqdn request */ |
| 17437 | if (ufqdn_len > 0) { |
| 17438 | vos_mem_zero(mdns_fqdn_info, sizeof(*mdns_fqdn_info)); |
| 17439 | mdns_fqdn_info->bss_idx = hostapd_adapter->sessionId; |
| 17440 | mdns_fqdn_info->fqdn_type = MDNS_FQDN_TYPE_UNIQUE; |
| 17441 | mdns_fqdn_info->fqdn_len = ufqdn_len; |
| 17442 | mdns_fqdn_info->mdns_fqdn_callback = hdd_mdns_fqdn_offload_done; |
| 17443 | mdns_fqdn_info->mdns_fqdn_cb_context = hostapd_adapter; |
| 17444 | vos_mem_copy(mdns_fqdn_info->fqdn_data, |
| 17445 | hdd_ctx->cfg_ini->mdns_uniquefqdn, |
| 17446 | mdns_fqdn_info->fqdn_len); |
| 17447 | if (eHAL_STATUS_SUCCESS != |
| 17448 | sme_set_mdns_fqdn(hdd_ctx->hHal, mdns_fqdn_info)) { |
| 17449 | hddLog(LOGE, FL("sme_set_mdns_fqdn fail!")); |
| 17450 | vos_mem_free(mdns_fqdn_info); |
| 17451 | return FALSE; |
| 17452 | } |
| 17453 | } |
| 17454 | vos_mem_free(mdns_fqdn_info); |
| 17455 | |
| 17456 | /* 2. Prepare the MDNS response request to send to SME */ |
| 17457 | mdns_resp_info = vos_mem_malloc(sizeof(*mdns_resp_info)); |
| 17458 | if (NULL == mdns_resp_info) { |
| 17459 | hddLog(LOGE, FL("could not allocate tSirMDNSResponseInfo!")); |
| 17460 | return FALSE; |
| 17461 | } |
| 17462 | |
| 17463 | vos_mem_zero(mdns_resp_info, sizeof(*mdns_resp_info)); |
| 17464 | mdns_resp_info->bss_idx = hostapd_adapter->sessionId; |
| 17465 | mdns_resp_info->mdns_resp_callback = hdd_mdns_resp_offload_done; |
| 17466 | mdns_resp_info->mdns_resp_cb_context = hostapd_adapter; |
| 17467 | if (!wlan_hdd_mdns_pack_response(hdd_ctx->cfg_ini, mdns_resp_info)) { |
| 17468 | hddLog(LOGE, FL("wlan_hdd_pack_mdns_response fail!")); |
| 17469 | vos_mem_free(mdns_resp_info); |
| 17470 | return FALSE; |
| 17471 | } |
| 17472 | if (eHAL_STATUS_SUCCESS != |
| 17473 | sme_set_mdns_resp(hdd_ctx->hHal, mdns_resp_info)) { |
| 17474 | hddLog(LOGE, FL("sme_set_mdns_resp fail!")); |
| 17475 | vos_mem_free(mdns_resp_info); |
| 17476 | return FALSE; |
| 17477 | } |
| 17478 | vos_mem_free(mdns_resp_info); |
| 17479 | |
| 17480 | /* 3. Prepare the MDNS Enable request to send to SME */ |
| 17481 | mdns_offload_info = vos_mem_malloc(sizeof(*mdns_offload_info)); |
| 17482 | if (NULL == mdns_offload_info) { |
| 17483 | hddLog(LOGE, FL("could not allocate tSirMDNSOffloadInfo!")); |
| 17484 | return FALSE; |
| 17485 | } |
| 17486 | |
| 17487 | vos_mem_zero(mdns_offload_info, sizeof(*mdns_offload_info)); |
| 17488 | |
| 17489 | mdns_offload_info->bss_idx = hostapd_adapter->sessionId; |
| 17490 | mdns_offload_info->enable = hdd_ctx->cfg_ini->enable_mdns_offload; |
| 17491 | mdns_offload_info->mdns_enable_callback = hdd_mdns_enable_offload_done; |
| 17492 | mdns_offload_info->mdns_enable_cb_context = hostapd_adapter; |
| 17493 | if (eHAL_STATUS_SUCCESS != |
| 17494 | sme_set_mdns_offload(hdd_ctx->hHal, mdns_offload_info)) { |
| 17495 | hddLog(LOGE, FL("sme_set_mdns_offload fail!")); |
| 17496 | vos_mem_free(mdns_offload_info); |
| 17497 | return FALSE; |
| 17498 | } |
| 17499 | |
| 17500 | vos_mem_free(mdns_offload_info); |
| 17501 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, |
| 17502 | "%s: enable mDNS offload successfully!", __func__); |
| 17503 | return TRUE; |
| 17504 | } |
Manjeet Singh | 3ed7924 | 2017-01-11 19:04:32 +0530 | [diff] [blame] | 17505 | |
| 17506 | |
Anurag Chouhan | 0b29de0 | 2016-12-16 13:18:40 +0530 | [diff] [blame] | 17507 | #endif /* MDNS_OFFLOAD */ |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 17508 | |
Hanumanth Reddy Pothula | d864f31 | 2017-01-18 16:16:08 +0530 | [diff] [blame] | 17509 | /** |
| 17510 | * wlan_hdd_start_sap() - This function starts bss of SAP. |
| 17511 | * @ap_adapter: SAP adapter |
| 17512 | * |
| 17513 | * This function will process the starting of sap adapter. |
| 17514 | * |
| 17515 | * Return: void. |
| 17516 | */ |
| 17517 | void wlan_hdd_start_sap(hdd_adapter_t *ap_adapter) |
| 17518 | { |
| 17519 | hdd_ap_ctx_t *hdd_ap_ctx; |
| 17520 | hdd_hostapd_state_t *hostapd_state; |
| 17521 | VOS_STATUS vos_status; |
| 17522 | hdd_context_t *hdd_ctx; |
| 17523 | tsap_Config_t *pConfig; |
| 17524 | |
| 17525 | if (NULL == ap_adapter) { |
| 17526 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 17527 | FL("ap_adapter is NULL here")); |
| 17528 | return; |
| 17529 | } |
| 17530 | |
| 17531 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
| 17532 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 17533 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
| 17534 | pConfig = &ap_adapter->sessionCtx.ap.sapConfig; |
| 17535 | |
| 17536 | mutex_lock(&hdd_ctx->sap_lock); |
| 17537 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) |
| 17538 | goto end; |
| 17539 | |
| 17540 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
| 17541 | hddLog(LOGE, FL("SAP Not able to set AP IEs")); |
| 17542 | goto end; |
| 17543 | } |
| 17544 | |
| 17545 | vos_event_reset(&hostapd_state->vosEvent); |
| 17546 | if (WLANSAP_StartBss(hdd_ctx->pvosContext, hdd_hostapd_SAPEventCB, |
| 17547 | &hdd_ap_ctx->sapConfig, (v_PVOID_t)ap_adapter->dev) |
| 17548 | != VOS_STATUS_SUCCESS) { |
| 17549 | goto end; |
| 17550 | } |
| 17551 | |
| 17552 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
| 17553 | FL("Waiting for SAP to start")); |
| 17554 | vos_status = vos_wait_single_event(&hostapd_state->vosEvent, 10000); |
| 17555 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) { |
| 17556 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 17557 | FL("SAP Start failed")); |
| 17558 | goto end; |
| 17559 | } |
| 17560 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
| 17561 | FL("SAP Start Success")); |
| 17562 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
| 17563 | |
| 17564 | wlan_hdd_incr_active_session(hdd_ctx, ap_adapter->device_mode); |
| 17565 | hostapd_state->bCommit = TRUE; |
| 17566 | |
| 17567 | end: |
| 17568 | mutex_unlock(&hdd_ctx->sap_lock); |
| 17569 | return; |
| 17570 | } |
| 17571 | |
Manjeet Singh | 3ed7924 | 2017-01-11 19:04:32 +0530 | [diff] [blame] | 17572 | #ifdef WLAN_FEATURE_TSF |
| 17573 | |
| 17574 | /** |
| 17575 | * hdd_tsf_cb() - handle tsf request callback |
| 17576 | * |
| 17577 | * @pcb_cxt: pointer to the hdd_contex |
| 17578 | * @ptsf: pointer to struct stsf |
| 17579 | * |
| 17580 | * Based on the request sent . |
| 17581 | * |
| 17582 | * Return: Describe the execute result of this routine |
| 17583 | */ |
| 17584 | static int hdd_tsf_cb(void *pcb_ctx, struct stsf *ptsf) |
| 17585 | { |
| 17586 | hdd_context_t *hddctx; |
| 17587 | int status; |
| 17588 | hdd_adapter_t* adapter = (hdd_adapter_t*)pcb_ctx; |
| 17589 | |
| 17590 | if (pcb_ctx == NULL || ptsf == NULL) { |
| 17591 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 17592 | FL("HDD context is not valid")); |
| 17593 | return -EINVAL; |
| 17594 | } |
| 17595 | |
| 17596 | hddctx = (hdd_context_t *)pcb_ctx; |
| 17597 | status = wlan_hdd_validate_context(hddctx); |
| 17598 | if (0 != status) |
| 17599 | return -EINVAL; |
| 17600 | |
| 17601 | if (NULL == adapter) { |
| 17602 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 17603 | FL("failed to find adapter")); |
| 17604 | return -EINVAL; |
| 17605 | } |
| 17606 | |
| 17607 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 17608 | FL("tsf cb handle event, device_mode is %d"), |
| 17609 | adapter->device_mode); |
| 17610 | |
| 17611 | /* copy the return value to hdd_tsf_ctx in adapter*/ |
| 17612 | if (ptsf->tsf_req_status) { |
| 17613 | |
| 17614 | vos_spin_lock_acquire(&adapter->tsf_cap_ctx.tsf_lock); |
| 17615 | adapter->tsf_cap_ctx.tsf_get_state = TSF_NOT_RETURNED_BY_FW; |
| 17616 | adapter->tsf_cap_ctx.tsf_capture_state = TSF_IDLE; |
| 17617 | vos_event_set (&adapter->tsf_cap_ctx.tsf_capture_done_event); |
| 17618 | vos_spin_lock_release(&adapter->tsf_cap_ctx.tsf_lock); |
| 17619 | |
| 17620 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("tsf req failure :%d"), |
| 17621 | ptsf->tsf_req_status); |
| 17622 | return ptsf->tsf_req_status; |
| 17623 | } |
| 17624 | /* If this is a get request.Store the tsf values in adapter. */ |
| 17625 | if (!ptsf->set_tsf_req) { |
| 17626 | vos_spin_lock_acquire(&adapter->tsf_cap_ctx.tsf_lock); |
| 17627 | adapter->tsf_cap_ctx.tsf_low = ptsf->tsf_low; |
| 17628 | adapter->tsf_cap_ctx.tsf_high = ptsf->tsf_high; |
| 17629 | adapter->tsf_cap_ctx.tsf_get_state = TSF_RETURN; |
| 17630 | adapter->tsf_cap_ctx.tsf_capture_state = TSF_IDLE; |
| 17631 | vos_spin_lock_release(&adapter->tsf_cap_ctx.tsf_lock); |
| 17632 | |
| 17633 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 17634 | FL("hdd_get_tsf_cb sta=%u, tsf_low=%u, tsf_high=%u"), |
| 17635 | adapter->sessionId, ptsf->tsf_low, ptsf->tsf_high); |
| 17636 | } |
| 17637 | else { |
| 17638 | vos_spin_lock_acquire(&adapter->tsf_cap_ctx.tsf_lock); |
| 17639 | adapter->tsf_cap_ctx.tsf_capture_state = TSF_CAP_STATE; |
| 17640 | adapter->tsf_cap_ctx.tsf_get_state = TSF_CURRENT_IN_CAP_STATE; |
| 17641 | vos_spin_lock_release(&adapter->tsf_cap_ctx.tsf_lock); |
| 17642 | } |
| 17643 | vos_spin_lock_acquire(&adapter->tsf_cap_ctx.tsf_lock); |
| 17644 | vos_event_set (&adapter->tsf_cap_ctx.tsf_capture_done_event); |
| 17645 | vos_spin_lock_release(&adapter->tsf_cap_ctx.tsf_lock); |
| 17646 | |
| 17647 | /* free allocated mem */ |
| 17648 | vos_mem_free(ptsf); |
| 17649 | |
| 17650 | return 0; |
| 17651 | } |
| 17652 | |
| 17653 | /** |
| 17654 | * hdd_capture_tsf() - capture tsf |
| 17655 | * |
| 17656 | * @adapter: pointer to adapter |
| 17657 | * @buf: pointer to upper layer buf |
| 17658 | * @len : the length of buf |
| 17659 | * |
| 17660 | * This function returns tsf value to uplayer. |
| 17661 | * |
| 17662 | * Return: Describe the execute result of this routine |
| 17663 | */ |
| 17664 | int hdd_capture_tsf(hdd_adapter_t *adapter, uint32_t *buf, int len) |
| 17665 | { |
| 17666 | int ret = 0; |
| 17667 | hdd_station_ctx_t *hdd_sta_ctx; |
| 17668 | hdd_context_t *hdd_ctx; |
| 17669 | tSirCapTsfParams cap_tsf_params; |
| 17670 | VOS_STATUS status; |
| 17671 | |
| 17672 | if (adapter == NULL || buf == NULL) { |
| 17673 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 17674 | FL("invalid pointer")); |
| 17675 | return -EINVAL; |
| 17676 | } |
| 17677 | if (len != 1) |
| 17678 | return -EINVAL; |
| 17679 | |
| 17680 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 17681 | |
| 17682 | if (wlan_hdd_validate_context(hdd_ctx)) { |
| 17683 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 17684 | FL("invalid hdd ctx")); |
| 17685 | return -EINVAL; |
| 17686 | } |
| 17687 | if (adapter->device_mode == WLAN_HDD_INFRA_STATION || |
| 17688 | adapter->device_mode == WLAN_HDD_P2P_CLIENT) { |
| 17689 | hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 17690 | if (hdd_sta_ctx->conn_info.connState != |
| 17691 | eConnectionState_Associated) { |
| 17692 | |
| 17693 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 17694 | FL("failed to cap tsf, not connect with ap")); |
| 17695 | buf[0] = TSF_STA_NOT_CONNECTED_NO_TSF; |
| 17696 | return ret; |
| 17697 | } |
| 17698 | } |
| 17699 | if ((adapter->device_mode == WLAN_HDD_SOFTAP || |
| 17700 | adapter->device_mode == WLAN_HDD_P2P_GO) && |
| 17701 | !(test_bit(SOFTAP_BSS_STARTED, &adapter->event_flags))) { |
| 17702 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 17703 | FL("Soft AP / P2p GO not beaconing")); |
| 17704 | buf[0] = TSF_SAP_NOT_STARTED_NO_TSF; |
| 17705 | return ret; |
| 17706 | } |
| 17707 | if (adapter->tsf_cap_ctx.tsf_capture_state == TSF_CAP_STATE) { |
| 17708 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 17709 | FL("current in capture state, pls reset")); |
| 17710 | buf[0] = TSF_CURRENT_IN_CAP_STATE; |
| 17711 | } else { |
| 17712 | hddLog(VOS_TRACE_LEVEL_INFO, FL("ioctl issue cap tsf cmd")); |
| 17713 | buf[0] = TSF_RETURN; |
| 17714 | cap_tsf_params.session_id = adapter->sessionId; |
| 17715 | cap_tsf_params.tsf_rsp_cb_func = hdd_tsf_cb; |
| 17716 | cap_tsf_params.tsf_rsp_cb_ctx = adapter; |
| 17717 | |
| 17718 | vos_spin_lock_acquire(&adapter->tsf_cap_ctx.tsf_lock); |
| 17719 | adapter->tsf_cap_ctx.tsf_capture_state = TSF_CAP_STATE; |
| 17720 | adapter->tsf_cap_ctx.tsf_get_state = TSF_CURRENT_IN_CAP_STATE; |
| 17721 | vos_spin_lock_release(&adapter->tsf_cap_ctx.tsf_lock); |
| 17722 | |
| 17723 | ret = sme_capture_tsf_req(hdd_ctx->hHal, cap_tsf_params); |
| 17724 | |
| 17725 | if (ret != VOS_STATUS_SUCCESS) { |
| 17726 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("capture fail")); |
| 17727 | buf[0] = TSF_CAPTURE_FAIL; |
| 17728 | vos_spin_lock_acquire(&adapter->tsf_cap_ctx.tsf_lock); |
| 17729 | adapter->tsf_cap_ctx.tsf_capture_state = TSF_IDLE; |
| 17730 | vos_spin_lock_release(&adapter->tsf_cap_ctx.tsf_lock); |
| 17731 | return -EINVAL; |
| 17732 | } |
| 17733 | /* wait till we get a response from fw */ |
| 17734 | status = vos_wait_single_event(&adapter->tsf_cap_ctx. |
| 17735 | tsf_capture_done_event, |
| 17736 | HDD_TSF_CAP_REQ_TIMEOUT); |
| 17737 | |
| 17738 | if (!VOS_IS_STATUS_SUCCESS(status)) { |
| 17739 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 17740 | ("capture tsf vos wait for single_event failed!! %d"), |
| 17741 | adapter->tsf_cap_ctx.tsf_get_state); |
| 17742 | |
| 17743 | vos_spin_lock_acquire(&adapter->tsf_cap_ctx.tsf_lock); |
| 17744 | adapter->tsf_cap_ctx.tsf_capture_state = TSF_IDLE; |
| 17745 | vos_spin_lock_release(&adapter->tsf_cap_ctx.tsf_lock); |
| 17746 | |
| 17747 | return -EINVAL; |
| 17748 | } |
| 17749 | } |
| 17750 | buf[0] = TSF_RETURN; |
| 17751 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 17752 | FL("ioctl return cap tsf cmd, ret = %d"), ret); |
| 17753 | return ret; |
| 17754 | } |
| 17755 | |
| 17756 | /** |
| 17757 | * hdd_indicate_tsf() - return tsf to uplayer |
| 17758 | * |
| 17759 | * @adapter: pointer to adapter |
| 17760 | * @buf: pointer to uplayer buf |
| 17761 | * @len : the length of buf |
| 17762 | * |
| 17763 | * This function returns tsf value to uplayer. |
| 17764 | * |
| 17765 | * Return: Describe the execute result of this routine |
| 17766 | */ |
| 17767 | int hdd_indicate_tsf(hdd_adapter_t *adapter, uint32_t *buf, int len) |
| 17768 | { |
| 17769 | int ret = 0; |
| 17770 | hdd_station_ctx_t *hdd_sta_ctx; |
| 17771 | hdd_context_t *hdd_ctx; |
| 17772 | tSirCapTsfParams cap_tsf_params; |
| 17773 | VOS_STATUS status; |
| 17774 | |
| 17775 | if (adapter == NULL || buf == NULL) { |
| 17776 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 17777 | FL("invalid pointer")); |
| 17778 | return -EINVAL; |
| 17779 | } |
| 17780 | if (len != 3) |
| 17781 | return -EINVAL; |
| 17782 | |
| 17783 | buf [1] = 0; |
| 17784 | buf [2] = 0; |
| 17785 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 17786 | |
| 17787 | if (wlan_hdd_validate_context(hdd_ctx)) { |
| 17788 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 17789 | FL("invalid hdd ctx")); |
| 17790 | return -EINVAL; |
| 17791 | } |
| 17792 | if (adapter->device_mode == WLAN_HDD_INFRA_STATION || |
| 17793 | adapter->device_mode == WLAN_HDD_P2P_CLIENT) { |
| 17794 | hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 17795 | if (hdd_sta_ctx->conn_info.connState != |
| 17796 | eConnectionState_Associated) { |
| 17797 | |
| 17798 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 17799 | FL("failed to cap tsf, not connect with ap")); |
| 17800 | buf[0] = TSF_STA_NOT_CONNECTED_NO_TSF; |
| 17801 | return ret; |
| 17802 | } |
| 17803 | } |
| 17804 | if ((adapter->device_mode == WLAN_HDD_SOFTAP || |
| 17805 | adapter->device_mode == WLAN_HDD_P2P_GO) && |
| 17806 | !(test_bit(SOFTAP_BSS_STARTED, &adapter->event_flags))) { |
| 17807 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 17808 | FL("Soft AP / P2p GO not beaconing")); |
| 17809 | buf[0] = TSF_SAP_NOT_STARTED_NO_TSF; |
| 17810 | return ret; |
| 17811 | } |
| 17812 | |
| 17813 | if (adapter->tsf_cap_ctx.tsf_capture_state != TSF_CAP_STATE || |
| 17814 | adapter->tsf_cap_ctx.tsf_get_state != TSF_CURRENT_IN_CAP_STATE ) { |
| 17815 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 17816 | FL("Not in capture state,Enter capture state first")); |
| 17817 | buf[0] = TSF_GET_FAIL; |
| 17818 | } else { |
| 17819 | hddLog(VOS_TRACE_LEVEL_INFO, FL("ioctl issue cap tsf cmd")); |
| 17820 | cap_tsf_params.session_id = adapter->sessionId; |
| 17821 | cap_tsf_params.tsf_rsp_cb_func = hdd_tsf_cb; |
| 17822 | cap_tsf_params.tsf_rsp_cb_ctx = adapter; |
| 17823 | |
| 17824 | ret = sme_get_tsf_req(hdd_ctx->hHal, cap_tsf_params); |
| 17825 | |
| 17826 | if (ret != VOS_STATUS_SUCCESS) { |
| 17827 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("capture fail")); |
| 17828 | buf[0] = TSF_CAPTURE_FAIL; |
| 17829 | vos_spin_lock_acquire(&adapter->tsf_cap_ctx.tsf_lock); |
| 17830 | adapter->tsf_cap_ctx.tsf_capture_state = TSF_IDLE; |
| 17831 | vos_spin_lock_release(&adapter->tsf_cap_ctx.tsf_lock); |
| 17832 | return -EINVAL; |
| 17833 | } |
| 17834 | /* wait till we get a response from fw */ |
| 17835 | status = vos_wait_single_event(&adapter->tsf_cap_ctx. |
| 17836 | tsf_capture_done_event, |
| 17837 | HDD_TSF_GET_REQ_TIMEOUT); |
| 17838 | |
| 17839 | if (!VOS_IS_STATUS_SUCCESS(status)) { |
| 17840 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 17841 | ("capture tsf vos wait for single_event failed!! %d"), |
| 17842 | status); |
| 17843 | |
| 17844 | vos_spin_lock_acquire(&adapter->tsf_cap_ctx.tsf_lock); |
| 17845 | adapter->tsf_cap_ctx.tsf_capture_state = TSF_IDLE; |
| 17846 | vos_spin_lock_release(&adapter->tsf_cap_ctx.tsf_lock); |
| 17847 | return status; |
| 17848 | } |
| 17849 | buf[1] = adapter->tsf_cap_ctx.tsf_low; |
| 17850 | buf[2] = adapter->tsf_cap_ctx.tsf_high; |
| 17851 | |
| 17852 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 17853 | FL("get tsf cmd,status=%u, tsf_low=%u, tsf_high=%u"), |
| 17854 | buf[0], buf[1], buf[2]); |
| 17855 | } |
| 17856 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 17857 | FL("ioctl return cap tsf cmd, ret = %d"), ret); |
| 17858 | return ret; |
| 17859 | } |
| 17860 | |
| 17861 | void wlan_hdd_tsf_init(hdd_adapter_t *adapter) |
| 17862 | { |
| 17863 | |
| 17864 | if (adapter == NULL) { |
| 17865 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 17866 | FL("TSF init on a null adapter!")); |
| 17867 | return; |
| 17868 | } |
| 17869 | |
| 17870 | adapter->tsf_cap_ctx.tsf_get_state = TSF_RETURN; |
| 17871 | adapter->tsf_cap_ctx.tsf_capture_state = TSF_IDLE; |
| 17872 | vos_event_init(&adapter->tsf_cap_ctx.tsf_capture_done_event); |
| 17873 | vos_spin_lock_init(&adapter->tsf_cap_ctx.tsf_lock); |
| 17874 | adapter->tsf_cap_ctx.tsf_high = 0; |
| 17875 | adapter->tsf_cap_ctx.tsf_low = 0; |
| 17876 | } |
| 17877 | |
| 17878 | #endif |
| 17879 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 17880 | //Register the module init/exit functions |
| 17881 | module_init(hdd_module_init); |
| 17882 | module_exit(hdd_module_exit); |
| 17883 | |
| 17884 | MODULE_LICENSE("Dual BSD/GPL"); |
| 17885 | MODULE_AUTHOR("Qualcomm Atheros, Inc."); |
| 17886 | MODULE_DESCRIPTION("WLAN HOST DEVICE DRIVER"); |
| 17887 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 17888 | module_param_call(con_mode, con_mode_handler, param_get_int, &con_mode, |
| 17889 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 17890 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 17891 | module_param_call(fwpath, fwpath_changed_handler, param_get_string, &fwpath, |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 17892 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 17893 | |
| 17894 | module_param(enable_dfs_chan_scan, int, |
| 17895 | S_IRUSR | S_IRGRP | S_IROTH); |
| 17896 | |
| 17897 | module_param(enable_11d, int, |
| 17898 | S_IRUSR | S_IRGRP | S_IROTH); |
| 17899 | |
| 17900 | module_param(country_code, charp, |
| 17901 | S_IRUSR | S_IRGRP | S_IROTH); |