Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
Arunk Khandavalli | 95608be | 2019-01-22 13:12:54 +0530 | [diff] [blame] | 2 | * Copyright (c) 2012-2019 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> |
Rajeev Kumar Sirasanagandla | f8fc27c | 2018-12-06 14:56:43 +0530 | [diff] [blame] | 65 | #include <vos_nvitem.h> |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 66 | #include <vos_sched.h> |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 67 | #include <linux/etherdevice.h> |
| 68 | #include <linux/firmware.h> |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 69 | #ifdef ANI_BUS_TYPE_PLATFORM |
| 70 | #include <linux/wcnss_wlan.h> |
| 71 | #endif //ANI_BUS_TYPE_PLATFORM |
| 72 | #ifdef ANI_BUS_TYPE_PCI |
| 73 | #include "wcnss_wlan.h" |
| 74 | #endif /* ANI_BUS_TYPE_PCI */ |
| 75 | #include <wlan_hdd_tx_rx.h> |
| 76 | #include <palTimer.h> |
| 77 | #include <wniApi.h> |
| 78 | #include <wlan_nlink_srv.h> |
| 79 | #include <wlan_btc_svc.h> |
| 80 | #include <wlan_hdd_cfg.h> |
| 81 | #include <wlan_ptt_sock_svc.h> |
Vinay Krishna Eranna | d938c42 | 2014-03-10 17:14:21 +0530 | [diff] [blame] | 82 | #include <wlan_logging_sock_svc.h> |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 83 | #include <wlan_hdd_wowl.h> |
| 84 | #include <wlan_hdd_misc.h> |
| 85 | #include <wlan_hdd_wext.h> |
| 86 | #ifdef WLAN_BTAMP_FEATURE |
| 87 | #include <bap_hdd_main.h> |
| 88 | #include <bapInternal.h> |
| 89 | #endif // WLAN_BTAMP_FEATURE |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 90 | #include "wlan_hdd_trace.h" |
| 91 | #include "vos_types.h" |
| 92 | #include "vos_trace.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 93 | #include <linux/wireless.h> |
| 94 | #include <net/cfg80211.h> |
Vinay Krishna Eranna | d9cbdb3 | 2014-01-16 12:59:10 +0530 | [diff] [blame] | 95 | #include <linux/inetdevice.h> |
| 96 | #include <net/addrconf.h> |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 97 | #include "wlan_hdd_cfg80211.h" |
| 98 | #include "wlan_hdd_p2p.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 99 | #include <linux/rtnetlink.h> |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 100 | int wlan_hdd_ftm_start(hdd_context_t *pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 101 | #include "sapApi.h" |
| 102 | #include <linux/semaphore.h> |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 103 | #include <linux/ctype.h> |
Arun Kumar Khandavalli | 74fe303 | 2014-03-17 20:35:34 +0530 | [diff] [blame] | 104 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)) |
| 105 | #include <soc/qcom/subsystem_restart.h> |
| 106 | #else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 107 | #include <mach/subsystem_restart.h> |
Arun Kumar Khandavalli | 74fe303 | 2014-03-17 20:35:34 +0530 | [diff] [blame] | 108 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 109 | #include <wlan_hdd_hostapd.h> |
| 110 | #include <wlan_hdd_softap_tx_rx.h> |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 111 | #include "cfgApi.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 112 | #include "wlan_hdd_dev_pwr.h" |
| 113 | #ifdef WLAN_BTAMP_FEATURE |
| 114 | #include "bap_hdd_misc.h" |
| 115 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 116 | #include "wlan_qct_pal_trace.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 117 | #include "qwlan_version.h" |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 118 | #include "wlan_qct_wda.h" |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 119 | #ifdef FEATURE_WLAN_TDLS |
| 120 | #include "wlan_hdd_tdls.h" |
| 121 | #endif |
Yue Ma | 0d4891e | 2013-08-06 17:01:45 -0700 | [diff] [blame] | 122 | #include "wlan_hdd_debugfs.h" |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 123 | #include "sapInternal.h" |
Hanumanth Reddy Pothula | 1efcd16 | 2018-03-14 14:32:27 +0530 | [diff] [blame] | 124 | #include "wlan_hdd_request_manager.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 125 | |
| 126 | #ifdef MODULE |
| 127 | #define WLAN_MODULE_NAME module_name(THIS_MODULE) |
| 128 | #else |
| 129 | #define WLAN_MODULE_NAME "wlan" |
| 130 | #endif |
| 131 | |
| 132 | #ifdef TIMER_MANAGER |
| 133 | #define TIMER_MANAGER_STR " +TIMER_MANAGER" |
| 134 | #else |
| 135 | #define TIMER_MANAGER_STR "" |
| 136 | #endif |
| 137 | |
| 138 | #ifdef MEMORY_DEBUG |
| 139 | #define MEMORY_DEBUG_STR " +MEMORY_DEBUG" |
| 140 | #else |
| 141 | #define MEMORY_DEBUG_STR "" |
| 142 | #endif |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 143 | #define MAX_WAIT_FOR_ROC_COMPLETION 3 |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 144 | /* the Android framework expects this param even though we don't use it */ |
| 145 | #define BUF_LEN 20 |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 146 | static char fwpath_buffer[BUF_LEN]; |
| 147 | static struct kparam_string fwpath = { |
| 148 | .string = fwpath_buffer, |
| 149 | .maxlen = BUF_LEN, |
| 150 | }; |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 151 | |
| 152 | static char *country_code; |
| 153 | static int enable_11d = -1; |
| 154 | static int enable_dfs_chan_scan = -1; |
| 155 | |
Madan Mohan Koyyalamudi | 05f313c | 2012-09-18 19:19:15 -0700 | [diff] [blame] | 156 | #ifndef MODULE |
Madan Mohan Koyyalamudi | dfd6aa8 | 2012-10-18 20:18:43 -0700 | [diff] [blame] | 157 | static int wlan_hdd_inited; |
Madan Mohan Koyyalamudi | 05f313c | 2012-09-18 19:19:15 -0700 | [diff] [blame] | 158 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 159 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 160 | /* |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 161 | * spinlock for synchronizing asynchronous request/response |
| 162 | * (full description of use in wlan_hdd_main.h) |
| 163 | */ |
| 164 | DEFINE_SPINLOCK(hdd_context_lock); |
| 165 | |
| 166 | /* |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 167 | * The rate at which the driver sends RESTART event to supplicant |
| 168 | * once the function 'vos_wlanRestart()' is called |
| 169 | * |
| 170 | */ |
| 171 | #define WLAN_HDD_RESTART_RETRY_DELAY_MS 5000 /* 5 second */ |
| 172 | #define WLAN_HDD_RESTART_RETRY_MAX_CNT 5 /* 5 retries */ |
Varun Reddy Yeturu | 6d99ac8 | 2013-05-08 14:15:35 -0700 | [diff] [blame] | 173 | |
| 174 | /* |
| 175 | * Size of Driver command strings from upper layer |
| 176 | */ |
| 177 | #define SIZE_OF_SETROAMMODE 11 /* size of SETROAMMODE */ |
| 178 | #define SIZE_OF_GETROAMMODE 11 /* size of GETROAMMODE */ |
| 179 | |
Abhishek Singh | 00b7197 | 2016-01-07 10:51:04 +0530 | [diff] [blame] | 180 | #ifdef WLAN_FEATURE_RMC |
| 181 | /* |
| 182 | * Ibss prop IE from command will be of size: |
| 183 | * size = sizeof(oui) + sizeof(oui_data) + 1(Element ID) + 1(EID Length) |
| 184 | * OUI_DATA should be at least 3 bytes long |
| 185 | */ |
| 186 | #define WLAN_HDD_IBSS_MIN_OUI_DATA_LENGTH (3) |
| 187 | #endif |
| 188 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 189 | #if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD) |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 190 | #define TID_MIN_VALUE 0 |
| 191 | #define TID_MAX_VALUE 15 |
| 192 | static VOS_STATUS hdd_get_tsm_stats(hdd_adapter_t *pAdapter, const tANI_U8 tid, |
| 193 | tAniTrafStrmMetrics* pTsmMetrics); |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 194 | static VOS_STATUS hdd_parse_ese_beacon_req(tANI_U8 *pValue, |
| 195 | tCsrEseBeaconReq *pEseBcnReq); |
| 196 | #endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */ |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 197 | |
Atul Mittal | 1d72242 | 2014-03-19 11:15:07 +0530 | [diff] [blame] | 198 | /* |
| 199 | * Maximum buffer size used for returning the data back to user space |
| 200 | */ |
| 201 | #define WLAN_MAX_BUF_SIZE 1024 |
| 202 | #define WLAN_PRIV_DATA_MAX_LEN 8192 |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 203 | |
Abhishek Singh | 00b7197 | 2016-01-07 10:51:04 +0530 | [diff] [blame] | 204 | /* |
| 205 | * When ever we need to print IBSSPEERINFOALL for morethan 16 STA |
| 206 | * we will split the printing. |
| 207 | */ |
| 208 | #define NUM_OF_STA_DATA_TO_PRINT 16 |
| 209 | |
| 210 | #ifdef WLAN_FEATURE_RMC |
| 211 | #define WLAN_NLINK_CESIUM 30 |
| 212 | #endif |
| 213 | |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 214 | //wait time for beacon miss rate. |
| 215 | #define BCN_MISS_RATE_TIME 500 |
| 216 | |
Selvaraj, Sridhar | 5aff1ed | 2016-06-18 01:26:23 +0530 | [diff] [blame] | 217 | /* |
| 218 | * Android DRIVER command structures |
| 219 | */ |
| 220 | struct android_wifi_reassoc_params { |
| 221 | unsigned char bssid[18]; |
| 222 | int channel; |
| 223 | }; |
| 224 | |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 225 | static vos_wake_lock_t wlan_wake_lock; |
| 226 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 227 | /* set when SSR is needed after unload */ |
Madan Mohan Koyyalamudi | b5da533 | 2012-10-15 17:23:21 -0700 | [diff] [blame] | 228 | static e_hdd_ssr_required isSsrRequired = HDD_SSR_NOT_REQUIRED; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 229 | |
| 230 | //internal function declaration |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 231 | static VOS_STATUS wlan_hdd_framework_restart(hdd_context_t *pHddCtx); |
| 232 | static void wlan_hdd_restart_init(hdd_context_t *pHddCtx); |
| 233 | static void wlan_hdd_restart_deinit(hdd_context_t *pHddCtx); |
Abhishek Singh | 00b7197 | 2016-01-07 10:51:04 +0530 | [diff] [blame] | 234 | |
| 235 | #ifdef WLAN_FEATURE_RMC |
| 236 | static void hdd_tx_fail_ind_callback(v_U8_t *MacAddr, v_U8_t seqNo); |
| 237 | |
| 238 | static int hdd_open_cesium_nl_sock(void); |
| 239 | static void hdd_close_cesium_nl_sock(void); |
| 240 | static struct sock *cesium_nl_srv_sock; |
| 241 | static v_U16_t cesium_pid; |
| 242 | |
| 243 | static int hdd_ParseIBSSTXFailEventParams(tANI_U8 *pValue, |
| 244 | tANI_U8 *tx_fail_count, |
| 245 | tANI_U16 *pid); |
| 246 | |
| 247 | static int hdd_ParseUserParams(tANI_U8 *pValue, tANI_U8 **ppArg); |
| 248 | |
| 249 | #endif /* WLAN_FEATURE_RMC */ |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 250 | void wlan_hdd_restart_timer_cb(v_PVOID_t usrDataForCallback); |
Sameer Thalappil | 45931fb | 2013-02-01 11:18:05 -0800 | [diff] [blame] | 251 | void hdd_set_wlan_suspend_mode(bool suspend); |
Sourav Mohapatra | 2416e0e | 2018-03-05 18:44:21 +0530 | [diff] [blame] | 252 | void hdd_set_vowifi_mode(hdd_context_t *hdd_ctx, bool enable); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 253 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 254 | v_U16_t hdd_select_queue(struct net_device *dev, |
Anand N Sunkad | e9adb1b | 2015-07-29 09:56:45 +0530 | [diff] [blame] | 255 | struct sk_buff *skb |
| 256 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0)) |
| 257 | , void *accel_priv |
| 258 | #endif |
| 259 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) |
| 260 | , select_queue_fallback_t fallback |
| 261 | #endif |
| 262 | ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 263 | |
| 264 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 265 | static void hdd_set_multicast_list(struct net_device *dev); |
| 266 | #endif |
| 267 | |
| 268 | void hdd_wlan_initial_scan(hdd_adapter_t *pAdapter); |
| 269 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 270 | #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] | 271 | void hdd_getBand_helper(hdd_context_t *pHddCtx, int *pBand); |
| 272 | 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] | 273 | static VOS_STATUS hdd_parse_send_action_frame_data(tANI_U8 *pValue, tANI_U8 *pTargetApBssid, |
| 274 | tANI_U8 *pChannel, tANI_U8 *pDwellTime, |
| 275 | tANI_U8 **pBuf, tANI_U8 *pBufLen); |
Selvaraj, Sridhar | 5aff1ed | 2016-06-18 01:26:23 +0530 | [diff] [blame] | 276 | static int hdd_parse_reassoc_command_v1_data(const tANI_U8 *pValue, |
| 277 | tANI_U8 *pTargetApBssid, tANI_U8 *pChannel); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 278 | #endif |
Ratheesh S P | 2128041 | 2015-05-19 14:21:52 +0530 | [diff] [blame] | 279 | |
| 280 | /* Store WLAN driver info in a global variable such that crash debugger |
| 281 | can extract it from driver debug symbol and crashdump for post processing */ |
| 282 | tANI_U8 g_wlan_driver[ ] = "pronto_driver"; |
| 283 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 284 | #if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD) |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 285 | 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] | 286 | #endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */ |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 287 | |
Mihir Shete | e1093ba | 2014-01-21 20:13:32 +0530 | [diff] [blame] | 288 | static VOS_STATUS wlan_hdd_init_channels(hdd_context_t *pHddCtx); |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 289 | const char * hdd_device_modetoString(v_U8_t device_mode) |
| 290 | { |
| 291 | switch(device_mode) |
| 292 | { |
| 293 | CASE_RETURN_STRING( WLAN_HDD_INFRA_STATION ); |
| 294 | CASE_RETURN_STRING( WLAN_HDD_SOFTAP ); |
| 295 | CASE_RETURN_STRING( WLAN_HDD_P2P_CLIENT ); |
| 296 | CASE_RETURN_STRING( WLAN_HDD_P2P_GO ); |
| 297 | CASE_RETURN_STRING( WLAN_HDD_MONITOR); |
| 298 | CASE_RETURN_STRING( WLAN_HDD_FTM ); |
| 299 | CASE_RETURN_STRING( WLAN_HDD_IBSS ); |
| 300 | CASE_RETURN_STRING( WLAN_HDD_P2P_DEVICE ); |
| 301 | default: |
| 302 | return "device_mode Unknown"; |
| 303 | } |
| 304 | } |
Mihir Shete | e1093ba | 2014-01-21 20:13:32 +0530 | [diff] [blame] | 305 | |
Mukul Sharma | a78cf6b | 2015-02-24 16:59:01 +0530 | [diff] [blame] | 306 | static int __hdd_netdev_notifier_call(struct notifier_block * nb, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 307 | unsigned long state, |
| 308 | void *ndev) |
| 309 | { |
Yeshwanth Sriram Guntuka | db04f47 | 2019-08-08 16:58:23 +0530 | [diff] [blame] | 310 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 311 | struct netdev_notifier_info *info = ndev; |
| 312 | struct net_device *dev = info->dev; |
| 313 | #else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 314 | struct net_device *dev = ndev; |
Yeshwanth Sriram Guntuka | db04f47 | 2019-08-08 16:58:23 +0530 | [diff] [blame] | 315 | #endif |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 316 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 27cee45 | 2013-03-27 11:10:24 -0700 | [diff] [blame] | 317 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 318 | #ifdef WLAN_BTAMP_FEATURE |
| 319 | VOS_STATUS status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 320 | #endif |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 321 | long result; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 322 | |
| 323 | //Make sure that this callback corresponds to our device. |
Jeff Johnson | 27cee45 | 2013-03-27 11:10:24 -0700 | [diff] [blame] | 324 | if ((strncmp(dev->name, "wlan", 4)) && |
Amar Singhal | 4c723bd | 2013-03-25 18:14:15 -0700 | [diff] [blame] | 325 | (strncmp(dev->name, "p2p", 3))) |
| 326 | return NOTIFY_DONE; |
| 327 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 328 | if (!dev->ieee80211_ptr) |
Jeff Johnson | 27cee45 | 2013-03-27 11:10:24 -0700 | [diff] [blame] | 329 | return NOTIFY_DONE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 330 | |
Jeff Johnson | 27cee45 | 2013-03-27 11:10:24 -0700 | [diff] [blame] | 331 | if (NULL == pAdapter) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 332 | { |
Jeff Johnson | a8a1a48 | 2012-12-12 16:49:33 -0800 | [diff] [blame] | 333 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: HDD Adapter Null Pointer", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 334 | VOS_ASSERT(0); |
| 335 | return NOTIFY_DONE; |
| 336 | } |
| 337 | |
Jeff Johnson | 27cee45 | 2013-03-27 11:10:24 -0700 | [diff] [blame] | 338 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 339 | if (NULL == pHddCtx) |
| 340 | { |
| 341 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: HDD Context Null Pointer", __func__); |
| 342 | VOS_ASSERT(0); |
| 343 | return NOTIFY_DONE; |
| 344 | } |
Sameer Thalappil | 1406797 | 2014-01-23 14:54:54 -0800 | [diff] [blame] | 345 | if (pHddCtx->isLogpInProgress) |
| 346 | return NOTIFY_DONE; |
| 347 | |
Jeff Johnson | 27cee45 | 2013-03-27 11:10:24 -0700 | [diff] [blame] | 348 | |
| 349 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s New Net Device State = %lu", |
| 350 | __func__, dev->name, state); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 351 | |
| 352 | switch (state) { |
| 353 | case NETDEV_REGISTER: |
| 354 | break; |
| 355 | |
| 356 | case NETDEV_UNREGISTER: |
| 357 | break; |
| 358 | |
| 359 | case NETDEV_UP: |
| 360 | break; |
| 361 | |
| 362 | case NETDEV_DOWN: |
| 363 | break; |
| 364 | |
| 365 | case NETDEV_CHANGE: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 366 | if(TRUE == pAdapter->isLinkUpSvcNeeded) |
| 367 | complete(&pAdapter->linkup_event_var); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 368 | break; |
| 369 | |
| 370 | case NETDEV_GOING_DOWN: |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 371 | result = wlan_hdd_scan_abort(pAdapter); |
Girish Gowli | 4bf7a63 | 2014-06-12 13:42:11 +0530 | [diff] [blame] | 372 | if (result < 0) |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 373 | { |
| 374 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 375 | "%s: Timeout occurred while waiting for abortscan %ld", |
| 376 | __func__, result); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 377 | } |
| 378 | else |
| 379 | { |
| 380 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 381 | "%s: Scan Abort Successful" , __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 382 | } |
| 383 | #ifdef WLAN_BTAMP_FEATURE |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 384 | 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] | 385 | status = WLANBAP_StopAmp(); |
| 386 | if(VOS_STATUS_SUCCESS != status ) |
| 387 | { |
| 388 | pHddCtx->isAmpAllowed = VOS_TRUE; |
| 389 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 390 | "%s: Failed to stop AMP", __func__); |
| 391 | } |
| 392 | else |
| 393 | { |
| 394 | //a state m/c implementation in PAL is TBD to avoid this delay |
| 395 | msleep(500); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 396 | if ( pHddCtx->isAmpAllowed ) |
| 397 | { |
| 398 | WLANBAP_DeregisterFromHCI(); |
| 399 | pHddCtx->isAmpAllowed = VOS_FALSE; |
| 400 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 401 | } |
| 402 | #endif //WLAN_BTAMP_FEATURE |
| 403 | break; |
| 404 | |
| 405 | default: |
| 406 | break; |
| 407 | } |
| 408 | |
| 409 | return NOTIFY_DONE; |
| 410 | } |
| 411 | |
Mukul Sharma | a78cf6b | 2015-02-24 16:59:01 +0530 | [diff] [blame] | 412 | static int hdd_netdev_notifier_call(struct notifier_block * nb, |
| 413 | unsigned long state, |
| 414 | void *ndev) |
| 415 | { |
| 416 | int ret; |
| 417 | vos_ssr_protect(__func__); |
| 418 | ret = __hdd_netdev_notifier_call( nb, state, ndev); |
| 419 | vos_ssr_unprotect(__func__); |
| 420 | return ret; |
| 421 | } |
| 422 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 423 | struct notifier_block hdd_netdev_notifier = { |
| 424 | .notifier_call = hdd_netdev_notifier_call, |
| 425 | }; |
| 426 | |
| 427 | /*--------------------------------------------------------------------------- |
| 428 | * Function definitions |
| 429 | *-------------------------------------------------------------------------*/ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 430 | void hdd_unregister_mcast_bcast_filter(hdd_context_t *pHddCtx); |
| 431 | void hdd_register_mcast_bcast_filter(hdd_context_t *pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 432 | //variable to hold the insmod parameters |
Madan Mohan Koyyalamudi | dfd6aa8 | 2012-10-18 20:18:43 -0700 | [diff] [blame] | 433 | static int con_mode; |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 434 | #ifndef MODULE |
| 435 | /* current con_mode - used only for statically linked driver |
| 436 | * con_mode is changed by userspace to indicate a mode change which will |
| 437 | * result in calling the module exit and init functions. The module |
| 438 | * exit function will clean up based on the value of con_mode prior to it |
| 439 | * being changed by userspace. So curr_con_mode records the current con_mode |
| 440 | * for exit when con_mode becomes the next mode for init |
| 441 | */ |
Madan Mohan Koyyalamudi | dfd6aa8 | 2012-10-18 20:18:43 -0700 | [diff] [blame] | 442 | static int curr_con_mode; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 443 | #endif |
| 444 | |
Srinivas Girigowda | 8bf64cb | 2015-09-30 19:50:09 +0530 | [diff] [blame] | 445 | #ifdef WLAN_FEATURE_OFFLOAD_PACKETS |
| 446 | /** |
| 447 | * hdd_init_offloaded_packets_ctx() - Initialize offload packets context |
| 448 | * @hdd_ctx: hdd global context |
| 449 | * |
| 450 | * Return: none |
| 451 | */ |
| 452 | static void hdd_init_offloaded_packets_ctx(hdd_context_t *hdd_ctx) |
| 453 | { |
| 454 | uint8_t i; |
| 455 | |
| 456 | mutex_init(&hdd_ctx->op_ctx.op_lock); |
| 457 | for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++) |
| 458 | { |
| 459 | hdd_ctx->op_ctx.op_table[i].request_id = 0; |
| 460 | hdd_ctx->op_ctx.op_table[i].pattern_id = i; |
| 461 | } |
| 462 | } |
| 463 | #else |
| 464 | static void hdd_init_offloaded_packets_ctx(hdd_context_t *hdd_ctx) |
| 465 | { |
| 466 | } |
| 467 | #endif |
| 468 | |
Varun Reddy Yeturu | 587e680 | 2013-01-24 12:21:41 -0800 | [diff] [blame] | 469 | /**--------------------------------------------------------------------------- |
| 470 | |
| 471 | \brief hdd_vos_trace_enable() - Configure initial VOS Trace enable |
| 472 | |
| 473 | Called immediately after the cfg.ini is read in order to configure |
| 474 | the desired trace levels. |
| 475 | |
| 476 | \param - moduleId - module whose trace level is being configured |
| 477 | \param - bitmask - bitmask of log levels to be enabled |
| 478 | |
| 479 | \return - void |
| 480 | |
| 481 | --------------------------------------------------------------------------*/ |
| 482 | static void hdd_vos_trace_enable(VOS_MODULE_ID moduleId, v_U32_t bitmask) |
| 483 | { |
| 484 | wpt_tracelevel level; |
| 485 | |
| 486 | /* if the bitmask is the default value, then a bitmask was not |
| 487 | specified in cfg.ini, so leave the logging level alone (it |
| 488 | will remain at the "compiled in" default value) */ |
| 489 | if (CFG_VOS_TRACE_ENABLE_DEFAULT == bitmask) |
| 490 | { |
| 491 | return; |
| 492 | } |
| 493 | |
| 494 | /* a mask was specified. start by disabling all logging */ |
| 495 | vos_trace_setValue(moduleId, VOS_TRACE_LEVEL_NONE, 0); |
| 496 | |
| 497 | /* now cycle through the bitmask until all "set" bits are serviced */ |
| 498 | level = VOS_TRACE_LEVEL_FATAL; |
| 499 | while (0 != bitmask) |
| 500 | { |
| 501 | if (bitmask & 1) |
| 502 | { |
| 503 | vos_trace_setValue(moduleId, level, 1); |
| 504 | } |
| 505 | level++; |
| 506 | bitmask >>= 1; |
| 507 | } |
| 508 | } |
| 509 | |
| 510 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 511 | /**--------------------------------------------------------------------------- |
| 512 | |
| 513 | \brief hdd_wdi_trace_enable() - Configure initial WDI Trace enable |
| 514 | |
| 515 | Called immediately after the cfg.ini is read in order to configure |
| 516 | the desired trace levels in the WDI. |
| 517 | |
| 518 | \param - moduleId - module whose trace level is being configured |
| 519 | \param - bitmask - bitmask of log levels to be enabled |
| 520 | |
| 521 | \return - void |
| 522 | |
| 523 | --------------------------------------------------------------------------*/ |
| 524 | static void hdd_wdi_trace_enable(wpt_moduleid moduleId, v_U32_t bitmask) |
| 525 | { |
| 526 | wpt_tracelevel level; |
| 527 | |
| 528 | /* if the bitmask is the default value, then a bitmask was not |
| 529 | specified in cfg.ini, so leave the logging level alone (it |
| 530 | will remain at the "compiled in" default value) */ |
| 531 | if (CFG_WDI_TRACE_ENABLE_DEFAULT == bitmask) |
| 532 | { |
| 533 | return; |
| 534 | } |
| 535 | |
| 536 | /* a mask was specified. start by disabling all logging */ |
| 537 | wpalTraceSetLevel(moduleId, eWLAN_PAL_TRACE_LEVEL_NONE, 0); |
| 538 | |
| 539 | /* now cycle through the bitmask until all "set" bits are serviced */ |
| 540 | level = eWLAN_PAL_TRACE_LEVEL_FATAL; |
| 541 | while (0 != bitmask) |
| 542 | { |
| 543 | if (bitmask & 1) |
| 544 | { |
| 545 | wpalTraceSetLevel(moduleId, level, 1); |
| 546 | } |
| 547 | level++; |
| 548 | bitmask >>= 1; |
| 549 | } |
| 550 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 551 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 552 | /* |
| 553 | * FUNCTION: wlan_hdd_validate_context |
| 554 | * This function is used to check the HDD context |
| 555 | */ |
| 556 | int wlan_hdd_validate_context(hdd_context_t *pHddCtx) |
| 557 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 558 | |
| 559 | if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini) |
| 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, |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 562 | "%s: HDD context is Null", __func__); |
| 563 | return -ENODEV; |
| 564 | } |
| 565 | |
| 566 | if (pHddCtx->isLogpInProgress) |
| 567 | { |
Mahesh A Saptasagar | 886997a | 2015-03-04 13:15:51 +0530 | [diff] [blame] | 568 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
c_hpothu | 8adb97b | 2014-12-08 19:38:20 +0530 | [diff] [blame] | 569 | "%s: LOGP %s. Ignore!!", __func__, |
| 570 | vos_is_wlan_in_badState(VOS_MODULE_ID_HDD, NULL) |
| 571 | ?"failed":"in Progress"); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 572 | return -EAGAIN; |
| 573 | } |
| 574 | |
Mihir Shete | 1815629 | 2014-03-11 15:38:30 +0530 | [diff] [blame] | 575 | if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx)) |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 576 | { |
Mahesh A Saptasagar | 886997a | 2015-03-04 13:15:51 +0530 | [diff] [blame] | 577 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 578 | "%s: Unloading/Loading in Progress. Ignore!!!", __func__); |
| 579 | return -EAGAIN; |
| 580 | } |
| 581 | return 0; |
| 582 | } |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 583 | #ifdef CONFIG_ENABLE_LINUX_REG |
| 584 | void hdd_checkandupdate_phymode( hdd_context_t *pHddCtx) |
| 585 | { |
| 586 | hdd_adapter_t *pAdapter = NULL; |
| 587 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 588 | eCsrPhyMode phyMode; |
| 589 | hdd_config_t *cfg_param = NULL; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 590 | |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 591 | if (NULL == pHddCtx) |
| 592 | { |
| 593 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 594 | "HDD Context is null !!"); |
| 595 | return ; |
| 596 | } |
| 597 | |
| 598 | pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 599 | if (NULL == pAdapter) |
| 600 | { |
| 601 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 602 | "pAdapter is null !!"); |
| 603 | return ; |
| 604 | } |
| 605 | |
| 606 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 607 | if (NULL == pHddStaCtx) |
| 608 | { |
| 609 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 610 | "pHddStaCtx is null !!"); |
| 611 | return ; |
| 612 | } |
| 613 | |
| 614 | cfg_param = pHddCtx->cfg_ini; |
| 615 | if (NULL == cfg_param) |
| 616 | { |
| 617 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 618 | "cfg_params not available !!"); |
| 619 | return ; |
| 620 | } |
| 621 | |
| 622 | phyMode = sme_GetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter)); |
| 623 | |
| 624 | if (!pHddCtx->isVHT80Allowed) |
| 625 | { |
| 626 | if ((eCSR_DOT11_MODE_AUTO == phyMode) || |
| 627 | (eCSR_DOT11_MODE_11ac == phyMode) || |
| 628 | (eCSR_DOT11_MODE_11ac_ONLY == phyMode)) |
| 629 | { |
| 630 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 631 | "Setting phymode to 11n!!"); |
| 632 | sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_DOT11_MODE_11n); |
| 633 | } |
| 634 | } |
| 635 | else |
| 636 | { |
| 637 | /*New country Supports 11ac as well resetting value back from .ini*/ |
| 638 | sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 639 | hdd_cfg_xlate_to_csr_phy_mode(cfg_param->dot11Mode)); |
| 640 | return ; |
| 641 | } |
| 642 | |
| 643 | if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) && |
| 644 | ((eCSR_CFG_DOT11_MODE_11AC_ONLY == pHddStaCtx->conn_info.dot11Mode) || |
| 645 | (eCSR_CFG_DOT11_MODE_11AC == pHddStaCtx->conn_info.dot11Mode))) |
| 646 | { |
| 647 | VOS_STATUS vosStatus; |
| 648 | |
| 649 | // need to issue a disconnect to CSR. |
| 650 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 651 | vosStatus = sme_RoamDisconnect(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 652 | pAdapter->sessionId, |
| 653 | eCSR_DISCONNECT_REASON_UNSPECIFIED ); |
| 654 | |
| 655 | if (VOS_STATUS_SUCCESS == vosStatus) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 656 | { |
| 657 | long ret; |
| 658 | |
| 659 | ret = wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var, |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 660 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 661 | if (0 >= ret) |
| 662 | hddLog(LOGE, FL("failure waiting for disconnect_comp_var %ld"), |
| 663 | ret); |
| 664 | } |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 665 | |
| 666 | } |
| 667 | } |
| 668 | #else |
Gopichand Nakkala | dacbcb5 | 2013-04-18 16:41:54 +0530 | [diff] [blame] | 669 | void hdd_checkandupdate_phymode( hdd_adapter_t *pAdapter, char *country_code) |
| 670 | { |
| 671 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 672 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 673 | hdd_config_t *cfg_param; |
| 674 | eCsrPhyMode phyMode; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 675 | long ret; |
Gopichand Nakkala | dacbcb5 | 2013-04-18 16:41:54 +0530 | [diff] [blame] | 676 | |
| 677 | if (NULL == pHddCtx) |
| 678 | { |
| 679 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 680 | "HDD Context is null !!"); |
| 681 | return ; |
| 682 | } |
| 683 | |
| 684 | cfg_param = pHddCtx->cfg_ini; |
| 685 | |
| 686 | if (NULL == cfg_param) |
| 687 | { |
| 688 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 689 | "cfg_params not available !!"); |
| 690 | return ; |
| 691 | } |
| 692 | |
| 693 | phyMode = sme_GetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter)); |
| 694 | |
| 695 | if (NULL != strstr(cfg_param->listOfNon11acCountryCode, country_code)) |
| 696 | { |
| 697 | if ((eCSR_DOT11_MODE_AUTO == phyMode) || |
| 698 | (eCSR_DOT11_MODE_11ac == phyMode) || |
| 699 | (eCSR_DOT11_MODE_11ac_ONLY == phyMode)) |
| 700 | { |
| 701 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 702 | "Setting phymode to 11n!!"); |
| 703 | sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter), eCSR_DOT11_MODE_11n); |
| 704 | } |
| 705 | } |
| 706 | else |
| 707 | { |
| 708 | /*New country Supports 11ac as well resetting value back from .ini*/ |
| 709 | sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 710 | hdd_cfg_xlate_to_csr_phy_mode(cfg_param->dot11Mode)); |
| 711 | return ; |
| 712 | } |
| 713 | |
| 714 | if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) && |
| 715 | ((eCSR_CFG_DOT11_MODE_11AC_ONLY == pHddStaCtx->conn_info.dot11Mode) || |
| 716 | (eCSR_CFG_DOT11_MODE_11AC == pHddStaCtx->conn_info.dot11Mode))) |
| 717 | { |
| 718 | VOS_STATUS vosStatus; |
| 719 | |
| 720 | // need to issue a disconnect to CSR. |
| 721 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 722 | vosStatus = sme_RoamDisconnect(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 723 | pAdapter->sessionId, |
| 724 | eCSR_DISCONNECT_REASON_UNSPECIFIED ); |
| 725 | |
| 726 | if (VOS_STATUS_SUCCESS == vosStatus) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 727 | { |
| 728 | ret = wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var, |
Gopichand Nakkala | dacbcb5 | 2013-04-18 16:41:54 +0530 | [diff] [blame] | 729 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 730 | if (ret <= 0) |
| 731 | { |
| 732 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 733 | "wait on disconnect_comp_var is failed %ld", ret); |
| 734 | } |
| 735 | } |
Gopichand Nakkala | dacbcb5 | 2013-04-18 16:41:54 +0530 | [diff] [blame] | 736 | |
| 737 | } |
| 738 | } |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 739 | #endif //CONFIG_ENABLE_LINUX_REG |
Gopichand Nakkala | dacbcb5 | 2013-04-18 16:41:54 +0530 | [diff] [blame] | 740 | |
Tushnim Bhattacharyya | 9cdf608 | 2013-04-21 16:33:30 -0700 | [diff] [blame] | 741 | void hdd_checkandupdate_dfssetting( hdd_adapter_t *pAdapter, char *country_code) |
| 742 | { |
| 743 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 744 | hdd_config_t *cfg_param; |
| 745 | |
| 746 | if (NULL == pHddCtx) |
| 747 | { |
| 748 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 749 | "HDD Context is null !!"); |
| 750 | return ; |
| 751 | } |
| 752 | |
| 753 | cfg_param = pHddCtx->cfg_ini; |
| 754 | |
| 755 | if (NULL == cfg_param) |
| 756 | { |
| 757 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 758 | "cfg_params not available !!"); |
| 759 | return ; |
| 760 | } |
| 761 | |
Agarwal Ashish | 738843c | 2014-09-25 12:27:56 +0530 | [diff] [blame] | 762 | if (NULL != strstr(cfg_param->listOfNonDfsCountryCode, country_code) || |
| 763 | pHddCtx->disable_dfs_flag == TRUE) |
Tushnim Bhattacharyya | 9cdf608 | 2013-04-21 16:33:30 -0700 | [diff] [blame] | 764 | { |
| 765 | /*New country doesn't support DFS */ |
| 766 | sme_UpdateDfsSetting(WLAN_HDD_GET_HAL_CTX(pAdapter), 0); |
| 767 | } |
Ashish Kumar Dhanotiya | 445b3b9 | 2018-06-07 12:38:12 +0530 | [diff] [blame] | 768 | else |
| 769 | { |
| 770 | /* New country Supports DFS as well resetting value back from .ini */ |
| 771 | sme_UpdateDfsSetting(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 772 | cfg_param->enableDFSChnlScan); |
| 773 | } |
Tushnim Bhattacharyya | 9cdf608 | 2013-04-21 16:33:30 -0700 | [diff] [blame] | 774 | |
| 775 | } |
| 776 | |
Abhishek Singh | 00b7197 | 2016-01-07 10:51:04 +0530 | [diff] [blame] | 777 | #ifdef WLAN_FEATURE_RMC |
| 778 | static int hdd_parse_setrmcenable_command(tANI_U8 *pValue, tANI_U8 *pRmcEnable) |
| 779 | { |
| 780 | tANI_U8 *inPtr = pValue; |
| 781 | int tempInt; |
| 782 | int v = 0; |
| 783 | char buf[32]; |
| 784 | *pRmcEnable = 0; |
| 785 | |
| 786 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 787 | /*no argument after the command*/ |
| 788 | if (NULL == inPtr) |
| 789 | { |
| 790 | return 0; |
| 791 | } |
| 792 | |
| 793 | /*no space after the command*/ |
| 794 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 795 | { |
| 796 | return 0; |
| 797 | } |
| 798 | |
| 799 | /*removing empty spaces*/ |
| 800 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
| 801 | |
| 802 | /*no argument followed by spaces*/ |
| 803 | if ('\0' == *inPtr) |
| 804 | { |
| 805 | return 0; |
| 806 | } |
| 807 | |
| 808 | /* getting the first argument which enables or disables RMC |
| 809 | * for input IP v4 address*/ |
Ashish Kumar Dhanotiya | 54d31a3 | 2017-08-04 17:12:44 +0530 | [diff] [blame] | 810 | sscanf(inPtr, "%31s ", buf); |
Abhishek Singh | 00b7197 | 2016-01-07 10:51:04 +0530 | [diff] [blame] | 811 | v = kstrtos32(buf, 10, &tempInt); |
| 812 | if ( v < 0) |
| 813 | { |
| 814 | return -EINVAL; |
| 815 | } |
| 816 | |
| 817 | *pRmcEnable = tempInt; |
| 818 | |
| 819 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 820 | "ucRmcEnable: %d", *pRmcEnable); |
| 821 | |
| 822 | return 0; |
| 823 | } |
| 824 | |
| 825 | /* Function header left blank Intentionally */ |
| 826 | static int hdd_parse_setrmcactionperiod_command(tANI_U8 *pValue, |
| 827 | tANI_U32 *pActionPeriod) |
| 828 | { |
| 829 | tANI_U8 *inPtr = pValue; |
| 830 | int tempInt; |
| 831 | int v = 0; |
| 832 | char buf[32]; |
| 833 | *pActionPeriod = 0; |
| 834 | |
| 835 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 836 | /*no argument after the command*/ |
| 837 | if (NULL == inPtr) |
| 838 | { |
| 839 | return -EINVAL; |
| 840 | } |
| 841 | |
| 842 | /*no space after the command*/ |
| 843 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 844 | { |
| 845 | return -EINVAL; |
| 846 | } |
| 847 | |
| 848 | /*removing empty spaces*/ |
| 849 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
| 850 | |
| 851 | /*no argument followed by spaces*/ |
| 852 | if ('\0' == *inPtr) |
| 853 | { |
| 854 | return 0; |
| 855 | } |
| 856 | |
| 857 | /* getting the first argument which enables or disables RMC |
| 858 | * for input IP v4 address*/ |
Ashish Kumar Dhanotiya | 54d31a3 | 2017-08-04 17:12:44 +0530 | [diff] [blame] | 859 | sscanf(inPtr, "%31s ", buf); |
Abhishek Singh | 00b7197 | 2016-01-07 10:51:04 +0530 | [diff] [blame] | 860 | v = kstrtos32(buf, 10, &tempInt); |
| 861 | if ( v < 0) |
| 862 | { |
| 863 | return -EINVAL; |
| 864 | } |
| 865 | |
| 866 | /* Range checking for passed paramter */ |
| 867 | if (tempInt < WNI_CFG_RMC_ACTION_PERIOD_FREQUENCY_STAMIN || |
| 868 | tempInt > WNI_CFG_RMC_ACTION_PERIOD_FREQUENCY_STAMAX) |
| 869 | { |
| 870 | return -EINVAL; |
| 871 | } |
| 872 | |
| 873 | *pActionPeriod = tempInt; |
| 874 | |
| 875 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 876 | "uActionPeriod: %d", *pActionPeriod); |
| 877 | |
| 878 | return 0; |
| 879 | } |
Dundi Raviteja | e110a04 | 2018-04-18 13:11:37 +0530 | [diff] [blame] | 880 | |
| 881 | /** |
| 882 | * hdd_set_vowifi_mode() - Process VOWIFI command. |
| 883 | * @hdd_ctx: context handler |
Sourav Mohapatra | 2416e0e | 2018-03-05 18:44:21 +0530 | [diff] [blame] | 884 | * @enable: Value to be sent as a part of the VOWIFI command |
| 885 | * |
Dundi Raviteja | e110a04 | 2018-04-18 13:11:37 +0530 | [diff] [blame] | 886 | * Invoke the SME api if station is connected in 2.4 GHz band. |
| 887 | * Also start split scan if VOWIFIMODE and dynamic split scan |
| 888 | * both are enabled. |
| 889 | |
Sourav Mohapatra | 2416e0e | 2018-03-05 18:44:21 +0530 | [diff] [blame] | 890 | * Return: void |
| 891 | */ |
| 892 | void hdd_set_vowifi_mode(hdd_context_t *hdd_ctx, bool enable) |
| 893 | { |
| 894 | tANI_U8 sta_chan; |
| 895 | |
Dundi Raviteja | ab9d309 | 2018-04-05 18:24:40 +0530 | [diff] [blame] | 896 | if (!hdd_ctx->cfg_ini) { |
| 897 | hddLog(LOGE, "cfg_ini got NULL"); |
| 898 | return; |
| 899 | } |
| 900 | |
Sourav Mohapatra | 2416e0e | 2018-03-05 18:44:21 +0530 | [diff] [blame] | 901 | sta_chan = hdd_get_operating_channel(hdd_ctx, WLAN_HDD_INFRA_STATION); |
| 902 | |
Dundi Raviteja | e110a04 | 2018-04-18 13:11:37 +0530 | [diff] [blame] | 903 | if (CSR_IS_CHANNEL_24GHZ(sta_chan)) |
Sourav Mohapatra | 2416e0e | 2018-03-05 18:44:21 +0530 | [diff] [blame] | 904 | sme_set_vowifi_mode(hdd_ctx->hHal, enable); |
Dundi Raviteja | e110a04 | 2018-04-18 13:11:37 +0530 | [diff] [blame] | 905 | else |
Sourav Mohapatra | 2416e0e | 2018-03-05 18:44:21 +0530 | [diff] [blame] | 906 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 907 | "VoWiFi command rejected as not connected in 2.4GHz"); |
Dundi Raviteja | e110a04 | 2018-04-18 13:11:37 +0530 | [diff] [blame] | 908 | |
| 909 | if (enable && hdd_ctx->cfg_ini->dynSplitscan) { |
| 910 | hdd_ctx->is_vowifi_enabled = true; |
| 911 | hdd_ctx->issplitscan_enabled = TRUE; |
| 912 | sme_enable_disable_split_scan(hdd_ctx->hHal, |
| 913 | hdd_ctx->cfg_ini->nNumStaChanCombinedConc, |
| 914 | hdd_ctx->cfg_ini->nNumP2PChanCombinedConc); |
| 915 | } else { |
| 916 | hdd_ctx->is_vowifi_enabled = false; |
Dundi Raviteja | ab9d309 | 2018-04-05 18:24:40 +0530 | [diff] [blame] | 917 | } |
Sourav Mohapatra | 2416e0e | 2018-03-05 18:44:21 +0530 | [diff] [blame] | 918 | } |
Abhishek Singh | 00b7197 | 2016-01-07 10:51:04 +0530 | [diff] [blame] | 919 | |
| 920 | /* Function header left blank Intentionally */ |
| 921 | static int hdd_parse_setrmcrate_command(tANI_U8 *pValue, |
| 922 | tANI_U32 *pRate, tTxrateinfoflags *pTxFlags) |
| 923 | { |
| 924 | tANI_U8 *inPtr = pValue; |
| 925 | int tempInt; |
| 926 | int v = 0; |
| 927 | char buf[32]; |
| 928 | *pRate = 0; |
| 929 | *pTxFlags = 0; |
| 930 | |
| 931 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 932 | /*no argument after the command*/ |
| 933 | if (NULL == inPtr) |
| 934 | { |
| 935 | return -EINVAL; |
| 936 | } |
| 937 | |
| 938 | /*no space after the command*/ |
| 939 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 940 | { |
| 941 | return -EINVAL; |
| 942 | } |
| 943 | |
| 944 | /*removing empty spaces*/ |
| 945 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
| 946 | |
| 947 | /*no argument followed by spaces*/ |
| 948 | if ('\0' == *inPtr) |
| 949 | { |
| 950 | return 0; |
| 951 | } |
| 952 | |
| 953 | /* |
| 954 | * getting the first argument which sets multicast rate. |
| 955 | */ |
Ashish Kumar Dhanotiya | 06f9f20 | 2017-08-04 15:26:27 +0530 | [diff] [blame] | 956 | sscanf(inPtr, "%31s ", buf); |
Abhishek Singh | 00b7197 | 2016-01-07 10:51:04 +0530 | [diff] [blame] | 957 | v = kstrtos32(buf, 10, &tempInt); |
| 958 | if ( v < 0) |
| 959 | { |
| 960 | return -EINVAL; |
| 961 | } |
| 962 | |
| 963 | /* |
| 964 | * Validate the multicast rate. |
| 965 | */ |
| 966 | switch (tempInt) |
| 967 | { |
| 968 | default: |
| 969 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
| 970 | "Unsupported rate: %d", tempInt); |
| 971 | return -EINVAL; |
| 972 | case 0: |
| 973 | case 6: |
| 974 | case 9: |
| 975 | case 12: |
| 976 | case 18: |
| 977 | case 24: |
| 978 | case 36: |
| 979 | case 48: |
| 980 | case 54: |
| 981 | *pTxFlags = eHAL_TX_RATE_LEGACY; |
| 982 | *pRate = tempInt * 10; |
| 983 | break; |
| 984 | case 65: |
| 985 | *pTxFlags = eHAL_TX_RATE_HT20; |
| 986 | *pRate = tempInt * 10; |
| 987 | break; |
| 988 | case 72: |
| 989 | *pTxFlags = eHAL_TX_RATE_HT20 | eHAL_TX_RATE_SGI; |
| 990 | *pRate = 722; /* fractional rate 72.2 Mbps */ |
| 991 | break; |
| 992 | } |
| 993 | |
| 994 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 995 | "Rate: %d", *pRate); |
| 996 | |
| 997 | return 0; |
| 998 | } |
| 999 | |
| 1000 | /**--------------------------------------------------------------------------- |
| 1001 | |
| 1002 | \brief hdd_cfg80211_get_ibss_peer_info_cb() - Callback function for IBSS |
| 1003 | Peer Info request |
| 1004 | |
| 1005 | This is an asynchronous callback function from SME when the peer info |
| 1006 | is received |
| 1007 | |
| 1008 | \pUserData -> Adapter private data |
| 1009 | \pPeerInfoRsp -> Peer info response |
| 1010 | |
| 1011 | \return - 0 for success non-zero for failure |
| 1012 | --------------------------------------------------------------------------*/ |
| 1013 | static void |
| 1014 | hdd_cfg80211_get_ibss_peer_info_cb(v_VOID_t *pUserData, v_VOID_t *pPeerInfoRsp) |
| 1015 | { |
| 1016 | hdd_adapter_t *pAdapter = (hdd_adapter_t *)pUserData; |
| 1017 | tSirPeerInfoRspParams *pPeerInfo = (tSirPeerInfoRspParams *)pPeerInfoRsp; |
| 1018 | hdd_station_ctx_t *pStaCtx; |
| 1019 | v_U8_t i; |
| 1020 | |
| 1021 | /*Sanity check*/ |
| 1022 | if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)) |
| 1023 | { |
| 1024 | hddLog(LOGE, |
| 1025 | FL("invalid adapter or adapter has invalid magic")); |
| 1026 | return; |
| 1027 | } |
| 1028 | |
| 1029 | pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 1030 | if (NULL != pStaCtx && NULL != pPeerInfo && |
| 1031 | eHAL_STATUS_SUCCESS == pPeerInfo->status) |
| 1032 | { |
| 1033 | pStaCtx->ibss_peer_info.status = pPeerInfo->status; |
| 1034 | pStaCtx->ibss_peer_info.numIBSSPeers = pPeerInfo->numPeers; |
| 1035 | |
| 1036 | /* Paranoia check */ |
| 1037 | if (pPeerInfo->numPeers < HDD_MAX_NUM_IBSS_STA) |
| 1038 | { |
| 1039 | for (i = 0; i < pPeerInfo->numPeers; i++) |
| 1040 | { |
| 1041 | memcpy(&pStaCtx->ibss_peer_info.ibssPeerList[i], |
| 1042 | &pPeerInfo->peerInfoParams[i], |
| 1043 | sizeof(hdd_ibss_peer_info_params_t)); |
| 1044 | } |
| 1045 | hddLog(LOG1, |
| 1046 | FL("Peer Info copied in HDD")); |
| 1047 | } |
| 1048 | else |
| 1049 | { |
| 1050 | hddLog(LOGE, |
| 1051 | FL(" Number of peers %d returned is more than limit %d"), |
| 1052 | pPeerInfo->numPeers, HDD_MAX_NUM_IBSS_STA); |
| 1053 | } |
| 1054 | } |
| 1055 | else |
| 1056 | { |
| 1057 | hddLog(LOG1, |
| 1058 | FL("peerInfo returned is NULL")); |
| 1059 | } |
| 1060 | |
| 1061 | complete(&pAdapter->ibss_peer_info_comp); |
| 1062 | } |
| 1063 | |
| 1064 | /**--------------------------------------------------------------------------- |
| 1065 | |
| 1066 | \brief hdd_cfg80211_get_ibss_peer_info_all() - |
| 1067 | |
| 1068 | Request function to get IBSS peer info from lower layers |
| 1069 | |
| 1070 | \pAdapter -> Adapter context |
| 1071 | |
| 1072 | \return - 0 for success non-zero for failure |
| 1073 | --------------------------------------------------------------------------*/ |
| 1074 | static |
| 1075 | VOS_STATUS hdd_cfg80211_get_ibss_peer_info_all(hdd_adapter_t *pAdapter) |
| 1076 | { |
| 1077 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 1078 | long status; |
| 1079 | VOS_STATUS retStatus = VOS_STATUS_E_FAILURE; |
| 1080 | |
| 1081 | INIT_COMPLETION(pAdapter->ibss_peer_info_comp); |
| 1082 | |
| 1083 | retStatus = sme_RequestIBSSPeerInfo(hHal, pAdapter, |
| 1084 | hdd_cfg80211_get_ibss_peer_info_cb, |
| 1085 | VOS_TRUE, 0xFF); |
| 1086 | |
| 1087 | if (VOS_STATUS_SUCCESS == retStatus) |
| 1088 | { |
| 1089 | status = wait_for_completion_interruptible_timeout |
| 1090 | (&pAdapter->ibss_peer_info_comp, |
| 1091 | msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT)); |
| 1092 | |
| 1093 | /* status will be 0 if timed out */ |
| 1094 | if (status <= 0) |
| 1095 | { |
| 1096 | hddLog(VOS_TRACE_LEVEL_WARN, "%s: Warning: IBSS_PEER_INFO_TIMEOUT %ld", |
| 1097 | __func__, status); |
| 1098 | retStatus = VOS_STATUS_E_FAILURE; |
| 1099 | return retStatus; |
| 1100 | } |
| 1101 | } |
| 1102 | else |
| 1103 | { |
| 1104 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 1105 | "%s: Warning: sme_RequestIBSSPeerInfo Request failed", __func__); |
| 1106 | } |
| 1107 | |
| 1108 | return retStatus; |
| 1109 | } |
| 1110 | |
| 1111 | /**--------------------------------------------------------------------------- |
| 1112 | |
| 1113 | \brief hdd_cfg80211_get_ibss_peer_info() - |
| 1114 | |
| 1115 | Request function to get IBSS peer info from lower layers |
| 1116 | |
| 1117 | \pAdapter -> Adapter context |
| 1118 | \staIdx -> Sta index for which the peer info is requested |
| 1119 | |
| 1120 | \return - 0 for success non-zero for failure |
| 1121 | --------------------------------------------------------------------------*/ |
| 1122 | static VOS_STATUS |
| 1123 | hdd_cfg80211_get_ibss_peer_info(hdd_adapter_t *pAdapter, v_U8_t staIdx) |
| 1124 | { |
| 1125 | long status; |
| 1126 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 1127 | VOS_STATUS retStatus = VOS_STATUS_E_FAILURE; |
| 1128 | |
| 1129 | INIT_COMPLETION(pAdapter->ibss_peer_info_comp); |
| 1130 | |
| 1131 | retStatus = sme_RequestIBSSPeerInfo(hHal, pAdapter, |
| 1132 | hdd_cfg80211_get_ibss_peer_info_cb, |
| 1133 | VOS_FALSE, staIdx); |
| 1134 | |
| 1135 | if (VOS_STATUS_SUCCESS == retStatus) |
| 1136 | { |
| 1137 | status = wait_for_completion_interruptible_timeout |
| 1138 | (&pAdapter->ibss_peer_info_comp, |
| 1139 | msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT)); |
| 1140 | |
| 1141 | /* status = 0 on timeout */ |
| 1142 | if (status <= 0) |
| 1143 | { |
| 1144 | hddLog(VOS_TRACE_LEVEL_WARN, "%s: Warning: IBSS_PEER_INFO_TIMEOUT %ld", |
| 1145 | __func__, status); |
| 1146 | retStatus = VOS_STATUS_E_FAILURE; |
| 1147 | return retStatus; |
| 1148 | } |
| 1149 | } |
| 1150 | else |
| 1151 | { |
| 1152 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 1153 | "%s: Warning: sme_RequestIBSSPeerInfo Request failed", __func__); |
| 1154 | } |
| 1155 | |
| 1156 | return retStatus; |
| 1157 | } |
| 1158 | |
| 1159 | /* Function header left blank Intentionally */ |
| 1160 | VOS_STATUS |
| 1161 | hdd_parse_get_ibss_peer_info(tANI_U8 *pValue, v_MACADDR_t *pPeerMacAddr) |
| 1162 | { |
| 1163 | tANI_U8 *inPtr = pValue; |
| 1164 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 1165 | |
| 1166 | /*no argument after the command*/ |
| 1167 | if (NULL == inPtr) |
| 1168 | { |
| 1169 | return VOS_STATUS_E_FAILURE;; |
| 1170 | } |
| 1171 | |
| 1172 | /*no space after the command*/ |
| 1173 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 1174 | { |
| 1175 | return VOS_STATUS_E_FAILURE;; |
| 1176 | } |
| 1177 | |
| 1178 | /*removing empty spaces*/ |
| 1179 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 1180 | |
| 1181 | /*no argument followed by spaces*/ |
| 1182 | if ('\0' == *inPtr) |
| 1183 | { |
| 1184 | return VOS_STATUS_E_FAILURE;; |
| 1185 | } |
| 1186 | |
| 1187 | /*getting the first argument ie the peer mac address */ |
| 1188 | if (inPtr[2] != ':' || inPtr[5] != ':' || inPtr[8] != ':' || |
| 1189 | inPtr[11] != ':' || inPtr[14] != ':') |
| 1190 | { |
| 1191 | return VOS_STATUS_E_FAILURE;; |
| 1192 | } |
| 1193 | sscanf(inPtr, "%2x:%2x:%2x:%2x:%2x:%2x", |
| 1194 | (unsigned int *)&pPeerMacAddr->bytes[0], |
| 1195 | (unsigned int *)&pPeerMacAddr->bytes[1], |
| 1196 | (unsigned int *)&pPeerMacAddr->bytes[2], |
| 1197 | (unsigned int *)&pPeerMacAddr->bytes[3], |
| 1198 | (unsigned int *)&pPeerMacAddr->bytes[4], |
| 1199 | (unsigned int *)&pPeerMacAddr->bytes[5]); |
| 1200 | |
| 1201 | /* The command buffer seems to be fine */ |
| 1202 | return VOS_STATUS_SUCCESS; |
| 1203 | } |
| 1204 | |
| 1205 | /* Function header left blank Intentionally */ |
| 1206 | static int hdd_parse_set_ibss_oui_data_command(tANI_U8 *command, tANI_U8 *ie, |
| 1207 | tANI_U32 limit) |
| 1208 | { |
| 1209 | tANI_U8 len; |
| 1210 | tANI_U8 data; |
| 1211 | |
| 1212 | /* skip white space */ |
| 1213 | while ((SPACE_ASCII_VALUE == *command) && ('\0' != *command)) |
| 1214 | { |
| 1215 | command++; |
| 1216 | limit--; |
| 1217 | } |
| 1218 | |
| 1219 | /* skip element id and element length */ |
| 1220 | len = 2; |
| 1221 | |
| 1222 | /* extract oui */ |
| 1223 | while ((SPACE_ASCII_VALUE != *command) && ('\0' != *command) && |
| 1224 | (limit > 1)) |
| 1225 | { |
| 1226 | /* Convert ASCII to decimal */ |
| 1227 | data = ((*command -'0') << 4) | (*(command + 1) - '0'); |
| 1228 | ie[len++] = data; |
| 1229 | command += 2; |
| 1230 | limit -= 2; |
| 1231 | } |
| 1232 | |
| 1233 | /* skip white space */ |
| 1234 | while ((SPACE_ASCII_VALUE == *command) && ('\0' != *command)) |
| 1235 | { |
| 1236 | command++; |
| 1237 | limit--; |
| 1238 | } |
| 1239 | |
| 1240 | /* extract data */ |
| 1241 | while ((SPACE_ASCII_VALUE != *command) && ('\0' != *command) && |
| 1242 | (limit > 1)) |
| 1243 | { |
| 1244 | /* Convert ASCII to decimal */ |
| 1245 | data = ((*command -'0') << 4) | (*(command + 1) - '0'); |
| 1246 | ie[len++] = data; |
| 1247 | command += 2; |
| 1248 | limit -= 2; |
| 1249 | } |
| 1250 | |
| 1251 | /* fill element id and element length */ |
| 1252 | ie[0] = IE_EID_VENDOR; |
| 1253 | ie[1] = len - 2; |
| 1254 | |
| 1255 | return len; |
| 1256 | } |
| 1257 | |
| 1258 | static tANI_U32 hdd_find_ibss_wpa_ie_pos(tANI_U8 *addIePtr, tANI_U32 addIeLen) |
| 1259 | { |
| 1260 | tANI_U32 ieLenPresent = 0; |
| 1261 | int left = addIeLen; |
| 1262 | v_U8_t *ptr = addIePtr; |
| 1263 | v_U8_t elem_id,elem_len; |
| 1264 | |
| 1265 | while(left >= 2) |
| 1266 | { |
| 1267 | elem_id = ptr[0]; |
| 1268 | elem_len = ptr[1]; |
| 1269 | left -= 2; |
| 1270 | if(elem_len > left) |
| 1271 | { |
| 1272 | hddLog(LOGE, |
| 1273 | FL("****Invalid elem_len=%d left=%d*****"), |
| 1274 | elem_len,left); |
| 1275 | return 0; |
| 1276 | } |
| 1277 | if ((elem_id == IE_EID_VENDOR) && |
| 1278 | (left >= WPA_OUI_TYPE_SIZE)) |
| 1279 | { |
| 1280 | if (!memcmp(&ptr[2], WPA_OUI_TYPE, |
| 1281 | WPA_OUI_TYPE_SIZE)) |
| 1282 | { |
| 1283 | ieLenPresent += elem_len + 2; |
| 1284 | return ieLenPresent; |
| 1285 | } |
| 1286 | } |
| 1287 | ieLenPresent += (elem_len + 2); |
| 1288 | left -= elem_len; |
| 1289 | ptr += (elem_len + 2); |
| 1290 | } |
| 1291 | return 0; |
| 1292 | } |
| 1293 | |
| 1294 | #endif /* WLAN_FEATURE_RMC */ |
| 1295 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1296 | #ifdef FEATURE_WLAN_BATCH_SCAN |
| 1297 | |
| 1298 | /**--------------------------------------------------------------------------- |
| 1299 | |
| 1300 | \brief hdd_extract_assigned_int_from_str() - Extracts assigned integer from |
| 1301 | input string |
| 1302 | |
| 1303 | This function extracts assigned integer from string in below format: |
| 1304 | "STRING=10" : extracts integer 10 from this string |
| 1305 | |
| 1306 | \param - pInPtr Pointer to input string |
| 1307 | \param - base Base for string to int conversion(10 for decimal 16 for hex) |
| 1308 | \param - pOutPtr Pointer to variable in which extracted integer needs to be |
| 1309 | assigned |
| 1310 | \param - pLastArg to tell whether it is last arguement in input string or |
| 1311 | not |
| 1312 | |
| 1313 | \return - NULL for failure cases |
| 1314 | pointer to next arguement in input string for success cases |
| 1315 | --------------------------------------------------------------------------*/ |
| 1316 | static tANI_U8 * |
| 1317 | hdd_extract_assigned_int_from_str |
| 1318 | ( |
| 1319 | tANI_U8 *pInPtr, |
| 1320 | tANI_U8 base, |
| 1321 | tANI_U32 *pOutPtr, |
| 1322 | tANI_U8 *pLastArg |
| 1323 | ) |
| 1324 | { |
| 1325 | int tempInt; |
| 1326 | int v = 0; |
| 1327 | char buf[32]; |
| 1328 | int val = 0; |
| 1329 | *pLastArg = FALSE; |
| 1330 | |
| 1331 | pInPtr = strnchr(pInPtr, strlen(pInPtr), EQUALS_TO_ASCII_VALUE); |
| 1332 | if (NULL == pInPtr) |
| 1333 | { |
| 1334 | return NULL; |
| 1335 | } |
| 1336 | |
| 1337 | pInPtr++; |
| 1338 | |
| 1339 | while ((SPACE_ASCII_VALUE == *pInPtr) && ('\0' != *pInPtr)) pInPtr++; |
| 1340 | |
| 1341 | val = sscanf(pInPtr, "%32s ", buf); |
| 1342 | if (val < 0 && val > strlen(pInPtr)) |
| 1343 | { |
| 1344 | return NULL; |
| 1345 | } |
| 1346 | pInPtr += val; |
| 1347 | v = kstrtos32(buf, base, &tempInt); |
| 1348 | if (v < 0) |
| 1349 | { |
| 1350 | return NULL; |
| 1351 | } |
Rajeev Kumar | 4d93d84 | 2014-01-02 18:31:21 -0800 | [diff] [blame] | 1352 | if (tempInt < 0) |
| 1353 | { |
| 1354 | tempInt = 0; |
| 1355 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1356 | *pOutPtr = tempInt; |
| 1357 | |
| 1358 | pInPtr = strnchr(pInPtr, strlen(pInPtr), SPACE_ASCII_VALUE); |
| 1359 | if (NULL == pInPtr) |
| 1360 | { |
| 1361 | *pLastArg = TRUE; |
| 1362 | return NULL; |
| 1363 | } |
| 1364 | while ((SPACE_ASCII_VALUE == *pInPtr) && ('\0' != *pInPtr)) pInPtr++; |
| 1365 | |
| 1366 | return pInPtr; |
| 1367 | } |
| 1368 | |
| 1369 | /**--------------------------------------------------------------------------- |
| 1370 | |
| 1371 | \brief hdd_extract_assigned_char_from_str() - Extracts assigned char from |
| 1372 | input string |
| 1373 | |
| 1374 | This function extracts assigned character from string in below format: |
| 1375 | "STRING=A" : extracts char 'A' from this string |
| 1376 | |
| 1377 | \param - pInPtr Pointer to input string |
| 1378 | \param - pOutPtr Pointer to variable in which extracted char needs to be |
| 1379 | assigned |
| 1380 | \param - pLastArg to tell whether it is last arguement in input string or |
| 1381 | not |
| 1382 | |
| 1383 | \return - NULL for failure cases |
| 1384 | pointer to next arguement in input string for success cases |
| 1385 | --------------------------------------------------------------------------*/ |
| 1386 | static tANI_U8 * |
| 1387 | hdd_extract_assigned_char_from_str |
| 1388 | ( |
| 1389 | tANI_U8 *pInPtr, |
| 1390 | tANI_U8 *pOutPtr, |
| 1391 | tANI_U8 *pLastArg |
| 1392 | ) |
| 1393 | { |
| 1394 | *pLastArg = FALSE; |
| 1395 | |
| 1396 | pInPtr = strnchr(pInPtr, strlen(pInPtr), EQUALS_TO_ASCII_VALUE); |
| 1397 | if (NULL == pInPtr) |
| 1398 | { |
| 1399 | return NULL; |
| 1400 | } |
| 1401 | |
| 1402 | pInPtr++; |
| 1403 | |
| 1404 | while ((SPACE_ASCII_VALUE == *pInPtr) && ('\0' != *pInPtr)) pInPtr++; |
| 1405 | |
| 1406 | *pOutPtr = *pInPtr; |
| 1407 | |
| 1408 | pInPtr = strnchr(pInPtr, strlen(pInPtr), SPACE_ASCII_VALUE); |
| 1409 | if (NULL == pInPtr) |
| 1410 | { |
| 1411 | *pLastArg = TRUE; |
| 1412 | return NULL; |
| 1413 | } |
| 1414 | while ((SPACE_ASCII_VALUE == *pInPtr) && ('\0' != *pInPtr)) pInPtr++; |
| 1415 | |
| 1416 | return pInPtr; |
| 1417 | } |
| 1418 | |
| 1419 | |
| 1420 | /**--------------------------------------------------------------------------- |
| 1421 | |
| 1422 | \brief hdd_parse_set_batchscan_command () - HDD parse set batch scan command |
| 1423 | |
| 1424 | This function parses set batch scan command in below format: |
| 1425 | WLS_BATCHING_SET <space> followed by below arguements |
| 1426 | "SCANFREQ=XX" : Optional defaults to 30 sec |
| 1427 | "MSCAN=XX" : Required number of scans to attempt to batch |
| 1428 | "BESTN=XX" : Best Network (RSSI) defaults to 16 |
| 1429 | "CHANNEL=<X,Y>" : optional defaults to all channels, can list 'A'or` B. |
| 1430 | A. implies only 5 GHz , B. implies only 2.4GHz |
| 1431 | "RTT=X" : optional defaults to 0 |
| 1432 | returns the MIN of MSCAN or the max # of scans firmware can cache or -1 on |
| 1433 | error |
| 1434 | |
| 1435 | For example input commands: |
| 1436 | 1) WLS_BATCHING_SET SCANFREQ=60 MSCAN=10 BESTN=20 CHANNEL=A RTT=0 -> This is |
| 1437 | translated into set batch scan with following parameters: |
| 1438 | a) Frequence 60 seconds |
| 1439 | b) Batch 10 scans together |
| 1440 | c) Best RSSI to be 20 |
| 1441 | d) 5GHz band only |
| 1442 | e) RTT is equal to 0 |
| 1443 | |
| 1444 | \param - pValue Pointer to input channel list |
| 1445 | \param - pHddSetBatchScanReq Pointer to HDD batch scan request structure |
| 1446 | |
| 1447 | \return - 0 for success non-zero for failure |
| 1448 | |
| 1449 | --------------------------------------------------------------------------*/ |
| 1450 | static int |
| 1451 | hdd_parse_set_batchscan_command |
| 1452 | ( |
| 1453 | tANI_U8 *pValue, |
| 1454 | tSirSetBatchScanReq *pHddSetBatchScanReq |
| 1455 | ) |
| 1456 | { |
| 1457 | tANI_U8 *inPtr = pValue; |
| 1458 | tANI_U8 val = 0; |
| 1459 | tANI_U8 lastArg = 0; |
Abhishek Singh | 00b7197 | 2016-01-07 10:51:04 +0530 | [diff] [blame] | 1460 | tANI_U32 nScanFreq = HDD_SET_BATCH_SCAN_DEFAULT_FREQ; |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 1461 | tANI_U32 nMscan; |
Abhishek Singh | 00b7197 | 2016-01-07 10:51:04 +0530 | [diff] [blame] | 1462 | tANI_U32 nBestN = HDD_SET_BATCH_SCAN_BEST_NETWORK; |
| 1463 | tANI_U8 ucRfBand = HDD_SET_BATCH_SCAN_DEFAULT_BAND; |
| 1464 | tANI_U32 nRtt = 0; |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 1465 | tANI_U32 temp; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1466 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1467 | /*go to space after WLS_BATCHING_SET command*/ |
| 1468 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 1469 | /*no argument after the command*/ |
| 1470 | if (NULL == inPtr) |
| 1471 | { |
| 1472 | return -EINVAL; |
| 1473 | } |
| 1474 | |
| 1475 | /*no space after the command*/ |
| 1476 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 1477 | { |
| 1478 | return -EINVAL; |
| 1479 | } |
| 1480 | |
| 1481 | /*removing empty spaces*/ |
| 1482 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
| 1483 | |
| 1484 | /*no argument followed by spaces*/ |
| 1485 | if ('\0' == *inPtr) |
| 1486 | { |
| 1487 | return -EINVAL; |
| 1488 | } |
| 1489 | |
| 1490 | /*check and parse SCANFREQ*/ |
| 1491 | if ((strncmp(inPtr, "SCANFREQ", 8) == 0)) |
| 1492 | { |
| 1493 | inPtr = hdd_extract_assigned_int_from_str(inPtr, 10, |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 1494 | &temp, &lastArg); |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 1495 | |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 1496 | if (0 != temp) |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 1497 | { |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 1498 | nScanFreq = temp; |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 1499 | } |
| 1500 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1501 | if ( (NULL == inPtr) || (TRUE == lastArg)) |
| 1502 | { |
| 1503 | return -EINVAL; |
| 1504 | } |
| 1505 | } |
| 1506 | |
| 1507 | /*check and parse MSCAN*/ |
| 1508 | if ((strncmp(inPtr, "MSCAN", 5) == 0)) |
| 1509 | { |
| 1510 | inPtr = hdd_extract_assigned_int_from_str(inPtr, 10, |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 1511 | &nMscan, &lastArg); |
| 1512 | |
| 1513 | if (0 == nMscan) |
| 1514 | { |
| 1515 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1516 | "invalid MSCAN=%d", nMscan); |
| 1517 | return -EINVAL; |
| 1518 | } |
| 1519 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1520 | if (TRUE == lastArg) |
| 1521 | { |
| 1522 | goto done; |
| 1523 | } |
| 1524 | else if (NULL == inPtr) |
| 1525 | { |
| 1526 | return -EINVAL; |
| 1527 | } |
| 1528 | } |
| 1529 | else |
| 1530 | { |
| 1531 | return -EINVAL; |
| 1532 | } |
| 1533 | |
| 1534 | /*check and parse BESTN*/ |
| 1535 | if ((strncmp(inPtr, "BESTN", 5) == 0)) |
| 1536 | { |
| 1537 | inPtr = hdd_extract_assigned_int_from_str(inPtr, 10, |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 1538 | &temp, &lastArg); |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 1539 | |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 1540 | if (0 != temp) |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 1541 | { |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 1542 | nBestN = temp; |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 1543 | } |
| 1544 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1545 | if (TRUE == lastArg) |
| 1546 | { |
| 1547 | goto done; |
| 1548 | } |
| 1549 | else if (NULL == inPtr) |
| 1550 | { |
| 1551 | return -EINVAL; |
| 1552 | } |
| 1553 | } |
| 1554 | |
| 1555 | /*check and parse CHANNEL*/ |
| 1556 | if ((strncmp(inPtr, "CHANNEL", 7) == 0)) |
| 1557 | { |
| 1558 | inPtr = hdd_extract_assigned_char_from_str(inPtr, &val, &lastArg); |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 1559 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1560 | if (('A' == val) || ('a' == val)) |
| 1561 | { |
c_hpothu | ebf8973 | 2014-02-25 13:00:24 +0530 | [diff] [blame] | 1562 | ucRfBand = HDD_SET_BATCH_SCAN_5GHz_BAND_ONLY; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1563 | } |
| 1564 | else if (('B' == val) || ('b' == val)) |
| 1565 | { |
c_hpothu | ebf8973 | 2014-02-25 13:00:24 +0530 | [diff] [blame] | 1566 | ucRfBand = HDD_SET_BATCH_SCAN_24GHz_BAND_ONLY; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1567 | } |
| 1568 | else |
| 1569 | { |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 1570 | ucRfBand = HDD_SET_BATCH_SCAN_DEFAULT_BAND; |
| 1571 | } |
| 1572 | |
| 1573 | if (TRUE == lastArg) |
| 1574 | { |
| 1575 | goto done; |
| 1576 | } |
| 1577 | else if (NULL == inPtr) |
| 1578 | { |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1579 | return -EINVAL; |
| 1580 | } |
| 1581 | } |
| 1582 | |
| 1583 | /*check and parse RTT*/ |
| 1584 | if ((strncmp(inPtr, "RTT", 3) == 0)) |
| 1585 | { |
| 1586 | inPtr = hdd_extract_assigned_int_from_str(inPtr, 10, |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 1587 | &nRtt, &lastArg); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1588 | if (TRUE == lastArg) |
| 1589 | { |
| 1590 | goto done; |
| 1591 | } |
| 1592 | if (NULL == inPtr) |
| 1593 | { |
| 1594 | return -EINVAL; |
| 1595 | } |
| 1596 | } |
| 1597 | |
| 1598 | |
| 1599 | done: |
| 1600 | |
Rajeev Kumar | 45e64a7 | 2013-11-18 19:48:15 -0800 | [diff] [blame] | 1601 | pHddSetBatchScanReq->scanFrequency = nScanFreq; |
| 1602 | pHddSetBatchScanReq->numberOfScansToBatch = nMscan; |
| 1603 | pHddSetBatchScanReq->bestNetwork = nBestN; |
| 1604 | pHddSetBatchScanReq->rfBand = ucRfBand; |
| 1605 | pHddSetBatchScanReq->rtt = nRtt; |
| 1606 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1607 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1608 | "Received WLS_BATCHING_SET with SCANFREQ=%d " |
| 1609 | "MSCAN=%d BESTN=%d CHANNEL=%d RTT=%d", |
| 1610 | pHddSetBatchScanReq->scanFrequency, |
| 1611 | pHddSetBatchScanReq->numberOfScansToBatch, |
| 1612 | pHddSetBatchScanReq->bestNetwork, |
| 1613 | pHddSetBatchScanReq->rfBand, |
| 1614 | pHddSetBatchScanReq->rtt); |
| 1615 | |
| 1616 | return 0; |
| 1617 | }/*End of hdd_parse_set_batchscan_command*/ |
| 1618 | |
| 1619 | /**--------------------------------------------------------------------------- |
| 1620 | |
| 1621 | \brief hdd_set_batch_scan_req_callback () - This function is called after |
| 1622 | receiving set batch scan response from FW and it saves set batch scan |
| 1623 | response data FW to HDD context and sets the completion event on |
| 1624 | which hdd_ioctl is waiting |
| 1625 | |
| 1626 | \param - callbackContext Pointer to HDD adapter |
| 1627 | \param - pRsp Pointer to set batch scan response data received from FW |
| 1628 | |
| 1629 | \return - nothing |
| 1630 | |
| 1631 | --------------------------------------------------------------------------*/ |
| 1632 | static void hdd_set_batch_scan_req_callback |
| 1633 | ( |
| 1634 | void *callbackContext, |
| 1635 | tSirSetBatchScanRsp *pRsp |
| 1636 | ) |
| 1637 | { |
| 1638 | hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext; |
| 1639 | tSirSetBatchScanRsp *pHddSetBatchScanRsp; |
| 1640 | |
| 1641 | /*sanity check*/ |
| 1642 | if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) |
| 1643 | { |
| 1644 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1645 | "%s: Invalid pAdapter magic", __func__); |
| 1646 | VOS_ASSERT(0); |
| 1647 | return; |
| 1648 | } |
| 1649 | pHddSetBatchScanRsp = &pAdapter->hddSetBatchScanRsp; |
| 1650 | |
| 1651 | /*save set batch scan response*/ |
| 1652 | pHddSetBatchScanRsp->nScansToBatch = pRsp->nScansToBatch; |
| 1653 | |
| 1654 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
| 1655 | "Received set batch scan rsp from FW with nScansToBatch=%d", |
| 1656 | pHddSetBatchScanRsp->nScansToBatch); |
| 1657 | |
| 1658 | pAdapter->hdd_wait_for_set_batch_scan_rsp = FALSE; |
| 1659 | complete(&pAdapter->hdd_set_batch_scan_req_var); |
| 1660 | |
| 1661 | return; |
| 1662 | }/*End of hdd_set_batch_scan_req_callback*/ |
| 1663 | |
| 1664 | |
| 1665 | /**--------------------------------------------------------------------------- |
| 1666 | |
| 1667 | \brief hdd_populate_batch_scan_rsp_queue () - This function stores AP meta |
| 1668 | info in hdd batch scan response queue |
| 1669 | |
| 1670 | \param - pAdapter Pointer to hdd adapter |
| 1671 | \param - pAPMetaInfo Pointer to access point meta info |
| 1672 | \param - scanId scan ID of batch scan response |
| 1673 | \param - isLastAp tells whether AP is last AP in batch scan response or not |
| 1674 | |
| 1675 | \return - nothing |
| 1676 | |
| 1677 | --------------------------------------------------------------------------*/ |
| 1678 | static void hdd_populate_batch_scan_rsp_queue( hdd_adapter_t* pAdapter, |
| 1679 | tpSirBatchScanNetworkInfo pApMetaInfo, tANI_U32 scanId, v_BOOL_t isLastAp) |
| 1680 | { |
| 1681 | tHddBatchScanRsp *pHead; |
| 1682 | tHddBatchScanRsp *pNode; |
| 1683 | tHddBatchScanRsp *pPrev; |
| 1684 | tHddBatchScanRsp *pTemp; |
| 1685 | tANI_U8 ssidLen; |
| 1686 | |
| 1687 | /*head of hdd batch scan response queue*/ |
| 1688 | pHead = pAdapter->pBatchScanRsp; |
| 1689 | |
| 1690 | pNode = (tHddBatchScanRsp *)vos_mem_malloc(sizeof(tHddBatchScanRsp)); |
| 1691 | if (NULL == pNode) |
| 1692 | { |
| 1693 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1694 | "%s: Could not allocate memory", __func__); |
| 1695 | VOS_ASSERT(0); |
| 1696 | return; |
| 1697 | } |
| 1698 | |
| 1699 | vos_mem_copy(pNode->ApInfo.bssid, pApMetaInfo->bssid, |
| 1700 | sizeof(pNode->ApInfo.bssid)); |
| 1701 | ssidLen = strlen(pApMetaInfo->ssid); |
| 1702 | if (SIR_MAX_SSID_SIZE < ssidLen) |
| 1703 | { |
| 1704 | /*invalid scan result*/ |
| 1705 | vos_mem_free(pNode); |
| 1706 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1707 | "%s: Invalid AP meta info ssidlen %d", __func__, ssidLen); |
| 1708 | return; |
| 1709 | } |
| 1710 | vos_mem_copy(pNode->ApInfo.ssid, pApMetaInfo->ssid, ssidLen); |
| 1711 | /*null terminate ssid*/ |
| 1712 | pNode->ApInfo.ssid[ssidLen] = '\0'; |
| 1713 | pNode->ApInfo.ch = pApMetaInfo->ch; |
| 1714 | pNode->ApInfo.rssi = pApMetaInfo->rssi; |
| 1715 | pNode->ApInfo.age = pApMetaInfo->timestamp; |
| 1716 | pNode->ApInfo.batchId = scanId; |
| 1717 | pNode->ApInfo.isLastAp = isLastAp; |
| 1718 | |
| 1719 | pNode->pNext = NULL; |
| 1720 | if (NULL == pHead) |
| 1721 | { |
| 1722 | pAdapter->pBatchScanRsp = pNode; |
| 1723 | } |
| 1724 | else |
| 1725 | { |
| 1726 | pTemp = pHead; |
| 1727 | while (NULL != pTemp) |
| 1728 | { |
| 1729 | pPrev = pTemp; |
| 1730 | pTemp = pTemp->pNext; |
| 1731 | } |
| 1732 | pPrev->pNext = pNode; |
| 1733 | } |
| 1734 | |
| 1735 | return; |
| 1736 | }/*End of hdd_populate_batch_scan_rsp_queue*/ |
| 1737 | |
| 1738 | /**--------------------------------------------------------------------------- |
| 1739 | |
| 1740 | \brief hdd_batch_scan_result_ind_callback () - This function is called after |
| 1741 | receiving batch scan response indication from FW. It saves get batch scan |
| 1742 | response data in HDD batch scan response queue. This callback sets the |
| 1743 | completion event on which hdd_ioctl is waiting only after getting complete |
| 1744 | batch scan response data from FW |
| 1745 | |
| 1746 | \param - callbackContext Pointer to HDD adapter |
| 1747 | \param - pRsp Pointer to get batch scan response data received from FW |
| 1748 | |
| 1749 | \return - nothing |
| 1750 | |
| 1751 | --------------------------------------------------------------------------*/ |
| 1752 | static void hdd_batch_scan_result_ind_callback |
| 1753 | ( |
| 1754 | void *callbackContext, |
| 1755 | void *pRsp |
| 1756 | ) |
| 1757 | { |
| 1758 | v_BOOL_t isLastAp; |
| 1759 | tANI_U32 numApMetaInfo; |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1760 | tANI_U32 numNetworkInScanList; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1761 | tANI_U32 numberScanList; |
| 1762 | tANI_U32 nextScanListOffset; |
| 1763 | tANI_U32 nextApMetaInfoOffset; |
| 1764 | hdd_adapter_t* pAdapter; |
| 1765 | tpSirBatchScanList pScanList; |
| 1766 | tpSirBatchScanNetworkInfo pApMetaInfo; |
| 1767 | tpSirBatchScanResultIndParam pBatchScanRsp;/*batch scan rsp data from FW*/ |
| 1768 | tSirSetBatchScanReq *pReq; |
| 1769 | |
| 1770 | pAdapter = (hdd_adapter_t *)callbackContext; |
| 1771 | /*sanity check*/ |
Rajeev Kumar | 5286bb9 | 2013-12-05 11:52:10 -0800 | [diff] [blame] | 1772 | if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)) |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1773 | { |
| 1774 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1775 | "%s: Invalid pAdapter magic", __func__); |
| 1776 | VOS_ASSERT(0); |
| 1777 | return; |
| 1778 | } |
| 1779 | |
| 1780 | /*initialize locals*/ |
| 1781 | pReq = &pAdapter->hddSetBatchScanReq; |
| 1782 | pBatchScanRsp = (tpSirBatchScanResultIndParam)pRsp; |
| 1783 | isLastAp = FALSE; |
| 1784 | numApMetaInfo = 0; |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1785 | numNetworkInScanList = 0; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1786 | numberScanList = 0; |
| 1787 | nextScanListOffset = 0; |
| 1788 | nextApMetaInfoOffset = 0; |
| 1789 | pScanList = NULL; |
| 1790 | pApMetaInfo = NULL; |
| 1791 | |
| 1792 | if ((NULL == pBatchScanRsp) || (NULL == pReq)) |
| 1793 | { |
| 1794 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | c135a9a | 2017-09-19 08:37:24 -0700 | [diff] [blame] | 1795 | "%s: pBatchScanRsp is %pK pReq %pK", __func__, pBatchScanRsp, pReq); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1796 | isLastAp = TRUE; |
| 1797 | goto done; |
| 1798 | } |
| 1799 | |
| 1800 | pAdapter->numScanList = numberScanList = pBatchScanRsp->numScanLists; |
| 1801 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1802 | "Batch scan rsp: numberScalList %d", numberScanList); |
| 1803 | |
| 1804 | if ((!numberScanList) || (numberScanList > pReq->numberOfScansToBatch)) |
| 1805 | { |
| 1806 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1807 | "%s: numberScanList %d", __func__, numberScanList); |
| 1808 | isLastAp = TRUE; |
| 1809 | goto done; |
| 1810 | } |
| 1811 | |
| 1812 | while (numberScanList) |
| 1813 | { |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1814 | pScanList = (tpSirBatchScanList)((tANI_U8 *)pBatchScanRsp->scanResults + |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1815 | nextScanListOffset); |
| 1816 | if (NULL == pScanList) |
| 1817 | { |
| 1818 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | c135a9a | 2017-09-19 08:37:24 -0700 | [diff] [blame] | 1819 | "%s: pScanList is %pK", __func__, pScanList); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1820 | isLastAp = TRUE; |
| 1821 | goto done; |
| 1822 | } |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1823 | numNetworkInScanList = numApMetaInfo = pScanList->numNetworksInScanList; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1824 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1825 | "Batch scan rsp: numApMetaInfo %d scanId %d", |
| 1826 | numApMetaInfo, pScanList->scanId); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1827 | |
| 1828 | if ((!numApMetaInfo) || (numApMetaInfo > pReq->bestNetwork)) |
| 1829 | { |
| 1830 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1831 | "%s: numApMetaInfo %d", __func__, numApMetaInfo); |
| 1832 | isLastAp = TRUE; |
| 1833 | goto done; |
| 1834 | } |
| 1835 | |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1836 | /*Initialize next AP meta info offset for next scan list*/ |
| 1837 | nextApMetaInfoOffset = 0; |
| 1838 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1839 | while (numApMetaInfo) |
| 1840 | { |
| 1841 | pApMetaInfo = (tpSirBatchScanNetworkInfo)(pScanList->scanList + |
| 1842 | nextApMetaInfoOffset); |
| 1843 | if (NULL == pApMetaInfo) |
| 1844 | { |
| 1845 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | c135a9a | 2017-09-19 08:37:24 -0700 | [diff] [blame] | 1846 | "%s: pApMetaInfo is %pK", __func__, pApMetaInfo); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1847 | isLastAp = TRUE; |
| 1848 | goto done; |
| 1849 | } |
| 1850 | /*calculate AP age*/ |
| 1851 | pApMetaInfo->timestamp = |
| 1852 | pBatchScanRsp->timestamp - pApMetaInfo->timestamp; |
| 1853 | |
| 1854 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
Arif Hussain | a7c8e41 | 2013-11-20 11:06:42 -0800 | [diff] [blame] | 1855 | "%s: bssId "MAC_ADDRESS_STR |
| 1856 | " ch %d rssi %d timestamp %d", __func__, |
| 1857 | MAC_ADDR_ARRAY(pApMetaInfo->bssid), |
| 1858 | pApMetaInfo->ch, pApMetaInfo->rssi, |
| 1859 | pApMetaInfo->timestamp); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1860 | |
| 1861 | /*mark last AP in batch scan response*/ |
| 1862 | if ((TRUE == pBatchScanRsp->isLastResult) && |
| 1863 | (1 == numberScanList) && (1 == numApMetaInfo)) |
| 1864 | { |
| 1865 | isLastAp = TRUE; |
| 1866 | } |
| 1867 | |
| 1868 | mutex_lock(&pAdapter->hdd_batch_scan_lock); |
| 1869 | /*store batch scan repsonse in hdd queue*/ |
| 1870 | hdd_populate_batch_scan_rsp_queue(pAdapter, pApMetaInfo, |
| 1871 | pScanList->scanId, isLastAp); |
| 1872 | mutex_unlock(&pAdapter->hdd_batch_scan_lock); |
| 1873 | |
| 1874 | nextApMetaInfoOffset += sizeof(tSirBatchScanNetworkInfo); |
| 1875 | numApMetaInfo--; |
| 1876 | } |
| 1877 | |
Rajeev Kumar | ce651e4 | 2013-10-21 18:57:15 -0700 | [diff] [blame] | 1878 | nextScanListOffset += ((sizeof(tSirBatchScanList) - sizeof(tANI_U8)) |
| 1879 | + (sizeof(tSirBatchScanNetworkInfo) |
| 1880 | * numNetworkInScanList)); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1881 | numberScanList--; |
| 1882 | } |
| 1883 | |
| 1884 | done: |
| 1885 | |
| 1886 | /*notify hdd_ioctl only if complete batch scan rsp is received and it was |
| 1887 | requested from hdd_ioctl*/ |
| 1888 | if ((TRUE == pAdapter->hdd_wait_for_get_batch_scan_rsp) && |
| 1889 | (TRUE == isLastAp)) |
| 1890 | { |
| 1891 | pAdapter->hdd_wait_for_get_batch_scan_rsp = FALSE; |
| 1892 | complete(&pAdapter->hdd_get_batch_scan_req_var); |
| 1893 | } |
| 1894 | |
| 1895 | return; |
| 1896 | }/*End of hdd_batch_scan_result_ind_callback*/ |
| 1897 | |
| 1898 | /**--------------------------------------------------------------------------- |
| 1899 | |
| 1900 | \brief hdd_format_batch_scan_rsp () - This function formats batch scan |
| 1901 | response as per batch scan FR request format by putting proper markers |
| 1902 | |
| 1903 | \param - pDest pointer to destination buffer |
| 1904 | \param - cur_len current length |
| 1905 | \param - tot_len total remaining size which can be written to user space |
| 1906 | \param - pApMetaInfo Pointer to get batch scan response AP meta info |
| 1907 | \param - pAdapter Pointer to HDD adapter |
| 1908 | |
| 1909 | \return - ret no of characters written |
| 1910 | |
| 1911 | --------------------------------------------------------------------------*/ |
| 1912 | static tANI_U32 |
| 1913 | hdd_format_batch_scan_rsp |
| 1914 | ( |
| 1915 | tANI_U8 *pDest, |
| 1916 | tANI_U32 cur_len, |
| 1917 | tANI_U32 tot_len, |
| 1918 | tHddBatchScanRsp *pApMetaInfo, |
| 1919 | hdd_adapter_t* pAdapter |
| 1920 | ) |
| 1921 | { |
| 1922 | tANI_U32 ret = 0; |
| 1923 | tANI_U32 rem_len = 0; |
| 1924 | tANI_U8 temp_len = 0; |
| 1925 | tANI_U8 temp_total_len = 0; |
| 1926 | tANI_U8 temp[HDD_BATCH_SCAN_AP_META_INFO_SIZE]; |
| 1927 | tANI_U8 *pTemp = temp; |
| 1928 | |
| 1929 | /*Batch scan reponse needs to be returned to user space in |
| 1930 | following format: |
| 1931 | "scancount=X\n" where X is the number of scans in current batch |
| 1932 | batch |
| 1933 | "trunc\n" optional present if current scan truncated |
| 1934 | "bssid=XX:XX:XX:XX:XX:XX\n" |
| 1935 | "ssid=XXXX\n" |
| 1936 | "freq=X\n" frequency in Mhz |
| 1937 | "level=XX\n" |
| 1938 | "age=X\n" ms |
| 1939 | "dist=X\n" cm (-1 if not available) |
| 1940 | "errror=X\n" (-1if not available) |
| 1941 | "====\n" (end of ap marker) |
| 1942 | "####\n" (end of scan marker) |
| 1943 | "----\n" (end of results)*/ |
| 1944 | /*send scan result in above format to user space based on |
| 1945 | available length*/ |
| 1946 | /*The GET response may have more data than the driver can return in its |
| 1947 | buffer. In that case the buffer should be filled to the nearest complete |
| 1948 | scan, ending with "%%%%".Subsequent callsshould return the remaining data |
| 1949 | starting with the next scan (optional .trunc\n., .apcount=X\n., etc). |
| 1950 | The final buffer should end with "----\n"*/ |
| 1951 | |
| 1952 | /*sanity*/ |
| 1953 | if (cur_len > tot_len) |
| 1954 | { |
| 1955 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1956 | "%s: invaid cur_len %d tot_len %d", __func__, cur_len, tot_len); |
| 1957 | return 0; |
| 1958 | } |
| 1959 | else |
| 1960 | { |
| 1961 | rem_len = (tot_len - cur_len); |
| 1962 | } |
| 1963 | |
| 1964 | /*end scan marker*/ |
| 1965 | if (pApMetaInfo->ApInfo.batchId != pAdapter->prev_batch_id) |
| 1966 | { |
| 1967 | temp_len = snprintf(pTemp, sizeof(temp), "####\n"); |
| 1968 | pTemp += temp_len; |
| 1969 | temp_total_len += temp_len; |
| 1970 | } |
| 1971 | |
| 1972 | /*bssid*/ |
| 1973 | temp_len = snprintf(pTemp, sizeof(temp), |
| 1974 | "bssid=0x%x:0x%x:0x%x:0x%x:0x%x:0x%x\n", |
| 1975 | pApMetaInfo->ApInfo.bssid[0], pApMetaInfo->ApInfo.bssid[1], |
| 1976 | pApMetaInfo->ApInfo.bssid[2], pApMetaInfo->ApInfo.bssid[3], |
| 1977 | pApMetaInfo->ApInfo.bssid[4], pApMetaInfo->ApInfo.bssid[5]); |
| 1978 | pTemp += temp_len; |
| 1979 | temp_total_len += temp_len; |
| 1980 | |
| 1981 | /*ssid*/ |
| 1982 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "ssid=%s\n", |
| 1983 | pApMetaInfo->ApInfo.ssid); |
| 1984 | pTemp += temp_len; |
| 1985 | temp_total_len += temp_len; |
| 1986 | |
| 1987 | /*freq*/ |
| 1988 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "freq=%d\n", |
Rajeev Kumar | c40f751 | 2013-11-04 14:13:23 -0800 | [diff] [blame] | 1989 | sme_ChnToFreq(pApMetaInfo->ApInfo.ch)); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 1990 | pTemp += temp_len; |
| 1991 | temp_total_len += temp_len; |
| 1992 | |
| 1993 | /*level*/ |
| 1994 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "level=%d\n", |
| 1995 | pApMetaInfo->ApInfo.rssi); |
| 1996 | pTemp += temp_len; |
| 1997 | temp_total_len += temp_len; |
| 1998 | |
| 1999 | /*age*/ |
Jeff Johnson | 0279779 | 2013-10-26 19:17:13 -0700 | [diff] [blame] | 2000 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "age=%d\n", |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 2001 | pApMetaInfo->ApInfo.age); |
| 2002 | pTemp += temp_len; |
| 2003 | temp_total_len += temp_len; |
| 2004 | |
| 2005 | /*dist*/ |
| 2006 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "dist=-1\n"); |
| 2007 | pTemp += temp_len; |
| 2008 | temp_total_len += temp_len; |
| 2009 | |
| 2010 | /*error*/ |
| 2011 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "error=-1\n"); |
| 2012 | pTemp += temp_len; |
| 2013 | temp_total_len += temp_len; |
| 2014 | |
| 2015 | /*end AP marker*/ |
| 2016 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "====\n"); |
| 2017 | pTemp += temp_len; |
| 2018 | temp_total_len += temp_len; |
| 2019 | |
| 2020 | /*last AP in batch scan response*/ |
| 2021 | if(TRUE == pApMetaInfo->ApInfo.isLastAp) |
| 2022 | { |
| 2023 | /*end scan marker*/ |
| 2024 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "####\n"); |
| 2025 | pTemp += temp_len; |
| 2026 | temp_total_len += temp_len; |
| 2027 | |
| 2028 | /*end batch scan result marker*/ |
| 2029 | temp_len = snprintf(pTemp, (sizeof(temp) - temp_total_len), "----\n"); |
| 2030 | pTemp += temp_len; |
| 2031 | temp_total_len += temp_len; |
Kiet Lam | aa8e15a | 2014-02-11 23:30:06 -0800 | [diff] [blame] | 2032 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 2033 | } |
| 2034 | |
| 2035 | if (temp_total_len < rem_len) |
| 2036 | { |
| 2037 | ret = temp_total_len + 1; |
| 2038 | strlcpy(pDest, temp, ret); |
| 2039 | pAdapter->isTruncated = FALSE; |
| 2040 | } |
| 2041 | else |
| 2042 | { |
| 2043 | pAdapter->isTruncated = TRUE; |
| 2044 | if (rem_len >= strlen("%%%%")) |
| 2045 | { |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 2046 | ret = snprintf(pDest, sizeof(temp), "%%%%"); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 2047 | } |
Rajeev Kumar | c933d98 | 2013-11-18 20:04:20 -0800 | [diff] [blame] | 2048 | else |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 2049 | { |
| 2050 | ret = 0; |
| 2051 | } |
| 2052 | } |
| 2053 | |
| 2054 | return ret; |
| 2055 | |
| 2056 | }/*End of hdd_format_batch_scan_rsp*/ |
| 2057 | |
| 2058 | /**--------------------------------------------------------------------------- |
| 2059 | |
| 2060 | \brief hdd_populate_user_batch_scan_rsp() - This function populates user data |
| 2061 | buffer starting with head of hdd batch scan response queue |
| 2062 | |
| 2063 | \param - pAdapter Pointer to HDD adapter |
| 2064 | \param - pDest Pointer to user data buffer |
| 2065 | \param - cur_len current offset in user buffer |
| 2066 | \param - rem_len remaining no of bytes in user buffer |
| 2067 | |
| 2068 | \return - number of bytes written in user buffer |
| 2069 | |
| 2070 | --------------------------------------------------------------------------*/ |
| 2071 | |
| 2072 | tANI_U32 hdd_populate_user_batch_scan_rsp |
| 2073 | ( |
| 2074 | hdd_adapter_t* pAdapter, |
| 2075 | tANI_U8 *pDest, |
| 2076 | tANI_U32 cur_len, |
| 2077 | tANI_U32 rem_len |
| 2078 | ) |
| 2079 | { |
| 2080 | tHddBatchScanRsp *pHead; |
| 2081 | tHddBatchScanRsp *pPrev; |
| 2082 | tANI_U32 len; |
| 2083 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 2084 | pAdapter->isTruncated = FALSE; |
| 2085 | |
| 2086 | /*head of hdd batch scan response queue*/ |
| 2087 | pHead = pAdapter->pBatchScanRsp; |
| 2088 | while (pHead) |
| 2089 | { |
| 2090 | len = hdd_format_batch_scan_rsp(pDest, cur_len, rem_len, pHead, |
| 2091 | pAdapter); |
| 2092 | pDest += len; |
Rajeev Kumar | 292d2bb | 2013-10-23 15:01:44 -0700 | [diff] [blame] | 2093 | pDest--; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 2094 | cur_len += len; |
| 2095 | if(TRUE == pAdapter->isTruncated) |
| 2096 | { |
| 2097 | /*result is truncated return rest of scan rsp in next req*/ |
| 2098 | cur_len = rem_len; |
| 2099 | break; |
| 2100 | } |
| 2101 | pPrev = pHead; |
| 2102 | pHead = pHead->pNext; |
| 2103 | pAdapter->pBatchScanRsp = pHead; |
Rajeev Kumar | be17d8b | 2014-01-10 15:39:45 -0800 | [diff] [blame] | 2104 | if (TRUE == pPrev->ApInfo.isLastAp) |
| 2105 | { |
| 2106 | pAdapter->prev_batch_id = 0; |
| 2107 | } |
| 2108 | else |
| 2109 | { |
| 2110 | pAdapter->prev_batch_id = pPrev->ApInfo.batchId; |
| 2111 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 2112 | vos_mem_free(pPrev); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 2113 | pPrev = NULL; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 2114 | } |
| 2115 | |
| 2116 | return cur_len; |
| 2117 | }/*End of hdd_populate_user_batch_scan_rsp*/ |
| 2118 | |
| 2119 | /**--------------------------------------------------------------------------- |
| 2120 | |
| 2121 | \brief hdd_return_batch_scan_rsp_to_user () - This function returns batch |
| 2122 | scan response data from HDD queue to user space |
| 2123 | It does following in detail: |
| 2124 | a) if HDD has enough data in its queue then it 1st copies data to user |
| 2125 | space and then send get batch scan indication message to FW. In this |
| 2126 | case it does not wait on any event and batch scan response data will |
| 2127 | be populated in HDD response queue in MC thread context after receiving |
| 2128 | indication from FW |
| 2129 | b) else send get batch scan indication message to FW and wait on an event |
| 2130 | which will be set once HDD receives complete batch scan response from |
| 2131 | FW and then this function returns batch scan response to user space |
| 2132 | |
| 2133 | \param - pAdapter Pointer to HDD adapter |
| 2134 | \param - pPrivData Pointer to priv_data |
| 2135 | |
| 2136 | \return - 0 for success -EFAULT for failure |
| 2137 | |
| 2138 | --------------------------------------------------------------------------*/ |
| 2139 | |
| 2140 | int hdd_return_batch_scan_rsp_to_user |
| 2141 | ( |
| 2142 | hdd_adapter_t* pAdapter, |
| 2143 | hdd_priv_data_t *pPrivData, |
| 2144 | tANI_U8 *command |
| 2145 | ) |
| 2146 | { |
| 2147 | tANI_U8 *pDest; |
| 2148 | tANI_U32 count = 0; |
| 2149 | tANI_U32 len = 0; |
| 2150 | tANI_U32 cur_len = 0; |
| 2151 | tANI_U32 rem_len = 0; |
| 2152 | eHalStatus halStatus; |
| 2153 | unsigned long rc; |
| 2154 | tSirTriggerBatchScanResultInd *pReq; |
| 2155 | |
| 2156 | pReq = &pAdapter->hddTriggerBatchScanResultInd; |
| 2157 | pReq->param = 0;/*batch scan client*/ |
| 2158 | pDest = (tANI_U8 *)(command + pPrivData->used_len); |
| 2159 | pAdapter->hdd_wait_for_get_batch_scan_rsp = FALSE; |
| 2160 | |
| 2161 | cur_len = pPrivData->used_len; |
| 2162 | if (pPrivData->total_len > pPrivData->used_len) |
| 2163 | { |
| 2164 | rem_len = pPrivData->total_len - pPrivData->used_len; |
| 2165 | } |
| 2166 | else |
| 2167 | { |
| 2168 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2169 | "%s: Invalid user data buffer total_len %d used_len %d", |
| 2170 | __func__, pPrivData->total_len, pPrivData->used_len); |
| 2171 | return -EFAULT; |
| 2172 | } |
| 2173 | |
| 2174 | mutex_lock(&pAdapter->hdd_batch_scan_lock); |
| 2175 | len = hdd_populate_user_batch_scan_rsp(pAdapter, pDest, |
| 2176 | cur_len, rem_len); |
| 2177 | mutex_unlock(&pAdapter->hdd_batch_scan_lock); |
| 2178 | |
| 2179 | /*enough scan result available in cache to return to user space or |
| 2180 | scan result needs to be fetched 1st from fw and then return*/ |
Rajeev Kumar | 99db626 | 2013-11-11 15:23:36 -0800 | [diff] [blame] | 2181 | if (len == cur_len) |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 2182 | { |
| 2183 | pAdapter->hdd_wait_for_get_batch_scan_rsp = TRUE; |
| 2184 | halStatus = sme_TriggerBatchScanResultInd( |
| 2185 | WLAN_HDD_GET_HAL_CTX(pAdapter), pReq, |
| 2186 | pAdapter->sessionId, hdd_batch_scan_result_ind_callback, |
| 2187 | pAdapter); |
| 2188 | if ( eHAL_STATUS_SUCCESS == halStatus ) |
| 2189 | { |
| 2190 | if (TRUE == pAdapter->hdd_wait_for_get_batch_scan_rsp) |
| 2191 | { |
| 2192 | INIT_COMPLETION(pAdapter->hdd_get_batch_scan_req_var); |
| 2193 | rc = wait_for_completion_timeout( |
| 2194 | &pAdapter->hdd_get_batch_scan_req_var, |
| 2195 | msecs_to_jiffies(HDD_GET_BATCH_SCAN_RSP_TIME_OUT)); |
Abhishek Singh | 00b7197 | 2016-01-07 10:51:04 +0530 | [diff] [blame] | 2196 | if (0 >= rc) |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 2197 | { |
| 2198 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Abhishek Singh | 00b7197 | 2016-01-07 10:51:04 +0530 | [diff] [blame] | 2199 | "%s: wait on hdd_get_batch_scan_req_var failed %ld", |
| 2200 | __func__, rc); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 2201 | return -EFAULT; |
| 2202 | } |
| 2203 | } |
| 2204 | |
| 2205 | len = snprintf(pDest, HDD_BATCH_SCAN_AP_META_INFO_SIZE, |
Jeff Johnson | 0279779 | 2013-10-26 19:17:13 -0700 | [diff] [blame] | 2206 | "scancount=%u\n", pAdapter->numScanList); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 2207 | pDest += len; |
| 2208 | cur_len += len; |
| 2209 | |
| 2210 | mutex_lock(&pAdapter->hdd_batch_scan_lock); |
| 2211 | len = hdd_populate_user_batch_scan_rsp(pAdapter, pDest, |
| 2212 | cur_len, rem_len); |
| 2213 | mutex_unlock(&pAdapter->hdd_batch_scan_lock); |
| 2214 | |
| 2215 | count = 0; |
| 2216 | len = (len - pPrivData->used_len); |
| 2217 | pDest = (command + pPrivData->used_len); |
| 2218 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Rajeev Kumar | 99db626 | 2013-11-11 15:23:36 -0800 | [diff] [blame] | 2219 | "NEW BATCH SCAN RESULT:"); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 2220 | while(count < len) |
| 2221 | { |
| 2222 | printk("%c", *(pDest + count)); |
| 2223 | count++; |
| 2224 | } |
| 2225 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2226 | "%s: copy %d data to user buffer", __func__, len); |
| 2227 | if (copy_to_user(pPrivData->buf, pDest, len)) |
| 2228 | { |
| 2229 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2230 | "%s: failed to copy data to user buffer", __func__); |
| 2231 | return -EFAULT; |
| 2232 | } |
| 2233 | } |
| 2234 | else |
| 2235 | { |
| 2236 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2237 | "sme_GetBatchScanScan returned failure halStatus %d", |
| 2238 | halStatus); |
| 2239 | return -EINVAL; |
| 2240 | } |
| 2241 | } |
| 2242 | else |
| 2243 | { |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 2244 | count = 0; |
| 2245 | len = (len - pPrivData->used_len); |
| 2246 | pDest = (command + pPrivData->used_len); |
| 2247 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Rajeev Kumar | 99db626 | 2013-11-11 15:23:36 -0800 | [diff] [blame] | 2248 | "REMAINING TRUNCATED BATCH SCAN RESULT:"); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 2249 | while(count < len) |
| 2250 | { |
| 2251 | printk("%c", *(pDest + count)); |
| 2252 | count++; |
| 2253 | } |
Rajeev Kumar | 99db626 | 2013-11-11 15:23:36 -0800 | [diff] [blame] | 2254 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2255 | "%s: copy %d data to user buffer", __func__, len); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 2256 | if (copy_to_user(pPrivData->buf, pDest, len)) |
| 2257 | { |
| 2258 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2259 | "%s: failed to copy data to user buffer", __func__); |
| 2260 | return -EFAULT; |
| 2261 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 2262 | } |
| 2263 | |
| 2264 | return 0; |
| 2265 | } /*End of hdd_return_batch_scan_rsp_to_user*/ |
| 2266 | |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 2267 | /**--------------------------------------------------------------------------- |
| 2268 | |
| 2269 | \brief hdd_handle_batch_scan_ioctl () - This function handles WLS_BATCHING |
| 2270 | IOCTLs from user space. Following BATCH SCAN DEV IOCTs are handled: |
| 2271 | WLS_BATCHING VERSION |
| 2272 | WLS_BATCHING SET |
| 2273 | WLS_BATCHING GET |
| 2274 | WLS_BATCHING STOP |
| 2275 | |
| 2276 | \param - pAdapter Pointer to HDD adapter |
| 2277 | \param - pPrivdata Pointer to priv_data |
| 2278 | \param - command Pointer to command |
| 2279 | |
| 2280 | \return - 0 for success -EFAULT for failure |
| 2281 | |
| 2282 | --------------------------------------------------------------------------*/ |
| 2283 | |
| 2284 | int hdd_handle_batch_scan_ioctl |
| 2285 | ( |
| 2286 | hdd_adapter_t *pAdapter, |
| 2287 | hdd_priv_data_t *pPrivdata, |
| 2288 | tANI_U8 *command |
| 2289 | ) |
| 2290 | { |
| 2291 | int ret = 0; |
Yue Ma | e36e355 | 2014-03-05 17:06:20 -0800 | [diff] [blame] | 2292 | hdd_context_t *pHddCtx; |
| 2293 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2294 | ENTER(); |
| 2295 | |
Yue Ma | e36e355 | 2014-03-05 17:06:20 -0800 | [diff] [blame] | 2296 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2297 | ret = wlan_hdd_validate_context(pHddCtx); |
| 2298 | if (ret) |
| 2299 | { |
Yue Ma | e36e355 | 2014-03-05 17:06:20 -0800 | [diff] [blame] | 2300 | goto exit; |
| 2301 | } |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 2302 | |
| 2303 | if (strncmp(command, "WLS_BATCHING VERSION", 20) == 0) |
| 2304 | { |
| 2305 | char extra[32]; |
| 2306 | tANI_U8 len = 0; |
| 2307 | tANI_U8 version = HDD_BATCH_SCAN_VERSION; |
| 2308 | |
| 2309 | if (FALSE == sme_IsFeatureSupportedByFW(BATCH_SCAN)) |
| 2310 | { |
| 2311 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2312 | "%s: Batch scan feature is not supported by FW", __func__); |
| 2313 | ret = -EINVAL; |
| 2314 | goto exit; |
| 2315 | } |
| 2316 | |
| 2317 | len = scnprintf(extra, sizeof(extra), "WLS_BATCHING_VERSION %d", |
| 2318 | version); |
| 2319 | if (copy_to_user(pPrivdata->buf, &extra, len + 1)) |
| 2320 | { |
| 2321 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2322 | "%s: failed to copy data to user buffer", __func__); |
| 2323 | ret = -EFAULT; |
| 2324 | goto exit; |
| 2325 | } |
| 2326 | ret = HDD_BATCH_SCAN_VERSION; |
| 2327 | } |
| 2328 | else if (strncmp(command, "WLS_BATCHING SET", 16) == 0) |
| 2329 | { |
| 2330 | int status; |
| 2331 | tANI_U8 *value = (command + 16); |
| 2332 | eHalStatus halStatus; |
| 2333 | unsigned long rc; |
| 2334 | tSirSetBatchScanReq *pReq = &pAdapter->hddSetBatchScanReq; |
| 2335 | tSirSetBatchScanRsp *pRsp = &pAdapter->hddSetBatchScanRsp; |
| 2336 | |
| 2337 | if (FALSE == sme_IsFeatureSupportedByFW(BATCH_SCAN)) |
| 2338 | { |
| 2339 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2340 | "%s: Batch scan feature is not supported by FW", __func__); |
| 2341 | ret = -EINVAL; |
| 2342 | goto exit; |
| 2343 | } |
| 2344 | |
| 2345 | if ((WLAN_HDD_INFRA_STATION != pAdapter->device_mode) && |
| 2346 | (WLAN_HDD_P2P_CLIENT != pAdapter->device_mode) && |
| 2347 | (WLAN_HDD_P2P_GO != pAdapter->device_mode) && |
| 2348 | (WLAN_HDD_P2P_DEVICE != pAdapter->device_mode)) |
| 2349 | { |
| 2350 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 2351 | "Received WLS_BATCHING SET command in invalid mode %s (%d) " |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 2352 | "WLS_BATCHING_SET is only allowed in infra STA/P2P client mode", |
Sushant Kaushik | 8bc7df2 | 2014-04-09 17:55:29 +0530 | [diff] [blame] | 2353 | hdd_device_modetoString(pAdapter->device_mode), |
| 2354 | pAdapter->device_mode); |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 2355 | ret = -EINVAL; |
| 2356 | goto exit; |
| 2357 | } |
| 2358 | |
| 2359 | status = hdd_parse_set_batchscan_command(value, pReq); |
| 2360 | if (status) |
| 2361 | { |
| 2362 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2363 | "Invalid WLS_BATCHING SET command"); |
| 2364 | ret = -EINVAL; |
| 2365 | goto exit; |
| 2366 | } |
| 2367 | |
| 2368 | |
| 2369 | pAdapter->hdd_wait_for_set_batch_scan_rsp = TRUE; |
| 2370 | halStatus = sme_SetBatchScanReq(WLAN_HDD_GET_HAL_CTX(pAdapter), pReq, |
| 2371 | pAdapter->sessionId, hdd_set_batch_scan_req_callback, |
| 2372 | pAdapter); |
| 2373 | |
| 2374 | if ( eHAL_STATUS_SUCCESS == halStatus ) |
| 2375 | { |
Mahesh A Saptasagar | 5f56817 | 2014-05-14 17:02:33 +0530 | [diff] [blame] | 2376 | char extra[32]; |
| 2377 | tANI_U8 len = 0; |
| 2378 | tANI_U8 mScan = 0; |
| 2379 | |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 2380 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2381 | "sme_SetBatchScanReq returned success halStatus %d", |
| 2382 | halStatus); |
| 2383 | if (TRUE == pAdapter->hdd_wait_for_set_batch_scan_rsp) |
| 2384 | { |
| 2385 | INIT_COMPLETION(pAdapter->hdd_set_batch_scan_req_var); |
| 2386 | rc = wait_for_completion_timeout( |
| 2387 | &pAdapter->hdd_set_batch_scan_req_var, |
| 2388 | msecs_to_jiffies(HDD_SET_BATCH_SCAN_REQ_TIME_OUT)); |
| 2389 | if (0 == rc) |
| 2390 | { |
| 2391 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2392 | "%s: Timeout waiting for set batch scan to complete", |
| 2393 | __func__); |
| 2394 | ret = -EINVAL; |
| 2395 | goto exit; |
| 2396 | } |
| 2397 | } |
| 2398 | if ( !pRsp->nScansToBatch ) |
| 2399 | { |
| 2400 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2401 | "%s: Received set batch scan failure response from FW", |
| 2402 | __func__); |
| 2403 | ret = -EINVAL; |
| 2404 | goto exit; |
| 2405 | } |
| 2406 | /*As per the Batch Scan Framework API we should return the MIN of |
| 2407 | either MSCAN or the max # of scans firmware can cache*/ |
Mahesh A Saptasagar | 5f56817 | 2014-05-14 17:02:33 +0530 | [diff] [blame] | 2408 | mScan = MIN(pReq->numberOfScansToBatch , pRsp->nScansToBatch); |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 2409 | |
| 2410 | pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STARTED; |
| 2411 | |
| 2412 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2413 | "%s: request MSCAN %d response MSCAN %d ret %d", |
Mahesh A Saptasagar | 5f56817 | 2014-05-14 17:02:33 +0530 | [diff] [blame] | 2414 | __func__, pReq->numberOfScansToBatch, pRsp->nScansToBatch, mScan); |
| 2415 | len = scnprintf(extra, sizeof(extra), "%d", mScan); |
| 2416 | if (copy_to_user(pPrivdata->buf, &extra, len + 1)) |
| 2417 | { |
| 2418 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2419 | "%s: failed to copy MSCAN value to user buffer", __func__); |
| 2420 | ret = -EFAULT; |
| 2421 | goto exit; |
| 2422 | } |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 2423 | } |
| 2424 | else |
| 2425 | { |
| 2426 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2427 | "sme_SetBatchScanReq returned failure halStatus %d", |
| 2428 | halStatus); |
| 2429 | ret = -EINVAL; |
| 2430 | goto exit; |
| 2431 | } |
| 2432 | } |
| 2433 | else if (strncmp(command, "WLS_BATCHING STOP", 17) == 0) |
| 2434 | { |
| 2435 | eHalStatus halStatus; |
| 2436 | tSirStopBatchScanInd *pInd = &pAdapter->hddStopBatchScanInd; |
| 2437 | pInd->param = 0; |
| 2438 | |
| 2439 | if (FALSE == sme_IsFeatureSupportedByFW(BATCH_SCAN)) |
| 2440 | { |
| 2441 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2442 | "%s: Batch scan feature is not supported by FW", __func__); |
| 2443 | ret = -EINVAL; |
| 2444 | goto exit; |
| 2445 | } |
| 2446 | |
| 2447 | if (eHDD_BATCH_SCAN_STATE_STARTED != pAdapter->batchScanState) |
| 2448 | { |
Deepthi Gowri | bfd1713 | 2014-11-14 17:59:04 +0530 | [diff] [blame] | 2449 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 2450 | "Batch scan is not yet enabled batch scan state %d", |
| 2451 | pAdapter->batchScanState); |
| 2452 | ret = -EINVAL; |
| 2453 | goto exit; |
| 2454 | } |
| 2455 | |
Kiet Lam | aa8e15a | 2014-02-11 23:30:06 -0800 | [diff] [blame] | 2456 | mutex_lock(&pAdapter->hdd_batch_scan_lock); |
| 2457 | hdd_deinit_batch_scan(pAdapter); |
| 2458 | mutex_unlock(&pAdapter->hdd_batch_scan_lock); |
| 2459 | |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 2460 | pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STOPPED; |
| 2461 | |
| 2462 | halStatus = sme_StopBatchScanInd(WLAN_HDD_GET_HAL_CTX(pAdapter), pInd, |
| 2463 | pAdapter->sessionId); |
| 2464 | if ( eHAL_STATUS_SUCCESS == halStatus ) |
| 2465 | { |
| 2466 | ret = 0; |
| 2467 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2468 | "sme_StopBatchScanInd returned success halStatus %d", |
| 2469 | halStatus); |
| 2470 | } |
| 2471 | else |
| 2472 | { |
| 2473 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2474 | "sme_StopBatchScanInd returned failure halStatus %d", |
| 2475 | halStatus); |
| 2476 | ret = -EINVAL; |
| 2477 | goto exit; |
| 2478 | } |
| 2479 | } |
| 2480 | else if (strncmp(command, "WLS_BATCHING GET", 16) == 0) |
| 2481 | { |
| 2482 | tANI_U32 remain_len; |
| 2483 | |
| 2484 | if (FALSE == sme_IsFeatureSupportedByFW(BATCH_SCAN)) |
| 2485 | { |
| 2486 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2487 | "%s: Batch scan feature is not supported by FW", __func__); |
| 2488 | ret = -EINVAL; |
| 2489 | goto exit; |
| 2490 | } |
| 2491 | |
| 2492 | if (eHDD_BATCH_SCAN_STATE_STARTED != pAdapter->batchScanState) |
| 2493 | { |
Deepthi Gowri | bfd1713 | 2014-11-14 17:59:04 +0530 | [diff] [blame] | 2494 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 2495 | "Batch scan is not yet enabled could not return results" |
| 2496 | "Batch Scan state %d", |
| 2497 | pAdapter->batchScanState); |
| 2498 | ret = -EINVAL; |
| 2499 | goto exit; |
| 2500 | } |
| 2501 | |
| 2502 | pPrivdata->used_len = 16; |
| 2503 | remain_len = pPrivdata->total_len - pPrivdata->used_len; |
| 2504 | if (remain_len < pPrivdata->total_len) |
| 2505 | { |
| 2506 | /*Clear previous batch scan response data if any*/ |
| 2507 | vos_mem_zero((tANI_U8 *)(command + pPrivdata->used_len), remain_len); |
| 2508 | } |
| 2509 | else |
| 2510 | { |
| 2511 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2512 | "Invalid total length from user space can't fetch batch" |
| 2513 | " scan response total_len %d used_len %d remain len %d", |
| 2514 | pPrivdata->total_len, pPrivdata->used_len, remain_len); |
| 2515 | ret = -EINVAL; |
| 2516 | goto exit; |
| 2517 | } |
| 2518 | ret = hdd_return_batch_scan_rsp_to_user(pAdapter, pPrivdata, command); |
| 2519 | } |
| 2520 | |
| 2521 | exit: |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 2522 | EXIT(); |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 2523 | return ret; |
| 2524 | } |
| 2525 | |
| 2526 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 2527 | #endif/*End of FEATURE_WLAN_BATCH_SCAN*/ |
| 2528 | |
Selvaraj, Sridhar | 5aff1ed | 2016-06-18 01:26:23 +0530 | [diff] [blame] | 2529 | #if defined(WLAN_FEATURE_VOWIFI_11R) || defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR) |
| 2530 | /** |
| 2531 | * hdd_assign_handoff_src_reassoc - Set handoff source as REASSOC |
| 2532 | * to Handoff request |
| 2533 | * @handoffInfo: Pointer to Handoff request |
| 2534 | * @src: enum of handoff_src |
| 2535 | * Return: None |
| 2536 | */ |
| 2537 | #ifndef QCA_WIFI_ISOC |
| 2538 | static inline void hdd_assign_handoff_src_reassoc(tCsrHandoffRequest |
| 2539 | *handoffInfo, handoff_src src) |
| 2540 | { |
| 2541 | handoffInfo->src = src; |
| 2542 | } |
| 2543 | #else |
| 2544 | static inline void hdd_assign_handoff_src_reassoc(tCsrHandoffRequest |
| 2545 | *handoffInfo, handoff_src src) |
| 2546 | { |
| 2547 | } |
| 2548 | #endif |
| 2549 | |
| 2550 | /** |
Selvaraj, Sridhar | 4fa1523 | 2016-06-18 12:27:25 +0530 | [diff] [blame] | 2551 | * hdd_reassoc() - perform a user space-directed reassoc |
Selvaraj, Sridhar | 5aff1ed | 2016-06-18 01:26:23 +0530 | [diff] [blame] | 2552 | * |
| 2553 | * @pAdapter: Adapter upon which the command was received |
| 2554 | * @bssid: BSSID with which to reassociate |
| 2555 | * @channel: channel upon which to reassociate |
Selvaraj, Sridhar | 4fa1523 | 2016-06-18 12:27:25 +0530 | [diff] [blame] | 2556 | * @src: The source for the trigger of this action |
Selvaraj, Sridhar | 5aff1ed | 2016-06-18 01:26:23 +0530 | [diff] [blame] | 2557 | * |
| 2558 | * Return: 0 for success non-zero for failure |
| 2559 | */ |
| 2560 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
Selvaraj, Sridhar | 8ecb419 | 2016-06-23 17:50:49 +0530 | [diff] [blame] | 2561 | int hdd_reassoc(hdd_adapter_t *pAdapter, const tANI_U8 *bssid, |
Selvaraj, Sridhar | 4fa1523 | 2016-06-18 12:27:25 +0530 | [diff] [blame] | 2562 | const tANI_U8 channel, const handoff_src src) |
Selvaraj, Sridhar | 5aff1ed | 2016-06-18 01:26:23 +0530 | [diff] [blame] | 2563 | { |
| 2564 | hdd_station_ctx_t *pHddStaCtx; |
| 2565 | tCsrHandoffRequest handoffInfo; |
| 2566 | hdd_context_t *pHddCtx = NULL; |
| 2567 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2568 | |
| 2569 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 2570 | |
| 2571 | /* if not associated, no need to proceed with reassoc */ |
| 2572 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) { |
| 2573 | hddLog(LOG1, FL("Not associated")); |
| 2574 | return -EINVAL; |
| 2575 | } |
| 2576 | |
| 2577 | /* if the target bssid is same as currently associated AP, |
| 2578 | then no need to proceed with reassoc */ |
| 2579 | if (!memcmp(bssid, pHddStaCtx->conn_info.bssId, sizeof(tSirMacAddr))) { |
| 2580 | hddLog(LOG1, FL("Reassoc BSSID is same as currently associated AP bssid")); |
| 2581 | return -EINVAL; |
| 2582 | } |
| 2583 | |
| 2584 | /* Check channel number is a valid channel number */ |
| 2585 | if (VOS_STATUS_SUCCESS != |
| 2586 | wlan_hdd_validate_operation_channel(pAdapter, channel)) { |
| 2587 | hddLog(LOGE, FL("Invalid Channel %d"), channel); |
| 2588 | return -EINVAL; |
| 2589 | } |
| 2590 | |
| 2591 | /* Proceed with reassoc */ |
| 2592 | handoffInfo.channel = channel; |
Selvaraj, Sridhar | 4fa1523 | 2016-06-18 12:27:25 +0530 | [diff] [blame] | 2593 | hdd_assign_handoff_src_reassoc(&handoffInfo, src); |
Selvaraj, Sridhar | 5aff1ed | 2016-06-18 01:26:23 +0530 | [diff] [blame] | 2594 | memcpy(handoffInfo.bssid, bssid, sizeof(tSirMacAddr)); |
| 2595 | sme_HandoffRequest(pHddCtx->hHal, &handoffInfo); |
| 2596 | return 0; |
| 2597 | } |
| 2598 | #else |
Selvaraj, Sridhar | 8ecb419 | 2016-06-23 17:50:49 +0530 | [diff] [blame] | 2599 | int hdd_reassoc(hdd_adapter_t *pAdapter, const tANI_U8 *bssid, |
Selvaraj, Sridhar | 4fa1523 | 2016-06-18 12:27:25 +0530 | [diff] [blame] | 2600 | const tANI_U8 channel, const handoff_src src) |
Selvaraj, Sridhar | 5aff1ed | 2016-06-18 01:26:23 +0530 | [diff] [blame] | 2601 | { |
| 2602 | return -EPERM; |
| 2603 | } |
| 2604 | #endif |
| 2605 | |
| 2606 | /** |
| 2607 | * hdd_parse_reassoc_v1() - parse version 1 of the REASSOC command |
| 2608 | * This function parses the v1 REASSOC command with the format |
| 2609 | * REASSOC xx:xx:xx:xx:xx:xx CH where "xx:xx:xx:xx:xx:xx" is the |
| 2610 | * Hex-ASCII representation of the BSSID and CH is the ASCII |
| 2611 | * representation of the channel. For example |
| 2612 | * REASSOC 00:0a:0b:11:22:33 48 |
| 2613 | * |
| 2614 | * @pAdapter: Adapter upon which the command was received |
| 2615 | * @command: ASCII text command that was received |
| 2616 | * |
| 2617 | * Return: 0 for success non-zero for failure |
| 2618 | */ |
| 2619 | static int |
| 2620 | hdd_parse_reassoc_v1(hdd_adapter_t *pAdapter, const char *command) |
| 2621 | { |
| 2622 | tANI_U8 channel = 0; |
| 2623 | tSirMacAddr bssid; |
| 2624 | int ret; |
| 2625 | |
| 2626 | ret = hdd_parse_reassoc_command_v1_data(command, bssid, &channel); |
| 2627 | if (ret) |
| 2628 | hddLog(LOGE, FL("Failed to parse reassoc command data")); |
| 2629 | else |
Selvaraj, Sridhar | 4fa1523 | 2016-06-18 12:27:25 +0530 | [diff] [blame] | 2630 | ret = hdd_reassoc(pAdapter, bssid, channel, REASSOC); |
Selvaraj, Sridhar | 5aff1ed | 2016-06-18 01:26:23 +0530 | [diff] [blame] | 2631 | |
| 2632 | return ret; |
| 2633 | } |
| 2634 | |
| 2635 | /** |
| 2636 | * hdd_parse_reassoc_v2() - parse version 2 of the REASSOC command |
| 2637 | * This function parses the v2 REASSOC command with the format |
| 2638 | * REASSOC <android_wifi_reassoc_params> |
| 2639 | * |
| 2640 | * @pAdapter: Adapter upon which the command was received |
| 2641 | * @command: command that was received, ASCII command followed |
| 2642 | * by binary data |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 2643 | * @total_len: Total length of the command received |
Selvaraj, Sridhar | 5aff1ed | 2016-06-18 01:26:23 +0530 | [diff] [blame] | 2644 | * |
| 2645 | * Return: 0 for success non-zero for failure |
| 2646 | */ |
| 2647 | static int |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 2648 | hdd_parse_reassoc_v2(hdd_adapter_t *pAdapter, const char *command, |
| 2649 | int total_len) |
Selvaraj, Sridhar | 5aff1ed | 2016-06-18 01:26:23 +0530 | [diff] [blame] | 2650 | { |
| 2651 | struct android_wifi_reassoc_params params; |
| 2652 | tSirMacAddr bssid; |
| 2653 | int ret; |
| 2654 | |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 2655 | if (total_len < sizeof(params) + 8) { |
| 2656 | hddLog(LOGE, FL("Invalid command length")); |
| 2657 | return -EINVAL; |
| 2658 | } |
| 2659 | |
Selvaraj, Sridhar | 5aff1ed | 2016-06-18 01:26:23 +0530 | [diff] [blame] | 2660 | /* The params are located after "REASSOC " */ |
| 2661 | memcpy(¶ms, command + 8, sizeof(params)); |
| 2662 | |
| 2663 | if (!mac_pton(params.bssid, (u8 *)&bssid)) { |
| 2664 | hddLog(LOGE, FL("MAC address parsing failed")); |
| 2665 | ret = -EINVAL; |
| 2666 | } else { |
Selvaraj, Sridhar | 4fa1523 | 2016-06-18 12:27:25 +0530 | [diff] [blame] | 2667 | ret = hdd_reassoc(pAdapter, bssid, params.channel, REASSOC); |
Selvaraj, Sridhar | 5aff1ed | 2016-06-18 01:26:23 +0530 | [diff] [blame] | 2668 | } |
| 2669 | return ret; |
| 2670 | } |
| 2671 | |
| 2672 | /** |
| 2673 | * hdd_parse_reassoc() - parse the REASSOC command |
| 2674 | * There are two different versions of the REASSOC command.Version 1 |
| 2675 | * of the command contains a parameter list that is ASCII characters |
| 2676 | * whereas version 2 contains a combination of ASCII and binary |
| 2677 | * payload. Determine if a version 1 or a version 2 command is being |
| 2678 | * parsed by examining the parameters, and then dispatch the parser |
| 2679 | * that is appropriate for the command. |
| 2680 | * |
| 2681 | * @pAdapter: Adapter upon which the command was received |
| 2682 | * @command: command that was received |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 2683 | * @total_len: Total length of the command received |
Selvaraj, Sridhar | 5aff1ed | 2016-06-18 01:26:23 +0530 | [diff] [blame] | 2684 | * |
| 2685 | * Return: 0 for success non-zero for failure |
| 2686 | */ |
| 2687 | static int |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 2688 | 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] | 2689 | { |
| 2690 | int ret; |
| 2691 | |
| 2692 | /* |
| 2693 | * both versions start with "REASSOC" |
| 2694 | * v1 has a bssid and channel # as an ASCII string |
| 2695 | * REASSOC xx:xx:xx:xx:xx:xx CH |
| 2696 | * v2 has a C struct |
| 2697 | * REASSOC <binary c struct> |
| 2698 | * |
| 2699 | * The first field in the v2 struct is also the bssid in ASCII. |
| 2700 | * But in the case of a v2 message the BSSID is NUL-terminated. |
| 2701 | * Hence we can peek at that offset to see if this is V1 or V2 |
| 2702 | * REASSOC xx:xx:xx:xx:xx:xx* |
| 2703 | * 1111111111222222 |
| 2704 | * 01234567890123456789012345 |
| 2705 | */ |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 2706 | |
| 2707 | if (total_len < 26) { |
| 2708 | hddLog(LOGE, FL("Invalid command (total_len=%d)"), total_len); |
| 2709 | return -EINVAL; |
| 2710 | } |
| 2711 | |
Selvaraj, Sridhar | 5aff1ed | 2016-06-18 01:26:23 +0530 | [diff] [blame] | 2712 | if (command[25]) |
| 2713 | ret = hdd_parse_reassoc_v1(pAdapter, command); |
| 2714 | else |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 2715 | ret = hdd_parse_reassoc_v2(pAdapter, command, total_len); |
Selvaraj, Sridhar | 5aff1ed | 2016-06-18 01:26:23 +0530 | [diff] [blame] | 2716 | |
| 2717 | return ret; |
| 2718 | } |
| 2719 | #endif /* WLAN_FEATURE_VOWIFI_11R || FEATURE_WLAN_ESE FEATURE_WLAN_LFR */ |
| 2720 | |
Hanumanth Reddy Pothula | 7aa4bea | 2018-04-09 17:19:03 +0530 | [diff] [blame] | 2721 | struct bcn_miss_rate_priv { |
| 2722 | int bcn_miss_rate; |
| 2723 | }; |
| 2724 | |
| 2725 | /** |
| 2726 | * get_bcn_miss_rate_cb() callback invoked on receiving beacon miss |
| 2727 | * rate from firmware |
| 2728 | * @status: Status of get beacon miss rate operation |
| 2729 | * @bcnMissRate: Beacon miss rate |
| 2730 | * @context: Context passed while registering callback |
| 2731 | * |
| 2732 | * This function is invoked by WDA layer on receiving |
| 2733 | * WDI_GET_BCN_MISS_RATE_RSP |
| 2734 | * |
| 2735 | * Return: None |
| 2736 | */ |
| 2737 | static void get_bcn_miss_rate_cb(VOS_STATUS status, int bcnMissRate, |
| 2738 | void *context) |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 2739 | { |
Hanumanth Reddy Pothula | 7aa4bea | 2018-04-09 17:19:03 +0530 | [diff] [blame] | 2740 | struct hdd_request *request; |
| 2741 | struct bcn_miss_rate_priv *priv; |
c_hpothu | 39eb1e3 | 2014-06-26 16:31:50 +0530 | [diff] [blame] | 2742 | |
Hanumanth Reddy Pothula | 7aa4bea | 2018-04-09 17:19:03 +0530 | [diff] [blame] | 2743 | request = hdd_request_get(context); |
| 2744 | if (!request) { |
| 2745 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Obsolete request")); |
| 2746 | return; |
| 2747 | } |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 2748 | |
Hanumanth Reddy Pothula | 7aa4bea | 2018-04-09 17:19:03 +0530 | [diff] [blame] | 2749 | priv = hdd_request_priv(request); |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 2750 | |
Hanumanth Reddy Pothula | 7aa4bea | 2018-04-09 17:19:03 +0530 | [diff] [blame] | 2751 | if (VOS_STATUS_SUCCESS == status) |
| 2752 | priv->bcn_miss_rate = bcnMissRate; |
| 2753 | else |
| 2754 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("failed to get bcnMissRate")); |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 2755 | |
Hanumanth Reddy Pothula | 7aa4bea | 2018-04-09 17:19:03 +0530 | [diff] [blame] | 2756 | hdd_request_complete(request); |
| 2757 | hdd_request_put(request); |
Hanumanth Reddy Pothula | d0d3c17 | 2018-05-02 18:53:05 +0530 | [diff] [blame] | 2758 | |
Hanumanth Reddy Pothula | 7aa4bea | 2018-04-09 17:19:03 +0530 | [diff] [blame] | 2759 | return; |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 2760 | } |
| 2761 | |
Hanumanth Reddy Pothula | 7aa4bea | 2018-04-09 17:19:03 +0530 | [diff] [blame] | 2762 | struct fw_stats_priv { |
| 2763 | tSirFwStatsResult *fw_stats; |
| 2764 | }; |
| 2765 | |
| 2766 | /** |
| 2767 | * hdd_fw_stats_cb() callback invoked on receiving firmware stats |
| 2768 | * from firmware |
| 2769 | * @status: Status of get firmware stats operation |
| 2770 | * @fwStatsResult: firmware stats |
| 2771 | * @context: Context passed while registering callback |
| 2772 | * |
| 2773 | * This function is invoked by WDA layer on receiving |
| 2774 | * WDI_GET_FW_STATS_RSP |
| 2775 | * |
| 2776 | * Return: None |
| 2777 | */ |
| 2778 | static void hdd_fw_stats_cb(VOS_STATUS status, |
| 2779 | tSirFwStatsResult *fwStatsResult, void *context) |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 2780 | { |
Hanumanth Reddy Pothula | 7aa4bea | 2018-04-09 17:19:03 +0530 | [diff] [blame] | 2781 | struct hdd_request *request; |
| 2782 | struct fw_stats_priv *priv; |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 2783 | |
Hanumanth Reddy Pothula | 7aa4bea | 2018-04-09 17:19:03 +0530 | [diff] [blame] | 2784 | hddLog(VOS_TRACE_LEVEL_INFO, FL("with status = %d"),status); |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 2785 | |
Hanumanth Reddy Pothula | 7aa4bea | 2018-04-09 17:19:03 +0530 | [diff] [blame] | 2786 | request = hdd_request_get(context); |
| 2787 | if (!request) { |
| 2788 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Obsolete request")); |
| 2789 | return; |
| 2790 | } |
| 2791 | priv = hdd_request_priv(request); |
| 2792 | |
| 2793 | if (VOS_STATUS_SUCCESS == status) |
| 2794 | *priv->fw_stats = *fwStatsResult; |
| 2795 | else |
| 2796 | priv->fw_stats = NULL; |
| 2797 | |
| 2798 | hdd_request_complete(request); |
| 2799 | hdd_request_put(request); |
| 2800 | return; |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 2801 | } |
| 2802 | |
jge | 3556720 | 2017-06-21 16:39:38 +0800 | [diff] [blame] | 2803 | /* |
| 2804 | *hdd_parse_setmaxtxpower_command() - HDD Parse MAXTXPOWER command |
| 2805 | *@pValue Pointer to MAXTXPOWER command |
| 2806 | *@pTxPower Pointer to tx power |
| 2807 | * |
| 2808 | *This function parses the MAXTXPOWER command passed in the format |
| 2809 | * MAXTXPOWER<space>X(Tx power in dbm) |
| 2810 | * For example input commands: |
| 2811 | * 1) MAXTXPOWER -8 -> This is translated into set max TX power to -8 dbm |
| 2812 | * 2) MAXTXPOWER -23 -> This is translated into set max TX power to -23 dbm |
| 2813 | * |
| 2814 | *return - 0 for success non-zero for failure |
| 2815 | */ |
| 2816 | static int hdd_parse_setmaxtxpower_command(unsigned char *pValue, int *pTxPower) |
| 2817 | { |
| 2818 | unsigned char *inPtr = pValue; |
| 2819 | int tempInt; |
| 2820 | int v = 0; |
| 2821 | *pTxPower = 0; |
| 2822 | |
| 2823 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 2824 | /* no argument after the command */ |
| 2825 | if (NULL == inPtr) |
| 2826 | return -EINVAL; |
| 2827 | /* no space after the command */ |
| 2828 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 2829 | return -EINVAL; |
| 2830 | |
| 2831 | /* removing empty spaces */ |
| 2832 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
| 2833 | |
| 2834 | /* no argument followed by spaces */ |
| 2835 | if ('\0' == *inPtr) |
| 2836 | return 0; |
| 2837 | |
| 2838 | v = kstrtos32(inPtr, 10, &tempInt); |
| 2839 | |
| 2840 | /* Range checking for passed parameter */ |
| 2841 | if ((tempInt < HDD_MIN_TX_POWER) || (tempInt > HDD_MAX_TX_POWER)) |
| 2842 | return -EINVAL; |
| 2843 | |
| 2844 | *pTxPower = tempInt; |
| 2845 | |
| 2846 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 2847 | "SETMAXTXPOWER: %d", *pTxPower); |
| 2848 | |
| 2849 | return 0; |
| 2850 | } |
| 2851 | |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2852 | static int hdd_get_dwell_time(hdd_config_t *pCfg, tANI_U8 *command, char *extra, tANI_U8 n, tANI_U8 *len) |
| 2853 | { |
| 2854 | int ret = 0; |
| 2855 | |
| 2856 | if (!pCfg || !command || !extra || !len) |
| 2857 | { |
| 2858 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2859 | "%s: argument passsed for GETDWELLTIME is incorrect", __func__); |
| 2860 | ret = -EINVAL; |
| 2861 | return ret; |
| 2862 | } |
| 2863 | |
| 2864 | if (strncmp(command, "GETDWELLTIME ACTIVE MAX", 23) == 0) |
| 2865 | { |
| 2866 | *len = scnprintf(extra, n, "GETDWELLTIME ACTIVE MAX %u\n", |
| 2867 | (int)pCfg->nActiveMaxChnTime); |
| 2868 | return ret; |
| 2869 | } |
| 2870 | else if (strncmp(command, "GETDWELLTIME ACTIVE MIN", 23) == 0) |
| 2871 | { |
| 2872 | *len = scnprintf(extra, n, "GETDWELLTIME ACTIVE MIN %u\n", |
| 2873 | (int)pCfg->nActiveMinChnTime); |
| 2874 | return ret; |
| 2875 | } |
| 2876 | else if (strncmp(command, "GETDWELLTIME PASSIVE MAX", 24) == 0) |
| 2877 | { |
| 2878 | *len = scnprintf(extra, n, "GETDWELLTIME PASSIVE MAX %u\n", |
| 2879 | (int)pCfg->nPassiveMaxChnTime); |
| 2880 | return ret; |
| 2881 | } |
| 2882 | else if (strncmp(command, "GETDWELLTIME PASSIVE MIN", 24) == 0) |
| 2883 | { |
| 2884 | *len = scnprintf(extra, n, "GETDWELLTIME PASSIVE MIN %u\n", |
| 2885 | (int)pCfg->nPassiveMinChnTime); |
| 2886 | return ret; |
| 2887 | } |
Rajesh Babu Prathipati | 0fd227e | 2014-07-05 12:50:00 +0530 | [diff] [blame] | 2888 | else if (strncmp(command, "GETDWELLTIME", 12) == 0) |
| 2889 | { |
| 2890 | *len = scnprintf(extra, n, "GETDWELLTIME %u \n", |
| 2891 | (int)pCfg->nActiveMaxChnTime); |
| 2892 | return ret; |
| 2893 | } |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 2894 | else |
| 2895 | { |
| 2896 | ret = -EINVAL; |
| 2897 | } |
| 2898 | |
| 2899 | return ret; |
| 2900 | } |
| 2901 | |
Dundi Raviteja | ae5adf4 | 2018-04-23 20:44:47 +0530 | [diff] [blame] | 2902 | /** |
| 2903 | * hdd_btc_get_dwell_time() - Get BTC dwell time parameters |
| 2904 | * @pCfg: Pointer to HDD context |
| 2905 | * @command: ASCII text command that is received |
| 2906 | * @extra: Pointer to copy data sent to user |
| 2907 | * @n: size of 'extra' buffer |
| 2908 | * @len: length copied to 'extra' buffer |
| 2909 | * |
| 2910 | * Driver commands: |
| 2911 | * wpa_cli DRIVER BTCGETDWELLTIME ESCO MAX |
| 2912 | * wpa_cli DRIVER BTCGETDWELLTIME ESCO MIN |
| 2913 | * wpa_cli DRIVER BTCGETDWELLTIME SCO MAX |
| 2914 | * wpa_cli DRIVER BTCGETDWELLTIME SCO MIN |
| 2915 | * |
| 2916 | * Return: 0 for success non-zero for failure |
| 2917 | */ |
| 2918 | |
| 2919 | static int hdd_btc_get_dwell_time(hdd_config_t *pCfg, tANI_U8 *command, |
| 2920 | char *extra, tANI_U8 n, tANI_U8 *len) |
| 2921 | { |
| 2922 | int ret = 0; |
| 2923 | |
| 2924 | if (!pCfg || !command || !extra || !len) |
| 2925 | { |
| 2926 | hddLog(LOGE, FL("Argument passsed for BTCGETDWELLTIME is incorrect")); |
| 2927 | ret = -EINVAL; |
| 2928 | return ret; |
| 2929 | } |
| 2930 | |
| 2931 | if (strncmp(command, "BTCGETDWELLTIME ESCO MAX", 24) == 0) |
| 2932 | { |
| 2933 | *len = scnprintf(extra, n, "BTCGETDWELLTIME ESCO MAX %u\n", |
| 2934 | (int)pCfg->max_chntime_btc_esco); |
| 2935 | return ret; |
| 2936 | } |
| 2937 | else if (strncmp(command, "BTCGETDWELLTIME ESCO MIN", 24) == 0) |
| 2938 | { |
| 2939 | *len = scnprintf(extra, n, "BTCGETDWELLTIME ESCO MIN %u\n", |
| 2940 | (int)pCfg->min_chntime_btc_esco); |
| 2941 | return ret; |
| 2942 | } |
| 2943 | else if (strncmp(command, "BTCGETDWELLTIME SCO MAX", 23) == 0) |
| 2944 | { |
| 2945 | *len = scnprintf(extra, n, "BTCGETDWELLTIME SCO MAX %u\n", |
| 2946 | (int)pCfg->max_chntime_btc_sco); |
| 2947 | return ret; |
| 2948 | } |
| 2949 | else if (strncmp(command, "BTCGETDWELLTIME SCO MIN", 23) == 0) |
| 2950 | { |
| 2951 | *len = scnprintf(extra, n, "BTCGETDWELLTIME SCO MIN %u\n", |
| 2952 | (int)pCfg->min_chntime_btc_sco); |
| 2953 | return ret; |
| 2954 | } |
| 2955 | else |
| 2956 | { |
| 2957 | ret = -EINVAL; |
| 2958 | } |
| 2959 | |
| 2960 | return ret; |
| 2961 | } |
| 2962 | |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 2963 | int hdd_drv_cmd_validate(tANI_U8 *command, int len) |
| 2964 | { |
| 2965 | if (command[len] != ' ') |
| 2966 | return -EINVAL; |
| 2967 | |
| 2968 | return 0; |
| 2969 | } |
| 2970 | |
Dundi Raviteja | ae5adf4 | 2018-04-23 20:44:47 +0530 | [diff] [blame] | 2971 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 2972 | |
| 2973 | /** |
| 2974 | * hdd_conc_get_dwell_time() - Get concurrency dwell time parameters |
| 2975 | * @pCfg: Pointer to HDD context |
| 2976 | * @command: ASCII text command that is received |
| 2977 | * @extra: Pointer to copy data sent to user |
| 2978 | * @n: size of 'extra' buffer |
| 2979 | * @len: length copied to 'extra' buffer |
| 2980 | * |
| 2981 | * Driver commands: |
| 2982 | * wpa_cli DRIVER CONCGETDWELLTIME ACTIVE MAX |
| 2983 | * wpa_cli DRIVER CONCGETDWELLTIME ACTIVE MIN |
| 2984 | * wpa_cli DRIVER CONCGETDWELLTIME PASSIVE MAX |
| 2985 | * wpa_cli DRIVER CONCGETDWELLTIME PASSIVE MIN |
| 2986 | * |
| 2987 | * Return: 0 for success non-zero for failure |
| 2988 | */ |
| 2989 | |
| 2990 | static int hdd_conc_get_dwell_time(hdd_config_t *pCfg, tANI_U8 *command, |
| 2991 | char *extra, tANI_U8 n, tANI_U8 *len) |
| 2992 | { |
| 2993 | int ret = 0; |
| 2994 | |
| 2995 | if (!pCfg || !command || !extra || !len) |
| 2996 | { |
| 2997 | hddLog(LOGE, FL("Argument passsed for CONCGETDWELLTIME is incorrect")); |
| 2998 | ret = -EINVAL; |
| 2999 | return ret; |
| 3000 | } |
| 3001 | |
| 3002 | if (strncmp(command, "CONCGETDWELLTIME ACTIVE MAX", 27) == 0) |
| 3003 | { |
| 3004 | *len = scnprintf(extra, n, "CONCGETDWELLTIME ACTIVE MAX %u\n", |
| 3005 | (int)pCfg->nActiveMaxChnTimeConc); |
| 3006 | return ret; |
| 3007 | } |
| 3008 | else if (strncmp(command, "CONCGETDWELLTIME ACTIVE MIN", 27) == 0) |
| 3009 | { |
| 3010 | *len = scnprintf(extra, n, "CONCGETDWELLTIME ACTIVE MIN %u\n", |
| 3011 | (int)pCfg->nActiveMinChnTimeConc); |
| 3012 | return ret; |
| 3013 | } |
| 3014 | else if (strncmp(command, "CONCGETDWELLTIME PASSIVE MAX", 28) == 0) |
| 3015 | { |
| 3016 | *len = scnprintf(extra, n, "CONCGETDWELLTIME PASSIVE MAX %u\n", |
| 3017 | (int)pCfg->nPassiveMaxChnTimeConc); |
| 3018 | return ret; |
| 3019 | } |
| 3020 | else if (strncmp(command, "CONCGETDWELLTIME PASSIVE MIN", 28) == 0) |
| 3021 | { |
| 3022 | *len = scnprintf(extra, n, "CONCGETDWELLTIME PASSIVE MIN %u\n", |
| 3023 | (int)pCfg->nPassiveMinChnTimeConc); |
| 3024 | return ret; |
| 3025 | } |
| 3026 | else |
| 3027 | { |
| 3028 | ret = -EINVAL; |
| 3029 | } |
| 3030 | |
| 3031 | return ret; |
| 3032 | } |
| 3033 | |
| 3034 | /** |
| 3035 | * hdd_conc_set_dwell_time() - Set concurrency dwell time parameters |
| 3036 | * @pAdapter: Adapter upon which the command was received |
| 3037 | * @command: ASCII text command that is received |
| 3038 | * |
| 3039 | * Driver commands: |
| 3040 | * wpa_cli DRIVER CONCSETDWELLTIME ACTIVE MAX <value> |
| 3041 | * wpa_cli DRIVER CONCSETDWELLTIME ACTIVE MIN <value> |
| 3042 | * wpa_cli DRIVER CONCSETDWELLTIME PASSIVE MAX <value |
| 3043 | * wpa_cli DRIVER CONCSETDWELLTIME PASSIVE MIN <value> |
| 3044 | * |
| 3045 | * Return: 0 for success non-zero for failure |
| 3046 | */ |
| 3047 | |
| 3048 | static int hdd_conc_set_dwell_time(hdd_adapter_t *pAdapter, tANI_U8 *command) |
| 3049 | { |
| 3050 | tHalHandle hHal; |
| 3051 | hdd_config_t *pCfg; |
| 3052 | tANI_U8 *value = command; |
| 3053 | int val = 0, ret = 0, temp = 0; |
| 3054 | tSmeConfigParams smeConfig; |
| 3055 | |
| 3056 | if (!pAdapter || !command || !(pCfg = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini) |
| 3057 | || !(hHal = (WLAN_HDD_GET_HAL_CTX(pAdapter)))) |
| 3058 | { |
| 3059 | hddLog(LOGE, FL("Argument passed for CONCSETDWELLTIME is incorrect")); |
| 3060 | ret = -EINVAL; |
| 3061 | return ret; |
| 3062 | } |
| 3063 | |
| 3064 | vos_mem_zero(&smeConfig, sizeof(smeConfig)); |
| 3065 | sme_GetConfigParam(hHal, &smeConfig); |
| 3066 | |
| 3067 | if (strncmp(command, "CONCSETDWELLTIME ACTIVE MAX", 27) == 0 ) |
| 3068 | { |
| 3069 | if (hdd_drv_cmd_validate(command, 27)) { |
| 3070 | hddLog(LOGE, FL("Invalid driver command")); |
| 3071 | return -EINVAL; |
| 3072 | } |
| 3073 | |
| 3074 | value = value + 28; |
| 3075 | temp = kstrtou32(value, 10, &val); |
| 3076 | if (temp != 0 || val < CFG_ACTIVE_MAX_CHANNEL_TIME_CONC_MIN || |
| 3077 | val > CFG_ACTIVE_MAX_CHANNEL_TIME_CONC_MAX) |
| 3078 | { |
| 3079 | hddLog(LOGE, FL("Argument passed for CONCSETDWELLTIME ACTIVE MAX is incorrect")); |
| 3080 | ret = -EFAULT; |
| 3081 | return ret; |
| 3082 | } |
| 3083 | pCfg->nActiveMaxChnTimeConc = val; |
| 3084 | smeConfig.csrConfig.nActiveMaxChnTimeConc = val; |
| 3085 | sme_UpdateConfig(hHal, &smeConfig); |
| 3086 | } |
| 3087 | else if (strncmp(command, "CONCSETDWELLTIME ACTIVE MIN", 27) == 0) |
| 3088 | { |
| 3089 | if (hdd_drv_cmd_validate(command, 27)) { |
| 3090 | hddLog(LOGE, FL("Invalid driver command")); |
| 3091 | return -EINVAL; |
| 3092 | } |
| 3093 | |
| 3094 | value = value + 28; |
| 3095 | temp = kstrtou32(value, 10, &val); |
| 3096 | if (temp !=0 || val < CFG_ACTIVE_MIN_CHANNEL_TIME_CONC_MIN || |
| 3097 | val > CFG_ACTIVE_MIN_CHANNEL_TIME_CONC_MAX) |
| 3098 | { |
| 3099 | hddLog(LOGE, FL("Argument passsed for CONCSETDWELLTIME ACTIVE MIN is incorrect")); |
| 3100 | ret = -EFAULT; |
| 3101 | return ret; |
| 3102 | } |
| 3103 | pCfg->nActiveMinChnTimeConc = val; |
| 3104 | smeConfig.csrConfig.nActiveMinChnTimeConc = val; |
| 3105 | sme_UpdateConfig(hHal, &smeConfig); |
| 3106 | } |
| 3107 | else if (strncmp(command, "CONCSETDWELLTIME PASSIVE MAX", 28) == 0) |
| 3108 | { |
| 3109 | if (hdd_drv_cmd_validate(command, 28)) { |
| 3110 | hddLog(LOGE, FL("Invalid driver command")); |
| 3111 | return -EINVAL; |
| 3112 | } |
| 3113 | |
| 3114 | value = value + 29; |
| 3115 | temp = kstrtou32(value, 10, &val); |
| 3116 | if (temp != 0 || val < CFG_PASSIVE_MAX_CHANNEL_TIME_CONC_MIN || |
| 3117 | val > CFG_PASSIVE_MAX_CHANNEL_TIME_CONC_MAX) |
| 3118 | { |
| 3119 | hddLog(LOGE, FL("Argument passed for CONCSETDWELLTIME PASSIVE MAX is incorrect")); |
| 3120 | ret = -EFAULT; |
| 3121 | return ret; |
| 3122 | } |
| 3123 | pCfg->nPassiveMaxChnTimeConc = val; |
| 3124 | smeConfig.csrConfig.nPassiveMaxChnTimeConc = val; |
| 3125 | sme_UpdateConfig(hHal, &smeConfig); |
| 3126 | } |
| 3127 | else if (strncmp(command, "CONCSETDWELLTIME PASSIVE MIN", 28) == 0) |
| 3128 | { |
| 3129 | if (hdd_drv_cmd_validate(command, 28)) { |
| 3130 | hddLog(LOGE, FL("Invalid driver command")); |
| 3131 | return -EINVAL; |
| 3132 | } |
| 3133 | |
| 3134 | value = value + 29; |
| 3135 | temp = kstrtou32(value, 10, &val); |
| 3136 | if (temp != 0 || val < CFG_PASSIVE_MIN_CHANNEL_TIME_CONC_MIN || |
| 3137 | val > CFG_PASSIVE_MIN_CHANNEL_TIME_CONC_MAX ) |
| 3138 | { |
| 3139 | hddLog(LOGE, FL("Argument passed for CONCSETDWELLTIME PASSIVE MIN is incorrect")); |
| 3140 | ret = -EFAULT; |
| 3141 | return ret; |
| 3142 | } |
| 3143 | pCfg->nPassiveMinChnTimeConc = val; |
| 3144 | smeConfig.csrConfig.nPassiveMinChnTimeConc = val; |
| 3145 | sme_UpdateConfig(hHal, &smeConfig); |
| 3146 | } |
| 3147 | else |
| 3148 | { |
| 3149 | ret = -EINVAL; |
| 3150 | } |
| 3151 | |
| 3152 | return ret; |
| 3153 | } |
| 3154 | |
| 3155 | #endif |
| 3156 | |
| 3157 | /** |
| 3158 | * hdd_btc_set_dwell_time() - Set BTC dwell time parameters |
| 3159 | * @pAdapter: Adapter upon which the command was received |
| 3160 | * @command: ASCII text command that is received |
| 3161 | * |
| 3162 | * Driver commands: |
| 3163 | * wpa_cli DRIVER BTCSETDWELLTIME ESCO MAX <value> |
| 3164 | * wpa_cli DRIVER BTCSETDWELLTIME ESCO MIN <value> |
| 3165 | * wpa_cli DRIVER BTCSETDWELLTIME SCO MAX <value> |
| 3166 | * wpa_cli DRIVER BTCSETDWELLTIME SCO MIN <value> |
| 3167 | * |
| 3168 | * Return: 0 for success non-zero for failure |
| 3169 | */ |
| 3170 | |
| 3171 | static int hdd_btc_set_dwell_time(hdd_adapter_t *pAdapter, tANI_U8 *command) |
| 3172 | { |
| 3173 | tHalHandle hHal; |
| 3174 | hdd_config_t *pCfg; |
| 3175 | tANI_U8 *value = command; |
| 3176 | int val = 0, ret = 0, temp = 0; |
| 3177 | tSmeConfigParams smeConfig; |
| 3178 | |
| 3179 | if (!pAdapter || !command || !(pCfg = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini) |
| 3180 | || !(hHal = (WLAN_HDD_GET_HAL_CTX(pAdapter)))) |
| 3181 | { |
| 3182 | hddLog(LOGE, FL("Argument passed for BTCSETDWELLTIME is incorrect")); |
| 3183 | ret = -EINVAL; |
| 3184 | return ret; |
| 3185 | } |
| 3186 | |
| 3187 | vos_mem_zero(&smeConfig, sizeof(smeConfig)); |
| 3188 | sme_GetConfigParam(hHal, &smeConfig); |
| 3189 | |
| 3190 | if (strncmp(command, "BTCSETDWELLTIME ESCO MAX", 24) == 0) |
| 3191 | { |
| 3192 | if (hdd_drv_cmd_validate(command, 24)) { |
| 3193 | hddLog(LOGE, FL("Invalid driver command")); |
| 3194 | return -EINVAL; |
| 3195 | } |
| 3196 | |
| 3197 | value = value + 25; |
| 3198 | temp = kstrtou32(value, 10, &val); |
| 3199 | if (temp != 0 || val < CFG_ACTIVE_MAX_CHANNEL_TIME_BTC_MIN || |
| 3200 | val > CFG_ACTIVE_MAX_CHANNEL_TIME_BTC_MAX) |
| 3201 | { |
| 3202 | hddLog(LOGE, FL("Argument passed for BTCSETDWELLTIME ESCO MAX is incorrect")); |
| 3203 | ret = -EFAULT; |
| 3204 | return ret; |
| 3205 | } |
| 3206 | pCfg->max_chntime_btc_esco = val; |
| 3207 | smeConfig.csrConfig.max_chntime_btc_esco = val; |
| 3208 | sme_UpdateConfig(hHal, &smeConfig); |
| 3209 | } |
| 3210 | else if (strncmp(command, "BTCSETDWELLTIME ESCO MIN", 24) == 0) |
| 3211 | { |
| 3212 | if (hdd_drv_cmd_validate(command, 24)) { |
| 3213 | hddLog(LOGE, FL("Invalid driver command")); |
| 3214 | return -EINVAL; |
| 3215 | } |
| 3216 | |
| 3217 | value = value + 25; |
| 3218 | temp = kstrtou32(value, 10, &val); |
| 3219 | if (temp !=0 || val < CFG_ACTIVE_MIN_CHANNEL_TIME_BTC_MIN || |
| 3220 | val > CFG_ACTIVE_MIN_CHANNEL_TIME_BTC_MAX) |
| 3221 | { |
| 3222 | hddLog(LOGE, FL("Argument passsed for BTCSETDWELLTIME ESCO MIN is incorrect")); |
| 3223 | ret = -EFAULT; |
| 3224 | return ret; |
| 3225 | } |
| 3226 | pCfg->min_chntime_btc_esco = val; |
| 3227 | smeConfig.csrConfig.min_chntime_btc_esco = val; |
| 3228 | sme_UpdateConfig(hHal, &smeConfig); |
| 3229 | } |
| 3230 | else if (strncmp(command, "BTCSETDWELLTIME SCO MAX", 23) == 0) |
| 3231 | { |
| 3232 | if (hdd_drv_cmd_validate(command, 23)) { |
| 3233 | hddLog(LOGE, FL("Invalid driver command")); |
| 3234 | return -EINVAL; |
| 3235 | } |
| 3236 | |
| 3237 | value = value + 24; |
| 3238 | temp = kstrtou32(value, 10, &val); |
| 3239 | if (temp != 0 || val < CFG_ACTIVE_MAX_CHANNEL_TIME_BTC_SCO_MIN || |
| 3240 | val > CFG_ACTIVE_MAX_CHANNEL_TIME_BTC_SCO_MAX) |
| 3241 | { |
| 3242 | hddLog(LOGE, FL("Argument passed for BTCSETDWELLTIME SCO MAX is incorrect")); |
| 3243 | ret = -EFAULT; |
| 3244 | return ret; |
| 3245 | } |
| 3246 | pCfg->max_chntime_btc_sco = val; |
| 3247 | smeConfig.csrConfig.max_chntime_btc_sco = val; |
| 3248 | sme_UpdateConfig(hHal, &smeConfig); |
| 3249 | } |
| 3250 | else if (strncmp(command, "BTCSETDWELLTIME SCO MIN", 23) == 0) |
| 3251 | { |
| 3252 | if (hdd_drv_cmd_validate(command, 23)) { |
| 3253 | hddLog(LOGE, FL("Invalid driver command")); |
| 3254 | return -EINVAL; |
| 3255 | } |
| 3256 | |
| 3257 | value = value + 24; |
| 3258 | temp = kstrtou32(value, 10, &val); |
| 3259 | if (temp != 0 || val < CFG_ACTIVE_MIN_CHANNEL_TIME_BTC_SCO_MIN || |
| 3260 | val > CFG_ACTIVE_MIN_CHANNEL_TIME_BTC_SCO_MAX) |
| 3261 | { |
| 3262 | hddLog(LOGE, FL("Argument passed for BTCSETDWELLTIME SCO MIN is incorrect")); |
| 3263 | ret = -EFAULT; |
| 3264 | return ret; |
| 3265 | } |
| 3266 | pCfg->min_chntime_btc_sco = val; |
| 3267 | smeConfig.csrConfig.min_chntime_btc_sco = val; |
| 3268 | sme_UpdateConfig(hHal, &smeConfig); |
| 3269 | } |
| 3270 | else |
| 3271 | { |
| 3272 | ret = -EINVAL; |
| 3273 | } |
| 3274 | |
| 3275 | return ret; |
| 3276 | } |
| 3277 | |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 3278 | static int hdd_set_dwell_time(hdd_adapter_t *pAdapter, tANI_U8 *command) |
| 3279 | { |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 3280 | tHalHandle hHal; |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 3281 | hdd_config_t *pCfg; |
| 3282 | tANI_U8 *value = command; |
| 3283 | int val = 0, ret = 0, temp = 0; |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 3284 | tSmeConfigParams smeConfig; |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 3285 | |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 3286 | if (!pAdapter || !command || !(pCfg = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini) |
| 3287 | || !(hHal = (WLAN_HDD_GET_HAL_CTX(pAdapter)))) |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 3288 | { |
| 3289 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3290 | "%s: argument passed for SETDWELLTIME is incorrect", __func__); |
| 3291 | ret = -EINVAL; |
| 3292 | return ret; |
| 3293 | } |
| 3294 | |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 3295 | vos_mem_zero(&smeConfig, sizeof(smeConfig)); |
| 3296 | sme_GetConfigParam(hHal, &smeConfig); |
| 3297 | |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 3298 | if (strncmp(command, "SETDWELLTIME ACTIVE MAX", 23) == 0 ) |
| 3299 | { |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 3300 | if (hdd_drv_cmd_validate(command, 23)) |
| 3301 | return -EINVAL; |
| 3302 | |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 3303 | value = value + 24; |
| 3304 | temp = kstrtou32(value, 10, &val); |
| 3305 | if (temp != 0 || val < CFG_ACTIVE_MAX_CHANNEL_TIME_MIN || |
| 3306 | val > CFG_ACTIVE_MAX_CHANNEL_TIME_MAX ) |
| 3307 | { |
| 3308 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3309 | "%s: argument passed for SETDWELLTIME ACTIVE MAX is incorrect", __func__); |
| 3310 | ret = -EFAULT; |
| 3311 | return ret; |
| 3312 | } |
| 3313 | pCfg->nActiveMaxChnTime = val; |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 3314 | smeConfig.csrConfig.nActiveMaxChnTime = val; |
| 3315 | sme_UpdateConfig(hHal, &smeConfig); |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 3316 | } |
| 3317 | else if (strncmp(command, "SETDWELLTIME ACTIVE MIN", 23) == 0) |
| 3318 | { |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 3319 | if (hdd_drv_cmd_validate(command, 23)) |
| 3320 | return -EINVAL; |
| 3321 | |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 3322 | value = value + 24; |
| 3323 | temp = kstrtou32(value, 10, &val); |
| 3324 | if (temp !=0 || val < CFG_ACTIVE_MIN_CHANNEL_TIME_MIN || |
| 3325 | val > CFG_ACTIVE_MIN_CHANNEL_TIME_MAX ) |
| 3326 | { |
| 3327 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3328 | "%s: argument passsed for SETDWELLTIME ACTIVE MIN is incorrect", __func__); |
| 3329 | ret = -EFAULT; |
| 3330 | return ret; |
| 3331 | } |
| 3332 | pCfg->nActiveMinChnTime = val; |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 3333 | smeConfig.csrConfig.nActiveMinChnTime = val; |
| 3334 | sme_UpdateConfig(hHal, &smeConfig); |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 3335 | } |
| 3336 | else if (strncmp(command, "SETDWELLTIME PASSIVE MAX", 24) == 0) |
| 3337 | { |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 3338 | if (hdd_drv_cmd_validate(command, 24)) |
| 3339 | return -EINVAL; |
| 3340 | |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 3341 | value = value + 25; |
| 3342 | temp = kstrtou32(value, 10, &val); |
| 3343 | if (temp != 0 || val < CFG_PASSIVE_MAX_CHANNEL_TIME_MIN || |
| 3344 | val > CFG_PASSIVE_MAX_CHANNEL_TIME_MAX ) |
| 3345 | { |
| 3346 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3347 | "%s: argument passed for SETDWELLTIME PASSIVE MAX is incorrect", __func__); |
| 3348 | ret = -EFAULT; |
| 3349 | return ret; |
| 3350 | } |
| 3351 | pCfg->nPassiveMaxChnTime = val; |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 3352 | smeConfig.csrConfig.nPassiveMaxChnTime = val; |
| 3353 | sme_UpdateConfig(hHal, &smeConfig); |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 3354 | } |
| 3355 | else if (strncmp(command, "SETDWELLTIME PASSIVE MIN", 24) == 0) |
| 3356 | { |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 3357 | if (hdd_drv_cmd_validate(command, 24)) |
| 3358 | return -EINVAL; |
| 3359 | |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 3360 | value = value + 25; |
| 3361 | temp = kstrtou32(value, 10, &val); |
| 3362 | if (temp != 0 || val < CFG_PASSIVE_MIN_CHANNEL_TIME_MIN || |
| 3363 | val > CFG_PASSIVE_MIN_CHANNEL_TIME_MAX ) |
| 3364 | { |
| 3365 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3366 | "%s: argument passed for SETDWELLTIME PASSIVE MIN is incorrect", __func__); |
| 3367 | ret = -EFAULT; |
| 3368 | return ret; |
| 3369 | } |
| 3370 | pCfg->nPassiveMinChnTime = val; |
Rajesh Babu Prathipati | b09815c | 2014-07-05 11:22:24 +0530 | [diff] [blame] | 3371 | smeConfig.csrConfig.nPassiveMinChnTime = val; |
| 3372 | sme_UpdateConfig(hHal, &smeConfig); |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 3373 | } |
Rajesh Babu Prathipati | 0fd227e | 2014-07-05 12:50:00 +0530 | [diff] [blame] | 3374 | else if (strncmp(command, "SETDWELLTIME", 12) == 0) |
| 3375 | { |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 3376 | if (hdd_drv_cmd_validate(command, 12)) |
| 3377 | return -EINVAL; |
| 3378 | |
Rajesh Babu Prathipati | 0fd227e | 2014-07-05 12:50:00 +0530 | [diff] [blame] | 3379 | value = value + 13; |
| 3380 | temp = kstrtou32(value, 10, &val); |
| 3381 | if (temp != 0 || val < CFG_ACTIVE_MAX_CHANNEL_TIME_MIN || |
| 3382 | val > CFG_ACTIVE_MAX_CHANNEL_TIME_MAX ) |
| 3383 | { |
| 3384 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3385 | "%s: argument passed for SETDWELLTIME is incorrect", __func__); |
| 3386 | ret = -EFAULT; |
| 3387 | return ret; |
| 3388 | } |
| 3389 | pCfg->nActiveMaxChnTime = val; |
| 3390 | smeConfig.csrConfig.nActiveMaxChnTime = val; |
| 3391 | sme_UpdateConfig(hHal, &smeConfig); |
| 3392 | } |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 3393 | else |
| 3394 | { |
| 3395 | ret = -EINVAL; |
| 3396 | } |
| 3397 | |
| 3398 | return ret; |
| 3399 | } |
Agarwal Ashish | 8bd53ae | 2015-06-12 18:03:45 +0530 | [diff] [blame] | 3400 | static int hdd_cmd_setFccChannel(hdd_context_t *pHddCtx, tANI_U8 *cmd, |
| 3401 | tANI_U8 cmd_len) |
| 3402 | { |
| 3403 | tANI_U8 *value; |
| 3404 | tANI_U8 fcc_constraint; |
| 3405 | |
| 3406 | eHalStatus status; |
| 3407 | int ret = 0; |
| 3408 | value = cmd + cmd_len + 1; |
| 3409 | |
| 3410 | ret = kstrtou8(value, 10, &fcc_constraint); |
| 3411 | if ((ret < 0) || (fcc_constraint > 1)) { |
| 3412 | /* |
| 3413 | * If the input value is greater than max value of datatype, |
| 3414 | * then also it is a failure |
| 3415 | */ |
| 3416 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3417 | "%s: value out of range", __func__); |
| 3418 | return -EINVAL; |
| 3419 | } |
| 3420 | |
Agrawal Ashish | 842eea8 | 2016-02-04 17:56:16 +0530 | [diff] [blame] | 3421 | status = sme_handleSetFccChannel(pHddCtx->hHal, fcc_constraint, |
| 3422 | pHddCtx->scan_info.mScanPending); |
Agarwal Ashish | 8bd53ae | 2015-06-12 18:03:45 +0530 | [diff] [blame] | 3423 | if (status != eHAL_STATUS_SUCCESS) |
| 3424 | ret = -EPERM; |
| 3425 | |
| 3426 | return ret; |
| 3427 | } |
| 3428 | |
Mahesh A Saptasagar | beca12c | 2015-09-07 16:21:06 +0530 | [diff] [blame] | 3429 | /**--------------------------------------------------------------------------- |
Agarwal Ashish | 8bd53ae | 2015-06-12 18:03:45 +0530 | [diff] [blame] | 3430 | |
Mahesh A Saptasagar | beca12c | 2015-09-07 16:21:06 +0530 | [diff] [blame] | 3431 | \brief hdd_enable_disable_ca_event() - When Host sends IOCTL (enabled), |
| 3432 | FW will send *ONE* CA ind to Host(even though it is duplicate). |
| 3433 | When Host send IOCTL (disable), FW doesn't perform any action. |
| 3434 | Whenever any change in CA *and* WLAN is in SAP/P2P-GO mode, FW |
| 3435 | sends CA ind to host. (regard less of IOCTL status) |
| 3436 | \param - pHddCtx - HDD context |
| 3437 | \param - command - command received from framework |
| 3438 | \param - cmd_len - len of the command |
| 3439 | |
| 3440 | \return - 0 on success, appropriate error values on failure. |
| 3441 | |
| 3442 | --------------------------------------------------------------------------*/ |
| 3443 | int hdd_enable_disable_ca_event(hdd_context_t *pHddCtx, tANI_U8* command, tANI_U8 cmd_len) |
| 3444 | { |
| 3445 | tANI_U8 set_value; |
| 3446 | int ret = 0; |
| 3447 | eHalStatus status; |
| 3448 | |
| 3449 | ret = wlan_hdd_validate_context(pHddCtx); |
| 3450 | if (0 != ret) |
| 3451 | { |
| 3452 | ret = -EINVAL; |
| 3453 | goto exit; |
| 3454 | } |
| 3455 | |
| 3456 | if (pHddCtx->cfg_ini->gOptimizeCAevent == 0) |
| 3457 | { |
| 3458 | hddLog(VOS_TRACE_LEVEL_ERROR, "Enable gOptimizeCAevent" |
| 3459 | " ini param to control channel avooidance indication"); |
| 3460 | ret = 0; |
| 3461 | goto exit; |
| 3462 | } |
| 3463 | |
| 3464 | set_value = command[cmd_len + 1] - '0'; |
| 3465 | status = sme_enableDisableChanAvoidIndEvent(pHddCtx->hHal, set_value); |
| 3466 | if (status != eHAL_STATUS_SUCCESS) |
| 3467 | { |
| 3468 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failed to send" |
| 3469 | " enableDisableChanAoidance command to SME\n", __func__); |
| 3470 | ret = -EINVAL; |
| 3471 | } |
| 3472 | |
| 3473 | exit: |
| 3474 | return ret; |
| 3475 | } |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 3476 | |
Selvaraj, Sridhar | 3714c4d | 2016-06-22 15:19:12 +0530 | [diff] [blame] | 3477 | /** |
| 3478 | * wlan_hdd_fastreassoc_handoff_request() - Post Handoff request to SME |
| 3479 | * @pHddCtx: Pointer to the HDD context |
| 3480 | * @channel: channel to reassociate |
| 3481 | * @targetApBssid: Target AP/BSSID to reassociate |
| 3482 | * |
| 3483 | * Return: None |
| 3484 | */ |
| 3485 | #if defined(WLAN_FEATURE_ROAM_SCAN_OFFLOAD) && !defined(QCA_WIFI_ISOC) |
| 3486 | static void wlan_hdd_fastreassoc_handoff_request(hdd_context_t *pHddCtx, |
| 3487 | uint8_t channel, tSirMacAddr targetApBssid) |
| 3488 | { |
| 3489 | tCsrHandoffRequest handoffInfo; |
| 3490 | handoffInfo.channel = channel; |
| 3491 | handoffInfo.src = FASTREASSOC; |
| 3492 | vos_mem_copy(handoffInfo.bssid, targetApBssid, sizeof(tSirMacAddr)); |
| 3493 | sme_HandoffRequest(pHddCtx->hHal, &handoffInfo); |
| 3494 | } |
| 3495 | #else |
| 3496 | static void wlan_hdd_fastreassoc_handoff_request(hdd_context_t *pHddCtx, |
| 3497 | uint8_t channel, tSirMacAddr targetApBssid) |
| 3498 | { |
| 3499 | } |
| 3500 | #endif |
| 3501 | |
| 3502 | /** |
| 3503 | * csr_fastroam_neighbor_ap_event() - Function to trigger scan/roam |
| 3504 | * @pAdapter: Pointer to HDD adapter |
| 3505 | * @channel: Channel to scan/roam |
| 3506 | * @targetApBssid: BSSID to roam |
| 3507 | * |
| 3508 | * Return: None |
| 3509 | */ |
| 3510 | #ifdef QCA_WIFI_ISOC |
| 3511 | static void csr_fastroam_neighbor_ap_event(hdd_adapter_t *pAdapter, |
| 3512 | uint8_t channel, tSirMacAddr targetApBssid) |
| 3513 | { |
| 3514 | smeIssueFastRoamNeighborAPEvent(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 3515 | &targetApBssid[0], eSME_ROAM_TRIGGER_SCAN, channel); |
| 3516 | } |
| 3517 | #else |
| 3518 | static void csr_fastroam_neighbor_ap_event(hdd_adapter_t *pAdapter, |
| 3519 | uint8_t channel, tSirMacAddr targetApBssid) |
| 3520 | { |
| 3521 | } |
| 3522 | #endif |
| 3523 | |
| 3524 | /** |
| 3525 | * wlan_hdd_handle_fastreassoc() - Handle fastreassoc command |
| 3526 | * @pAdapter: pointer to hdd adapter |
| 3527 | * @command: pointer to the command received |
| 3528 | * |
| 3529 | * Return: VOS_STATUS enum |
| 3530 | */ |
| 3531 | static VOS_STATUS wlan_hdd_handle_fastreassoc(hdd_adapter_t *pAdapter, |
| 3532 | uint8_t *command) |
| 3533 | { |
| 3534 | tANI_U8 *value = command; |
| 3535 | tANI_U8 channel = 0; |
| 3536 | tSirMacAddr targetApBssid; |
Selvaraj, Sridhar | 3714c4d | 2016-06-22 15:19:12 +0530 | [diff] [blame] | 3537 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 3538 | hdd_context_t *pHddCtx = NULL; |
Selvaraj, Sridhar | 5aff1ed | 2016-06-18 01:26:23 +0530 | [diff] [blame] | 3539 | int ret; |
Selvaraj, Sridhar | 349b8fe | 2017-01-18 13:11:25 +0530 | [diff] [blame] | 3540 | tCsrRoamModifyProfileFields mod_profile_fields; |
| 3541 | uint32_t roam_id = 0; |
Selvaraj, Sridhar | 3714c4d | 2016-06-22 15:19:12 +0530 | [diff] [blame] | 3542 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3543 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 3544 | |
| 3545 | /* if not associated, no need to proceed with reassoc */ |
| 3546 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) { |
| 3547 | hddLog(LOG1, FL("Not associated!")); |
| 3548 | return eHAL_STATUS_FAILURE; |
| 3549 | } |
| 3550 | |
Selvaraj, Sridhar | 5aff1ed | 2016-06-18 01:26:23 +0530 | [diff] [blame] | 3551 | ret = hdd_parse_reassoc_command_v1_data(value, targetApBssid, &channel); |
| 3552 | if (ret) { |
Selvaraj, Sridhar | 3714c4d | 2016-06-22 15:19:12 +0530 | [diff] [blame] | 3553 | hddLog(LOGE, FL("Failed to parse reassoc command data")); |
| 3554 | return eHAL_STATUS_FAILURE; |
| 3555 | } |
| 3556 | |
| 3557 | /* if the target bssid is same as currently associated AP, |
| 3558 | then no need to proceed with reassoc */ |
| 3559 | if (vos_mem_compare(targetApBssid, |
| 3560 | pHddStaCtx->conn_info.bssId, |
| 3561 | sizeof(tSirMacAddr))) { |
Selvaraj, Sridhar | 349b8fe | 2017-01-18 13:11:25 +0530 | [diff] [blame] | 3562 | sme_GetModifyProfileFields(pHddCtx->hHal, pAdapter->sessionId, |
| 3563 | &mod_profile_fields); |
| 3564 | sme_RoamReassoc(pHddCtx->hHal, pAdapter->sessionId, NULL, |
| 3565 | mod_profile_fields, &roam_id, 1); |
Selvaraj, Sridhar | 3714c4d | 2016-06-22 15:19:12 +0530 | [diff] [blame] | 3566 | hddLog(LOG1, FL("Reassoc BSSID is same as currently associated AP bssid")); |
Selvaraj, Sridhar | 349b8fe | 2017-01-18 13:11:25 +0530 | [diff] [blame] | 3567 | return eHAL_STATUS_SUCCESS; |
Selvaraj, Sridhar | 3714c4d | 2016-06-22 15:19:12 +0530 | [diff] [blame] | 3568 | } |
| 3569 | |
| 3570 | /* Check channel number is a valid channel number */ |
| 3571 | if (VOS_STATUS_SUCCESS != |
| 3572 | wlan_hdd_validate_operation_channel(pAdapter, channel)) { |
| 3573 | hddLog(LOGE, FL("Invalid Channel [%d]"), channel); |
| 3574 | return eHAL_STATUS_FAILURE; |
| 3575 | } |
| 3576 | |
| 3577 | /* Proceed with reassoc */ |
| 3578 | wlan_hdd_fastreassoc_handoff_request(pHddCtx, channel, targetApBssid); |
| 3579 | |
| 3580 | /* Proceed with scan/roam */ |
| 3581 | csr_fastroam_neighbor_ap_event(pAdapter, channel, targetApBssid); |
| 3582 | |
| 3583 | return eHAL_STATUS_SUCCESS; |
| 3584 | } |
| 3585 | |
| 3586 | /** |
| 3587 | * hdd_assign_reassoc_handoff - Set handoff source as REASSOC |
| 3588 | * @handoffInfo: Pointer to the csr Handoff Request. |
| 3589 | * |
| 3590 | * Return: None |
| 3591 | */ |
| 3592 | #ifndef QCA_WIFI_ISOC |
| 3593 | static inline void hdd_assign_reassoc_handoff(tCsrHandoffRequest *handoffInfo) |
| 3594 | { |
| 3595 | handoffInfo->src = REASSOC; |
| 3596 | } |
| 3597 | #else |
| 3598 | static inline void hdd_assign_reassoc_handoff(tCsrHandoffRequest *handoffInfo) |
| 3599 | { |
| 3600 | } |
| 3601 | #endif |
| 3602 | |
Ashish Kumar Dhanotiya | 32d092b | 2018-02-20 21:43:57 +0530 | [diff] [blame] | 3603 | /** |
| 3604 | * wlan_hdd_free_cache_channels() - Free the cache channels list |
| 3605 | * @hdd_ctx: Pointer to HDD context |
| 3606 | * |
| 3607 | * Return: None |
| 3608 | */ |
| 3609 | |
| 3610 | static void wlan_hdd_free_cache_channels(hdd_context_t *hdd_ctx) |
| 3611 | { |
Ashish Kumar Dhanotiya | 1980383 | 2018-05-24 19:05:48 +0530 | [diff] [blame] | 3612 | if(!hdd_ctx || !hdd_ctx->original_channels) |
| 3613 | return; |
| 3614 | |
Ashish Kumar Dhanotiya | 32d092b | 2018-02-20 21:43:57 +0530 | [diff] [blame] | 3615 | mutex_lock(&hdd_ctx->cache_channel_lock); |
Ashish Kumar Dhanotiya | 95e5bc2 | 2018-04-19 17:06:33 +0530 | [diff] [blame] | 3616 | hdd_ctx->original_channels->num_channels = 0; |
| 3617 | vos_mem_free(hdd_ctx->original_channels->channel_info); |
| 3618 | hdd_ctx->original_channels->channel_info = NULL; |
| 3619 | vos_mem_free(hdd_ctx->original_channels); |
| 3620 | hdd_ctx->original_channels = NULL; |
Ashish Kumar Dhanotiya | 32d092b | 2018-02-20 21:43:57 +0530 | [diff] [blame] | 3621 | mutex_unlock(&hdd_ctx->cache_channel_lock); |
| 3622 | } |
| 3623 | |
| 3624 | /** |
| 3625 | * hdd_alloc_chan_cache() - Allocate the memory to cache the channel |
| 3626 | * info for the channels received in command SET_DISABLE_CHANNEL_LIST |
| 3627 | * @hdd_ctx: Pointer to HDD context |
| 3628 | * @num_chan: Number of channels for which memory needs to |
| 3629 | * be allocated |
| 3630 | * |
| 3631 | * Return: 0 on success and error code on failure |
| 3632 | */ |
| 3633 | |
| 3634 | int hdd_alloc_chan_cache(hdd_context_t *hdd_ctx, int num_chan) |
| 3635 | { |
Ashish Kumar Dhanotiya | 95e5bc2 | 2018-04-19 17:06:33 +0530 | [diff] [blame] | 3636 | hdd_ctx->original_channels = |
Ashish Kumar Dhanotiya | 32d092b | 2018-02-20 21:43:57 +0530 | [diff] [blame] | 3637 | vos_mem_malloc(sizeof(struct hdd_cache_channels)); |
Ashish Kumar Dhanotiya | 95e5bc2 | 2018-04-19 17:06:33 +0530 | [diff] [blame] | 3638 | if (!hdd_ctx->original_channels) { |
| 3639 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3640 | "In %s, VOS_MALLOC_ERR", __func__); |
| 3641 | return -EINVAL; |
| 3642 | } |
| 3643 | hdd_ctx->original_channels->num_channels = num_chan; |
| 3644 | hdd_ctx->original_channels->channel_info = |
Ashish Kumar Dhanotiya | 32d092b | 2018-02-20 21:43:57 +0530 | [diff] [blame] | 3645 | vos_mem_malloc(num_chan * |
| 3646 | sizeof(struct hdd_cache_channel_info)); |
Ashish Kumar Dhanotiya | 95e5bc2 | 2018-04-19 17:06:33 +0530 | [diff] [blame] | 3647 | if (!hdd_ctx->original_channels->channel_info) { |
| 3648 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3649 | "In %s, VOS_MALLOC_ERR", __func__); |
| 3650 | hdd_ctx->original_channels->num_channels = 0; |
| 3651 | vos_mem_free(hdd_ctx->original_channels); |
| 3652 | hdd_ctx->original_channels = NULL; |
| 3653 | return -ENOMEM; |
Ashish Kumar Dhanotiya | 32d092b | 2018-02-20 21:43:57 +0530 | [diff] [blame] | 3654 | } |
| 3655 | return 0; |
| 3656 | |
| 3657 | } |
| 3658 | |
| 3659 | |
| 3660 | int hdd_parse_disable_chan_cmd(hdd_adapter_t *adapter, tANI_U8 *ptr) |
| 3661 | { |
| 3662 | v_PVOID_t pvosGCtx = vos_get_global_context(VOS_MODULE_ID_HDD, NULL); |
| 3663 | hdd_context_t *hdd_ctx = vos_get_context(VOS_MODULE_ID_HDD, pvosGCtx); |
| 3664 | tANI_U8 *param; |
Ashish Kumar Dhanotiya | 95e5bc2 | 2018-04-19 17:06:33 +0530 | [diff] [blame] | 3665 | int j, tempInt, ret = 0, i, num_channels; |
| 3666 | int parsed_channels[MAX_CHANNEL]; |
| 3667 | bool is_command_repeated = false; |
Ashish Kumar Dhanotiya | 32d092b | 2018-02-20 21:43:57 +0530 | [diff] [blame] | 3668 | |
| 3669 | if (NULL == pvosGCtx) { |
| 3670 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 3671 | "VOS Global Context is NULL"); |
| 3672 | return -EINVAL; |
| 3673 | } |
| 3674 | |
| 3675 | if (NULL == hdd_ctx) { |
| 3676 | hddLog(VOS_TRACE_LEVEL_FATAL, "HDD Context is NULL"); |
| 3677 | return -EINVAL; |
| 3678 | } |
| 3679 | |
| 3680 | param = strchr(ptr, ' '); |
| 3681 | /*no argument after the command*/ |
| 3682 | if (NULL == param) |
| 3683 | return -EINVAL; |
| 3684 | |
| 3685 | /*no space after the command*/ |
| 3686 | else if (SPACE_ASCII_VALUE != *param) |
| 3687 | return -EINVAL; |
| 3688 | |
| 3689 | param++; |
| 3690 | |
| 3691 | /*removing empty spaces*/ |
| 3692 | while ((SPACE_ASCII_VALUE == *param) && ('\0' != *param)) |
| 3693 | param++; |
| 3694 | |
| 3695 | /*no argument followed by spaces*/ |
| 3696 | if ('\0' == *param) |
| 3697 | return -EINVAL; |
| 3698 | |
| 3699 | /*getting the first argument ie the number of channels*/ |
| 3700 | if (sscanf(param, "%d ", &tempInt) != 1) { |
| 3701 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3702 | "%s: Cannot get number of channels from input", |
| 3703 | __func__); |
| 3704 | return -EINVAL; |
| 3705 | } |
| 3706 | |
| 3707 | if (tempInt < 0 || tempInt > MAX_CHANNEL) { |
| 3708 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3709 | "%s: Invalid Number of channel received", __func__); |
| 3710 | return -EINVAL; |
| 3711 | } |
| 3712 | |
| 3713 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, |
| 3714 | "%s: Number of channel to disable are: %d", |
| 3715 | __func__, tempInt); |
| 3716 | |
| 3717 | if (!tempInt) { |
| 3718 | if (!wlan_hdd_restore_channels(hdd_ctx)) { |
| 3719 | /* |
| 3720 | * Free the cache channels only when the command is |
| 3721 | * received with num channels as 0 |
| 3722 | */ |
| 3723 | wlan_hdd_free_cache_channels(hdd_ctx); |
| 3724 | } |
| 3725 | return 0; |
| 3726 | } |
| 3727 | |
| 3728 | mutex_lock(&hdd_ctx->cache_channel_lock); |
Ashish Kumar Dhanotiya | 95e5bc2 | 2018-04-19 17:06:33 +0530 | [diff] [blame] | 3729 | if (!hdd_ctx->original_channels) { |
| 3730 | if (hdd_alloc_chan_cache(hdd_ctx, tempInt)) { |
| 3731 | ret = -ENOMEM; |
| 3732 | goto mem_alloc_failed; |
| 3733 | } |
| 3734 | } else if (hdd_ctx->original_channels->num_channels != tempInt) { |
| 3735 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3736 | "%s, Invalid No of channel provided in the list", |
| 3737 | __func__); |
| 3738 | ret = -EINVAL; |
| 3739 | is_command_repeated = true; |
| 3740 | goto parse_failed; |
| 3741 | } else { |
| 3742 | is_command_repeated = true; |
Ashish Kumar Dhanotiya | 32d092b | 2018-02-20 21:43:57 +0530 | [diff] [blame] | 3743 | } |
Ashish Kumar Dhanotiya | 32d092b | 2018-02-20 21:43:57 +0530 | [diff] [blame] | 3744 | |
Ashish Kumar Dhanotiya | 95e5bc2 | 2018-04-19 17:06:33 +0530 | [diff] [blame] | 3745 | num_channels = tempInt; |
| 3746 | |
| 3747 | for (j = 0; j < num_channels; j++) { |
Ashish Kumar Dhanotiya | 32d092b | 2018-02-20 21:43:57 +0530 | [diff] [blame] | 3748 | /* |
| 3749 | * param pointing to the beginning of first space |
| 3750 | * after number of channels |
| 3751 | */ |
| 3752 | param = strpbrk(param, " "); |
| 3753 | /*no channel list after the number of channels argument*/ |
| 3754 | if (NULL == param) { |
| 3755 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3756 | "%s, Invalid No of channel provided in the list", |
| 3757 | __func__); |
| 3758 | ret = -EINVAL; |
Ashish Kumar Dhanotiya | 95e5bc2 | 2018-04-19 17:06:33 +0530 | [diff] [blame] | 3759 | goto parse_failed; |
Ashish Kumar Dhanotiya | 32d092b | 2018-02-20 21:43:57 +0530 | [diff] [blame] | 3760 | } |
| 3761 | |
| 3762 | param++; |
| 3763 | |
| 3764 | /*removing empty space*/ |
| 3765 | while ((SPACE_ASCII_VALUE == *param) && ('\0' != *param)) |
| 3766 | param++; |
| 3767 | |
| 3768 | if ('\0' == *param) { |
| 3769 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3770 | "%s, No channel is provided in the list", |
| 3771 | __func__); |
| 3772 | ret = -EINVAL; |
Ashish Kumar Dhanotiya | 95e5bc2 | 2018-04-19 17:06:33 +0530 | [diff] [blame] | 3773 | goto parse_failed; |
Ashish Kumar Dhanotiya | 32d092b | 2018-02-20 21:43:57 +0530 | [diff] [blame] | 3774 | |
| 3775 | } |
| 3776 | |
| 3777 | if (sscanf(param, "%d ", &tempInt) != 1) { |
| 3778 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3779 | "%s: Cannot read channel number", |
| 3780 | __func__); |
| 3781 | ret = -EINVAL; |
Ashish Kumar Dhanotiya | 95e5bc2 | 2018-04-19 17:06:33 +0530 | [diff] [blame] | 3782 | goto parse_failed; |
Ashish Kumar Dhanotiya | 32d092b | 2018-02-20 21:43:57 +0530 | [diff] [blame] | 3783 | |
| 3784 | } |
| 3785 | |
| 3786 | if (!IS_CHANNEL_VALID(tempInt)) { |
| 3787 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3788 | "%s: Invalid channel number received", |
| 3789 | __func__); |
| 3790 | ret = -EINVAL; |
Ashish Kumar Dhanotiya | 95e5bc2 | 2018-04-19 17:06:33 +0530 | [diff] [blame] | 3791 | goto parse_failed; |
Ashish Kumar Dhanotiya | 32d092b | 2018-02-20 21:43:57 +0530 | [diff] [blame] | 3792 | |
| 3793 | } |
| 3794 | |
| 3795 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: channel[%d] = %d", __func__, |
| 3796 | j, tempInt); |
Ashish Kumar Dhanotiya | 95e5bc2 | 2018-04-19 17:06:33 +0530 | [diff] [blame] | 3797 | |
| 3798 | parsed_channels[j] = tempInt; |
Ashish Kumar Dhanotiya | 32d092b | 2018-02-20 21:43:57 +0530 | [diff] [blame] | 3799 | } |
| 3800 | |
| 3801 | /*extra arguments check*/ |
| 3802 | param = strchr(param, ' '); |
| 3803 | if (NULL != param) { |
| 3804 | while ((SPACE_ASCII_VALUE == *param) && ('\0' != *param)) |
| 3805 | param++; |
| 3806 | |
| 3807 | if ('\0' != *param) { |
| 3808 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3809 | "%s: Invalid argument received", __func__); |
| 3810 | ret = -EINVAL; |
Ashish Kumar Dhanotiya | 95e5bc2 | 2018-04-19 17:06:33 +0530 | [diff] [blame] | 3811 | goto parse_failed; |
Ashish Kumar Dhanotiya | 32d092b | 2018-02-20 21:43:57 +0530 | [diff] [blame] | 3812 | } |
| 3813 | } |
| 3814 | |
Ashish Kumar Dhanotiya | 95e5bc2 | 2018-04-19 17:06:33 +0530 | [diff] [blame] | 3815 | /* |
| 3816 | * If command is received first time, cache the channels to |
| 3817 | * be disabled else compare the channels received in the |
| 3818 | * command with the cached channels, if channel list matches |
| 3819 | * return success otherewise return failure. |
| 3820 | */ |
| 3821 | if (!is_command_repeated) |
| 3822 | for (j = 0; j < num_channels; j++) |
| 3823 | hdd_ctx->original_channels-> |
| 3824 | channel_info[j].channel_num = |
| 3825 | parsed_channels[j]; |
| 3826 | else { |
| 3827 | for (i = 0; i < num_channels; i++) { |
| 3828 | for (j = 0; j < num_channels; j++) |
| 3829 | if (hdd_ctx->original_channels-> |
| 3830 | channel_info[i].channel_num == |
| 3831 | parsed_channels[j]) |
| 3832 | break; |
| 3833 | if (j == num_channels) { |
| 3834 | ret = -EINVAL; |
| 3835 | goto parse_failed; |
| 3836 | } |
| 3837 | } |
| 3838 | ret = 0; |
| 3839 | } |
| 3840 | |
| 3841 | mem_alloc_failed: |
Ashish Kumar Dhanotiya | 32d092b | 2018-02-20 21:43:57 +0530 | [diff] [blame] | 3842 | mutex_unlock(&hdd_ctx->cache_channel_lock); |
Ashish Kumar Dhanotiya | 1cf97dd | 2019-03-11 16:59:25 +0530 | [diff] [blame] | 3843 | /* Disable the channels received in command SET_DISABLE_CHANNEL_LIST*/ |
| 3844 | if (!is_command_repeated) { |
| 3845 | wlan_hdd_disable_channels(hdd_ctx); |
| 3846 | hdd_check_and_disconnect_sta_on_invalid_channel(hdd_ctx); |
| 3847 | } |
| 3848 | |
Ashish Kumar Dhanotiya | 32d092b | 2018-02-20 21:43:57 +0530 | [diff] [blame] | 3849 | EXIT(); |
| 3850 | |
| 3851 | return ret; |
Ashish Kumar Dhanotiya | 95e5bc2 | 2018-04-19 17:06:33 +0530 | [diff] [blame] | 3852 | |
| 3853 | parse_failed: |
| 3854 | mutex_unlock(&hdd_ctx->cache_channel_lock); |
| 3855 | if (!is_command_repeated) |
| 3856 | wlan_hdd_free_cache_channels(hdd_ctx); |
| 3857 | EXIT(); |
| 3858 | return ret; |
| 3859 | |
Ashish Kumar Dhanotiya | 32d092b | 2018-02-20 21:43:57 +0530 | [diff] [blame] | 3860 | } |
| 3861 | |
Hanumanth Reddy Pothula | 8ae38bb | 2018-03-07 18:59:30 +0530 | [diff] [blame] | 3862 | int hdd_get_disable_ch_list(hdd_context_t *hdd_ctx, tANI_U8 *buf, |
Ashish Kumar Dhanotiya | 95e5bc2 | 2018-04-19 17:06:33 +0530 | [diff] [blame] | 3863 | uint32_t buf_len) |
Hanumanth Reddy Pothula | 8ae38bb | 2018-03-07 18:59:30 +0530 | [diff] [blame] | 3864 | { |
| 3865 | struct hdd_cache_channel_info *ch_list; |
| 3866 | unsigned char i, num_ch; |
| 3867 | int len = 0; |
| 3868 | |
| 3869 | mutex_lock(&hdd_ctx->cache_channel_lock); |
Ashish Kumar Dhanotiya | 95e5bc2 | 2018-04-19 17:06:33 +0530 | [diff] [blame] | 3870 | if (hdd_ctx->original_channels && |
| 3871 | hdd_ctx->original_channels->num_channels && |
| 3872 | hdd_ctx->original_channels->channel_info) { |
| 3873 | num_ch = hdd_ctx->original_channels->num_channels; |
Hanumanth Reddy Pothula | 8ae38bb | 2018-03-07 18:59:30 +0530 | [diff] [blame] | 3874 | |
| 3875 | len = scnprintf(buf, buf_len, "%s %hhu", |
| 3876 | "GET_DISABLE_CHANNEL_LIST", num_ch); |
| 3877 | |
Ashish Kumar Dhanotiya | 95e5bc2 | 2018-04-19 17:06:33 +0530 | [diff] [blame] | 3878 | ch_list = hdd_ctx->original_channels->channel_info; |
Hanumanth Reddy Pothula | 8ae38bb | 2018-03-07 18:59:30 +0530 | [diff] [blame] | 3879 | |
Ashish Kumar Dhanotiya | 95e5bc2 | 2018-04-19 17:06:33 +0530 | [diff] [blame] | 3880 | for (i = 0; (i < num_ch) && (len < buf_len-1); i++) { |
Hanumanth Reddy Pothula | 8ae38bb | 2018-03-07 18:59:30 +0530 | [diff] [blame] | 3881 | len += scnprintf(buf + len, buf_len - len, |
| 3882 | " %d", ch_list[i].channel_num); |
| 3883 | } |
| 3884 | } |
| 3885 | mutex_unlock(&hdd_ctx->cache_channel_lock); |
| 3886 | |
| 3887 | return len; |
| 3888 | } |
| 3889 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 3890 | static int hdd_driver_command(hdd_adapter_t *pAdapter, |
| 3891 | hdd_priv_data_t *ppriv_data) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3892 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3893 | hdd_priv_data_t priv_data; |
| 3894 | tANI_U8 *command = NULL; |
Kaushik, Sushant | 9612244 | 2014-10-21 16:40:18 +0530 | [diff] [blame] | 3895 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 3896 | hdd_scaninfo_t *pScanInfo = NULL; |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 3897 | int ret = 0; |
Kaushik, Sushant | 9612244 | 2014-10-21 16:40:18 +0530 | [diff] [blame] | 3898 | int status; |
Anand N Sunkad | e9adb1b | 2015-07-29 09:56:45 +0530 | [diff] [blame] | 3899 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) |
| 3900 | struct cfg80211_mgmt_tx_params params; |
| 3901 | #endif |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 3902 | |
| 3903 | ENTER(); |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 3904 | /* |
| 3905 | * Note that valid pointers are provided by caller |
| 3906 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3907 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 3908 | /* copy to local struct to avoid numerous changes to legacy code */ |
| 3909 | priv_data = *ppriv_data; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3910 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 3911 | if (priv_data.total_len <= 0 || |
| 3912 | priv_data.total_len > WLAN_PRIV_DATA_MAX_LEN) |
Sameer Thalappil | 8ef3a0e | 2013-04-05 14:36:04 -0700 | [diff] [blame] | 3913 | { |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 3914 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 3915 | "%s:invalid priv_data.total_len(%d)!!!", __func__, |
| 3916 | priv_data.total_len); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 3917 | ret = -EINVAL; |
| 3918 | goto exit; |
| 3919 | } |
Kaushik, Sushant | 9612244 | 2014-10-21 16:40:18 +0530 | [diff] [blame] | 3920 | status = wlan_hdd_validate_context(pHddCtx); |
| 3921 | if (0 != status) |
| 3922 | { |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 3923 | ret = -EINVAL; |
| 3924 | goto exit; |
Kaushik, Sushant | 9612244 | 2014-10-21 16:40:18 +0530 | [diff] [blame] | 3925 | } |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 3926 | /* Allocate +1 for '\0' */ |
| 3927 | command = kmalloc(priv_data.total_len + 1, GFP_KERNEL); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3928 | if (!command) |
| 3929 | { |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 3930 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3931 | "%s: failed to allocate memory", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3932 | ret = -ENOMEM; |
| 3933 | goto exit; |
| 3934 | } |
| 3935 | |
| 3936 | if (copy_from_user(command, priv_data.buf, priv_data.total_len)) |
| 3937 | { |
| 3938 | ret = -EFAULT; |
| 3939 | goto exit; |
| 3940 | } |
| 3941 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 3942 | /* Make sure the command is NUL-terminated */ |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 3943 | command[priv_data.total_len] = '\0'; |
| 3944 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 3945 | /* at one time the following block of code was conditional. braces |
| 3946 | * have been retained to avoid re-indenting the legacy code |
| 3947 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3948 | { |
| 3949 | hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx; |
| 3950 | |
| 3951 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | f9bdd4e | 2012-10-30 18:05:03 -0700 | [diff] [blame] | 3952 | "%s: Received %s cmd from Wi-Fi GUI***", __func__, command); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3953 | |
| 3954 | if (strncmp(command, "P2P_DEV_ADDR", 12) == 0 ) |
| 3955 | { |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 3956 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 3957 | TRACE_CODE_HDD_P2P_DEV_ADDR_IOCTL, |
| 3958 | pAdapter->sessionId, (unsigned) |
| 3959 | (*(pHddCtx->p2pDeviceAddress.bytes+2)<<24 | |
| 3960 | *(pHddCtx->p2pDeviceAddress.bytes+3)<<16 | |
| 3961 | *(pHddCtx->p2pDeviceAddress.bytes+4)<<8 | |
| 3962 | *(pHddCtx->p2pDeviceAddress.bytes+5)))); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3963 | if (copy_to_user(priv_data.buf, pHddCtx->p2pDeviceAddress.bytes, |
| 3964 | sizeof(tSirMacAddr))) |
| 3965 | { |
| 3966 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 3967 | "%s: failed to copy data to user buffer", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3968 | ret = -EFAULT; |
| 3969 | } |
| 3970 | } |
Amar Singhal | 0974e40 | 2013-02-12 14:27:46 -0800 | [diff] [blame] | 3971 | else if(strncmp(command, "SETBAND", 7) == 0) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3972 | { |
Amar Singhal | 0974e40 | 2013-02-12 14:27:46 -0800 | [diff] [blame] | 3973 | tANI_U8 *ptr = command ; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3974 | |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 3975 | ret = hdd_drv_cmd_validate(command, 7); |
| 3976 | if (ret) |
| 3977 | goto exit; |
| 3978 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3979 | /* Change band request received */ |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3980 | |
| 3981 | /* First 8 bytes will have "SETBAND " and |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3982 | * 9 byte will have band setting value */ |
Madan Mohan Koyyalamudi | 8bdd311 | 2012-09-24 13:55:14 -0700 | [diff] [blame] | 3983 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Amar Singhal | 0974e40 | 2013-02-12 14:27:46 -0800 | [diff] [blame] | 3984 | "%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] | 3985 | if(VOS_FTM_MODE != hdd_get_conparam()) |
| 3986 | { |
| 3987 | /* Change band request received */ |
| 3988 | ret = hdd_setBand_helper(pAdapter->dev, ptr); |
| 3989 | if(ret < 0) |
| 3990 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 3991 | "%s: failed to set band ret=%d", __func__, ret); |
| 3992 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 3993 | } |
Kiet Lam | f040f47 | 2013-11-20 21:15:23 +0530 | [diff] [blame] | 3994 | else if(strncmp(command, "SETWMMPS", 8) == 0) |
| 3995 | { |
| 3996 | tANI_U8 *ptr = command; |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 3997 | |
| 3998 | ret = hdd_drv_cmd_validate(command, 8); |
| 3999 | if (ret) |
| 4000 | goto exit; |
| 4001 | |
Kiet Lam | f040f47 | 2013-11-20 21:15:23 +0530 | [diff] [blame] | 4002 | ret = hdd_wmmps_helper(pAdapter, ptr); |
| 4003 | } |
Agarwal Ashish | ef54a18 | 2014-12-16 15:07:31 +0530 | [diff] [blame] | 4004 | |
| 4005 | else if(strncmp(command, "TDLSSCAN", 8) == 0) |
| 4006 | { |
| 4007 | tANI_U8 *ptr = command; |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 4008 | |
| 4009 | ret = hdd_drv_cmd_validate(command, 8); |
| 4010 | if (ret) |
| 4011 | goto exit; |
| 4012 | |
Agarwal Ashish | ef54a18 | 2014-12-16 15:07:31 +0530 | [diff] [blame] | 4013 | ret = hdd_set_tdls_scan_type(pAdapter, ptr); |
| 4014 | } |
| 4015 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4016 | else if ( strncasecmp(command, "COUNTRY", 7) == 0 ) |
| 4017 | { |
| 4018 | char *country_code; |
| 4019 | |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 4020 | ret = hdd_drv_cmd_validate(command, 7); |
| 4021 | if (ret) |
| 4022 | goto exit; |
| 4023 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4024 | country_code = command + 8; |
Tushnim Bhattacharyya | 9cdf608 | 2013-04-21 16:33:30 -0700 | [diff] [blame] | 4025 | |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 4026 | INIT_COMPLETION(pAdapter->change_country_code); |
Tushnim Bhattacharyya | 9cdf608 | 2013-04-21 16:33:30 -0700 | [diff] [blame] | 4027 | hdd_checkandupdate_dfssetting(pAdapter, country_code); |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 4028 | #ifndef CONFIG_ENABLE_LINUX_REG |
Gopichand Nakkala | dacbcb5 | 2013-04-18 16:41:54 +0530 | [diff] [blame] | 4029 | hdd_checkandupdate_phymode(pAdapter, country_code); |
Tushnim Bhattacharyya | 71ccecc | 2013-10-14 16:22:56 -0700 | [diff] [blame] | 4030 | #endif |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 4031 | ret = (int)sme_ChangeCountryCode(pHddCtx->hHal, |
| 4032 | (void *)(tSmeChangeCountryCallback) |
| 4033 | wlan_hdd_change_country_code_callback, |
Abhishek Singh | a306a44 | 2013-11-07 18:39:01 +0530 | [diff] [blame] | 4034 | country_code, pAdapter, pHddCtx->pvosContext, eSIR_TRUE, eSIR_TRUE); |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 4035 | if (eHAL_STATUS_SUCCESS == ret) |
| 4036 | { |
| 4037 | ret = wait_for_completion_interruptible_timeout( |
| 4038 | &pAdapter->change_country_code, |
| 4039 | msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY)); |
| 4040 | if (0 >= ret) |
| 4041 | { |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 4042 | 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] | 4043 | __func__, ret); |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 4044 | } |
| 4045 | } |
| 4046 | else |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4047 | { |
| 4048 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 4049 | "%s: SME Change Country code fail ret=%d", __func__, ret); |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 4050 | ret = -EINVAL; |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4051 | } |
Sameer Thalappil | da4eb6a | 2013-09-25 11:45:07 -0700 | [diff] [blame] | 4052 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 4053 | } |
| 4054 | /* |
| 4055 | command should be a string having format |
| 4056 | SET_SAP_CHANNEL_LIST <num of channels> <the channels seperated by spaces> |
| 4057 | */ |
Amar Singhal | 0974e40 | 2013-02-12 14:27:46 -0800 | [diff] [blame] | 4058 | else if(strncmp(command, "SET_SAP_CHANNEL_LIST", 20) == 0) |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 4059 | { |
Amar Singhal | 0974e40 | 2013-02-12 14:27:46 -0800 | [diff] [blame] | 4060 | tANI_U8 *ptr = command; |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 4061 | |
| 4062 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 4063 | " Received Command to Set Preferred Channels for SAP in %s", __func__); |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 4064 | |
Mahesh Kumar Kalikot Veetil | 2aad8d8 | 2013-02-07 12:31:28 -0800 | [diff] [blame] | 4065 | ret = sapSetPreferredChannel(ptr); |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4066 | } |
Sourav Mohapatra | 2416e0e | 2018-03-05 18:44:21 +0530 | [diff] [blame] | 4067 | |
| 4068 | else if (strncmp(command, "VOWIFIMODE", 10) == 0) |
| 4069 | { |
| 4070 | tANI_U8 *ptr; |
| 4071 | |
| 4072 | ret = hdd_drv_cmd_validate(command, 10); |
| 4073 | if (ret) |
| 4074 | goto exit; |
| 4075 | |
| 4076 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4077 | "Received Command for VOWIFI mode in %s", __func__); |
| 4078 | |
| 4079 | ptr = (tANI_U8*)command + 11; |
| 4080 | hdd_set_vowifi_mode(pHddCtx, *ptr - '0'); |
| 4081 | } |
| 4082 | |
Sameer Thalappil | 45931fb | 2013-02-01 11:18:05 -0800 | [diff] [blame] | 4083 | else if(strncmp(command, "SETSUSPENDMODE", 14) == 0) |
| 4084 | { |
| 4085 | int suspend = 0; |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 4086 | tANI_U8 *ptr; |
| 4087 | |
| 4088 | ret = hdd_drv_cmd_validate(command, 14); |
| 4089 | if (ret) |
| 4090 | goto exit; |
| 4091 | |
| 4092 | ptr = (tANI_U8*)command + 15; |
Sameer Thalappil | 45931fb | 2013-02-01 11:18:05 -0800 | [diff] [blame] | 4093 | |
| 4094 | suspend = *ptr - '0'; |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 4095 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 4096 | TRACE_CODE_HDD_SETSUSPENDMODE_IOCTL, |
| 4097 | pAdapter->sessionId, suspend)); |
Sameer Thalappil | 45931fb | 2013-02-01 11:18:05 -0800 | [diff] [blame] | 4098 | hdd_set_wlan_suspend_mode(suspend); |
| 4099 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4100 | #ifdef WLAN_FEATURE_NEIGHBOR_ROAMING |
| 4101 | else if (strncmp(command, "SETROAMTRIGGER", 14) == 0) |
| 4102 | { |
| 4103 | tANI_U8 *value = command; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 4104 | tANI_S8 rssi = 0; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4105 | tANI_U8 lookUpThreshold = CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_DEFAULT; |
| 4106 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 4107 | |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 4108 | ret = hdd_drv_cmd_validate(command, 14); |
| 4109 | if (ret) |
| 4110 | goto exit; |
| 4111 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4112 | /* Move pointer to ahead of SETROAMTRIGGER<delimiter> */ |
| 4113 | value = value + 15; |
| 4114 | |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 4115 | /* Convert the value from ascii to integer */ |
| 4116 | ret = kstrtos8(value, 10, &rssi); |
| 4117 | if (ret < 0) |
| 4118 | { |
| 4119 | /* If the input value is greater than max value of datatype, then also |
| 4120 | kstrtou8 fails */ |
| 4121 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4122 | "%s: kstrtou8 failed Input value may be out of range[%d - %d]", |
Srinivas Girigowda | fa7157d | 2013-10-31 10:14:22 -0700 | [diff] [blame] | 4123 | __func__, |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 4124 | CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MIN, |
| 4125 | CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MAX); |
| 4126 | ret = -EINVAL; |
| 4127 | goto exit; |
| 4128 | } |
| 4129 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4130 | lookUpThreshold = abs(rssi); |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 4131 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4132 | if ((lookUpThreshold < CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MIN) || |
| 4133 | (lookUpThreshold > CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MAX)) |
| 4134 | { |
| 4135 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4136 | "Neighbor lookup threshold value %d is out of range" |
| 4137 | " (Min: %d Max: %d)", lookUpThreshold, |
| 4138 | CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MIN, |
| 4139 | CFG_NEIGHBOR_LOOKUP_RSSI_THRESHOLD_MAX); |
| 4140 | ret = -EINVAL; |
| 4141 | goto exit; |
| 4142 | } |
| 4143 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 4144 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 4145 | TRACE_CODE_HDD_SETROAMTRIGGER_IOCTL, |
| 4146 | pAdapter->sessionId, lookUpThreshold)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4147 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4148 | "%s: Received Command to Set Roam trigger" |
| 4149 | " (Neighbor lookup threshold) = %d", __func__, lookUpThreshold); |
| 4150 | |
| 4151 | pHddCtx->cfg_ini->nNeighborLookupRssiThreshold = lookUpThreshold; |
| 4152 | status = sme_setNeighborLookupRssiThreshold((tHalHandle)(pHddCtx->hHal), lookUpThreshold); |
| 4153 | if (eHAL_STATUS_SUCCESS != status) |
| 4154 | { |
| 4155 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4156 | "%s: Failed to set roam trigger, try again", __func__); |
| 4157 | ret = -EPERM; |
| 4158 | goto exit; |
| 4159 | } |
| 4160 | |
| 4161 | /* Set Reassoc threshold to (lookup rssi threshold + 5 dBm) */ |
mukul sharma | d6e1fdd | 2014-06-23 19:19:09 +0530 | [diff] [blame] | 4162 | pHddCtx->cfg_ini->nNeighborReassocRssiThreshold = lookUpThreshold + 5; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4163 | sme_setNeighborReassocRssiThreshold((tHalHandle)(pHddCtx->hHal), lookUpThreshold + 5); |
| 4164 | } |
| 4165 | else if (strncmp(command, "GETROAMTRIGGER", 14) == 0) |
| 4166 | { |
| 4167 | tANI_U8 lookUpThreshold = sme_getNeighborLookupRssiThreshold((tHalHandle)(pHddCtx->hHal)); |
| 4168 | int rssi = (-1) * lookUpThreshold; |
| 4169 | char extra[32]; |
| 4170 | tANI_U8 len = 0; |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 4171 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 4172 | TRACE_CODE_HDD_GETROAMTRIGGER_IOCTL, |
| 4173 | pAdapter->sessionId, lookUpThreshold)); |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 4174 | len = scnprintf(extra, sizeof(extra), "%s %d", command, rssi); |
Srinivas Girigowda | 9171923 | 2015-07-13 15:10:10 +0530 | [diff] [blame] | 4175 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 4176 | if (copy_to_user(priv_data.buf, &extra, len)) |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4177 | { |
| 4178 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4179 | "%s: failed to copy data to user buffer", __func__); |
| 4180 | ret = -EFAULT; |
| 4181 | goto exit; |
| 4182 | } |
| 4183 | } |
| 4184 | else if (strncmp(command, "SETROAMSCANPERIOD", 17) == 0) |
| 4185 | { |
| 4186 | tANI_U8 *value = command; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 4187 | tANI_U8 roamScanPeriod = 0; |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4188 | tANI_U16 neighborEmptyScanRefreshPeriod = CFG_EMPTY_SCAN_REFRESH_PERIOD_DEFAULT; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 4189 | |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 4190 | ret = hdd_drv_cmd_validate(command, 17); |
| 4191 | if (ret) |
| 4192 | goto exit; |
| 4193 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4194 | /* input refresh period is in terms of seconds */ |
| 4195 | /* Move pointer to ahead of SETROAMSCANPERIOD<delimiter> */ |
| 4196 | value = value + 18; |
| 4197 | /* Convert the value from ascii to integer */ |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 4198 | ret = kstrtou8(value, 10, &roamScanPeriod); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4199 | if (ret < 0) |
| 4200 | { |
| 4201 | /* 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] | 4202 | kstrtou8 fails */ |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4203 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 4204 | "%s: kstrtou8 failed Input value may be out of range[%d - %d]", |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4205 | __func__, |
Srinivas Girigowda | b8edd1e | 2013-03-19 11:42:08 -0700 | [diff] [blame] | 4206 | (CFG_EMPTY_SCAN_REFRESH_PERIOD_MIN/1000), |
| 4207 | (CFG_EMPTY_SCAN_REFRESH_PERIOD_MAX/1000)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4208 | ret = -EINVAL; |
| 4209 | goto exit; |
| 4210 | } |
| 4211 | |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 4212 | if ((roamScanPeriod < (CFG_EMPTY_SCAN_REFRESH_PERIOD_MIN/1000)) || |
| 4213 | (roamScanPeriod > (CFG_EMPTY_SCAN_REFRESH_PERIOD_MAX/1000))) |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4214 | { |
| 4215 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 4216 | "Roam scan period value %d is out of range" |
| 4217 | " (Min: %d Max: %d)", roamScanPeriod, |
Srinivas Girigowda | b8edd1e | 2013-03-19 11:42:08 -0700 | [diff] [blame] | 4218 | (CFG_EMPTY_SCAN_REFRESH_PERIOD_MIN/1000), |
| 4219 | (CFG_EMPTY_SCAN_REFRESH_PERIOD_MAX/1000)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4220 | ret = -EINVAL; |
| 4221 | goto exit; |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 4222 | } |
| 4223 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 4224 | TRACE_CODE_HDD_SETROAMSCANPERIOD_IOCTL, |
| 4225 | pAdapter->sessionId, roamScanPeriod)); |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 4226 | neighborEmptyScanRefreshPeriod = roamScanPeriod * 1000; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4227 | |
| 4228 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4229 | "%s: Received Command to Set roam scan period" |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 4230 | " (Empty Scan refresh period) = %d", __func__, roamScanPeriod); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4231 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4232 | pHddCtx->cfg_ini->nEmptyScanRefreshPeriod = neighborEmptyScanRefreshPeriod; |
| 4233 | sme_UpdateEmptyScanRefreshPeriod((tHalHandle)(pHddCtx->hHal), neighborEmptyScanRefreshPeriod); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4234 | } |
| 4235 | else if (strncmp(command, "GETROAMSCANPERIOD", 17) == 0) |
| 4236 | { |
| 4237 | tANI_U16 nEmptyScanRefreshPeriod = sme_getEmptyScanRefreshPeriod((tHalHandle)(pHddCtx->hHal)); |
| 4238 | char extra[32]; |
| 4239 | tANI_U8 len = 0; |
| 4240 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 4241 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 4242 | TRACE_CODE_HDD_GETROAMSCANPERIOD_IOCTL, |
| 4243 | pAdapter->sessionId, nEmptyScanRefreshPeriod)); |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 4244 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 4245 | "GETROAMSCANPERIOD", (nEmptyScanRefreshPeriod/1000)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4246 | /* Returned value is in units of seconds */ |
Ratnam Rachuri | a72ba11 | 2015-07-17 13:27:03 +0530 | [diff] [blame] | 4247 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 4248 | if (copy_to_user(priv_data.buf, &extra, len)) { |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4249 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4250 | "%s: failed to copy data to user buffer", __func__); |
| 4251 | ret = -EFAULT; |
| 4252 | goto exit; |
| 4253 | } |
| 4254 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4255 | else if (strncmp(command, "SETROAMSCANREFRESHPERIOD", 24) == 0) |
| 4256 | { |
| 4257 | tANI_U8 *value = command; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 4258 | tANI_U8 roamScanRefreshPeriod = 0; |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4259 | tANI_U16 neighborScanRefreshPeriod = CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_DEFAULT; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 4260 | |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 4261 | ret = hdd_drv_cmd_validate(command, 24); |
| 4262 | if (ret) |
| 4263 | goto exit; |
| 4264 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4265 | /* input refresh period is in terms of seconds */ |
| 4266 | /* Move pointer to ahead of SETROAMSCANREFRESHPERIOD<delimiter> */ |
| 4267 | value = value + 25; |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 4268 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4269 | /* Convert the value from ascii to integer */ |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 4270 | ret = kstrtou8(value, 10, &roamScanRefreshPeriod); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4271 | if (ret < 0) |
| 4272 | { |
| 4273 | /* 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] | 4274 | kstrtou8 fails */ |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4275 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 4276 | "%s: kstrtou8 failed Input value may be out of range[%d - %d]", |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4277 | __func__, |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4278 | (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MIN/1000), |
| 4279 | (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MAX/1000)); |
| 4280 | ret = -EINVAL; |
| 4281 | goto exit; |
| 4282 | } |
| 4283 | |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 4284 | if ((roamScanRefreshPeriod < (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MIN/1000)) || |
| 4285 | (roamScanRefreshPeriod > (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MAX/1000))) |
| 4286 | { |
| 4287 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4288 | "Neighbor scan results refresh period value %d is out of range" |
| 4289 | " (Min: %d Max: %d)", roamScanRefreshPeriod, |
| 4290 | (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MIN/1000), |
| 4291 | (CFG_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD_MAX/1000)); |
| 4292 | ret = -EINVAL; |
| 4293 | goto exit; |
| 4294 | } |
| 4295 | neighborScanRefreshPeriod = roamScanRefreshPeriod * 1000; |
| 4296 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4297 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4298 | "%s: Received Command to Set roam scan refresh period" |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 4299 | " (Scan refresh period) = %d", __func__, roamScanRefreshPeriod); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4300 | |
| 4301 | pHddCtx->cfg_ini->nNeighborResultsRefreshPeriod = neighborScanRefreshPeriod; |
| 4302 | sme_setNeighborScanRefreshPeriod((tHalHandle)(pHddCtx->hHal), neighborScanRefreshPeriod); |
| 4303 | } |
| 4304 | else if (strncmp(command, "GETROAMSCANREFRESHPERIOD", 24) == 0) |
| 4305 | { |
| 4306 | tANI_U16 value = sme_getNeighborScanRefreshPeriod((tHalHandle)(pHddCtx->hHal)); |
| 4307 | char extra[32]; |
| 4308 | tANI_U8 len = 0; |
| 4309 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 4310 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 4311 | "GETROAMSCANREFRESHPERIOD", (value/1000)); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4312 | /* Returned value is in units of seconds */ |
Ratnam Rachuri | 2c9d670 | 2015-07-17 13:25:16 +0530 | [diff] [blame] | 4313 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 4314 | if (copy_to_user(priv_data.buf, &extra, len)) { |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4315 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4316 | "%s: failed to copy data to user buffer", __func__); |
| 4317 | ret = -EFAULT; |
| 4318 | goto exit; |
| 4319 | } |
| 4320 | } |
Varun Reddy Yeturu | 6d99ac8 | 2013-05-08 14:15:35 -0700 | [diff] [blame] | 4321 | #ifdef FEATURE_WLAN_LFR |
| 4322 | /* SETROAMMODE */ |
| 4323 | else if (strncmp(command, "SETROAMMODE", SIZE_OF_SETROAMMODE) == 0) |
| 4324 | { |
| 4325 | tANI_U8 *value = command; |
| 4326 | tANI_BOOLEAN roamMode = CFG_LFR_FEATURE_ENABLED_DEFAULT; |
| 4327 | |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 4328 | if (pHddCtx->concurrency_mode == VOS_STA_MON) { |
| 4329 | hddLog(LOGE, |
| 4330 | FL("Roaming is always disabled in STA + MON concurrency")); |
| 4331 | ret = -EINVAL; |
| 4332 | goto exit; |
| 4333 | } |
| 4334 | |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 4335 | ret = hdd_drv_cmd_validate(command, SIZE_OF_SETROAMMODE); |
| 4336 | if (ret) |
| 4337 | goto exit; |
| 4338 | |
Varun Reddy Yeturu | 6d99ac8 | 2013-05-08 14:15:35 -0700 | [diff] [blame] | 4339 | /* Move pointer to ahead of SETROAMMODE<delimiter> */ |
| 4340 | value = value + SIZE_OF_SETROAMMODE + 1; |
| 4341 | |
| 4342 | /* Convert the value from ascii to integer */ |
| 4343 | ret = kstrtou8(value, SIZE_OF_SETROAMMODE, &roamMode); |
| 4344 | if (ret < 0) |
| 4345 | { |
| 4346 | /* If the input value is greater than max value of datatype, then also |
| 4347 | kstrtou8 fails */ |
| 4348 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4349 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 4350 | CFG_LFR_FEATURE_ENABLED_MIN, |
| 4351 | CFG_LFR_FEATURE_ENABLED_MAX); |
| 4352 | ret = -EINVAL; |
| 4353 | goto exit; |
| 4354 | } |
| 4355 | if ((roamMode < CFG_LFR_FEATURE_ENABLED_MIN) || |
| 4356 | (roamMode > CFG_LFR_FEATURE_ENABLED_MAX)) |
| 4357 | { |
| 4358 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4359 | "Roam Mode value %d is out of range" |
| 4360 | " (Min: %d Max: %d)", roamMode, |
| 4361 | CFG_LFR_FEATURE_ENABLED_MIN, |
| 4362 | CFG_LFR_FEATURE_ENABLED_MAX); |
| 4363 | ret = -EINVAL; |
| 4364 | goto exit; |
| 4365 | } |
| 4366 | |
| 4367 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4368 | "%s: Received Command to Set Roam Mode = %d", __func__, roamMode); |
| 4369 | /* |
| 4370 | * Note that |
| 4371 | * SETROAMMODE 0 is to enable LFR while |
| 4372 | * SETROAMMODE 1 is to disable LFR, but |
| 4373 | * NotifyIsFastRoamIniFeatureEnabled 0/1 is to enable/disable. |
| 4374 | * So, we have to invert the value to call sme_UpdateIsFastRoamIniFeatureEnabled. |
| 4375 | */ |
| 4376 | if (CFG_LFR_FEATURE_ENABLED_MIN == roamMode) |
| 4377 | roamMode = CFG_LFR_FEATURE_ENABLED_MAX; /* Roam enable */ |
| 4378 | else |
| 4379 | roamMode = CFG_LFR_FEATURE_ENABLED_MIN; /* Roam disable */ |
| 4380 | |
| 4381 | pHddCtx->cfg_ini->isFastRoamIniFeatureEnabled = roamMode; |
| 4382 | sme_UpdateIsFastRoamIniFeatureEnabled((tHalHandle)(pHddCtx->hHal), roamMode); |
| 4383 | } |
| 4384 | /* GETROAMMODE */ |
Mahesh A Saptasagar | ec7d109 | 2015-04-02 13:41:34 +0530 | [diff] [blame] | 4385 | else if (strncmp(command, "GETROAMMODE", SIZE_OF_GETROAMMODE) == 0) |
Varun Reddy Yeturu | 6d99ac8 | 2013-05-08 14:15:35 -0700 | [diff] [blame] | 4386 | { |
| 4387 | tANI_BOOLEAN roamMode = sme_getIsLfrFeatureEnabled((tHalHandle)(pHddCtx->hHal)); |
| 4388 | char extra[32]; |
| 4389 | tANI_U8 len = 0; |
| 4390 | |
| 4391 | /* |
| 4392 | * roamMode value shall be inverted because the sementics is different. |
| 4393 | */ |
| 4394 | if (CFG_LFR_FEATURE_ENABLED_MIN == roamMode) |
| 4395 | roamMode = CFG_LFR_FEATURE_ENABLED_MAX; |
| 4396 | else |
| 4397 | roamMode = CFG_LFR_FEATURE_ENABLED_MIN; |
| 4398 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 4399 | len = scnprintf(extra, sizeof(extra), "%s %d", command, roamMode); |
Ratnam Rachuri | 28693eb | 2015-07-17 13:23:42 +0530 | [diff] [blame] | 4400 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 4401 | if (copy_to_user(priv_data.buf, &extra, len)) { |
Varun Reddy Yeturu | 6d99ac8 | 2013-05-08 14:15:35 -0700 | [diff] [blame] | 4402 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4403 | "%s: failed to copy data to user buffer", __func__); |
| 4404 | ret = -EFAULT; |
| 4405 | goto exit; |
| 4406 | } |
| 4407 | } |
| 4408 | #endif |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4409 | #endif |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4410 | #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] | 4411 | else if (strncmp(command, "SETROAMDELTA", 12) == 0) |
| 4412 | { |
| 4413 | tANI_U8 *value = command; |
| 4414 | tANI_U8 roamRssiDiff = CFG_ROAM_RSSI_DIFF_DEFAULT; |
| 4415 | |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 4416 | ret = hdd_drv_cmd_validate(command, 12); |
| 4417 | if (ret) |
| 4418 | goto exit; |
| 4419 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4420 | /* Move pointer to ahead of SETROAMDELTA<delimiter> */ |
| 4421 | value = value + 13; |
| 4422 | /* Convert the value from ascii to integer */ |
| 4423 | ret = kstrtou8(value, 10, &roamRssiDiff); |
| 4424 | if (ret < 0) |
| 4425 | { |
| 4426 | /* If the input value is greater than max value of datatype, then also |
| 4427 | kstrtou8 fails */ |
| 4428 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4429 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 4430 | CFG_ROAM_RSSI_DIFF_MIN, |
| 4431 | CFG_ROAM_RSSI_DIFF_MAX); |
| 4432 | ret = -EINVAL; |
| 4433 | goto exit; |
| 4434 | } |
| 4435 | |
| 4436 | if ((roamRssiDiff < CFG_ROAM_RSSI_DIFF_MIN) || |
| 4437 | (roamRssiDiff > CFG_ROAM_RSSI_DIFF_MAX)) |
| 4438 | { |
| 4439 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4440 | "Roam rssi diff value %d is out of range" |
| 4441 | " (Min: %d Max: %d)", roamRssiDiff, |
| 4442 | CFG_ROAM_RSSI_DIFF_MIN, |
| 4443 | CFG_ROAM_RSSI_DIFF_MAX); |
| 4444 | ret = -EINVAL; |
| 4445 | goto exit; |
| 4446 | } |
| 4447 | |
| 4448 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4449 | "%s: Received Command to Set roam rssi diff = %d", __func__, roamRssiDiff); |
| 4450 | |
| 4451 | pHddCtx->cfg_ini->RoamRssiDiff = roamRssiDiff; |
| 4452 | sme_UpdateRoamRssiDiff((tHalHandle)(pHddCtx->hHal), roamRssiDiff); |
| 4453 | } |
Mahesh A Saptasagar | ec7d109 | 2015-04-02 13:41:34 +0530 | [diff] [blame] | 4454 | else if (strncmp(command, "GETROAMDELTA", 12) == 0) |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4455 | { |
| 4456 | tANI_U8 roamRssiDiff = sme_getRoamRssiDiff((tHalHandle)(pHddCtx->hHal)); |
| 4457 | char extra[32]; |
| 4458 | tANI_U8 len = 0; |
| 4459 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 4460 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 4461 | TRACE_CODE_HDD_GETROAMDELTA_IOCTL, |
| 4462 | pAdapter->sessionId, roamRssiDiff)); |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 4463 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 4464 | command, roamRssiDiff); |
Ratnam Rachuri | 22a3b40 | 2015-07-17 13:21:49 +0530 | [diff] [blame] | 4465 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 4466 | if (copy_to_user(priv_data.buf, &extra, len)) { |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4467 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4468 | "%s: failed to copy data to user buffer", __func__); |
| 4469 | ret = -EFAULT; |
| 4470 | goto exit; |
| 4471 | } |
| 4472 | } |
| 4473 | #endif |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4474 | #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] | 4475 | else if (strncmp(command, "GETBAND", 7) == 0) |
| 4476 | { |
| 4477 | int band = -1; |
| 4478 | char extra[32]; |
| 4479 | tANI_U8 len = 0; |
| 4480 | hdd_getBand_helper(pHddCtx, &band); |
| 4481 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 4482 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 4483 | TRACE_CODE_HDD_GETBAND_IOCTL, |
| 4484 | pAdapter->sessionId, band)); |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 4485 | len = scnprintf(extra, sizeof(extra), "%s %d", command, band); |
Ratnam Rachuri | 5213959 | 2015-07-17 13:17:29 +0530 | [diff] [blame] | 4486 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 4487 | if (copy_to_user(priv_data.buf, &extra, len)) { |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4488 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4489 | "%s: failed to copy data to user buffer", __func__); |
| 4490 | ret = -EFAULT; |
| 4491 | goto exit; |
| 4492 | } |
| 4493 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4494 | else if (strncmp(command, "SETROAMSCANCHANNELS", 19) == 0) |
| 4495 | { |
| 4496 | tANI_U8 *value = command; |
| 4497 | tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0}; |
| 4498 | tANI_U8 numChannels = 0; |
| 4499 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 4500 | |
| 4501 | status = hdd_parse_channellist(value, ChannelList, &numChannels); |
| 4502 | if (eHAL_STATUS_SUCCESS != status) |
| 4503 | { |
| 4504 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4505 | "%s: Failed to parse channel list information", __func__); |
| 4506 | ret = -EINVAL; |
| 4507 | goto exit; |
| 4508 | } |
| 4509 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 4510 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 4511 | TRACE_CODE_HDD_SETROAMSCANCHANNELS_IOCTL, |
| 4512 | pAdapter->sessionId, numChannels)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4513 | if (numChannels > WNI_CFG_VALID_CHANNEL_LIST_LEN) |
| 4514 | { |
| 4515 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4516 | "%s: number of channels (%d) supported exceeded max (%d)", __func__, |
| 4517 | numChannels, WNI_CFG_VALID_CHANNEL_LIST_LEN); |
| 4518 | ret = -EINVAL; |
| 4519 | goto exit; |
| 4520 | } |
| 4521 | status = sme_ChangeRoamScanChannelList((tHalHandle)(pHddCtx->hHal), ChannelList, |
| 4522 | numChannels); |
| 4523 | if (eHAL_STATUS_SUCCESS != status) |
| 4524 | { |
| 4525 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4526 | "%s: Failed to update channel list information", __func__); |
| 4527 | ret = -EINVAL; |
| 4528 | goto exit; |
| 4529 | } |
| 4530 | } |
| 4531 | else if (strncmp(command, "GETROAMSCANCHANNELS", 19) == 0) |
| 4532 | { |
| 4533 | tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0}; |
| 4534 | tANI_U8 numChannels = 0; |
Jeff Johnson | 51b6778 | 2013-04-05 12:35:41 -0700 | [diff] [blame] | 4535 | tANI_U8 j = 0; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4536 | char extra[128] = {0}; |
Jeff Johnson | 51b6778 | 2013-04-05 12:35:41 -0700 | [diff] [blame] | 4537 | int len; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4538 | |
| 4539 | if (eHAL_STATUS_SUCCESS != sme_getRoamScanChannelList( (tHalHandle)(pHddCtx->hHal), |
| 4540 | ChannelList, &numChannels )) |
| 4541 | { |
| 4542 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 4543 | "%s: failed to get roam scan channel list", __func__); |
| 4544 | ret = -EFAULT; |
| 4545 | goto exit; |
| 4546 | } |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 4547 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 4548 | TRACE_CODE_HDD_GETROAMSCANCHANNELS_IOCTL, |
| 4549 | pAdapter->sessionId, numChannels)); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4550 | /* output channel list is of the format |
| 4551 | [Number of roam scan channels][Channel1][Channel2]... */ |
| 4552 | /* copy the number of channels in the 0th index */ |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 4553 | len = scnprintf(extra, sizeof(extra), "%s %d", command, numChannels); |
Sushant Kaushik | a08ca19 | 2015-09-16 15:52:04 +0530 | [diff] [blame] | 4554 | for (j = 0; (j < numChannels) && len <= sizeof(extra); j++) |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4555 | { |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 4556 | len += scnprintf(extra + len, sizeof(extra) - len, " %d", |
| 4557 | ChannelList[j]); |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4558 | } |
| 4559 | |
Sushant Kaushik | c9b8be5 | 2015-07-15 16:41:27 +0530 | [diff] [blame] | 4560 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 4561 | if (copy_to_user(priv_data.buf, &extra, len)) |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 4562 | { |
| 4563 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4564 | "%s: failed to copy data to user buffer", __func__); |
| 4565 | ret = -EFAULT; |
| 4566 | goto exit; |
| 4567 | } |
| 4568 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4569 | else if (strncmp(command, "GETCCXMODE", 10) == 0) |
| 4570 | { |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4571 | tANI_BOOLEAN eseMode = sme_getIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal)); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4572 | char extra[32]; |
| 4573 | tANI_U8 len = 0; |
| 4574 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4575 | /* Check if the features OKC/ESE/11R are supported simultaneously, |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 4576 | then this operation is not permitted (return FAILURE) */ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4577 | if (eseMode && |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 4578 | hdd_is_okc_mode_enabled(pHddCtx) && |
| 4579 | sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal))) |
| 4580 | { |
| 4581 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4582 | "%s: OKC/ESE/11R are supported simultaneously" |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 4583 | " hence this operation is not permitted!", __func__); |
| 4584 | ret = -EPERM; |
| 4585 | goto exit; |
| 4586 | } |
| 4587 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 4588 | len = scnprintf(extra, sizeof(extra), "%s %d", |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4589 | "GETCCXMODE", eseMode); |
Sushant Kaushik | f8abd35 | 2015-07-15 16:37:49 +0530 | [diff] [blame] | 4590 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 4591 | if (copy_to_user(priv_data.buf, &extra, len)) |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4592 | { |
| 4593 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4594 | "%s: failed to copy data to user buffer", __func__); |
| 4595 | ret = -EFAULT; |
| 4596 | goto exit; |
| 4597 | } |
| 4598 | } |
| 4599 | else if (strncmp(command, "GETOKCMODE", 10) == 0) |
| 4600 | { |
| 4601 | tANI_BOOLEAN okcMode = hdd_is_okc_mode_enabled(pHddCtx); |
| 4602 | char extra[32]; |
| 4603 | tANI_U8 len = 0; |
| 4604 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4605 | /* Check if the features OKC/ESE/11R are supported simultaneously, |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 4606 | then this operation is not permitted (return FAILURE) */ |
| 4607 | if (okcMode && |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4608 | sme_getIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal)) && |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 4609 | sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal))) |
| 4610 | { |
| 4611 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 4612 | "%s: OKC/ESE/11R are supported simultaneously" |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 4613 | " hence this operation is not permitted!", __func__); |
| 4614 | ret = -EPERM; |
| 4615 | goto exit; |
| 4616 | } |
| 4617 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 4618 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 4619 | "GETOKCMODE", okcMode); |
Sushant Kaushik | bc2fb5c | 2015-07-15 16:43:16 +0530 | [diff] [blame] | 4620 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 4621 | if (copy_to_user(priv_data.buf, &extra, len)) |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4622 | { |
| 4623 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4624 | "%s: failed to copy data to user buffer", __func__); |
| 4625 | ret = -EFAULT; |
| 4626 | goto exit; |
| 4627 | } |
| 4628 | } |
Srinivas Girigowda | cb4c641 | 2013-07-02 10:19:12 -0700 | [diff] [blame] | 4629 | else if (strncmp(command, "GETFASTROAM", 11) == 0) |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4630 | { |
| 4631 | tANI_BOOLEAN lfrMode = sme_getIsLfrFeatureEnabled((tHalHandle)(pHddCtx->hHal)); |
| 4632 | char extra[32]; |
| 4633 | tANI_U8 len = 0; |
| 4634 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 4635 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 4636 | "GETFASTROAM", lfrMode); |
Sushant Kaushik | 4da7ec9 | 2015-07-15 16:39:32 +0530 | [diff] [blame] | 4637 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 4638 | if (copy_to_user(priv_data.buf, &extra, len)) |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4639 | { |
| 4640 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4641 | "%s: failed to copy data to user buffer", __func__); |
| 4642 | ret = -EFAULT; |
| 4643 | goto exit; |
| 4644 | } |
| 4645 | } |
| 4646 | else if (strncmp(command, "GETFASTTRANSITION", 17) == 0) |
| 4647 | { |
| 4648 | tANI_BOOLEAN ft = sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal)); |
| 4649 | char extra[32]; |
| 4650 | tANI_U8 len = 0; |
| 4651 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 4652 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 4653 | "GETFASTTRANSITION", ft); |
Sushant Kaushik | 231a445 | 2015-07-15 16:23:56 +0530 | [diff] [blame] | 4654 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 4655 | if (copy_to_user(priv_data.buf, &extra, len)) |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4656 | { |
| 4657 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4658 | "%s: failed to copy data to user buffer", __func__); |
| 4659 | ret = -EFAULT; |
| 4660 | goto exit; |
| 4661 | } |
| 4662 | } |
| 4663 | else if (strncmp(command, "SETROAMSCANCHANNELMINTIME", 25) == 0) |
| 4664 | { |
| 4665 | tANI_U8 *value = command; |
| 4666 | tANI_U8 minTime = CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_DEFAULT; |
| 4667 | |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 4668 | ret = hdd_drv_cmd_validate(command, 25); |
| 4669 | if (ret) |
| 4670 | goto exit; |
| 4671 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4672 | /* Move pointer to ahead of SETROAMSCANCHANNELMINTIME<delimiter> */ |
| 4673 | value = value + 26; |
| 4674 | /* Convert the value from ascii to integer */ |
| 4675 | ret = kstrtou8(value, 10, &minTime); |
| 4676 | if (ret < 0) |
| 4677 | { |
| 4678 | /* If the input value is greater than max value of datatype, then also |
| 4679 | kstrtou8 fails */ |
| 4680 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4681 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 4682 | CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MIN, |
| 4683 | CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MAX); |
| 4684 | ret = -EINVAL; |
| 4685 | goto exit; |
| 4686 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4687 | if ((minTime < CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MIN) || |
| 4688 | (minTime > CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MAX)) |
| 4689 | { |
| 4690 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4691 | "scan min channel time value %d is out of range" |
| 4692 | " (Min: %d Max: %d)", minTime, |
| 4693 | CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MIN, |
| 4694 | CFG_NEIGHBOR_SCAN_MIN_CHAN_TIME_MAX); |
| 4695 | ret = -EINVAL; |
| 4696 | goto exit; |
| 4697 | } |
| 4698 | |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 4699 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 4700 | TRACE_CODE_HDD_SETROAMSCANCHANNELMINTIME_IOCTL, |
| 4701 | pAdapter->sessionId, minTime)); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4702 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4703 | "%s: Received Command to change channel min time = %d", __func__, minTime); |
| 4704 | |
| 4705 | pHddCtx->cfg_ini->nNeighborScanMinChanTime = minTime; |
| 4706 | sme_setNeighborScanMinChanTime((tHalHandle)(pHddCtx->hHal), minTime); |
| 4707 | } |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4708 | else if (strncmp(command, "SENDACTIONFRAME", 15) == 0) |
| 4709 | { |
| 4710 | tANI_U8 *value = command; |
| 4711 | tANI_U8 channel = 0; |
| 4712 | tANI_U8 dwellTime = 0; |
| 4713 | tANI_U8 bufLen = 0; |
| 4714 | tANI_U8 *buf = NULL; |
| 4715 | tSirMacAddr targetApBssid; |
| 4716 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 4717 | struct ieee80211_channel chan; |
| 4718 | tANI_U8 finalLen = 0; |
| 4719 | tANI_U8 *finalBuf = NULL; |
| 4720 | tANI_U8 temp = 0; |
| 4721 | u64 cookie; |
| 4722 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 4723 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 4724 | |
| 4725 | /* if not associated, no need to send action frame */ |
| 4726 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 4727 | { |
| 4728 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:Not associated!",__func__); |
| 4729 | ret = -EINVAL; |
| 4730 | goto exit; |
| 4731 | } |
| 4732 | |
| 4733 | status = hdd_parse_send_action_frame_data(value, targetApBssid, &channel, |
| 4734 | &dwellTime, &buf, &bufLen); |
| 4735 | if (eHAL_STATUS_SUCCESS != status) |
| 4736 | { |
| 4737 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4738 | "%s: Failed to parse send action frame data", __func__); |
| 4739 | ret = -EINVAL; |
| 4740 | goto exit; |
| 4741 | } |
| 4742 | |
| 4743 | /* if the target bssid is different from currently associated AP, |
| 4744 | then no need to send action frame */ |
| 4745 | if (VOS_TRUE != vos_mem_compare(targetApBssid, |
| 4746 | pHddStaCtx->conn_info.bssId, sizeof(tSirMacAddr))) |
| 4747 | { |
| 4748 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s:STA is not associated to this AP!",__func__); |
| 4749 | ret = -EINVAL; |
Jeff Johnson | 11c3315 | 2013-04-16 17:52:40 -0700 | [diff] [blame] | 4750 | vos_mem_free(buf); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 4751 | buf = NULL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4752 | goto exit; |
| 4753 | } |
| 4754 | |
| 4755 | /* if the channel number is different from operating channel then |
| 4756 | no need to send action frame */ |
| 4757 | if (channel != pHddStaCtx->conn_info.operationChannel) |
| 4758 | { |
| 4759 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4760 | "%s: channel(%d) is different from operating channel(%d)", |
| 4761 | __func__, channel, pHddStaCtx->conn_info.operationChannel); |
| 4762 | ret = -EINVAL; |
Jeff Johnson | 11c3315 | 2013-04-16 17:52:40 -0700 | [diff] [blame] | 4763 | vos_mem_free(buf); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 4764 | buf = NULL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4765 | goto exit; |
| 4766 | } |
| 4767 | chan.center_freq = sme_ChnToFreq(channel); |
| 4768 | |
| 4769 | finalLen = bufLen + 24; |
| 4770 | finalBuf = vos_mem_malloc(finalLen); |
| 4771 | if (NULL == finalBuf) |
| 4772 | { |
| 4773 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:memory allocation failed",__func__); |
| 4774 | ret = -ENOMEM; |
Jeff Johnson | 11c3315 | 2013-04-16 17:52:40 -0700 | [diff] [blame] | 4775 | vos_mem_free(buf); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 4776 | buf = NULL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4777 | goto exit; |
| 4778 | } |
| 4779 | vos_mem_zero(finalBuf, finalLen); |
| 4780 | |
| 4781 | /* Fill subtype */ |
| 4782 | temp = SIR_MAC_MGMT_ACTION << 4; |
| 4783 | vos_mem_copy(finalBuf + 0, &temp, sizeof(temp)); |
| 4784 | |
| 4785 | /* Fill type */ |
| 4786 | temp = SIR_MAC_MGMT_FRAME; |
| 4787 | vos_mem_copy(finalBuf + 2, &temp, sizeof(temp)); |
| 4788 | |
| 4789 | /* Fill destination address (bssid of the AP) */ |
| 4790 | vos_mem_copy(finalBuf + 4, targetApBssid, sizeof(targetApBssid)); |
| 4791 | |
Srinivas Girigowda | b27c019 | 2013-06-03 10:19:56 -0700 | [diff] [blame] | 4792 | /* Fill source address (STA mac address) */ |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4793 | vos_mem_copy(finalBuf + 10, pAdapter->macAddressCurrent.bytes, sizeof(pAdapter->macAddressCurrent.bytes)); |
| 4794 | |
Srinivas Girigowda | b27c019 | 2013-06-03 10:19:56 -0700 | [diff] [blame] | 4795 | /* Fill BSSID (AP mac address) */ |
| 4796 | vos_mem_copy(finalBuf + 16, targetApBssid, sizeof(targetApBssid)); |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4797 | |
| 4798 | /* Fill received buffer from 24th address */ |
| 4799 | vos_mem_copy(finalBuf + 24, buf, bufLen); |
| 4800 | |
Jeff Johnson | 11c3315 | 2013-04-16 17:52:40 -0700 | [diff] [blame] | 4801 | /* done with the parsed buffer */ |
| 4802 | vos_mem_free(buf); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 4803 | buf = NULL; |
Jeff Johnson | 11c3315 | 2013-04-16 17:52:40 -0700 | [diff] [blame] | 4804 | |
Anand N Sunkad | e9adb1b | 2015-07-29 09:56:45 +0530 | [diff] [blame] | 4805 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) |
| 4806 | params.chan = &chan; |
| 4807 | params.offchan = 0; |
| 4808 | params.wait = dwellTime; |
| 4809 | params.buf = finalBuf; |
| 4810 | params.len = finalLen; |
| 4811 | params.no_cck = 1; |
| 4812 | params.dont_wait_for_ack = 1; |
| 4813 | ret = wlan_hdd_mgmt_tx(NULL, &pAdapter->wdev, ¶ms, &cookie); |
| 4814 | #else |
DARAM SUDHA | 39eede6 | 2014-02-12 11:16:40 +0530 | [diff] [blame] | 4815 | wlan_hdd_mgmt_tx( NULL, |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 4816 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 4817 | &(pAdapter->wdev), |
| 4818 | #else |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 4819 | pAdapter->dev, |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 4820 | #endif |
| 4821 | &chan, 0, |
| 4822 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)) |
| 4823 | NL80211_CHAN_HT20, 1, |
| 4824 | #endif |
| 4825 | dwellTime, finalBuf, finalLen, 1, |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4826 | 1, &cookie ); |
Anand N Sunkad | e9adb1b | 2015-07-29 09:56:45 +0530 | [diff] [blame] | 4827 | #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)*/ |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 4828 | vos_mem_free(finalBuf); |
| 4829 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4830 | else if (strncmp(command, "GETROAMSCANCHANNELMINTIME", 25) == 0) |
| 4831 | { |
| 4832 | tANI_U16 val = sme_getNeighborScanMinChanTime((tHalHandle)(pHddCtx->hHal)); |
| 4833 | char extra[32]; |
| 4834 | tANI_U8 len = 0; |
| 4835 | |
| 4836 | /* value is interms of msec */ |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 4837 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 4838 | "GETROAMSCANCHANNELMINTIME", val); |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 4839 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 4840 | TRACE_CODE_HDD_GETROAMSCANCHANNELMINTIME_IOCTL, |
| 4841 | pAdapter->sessionId, val)); |
Sushant Kaushik | bb8c52c | 2015-07-15 16:36:23 +0530 | [diff] [blame] | 4842 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 4843 | if (copy_to_user(priv_data.buf, &extra, len)) |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4844 | { |
| 4845 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4846 | "%s: failed to copy data to user buffer", __func__); |
| 4847 | ret = -EFAULT; |
| 4848 | goto exit; |
| 4849 | } |
| 4850 | } |
| 4851 | else if (strncmp(command, "SETSCANCHANNELTIME", 18) == 0) |
| 4852 | { |
| 4853 | tANI_U8 *value = command; |
Varun Reddy Yeturu | 3885a66 | 2013-06-19 07:10:37 -0700 | [diff] [blame] | 4854 | tANI_U16 maxTime = CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_DEFAULT; |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4855 | |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 4856 | ret = hdd_drv_cmd_validate(command, 18); |
| 4857 | if (ret) |
| 4858 | goto exit; |
| 4859 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4860 | /* Move pointer to ahead of SETSCANCHANNELTIME<delimiter> */ |
| 4861 | value = value + 19; |
| 4862 | /* Convert the value from ascii to integer */ |
Varun Reddy Yeturu | 3885a66 | 2013-06-19 07:10:37 -0700 | [diff] [blame] | 4863 | ret = kstrtou16(value, 10, &maxTime); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4864 | if (ret < 0) |
| 4865 | { |
| 4866 | /* 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] | 4867 | kstrtou16 fails */ |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4868 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Varun Reddy Yeturu | 3885a66 | 2013-06-19 07:10:37 -0700 | [diff] [blame] | 4869 | "%s: kstrtou16 failed range [%d - %d]", __func__, |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4870 | CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MIN, |
| 4871 | CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MAX); |
| 4872 | ret = -EINVAL; |
| 4873 | goto exit; |
| 4874 | } |
| 4875 | |
| 4876 | if ((maxTime < CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MIN) || |
| 4877 | (maxTime > CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MAX)) |
| 4878 | { |
| 4879 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4880 | "lfr mode value %d is out of range" |
| 4881 | " (Min: %d Max: %d)", maxTime, |
| 4882 | CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MIN, |
| 4883 | CFG_NEIGHBOR_SCAN_MAX_CHAN_TIME_MAX); |
| 4884 | ret = -EINVAL; |
| 4885 | goto exit; |
| 4886 | } |
| 4887 | |
| 4888 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4889 | "%s: Received Command to change channel max time = %d", __func__, maxTime); |
| 4890 | |
| 4891 | pHddCtx->cfg_ini->nNeighborScanMaxChanTime = maxTime; |
| 4892 | sme_setNeighborScanMaxChanTime((tHalHandle)(pHddCtx->hHal), maxTime); |
| 4893 | } |
| 4894 | else if (strncmp(command, "GETSCANCHANNELTIME", 18) == 0) |
| 4895 | { |
| 4896 | tANI_U16 val = sme_getNeighborScanMaxChanTime((tHalHandle)(pHddCtx->hHal)); |
| 4897 | char extra[32]; |
| 4898 | tANI_U8 len = 0; |
| 4899 | |
| 4900 | /* value is interms of msec */ |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 4901 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 4902 | "GETSCANCHANNELTIME", val); |
Ratheesh S P | acbfa93 | 2015-07-16 15:27:18 +0530 | [diff] [blame] | 4903 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 4904 | if (copy_to_user(priv_data.buf, &extra, len)) |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4905 | { |
| 4906 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4907 | "%s: failed to copy data to user buffer", __func__); |
| 4908 | ret = -EFAULT; |
| 4909 | goto exit; |
| 4910 | } |
| 4911 | } |
| 4912 | else if (strncmp(command, "SETSCANHOMETIME", 15) == 0) |
| 4913 | { |
| 4914 | tANI_U8 *value = command; |
| 4915 | tANI_U16 val = CFG_NEIGHBOR_SCAN_TIMER_PERIOD_DEFAULT; |
| 4916 | |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 4917 | ret = hdd_drv_cmd_validate(command, 15); |
| 4918 | if (ret) |
| 4919 | goto exit; |
| 4920 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4921 | /* Move pointer to ahead of SETSCANHOMETIME<delimiter> */ |
| 4922 | value = value + 16; |
| 4923 | /* Convert the value from ascii to integer */ |
| 4924 | ret = kstrtou16(value, 10, &val); |
| 4925 | if (ret < 0) |
| 4926 | { |
| 4927 | /* If the input value is greater than max value of datatype, then also |
| 4928 | kstrtou16 fails */ |
| 4929 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4930 | "%s: kstrtou16 failed range [%d - %d]", __func__, |
| 4931 | CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MIN, |
| 4932 | CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MAX); |
| 4933 | ret = -EINVAL; |
| 4934 | goto exit; |
| 4935 | } |
| 4936 | |
| 4937 | if ((val < CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MIN) || |
| 4938 | (val > CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MAX)) |
| 4939 | { |
| 4940 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4941 | "scan home time value %d is out of range" |
| 4942 | " (Min: %d Max: %d)", val, |
| 4943 | CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MIN, |
| 4944 | CFG_NEIGHBOR_SCAN_TIMER_PERIOD_MAX); |
| 4945 | ret = -EINVAL; |
| 4946 | goto exit; |
| 4947 | } |
| 4948 | |
| 4949 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4950 | "%s: Received Command to change scan home time = %d", __func__, val); |
| 4951 | |
| 4952 | pHddCtx->cfg_ini->nNeighborScanPeriod = val; |
| 4953 | sme_setNeighborScanPeriod((tHalHandle)(pHddCtx->hHal), val); |
| 4954 | } |
| 4955 | else if (strncmp(command, "GETSCANHOMETIME", 15) == 0) |
| 4956 | { |
| 4957 | tANI_U16 val = sme_getNeighborScanPeriod((tHalHandle)(pHddCtx->hHal)); |
| 4958 | char extra[32]; |
| 4959 | tANI_U8 len = 0; |
| 4960 | |
| 4961 | /* value is interms of msec */ |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 4962 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 4963 | "GETSCANHOMETIME", val); |
Ratheesh S P | 728d7c6 | 2015-07-16 15:38:58 +0530 | [diff] [blame] | 4964 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 4965 | if (copy_to_user(priv_data.buf, &extra, len)) |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4966 | { |
| 4967 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4968 | "%s: failed to copy data to user buffer", __func__); |
| 4969 | ret = -EFAULT; |
| 4970 | goto exit; |
| 4971 | } |
| 4972 | } |
| 4973 | else if (strncmp(command, "SETROAMINTRABAND", 16) == 0) |
| 4974 | { |
| 4975 | tANI_U8 *value = command; |
| 4976 | tANI_U8 val = CFG_ROAM_INTRA_BAND_DEFAULT; |
| 4977 | |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 4978 | ret = hdd_drv_cmd_validate(command, 16); |
| 4979 | if (ret) |
| 4980 | goto exit; |
| 4981 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4982 | /* Move pointer to ahead of SETROAMINTRABAND<delimiter> */ |
| 4983 | value = value + 17; |
| 4984 | /* Convert the value from ascii to integer */ |
| 4985 | ret = kstrtou8(value, 10, &val); |
| 4986 | if (ret < 0) |
| 4987 | { |
| 4988 | /* If the input value is greater than max value of datatype, then also |
| 4989 | kstrtou8 fails */ |
| 4990 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4991 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 4992 | CFG_ROAM_INTRA_BAND_MIN, |
| 4993 | CFG_ROAM_INTRA_BAND_MAX); |
| 4994 | ret = -EINVAL; |
| 4995 | goto exit; |
| 4996 | } |
| 4997 | |
| 4998 | if ((val < CFG_ROAM_INTRA_BAND_MIN) || |
| 4999 | (val > CFG_ROAM_INTRA_BAND_MAX)) |
| 5000 | { |
| 5001 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5002 | "intra band mode value %d is out of range" |
| 5003 | " (Min: %d Max: %d)", val, |
| 5004 | CFG_ROAM_INTRA_BAND_MIN, |
| 5005 | CFG_ROAM_INTRA_BAND_MAX); |
| 5006 | ret = -EINVAL; |
| 5007 | goto exit; |
| 5008 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 5009 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5010 | "%s: Received Command to change intra band = %d", __func__, val); |
| 5011 | |
| 5012 | pHddCtx->cfg_ini->nRoamIntraBand = val; |
| 5013 | sme_setRoamIntraBand((tHalHandle)(pHddCtx->hHal), val); |
| 5014 | } |
| 5015 | else if (strncmp(command, "GETROAMINTRABAND", 16) == 0) |
| 5016 | { |
| 5017 | tANI_U16 val = sme_getRoamIntraBand((tHalHandle)(pHddCtx->hHal)); |
| 5018 | char extra[32]; |
| 5019 | tANI_U8 len = 0; |
| 5020 | |
| 5021 | /* value is interms of msec */ |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 5022 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 5023 | "GETROAMINTRABAND", val); |
Ratheesh S P | 2dd2a3e | 2015-07-16 15:34:23 +0530 | [diff] [blame] | 5024 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 5025 | if (copy_to_user(priv_data.buf, &extra, len)) |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 5026 | { |
| 5027 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5028 | "%s: failed to copy data to user buffer", __func__); |
| 5029 | ret = -EFAULT; |
| 5030 | goto exit; |
| 5031 | } |
| 5032 | } |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 5033 | else if (strncmp(command, "SETSCANNPROBES", 14) == 0) |
| 5034 | { |
| 5035 | tANI_U8 *value = command; |
| 5036 | tANI_U8 nProbes = CFG_ROAM_SCAN_N_PROBES_DEFAULT; |
| 5037 | |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 5038 | ret = hdd_drv_cmd_validate(command, 14); |
| 5039 | if (ret) |
| 5040 | goto exit; |
| 5041 | |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 5042 | /* Move pointer to ahead of SETSCANNPROBES<delimiter> */ |
| 5043 | value = value + 15; |
| 5044 | /* Convert the value from ascii to integer */ |
| 5045 | ret = kstrtou8(value, 10, &nProbes); |
| 5046 | if (ret < 0) |
| 5047 | { |
| 5048 | /* If the input value is greater than max value of datatype, then also |
| 5049 | kstrtou8 fails */ |
| 5050 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5051 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 5052 | CFG_ROAM_SCAN_N_PROBES_MIN, |
| 5053 | CFG_ROAM_SCAN_N_PROBES_MAX); |
| 5054 | ret = -EINVAL; |
| 5055 | goto exit; |
| 5056 | } |
| 5057 | |
| 5058 | if ((nProbes < CFG_ROAM_SCAN_N_PROBES_MIN) || |
| 5059 | (nProbes > CFG_ROAM_SCAN_N_PROBES_MAX)) |
| 5060 | { |
| 5061 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5062 | "NProbes value %d is out of range" |
| 5063 | " (Min: %d Max: %d)", nProbes, |
| 5064 | CFG_ROAM_SCAN_N_PROBES_MIN, |
| 5065 | CFG_ROAM_SCAN_N_PROBES_MAX); |
| 5066 | ret = -EINVAL; |
| 5067 | goto exit; |
| 5068 | } |
| 5069 | |
| 5070 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5071 | "%s: Received Command to Set nProbes = %d", __func__, nProbes); |
| 5072 | |
| 5073 | pHddCtx->cfg_ini->nProbes = nProbes; |
| 5074 | sme_UpdateRoamScanNProbes((tHalHandle)(pHddCtx->hHal), nProbes); |
| 5075 | } |
Mahesh A Saptasagar | ec7d109 | 2015-04-02 13:41:34 +0530 | [diff] [blame] | 5076 | else if (strncmp(command, "GETSCANNPROBES", 14) == 0) |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 5077 | { |
| 5078 | tANI_U8 val = sme_getRoamScanNProbes((tHalHandle)(pHddCtx->hHal)); |
| 5079 | char extra[32]; |
| 5080 | tANI_U8 len = 0; |
| 5081 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 5082 | len = scnprintf(extra, sizeof(extra), "%s %d", command, val); |
Ratnam Rachuri | 6da525d | 2015-08-07 13:55:54 +0530 | [diff] [blame] | 5083 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 5084 | if (copy_to_user(priv_data.buf, &extra, len)) { |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 5085 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5086 | "%s: failed to copy data to user buffer", __func__); |
| 5087 | ret = -EFAULT; |
| 5088 | goto exit; |
| 5089 | } |
| 5090 | } |
| 5091 | else if (strncmp(command, "SETSCANHOMEAWAYTIME", 19) == 0) |
| 5092 | { |
| 5093 | tANI_U8 *value = command; |
| 5094 | tANI_U16 homeAwayTime = CFG_ROAM_SCAN_HOME_AWAY_TIME_DEFAULT; |
| 5095 | |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 5096 | ret = hdd_drv_cmd_validate(command, 19); |
| 5097 | if (ret) |
| 5098 | goto exit; |
| 5099 | |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 5100 | /* Move pointer to ahead of SETSCANHOMEAWAYTIME<delimiter> */ |
| 5101 | /* input value is in units of msec */ |
| 5102 | value = value + 20; |
| 5103 | /* Convert the value from ascii to integer */ |
| 5104 | ret = kstrtou16(value, 10, &homeAwayTime); |
| 5105 | if (ret < 0) |
| 5106 | { |
| 5107 | /* If the input value is greater than max value of datatype, then also |
| 5108 | kstrtou8 fails */ |
| 5109 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5110 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 5111 | CFG_ROAM_SCAN_HOME_AWAY_TIME_MIN, |
| 5112 | CFG_ROAM_SCAN_HOME_AWAY_TIME_MAX); |
| 5113 | ret = -EINVAL; |
| 5114 | goto exit; |
| 5115 | } |
| 5116 | |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 5117 | if ((homeAwayTime < CFG_ROAM_SCAN_HOME_AWAY_TIME_MIN) || |
| 5118 | (homeAwayTime > CFG_ROAM_SCAN_HOME_AWAY_TIME_MAX)) |
| 5119 | { |
| 5120 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5121 | "homeAwayTime value %d is out of range" |
| 5122 | " (Min: %d Max: %d)", homeAwayTime, |
| 5123 | CFG_ROAM_SCAN_HOME_AWAY_TIME_MIN, |
| 5124 | CFG_ROAM_SCAN_HOME_AWAY_TIME_MAX); |
| 5125 | ret = -EINVAL; |
| 5126 | goto exit; |
| 5127 | } |
| 5128 | |
| 5129 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5130 | "%s: Received Command to Set scan away time = %d", __func__, homeAwayTime); |
Srinivas Girigowda | 6cf0b82 | 2013-06-27 14:00:20 -0700 | [diff] [blame] | 5131 | if (pHddCtx->cfg_ini->nRoamScanHomeAwayTime != homeAwayTime) |
| 5132 | { |
| 5133 | pHddCtx->cfg_ini->nRoamScanHomeAwayTime = homeAwayTime; |
| 5134 | sme_UpdateRoamScanHomeAwayTime((tHalHandle)(pHddCtx->hHal), homeAwayTime, eANI_BOOLEAN_TRUE); |
| 5135 | } |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 5136 | } |
Mahesh A Saptasagar | ec7d109 | 2015-04-02 13:41:34 +0530 | [diff] [blame] | 5137 | else if (strncmp(command, "GETSCANHOMEAWAYTIME", 19) == 0) |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 5138 | { |
| 5139 | tANI_U16 val = sme_getRoamScanHomeAwayTime((tHalHandle)(pHddCtx->hHal)); |
| 5140 | char extra[32]; |
| 5141 | tANI_U8 len = 0; |
| 5142 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 5143 | len = scnprintf(extra, sizeof(extra), "%s %d", command, val); |
Ratnam Rachuri | 51a5ad1 | 2015-08-07 14:06:37 +0530 | [diff] [blame] | 5144 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 5145 | if (copy_to_user(priv_data.buf, &extra, len)) { |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 5146 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5147 | "%s: failed to copy data to user buffer", __func__); |
| 5148 | ret = -EFAULT; |
| 5149 | goto exit; |
| 5150 | } |
| 5151 | } |
| 5152 | else if (strncmp(command, "REASSOC", 7) == 0) |
| 5153 | { |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 5154 | ret = hdd_drv_cmd_validate(command, 7); |
| 5155 | if (ret) |
| 5156 | goto exit; |
| 5157 | |
| 5158 | ret = hdd_parse_reassoc(pAdapter, command, priv_data.total_len); |
Selvaraj, Sridhar | 5aff1ed | 2016-06-18 01:26:23 +0530 | [diff] [blame] | 5159 | if (!ret) |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 5160 | goto exit; |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 5161 | } |
Srinivas Girigowda | ad34ca9 | 2013-10-22 10:54:29 -0700 | [diff] [blame] | 5162 | else if (strncmp(command, "SETWESMODE", 10) == 0) |
| 5163 | { |
| 5164 | tANI_U8 *value = command; |
| 5165 | tANI_BOOLEAN wesMode = CFG_ENABLE_WES_MODE_NAME_DEFAULT; |
| 5166 | |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 5167 | ret = hdd_drv_cmd_validate(command, 10); |
| 5168 | if (ret) |
| 5169 | goto exit; |
| 5170 | |
Srinivas Girigowda | ad34ca9 | 2013-10-22 10:54:29 -0700 | [diff] [blame] | 5171 | /* Move pointer to ahead of SETWESMODE<delimiter> */ |
| 5172 | value = value + 11; |
| 5173 | /* Convert the value from ascii to integer */ |
| 5174 | ret = kstrtou8(value, 10, &wesMode); |
| 5175 | if (ret < 0) |
| 5176 | { |
| 5177 | /* If the input value is greater than max value of datatype, then also |
| 5178 | kstrtou8 fails */ |
| 5179 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5180 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 5181 | CFG_ENABLE_WES_MODE_NAME_MIN, |
| 5182 | CFG_ENABLE_WES_MODE_NAME_MAX); |
| 5183 | ret = -EINVAL; |
| 5184 | goto exit; |
| 5185 | } |
| 5186 | |
| 5187 | if ((wesMode < CFG_ENABLE_WES_MODE_NAME_MIN) || |
| 5188 | (wesMode > CFG_ENABLE_WES_MODE_NAME_MAX)) |
| 5189 | { |
| 5190 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5191 | "WES Mode value %d is out of range" |
| 5192 | " (Min: %d Max: %d)", wesMode, |
| 5193 | CFG_ENABLE_WES_MODE_NAME_MIN, |
| 5194 | CFG_ENABLE_WES_MODE_NAME_MAX); |
| 5195 | ret = -EINVAL; |
| 5196 | goto exit; |
| 5197 | } |
| 5198 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5199 | "%s: Received Command to Set WES Mode rssi diff = %d", __func__, wesMode); |
| 5200 | |
| 5201 | pHddCtx->cfg_ini->isWESModeEnabled = wesMode; |
| 5202 | sme_UpdateWESMode((tHalHandle)(pHddCtx->hHal), wesMode); |
| 5203 | } |
Mahesh A Saptasagar | ec7d109 | 2015-04-02 13:41:34 +0530 | [diff] [blame] | 5204 | else if (strncmp(command, "GETWESMODE", 10) == 0) |
Srinivas Girigowda | ad34ca9 | 2013-10-22 10:54:29 -0700 | [diff] [blame] | 5205 | { |
| 5206 | tANI_BOOLEAN wesMode = sme_GetWESMode((tHalHandle)(pHddCtx->hHal)); |
| 5207 | char extra[32]; |
| 5208 | tANI_U8 len = 0; |
| 5209 | |
Arif Hussain | 826d941 | 2013-11-12 16:44:54 -0800 | [diff] [blame] | 5210 | len = scnprintf(extra, sizeof(extra), "%s %d", command, wesMode); |
Ratnam Rachuri | 8fe90c6 | 2015-08-07 14:03:26 +0530 | [diff] [blame] | 5211 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 5212 | if (copy_to_user(priv_data.buf, &extra, len)) { |
Srinivas Girigowda | ad34ca9 | 2013-10-22 10:54:29 -0700 | [diff] [blame] | 5213 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5214 | "%s: failed to copy data to user buffer", __func__); |
| 5215 | ret = -EFAULT; |
| 5216 | goto exit; |
| 5217 | } |
| 5218 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 5219 | #endif /* WLAN_FEATURE_VOWIFI_11R || FEATURE_WLAN_ESE || FEATURE_WLAN_LFR */ |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 5220 | #ifdef FEATURE_WLAN_LFR |
| 5221 | else if (strncmp(command, "SETFASTROAM", 11) == 0) |
| 5222 | { |
| 5223 | tANI_U8 *value = command; |
| 5224 | tANI_U8 lfrMode = CFG_LFR_FEATURE_ENABLED_DEFAULT; |
| 5225 | |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 5226 | if (pHddCtx->concurrency_mode == VOS_STA_MON) { |
| 5227 | hddLog(LOGE, |
| 5228 | FL("Roaming is always disabled in STA + MON concurrency")); |
| 5229 | ret = -EINVAL; |
| 5230 | goto exit; |
| 5231 | } |
| 5232 | |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 5233 | ret = hdd_drv_cmd_validate(command, 11); |
| 5234 | if (ret) |
| 5235 | goto exit; |
| 5236 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 5237 | /* Move pointer to ahead of SETFASTROAM<delimiter> */ |
| 5238 | value = value + 12; |
| 5239 | /* Convert the value from ascii to integer */ |
| 5240 | ret = kstrtou8(value, 10, &lfrMode); |
| 5241 | if (ret < 0) |
| 5242 | { |
| 5243 | /* If the input value is greater than max value of datatype, then also |
| 5244 | kstrtou8 fails */ |
| 5245 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5246 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 5247 | CFG_LFR_FEATURE_ENABLED_MIN, |
| 5248 | CFG_LFR_FEATURE_ENABLED_MAX); |
| 5249 | ret = -EINVAL; |
| 5250 | goto exit; |
| 5251 | } |
| 5252 | |
| 5253 | if ((lfrMode < CFG_LFR_FEATURE_ENABLED_MIN) || |
| 5254 | (lfrMode > CFG_LFR_FEATURE_ENABLED_MAX)) |
| 5255 | { |
| 5256 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5257 | "lfr mode value %d is out of range" |
| 5258 | " (Min: %d Max: %d)", lfrMode, |
| 5259 | CFG_LFR_FEATURE_ENABLED_MIN, |
| 5260 | CFG_LFR_FEATURE_ENABLED_MAX); |
| 5261 | ret = -EINVAL; |
| 5262 | goto exit; |
| 5263 | } |
| 5264 | |
| 5265 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5266 | "%s: Received Command to change lfr mode = %d", __func__, lfrMode); |
| 5267 | |
| 5268 | pHddCtx->cfg_ini->isFastRoamIniFeatureEnabled = lfrMode; |
| 5269 | sme_UpdateIsFastRoamIniFeatureEnabled((tHalHandle)(pHddCtx->hHal), lfrMode); |
| 5270 | } |
| 5271 | #endif |
| 5272 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 5273 | else if (strncmp(command, "SETFASTTRANSITION", 17) == 0) |
| 5274 | { |
| 5275 | tANI_U8 *value = command; |
| 5276 | tANI_U8 ft = CFG_FAST_TRANSITION_ENABLED_NAME_DEFAULT; |
| 5277 | |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 5278 | ret = hdd_drv_cmd_validate(command, 17); |
| 5279 | if (ret) |
| 5280 | goto exit; |
| 5281 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 5282 | /* Move pointer to ahead of SETFASTROAM<delimiter> */ |
| 5283 | value = value + 18; |
| 5284 | /* Convert the value from ascii to integer */ |
| 5285 | ret = kstrtou8(value, 10, &ft); |
| 5286 | if (ret < 0) |
| 5287 | { |
| 5288 | /* If the input value is greater than max value of datatype, then also |
| 5289 | kstrtou8 fails */ |
| 5290 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5291 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 5292 | CFG_FAST_TRANSITION_ENABLED_NAME_MIN, |
| 5293 | CFG_FAST_TRANSITION_ENABLED_NAME_MAX); |
| 5294 | ret = -EINVAL; |
| 5295 | goto exit; |
| 5296 | } |
| 5297 | |
| 5298 | if ((ft < CFG_FAST_TRANSITION_ENABLED_NAME_MIN) || |
| 5299 | (ft > CFG_FAST_TRANSITION_ENABLED_NAME_MAX)) |
| 5300 | { |
| 5301 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5302 | "ft mode value %d is out of range" |
| 5303 | " (Min: %d Max: %d)", ft, |
| 5304 | CFG_FAST_TRANSITION_ENABLED_NAME_MIN, |
| 5305 | CFG_FAST_TRANSITION_ENABLED_NAME_MAX); |
| 5306 | ret = -EINVAL; |
| 5307 | goto exit; |
| 5308 | } |
| 5309 | |
| 5310 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5311 | "%s: Received Command to change ft mode = %d", __func__, ft); |
| 5312 | |
| 5313 | pHddCtx->cfg_ini->isFastTransitionEnabled = ft; |
| 5314 | sme_UpdateFastTransitionEnabled((tHalHandle)(pHddCtx->hHal), ft); |
| 5315 | } |
Padma, Santhosh Kumar | 778d838 | 2015-03-04 17:41:22 +0530 | [diff] [blame] | 5316 | else if (strncmp(command, "SETDFSSCANMODE", 14) == 0) |
| 5317 | { |
| 5318 | tANI_U8 *value = command; |
| 5319 | tANI_U8 dfsScanMode = DFS_CHNL_SCAN_ENABLED_NORMAL; |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 5320 | |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 5321 | ret = hdd_drv_cmd_validate(command, 14); |
| 5322 | if (ret) |
| 5323 | goto exit; |
| 5324 | |
Padma, Santhosh Kumar | 778d838 | 2015-03-04 17:41:22 +0530 | [diff] [blame] | 5325 | /* Move pointer to ahead of SETDFSSCANMODE<delimiter> */ |
| 5326 | value = value + 15; |
| 5327 | /* Convert the value from ascii to integer */ |
| 5328 | ret = kstrtou8(value, 10, &dfsScanMode); |
| 5329 | if (ret < 0) |
| 5330 | { |
| 5331 | /* If the input value is greater than max value of |
| 5332 | datatype, then also kstrtou8 fails |
| 5333 | */ |
| 5334 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5335 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 5336 | CFG_ENABLE_DFS_CHNL_SCAN_MIN, |
| 5337 | CFG_ENABLE_DFS_CHNL_SCAN_MAX); |
| 5338 | ret = -EINVAL; |
| 5339 | goto exit; |
| 5340 | } |
| 5341 | |
| 5342 | if ((dfsScanMode < CFG_ENABLE_DFS_CHNL_SCAN_MIN) || |
| 5343 | (dfsScanMode > CFG_ENABLE_DFS_CHNL_SCAN_MAX)) |
| 5344 | { |
| 5345 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5346 | "dfsScanMode value %d is out of range" |
| 5347 | " (Min: %d Max: %d)", dfsScanMode, |
| 5348 | CFG_ENABLE_DFS_CHNL_SCAN_MIN, |
| 5349 | CFG_ENABLE_DFS_CHNL_SCAN_MAX); |
| 5350 | ret = -EINVAL; |
| 5351 | goto exit; |
| 5352 | } |
| 5353 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5354 | "%s: Received Command to Set DFS Scan Mode = %d", |
| 5355 | __func__, dfsScanMode); |
| 5356 | |
| 5357 | ret = wlan_hdd_handle_dfs_chan_scan(pHddCtx, dfsScanMode); |
| 5358 | } |
| 5359 | else if (strncmp(command, "GETDFSSCANMODE", 14) == 0) |
| 5360 | { |
| 5361 | tANI_U8 dfsScanMode = sme_GetDFSScanMode(pHddCtx->hHal); |
| 5362 | char extra[32]; |
| 5363 | tANI_U8 len = 0; |
| 5364 | |
| 5365 | len = scnprintf(extra, sizeof(extra), "%s %d", command, dfsScanMode); |
Ratheesh S P | 767224e | 2015-07-16 15:35:51 +0530 | [diff] [blame] | 5366 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 5367 | if (copy_to_user(priv_data.buf, &extra, len)) |
Padma, Santhosh Kumar | 778d838 | 2015-03-04 17:41:22 +0530 | [diff] [blame] | 5368 | { |
| 5369 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5370 | "%s: failed to copy data to user buffer", __func__); |
| 5371 | ret = -EFAULT; |
| 5372 | goto exit; |
| 5373 | } |
| 5374 | } |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 5375 | else if (strncmp(command, "FASTREASSOC", 11) == 0) |
| 5376 | { |
Selvaraj, Sridhar | 3714c4d | 2016-06-22 15:19:12 +0530 | [diff] [blame] | 5377 | ret = wlan_hdd_handle_fastreassoc(pAdapter, command); |
| 5378 | if (!ret) |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 5379 | goto exit; |
Madan Mohan Koyyalamudi | 4810141 | 2013-09-11 23:09:37 +0530 | [diff] [blame] | 5380 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 5381 | #endif |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 5382 | #ifdef FEATURE_WLAN_ESE |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 5383 | else if (strncmp(command, "SETCCXMODE", 10) == 0) |
| 5384 | { |
| 5385 | tANI_U8 *value = command; |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 5386 | tANI_U8 eseMode = CFG_ESE_FEATURE_ENABLED_DEFAULT; |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 5387 | |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 5388 | ret = hdd_drv_cmd_validate(command, 10); |
| 5389 | if (ret) |
| 5390 | goto exit; |
| 5391 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 5392 | /* Check if the features OKC/ESE/11R are supported simultaneously, |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 5393 | then this operation is not permitted (return FAILURE) */ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 5394 | if (sme_getIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal)) && |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 5395 | hdd_is_okc_mode_enabled(pHddCtx) && |
| 5396 | sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal))) |
| 5397 | { |
| 5398 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 5399 | "%s: OKC/ESE/11R are supported simultaneously" |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 5400 | " hence this operation is not permitted!", __func__); |
| 5401 | ret = -EPERM; |
| 5402 | goto exit; |
| 5403 | } |
| 5404 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 5405 | /* Move pointer to ahead of SETCCXMODE<delimiter> */ |
| 5406 | value = value + 11; |
| 5407 | /* Convert the value from ascii to integer */ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 5408 | ret = kstrtou8(value, 10, &eseMode); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 5409 | if (ret < 0) |
| 5410 | { |
| 5411 | /* If the input value is greater than max value of datatype, then also |
| 5412 | kstrtou8 fails */ |
| 5413 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5414 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 5415 | CFG_ESE_FEATURE_ENABLED_MIN, |
| 5416 | CFG_ESE_FEATURE_ENABLED_MAX); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 5417 | ret = -EINVAL; |
| 5418 | goto exit; |
| 5419 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 5420 | if ((eseMode < CFG_ESE_FEATURE_ENABLED_MIN) || |
| 5421 | (eseMode > CFG_ESE_FEATURE_ENABLED_MAX)) |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 5422 | { |
| 5423 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 5424 | "Ese mode value %d is out of range" |
| 5425 | " (Min: %d Max: %d)", eseMode, |
| 5426 | CFG_ESE_FEATURE_ENABLED_MIN, |
| 5427 | CFG_ESE_FEATURE_ENABLED_MAX); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 5428 | ret = -EINVAL; |
| 5429 | goto exit; |
| 5430 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 5431 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 5432 | "%s: Received Command to change ese mode = %d", __func__, eseMode); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 5433 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 5434 | pHddCtx->cfg_ini->isEseIniFeatureEnabled = eseMode; |
| 5435 | sme_UpdateIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal), eseMode); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 5436 | } |
| 5437 | #endif |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 5438 | else if (strncmp(command, "SETROAMSCANCONTROL", 18) == 0) |
| 5439 | { |
| 5440 | tANI_U8 *value = command; |
| 5441 | tANI_BOOLEAN roamScanControl = 0; |
| 5442 | |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 5443 | ret = hdd_drv_cmd_validate(command, 18); |
| 5444 | if (ret) |
| 5445 | goto exit; |
| 5446 | |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 5447 | /* Move pointer to ahead of SETROAMSCANCONTROL<delimiter> */ |
| 5448 | value = value + 19; |
| 5449 | /* Convert the value from ascii to integer */ |
| 5450 | ret = kstrtou8(value, 10, &roamScanControl); |
| 5451 | if (ret < 0) |
| 5452 | { |
| 5453 | /* If the input value is greater than max value of datatype, then also |
| 5454 | kstrtou8 fails */ |
| 5455 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5456 | "%s: kstrtou8 failed ", __func__); |
| 5457 | ret = -EINVAL; |
| 5458 | goto exit; |
| 5459 | } |
| 5460 | |
| 5461 | if (0 != roamScanControl) |
| 5462 | { |
| 5463 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5464 | "roam scan control invalid value = %d", |
| 5465 | roamScanControl); |
| 5466 | ret = -EINVAL; |
| 5467 | goto exit; |
| 5468 | } |
| 5469 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5470 | "%s: Received Command to Set roam scan control = %d", __func__, roamScanControl); |
| 5471 | |
| 5472 | sme_SetRoamScanControl((tHalHandle)(pHddCtx->hHal), roamScanControl); |
| 5473 | } |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 5474 | #ifdef FEATURE_WLAN_OKC |
| 5475 | else if (strncmp(command, "SETOKCMODE", 10) == 0) |
| 5476 | { |
| 5477 | tANI_U8 *value = command; |
| 5478 | tANI_U8 okcMode = CFG_OKC_FEATURE_ENABLED_DEFAULT; |
| 5479 | |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 5480 | ret = hdd_drv_cmd_validate(command, 10); |
| 5481 | if (ret) |
| 5482 | goto exit; |
| 5483 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 5484 | /* Check if the features OKC/ESE/11R are supported simultaneously, |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 5485 | then this operation is not permitted (return FAILURE) */ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 5486 | if (sme_getIsEseFeatureEnabled((tHalHandle)(pHddCtx->hHal)) && |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 5487 | hdd_is_okc_mode_enabled(pHddCtx) && |
| 5488 | sme_getIsFtFeatureEnabled((tHalHandle)(pHddCtx->hHal))) |
| 5489 | { |
| 5490 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 5491 | "%s: OKC/ESE/11R are supported simultaneously" |
Srinivas Girigowda | c6745a3 | 2013-07-15 19:19:10 -0700 | [diff] [blame] | 5492 | " hence this operation is not permitted!", __func__); |
| 5493 | ret = -EPERM; |
| 5494 | goto exit; |
| 5495 | } |
| 5496 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 5497 | /* Move pointer to ahead of SETOKCMODE<delimiter> */ |
| 5498 | value = value + 11; |
| 5499 | /* Convert the value from ascii to integer */ |
| 5500 | ret = kstrtou8(value, 10, &okcMode); |
| 5501 | if (ret < 0) |
| 5502 | { |
| 5503 | /* If the input value is greater than max value of datatype, then also |
| 5504 | kstrtou8 fails */ |
| 5505 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5506 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 5507 | CFG_OKC_FEATURE_ENABLED_MIN, |
| 5508 | CFG_OKC_FEATURE_ENABLED_MAX); |
| 5509 | ret = -EINVAL; |
| 5510 | goto exit; |
| 5511 | } |
| 5512 | |
| 5513 | if ((okcMode < CFG_OKC_FEATURE_ENABLED_MIN) || |
| 5514 | (okcMode > CFG_OKC_FEATURE_ENABLED_MAX)) |
| 5515 | { |
| 5516 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5517 | "Okc mode value %d is out of range" |
| 5518 | " (Min: %d Max: %d)", okcMode, |
| 5519 | CFG_OKC_FEATURE_ENABLED_MIN, |
| 5520 | CFG_OKC_FEATURE_ENABLED_MAX); |
| 5521 | ret = -EINVAL; |
| 5522 | goto exit; |
| 5523 | } |
| 5524 | |
| 5525 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5526 | "%s: Received Command to change okc mode = %d", __func__, okcMode); |
| 5527 | |
| 5528 | pHddCtx->cfg_ini->isOkcIniFeatureEnabled = okcMode; |
| 5529 | } |
Srinivas Girigowda | ad34ca9 | 2013-10-22 10:54:29 -0700 | [diff] [blame] | 5530 | #endif /* FEATURE_WLAN_OKC */ |
Mahesh A Saptasagar | ec7d109 | 2015-04-02 13:41:34 +0530 | [diff] [blame] | 5531 | else if (strncmp(command, "GETROAMSCANCONTROL", 18) == 0) |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 5532 | { |
| 5533 | tANI_BOOLEAN roamScanControl = sme_GetRoamScanControl((tHalHandle)(pHddCtx->hHal)); |
| 5534 | char extra[32]; |
| 5535 | tANI_U8 len = 0; |
| 5536 | |
Sameer Thalappil | b0a3023 | 2013-09-27 15:37:48 -0700 | [diff] [blame] | 5537 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 5538 | command, roamScanControl); |
Ratnam Rachuri | 083ada8 | 2015-08-07 14:01:05 +0530 | [diff] [blame] | 5539 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 5540 | if (copy_to_user(priv_data.buf, &extra, len)) { |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 5541 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5542 | "%s: failed to copy data to user buffer", __func__); |
| 5543 | ret = -EFAULT; |
| 5544 | goto exit; |
| 5545 | } |
| 5546 | } |
Gopichand Nakkala | 227c7f3 | 2013-06-26 22:44:57 +0530 | [diff] [blame] | 5547 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 5548 | else if (strncmp(command, "ENABLE_PKTFILTER_IPV6", 21) == 0) |
| 5549 | { |
| 5550 | tANI_U8 filterType = 0; |
| 5551 | tANI_U8 *value = command; |
| 5552 | |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 5553 | ret = hdd_drv_cmd_validate(command, 21); |
| 5554 | if (ret) |
| 5555 | goto exit; |
| 5556 | |
Gopichand Nakkala | 227c7f3 | 2013-06-26 22:44:57 +0530 | [diff] [blame] | 5557 | /* Move pointer to ahead of ENABLE_PKTFILTER_IPV6<delimiter> */ |
| 5558 | value = value + 22; |
| 5559 | |
| 5560 | /* Convert the value from ascii to integer */ |
| 5561 | ret = kstrtou8(value, 10, &filterType); |
| 5562 | if (ret < 0) |
| 5563 | { |
| 5564 | /* If the input value is greater than max value of datatype, |
| 5565 | * then also kstrtou8 fails |
| 5566 | */ |
| 5567 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5568 | "%s: kstrtou8 failed range ", __func__); |
| 5569 | ret = -EINVAL; |
| 5570 | goto exit; |
| 5571 | } |
| 5572 | |
| 5573 | if (filterType != 0 && filterType != 1) |
| 5574 | { |
| 5575 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5576 | "%s: Accepted Values are 0 and 1 ", __func__); |
| 5577 | ret = -EINVAL; |
| 5578 | goto exit; |
| 5579 | } |
| 5580 | wlan_hdd_setIPv6Filter(WLAN_HDD_GET_CTX(pAdapter), filterType, |
| 5581 | pAdapter->sessionId); |
| 5582 | } |
| 5583 | #endif |
Sundaresan Ramachandran | 76e48e8 | 2013-07-15 13:07:17 +0530 | [diff] [blame] | 5584 | else if (strncmp(command, "BTCOEXMODE", 10) == 0 ) |
| 5585 | { |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 5586 | char *dhcpPhase; |
Satyanarayana Dash | 1faea4f | 2014-09-22 16:21:04 +0530 | [diff] [blame] | 5587 | int ret; |
| 5588 | |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 5589 | ret = hdd_drv_cmd_validate(command, 10); |
| 5590 | if (ret) |
| 5591 | goto exit; |
| 5592 | |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 5593 | dhcpPhase = command + 11; |
| 5594 | if ('1' == *dhcpPhase) |
Sundaresan Ramachandran | 76e48e8 | 2013-07-15 13:07:17 +0530 | [diff] [blame] | 5595 | { |
Deepthi Gowri | bfd1713 | 2014-11-14 17:59:04 +0530 | [diff] [blame] | 5596 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 5597 | FL("send DHCP START indication")); |
c_hpothu | 9b781ba | 2013-12-30 20:57:45 +0530 | [diff] [blame] | 5598 | |
| 5599 | pHddCtx->btCoexModeSet = TRUE; |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 5600 | |
Satyanarayana Dash | 1faea4f | 2014-09-22 16:21:04 +0530 | [diff] [blame] | 5601 | ret = wlan_hdd_scan_abort(pAdapter); |
| 5602 | if (ret < 0) |
| 5603 | { |
| 5604 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5605 | FL("failed to abort existing scan %d"), ret); |
| 5606 | } |
| 5607 | |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 5608 | sme_DHCPStartInd(pHddCtx->hHal, pAdapter->device_mode, |
| 5609 | pAdapter->sessionId); |
Sundaresan Ramachandran | 76e48e8 | 2013-07-15 13:07:17 +0530 | [diff] [blame] | 5610 | } |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 5611 | else if ('2' == *dhcpPhase) |
Sundaresan Ramachandran | 76e48e8 | 2013-07-15 13:07:17 +0530 | [diff] [blame] | 5612 | { |
Deepthi Gowri | bfd1713 | 2014-11-14 17:59:04 +0530 | [diff] [blame] | 5613 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 5614 | FL("send DHCP STOP indication")); |
c_hpothu | 9b781ba | 2013-12-30 20:57:45 +0530 | [diff] [blame] | 5615 | |
| 5616 | pHddCtx->btCoexModeSet = FALSE; |
Kiet Lam | ad16125 | 2014-07-22 11:23:32 -0700 | [diff] [blame] | 5617 | |
| 5618 | sme_DHCPStopInd(pHddCtx->hHal, pAdapter->device_mode, |
| 5619 | pAdapter->sessionId); |
Sundaresan Ramachandran | 76e48e8 | 2013-07-15 13:07:17 +0530 | [diff] [blame] | 5620 | } |
| 5621 | } |
Jeff Johnson | f54df2c | 2013-07-24 11:43:39 -0700 | [diff] [blame] | 5622 | else if (strncmp(command, "SCAN-ACTIVE", 11) == 0) |
| 5623 | { |
Abhishek Singh | 58749d6 | 2016-02-03 15:27:20 +0530 | [diff] [blame] | 5624 | hddLog(LOG1, |
| 5625 | FL("making default scan to ACTIVE")); |
c_hpothu | dbefd3e | 2014-04-28 15:59:47 +0530 | [diff] [blame] | 5626 | pHddCtx->scan_info.scan_mode = eSIR_ACTIVE_SCAN; |
Jeff Johnson | f54df2c | 2013-07-24 11:43:39 -0700 | [diff] [blame] | 5627 | } |
| 5628 | else if (strncmp(command, "SCAN-PASSIVE", 12) == 0) |
| 5629 | { |
Abhishek Singh | 58749d6 | 2016-02-03 15:27:20 +0530 | [diff] [blame] | 5630 | hddLog(LOG1, |
| 5631 | FL("making default scan to PASSIVE")); |
c_hpothu | dbefd3e | 2014-04-28 15:59:47 +0530 | [diff] [blame] | 5632 | pHddCtx->scan_info.scan_mode = eSIR_PASSIVE_SCAN; |
Jeff Johnson | f54df2c | 2013-07-24 11:43:39 -0700 | [diff] [blame] | 5633 | } |
Hanumantha Reddy Pothula | 212243c | 2013-08-01 17:28:31 +0530 | [diff] [blame] | 5634 | else if (strncmp(command, "GETDWELLTIME", 12) == 0) |
| 5635 | { |
| 5636 | hdd_config_t *pCfg = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini; |
| 5637 | char extra[32]; |
| 5638 | tANI_U8 len = 0; |
| 5639 | |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 5640 | memset(extra, 0, sizeof(extra)); |
| 5641 | ret = hdd_get_dwell_time(pCfg, command, extra, sizeof(extra), &len); |
Ratnam Rachuri | 12d5d46 | 2015-08-07 14:10:23 +0530 | [diff] [blame] | 5642 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 5643 | if (ret != 0 || copy_to_user(priv_data.buf, &extra, len)) { |
Hanumantha Reddy Pothula | 212243c | 2013-08-01 17:28:31 +0530 | [diff] [blame] | 5644 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5645 | "%s: failed to copy data to user buffer", __func__); |
| 5646 | ret = -EFAULT; |
| 5647 | goto exit; |
| 5648 | } |
| 5649 | ret = len; |
| 5650 | } |
| 5651 | else if (strncmp(command, "SETDWELLTIME", 12) == 0) |
| 5652 | { |
Rajesh Babu Prathipati | c7baf6f | 2014-05-30 10:08:16 +0530 | [diff] [blame] | 5653 | ret = hdd_set_dwell_time(pAdapter, command); |
Hanumantha Reddy Pothula | 212243c | 2013-08-01 17:28:31 +0530 | [diff] [blame] | 5654 | } |
Dundi Raviteja | ae5adf4 | 2018-04-23 20:44:47 +0530 | [diff] [blame] | 5655 | else if (strncmp(command, "BTCGETDWELLTIME", 15) == 0) |
| 5656 | { |
| 5657 | hdd_config_t *pCfg = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini; |
| 5658 | char extra[32]; |
| 5659 | tANI_U8 len = 0; |
| 5660 | |
| 5661 | if (hdd_drv_cmd_validate(command, 15)) { |
| 5662 | hddLog(LOGE, FL("Invalid driver command")); |
| 5663 | return -EINVAL; |
| 5664 | } |
| 5665 | |
| 5666 | memset(extra, 0, sizeof(extra)); |
| 5667 | ret = hdd_btc_get_dwell_time(pCfg, command, extra, |
| 5668 | sizeof(extra), &len); |
| 5669 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 5670 | if (ret != 0 || copy_to_user(priv_data.buf, &extra, len)) { |
| 5671 | hddLog(LOGE, FL("Failed to copy data to user buffer")); |
| 5672 | ret = -EFAULT; |
| 5673 | goto exit; |
| 5674 | } |
| 5675 | ret = len; |
| 5676 | } |
| 5677 | else if (strncmp(command, "BTCSETDWELLTIME", 15) == 0) |
| 5678 | { |
| 5679 | if (hdd_drv_cmd_validate(command, 15)) { |
| 5680 | hddLog(LOGE, FL("Invalid driver command")); |
| 5681 | return -EINVAL; |
| 5682 | } |
| 5683 | ret = hdd_btc_set_dwell_time(pAdapter, command); |
| 5684 | } |
| 5685 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 5686 | else if (strncmp(command, "CONCGETDWELLTIME", 16) == 0) |
| 5687 | { |
| 5688 | hdd_config_t *pCfg = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini; |
| 5689 | char extra[32]; |
| 5690 | tANI_U8 len = 0; |
| 5691 | |
| 5692 | if (hdd_drv_cmd_validate(command, 16)) { |
| 5693 | hddLog(LOGE, FL("Invalid driver command")); |
| 5694 | return -EINVAL; |
| 5695 | } |
| 5696 | |
| 5697 | memset(extra, 0, sizeof(extra)); |
| 5698 | ret = hdd_conc_get_dwell_time(pCfg, command, extra, |
| 5699 | sizeof(extra), &len); |
| 5700 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 5701 | if (ret != 0 || copy_to_user(priv_data.buf, &extra, len)) { |
| 5702 | hddLog(LOGE, FL("Failed to copy data to user buffer")); |
| 5703 | ret = -EFAULT; |
| 5704 | goto exit; |
| 5705 | } |
| 5706 | ret = len; |
| 5707 | } |
| 5708 | else if (strncmp(command, "CONCSETDWELLTIME", 16) == 0) |
| 5709 | { |
| 5710 | if (hdd_drv_cmd_validate(command, 16)) { |
| 5711 | hddLog(LOGE, FL("Invalid driver command")); |
| 5712 | return -EINVAL; |
| 5713 | } |
| 5714 | ret = hdd_conc_set_dwell_time(pAdapter, command); |
| 5715 | } |
| 5716 | #endif |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 5717 | else if ( strncasecmp(command, "MIRACAST", 8) == 0 ) |
| 5718 | { |
| 5719 | tANI_U8 filterType = 0; |
| 5720 | tANI_U8 *value; |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 5721 | |
| 5722 | ret = hdd_drv_cmd_validate(command, 8); |
| 5723 | if (ret) |
| 5724 | goto exit; |
| 5725 | |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 5726 | value = command + 9; |
| 5727 | |
| 5728 | /* Convert the value from ascii to integer */ |
| 5729 | ret = kstrtou8(value, 10, &filterType); |
| 5730 | if (ret < 0) |
| 5731 | { |
| 5732 | /* If the input value is greater than max value of datatype, |
| 5733 | * then also kstrtou8 fails |
| 5734 | */ |
| 5735 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5736 | "%s: kstrtou8 failed range ", __func__); |
| 5737 | ret = -EINVAL; |
| 5738 | goto exit; |
| 5739 | } |
| 5740 | if ((filterType < WLAN_HDD_DRIVER_MIRACAST_CFG_MIN_VAL ) || |
| 5741 | (filterType > WLAN_HDD_DRIVER_MIRACAST_CFG_MAX_VAL)) |
| 5742 | { |
| 5743 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5744 | "%s: Accepted Values are 0 to 2. 0-Disabled, 1-Source," |
| 5745 | " 2-Sink ", __func__); |
| 5746 | ret = -EINVAL; |
| 5747 | goto exit; |
| 5748 | } |
| 5749 | //Filtertype value should be either 0-Disabled, 1-Source, 2-sink |
| 5750 | pHddCtx->drvr_miracast = filterType; |
Kaushik, Sushant | 9612244 | 2014-10-21 16:40:18 +0530 | [diff] [blame] | 5751 | pScanInfo = &pHddCtx->scan_info; |
| 5752 | if (filterType && pScanInfo != NULL && |
| 5753 | pHddCtx->scan_info.mScanPending) |
| 5754 | { |
| 5755 | /*Miracast Session started. Abort Scan */ |
| 5756 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5757 | "%s, Aborting Scan For Miracast",__func__); |
| 5758 | hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId, |
| 5759 | eCSR_SCAN_ABORT_DEFAULT); |
| 5760 | } |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 5761 | hdd_tx_rx_pkt_cnt_stat_timer_handler(pHddCtx); |
Ganesh Kondabattini | 8f6e3b3 | 2014-08-25 16:07:54 +0530 | [diff] [blame] | 5762 | sme_SetMiracastMode(pHddCtx->hHal, pHddCtx->drvr_miracast); |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 5763 | } |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 5764 | else if (strncmp(command, "SETMCRATE", 9) == 0) |
| 5765 | { |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 5766 | tANI_U8 *value = command; |
| 5767 | int targetRate; |
Leo Chang | 1f98cbd | 2013-10-17 15:03:52 -0700 | [diff] [blame] | 5768 | tSirRateUpdateInd *rateUpdate; |
| 5769 | eHalStatus status; |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 5770 | |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 5771 | ret = hdd_drv_cmd_validate(command, 9); |
| 5772 | if (ret) |
| 5773 | goto exit; |
| 5774 | |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 5775 | /* Only valid for SAP mode */ |
| 5776 | if (WLAN_HDD_SOFTAP != pAdapter->device_mode) |
| 5777 | { |
| 5778 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5779 | "%s: SAP mode is not running", __func__); |
| 5780 | ret = -EFAULT; |
| 5781 | goto exit; |
| 5782 | } |
| 5783 | |
| 5784 | /* Move pointer to ahead of SETMCRATE<delimiter> */ |
| 5785 | /* input value is in units of hundred kbps */ |
| 5786 | value = value + 10; |
| 5787 | /* Convert the value from ascii to integer, decimal base */ |
| 5788 | ret = kstrtouint(value, 10, &targetRate); |
| 5789 | |
Leo Chang | 1f98cbd | 2013-10-17 15:03:52 -0700 | [diff] [blame] | 5790 | rateUpdate = (tSirRateUpdateInd *)vos_mem_malloc(sizeof(tSirRateUpdateInd)); |
| 5791 | if (NULL == rateUpdate) |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 5792 | { |
Leo Chang | 1f98cbd | 2013-10-17 15:03:52 -0700 | [diff] [blame] | 5793 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5794 | "%s: SETMCRATE indication alloc fail", __func__); |
| 5795 | ret = -EFAULT; |
| 5796 | goto exit; |
| 5797 | } |
| 5798 | vos_mem_zero(rateUpdate, sizeof(tSirRateUpdateInd )); |
| 5799 | |
| 5800 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 5801 | "MC Target rate %d", targetRate); |
| 5802 | /* Ignore unicast */ |
| 5803 | rateUpdate->ucastDataRate = -1; |
| 5804 | rateUpdate->mcastDataRate24GHz = targetRate; |
| 5805 | rateUpdate->mcastDataRate5GHz = targetRate; |
| 5806 | rateUpdate->mcastDataRate24GHzTxFlag = 0; |
| 5807 | rateUpdate->mcastDataRate5GHzTxFlag = 0; |
| 5808 | status = sme_SendRateUpdateInd(pHddCtx->hHal, rateUpdate); |
| 5809 | if (eHAL_STATUS_SUCCESS != status) |
| 5810 | { |
| 5811 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5812 | "%s: SET_MC_RATE failed", __func__); |
| 5813 | vos_mem_free(rateUpdate); |
| 5814 | ret = -EFAULT; |
| 5815 | goto exit; |
Leo Chang | 614d207 | 2013-08-22 14:59:44 -0700 | [diff] [blame] | 5816 | } |
| 5817 | } |
jge | 3556720 | 2017-06-21 16:39:38 +0800 | [diff] [blame] | 5818 | else if (strncmp(command, "MAXTXPOWER", 10) == 0) |
| 5819 | { |
| 5820 | int status; |
| 5821 | int txPower; |
| 5822 | eHalStatus smeStatus; |
| 5823 | tANI_U8 *value = command; |
| 5824 | tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
| 5825 | tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
| 5826 | |
| 5827 | status = hdd_parse_setmaxtxpower_command(value, &txPower); |
| 5828 | if (status) |
| 5829 | { |
| 5830 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5831 | "Invalid MAXTXPOWER command "); |
| 5832 | ret = -EINVAL; |
| 5833 | goto exit; |
| 5834 | } |
| 5835 | |
| 5836 | hddLog(VOS_TRACE_LEVEL_INFO, "max tx power %d selfMac: " |
| 5837 | MAC_ADDRESS_STR " bssId: " MAC_ADDRESS_STR " ", |
| 5838 | txPower, MAC_ADDR_ARRAY(selfMac), |
| 5839 | MAC_ADDR_ARRAY(bssid)); |
| 5840 | smeStatus = sme_SetMaxTxPower((tHalHandle)(pHddCtx->hHal), |
| 5841 | bssid, selfMac, txPower) ; |
| 5842 | if( smeStatus != eHAL_STATUS_SUCCESS ) |
| 5843 | { |
| 5844 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s:Set max tx power failed", |
| 5845 | __func__); |
| 5846 | ret = -EINVAL; |
| 5847 | goto exit; |
| 5848 | } |
| 5849 | |
| 5850 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Set max tx power success", |
| 5851 | __func__); |
| 5852 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 5853 | #ifdef FEATURE_WLAN_BATCH_SCAN |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 5854 | else if (strncmp(command, "WLS_BATCHING", 12) == 0) |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 5855 | { |
Rajeev Kumar | 8b37329 | 2014-01-08 20:36:55 -0800 | [diff] [blame] | 5856 | ret = hdd_handle_batch_scan_ioctl(pAdapter, &priv_data, command); |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 5857 | } |
| 5858 | #endif |
Abhishek Singh | 00b7197 | 2016-01-07 10:51:04 +0530 | [diff] [blame] | 5859 | #ifdef WLAN_FEATURE_RMC |
| 5860 | else if ((strncasecmp(command, "SETIBSSBEACONOUIDATA", 20) == 0) && |
| 5861 | (WLAN_HDD_IBSS == pAdapter->device_mode)) |
| 5862 | { |
| 5863 | int i = 0; |
| 5864 | tANI_U8 *ibss_ie; |
| 5865 | tANI_U32 command_len; |
| 5866 | tANI_U8 *value = command; |
| 5867 | tHalHandle hHal = pHddCtx->hHal; |
| 5868 | tpAniSirGlobal pMac = PMAC_STRUCT(hHal); |
| 5869 | tANI_U32 ibss_ie_length; |
| 5870 | tANI_U32 len, present; |
| 5871 | tANI_U8 *addIE; |
| 5872 | tANI_U8 *addIEData; |
| 5873 | |
| 5874 | hddLog(LOG1, |
| 5875 | FL(" received command %s"),((char *) value)); |
| 5876 | /* validate argument of command */ |
| 5877 | if (strlen(value) <= 21) |
| 5878 | { |
| 5879 | hddLog(LOGE, |
| 5880 | FL("No arguements in command length %zu"), strlen(value)); |
| 5881 | ret = -EFAULT; |
| 5882 | goto exit; |
| 5883 | } |
| 5884 | |
| 5885 | /* moving to arguments of commands */ |
| 5886 | value = value + 21; |
| 5887 | command_len = strlen(value); |
| 5888 | |
| 5889 | /* oui_data can't be less than 3 bytes */ |
| 5890 | if (command_len <= (2 * WLAN_HDD_IBSS_MIN_OUI_DATA_LENGTH)) |
| 5891 | { |
| 5892 | hddLog(LOGE, |
| 5893 | FL("Invalid SETIBSSBEACONOUIDATA command length %d"), |
| 5894 | command_len); |
| 5895 | ret = -EFAULT; |
| 5896 | goto exit; |
| 5897 | } |
| 5898 | ibss_ie = vos_mem_malloc(command_len); |
| 5899 | if (!ibss_ie) { |
| 5900 | hddLog(LOGE, |
| 5901 | FL("Could not allocate memory for command length %d"), |
| 5902 | command_len); |
| 5903 | ret = -ENOMEM; |
| 5904 | goto exit; |
| 5905 | } |
| 5906 | vos_mem_zero(ibss_ie, command_len); |
| 5907 | |
| 5908 | ibss_ie_length = hdd_parse_set_ibss_oui_data_command(value, ibss_ie, |
| 5909 | command_len); |
| 5910 | if (ibss_ie_length < (2 * WLAN_HDD_IBSS_MIN_OUI_DATA_LENGTH)) { |
| 5911 | hddLog(LOGE, FL("Could not parse command %s return length %d"), |
| 5912 | value, ibss_ie_length); |
| 5913 | ret = -EFAULT; |
| 5914 | vos_mem_free(ibss_ie); |
| 5915 | goto exit; |
| 5916 | } |
| 5917 | |
| 5918 | hddLog(LOG1, FL("ibss_ie length %d ibss_ie:"), ibss_ie_length); |
| 5919 | while (i < ibss_ie_length) |
| 5920 | hddLog(LOG1, FL("0x%x"), ibss_ie[i++]); |
| 5921 | |
| 5922 | /* Populate Vendor IE in Beacon */ |
| 5923 | if ((ccmCfgGetInt(hHal, |
| 5924 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, |
| 5925 | &present)) != eHAL_STATUS_SUCCESS) |
| 5926 | { |
| 5927 | hddLog(LOGE, |
| 5928 | FL("unable to ftch WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG")); |
| 5929 | ret = -EFAULT; |
| 5930 | vos_mem_free(ibss_ie); |
| 5931 | goto exit; |
| 5932 | } |
| 5933 | |
| 5934 | addIE = vos_mem_malloc(WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA_LEN); |
| 5935 | if (!addIE) { |
| 5936 | hddLog(LOGE, |
| 5937 | FL("Could not allocate memory for command length %d"), |
| 5938 | command_len); |
| 5939 | vos_mem_free(ibss_ie); |
| 5940 | ret = -ENOMEM; |
| 5941 | goto exit; |
| 5942 | } |
| 5943 | vos_mem_zero(addIE, WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA_LEN); |
| 5944 | |
| 5945 | if (present) |
| 5946 | { |
| 5947 | if ((wlan_cfgGetStrLen(pMac, |
| 5948 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, &len)) != eSIR_SUCCESS) |
| 5949 | { |
| 5950 | hddLog(LOGE, |
| 5951 | FL("unable to fetch WNI_CFG_PROBE_RSP_BCN_ADDNIE_LEN")); |
| 5952 | ret = -EFAULT; |
| 5953 | vos_mem_free(ibss_ie); |
| 5954 | vos_mem_free(addIE); |
| 5955 | goto exit; |
| 5956 | } |
| 5957 | |
| 5958 | if (len <= WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA_LEN && len && |
| 5959 | ((len + ibss_ie_length) <= |
| 5960 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA_LEN)) |
| 5961 | { |
| 5962 | if ((ccmCfgGetStr(hHal, |
| 5963 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, addIE, &len)) |
| 5964 | != eHAL_STATUS_SUCCESS) |
| 5965 | { |
| 5966 | hddLog(LOGE, |
| 5967 | FL("unable to fetch WNI_PROBE_RSP_BCN_ADDNIE_DATA")); |
| 5968 | ret = -EFAULT; |
| 5969 | vos_mem_free(ibss_ie); |
| 5970 | vos_mem_free(addIE); |
| 5971 | goto exit; |
| 5972 | } |
| 5973 | else |
| 5974 | { |
| 5975 | /* Curruntly only WPA IE is added before Vendor IE |
| 5976 | * so we can blindly place the Vendor IE after WPA |
| 5977 | * IE. If no WPA IE found replace all with Vendor IE. |
| 5978 | */ |
| 5979 | len = hdd_find_ibss_wpa_ie_pos(addIE, len); |
| 5980 | } |
| 5981 | } |
| 5982 | else |
| 5983 | { |
| 5984 | hddLog(LOGE, |
| 5985 | FL("IE len exceed limit len %d,ibss_ie_length %d "), |
| 5986 | len, ibss_ie_length); |
| 5987 | ret = -EFAULT; |
| 5988 | vos_mem_free(addIE); |
| 5989 | vos_mem_free(ibss_ie); |
| 5990 | goto exit; |
| 5991 | } |
| 5992 | } |
| 5993 | else { |
| 5994 | len = 0; |
| 5995 | } |
| 5996 | |
| 5997 | vos_mem_copy (addIE + len , ibss_ie, ibss_ie_length); |
| 5998 | len += ibss_ie_length; |
| 5999 | |
| 6000 | if (ccmCfgSetStr(hHal, |
| 6001 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, addIE, len, NULL, |
| 6002 | eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS) |
| 6003 | { |
| 6004 | hddLog(LOGE, |
| 6005 | FL("unable to set WNI_CFG_PRBE_RSP_BCN_ADDNIE_DATA")); |
| 6006 | ret = -EFAULT; |
| 6007 | vos_mem_free(ibss_ie); |
| 6008 | vos_mem_free(addIE); |
| 6009 | goto exit; |
| 6010 | } |
| 6011 | vos_mem_free(addIE); |
| 6012 | if (ccmCfgSetInt(hHal, |
| 6013 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL, |
| 6014 | eANI_BOOLEAN_FALSE) != eHAL_STATUS_SUCCESS) |
| 6015 | { |
| 6016 | hddLog(LOGE, |
| 6017 | FL("unble to set WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG")); |
| 6018 | ret = -EFAULT; |
| 6019 | vos_mem_free(ibss_ie); |
| 6020 | goto exit; |
| 6021 | } |
| 6022 | |
| 6023 | /* Populate Vendor IE in probe resp */ |
| 6024 | if ((ccmCfgGetInt(hHal, |
| 6025 | WNI_CFG_PROBE_RSP_ADDNIE_FLAG, |
| 6026 | &present)) != eHAL_STATUS_SUCCESS) |
| 6027 | { |
| 6028 | hddLog(LOGE, |
| 6029 | FL("unable to fetch WNI_CFG_PROBE_RSP_ADDNIE_FLAG")); |
| 6030 | ret = -EFAULT; |
| 6031 | vos_mem_free(ibss_ie); |
| 6032 | goto exit; |
| 6033 | } |
| 6034 | |
| 6035 | addIEData = vos_mem_malloc(WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN); |
| 6036 | if (!addIEData) { |
| 6037 | hddLog(LOGE, |
| 6038 | FL("Could not allocate memory for command length %d"), |
| 6039 | command_len); |
| 6040 | vos_mem_free(ibss_ie); |
| 6041 | ret = -ENOMEM; |
| 6042 | goto exit; |
| 6043 | } |
| 6044 | vos_mem_zero(addIEData, WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN); |
| 6045 | |
| 6046 | if (present) { |
| 6047 | if (eSIR_SUCCESS != wlan_cfgGetStrLen(pMac, |
| 6048 | WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &len)) { |
| 6049 | hddLog(LOGE, |
| 6050 | FL("unable to fetch WNI_CFG_PROBE_RSP_ADDNIE_DATA1")); |
| 6051 | ret = -EFAULT; |
| 6052 | vos_mem_free(ibss_ie); |
| 6053 | vos_mem_free(addIEData); |
| 6054 | goto exit; |
| 6055 | } |
| 6056 | if (len < WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN && len && |
| 6057 | (ibss_ie_length + len) <= |
| 6058 | WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN) { |
| 6059 | |
| 6060 | if ((ccmCfgGetStr(hHal, |
| 6061 | WNI_CFG_PROBE_RSP_ADDNIE_DATA1, addIEData, &len)) |
| 6062 | != eHAL_STATUS_SUCCESS) { |
| 6063 | hddLog(LOGE, |
| 6064 | FL("unable fetch WNI_CFG_PROBE_RSP_ADDNIE_DATA1")); |
| 6065 | ret = -EFAULT; |
| 6066 | vos_mem_free(ibss_ie); |
| 6067 | vos_mem_free(addIEData); |
| 6068 | goto exit; |
| 6069 | } |
| 6070 | else { |
| 6071 | /* Curruntly only WPA IE is added before Vendor IE |
| 6072 | * so we can blindly place the Vendor IE after WPA |
| 6073 | * IE. If no WPA IE found replace all with Vendor IE. |
| 6074 | */ |
| 6075 | len = hdd_find_ibss_wpa_ie_pos(addIEData, len); |
| 6076 | } |
| 6077 | } |
| 6078 | else |
| 6079 | { |
| 6080 | hddLog(LOGE, |
| 6081 | FL("IE len exceed limit len %d,ibss_ie_length %d "), |
| 6082 | len, ibss_ie_length); |
| 6083 | ret = -EFAULT; |
| 6084 | vos_mem_free(addIEData); |
| 6085 | vos_mem_free(ibss_ie); |
| 6086 | goto exit; |
| 6087 | } |
| 6088 | } /* probe rsp ADD IE present */ |
| 6089 | else { |
| 6090 | /* probe rsp add IE is not present */ |
| 6091 | len = 0; |
| 6092 | } |
| 6093 | |
| 6094 | vos_mem_copy(addIEData +len , ibss_ie, ibss_ie_length); |
| 6095 | len += ibss_ie_length; |
| 6096 | |
| 6097 | vos_mem_free(ibss_ie); |
| 6098 | |
| 6099 | if (ccmCfgSetStr(hHal, |
| 6100 | WNI_CFG_PROBE_RSP_ADDNIE_DATA1, |
| 6101 | (tANI_U8*)(addIEData), |
| 6102 | len, NULL, |
| 6103 | eANI_BOOLEAN_FALSE) |
| 6104 | == eHAL_STATUS_FAILURE) { |
| 6105 | hddLog(LOGE, |
| 6106 | FL("unable to copy to WNI_CFG_PROBE_RSP_ADDNIE_DATA1")); |
| 6107 | ret = -EFAULT; |
| 6108 | vos_mem_free(addIEData); |
| 6109 | goto exit; |
| 6110 | } |
| 6111 | vos_mem_free(addIEData); |
| 6112 | if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 6113 | WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL, |
| 6114 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 6115 | { |
| 6116 | hddLog(LOGE, |
| 6117 | FL("unable to copy WNI_CFG_PROBE_RSP_ADDNIE_FLAG")); |
| 6118 | ret = -EFAULT; |
| 6119 | goto exit; |
| 6120 | } |
| 6121 | } |
| 6122 | else if (strncasecmp(command, "SETRMCENABLE", 12) == 0) |
| 6123 | { |
| 6124 | tANI_U8 *value = command; |
| 6125 | tANI_U8 ucRmcEnable = 0; |
| 6126 | int status; |
| 6127 | |
| 6128 | if ((WLAN_HDD_IBSS != pAdapter->device_mode) && |
| 6129 | (WLAN_HDD_SOFTAP != pAdapter->device_mode)) |
| 6130 | { |
| 6131 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6132 | "Received SETRMCENABLE command in invalid mode %d " |
| 6133 | "SETRMCENABLE command is only allowed in IBSS or SOFTAP mode", |
| 6134 | pAdapter->device_mode); |
| 6135 | ret = -EINVAL; |
| 6136 | goto exit; |
| 6137 | } |
| 6138 | |
| 6139 | status = hdd_parse_setrmcenable_command(value, &ucRmcEnable); |
| 6140 | if (status) |
| 6141 | { |
| 6142 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6143 | "Invalid SETRMCENABLE command "); |
| 6144 | ret = -EINVAL; |
| 6145 | goto exit; |
| 6146 | } |
| 6147 | |
| 6148 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 6149 | "%s: ucRmcEnable %d ", __func__, ucRmcEnable); |
| 6150 | |
| 6151 | if (TRUE == ucRmcEnable) |
| 6152 | { |
| 6153 | status = sme_EnableRMC( (tHalHandle)(pHddCtx->hHal), |
| 6154 | pAdapter->sessionId ); |
| 6155 | } |
| 6156 | else if(FALSE == ucRmcEnable) |
| 6157 | { |
| 6158 | status = sme_DisableRMC( (tHalHandle)(pHddCtx->hHal), |
| 6159 | pAdapter->sessionId ); |
| 6160 | } |
| 6161 | else |
| 6162 | { |
| 6163 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6164 | "Invalid SETRMCENABLE command %d", ucRmcEnable); |
| 6165 | ret = -EINVAL; |
| 6166 | goto exit; |
| 6167 | } |
| 6168 | |
| 6169 | if (VOS_STATUS_SUCCESS != status) |
| 6170 | { |
| 6171 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6172 | "%s: SETRMC %d failed status %d", __func__, ucRmcEnable, |
| 6173 | status); |
| 6174 | ret = -EINVAL; |
| 6175 | goto exit; |
| 6176 | } |
| 6177 | } |
| 6178 | else if (strncasecmp(command, "SETRMCACTIONPERIOD", 18) == 0) |
| 6179 | { |
| 6180 | tANI_U8 *value = command; |
| 6181 | tANI_U32 uActionPeriod = 0; |
| 6182 | int status; |
| 6183 | |
| 6184 | if ((WLAN_HDD_IBSS != pAdapter->device_mode) && |
| 6185 | (WLAN_HDD_SOFTAP != pAdapter->device_mode)) |
| 6186 | { |
| 6187 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6188 | "Received SETRMC command in invalid mode %d " |
| 6189 | "SETRMC command is only allowed in IBSS or SOFTAP mode", |
| 6190 | pAdapter->device_mode); |
| 6191 | ret = -EINVAL; |
| 6192 | goto exit; |
| 6193 | } |
| 6194 | |
| 6195 | status = hdd_parse_setrmcactionperiod_command(value, &uActionPeriod); |
| 6196 | if (status) |
| 6197 | { |
| 6198 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6199 | "Invalid SETRMCACTIONPERIOD command "); |
| 6200 | ret = -EINVAL; |
| 6201 | goto exit; |
| 6202 | } |
| 6203 | |
| 6204 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 6205 | "%s: uActionPeriod %d ", __func__, uActionPeriod); |
| 6206 | |
| 6207 | if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_RMC_ACTION_PERIOD_FREQUENCY, |
| 6208 | uActionPeriod, NULL, eANI_BOOLEAN_FALSE)) |
| 6209 | { |
| 6210 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6211 | "%s: Could not set SETRMCACTIONPERIOD %d", __func__, uActionPeriod); |
| 6212 | ret = -EINVAL; |
| 6213 | goto exit; |
| 6214 | } |
| 6215 | |
| 6216 | } |
| 6217 | else if (strncasecmp(command, "GETIBSSPEERINFOALL", 18) == 0) |
| 6218 | { |
| 6219 | /* Peer Info All Command */ |
| 6220 | int status = eHAL_STATUS_SUCCESS; |
| 6221 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 6222 | char *extra = NULL; |
| 6223 | int idx = 0, length = 0; |
| 6224 | v_MACADDR_t *macAddr; |
| 6225 | v_U32_t txRateMbps = 0, numOfBytestoPrint = 0; |
| 6226 | |
| 6227 | if (WLAN_HDD_IBSS == pAdapter->device_mode) |
| 6228 | { |
| 6229 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 6230 | } |
| 6231 | else |
| 6232 | { |
| 6233 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 6234 | "%s: pAdapter is not valid for this device mode", |
| 6235 | __func__); |
| 6236 | ret = -EINVAL; |
| 6237 | goto exit; |
| 6238 | } |
| 6239 | |
| 6240 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 6241 | "%s: Received GETIBSSPEERINFOALL Command", __func__); |
| 6242 | |
| 6243 | |
| 6244 | /* Handle the command */ |
| 6245 | status = hdd_cfg80211_get_ibss_peer_info_all(pAdapter); |
| 6246 | if (VOS_STATUS_SUCCESS == status) |
| 6247 | { |
| 6248 | /* The variable extra needed to be allocated on the heap since |
| 6249 | * amount of memory required to copy the data for 32 devices |
| 6250 | * exceeds the size of 1024 bytes of default stack size. On |
| 6251 | * 64 bit devices, the default max stack size of 2048 bytes |
| 6252 | */ |
| 6253 | extra = kmalloc(WLAN_MAX_BUF_SIZE, GFP_KERNEL); |
| 6254 | |
| 6255 | if (NULL == extra) |
| 6256 | { |
| 6257 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6258 | "%s:kmalloc failed", __func__); |
| 6259 | ret = -EINVAL; |
| 6260 | goto exit; |
| 6261 | } |
| 6262 | |
| 6263 | /* Copy number of stations */ |
| 6264 | length = scnprintf( extra, WLAN_MAX_BUF_SIZE, "%d ", |
| 6265 | pHddStaCtx->ibss_peer_info.numIBSSPeers); |
| 6266 | numOfBytestoPrint = length; |
| 6267 | for (idx = 0; idx < pHddStaCtx->ibss_peer_info.numIBSSPeers; idx++) |
| 6268 | { |
| 6269 | macAddr = |
| 6270 | hdd_wlan_get_ibss_mac_addr_from_staid(pAdapter, |
| 6271 | pHddStaCtx->ibss_peer_info.ibssPeerList[idx].staIdx); |
| 6272 | if (NULL != macAddr) |
| 6273 | { |
| 6274 | txRateMbps = |
| 6275 | ((pHddStaCtx->ibss_peer_info.ibssPeerList[idx].txRate)*500*1000)/1000000; |
| 6276 | |
| 6277 | length += scnprintf( (extra + length), WLAN_MAX_BUF_SIZE - length, |
| 6278 | "%02x:%02x:%02x:%02x:%02x:%02x %d %d ", |
| 6279 | macAddr->bytes[0], macAddr->bytes[1], macAddr->bytes[2], |
| 6280 | macAddr->bytes[3], macAddr->bytes[4], macAddr->bytes[5], |
| 6281 | (int)txRateMbps, |
| 6282 | (int)pHddStaCtx->ibss_peer_info.ibssPeerList[idx].rssi); |
| 6283 | } |
| 6284 | else |
| 6285 | { |
| 6286 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6287 | "%s: MAC ADDR is NULL for staIdx: %d", __func__, |
| 6288 | pHddStaCtx->ibss_peer_info.ibssPeerList[idx].staIdx); |
| 6289 | } |
| 6290 | |
| 6291 | /* |
| 6292 | * VOS_TRACE() macro has limitation of 512 bytes for the print |
| 6293 | * buffer. Hence printing the data in two chunks. The first chunk |
| 6294 | * will have the data for 16 devices and the second chunk will |
| 6295 | * have the rest. |
| 6296 | */ |
| 6297 | if (idx < NUM_OF_STA_DATA_TO_PRINT) |
| 6298 | { |
| 6299 | numOfBytestoPrint = length; |
| 6300 | } |
| 6301 | } |
| 6302 | |
| 6303 | /* |
| 6304 | * Copy the data back into buffer, if the data to copy is |
| 6305 | * morethan 512 bytes than we will split the data and do |
| 6306 | * it in two shots |
| 6307 | */ |
| 6308 | if (copy_to_user(priv_data.buf, extra, numOfBytestoPrint)) |
| 6309 | { |
| 6310 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6311 | "%s: Copy into user data buffer failed ", __func__); |
| 6312 | ret = -EFAULT; |
| 6313 | kfree(extra); |
| 6314 | goto exit; |
| 6315 | } |
| 6316 | priv_data.buf[numOfBytestoPrint] = '\0'; |
| 6317 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, |
| 6318 | "%s", priv_data.buf); |
| 6319 | |
| 6320 | if (length > numOfBytestoPrint) |
| 6321 | { |
| 6322 | if (copy_to_user(priv_data.buf + numOfBytestoPrint, |
| 6323 | extra + numOfBytestoPrint, |
| 6324 | length - numOfBytestoPrint + 1)) |
| 6325 | { |
| 6326 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6327 | "%s: Copy into user data buffer failed ", __func__); |
| 6328 | ret = -EFAULT; |
| 6329 | kfree(extra); |
| 6330 | goto exit; |
| 6331 | } |
| 6332 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, |
| 6333 | "%s", &priv_data.buf[numOfBytestoPrint]); |
| 6334 | } |
| 6335 | |
| 6336 | /* Free temporary buffer */ |
| 6337 | kfree(extra); |
| 6338 | } |
| 6339 | |
| 6340 | else |
| 6341 | { |
| 6342 | /* Command failed, log error */ |
| 6343 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6344 | "%s: GETIBSSPEERINFOALL command failed with status code %d", |
| 6345 | __func__, status); |
| 6346 | ret = -EINVAL; |
| 6347 | goto exit; |
| 6348 | } |
| 6349 | ret = 0; |
| 6350 | } |
| 6351 | else if(strncasecmp(command, "GETIBSSPEERINFO", 15) == 0) |
| 6352 | { |
| 6353 | /* Peer Info <Peer Addr> command */ |
| 6354 | tANI_U8 *value = command; |
| 6355 | VOS_STATUS status; |
| 6356 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 6357 | char extra[128] = { 0 }; |
| 6358 | v_U32_t length = 0; |
| 6359 | v_U8_t staIdx = 0; |
| 6360 | v_U32_t txRateMbps = 0; |
| 6361 | v_MACADDR_t peerMacAddr; |
| 6362 | |
| 6363 | if (WLAN_HDD_IBSS == pAdapter->device_mode) |
| 6364 | { |
| 6365 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 6366 | } |
| 6367 | else |
| 6368 | { |
| 6369 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 6370 | "%s: pAdapter is not valid for this device mode", |
| 6371 | __func__); |
| 6372 | ret = -EINVAL; |
| 6373 | goto exit; |
| 6374 | } |
| 6375 | |
| 6376 | /* if there are no peers, no need to continue with the command */ |
| 6377 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 6378 | "%s: Received GETIBSSPEERINFO Command", __func__); |
| 6379 | |
| 6380 | if (eConnectionState_IbssConnected != pHddStaCtx->conn_info.connState) |
| 6381 | { |
| 6382 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 6383 | "%s:No IBSS Peers coalesced", __func__); |
| 6384 | ret = -EINVAL; |
| 6385 | goto exit; |
| 6386 | } |
| 6387 | |
| 6388 | /* Parse the incoming command buffer */ |
| 6389 | status = hdd_parse_get_ibss_peer_info(value, &peerMacAddr); |
| 6390 | if (VOS_STATUS_SUCCESS != status) |
| 6391 | { |
| 6392 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6393 | "%s: Invalid GETIBSSPEERINFO command", __func__); |
| 6394 | ret = -EINVAL; |
| 6395 | goto exit; |
| 6396 | } |
| 6397 | |
| 6398 | /* Get station index for the peer mac address */ |
| 6399 | hdd_Ibss_GetStaId(pHddStaCtx, &peerMacAddr, &staIdx); |
| 6400 | |
| 6401 | if (staIdx > HDD_MAX_NUM_IBSS_STA) |
| 6402 | { |
| 6403 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6404 | "%s: Invalid StaIdx %d returned", __func__, staIdx); |
| 6405 | ret = -EINVAL; |
| 6406 | goto exit; |
| 6407 | } |
| 6408 | |
| 6409 | /* Handle the command */ |
| 6410 | status = hdd_cfg80211_get_ibss_peer_info(pAdapter, staIdx); |
| 6411 | if (VOS_STATUS_SUCCESS == status) |
| 6412 | { |
| 6413 | v_U32_t txRate = pHddStaCtx->ibss_peer_info.ibssPeerList[0].txRate; |
| 6414 | txRateMbps = (txRate * 500 * 1000)/1000000; |
| 6415 | |
| 6416 | length = scnprintf( extra, sizeof(extra), "%d %d", (int)txRateMbps, |
| 6417 | (int)pHddStaCtx->ibss_peer_info.ibssPeerList[0].rssi); |
| 6418 | |
| 6419 | /* Copy the data back into buffer */ |
| 6420 | if (copy_to_user(priv_data.buf, &extra, length+ 1)) |
| 6421 | { |
| 6422 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6423 | "%s: copy data to user buffer failed GETIBSSPEERINFO command", |
| 6424 | __func__); |
| 6425 | ret = -EFAULT; |
| 6426 | goto exit; |
| 6427 | } |
| 6428 | } |
| 6429 | else |
| 6430 | { |
| 6431 | /* Command failed, log error */ |
| 6432 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6433 | "%s: GETIBSSPEERINFO command failed with status code %d", |
| 6434 | __func__, status); |
| 6435 | ret = -EINVAL; |
| 6436 | goto exit; |
| 6437 | } |
| 6438 | |
| 6439 | /* Success ! */ |
| 6440 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, |
| 6441 | "%s", priv_data.buf); |
| 6442 | ret = 0; |
| 6443 | } |
| 6444 | else if (strncasecmp(command, "SETRMCTXRATE", 12) == 0) |
| 6445 | { |
| 6446 | tANI_U8 *value = command; |
| 6447 | tANI_U32 uRate = 0; |
| 6448 | tTxrateinfoflags txFlags = 0; |
| 6449 | tSirRateUpdateInd *rateUpdateParams; |
| 6450 | int status; |
| 6451 | |
| 6452 | if ((WLAN_HDD_IBSS != pAdapter->device_mode) && |
| 6453 | (WLAN_HDD_SOFTAP != pAdapter->device_mode)) |
| 6454 | { |
| 6455 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6456 | "Received SETRMCTXRATE command in invalid mode %d " |
| 6457 | "SETRMC command is only allowed in IBSS or SOFTAP mode", |
| 6458 | pAdapter->device_mode); |
| 6459 | ret = -EINVAL; |
| 6460 | goto exit; |
| 6461 | } |
| 6462 | |
| 6463 | status = hdd_parse_setrmcrate_command(value, &uRate, &txFlags); |
| 6464 | if (status) |
| 6465 | { |
| 6466 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6467 | "Invalid SETRMCTXRATE command "); |
| 6468 | ret = -EINVAL; |
| 6469 | goto exit; |
| 6470 | } |
| 6471 | |
| 6472 | rateUpdateParams = vos_mem_malloc(sizeof(tSirRateUpdateInd)); |
| 6473 | if (NULL == rateUpdateParams) |
| 6474 | { |
| 6475 | ret = -EINVAL; |
| 6476 | goto exit; |
| 6477 | } |
| 6478 | |
| 6479 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 6480 | "%s: uRate %d ", __func__, uRate); |
| 6481 | |
| 6482 | vos_mem_zero(rateUpdateParams, sizeof(tSirRateUpdateInd )); |
| 6483 | |
| 6484 | /* -1 implies ignore this param */ |
| 6485 | rateUpdateParams->ucastDataRate = -1; |
| 6486 | |
| 6487 | /* |
| 6488 | * Fill the user specifieed RMC rate param |
| 6489 | * and the derived tx flags. |
| 6490 | */ |
| 6491 | rateUpdateParams->rmcDataRate = uRate; |
| 6492 | rateUpdateParams->rmcDataRateTxFlag = txFlags; |
| 6493 | |
| 6494 | status = sme_SendRateUpdateInd((tHalHandle)(pHddCtx->hHal), rateUpdateParams); |
| 6495 | } |
| 6496 | else if (strncasecmp(command, "SETIBSSTXFAILEVENT", 18) == 0 ) |
| 6497 | { |
| 6498 | char *value; |
| 6499 | tANI_U8 tx_fail_count = 0; |
| 6500 | tANI_U16 pid = 0; |
| 6501 | |
| 6502 | value = command; |
| 6503 | |
| 6504 | ret = hdd_ParseIBSSTXFailEventParams(value, &tx_fail_count, &pid); |
| 6505 | |
| 6506 | if (0 != ret) |
| 6507 | { |
| 6508 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6509 | "%s: Failed to parse SETIBSSTXFAILEVENT arguments", |
| 6510 | __func__); |
| 6511 | goto exit; |
| 6512 | } |
| 6513 | |
| 6514 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: tx_fail_cnt=%hhu, pid=%hu", |
| 6515 | __func__, tx_fail_count, pid); |
| 6516 | |
| 6517 | if (0 == tx_fail_count) |
| 6518 | { |
| 6519 | // Disable TX Fail Indication |
| 6520 | if (eHAL_STATUS_SUCCESS == |
| 6521 | sme_TXFailMonitorStartStopInd(pHddCtx->hHal, |
| 6522 | tx_fail_count, |
| 6523 | NULL)) |
| 6524 | { |
| 6525 | cesium_pid = 0; |
| 6526 | } |
| 6527 | else |
| 6528 | { |
| 6529 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6530 | "%s: failed to disable TX Fail Event ", __func__); |
| 6531 | ret = -EINVAL; |
| 6532 | } |
| 6533 | } |
| 6534 | else |
| 6535 | { |
| 6536 | if (eHAL_STATUS_SUCCESS == |
| 6537 | sme_TXFailMonitorStartStopInd(pHddCtx->hHal, |
| 6538 | tx_fail_count, |
| 6539 | (void*)hdd_tx_fail_ind_callback)) |
| 6540 | { |
| 6541 | cesium_pid = pid; |
| 6542 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 6543 | "%s: Registered Cesium pid %u", __func__, |
| 6544 | cesium_pid); |
| 6545 | } |
| 6546 | else |
| 6547 | { |
| 6548 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6549 | "%s: Failed to enable TX Fail Monitoring", __func__); |
| 6550 | ret = -EINVAL; |
| 6551 | } |
| 6552 | } |
| 6553 | } |
| 6554 | |
| 6555 | #endif /* WLAN_FEATURE_RMC */ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 6556 | #if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD) |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 6557 | else if (strncmp(command, "SETCCXROAMSCANCHANNELS", 22) == 0) |
| 6558 | { |
| 6559 | tANI_U8 *value = command; |
| 6560 | tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0}; |
| 6561 | tANI_U8 numChannels = 0; |
| 6562 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 6563 | |
| 6564 | status = hdd_parse_channellist(value, ChannelList, &numChannels); |
| 6565 | if (eHAL_STATUS_SUCCESS != status) |
| 6566 | { |
| 6567 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6568 | "%s: Failed to parse channel list information", __func__); |
| 6569 | ret = -EINVAL; |
| 6570 | goto exit; |
| 6571 | } |
| 6572 | |
| 6573 | if (numChannels > WNI_CFG_VALID_CHANNEL_LIST_LEN) |
| 6574 | { |
| 6575 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6576 | "%s: number of channels (%d) supported exceeded max (%d)", __func__, |
| 6577 | numChannels, WNI_CFG_VALID_CHANNEL_LIST_LEN); |
| 6578 | ret = -EINVAL; |
| 6579 | goto exit; |
| 6580 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 6581 | status = sme_SetEseRoamScanChannelList((tHalHandle)(pHddCtx->hHal), |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 6582 | ChannelList, |
| 6583 | numChannels); |
| 6584 | if (eHAL_STATUS_SUCCESS != status) |
| 6585 | { |
| 6586 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6587 | "%s: Failed to update channel list information", __func__); |
| 6588 | ret = -EINVAL; |
| 6589 | goto exit; |
| 6590 | } |
| 6591 | } |
| 6592 | else if (strncmp(command, "GETTSMSTATS", 11) == 0) |
| 6593 | { |
| 6594 | tANI_U8 *value = command; |
| 6595 | char extra[128] = {0}; |
| 6596 | int len = 0; |
| 6597 | tANI_U8 tid = 0; |
| 6598 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 6599 | tAniTrafStrmMetrics tsmMetrics; |
| 6600 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 6601 | |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 6602 | ret = hdd_drv_cmd_validate(command, 11); |
| 6603 | if (ret) |
| 6604 | goto exit; |
| 6605 | |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 6606 | /* if not associated, return error */ |
| 6607 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 6608 | { |
| 6609 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "%s:Not associated!",__func__); |
| 6610 | ret = -EINVAL; |
| 6611 | goto exit; |
| 6612 | } |
| 6613 | |
| 6614 | /* Move pointer to ahead of GETTSMSTATS<delimiter> */ |
| 6615 | value = value + 12; |
| 6616 | /* Convert the value from ascii to integer */ |
| 6617 | ret = kstrtou8(value, 10, &tid); |
| 6618 | if (ret < 0) |
| 6619 | { |
| 6620 | /* If the input value is greater than max value of datatype, then also |
| 6621 | kstrtou8 fails */ |
| 6622 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6623 | "%s: kstrtou8 failed range [%d - %d]", __func__, |
| 6624 | TID_MIN_VALUE, |
| 6625 | TID_MAX_VALUE); |
| 6626 | ret = -EINVAL; |
| 6627 | goto exit; |
| 6628 | } |
| 6629 | |
| 6630 | if ((tid < TID_MIN_VALUE) || (tid > TID_MAX_VALUE)) |
| 6631 | { |
| 6632 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6633 | "tid value %d is out of range" |
| 6634 | " (Min: %d Max: %d)", tid, |
| 6635 | TID_MIN_VALUE, |
| 6636 | TID_MAX_VALUE); |
| 6637 | ret = -EINVAL; |
| 6638 | goto exit; |
| 6639 | } |
| 6640 | |
| 6641 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 6642 | "%s: Received Command to get tsm stats tid = %d", __func__, tid); |
| 6643 | |
| 6644 | if (VOS_STATUS_SUCCESS != hdd_get_tsm_stats(pAdapter, tid, &tsmMetrics)) |
| 6645 | { |
| 6646 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6647 | "%s: failed to get tsm stats", __func__); |
| 6648 | ret = -EFAULT; |
| 6649 | goto exit; |
| 6650 | } |
| 6651 | |
| 6652 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 6653 | "UplinkPktQueueDly(%d)\n" |
| 6654 | "UplinkPktQueueDlyHist[0](%d)\n" |
| 6655 | "UplinkPktQueueDlyHist[1](%d)\n" |
| 6656 | "UplinkPktQueueDlyHist[2](%d)\n" |
| 6657 | "UplinkPktQueueDlyHist[3](%d)\n" |
Arun Kumar Khandavalli | e876821 | 2014-02-17 16:43:34 +0530 | [diff] [blame] | 6658 | "UplinkPktTxDly(%u)\n" |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 6659 | "UplinkPktLoss(%d)\n" |
| 6660 | "UplinkPktCount(%d)\n" |
| 6661 | "RoamingCount(%d)\n" |
| 6662 | "RoamingDly(%d)", tsmMetrics.UplinkPktQueueDly, |
| 6663 | tsmMetrics.UplinkPktQueueDlyHist[0], |
| 6664 | tsmMetrics.UplinkPktQueueDlyHist[1], |
| 6665 | tsmMetrics.UplinkPktQueueDlyHist[2], |
| 6666 | tsmMetrics.UplinkPktQueueDlyHist[3], |
| 6667 | tsmMetrics.UplinkPktTxDly, tsmMetrics.UplinkPktLoss, |
| 6668 | tsmMetrics.UplinkPktCount, tsmMetrics.RoamingCount, tsmMetrics.RoamingDly); |
| 6669 | |
| 6670 | /* Output TSM stats is of the format |
| 6671 | GETTSMSTATS [PktQueueDly] [PktQueueDlyHist[0]]:[PktQueueDlyHist[1]] ...[RoamingDly] |
| 6672 | eg., GETTSMSTATS 10 1:0:0:161 20 1 17 8 39800 */ |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 6673 | 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] | 6674 | tsmMetrics.UplinkPktQueueDly, tsmMetrics.UplinkPktQueueDlyHist[0], |
| 6675 | tsmMetrics.UplinkPktQueueDlyHist[1], tsmMetrics.UplinkPktQueueDlyHist[2], |
| 6676 | tsmMetrics.UplinkPktQueueDlyHist[3], tsmMetrics.UplinkPktTxDly, |
| 6677 | tsmMetrics.UplinkPktLoss, tsmMetrics.UplinkPktCount, tsmMetrics.RoamingCount, |
| 6678 | tsmMetrics.RoamingDly); |
| 6679 | |
Ratnam Rachuri | d53009c | 2015-08-07 13:59:00 +0530 | [diff] [blame] | 6680 | len = VOS_MIN(priv_data.total_len, len + 1); |
| 6681 | if (copy_to_user(priv_data.buf, &extra, len)) { |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 6682 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6683 | "%s: failed to copy data to user buffer", __func__); |
| 6684 | ret = -EFAULT; |
| 6685 | goto exit; |
| 6686 | } |
| 6687 | } |
| 6688 | else if (strncmp(command, "SETCCKMIE", 9) == 0) |
| 6689 | { |
| 6690 | tANI_U8 *value = command; |
| 6691 | tANI_U8 *cckmIe = NULL; |
| 6692 | tANI_U8 cckmIeLen = 0; |
| 6693 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 6694 | |
| 6695 | status = hdd_parse_get_cckm_ie(value, &cckmIe, &cckmIeLen); |
| 6696 | if (eHAL_STATUS_SUCCESS != status) |
| 6697 | { |
| 6698 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6699 | "%s: Failed to parse cckm ie data", __func__); |
| 6700 | ret = -EINVAL; |
| 6701 | goto exit; |
| 6702 | } |
| 6703 | |
| 6704 | if (cckmIeLen > DOT11F_IE_RSN_MAX_LEN) |
| 6705 | { |
| 6706 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6707 | "%s: CCKM Ie input length is more than max[%d]", __func__, |
| 6708 | DOT11F_IE_RSN_MAX_LEN); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 6709 | vos_mem_free(cckmIe); |
| 6710 | cckmIe = NULL; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 6711 | ret = -EINVAL; |
| 6712 | goto exit; |
| 6713 | } |
| 6714 | sme_SetCCKMIe((tHalHandle)(pHddCtx->hHal), pAdapter->sessionId, cckmIe, cckmIeLen); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 6715 | vos_mem_free(cckmIe); |
| 6716 | cckmIe = NULL; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 6717 | } |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 6718 | else if (strncmp(command, "CCXBEACONREQ", 12) == 0) |
| 6719 | { |
| 6720 | tANI_U8 *value = command; |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 6721 | tCsrEseBeaconReq eseBcnReq; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 6722 | eHalStatus status = eHAL_STATUS_SUCCESS; |
Srinivas Girigowda | 0c6d7fe | 2014-05-28 18:18:10 -0700 | [diff] [blame] | 6723 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 6724 | status = hdd_parse_ese_beacon_req(value, &eseBcnReq); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 6725 | if (eHAL_STATUS_SUCCESS != status) |
| 6726 | { |
| 6727 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 6728 | "%s: Failed to parse ese beacon req", __func__); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 6729 | ret = -EINVAL; |
| 6730 | goto exit; |
| 6731 | } |
Srinivas Girigowda | 0c6d7fe | 2014-05-28 18:18:10 -0700 | [diff] [blame] | 6732 | if (!hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) { |
| 6733 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Not associated")); |
| 6734 | hdd_indicateEseBcnReportNoResults (pAdapter, |
| 6735 | eseBcnReq.bcnReq[0].measurementToken, |
| 6736 | 0x02, //BIT(1) set for measurement done |
| 6737 | 0); // no BSS |
| 6738 | goto exit; |
| 6739 | } |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 6740 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 6741 | status = sme_SetEseBeaconRequest((tHalHandle)(pHddCtx->hHal), pAdapter->sessionId, &eseBcnReq); |
| 6742 | if (eHAL_STATUS_SUCCESS != status) |
| 6743 | { |
| 6744 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6745 | "%s: sme_SetEseBeaconRequest failed (%d)", __func__, status); |
| 6746 | ret = -EINVAL; |
| 6747 | goto exit; |
| 6748 | } |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 6749 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 6750 | #endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */ |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 6751 | else if (strncmp(command, "GETBCNMISSRATE", 14) == 0) |
| 6752 | { |
| 6753 | eHalStatus status; |
| 6754 | char buf[32], len; |
Hanumanth Reddy Pothula | 7aa4bea | 2018-04-09 17:19:03 +0530 | [diff] [blame] | 6755 | void *cookie; |
| 6756 | struct hdd_request *request; |
| 6757 | struct bcn_miss_rate_priv *priv; |
| 6758 | static const struct hdd_request_params params = { |
| 6759 | .priv_size = sizeof(*priv), |
| 6760 | .timeout_ms = WLAN_WAIT_TIME_STATS, |
| 6761 | }; |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 6762 | |
| 6763 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 6764 | |
| 6765 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 6766 | { |
| 6767 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 6768 | FL("GETBCNMISSRATE: STA is not in connected state")); |
| 6769 | ret = -1; |
| 6770 | goto exit; |
| 6771 | } |
Hanumanth Reddy Pothula | 7aa4bea | 2018-04-09 17:19:03 +0530 | [diff] [blame] | 6772 | request = hdd_request_alloc(¶ms); |
| 6773 | if (!request) { |
| 6774 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure")); |
| 6775 | ret = -ENOMEM; |
| 6776 | goto exit; |
| 6777 | } |
| 6778 | cookie = hdd_request_cookie(request); |
| 6779 | priv = hdd_request_priv(request); |
| 6780 | priv->bcn_miss_rate = -1; |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 6781 | |
| 6782 | status = sme_getBcnMissRate((tHalHandle)(pHddCtx->hHal), |
| 6783 | pAdapter->sessionId, |
Hanumanth Reddy Pothula | 7aa4bea | 2018-04-09 17:19:03 +0530 | [diff] [blame] | 6784 | (void *)get_bcn_miss_rate_cb, |
| 6785 | cookie); |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 6786 | if( eHAL_STATUS_SUCCESS != status) |
| 6787 | { |
| 6788 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6789 | FL("GETBCNMISSRATE: fail to post WDA cmd")); |
| 6790 | ret = -EINVAL; |
Hanumanth Reddy Pothula | 7aa4bea | 2018-04-09 17:19:03 +0530 | [diff] [blame] | 6791 | goto free_bcn_miss_rate_req; |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 6792 | } |
| 6793 | |
Hanumanth Reddy Pothula | 7aa4bea | 2018-04-09 17:19:03 +0530 | [diff] [blame] | 6794 | ret = hdd_request_wait_for_response(request); |
| 6795 | if(ret) |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 6796 | { |
| 6797 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6798 | FL("failed to wait on bcnMissRateComp %d"), ret); |
| 6799 | |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 6800 | ret = -EINVAL; |
Hanumanth Reddy Pothula | 7aa4bea | 2018-04-09 17:19:03 +0530 | [diff] [blame] | 6801 | goto free_bcn_miss_rate_req; |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 6802 | } |
| 6803 | |
| 6804 | hddLog(VOS_TRACE_LEVEL_INFO, |
Hanumanth Reddy Pothula | 7aa4bea | 2018-04-09 17:19:03 +0530 | [diff] [blame] | 6805 | FL("GETBCNMISSRATE: bcnMissRate: %d"), priv->bcn_miss_rate); |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 6806 | |
Hanumanth Reddy Pothula | 7aa4bea | 2018-04-09 17:19:03 +0530 | [diff] [blame] | 6807 | if (priv->bcn_miss_rate == -1) { |
| 6808 | ret = -EFAULT; |
| 6809 | goto free_bcn_miss_rate_req; |
| 6810 | } |
| 6811 | |
| 6812 | len = snprintf(buf, sizeof(buf), "GETBCNMISSRATE %d", |
| 6813 | priv->bcn_miss_rate); |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 6814 | if (copy_to_user(priv_data.buf, &buf, len + 1)) |
| 6815 | { |
| 6816 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6817 | "%s: failed to copy data to user buffer", __func__); |
| 6818 | ret = -EFAULT; |
Hanumanth Reddy Pothula | 7aa4bea | 2018-04-09 17:19:03 +0530 | [diff] [blame] | 6819 | goto free_bcn_miss_rate_req; |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 6820 | } |
| 6821 | ret = len; |
Hanumanth Reddy Pothula | 7aa4bea | 2018-04-09 17:19:03 +0530 | [diff] [blame] | 6822 | |
| 6823 | free_bcn_miss_rate_req: |
| 6824 | hdd_request_put(request); |
c_hpothu | 9236791 | 2014-05-01 15:18:17 +0530 | [diff] [blame] | 6825 | } |
Atul Mittal | 87ec242 | 2014-09-24 13:12:50 +0530 | [diff] [blame] | 6826 | #ifdef FEATURE_WLAN_TDLS |
| 6827 | else if (strncmp(command, "TDLSSECONDARYCHANNELOFFSET", 26) == 0) { |
| 6828 | tANI_U8 *value = command; |
| 6829 | int set_value; |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 6830 | |
| 6831 | ret = hdd_drv_cmd_validate(command, 26); |
| 6832 | if (ret) |
| 6833 | goto exit; |
| 6834 | |
Atul Mittal | 87ec242 | 2014-09-24 13:12:50 +0530 | [diff] [blame] | 6835 | /* Move pointer to ahead of TDLSOFFCH*/ |
| 6836 | value += 26; |
c_manjee | bbc4021 | 2015-12-08 13:52:59 +0530 | [diff] [blame] | 6837 | if (!(sscanf(value, "%d", &set_value))) { |
| 6838 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 6839 | FL("No input identified")); |
| 6840 | ret = -EINVAL; |
| 6841 | goto exit; |
| 6842 | } |
| 6843 | |
Atul Mittal | 87ec242 | 2014-09-24 13:12:50 +0530 | [diff] [blame] | 6844 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 6845 | "%s: Tdls offchannel offset:%d", |
| 6846 | __func__, set_value); |
| 6847 | ret = iw_set_tdlssecoffchanneloffset(pHddCtx, set_value); |
| 6848 | if (ret < 0) |
| 6849 | { |
| 6850 | ret = -EINVAL; |
| 6851 | goto exit; |
| 6852 | } |
| 6853 | |
| 6854 | } else if (strncmp(command, "TDLSOFFCHANNELMODE", 18) == 0) { |
| 6855 | tANI_U8 *value = command; |
| 6856 | int set_value; |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 6857 | |
| 6858 | ret = hdd_drv_cmd_validate(command, 18); |
| 6859 | if (ret) |
| 6860 | goto exit; |
| 6861 | |
Atul Mittal | 87ec242 | 2014-09-24 13:12:50 +0530 | [diff] [blame] | 6862 | /* Move pointer to ahead of tdlsoffchnmode*/ |
| 6863 | value += 18; |
c_manjee | 8232389 | 2015-12-08 12:40:34 +0530 | [diff] [blame] | 6864 | ret = sscanf(value, "%d", &set_value); |
| 6865 | if (ret != 1) { |
| 6866 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 6867 | FL("No input identified")); |
| 6868 | ret = -EINVAL; |
| 6869 | goto exit; |
| 6870 | } |
Atul Mittal | 87ec242 | 2014-09-24 13:12:50 +0530 | [diff] [blame] | 6871 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 6872 | "%s: Tdls offchannel mode:%d", |
| 6873 | __func__, set_value); |
| 6874 | ret = iw_set_tdlsoffchannelmode(pAdapter, set_value); |
| 6875 | if (ret < 0) |
| 6876 | { |
| 6877 | ret = -EINVAL; |
| 6878 | goto exit; |
| 6879 | } |
| 6880 | } else if (strncmp(command, "TDLSOFFCHANNEL", 14) == 0) { |
| 6881 | tANI_U8 *value = command; |
| 6882 | int set_value; |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 6883 | |
| 6884 | ret = hdd_drv_cmd_validate(command, 14); |
| 6885 | if (ret) |
| 6886 | goto exit; |
| 6887 | |
Atul Mittal | 87ec242 | 2014-09-24 13:12:50 +0530 | [diff] [blame] | 6888 | /* Move pointer to ahead of TDLSOFFCH*/ |
| 6889 | value += 14; |
c_manjee | f6ccaf5 | 2015-12-08 11:52:11 +0530 | [diff] [blame] | 6890 | ret = sscanf(value, "%d", &set_value); |
| 6891 | if (ret != 1) { |
| 6892 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6893 | "Wrong value is given for hdd_set_tdls_offchannel"); |
| 6894 | ret = -EINVAL; |
| 6895 | goto exit; |
| 6896 | } |
| 6897 | |
Atul Mittal | 87ec242 | 2014-09-24 13:12:50 +0530 | [diff] [blame] | 6898 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 6899 | "%s: Tdls offchannel num: %d", |
| 6900 | __func__, set_value); |
| 6901 | ret = iw_set_tdlsoffchannel(pHddCtx, set_value); |
| 6902 | if (ret < 0) |
| 6903 | { |
| 6904 | ret = -EINVAL; |
| 6905 | goto exit; |
| 6906 | } |
| 6907 | } |
| 6908 | #endif |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 6909 | else if (strncmp(command, "GETFWSTATS", 10) == 0) |
| 6910 | { |
| 6911 | eHalStatus status; |
| 6912 | char *buf = NULL; |
| 6913 | char len; |
Hanumanth Reddy Pothula | 7aa4bea | 2018-04-09 17:19:03 +0530 | [diff] [blame] | 6914 | tSirFwStatsResult *fwStatsRsp = &(pAdapter->fwStatsRsp), |
| 6915 | *fw_stats_result; |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 6916 | tANI_U8 *ptr = command; |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 6917 | int stats; |
Hanumanth Reddy Pothula | 7aa4bea | 2018-04-09 17:19:03 +0530 | [diff] [blame] | 6918 | void *cookie; |
| 6919 | struct hdd_request *request; |
| 6920 | struct fw_stats_priv *priv; |
| 6921 | static const struct hdd_request_params params = { |
| 6922 | .priv_size = sizeof(*priv), |
| 6923 | .timeout_ms = WLAN_WAIT_TIME_STATS, |
| 6924 | }; |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 6925 | |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 6926 | ret = hdd_drv_cmd_validate(command, 10); |
| 6927 | if (ret) |
| 6928 | goto exit; |
| 6929 | |
| 6930 | stats = *(ptr + 11) - '0'; |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 6931 | hddLog(VOS_TRACE_LEVEL_INFO, FL("stats = %d "),stats); |
| 6932 | if (!IS_FEATURE_FW_STATS_ENABLE) |
| 6933 | { |
| 6934 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6935 | FL("Get Firmware stats feature not supported")); |
| 6936 | ret = -EINVAL; |
| 6937 | goto exit; |
| 6938 | } |
| 6939 | |
| 6940 | if (FW_STATS_MAX <= stats || 0 >= stats) |
| 6941 | { |
| 6942 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6943 | FL(" stats %d not supported"),stats); |
| 6944 | ret = -EINVAL; |
| 6945 | goto exit; |
| 6946 | } |
| 6947 | |
Hanumanth Reddy Pothula | 7aa4bea | 2018-04-09 17:19:03 +0530 | [diff] [blame] | 6948 | request = hdd_request_alloc(¶ms); |
| 6949 | if (!request) { |
| 6950 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure")); |
| 6951 | ret = -ENOMEM; |
| 6952 | goto exit; |
| 6953 | } |
| 6954 | cookie = hdd_request_cookie(request); |
| 6955 | |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 6956 | status = sme_GetFwStats( (tHalHandle)pHddCtx->hHal, stats, |
Hanumanth Reddy Pothula | 7aa4bea | 2018-04-09 17:19:03 +0530 | [diff] [blame] | 6957 | cookie, hdd_fw_stats_cb); |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 6958 | if (eHAL_STATUS_SUCCESS != status) |
| 6959 | { |
| 6960 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6961 | FL(" fail to post WDA cmd status = %d"), status); |
| 6962 | ret = -EINVAL; |
Hanumanth Reddy Pothula | 7aa4bea | 2018-04-09 17:19:03 +0530 | [diff] [blame] | 6963 | hdd_request_put(request); |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 6964 | goto exit; |
| 6965 | } |
Hanumanth Reddy Pothula | 7aa4bea | 2018-04-09 17:19:03 +0530 | [diff] [blame] | 6966 | ret = hdd_request_wait_for_response(request); |
| 6967 | if (ret) |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 6968 | { |
| 6969 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6970 | FL("failed to wait on GwtFwstats")); |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 6971 | ret = -EINVAL; |
Hanumanth Reddy Pothula | 7aa4bea | 2018-04-09 17:19:03 +0530 | [diff] [blame] | 6972 | hdd_request_put(request); |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 6973 | goto exit; |
| 6974 | } |
Hanumanth Reddy Pothula | 7aa4bea | 2018-04-09 17:19:03 +0530 | [diff] [blame] | 6975 | |
| 6976 | priv = hdd_request_priv(request); |
| 6977 | fw_stats_result = priv->fw_stats; |
| 6978 | fwStatsRsp->type = 0; |
| 6979 | if (NULL != fw_stats_result) |
| 6980 | { |
| 6981 | switch (fw_stats_result->type ) |
| 6982 | { |
| 6983 | case FW_UBSP_STATS: |
| 6984 | { |
| 6985 | tSirUbspFwStats *stats = |
| 6986 | &fwStatsRsp->fwStatsData.ubspStats; |
| 6987 | memcpy(fwStatsRsp, fw_stats_result, |
| 6988 | sizeof(tSirFwStatsResult)); |
| 6989 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6990 | FL("ubsp_enter_cnt = %d ubsp_jump_ddr_cnt = %d"), |
| 6991 | stats->ubsp_enter_cnt, |
| 6992 | stats->ubsp_jump_ddr_cnt); |
| 6993 | } |
| 6994 | break; |
| 6995 | |
| 6996 | default: |
| 6997 | { |
| 6998 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6999 | FL("No handling for stats type %d"), |
| 7000 | fw_stats_result->type); |
| 7001 | } |
| 7002 | } |
| 7003 | } |
| 7004 | hdd_request_put(request); |
| 7005 | |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 7006 | if (fwStatsRsp->type) |
| 7007 | { |
| 7008 | buf = kmalloc(FW_STATE_RSP_LEN, GFP_KERNEL); |
| 7009 | if (!buf) |
| 7010 | { |
| 7011 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 7012 | FL(" failed to allocate memory")); |
| 7013 | ret = -ENOMEM; |
| 7014 | goto exit; |
| 7015 | } |
| 7016 | switch( fwStatsRsp->type ) |
| 7017 | { |
| 7018 | case FW_UBSP_STATS: |
| 7019 | { |
| 7020 | len = snprintf(buf, FW_STATE_RSP_LEN, |
| 7021 | "GETFWSTATS: ubsp_enter_cnt %d ubsp_jump_ddr_cnt %d", |
Abhishek Singh | 08aa776 | 2014-12-16 13:59:03 +0530 | [diff] [blame] | 7022 | fwStatsRsp->fwStatsData.ubspStats.ubsp_enter_cnt, |
| 7023 | fwStatsRsp->fwStatsData.ubspStats.ubsp_jump_ddr_cnt); |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 7024 | } |
| 7025 | break; |
| 7026 | default: |
| 7027 | { |
| 7028 | hddLog(VOS_TRACE_LEVEL_ERROR, FL( "No handling for stats type %d"),fwStatsRsp->type); |
| 7029 | ret = -EFAULT; |
| 7030 | kfree(buf); |
| 7031 | goto exit; |
| 7032 | } |
| 7033 | } |
| 7034 | if (copy_to_user(priv_data.buf, buf, len + 1)) |
| 7035 | { |
| 7036 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 7037 | FL(" failed to copy data to user buffer")); |
| 7038 | ret = -EFAULT; |
| 7039 | kfree(buf); |
| 7040 | goto exit; |
| 7041 | } |
| 7042 | ret = len; |
| 7043 | kfree(buf); |
| 7044 | } |
| 7045 | else |
| 7046 | { |
| 7047 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 7048 | FL("failed to fetch the stats")); |
| 7049 | ret = -EFAULT; |
| 7050 | goto exit; |
| 7051 | } |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 7052 | } |
Agarwal Ashish | 8bd53ae | 2015-06-12 18:03:45 +0530 | [diff] [blame] | 7053 | else if (strncasecmp(command, "SET_FCC_CHANNEL", 15) == 0) |
| 7054 | { |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 7055 | ret = hdd_drv_cmd_validate(command, 15); |
| 7056 | if (ret) |
| 7057 | goto exit; |
| 7058 | |
Agarwal Ashish | 8bd53ae | 2015-06-12 18:03:45 +0530 | [diff] [blame] | 7059 | /* |
| 7060 | * this command wld be called by user-space when it detects WLAN |
| 7061 | * ON after airplane mode is set. When APM is set, WLAN turns off. |
| 7062 | * But it can be turned back on. Otherwise; when APM is turned back |
| 7063 | * off, WLAN wld turn back on. So at that point the command is |
| 7064 | * expected to come down. 0 means disable, 1 means enable. The |
| 7065 | * constraint is removed when parameter 1 is set or different |
| 7066 | * country code is set |
| 7067 | */ |
| 7068 | ret = hdd_cmd_setFccChannel(pHddCtx, command, 15); |
| 7069 | } |
Mahesh A Saptasagar | beca12c | 2015-09-07 16:21:06 +0530 | [diff] [blame] | 7070 | else if (strncasecmp(command, "DISABLE_CA_EVENT", 16) == 0) |
| 7071 | { |
Rajeev Kumar Sirasanagandla | f740b1e | 2017-08-23 18:07:01 +0530 | [diff] [blame] | 7072 | ret = hdd_drv_cmd_validate(command, 16); |
| 7073 | if (ret) |
| 7074 | goto exit; |
| 7075 | |
Mahesh A Saptasagar | beca12c | 2015-09-07 16:21:06 +0530 | [diff] [blame] | 7076 | ret = hdd_enable_disable_ca_event(pHddCtx, command, 16); |
| 7077 | } |
Ashish Kumar Dhanotiya | 32d092b | 2018-02-20 21:43:57 +0530 | [diff] [blame] | 7078 | /* |
| 7079 | * command should be a string having format |
| 7080 | * SET_DISABLE_CHANNEL_LIST <num of channels> |
| 7081 | * <channels separated by spaces> |
| 7082 | */ |
| 7083 | else if (strncmp(command, "SET_DISABLE_CHANNEL_LIST", 24) == 0) { |
| 7084 | tANI_U8 *ptr = command; |
| 7085 | ret = hdd_drv_cmd_validate(command, 24); |
| 7086 | if (ret) |
| 7087 | goto exit; |
| 7088 | |
| 7089 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 7090 | " Received Command to disable Channels %s", |
| 7091 | __func__); |
| 7092 | ret = hdd_parse_disable_chan_cmd(pAdapter, ptr); |
| 7093 | if (ret) |
| 7094 | goto exit; |
| 7095 | } |
Hanumanth Reddy Pothula | 8ae38bb | 2018-03-07 18:59:30 +0530 | [diff] [blame] | 7096 | else if (strncmp(command, "GET_DISABLE_CHANNEL_LIST", 24) == 0) { |
Ashish Kumar Dhanotiya | 95e5bc2 | 2018-04-19 17:06:33 +0530 | [diff] [blame] | 7097 | char extra[512] = {0}; |
| 7098 | int max_len, copied_length; |
Ashish Kumar Dhanotiya | 32d092b | 2018-02-20 21:43:57 +0530 | [diff] [blame] | 7099 | |
Ashish Kumar Dhanotiya | 95e5bc2 | 2018-04-19 17:06:33 +0530 | [diff] [blame] | 7100 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Hanumanth Reddy Pothula | 8ae38bb | 2018-03-07 18:59:30 +0530 | [diff] [blame] | 7101 | " Received Command to get disable Channels list %s", |
| 7102 | __func__); |
| 7103 | |
Ashish Kumar Dhanotiya | 95e5bc2 | 2018-04-19 17:06:33 +0530 | [diff] [blame] | 7104 | max_len = VOS_MIN(priv_data.total_len, sizeof(extra)); |
| 7105 | copied_length = hdd_get_disable_ch_list(pHddCtx, extra, max_len); |
| 7106 | if (copied_length == 0) { |
| 7107 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Hanumanth Reddy Pothula | 8ae38bb | 2018-03-07 18:59:30 +0530 | [diff] [blame] | 7108 | FL("disable channel list are not yet programed")); |
| 7109 | ret = -EINVAL; |
| 7110 | goto exit; |
| 7111 | } |
| 7112 | |
Ashish Kumar Dhanotiya | 95e5bc2 | 2018-04-19 17:06:33 +0530 | [diff] [blame] | 7113 | if (copy_to_user(priv_data.buf, &extra, copied_length + 1)) { |
| 7114 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7115 | "%s: failed to copy data to user buffer", __func__); |
Hanumanth Reddy Pothula | 8ae38bb | 2018-03-07 18:59:30 +0530 | [diff] [blame] | 7116 | ret = -EFAULT; |
| 7117 | goto exit; |
| 7118 | } |
| 7119 | |
| 7120 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 7121 | FL("data:%s"), extra); |
| 7122 | } |
Madan Mohan Koyyalamudi | f9bdd4e | 2012-10-30 18:05:03 -0700 | [diff] [blame] | 7123 | else { |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 7124 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, |
| 7125 | TRACE_CODE_HDD_UNSUPPORTED_IOCTL, |
| 7126 | pAdapter->sessionId, 0)); |
Satyanarayana Dash | 7280601 | 2014-12-02 14:30:08 +0530 | [diff] [blame] | 7127 | hddLog( VOS_TRACE_LEVEL_WARN, FL("Unsupported GUI command %s"), |
| 7128 | command); |
Madan Mohan Koyyalamudi | f9bdd4e | 2012-10-30 18:05:03 -0700 | [diff] [blame] | 7129 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7130 | } |
| 7131 | exit: |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 7132 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7133 | if (command) |
| 7134 | { |
| 7135 | kfree(command); |
| 7136 | } |
| 7137 | return ret; |
| 7138 | } |
| 7139 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 7140 | #ifdef CONFIG_COMPAT |
| 7141 | static int hdd_driver_compat_ioctl(hdd_adapter_t *pAdapter, struct ifreq *ifr) |
| 7142 | { |
| 7143 | struct { |
| 7144 | compat_uptr_t buf; |
| 7145 | int used_len; |
| 7146 | int total_len; |
| 7147 | } compat_priv_data; |
| 7148 | hdd_priv_data_t priv_data; |
| 7149 | int ret = 0; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 7150 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 7151 | /* |
| 7152 | * Note that pAdapter and ifr have already been verified by caller, |
| 7153 | * and HDD context has also been validated |
| 7154 | */ |
| 7155 | if (copy_from_user(&compat_priv_data, ifr->ifr_data, |
| 7156 | sizeof(compat_priv_data))) { |
| 7157 | ret = -EFAULT; |
| 7158 | goto exit; |
| 7159 | } |
| 7160 | priv_data.buf = compat_ptr(compat_priv_data.buf); |
| 7161 | priv_data.used_len = compat_priv_data.used_len; |
| 7162 | priv_data.total_len = compat_priv_data.total_len; |
| 7163 | ret = hdd_driver_command(pAdapter, &priv_data); |
| 7164 | exit: |
| 7165 | return ret; |
| 7166 | } |
| 7167 | #else /* CONFIG_COMPAT */ |
| 7168 | static int hdd_driver_compat_ioctl(hdd_adapter_t *pAdapter, struct ifreq *ifr) |
| 7169 | { |
| 7170 | /* will never be invoked */ |
| 7171 | return 0; |
| 7172 | } |
| 7173 | #endif /* CONFIG_COMPAT */ |
| 7174 | |
| 7175 | static int hdd_driver_ioctl(hdd_adapter_t *pAdapter, struct ifreq *ifr) |
| 7176 | { |
| 7177 | hdd_priv_data_t priv_data; |
| 7178 | int ret = 0; |
| 7179 | |
| 7180 | /* |
| 7181 | * Note that pAdapter and ifr have already been verified by caller, |
| 7182 | * and HDD context has also been validated |
| 7183 | */ |
| 7184 | if (copy_from_user(&priv_data, ifr->ifr_data, sizeof(priv_data))) { |
| 7185 | ret = -EFAULT; |
| 7186 | } else { |
| 7187 | ret = hdd_driver_command(pAdapter, &priv_data); |
| 7188 | } |
| 7189 | return ret; |
| 7190 | } |
| 7191 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 7192 | int __hdd_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 7193 | { |
| 7194 | hdd_adapter_t *pAdapter; |
| 7195 | hdd_context_t *pHddCtx; |
| 7196 | int ret; |
| 7197 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 7198 | ENTER(); |
| 7199 | |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 7200 | pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7201 | if (NULL == pAdapter) { |
| 7202 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7203 | "%s: HDD adapter context is Null", __func__); |
| 7204 | ret = -ENODEV; |
| 7205 | goto exit; |
| 7206 | } |
| 7207 | if (dev != pAdapter->dev) { |
| 7208 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 7209 | "%s: HDD adapter/dev inconsistency", __func__); |
| 7210 | ret = -ENODEV; |
| 7211 | goto exit; |
| 7212 | } |
| 7213 | |
| 7214 | if ((!ifr) || (!ifr->ifr_data)) { |
| 7215 | ret = -EINVAL; |
| 7216 | goto exit; |
| 7217 | } |
| 7218 | |
| 7219 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 7220 | ret = wlan_hdd_validate_context(pHddCtx); |
| 7221 | if (ret) { |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 7222 | ret = -EBUSY; |
| 7223 | goto exit; |
| 7224 | } |
| 7225 | |
| 7226 | switch (cmd) { |
| 7227 | case (SIOCDEVPRIVATE + 1): |
| 7228 | if (is_compat_task()) |
| 7229 | ret = hdd_driver_compat_ioctl(pAdapter, ifr); |
| 7230 | else |
| 7231 | ret = hdd_driver_ioctl(pAdapter, ifr); |
| 7232 | break; |
| 7233 | default: |
| 7234 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unknown ioctl %d", |
| 7235 | __func__, cmd); |
| 7236 | ret = -EINVAL; |
| 7237 | break; |
| 7238 | } |
| 7239 | exit: |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 7240 | EXIT(); |
Jeff Johnson | d6e7b3f | 2014-03-20 12:12:11 -0700 | [diff] [blame] | 7241 | return ret; |
| 7242 | } |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 7243 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 7244 | int hdd_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) |
| 7245 | { |
| 7246 | int ret; |
| 7247 | |
| 7248 | vos_ssr_protect(__func__); |
| 7249 | ret = __hdd_ioctl(dev, ifr, cmd); |
| 7250 | vos_ssr_unprotect(__func__); |
| 7251 | |
| 7252 | return ret; |
| 7253 | } |
| 7254 | |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 7255 | int hdd_mon_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) |
| 7256 | { |
| 7257 | return 0; |
| 7258 | } |
| 7259 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 7260 | #if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 7261 | /**--------------------------------------------------------------------------- |
| 7262 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 7263 | \brief hdd_parse_ese_beacon_req() - Parse ese beacon request |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 7264 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 7265 | This function parses the ese beacon request passed in the format |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 7266 | CCXBEACONREQ<space><Number of fields><space><Measurement token> |
| 7267 | <space>Channel 1<space>Scan Mode <space>Meas Duration<space>Channel N |
| 7268 | <space>Scan Mode N<space>Meas Duration N |
| 7269 | if the Number of bcn req fields (N) does not match with the actual number of fields passed |
| 7270 | then take N. |
| 7271 | <Meas Token><Channel><Scan Mode> and <Meas Duration> are treated as one pair |
| 7272 | For example, CCXBEACONREQ 2 1 1 1 30 2 44 0 40. |
| 7273 | This function does not take care of removing duplicate channels from the list |
| 7274 | |
| 7275 | \param - pValue Pointer to data |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 7276 | \param - pEseBcnReq output pointer to store parsed ie information |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 7277 | |
| 7278 | \return - 0 for success non-zero for failure |
| 7279 | |
| 7280 | --------------------------------------------------------------------------*/ |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 7281 | static VOS_STATUS hdd_parse_ese_beacon_req(tANI_U8 *pValue, |
| 7282 | tCsrEseBeaconReq *pEseBcnReq) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 7283 | { |
| 7284 | tANI_U8 *inPtr = pValue; |
Arun Khandavalli | 9f3b483 | 2016-06-30 16:58:38 +0530 | [diff] [blame] | 7285 | uint8_t input = 0; |
| 7286 | uint32_t tempInt = 0; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 7287 | int j = 0, i = 0, v = 0; |
| 7288 | char buf[32]; |
| 7289 | |
| 7290 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 7291 | /*no argument after the command*/ |
| 7292 | if (NULL == inPtr) |
| 7293 | { |
| 7294 | return -EINVAL; |
| 7295 | } |
| 7296 | /*no space after the command*/ |
| 7297 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 7298 | { |
| 7299 | return -EINVAL; |
| 7300 | } |
| 7301 | |
| 7302 | /*removing empty spaces*/ |
| 7303 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
| 7304 | |
| 7305 | /*no argument followed by spaces*/ |
| 7306 | if ('\0' == *inPtr) return -EINVAL; |
| 7307 | |
| 7308 | /*getting the first argument ie measurement token*/ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 7309 | v = sscanf(inPtr, "%31s ", buf); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 7310 | if (1 != v) return -EINVAL; |
| 7311 | |
Arun Khandavalli | 9f3b483 | 2016-06-30 16:58:38 +0530 | [diff] [blame] | 7312 | v = kstrtos8(buf, 10, &input); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 7313 | if ( v < 0) return -EINVAL; |
| 7314 | |
Arun Khandavalli | 9f3b483 | 2016-06-30 16:58:38 +0530 | [diff] [blame] | 7315 | input = VOS_MIN(input, SIR_ESE_MAX_MEAS_IE_REQS); |
| 7316 | pEseBcnReq->numBcnReqIe = input; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 7317 | |
Srinivas Girigowda | 725a88e | 2016-03-31 19:24:25 +0530 | [diff] [blame] | 7318 | hddLog(LOG1, "Number of Bcn Req Ie fields: %d", pEseBcnReq->numBcnReqIe); |
| 7319 | |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 7320 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 7321 | for (j = 0; j < (pEseBcnReq->numBcnReqIe); j++) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 7322 | { |
| 7323 | for (i = 0; i < 4; i++) |
| 7324 | { |
| 7325 | /*inPtr pointing to the beginning of first space after number of ie fields*/ |
| 7326 | inPtr = strpbrk( inPtr, " " ); |
| 7327 | /*no ie data after the number of ie fields argument*/ |
| 7328 | if (NULL == inPtr) return -EINVAL; |
| 7329 | |
| 7330 | /*removing empty space*/ |
| 7331 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
| 7332 | |
| 7333 | /*no ie data after the number of ie fields argument and spaces*/ |
| 7334 | if ( '\0' == *inPtr ) return -EINVAL; |
| 7335 | |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 7336 | v = sscanf(inPtr, "%31s ", buf); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 7337 | if (1 != v) return -EINVAL; |
| 7338 | |
Arun Khandavalli | 9f3b483 | 2016-06-30 16:58:38 +0530 | [diff] [blame] | 7339 | v = kstrtou32(buf, 10, &tempInt); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 7340 | if (v < 0) return -EINVAL; |
| 7341 | |
| 7342 | switch (i) |
| 7343 | { |
| 7344 | case 0: /* Measurement token */ |
Arun Khandavalli | 9f3b483 | 2016-06-30 16:58:38 +0530 | [diff] [blame] | 7345 | if (!tempInt) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 7346 | { |
| 7347 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Arun Khandavalli | 9f3b483 | 2016-06-30 16:58:38 +0530 | [diff] [blame] | 7348 | "Invalid Measurement Token: %u", tempInt); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 7349 | return -EINVAL; |
| 7350 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 7351 | pEseBcnReq->bcnReq[j].measurementToken = tempInt; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 7352 | break; |
| 7353 | |
| 7354 | case 1: /* Channel number */ |
Arun Khandavalli | 9f3b483 | 2016-06-30 16:58:38 +0530 | [diff] [blame] | 7355 | if ((!tempInt) || |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 7356 | (tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX)) |
| 7357 | { |
| 7358 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Arun Khandavalli | 9f3b483 | 2016-06-30 16:58:38 +0530 | [diff] [blame] | 7359 | "Invalid Channel Number: %u", tempInt); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 7360 | return -EINVAL; |
| 7361 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 7362 | pEseBcnReq->bcnReq[j].channel = tempInt; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 7363 | break; |
| 7364 | |
| 7365 | case 2: /* Scan mode */ |
Varun Reddy Yeturu | 0b18d5a | 2013-12-04 11:42:23 -0800 | [diff] [blame] | 7366 | if ((tempInt < eSIR_PASSIVE_SCAN) || (tempInt > eSIR_BEACON_TABLE)) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 7367 | { |
| 7368 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Arun Khandavalli | 9f3b483 | 2016-06-30 16:58:38 +0530 | [diff] [blame] | 7369 | "Invalid Scan Mode(%u) Expected{0|1|2}", tempInt); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 7370 | return -EINVAL; |
| 7371 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 7372 | pEseBcnReq->bcnReq[j].scanMode= tempInt; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 7373 | break; |
| 7374 | |
| 7375 | case 3: /* Measurement duration */ |
Arun Khandavalli | 9f3b483 | 2016-06-30 16:58:38 +0530 | [diff] [blame] | 7376 | if (((!tempInt) && (pEseBcnReq->bcnReq[j].scanMode != eSIR_BEACON_TABLE)) || |
| 7377 | ((pEseBcnReq->bcnReq[j].scanMode == eSIR_BEACON_TABLE))) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 7378 | { |
| 7379 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Arun Khandavalli | 9f3b483 | 2016-06-30 16:58:38 +0530 | [diff] [blame] | 7380 | "Invalid Measurement Duration: %u", tempInt); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 7381 | return -EINVAL; |
| 7382 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 7383 | pEseBcnReq->bcnReq[j].measurementDuration = tempInt; |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 7384 | break; |
| 7385 | } |
| 7386 | } |
| 7387 | } |
| 7388 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 7389 | for (j = 0; j < pEseBcnReq->numBcnReqIe; j++) |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 7390 | { |
| 7391 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Arun Kumar Khandavalli | e876821 | 2014-02-17 16:43:34 +0530 | [diff] [blame] | 7392 | "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] | 7393 | j, |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 7394 | pEseBcnReq->bcnReq[j].measurementToken, |
| 7395 | pEseBcnReq->bcnReq[j].channel, |
| 7396 | pEseBcnReq->bcnReq[j].scanMode, |
| 7397 | pEseBcnReq->bcnReq[j].measurementDuration); |
Srinivas Girigowda | 91ccbe8 | 2013-11-10 16:37:38 -0800 | [diff] [blame] | 7398 | } |
| 7399 | |
| 7400 | return VOS_STATUS_SUCCESS; |
| 7401 | } |
| 7402 | |
Hanumanth Reddy Pothula | 1ceb703 | 2018-04-05 19:35:55 +0530 | [diff] [blame] | 7403 | struct tsm_priv { |
| 7404 | tAniTrafStrmMetrics tsm_metrics; |
| 7405 | }; |
| 7406 | |
| 7407 | static void hdd_get_tsm_stats_cb(tAniTrafStrmMetrics tsm_metrics, |
| 7408 | const tANI_U32 sta_id, void *context ) |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 7409 | { |
Hanumanth Reddy Pothula | 1ceb703 | 2018-04-05 19:35:55 +0530 | [diff] [blame] | 7410 | struct hdd_request *request; |
| 7411 | struct tsm_priv *priv; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 7412 | |
Hanumanth Reddy Pothula | 1ceb703 | 2018-04-05 19:35:55 +0530 | [diff] [blame] | 7413 | ENTER(); |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 7414 | |
Hanumanth Reddy Pothula | 1ceb703 | 2018-04-05 19:35:55 +0530 | [diff] [blame] | 7415 | request = hdd_request_get(context); |
| 7416 | if (!request) { |
| 7417 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Obsolete request")); |
| 7418 | return; |
| 7419 | } |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 7420 | |
Hanumanth Reddy Pothula | 1ceb703 | 2018-04-05 19:35:55 +0530 | [diff] [blame] | 7421 | priv = hdd_request_priv(request); |
| 7422 | priv->tsm_metrics = tsm_metrics; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 7423 | |
Hanumanth Reddy Pothula | 1ceb703 | 2018-04-05 19:35:55 +0530 | [diff] [blame] | 7424 | hdd_request_complete(request); |
| 7425 | hdd_request_put(request); |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 7426 | |
Hanumanth Reddy Pothula | 1ceb703 | 2018-04-05 19:35:55 +0530 | [diff] [blame] | 7427 | EXIT(); |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 7428 | } |
| 7429 | |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 7430 | static VOS_STATUS hdd_get_tsm_stats(hdd_adapter_t *pAdapter, const tANI_U8 tid, |
| 7431 | tAniTrafStrmMetrics* pTsmMetrics) |
| 7432 | { |
| 7433 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 7434 | eHalStatus hstatus; |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 7435 | VOS_STATUS vstatus = VOS_STATUS_SUCCESS; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 7436 | hdd_context_t *pHddCtx = NULL; |
Hanumanth Reddy Pothula | 1ceb703 | 2018-04-05 19:35:55 +0530 | [diff] [blame] | 7437 | int ret; |
| 7438 | void *cookie; |
| 7439 | struct hdd_request *request; |
| 7440 | struct tsm_priv *priv; |
| 7441 | static const struct hdd_request_params params = { |
| 7442 | .priv_size = sizeof(*priv), |
| 7443 | .timeout_ms = WLAN_WAIT_TIME_STATS, |
| 7444 | }; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 7445 | |
| 7446 | if (NULL == pAdapter) |
| 7447 | { |
| 7448 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: pAdapter is NULL", __func__); |
| 7449 | return VOS_STATUS_E_FAULT; |
| 7450 | } |
| 7451 | |
| 7452 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 7453 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 7454 | |
Hanumanth Reddy Pothula | 1ceb703 | 2018-04-05 19:35:55 +0530 | [diff] [blame] | 7455 | request = hdd_request_alloc(¶ms); |
| 7456 | if (!request) { |
| 7457 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure")); |
| 7458 | return VOS_STATUS_E_NOMEM; |
| 7459 | } |
| 7460 | cookie = hdd_request_cookie(request); |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 7461 | |
| 7462 | /* query tsm stats */ |
Hanumanth Reddy Pothula | 1ceb703 | 2018-04-05 19:35:55 +0530 | [diff] [blame] | 7463 | hstatus = sme_GetTsmStats(pHddCtx->hHal, hdd_get_tsm_stats_cb, |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 7464 | pHddStaCtx->conn_info.staId[ 0 ], |
| 7465 | pHddStaCtx->conn_info.bssId, |
Hanumanth Reddy Pothula | 1ceb703 | 2018-04-05 19:35:55 +0530 | [diff] [blame] | 7466 | cookie, pHddCtx->pvosContext, tid); |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 7467 | |
| 7468 | if (eHAL_STATUS_SUCCESS != hstatus) |
| 7469 | { |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 7470 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unable to retrieve statistics", |
| 7471 | __func__); |
| 7472 | vstatus = VOS_STATUS_E_FAULT; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 7473 | } |
| 7474 | else |
| 7475 | { |
| 7476 | /* request was sent -- wait for the response */ |
Hanumanth Reddy Pothula | 1ceb703 | 2018-04-05 19:35:55 +0530 | [diff] [blame] | 7477 | ret = hdd_request_wait_for_response(request); |
| 7478 | if (ret) { |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 7479 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Hanumanth Reddy Pothula | 1ceb703 | 2018-04-05 19:35:55 +0530 | [diff] [blame] | 7480 | "SME timeout while retrieving statistics"); |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 7481 | vstatus = VOS_STATUS_E_TIMEOUT; |
Hanumanth Reddy Pothula | 1ceb703 | 2018-04-05 19:35:55 +0530 | [diff] [blame] | 7482 | } else { |
| 7483 | priv = hdd_request_priv(request); |
| 7484 | *pTsmMetrics = priv->tsm_metrics; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 7485 | } |
| 7486 | } |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 7487 | |
Hanumanth Reddy Pothula | 1ceb703 | 2018-04-05 19:35:55 +0530 | [diff] [blame] | 7488 | hdd_request_put(request); |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 7489 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 7490 | return vstatus; |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 7491 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 7492 | #endif /*FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */ |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 7493 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 7494 | #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] | 7495 | void hdd_getBand_helper(hdd_context_t *pHddCtx, int *pBand) |
| 7496 | { |
| 7497 | eCsrBand band = -1; |
| 7498 | sme_GetFreqBand((tHalHandle)(pHddCtx->hHal), &band); |
| 7499 | switch (band) |
| 7500 | { |
| 7501 | case eCSR_BAND_ALL: |
| 7502 | *pBand = WLAN_HDD_UI_BAND_AUTO; |
| 7503 | break; |
| 7504 | |
| 7505 | case eCSR_BAND_24: |
| 7506 | *pBand = WLAN_HDD_UI_BAND_2_4_GHZ; |
| 7507 | break; |
| 7508 | |
| 7509 | case eCSR_BAND_5G: |
| 7510 | *pBand = WLAN_HDD_UI_BAND_5_GHZ; |
| 7511 | break; |
| 7512 | |
| 7513 | default: |
| 7514 | hddLog( VOS_TRACE_LEVEL_WARN, "%s: Invalid Band %d", __func__, band); |
| 7515 | *pBand = -1; |
| 7516 | break; |
| 7517 | } |
| 7518 | } |
| 7519 | |
| 7520 | /**--------------------------------------------------------------------------- |
| 7521 | |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 7522 | \brief hdd_parse_send_action_frame_data() - HDD Parse send action frame data |
| 7523 | |
| 7524 | This function parses the send action frame data passed in the format |
| 7525 | SENDACTIONFRAME<space><bssid><space><channel><space><dwelltime><space><data> |
| 7526 | |
Srinivas Girigowda | 5607685 | 2013-08-20 14:00:50 -0700 | [diff] [blame] | 7527 | \param - pValue Pointer to input data |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 7528 | \param - pTargetApBssid Pointer to target Ap bssid |
| 7529 | \param - pChannel Pointer to the Target AP channel |
| 7530 | \param - pDwellTime Pointer to the time to stay off-channel after transmitting action frame |
| 7531 | \param - pBuf Pointer to data |
| 7532 | \param - pBufLen Pointer to data length |
| 7533 | |
| 7534 | \return - 0 for success non-zero for failure |
| 7535 | |
| 7536 | --------------------------------------------------------------------------*/ |
| 7537 | VOS_STATUS hdd_parse_send_action_frame_data(tANI_U8 *pValue, tANI_U8 *pTargetApBssid, tANI_U8 *pChannel, |
| 7538 | tANI_U8 *pDwellTime, tANI_U8 **pBuf, tANI_U8 *pBufLen) |
| 7539 | { |
| 7540 | tANI_U8 *inPtr = pValue; |
| 7541 | tANI_U8 *dataEnd; |
| 7542 | int tempInt; |
| 7543 | int j = 0; |
| 7544 | int i = 0; |
| 7545 | int v = 0; |
| 7546 | tANI_U8 tempBuf[32]; |
| 7547 | tANI_U8 tempByte = 0; |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 7548 | /* 12 hexa decimal digits, 5 ':' and '\0' */ |
| 7549 | tANI_U8 macAddress[18]; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 7550 | |
| 7551 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 7552 | /*no argument after the command*/ |
| 7553 | if (NULL == inPtr) |
| 7554 | { |
| 7555 | return -EINVAL; |
| 7556 | } |
| 7557 | |
| 7558 | /*no space after the command*/ |
| 7559 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 7560 | { |
| 7561 | return -EINVAL; |
| 7562 | } |
| 7563 | |
| 7564 | /*removing empty spaces*/ |
| 7565 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 7566 | |
| 7567 | /*no argument followed by spaces*/ |
| 7568 | if ('\0' == *inPtr) |
| 7569 | { |
| 7570 | return -EINVAL; |
| 7571 | } |
| 7572 | |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 7573 | v = sscanf(inPtr, "%17s", macAddress); |
| 7574 | if (!((1 == v) && hdd_is_valid_mac_address(macAddress))) |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 7575 | { |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 7576 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7577 | "Invalid MAC address or All hex inputs are not read (%d)", v); |
| 7578 | return -EINVAL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 7579 | } |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 7580 | |
| 7581 | pTargetApBssid[0] = hdd_parse_hex(macAddress[0]) << 4 | hdd_parse_hex(macAddress[1]); |
| 7582 | pTargetApBssid[1] = hdd_parse_hex(macAddress[3]) << 4 | hdd_parse_hex(macAddress[4]); |
| 7583 | pTargetApBssid[2] = hdd_parse_hex(macAddress[6]) << 4 | hdd_parse_hex(macAddress[7]); |
| 7584 | pTargetApBssid[3] = hdd_parse_hex(macAddress[9]) << 4 | hdd_parse_hex(macAddress[10]); |
| 7585 | pTargetApBssid[4] = hdd_parse_hex(macAddress[12]) << 4 | hdd_parse_hex(macAddress[13]); |
| 7586 | 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] | 7587 | |
| 7588 | /* point to the next argument */ |
| 7589 | inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE); |
| 7590 | /*no argument after the command*/ |
| 7591 | if (NULL == inPtr) return -EINVAL; |
| 7592 | |
| 7593 | /*removing empty spaces*/ |
| 7594 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 7595 | |
| 7596 | /*no argument followed by spaces*/ |
| 7597 | if ('\0' == *inPtr) |
| 7598 | { |
| 7599 | return -EINVAL; |
| 7600 | } |
| 7601 | |
| 7602 | /*getting the next argument ie the channel number */ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 7603 | v = sscanf(inPtr, "%31s ", tempBuf); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 7604 | if (1 != v) return -EINVAL; |
| 7605 | |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 7606 | v = kstrtos32(tempBuf, 10, &tempInt); |
Agarwal Ashish | 353b3a8 | 2014-04-08 14:55:11 +0530 | [diff] [blame] | 7607 | if ( v < 0 || tempInt <= 0 || tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX ) |
Kiet Lam | be150c2 | 2013-11-21 16:30:32 +0530 | [diff] [blame] | 7608 | return -EINVAL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 7609 | |
| 7610 | *pChannel = tempInt; |
| 7611 | |
| 7612 | /* point to the next argument */ |
| 7613 | inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE); |
| 7614 | /*no argument after the command*/ |
| 7615 | if (NULL == inPtr) return -EINVAL; |
| 7616 | /*removing empty spaces*/ |
| 7617 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 7618 | |
| 7619 | /*no argument followed by spaces*/ |
| 7620 | if ('\0' == *inPtr) |
| 7621 | { |
| 7622 | return -EINVAL; |
| 7623 | } |
| 7624 | |
| 7625 | /*getting the next argument ie the dwell time */ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 7626 | v = sscanf(inPtr, "%31s ", tempBuf); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 7627 | if (1 != v) return -EINVAL; |
| 7628 | |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 7629 | v = kstrtos32(tempBuf, 10, &tempInt); |
Srinivas Girigowda | 5a6e067 | 2014-01-09 14:42:57 -0800 | [diff] [blame] | 7630 | if ( v < 0 || tempInt < 0) return -EINVAL; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 7631 | |
| 7632 | *pDwellTime = tempInt; |
| 7633 | |
| 7634 | /* point to the next argument */ |
| 7635 | inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE); |
| 7636 | /*no argument after the command*/ |
| 7637 | if (NULL == inPtr) return -EINVAL; |
| 7638 | /*removing empty spaces*/ |
| 7639 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 7640 | |
| 7641 | /*no argument followed by spaces*/ |
| 7642 | if ('\0' == *inPtr) |
| 7643 | { |
| 7644 | return -EINVAL; |
| 7645 | } |
| 7646 | |
| 7647 | /* find the length of data */ |
| 7648 | dataEnd = inPtr; |
| 7649 | while(('\0' != *dataEnd) ) |
| 7650 | { |
| 7651 | dataEnd++; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 7652 | } |
Kiet Lam | be150c2 | 2013-11-21 16:30:32 +0530 | [diff] [blame] | 7653 | *pBufLen = dataEnd - inPtr ; |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 7654 | if ( *pBufLen <= 0) return -EINVAL; |
| 7655 | |
Srinivas Girigowda | b5ae85d | 2013-06-03 10:51:45 -0700 | [diff] [blame] | 7656 | /* Allocate the number of bytes based on the number of input characters |
| 7657 | whether it is even or odd. |
| 7658 | if the number of input characters are even, then we need N/2 byte. |
| 7659 | if the number of input characters are odd, then we need do (N+1)/2 to |
| 7660 | compensate rounding off. |
| 7661 | For example, if N = 18, then (18 + 1)/2 = 9 bytes are enough. |
| 7662 | If N = 19, then we need 10 bytes, hence (19 + 1)/2 = 10 bytes */ |
| 7663 | *pBuf = vos_mem_malloc((*pBufLen + 1)/2); |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 7664 | if (NULL == *pBuf) |
| 7665 | { |
| 7666 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 7667 | "%s: vos_mem_alloc failed ", __func__); |
| 7668 | return -EINVAL; |
| 7669 | } |
| 7670 | |
| 7671 | /* the buffer received from the upper layer is character buffer, |
| 7672 | we need to prepare the buffer taking 2 characters in to a U8 hex decimal number |
| 7673 | for example 7f0000f0...form a buffer to contain 7f in 0th location, 00 in 1st |
| 7674 | and f0 in 3rd location */ |
| 7675 | for (i = 0, j = 0; j < *pBufLen; j += 2) |
| 7676 | { |
Kiet Lam | be150c2 | 2013-11-21 16:30:32 +0530 | [diff] [blame] | 7677 | if( j+1 == *pBufLen) |
| 7678 | { |
| 7679 | tempByte = hdd_parse_hex(inPtr[j]); |
| 7680 | } |
| 7681 | else |
| 7682 | { |
| 7683 | tempByte = (hdd_parse_hex(inPtr[j]) << 4) | (hdd_parse_hex(inPtr[j + 1])); |
| 7684 | } |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 7685 | (*pBuf)[i++] = tempByte; |
| 7686 | } |
| 7687 | *pBufLen = i; |
| 7688 | return VOS_STATUS_SUCCESS; |
| 7689 | } |
| 7690 | |
Srinivas Girigowda | 100eb32 | 2013-03-15 16:48:20 -0700 | [diff] [blame] | 7691 | /**--------------------------------------------------------------------------- |
| 7692 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 7693 | \brief hdd_parse_channellist() - HDD Parse channel list |
| 7694 | |
| 7695 | This function parses the channel list passed in the format |
| 7696 | 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] | 7697 | if the Number of channels (N) does not match with the actual number of channels passed |
| 7698 | then take the minimum of N and count of (Ch1, Ch2, ...Ch M) |
| 7699 | For example, if SETROAMSCANCHANNELS 3 36 40 44 48, only 36, 40 and 44 shall be taken. |
| 7700 | If SETROAMSCANCHANNELS 5 36 40 44 48, ignore 5 and take 36, 40, 44 and 48. |
| 7701 | 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] | 7702 | |
| 7703 | \param - pValue Pointer to input channel list |
| 7704 | \param - ChannelList Pointer to local output array to record channel list |
| 7705 | \param - pNumChannels Pointer to number of roam scan channels |
| 7706 | |
| 7707 | \return - 0 for success non-zero for failure |
| 7708 | |
| 7709 | --------------------------------------------------------------------------*/ |
| 7710 | VOS_STATUS hdd_parse_channellist(tANI_U8 *pValue, tANI_U8 *pChannelList, tANI_U8 *pNumChannels) |
| 7711 | { |
| 7712 | tANI_U8 *inPtr = pValue; |
| 7713 | int tempInt; |
| 7714 | int j = 0; |
| 7715 | int v = 0; |
| 7716 | char buf[32]; |
| 7717 | |
| 7718 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 7719 | /*no argument after the command*/ |
| 7720 | if (NULL == inPtr) |
| 7721 | { |
| 7722 | return -EINVAL; |
| 7723 | } |
| 7724 | |
| 7725 | /*no space after the command*/ |
| 7726 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 7727 | { |
| 7728 | return -EINVAL; |
| 7729 | } |
| 7730 | |
| 7731 | /*removing empty spaces*/ |
Jeff Johnson | a1f9afb | 2013-04-03 09:13:31 -0700 | [diff] [blame] | 7732 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 7733 | |
| 7734 | /*no argument followed by spaces*/ |
| 7735 | if ('\0' == *inPtr) |
| 7736 | { |
| 7737 | return -EINVAL; |
| 7738 | } |
| 7739 | |
| 7740 | /*getting the first argument ie the number of channels*/ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 7741 | v = sscanf(inPtr, "%31s ", buf); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 7742 | if (1 != v) return -EINVAL; |
| 7743 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 7744 | v = kstrtos32(buf, 10, &tempInt); |
Jeff Johnson | a1f9afb | 2013-04-03 09:13:31 -0700 | [diff] [blame] | 7745 | if ((v < 0) || |
| 7746 | (tempInt <= 0) || |
| 7747 | (tempInt > WNI_CFG_VALID_CHANNEL_LIST_LEN)) |
| 7748 | { |
| 7749 | return -EINVAL; |
| 7750 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 7751 | |
| 7752 | *pNumChannels = tempInt; |
| 7753 | |
| 7754 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
| 7755 | "Number of channels are: %d", *pNumChannels); |
| 7756 | |
| 7757 | for (j = 0; j < (*pNumChannels); j++) |
| 7758 | { |
| 7759 | /*inPtr pointing to the beginning of first space after number of channels*/ |
| 7760 | inPtr = strpbrk( inPtr, " " ); |
| 7761 | /*no channel list after the number of channels argument*/ |
| 7762 | if (NULL == inPtr) |
| 7763 | { |
Srinivas Girigowda | cf9a9b4 | 2013-03-21 11:55:24 -0700 | [diff] [blame] | 7764 | if (0 != j) |
| 7765 | { |
| 7766 | *pNumChannels = j; |
| 7767 | return VOS_STATUS_SUCCESS; |
| 7768 | } |
| 7769 | else |
| 7770 | { |
| 7771 | return -EINVAL; |
| 7772 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 7773 | } |
| 7774 | |
| 7775 | /*removing empty space*/ |
Jeff Johnson | a1f9afb | 2013-04-03 09:13:31 -0700 | [diff] [blame] | 7776 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr)) inPtr++; |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 7777 | |
| 7778 | /*no channel list after the number of channels argument and spaces*/ |
| 7779 | if ( '\0' == *inPtr ) |
| 7780 | { |
Srinivas Girigowda | cf9a9b4 | 2013-03-21 11:55:24 -0700 | [diff] [blame] | 7781 | if (0 != j) |
| 7782 | { |
| 7783 | *pNumChannels = j; |
| 7784 | return VOS_STATUS_SUCCESS; |
| 7785 | } |
| 7786 | else |
| 7787 | { |
| 7788 | return -EINVAL; |
| 7789 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 7790 | } |
| 7791 | |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 7792 | v = sscanf(inPtr, "%31s ", buf); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 7793 | if (1 != v) return -EINVAL; |
| 7794 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 7795 | v = kstrtos32(buf, 10, &tempInt); |
Jeff Johnson | a1f9afb | 2013-04-03 09:13:31 -0700 | [diff] [blame] | 7796 | if ((v < 0) || |
| 7797 | (tempInt <= 0) || |
| 7798 | (tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX)) |
| 7799 | { |
| 7800 | return -EINVAL; |
| 7801 | } |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 7802 | pChannelList[j] = tempInt; |
| 7803 | |
| 7804 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
| 7805 | "Channel %d added to preferred channel list", |
| 7806 | pChannelList[j] ); |
| 7807 | } |
| 7808 | |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 7809 | return VOS_STATUS_SUCCESS; |
| 7810 | } |
| 7811 | |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 7812 | |
Selvaraj, Sridhar | 5aff1ed | 2016-06-18 01:26:23 +0530 | [diff] [blame] | 7813 | /** |
| 7814 | * hdd_parse_reassoc_command_v1_data() - HDD Parse reassoc command data |
| 7815 | * This function parses the reasoc command data passed in the format |
| 7816 | * REASSOC<space><bssid><space><channel> |
| 7817 | * |
| 7818 | * @pValue: Pointer to input data (its a NUL terminated string) |
| 7819 | * @pTargetApBssid: Pointer to target Ap bssid |
| 7820 | * @pChannel: Pointer to the Target AP channel |
| 7821 | * |
| 7822 | * Return: 0 for success non-zero for failure |
| 7823 | */ |
| 7824 | static int hdd_parse_reassoc_command_v1_data(const tANI_U8 *pValue, |
| 7825 | tANI_U8 *pTargetApBssid, tANI_U8 *pChannel) |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 7826 | { |
Selvaraj, Sridhar | 5aff1ed | 2016-06-18 01:26:23 +0530 | [diff] [blame] | 7827 | const tANI_U8 *inPtr = pValue; |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 7828 | int tempInt; |
| 7829 | int v = 0; |
| 7830 | tANI_U8 tempBuf[32]; |
Kiet Lam | aa8e15a | 2014-02-11 23:30:06 -0800 | [diff] [blame] | 7831 | /* 12 hexa decimal digits, 5 ':' and '\0' */ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 7832 | tANI_U8 macAddress[18]; |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 7833 | |
| 7834 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 7835 | /*no argument after the command*/ |
| 7836 | if (NULL == inPtr) |
| 7837 | { |
| 7838 | return -EINVAL; |
| 7839 | } |
| 7840 | |
| 7841 | /*no space after the command*/ |
| 7842 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 7843 | { |
| 7844 | return -EINVAL; |
| 7845 | } |
| 7846 | |
| 7847 | /*removing empty spaces*/ |
| 7848 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 7849 | |
| 7850 | /*no argument followed by spaces*/ |
| 7851 | if ('\0' == *inPtr) |
| 7852 | { |
| 7853 | return -EINVAL; |
| 7854 | } |
| 7855 | |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 7856 | v = sscanf(inPtr, "%17s", macAddress); |
| 7857 | if (!((1 == v) && hdd_is_valid_mac_address(macAddress))) |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 7858 | { |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 7859 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7860 | "Invalid MAC address or All hex inputs are not read (%d)", v); |
| 7861 | return -EINVAL; |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 7862 | } |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 7863 | |
| 7864 | pTargetApBssid[0] = hdd_parse_hex(macAddress[0]) << 4 | hdd_parse_hex(macAddress[1]); |
| 7865 | pTargetApBssid[1] = hdd_parse_hex(macAddress[3]) << 4 | hdd_parse_hex(macAddress[4]); |
| 7866 | pTargetApBssid[2] = hdd_parse_hex(macAddress[6]) << 4 | hdd_parse_hex(macAddress[7]); |
| 7867 | pTargetApBssid[3] = hdd_parse_hex(macAddress[9]) << 4 | hdd_parse_hex(macAddress[10]); |
| 7868 | pTargetApBssid[4] = hdd_parse_hex(macAddress[12]) << 4 | hdd_parse_hex(macAddress[13]); |
| 7869 | 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] | 7870 | |
| 7871 | /* point to the next argument */ |
| 7872 | inPtr = strnchr(inPtr, strlen(inPtr), SPACE_ASCII_VALUE); |
| 7873 | /*no argument after the command*/ |
| 7874 | if (NULL == inPtr) return -EINVAL; |
| 7875 | |
| 7876 | /*removing empty spaces*/ |
| 7877 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 7878 | |
| 7879 | /*no argument followed by spaces*/ |
| 7880 | if ('\0' == *inPtr) |
| 7881 | { |
| 7882 | return -EINVAL; |
| 7883 | } |
| 7884 | |
| 7885 | /*getting the next argument ie the channel number */ |
Srinivas Girigowda | 4081bb1 | 2014-01-06 17:12:58 -0800 | [diff] [blame] | 7886 | v = sscanf(inPtr, "%31s ", tempBuf); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 7887 | if (1 != v) return -EINVAL; |
| 7888 | |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 7889 | v = kstrtos32(tempBuf, 10, &tempInt); |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 7890 | if ((v < 0) || |
Padma, Santhosh Kumar | 0fa809b | 2014-11-13 14:56:56 +0530 | [diff] [blame] | 7891 | (tempInt < 0) || |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 7892 | (tempInt > WNI_CFG_CURRENT_CHANNEL_STAMAX)) |
| 7893 | { |
| 7894 | return -EINVAL; |
| 7895 | } |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 7896 | |
| 7897 | *pChannel = tempInt; |
| 7898 | return VOS_STATUS_SUCCESS; |
| 7899 | } |
| 7900 | |
| 7901 | #endif |
| 7902 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 7903 | #if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD) |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 7904 | /**--------------------------------------------------------------------------- |
| 7905 | |
| 7906 | \brief hdd_parse_get_cckm_ie() - HDD Parse and fetch the CCKM IE |
| 7907 | |
| 7908 | This function parses the SETCCKM IE command |
| 7909 | SETCCKMIE<space><ie data> |
| 7910 | |
| 7911 | \param - pValue Pointer to input data |
| 7912 | \param - pCckmIe Pointer to output cckm Ie |
| 7913 | \param - pCckmIeLen Pointer to output cckm ie length |
| 7914 | |
| 7915 | \return - 0 for success non-zero for failure |
| 7916 | |
| 7917 | --------------------------------------------------------------------------*/ |
| 7918 | VOS_STATUS hdd_parse_get_cckm_ie(tANI_U8 *pValue, tANI_U8 **pCckmIe, |
| 7919 | tANI_U8 *pCckmIeLen) |
| 7920 | { |
| 7921 | tANI_U8 *inPtr = pValue; |
| 7922 | tANI_U8 *dataEnd; |
| 7923 | int j = 0; |
| 7924 | int i = 0; |
| 7925 | tANI_U8 tempByte = 0; |
| 7926 | |
| 7927 | inPtr = strnchr(pValue, strlen(pValue), SPACE_ASCII_VALUE); |
| 7928 | /*no argument after the command*/ |
| 7929 | if (NULL == inPtr) |
| 7930 | { |
| 7931 | return -EINVAL; |
| 7932 | } |
| 7933 | |
| 7934 | /*no space after the command*/ |
| 7935 | else if (SPACE_ASCII_VALUE != *inPtr) |
| 7936 | { |
| 7937 | return -EINVAL; |
| 7938 | } |
| 7939 | |
| 7940 | /*removing empty spaces*/ |
| 7941 | while ((SPACE_ASCII_VALUE == *inPtr) && ('\0' != *inPtr) ) inPtr++; |
| 7942 | |
| 7943 | /*no argument followed by spaces*/ |
| 7944 | if ('\0' == *inPtr) |
| 7945 | { |
| 7946 | return -EINVAL; |
| 7947 | } |
| 7948 | |
| 7949 | /* find the length of data */ |
| 7950 | dataEnd = inPtr; |
| 7951 | while(('\0' != *dataEnd) ) |
| 7952 | { |
| 7953 | dataEnd++; |
| 7954 | ++(*pCckmIeLen); |
| 7955 | } |
| 7956 | if ( *pCckmIeLen <= 0) return -EINVAL; |
| 7957 | |
| 7958 | /* Allocate the number of bytes based on the number of input characters |
| 7959 | whether it is even or odd. |
| 7960 | if the number of input characters are even, then we need N/2 byte. |
| 7961 | if the number of input characters are odd, then we need do (N+1)/2 to |
| 7962 | compensate rounding off. |
| 7963 | For example, if N = 18, then (18 + 1)/2 = 9 bytes are enough. |
| 7964 | If N = 19, then we need 10 bytes, hence (19 + 1)/2 = 10 bytes */ |
| 7965 | *pCckmIe = vos_mem_malloc((*pCckmIeLen + 1)/2); |
| 7966 | if (NULL == *pCckmIe) |
| 7967 | { |
| 7968 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 7969 | "%s: vos_mem_alloc failed ", __func__); |
| 7970 | return -EINVAL; |
| 7971 | } |
| 7972 | vos_mem_zero(*pCckmIe, (*pCckmIeLen + 1)/2); |
| 7973 | /* the buffer received from the upper layer is character buffer, |
| 7974 | we need to prepare the buffer taking 2 characters in to a U8 hex decimal number |
| 7975 | for example 7f0000f0...form a buffer to contain 7f in 0th location, 00 in 1st |
| 7976 | and f0 in 3rd location */ |
| 7977 | for (i = 0, j = 0; j < *pCckmIeLen; j += 2) |
| 7978 | { |
| 7979 | tempByte = (hdd_parse_hex(inPtr[j]) << 4) | (hdd_parse_hex(inPtr[j + 1])); |
| 7980 | (*pCckmIe)[i++] = tempByte; |
| 7981 | } |
| 7982 | *pCckmIeLen = i; |
| 7983 | |
| 7984 | return VOS_STATUS_SUCCESS; |
| 7985 | } |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 7986 | #endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */ |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 7987 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7988 | /**--------------------------------------------------------------------------- |
| 7989 | |
Srinivas Girigowda | 0c69aee | 2013-10-09 17:21:01 -0700 | [diff] [blame] | 7990 | \brief hdd_is_valid_mac_address() - Validate MAC address |
| 7991 | |
| 7992 | This function validates whether the given MAC address is valid or not |
| 7993 | Expected MAC address is of the format XX:XX:XX:XX:XX:XX |
| 7994 | where X is the hexa decimal digit character and separated by ':' |
| 7995 | This algorithm works even if MAC address is not separated by ':' |
| 7996 | |
| 7997 | This code checks given input string mac contains exactly 12 hexadecimal digits. |
| 7998 | and a separator colon : appears in the input string only after |
| 7999 | an even number of hex digits. |
| 8000 | |
| 8001 | \param - pMacAddr pointer to the input MAC address |
| 8002 | \return - 1 for valid and 0 for invalid |
| 8003 | |
| 8004 | --------------------------------------------------------------------------*/ |
| 8005 | |
| 8006 | v_BOOL_t hdd_is_valid_mac_address(const tANI_U8 *pMacAddr) |
| 8007 | { |
| 8008 | int xdigit = 0; |
| 8009 | int separator = 0; |
| 8010 | while (*pMacAddr) |
| 8011 | { |
| 8012 | if (isxdigit(*pMacAddr)) |
| 8013 | { |
| 8014 | xdigit++; |
| 8015 | } |
| 8016 | else if (':' == *pMacAddr) |
| 8017 | { |
| 8018 | if (0 == xdigit || ((xdigit / 2) - 1) != separator) |
| 8019 | break; |
| 8020 | |
| 8021 | ++separator; |
| 8022 | } |
| 8023 | else |
| 8024 | { |
| 8025 | separator = -1; |
| 8026 | /* Invalid MAC found */ |
| 8027 | return 0; |
| 8028 | } |
| 8029 | ++pMacAddr; |
| 8030 | } |
| 8031 | return (xdigit == 12 && (separator == 5 || separator == 0)); |
| 8032 | } |
| 8033 | |
| 8034 | /**--------------------------------------------------------------------------- |
| 8035 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 8036 | \brief __hdd_open() - HDD Open function |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8037 | |
| 8038 | \param - dev Pointer to net_device structure |
| 8039 | |
| 8040 | \return - 0 for success non-zero for failure |
| 8041 | |
| 8042 | --------------------------------------------------------------------------*/ |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 8043 | int __hdd_open(struct net_device *dev) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8044 | { |
| 8045 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 8046 | hdd_context_t *pHddCtx; |
| 8047 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 8048 | VOS_STATUS status; |
| 8049 | v_BOOL_t in_standby = TRUE; |
| 8050 | |
| 8051 | if (NULL == pAdapter) |
| 8052 | { |
| 8053 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Agarwal Ashish | 971c288 | 2013-10-30 20:11:12 +0530 | [diff] [blame] | 8054 | "%s: pAdapter is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8055 | return -ENODEV; |
| 8056 | } |
| 8057 | |
| 8058 | pHddCtx = (hdd_context_t*)pAdapter->pHddCtx; |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 8059 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_OPEN_REQUEST, |
| 8060 | pAdapter->sessionId, pAdapter->device_mode)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8061 | if (NULL == pHddCtx) |
| 8062 | { |
| 8063 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 8064 | "%s: HDD context is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8065 | return -ENODEV; |
| 8066 | } |
| 8067 | |
Arun Kumar Khandavalli | 9113aee | 2020-02-26 10:54:02 +0530 | [diff] [blame^] | 8068 | if (test_bit(DEVICE_IFACE_OPENED, &pAdapter->event_flags)) { |
| 8069 | hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: session already opened for the adapter", |
| 8070 | __func__); |
| 8071 | return 0; |
| 8072 | } |
| 8073 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8074 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 8075 | while ( (NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status) ) |
| 8076 | { |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 8077 | if (test_bit(DEVICE_IFACE_OPENED, &pAdapterNode->pAdapter->event_flags)) |
| 8078 | { |
| 8079 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: chip already out of standby", |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 8080 | __func__); |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 8081 | in_standby = FALSE; |
| 8082 | break; |
| 8083 | } |
| 8084 | else |
| 8085 | { |
| 8086 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 8087 | pAdapterNode = pNext; |
| 8088 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8089 | } |
| 8090 | |
| 8091 | if (TRUE == in_standby) |
| 8092 | { |
| 8093 | if (VOS_STATUS_SUCCESS != wlan_hdd_exit_lowpower(pHddCtx, pAdapter)) |
| 8094 | { |
| 8095 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failed to bring " |
| 8096 | "wlan out of power save", __func__); |
| 8097 | return -EINVAL; |
| 8098 | } |
| 8099 | } |
Arun Kumar Khandavalli | 9113aee | 2020-02-26 10:54:02 +0530 | [diff] [blame^] | 8100 | |
| 8101 | status = hdd_init_station_mode( pAdapter ); |
| 8102 | if( VOS_STATUS_SUCCESS != status ) { |
| 8103 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failed to create session for station mode", |
| 8104 | __func__); |
| 8105 | return -EINVAL; |
| 8106 | } |
| 8107 | |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 8108 | set_bit(DEVICE_IFACE_OPENED, &pAdapter->event_flags); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8109 | if (hdd_connIsConnected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) |
| 8110 | { |
| 8111 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 8112 | "%s: Enabling Tx Queues", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8113 | /* Enable TX queues only when we are connected */ |
Padma, Santhosh Kumar | 9dacb5c | 2014-12-17 19:22:56 +0530 | [diff] [blame] | 8114 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8115 | netif_tx_start_all_queues(dev); |
| 8116 | } |
| 8117 | |
| 8118 | return 0; |
| 8119 | } |
| 8120 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 8121 | /**--------------------------------------------------------------------------- |
| 8122 | |
| 8123 | \brief hdd_open() - Wrapper function for __hdd_open to protect it from SSR |
| 8124 | |
| 8125 | This is called in response to ifconfig up |
| 8126 | |
| 8127 | \param - dev Pointer to net_device structure |
| 8128 | |
| 8129 | \return - 0 for success non-zero for failure |
| 8130 | |
| 8131 | --------------------------------------------------------------------------*/ |
| 8132 | int hdd_open(struct net_device *dev) |
| 8133 | { |
| 8134 | int ret; |
| 8135 | |
| 8136 | vos_ssr_protect(__func__); |
| 8137 | ret = __hdd_open(dev); |
| 8138 | vos_ssr_unprotect(__func__); |
| 8139 | |
| 8140 | return ret; |
| 8141 | } |
| 8142 | |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 8143 | int __hdd_mon_open (struct net_device *dev) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8144 | { |
| 8145 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 8146 | hdd_adapter_t *sta_adapter; |
| 8147 | hdd_context_t *hdd_ctx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8148 | |
| 8149 | if(pAdapter == NULL) { |
| 8150 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 8151 | "%s: HDD adapter context is Null", __func__); |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 8152 | return -EINVAL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8153 | } |
| 8154 | |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 8155 | if (vos_get_concurrency_mode() != VOS_STA_MON) |
| 8156 | return 0; |
| 8157 | |
| 8158 | hdd_ctx = WLAN_HDD_GET_CTX(pAdapter); |
| 8159 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 8160 | return -EINVAL; |
| 8161 | |
| 8162 | sta_adapter = hdd_get_adapter(hdd_ctx, WLAN_HDD_INFRA_STATION); |
| 8163 | if (!sta_adapter) { |
| 8164 | hddLog(LOGE, FL("No valid STA interface")); |
| 8165 | return -EINVAL; |
| 8166 | } |
| 8167 | |
| 8168 | if (!test_bit(DEVICE_IFACE_OPENED, &sta_adapter->event_flags)) { |
| 8169 | hddLog(LOGE, FL("STA Interface is not OPENED")); |
| 8170 | return -EINVAL; |
| 8171 | } |
| 8172 | |
| 8173 | set_bit(DEVICE_IFACE_OPENED, &pAdapter->event_flags); |
| 8174 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8175 | return 0; |
| 8176 | } |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 8177 | |
| 8178 | int hdd_mon_open (struct net_device *dev) |
| 8179 | { |
| 8180 | int ret; |
| 8181 | |
| 8182 | vos_ssr_protect(__func__); |
| 8183 | ret = __hdd_mon_open(dev); |
| 8184 | vos_ssr_unprotect(__func__); |
| 8185 | |
| 8186 | return ret; |
| 8187 | } |
| 8188 | |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 8189 | int __hdd_mon_stop (struct net_device *dev) |
| 8190 | { |
| 8191 | hdd_adapter_t *mon_adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 8192 | hdd_context_t *hdd_ctx; |
| 8193 | |
| 8194 | if (vos_get_concurrency_mode() != VOS_STA_MON) |
| 8195 | return 0; |
| 8196 | |
| 8197 | if(!mon_adapter) { |
| 8198 | hddLog(LOGE, FL("HDD adapter is Null")); |
| 8199 | return -EINVAL; |
| 8200 | } |
| 8201 | |
| 8202 | hdd_ctx = WLAN_HDD_GET_CTX(mon_adapter); |
| 8203 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 8204 | return -EINVAL; |
| 8205 | |
| 8206 | if (!test_bit(DEVICE_IFACE_OPENED, &mon_adapter->event_flags)) { |
| 8207 | hddLog(LOGE, FL("NETDEV Interface is not OPENED")); |
| 8208 | return -ENODEV; |
| 8209 | } |
| 8210 | |
| 8211 | clear_bit(DEVICE_IFACE_OPENED, &mon_adapter->event_flags); |
| 8212 | hdd_stop_adapter(hdd_ctx, mon_adapter, VOS_FALSE); |
| 8213 | |
| 8214 | return 0; |
| 8215 | } |
| 8216 | |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 8217 | int hdd_mon_stop(struct net_device *dev) |
| 8218 | { |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 8219 | int ret; |
| 8220 | |
| 8221 | vos_ssr_protect(__func__); |
| 8222 | ret = __hdd_mon_stop(dev); |
| 8223 | vos_ssr_unprotect(__func__); |
| 8224 | |
| 8225 | return ret; |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 8226 | } |
| 8227 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8228 | /**--------------------------------------------------------------------------- |
| 8229 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 8230 | \brief __hdd_stop() - HDD stop function |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8231 | |
| 8232 | \param - dev Pointer to net_device structure |
| 8233 | |
| 8234 | \return - 0 for success non-zero for failure |
| 8235 | |
| 8236 | --------------------------------------------------------------------------*/ |
| 8237 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 8238 | int __hdd_stop (struct net_device *dev) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8239 | { |
Vinay Krishna Eranna | 90f4353 | 2014-10-27 16:45:54 +0530 | [diff] [blame] | 8240 | int ret = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8241 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 8242 | hdd_context_t *pHddCtx; |
| 8243 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 8244 | VOS_STATUS status; |
| 8245 | v_BOOL_t enter_standby = TRUE; |
| 8246 | |
| 8247 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8248 | if (NULL == pAdapter) |
| 8249 | { |
| 8250 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Agarwal Ashish | 971c288 | 2013-10-30 20:11:12 +0530 | [diff] [blame] | 8251 | "%s: pAdapter is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8252 | return -ENODEV; |
| 8253 | } |
Sachin Ahuja | 9b4958f | 2015-01-15 21:37:00 +0530 | [diff] [blame] | 8254 | MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_STOP_REQUEST, |
Sushant Kaushik | 4b7cb30 | 2014-01-06 17:45:01 +0530 | [diff] [blame] | 8255 | pAdapter->sessionId, pAdapter->device_mode)); |
Vinay Krishna Eranna | 90f4353 | 2014-10-27 16:45:54 +0530 | [diff] [blame] | 8256 | |
| 8257 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 8258 | ret = wlan_hdd_validate_context(pHddCtx); |
| 8259 | if (ret) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8260 | { |
Vinay Krishna Eranna | 90f4353 | 2014-10-27 16:45:54 +0530 | [diff] [blame] | 8261 | return ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8262 | } |
| 8263 | |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 8264 | /* Nothing to be done if the interface is not opened */ |
| 8265 | if (VOS_FALSE == test_bit(DEVICE_IFACE_OPENED, &pAdapter->event_flags)) |
| 8266 | { |
| 8267 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8268 | "%s: NETDEV Interface is not OPENED", __func__); |
| 8269 | return -ENODEV; |
| 8270 | } |
| 8271 | |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 8272 | if (pHddCtx->concurrency_mode == VOS_STA_MON) { |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 8273 | /* |
Rajeev Kumar Sirasanagandla | a74e122 | 2018-01-09 17:38:55 +0530 | [diff] [blame] | 8274 | * In STA + Monitor mode concurrency, no point in running |
| 8275 | * capture on monitor interface, when STA interface is stopped |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 8276 | */ |
Rajeev Kumar Sirasanagandla | a74e122 | 2018-01-09 17:38:55 +0530 | [diff] [blame] | 8277 | wlan_hdd_stop_mon(pHddCtx, true); |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 8278 | } |
| 8279 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8280 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disabling OS Tx queues", __func__); |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 8281 | |
| 8282 | /* Disable TX on the interface, after this hard_start_xmit() will not |
| 8283 | * be called on that interface |
| 8284 | */ |
Padma, Santhosh Kumar | 9dacb5c | 2014-12-17 19:22:56 +0530 | [diff] [blame] | 8285 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8286 | netif_tx_disable(pAdapter->dev); |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 8287 | |
| 8288 | /* Mark the interface status as "down" for outside world */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8289 | netif_carrier_off(pAdapter->dev); |
| 8290 | |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 8291 | /* The interface is marked as down for outside world (aka kernel) |
| 8292 | * But the driver is pretty much alive inside. The driver needs to |
| 8293 | * tear down the existing connection on the netdev (session) |
| 8294 | * cleanup the data pipes and wait until the control plane is stabilized |
| 8295 | * for this interface. The call also needs to wait until the above |
| 8296 | * mentioned actions are completed before returning to the caller. |
| 8297 | * Notice that the hdd_stop_adapter is requested not to close the session |
| 8298 | * That is intentional to be able to scan if it is a STA/P2P interface |
| 8299 | */ |
Arun Kumar Khandavalli | 9113aee | 2020-02-26 10:54:02 +0530 | [diff] [blame^] | 8300 | hdd_stop_adapter(pHddCtx, pAdapter, VOS_TRUE); |
| 8301 | clear_bit(DEVICE_IFACE_OPENED, &pAdapter->event_flags); |
Mahesh A Saptasagar | 02e36e8 | 2015-01-14 20:39:19 +0530 | [diff] [blame] | 8302 | #ifdef FEATURE_WLAN_TDLS |
| 8303 | mutex_lock(&pHddCtx->tdls_lock); |
| 8304 | #endif |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 8305 | /* DeInit the adapter. This ensures datapath cleanup as well */ |
c_hpothu | 002231a | 2015-02-05 14:58:51 +0530 | [diff] [blame] | 8306 | hdd_deinit_adapter(pHddCtx, pAdapter, TRUE); |
Mahesh A Saptasagar | 02e36e8 | 2015-01-14 20:39:19 +0530 | [diff] [blame] | 8307 | #ifdef FEATURE_WLAN_TDLS |
| 8308 | mutex_unlock(&pHddCtx->tdls_lock); |
| 8309 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8310 | /* SoftAP ifaces should never go in power save mode |
| 8311 | making sure same here. */ |
| 8312 | if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8313 | || (WLAN_HDD_P2P_GO == pAdapter->device_mode ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8314 | ) |
| 8315 | { |
| 8316 | /* SoftAP mode, so return from here */ |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8317 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8318 | "%s: In SAP MODE", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8319 | EXIT(); |
| 8320 | return 0; |
| 8321 | } |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 8322 | /* Find if any iface is up. If any iface is up then can't put device to |
| 8323 | * sleep/power save mode |
| 8324 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8325 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 8326 | while ( (NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status) ) |
| 8327 | { |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 8328 | if (test_bit(DEVICE_IFACE_OPENED, &pAdapterNode->pAdapter->event_flags)) |
| 8329 | { |
| 8330 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Still other ifaces are up cannot " |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 8331 | "put device to sleep", __func__); |
Jeff Johnson | 6a81ca4 | 2013-04-05 10:37:08 -0700 | [diff] [blame] | 8332 | enter_standby = FALSE; |
| 8333 | break; |
| 8334 | } |
| 8335 | else |
| 8336 | { |
| 8337 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 8338 | pAdapterNode = pNext; |
| 8339 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8340 | } |
| 8341 | |
| 8342 | if (TRUE == enter_standby) |
| 8343 | { |
| 8344 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: All Interfaces are Down " |
| 8345 | "entering standby", __func__); |
| 8346 | if (VOS_STATUS_SUCCESS != wlan_hdd_enter_lowpower(pHddCtx)) |
| 8347 | { |
| 8348 | /*log and return success*/ |
| 8349 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Failed to put " |
| 8350 | "wlan in power save", __func__); |
| 8351 | } |
| 8352 | } |
Hanumanth Reddy Pothula | 972e1df | 2018-06-14 13:33:47 +0530 | [diff] [blame] | 8353 | |
Arun Kumar Khandavalli | 9113aee | 2020-02-26 10:54:02 +0530 | [diff] [blame^] | 8354 | pAdapter->dev->wireless_handlers = NULL; |
| 8355 | |
Hanumanth Reddy Pothula | 972e1df | 2018-06-14 13:33:47 +0530 | [diff] [blame] | 8356 | /* |
| 8357 | * Upon wifi turn off, DUT has to flush the scan results so if |
| 8358 | * this is the last cli iface, flush the scan database. |
| 8359 | */ |
| 8360 | if (!hdd_is_cli_iface_up(pHddCtx)) |
| 8361 | sme_ScanFlushResult(pHddCtx->hHal, 0); |
Arun Kumar Khandavalli | 9113aee | 2020-02-26 10:54:02 +0530 | [diff] [blame^] | 8362 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8363 | EXIT(); |
| 8364 | return 0; |
| 8365 | } |
| 8366 | |
| 8367 | /**--------------------------------------------------------------------------- |
| 8368 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 8369 | \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] | 8370 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 8371 | This is called in response to ifconfig down |
| 8372 | |
| 8373 | \param - dev Pointer to net_device structure |
| 8374 | |
| 8375 | \return - 0 for success non-zero for failure |
| 8376 | -----------------------------------------------------------------------------*/ |
| 8377 | int hdd_stop (struct net_device *dev) |
| 8378 | { |
| 8379 | int ret; |
| 8380 | |
| 8381 | vos_ssr_protect(__func__); |
| 8382 | ret = __hdd_stop(dev); |
| 8383 | vos_ssr_unprotect(__func__); |
| 8384 | |
| 8385 | return ret; |
| 8386 | } |
| 8387 | |
| 8388 | /**--------------------------------------------------------------------------- |
| 8389 | |
| 8390 | \brief __hdd_uninit() - HDD uninit function |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8391 | |
| 8392 | \param - dev Pointer to net_device structure |
| 8393 | |
| 8394 | \return - void |
| 8395 | |
| 8396 | --------------------------------------------------------------------------*/ |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 8397 | static void __hdd_uninit (struct net_device *dev) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8398 | { |
| 8399 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Mahesh A Saptasagar | 02e36e8 | 2015-01-14 20:39:19 +0530 | [diff] [blame] | 8400 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8401 | ENTER(); |
| 8402 | |
| 8403 | do |
| 8404 | { |
| 8405 | if (NULL == pAdapter) |
| 8406 | { |
| 8407 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 8408 | "%s: NULL pAdapter", __func__); |
| 8409 | break; |
| 8410 | } |
| 8411 | |
| 8412 | if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) |
| 8413 | { |
| 8414 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 8415 | "%s: Invalid magic", __func__); |
| 8416 | break; |
| 8417 | } |
Mahesh A Saptasagar | 02e36e8 | 2015-01-14 20:39:19 +0530 | [diff] [blame] | 8418 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 8419 | if (NULL == pHddCtx) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8420 | { |
| 8421 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 8422 | "%s: NULL pHddCtx", __func__); |
| 8423 | break; |
| 8424 | } |
| 8425 | |
| 8426 | if (dev != pAdapter->dev) |
| 8427 | { |
| 8428 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 8429 | "%s: Invalid device reference", __func__); |
| 8430 | /* we haven't validated all cases so let this go for now */ |
| 8431 | } |
Mahesh A Saptasagar | 02e36e8 | 2015-01-14 20:39:19 +0530 | [diff] [blame] | 8432 | #ifdef FEATURE_WLAN_TDLS |
| 8433 | mutex_lock(&pHddCtx->tdls_lock); |
| 8434 | #endif |
c_hpothu | 002231a | 2015-02-05 14:58:51 +0530 | [diff] [blame] | 8435 | hdd_deinit_adapter(pHddCtx, pAdapter, TRUE); |
Mahesh A Saptasagar | 02e36e8 | 2015-01-14 20:39:19 +0530 | [diff] [blame] | 8436 | #ifdef FEATURE_WLAN_TDLS |
| 8437 | mutex_unlock(&pHddCtx->tdls_lock); |
| 8438 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8439 | |
| 8440 | /* after uninit our adapter structure will no longer be valid */ |
| 8441 | pAdapter->dev = NULL; |
| 8442 | pAdapter->magic = 0; |
Manjeet Singh | 47ee847 | 2016-04-11 11:57:18 +0530 | [diff] [blame] | 8443 | pAdapter->pHddCtx = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8444 | } while (0); |
| 8445 | |
| 8446 | EXIT(); |
| 8447 | } |
| 8448 | |
| 8449 | /**--------------------------------------------------------------------------- |
| 8450 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 8451 | \brief hdd_uninit() - Wrapper function to protect __hdd_uninit from SSR |
| 8452 | |
| 8453 | This is called during the netdev unregister to uninitialize all data |
| 8454 | associated with the device |
| 8455 | |
| 8456 | \param - dev Pointer to net_device structure |
| 8457 | |
| 8458 | \return - void |
| 8459 | |
| 8460 | --------------------------------------------------------------------------*/ |
| 8461 | static void hdd_uninit (struct net_device *dev) |
| 8462 | { |
| 8463 | vos_ssr_protect(__func__); |
| 8464 | __hdd_uninit(dev); |
| 8465 | vos_ssr_unprotect(__func__); |
| 8466 | } |
| 8467 | |
| 8468 | /**--------------------------------------------------------------------------- |
| 8469 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8470 | \brief hdd_release_firmware() - |
| 8471 | |
| 8472 | This function calls the release firmware API to free the firmware buffer. |
| 8473 | |
| 8474 | \param - pFileName Pointer to the File Name. |
| 8475 | pCtx - Pointer to the adapter . |
| 8476 | |
| 8477 | |
| 8478 | \return - 0 for success, non zero for failure |
| 8479 | |
| 8480 | --------------------------------------------------------------------------*/ |
| 8481 | |
| 8482 | VOS_STATUS hdd_release_firmware(char *pFileName,v_VOID_t *pCtx) |
| 8483 | { |
| 8484 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 8485 | hdd_context_t *pHddCtx = (hdd_context_t*)pCtx; |
| 8486 | ENTER(); |
| 8487 | |
| 8488 | |
| 8489 | if (!strcmp(WLAN_FW_FILE, pFileName)) { |
| 8490 | |
| 8491 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"%s: Loaded firmware file is %s",__func__,pFileName); |
| 8492 | |
| 8493 | if(pHddCtx->fw) { |
| 8494 | release_firmware(pHddCtx->fw); |
| 8495 | pHddCtx->fw = NULL; |
| 8496 | } |
| 8497 | else |
| 8498 | status = VOS_STATUS_E_FAILURE; |
| 8499 | } |
| 8500 | else if (!strcmp(WLAN_NV_FILE,pFileName)) { |
| 8501 | if(pHddCtx->nv) { |
| 8502 | release_firmware(pHddCtx->nv); |
| 8503 | pHddCtx->nv = NULL; |
| 8504 | } |
| 8505 | else |
| 8506 | status = VOS_STATUS_E_FAILURE; |
| 8507 | |
| 8508 | } |
| 8509 | |
| 8510 | EXIT(); |
| 8511 | return status; |
| 8512 | } |
| 8513 | |
| 8514 | /**--------------------------------------------------------------------------- |
| 8515 | |
| 8516 | \brief hdd_request_firmware() - |
| 8517 | |
| 8518 | This function reads the firmware file using the request firmware |
| 8519 | API and returns the the firmware data and the firmware file size. |
| 8520 | |
| 8521 | \param - pfileName - Pointer to the file name. |
| 8522 | - pCtx - Pointer to the adapter . |
| 8523 | - ppfw_data - Pointer to the pointer of the firmware data. |
| 8524 | - pSize - Pointer to the file size. |
| 8525 | |
| 8526 | \return - VOS_STATUS_SUCCESS for success, VOS_STATUS_E_FAILURE for failure |
| 8527 | |
| 8528 | --------------------------------------------------------------------------*/ |
| 8529 | |
| 8530 | |
| 8531 | VOS_STATUS hdd_request_firmware(char *pfileName,v_VOID_t *pCtx,v_VOID_t **ppfw_data, v_SIZE_t *pSize) |
| 8532 | { |
| 8533 | int status; |
| 8534 | VOS_STATUS retval = VOS_STATUS_SUCCESS; |
| 8535 | hdd_context_t *pHddCtx = (hdd_context_t*)pCtx; |
| 8536 | ENTER(); |
| 8537 | |
| 8538 | if( (!strcmp(WLAN_FW_FILE, pfileName)) ) { |
| 8539 | |
| 8540 | status = request_firmware(&pHddCtx->fw, pfileName, pHddCtx->parent_dev); |
| 8541 | |
| 8542 | if(status || !pHddCtx->fw || !pHddCtx->fw->data) { |
| 8543 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Firmware %s download failed", |
| 8544 | __func__, pfileName); |
| 8545 | retval = VOS_STATUS_E_FAILURE; |
| 8546 | } |
| 8547 | |
| 8548 | else { |
| 8549 | *ppfw_data = (v_VOID_t *)pHddCtx->fw->data; |
| 8550 | *pSize = pHddCtx->fw->size; |
| 8551 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Firmware size = %d", |
| 8552 | __func__, *pSize); |
| 8553 | } |
| 8554 | } |
| 8555 | else if(!strcmp(WLAN_NV_FILE, pfileName)) { |
| 8556 | |
| 8557 | status = request_firmware(&pHddCtx->nv, pfileName, pHddCtx->parent_dev); |
| 8558 | |
| 8559 | if(status || !pHddCtx->nv || !pHddCtx->nv->data) { |
| 8560 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: nv %s download failed", |
| 8561 | __func__, pfileName); |
| 8562 | retval = VOS_STATUS_E_FAILURE; |
| 8563 | } |
| 8564 | |
| 8565 | else { |
| 8566 | *ppfw_data = (v_VOID_t *)pHddCtx->nv->data; |
| 8567 | *pSize = pHddCtx->nv->size; |
| 8568 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: nv file size = %d", |
| 8569 | __func__, *pSize); |
| 8570 | } |
| 8571 | } |
| 8572 | |
| 8573 | EXIT(); |
| 8574 | return retval; |
| 8575 | } |
| 8576 | /**--------------------------------------------------------------------------- |
| 8577 | \brief hdd_full_pwr_cbk() - HDD full power callbackfunction |
| 8578 | |
| 8579 | This is the function invoked by SME to inform the result of a full power |
| 8580 | request issued by HDD |
| 8581 | |
| 8582 | \param - callbackcontext - Pointer to cookie |
| 8583 | status - result of request |
| 8584 | |
| 8585 | \return - None |
| 8586 | |
| 8587 | --------------------------------------------------------------------------*/ |
| 8588 | void hdd_full_pwr_cbk(void *callbackContext, eHalStatus status) |
| 8589 | { |
| 8590 | hdd_context_t *pHddCtx = (hdd_context_t*)callbackContext; |
| 8591 | |
Madan Mohan Koyyalamudi | 8bdd311 | 2012-09-24 13:55:14 -0700 | [diff] [blame] | 8592 | 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] | 8593 | if(&pHddCtx->full_pwr_comp_var) |
| 8594 | { |
| 8595 | complete(&pHddCtx->full_pwr_comp_var); |
| 8596 | } |
| 8597 | } |
| 8598 | |
Abhishek Singh | 00b7197 | 2016-01-07 10:51:04 +0530 | [diff] [blame] | 8599 | #ifdef WLAN_FEATURE_RMC |
| 8600 | static void hdd_tx_fail_ind_callback(v_U8_t *MacAddr, v_U8_t seqNo) |
| 8601 | { |
| 8602 | int payload_len; |
| 8603 | struct sk_buff *skb; |
| 8604 | struct nlmsghdr *nlh; |
| 8605 | v_U8_t *data; |
| 8606 | |
| 8607 | payload_len = ETH_ALEN; |
| 8608 | |
| 8609 | if (0 == cesium_pid) |
| 8610 | { |
| 8611 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: cesium process not registered", |
| 8612 | __func__); |
| 8613 | return; |
| 8614 | } |
| 8615 | |
| 8616 | if ((skb = nlmsg_new(payload_len,GFP_ATOMIC)) == NULL) |
| 8617 | { |
| 8618 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8619 | "%s: nlmsg_new() failed for msg size[%d]", |
| 8620 | __func__, NLMSG_SPACE(payload_len)); |
| 8621 | return; |
| 8622 | } |
| 8623 | |
| 8624 | nlh = nlmsg_put(skb, cesium_pid, seqNo, 0, payload_len, NLM_F_REQUEST); |
| 8625 | |
| 8626 | if (NULL == nlh) |
| 8627 | { |
| 8628 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8629 | "%s: nlmsg_put() failed for msg size[%d]", |
| 8630 | __func__, NLMSG_SPACE(payload_len)); |
| 8631 | |
| 8632 | kfree_skb(skb); |
| 8633 | return; |
| 8634 | } |
| 8635 | |
| 8636 | data = nlmsg_data(nlh); |
| 8637 | memcpy(data, MacAddr, ETH_ALEN); |
| 8638 | |
| 8639 | if (nlmsg_unicast(cesium_nl_srv_sock, skb, cesium_pid) < 0) |
| 8640 | { |
| 8641 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: nlmsg_unicast() failed for msg size[%d]", |
| 8642 | __func__, NLMSG_SPACE(payload_len)); |
| 8643 | } |
| 8644 | |
| 8645 | return; |
| 8646 | } |
| 8647 | |
| 8648 | /**--------------------------------------------------------------------------- |
| 8649 | \brief hdd_ParseuserParams - return a pointer to the next argument |
| 8650 | |
| 8651 | \return - status |
| 8652 | |
| 8653 | --------------------------------------------------------------------------*/ |
| 8654 | static int hdd_ParseUserParams(tANI_U8 *pValue, tANI_U8 **ppArg) |
| 8655 | { |
| 8656 | tANI_U8 *pVal; |
| 8657 | |
| 8658 | pVal = strchr(pValue, ' '); |
| 8659 | |
| 8660 | if (NULL == pVal) |
| 8661 | { |
| 8662 | /* no argument remains */ |
| 8663 | return -EINVAL; |
| 8664 | } |
| 8665 | else if (SPACE_ASCII_VALUE != *pVal) |
| 8666 | { |
| 8667 | /* no space after the current argument */ |
| 8668 | return -EINVAL; |
| 8669 | } |
| 8670 | |
| 8671 | pVal++; |
| 8672 | |
| 8673 | /* remove empty spaces */ |
| 8674 | while ((SPACE_ASCII_VALUE == *pVal) && ('\0' != *pVal)) |
| 8675 | { |
| 8676 | pVal++; |
| 8677 | } |
| 8678 | |
| 8679 | /* no argument followed by spaces */ |
| 8680 | if ('\0' == *pVal) |
| 8681 | { |
| 8682 | return -EINVAL; |
| 8683 | } |
| 8684 | |
| 8685 | *ppArg = pVal; |
| 8686 | |
| 8687 | return 0; |
| 8688 | } |
| 8689 | |
| 8690 | /**---------------------------------------------------------------------------- |
| 8691 | \brief hdd_ParseIBSSTXFailEventParams - Parse params for SETIBSSTXFAILEVENT |
| 8692 | |
| 8693 | \return - status |
| 8694 | |
| 8695 | ------------------------------------------------------------------------------*/ |
| 8696 | static int hdd_ParseIBSSTXFailEventParams(tANI_U8 *pValue, |
| 8697 | tANI_U8 *tx_fail_count, |
| 8698 | tANI_U16 *pid) |
| 8699 | { |
| 8700 | tANI_U8 *param = NULL; |
| 8701 | int ret; |
| 8702 | |
| 8703 | ret = hdd_ParseUserParams(pValue, ¶m); |
| 8704 | |
| 8705 | if (0 == ret && NULL != param) |
| 8706 | { |
| 8707 | if (1 != sscanf(param, "%hhu", tx_fail_count)) |
| 8708 | { |
| 8709 | ret = -EINVAL; |
| 8710 | goto done; |
| 8711 | } |
| 8712 | } |
| 8713 | else |
| 8714 | { |
| 8715 | goto done; |
| 8716 | } |
| 8717 | |
| 8718 | if (0 == *tx_fail_count) |
| 8719 | { |
| 8720 | *pid = 0; |
| 8721 | goto done; |
| 8722 | } |
| 8723 | |
| 8724 | pValue = param; |
| 8725 | pValue++; |
| 8726 | |
| 8727 | ret = hdd_ParseUserParams(pValue, ¶m); |
| 8728 | |
| 8729 | if (0 == ret) |
| 8730 | { |
| 8731 | if (1 != sscanf(param, "%hu", pid)) |
| 8732 | { |
| 8733 | ret = -EINVAL; |
| 8734 | goto done; |
| 8735 | } |
| 8736 | } |
| 8737 | else |
| 8738 | { |
| 8739 | goto done; |
| 8740 | } |
| 8741 | |
| 8742 | done: |
| 8743 | return ret; |
| 8744 | } |
| 8745 | |
| 8746 | static int hdd_open_cesium_nl_sock() |
| 8747 | { |
| 8748 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 8749 | struct netlink_kernel_cfg cfg = { |
| 8750 | .groups = WLAN_NLINK_MCAST_GRP_ID, |
| 8751 | .input = NULL |
| 8752 | }; |
| 8753 | #endif |
| 8754 | int ret = 0; |
| 8755 | |
| 8756 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 8757 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 8758 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)) |
| 8759 | THIS_MODULE, |
| 8760 | #endif |
| 8761 | &cfg); |
| 8762 | #else |
| 8763 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 8764 | WLAN_NLINK_MCAST_GRP_ID, NULL, NULL, THIS_MODULE); |
| 8765 | #endif |
| 8766 | |
| 8767 | if (cesium_nl_srv_sock == NULL) |
| 8768 | { |
| 8769 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8770 | "NLINK: cesium netlink_kernel_create failed"); |
| 8771 | ret = -ECONNREFUSED; |
| 8772 | } |
| 8773 | |
| 8774 | return ret; |
| 8775 | } |
| 8776 | |
| 8777 | static void hdd_close_cesium_nl_sock() |
| 8778 | { |
| 8779 | if (NULL != cesium_nl_srv_sock) |
| 8780 | { |
| 8781 | netlink_kernel_release(cesium_nl_srv_sock); |
| 8782 | cesium_nl_srv_sock = NULL; |
| 8783 | } |
| 8784 | } |
| 8785 | #endif /* WLAN_FEATURE_RMC */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8786 | /**--------------------------------------------------------------------------- |
| 8787 | |
| 8788 | \brief hdd_req_bmps_cbk() - HDD Request BMPS callback function |
| 8789 | |
| 8790 | This is the function invoked by SME to inform the result of BMPS |
| 8791 | request issued by HDD |
| 8792 | |
| 8793 | \param - callbackcontext - Pointer to cookie |
| 8794 | status - result of request |
| 8795 | |
| 8796 | \return - None |
| 8797 | |
| 8798 | --------------------------------------------------------------------------*/ |
| 8799 | void hdd_req_bmps_cbk(void *callbackContext, eHalStatus status) |
| 8800 | { |
| 8801 | |
| 8802 | struct completion *completion_var = (struct completion*) callbackContext; |
| 8803 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 8804 | hddLog(VOS_TRACE_LEVEL_ERROR, "HDD BMPS request Callback, status = %d", status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8805 | if(completion_var != NULL) |
| 8806 | { |
| 8807 | complete(completion_var); |
| 8808 | } |
| 8809 | } |
| 8810 | |
| 8811 | /**--------------------------------------------------------------------------- |
| 8812 | |
| 8813 | \brief hdd_get_cfg_file_size() - |
| 8814 | |
| 8815 | This function reads the configuration file using the request firmware |
| 8816 | API and returns the configuration file size. |
| 8817 | |
| 8818 | \param - pCtx - Pointer to the adapter . |
| 8819 | - pFileName - Pointer to the file name. |
| 8820 | - pBufSize - Pointer to the buffer size. |
| 8821 | |
| 8822 | \return - 0 for success, non zero for failure |
| 8823 | |
| 8824 | --------------------------------------------------------------------------*/ |
| 8825 | |
| 8826 | VOS_STATUS hdd_get_cfg_file_size(v_VOID_t *pCtx, char *pFileName, v_SIZE_t *pBufSize) |
| 8827 | { |
| 8828 | int status; |
| 8829 | hdd_context_t *pHddCtx = (hdd_context_t*)pCtx; |
| 8830 | |
| 8831 | ENTER(); |
| 8832 | |
| 8833 | status = request_firmware(&pHddCtx->fw, pFileName, pHddCtx->parent_dev); |
| 8834 | |
| 8835 | if(status || !pHddCtx->fw || !pHddCtx->fw->data) { |
| 8836 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: CFG download failed",__func__); |
| 8837 | status = VOS_STATUS_E_FAILURE; |
| 8838 | } |
| 8839 | else { |
| 8840 | *pBufSize = pHddCtx->fw->size; |
| 8841 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: CFG size = %d", __func__, *pBufSize); |
| 8842 | release_firmware(pHddCtx->fw); |
| 8843 | pHddCtx->fw = NULL; |
| 8844 | } |
| 8845 | |
| 8846 | EXIT(); |
| 8847 | return VOS_STATUS_SUCCESS; |
| 8848 | } |
| 8849 | |
| 8850 | /**--------------------------------------------------------------------------- |
| 8851 | |
| 8852 | \brief hdd_read_cfg_file() - |
| 8853 | |
| 8854 | This function reads the configuration file using the request firmware |
| 8855 | API and returns the cfg data and the buffer size of the configuration file. |
| 8856 | |
| 8857 | \param - pCtx - Pointer to the adapter . |
| 8858 | - pFileName - Pointer to the file name. |
| 8859 | - pBuffer - Pointer to the data buffer. |
| 8860 | - pBufSize - Pointer to the buffer size. |
| 8861 | |
| 8862 | \return - 0 for success, non zero for failure |
| 8863 | |
| 8864 | --------------------------------------------------------------------------*/ |
| 8865 | |
| 8866 | VOS_STATUS hdd_read_cfg_file(v_VOID_t *pCtx, char *pFileName, |
| 8867 | v_VOID_t *pBuffer, v_SIZE_t *pBufSize) |
| 8868 | { |
| 8869 | int status; |
| 8870 | hdd_context_t *pHddCtx = (hdd_context_t*)pCtx; |
| 8871 | |
| 8872 | ENTER(); |
| 8873 | |
| 8874 | status = request_firmware(&pHddCtx->fw, pFileName, pHddCtx->parent_dev); |
| 8875 | |
| 8876 | if(status || !pHddCtx->fw || !pHddCtx->fw->data) { |
| 8877 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: CFG download failed",__func__); |
| 8878 | return VOS_STATUS_E_FAILURE; |
| 8879 | } |
| 8880 | else { |
| 8881 | if(*pBufSize != pHddCtx->fw->size) { |
| 8882 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Caller sets invalid CFG " |
| 8883 | "file size", __func__); |
| 8884 | release_firmware(pHddCtx->fw); |
| 8885 | pHddCtx->fw = NULL; |
| 8886 | return VOS_STATUS_E_FAILURE; |
| 8887 | } |
| 8888 | else { |
| 8889 | if(pBuffer) { |
| 8890 | vos_mem_copy(pBuffer,pHddCtx->fw->data,*pBufSize); |
| 8891 | } |
| 8892 | release_firmware(pHddCtx->fw); |
| 8893 | pHddCtx->fw = NULL; |
| 8894 | } |
| 8895 | } |
| 8896 | |
| 8897 | EXIT(); |
| 8898 | |
| 8899 | return VOS_STATUS_SUCCESS; |
| 8900 | } |
| 8901 | |
| 8902 | /**--------------------------------------------------------------------------- |
| 8903 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 8904 | \brief __hdd_set_mac_address() - |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8905 | |
| 8906 | This function sets the user specified mac address using |
| 8907 | the command ifconfig wlanX hw ether <mac adress>. |
| 8908 | |
| 8909 | \param - dev - Pointer to the net device. |
| 8910 | - addr - Pointer to the sockaddr. |
| 8911 | \return - 0 for success, non zero for failure |
| 8912 | |
| 8913 | --------------------------------------------------------------------------*/ |
| 8914 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 8915 | static int __hdd_set_mac_address(struct net_device *dev, void *addr) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8916 | { |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 8917 | hdd_adapter_t *pAdapter; |
Arun Kumar Khandavalli | 18303eb | 2020-01-22 20:44:09 +0530 | [diff] [blame] | 8918 | hdd_adapter_t *adapter_temp; |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 8919 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8920 | struct sockaddr *psta_mac_addr = addr; |
Arun Kumar Khandavalli | 18303eb | 2020-01-22 20:44:09 +0530 | [diff] [blame] | 8921 | int ret = 0, i; |
| 8922 | v_MACADDR_t mac_addr; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8923 | |
| 8924 | ENTER(); |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 8925 | pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 8926 | if (NULL == pAdapter) |
| 8927 | { |
| 8928 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8929 | "%s: Adapter is NULL",__func__); |
| 8930 | return -EINVAL; |
| 8931 | } |
| 8932 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 8933 | ret = wlan_hdd_validate_context(pHddCtx); |
| 8934 | if (0 != ret) |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 8935 | return ret; |
Arun Kumar Khandavalli | 18303eb | 2020-01-22 20:44:09 +0530 | [diff] [blame] | 8936 | |
| 8937 | memcpy(&mac_addr, psta_mac_addr->sa_data, sizeof(mac_addr)); |
| 8938 | if(vos_is_macaddr_zero(&mac_addr)) { |
| 8939 | hddLog(VOS_TRACE_LEVEL_ERROR, "Zero Mac address"); |
| 8940 | return -EINVAL; |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 8941 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8942 | |
Arun Kumar Khandavalli | 18303eb | 2020-01-22 20:44:09 +0530 | [diff] [blame] | 8943 | if (vos_is_macaddr_broadcast(&mac_addr)) { |
| 8944 | hddLog(VOS_TRACE_LEVEL_ERROR,"MAC is Broadcast"); |
| 8945 | return -EINVAL; |
| 8946 | } |
| 8947 | |
| 8948 | if (vos_is_macaddr_multicast(&mac_addr)) { |
| 8949 | hddLog(VOS_TRACE_LEVEL_ERROR, "Multicast Mac address"); |
| 8950 | return -EINVAL; |
| 8951 | } |
| 8952 | adapter_temp = hdd_get_adapter_by_macaddr(pHddCtx, mac_addr.bytes); |
| 8953 | if (adapter_temp) { |
| 8954 | if (!strcmp(adapter_temp->dev->name, dev->name)) |
| 8955 | return 0; |
| 8956 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8957 | "%s: WLAN Mac Addr: " |
| 8958 | MAC_ADDRESS_STR, __func__, |
| 8959 | MAC_ADDR_ARRAY(mac_addr.bytes)); |
| 8960 | return -EINVAL; |
| 8961 | } |
| 8962 | |
| 8963 | for (i = 0; i < VOS_MAX_CONCURRENCY_PERSONA; i++) { |
| 8964 | if (!vos_mem_compare(&pAdapter->macAddressCurrent.bytes, |
| 8965 | &pHddCtx->cfg_ini->intfMacAddr[i].bytes[0], VOS_MAC_ADDR_SIZE)) { |
| 8966 | memcpy(&pHddCtx->cfg_ini->intfMacAddr[i].bytes[0], mac_addr.bytes, |
| 8967 | VOS_MAC_ADDR_SIZE); |
| 8968 | break; |
| 8969 | } |
| 8970 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8971 | memcpy(&pAdapter->macAddressCurrent, psta_mac_addr->sa_data, ETH_ALEN); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8972 | memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN); |
| 8973 | |
| 8974 | EXIT(); |
Arun Kumar Khandavalli | 18303eb | 2020-01-22 20:44:09 +0530 | [diff] [blame] | 8975 | return 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8976 | } |
| 8977 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 8978 | /**--------------------------------------------------------------------------- |
| 8979 | |
| 8980 | \brief hdd_set_mac_address() - |
| 8981 | |
| 8982 | Wrapper function to protect __hdd_set_mac_address() function from ssr |
| 8983 | |
| 8984 | \param - dev - Pointer to the net device. |
| 8985 | - addr - Pointer to the sockaddr. |
| 8986 | \return - 0 for success, non zero for failure |
| 8987 | |
| 8988 | --------------------------------------------------------------------------*/ |
| 8989 | static int hdd_set_mac_address(struct net_device *dev, void *addr) |
| 8990 | { |
| 8991 | int ret; |
| 8992 | |
| 8993 | vos_ssr_protect(__func__); |
| 8994 | ret = __hdd_set_mac_address(dev, addr); |
| 8995 | vos_ssr_unprotect(__func__); |
| 8996 | |
| 8997 | return ret; |
| 8998 | } |
| 8999 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9000 | tANI_U8* wlan_hdd_get_intf_addr(hdd_context_t* pHddCtx) |
| 9001 | { |
| 9002 | int i; |
| 9003 | for ( i = 0; i < VOS_MAX_CONCURRENCY_PERSONA; i++) |
| 9004 | { |
Abhishek Singh | eb18378 | 2014-02-06 13:37:21 +0530 | [diff] [blame] | 9005 | if( 0 == ((pHddCtx->cfg_ini->intfAddrMask) & (1 << i)) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9006 | break; |
| 9007 | } |
| 9008 | |
| 9009 | if( VOS_MAX_CONCURRENCY_PERSONA == i) |
| 9010 | return NULL; |
| 9011 | |
| 9012 | pHddCtx->cfg_ini->intfAddrMask |= (1 << i); |
| 9013 | return &pHddCtx->cfg_ini->intfMacAddr[i].bytes[0]; |
| 9014 | } |
| 9015 | |
| 9016 | void wlan_hdd_release_intf_addr(hdd_context_t* pHddCtx, tANI_U8* releaseAddr) |
| 9017 | { |
| 9018 | int i; |
| 9019 | for ( i = 0; i < VOS_MAX_CONCURRENCY_PERSONA; i++) |
| 9020 | { |
| 9021 | if ( !memcmp(releaseAddr, &pHddCtx->cfg_ini->intfMacAddr[i].bytes[0], 6) ) |
| 9022 | { |
| 9023 | pHddCtx->cfg_ini->intfAddrMask &= ~(1 << i); |
| 9024 | break; |
| 9025 | } |
| 9026 | } |
| 9027 | return; |
| 9028 | } |
| 9029 | |
| 9030 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)) |
| 9031 | static struct net_device_ops wlan_drv_ops = { |
| 9032 | .ndo_open = hdd_open, |
| 9033 | .ndo_stop = hdd_stop, |
| 9034 | .ndo_uninit = hdd_uninit, |
| 9035 | .ndo_start_xmit = hdd_hard_start_xmit, |
| 9036 | .ndo_tx_timeout = hdd_tx_timeout, |
| 9037 | .ndo_get_stats = hdd_stats, |
| 9038 | .ndo_do_ioctl = hdd_ioctl, |
| 9039 | .ndo_set_mac_address = hdd_set_mac_address, |
| 9040 | .ndo_select_queue = hdd_select_queue, |
| 9041 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 9042 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(3,1,0)) |
| 9043 | .ndo_set_rx_mode = hdd_set_multicast_list, |
| 9044 | #else |
| 9045 | .ndo_set_multicast_list = hdd_set_multicast_list, |
| 9046 | #endif //LINUX_VERSION_CODE |
| 9047 | #endif |
| 9048 | }; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9049 | static struct net_device_ops wlan_mon_drv_ops = { |
| 9050 | .ndo_open = hdd_mon_open, |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 9051 | .ndo_stop = hdd_mon_stop, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9052 | .ndo_uninit = hdd_uninit, |
| 9053 | .ndo_start_xmit = hdd_mon_hard_start_xmit, |
| 9054 | .ndo_tx_timeout = hdd_tx_timeout, |
| 9055 | .ndo_get_stats = hdd_stats, |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 9056 | .ndo_do_ioctl = hdd_mon_ioctl, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9057 | .ndo_set_mac_address = hdd_set_mac_address, |
| 9058 | }; |
Mahesh A Saptasagar | 305e263 | 2015-03-04 12:57:33 +0530 | [diff] [blame] | 9059 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9060 | #endif |
| 9061 | |
| 9062 | void hdd_set_station_ops( struct net_device *pWlanDev ) |
| 9063 | { |
| 9064 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9065 | pWlanDev->netdev_ops = &wlan_drv_ops; |
| 9066 | #else |
| 9067 | pWlanDev->open = hdd_open; |
| 9068 | pWlanDev->stop = hdd_stop; |
| 9069 | pWlanDev->uninit = hdd_uninit; |
| 9070 | pWlanDev->hard_start_xmit = NULL; |
| 9071 | pWlanDev->tx_timeout = hdd_tx_timeout; |
| 9072 | pWlanDev->get_stats = hdd_stats; |
| 9073 | pWlanDev->do_ioctl = hdd_ioctl; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9074 | pWlanDev->set_mac_address = hdd_set_mac_address; |
| 9075 | #endif |
| 9076 | } |
| 9077 | |
Katya Nigam | 1fd2440 | 2015-02-16 14:52:19 +0530 | [diff] [blame] | 9078 | void hdd_set_ibss_ops( hdd_adapter_t *pAdapter ) |
| 9079 | { |
| 9080 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)) |
| 9081 | wlan_drv_ops.ndo_start_xmit = hdd_ibss_hard_start_xmit; |
| 9082 | #else |
| 9083 | pAdapter->dev->hard_start_xmit = hdd_ibss_hard_start_xmit; |
| 9084 | #endif |
| 9085 | } |
| 9086 | |
Jeff Johnson | eed415b | 2013-01-18 16:11:20 -0800 | [diff] [blame] | 9087 | 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] | 9088 | { |
| 9089 | struct net_device *pWlanDev = NULL; |
| 9090 | hdd_adapter_t *pAdapter = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9091 | /* |
| 9092 | * cfg80211 initialization and registration.... |
| 9093 | */ |
Anand N Sunkad | c34abbd | 2015-07-29 09:52:59 +0530 | [diff] [blame] | 9094 | pWlanDev = alloc_netdev_mq(sizeof( hdd_adapter_t ), name, |
| 9095 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)) |
| 9096 | NET_NAME_UNKNOWN, |
| 9097 | #endif |
| 9098 | ether_setup, NUM_TX_QUEUES); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9099 | if(pWlanDev != NULL) |
| 9100 | { |
| 9101 | |
| 9102 | //Save the pointer to the net_device in the HDD adapter |
| 9103 | pAdapter = (hdd_adapter_t*) netdev_priv( pWlanDev ); |
| 9104 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9105 | vos_mem_zero( pAdapter, sizeof( hdd_adapter_t ) ); |
| 9106 | |
| 9107 | pAdapter->dev = pWlanDev; |
| 9108 | pAdapter->pHddCtx = pHddCtx; |
| 9109 | pAdapter->magic = WLAN_HDD_ADAPTER_MAGIC; |
Agarwal Ashish | 47d1811 | 2014-08-04 19:55:07 +0530 | [diff] [blame] | 9110 | spin_lock_init(&pAdapter->lock_for_active_session); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9111 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 9112 | #ifdef FEATURE_WLAN_BATCH_SCAN |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 9113 | pAdapter->pBatchScanRsp = NULL; |
| 9114 | pAdapter->numScanList = 0; |
Rajeev Kumar | 20140c1 | 2013-10-21 19:39:02 -0700 | [diff] [blame] | 9115 | pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STOPPED; |
Kiet Lam | aa8e15a | 2014-02-11 23:30:06 -0800 | [diff] [blame] | 9116 | pAdapter->prev_batch_id = 0; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 9117 | mutex_init(&pAdapter->hdd_batch_scan_lock); |
| 9118 | #endif |
| 9119 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9120 | pAdapter->isLinkUpSvcNeeded = FALSE; |
| 9121 | pAdapter->higherDtimTransition = eANI_BOOLEAN_TRUE; |
| 9122 | //Init the net_device structure |
| 9123 | strlcpy(pWlanDev->name, name, IFNAMSIZ); |
| 9124 | |
| 9125 | vos_mem_copy(pWlanDev->dev_addr, (void *)macAddr, sizeof(tSirMacAddr)); |
| 9126 | vos_mem_copy( pAdapter->macAddressCurrent.bytes, macAddr, sizeof(tSirMacAddr)); |
| 9127 | pWlanDev->watchdog_timeo = HDD_TX_TIMEOUT; |
Alok Kumar | 8445854 | 2018-05-14 15:03:08 +0530 | [diff] [blame] | 9128 | |
| 9129 | pWlanDev->needed_headroom = LIBRA_HW_NEEDED_HEADROOM; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9130 | |
| 9131 | hdd_set_station_ops( pAdapter->dev ); |
| 9132 | |
| 9133 | pWlanDev->destructor = free_netdev; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9134 | pWlanDev->ieee80211_ptr = &pAdapter->wdev ; |
| 9135 | pAdapter->wdev.wiphy = pHddCtx->wiphy; |
| 9136 | pAdapter->wdev.netdev = pWlanDev; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9137 | /* set pWlanDev's parent to underlying device */ |
| 9138 | SET_NETDEV_DEV(pWlanDev, pHddCtx->parent_dev); |
Kumar Anand | 82c009f | 2014-05-29 00:29:42 -0700 | [diff] [blame] | 9139 | |
| 9140 | hdd_wmm_init( pAdapter ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9141 | } |
| 9142 | |
| 9143 | return pAdapter; |
| 9144 | } |
| 9145 | |
| 9146 | VOS_STATUS hdd_register_interface( hdd_adapter_t *pAdapter, tANI_U8 rtnl_lock_held ) |
| 9147 | { |
| 9148 | struct net_device *pWlanDev = pAdapter->dev; |
| 9149 | //hdd_station_ctx_t *pHddStaCtx = &pAdapter->sessionCtx.station; |
| 9150 | //hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
| 9151 | //eHalStatus halStatus = eHAL_STATUS_SUCCESS; |
| 9152 | |
| 9153 | if( rtnl_lock_held ) |
| 9154 | { |
Madan Mohan Koyyalamudi | d8ac866 | 2012-11-06 19:04:56 -0800 | [diff] [blame] | 9155 | if (strnchr(pWlanDev->name, strlen(pWlanDev->name), '%')) { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9156 | if( dev_alloc_name(pWlanDev, pWlanDev->name) < 0 ) |
| 9157 | { |
| 9158 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s:Failed:dev_alloc_name",__func__); |
| 9159 | return VOS_STATUS_E_FAILURE; |
| 9160 | } |
| 9161 | } |
| 9162 | if (register_netdevice(pWlanDev)) |
| 9163 | { |
| 9164 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s:Failed:register_netdev",__func__); |
| 9165 | return VOS_STATUS_E_FAILURE; |
| 9166 | } |
| 9167 | } |
| 9168 | else |
| 9169 | { |
| 9170 | if(register_netdev(pWlanDev)) |
| 9171 | { |
| 9172 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failed:register_netdev",__func__); |
| 9173 | return VOS_STATUS_E_FAILURE; |
| 9174 | } |
| 9175 | } |
| 9176 | set_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags); |
| 9177 | |
| 9178 | return VOS_STATUS_SUCCESS; |
| 9179 | } |
| 9180 | |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 9181 | static eHalStatus hdd_smeCloseSessionCallback(void *pContext) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9182 | { |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 9183 | hdd_adapter_t *pAdapter = pContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9184 | |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 9185 | if (NULL == pAdapter) |
| 9186 | { |
| 9187 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: NULL pAdapter", __func__); |
| 9188 | return eHAL_STATUS_INVALID_PARAMETER; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9189 | } |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 9190 | |
| 9191 | if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) |
| 9192 | { |
| 9193 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Invalid magic", __func__); |
| 9194 | return eHAL_STATUS_NOT_INITIALIZED; |
| 9195 | } |
| 9196 | |
| 9197 | clear_bit(SME_SESSION_OPENED, &pAdapter->event_flags); |
| 9198 | |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 9199 | #ifndef WLAN_OPEN_SOURCE |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 9200 | /* need to make sure all of our scheduled work has completed. |
| 9201 | * This callback is called from MC thread context, so it is safe to |
| 9202 | * to call below flush workqueue API from here. |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 9203 | * |
| 9204 | * Even though this is called from MC thread context, if there is a faulty |
| 9205 | * work item in the system, that can hang this call forever. So flushing |
| 9206 | * this global work queue is not safe; and now we make sure that |
| 9207 | * individual work queues are stopped correctly. But the cancel work queue |
| 9208 | * is a GPL only API, so the proprietary version of the driver would still |
| 9209 | * rely on the global work queue flush. |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 9210 | */ |
| 9211 | flush_scheduled_work(); |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 9212 | #endif |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 9213 | |
| 9214 | /* We can be blocked while waiting for scheduled work to be |
| 9215 | * flushed, and the adapter structure can potentially be freed, in |
| 9216 | * which case the magic will have been reset. So make sure the |
| 9217 | * magic is still good, and hence the adapter structure is still |
| 9218 | * valid, before signaling completion */ |
| 9219 | if (WLAN_HDD_ADAPTER_MAGIC == pAdapter->magic) |
| 9220 | { |
| 9221 | complete(&pAdapter->session_close_comp_var); |
| 9222 | } |
| 9223 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9224 | return eHAL_STATUS_SUCCESS; |
| 9225 | } |
Manjeet Singh | 47ee847 | 2016-04-11 11:57:18 +0530 | [diff] [blame] | 9226 | /** |
| 9227 | * hdd_close_tx_queues() - close tx queues |
| 9228 | * @hdd_ctx: hdd global context |
| 9229 | * |
| 9230 | * Return: None |
| 9231 | */ |
| 9232 | static void hdd_close_tx_queues(hdd_context_t *hdd_ctx) |
| 9233 | { |
| 9234 | VOS_STATUS status; |
| 9235 | hdd_adapter_t *adapter; |
| 9236 | hdd_adapter_list_node_t *adapter_node = NULL, *next_adapter = NULL; |
| 9237 | /* Not validating hdd_ctx as it's already done by the caller */ |
| 9238 | ENTER(); |
| 9239 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
| 9240 | while (NULL != adapter_node && VOS_STATUS_SUCCESS == status) { |
| 9241 | adapter = adapter_node->pAdapter; |
| 9242 | if (adapter && adapter->dev) { |
| 9243 | netif_tx_disable (adapter->dev); |
| 9244 | netif_carrier_off(adapter->dev); |
| 9245 | } |
| 9246 | status = hdd_get_next_adapter(hdd_ctx, adapter_node, |
| 9247 | &next_adapter); |
| 9248 | adapter_node = next_adapter; |
| 9249 | } |
| 9250 | EXIT(); |
| 9251 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9252 | |
| 9253 | VOS_STATUS hdd_init_station_mode( hdd_adapter_t *pAdapter ) |
| 9254 | { |
| 9255 | struct net_device *pWlanDev = pAdapter->dev; |
| 9256 | hdd_station_ctx_t *pHddStaCtx = &pAdapter->sessionCtx.station; |
| 9257 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
| 9258 | eHalStatus halStatus = eHAL_STATUS_SUCCESS; |
| 9259 | VOS_STATUS status = VOS_STATUS_E_FAILURE; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 9260 | long rc = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9261 | |
Nirav Shah | 7e3c813 | 2015-06-22 23:51:42 +0530 | [diff] [blame] | 9262 | spin_lock_init( &pAdapter->sta_hash_lock); |
| 9263 | pAdapter->is_sta_id_hash_initialized = VOS_FALSE; |
| 9264 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9265 | INIT_COMPLETION(pAdapter->session_open_comp_var); |
Kiran Kumar Lokere | 0ad5cd3 | 2013-06-25 11:26:22 -0700 | [diff] [blame] | 9266 | sme_SetCurrDeviceMode(pHddCtx->hHal, pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9267 | //Open a SME session for future operation |
| 9268 | halStatus = sme_OpenSession( pHddCtx->hHal, hdd_smeRoamCallback, pAdapter, |
Kiran Kumar Lokere | 0ad5cd3 | 2013-06-25 11:26:22 -0700 | [diff] [blame] | 9269 | (tANI_U8 *)&pAdapter->macAddressCurrent, &pAdapter->sessionId); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9270 | if ( !HAL_STATUS_SUCCESS( halStatus ) ) |
| 9271 | { |
| 9272 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 9273 | "sme_OpenSession() failed with status code %08d [x%08x]", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9274 | halStatus, halStatus ); |
| 9275 | status = VOS_STATUS_E_FAILURE; |
| 9276 | goto error_sme_open; |
| 9277 | } |
| 9278 | |
| 9279 | //Block on a completion variable. Can't wait forever though. |
Vinay Krishna Eranna | 0fe2e7c | 2014-04-09 21:32:08 +0530 | [diff] [blame] | 9280 | rc = wait_for_completion_timeout( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9281 | &pAdapter->session_open_comp_var, |
| 9282 | msecs_to_jiffies(WLAN_WAIT_TIME_SESSIONOPENCLOSE)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 9283 | if (rc <= 0) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9284 | { |
| 9285 | hddLog(VOS_TRACE_LEVEL_FATAL, |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 9286 | "Session is not opened within timeout period code %ld", rc ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9287 | status = VOS_STATUS_E_FAILURE; |
| 9288 | goto error_sme_open; |
| 9289 | } |
| 9290 | |
| 9291 | // Register wireless extensions |
| 9292 | if( eHAL_STATUS_SUCCESS != (halStatus = hdd_register_wext(pWlanDev))) |
| 9293 | { |
| 9294 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 9295 | "hdd_register_wext() failed with status code %08d [x%08x]", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9296 | halStatus, halStatus ); |
| 9297 | status = VOS_STATUS_E_FAILURE; |
| 9298 | goto error_register_wext; |
| 9299 | } |
Katya Nigam | 1fd2440 | 2015-02-16 14:52:19 +0530 | [diff] [blame] | 9300 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9301 | //Safe to register the hard_start_xmit function again |
Katya Nigam | 1fd2440 | 2015-02-16 14:52:19 +0530 | [diff] [blame] | 9302 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)) |
| 9303 | wlan_drv_ops.ndo_start_xmit = hdd_hard_start_xmit; |
| 9304 | #else |
| 9305 | pWlanDev->hard_start_xmit = hdd_hard_start_xmit; |
| 9306 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9307 | |
| 9308 | //Set the Connection State to Not Connected |
Abhishek Singh | f4669da | 2014-05-26 15:07:49 +0530 | [diff] [blame] | 9309 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 9310 | "%s: Set HDD connState to eConnectionState_NotConnected", |
| 9311 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9312 | pHddStaCtx->conn_info.connState = eConnectionState_NotConnected; |
| 9313 | |
| 9314 | //Set the default operation channel |
| 9315 | pHddStaCtx->conn_info.operationChannel = pHddCtx->cfg_ini->OperatingChannel; |
| 9316 | |
| 9317 | /* Make the default Auth Type as OPEN*/ |
| 9318 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 9319 | |
| 9320 | if( VOS_STATUS_SUCCESS != ( status = hdd_init_tx_rx( pAdapter ) ) ) |
| 9321 | { |
| 9322 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 9323 | "hdd_init_tx_rx() failed with status code %08d [x%08x]", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9324 | status, status ); |
| 9325 | goto error_init_txrx; |
| 9326 | } |
| 9327 | |
| 9328 | set_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags); |
| 9329 | |
| 9330 | if( VOS_STATUS_SUCCESS != ( status = hdd_wmm_adapter_init( pAdapter ) ) ) |
| 9331 | { |
| 9332 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 9333 | "hdd_wmm_adapter_init() failed with status code %08d [x%08x]", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9334 | status, status ); |
| 9335 | goto error_wmm_init; |
| 9336 | } |
| 9337 | |
| 9338 | set_bit(WMM_INIT_DONE, &pAdapter->event_flags); |
| 9339 | |
| 9340 | return VOS_STATUS_SUCCESS; |
| 9341 | |
| 9342 | error_wmm_init: |
| 9343 | clear_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags); |
| 9344 | hdd_deinit_tx_rx(pAdapter); |
| 9345 | error_init_txrx: |
| 9346 | hdd_UnregisterWext(pWlanDev); |
| 9347 | error_register_wext: |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 9348 | if (test_bit(SME_SESSION_OPENED, &pAdapter->event_flags)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9349 | { |
| 9350 | INIT_COMPLETION(pAdapter->session_close_comp_var); |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 9351 | if (eHAL_STATUS_SUCCESS == sme_CloseSession(pHddCtx->hHal, |
Agrawal Ashish | 5a3522c | 2016-03-02 15:08:28 +0530 | [diff] [blame] | 9352 | pAdapter->sessionId, FALSE, VOS_TRUE, |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 9353 | hdd_smeCloseSessionCallback, pAdapter)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9354 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 9355 | unsigned long rc; |
| 9356 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9357 | //Block on a completion variable. Can't wait forever though. |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 9358 | rc = wait_for_completion_timeout( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9359 | &pAdapter->session_close_comp_var, |
Jeff Johnson | c6ab5b9 | 2013-04-15 17:02:05 -0700 | [diff] [blame] | 9360 | msecs_to_jiffies(WLAN_WAIT_TIME_SESSIONOPENCLOSE)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 9361 | if (rc <= 0) |
| 9362 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 9363 | FL("Session is not opened within timeout period code %ld"), rc); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9364 | } |
| 9365 | } |
| 9366 | error_sme_open: |
| 9367 | return status; |
| 9368 | } |
| 9369 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9370 | void hdd_cleanup_actionframe( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter ) |
| 9371 | { |
| 9372 | hdd_cfg80211_state_t *cfgState; |
| 9373 | |
| 9374 | cfgState = WLAN_HDD_GET_CFG_STATE_PTR( pAdapter ); |
| 9375 | |
| 9376 | if( NULL != cfgState->buf ) |
| 9377 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 9378 | long rc; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9379 | INIT_COMPLETION(pAdapter->tx_action_cnf_event); |
| 9380 | rc = wait_for_completion_interruptible_timeout( |
| 9381 | &pAdapter->tx_action_cnf_event, |
| 9382 | msecs_to_jiffies(ACTION_FRAME_TX_TIMEOUT)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 9383 | if (rc <= 0) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9384 | { |
Deepthi Gowri | 91b3e9c | 2015-08-25 13:14:58 +0530 | [diff] [blame] | 9385 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9386 | "%s ERROR: HDD Wait for Action Confirmation Failed!! %ld" |
| 9387 | , __func__, rc); |
| 9388 | |
| 9389 | // Inform tx status as FAILURE to upper layer and free cfgState->buf |
| 9390 | hdd_sendActionCnf( pAdapter, FALSE ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9391 | } |
| 9392 | } |
| 9393 | return; |
| 9394 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9395 | |
c_hpothu | 002231a | 2015-02-05 14:58:51 +0530 | [diff] [blame] | 9396 | 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] | 9397 | { |
| 9398 | ENTER(); |
| 9399 | switch ( pAdapter->device_mode ) |
| 9400 | { |
Katya Nigam | 1fd2440 | 2015-02-16 14:52:19 +0530 | [diff] [blame] | 9401 | case WLAN_HDD_IBSS: |
| 9402 | { |
| 9403 | if(test_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags)) |
| 9404 | { |
| 9405 | hdd_ibss_deinit_tx_rx( pAdapter ); |
| 9406 | clear_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags); |
| 9407 | } |
| 9408 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9409 | case WLAN_HDD_INFRA_STATION: |
| 9410 | case WLAN_HDD_P2P_CLIENT: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9411 | case WLAN_HDD_P2P_DEVICE: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9412 | { |
| 9413 | if(test_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags)) |
| 9414 | { |
| 9415 | hdd_deinit_tx_rx( pAdapter ); |
| 9416 | clear_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags); |
| 9417 | } |
| 9418 | |
| 9419 | if(test_bit(WMM_INIT_DONE, &pAdapter->event_flags)) |
| 9420 | { |
| 9421 | hdd_wmm_adapter_close( pAdapter ); |
| 9422 | clear_bit(WMM_INIT_DONE, &pAdapter->event_flags); |
| 9423 | } |
| 9424 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9425 | hdd_cleanup_actionframe(pHddCtx, pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9426 | break; |
| 9427 | } |
| 9428 | |
| 9429 | case WLAN_HDD_SOFTAP: |
| 9430 | case WLAN_HDD_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9431 | { |
Madan Mohan Koyyalamudi | 8c6dec8 | 2013-09-26 15:56:13 +0530 | [diff] [blame] | 9432 | |
| 9433 | if (test_bit(WMM_INIT_DONE, &pAdapter->event_flags)) |
| 9434 | { |
| 9435 | hdd_wmm_adapter_close( pAdapter ); |
| 9436 | clear_bit(WMM_INIT_DONE, &pAdapter->event_flags); |
| 9437 | } |
| 9438 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9439 | hdd_cleanup_actionframe(pHddCtx, pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9440 | |
c_hpothu | 002231a | 2015-02-05 14:58:51 +0530 | [diff] [blame] | 9441 | hdd_unregister_hostapd(pAdapter, rtnl_held); |
Agrawal Ashish | a0584d4 | 2016-09-29 13:03:45 +0530 | [diff] [blame] | 9442 | /* set con_mode to STA only when no SAP concurrency mode */ |
| 9443 | if (!(hdd_get_concurrency_mode() & (VOS_SAP | VOS_P2P_GO))) |
| 9444 | hdd_set_conparam(0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9445 | break; |
| 9446 | } |
| 9447 | |
| 9448 | case WLAN_HDD_MONITOR: |
| 9449 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9450 | if(test_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags)) |
| 9451 | { |
| 9452 | hdd_deinit_tx_rx( pAdapter ); |
| 9453 | clear_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags); |
| 9454 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9455 | break; |
| 9456 | } |
| 9457 | |
| 9458 | |
| 9459 | default: |
| 9460 | break; |
| 9461 | } |
| 9462 | |
| 9463 | EXIT(); |
| 9464 | } |
| 9465 | |
| 9466 | void hdd_cleanup_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter, tANI_U8 rtnl_held ) |
| 9467 | { |
Mingcheng Zhu | 87f22fc | 2014-01-30 19:23:32 -0800 | [diff] [blame] | 9468 | struct net_device *pWlanDev = NULL; |
Srinivas, Dasari | 693dfc5 | 2013-12-27 17:29:09 +0530 | [diff] [blame] | 9469 | |
| 9470 | ENTER(); |
| 9471 | if (NULL == pAdapter) |
| 9472 | { |
| 9473 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9474 | "%s: HDD adapter is Null", __func__); |
| 9475 | return; |
| 9476 | } |
| 9477 | |
| 9478 | pWlanDev = pAdapter->dev; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9479 | |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 9480 | #ifdef FEATURE_WLAN_BATCH_SCAN |
Srinivas, Dasari | 693dfc5 | 2013-12-27 17:29:09 +0530 | [diff] [blame] | 9481 | if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
| 9482 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 9483 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Srinivas, Dasari | 693dfc5 | 2013-12-27 17:29:09 +0530 | [diff] [blame] | 9484 | || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE) |
| 9485 | ) |
| 9486 | { |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 9487 | if (pAdapter) |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 9488 | { |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 9489 | if (eHDD_BATCH_SCAN_STATE_STARTED == pAdapter->batchScanState) |
| 9490 | { |
| 9491 | hdd_deinit_batch_scan(pAdapter); |
| 9492 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 9493 | } |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 9494 | } |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 9495 | #endif |
| 9496 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9497 | if(test_bit(NET_DEVICE_REGISTERED, &pAdapter->event_flags)) { |
| 9498 | if( rtnl_held ) |
| 9499 | { |
| 9500 | unregister_netdevice(pWlanDev); |
| 9501 | } |
| 9502 | else |
| 9503 | { |
| 9504 | unregister_netdev(pWlanDev); |
| 9505 | } |
| 9506 | // note that the pAdapter is no longer valid at this point |
| 9507 | // since the memory has been reclaimed |
| 9508 | } |
| 9509 | |
Srinivas, Dasari | 693dfc5 | 2013-12-27 17:29:09 +0530 | [diff] [blame] | 9510 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9511 | } |
| 9512 | |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 9513 | void hdd_set_pwrparams(hdd_context_t *pHddCtx) |
| 9514 | { |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 9515 | VOS_STATUS status; |
| 9516 | hdd_adapter_t *pAdapter = NULL; |
| 9517 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 9518 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 9519 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 9520 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 9521 | /*loop through all adapters.*/ |
| 9522 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 9523 | { |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 9524 | pAdapter = pAdapterNode->pAdapter; |
| 9525 | if ( (WLAN_HDD_INFRA_STATION != pAdapter->device_mode) |
| 9526 | && (WLAN_HDD_P2P_CLIENT != pAdapter->device_mode) ) |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 9527 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 9528 | { // we skip this registration for modes other than STA and P2P client modes. |
| 9529 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 9530 | pAdapterNode = pNext; |
| 9531 | continue; |
| 9532 | } |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 9533 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 9534 | //Apply Dynamic DTIM For P2P |
| 9535 | //Only if ignoreDynamicDtimInP2pMode is not set in ini |
| 9536 | if ((pHddCtx->cfg_ini->enableDynamicDTIM || |
| 9537 | pHddCtx->cfg_ini->enableModulatedDTIM) && |
| 9538 | ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
| 9539 | ((WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) && |
| 9540 | !(pHddCtx->cfg_ini->ignoreDynamicDtimInP2pMode))) && |
| 9541 | (eANI_BOOLEAN_TRUE == pAdapter->higherDtimTransition) && |
| 9542 | (eConnectionState_Associated == |
| 9543 | (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) && |
| 9544 | (pHddCtx->cfg_ini->fIsBmpsEnabled)) |
| 9545 | { |
| 9546 | tSirSetPowerParamsReq powerRequest = { 0 }; |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 9547 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 9548 | powerRequest.uIgnoreDTIM = 1; |
| 9549 | powerRequest.uMaxLIModulatedDTIM = pHddCtx->cfg_ini->fMaxLIModulatedDTIM; |
| 9550 | |
| 9551 | if (pHddCtx->cfg_ini->enableModulatedDTIM) |
| 9552 | { |
| 9553 | powerRequest.uDTIMPeriod = pHddCtx->cfg_ini->enableModulatedDTIM; |
| 9554 | powerRequest.uListenInterval = pHddCtx->hdd_actual_LI_value; |
| 9555 | } |
| 9556 | else |
| 9557 | { |
| 9558 | powerRequest.uListenInterval = pHddCtx->cfg_ini->enableDynamicDTIM; |
| 9559 | } |
| 9560 | |
| 9561 | /* Update ignoreDTIM and ListedInterval in CFG to remain at the DTIM |
| 9562 | * specified during Enter/Exit BMPS when LCD off*/ |
| 9563 | ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IGNORE_DTIM, powerRequest.uIgnoreDTIM, |
| 9564 | NULL, eANI_BOOLEAN_FALSE); |
| 9565 | ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_LISTEN_INTERVAL, powerRequest.uListenInterval, |
| 9566 | NULL, eANI_BOOLEAN_FALSE); |
| 9567 | |
| 9568 | /* switch to the DTIM specified in cfg.ini */ |
| 9569 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Abhishek Singh | 1e390cf | 2015-10-27 13:45:17 +0530 | [diff] [blame] | 9570 | "Switch to DTIM %d Listen interval %d", |
| 9571 | powerRequest.uDTIMPeriod, |
| 9572 | powerRequest.uListenInterval); |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 9573 | sme_SetPowerParams( pHddCtx->hHal, &powerRequest, TRUE); |
| 9574 | break; |
| 9575 | |
| 9576 | } |
| 9577 | |
| 9578 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 9579 | pAdapterNode = pNext; |
| 9580 | } |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 9581 | } |
| 9582 | |
| 9583 | void hdd_reset_pwrparams(hdd_context_t *pHddCtx) |
| 9584 | { |
| 9585 | /*Switch back to DTIM 1*/ |
| 9586 | tSirSetPowerParamsReq powerRequest = { 0 }; |
| 9587 | |
| 9588 | powerRequest.uIgnoreDTIM = pHddCtx->hdd_actual_ignore_DTIM_value; |
| 9589 | powerRequest.uListenInterval = pHddCtx->hdd_actual_LI_value; |
Yue Ma | c24062f | 2013-05-13 17:01:29 -0700 | [diff] [blame] | 9590 | powerRequest.uMaxLIModulatedDTIM = pHddCtx->cfg_ini->fMaxLIModulatedDTIM; |
Tushnim Bhattacharyya | 3a37def | 2013-02-24 11:11:15 -0800 | [diff] [blame] | 9591 | |
| 9592 | /* Update ignoreDTIM and ListedInterval in CFG with default values */ |
| 9593 | ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IGNORE_DTIM, powerRequest.uIgnoreDTIM, |
| 9594 | NULL, eANI_BOOLEAN_FALSE); |
| 9595 | ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_LISTEN_INTERVAL, powerRequest.uListenInterval, |
| 9596 | NULL, eANI_BOOLEAN_FALSE); |
| 9597 | |
| 9598 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 9599 | "Switch to DTIM%d",powerRequest.uListenInterval); |
| 9600 | sme_SetPowerParams( pHddCtx->hHal, &powerRequest, TRUE); |
| 9601 | |
| 9602 | } |
| 9603 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9604 | VOS_STATUS hdd_enable_bmps_imps(hdd_context_t *pHddCtx) |
| 9605 | { |
| 9606 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
Sushant Kaushik | 4928e54 | 2014-12-29 15:25:54 +0530 | [diff] [blame] | 9607 | if (WLAN_HDD_IS_UNLOAD_IN_PROGRESS(pHddCtx)) |
| 9608 | { |
| 9609 | hddLog( LOGE, FL("Wlan Unload in progress")); |
| 9610 | return VOS_STATUS_E_PERM; |
| 9611 | } |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 9612 | |
| 9613 | if (wlan_hdd_check_monitor_state(pHddCtx)) { |
| 9614 | hddLog(LOG1, FL("Monitor mode is started, cannot enable BMPS")); |
| 9615 | return VOS_STATUS_SUCCESS; |
| 9616 | } |
| 9617 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9618 | if(pHddCtx->cfg_ini->fIsBmpsEnabled) |
| 9619 | { |
| 9620 | sme_EnablePowerSave(pHddCtx->hHal, ePMC_BEACON_MODE_POWER_SAVE); |
| 9621 | } |
| 9622 | |
| 9623 | if(pHddCtx->cfg_ini->fIsAutoBmpsTimerEnabled) |
| 9624 | { |
| 9625 | sme_StartAutoBmpsTimer(pHddCtx->hHal); |
| 9626 | } |
| 9627 | |
| 9628 | if (pHddCtx->cfg_ini->fIsImpsEnabled) |
| 9629 | { |
| 9630 | sme_EnablePowerSave (pHddCtx->hHal, ePMC_IDLE_MODE_POWER_SAVE); |
| 9631 | } |
| 9632 | |
| 9633 | return status; |
| 9634 | } |
| 9635 | |
| 9636 | VOS_STATUS hdd_disable_bmps_imps(hdd_context_t *pHddCtx, tANI_U8 session_type) |
| 9637 | { |
| 9638 | hdd_adapter_t *pAdapter = NULL; |
| 9639 | eHalStatus halStatus; |
| 9640 | VOS_STATUS status = VOS_STATUS_E_INVAL; |
| 9641 | v_BOOL_t disableBmps = FALSE; |
| 9642 | v_BOOL_t disableImps = FALSE; |
| 9643 | |
| 9644 | switch(session_type) |
| 9645 | { |
| 9646 | case WLAN_HDD_INFRA_STATION: |
| 9647 | case WLAN_HDD_SOFTAP: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9648 | case WLAN_HDD_P2P_CLIENT: |
| 9649 | case WLAN_HDD_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9650 | //Exit BMPS -> Is Sta/P2P Client is already connected |
| 9651 | pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 9652 | if((NULL != pAdapter)&& |
| 9653 | hdd_connIsConnected( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) |
| 9654 | { |
| 9655 | disableBmps = TRUE; |
| 9656 | } |
| 9657 | |
| 9658 | pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_CLIENT); |
| 9659 | if((NULL != pAdapter)&& |
| 9660 | hdd_connIsConnected( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) |
| 9661 | { |
| 9662 | disableBmps = TRUE; |
| 9663 | } |
| 9664 | |
| 9665 | //Exit both Bmps and Imps incase of Go/SAP Mode |
| 9666 | if((WLAN_HDD_SOFTAP == session_type) || |
| 9667 | (WLAN_HDD_P2P_GO == session_type)) |
| 9668 | { |
| 9669 | disableBmps = TRUE; |
| 9670 | disableImps = TRUE; |
| 9671 | } |
| 9672 | |
| 9673 | if(TRUE == disableImps) |
| 9674 | { |
| 9675 | if (pHddCtx->cfg_ini->fIsImpsEnabled) |
| 9676 | { |
| 9677 | sme_DisablePowerSave (pHddCtx->hHal, ePMC_IDLE_MODE_POWER_SAVE); |
| 9678 | } |
| 9679 | } |
| 9680 | |
| 9681 | if(TRUE == disableBmps) |
| 9682 | { |
| 9683 | if(pHddCtx->cfg_ini->fIsBmpsEnabled) |
| 9684 | { |
| 9685 | halStatus = sme_DisablePowerSave(pHddCtx->hHal, ePMC_BEACON_MODE_POWER_SAVE); |
| 9686 | |
| 9687 | if(eHAL_STATUS_SUCCESS != halStatus) |
| 9688 | { |
| 9689 | status = VOS_STATUS_E_FAILURE; |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 9690 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Fail to Disable Power Save", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9691 | VOS_ASSERT(0); |
| 9692 | return status; |
| 9693 | } |
| 9694 | } |
| 9695 | |
| 9696 | if(pHddCtx->cfg_ini->fIsAutoBmpsTimerEnabled) |
| 9697 | { |
| 9698 | halStatus = sme_StopAutoBmpsTimer(pHddCtx->hHal); |
| 9699 | |
| 9700 | if(eHAL_STATUS_SUCCESS != halStatus) |
| 9701 | { |
| 9702 | status = VOS_STATUS_E_FAILURE; |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 9703 | 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] | 9704 | VOS_ASSERT(0); |
| 9705 | return status; |
| 9706 | } |
| 9707 | } |
| 9708 | } |
| 9709 | |
| 9710 | if((TRUE == disableBmps) || |
| 9711 | (TRUE == disableImps)) |
| 9712 | { |
| 9713 | /* Now, get the chip into Full Power now */ |
| 9714 | INIT_COMPLETION(pHddCtx->full_pwr_comp_var); |
| 9715 | halStatus = sme_RequestFullPower(pHddCtx->hHal, hdd_full_pwr_cbk, |
| 9716 | pHddCtx, eSME_FULL_PWR_NEEDED_BY_HDD); |
| 9717 | |
| 9718 | if(halStatus != eHAL_STATUS_SUCCESS) |
| 9719 | { |
| 9720 | if(halStatus == eHAL_STATUS_PMC_PENDING) |
| 9721 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 9722 | long ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9723 | //Block on a completion variable. Can't wait forever though |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 9724 | ret = wait_for_completion_interruptible_timeout( |
| 9725 | &pHddCtx->full_pwr_comp_var, |
| 9726 | msecs_to_jiffies(1000)); |
| 9727 | if (ret <= 0) |
| 9728 | { |
| 9729 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 9730 | "%s: wait on full_pwr_comp_var failed %ld", |
| 9731 | __func__, ret); |
| 9732 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9733 | } |
| 9734 | else |
| 9735 | { |
| 9736 | status = VOS_STATUS_E_FAILURE; |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 9737 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Request for Full Power failed", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9738 | VOS_ASSERT(0); |
| 9739 | return status; |
| 9740 | } |
| 9741 | } |
| 9742 | |
| 9743 | status = VOS_STATUS_SUCCESS; |
| 9744 | } |
| 9745 | |
| 9746 | break; |
| 9747 | } |
| 9748 | return status; |
| 9749 | } |
Hanumantha Reddy Pothula | 91cdd7f | 2015-09-03 21:25:16 +0530 | [diff] [blame] | 9750 | |
Hanumanth Reddy Pothula | b8be9ab | 2018-04-12 20:03:05 +0530 | [diff] [blame] | 9751 | void hdd_mon_post_msg_cb(void *context) |
Hanumantha Reddy Pothula | 91cdd7f | 2015-09-03 21:25:16 +0530 | [diff] [blame] | 9752 | { |
Hanumanth Reddy Pothula | b8be9ab | 2018-04-12 20:03:05 +0530 | [diff] [blame] | 9753 | struct hdd_request *request; |
Hanumantha Reddy Pothula | 91cdd7f | 2015-09-03 21:25:16 +0530 | [diff] [blame] | 9754 | |
Hanumanth Reddy Pothula | b8be9ab | 2018-04-12 20:03:05 +0530 | [diff] [blame] | 9755 | request = hdd_request_get(context); |
| 9756 | if (!request) { |
| 9757 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Obsolete request")); |
| 9758 | return; |
| 9759 | } |
| 9760 | |
| 9761 | hdd_request_complete(request); |
| 9762 | hdd_request_put(request); |
Hanumantha Reddy Pothula | 91cdd7f | 2015-09-03 21:25:16 +0530 | [diff] [blame] | 9763 | } |
| 9764 | |
Hanumanth Reddy Pothula | b8be9ab | 2018-04-12 20:03:05 +0530 | [diff] [blame] | 9765 | |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 9766 | void hdd_init_mon_mode (hdd_adapter_t *pAdapter) |
| 9767 | { |
| 9768 | hdd_mon_ctx_t *pMonCtx = NULL; |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 9769 | |
Rajeev Kumar Sirasanagandla | 5444761 | 2018-03-06 15:49:56 +0530 | [diff] [blame] | 9770 | spin_lock_init(&pAdapter->sta_hash_lock); |
| 9771 | pAdapter->is_sta_id_hash_initialized = VOS_FALSE; |
| 9772 | |
| 9773 | pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter); |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 9774 | pMonCtx->state = 0; |
| 9775 | pMonCtx->ChannelNo = 1; |
| 9776 | pMonCtx->ChannelBW = 20; |
Katya Nigam | d7d3a1f | 2015-06-11 14:04:24 +0530 | [diff] [blame] | 9777 | pMonCtx->crcCheckEnabled = 1; |
| 9778 | pMonCtx->typeSubtypeBitmap = 0xFFFF00000000; |
| 9779 | pMonCtx->is80211to803ConReq = 1; |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 9780 | pMonCtx->numOfMacFilters = 0; |
| 9781 | } |
| 9782 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9783 | |
| 9784 | 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] | 9785 | const char *iface_name, tSirMacAddr macAddr, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9786 | tANI_U8 rtnl_held ) |
| 9787 | { |
| 9788 | hdd_adapter_t *pAdapter = NULL; |
| 9789 | hdd_adapter_list_node_t *pHddAdapterNode = NULL; |
| 9790 | VOS_STATUS status = VOS_STATUS_E_FAILURE; |
| 9791 | VOS_STATUS exitbmpsStatus; |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 9792 | v_CONTEXT_t pVosContext = NULL; |
| 9793 | |
| 9794 | /* No need to check for NULL, reaching this step |
| 9795 | * means vos context is initialized |
| 9796 | */ |
| 9797 | pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9798 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 9799 | 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] | 9800 | |
Nirav Shah | 436658f | 2014-02-28 17:05:45 +0530 | [diff] [blame] | 9801 | if(macAddr == NULL) |
| 9802 | { |
| 9803 | /* Not received valid macAddr */ |
| 9804 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9805 | "%s:Unable to add virtual intf: Not able to get" |
| 9806 | "valid mac address",__func__); |
| 9807 | return NULL; |
| 9808 | } |
| 9809 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9810 | //Disable BMPS incase of Concurrency |
| 9811 | exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx, session_type); |
| 9812 | |
| 9813 | if(VOS_STATUS_E_FAILURE == exitbmpsStatus) |
| 9814 | { |
| 9815 | //Fail to Exit BMPS |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 9816 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Fail to Exit BMPS", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9817 | VOS_ASSERT(0); |
| 9818 | return NULL; |
| 9819 | } |
| 9820 | |
| 9821 | switch(session_type) |
| 9822 | { |
| 9823 | case WLAN_HDD_INFRA_STATION: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9824 | case WLAN_HDD_P2P_CLIENT: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9825 | case WLAN_HDD_P2P_DEVICE: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9826 | { |
| 9827 | pAdapter = hdd_alloc_station_adapter( pHddCtx, macAddr, iface_name ); |
| 9828 | |
| 9829 | if( NULL == pAdapter ) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 9830 | { |
| 9831 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 9832 | FL("failed to allocate adapter for session %d"), session_type); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9833 | return NULL; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 9834 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9835 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 9836 | #ifdef FEATURE_WLAN_TDLS |
| 9837 | /* A Mutex Lock is introduced while changing/initializing the mode to |
| 9838 | * protect the concurrent access for the Adapters by TDLS module. |
| 9839 | */ |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 9840 | mutex_lock(&pHddCtx->tdls_lock); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 9841 | #endif |
| 9842 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 9843 | pAdapter->wdev.iftype = (session_type == WLAN_HDD_P2P_CLIENT) ? |
| 9844 | NL80211_IFTYPE_P2P_CLIENT: |
| 9845 | NL80211_IFTYPE_STATION; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9846 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9847 | pAdapter->device_mode = session_type; |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 9848 | #ifdef FEATURE_WLAN_TDLS |
| 9849 | mutex_unlock(&pHddCtx->tdls_lock); |
| 9850 | #endif |
Sunil Dutt | 66485cb | 2013-12-19 19:05:03 +0530 | [diff] [blame] | 9851 | |
Mahesh A Saptasagar | 67ab922 | 2015-10-21 15:38:41 +0530 | [diff] [blame] | 9852 | hdd_initialize_adapter_common(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9853 | |
| 9854 | status = hdd_register_interface( pAdapter, rtnl_held ); |
| 9855 | if( VOS_STATUS_SUCCESS != status ) |
| 9856 | { |
Mahesh A Saptasagar | 02e36e8 | 2015-01-14 20:39:19 +0530 | [diff] [blame] | 9857 | #ifdef FEATURE_WLAN_TDLS |
| 9858 | mutex_lock(&pHddCtx->tdls_lock); |
| 9859 | #endif |
c_hpothu | 002231a | 2015-02-05 14:58:51 +0530 | [diff] [blame] | 9860 | hdd_deinit_adapter(pHddCtx, pAdapter, rtnl_held); |
Mahesh A Saptasagar | 02e36e8 | 2015-01-14 20:39:19 +0530 | [diff] [blame] | 9861 | #ifdef FEATURE_WLAN_TDLS |
| 9862 | mutex_unlock(&pHddCtx->tdls_lock); |
| 9863 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9864 | goto err_free_netdev; |
| 9865 | } |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 9866 | |
Vinay Krishna Eranna | 4d055d4 | 2013-12-17 17:02:01 +0530 | [diff] [blame] | 9867 | // Workqueue which gets scheduled in IPv4 notification callback. |
Anand N Sunkad | dc63c79 | 2015-06-03 14:33:24 +0530 | [diff] [blame] | 9868 | vos_init_work(&pAdapter->ipv4NotifierWorkQueue, hdd_ipv4_notifier_work_queue); |
Vinay Krishna Eranna | 4d055d4 | 2013-12-17 17:02:01 +0530 | [diff] [blame] | 9869 | |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 9870 | #ifdef WLAN_NS_OFFLOAD |
| 9871 | // Workqueue which gets scheduled in IPv6 notification callback. |
Anand N Sunkad | dc63c79 | 2015-06-03 14:33:24 +0530 | [diff] [blame] | 9872 | vos_init_work(&pAdapter->ipv6NotifierWorkQueue, hdd_ipv6_notifier_work_queue); |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 9873 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9874 | //Stop the Interface TX queue. |
Padma, Santhosh Kumar | 9dacb5c | 2014-12-17 19:22:56 +0530 | [diff] [blame] | 9875 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9876 | netif_tx_disable(pAdapter->dev); |
| 9877 | //netif_tx_disable(pWlanDev); |
| 9878 | netif_carrier_off(pAdapter->dev); |
| 9879 | |
Ganesh Kondabattini | babfb49 | 2014-12-17 20:25:29 +0530 | [diff] [blame] | 9880 | if (WLAN_HDD_P2P_CLIENT == session_type || |
| 9881 | WLAN_HDD_P2P_DEVICE == session_type) |
| 9882 | { |
| 9883 | /* Initialize the work queue to defer the |
| 9884 | * back to back RoC request */ |
Anand N Sunkad | dc63c79 | 2015-06-03 14:33:24 +0530 | [diff] [blame] | 9885 | vos_init_delayed_work(&pAdapter->roc_work, |
Ganesh Kondabattini | babfb49 | 2014-12-17 20:25:29 +0530 | [diff] [blame] | 9886 | hdd_p2p_roc_work_queue); |
| 9887 | } |
| 9888 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9889 | break; |
| 9890 | } |
| 9891 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9892 | case WLAN_HDD_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9893 | case WLAN_HDD_SOFTAP: |
| 9894 | { |
| 9895 | pAdapter = hdd_wlan_create_ap_dev( pHddCtx, macAddr, (tANI_U8 *)iface_name ); |
| 9896 | if( NULL == pAdapter ) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 9897 | { |
| 9898 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 9899 | FL("failed to allocate adapter for session %d"), session_type); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9900 | return NULL; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 9901 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9902 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9903 | pAdapter->wdev.iftype = (session_type == WLAN_HDD_SOFTAP) ? |
| 9904 | NL80211_IFTYPE_AP: |
| 9905 | NL80211_IFTYPE_P2P_GO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9906 | pAdapter->device_mode = session_type; |
| 9907 | |
Mahesh A Saptasagar | 67ab922 | 2015-10-21 15:38:41 +0530 | [diff] [blame] | 9908 | hdd_initialize_adapter_common(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9909 | |
Nirav Shah | 7e3c813 | 2015-06-22 23:51:42 +0530 | [diff] [blame] | 9910 | status = hdd_sta_id_hash_attach(pAdapter); |
| 9911 | if (VOS_STATUS_SUCCESS != status) |
| 9912 | { |
| 9913 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 9914 | FL("failed to attach hash for session %d"), session_type); |
Nirav Shah | 7e3c813 | 2015-06-22 23:51:42 +0530 | [diff] [blame] | 9915 | goto err_free_netdev; |
| 9916 | } |
| 9917 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9918 | status = hdd_register_hostapd( pAdapter, rtnl_held ); |
| 9919 | if( VOS_STATUS_SUCCESS != status ) |
| 9920 | { |
c_hpothu | 002231a | 2015-02-05 14:58:51 +0530 | [diff] [blame] | 9921 | hdd_deinit_adapter(pHddCtx, pAdapter, rtnl_held); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9922 | goto err_free_netdev; |
| 9923 | } |
Padma, Santhosh Kumar | 9dacb5c | 2014-12-17 19:22:56 +0530 | [diff] [blame] | 9924 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9925 | netif_tx_disable(pAdapter->dev); |
| 9926 | netif_carrier_off(pAdapter->dev); |
| 9927 | |
| 9928 | hdd_set_conparam( 1 ); |
Ganesh Kondabattini | babfb49 | 2014-12-17 20:25:29 +0530 | [diff] [blame] | 9929 | |
Hanumanth Reddy Pothula | b4537b8 | 2018-03-02 12:20:38 +0530 | [diff] [blame] | 9930 | // Workqueue which gets scheduled in IPv4 notification callback. |
| 9931 | vos_init_work(&pAdapter->ipv4NotifierWorkQueue, |
| 9932 | hdd_ipv4_notifier_work_queue); |
| 9933 | |
| 9934 | #ifdef WLAN_NS_OFFLOAD |
| 9935 | // Workqueue which gets scheduled in IPv6 notification callback. |
| 9936 | vos_init_work(&pAdapter->ipv6NotifierWorkQueue, |
| 9937 | hdd_ipv6_notifier_work_queue); |
| 9938 | #endif |
| 9939 | |
Ganesh Kondabattini | babfb49 | 2014-12-17 20:25:29 +0530 | [diff] [blame] | 9940 | if (WLAN_HDD_P2P_GO == session_type) |
| 9941 | { |
| 9942 | /* Initialize the work queue to |
| 9943 | * defer the back to back RoC request */ |
| 9944 | INIT_DELAYED_WORK(&pAdapter->roc_work, |
| 9945 | hdd_p2p_roc_work_queue); |
| 9946 | } |
Bhargav Shah | d071591 | 2015-10-01 18:17:37 +0530 | [diff] [blame] | 9947 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9948 | break; |
| 9949 | } |
| 9950 | case WLAN_HDD_MONITOR: |
| 9951 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9952 | pAdapter = hdd_alloc_station_adapter( pHddCtx, macAddr, iface_name ); |
| 9953 | if( NULL == pAdapter ) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 9954 | { |
| 9955 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 9956 | FL("failed to allocate adapter for session %d"), session_type); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9957 | return NULL; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 9958 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9959 | |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 9960 | pAdapter->device_mode = session_type; |
| 9961 | pAdapter->wdev.iftype = NL80211_IFTYPE_MONITOR; |
| 9962 | |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 9963 | // Register wireless extensions |
| 9964 | if( VOS_STATUS_SUCCESS != (status = hdd_register_wext(pAdapter->dev))) |
| 9965 | { |
| 9966 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 9967 | "hdd_register_wext() failed with status code %08d [x%08x]", |
| 9968 | status, status ); |
| 9969 | status = VOS_STATUS_E_FAILURE; |
| 9970 | } |
| 9971 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9972 | #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29) |
| 9973 | pAdapter->dev->netdev_ops = &wlan_mon_drv_ops; |
| 9974 | #else |
| 9975 | pAdapter->dev->open = hdd_mon_open; |
| 9976 | pAdapter->dev->hard_start_xmit = hdd_mon_hard_start_xmit; |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 9977 | pAdapter->dev->stop = hdd_mon_stop; |
| 9978 | pAdapter->dev->do_ioctl = hdd_mon_ioctl; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9979 | #endif |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 9980 | hdd_init_mon_mode( pAdapter ); |
Mahesh A Saptasagar | 67ab922 | 2015-10-21 15:38:41 +0530 | [diff] [blame] | 9981 | hdd_initialize_adapter_common(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9982 | hdd_init_tx_rx( pAdapter ); |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 9983 | |
| 9984 | if (VOS_MONITOR_MODE != hdd_get_conparam()) |
| 9985 | WLANTL_SetMonRxCbk( pVosContext, hdd_rx_packet_monitor_cbk ); |
| 9986 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9987 | set_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags); |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 9988 | status = hdd_register_interface( pAdapter, rtnl_held ); |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 9989 | //Stop the Interface TX queue. |
| 9990 | netif_tx_disable(pAdapter->dev); |
| 9991 | netif_carrier_off(pAdapter->dev); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9992 | } |
| 9993 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9994 | case WLAN_HDD_FTM: |
| 9995 | { |
| 9996 | pAdapter = hdd_alloc_station_adapter( pHddCtx, macAddr, iface_name ); |
| 9997 | |
| 9998 | if( NULL == pAdapter ) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 9999 | { |
| 10000 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 10001 | FL("failed to allocate adapter for session %d"), session_type); |
| 10002 | return NULL; |
| 10003 | } |
| 10004 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10005 | /* Assign NL80211_IFTYPE_STATION as interface type to resolve Kernel Warning |
| 10006 | * message while loading driver in FTM mode. */ |
| 10007 | pAdapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 10008 | pAdapter->device_mode = session_type; |
| 10009 | status = hdd_register_interface( pAdapter, rtnl_held ); |
Madan Mohan Koyyalamudi | f89ac9f | 2013-09-19 16:58:12 +0530 | [diff] [blame] | 10010 | |
Mahesh A Saptasagar | 67ab922 | 2015-10-21 15:38:41 +0530 | [diff] [blame] | 10011 | hdd_initialize_adapter_common(pAdapter); |
Madan Mohan Koyyalamudi | f89ac9f | 2013-09-19 16:58:12 +0530 | [diff] [blame] | 10012 | hdd_init_tx_rx( pAdapter ); |
| 10013 | |
| 10014 | //Stop the Interface TX queue. |
Padma, Santhosh Kumar | 9dacb5c | 2014-12-17 19:22:56 +0530 | [diff] [blame] | 10015 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues")); |
Madan Mohan Koyyalamudi | f89ac9f | 2013-09-19 16:58:12 +0530 | [diff] [blame] | 10016 | netif_tx_disable(pAdapter->dev); |
| 10017 | netif_carrier_off(pAdapter->dev); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10018 | } |
| 10019 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10020 | default: |
| 10021 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 10022 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s Invalid session type %d", |
| 10023 | __func__, session_type); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10024 | VOS_ASSERT(0); |
| 10025 | return NULL; |
| 10026 | } |
| 10027 | } |
| 10028 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10029 | if( VOS_STATUS_SUCCESS == status ) |
| 10030 | { |
Mahesh A Saptasagar | 67ab922 | 2015-10-21 15:38:41 +0530 | [diff] [blame] | 10031 | //Add it to the hdd's session list. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10032 | pHddAdapterNode = vos_mem_malloc( sizeof( hdd_adapter_list_node_t ) ); |
| 10033 | if( NULL == pHddAdapterNode ) |
| 10034 | { |
| 10035 | status = VOS_STATUS_E_NOMEM; |
| 10036 | } |
| 10037 | else |
| 10038 | { |
| 10039 | pHddAdapterNode->pAdapter = pAdapter; |
| 10040 | status = hdd_add_adapter_back ( pHddCtx, |
| 10041 | pHddAdapterNode ); |
| 10042 | } |
| 10043 | } |
| 10044 | |
| 10045 | if( VOS_STATUS_SUCCESS != status ) |
| 10046 | { |
| 10047 | if( NULL != pAdapter ) |
| 10048 | { |
| 10049 | hdd_cleanup_adapter( pHddCtx, pAdapter, rtnl_held ); |
| 10050 | pAdapter = NULL; |
| 10051 | } |
| 10052 | if( NULL != pHddAdapterNode ) |
| 10053 | { |
| 10054 | vos_mem_free( pHddAdapterNode ); |
| 10055 | } |
| 10056 | |
| 10057 | goto resume_bmps; |
| 10058 | } |
| 10059 | |
| 10060 | if(VOS_STATUS_SUCCESS == status) |
| 10061 | { |
| 10062 | wlan_hdd_set_concurrency_mode(pHddCtx, session_type); |
Madan Mohan Koyyalamudi | 96dd30d | 2012-10-05 17:24:51 -0700 | [diff] [blame] | 10063 | //Initialize the WoWL service |
| 10064 | if(!hdd_init_wowl(pAdapter)) |
| 10065 | { |
| 10066 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hdd_init_wowl failed",__func__); |
| 10067 | goto err_free_netdev; |
| 10068 | } |
Manjeet Singh | 3ed7924 | 2017-01-11 19:04:32 +0530 | [diff] [blame] | 10069 | //Initialize the TSF capture data |
| 10070 | wlan_hdd_tsf_init(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10071 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10072 | return pAdapter; |
| 10073 | |
| 10074 | err_free_netdev: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10075 | wlan_hdd_release_intf_addr( pHddCtx, |
| 10076 | pAdapter->macAddressCurrent.bytes ); |
Hanumanth Reddy Pothula | ab8e194 | 2018-05-24 18:10:39 +0530 | [diff] [blame] | 10077 | free_netdev(pAdapter->dev); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10078 | |
| 10079 | resume_bmps: |
| 10080 | //If bmps disabled enable it |
| 10081 | if(VOS_STATUS_SUCCESS == exitbmpsStatus) |
| 10082 | { |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 10083 | if (pHddCtx->hdd_wlan_suspended) |
| 10084 | { |
| 10085 | hdd_set_pwrparams(pHddCtx); |
| 10086 | } |
| 10087 | hdd_enable_bmps_imps(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10088 | } |
| 10089 | return NULL; |
| 10090 | } |
| 10091 | |
| 10092 | VOS_STATUS hdd_close_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter, |
| 10093 | tANI_U8 rtnl_held ) |
| 10094 | { |
| 10095 | hdd_adapter_list_node_t *pAdapterNode, *pCurrent, *pNext; |
| 10096 | VOS_STATUS status; |
| 10097 | |
| 10098 | status = hdd_get_front_adapter ( pHddCtx, &pCurrent ); |
| 10099 | if( VOS_STATUS_SUCCESS != status ) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 10100 | { |
| 10101 | hddLog(VOS_TRACE_LEVEL_WARN,"%s: adapter list empty %d", |
| 10102 | __func__, status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10103 | return status; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 10104 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10105 | |
| 10106 | while ( pCurrent->pAdapter != pAdapter ) |
| 10107 | { |
| 10108 | status = hdd_get_next_adapter ( pHddCtx, pCurrent, &pNext ); |
| 10109 | if( VOS_STATUS_SUCCESS != status ) |
| 10110 | break; |
| 10111 | |
| 10112 | pCurrent = pNext; |
| 10113 | } |
| 10114 | pAdapterNode = pCurrent; |
| 10115 | if( VOS_STATUS_SUCCESS == status ) |
| 10116 | { |
| 10117 | wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode); |
| 10118 | hdd_cleanup_adapter( pHddCtx, pAdapterNode->pAdapter, rtnl_held ); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 10119 | |
| 10120 | #ifdef FEATURE_WLAN_TDLS |
| 10121 | |
| 10122 | /* A Mutex Lock is introduced while changing/initializing the mode to |
| 10123 | * protect the concurrent access for the Adapters by TDLS module. |
| 10124 | */ |
Rajesh Chauhan | a34c6e6 | 2014-03-25 16:37:58 +0530 | [diff] [blame] | 10125 | mutex_lock(&pHddCtx->tdls_lock); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 10126 | #endif |
| 10127 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10128 | hdd_remove_adapter( pHddCtx, pAdapterNode ); |
| 10129 | vos_mem_free( pAdapterNode ); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 10130 | pAdapterNode = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10131 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 10132 | #ifdef FEATURE_WLAN_TDLS |
| 10133 | mutex_unlock(&pHddCtx->tdls_lock); |
| 10134 | #endif |
| 10135 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10136 | |
| 10137 | /* 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] | 10138 | if ((!vos_concurrent_open_sessions_running()) && |
| 10139 | ((pHddCtx->no_of_open_sessions[VOS_STA_MODE] >= 1) || |
| 10140 | (pHddCtx->no_of_open_sessions[VOS_P2P_CLIENT_MODE] >= 1))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10141 | { |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 10142 | if (pHddCtx->hdd_wlan_suspended) |
| 10143 | { |
| 10144 | hdd_set_pwrparams(pHddCtx); |
| 10145 | } |
| 10146 | hdd_enable_bmps_imps(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10147 | } |
| 10148 | |
| 10149 | return VOS_STATUS_SUCCESS; |
| 10150 | } |
| 10151 | |
| 10152 | return VOS_STATUS_E_FAILURE; |
| 10153 | } |
| 10154 | |
| 10155 | VOS_STATUS hdd_close_all_adapters( hdd_context_t *pHddCtx ) |
| 10156 | { |
| 10157 | hdd_adapter_list_node_t *pHddAdapterNode; |
| 10158 | VOS_STATUS status; |
| 10159 | |
| 10160 | ENTER(); |
| 10161 | |
| 10162 | do |
| 10163 | { |
| 10164 | status = hdd_remove_front_adapter( pHddCtx, &pHddAdapterNode ); |
| 10165 | if( pHddAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 10166 | { |
| 10167 | hdd_cleanup_adapter( pHddCtx, pHddAdapterNode->pAdapter, FALSE ); |
| 10168 | vos_mem_free( pHddAdapterNode ); |
| 10169 | } |
| 10170 | }while( NULL != pHddAdapterNode && VOS_STATUS_E_EMPTY != status ); |
| 10171 | |
| 10172 | EXIT(); |
| 10173 | |
| 10174 | return VOS_STATUS_SUCCESS; |
| 10175 | } |
| 10176 | |
| 10177 | void wlan_hdd_reset_prob_rspies(hdd_adapter_t* pHostapdAdapter) |
| 10178 | { |
| 10179 | v_U8_t addIE[1] = {0}; |
| 10180 | |
| 10181 | if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 10182 | WNI_CFG_PROBE_RSP_ADDNIE_DATA1,(tANI_U8*)addIE, 0, NULL, |
| 10183 | eANI_BOOLEAN_FALSE) ) |
| 10184 | { |
| 10185 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 10186 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10187 | } |
| 10188 | |
| 10189 | if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 10190 | WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL, |
| 10191 | eANI_BOOLEAN_FALSE) ) |
| 10192 | { |
| 10193 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 10194 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10195 | } |
| 10196 | |
| 10197 | if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 10198 | WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL, |
| 10199 | eANI_BOOLEAN_FALSE) ) |
| 10200 | { |
| 10201 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 10202 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10203 | } |
| 10204 | } |
| 10205 | |
Anurag Chouhan | 8302600 | 2016-12-13 22:46:21 +0530 | [diff] [blame] | 10206 | VOS_STATUS hdd_cleanup_ap_events(hdd_adapter_t *adapter) |
| 10207 | { |
| 10208 | #ifdef DHCP_SERVER_OFFLOAD |
| 10209 | vos_event_destroy(&adapter->dhcp_status.vos_event); |
| 10210 | #endif |
Anurag Chouhan | 0b29de0 | 2016-12-16 13:18:40 +0530 | [diff] [blame] | 10211 | #ifdef MDNS_OFFLOAD |
| 10212 | vos_event_destroy(&adapter->mdns_status.vos_event); |
| 10213 | #endif |
Anurag Chouhan | 8302600 | 2016-12-13 22:46:21 +0530 | [diff] [blame] | 10214 | return VOS_STATUS_SUCCESS; |
| 10215 | } |
| 10216 | |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 10217 | int wlan_hdd_stop_mon(hdd_context_t *hdd_ctx, bool wait) |
| 10218 | { |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 10219 | hdd_adapter_t *adapter; |
Hanumanth Reddy Pothula | b8be9ab | 2018-04-12 20:03:05 +0530 | [diff] [blame] | 10220 | hdd_mon_ctx_t *mon_ctx; |
| 10221 | void (*func_ptr)(void *context) = NULL; |
| 10222 | int ret = 0; |
| 10223 | void *cookie = NULL; |
| 10224 | struct hdd_request *request; |
| 10225 | static const struct hdd_request_params params = { |
| 10226 | .priv_size = 0, |
| 10227 | .timeout_ms = MON_MODE_MSG_TIMEOUT, |
| 10228 | }; |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 10229 | |
| 10230 | adapter = hdd_get_adapter(hdd_ctx, WLAN_HDD_MONITOR); |
| 10231 | if (!adapter) { |
| 10232 | hddLog(LOGE, FL("Invalid STA + MON mode")); |
| 10233 | return -EINVAL; |
| 10234 | } |
| 10235 | |
| 10236 | mon_ctx = WLAN_HDD_GET_MONITOR_CTX_PTR(adapter); |
| 10237 | if (!mon_ctx) |
| 10238 | return 0; |
| 10239 | |
| 10240 | if (mon_ctx->state != MON_MODE_START) |
| 10241 | return 0; |
| 10242 | |
| 10243 | mon_ctx->state = MON_MODE_STOP; |
| 10244 | if (wait) { |
Hanumanth Reddy Pothula | b8be9ab | 2018-04-12 20:03:05 +0530 | [diff] [blame] | 10245 | func_ptr = hdd_mon_post_msg_cb; |
| 10246 | request = hdd_request_alloc(¶ms); |
| 10247 | if (!request) { |
| 10248 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 10249 | FL("Request allocation failure")); |
| 10250 | return -ENOMEM; |
| 10251 | } |
| 10252 | cookie = hdd_request_cookie(request); |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 10253 | } |
| 10254 | |
Hanumanth Reddy Pothula | b8be9ab | 2018-04-12 20:03:05 +0530 | [diff] [blame] | 10255 | /* |
| 10256 | * If func_ptr is NULL, on receiving WDI_MON_START_RSP or |
| 10257 | * WDI_MON_STOP_RSP hdd_mon_post_msg_cb() won't be invoked |
| 10258 | * and so uninitialized cookie won't be accessed. |
| 10259 | */ |
| 10260 | if (VOS_STATUS_SUCCESS != wlan_hdd_mon_postMsg(cookie, |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 10261 | mon_ctx, |
Hanumanth Reddy Pothula | b8be9ab | 2018-04-12 20:03:05 +0530 | [diff] [blame] | 10262 | func_ptr)) { |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 10263 | hddLog(LOGE, FL("failed to stop MON MODE")); |
Hanumanth Reddy Pothula | b8be9ab | 2018-04-12 20:03:05 +0530 | [diff] [blame] | 10264 | ret = -EINVAL; |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 10265 | } |
| 10266 | |
| 10267 | if (!wait) |
| 10268 | goto bmps_roaming; |
| 10269 | |
Hanumanth Reddy Pothula | b8be9ab | 2018-04-12 20:03:05 +0530 | [diff] [blame] | 10270 | if (!ret) |
| 10271 | ret = hdd_request_wait_for_response(request); |
| 10272 | hdd_request_put(request); |
| 10273 | if (ret) { |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 10274 | hddLog(LOGE, |
Hanumanth Reddy Pothula | b8be9ab | 2018-04-12 20:03:05 +0530 | [diff] [blame] | 10275 | FL("timeout on stop monitor mode completion %d"), ret); |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 10276 | return -EINVAL; |
| 10277 | } |
| 10278 | |
| 10279 | bmps_roaming: |
| 10280 | hddLog(LOG1, FL("Enable BMPS")); |
| 10281 | hdd_enable_bmps_imps(hdd_ctx); |
| 10282 | hdd_restore_roaming(hdd_ctx); |
| 10283 | |
| 10284 | return 0; |
| 10285 | } |
| 10286 | |
| 10287 | bool wlan_hdd_check_monitor_state(hdd_context_t *hdd_ctx) |
| 10288 | { |
| 10289 | hdd_adapter_t *mon_adapter; |
| 10290 | hdd_mon_ctx_t *mon_ctx; |
| 10291 | |
| 10292 | if (hdd_ctx->concurrency_mode != VOS_STA_MON) |
| 10293 | return false; |
| 10294 | |
| 10295 | mon_adapter = hdd_get_adapter(hdd_ctx, WLAN_HDD_MONITOR); |
| 10296 | if (!mon_adapter) { |
| 10297 | hddLog(LOGE, FL("Invalid concurrency mode")); |
| 10298 | return false; |
| 10299 | } |
| 10300 | |
| 10301 | mon_ctx = WLAN_HDD_GET_MONITOR_CTX_PTR(mon_adapter); |
| 10302 | if (mon_ctx->state == MON_MODE_START) |
| 10303 | return true; |
| 10304 | |
| 10305 | return false; |
| 10306 | } |
| 10307 | |
| 10308 | int wlan_hdd_check_and_stop_mon(hdd_adapter_t *sta_adapter, bool wait) |
| 10309 | { |
| 10310 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(sta_adapter); |
| 10311 | |
| 10312 | if ((sta_adapter->device_mode != WLAN_HDD_INFRA_STATION) || |
| 10313 | !wlan_hdd_check_monitor_state(hdd_ctx)) |
| 10314 | return 0; |
| 10315 | |
| 10316 | if (wlan_hdd_stop_mon(hdd_ctx, wait)) |
| 10317 | return -EINVAL; |
| 10318 | |
| 10319 | return 0; |
| 10320 | } |
| 10321 | |
| 10322 | void hdd_disable_roaming(hdd_context_t *hdd_ctx) |
| 10323 | { |
| 10324 | if (!hdd_ctx) |
| 10325 | return; |
| 10326 | |
| 10327 | if (!hdd_ctx->cfg_ini->isFastRoamIniFeatureEnabled) { |
| 10328 | hdd_ctx->roaming_ini_original = CFG_LFR_FEATURE_ENABLED_MIN; |
| 10329 | return; |
| 10330 | } |
| 10331 | |
| 10332 | hddLog(LOG1, FL("Disable driver and firmware roaming")); |
| 10333 | |
| 10334 | hdd_ctx->roaming_ini_original = |
| 10335 | hdd_ctx->cfg_ini->isFastRoamIniFeatureEnabled; |
| 10336 | |
| 10337 | hdd_ctx->cfg_ini->isFastRoamIniFeatureEnabled = |
| 10338 | CFG_LFR_FEATURE_ENABLED_MIN; |
| 10339 | |
| 10340 | sme_UpdateIsFastRoamIniFeatureEnabled(hdd_ctx->hHal, |
| 10341 | CFG_LFR_FEATURE_ENABLED_MIN); |
| 10342 | } |
| 10343 | |
| 10344 | void hdd_restore_roaming(hdd_context_t *hdd_ctx) |
| 10345 | { |
| 10346 | if (!hdd_ctx->roaming_ini_original) |
| 10347 | return; |
| 10348 | |
| 10349 | hddLog(LOG1, FL("Enable driver and firmware roaming")); |
| 10350 | |
| 10351 | hdd_ctx->cfg_ini->isFastRoamIniFeatureEnabled = |
| 10352 | CFG_LFR_FEATURE_ENABLED_MAX; |
| 10353 | |
| 10354 | hdd_ctx->roaming_ini_original = CFG_LFR_FEATURE_ENABLED_MIN; |
| 10355 | |
| 10356 | sme_UpdateIsFastRoamIniFeatureEnabled(hdd_ctx->hHal, |
| 10357 | CFG_LFR_FEATURE_ENABLED_MAX); |
| 10358 | } |
Anurag Chouhan | 8302600 | 2016-12-13 22:46:21 +0530 | [diff] [blame] | 10359 | |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 10360 | VOS_STATUS hdd_stop_adapter( hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter, |
| 10361 | const v_BOOL_t bCloseSession ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10362 | { |
| 10363 | eHalStatus halStatus = eHAL_STATUS_SUCCESS; |
| 10364 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Kaushik, Sushant | 4975a57 | 2014-10-21 16:07:48 +0530 | [diff] [blame] | 10365 | hdd_scaninfo_t *pScanInfo = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10366 | union iwreq_data wrqu; |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 10367 | v_U8_t retry = 0; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 10368 | long ret; |
Nirav Shah | 7e3c813 | 2015-06-22 23:51:42 +0530 | [diff] [blame] | 10369 | VOS_STATUS status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10370 | |
Anand N Sunkad | 26d71b9 | 2014-12-24 18:08:22 +0530 | [diff] [blame] | 10371 | if (pHddCtx->isLogpInProgress) { |
| 10372 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 10373 | "%s:LOGP in Progress. Ignore!!!",__func__); |
| 10374 | return VOS_STATUS_E_FAILURE; |
| 10375 | } |
| 10376 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10377 | ENTER(); |
Vinay Krishna Eranna | f97ef5c | 2014-12-26 17:47:19 +0530 | [diff] [blame] | 10378 | |
Kaushik, Sushant | 4975a57 | 2014-10-21 16:07:48 +0530 | [diff] [blame] | 10379 | pScanInfo = &pHddCtx->scan_info; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10380 | switch(pAdapter->device_mode) |
| 10381 | { |
Nirav Shah | 0cf4d89 | 2015-11-05 16:27:27 +0530 | [diff] [blame] | 10382 | case WLAN_HDD_IBSS: |
| 10383 | if ( VOS_TRUE == bCloseSession ) |
| 10384 | { |
| 10385 | status = hdd_sta_id_hash_detach(pAdapter); |
| 10386 | if (status != VOS_STATUS_SUCCESS) |
| 10387 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 10388 | FL("sta id hash detach failed")); |
| 10389 | } |
| 10390 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10391 | case WLAN_HDD_INFRA_STATION: |
| 10392 | case WLAN_HDD_P2P_CLIENT: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 10393 | case WLAN_HDD_P2P_DEVICE: |
Vinay Krishna Eranna | b09d3e7 | 2014-03-26 21:23:55 +0530 | [diff] [blame] | 10394 | { |
| 10395 | 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] | 10396 | #ifdef FEATURE_WLAN_TDLS |
| 10397 | mutex_lock(&pHddCtx->tdls_lock); |
| 10398 | wlan_hdd_tdls_exit(pAdapter, TRUE); |
| 10399 | mutex_unlock(&pHddCtx->tdls_lock); |
| 10400 | #endif |
Abhinav Kumar | e548f1e | 2018-07-12 16:40:43 +0530 | [diff] [blame] | 10401 | if(hdd_connIsConnected(pstation) || |
| 10402 | (pstation->conn_info.connState == eConnectionState_Connecting)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10403 | { |
| 10404 | if (pWextState->roamProfile.BSSType == eCSR_BSS_TYPE_START_IBSS) |
Abhinav Kumar | e548f1e | 2018-07-12 16:40:43 +0530 | [diff] [blame] | 10405 | { |
| 10406 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10407 | halStatus = sme_RoamDisconnect(pHddCtx->hHal, |
| 10408 | pAdapter->sessionId, |
| 10409 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
Abhinav Kumar | e548f1e | 2018-07-12 16:40:43 +0530 | [diff] [blame] | 10410 | /* Success implies disconnect command got queued up successfully |
| 10411 | * Or cmd not queued as scan for SSID is in progress |
| 10412 | */ |
| 10413 | if((eHAL_STATUS_SUCCESS == halStatus) || |
| 10414 | (eHAL_STATUS_CMD_NOT_QUEUED == halStatus)) |
| 10415 | { |
| 10416 | ret = wait_for_completion_timeout( |
| 10417 | &pAdapter->disconnect_comp_var, |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 10418 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
Abhinav Kumar | e548f1e | 2018-07-12 16:40:43 +0530 | [diff] [blame] | 10419 | if (ret <= 0 && |
| 10420 | (eHAL_STATUS_CMD_NOT_QUEUED != halStatus)) |
| 10421 | { |
| 10422 | hddLog(VOS_TRACE_LEVEL_ERROR, |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 10423 | "%s: wait on disconnect_comp_var failed %ld", |
| 10424 | __func__, ret); |
Abhinav Kumar | e548f1e | 2018-07-12 16:40:43 +0530 | [diff] [blame] | 10425 | } |
| 10426 | } |
| 10427 | else |
| 10428 | { |
| 10429 | hddLog(LOGE, "%s: failed to post disconnect event to SME", |
| 10430 | __func__); |
| 10431 | } |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 10432 | } |
| 10433 | else |
| 10434 | { |
Abhinav Kumar | e548f1e | 2018-07-12 16:40:43 +0530 | [diff] [blame] | 10435 | wlan_hdd_disconnect(pAdapter, eCSR_DISCONNECT_REASON_DEAUTH); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10436 | } |
| 10437 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 10438 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 10439 | memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN); |
| 10440 | wireless_send_event(pAdapter->dev, SIOCGIWAP, &wrqu, NULL); |
| 10441 | } |
Vinay Krishna Eranna | b09d3e7 | 2014-03-26 21:23:55 +0530 | [diff] [blame] | 10442 | else if(pstation->conn_info.connState == |
| 10443 | eConnectionState_Disconnecting) |
| 10444 | { |
| 10445 | ret = wait_for_completion_interruptible_timeout( |
| 10446 | &pAdapter->disconnect_comp_var, |
| 10447 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 10448 | if (ret <= 0) |
| 10449 | { |
| 10450 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 10451 | FL("wait on disconnect_comp_var failed %ld"), ret); |
| 10452 | } |
| 10453 | } |
Sachin Ahuja | 27dd240 | 2016-08-01 20:30:31 +0530 | [diff] [blame] | 10454 | if(pScanInfo != NULL && pHddCtx->scan_info.mScanPending) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10455 | { |
Mahesh A Saptasagar | 0b61dcc | 2016-02-15 14:23:38 +0530 | [diff] [blame] | 10456 | wlan_hdd_scan_abort(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10457 | } |
Abhishek Singh | 3ac179b | 2015-09-21 10:01:34 +0530 | [diff] [blame] | 10458 | if ((pAdapter->device_mode != WLAN_HDD_INFRA_STATION) && |
| 10459 | (pAdapter->device_mode != WLAN_HDD_IBSS)) |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 10460 | { |
| 10461 | while (pAdapter->is_roc_inprogress) |
| 10462 | { |
| 10463 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10464 | "%s: ROC in progress for session %d!!!", |
| 10465 | __func__, pAdapter->sessionId); |
| 10466 | // waiting for ROC to expire |
| 10467 | msleep(500); |
| 10468 | /* In GO present case , if retry exceeds 3, |
| 10469 | it means something went wrong. */ |
| 10470 | if ( retry++ > MAX_WAIT_FOR_ROC_COMPLETION ) |
| 10471 | { |
| 10472 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10473 | "%s: ROC completion is not received.!!!", __func__); |
Deepthi Gowri | 7049825 | 2015-01-20 15:56:45 +0530 | [diff] [blame] | 10474 | if (eHAL_STATUS_SUCCESS != |
| 10475 | sme_CancelRemainOnChannel( WLAN_HDD_GET_HAL_CTX( pAdapter), |
| 10476 | pAdapter->sessionId )) |
| 10477 | { |
| 10478 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10479 | FL("Failed to Cancel Remain on Channel")); |
| 10480 | } |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 10481 | wait_for_completion_interruptible_timeout( |
| 10482 | &pAdapter->cancel_rem_on_chan_var, |
| 10483 | msecs_to_jiffies(WAIT_CANCEL_REM_CHAN)); |
| 10484 | break; |
| 10485 | } |
| 10486 | } |
Anand N Sunkad | dc63c79 | 2015-06-03 14:33:24 +0530 | [diff] [blame] | 10487 | vos_flush_delayed_work(&pAdapter->roc_work); |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 10488 | } |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 10489 | #ifdef WLAN_NS_OFFLOAD |
Anand N Sunkad | dc63c79 | 2015-06-03 14:33:24 +0530 | [diff] [blame] | 10490 | vos_flush_work(&pAdapter->ipv6NotifierWorkQueue); |
Vinay Krishna Eranna | d5b2be2 | 2013-12-01 17:00:15 +0530 | [diff] [blame] | 10491 | #endif |
Vinay Krishna Eranna | f97ef5c | 2014-12-26 17:47:19 +0530 | [diff] [blame] | 10492 | |
Anand N Sunkad | dc63c79 | 2015-06-03 14:33:24 +0530 | [diff] [blame] | 10493 | vos_flush_work(&pAdapter->ipv4NotifierWorkQueue); |
Vinay Krishna Eranna | f97ef5c | 2014-12-26 17:47:19 +0530 | [diff] [blame] | 10494 | |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 10495 | /* It is possible that the caller of this function does not |
| 10496 | * wish to close the session |
| 10497 | */ |
| 10498 | if (VOS_TRUE == bCloseSession && |
| 10499 | test_bit(SME_SESSION_OPENED, &pAdapter->event_flags)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10500 | { |
| 10501 | INIT_COMPLETION(pAdapter->session_close_comp_var); |
| 10502 | if (eHAL_STATUS_SUCCESS == |
Agrawal Ashish | 5a3522c | 2016-03-02 15:08:28 +0530 | [diff] [blame] | 10503 | sme_CloseSession(pHddCtx->hHal, pAdapter->sessionId, FALSE, |
| 10504 | VOS_FALSE, hdd_smeCloseSessionCallback, pAdapter)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10505 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 10506 | unsigned long ret; |
| 10507 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10508 | //Block on a completion variable. Can't wait forever though. |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 10509 | ret = wait_for_completion_timeout( |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 10510 | &pAdapter->session_close_comp_var, |
| 10511 | msecs_to_jiffies(WLAN_WAIT_TIME_SESSIONOPENCLOSE)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 10512 | if ( 0 >= ret) |
| 10513 | { |
| 10514 | hddLog(LOGE, "%s: failure waiting for session_close_comp_var %ld", |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 10515 | __func__, ret); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 10516 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10517 | } |
| 10518 | } |
Vinay Krishna Eranna | b09d3e7 | 2014-03-26 21:23:55 +0530 | [diff] [blame] | 10519 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10520 | break; |
| 10521 | |
| 10522 | case WLAN_HDD_SOFTAP: |
Abhishek Singh | 3dc4c97 | 2019-05-09 11:04:24 +0530 | [diff] [blame] | 10523 | /* Delete all associated STAs before stopping AP */ |
| 10524 | if (test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags)) |
| 10525 | hdd_del_all_sta(pAdapter); |
| 10526 | /* Fall through */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10527 | case WLAN_HDD_P2P_GO: |
Abhishek Singh | 3dc4c97 | 2019-05-09 11:04:24 +0530 | [diff] [blame] | 10528 | |
Nirav Shah | 0cf4d89 | 2015-11-05 16:27:27 +0530 | [diff] [blame] | 10529 | if ( VOS_TRUE == bCloseSession ) |
| 10530 | { |
| 10531 | status = hdd_sta_id_hash_detach(pAdapter); |
| 10532 | if (status != VOS_STATUS_SUCCESS) |
| 10533 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 10534 | FL("sta id hash detach failed")); |
| 10535 | } |
| 10536 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10537 | //Any softap specific cleanup here... |
Anurag Chouhan | 8302600 | 2016-12-13 22:46:21 +0530 | [diff] [blame] | 10538 | hdd_cleanup_ap_events(pAdapter); |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 10539 | if (pAdapter->device_mode == WLAN_HDD_P2P_GO) { |
| 10540 | while (pAdapter->is_roc_inprogress) { |
| 10541 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10542 | "%s: ROC in progress for session %d!!!", |
| 10543 | __func__, pAdapter->sessionId); |
| 10544 | msleep(500); |
| 10545 | if ( retry++ > MAX_WAIT_FOR_ROC_COMPLETION ) { |
| 10546 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10547 | "%s: ROC completion is not received.!!!", __func__); |
| 10548 | WLANSAP_CancelRemainOnChannel( |
| 10549 | (WLAN_HDD_GET_CTX(pAdapter))->pvosContext); |
| 10550 | wait_for_completion_interruptible_timeout( |
| 10551 | &pAdapter->cancel_rem_on_chan_var, |
| 10552 | msecs_to_jiffies(WAIT_CANCEL_REM_CHAN)); |
| 10553 | break; |
| 10554 | } |
| 10555 | } |
Ganesh Kondabattini | babfb49 | 2014-12-17 20:25:29 +0530 | [diff] [blame] | 10556 | |
Anand N Sunkad | dc63c79 | 2015-06-03 14:33:24 +0530 | [diff] [blame] | 10557 | vos_flush_delayed_work(&pAdapter->roc_work); |
Kaushik, Sushant | 7005e37 | 2014-04-08 11:36:54 +0530 | [diff] [blame] | 10558 | } |
Agrawal Ashish | 17ef508 | 2016-10-17 18:33:21 +0530 | [diff] [blame] | 10559 | #ifdef SAP_AUTH_OFFLOAD |
| 10560 | if (pHddCtx->cfg_ini->enable_sap_auth_offload) |
| 10561 | hdd_set_sap_auth_offload(pAdapter, FALSE); |
| 10562 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10563 | mutex_lock(&pHddCtx->sap_lock); |
| 10564 | if (test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags)) |
| 10565 | { |
| 10566 | VOS_STATUS status; |
| 10567 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Hanumanth Reddy Pothula | 74ba68c | 2018-06-22 17:52:09 +0530 | [diff] [blame] | 10568 | hdd_hostapd_state_t *pHostapdState = |
| 10569 | WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10570 | |
Hanumanth Reddy Pothula | 74ba68c | 2018-06-22 17:52:09 +0530 | [diff] [blame] | 10571 | vos_event_reset(&pHostapdState->vosEvent); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10572 | //Stop Bss. |
| 10573 | status = WLANSAP_StopBss(pHddCtx->pvosContext); |
| 10574 | if (VOS_IS_STATUS_SUCCESS(status)) |
| 10575 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10576 | status = vos_wait_single_event(&pHostapdState->vosEvent, 10000); |
| 10577 | |
| 10578 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 10579 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 10580 | hddLog(LOGE, "%s: failure waiting for WLANSAP_StopBss %d", |
| 10581 | __func__, status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10582 | } |
| 10583 | } |
| 10584 | else |
| 10585 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 10586 | hddLog(LOGE, "%s: failure in WLANSAP_StopBss", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10587 | } |
| 10588 | clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags); |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 10589 | wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10590 | |
| 10591 | if (eHAL_STATUS_FAILURE == |
| 10592 | ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, |
| 10593 | 0, NULL, eANI_BOOLEAN_FALSE)) |
| 10594 | { |
| 10595 | hddLog(LOGE, |
| 10596 | "%s: Failed to set WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 10597 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10598 | } |
| 10599 | |
| 10600 | if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal, |
| 10601 | WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL, |
| 10602 | eANI_BOOLEAN_FALSE) ) |
| 10603 | { |
| 10604 | hddLog(LOGE, |
| 10605 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM"); |
| 10606 | } |
| 10607 | |
| 10608 | // Reset WNI_CFG_PROBE_RSP Flags |
| 10609 | wlan_hdd_reset_prob_rspies(pAdapter); |
| 10610 | kfree(pAdapter->sessionCtx.ap.beacon); |
| 10611 | pAdapter->sessionCtx.ap.beacon = NULL; |
| 10612 | } |
| 10613 | mutex_unlock(&pHddCtx->sap_lock); |
Hanumanth Reddy Pothula | b4537b8 | 2018-03-02 12:20:38 +0530 | [diff] [blame] | 10614 | |
| 10615 | #ifdef WLAN_NS_OFFLOAD |
| 10616 | vos_flush_work(&pAdapter->ipv6NotifierWorkQueue); |
| 10617 | #endif |
| 10618 | vos_flush_work(&pAdapter->ipv4NotifierWorkQueue); |
| 10619 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10620 | break; |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 10621 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10622 | case WLAN_HDD_MONITOR: |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 10623 | if (VOS_MONITOR_MODE != hdd_get_conparam()) |
| 10624 | wlan_hdd_stop_mon(pHddCtx, true); |
| 10625 | break; |
Sameer Thalappil | bee426e | 2013-10-30 10:30:30 -0700 | [diff] [blame] | 10626 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10627 | default: |
| 10628 | break; |
| 10629 | } |
| 10630 | |
| 10631 | EXIT(); |
| 10632 | return VOS_STATUS_SUCCESS; |
| 10633 | } |
| 10634 | |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 10635 | /** |
| 10636 | * wlan_hdd_restart_sap() - to restart SAP in driver internally |
| 10637 | * @ap_adapter: - Pointer to SAP hdd_adapter_t structure |
| 10638 | * |
| 10639 | * wlan_hdd_restart_sap first delete SAP and do cleanup. |
| 10640 | * After that WLANSAP_StartBss start re-start process of SAP. |
| 10641 | * |
| 10642 | * Return: None |
| 10643 | */ |
| 10644 | static void wlan_hdd_restart_sap(hdd_adapter_t *ap_adapter) |
| 10645 | { |
| 10646 | hdd_ap_ctx_t *pHddApCtx; |
| 10647 | hdd_hostapd_state_t *pHostapdState; |
| 10648 | VOS_STATUS vos_status; |
| 10649 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(ap_adapter); |
Rajeev Kumar Sirasanagandla | 5b21a9c | 2018-01-08 17:05:11 +0530 | [diff] [blame] | 10650 | #ifdef USE_CFG80211_DEL_STA_V2 |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 10651 | struct station_del_parameters delStaParams; |
| 10652 | #endif |
| 10653 | tsap_Config_t *pConfig; |
| 10654 | |
| 10655 | pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 10656 | pConfig = &pHddApCtx->sapConfig; |
| 10657 | |
| 10658 | mutex_lock(&pHddCtx->sap_lock); |
| 10659 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
Rajeev Kumar Sirasanagandla | 5b21a9c | 2018-01-08 17:05:11 +0530 | [diff] [blame] | 10660 | #ifdef USE_CFG80211_DEL_STA_V2 |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 10661 | delStaParams.mac = NULL; |
| 10662 | delStaParams.subtype = SIR_MAC_MGMT_DEAUTH >> 4; |
| 10663 | delStaParams.reason_code = eCsrForcedDeauthSta; |
| 10664 | wlan_hdd_cfg80211_del_station(ap_adapter->wdev.wiphy, ap_adapter->dev, |
| 10665 | &delStaParams); |
| 10666 | #else |
| 10667 | wlan_hdd_cfg80211_del_station(ap_adapter->wdev.wiphy, ap_adapter->dev, |
| 10668 | NULL); |
| 10669 | #endif |
| 10670 | hdd_cleanup_actionframe(pHddCtx, ap_adapter); |
| 10671 | |
| 10672 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
| 10673 | vos_event_reset(&pHostapdState->vosEvent); |
| 10674 | |
| 10675 | if (VOS_STATUS_SUCCESS == WLANSAP_StopBss(pHddCtx->pvosContext)) { |
| 10676 | vos_status = vos_wait_single_event(&pHostapdState->vosEvent, |
| 10677 | 10000); |
| 10678 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) { |
| 10679 | hddLog(LOGE, FL("SAP Stop Failed")); |
| 10680 | goto end; |
| 10681 | } |
| 10682 | } |
| 10683 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
| 10684 | wlan_hdd_decr_active_session(pHddCtx, ap_adapter->device_mode); |
| 10685 | hddLog(LOG1, FL("SAP Stop Success")); |
| 10686 | |
| 10687 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
| 10688 | hddLog(LOGE, FL("SAP Not able to set AP IEs")); |
| 10689 | goto end; |
| 10690 | } |
| 10691 | |
Hanumanth Reddy Pothula | 74ba68c | 2018-06-22 17:52:09 +0530 | [diff] [blame] | 10692 | vos_event_reset(&pHostapdState->vosEvent); |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 10693 | if (WLANSAP_StartBss(pHddCtx->pvosContext, hdd_hostapd_SAPEventCB, |
| 10694 | pConfig, (v_PVOID_t)ap_adapter->dev) != VOS_STATUS_SUCCESS) { |
| 10695 | hddLog(LOGE, FL("SAP Start Bss fail")); |
| 10696 | goto end; |
| 10697 | } |
| 10698 | |
| 10699 | hddLog(LOG1, FL("Waiting for SAP to start")); |
| 10700 | vos_status = vos_wait_single_event(&pHostapdState->vosEvent, 10000); |
| 10701 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) { |
| 10702 | hddLog(LOGE, FL("SAP Start failed")); |
| 10703 | goto end; |
| 10704 | } |
| 10705 | hddLog(LOG1, FL("SAP Start Success")); |
| 10706 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
| 10707 | wlan_hdd_incr_active_session(pHddCtx, ap_adapter->device_mode); |
| 10708 | pHostapdState->bCommit = TRUE; |
Anurag Chouhan | b2951ae | 2017-03-12 13:41:35 +0530 | [diff] [blame] | 10709 | if (!VOS_IS_STATUS_SUCCESS(hdd_dhcp_mdns_offload(ap_adapter))) { |
| 10710 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("DHCP/MDNS offload Failed!!")); |
| 10711 | vos_event_reset(&pHostapdState->vosEvent); |
| 10712 | if (VOS_STATUS_SUCCESS == WLANSAP_StopBss(pHddCtx->pvosContext)) { |
| 10713 | vos_status = vos_wait_single_event(&pHostapdState->vosEvent, |
| 10714 | 10000); |
| 10715 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) { |
| 10716 | hddLog(LOGE, FL("SAP Stop Failed")); |
| 10717 | goto end; |
| 10718 | } |
| 10719 | } |
| 10720 | } |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 10721 | } |
| 10722 | end: |
| 10723 | mutex_unlock(&pHddCtx->sap_lock); |
| 10724 | return; |
| 10725 | } |
| 10726 | |
| 10727 | /** |
| 10728 | * __hdd_sap_restart_handle() - to handle restarting of SAP |
| 10729 | * @work: name of the work |
| 10730 | * |
| 10731 | * Purpose of this function is to trigger sap start. this function |
| 10732 | * will be called from workqueue. |
| 10733 | * |
| 10734 | * Return: void. |
| 10735 | */ |
| 10736 | static void __hdd_sap_restart_handle(struct work_struct *work) |
| 10737 | { |
| 10738 | hdd_adapter_t *sap_adapter; |
| 10739 | hdd_context_t *hdd_ctx = container_of(work, |
| 10740 | hdd_context_t, |
| 10741 | sap_start_work); |
| 10742 | if (0 != wlan_hdd_validate_context(hdd_ctx)) { |
| 10743 | vos_ssr_unprotect(__func__); |
| 10744 | return; |
| 10745 | } |
| 10746 | sap_adapter = hdd_get_adapter(hdd_ctx, |
| 10747 | WLAN_HDD_SOFTAP); |
| 10748 | if (sap_adapter == NULL) { |
| 10749 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 10750 | FL("sap_adapter is NULL")); |
| 10751 | vos_ssr_unprotect(__func__); |
| 10752 | return; |
| 10753 | } |
| 10754 | |
| 10755 | if (hdd_ctx->is_ch_avoid_in_progress) { |
| 10756 | sap_adapter->sessionCtx.ap.sapConfig.channel = AUTO_CHANNEL_SELECT; |
| 10757 | wlan_hdd_restart_sap(sap_adapter); |
| 10758 | hdd_change_ch_avoidance_status(hdd_ctx, false); |
| 10759 | } |
Agrawal Ashish | 574b3e6 | 2017-02-09 18:58:34 +0530 | [diff] [blame] | 10760 | if (hdd_ctx->cfg_ini->enable_sap_auth_offload) |
| 10761 | wlan_hdd_restart_sap(sap_adapter); |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 10762 | } |
| 10763 | |
| 10764 | /** |
| 10765 | * hdd_sap_restart_handle() - to handle restarting of SAP |
| 10766 | * @work: name of the work |
| 10767 | * |
| 10768 | * Purpose of this function is to trigger sap start. this function |
| 10769 | * will be called from workqueue. |
| 10770 | * |
| 10771 | * Return: void. |
| 10772 | */ |
| 10773 | static void hdd_sap_restart_handle(struct work_struct *work) |
| 10774 | { |
| 10775 | vos_ssr_protect(__func__); |
| 10776 | __hdd_sap_restart_handle(work); |
| 10777 | vos_ssr_unprotect(__func__); |
| 10778 | } |
| 10779 | |
| 10780 | |
Abhishek Singh | 78c691f | 2017-11-30 13:48:44 +0530 | [diff] [blame] | 10781 | /** |
| 10782 | * __hdd_force_scc_with_ecsa_handle() - to handle force scc using ecsa |
| 10783 | * @work: name of the work |
| 10784 | * |
| 10785 | * Purpose of this function is to force SCC using ECSA. This function |
| 10786 | * will be called from workqueue. |
| 10787 | * |
| 10788 | * Return: void. |
| 10789 | */ |
| 10790 | static void |
| 10791 | __hdd_force_scc_with_ecsa_handle(struct work_struct *work) |
| 10792 | { |
| 10793 | hdd_adapter_t *sap_adapter; |
| 10794 | hdd_station_ctx_t *sta_ctx; |
| 10795 | hdd_adapter_t *sta_adapter; |
Ganesh Kondabattini | 3655a6d | 2018-01-08 20:25:39 +0530 | [diff] [blame] | 10796 | ptSapContext sap_ctx = NULL; |
| 10797 | v_CONTEXT_t vos_ctx; |
| 10798 | tANI_U8 target_channel; |
| 10799 | tsap_Config_t *sap_config; |
| 10800 | bool sta_sap_scc_on_dfs_chan; |
| 10801 | eNVChannelEnabledType chan_state; |
Abhishek Singh | 78c691f | 2017-11-30 13:48:44 +0530 | [diff] [blame] | 10802 | hdd_context_t *hdd_ctx = container_of(to_delayed_work(work), |
| 10803 | hdd_context_t, |
| 10804 | ecsa_chan_change_work); |
| 10805 | |
| 10806 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 10807 | return; |
| 10808 | |
| 10809 | sap_adapter = hdd_get_adapter(hdd_ctx, |
| 10810 | WLAN_HDD_SOFTAP); |
| 10811 | if (!sap_adapter) { |
| 10812 | hddLog(LOGE, FL("sap_adapter is NULL")); |
| 10813 | return; |
| 10814 | } |
| 10815 | |
Ganesh Kondabattini | 3655a6d | 2018-01-08 20:25:39 +0530 | [diff] [blame] | 10816 | vos_ctx = hdd_ctx->pvosContext; |
| 10817 | if (!vos_ctx) { |
| 10818 | hddLog(LOGE, FL("vos_ctx is NULL")); |
| 10819 | return; |
| 10820 | } |
| 10821 | |
| 10822 | sap_ctx = VOS_GET_SAP_CB(vos_ctx); |
| 10823 | if (!sap_ctx) { |
| 10824 | hddLog(LOGE, FL("sap_ctx is NULL")); |
| 10825 | return; |
| 10826 | } |
| 10827 | |
| 10828 | sap_config = &sap_adapter->sessionCtx.ap.sapConfig; |
| 10829 | |
| 10830 | sta_sap_scc_on_dfs_chan = hdd_is_sta_sap_scc_allowed_on_dfs_chan(hdd_ctx); |
| 10831 | |
Abhishek Singh | 78c691f | 2017-11-30 13:48:44 +0530 | [diff] [blame] | 10832 | sta_adapter = hdd_get_adapter(hdd_ctx, |
| 10833 | WLAN_HDD_INFRA_STATION); |
| 10834 | if (!sta_adapter) { |
| 10835 | hddLog(LOGE, FL("sta_adapter is NULL")); |
| 10836 | return; |
| 10837 | } |
Abhishek Singh | 78c691f | 2017-11-30 13:48:44 +0530 | [diff] [blame] | 10838 | |
Abhishek Singh | 10e17cf | 2018-03-12 14:34:22 +0530 | [diff] [blame] | 10839 | if (wlansap_chk_n_set_chan_change_in_progress(sap_ctx)) |
Abhishek Singh | 78c691f | 2017-11-30 13:48:44 +0530 | [diff] [blame] | 10840 | return; |
Abhishek Singh | 10e17cf | 2018-03-12 14:34:22 +0530 | [diff] [blame] | 10841 | INIT_COMPLETION(sap_ctx->ecsa_info.chan_switch_comp); |
| 10842 | |
| 10843 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(sta_adapter); |
| 10844 | if (sta_ctx->conn_info.connState != eConnectionState_Associated) { |
| 10845 | if (sta_ctx->conn_info.connState == eConnectionState_NotConnected) { |
| 10846 | chan_state = vos_nv_getChannelEnabledState(sap_ctx->channel); |
| 10847 | hddLog(LOG1, FL("sta not in connected state %d, sta_sap_scc_on_dfs_chan %d, chan_state %d"), |
| 10848 | sta_ctx->conn_info.connState, sta_sap_scc_on_dfs_chan, |
| 10849 | chan_state); |
| 10850 | if (sta_sap_scc_on_dfs_chan && |
| 10851 | (chan_state == NV_CHANNEL_DFS)) { |
| 10852 | hddLog(LOGE, FL("Switch SAP to user configured channel")); |
| 10853 | target_channel = sap_config->user_config_channel; |
| 10854 | goto switch_channel; |
| 10855 | } |
| 10856 | } |
| 10857 | goto abort; |
Abhishek Singh | 78c691f | 2017-11-30 13:48:44 +0530 | [diff] [blame] | 10858 | } |
| 10859 | |
Ganesh Kondabattini | 3655a6d | 2018-01-08 20:25:39 +0530 | [diff] [blame] | 10860 | target_channel = sta_ctx->conn_info.operationChannel; |
| 10861 | switch_channel: |
| 10862 | hddLog(LOGE, FL("Switch SAP to %d channel"), |
| 10863 | target_channel); |
Abhishek Singh | 10e17cf | 2018-03-12 14:34:22 +0530 | [diff] [blame] | 10864 | if (!wlansap_set_channel_change(vos_ctx, target_channel, true)) |
| 10865 | return; |
| 10866 | |
| 10867 | abort: |
| 10868 | wlansap_reset_chan_change_in_progress(sap_ctx); |
| 10869 | complete(&sap_ctx->ecsa_info.chan_switch_comp); |
Abhishek Singh | 78c691f | 2017-11-30 13:48:44 +0530 | [diff] [blame] | 10870 | } |
| 10871 | |
| 10872 | /** |
| 10873 | * hdd_force_scc_with_ecsa_handle() - to handle force scc using ecsa |
| 10874 | * @work: name of the work |
| 10875 | * |
| 10876 | * Purpose of this function is to force SCC using ECSA. This function |
| 10877 | * will be called from workqueue. |
| 10878 | * |
| 10879 | * Return: void. |
| 10880 | */ |
| 10881 | static void |
| 10882 | hdd_force_scc_with_ecsa_handle(struct work_struct *work) |
| 10883 | { |
| 10884 | vos_ssr_protect(__func__); |
| 10885 | __hdd_force_scc_with_ecsa_handle(work); |
| 10886 | vos_ssr_unprotect(__func__); |
| 10887 | } |
| 10888 | |
Abhishek Singh | 10e17cf | 2018-03-12 14:34:22 +0530 | [diff] [blame] | 10889 | int hdd_wait_for_ecsa_complete(hdd_context_t *hdd_ctx) |
| 10890 | { |
| 10891 | int ret; |
| 10892 | ptSapContext sap_ctx = NULL; |
| 10893 | v_CONTEXT_t vos_ctx; |
| 10894 | |
| 10895 | vos_ctx = hdd_ctx->pvosContext; |
| 10896 | if (!vos_ctx) { |
| 10897 | hddLog(LOGE, FL("vos_ctx is NULL")); |
| 10898 | return 0; |
| 10899 | } |
| 10900 | |
| 10901 | sap_ctx = VOS_GET_SAP_CB(vos_ctx); |
| 10902 | if (!sap_ctx) { |
| 10903 | hddLog(LOG1, FL("sap_ctx is NULL")); |
| 10904 | return 0; |
| 10905 | } |
| 10906 | if(!sap_ctx->isSapSessionOpen) { |
| 10907 | hddLog(LOG1, FL("sap session not opened, SAP in state %d"), |
| 10908 | sap_ctx->sapsMachine); |
| 10909 | return 0; |
| 10910 | } |
| 10911 | |
| 10912 | if (!wlansap_get_change_in_progress(sap_ctx)) { |
| 10913 | hddLog(LOG1, FL("channel switch not in progress")); |
| 10914 | return 0; |
| 10915 | } |
| 10916 | ret = wait_for_completion_timeout(&sap_ctx->ecsa_info.chan_switch_comp, |
| 10917 | msecs_to_jiffies(HDD_SAP_CHAN_CNG_WAIT_TIME)); |
| 10918 | if (!ret) |
| 10919 | { |
| 10920 | hddLog(LOGE, FL("Timeout waiting for SAP channel switch")); |
| 10921 | return ret; |
| 10922 | } |
| 10923 | |
| 10924 | return 0; |
| 10925 | } |
| 10926 | |
| 10927 | |
Ganesh Kondabattini | 3655a6d | 2018-01-08 20:25:39 +0530 | [diff] [blame] | 10928 | /** |
| 10929 | * hdd_is_sta_sap_scc_allowed_on_dfs_chan() - check if sta+sap scc allowed on |
| 10930 | * dfs chan |
| 10931 | * @hdd_ctx: pointer to hdd context |
| 10932 | * |
| 10933 | * This function used to check if sta+sap scc allowed on DFS channel. |
| 10934 | * |
| 10935 | * Return: None |
| 10936 | */ |
| 10937 | bool hdd_is_sta_sap_scc_allowed_on_dfs_chan(hdd_context_t *hdd_ctx) |
| 10938 | { |
| 10939 | if (hdd_ctx->cfg_ini->force_scc_with_ecsa && |
| 10940 | hdd_ctx->cfg_ini->sta_sap_scc_on_dfs_chan) |
| 10941 | return true; |
| 10942 | else |
| 10943 | return false; |
| 10944 | } |
| 10945 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10946 | VOS_STATUS hdd_stop_all_adapters( hdd_context_t *pHddCtx ) |
| 10947 | { |
| 10948 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 10949 | VOS_STATUS status; |
| 10950 | hdd_adapter_t *pAdapter; |
| 10951 | |
| 10952 | ENTER(); |
| 10953 | |
| 10954 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 10955 | |
| 10956 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 10957 | { |
| 10958 | pAdapter = pAdapterNode->pAdapter; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10959 | |
Agarwal Ashish | 3a38bd1 | 2014-06-12 15:16:52 +0530 | [diff] [blame] | 10960 | hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 10961 | |
| 10962 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 10963 | pAdapterNode = pNext; |
| 10964 | } |
| 10965 | |
| 10966 | EXIT(); |
| 10967 | |
| 10968 | return VOS_STATUS_SUCCESS; |
| 10969 | } |
| 10970 | |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 10971 | |
| 10972 | #ifdef FEATURE_WLAN_BATCH_SCAN |
| 10973 | /**--------------------------------------------------------------------------- |
| 10974 | |
| 10975 | \brief hdd_deinit_batch_scan () - This function cleans up batch scan data |
| 10976 | structures |
| 10977 | |
| 10978 | \param - pAdapter Pointer to HDD adapter |
| 10979 | |
| 10980 | \return - None |
| 10981 | |
| 10982 | --------------------------------------------------------------------------*/ |
| 10983 | void hdd_deinit_batch_scan(hdd_adapter_t *pAdapter) |
| 10984 | { |
| 10985 | tHddBatchScanRsp *pNode; |
| 10986 | tHddBatchScanRsp *pPrev; |
| 10987 | |
Siddharth Bhal | b3e9b79 | 2014-02-24 15:14:16 +0530 | [diff] [blame] | 10988 | if (NULL == pAdapter) |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 10989 | { |
Siddharth Bhal | b3e9b79 | 2014-02-24 15:14:16 +0530 | [diff] [blame] | 10990 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 10991 | "%s: Adapter context is Null", __func__); |
| 10992 | return; |
| 10993 | } |
| 10994 | |
| 10995 | pNode = pAdapter->pBatchScanRsp; |
| 10996 | while (pNode) |
| 10997 | { |
| 10998 | pPrev = pNode; |
| 10999 | pNode = pNode->pNext; |
| 11000 | vos_mem_free((v_VOID_t * )pPrev); |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 11001 | } |
| 11002 | |
| 11003 | pAdapter->pBatchScanRsp = NULL; |
| 11004 | pAdapter->numScanList = 0; |
| 11005 | pAdapter->batchScanState = eHDD_BATCH_SCAN_STATE_STOPPED; |
| 11006 | pAdapter->prev_batch_id = 0; |
| 11007 | |
| 11008 | return; |
| 11009 | } |
| 11010 | #endif |
| 11011 | |
| 11012 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11013 | VOS_STATUS hdd_reset_all_adapters( hdd_context_t *pHddCtx ) |
| 11014 | { |
| 11015 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 11016 | VOS_STATUS status; |
| 11017 | hdd_adapter_t *pAdapter; |
| 11018 | |
| 11019 | ENTER(); |
| 11020 | |
| 11021 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 11022 | |
| 11023 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 11024 | { |
| 11025 | pAdapter = pAdapterNode->pAdapter; |
Padma, Santhosh Kumar | 9dacb5c | 2014-12-17 19:22:56 +0530 | [diff] [blame] | 11026 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11027 | netif_tx_disable(pAdapter->dev); |
Hanumanth Reddy Pothula | d864f31 | 2017-01-18 16:16:08 +0530 | [diff] [blame] | 11028 | |
| 11029 | if (pHddCtx->cfg_ini->sap_internal_restart && |
| 11030 | pAdapter->device_mode == WLAN_HDD_SOFTAP) { |
| 11031 | hddLog(LOG1, FL("driver supports sap restart")); |
| 11032 | vos_flush_work(&pHddCtx->sap_start_work); |
| 11033 | hdd_sap_indicate_disconnect_for_sta(pAdapter); |
| 11034 | hdd_cleanup_actionframe(pHddCtx, pAdapter); |
Hanumanth Reddy Pothula | 15bc0fa | 2017-02-03 17:24:17 +0530 | [diff] [blame] | 11035 | hdd_softap_deinit_tx_rx(pAdapter, true); |
| 11036 | hdd_sap_destroy_timers(pAdapter); |
Hanumanth Reddy Pothula | d864f31 | 2017-01-18 16:16:08 +0530 | [diff] [blame] | 11037 | } else { |
| 11038 | netif_carrier_off(pAdapter->dev); |
| 11039 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11040 | |
Srinivas Girigowda | 66c05eb | 2013-07-14 13:06:01 -0700 | [diff] [blame] | 11041 | pAdapter->sessionCtx.station.hdd_ReassocScenario = VOS_FALSE; |
Hanumanth Reddy Pothula | da449f1 | 2018-03-13 18:19:19 +0530 | [diff] [blame] | 11042 | |
| 11043 | if (pAdapter->device_mode == WLAN_HDD_MONITOR) |
| 11044 | pAdapter->sessionCtx.monitor.state = MON_MODE_STOP; |
Srinivas Girigowda | 66c05eb | 2013-07-14 13:06:01 -0700 | [diff] [blame] | 11045 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11046 | hdd_deinit_tx_rx(pAdapter); |
Agarwal Ashish | 6267caa | 2014-08-06 19:16:21 +0530 | [diff] [blame] | 11047 | |
Katya Nigam | 1fd2440 | 2015-02-16 14:52:19 +0530 | [diff] [blame] | 11048 | if(pAdapter->device_mode == WLAN_HDD_IBSS ) |
| 11049 | hdd_ibss_deinit_tx_rx(pAdapter); |
| 11050 | |
Nirav Shah | 7e3c813 | 2015-06-22 23:51:42 +0530 | [diff] [blame] | 11051 | status = hdd_sta_id_hash_detach(pAdapter); |
| 11052 | if (status != VOS_STATUS_SUCCESS) |
| 11053 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 11054 | FL("sta id hash detach failed for session id %d"), |
| 11055 | pAdapter->sessionId); |
| 11056 | |
Agarwal Ashish | 6267caa | 2014-08-06 19:16:21 +0530 | [diff] [blame] | 11057 | wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode); |
| 11058 | |
Madan Mohan Koyyalamudi | 8c6dec8 | 2013-09-26 15:56:13 +0530 | [diff] [blame] | 11059 | if (test_bit(WMM_INIT_DONE, &pAdapter->event_flags)) |
| 11060 | { |
| 11061 | hdd_wmm_adapter_close( pAdapter ); |
| 11062 | clear_bit(WMM_INIT_DONE, &pAdapter->event_flags); |
| 11063 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11064 | |
Siddharth Bhal | 2db319d | 2014-12-03 12:37:18 +0530 | [diff] [blame] | 11065 | if (test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags)) |
| 11066 | { |
| 11067 | clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags); |
| 11068 | } |
| 11069 | |
Rajeev Kumar | f999e58 | 2014-01-09 17:33:29 -0800 | [diff] [blame] | 11070 | #ifdef FEATURE_WLAN_BATCH_SCAN |
| 11071 | if (eHDD_BATCH_SCAN_STATE_STARTED == pAdapter->batchScanState) |
| 11072 | { |
| 11073 | hdd_deinit_batch_scan(pAdapter); |
| 11074 | } |
| 11075 | #endif |
| 11076 | |
Mahesh A Saptasagar | f5b8eff | 2015-01-31 01:07:07 +0530 | [diff] [blame] | 11077 | #ifdef FEATURE_WLAN_TDLS |
| 11078 | mutex_lock(&pHddCtx->tdls_lock); |
Pradeep Reddy POTTETI | 2d4d5c4 | 2015-03-03 14:34:19 +0530 | [diff] [blame] | 11079 | wlan_hdd_tdls_exit(pAdapter, TRUE); |
Mahesh A Saptasagar | f5b8eff | 2015-01-31 01:07:07 +0530 | [diff] [blame] | 11080 | mutex_unlock(&pHddCtx->tdls_lock); |
| 11081 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11082 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 11083 | pAdapterNode = pNext; |
| 11084 | } |
| 11085 | |
| 11086 | EXIT(); |
| 11087 | |
| 11088 | return VOS_STATUS_SUCCESS; |
| 11089 | } |
| 11090 | |
Abhishek Singh | bbe0b2a | 2016-12-05 11:57:36 +0530 | [diff] [blame] | 11091 | /** |
Abhishek Singh | 5a597e6 | 2016-12-05 15:16:30 +0530 | [diff] [blame] | 11092 | * hdd_get_bss_entry() - Get the bss entry matching the chan, bssid and ssid |
| 11093 | * @wiphy: wiphy |
| 11094 | * @channel: channel of the BSS to find |
| 11095 | * @bssid: bssid of the BSS to find |
| 11096 | * @ssid: ssid of the BSS to find |
| 11097 | * @ssid_len: ssid len of of the BSS to find |
| 11098 | * |
| 11099 | * The API is a wrapper to get bss from kernel matching the chan, |
| 11100 | * bssid and ssid |
| 11101 | * |
| 11102 | * Return: Void |
| 11103 | */ |
| 11104 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)) \ |
| 11105 | && !defined(WITH_BACKPORTS) && !defined(IEEE80211_PRIVACY) |
| 11106 | |
| 11107 | struct cfg80211_bss* hdd_get_bss_entry(struct wiphy *wiphy, |
| 11108 | struct ieee80211_channel *channel, |
| 11109 | const u8 *bssid, |
| 11110 | const u8 *ssid, size_t ssid_len) |
| 11111 | { |
| 11112 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 11113 | ssid, ssid_len, |
| 11114 | WLAN_CAPABILITY_ESS, |
| 11115 | WLAN_CAPABILITY_ESS); |
| 11116 | } |
| 11117 | #else |
| 11118 | struct cfg80211_bss* hdd_get_bss_entry(struct wiphy *wiphy, |
| 11119 | struct ieee80211_channel *channel, |
| 11120 | const u8 *bssid, |
| 11121 | const u8 *ssid, size_t ssid_len) |
| 11122 | { |
| 11123 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 11124 | ssid, ssid_len, |
| 11125 | IEEE80211_BSS_TYPE_ESS, |
| 11126 | IEEE80211_PRIVACY_ANY); |
| 11127 | } |
| 11128 | #endif |
| 11129 | |
Rajeev Kumar Sirasanagandla | 5b21a9c | 2018-01-08 17:05:11 +0530 | [diff] [blame] | 11130 | #if defined(CFG80211_CONNECT_BSS) || \ |
| 11131 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)) |
| 11132 | |
| 11133 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) || \ |
| 11134 | defined (CFG80211_CONNECT_TIMEOUT_REASON_CODE) |
| 11135 | /** |
| 11136 | * hdd_connect_bss() - helper function to send connection status to supplicant |
| 11137 | * @dev: network device |
| 11138 | * @bssid: bssid to which we want to associate |
| 11139 | * @bss: information about connected bss |
| 11140 | * @req_ie: Request Information Element |
| 11141 | * @req_ie_len: len of the req IE |
| 11142 | * @resp_ie: Response IE |
| 11143 | * @resp_ie_len: len of ht response IE |
| 11144 | * @status: status |
| 11145 | * @gfp: Kernel Flag |
| 11146 | * |
| 11147 | * This is a helper function to send connection status to supplicant |
| 11148 | * and gets invoked from wrapper API |
| 11149 | * |
| 11150 | * Return: Void |
| 11151 | */ |
| 11152 | static void hdd_connect_bss(struct net_device *dev, |
| 11153 | const u8 *bssid, |
| 11154 | struct cfg80211_bss *bss, |
| 11155 | const u8 *req_ie, |
| 11156 | size_t req_ie_len, |
| 11157 | const u8 *resp_ie, |
| 11158 | size_t resp_ie_len, |
| 11159 | u16 status, |
| 11160 | gfp_t gfp) |
| 11161 | { |
| 11162 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 11163 | resp_ie, resp_ie_len, status, gfp, NL80211_TIMEOUT_UNSPECIFIED); |
| 11164 | } |
| 11165 | #else |
| 11166 | /** |
| 11167 | * hdd_connect_bss() - helper function to send connection status to supplicant |
| 11168 | * @dev: network device |
| 11169 | * @bssid: bssid to which we want to associate |
| 11170 | * @bss: information about connected bss |
| 11171 | * @req_ie: Request Information Element |
| 11172 | * @req_ie_len: len of the req IE |
| 11173 | * @resp_ie: Response IE |
| 11174 | * @resp_ie_len: len of ht response IE |
| 11175 | * @status: status |
| 11176 | * @gfp: Kernel Flag |
| 11177 | * |
| 11178 | * This is a helper function to send connection status to supplicant |
| 11179 | * and gets invoked from wrapper API |
| 11180 | * |
| 11181 | * Return: Void |
| 11182 | */ |
| 11183 | static void hdd_connect_bss(struct net_device *dev, |
| 11184 | const u8 *bssid, |
| 11185 | struct cfg80211_bss *bss, |
| 11186 | const u8 *req_ie, |
| 11187 | size_t req_ie_len, |
| 11188 | const u8 *resp_ie, |
| 11189 | size_t resp_ie_len, |
| 11190 | u16 status, |
| 11191 | gfp_t gfp) |
| 11192 | { |
| 11193 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 11194 | resp_ie, resp_ie_len, status, gfp); |
| 11195 | } |
| 11196 | #endif |
| 11197 | |
Abhishek Singh | 5a597e6 | 2016-12-05 15:16:30 +0530 | [diff] [blame] | 11198 | /** |
Abhishek Singh | bbe0b2a | 2016-12-05 11:57:36 +0530 | [diff] [blame] | 11199 | * hdd_connect_result() - API to send connection status to supplicant |
| 11200 | * @dev: network device |
| 11201 | * @bssid: bssid to which we want to associate |
| 11202 | * @roam_info: information about connected bss |
| 11203 | * @req_ie: Request Information Element |
| 11204 | * @req_ie_len: len of the req IE |
| 11205 | * @resp_ie: Response IE |
| 11206 | * @resp_ie_len: len of ht response IE |
| 11207 | * @status: status |
| 11208 | * @gfp: Kernel Flag |
| 11209 | * |
| 11210 | * The API is a wrapper to send connection status to supplicant |
| 11211 | * |
| 11212 | * Return: Void |
| 11213 | */ |
Abhishek Singh | bbe0b2a | 2016-12-05 11:57:36 +0530 | [diff] [blame] | 11214 | void hdd_connect_result(struct net_device *dev, |
| 11215 | const u8 *bssid, |
| 11216 | tCsrRoamInfo *roam_info, |
| 11217 | const u8 *req_ie, |
| 11218 | size_t req_ie_len, |
| 11219 | const u8 *resp_ie, |
| 11220 | size_t resp_ie_len, |
| 11221 | u16 status, |
| 11222 | gfp_t gfp) |
| 11223 | { |
| 11224 | hdd_adapter_t *padapter = (hdd_adapter_t *) netdev_priv(dev); |
| 11225 | struct cfg80211_bss *bss = NULL; |
| 11226 | |
| 11227 | if (WLAN_STATUS_SUCCESS == status) { |
| 11228 | struct ieee80211_channel *chan; |
| 11229 | int freq; |
| 11230 | int chan_no = roam_info->pBssDesc->channelId;; |
| 11231 | |
| 11232 | if (chan_no <= 14) |
| 11233 | freq = ieee80211_channel_to_frequency(chan_no, |
Rajeev Kumar Sirasanagandla | 5b21a9c | 2018-01-08 17:05:11 +0530 | [diff] [blame] | 11234 | HDD_NL80211_BAND_2GHZ); |
Abhishek Singh | bbe0b2a | 2016-12-05 11:57:36 +0530 | [diff] [blame] | 11235 | else |
| 11236 | freq = ieee80211_channel_to_frequency(chan_no, |
Rajeev Kumar Sirasanagandla | 5b21a9c | 2018-01-08 17:05:11 +0530 | [diff] [blame] | 11237 | HDD_NL80211_BAND_5GHZ); |
Abhishek Singh | bbe0b2a | 2016-12-05 11:57:36 +0530 | [diff] [blame] | 11238 | |
| 11239 | chan = ieee80211_get_channel(padapter->wdev.wiphy, freq); |
Abhishek Singh | 5a597e6 | 2016-12-05 15:16:30 +0530 | [diff] [blame] | 11240 | bss = hdd_get_bss_entry(padapter->wdev.wiphy, |
| 11241 | chan, bssid, |
| 11242 | roam_info->u.pConnectedProfile->SSID.ssId, |
| 11243 | roam_info->u.pConnectedProfile->SSID.length); |
Abhishek Singh | bbe0b2a | 2016-12-05 11:57:36 +0530 | [diff] [blame] | 11244 | } |
| 11245 | |
Rajeev Kumar Sirasanagandla | 5b21a9c | 2018-01-08 17:05:11 +0530 | [diff] [blame] | 11246 | hdd_connect_bss(dev, bssid, bss, req_ie, req_ie_len, resp_ie, resp_ie_len, |
| 11247 | status, gfp); |
Abhishek Singh | bbe0b2a | 2016-12-05 11:57:36 +0530 | [diff] [blame] | 11248 | } |
| 11249 | #else |
Rajeev Kumar Sirasanagandla | 5b21a9c | 2018-01-08 17:05:11 +0530 | [diff] [blame] | 11250 | /** |
| 11251 | * hdd_connect_result() - API to send connection status to supplicant |
| 11252 | * @dev: network device |
| 11253 | * @bssid: bssid to which we want to associate |
| 11254 | * @roam_info: information about connected bss |
| 11255 | * @req_ie: Request Information Element |
| 11256 | * @req_ie_len: len of the req IE |
| 11257 | * @resp_ie: Response IE |
| 11258 | * @resp_ie_len: len of ht response IE |
| 11259 | * @status: status |
| 11260 | * @gfp: Kernel Flag |
| 11261 | * |
| 11262 | * The API is a wrapper to send connection status to supplicant |
| 11263 | * |
| 11264 | * Return: Void |
| 11265 | */ |
Abhishek Singh | bbe0b2a | 2016-12-05 11:57:36 +0530 | [diff] [blame] | 11266 | void hdd_connect_result(struct net_device *dev, |
| 11267 | const u8 *bssid, |
| 11268 | tCsrRoamInfo *roam_info, |
| 11269 | const u8 *req_ie, |
| 11270 | size_t req_ie_len, |
| 11271 | const u8 * resp_ie, |
| 11272 | size_t resp_ie_len, |
| 11273 | u16 status, |
| 11274 | gfp_t gfp) |
| 11275 | { |
| 11276 | cfg80211_connect_result(dev, bssid, req_ie, req_ie_len, |
| 11277 | resp_ie, resp_ie_len, status, gfp); |
| 11278 | } |
| 11279 | #endif |
| 11280 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11281 | VOS_STATUS hdd_start_all_adapters( hdd_context_t *pHddCtx ) |
| 11282 | { |
| 11283 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 11284 | VOS_STATUS status; |
| 11285 | hdd_adapter_t *pAdapter; |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 11286 | eConnectionState connState; |
Hanumanth Reddy Pothula | da449f1 | 2018-03-13 18:19:19 +0530 | [diff] [blame] | 11287 | v_CONTEXT_t pVosContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11288 | |
| 11289 | ENTER(); |
| 11290 | |
| 11291 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 11292 | |
| 11293 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 11294 | { |
| 11295 | pAdapter = pAdapterNode->pAdapter; |
| 11296 | |
Kumar Anand | 82c009f | 2014-05-29 00:29:42 -0700 | [diff] [blame] | 11297 | hdd_wmm_init( pAdapter ); |
| 11298 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11299 | switch(pAdapter->device_mode) |
| 11300 | { |
| 11301 | case WLAN_HDD_INFRA_STATION: |
| 11302 | case WLAN_HDD_P2P_CLIENT: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 11303 | case WLAN_HDD_P2P_DEVICE: |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 11304 | |
| 11305 | connState = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState; |
| 11306 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11307 | hdd_init_station_mode(pAdapter); |
| 11308 | /* Open the gates for HDD to receive Wext commands */ |
| 11309 | pAdapter->isLinkUpSvcNeeded = FALSE; |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 11310 | pHddCtx->scan_info.mScanPending = FALSE; |
| 11311 | pHddCtx->scan_info.waitScanResult = FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11312 | |
| 11313 | //Trigger the initial scan |
Mukul Sharma | e74e42c | 2015-08-06 23:55:49 +0530 | [diff] [blame] | 11314 | if (!pHddCtx->isLogpInProgress) |
| 11315 | hdd_wlan_initial_scan(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11316 | |
| 11317 | //Indicate disconnect event to supplicant if associated previously |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 11318 | if (eConnectionState_Associated == connState || |
| 11319 | eConnectionState_IbssConnected == connState ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11320 | { |
| 11321 | union iwreq_data wrqu; |
| 11322 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 11323 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 11324 | memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN); |
| 11325 | wireless_send_event(pAdapter->dev, SIOCGIWAP, &wrqu, NULL); |
Srinivas Girigowda | 66c05eb | 2013-07-14 13:06:01 -0700 | [diff] [blame] | 11326 | pAdapter->sessionCtx.station.hdd_ReassocScenario = VOS_FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11327 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11328 | /* indicate disconnected event to nl80211 */ |
Mahesh A Saptasagar | 9ff4bcc | 2016-06-01 17:17:50 +0530 | [diff] [blame] | 11329 | wlan_hdd_cfg80211_indicate_disconnect(pAdapter->dev, false, |
Mahesh A Saptasagar | b5a1514 | 2016-05-25 11:27:43 +0530 | [diff] [blame] | 11330 | WLAN_REASON_UNSPECIFIED); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11331 | } |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 11332 | else if (eConnectionState_Connecting == connState) |
| 11333 | { |
| 11334 | /* |
| 11335 | * Indicate connect failure to supplicant if we were in the |
| 11336 | * process of connecting |
| 11337 | */ |
Abhishek Singh | bbe0b2a | 2016-12-05 11:57:36 +0530 | [diff] [blame] | 11338 | hdd_connect_result(pAdapter->dev, NULL, NULL, |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 11339 | NULL, 0, NULL, 0, |
| 11340 | WLAN_STATUS_ASSOC_DENIED_UNSPEC, |
| 11341 | GFP_KERNEL); |
| 11342 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11343 | break; |
| 11344 | |
| 11345 | case WLAN_HDD_SOFTAP: |
Hanumanth Reddy Pothula | d864f31 | 2017-01-18 16:16:08 +0530 | [diff] [blame] | 11346 | if (pHddCtx->cfg_ini->sap_internal_restart) { |
Hanumanth Reddy Pothula | 15bc0fa | 2017-02-03 17:24:17 +0530 | [diff] [blame] | 11347 | hdd_init_ap_mode(pAdapter, true); |
Hanumanth Reddy Pothula | d864f31 | 2017-01-18 16:16:08 +0530 | [diff] [blame] | 11348 | status = hdd_sta_id_hash_attach(pAdapter); |
| 11349 | if (VOS_STATUS_SUCCESS != status) |
| 11350 | { |
| 11351 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 11352 | FL("failed to attach hash for")); |
| 11353 | } |
| 11354 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11355 | break; |
| 11356 | |
| 11357 | case WLAN_HDD_P2P_GO: |
Sameer Thalappil | edf0d79 | 2013-08-09 14:31:03 -0700 | [diff] [blame] | 11358 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s [SSR] send stop ap to supplicant", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11359 | __func__); |
Sameer Thalappil | edf0d79 | 2013-08-09 14:31:03 -0700 | [diff] [blame] | 11360 | cfg80211_ap_stopped(pAdapter->dev, GFP_KERNEL); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11361 | break; |
| 11362 | |
| 11363 | case WLAN_HDD_MONITOR: |
Hanumanth Reddy Pothula | da449f1 | 2018-03-13 18:19:19 +0530 | [diff] [blame] | 11364 | pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL); |
| 11365 | |
| 11366 | hddLog(VOS_TRACE_LEVEL_INFO, FL("[SSR] monitor mode")); |
| 11367 | if (!pVosContext) { |
| 11368 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos context is NULL")); |
| 11369 | break; |
| 11370 | } |
| 11371 | |
| 11372 | hdd_init_tx_rx(pAdapter); |
| 11373 | WLANTL_SetMonRxCbk( pVosContext, hdd_rx_packet_monitor_cbk); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11374 | break; |
Hanumanth Reddy Pothula | da449f1 | 2018-03-13 18:19:19 +0530 | [diff] [blame] | 11375 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11376 | default: |
| 11377 | break; |
| 11378 | } |
| 11379 | |
| 11380 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 11381 | pAdapterNode = pNext; |
| 11382 | } |
| 11383 | |
| 11384 | EXIT(); |
| 11385 | |
| 11386 | return VOS_STATUS_SUCCESS; |
| 11387 | } |
| 11388 | |
| 11389 | VOS_STATUS hdd_reconnect_all_adapters( hdd_context_t *pHddCtx ) |
| 11390 | { |
| 11391 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 11392 | hdd_adapter_t *pAdapter; |
| 11393 | VOS_STATUS status; |
| 11394 | v_U32_t roamId; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 11395 | long ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11396 | |
| 11397 | ENTER(); |
| 11398 | |
| 11399 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 11400 | |
| 11401 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 11402 | { |
| 11403 | pAdapter = pAdapterNode->pAdapter; |
| 11404 | |
| 11405 | if( (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
| 11406 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ) |
| 11407 | { |
| 11408 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 11409 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 11410 | |
Abhishek Singh | f4669da | 2014-05-26 15:07:49 +0530 | [diff] [blame] | 11411 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 11412 | "%s: Set HDD connState to eConnectionState_NotConnected", |
| 11413 | __func__); |
Ganesh Kondabattini | 0433841 | 2015-09-14 15:39:09 +0530 | [diff] [blame] | 11414 | spin_lock_bh(&pAdapter->lock_for_active_session); |
| 11415 | if (eConnectionState_Associated == pHddStaCtx->conn_info.connState) |
| 11416 | { |
| 11417 | wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode); |
| 11418 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11419 | pHddStaCtx->conn_info.connState = eConnectionState_NotConnected; |
Ganesh Kondabattini | 0433841 | 2015-09-14 15:39:09 +0530 | [diff] [blame] | 11420 | spin_unlock_bh(&pAdapter->lock_for_active_session); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11421 | init_completion(&pAdapter->disconnect_comp_var); |
| 11422 | sme_RoamDisconnect(pHddCtx->hHal, pAdapter->sessionId, |
| 11423 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
| 11424 | |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 11425 | ret = wait_for_completion_interruptible_timeout( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11426 | &pAdapter->disconnect_comp_var, |
| 11427 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 11428 | if (0 >= ret) |
| 11429 | hddLog(LOGE, "%s: failure waiting for disconnect_comp_var %ld", |
| 11430 | __func__, ret); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11431 | |
| 11432 | pWextState->roamProfile.csrPersona = pAdapter->device_mode; |
| 11433 | pHddCtx->isAmpAllowed = VOS_FALSE; |
| 11434 | sme_RoamConnect(pHddCtx->hHal, |
| 11435 | pAdapter->sessionId, &(pWextState->roamProfile), |
| 11436 | &roamId); |
| 11437 | } |
| 11438 | |
| 11439 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 11440 | pAdapterNode = pNext; |
| 11441 | } |
| 11442 | |
| 11443 | EXIT(); |
| 11444 | |
| 11445 | return VOS_STATUS_SUCCESS; |
| 11446 | } |
| 11447 | |
Sudhir Sattayappa Kohalli | 90e4c75 | 2013-03-21 14:25:04 -0700 | [diff] [blame] | 11448 | void hdd_dump_concurrency_info(hdd_context_t *pHddCtx) |
| 11449 | { |
| 11450 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 11451 | VOS_STATUS status; |
| 11452 | hdd_adapter_t *pAdapter; |
| 11453 | hdd_station_ctx_t *pHddStaCtx; |
| 11454 | hdd_ap_ctx_t *pHddApCtx; |
| 11455 | hdd_hostapd_state_t * pHostapdState; |
| 11456 | tCsrBssid staBssid = { 0 }, p2pBssid = { 0 }, apBssid = { 0 }; |
| 11457 | v_U8_t staChannel = 0, p2pChannel = 0, apChannel = 0; |
| 11458 | const char *p2pMode = "DEV"; |
| 11459 | const char *ccMode = "Standalone"; |
Sudhir Sattayappa Kohalli | 90e4c75 | 2013-03-21 14:25:04 -0700 | [diff] [blame] | 11460 | |
| 11461 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 11462 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 11463 | { |
| 11464 | pAdapter = pAdapterNode->pAdapter; |
| 11465 | switch (pAdapter->device_mode) { |
| 11466 | case WLAN_HDD_INFRA_STATION: |
| 11467 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 11468 | if (eConnectionState_Associated == pHddStaCtx->conn_info.connState) { |
| 11469 | staChannel = pHddStaCtx->conn_info.operationChannel; |
| 11470 | memcpy(staBssid, pHddStaCtx->conn_info.bssId, sizeof(staBssid)); |
| 11471 | } |
| 11472 | break; |
| 11473 | case WLAN_HDD_P2P_CLIENT: |
| 11474 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 11475 | if (eConnectionState_Associated == pHddStaCtx->conn_info.connState) { |
| 11476 | p2pChannel = pHddStaCtx->conn_info.operationChannel; |
| 11477 | memcpy(p2pBssid, pHddStaCtx->conn_info.bssId, sizeof(p2pBssid)); |
| 11478 | p2pMode = "CLI"; |
| 11479 | } |
| 11480 | break; |
| 11481 | case WLAN_HDD_P2P_GO: |
| 11482 | pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
| 11483 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 11484 | if (pHostapdState->bssState == BSS_START && pHostapdState->vosStatus==VOS_STATUS_SUCCESS) { |
| 11485 | p2pChannel = pHddApCtx->operatingChannel; |
| 11486 | memcpy(p2pBssid, pAdapter->macAddressCurrent.bytes, sizeof(p2pBssid)); |
| 11487 | } |
| 11488 | p2pMode = "GO"; |
| 11489 | break; |
| 11490 | case WLAN_HDD_SOFTAP: |
| 11491 | pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
| 11492 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 11493 | if (pHostapdState->bssState == BSS_START && pHostapdState->vosStatus==VOS_STATUS_SUCCESS) { |
| 11494 | apChannel = pHddApCtx->operatingChannel; |
| 11495 | memcpy(apBssid, pAdapter->macAddressCurrent.bytes, sizeof(apBssid)); |
| 11496 | } |
| 11497 | break; |
| 11498 | default: |
| 11499 | break; |
| 11500 | } |
| 11501 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 11502 | pAdapterNode = pNext; |
| 11503 | } |
| 11504 | if (staChannel > 0 && (apChannel > 0 || p2pChannel > 0)) { |
| 11505 | ccMode = (p2pChannel==staChannel||apChannel==staChannel) ? "SCC" : "MCC"; |
| 11506 | } |
Yeshwanth Sriram Guntuka | 0004c0b | 2017-12-06 14:43:49 +0530 | [diff] [blame] | 11507 | hddLog(VOS_TRACE_LEVEL_ERROR, "wlan(%d) " MAC_ADDRESS_STR " %s", |
| 11508 | staChannel, MAC_ADDR_ARRAY(staBssid), ccMode); |
Sudhir Sattayappa Kohalli | 90e4c75 | 2013-03-21 14:25:04 -0700 | [diff] [blame] | 11509 | if (p2pChannel > 0) { |
Sushant Kaushik | dc3184b | 2015-10-09 12:00:21 +0530 | [diff] [blame] | 11510 | hddLog(VOS_TRACE_LEVEL_ERROR, "p2p-%s(%d) " MAC_ADDRESS_STR, |
Sudhir Sattayappa Kohalli | 90e4c75 | 2013-03-21 14:25:04 -0700 | [diff] [blame] | 11511 | p2pMode, p2pChannel, MAC_ADDR_ARRAY(p2pBssid)); |
| 11512 | } |
| 11513 | if (apChannel > 0) { |
Sushant Kaushik | dc3184b | 2015-10-09 12:00:21 +0530 | [diff] [blame] | 11514 | hddLog(VOS_TRACE_LEVEL_ERROR, "AP(%d) " MAC_ADDRESS_STR, |
Sudhir Sattayappa Kohalli | 90e4c75 | 2013-03-21 14:25:04 -0700 | [diff] [blame] | 11515 | apChannel, MAC_ADDR_ARRAY(apBssid)); |
| 11516 | } |
| 11517 | |
| 11518 | if (p2pChannel > 0 && apChannel > 0) { |
| 11519 | hddLog(VOS_TRACE_LEVEL_ERROR, "Error concurrent SAP %d and P2P %d which is not support", apChannel, p2pChannel); |
| 11520 | } |
| 11521 | } |
| 11522 | |
Madan Mohan Koyyalamudi | b5da533 | 2012-10-15 17:23:21 -0700 | [diff] [blame] | 11523 | bool hdd_is_ssr_required( void) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11524 | { |
Madan Mohan Koyyalamudi | b5da533 | 2012-10-15 17:23:21 -0700 | [diff] [blame] | 11525 | return (isSsrRequired == HDD_SSR_REQUIRED); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11526 | } |
| 11527 | |
Madan Mohan Koyyalamudi | b5da533 | 2012-10-15 17:23:21 -0700 | [diff] [blame] | 11528 | /* Once SSR is disabled then it cannot be set. */ |
| 11529 | void hdd_set_ssr_required( e_hdd_ssr_required value) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11530 | { |
Madan Mohan Koyyalamudi | b5da533 | 2012-10-15 17:23:21 -0700 | [diff] [blame] | 11531 | if (HDD_SSR_DISABLED == isSsrRequired) |
| 11532 | return; |
| 11533 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11534 | isSsrRequired = value; |
| 11535 | } |
| 11536 | |
Hema Aparna Medicharla | 6b4d4f3 | 2015-06-23 04:09:12 +0530 | [diff] [blame] | 11537 | void hdd_set_pre_close( hdd_context_t *pHddCtx) |
| 11538 | { |
| 11539 | sme_PreClose(pHddCtx->hHal); |
| 11540 | } |
| 11541 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11542 | VOS_STATUS hdd_get_front_adapter( hdd_context_t *pHddCtx, |
| 11543 | hdd_adapter_list_node_t** ppAdapterNode) |
| 11544 | { |
| 11545 | VOS_STATUS status; |
Mukul Sharma | ae1266d | 2015-06-26 15:29:53 +0530 | [diff] [blame] | 11546 | spin_lock_bh(&pHddCtx->hddAdapters.lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11547 | status = hdd_list_peek_front ( &pHddCtx->hddAdapters, |
| 11548 | (hdd_list_node_t**) ppAdapterNode ); |
Mukul Sharma | ae1266d | 2015-06-26 15:29:53 +0530 | [diff] [blame] | 11549 | spin_unlock_bh(&pHddCtx->hddAdapters.lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11550 | return status; |
| 11551 | } |
| 11552 | |
| 11553 | VOS_STATUS hdd_get_next_adapter( hdd_context_t *pHddCtx, |
| 11554 | hdd_adapter_list_node_t* pAdapterNode, |
| 11555 | hdd_adapter_list_node_t** pNextAdapterNode) |
| 11556 | { |
| 11557 | VOS_STATUS status; |
Mukul Sharma | ae1266d | 2015-06-26 15:29:53 +0530 | [diff] [blame] | 11558 | spin_lock_bh(&pHddCtx->hddAdapters.lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11559 | status = hdd_list_peek_next ( &pHddCtx->hddAdapters, |
| 11560 | (hdd_list_node_t*) pAdapterNode, |
| 11561 | (hdd_list_node_t**)pNextAdapterNode ); |
| 11562 | |
Mukul Sharma | ae1266d | 2015-06-26 15:29:53 +0530 | [diff] [blame] | 11563 | spin_unlock_bh(&pHddCtx->hddAdapters.lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11564 | return status; |
| 11565 | } |
| 11566 | |
| 11567 | VOS_STATUS hdd_remove_adapter( hdd_context_t *pHddCtx, |
| 11568 | hdd_adapter_list_node_t* pAdapterNode) |
| 11569 | { |
| 11570 | VOS_STATUS status; |
Mukul Sharma | ae1266d | 2015-06-26 15:29:53 +0530 | [diff] [blame] | 11571 | spin_lock_bh(&pHddCtx->hddAdapters.lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11572 | status = hdd_list_remove_node ( &pHddCtx->hddAdapters, |
| 11573 | &pAdapterNode->node ); |
Mukul Sharma | ae1266d | 2015-06-26 15:29:53 +0530 | [diff] [blame] | 11574 | spin_unlock_bh(&pHddCtx->hddAdapters.lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11575 | return status; |
| 11576 | } |
| 11577 | |
| 11578 | VOS_STATUS hdd_remove_front_adapter( hdd_context_t *pHddCtx, |
| 11579 | hdd_adapter_list_node_t** ppAdapterNode) |
| 11580 | { |
| 11581 | VOS_STATUS status; |
Mukul Sharma | ae1266d | 2015-06-26 15:29:53 +0530 | [diff] [blame] | 11582 | spin_lock_bh(&pHddCtx->hddAdapters.lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11583 | status = hdd_list_remove_front( &pHddCtx->hddAdapters, |
| 11584 | (hdd_list_node_t**) ppAdapterNode ); |
Mukul Sharma | ae1266d | 2015-06-26 15:29:53 +0530 | [diff] [blame] | 11585 | spin_unlock_bh(&pHddCtx->hddAdapters.lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11586 | return status; |
| 11587 | } |
| 11588 | |
| 11589 | VOS_STATUS hdd_add_adapter_back( hdd_context_t *pHddCtx, |
| 11590 | hdd_adapter_list_node_t* pAdapterNode) |
| 11591 | { |
| 11592 | VOS_STATUS status; |
Mukul Sharma | ae1266d | 2015-06-26 15:29:53 +0530 | [diff] [blame] | 11593 | spin_lock_bh(&pHddCtx->hddAdapters.lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11594 | status = hdd_list_insert_back ( &pHddCtx->hddAdapters, |
| 11595 | (hdd_list_node_t*) pAdapterNode ); |
Mukul Sharma | ae1266d | 2015-06-26 15:29:53 +0530 | [diff] [blame] | 11596 | spin_unlock_bh(&pHddCtx->hddAdapters.lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11597 | return status; |
| 11598 | } |
| 11599 | |
| 11600 | VOS_STATUS hdd_add_adapter_front( hdd_context_t *pHddCtx, |
| 11601 | hdd_adapter_list_node_t* pAdapterNode) |
| 11602 | { |
| 11603 | VOS_STATUS status; |
Mukul Sharma | ae1266d | 2015-06-26 15:29:53 +0530 | [diff] [blame] | 11604 | spin_lock_bh(&pHddCtx->hddAdapters.lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11605 | status = hdd_list_insert_front ( &pHddCtx->hddAdapters, |
| 11606 | (hdd_list_node_t*) pAdapterNode ); |
Mukul Sharma | ae1266d | 2015-06-26 15:29:53 +0530 | [diff] [blame] | 11607 | spin_unlock_bh(&pHddCtx->hddAdapters.lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11608 | return status; |
| 11609 | } |
| 11610 | |
| 11611 | hdd_adapter_t * hdd_get_adapter_by_macaddr( hdd_context_t *pHddCtx, |
| 11612 | tSirMacAddr macAddr ) |
| 11613 | { |
| 11614 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 11615 | hdd_adapter_t *pAdapter; |
| 11616 | VOS_STATUS status; |
| 11617 | |
| 11618 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 11619 | |
| 11620 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 11621 | { |
| 11622 | pAdapter = pAdapterNode->pAdapter; |
| 11623 | |
| 11624 | if( pAdapter && vos_mem_compare( pAdapter->macAddressCurrent.bytes, |
| 11625 | macAddr, sizeof(tSirMacAddr) ) ) |
| 11626 | { |
| 11627 | return pAdapter; |
| 11628 | } |
| 11629 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 11630 | pAdapterNode = pNext; |
| 11631 | } |
| 11632 | |
| 11633 | return NULL; |
| 11634 | |
| 11635 | } |
| 11636 | |
| 11637 | hdd_adapter_t * hdd_get_adapter_by_name( hdd_context_t *pHddCtx, tANI_U8 *name ) |
| 11638 | { |
| 11639 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 11640 | hdd_adapter_t *pAdapter; |
| 11641 | VOS_STATUS status; |
| 11642 | |
| 11643 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 11644 | |
| 11645 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 11646 | { |
| 11647 | pAdapter = pAdapterNode->pAdapter; |
| 11648 | |
| 11649 | if( pAdapter && !strncmp( pAdapter->dev->name, (const char *)name, |
| 11650 | IFNAMSIZ ) ) |
| 11651 | { |
| 11652 | return pAdapter; |
| 11653 | } |
| 11654 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 11655 | pAdapterNode = pNext; |
| 11656 | } |
| 11657 | |
| 11658 | return NULL; |
| 11659 | |
| 11660 | } |
| 11661 | |
Ganesh Kondabattini | cbfdc39 | 2015-09-11 19:12:59 +0530 | [diff] [blame] | 11662 | hdd_adapter_t *hdd_get_adapter_by_sme_session_id( hdd_context_t *pHddCtx, |
| 11663 | tANI_U32 sme_session_id ) |
| 11664 | { |
| 11665 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 11666 | hdd_adapter_t *pAdapter; |
| 11667 | VOS_STATUS vos_status; |
| 11668 | |
| 11669 | |
| 11670 | vos_status = hdd_get_front_adapter( pHddCtx, &pAdapterNode); |
| 11671 | |
| 11672 | while ((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == vos_status)) |
| 11673 | { |
| 11674 | pAdapter = pAdapterNode->pAdapter; |
| 11675 | |
| 11676 | if (pAdapter->sessionId == sme_session_id) |
| 11677 | return pAdapter; |
| 11678 | |
| 11679 | vos_status = hdd_get_next_adapter(pHddCtx, pAdapterNode, &pNext); |
| 11680 | pAdapterNode = pNext; |
| 11681 | } |
| 11682 | |
| 11683 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 11684 | "%s: sme_session_id %d does not exist with host", |
| 11685 | __func__, sme_session_id); |
| 11686 | |
| 11687 | return NULL; |
| 11688 | } |
| 11689 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11690 | hdd_adapter_t * hdd_get_adapter( hdd_context_t *pHddCtx, device_mode_t mode ) |
| 11691 | { |
| 11692 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 11693 | hdd_adapter_t *pAdapter; |
| 11694 | VOS_STATUS status; |
| 11695 | |
| 11696 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 11697 | |
| 11698 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 11699 | { |
| 11700 | pAdapter = pAdapterNode->pAdapter; |
| 11701 | |
| 11702 | if( pAdapter && (mode == pAdapter->device_mode) ) |
| 11703 | { |
| 11704 | return pAdapter; |
| 11705 | } |
| 11706 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 11707 | pAdapterNode = pNext; |
| 11708 | } |
| 11709 | |
| 11710 | return NULL; |
| 11711 | |
| 11712 | } |
| 11713 | |
| 11714 | //Remove this function later |
| 11715 | hdd_adapter_t * hdd_get_mon_adapter( hdd_context_t *pHddCtx ) |
| 11716 | { |
| 11717 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 11718 | hdd_adapter_t *pAdapter; |
| 11719 | VOS_STATUS status; |
| 11720 | |
| 11721 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 11722 | |
| 11723 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 11724 | { |
| 11725 | pAdapter = pAdapterNode->pAdapter; |
| 11726 | |
| 11727 | if( pAdapter && WLAN_HDD_MONITOR == pAdapter->device_mode ) |
| 11728 | { |
| 11729 | return pAdapter; |
| 11730 | } |
| 11731 | |
| 11732 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 11733 | pAdapterNode = pNext; |
| 11734 | } |
| 11735 | |
| 11736 | return NULL; |
| 11737 | |
| 11738 | } |
| 11739 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11740 | /**--------------------------------------------------------------------------- |
| 11741 | |
Mahesh A Saptasgar | 6453461 | 2014-09-23 13:13:33 +0530 | [diff] [blame] | 11742 | \brief hdd_get_operating_channel() - |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11743 | |
| 11744 | This API returns the operating channel of the requested device mode |
| 11745 | |
| 11746 | \param - pHddCtx - Pointer to the HDD context. |
| 11747 | - mode - Device mode for which operating channel is required |
| 11748 | suported modes - WLAN_HDD_INFRA_STATION, WLAN_HDD_P2P_CLIENT |
| 11749 | WLAN_HDD_SOFTAP, WLAN_HDD_P2P_GO. |
| 11750 | \return - channel number. "0" id the requested device is not found OR it is not connected. |
| 11751 | --------------------------------------------------------------------------*/ |
| 11752 | v_U8_t hdd_get_operating_channel( hdd_context_t *pHddCtx, device_mode_t mode ) |
| 11753 | { |
| 11754 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 11755 | VOS_STATUS status; |
| 11756 | hdd_adapter_t *pAdapter; |
| 11757 | v_U8_t operatingChannel = 0; |
| 11758 | |
| 11759 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 11760 | |
| 11761 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 11762 | { |
| 11763 | pAdapter = pAdapterNode->pAdapter; |
| 11764 | |
| 11765 | if( mode == pAdapter->device_mode ) |
| 11766 | { |
| 11767 | switch(pAdapter->device_mode) |
| 11768 | { |
| 11769 | case WLAN_HDD_INFRA_STATION: |
| 11770 | case WLAN_HDD_P2P_CLIENT: |
| 11771 | if( hdd_connIsConnected( WLAN_HDD_GET_STATION_CTX_PTR( pAdapter )) ) |
| 11772 | operatingChannel = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.operationChannel; |
| 11773 | break; |
| 11774 | case WLAN_HDD_SOFTAP: |
| 11775 | case WLAN_HDD_P2P_GO: |
| 11776 | /*softap connection info */ |
| 11777 | if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags)) |
| 11778 | operatingChannel = (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->operatingChannel; |
| 11779 | break; |
| 11780 | default: |
| 11781 | break; |
| 11782 | } |
| 11783 | |
| 11784 | break; //Found the device of interest. break the loop |
| 11785 | } |
| 11786 | |
| 11787 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 11788 | pAdapterNode = pNext; |
| 11789 | } |
| 11790 | return operatingChannel; |
| 11791 | } |
| 11792 | |
| 11793 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 11794 | /**--------------------------------------------------------------------------- |
| 11795 | |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 11796 | \brief __hdd_set_multicast_list() - |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11797 | |
| 11798 | This used to set the multicast address list. |
| 11799 | |
| 11800 | \param - dev - Pointer to the WLAN device. |
| 11801 | - skb - Pointer to OS packet (sk_buff). |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 11802 | \return - success/fail |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11803 | |
| 11804 | --------------------------------------------------------------------------*/ |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 11805 | static void __hdd_set_multicast_list(struct net_device *dev) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11806 | { |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 11807 | hdd_adapter_t *pAdapter; |
| 11808 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11809 | int mc_count; |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 11810 | int i = 0, ret = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11811 | struct netdev_hw_addr *ha; |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 11812 | |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 11813 | ENTER(); |
| 11814 | |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 11815 | pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 11816 | if (NULL == pAdapter) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11817 | { |
| 11818 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 11819 | "%s: Adapter context is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11820 | return; |
| 11821 | } |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 11822 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 11823 | ret = wlan_hdd_validate_context(pHddCtx); |
| 11824 | if (0 != ret) |
| 11825 | { |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 11826 | return; |
| 11827 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11828 | if (dev->flags & IFF_ALLMULTI) |
| 11829 | { |
| 11830 | hddLog(VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 11831 | "%s: allow all multicast frames", __func__); |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 11832 | pAdapter->mc_addr_list.mc_cnt = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11833 | } |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 11834 | else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11835 | { |
| 11836 | mc_count = netdev_mc_count(dev); |
| 11837 | hddLog(VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 11838 | "%s: mc_count = %u", __func__, mc_count); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11839 | if (mc_count > WLAN_HDD_MAX_MC_ADDR_LIST) |
| 11840 | { |
| 11841 | hddLog(VOS_TRACE_LEVEL_INFO, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 11842 | "%s: No free filter available; allow all multicast frames", __func__); |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 11843 | pAdapter->mc_addr_list.mc_cnt = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11844 | return; |
| 11845 | } |
| 11846 | |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 11847 | pAdapter->mc_addr_list.mc_cnt = mc_count; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11848 | |
| 11849 | netdev_for_each_mc_addr(ha, dev) { |
| 11850 | if (i == mc_count) |
| 11851 | break; |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 11852 | memset(&(pAdapter->mc_addr_list.addr[i][0]), 0, ETH_ALEN); |
| 11853 | memcpy(&(pAdapter->mc_addr_list.addr[i][0]), ha->addr, ETH_ALEN); |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 11854 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: mlist[%d] = "MAC_ADDRESS_STR, |
Mahesh A Saptasagar | 7408839 | 2015-02-05 17:22:09 +0530 | [diff] [blame] | 11855 | __func__, i, |
Gopichand Nakkala | 0f27681 | 2013-02-24 14:45:51 +0530 | [diff] [blame] | 11856 | MAC_ADDR_ARRAY(pAdapter->mc_addr_list.addr[i])); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11857 | i++; |
| 11858 | } |
| 11859 | } |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 11860 | |
Ganesh Kondabattini | fb37e65 | 2015-10-09 15:46:47 +0530 | [diff] [blame] | 11861 | if (pHddCtx->hdd_wlan_suspended) |
| 11862 | { |
| 11863 | /* |
| 11864 | * Configure the Mcast address list to FW |
| 11865 | * If wlan is already in suspend mode |
| 11866 | */ |
| 11867 | wlan_hdd_set_mc_addr_list(pAdapter, TRUE); |
| 11868 | } |
Hanumantha Reddy Pothula | 7dc0e6c | 2015-03-06 15:11:16 +0530 | [diff] [blame] | 11869 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11870 | return; |
| 11871 | } |
Mahesh A Saptasagar | d68eb28 | 2014-12-17 14:20:19 +0530 | [diff] [blame] | 11872 | |
| 11873 | static void hdd_set_multicast_list(struct net_device *dev) |
| 11874 | { |
| 11875 | vos_ssr_protect(__func__); |
| 11876 | __hdd_set_multicast_list(dev); |
| 11877 | vos_ssr_unprotect(__func__); |
| 11878 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11879 | #endif |
| 11880 | |
| 11881 | /**--------------------------------------------------------------------------- |
| 11882 | |
| 11883 | \brief hdd_select_queue() - |
| 11884 | |
| 11885 | This function is registered with the Linux OS for network |
| 11886 | core to decide which queue to use first. |
| 11887 | |
| 11888 | \param - dev - Pointer to the WLAN device. |
| 11889 | - skb - Pointer to OS packet (sk_buff). |
| 11890 | \return - ac, Queue Index/access category corresponding to UP in IP header |
| 11891 | |
| 11892 | --------------------------------------------------------------------------*/ |
| 11893 | v_U16_t hdd_select_queue(struct net_device *dev, |
Anand N Sunkad | e9adb1b | 2015-07-29 09:56:45 +0530 | [diff] [blame] | 11894 | struct sk_buff *skb |
| 11895 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0)) |
| 11896 | , void *accel_priv |
| 11897 | #endif |
| 11898 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) |
| 11899 | , select_queue_fallback_t fallback |
| 11900 | #endif |
| 11901 | ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11902 | { |
| 11903 | return hdd_wmm_select_queue(dev, skb); |
| 11904 | } |
| 11905 | |
| 11906 | |
| 11907 | /**--------------------------------------------------------------------------- |
| 11908 | |
| 11909 | \brief hdd_wlan_initial_scan() - |
| 11910 | |
| 11911 | This function triggers the initial scan |
| 11912 | |
| 11913 | \param - pAdapter - Pointer to the HDD adapter. |
| 11914 | |
| 11915 | --------------------------------------------------------------------------*/ |
| 11916 | void hdd_wlan_initial_scan(hdd_adapter_t *pAdapter) |
| 11917 | { |
| 11918 | tCsrScanRequest scanReq; |
| 11919 | tCsrChannelInfo channelInfo; |
| 11920 | eHalStatus halStatus; |
Jeff Johnson | 0279779 | 2013-10-26 19:17:13 -0700 | [diff] [blame] | 11921 | tANI_U32 scanId; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11922 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 11923 | |
| 11924 | vos_mem_zero(&scanReq, sizeof(tCsrScanRequest)); |
| 11925 | vos_mem_set(&scanReq.bssid, sizeof(tCsrBssid), 0xff); |
| 11926 | scanReq.BSSType = eCSR_BSS_TYPE_ANY; |
| 11927 | |
| 11928 | if(sme_Is11dSupported(pHddCtx->hHal)) |
| 11929 | { |
| 11930 | halStatus = sme_ScanGetBaseChannels( pHddCtx->hHal, &channelInfo ); |
| 11931 | if ( HAL_STATUS_SUCCESS( halStatus ) ) |
| 11932 | { |
| 11933 | scanReq.ChannelInfo.ChannelList = vos_mem_malloc(channelInfo.numOfChannels); |
| 11934 | if( !scanReq.ChannelInfo.ChannelList ) |
| 11935 | { |
| 11936 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s kmalloc failed", __func__); |
| 11937 | vos_mem_free(channelInfo.ChannelList); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 11938 | channelInfo.ChannelList = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11939 | return; |
| 11940 | } |
| 11941 | vos_mem_copy(scanReq.ChannelInfo.ChannelList, channelInfo.ChannelList, |
| 11942 | channelInfo.numOfChannels); |
| 11943 | scanReq.ChannelInfo.numOfChannels = channelInfo.numOfChannels; |
| 11944 | vos_mem_free(channelInfo.ChannelList); |
Srinivas Girigowda | 8d2348f | 2013-12-12 12:14:15 -0800 | [diff] [blame] | 11945 | channelInfo.ChannelList = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11946 | } |
| 11947 | |
| 11948 | scanReq.scanType = eSIR_PASSIVE_SCAN; |
| 11949 | scanReq.requestType = eCSR_SCAN_REQUEST_11D_SCAN; |
| 11950 | scanReq.maxChnTime = pHddCtx->cfg_ini->nPassiveMaxChnTime; |
| 11951 | scanReq.minChnTime = pHddCtx->cfg_ini->nPassiveMinChnTime; |
| 11952 | } |
| 11953 | else |
| 11954 | { |
| 11955 | scanReq.scanType = eSIR_ACTIVE_SCAN; |
| 11956 | scanReq.requestType = eCSR_SCAN_REQUEST_FULL_SCAN; |
| 11957 | scanReq.maxChnTime = pHddCtx->cfg_ini->nActiveMaxChnTime; |
| 11958 | scanReq.minChnTime = pHddCtx->cfg_ini->nActiveMinChnTime; |
| 11959 | } |
| 11960 | |
| 11961 | halStatus = sme_ScanRequest(pHddCtx->hHal, pAdapter->sessionId, &scanReq, &scanId, NULL, NULL); |
| 11962 | if ( !HAL_STATUS_SUCCESS( halStatus ) ) |
| 11963 | { |
| 11964 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_ScanRequest failed status code %d", |
| 11965 | __func__, halStatus ); |
| 11966 | } |
| 11967 | |
| 11968 | if(sme_Is11dSupported(pHddCtx->hHal)) |
| 11969 | vos_mem_free(scanReq.ChannelInfo.ChannelList); |
| 11970 | } |
| 11971 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11972 | /**--------------------------------------------------------------------------- |
| 11973 | |
| 11974 | \brief hdd_full_power_callback() - HDD full power callback function |
| 11975 | |
| 11976 | This is the function invoked by SME to inform the result of a full power |
| 11977 | request issued by HDD |
| 11978 | |
| 11979 | \param - callbackcontext - Pointer to cookie |
| 11980 | \param - status - result of request |
| 11981 | |
| 11982 | \return - None |
| 11983 | |
| 11984 | --------------------------------------------------------------------------*/ |
| 11985 | static void hdd_full_power_callback(void *callbackContext, eHalStatus status) |
| 11986 | { |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 11987 | struct statsContext *pContext = callbackContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11988 | |
| 11989 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | c135a9a | 2017-09-19 08:37:24 -0700 | [diff] [blame] | 11990 | "%s: context = %pK, status = %d", __func__, pContext, status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11991 | |
| 11992 | if (NULL == callbackContext) |
| 11993 | { |
| 11994 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | c135a9a | 2017-09-19 08:37:24 -0700 | [diff] [blame] | 11995 | "%s: Bad param, context [%pK]", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 11996 | __func__, callbackContext); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 11997 | return; |
| 11998 | } |
| 11999 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 12000 | /* there is a race condition that exists between this callback |
| 12001 | function and the caller since the caller could time out either |
| 12002 | before or while this code is executing. we use a spinlock to |
| 12003 | serialize these actions */ |
| 12004 | spin_lock(&hdd_context_lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12005 | |
| 12006 | if (POWER_CONTEXT_MAGIC != pContext->magic) |
| 12007 | { |
| 12008 | /* the caller presumably timed out so there is nothing we can do */ |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 12009 | spin_unlock(&hdd_context_lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12010 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 12011 | "%s: Invalid context, magic [%08x]", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 12012 | __func__, pContext->magic); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12013 | return; |
| 12014 | } |
| 12015 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 12016 | /* context is valid so caller is still waiting */ |
| 12017 | |
| 12018 | /* paranoia: invalidate the magic */ |
| 12019 | pContext->magic = 0; |
| 12020 | |
| 12021 | /* notify the caller */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12022 | complete(&pContext->completion); |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 12023 | |
| 12024 | /* serialization is complete */ |
| 12025 | spin_unlock(&hdd_context_lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12026 | } |
| 12027 | |
Katya Nigam | f0511f6 | 2015-05-05 16:40:57 +0530 | [diff] [blame] | 12028 | void wlan_hdd_mon_set_typesubtype( hdd_mon_ctx_t *pMonCtx,int type) |
| 12029 | { |
| 12030 | pMonCtx->typeSubtypeBitmap = 0; |
| 12031 | if( type%10 ) /* Management Packets */ |
| 12032 | pMonCtx->typeSubtypeBitmap |= 0xFFFF; |
| 12033 | type/=10; |
| 12034 | if( type%10 ) /* Control Packets */ |
| 12035 | pMonCtx->typeSubtypeBitmap |= 0xFFFF0000; |
| 12036 | type/=10; |
| 12037 | if( type%10 ) /* Data Packets */ |
| 12038 | pMonCtx->typeSubtypeBitmap |= 0xFFFF00000000; |
| 12039 | } |
| 12040 | |
Hanumanth Reddy Pothula | b8be9ab | 2018-04-12 20:03:05 +0530 | [diff] [blame] | 12041 | VOS_STATUS wlan_hdd_mon_postMsg(void *context, hdd_mon_ctx_t *pMonCtx, |
| 12042 | void* callback) |
Katya Nigam | f0511f6 | 2015-05-05 16:40:57 +0530 | [diff] [blame] | 12043 | { |
| 12044 | vos_msg_t monMsg; |
Hanumantha Reddy Pothula | 91cdd7f | 2015-09-03 21:25:16 +0530 | [diff] [blame] | 12045 | tSirMonModeReq *pMonModeReq; |
Katya Nigam | f0511f6 | 2015-05-05 16:40:57 +0530 | [diff] [blame] | 12046 | |
Hanumantha Reddy Pothula | 91cdd7f | 2015-09-03 21:25:16 +0530 | [diff] [blame] | 12047 | if (MON_MODE_START == pMonCtx->state) |
| 12048 | monMsg.type = WDA_MON_START_REQ; |
| 12049 | else if (MON_MODE_STOP == pMonCtx->state) |
| 12050 | monMsg.type = WDA_MON_STOP_REQ; |
| 12051 | else { |
| 12052 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 12053 | FL("invalid monitor state %d"), pMonCtx->state); |
Katya Nigam | f0511f6 | 2015-05-05 16:40:57 +0530 | [diff] [blame] | 12054 | return VOS_STATUS_E_FAILURE; |
| 12055 | } |
| 12056 | |
Hanumantha Reddy Pothula | 91cdd7f | 2015-09-03 21:25:16 +0530 | [diff] [blame] | 12057 | pMonModeReq = vos_mem_malloc(sizeof(tSirMonModeReq)); |
| 12058 | if (pMonModeReq == NULL) { |
| 12059 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 12060 | FL("fail to allocate memory for monitor mode req")); |
| 12061 | return VOS_STATUS_E_FAILURE; |
| 12062 | } |
Katya Nigam | f0511f6 | 2015-05-05 16:40:57 +0530 | [diff] [blame] | 12063 | |
Hanumanth Reddy Pothula | b8be9ab | 2018-04-12 20:03:05 +0530 | [diff] [blame] | 12064 | pMonModeReq->context = context; |
Hanumantha Reddy Pothula | 91cdd7f | 2015-09-03 21:25:16 +0530 | [diff] [blame] | 12065 | pMonModeReq->data = pMonCtx; |
| 12066 | pMonModeReq->callback = callback; |
Katya Nigam | f0511f6 | 2015-05-05 16:40:57 +0530 | [diff] [blame] | 12067 | |
Katya Nigam | f0511f6 | 2015-05-05 16:40:57 +0530 | [diff] [blame] | 12068 | monMsg.reserved = 0; |
Hanumantha Reddy Pothula | 91cdd7f | 2015-09-03 21:25:16 +0530 | [diff] [blame] | 12069 | monMsg.bodyptr = pMonModeReq; |
Katya Nigam | f0511f6 | 2015-05-05 16:40:57 +0530 | [diff] [blame] | 12070 | monMsg.bodyval = 0; |
| 12071 | |
| 12072 | if (VOS_STATUS_SUCCESS != vos_mq_post_message( |
| 12073 | VOS_MODULE_ID_WDA,(vos_msg_t *)&monMsg)) { |
| 12074 | 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] | 12075 | vos_mem_free(pMonModeReq); |
Katya Nigam | f0511f6 | 2015-05-05 16:40:57 +0530 | [diff] [blame] | 12076 | } |
Hanumantha Reddy Pothula | 91cdd7f | 2015-09-03 21:25:16 +0530 | [diff] [blame] | 12077 | return VOS_STATUS_SUCCESS; |
Katya Nigam | f0511f6 | 2015-05-05 16:40:57 +0530 | [diff] [blame] | 12078 | } |
| 12079 | |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 12080 | void wlan_hdd_mon_close(hdd_context_t *pHddCtx) |
| 12081 | { |
| 12082 | VOS_STATUS vosStatus; |
| 12083 | v_CONTEXT_t pVosContext = pHddCtx->pvosContext; |
Hanumantha Reddy Pothula | 91cdd7f | 2015-09-03 21:25:16 +0530 | [diff] [blame] | 12084 | hdd_mon_ctx_t *pMonCtx = NULL; |
Hanumanth Reddy Pothula | b8be9ab | 2018-04-12 20:03:05 +0530 | [diff] [blame] | 12085 | int ret; |
| 12086 | void *cookie; |
| 12087 | struct hdd_request *request; |
| 12088 | static const struct hdd_request_params params = { |
| 12089 | .priv_size = 0, |
| 12090 | .timeout_ms = MON_MODE_MSG_TIMEOUT, |
| 12091 | }; |
Hanumantha Reddy Pothula | c99bc06 | 2015-09-08 14:59:26 +0530 | [diff] [blame] | 12092 | |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 12093 | hdd_adapter_t *pAdapter = hdd_get_adapter(pHddCtx,WLAN_HDD_MONITOR); |
| 12094 | if(pAdapter == NULL || pVosContext == NULL) |
| 12095 | { |
| 12096 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:pAdapter is NULL",__func__); |
| 12097 | return ; |
| 12098 | } |
Katya Nigam | f0511f6 | 2015-05-05 16:40:57 +0530 | [diff] [blame] | 12099 | |
Hanumantha Reddy Pothula | 91cdd7f | 2015-09-03 21:25:16 +0530 | [diff] [blame] | 12100 | pMonCtx = WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter); |
| 12101 | if (pMonCtx!= NULL && pMonCtx->state == MON_MODE_START) { |
| 12102 | pMonCtx->state = MON_MODE_STOP; |
Hanumanth Reddy Pothula | b8be9ab | 2018-04-12 20:03:05 +0530 | [diff] [blame] | 12103 | request = hdd_request_alloc(¶ms); |
| 12104 | if (!request) { |
| 12105 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request allocation failure")); |
| 12106 | return; |
| 12107 | } |
| 12108 | cookie = hdd_request_cookie(request); |
| 12109 | |
Hanumantha Reddy Pothula | 91cdd7f | 2015-09-03 21:25:16 +0530 | [diff] [blame] | 12110 | if (VOS_STATUS_SUCCESS != |
Hanumanth Reddy Pothula | b8be9ab | 2018-04-12 20:03:05 +0530 | [diff] [blame] | 12111 | wlan_hdd_mon_postMsg(cookie, pMonCtx, |
| 12112 | hdd_mon_post_msg_cb)) { |
Hanumantha Reddy Pothula | 91cdd7f | 2015-09-03 21:25:16 +0530 | [diff] [blame] | 12113 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 12114 | FL("failed to post MON MODE REQ")); |
| 12115 | pMonCtx->state = MON_MODE_START; |
Hanumanth Reddy Pothula | b8be9ab | 2018-04-12 20:03:05 +0530 | [diff] [blame] | 12116 | goto req_put; |
Hanumantha Reddy Pothula | 91cdd7f | 2015-09-03 21:25:16 +0530 | [diff] [blame] | 12117 | } |
Hanumanth Reddy Pothula | b8be9ab | 2018-04-12 20:03:05 +0530 | [diff] [blame] | 12118 | |
| 12119 | ret = hdd_request_wait_for_response(request); |
| 12120 | if (ret) |
Hanumantha Reddy Pothula | 91cdd7f | 2015-09-03 21:25:16 +0530 | [diff] [blame] | 12121 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Hanumanth Reddy Pothula | b8be9ab | 2018-04-12 20:03:05 +0530 | [diff] [blame] | 12122 | FL("timeout on monitor mode completion %d"), ret); |
| 12123 | |
| 12124 | req_put: |
| 12125 | hdd_request_put(request); |
Hanumantha Reddy Pothula | 91cdd7f | 2015-09-03 21:25:16 +0530 | [diff] [blame] | 12126 | } |
| 12127 | |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 12128 | hdd_UnregisterWext(pAdapter->dev); |
| 12129 | |
| 12130 | vos_mon_stop( pVosContext ); |
| 12131 | |
| 12132 | vosStatus = vos_sched_close( pVosContext ); |
| 12133 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) { |
| 12134 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, |
| 12135 | "%s: Failed to close VOSS Scheduler",__func__); |
| 12136 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) ); |
| 12137 | } |
| 12138 | |
| 12139 | vosStatus = vos_nv_close(); |
| 12140 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) |
| 12141 | { |
| 12142 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 12143 | "%s: Failed to close NV", __func__); |
| 12144 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) ); |
| 12145 | } |
| 12146 | |
| 12147 | vos_close(pVosContext); |
| 12148 | |
| 12149 | #ifdef WLAN_KD_READY_NOTIFIER |
| 12150 | nl_srv_exit(pHddCtx->ptt_pid); |
| 12151 | #else |
| 12152 | nl_srv_exit(); |
| 12153 | #endif |
| 12154 | |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 12155 | hdd_close_all_adapters( pHddCtx ); |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 12156 | } |
Agrawal Ashish | 33ec71e | 2015-11-26 20:20:58 +0530 | [diff] [blame] | 12157 | /** |
| 12158 | * hdd_wlan_free_wiphy_channels - free Channel pointer for wiphy |
| 12159 | * @ wiphy: the wiphy to validate against |
| 12160 | * |
| 12161 | * Return: void |
| 12162 | */ |
| 12163 | void hdd_wlan_free_wiphy_channels(struct wiphy *wiphy) |
| 12164 | { |
| 12165 | int i =0; |
Rajeev Kumar Sirasanagandla | 5b21a9c | 2018-01-08 17:05:11 +0530 | [diff] [blame] | 12166 | for (i = 0; i < HDD_NUM_NL80211_BANDS; i++) |
Agrawal Ashish | 33ec71e | 2015-11-26 20:20:58 +0530 | [diff] [blame] | 12167 | { |
| 12168 | if (NULL != wiphy->bands[i] && |
| 12169 | (NULL != wiphy->bands[i]->channels)) |
| 12170 | { |
| 12171 | vos_mem_free(wiphy->bands[i]->channels); |
| 12172 | wiphy->bands[i]->channels = NULL; |
| 12173 | } |
| 12174 | } |
| 12175 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12176 | /**--------------------------------------------------------------------------- |
| 12177 | |
| 12178 | \brief hdd_wlan_exit() - HDD WLAN exit function |
| 12179 | |
| 12180 | This is the driver exit point (invoked during rmmod) |
| 12181 | |
| 12182 | \param - pHddCtx - Pointer to the HDD Context |
| 12183 | |
| 12184 | \return - None |
| 12185 | |
| 12186 | --------------------------------------------------------------------------*/ |
| 12187 | void hdd_wlan_exit(hdd_context_t *pHddCtx) |
| 12188 | { |
| 12189 | eHalStatus halStatus; |
| 12190 | v_CONTEXT_t pVosContext = pHddCtx->pvosContext; |
| 12191 | VOS_STATUS vosStatus; |
Gopichand Nakkala | 66923aa | 2013-03-06 23:17:24 +0530 | [diff] [blame] | 12192 | struct wiphy *wiphy = pHddCtx->wiphy; |
Mingcheng Zhu | 87f22fc | 2014-01-30 19:23:32 -0800 | [diff] [blame] | 12193 | hdd_adapter_t* pAdapter = NULL; |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 12194 | struct statsContext powerContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12195 | long lrc; |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 12196 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12197 | |
| 12198 | ENTER(); |
| 12199 | |
Vinay Krishna Eranna | f97ef5c | 2014-12-26 17:47:19 +0530 | [diff] [blame] | 12200 | |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 12201 | if (VOS_MONITOR_MODE == hdd_get_conparam()) |
| 12202 | { |
| 12203 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: MONITOR MODE",__func__); |
| 12204 | wlan_hdd_mon_close(pHddCtx); |
Hanumantha Reddy Pothula | c99bc06 | 2015-09-08 14:59:26 +0530 | [diff] [blame] | 12205 | goto free_hdd_ctx; |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 12206 | } |
| 12207 | else if (VOS_FTM_MODE != hdd_get_conparam()) |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 12208 | { |
| 12209 | // Unloading, restart logic is no more required. |
| 12210 | wlan_hdd_restart_deinit(pHddCtx); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 12211 | |
Agarwal Ashish | b20e0ff | 2014-12-17 22:50:19 +0530 | [diff] [blame] | 12212 | #ifdef FEATURE_WLAN_TDLS |
| 12213 | /* At the time of driver unloading; if tdls connection is present; |
| 12214 | * hdd_rx_packet_cbk calls wlan_hdd_tdls_find_peer. |
| 12215 | * wlan_hdd_tdls_find_peer always checks for valid context; |
| 12216 | * as load/unload in progress there can be a race condition. |
| 12217 | * hdd_rx_packet_cbk calls wlan_hdd_tdls_find_peer only |
| 12218 | * when tdls state is enabled. |
| 12219 | * As soon as driver set load/unload flag; tdls flag also needs |
| 12220 | * to be disabled so that hdd_rx_packet_cbk won't call |
| 12221 | * wlan_hdd_tdls_find_peer. |
| 12222 | */ |
Masti, Narayanraddi | 20494af | 2015-12-17 20:56:42 +0530 | [diff] [blame] | 12223 | wlan_hdd_tdls_set_mode(pHddCtx, eTDLS_SUPPORT_DISABLED, FALSE, |
| 12224 | HDD_SET_TDLS_MODE_SOURCE_USER); |
Agarwal Ashish | b20e0ff | 2014-12-17 22:50:19 +0530 | [diff] [blame] | 12225 | #endif |
| 12226 | |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 12227 | vosStatus = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 12228 | while (NULL != pAdapterNode && VOS_STATUS_E_EMPTY != vosStatus) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12229 | { |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 12230 | pAdapter = pAdapterNode->pAdapter; |
| 12231 | if (NULL != pAdapter) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12232 | { |
Mahesh A Saptasagar | 305e263 | 2015-03-04 12:57:33 +0530 | [diff] [blame] | 12233 | /* Disable TX on the interface, after this hard_start_xmit() will |
| 12234 | * not be called on that interface |
| 12235 | */ |
| 12236 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues")); |
| 12237 | netif_tx_disable(pAdapter->dev); |
| 12238 | |
| 12239 | /* Mark the interface status as "down" for outside world */ |
| 12240 | netif_carrier_off(pAdapter->dev); |
| 12241 | |
Agarwal Ashish | 9ffa5b9 | 2014-11-18 21:07:02 +0530 | [diff] [blame] | 12242 | /* DeInit the adapter. This ensures that all data packets |
| 12243 | * are freed. |
| 12244 | */ |
Mahesh A Saptasagar | 02e36e8 | 2015-01-14 20:39:19 +0530 | [diff] [blame] | 12245 | #ifdef FEATURE_WLAN_TDLS |
| 12246 | mutex_lock(&pHddCtx->tdls_lock); |
| 12247 | #endif |
c_hpothu | 002231a | 2015-02-05 14:58:51 +0530 | [diff] [blame] | 12248 | hdd_deinit_adapter(pHddCtx, pAdapter, FALSE); |
Mahesh A Saptasagar | 02e36e8 | 2015-01-14 20:39:19 +0530 | [diff] [blame] | 12249 | #ifdef FEATURE_WLAN_TDLS |
| 12250 | mutex_unlock(&pHddCtx->tdls_lock); |
| 12251 | #endif |
Masti, Narayanraddi | 2637846 | 2016-01-05 18:20:28 +0530 | [diff] [blame] | 12252 | vos_flush_delayed_work(&pHddCtx->scan_ctxt.scan_work); |
| 12253 | |
| 12254 | wlan_hdd_init_deinit_defer_scan_context(&pHddCtx->scan_ctxt); |
Agarwal Ashish | 9ffa5b9 | 2014-11-18 21:07:02 +0530 | [diff] [blame] | 12255 | |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 12256 | if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode || |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 12257 | WLAN_HDD_P2P_CLIENT == pAdapter->device_mode || |
| 12258 | WLAN_HDD_MONITOR == pAdapter->device_mode) |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 12259 | { |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 12260 | if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode || |
| 12261 | WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) |
| 12262 | wlan_hdd_cfg80211_deregister_frames(pAdapter); |
| 12263 | |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 12264 | hdd_UnregisterWext(pAdapter->dev); |
| 12265 | } |
Kaushik, Sushant | 4975a57 | 2014-10-21 16:07:48 +0530 | [diff] [blame] | 12266 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12267 | } |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 12268 | vosStatus = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 12269 | pAdapterNode = pNext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12270 | } |
mukul sharma | bab477d | 2015-06-11 17:14:55 +0530 | [diff] [blame] | 12271 | |
Kaushik, Sushant | 4975a57 | 2014-10-21 16:07:48 +0530 | [diff] [blame] | 12272 | // Cancel any outstanding scan requests. We are about to close all |
| 12273 | // of our adapters, but an adapter structure is what SME passes back |
| 12274 | // to our callback function. Hence if there are any outstanding scan |
| 12275 | // requests then there is a race condition between when the adapter |
| 12276 | // is closed and when the callback is invoked.We try to resolve that |
| 12277 | // race condition here by canceling any outstanding scans before we |
| 12278 | // close the adapters. |
| 12279 | // Note that the scans may be cancelled in an asynchronous manner, |
| 12280 | // so ideally there needs to be some kind of synchronization. Rather |
| 12281 | // than introduce a new synchronization here, we will utilize the |
| 12282 | // fact that we are about to Request Full Power, and since that is |
| 12283 | // synchronized, the expectation is that by the time Request Full |
| 12284 | // Power has completed all scans will be cancelled. |
| 12285 | if (pHddCtx->scan_info.mScanPending) |
| 12286 | { |
Hema Aparna Medicharla | f05f6cd | 2015-01-21 14:44:19 +0530 | [diff] [blame] | 12287 | if(NULL != pAdapter) |
| 12288 | { |
| 12289 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 12290 | FL("abort scan mode: %d sessionId: %d"), |
| 12291 | pAdapter->device_mode, |
| 12292 | pAdapter->sessionId); |
| 12293 | } |
| 12294 | hdd_abort_mac_scan(pHddCtx, |
| 12295 | pHddCtx->scan_info.sessionId, |
| 12296 | eCSR_SCAN_ABORT_DEFAULT); |
Kaushik, Sushant | 4975a57 | 2014-10-21 16:07:48 +0530 | [diff] [blame] | 12297 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12298 | } |
c_hpothu | 5ab05e9 | 2014-06-13 17:34:05 +0530 | [diff] [blame] | 12299 | else |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 12300 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 12301 | hddLog(VOS_TRACE_LEVEL_INFO,"%s: FTM MODE",__func__); |
Hanumantha Reddy Pothula | 45af96b | 2015-02-12 16:07:58 +0530 | [diff] [blame] | 12302 | if (pHddCtx->ftm.ftm_state == WLAN_FTM_STARTING) |
| 12303 | { |
| 12304 | INIT_COMPLETION(pHddCtx->ftm.startCmpVar); |
| 12305 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 12306 | "%s: in middle of FTM START", __func__); |
| 12307 | lrc = wait_for_completion_timeout(&pHddCtx->ftm.startCmpVar, |
| 12308 | msecs_to_jiffies(20000)); |
| 12309 | if(!lrc) |
| 12310 | { |
| 12311 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 12312 | "%s: timedout on ftmStartCmpVar fatal error", __func__); |
| 12313 | } |
| 12314 | } |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 12315 | wlan_hdd_ftm_close(pHddCtx); |
| 12316 | goto free_hdd_ctx; |
| 12317 | } |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 12318 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12319 | /* DeRegister with platform driver as client for Suspend/Resume */ |
| 12320 | vosStatus = hddDeregisterPmOps(pHddCtx); |
| 12321 | if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) ) |
| 12322 | { |
| 12323 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddDeregisterPmOps failed",__func__); |
| 12324 | VOS_ASSERT(0); |
| 12325 | } |
| 12326 | |
| 12327 | vosStatus = hddDevTmUnregisterNotifyCallback(pHddCtx); |
| 12328 | if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) ) |
| 12329 | { |
| 12330 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddDevTmUnregisterNotifyCallback failed",__func__); |
| 12331 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12332 | |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 12333 | //Stop the traffic monitor timer |
Mahesh A Saptasagar | d461e43 | 2016-07-20 15:01:40 +0530 | [diff] [blame] | 12334 | if ((pHddCtx->cfg_ini->dynSplitscan) && (VOS_TIMER_STATE_RUNNING == |
| 12335 | vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr))) |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 12336 | { |
| 12337 | vos_timer_stop(&pHddCtx->tx_rx_trafficTmr); |
| 12338 | } |
| 12339 | |
| 12340 | // Destroy the traffic monitor timer |
Mahesh A Saptasagar | d461e43 | 2016-07-20 15:01:40 +0530 | [diff] [blame] | 12341 | if ((pHddCtx->cfg_ini->dynSplitscan) && |
| 12342 | (!VOS_IS_STATUS_SUCCESS(vos_timer_destroy( |
| 12343 | &pHddCtx->tx_rx_trafficTmr)))) |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 12344 | { |
| 12345 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 12346 | "%s: Cannot deallocate Traffic monitor timer", __func__); |
| 12347 | } |
| 12348 | |
Bhargav Shah | d071591 | 2015-10-01 18:17:37 +0530 | [diff] [blame] | 12349 | if (VOS_TIMER_STATE_RUNNING == |
| 12350 | vos_timer_getCurrentState(&pHddCtx->delack_timer)) { |
| 12351 | vos_timer_stop(&pHddCtx->delack_timer); |
| 12352 | } |
| 12353 | |
| 12354 | if (!VOS_IS_STATUS_SUCCESS(vos_timer_destroy( |
| 12355 | &pHddCtx->delack_timer))) { |
| 12356 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 12357 | "%s: Cannot deallocate Bus bandwidth timer", __func__); |
| 12358 | } |
| 12359 | |
Masti, Narayanraddi | 44b0db0 | 2015-12-22 11:54:35 +0530 | [diff] [blame] | 12360 | if (VOS_TIMER_STATE_RUNNING == |
| 12361 | vos_timer_getCurrentState(&pHddCtx->tdls_source_timer)) { |
| 12362 | vos_timer_stop(&pHddCtx->tdls_source_timer); |
| 12363 | } |
| 12364 | |
Abhishek Singh | 8a3e4dc | 2017-01-02 10:39:18 +0530 | [diff] [blame] | 12365 | vos_set_snoc_high_freq_voting(false); |
| 12366 | |
Masti, Narayanraddi | 44b0db0 | 2015-12-22 11:54:35 +0530 | [diff] [blame] | 12367 | vos_timer_destroy(&pHddCtx->tdls_source_timer); |
| 12368 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12369 | //Disable IMPS/BMPS as we do not want the device to enter any power |
| 12370 | //save mode during shutdown |
| 12371 | sme_DisablePowerSave(pHddCtx->hHal, ePMC_IDLE_MODE_POWER_SAVE); |
| 12372 | sme_DisablePowerSave(pHddCtx->hHal, ePMC_BEACON_MODE_POWER_SAVE); |
| 12373 | sme_DisablePowerSave(pHddCtx->hHal, ePMC_UAPSD_MODE_POWER_SAVE); |
| 12374 | |
| 12375 | //Ensure that device is in full power as we will touch H/W during vos_Stop |
| 12376 | init_completion(&powerContext.completion); |
| 12377 | powerContext.magic = POWER_CONTEXT_MAGIC; |
| 12378 | |
| 12379 | halStatus = sme_RequestFullPower(pHddCtx->hHal, hdd_full_power_callback, |
| 12380 | &powerContext, eSME_FULL_PWR_NEEDED_BY_HDD); |
| 12381 | |
| 12382 | if (eHAL_STATUS_SUCCESS != halStatus) |
| 12383 | { |
| 12384 | if (eHAL_STATUS_PMC_PENDING == halStatus) |
| 12385 | { |
| 12386 | /* request was sent -- wait for the response */ |
| 12387 | lrc = wait_for_completion_interruptible_timeout( |
| 12388 | &powerContext.completion, |
| 12389 | msecs_to_jiffies(WLAN_WAIT_TIME_POWER)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12390 | if (lrc <= 0) |
| 12391 | { |
| 12392 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s while requesting full power", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 12393 | __func__, (0 == lrc) ? "timeout" : "interrupt"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12394 | } |
| 12395 | } |
| 12396 | else |
| 12397 | { |
| 12398 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 12399 | "%s: Request for Full Power failed, status %d", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 12400 | __func__, halStatus); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12401 | /* continue -- need to clean up as much as possible */ |
| 12402 | } |
| 12403 | } |
Hanumantha Reddy Pothula | 81b42b2 | 2015-05-12 13:52:00 +0530 | [diff] [blame] | 12404 | if ((eHAL_STATUS_SUCCESS == halStatus) || |
| 12405 | (eHAL_STATUS_PMC_PENDING == halStatus && lrc > 0)) |
| 12406 | { |
| 12407 | /* This will issue a dump command which will clean up |
| 12408 | BTQM queues and unblock MC thread */ |
| 12409 | vos_fwDumpReq(274, 0, 0, 0, 0, 1); |
| 12410 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12411 | |
Jeff Johnson | 72a4051 | 2013-12-19 10:14:15 -0800 | [diff] [blame] | 12412 | /* either we never sent a request, we sent a request and received a |
| 12413 | response or we sent a request and timed out. if we never sent a |
| 12414 | request or if we sent a request and got a response, we want to |
| 12415 | clear the magic out of paranoia. if we timed out there is a |
| 12416 | race condition such that the callback function could be |
| 12417 | executing at the same time we are. of primary concern is if the |
| 12418 | callback function had already verified the "magic" but had not |
| 12419 | yet set the completion variable when a timeout occurred. we |
| 12420 | serialize these activities by invalidating the magic while |
| 12421 | holding a shared spinlock which will cause us to block if the |
| 12422 | callback is currently executing */ |
| 12423 | spin_lock(&hdd_context_lock); |
| 12424 | powerContext.magic = 0; |
| 12425 | spin_unlock(&hdd_context_lock); |
| 12426 | |
Hema Aparna Medicharla | a6cf65e | 2015-06-01 16:23:28 +0530 | [diff] [blame] | 12427 | /* If Device is shutdown, no point for SME to wait for responses |
| 12428 | from device. Pre Close SME */ |
| 12429 | if(wcnss_device_is_shutdown()) |
| 12430 | { |
| 12431 | sme_PreClose(pHddCtx->hHal); |
| 12432 | } |
Yue Ma | 0d4891e | 2013-08-06 17:01:45 -0700 | [diff] [blame] | 12433 | hdd_debugfs_exit(pHddCtx); |
| 12434 | |
Ratheesh S P | 35ed8b1 | 2015-04-27 14:01:07 +0530 | [diff] [blame] | 12435 | #ifdef WLAN_NS_OFFLOAD |
Ratheesh S P | 36dbc93 | 2015-08-07 14:28:57 +0530 | [diff] [blame] | 12436 | hddLog(LOG1, FL("Unregister IPv6 notifier")); |
Ratheesh S P | 35ed8b1 | 2015-04-27 14:01:07 +0530 | [diff] [blame] | 12437 | unregister_inet6addr_notifier(&pHddCtx->ipv6_notifier); |
| 12438 | #endif |
Ratheesh S P | 36dbc93 | 2015-08-07 14:28:57 +0530 | [diff] [blame] | 12439 | hddLog(LOG1, FL("Unregister IPv4 notifier")); |
Ratheesh S P | 35ed8b1 | 2015-04-27 14:01:07 +0530 | [diff] [blame] | 12440 | unregister_inetaddr_notifier(&pHddCtx->ipv4_notifier); |
| 12441 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12442 | // Unregister the Net Device Notifier |
| 12443 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 12444 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12445 | hdd_stop_all_adapters( pHddCtx ); |
| 12446 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12447 | #ifdef WLAN_BTAMP_FEATURE |
| 12448 | vosStatus = WLANBAP_Stop(pVosContext); |
| 12449 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) |
| 12450 | { |
| 12451 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 12452 | "%s: Failed to stop BAP",__func__); |
| 12453 | } |
| 12454 | #endif //WLAN_BTAMP_FEATURE |
| 12455 | |
| 12456 | //Stop all the modules |
| 12457 | vosStatus = vos_stop( pVosContext ); |
| 12458 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) |
| 12459 | { |
| 12460 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 12461 | "%s: Failed to stop VOSS",__func__); |
| 12462 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) ); |
Hanumantha Reddy Pothula | bd9601a | 2016-02-12 13:22:27 +0530 | [diff] [blame] | 12463 | if (isSsrPanicOnFailure()) |
| 12464 | VOS_BUG(0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12465 | } |
| 12466 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12467 | //This requires pMac access, Call this before vos_close(). |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12468 | hdd_unregister_mcast_bcast_filter(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12469 | |
| 12470 | //Close the scheduler before calling vos_close to make sure no thread is |
| 12471 | // scheduled after the each module close is called i.e after all the data |
| 12472 | // structures are freed. |
| 12473 | vosStatus = vos_sched_close( pVosContext ); |
| 12474 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) { |
| 12475 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, |
| 12476 | "%s: Failed to close VOSS Scheduler",__func__); |
| 12477 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) ); |
| 12478 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 12479 | #ifdef WLAN_FEATURE_HOLD_RX_WAKELOCK |
| 12480 | /* Destroy the wake lock */ |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 12481 | vos_wake_lock_destroy(&pHddCtx->rx_wake_lock); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 12482 | #endif |
Madan Mohan Koyyalamudi | 69fc3ad | 2012-11-28 16:04:56 -0800 | [diff] [blame] | 12483 | /* Destroy the wake lock */ |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 12484 | vos_wake_lock_destroy(&pHddCtx->sap_wake_lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12485 | |
Mihir Shete | 7a24b5f | 2013-12-21 12:18:31 +0530 | [diff] [blame] | 12486 | #ifdef CONFIG_ENABLE_LINUX_REG |
| 12487 | vosStatus = vos_nv_close(); |
| 12488 | if (!VOS_IS_STATUS_SUCCESS(vosStatus)) |
| 12489 | { |
| 12490 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 12491 | "%s: Failed to close NV", __func__); |
| 12492 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( vosStatus ) ); |
| 12493 | } |
| 12494 | #endif |
| 12495 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12496 | //Close VOSS |
| 12497 | //This frees pMac(HAL) context. There should not be any call that requires pMac access after this. |
| 12498 | vos_close(pVosContext); |
| 12499 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12500 | //Close Watchdog |
| 12501 | if(pHddCtx->cfg_ini->fIsLogpEnabled) |
| 12502 | vos_watchdog_close(pVosContext); |
| 12503 | |
Gopichand Nakkala | a035848 | 2013-06-12 17:05:47 +0530 | [diff] [blame] | 12504 | //Clean up HDD Nlink Service |
| 12505 | send_btc_nlink_msg(WLAN_MODULE_DOWN_IND, 0); |
Gopichand Nakkala | a035848 | 2013-06-12 17:05:47 +0530 | [diff] [blame] | 12506 | |
Manjeet Singh | 47ee847 | 2016-04-11 11:57:18 +0530 | [diff] [blame] | 12507 | hdd_close_tx_queues(pHddCtx); |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 12508 | wlan_free_fwr_mem_dump_buffer(); |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 12509 | |
Vinay Krishna Eranna | d938c42 | 2014-03-10 17:14:21 +0530 | [diff] [blame] | 12510 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 12511 | if (pHddCtx->cfg_ini->wlanLoggingEnable) |
Vinay Krishna Eranna | d938c42 | 2014-03-10 17:14:21 +0530 | [diff] [blame] | 12512 | { |
| 12513 | wlan_logging_sock_deactivate_svc(); |
| 12514 | } |
| 12515 | #endif |
| 12516 | |
Vinay Krishna Eranna | ef30b52 | 2014-08-26 17:48:16 +0530 | [diff] [blame] | 12517 | #ifdef WLAN_KD_READY_NOTIFIER |
| 12518 | nl_srv_exit(pHddCtx->ptt_pid); |
| 12519 | #else |
| 12520 | nl_srv_exit(); |
| 12521 | #endif /* WLAN_KD_READY_NOTIFIER */ |
| 12522 | |
Abhishek Singh | 00b7197 | 2016-01-07 10:51:04 +0530 | [diff] [blame] | 12523 | #ifdef WLAN_FEATURE_RMC |
| 12524 | hdd_close_cesium_nl_sock(); |
| 12525 | #endif /* WLAN_FEATURE_RMC */ |
Vinay Krishna Eranna | ef30b52 | 2014-08-26 17:48:16 +0530 | [diff] [blame] | 12526 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12527 | hdd_close_all_adapters( pHddCtx ); |
| 12528 | |
Padma, Santhosh Kumar | 9cd3833 | 2015-11-17 12:18:10 +0530 | [diff] [blame] | 12529 | vos_flush_delayed_work(&pHddCtx->spoof_mac_addr_work); |
Abhishek Singh | 78c691f | 2017-11-30 13:48:44 +0530 | [diff] [blame] | 12530 | vos_flush_delayed_work(&pHddCtx->ecsa_chan_change_work); |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 12531 | vos_flush_work(&pHddCtx->sap_start_work); |
Padma, Santhosh Kumar | 9cd3833 | 2015-11-17 12:18:10 +0530 | [diff] [blame] | 12532 | |
Hanumantha Reddy Pothula | 97f9bc9 | 2015-08-10 17:21:20 +0530 | [diff] [blame] | 12533 | free_hdd_ctx: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12534 | /* free the power on lock from platform driver */ |
| 12535 | if (free_riva_power_on_lock("wlan")) |
| 12536 | { |
| 12537 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to free power on lock", |
| 12538 | __func__); |
| 12539 | } |
| 12540 | |
Ashish Kumar Dhanotiya | 95e5bc2 | 2018-04-19 17:06:33 +0530 | [diff] [blame] | 12541 | /* Free the cache channels of the command SET_DISABLE_CHANNEL_LIST */ |
| 12542 | wlan_hdd_free_cache_channels(pHddCtx); |
| 12543 | |
c_hpothu | 78c7b60 | 2014-05-17 17:35:49 +0530 | [diff] [blame] | 12544 | //Free up dynamically allocated members inside HDD Adapter |
| 12545 | if (pHddCtx->cfg_ini) |
| 12546 | { |
| 12547 | kfree(pHddCtx->cfg_ini); |
| 12548 | pHddCtx->cfg_ini= NULL; |
| 12549 | } |
| 12550 | |
Hanumanth Reddy Pothula | 1efcd16 | 2018-03-14 14:32:27 +0530 | [diff] [blame] | 12551 | hdd_request_manager_deinit(); |
| 12552 | |
Hanumantha Reddy Pothula | 6fe221c | 2016-01-28 15:01:09 +0530 | [diff] [blame] | 12553 | /* FTM/MONITOR mode, WIPHY did not registered |
Leo Chang | f04ddad | 2013-09-18 13:46:38 -0700 | [diff] [blame] | 12554 | If un-register here, system crash will happen */ |
Hanumantha Reddy Pothula | 6fe221c | 2016-01-28 15:01:09 +0530 | [diff] [blame] | 12555 | if (!(VOS_FTM_MODE == hdd_get_conparam() || |
| 12556 | VOS_MONITOR_MODE == hdd_get_conparam())) |
Leo Chang | f04ddad | 2013-09-18 13:46:38 -0700 | [diff] [blame] | 12557 | { |
| 12558 | wiphy_unregister(wiphy) ; |
Agrawal Ashish | 33ec71e | 2015-11-26 20:20:58 +0530 | [diff] [blame] | 12559 | hdd_wlan_free_wiphy_channels(wiphy); |
Leo Chang | f04ddad | 2013-09-18 13:46:38 -0700 | [diff] [blame] | 12560 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12561 | wiphy_free(wiphy) ; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12562 | if (hdd_is_ssr_required()) |
| 12563 | { |
| 12564 | /* WDI timeout had happened during unload, so SSR is needed here */ |
Madan Mohan Koyyalamudi | 3246f5b | 2012-10-15 15:40:02 -0700 | [diff] [blame] | 12565 | subsystem_restart("wcnss"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12566 | msleep(5000); |
| 12567 | } |
| 12568 | hdd_set_ssr_required (VOS_FALSE); |
| 12569 | } |
| 12570 | |
| 12571 | |
| 12572 | /**--------------------------------------------------------------------------- |
| 12573 | |
| 12574 | \brief hdd_update_config_from_nv() - Function to update the contents of |
| 12575 | the running configuration with parameters taken from NV storage |
| 12576 | |
| 12577 | \param - pHddCtx - Pointer to the HDD global context |
| 12578 | |
| 12579 | \return - VOS_STATUS_SUCCESS if successful |
| 12580 | |
| 12581 | --------------------------------------------------------------------------*/ |
| 12582 | static VOS_STATUS hdd_update_config_from_nv(hdd_context_t* pHddCtx) |
| 12583 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12584 | v_BOOL_t itemIsValid = VOS_FALSE; |
| 12585 | VOS_STATUS status; |
| 12586 | v_MACADDR_t macFromNV[VOS_MAX_CONCURRENCY_PERSONA]; |
| 12587 | v_U8_t macLoop; |
| 12588 | |
| 12589 | /*If the NV is valid then get the macaddress from nv else get it from qcom_cfg.ini*/ |
| 12590 | status = vos_nv_getValidity(VNV_FIELD_IMAGE, &itemIsValid); |
| 12591 | if(status != VOS_STATUS_SUCCESS) |
| 12592 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 12593 | hddLog(VOS_TRACE_LEVEL_ERROR," vos_nv_getValidity() failed"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12594 | return VOS_STATUS_E_FAILURE; |
| 12595 | } |
| 12596 | |
| 12597 | if (itemIsValid == VOS_TRUE) |
| 12598 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 12599 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH," Reading the Macaddress from NV"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12600 | status = vos_nv_readMultiMacAddress((v_U8_t *)&macFromNV[0].bytes[0], |
| 12601 | VOS_MAX_CONCURRENCY_PERSONA); |
| 12602 | if(status != VOS_STATUS_SUCCESS) |
| 12603 | { |
| 12604 | /* Get MAC from NV fail, not update CFG info |
| 12605 | * INI MAC value will be used for MAC setting */ |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 12606 | hddLog(VOS_TRACE_LEVEL_ERROR," vos_nv_readMacAddress() failed"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12607 | return VOS_STATUS_E_FAILURE; |
| 12608 | } |
| 12609 | |
| 12610 | /* If first MAC is not valid, treat all others are not valid |
| 12611 | * Then all MACs will be got from ini file */ |
| 12612 | if(vos_is_macaddr_zero(&macFromNV[0])) |
| 12613 | { |
| 12614 | /* MAC address in NV file is not configured yet */ |
| 12615 | hddLog(VOS_TRACE_LEVEL_WARN, "Invalid MAC in NV file"); |
| 12616 | return VOS_STATUS_E_INVAL; |
| 12617 | } |
| 12618 | |
| 12619 | /* Get MAC address from NV, update CFG info */ |
| 12620 | for(macLoop = 0; macLoop < VOS_MAX_CONCURRENCY_PERSONA; macLoop++) |
| 12621 | { |
| 12622 | if(vos_is_macaddr_zero(&macFromNV[macLoop])) |
| 12623 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 12624 | 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] | 12625 | /* This MAC is not valid, skip it |
| 12626 | * This MAC will be got from ini file */ |
| 12627 | } |
| 12628 | else |
| 12629 | { |
| 12630 | vos_mem_copy((v_U8_t *)&pHddCtx->cfg_ini->intfMacAddr[macLoop].bytes[0], |
| 12631 | (v_U8_t *)&macFromNV[macLoop].bytes[0], |
| 12632 | VOS_MAC_ADDR_SIZE); |
| 12633 | } |
| 12634 | } |
| 12635 | } |
| 12636 | else |
| 12637 | { |
| 12638 | hddLog(VOS_TRACE_LEVEL_ERROR, "NV ITEM, MAC Not valid"); |
| 12639 | return VOS_STATUS_E_FAILURE; |
| 12640 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12641 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12642 | |
| 12643 | return VOS_STATUS_SUCCESS; |
| 12644 | } |
| 12645 | |
| 12646 | /**--------------------------------------------------------------------------- |
| 12647 | |
| 12648 | \brief hdd_post_voss_start_config() - HDD post voss start config helper |
| 12649 | |
| 12650 | \param - pAdapter - Pointer to the HDD |
| 12651 | |
| 12652 | \return - None |
| 12653 | |
| 12654 | --------------------------------------------------------------------------*/ |
| 12655 | VOS_STATUS hdd_post_voss_start_config(hdd_context_t* pHddCtx) |
| 12656 | { |
| 12657 | eHalStatus halStatus; |
| 12658 | v_U32_t listenInterval; |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 12659 | tANI_U32 ignoreDtim; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12660 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12661 | |
| 12662 | // Send ready indication to the HDD. This will kick off the MAC |
| 12663 | // into a 'running' state and should kick off an initial scan. |
| 12664 | halStatus = sme_HDDReadyInd( pHddCtx->hHal ); |
| 12665 | if ( !HAL_STATUS_SUCCESS( halStatus ) ) |
| 12666 | { |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 12667 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: sme_HDDReadyInd() failed with status " |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12668 | "code %08d [x%08x]",__func__, halStatus, halStatus ); |
| 12669 | return VOS_STATUS_E_FAILURE; |
| 12670 | } |
| 12671 | |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 12672 | // Set default LI and ignoreDtim into HDD context, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12673 | // otherwise under some race condition, HDD will set 0 LI value into RIVA, |
| 12674 | // And RIVA will crash |
| 12675 | wlan_cfgGetInt(pHddCtx->hHal, WNI_CFG_LISTEN_INTERVAL, &listenInterval); |
| 12676 | pHddCtx->hdd_actual_LI_value = listenInterval; |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 12677 | wlan_cfgGetInt(pHddCtx->hHal, WNI_CFG_IGNORE_DTIM, &ignoreDtim); |
| 12678 | pHddCtx->hdd_actual_ignore_DTIM_value = ignoreDtim; |
| 12679 | |
| 12680 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12681 | return VOS_STATUS_SUCCESS; |
| 12682 | } |
| 12683 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12684 | /* wake lock APIs for HDD */ |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 12685 | void hdd_prevent_suspend(uint32_t reason) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12686 | { |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 12687 | |
| 12688 | vos_wake_lock_acquire(&wlan_wake_lock, reason); |
| 12689 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12690 | } |
| 12691 | |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 12692 | void hdd_allow_suspend(uint32_t reason) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12693 | { |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 12694 | |
| 12695 | vos_wake_lock_release(&wlan_wake_lock, reason); |
| 12696 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12697 | } |
| 12698 | |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 12699 | 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] | 12700 | { |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 12701 | |
| 12702 | vos_wake_lock_timeout_release(&wlan_wake_lock, timeout, |
| 12703 | reason); |
| 12704 | |
Madan Mohan Koyyalamudi | 10d83a9 | 2012-09-28 15:47:05 -0700 | [diff] [blame] | 12705 | } |
| 12706 | |
Rajeev Kumar Sirasanagandla | 4c068d4 | 2019-02-22 21:39:36 +0530 | [diff] [blame] | 12707 | /** |
| 12708 | * hdd_get_feature_caps_cb() - Callback invoked from WDA |
| 12709 | * @cookie: to identify HDD request to firmware |
| 12710 | * |
| 12711 | * This function is invoked from WDA when feature capabilities response |
| 12712 | * is received from firmware. |
| 12713 | * |
| 12714 | * Return: None |
| 12715 | */ |
| 12716 | static void hdd_get_feature_caps_cb(void *cookie) |
| 12717 | { |
| 12718 | struct hdd_request *request; |
| 12719 | |
| 12720 | request = hdd_request_get(cookie); |
| 12721 | if (!request) { |
| 12722 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Obsolete request")); |
| 12723 | return; |
| 12724 | } |
| 12725 | |
| 12726 | pr_info("%s: Firmware feature capabilities received\n", __func__); |
| 12727 | |
| 12728 | hdd_request_complete(request); |
| 12729 | hdd_request_put(request); |
| 12730 | } |
| 12731 | |
| 12732 | /** |
| 12733 | * hdd_get_feature_caps() - Get features supported by firmware |
| 12734 | * @hdd_ctx: Pointer to HDD context |
| 12735 | * |
| 12736 | * This function uses request manager framework to get the feature |
| 12737 | * capabilities from firmware. |
| 12738 | * |
| 12739 | * Return: None |
| 12740 | */ |
| 12741 | static void hdd_get_feature_caps(hdd_context_t *hdd_ctx) |
| 12742 | { |
| 12743 | VOS_STATUS status; |
| 12744 | void *cookie; |
| 12745 | int ret; |
| 12746 | struct hdd_request *request; |
| 12747 | static const struct hdd_request_params params = { |
| 12748 | .priv_size = 0, |
| 12749 | .timeout_ms = WLAN_WAIT_TIME_FEATURE_CAPS, |
| 12750 | }; |
| 12751 | struct sir_feature_caps_params caps_params = {0}; |
| 12752 | |
| 12753 | request = hdd_request_alloc(¶ms); |
| 12754 | if (!request) { |
| 12755 | pr_err("%s: Request allocation failure\n", __func__); |
| 12756 | return; |
| 12757 | } |
| 12758 | |
| 12759 | cookie = hdd_request_cookie(request); |
| 12760 | caps_params.user_data = cookie; |
| 12761 | caps_params.feature_caps_cb = hdd_get_feature_caps_cb; |
| 12762 | |
| 12763 | status = sme_featureCapsExchange(&caps_params); |
| 12764 | if (status != VOS_STATUS_SUCCESS) { |
| 12765 | pr_err("%s: Unable to get feature caps\n", __func__); |
| 12766 | goto end; |
| 12767 | } |
| 12768 | |
| 12769 | /* request was sent -- wait for the response */ |
| 12770 | ret = hdd_request_wait_for_response(request); |
| 12771 | if (ret) { |
| 12772 | pr_err("%s: SME timeout while retrieving feature caps\n", |
| 12773 | __func__); |
| 12774 | goto end; |
| 12775 | } |
| 12776 | |
| 12777 | end: |
| 12778 | hdd_request_put(request); |
| 12779 | } |
| 12780 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 12781 | /**--------------------------------------------------------------------------- |
| 12782 | |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 12783 | \brief hdd_exchange_version_and_caps() - HDD function to exchange version and capability |
| 12784 | information between Host and Riva |
| 12785 | |
| 12786 | This function gets reported version of FW |
| 12787 | It also finds the version of Riva headers used to compile the host |
| 12788 | It compares the above two and prints a warning if they are different |
| 12789 | It gets the SW and HW version string |
| 12790 | Finally, it exchanges capabilities between host and Riva i.e. host and riva exchange a msg |
| 12791 | indicating the features they support through a bitmap |
| 12792 | |
| 12793 | \param - pHddCtx - Pointer to HDD context |
| 12794 | |
| 12795 | \return - void |
| 12796 | |
| 12797 | --------------------------------------------------------------------------*/ |
| 12798 | |
| 12799 | void hdd_exchange_version_and_caps(hdd_context_t *pHddCtx) |
| 12800 | { |
| 12801 | |
| 12802 | tSirVersionType versionCompiled; |
| 12803 | tSirVersionType versionReported; |
| 12804 | tSirVersionString versionString; |
| 12805 | tANI_U8 fwFeatCapsMsgSupported = 0; |
| 12806 | VOS_STATUS vstatus; |
| 12807 | |
Mingcheng Zhu | 87f22fc | 2014-01-30 19:23:32 -0800 | [diff] [blame] | 12808 | memset(&versionCompiled, 0, sizeof(versionCompiled)); |
| 12809 | memset(&versionReported, 0, sizeof(versionReported)); |
| 12810 | |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 12811 | /* retrieve and display WCNSS version information */ |
| 12812 | do { |
| 12813 | |
| 12814 | vstatus = sme_GetWcnssWlanCompiledVersion(pHddCtx->hHal, |
| 12815 | &versionCompiled); |
| 12816 | if (!VOS_IS_STATUS_SUCCESS(vstatus)) |
| 12817 | { |
| 12818 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 12819 | "%s: unable to retrieve WCNSS WLAN compiled version", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 12820 | __func__); |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 12821 | break; |
| 12822 | } |
| 12823 | |
| 12824 | vstatus = sme_GetWcnssWlanReportedVersion(pHddCtx->hHal, |
| 12825 | &versionReported); |
| 12826 | if (!VOS_IS_STATUS_SUCCESS(vstatus)) |
| 12827 | { |
| 12828 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 12829 | "%s: unable to retrieve WCNSS WLAN reported version", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 12830 | __func__); |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 12831 | break; |
| 12832 | } |
| 12833 | |
| 12834 | if ((versionCompiled.major != versionReported.major) || |
| 12835 | (versionCompiled.minor != versionReported.minor) || |
| 12836 | (versionCompiled.version != versionReported.version) || |
| 12837 | (versionCompiled.revision != versionReported.revision)) |
| 12838 | { |
| 12839 | pr_err("%s: WCNSS WLAN Version %u.%u.%u.%u, " |
| 12840 | "Host expected %u.%u.%u.%u\n", |
| 12841 | WLAN_MODULE_NAME, |
| 12842 | (int)versionReported.major, |
| 12843 | (int)versionReported.minor, |
| 12844 | (int)versionReported.version, |
| 12845 | (int)versionReported.revision, |
| 12846 | (int)versionCompiled.major, |
| 12847 | (int)versionCompiled.minor, |
| 12848 | (int)versionCompiled.version, |
| 12849 | (int)versionCompiled.revision); |
| 12850 | } |
| 12851 | else |
| 12852 | { |
| 12853 | pr_info("%s: WCNSS WLAN version %u.%u.%u.%u\n", |
| 12854 | WLAN_MODULE_NAME, |
| 12855 | (int)versionReported.major, |
| 12856 | (int)versionReported.minor, |
| 12857 | (int)versionReported.version, |
| 12858 | (int)versionReported.revision); |
| 12859 | } |
| 12860 | |
| 12861 | vstatus = sme_GetWcnssSoftwareVersion(pHddCtx->hHal, |
| 12862 | versionString, |
| 12863 | sizeof(versionString)); |
| 12864 | if (!VOS_IS_STATUS_SUCCESS(vstatus)) |
| 12865 | { |
| 12866 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 12867 | "%s: unable to retrieve WCNSS software version string", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 12868 | __func__); |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 12869 | break; |
| 12870 | } |
| 12871 | |
| 12872 | pr_info("%s: WCNSS software version %s\n", |
| 12873 | WLAN_MODULE_NAME, versionString); |
Sushant Kaushik | 084f659 | 2015-09-10 13:11:56 +0530 | [diff] [blame] | 12874 | vos_mem_copy(pHddCtx->fw_Version, versionString, sizeof(versionString)); |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 12875 | |
| 12876 | vstatus = sme_GetWcnssHardwareVersion(pHddCtx->hHal, |
| 12877 | versionString, |
| 12878 | sizeof(versionString)); |
| 12879 | if (!VOS_IS_STATUS_SUCCESS(vstatus)) |
| 12880 | { |
| 12881 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 12882 | "%s: unable to retrieve WCNSS hardware version string", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 12883 | __func__); |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 12884 | break; |
| 12885 | } |
| 12886 | |
| 12887 | pr_info("%s: WCNSS hardware version %s\n", |
| 12888 | WLAN_MODULE_NAME, versionString); |
| 12889 | |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 12890 | /* 1.Check if FW version is greater than 0.1.1.0. Only then send host-FW capability exchange message |
| 12891 | 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] | 12892 | send the message only if it the riva is 1.1 |
| 12893 | minor numbers for different riva branches: |
| 12894 | 0 -> (1.0)Mainline Build |
| 12895 | 1 -> (1.1)Mainline Build |
| 12896 | 2->(1.04) Stability Build |
| 12897 | */ |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 12898 | if (((versionReported.major>0) || (versionReported.minor>1) || |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 12899 | ((versionReported.minor>=1) && (versionReported.version>=1))) |
| 12900 | && ((versionReported.major == 1) && (versionReported.minor >= 1))) |
| 12901 | fwFeatCapsMsgSupported = 1; |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 12902 | |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 12903 | if (fwFeatCapsMsgSupported) |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 12904 | { |
| 12905 | #ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE |
| 12906 | if(!pHddCtx->cfg_ini->fEnableActiveModeOffload) |
| 12907 | sme_disableFeatureCapablity(WLANACTIVE_OFFLOAD); |
| 12908 | #endif |
Ravi Joshi | d2ca7c4 | 2013-07-23 08:37:49 -0700 | [diff] [blame] | 12909 | /* Indicate if IBSS heartbeat monitoring needs to be offloaded */ |
| 12910 | if (!pHddCtx->cfg_ini->enableIbssHeartBeatOffload) |
| 12911 | { |
| 12912 | sme_disableFeatureCapablity(IBSS_HEARTBEAT_OFFLOAD); |
| 12913 | } |
| 12914 | |
Rajeev Kumar Sirasanagandla | 4c068d4 | 2019-02-22 21:39:36 +0530 | [diff] [blame] | 12915 | hdd_get_feature_caps(pHddCtx); |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 12916 | } |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 12917 | |
| 12918 | } while (0); |
| 12919 | |
| 12920 | } |
Rajeev Kumar Sirasanagandla | 4c068d4 | 2019-02-22 21:39:36 +0530 | [diff] [blame] | 12921 | |
Neelansh Mittal | edafed2 | 2014-09-04 18:54:39 +0530 | [diff] [blame] | 12922 | void wlan_hdd_send_svc_nlink_msg(int type, void *data, int len) |
| 12923 | { |
| 12924 | struct sk_buff *skb; |
| 12925 | struct nlmsghdr *nlh; |
| 12926 | tAniMsgHdr *ani_hdr; |
Hanumantha Reddy Pothula | cf2c7ea | 2015-04-27 14:50:47 +0530 | [diff] [blame] | 12927 | int flags = GFP_KERNEL; |
Bhargav shah | 23c9494 | 2015-10-13 12:48:35 +0530 | [diff] [blame] | 12928 | void *nl_data = NULL; |
Neelansh Mittal | edafed2 | 2014-09-04 18:54:39 +0530 | [diff] [blame] | 12929 | |
Hanumantha Reddy Pothula | cf2c7ea | 2015-04-27 14:50:47 +0530 | [diff] [blame] | 12930 | if (in_interrupt() || irqs_disabled() || in_atomic()) |
| 12931 | flags = GFP_ATOMIC; |
| 12932 | |
| 12933 | skb = alloc_skb(NLMSG_SPACE(WLAN_NL_MAX_PAYLOAD), flags); |
Neelansh Mittal | edafed2 | 2014-09-04 18:54:39 +0530 | [diff] [blame] | 12934 | |
| 12935 | if(skb == NULL) { |
| 12936 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 12937 | "%s: alloc_skb failed", __func__); |
| 12938 | return; |
| 12939 | } |
| 12940 | |
| 12941 | nlh = (struct nlmsghdr *)skb->data; |
| 12942 | nlh->nlmsg_pid = 0; /* from kernel */ |
| 12943 | nlh->nlmsg_flags = 0; |
| 12944 | nlh->nlmsg_seq = 0; |
| 12945 | nlh->nlmsg_type = WLAN_NL_MSG_SVC; |
| 12946 | |
| 12947 | ani_hdr = NLMSG_DATA(nlh); |
| 12948 | ani_hdr->type = type; |
| 12949 | |
| 12950 | switch(type) { |
| 12951 | case WLAN_SVC_SAP_RESTART_IND: |
| 12952 | ani_hdr->length = 0; |
| 12953 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr))); |
| 12954 | skb_put(skb, NLMSG_SPACE(sizeof(tAniMsgHdr))); |
| 12955 | break; |
Bhargav Shah | d071591 | 2015-10-01 18:17:37 +0530 | [diff] [blame] | 12956 | case WLAN_SVC_WLAN_TP_IND: |
| 12957 | ani_hdr->length = len; |
| 12958 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr) |
| 12959 | + len)); |
| 12960 | nl_data = (char *)ani_hdr + sizeof(tAniMsgHdr); |
| 12961 | memcpy(nl_data, data, len); |
| 12962 | skb_put(skb, NLMSG_SPACE(sizeof(tAniMsgHdr) + len)); |
| 12963 | break; |
Bhargav shah | 23c9494 | 2015-10-13 12:48:35 +0530 | [diff] [blame] | 12964 | case WLAN_MSG_RPS_ENABLE_IND: |
| 12965 | ani_hdr->length = len; |
| 12966 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr) + len)); |
| 12967 | nl_data = (char *)ani_hdr + sizeof(tAniMsgHdr); |
| 12968 | memcpy(nl_data, data, len); |
| 12969 | skb_put(skb, NLMSG_SPACE(sizeof(tAniMsgHdr) + len)); |
| 12970 | break; |
Neelansh Mittal | edafed2 | 2014-09-04 18:54:39 +0530 | [diff] [blame] | 12971 | default: |
| 12972 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 12973 | "Attempt to send unknown nlink message %d", type); |
| 12974 | kfree_skb(skb); |
| 12975 | return; |
| 12976 | } |
| 12977 | |
| 12978 | nl_srv_bcast(skb); |
| 12979 | |
| 12980 | return; |
| 12981 | } |
| 12982 | |
Bhargav Shah | d071591 | 2015-10-01 18:17:37 +0530 | [diff] [blame] | 12983 | /** |
| 12984 | * hdd_request_tcp_delack() - Find the Delack value based on RX packet |
| 12985 | * @pHddCtx: Valid Global HDD context pointer |
| 12986 | * @rx_packets: Number of RX packet in perticular time |
| 12987 | * |
| 12988 | * Based on the RX packet this function calculate next value of tcp delack. |
| 12989 | * This function compare rx packet value to high and low threshold limit. |
| 12990 | * |
| 12991 | * Return: void |
| 12992 | */ |
| 12993 | void hdd_request_tcp_delack(hdd_context_t *pHddCtx, uint64_t rx_packets) |
| 12994 | { |
| 12995 | /* average of rx_packets and prev_rx is taken so that |
| 12996 | bus width doesnot fluctuate much */ |
| 12997 | uint64_t temp_rx = (rx_packets + pHddCtx->prev_rx)/2; |
Alok Kumar | f372446 | 2018-04-05 15:18:54 +0530 | [diff] [blame] | 12998 | enum wlan_tp_level next_rx_level = pHddCtx->cur_rx_level; |
Neelansh Mittal | edafed2 | 2014-09-04 18:54:39 +0530 | [diff] [blame] | 12999 | |
Bhargav Shah | d071591 | 2015-10-01 18:17:37 +0530 | [diff] [blame] | 13000 | pHddCtx->prev_rx = rx_packets; |
| 13001 | if (temp_rx > pHddCtx->cfg_ini->tcpDelAckThresholdHigh) |
Alok Kumar | f372446 | 2018-04-05 15:18:54 +0530 | [diff] [blame] | 13002 | next_rx_level = WLAN_SVC_TP_HIGH; |
Bhargav Shah | d071591 | 2015-10-01 18:17:37 +0530 | [diff] [blame] | 13003 | else if (temp_rx <= pHddCtx->cfg_ini->tcpDelAckThresholdLow) |
Alok Kumar | f372446 | 2018-04-05 15:18:54 +0530 | [diff] [blame] | 13004 | next_rx_level = WLAN_SVC_TP_LOW; |
Bhargav Shah | d071591 | 2015-10-01 18:17:37 +0530 | [diff] [blame] | 13005 | |
| 13006 | hdd_set_delack_value(pHddCtx, next_rx_level); |
| 13007 | } |
| 13008 | |
| 13009 | #define HDD_BW_GET_DIFF(x, y) ((x) >= (y) ? (x) - (y) : (ULONG_MAX - (y) + (x))) |
| 13010 | |
| 13011 | /** |
| 13012 | * hdd_tcp_delack_compute_function() - get link status |
| 13013 | * @priv: Valid Global HDD context pointer |
| 13014 | * |
| 13015 | * This function find number of RX packet during timer life span. |
| 13016 | * It request tcp delack with number of RX packet and re-configure delack timer |
| 13017 | * for tcpDelAckComputeInterval timer interval. |
| 13018 | * |
| 13019 | * Return: void |
| 13020 | */ |
| 13021 | void hdd_tcp_delack_compute_function(void *priv) |
| 13022 | { |
| 13023 | hdd_context_t *pHddCtx = (hdd_context_t *)priv; |
| 13024 | hdd_adapter_t *pAdapter = NULL; |
| 13025 | v_U32_t rx_packets = 0; |
| 13026 | hdd_adapter_list_node_t *pAdapterNode = NULL; |
| 13027 | VOS_STATUS status = 0; |
| 13028 | |
| 13029 | for (status = hdd_get_front_adapter(pHddCtx, &pAdapterNode); |
| 13030 | NULL != pAdapterNode && VOS_STATUS_SUCCESS == status; |
| 13031 | status = hdd_get_next_adapter(pHddCtx, pAdapterNode, &pAdapterNode)) { |
| 13032 | if ((pAdapter = pAdapterNode->pAdapter) == NULL) |
| 13033 | continue; |
| 13034 | |
| 13035 | rx_packets += HDD_BW_GET_DIFF(pAdapter->stats.rx_packets, |
| 13036 | pAdapter->prev_rx_packets); |
| 13037 | pAdapter->prev_rx_packets = pAdapter->stats.rx_packets; |
| 13038 | } |
| 13039 | |
| 13040 | hdd_request_tcp_delack(pHddCtx, rx_packets); |
| 13041 | |
| 13042 | vos_timer_start(&pHddCtx->delack_timer, |
| 13043 | pHddCtx->cfg_ini->tcpDelAckComputeInterval); |
| 13044 | } |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 13045 | |
| 13046 | /**--------------------------------------------------------------------------- |
| 13047 | |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 13048 | \brief hdd_is_5g_supported() - HDD function to know if hardware supports 5GHz |
| 13049 | |
| 13050 | \param - pHddCtx - Pointer to the hdd context |
| 13051 | |
| 13052 | \return - true if hardware supports 5GHz |
| 13053 | |
| 13054 | --------------------------------------------------------------------------*/ |
Vinay Krishna Eranna | facf5e2 | 2014-02-24 13:16:25 +0530 | [diff] [blame] | 13055 | boolean hdd_is_5g_supported(hdd_context_t * pHddCtx) |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 13056 | { |
| 13057 | /* If wcnss_wlan_iris_xo_mode() returns WCNSS_XO_48MHZ(1); |
| 13058 | * then hardware support 5Ghz. |
| 13059 | */ |
| 13060 | if (WCNSS_XO_48MHZ == wcnss_wlan_iris_xo_mode()) |
| 13061 | { |
Ratheesh S P | 36dbc93 | 2015-08-07 14:28:57 +0530 | [diff] [blame] | 13062 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Hardware supports 5Ghz", __func__); |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 13063 | return true; |
| 13064 | } |
| 13065 | else |
| 13066 | { |
Ratheesh S P | 36dbc93 | 2015-08-07 14:28:57 +0530 | [diff] [blame] | 13067 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Hardware doesn't supports 5Ghz", |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 13068 | __func__); |
| 13069 | return false; |
| 13070 | } |
| 13071 | } |
| 13072 | |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 13073 | /**--------------------------------------------------------------------------- |
| 13074 | |
| 13075 | \brief hdd_generate_iface_mac_addr_auto() - HDD Mac Interface Auto |
| 13076 | generate function |
| 13077 | |
| 13078 | This is generate the random mac address for WLAN interface |
| 13079 | |
| 13080 | \param - pHddCtx - Pointer to HDD context |
| 13081 | idx - Start interface index to get auto |
| 13082 | generated mac addr. |
| 13083 | mac_addr - Mac address |
| 13084 | |
| 13085 | \return - 0 for success, < 0 for failure |
| 13086 | |
| 13087 | --------------------------------------------------------------------------*/ |
| 13088 | |
| 13089 | static int hdd_generate_iface_mac_addr_auto(hdd_context_t *pHddCtx, |
| 13090 | int idx, v_MACADDR_t mac_addr) |
| 13091 | { |
| 13092 | int i; |
| 13093 | unsigned int serialno; |
| 13094 | serialno = wcnss_get_serial_number(); |
| 13095 | |
| 13096 | if (0 != serialno) |
| 13097 | { |
| 13098 | /* MAC address has 3 bytes of OUI so we have a maximum of 3 |
| 13099 | bytes of the serial number that can be used to generate |
| 13100 | the other 3 bytes of the MAC address. Mask off all but |
| 13101 | the lower 3 bytes (this will also make sure we don't |
| 13102 | overflow in the next step) */ |
| 13103 | serialno &= 0x00FFFFFF; |
| 13104 | |
| 13105 | /* we need a unique address for each session */ |
| 13106 | serialno *= VOS_MAX_CONCURRENCY_PERSONA; |
| 13107 | |
| 13108 | /* autogen other Mac addresses */ |
| 13109 | for (i = idx; i < VOS_MAX_CONCURRENCY_PERSONA; i++) |
| 13110 | { |
| 13111 | /* start with the entire default address */ |
| 13112 | pHddCtx->cfg_ini->intfMacAddr[i] = mac_addr; |
| 13113 | /* then replace the lower 3 bytes */ |
| 13114 | pHddCtx->cfg_ini->intfMacAddr[i].bytes[3] = (serialno >> 16) & 0xFF; |
| 13115 | pHddCtx->cfg_ini->intfMacAddr[i].bytes[4] = (serialno >> 8) & 0xFF; |
| 13116 | pHddCtx->cfg_ini->intfMacAddr[i].bytes[5] = serialno & 0xFF; |
| 13117 | |
Nachiket Kukade | de2e24f | 2017-09-25 16:24:27 +0530 | [diff] [blame] | 13118 | if (0 == memcmp(&pHddCtx->cfg_ini->intfMacAddr[i].bytes[0], |
| 13119 | &mac_addr.bytes[0], VOS_MAC_ADDR_SIZE)) |
| 13120 | pHddCtx->cfg_ini->intfMacAddr[i].bytes[5] += |
| 13121 | VOS_MAX_CONCURRENCY_PERSONA; |
| 13122 | |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 13123 | serialno++; |
| 13124 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 13125 | "%s: Derived Mac Addr: " |
| 13126 | MAC_ADDRESS_STR, __func__, |
| 13127 | MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[i].bytes)); |
| 13128 | } |
| 13129 | |
| 13130 | } |
| 13131 | else |
| 13132 | { |
| 13133 | hddLog(LOGE, FL("Failed to Get Serial NO")); |
| 13134 | return -1; |
| 13135 | } |
| 13136 | return 0; |
| 13137 | } |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 13138 | |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 13139 | int wlan_hdd_mon_open(hdd_context_t *pHddCtx) |
| 13140 | { |
| 13141 | VOS_STATUS status; |
| 13142 | v_CONTEXT_t pVosContext= NULL; |
| 13143 | hdd_adapter_t *pAdapter= NULL; |
| 13144 | |
| 13145 | pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL); |
| 13146 | |
| 13147 | if (NULL == pVosContext) |
| 13148 | { |
| 13149 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 13150 | "%s: Trying to open VOSS without a PreOpen", __func__); |
| 13151 | VOS_ASSERT(0); |
| 13152 | return VOS_STATUS_E_FAILURE; |
| 13153 | } |
| 13154 | |
| 13155 | status = vos_nv_open(); |
| 13156 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 13157 | { |
| 13158 | /* NV module cannot be initialized */ |
| 13159 | hddLog( VOS_TRACE_LEVEL_FATAL, |
| 13160 | "%s: vos_nv_open failed", __func__); |
| 13161 | return VOS_STATUS_E_FAILURE; |
| 13162 | } |
| 13163 | |
| 13164 | status = vos_init_wiphy_from_nv_bin(); |
| 13165 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 13166 | { |
| 13167 | /* NV module cannot be initialized */ |
| 13168 | hddLog( VOS_TRACE_LEVEL_FATAL, |
| 13169 | "%s: vos_init_wiphy failed", __func__); |
| 13170 | goto err_vos_nv_close; |
| 13171 | } |
| 13172 | |
| 13173 | status = vos_open( &pVosContext, pHddCtx->parent_dev); |
| 13174 | if ( !VOS_IS_STATUS_SUCCESS( status )) |
| 13175 | { |
| 13176 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: vos_open failed", __func__); |
| 13177 | goto err_vos_nv_close; |
| 13178 | } |
| 13179 | |
| 13180 | status = vos_mon_start( pVosContext ); |
| 13181 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 13182 | { |
| 13183 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: vos_start failed",__func__); |
| 13184 | goto err_vosclose; |
| 13185 | } |
| 13186 | |
| 13187 | WLANTL_SetMonRxCbk( pVosContext, hdd_rx_packet_monitor_cbk ); |
Rajeev Kumar Sirasanagandla | 4c068d4 | 2019-02-22 21:39:36 +0530 | [diff] [blame] | 13188 | sme_featureCapsExchange(NULL); |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 13189 | wcnss_wlan_set_drvdata(pHddCtx->parent_dev, pHddCtx); |
| 13190 | |
| 13191 | pAdapter = hdd_open_adapter( pHddCtx, WLAN_HDD_MONITOR, "wlan%d", |
| 13192 | wlan_hdd_get_intf_addr(pHddCtx), FALSE ); |
| 13193 | if( pAdapter == NULL ) |
| 13194 | { |
| 13195 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: hdd_open_adapter failed", __func__); |
| 13196 | goto err_close_adapter; |
| 13197 | } |
| 13198 | |
| 13199 | //Initialize the nlink service |
| 13200 | if(nl_srv_init() != 0) |
| 13201 | { |
| 13202 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: nl_srv_init failed", __func__); |
| 13203 | goto err_close_adapter; |
| 13204 | } |
| 13205 | return VOS_STATUS_SUCCESS; |
| 13206 | |
| 13207 | err_close_adapter: |
| 13208 | hdd_close_all_adapters( pHddCtx ); |
| 13209 | vos_mon_stop( pVosContext ); |
| 13210 | err_vosclose: |
| 13211 | status = vos_sched_close( pVosContext ); |
| 13212 | if (!VOS_IS_STATUS_SUCCESS(status)) { |
| 13213 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, |
| 13214 | "%s: Failed to close VOSS Scheduler", __func__); |
| 13215 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( status ) ); |
| 13216 | } |
| 13217 | vos_close(pVosContext ); |
| 13218 | |
| 13219 | err_vos_nv_close: |
| 13220 | vos_nv_close(); |
| 13221 | |
| 13222 | return status; |
| 13223 | } |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 13224 | /**--------------------------------------------------------------------------- |
| 13225 | |
Mihir Shete | fc7ff5b | 2014-01-27 11:30:05 +0530 | [diff] [blame] | 13226 | \brief hdd_11d_scan_done - callback to be executed when 11d scan is |
| 13227 | completed to flush out the scan results |
| 13228 | |
| 13229 | 11d scan is done during driver load and is a passive scan on all |
| 13230 | channels supported by the device, 11d scans may find some APs on |
| 13231 | frequencies which are forbidden to be used in the regulatory domain |
| 13232 | the device is operating in. If these APs are notified to the supplicant |
| 13233 | it may try to connect to these APs, thus flush out all the scan results |
| 13234 | which are present in SME after 11d scan is done. |
| 13235 | |
| 13236 | \return - eHalStatus |
| 13237 | |
| 13238 | --------------------------------------------------------------------------*/ |
| 13239 | static eHalStatus hdd_11d_scan_done(tHalHandle halHandle, void *pContext, |
| 13240 | tANI_U32 scanId, eCsrScanStatus status) |
| 13241 | { |
| 13242 | ENTER(); |
| 13243 | |
| 13244 | sme_ScanFlushResult(halHandle, 0); |
| 13245 | |
| 13246 | EXIT(); |
| 13247 | |
| 13248 | return eHAL_STATUS_SUCCESS; |
| 13249 | } |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 13250 | /**--------------------------------------------------------------------------- |
| 13251 | |
| 13252 | \brief hdd_init_frame_logging_done - callback to be executed when mgmt frame |
| 13253 | logging is completed successfully. |
| 13254 | |
| 13255 | \return - None |
| 13256 | |
| 13257 | --------------------------------------------------------------------------*/ |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 13258 | void hdd_init_frame_logging_done(void *fwlogInitCbContext, tAniLoggingInitRsp *pRsp) |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 13259 | { |
Siddharth Bhal | d1be97f | 2015-05-27 22:39:59 +0530 | [diff] [blame] | 13260 | hdd_context_t* pHddCtx = (hdd_context_t*)fwlogInitCbContext; |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 13261 | |
| 13262 | if (NULL == pHddCtx) |
| 13263 | { |
| 13264 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 13265 | "%s: HDD context is NULL",__func__); |
| 13266 | return; |
| 13267 | } |
| 13268 | |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 13269 | if ((pRsp->status == VOS_STATUS_SUCCESS) && |
Mahesh A Saptasagar | fabb1a0 | 2015-06-29 12:17:04 +0530 | [diff] [blame] | 13270 | (TRUE == pHddCtx->cfg_ini->enableMgmtLogging)) |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 13271 | { |
| 13272 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Mgmt Frame Logging init successful")); |
| 13273 | pHddCtx->mgmt_frame_logging = TRUE; |
| 13274 | } |
| 13275 | else |
| 13276 | { |
| 13277 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Mgmt Frame Logging init not success")); |
| 13278 | pHddCtx->mgmt_frame_logging = FALSE; |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 13279 | return; |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 13280 | } |
| 13281 | |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 13282 | /*Check feature supported by FW*/ |
| 13283 | if(TRUE == sme_IsFeatureSupportedByFW(MEMORY_DUMP_SUPPORTED)) |
| 13284 | { |
| 13285 | //Store fwr mem dump size given by firmware. |
| 13286 | wlan_store_fwr_mem_dump_size(pRsp->fw_mem_dump_max_size); |
| 13287 | } |
| 13288 | else |
| 13289 | { |
| 13290 | wlan_store_fwr_mem_dump_size(0); |
| 13291 | } |
| 13292 | |
| 13293 | |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 13294 | } |
| 13295 | /**--------------------------------------------------------------------------- |
| 13296 | |
| 13297 | \brief hdd_init_frame_logging - function to initialize frame logging. |
| 13298 | Currently only Mgmt Frames are logged in both TX |
| 13299 | and Rx direction and are sent to userspace |
| 13300 | application using logger thread when queried. |
| 13301 | |
| 13302 | \return - None |
| 13303 | |
| 13304 | --------------------------------------------------------------------------*/ |
Siddharth Bhal | d1be97f | 2015-05-27 22:39:59 +0530 | [diff] [blame] | 13305 | void hdd_init_frame_logging(hdd_context_t* pHddCtx) |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 13306 | { |
| 13307 | eHalStatus halStatus = eHAL_STATUS_FAILURE; |
Sreelakshmi Konamki | d8784d9 | 2016-04-14 14:59:13 +0530 | [diff] [blame] | 13308 | tSirFWLoggingInitParam wlanFWLoggingInitParam = {0}; |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 13309 | |
Siddharth Bhal | d1be97f | 2015-05-27 22:39:59 +0530 | [diff] [blame] | 13310 | if (TRUE != sme_IsFeatureSupportedByFW(MGMT_FRAME_LOGGING) && |
| 13311 | TRUE != sme_IsFeatureSupportedByFW(LOGGING_ENHANCEMENT)) |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 13312 | { |
| 13313 | hddLog(VOS_TRACE_LEVEL_INFO, FL("MGMT_FRAME_LOGGING not supp by FW")); |
| 13314 | return; |
| 13315 | } |
| 13316 | |
sheenam monga | 1a0202d | 2020-01-03 15:20:57 +0530 | [diff] [blame] | 13317 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Configuring %s %s %s Logging",__func__, |
Siddharth Bhal | d1be97f | 2015-05-27 22:39:59 +0530 | [diff] [blame] | 13318 | pHddCtx->cfg_ini->enableFWLogging?"FW Log,":"", |
| 13319 | pHddCtx->cfg_ini->enableContFWLogging ? "Cont FW log,":"", |
sheenam monga | 1a0202d | 2020-01-03 15:20:57 +0530 | [diff] [blame] | 13320 | pHddCtx->cfg_ini->enableMgmtLogging ? "Mgmt Pkt Log":""); |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 13321 | |
Siddharth Bhal | d1be97f | 2015-05-27 22:39:59 +0530 | [diff] [blame] | 13322 | if (pHddCtx->cfg_ini->enableFWLogging || |
| 13323 | pHddCtx->cfg_ini->enableContFWLogging) |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 13324 | { |
Sreelakshmi Konamki | d8784d9 | 2016-04-14 14:59:13 +0530 | [diff] [blame] | 13325 | wlanFWLoggingInitParam.enableFlag |= WLAN_QXDM_LOG_EN; |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 13326 | } |
| 13327 | |
Sushant Kaushik | 4680490 | 2015-07-08 14:46:03 +0530 | [diff] [blame] | 13328 | if (pHddCtx->cfg_ini->enableMgmtLogging) |
| 13329 | { |
Sreelakshmi Konamki | d8784d9 | 2016-04-14 14:59:13 +0530 | [diff] [blame] | 13330 | wlanFWLoggingInitParam.enableFlag |= WLAN_FRAME_LOG_EN; |
Sushant Kaushik | 4680490 | 2015-07-08 14:46:03 +0530 | [diff] [blame] | 13331 | } |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 13332 | if (pHddCtx->cfg_ini->enableBMUHWtracing) |
| 13333 | { |
Sreelakshmi Konamki | d8784d9 | 2016-04-14 14:59:13 +0530 | [diff] [blame] | 13334 | wlanFWLoggingInitParam.enableFlag |= WLAN_BMUHW_TRACE_LOG_EN; |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 13335 | } |
Sreelakshmi Konamki | d8784d9 | 2016-04-14 14:59:13 +0530 | [diff] [blame] | 13336 | if( wlanFWLoggingInitParam.enableFlag == 0 ) |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 13337 | { |
| 13338 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Logging not enabled", __func__); |
| 13339 | return; |
| 13340 | } |
Sreelakshmi Konamki | d8784d9 | 2016-04-14 14:59:13 +0530 | [diff] [blame] | 13341 | wlanFWLoggingInitParam.frameType = WLAN_FRAME_LOGGING_FRAMETYPE_MGMT; |
| 13342 | wlanFWLoggingInitParam.frameSize = WLAN_MGMT_LOGGING_FRAMESIZE_128BYTES; |
| 13343 | wlanFWLoggingInitParam.bufferMode = WLAN_FRAME_LOGGING_BUFFERMODE_CIRCULAR; |
| 13344 | wlanFWLoggingInitParam.continuousFrameLogging = |
Siddharth Bhal | d1be97f | 2015-05-27 22:39:59 +0530 | [diff] [blame] | 13345 | pHddCtx->cfg_ini->enableContFWLogging; |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 13346 | |
Sreelakshmi Konamki | d8784d9 | 2016-04-14 14:59:13 +0530 | [diff] [blame] | 13347 | wlanFWLoggingInitParam.enableFlag &= ~WLAN_DPU_TXP_LOG_EN; |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 13348 | |
Sreelakshmi Konamki | d8784d9 | 2016-04-14 14:59:13 +0530 | [diff] [blame] | 13349 | wlanFWLoggingInitParam.minLogBufferSize = |
Siddharth Bhal | d1be97f | 2015-05-27 22:39:59 +0530 | [diff] [blame] | 13350 | pHddCtx->cfg_ini->minLoggingBufferSize; |
Sreelakshmi Konamki | d8784d9 | 2016-04-14 14:59:13 +0530 | [diff] [blame] | 13351 | wlanFWLoggingInitParam.maxLogBufferSize = |
Siddharth Bhal | d1be97f | 2015-05-27 22:39:59 +0530 | [diff] [blame] | 13352 | pHddCtx->cfg_ini->maxLoggingBufferSize; |
Sreelakshmi Konamki | d8784d9 | 2016-04-14 14:59:13 +0530 | [diff] [blame] | 13353 | wlanFWLoggingInitParam.fwlogInitCallback = hdd_init_frame_logging_done; |
| 13354 | wlanFWLoggingInitParam.fwlogInitCbContext= pHddCtx; |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 13355 | |
Sreelakshmi Konamki | d8784d9 | 2016-04-14 14:59:13 +0530 | [diff] [blame] | 13356 | halStatus = sme_InitMgmtFrameLogging(pHddCtx->hHal, &wlanFWLoggingInitParam); |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 13357 | |
| 13358 | if (eHAL_STATUS_SUCCESS != halStatus) |
| 13359 | { |
Sreelakshmi Konamki | d8784d9 | 2016-04-14 14:59:13 +0530 | [diff] [blame] | 13360 | hddLog(LOGE, FL("sme_InitMgmtFrameLogging failed, returned %d"), |
| 13361 | halStatus); |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 13362 | } |
| 13363 | |
| 13364 | return; |
| 13365 | } |
Mihir Shete | fc7ff5b | 2014-01-27 11:30:05 +0530 | [diff] [blame] | 13366 | |
Bhargav shah | 23c9494 | 2015-10-13 12:48:35 +0530 | [diff] [blame] | 13367 | static void hdd_dp_util_send_rps_ind(hdd_context_t *hdd_ctxt) |
| 13368 | { |
| 13369 | hdd_adapter_t *adapter; |
| 13370 | hdd_adapter_list_node_t *adapter_node, *next; |
| 13371 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 13372 | struct wlan_rps_data rps_data; |
| 13373 | int count; |
| 13374 | |
| 13375 | if(!hdd_ctxt->cfg_ini->rps_mask) |
| 13376 | { |
| 13377 | return; |
| 13378 | } |
| 13379 | |
| 13380 | for (count=0; count < WLAN_SVC_IFACE_NUM_QUEUES; count++) |
| 13381 | { |
| 13382 | rps_data.cpu_map[count] = hdd_ctxt->cfg_ini->rps_mask; |
| 13383 | } |
| 13384 | |
| 13385 | rps_data.num_queues = WLAN_SVC_IFACE_NUM_QUEUES; |
| 13386 | |
| 13387 | hddLog(LOG1, FL("0x%x 0x%x 0x%x 0x%x 0x%x 0x%x"), |
| 13388 | rps_data.cpu_map[0], rps_data.cpu_map[1],rps_data.cpu_map[2], |
| 13389 | rps_data.cpu_map[3], rps_data.cpu_map[4], rps_data.cpu_map[5]); |
| 13390 | |
| 13391 | status = hdd_get_front_adapter (hdd_ctxt, &adapter_node); |
| 13392 | |
| 13393 | while (NULL != adapter_node && VOS_STATUS_SUCCESS == status) |
| 13394 | { |
| 13395 | adapter = adapter_node->pAdapter; |
| 13396 | if (NULL != adapter) { |
| 13397 | strlcpy(rps_data.ifname, adapter->dev->name, |
| 13398 | sizeof(rps_data.ifname)); |
| 13399 | wlan_hdd_send_svc_nlink_msg(WLAN_MSG_RPS_ENABLE_IND, |
| 13400 | (void *)&rps_data,sizeof(rps_data)); |
| 13401 | } |
| 13402 | status = hdd_get_next_adapter (hdd_ctxt, adapter_node, &next); |
| 13403 | adapter_node = next; |
| 13404 | } |
| 13405 | } |
| 13406 | |
Masti, Narayanraddi | 2637846 | 2016-01-05 18:20:28 +0530 | [diff] [blame] | 13407 | void wlan_hdd_schedule_defer_scan(struct work_struct *work) |
| 13408 | { |
| 13409 | scan_context_t *scan_ctx = |
| 13410 | container_of(work, scan_context_t, scan_work.work); |
| 13411 | |
| 13412 | if (NULL == scan_ctx) |
| 13413 | { |
| 13414 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 13415 | FL("scan_ctx is NULL")); |
| 13416 | return; |
| 13417 | } |
| 13418 | |
| 13419 | if (unlikely(TDLS_CTX_MAGIC != scan_ctx->magic)) |
| 13420 | return; |
| 13421 | |
| 13422 | scan_ctx->attempt++; |
| 13423 | |
| 13424 | wlan_hdd_cfg80211_scan(scan_ctx->wiphy, |
| 13425 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 13426 | scan_ctx->dev, |
| 13427 | #endif |
| 13428 | scan_ctx->scan_request); |
| 13429 | } |
| 13430 | |
| 13431 | int wlan_hdd_copy_defer_scan_context(hdd_context_t *pHddCtx, |
| 13432 | struct wiphy *wiphy, |
| 13433 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 13434 | struct net_device *dev, |
| 13435 | #endif |
| 13436 | struct cfg80211_scan_request *request) |
| 13437 | { |
| 13438 | scan_context_t *scan_ctx; |
| 13439 | |
| 13440 | ENTER(); |
| 13441 | if (0 != (wlan_hdd_validate_context(pHddCtx))) |
| 13442 | { |
| 13443 | return -1; |
| 13444 | } |
| 13445 | |
| 13446 | scan_ctx = &pHddCtx->scan_ctxt; |
| 13447 | |
| 13448 | scan_ctx->wiphy = wiphy; |
| 13449 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 13450 | scan_ctx->dev = dev; |
| 13451 | #endif |
| 13452 | |
| 13453 | scan_ctx->scan_request = request; |
| 13454 | |
| 13455 | EXIT(); |
| 13456 | return 0; |
| 13457 | } |
| 13458 | |
| 13459 | void wlan_hdd_defer_scan_init_work(hdd_context_t *pHddCtx, |
| 13460 | struct wiphy *wiphy, |
| 13461 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 13462 | struct net_device *dev, |
| 13463 | #endif |
| 13464 | struct cfg80211_scan_request *request, |
| 13465 | unsigned long delay) |
| 13466 | { |
| 13467 | if (TDLS_CTX_MAGIC != pHddCtx->scan_ctxt.magic) |
| 13468 | { |
| 13469 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 13470 | wlan_hdd_copy_defer_scan_context(pHddCtx, wiphy, dev, request); |
| 13471 | #else |
| 13472 | wlan_hdd_copy_defer_scan_context(pHddCtx, wiphy, request); |
| 13473 | #endif |
| 13474 | pHddCtx->scan_ctxt.attempt = 0; |
| 13475 | pHddCtx->scan_ctxt.magic = TDLS_CTX_MAGIC; |
| 13476 | } |
| 13477 | schedule_delayed_work(&pHddCtx->scan_ctxt.scan_work, delay); |
| 13478 | } |
| 13479 | |
| 13480 | void wlan_hdd_init_deinit_defer_scan_context(scan_context_t *scan_ctx) |
| 13481 | { |
| 13482 | scan_ctx->magic = 0; |
| 13483 | scan_ctx->attempt = 0; |
| 13484 | scan_ctx->reject = 0; |
| 13485 | scan_ctx->scan_request = NULL; |
| 13486 | |
| 13487 | return; |
| 13488 | } |
| 13489 | |
Mihir Shete | fc7ff5b | 2014-01-27 11:30:05 +0530 | [diff] [blame] | 13490 | /**--------------------------------------------------------------------------- |
| 13491 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13492 | \brief hdd_wlan_startup() - HDD init function |
| 13493 | |
| 13494 | This is the driver startup code executed once a WLAN device has been detected |
| 13495 | |
| 13496 | \param - dev - Pointer to the underlying device |
| 13497 | |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 13498 | \return - 0 for success, < 0 for failure |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13499 | |
| 13500 | --------------------------------------------------------------------------*/ |
| 13501 | |
| 13502 | int hdd_wlan_startup(struct device *dev ) |
| 13503 | { |
| 13504 | VOS_STATUS status; |
| 13505 | hdd_adapter_t *pAdapter = NULL; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 13506 | hdd_adapter_t *pP2pAdapter = NULL; |
Arunk Khandavalli | 95608be | 2019-01-22 13:12:54 +0530 | [diff] [blame] | 13507 | hdd_adapter_t *softapAdapter = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13508 | hdd_context_t *pHddCtx = NULL; |
| 13509 | v_CONTEXT_t pVosContext= NULL; |
| 13510 | #ifdef WLAN_BTAMP_FEATURE |
| 13511 | VOS_STATUS vStatus = VOS_STATUS_SUCCESS; |
| 13512 | WLANBAP_ConfigType btAmpConfig; |
| 13513 | hdd_config_t *pConfig; |
| 13514 | #endif |
| 13515 | int ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13516 | struct wiphy *wiphy; |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 13517 | v_MACADDR_t mac_addr; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13518 | |
| 13519 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13520 | /* |
| 13521 | * cfg80211: wiphy allocation |
| 13522 | */ |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 13523 | wiphy = wlan_hdd_cfg80211_wiphy_alloc(sizeof(hdd_context_t)) ; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13524 | |
| 13525 | if(wiphy == NULL) |
| 13526 | { |
| 13527 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: cfg80211 init failed", __func__); |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 13528 | return -EIO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13529 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13530 | pHddCtx = wiphy_priv(wiphy); |
| 13531 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13532 | //Initialize the adapter context to zeros. |
| 13533 | vos_mem_zero(pHddCtx, sizeof( hdd_context_t )); |
| 13534 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13535 | pHddCtx->wiphy = wiphy; |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 13536 | hdd_prevent_suspend(WIFI_POWER_EVENT_WAKELOCK_DRIVER_INIT); |
Mihir Shete | 1815629 | 2014-03-11 15:38:30 +0530 | [diff] [blame] | 13537 | pHddCtx->isLoadUnloadInProgress = WLAN_HDD_LOAD_IN_PROGRESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13538 | |
| 13539 | vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, TRUE); |
| 13540 | |
Siddharth Bhal | cd92b78 | 2015-06-29 12:25:40 +0530 | [diff] [blame] | 13541 | /* register for riva power on lock to platform driver |
| 13542 | * Locking power early to ensure FW doesn't reset by kernel while |
| 13543 | * host driver is busy initializing itself */ |
| 13544 | if (req_riva_power_on_lock("wlan")) |
| 13545 | { |
| 13546 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: req riva power on lock failed", |
| 13547 | __func__); |
| 13548 | goto err_free_hdd_context; |
| 13549 | } |
| 13550 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13551 | /*Get vos context here bcoz vos_open requires it*/ |
| 13552 | pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL); |
| 13553 | |
Madan Mohan Koyyalamudi | 0b78e15 | 2012-11-28 15:46:51 -0800 | [diff] [blame] | 13554 | if(pVosContext == NULL) |
| 13555 | { |
| 13556 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Failed vos_get_global_context",__func__); |
| 13557 | goto err_free_hdd_context; |
| 13558 | } |
| 13559 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13560 | //Save the Global VOSS context in adapter context for future. |
| 13561 | pHddCtx->pvosContext = pVosContext; |
| 13562 | |
| 13563 | //Save the adapter context in global context for future. |
| 13564 | ((VosContextType*)(pVosContext))->pHDDContext = (v_VOID_t*)pHddCtx; |
| 13565 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13566 | pHddCtx->parent_dev = dev; |
Sreelakshmi Konamki | f0646d5 | 2016-12-09 12:35:31 +0530 | [diff] [blame] | 13567 | pHddCtx->last_scan_reject_session_id = 0xFF; |
| 13568 | pHddCtx->last_scan_reject_reason = 0; |
Sreelakshmi Konamki | 20ebed9 | 2016-10-27 12:13:30 +0530 | [diff] [blame] | 13569 | pHddCtx->last_scan_reject_timestamp = 0; |
Abhishek Singh | e4b1256 | 2017-06-20 16:53:39 +0530 | [diff] [blame] | 13570 | pHddCtx->scan_reject_cnt = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13571 | |
| 13572 | init_completion(&pHddCtx->full_pwr_comp_var); |
| 13573 | init_completion(&pHddCtx->standby_comp_var); |
| 13574 | init_completion(&pHddCtx->req_bmps_comp_var); |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 13575 | init_completion(&pHddCtx->scan_info.scan_req_completion_event); |
Madan Mohan Koyyalamudi | f4e8100 | 2012-11-13 10:46:38 -0800 | [diff] [blame] | 13576 | init_completion(&pHddCtx->scan_info.abortscan_event_var); |
Kiet Lam | 46b8e4e | 2013-11-06 21:49:53 +0530 | [diff] [blame] | 13577 | init_completion(&pHddCtx->wiphy_channel_update_event); |
Arun Kumar Khandavalli | e0b046d | 2014-03-01 21:54:25 +0530 | [diff] [blame] | 13578 | init_completion(&pHddCtx->ssr_comp_var); |
Mahesh A Saptasagar | 67ab922 | 2015-10-21 15:38:41 +0530 | [diff] [blame] | 13579 | init_completion(&pHddCtx->mc_sus_event_var); |
| 13580 | init_completion(&pHddCtx->tx_sus_event_var); |
| 13581 | init_completion(&pHddCtx->rx_sus_event_var); |
| 13582 | |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 13583 | |
mukul sharma | 4bd8d2e | 2015-08-13 20:33:25 +0530 | [diff] [blame] | 13584 | hdd_init_ll_stats_ctx(pHddCtx); |
Anurag Chouhan | 6ee8154 | 2017-02-09 18:09:27 +0530 | [diff] [blame] | 13585 | hdd_init_nud_stats_ctx(pHddCtx); |
mukul sharma | 4bd8d2e | 2015-08-13 20:33:25 +0530 | [diff] [blame] | 13586 | |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 13587 | #ifdef CONFIG_ENABLE_LINUX_REG |
Amar Singhal | fddc28c | 2013-09-05 13:03:40 -0700 | [diff] [blame] | 13588 | init_completion(&pHddCtx->linux_reg_req); |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 13589 | #else |
| 13590 | init_completion(&pHddCtx->driver_crda_req); |
| 13591 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13592 | |
Padma, Santhosh Kumar | a1aa4a3 | 2015-06-19 19:00:46 +0530 | [diff] [blame] | 13593 | #ifdef WLAN_FEATURE_EXTSCAN |
| 13594 | init_completion(&pHddCtx->ext_scan_context.response_event); |
| 13595 | #endif /* WLAN_FEATURE_EXTSCAN */ |
| 13596 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 13597 | spin_lock_init(&pHddCtx->schedScan_lock); |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 13598 | vos_spin_lock_init(&pHddCtx->sap_update_info_lock); |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 13599 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13600 | hdd_list_init( &pHddCtx->hddAdapters, MAX_NUMBER_OF_ADAPTERS ); |
| 13601 | |
Padma, Santhosh Kumar | 9cd3833 | 2015-11-17 12:18:10 +0530 | [diff] [blame] | 13602 | vos_init_delayed_work(&pHddCtx->spoof_mac_addr_work, |
| 13603 | hdd_processSpoofMacAddrRequest); |
Kapil Gupta | 137ef89 | 2016-12-13 19:38:00 +0530 | [diff] [blame] | 13604 | vos_init_work(&pHddCtx->sap_start_work, hdd_sap_restart_handle); |
Abhishek Singh | 78c691f | 2017-11-30 13:48:44 +0530 | [diff] [blame] | 13605 | vos_init_delayed_work(&pHddCtx->ecsa_chan_change_work, |
| 13606 | hdd_force_scc_with_ecsa_handle); |
Padma, Santhosh Kumar | 9cd3833 | 2015-11-17 12:18:10 +0530 | [diff] [blame] | 13607 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 13608 | #ifdef FEATURE_WLAN_TDLS |
| 13609 | /* tdls_lock is initialized before an hdd_open_adapter ( which is |
| 13610 | * invoked by other instances also) to protect the concurrent |
| 13611 | * access for the Adapters by TDLS module. |
| 13612 | */ |
| 13613 | mutex_init(&pHddCtx->tdls_lock); |
| 13614 | #endif |
Siddharth Bhal | 7697221 | 2014-10-15 16:22:51 +0530 | [diff] [blame] | 13615 | mutex_init(&pHddCtx->spoofMacAddr.macSpoofingLock); |
Mukul Sharma | 1fd6efd | 2015-02-14 00:29:14 +0530 | [diff] [blame] | 13616 | mutex_init(&pHddCtx->wmmLock); |
| 13617 | |
Srinivas Girigowda | 8bf64cb | 2015-09-30 19:50:09 +0530 | [diff] [blame] | 13618 | hdd_init_offloaded_packets_ctx(pHddCtx); |
Agarwal Ashish | 1f42287 | 2014-07-22 00:11:55 +0530 | [diff] [blame] | 13619 | /* By default Strict Regulatory For FCC should be false */ |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 13620 | |
Agarwal Ashish | 1f42287 | 2014-07-22 00:11:55 +0530 | [diff] [blame] | 13621 | pHddCtx->nEnableStrictRegulatoryForFCC = FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13622 | // Load all config first as TL config is needed during vos_open |
| 13623 | pHddCtx->cfg_ini = (hdd_config_t*) kmalloc(sizeof(hdd_config_t), GFP_KERNEL); |
| 13624 | if(pHddCtx->cfg_ini == NULL) |
| 13625 | { |
| 13626 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Failed kmalloc hdd_config_t",__func__); |
| 13627 | goto err_free_hdd_context; |
| 13628 | } |
| 13629 | |
Hanumanth Reddy Pothula | 1efcd16 | 2018-03-14 14:32:27 +0530 | [diff] [blame] | 13630 | hdd_request_manager_init(); |
| 13631 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13632 | vos_mem_zero(pHddCtx->cfg_ini, sizeof( hdd_config_t )); |
| 13633 | |
| 13634 | // Read and parse the qcom_cfg.ini file |
| 13635 | status = hdd_parse_config_ini( pHddCtx ); |
| 13636 | if ( VOS_STATUS_SUCCESS != status ) |
| 13637 | { |
| 13638 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: error parsing %s", |
| 13639 | __func__, WLAN_INI_FILE); |
| 13640 | goto err_config; |
| 13641 | } |
Arif Hussain | d521891 | 2013-12-05 01:10:55 -0800 | [diff] [blame] | 13642 | #ifdef MEMORY_DEBUG |
| 13643 | if (pHddCtx->cfg_ini->IsMemoryDebugSupportEnabled) |
| 13644 | vos_mem_init(); |
| 13645 | |
| 13646 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: gEnableMemoryDebug=%d", |
| 13647 | __func__, pHddCtx->cfg_ini->IsMemoryDebugSupportEnabled); |
| 13648 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13649 | |
Gopichand Nakkala | b8f0f1a | 2013-05-23 18:19:48 +0530 | [diff] [blame] | 13650 | /* INI has been read, initialise the configuredMcastBcastFilter with |
| 13651 | * INI value as this will serve as the default value |
| 13652 | */ |
| 13653 | pHddCtx->configuredMcastBcastFilter = pHddCtx->cfg_ini->mcastBcastFilterSetting; |
| 13654 | hddLog(VOS_TRACE_LEVEL_INFO, "Setting configuredMcastBcastFilter: %d", |
| 13655 | pHddCtx->cfg_ini->mcastBcastFilterSetting); |
Gopichand Nakkala | fce506f | 2013-07-03 23:55:16 +0530 | [diff] [blame] | 13656 | |
| 13657 | if (false == hdd_is_5g_supported(pHddCtx)) |
| 13658 | { |
| 13659 | //5Ghz is not supported. |
| 13660 | if (1 != pHddCtx->cfg_ini->nBandCapability) |
| 13661 | { |
| 13662 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 13663 | "%s: Setting pHddCtx->cfg_ini->nBandCapability = 1", __func__); |
| 13664 | pHddCtx->cfg_ini->nBandCapability = 1; |
| 13665 | } |
| 13666 | } |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 13667 | |
| 13668 | /* If SNR Monitoring is enabled, FW has to parse all beacons |
| 13669 | * for calcaluting and storing the average SNR, so set Nth beacon |
| 13670 | * filter to 1 to enable FW to parse all the beaocons |
| 13671 | */ |
| 13672 | if (1 == pHddCtx->cfg_ini->fEnableSNRMonitoring) |
| 13673 | { |
| 13674 | /* The log level is deliberately set to WARN as overriding |
| 13675 | * nthBeaconFilter to 1 will increase power cosumption and this |
| 13676 | * might just prove helpful to detect the power issue. |
| 13677 | */ |
| 13678 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 13679 | "%s: Setting pHddCtx->cfg_ini->nthBeaconFilter = 1", __func__); |
| 13680 | pHddCtx->cfg_ini->nthBeaconFilter = 1; |
| 13681 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13682 | /* |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 13683 | * cfg80211: Initialization ... |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13684 | */ |
Manjeet Singh | 61016fa | 2016-12-02 11:10:19 +0530 | [diff] [blame] | 13685 | if (0 < wlan_hdd_cfg80211_init(dev, wiphy, pHddCtx->cfg_ini)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13686 | { |
Manjeet Singh | 61016fa | 2016-12-02 11:10:19 +0530 | [diff] [blame] | 13687 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 13688 | "%s: wlan_hdd_cfg80211_init return failure", __func__); |
| 13689 | goto err_config; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13690 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13691 | |
Varun Reddy Yeturu | 587e680 | 2013-01-24 12:21:41 -0800 | [diff] [blame] | 13692 | // Update VOS trace levels based upon the cfg.ini |
| 13693 | hdd_vos_trace_enable(VOS_MODULE_ID_BAP, |
| 13694 | pHddCtx->cfg_ini->vosTraceEnableBAP); |
| 13695 | hdd_vos_trace_enable(VOS_MODULE_ID_TL, |
| 13696 | pHddCtx->cfg_ini->vosTraceEnableTL); |
| 13697 | hdd_vos_trace_enable(VOS_MODULE_ID_WDI, |
| 13698 | pHddCtx->cfg_ini->vosTraceEnableWDI); |
| 13699 | hdd_vos_trace_enable(VOS_MODULE_ID_HDD, |
| 13700 | pHddCtx->cfg_ini->vosTraceEnableHDD); |
| 13701 | hdd_vos_trace_enable(VOS_MODULE_ID_SME, |
| 13702 | pHddCtx->cfg_ini->vosTraceEnableSME); |
| 13703 | hdd_vos_trace_enable(VOS_MODULE_ID_PE, |
| 13704 | pHddCtx->cfg_ini->vosTraceEnablePE); |
Katya Nigam | 70d6833 | 2013-09-16 16:49:45 +0530 | [diff] [blame] | 13705 | hdd_vos_trace_enable(VOS_MODULE_ID_PMC, |
| 13706 | pHddCtx->cfg_ini->vosTraceEnablePMC); |
Varun Reddy Yeturu | 587e680 | 2013-01-24 12:21:41 -0800 | [diff] [blame] | 13707 | hdd_vos_trace_enable(VOS_MODULE_ID_WDA, |
| 13708 | pHddCtx->cfg_ini->vosTraceEnableWDA); |
| 13709 | hdd_vos_trace_enable(VOS_MODULE_ID_SYS, |
| 13710 | pHddCtx->cfg_ini->vosTraceEnableSYS); |
| 13711 | hdd_vos_trace_enable(VOS_MODULE_ID_VOSS, |
| 13712 | pHddCtx->cfg_ini->vosTraceEnableVOSS); |
Varun Reddy Yeturu | 587e680 | 2013-01-24 12:21:41 -0800 | [diff] [blame] | 13713 | hdd_vos_trace_enable(VOS_MODULE_ID_SAP, |
| 13714 | pHddCtx->cfg_ini->vosTraceEnableSAP); |
| 13715 | hdd_vos_trace_enable(VOS_MODULE_ID_HDD_SOFTAP, |
| 13716 | pHddCtx->cfg_ini->vosTraceEnableHDDSAP); |
Varun Reddy Yeturu | 587e680 | 2013-01-24 12:21:41 -0800 | [diff] [blame] | 13717 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13718 | // Update WDI trace levels based upon the cfg.ini |
| 13719 | hdd_wdi_trace_enable(eWLAN_MODULE_DAL, |
| 13720 | pHddCtx->cfg_ini->wdiTraceEnableDAL); |
| 13721 | hdd_wdi_trace_enable(eWLAN_MODULE_DAL_CTRL, |
| 13722 | pHddCtx->cfg_ini->wdiTraceEnableCTL); |
| 13723 | hdd_wdi_trace_enable(eWLAN_MODULE_DAL_DATA, |
| 13724 | pHddCtx->cfg_ini->wdiTraceEnableDAT); |
| 13725 | hdd_wdi_trace_enable(eWLAN_MODULE_PAL, |
| 13726 | pHddCtx->cfg_ini->wdiTraceEnablePAL); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13727 | |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 13728 | if (VOS_FTM_MODE == hdd_get_conparam()) |
| 13729 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13730 | if ( VOS_STATUS_SUCCESS != wlan_hdd_ftm_open(pHddCtx) ) |
| 13731 | { |
| 13732 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: wlan_hdd_ftm_open Failed",__func__); |
| 13733 | goto err_free_hdd_context; |
| 13734 | } |
| 13735 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: FTM driver loaded success fully",__func__); |
Sachin Ahuja | 38ef5e0 | 2015-03-13 17:31:16 +0530 | [diff] [blame] | 13736 | pHddCtx->isLoadUnloadInProgress = WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS; |
c_hpothu | 2de0ef6 | 2014-04-15 16:16:15 +0530 | [diff] [blame] | 13737 | vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, FALSE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13738 | return VOS_STATUS_SUCCESS; |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 13739 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13740 | |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 13741 | if( VOS_MONITOR_MODE == hdd_get_conparam()) |
| 13742 | { |
| 13743 | if ( VOS_STATUS_SUCCESS != wlan_hdd_mon_open(pHddCtx)) |
| 13744 | { |
| 13745 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: wlan_hdd_mon_open Failed",__func__); |
| 13746 | goto err_free_hdd_context; |
| 13747 | } |
| 13748 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Driver loaded in Monitor Mode",__func__); |
| 13749 | pHddCtx->isLoadUnloadInProgress = WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS; |
| 13750 | vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, FALSE); |
| 13751 | return VOS_STATUS_SUCCESS; |
| 13752 | } |
| 13753 | |
Jeff Johnson | 88ba774 | 2013-02-27 14:36:02 -0800 | [diff] [blame] | 13754 | //Open watchdog module |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13755 | if(pHddCtx->cfg_ini->fIsLogpEnabled) |
| 13756 | { |
| 13757 | status = vos_watchdog_open(pVosContext, |
| 13758 | &((VosContextType*)pVosContext)->vosWatchdog, sizeof(VosWatchdogContext)); |
| 13759 | |
| 13760 | if(!VOS_IS_STATUS_SUCCESS( status )) |
| 13761 | { |
| 13762 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: vos_watchdog_open failed",__func__); |
Ashish Kumar Dhanotiya | 532bdef | 2017-05-09 17:31:59 +0530 | [diff] [blame] | 13763 | goto err_config; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13764 | } |
| 13765 | } |
| 13766 | |
| 13767 | pHddCtx->isLogpInProgress = FALSE; |
| 13768 | vos_set_logp_in_progress(VOS_MODULE_ID_VOSS, FALSE); |
| 13769 | |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 13770 | #ifdef CONFIG_ENABLE_LINUX_REG |
Amar Singhal | 0a40223 | 2013-10-11 20:57:16 -0700 | [diff] [blame] | 13771 | /* initialize the NV module. This is required so that |
| 13772 | we can initialize the channel information in wiphy |
| 13773 | from the NV.bin data. The channel information in |
| 13774 | wiphy needs to be initialized before wiphy registration */ |
| 13775 | |
| 13776 | status = vos_nv_open(); |
| 13777 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 13778 | { |
| 13779 | /* NV module cannot be initialized */ |
| 13780 | hddLog( VOS_TRACE_LEVEL_FATAL, |
| 13781 | "%s: vos_nv_open failed", __func__); |
Vinay Krishna Eranna | 2025d89 | 2014-09-18 16:51:42 +0530 | [diff] [blame] | 13782 | goto err_wdclose; |
Amar Singhal | 0a40223 | 2013-10-11 20:57:16 -0700 | [diff] [blame] | 13783 | } |
| 13784 | |
| 13785 | status = vos_init_wiphy_from_nv_bin(); |
| 13786 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 13787 | { |
| 13788 | /* NV module cannot be initialized */ |
| 13789 | hddLog( VOS_TRACE_LEVEL_FATAL, |
| 13790 | "%s: vos_init_wiphy failed", __func__); |
| 13791 | goto err_vos_nv_close; |
| 13792 | } |
| 13793 | |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 13794 | #endif |
Mahesh A Saptasagar | c3ed012 | 2016-01-19 16:45:11 +0530 | [diff] [blame] | 13795 | //Initialize the nlink service |
| 13796 | if(nl_srv_init() != 0) |
| 13797 | { |
| 13798 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: nl_srv_init failed", __func__); |
| 13799 | goto err_vos_nv_close; |
| 13800 | } |
| 13801 | |
| 13802 | #ifdef WLAN_KD_READY_NOTIFIER |
| 13803 | pHddCtx->kd_nl_init = 1; |
| 13804 | #endif /* WLAN_KD_READY_NOTIFIER */ |
| 13805 | |
Girish Gowli | bf0e1ab | 2015-01-19 16:05:16 +0530 | [diff] [blame] | 13806 | vos_set_roam_delay_stats_enabled(pHddCtx->cfg_ini->gEnableRoamDelayStats); |
Arun Kumar Khandavalli | ebb1948 | 2014-03-25 13:56:53 +0530 | [diff] [blame] | 13807 | status = vos_open( &pVosContext, pHddCtx->parent_dev); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13808 | if ( !VOS_IS_STATUS_SUCCESS( status )) |
| 13809 | { |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 13810 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: vos_open failed", __func__); |
Mahesh A Saptasagar | c3ed012 | 2016-01-19 16:45:11 +0530 | [diff] [blame] | 13811 | goto err_nl_srv; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13812 | } |
| 13813 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13814 | pHddCtx->hHal = (tHalHandle)vos_get_context( VOS_MODULE_ID_SME, pVosContext ); |
| 13815 | |
| 13816 | if ( NULL == pHddCtx->hHal ) |
| 13817 | { |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 13818 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: HAL context is null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13819 | goto err_vosclose; |
| 13820 | } |
| 13821 | |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 13822 | status = vos_preStart( pHddCtx->pvosContext ); |
| 13823 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 13824 | { |
| 13825 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: vos_preStart failed", __func__); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 13826 | goto err_vosclose; |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 13827 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 13828 | |
Arif Hussain | eaf6860 | 2013-12-30 23:10:44 -0800 | [diff] [blame] | 13829 | if (0 == enable_dfs_chan_scan || 1 == enable_dfs_chan_scan) |
| 13830 | { |
| 13831 | pHddCtx->cfg_ini->enableDFSChnlScan = enable_dfs_chan_scan; |
| 13832 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: module enable_dfs_chan_scan set to %d", |
| 13833 | __func__, enable_dfs_chan_scan); |
| 13834 | } |
| 13835 | if (0 == enable_11d || 1 == enable_11d) |
| 13836 | { |
| 13837 | pHddCtx->cfg_ini->Is11dSupportEnabled = enable_11d; |
| 13838 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: module enable_11d set to %d", |
| 13839 | __func__, enable_11d); |
| 13840 | } |
| 13841 | |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 13842 | /* Note that the vos_preStart() sequence triggers the cfg download. |
| 13843 | The cfg download must occur before we update the SME config |
| 13844 | since the SME config operation must access the cfg database */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13845 | status = hdd_set_sme_config( pHddCtx ); |
| 13846 | |
| 13847 | if ( VOS_STATUS_SUCCESS != status ) |
| 13848 | { |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 13849 | 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] | 13850 | goto err_vosclose; |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 13851 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13852 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13853 | /* In the integrated architecture we update the configuration from |
| 13854 | the INI file and from NV before vOSS has been started so that |
| 13855 | the final contents are available to send down to the cCPU */ |
| 13856 | |
| 13857 | // Apply the cfg.ini to cfg.dat |
| 13858 | if (FALSE == hdd_update_config_dat(pHddCtx)) |
| 13859 | { |
| 13860 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: config update failed",__func__ ); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 13861 | goto err_vosclose; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13862 | } |
| 13863 | |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 13864 | // Get mac addr from platform driver |
| 13865 | ret = wcnss_get_wlan_mac_address((char*)&mac_addr.bytes); |
| 13866 | |
| 13867 | if ((0 == ret) && (!vos_is_macaddr_zero(&mac_addr))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13868 | { |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 13869 | /* Store the mac addr for first interface */ |
| 13870 | pHddCtx->cfg_ini->intfMacAddr[0] = mac_addr; |
| 13871 | |
| 13872 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 13873 | "%s: WLAN Mac Addr: " |
| 13874 | MAC_ADDRESS_STR, __func__, |
| 13875 | MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[0].bytes)); |
| 13876 | |
| 13877 | /* Here, passing Arg2 as 1 because we do not want to change the |
| 13878 | last 3 bytes (means non OUI bytes) of first interface mac |
| 13879 | addr. |
| 13880 | */ |
| 13881 | if (0 != hdd_generate_iface_mac_addr_auto(pHddCtx, 1, mac_addr)) |
| 13882 | { |
| 13883 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 13884 | "%s: Failed to generate wlan interface mac addr " |
| 13885 | "using MAC from ini file ", __func__); |
| 13886 | } |
| 13887 | } |
| 13888 | else if (VOS_STATUS_SUCCESS != hdd_update_config_from_nv(pHddCtx)) |
| 13889 | { |
| 13890 | // Apply the NV to cfg.dat |
| 13891 | /* Prima Update MAC address only at here */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13892 | #ifdef WLAN_AUTOGEN_MACADDR_FEATURE |
| 13893 | /* There was not a valid set of MAC Addresses in NV. See if the |
| 13894 | default addresses were modified by the cfg.ini settings. If so, |
| 13895 | we'll use them, but if not, we'll autogenerate a set of MAC |
| 13896 | addresses based upon the device serial number */ |
| 13897 | |
| 13898 | static const v_MACADDR_t default_address = |
| 13899 | {{0x00, 0x0A, 0xF5, 0x89, 0x89, 0xFF}}; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13900 | |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 13901 | if (0 == memcmp(&default_address, &pHddCtx->cfg_ini->intfMacAddr[0], |
| 13902 | sizeof(default_address))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13903 | { |
| 13904 | /* cfg.ini has the default address, invoke autogen logic */ |
| 13905 | |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 13906 | /* Here, passing Arg2 as 0 because we want to change the |
| 13907 | last 3 bytes (means non OUI bytes) of all the interfaces |
| 13908 | mac addr. |
| 13909 | */ |
| 13910 | if (0 != hdd_generate_iface_mac_addr_auto(pHddCtx, 0, |
| 13911 | default_address)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13912 | { |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 13913 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 13914 | "%s: Failed to generate wlan interface mac addr " |
| 13915 | "using MAC from ini file " MAC_ADDRESS_STR, __func__, |
| 13916 | MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[0].bytes)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13917 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13918 | } |
| 13919 | else |
| 13920 | #endif //WLAN_AUTOGEN_MACADDR_FEATURE |
| 13921 | { |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 13922 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13923 | "%s: Invalid MAC address in NV, using MAC from ini file " |
| 13924 | MAC_ADDRESS_STR, __func__, |
| 13925 | MAC_ADDR_ARRAY(pHddCtx->cfg_ini->intfMacAddr[0].bytes)); |
| 13926 | } |
| 13927 | } |
| 13928 | { |
| 13929 | eHalStatus halStatus; |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 13930 | |
| 13931 | /* Set the MAC Address Currently this is used by HAL to |
| 13932 | * add self sta. Remove this once self sta is added as |
| 13933 | * part of session open. |
| 13934 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13935 | halStatus = cfgSetStr( pHddCtx->hHal, WNI_CFG_STA_ID, |
| 13936 | (v_U8_t *)&pHddCtx->cfg_ini->intfMacAddr[0], |
| 13937 | sizeof( pHddCtx->cfg_ini->intfMacAddr[0]) ); |
Hardik Kantilal Patel | 4d7982a | 2013-12-02 18:53:30 +0530 | [diff] [blame] | 13938 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13939 | if (!HAL_STATUS_SUCCESS( halStatus )) |
| 13940 | { |
| 13941 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: Failed to set MAC Address. " |
| 13942 | "HALStatus is %08d [x%08x]",__func__, halStatus, halStatus ); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 13943 | goto err_vosclose; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13944 | } |
| 13945 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13946 | |
| 13947 | /*Start VOSS which starts up the SME/MAC/HAL modules and everything else |
| 13948 | Note: Firmware image will be read and downloaded inside vos_start API */ |
| 13949 | status = vos_start( pHddCtx->pvosContext ); |
| 13950 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 13951 | { |
| 13952 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: vos_start failed",__func__); |
Hanumantha Reddy Pothula | bd9601a | 2016-02-12 13:22:27 +0530 | [diff] [blame] | 13953 | if (isSsrPanicOnFailure()) |
| 13954 | VOS_BUG(0); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 13955 | goto err_vosclose; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13956 | } |
| 13957 | |
Leo Chang | 6cec3e2 | 2014-01-21 15:33:49 -0800 | [diff] [blame] | 13958 | #ifdef FEATURE_WLAN_CH_AVOID |
| 13959 | /* Plug in avoid channel notification callback |
| 13960 | * This should happen before ADD_SELF_STA |
| 13961 | * 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] | 13962 | |
| 13963 | /* check the Channel Avoidance is enabled */ |
| 13964 | if (TRUE == pHddCtx->cfg_ini->fenableCHAvoidance) |
| 13965 | { |
| 13966 | sme_AddChAvoidCallback(pHddCtx->hHal, |
| 13967 | hdd_hostapd_ch_avoid_cb); |
| 13968 | } |
Leo Chang | 6cec3e2 | 2014-01-21 15:33:49 -0800 | [diff] [blame] | 13969 | #endif /* FEATURE_WLAN_CH_AVOID */ |
| 13970 | |
Madan Mohan Koyyalamudi | 8612ec9 | 2012-09-28 15:53:07 -0700 | [diff] [blame] | 13971 | /* Exchange capability info between Host and FW and also get versioning info from FW */ |
| 13972 | hdd_exchange_version_and_caps(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13973 | |
Agarwal Ashish | ad9281b | 2014-06-10 14:57:30 +0530 | [diff] [blame] | 13974 | #ifdef CONFIG_ENABLE_LINUX_REG |
| 13975 | status = wlan_hdd_init_channels(pHddCtx); |
| 13976 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 13977 | { |
| 13978 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: wlan_hdd_init_channels failed", |
| 13979 | __func__); |
| 13980 | goto err_vosstop; |
| 13981 | } |
| 13982 | #endif |
| 13983 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13984 | status = hdd_post_voss_start_config( pHddCtx ); |
| 13985 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 13986 | { |
| 13987 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hdd_post_voss_start_config failed", |
| 13988 | __func__); |
| 13989 | goto err_vosstop; |
| 13990 | } |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 13991 | |
Rajeev Kumar Sirasanagandla | 2bb30b8 | 2019-01-07 22:30:16 +0530 | [diff] [blame] | 13992 | wlan_hdd_cfg80211_scan_randomization_init(wiphy); |
| 13993 | |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 13994 | #ifndef CONFIG_ENABLE_LINUX_REG |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 13995 | wlan_hdd_cfg80211_update_reg_info( wiphy ); |
| 13996 | |
| 13997 | /* registration of wiphy dev with cfg80211 */ |
| 13998 | if (0 > wlan_hdd_cfg80211_register(wiphy)) |
| 13999 | { |
| 14000 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__); |
| 14001 | goto err_vosstop; |
| 14002 | } |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 14003 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14004 | |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 14005 | #ifdef CONFIG_ENABLE_LINUX_REG |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 14006 | /* registration of wiphy dev with cfg80211 */ |
| 14007 | if (0 > wlan_hdd_cfg80211_register(wiphy)) |
| 14008 | { |
| 14009 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__); |
| 14010 | goto err_vosstop; |
| 14011 | } |
| 14012 | |
Agarwal Ashish | 6db9d53 | 2014-09-30 18:19:10 +0530 | [diff] [blame] | 14013 | status = wlan_hdd_init_channels_for_cc(pHddCtx, INIT); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 14014 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 14015 | { |
| 14016 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: wlan_hdd_init_channels_for_cc failed", |
| 14017 | __func__); |
| 14018 | goto err_unregister_wiphy; |
| 14019 | } |
| 14020 | #endif |
| 14021 | |
c_hpothu | 4a298be | 2014-12-22 21:12:51 +0530 | [diff] [blame] | 14022 | wcnss_wlan_set_drvdata(pHddCtx->parent_dev, pHddCtx); |
| 14023 | |
Rajeev Kumar Sirasanagandla | 4c068d4 | 2019-02-22 21:39:36 +0530 | [diff] [blame] | 14024 | #ifdef SAP_AUTH_OFFLOAD |
| 14025 | if (!sme_IsFeatureSupportedByFW(SAP_OFFLOADS)) |
| 14026 | { |
| 14027 | hddLog(VOS_TRACE_LEVEL_INFO, FL(" SAP AUTH OFFLOAD not supp by FW")); |
| 14028 | pHddCtx->cfg_ini->enable_sap_auth_offload = 0; |
| 14029 | } |
| 14030 | #endif |
| 14031 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14032 | if (VOS_STA_SAP_MODE == hdd_get_conparam()) |
| 14033 | { |
| 14034 | pAdapter = hdd_open_adapter( pHddCtx, WLAN_HDD_SOFTAP, "softap.%d", |
| 14035 | wlan_hdd_get_intf_addr(pHddCtx), FALSE ); |
| 14036 | } |
| 14037 | else |
| 14038 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14039 | pAdapter = hdd_open_adapter( pHddCtx, WLAN_HDD_INFRA_STATION, "wlan%d", |
| 14040 | wlan_hdd_get_intf_addr(pHddCtx), FALSE ); |
| 14041 | if (pAdapter != NULL) |
| 14042 | { |
Katya Nigam | a7d81d7 | 2014-11-12 12:44:34 +0530 | [diff] [blame] | 14043 | 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] | 14044 | { |
Gopichand Nakkala | 49f96f6 | 2013-02-06 14:38:17 +0530 | [diff] [blame] | 14045 | vos_mem_copy( pHddCtx->p2pDeviceAddress.bytes, |
| 14046 | pHddCtx->cfg_ini->intfMacAddr[0].bytes, |
| 14047 | sizeof(tSirMacAddr)); |
Madan Mohan Koyyalamudi | edfc1b7 | 2012-10-18 20:25:55 -0700 | [diff] [blame] | 14048 | |
Gopichand Nakkala | 49f96f6 | 2013-02-06 14:38:17 +0530 | [diff] [blame] | 14049 | /* Generate the P2P Device Address. This consists of the device's |
| 14050 | * primary MAC address with the locally administered bit set. |
| 14051 | */ |
| 14052 | pHddCtx->p2pDeviceAddress.bytes[0] |= 0x02; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 14053 | } |
| 14054 | else |
| 14055 | { |
Gopichand Nakkala | 49f96f6 | 2013-02-06 14:38:17 +0530 | [diff] [blame] | 14056 | tANI_U8* p2p_dev_addr = wlan_hdd_get_intf_addr(pHddCtx); |
| 14057 | if (p2p_dev_addr != NULL) |
| 14058 | { |
| 14059 | vos_mem_copy(&pHddCtx->p2pDeviceAddress.bytes[0], |
| 14060 | p2p_dev_addr, VOS_MAC_ADDR_SIZE); |
| 14061 | } |
| 14062 | else |
| 14063 | { |
| 14064 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 14065 | "%s: Failed to allocate mac_address for p2p_device", |
| 14066 | __func__); |
| 14067 | goto err_close_adapter; |
| 14068 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14069 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 14070 | |
| 14071 | pP2pAdapter = hdd_open_adapter( pHddCtx, WLAN_HDD_P2P_DEVICE, "p2p%d", |
| 14072 | &pHddCtx->p2pDeviceAddress.bytes[0], FALSE ); |
| 14073 | if ( NULL == pP2pAdapter ) |
| 14074 | { |
| 14075 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 14076 | "%s: Failed to do hdd_open_adapter for P2P Device Interface", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 14077 | __func__); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 14078 | goto err_close_adapter; |
| 14079 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 14080 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14081 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14082 | |
| 14083 | if( pAdapter == NULL ) |
| 14084 | { |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 14085 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: hdd_open_adapter failed", __func__); |
| 14086 | goto err_close_adapter; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14087 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 14088 | |
Ashish Kumar Dhanotiya | 3ac85a2 | 2019-02-12 19:10:14 +0530 | [diff] [blame] | 14089 | if ((strlen(pHddCtx->cfg_ini->enabledefaultSAP) != 0) && |
| 14090 | (strcmp(pHddCtx->cfg_ini->enabledefaultSAP, "") != 0)) { |
Arunk Khandavalli | 95608be | 2019-01-22 13:12:54 +0530 | [diff] [blame] | 14091 | softapAdapter = hdd_open_adapter( pHddCtx, WLAN_HDD_SOFTAP, |
| 14092 | pHddCtx->cfg_ini->enabledefaultSAP, |
| 14093 | wlan_hdd_get_intf_addr(pHddCtx), FALSE); |
| 14094 | if (!softapAdapter) { |
| 14095 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: hdd_open_adapter failed", __func__); |
| 14096 | goto err_close_adapter; |
| 14097 | } |
| 14098 | } |
| 14099 | |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 14100 | if (country_code) |
| 14101 | { |
| 14102 | eHalStatus ret; |
Arif Hussain | cb60708 | 2013-12-20 11:57:42 -0800 | [diff] [blame] | 14103 | INIT_COMPLETION(pAdapter->change_country_code); |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 14104 | hdd_checkandupdate_dfssetting(pAdapter, country_code); |
| 14105 | #ifndef CONFIG_ENABLE_LINUX_REG |
| 14106 | hdd_checkandupdate_phymode(pAdapter, country_code); |
| 14107 | #endif |
Arif Hussain | eaf6860 | 2013-12-30 23:10:44 -0800 | [diff] [blame] | 14108 | ret = sme_ChangeCountryCode(pHddCtx->hHal, |
| 14109 | (void *)(tSmeChangeCountryCallback) |
| 14110 | wlan_hdd_change_country_code_callback, |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 14111 | country_code, |
| 14112 | pAdapter, pHddCtx->pvosContext, |
Abhishek Singh | a306a44 | 2013-11-07 18:39:01 +0530 | [diff] [blame] | 14113 | eSIR_TRUE, eSIR_TRUE); |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 14114 | if (eHAL_STATUS_SUCCESS == ret) |
| 14115 | { |
Arif Hussain | cb60708 | 2013-12-20 11:57:42 -0800 | [diff] [blame] | 14116 | ret = wait_for_completion_interruptible_timeout( |
| 14117 | &pAdapter->change_country_code, |
| 14118 | msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY)); |
| 14119 | |
| 14120 | if (0 >= ret) |
| 14121 | { |
| 14122 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 14123 | "%s: SME while setting country code timed out", __func__); |
| 14124 | } |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 14125 | } |
| 14126 | else |
| 14127 | { |
Arif Hussain | cb60708 | 2013-12-20 11:57:42 -0800 | [diff] [blame] | 14128 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 14129 | "%s: SME Change Country code from module param fail ret=%d", |
| 14130 | __func__, ret); |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 14131 | } |
| 14132 | } |
| 14133 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14134 | #ifdef WLAN_BTAMP_FEATURE |
| 14135 | vStatus = WLANBAP_Open(pVosContext); |
| 14136 | if(!VOS_IS_STATUS_SUCCESS(vStatus)) |
| 14137 | { |
| 14138 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 14139 | "%s: Failed to open BAP",__func__); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 14140 | goto err_close_adapter; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14141 | } |
| 14142 | |
| 14143 | vStatus = BSL_Init(pVosContext); |
| 14144 | if(!VOS_IS_STATUS_SUCCESS(vStatus)) |
| 14145 | { |
| 14146 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 14147 | "%s: Failed to Init BSL",__func__); |
| 14148 | goto err_bap_close; |
| 14149 | } |
| 14150 | vStatus = WLANBAP_Start(pVosContext); |
| 14151 | if (!VOS_IS_STATUS_SUCCESS(vStatus)) |
| 14152 | { |
| 14153 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 14154 | "%s: Failed to start TL",__func__); |
| 14155 | goto err_bap_close; |
| 14156 | } |
| 14157 | |
| 14158 | pConfig = pHddCtx->cfg_ini; |
| 14159 | btAmpConfig.ucPreferredChannel = pConfig->preferredChannel; |
| 14160 | status = WLANBAP_SetConfig(&btAmpConfig); |
| 14161 | |
| 14162 | #endif //WLAN_BTAMP_FEATURE |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 14163 | |
Mihir Shete | 9c23877 | 2014-10-15 14:35:16 +0530 | [diff] [blame] | 14164 | /* |
| 14165 | * UapsdMask is 0xf if U-APSD is enbaled for all AC's... |
| 14166 | * The value of CFG_QOS_WMM_UAPSD_MASK_DEFAULT is 0xaa(Magic Value) |
| 14167 | * which is greater than 0xf. So the below check is safe to make |
| 14168 | * sure that there is no entry for UapsdMask in the ini |
| 14169 | */ |
| 14170 | if (CFG_QOS_WMM_UAPSD_MASK_DEFAULT == pHddCtx->cfg_ini->UapsdMask) |
| 14171 | { |
| 14172 | if(IS_DYNAMIC_WMM_PS_ENABLED) |
| 14173 | { |
| 14174 | hddLog(VOS_TRACE_LEVEL_DEBUG,"%s: Enable UAPSD for VI & VO", |
| 14175 | __func__); |
| 14176 | pHddCtx->cfg_ini->UapsdMask = |
| 14177 | CFG_QOS_WMM_UAPSD_MASK_DYMANIC_WMM_PS_DEFAULT; |
| 14178 | } |
| 14179 | else |
| 14180 | { |
| 14181 | hddLog(VOS_TRACE_LEVEL_DEBUG,"%s: Do not enable UAPSD", |
| 14182 | __func__); |
| 14183 | pHddCtx->cfg_ini->UapsdMask = |
| 14184 | CFG_QOS_WMM_UAPSD_MASK_LEGACY_WMM_PS_DEFAULT; |
| 14185 | } |
| 14186 | } |
| 14187 | |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 14188 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 14189 | if(!(IS_ROAM_SCAN_OFFLOAD_FEATURE_ENABLE)) |
| 14190 | { |
| 14191 | hddLog(VOS_TRACE_LEVEL_DEBUG,"%s: ROAM_SCAN_OFFLOAD Feature not supported",__func__); |
| 14192 | pHddCtx->cfg_ini->isRoamOffloadScanEnabled = 0; |
| 14193 | sme_UpdateRoamScanOffloadEnabled((tHalHandle)(pHddCtx->hHal), |
| 14194 | pHddCtx->cfg_ini->isRoamOffloadScanEnabled); |
| 14195 | } |
| 14196 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14197 | |
Agarwal Ashish | 4b87f92 | 2014-06-18 03:03:21 +0530 | [diff] [blame] | 14198 | wlan_hdd_tdls_init(pHddCtx); |
| 14199 | |
Masti, Narayanraddi | 2637846 | 2016-01-05 18:20:28 +0530 | [diff] [blame] | 14200 | wlan_hdd_init_deinit_defer_scan_context(&pHddCtx->scan_ctxt); |
| 14201 | |
| 14202 | vos_init_delayed_work(&pHddCtx->scan_ctxt.scan_work, |
| 14203 | wlan_hdd_schedule_defer_scan); |
| 14204 | |
Mihir Shete | fc7ff5b | 2014-01-27 11:30:05 +0530 | [diff] [blame] | 14205 | sme_Register11dScanDoneCallback(pHddCtx->hHal, hdd_11d_scan_done); |
| 14206 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14207 | /* Register with platform driver as client for Suspend/Resume */ |
| 14208 | status = hddRegisterPmOps(pHddCtx); |
| 14209 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 14210 | { |
| 14211 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddRegisterPmOps failed",__func__); |
| 14212 | #ifdef WLAN_BTAMP_FEATURE |
| 14213 | goto err_bap_stop; |
| 14214 | #else |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 14215 | goto err_close_adapter; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14216 | #endif //WLAN_BTAMP_FEATURE |
| 14217 | } |
| 14218 | |
Yue Ma | 0d4891e | 2013-08-06 17:01:45 -0700 | [diff] [blame] | 14219 | /* Open debugfs interface */ |
| 14220 | if (VOS_STATUS_SUCCESS != hdd_debugfs_init(pAdapter)) |
| 14221 | { |
| 14222 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, |
| 14223 | "%s: hdd_debugfs_init failed!", __func__); |
Yue Ma | 0d4891e | 2013-08-06 17:01:45 -0700 | [diff] [blame] | 14224 | } |
| 14225 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14226 | /* Register TM level change handler function to the platform */ |
| 14227 | status = hddDevTmRegisterNotifyCallback(pHddCtx); |
| 14228 | if ( !VOS_IS_STATUS_SUCCESS( status ) ) |
| 14229 | { |
| 14230 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddDevTmRegisterNotifyCallback failed",__func__); |
| 14231 | goto err_unregister_pmops; |
| 14232 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14233 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14234 | // register net device notifier for device change notification |
| 14235 | ret = register_netdevice_notifier(&hdd_netdev_notifier); |
| 14236 | |
| 14237 | if(ret < 0) |
| 14238 | { |
| 14239 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: register_netdevice_notifier failed",__func__); |
Siddharth Bhal | cd92b78 | 2015-06-29 12:25:40 +0530 | [diff] [blame] | 14240 | goto err_unregister_pmops; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14241 | } |
| 14242 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14243 | //Initialize the BTC service |
| 14244 | if(btc_activate_service(pHddCtx) != 0) |
| 14245 | { |
| 14246 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: btc_activate_service failed",__func__); |
Mahesh A Saptasagar | c3ed012 | 2016-01-19 16:45:11 +0530 | [diff] [blame] | 14247 | goto err_reg_netdev; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14248 | } |
| 14249 | |
Padma, Santhosh Kumar | 2762e9d | 2015-10-20 15:02:57 +0530 | [diff] [blame] | 14250 | #ifdef FEATURE_OEM_DATA_SUPPORT |
| 14251 | //Initialize the OEM service |
| 14252 | if (oem_activate_service(pHddCtx) != 0) |
| 14253 | { |
| 14254 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 14255 | "%s: oem_activate_service failed", __func__); |
Hanumanth Reddy Pothula | 13789c4 | 2017-09-12 15:18:13 +0530 | [diff] [blame] | 14256 | goto err_btc_activate_service; |
Padma, Santhosh Kumar | 2762e9d | 2015-10-20 15:02:57 +0530 | [diff] [blame] | 14257 | } |
| 14258 | #endif |
| 14259 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14260 | #ifdef PTT_SOCK_SVC_ENABLE |
| 14261 | //Initialize the PTT service |
| 14262 | if(ptt_sock_activate_svc(pHddCtx) != 0) |
| 14263 | { |
| 14264 | 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] | 14265 | goto err_oem_activate_service; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14266 | } |
| 14267 | #endif |
| 14268 | |
Abhishek Singh | 00b7197 | 2016-01-07 10:51:04 +0530 | [diff] [blame] | 14269 | #ifdef WLAN_FEATURE_RMC |
| 14270 | if (hdd_open_cesium_nl_sock() < 0) |
| 14271 | { |
| 14272 | 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] | 14273 | goto err_ptt_sock_activate_svc; |
Abhishek Singh | 00b7197 | 2016-01-07 10:51:04 +0530 | [diff] [blame] | 14274 | } |
| 14275 | #endif |
| 14276 | |
Vinay Krishna Eranna | d938c42 | 2014-03-10 17:14:21 +0530 | [diff] [blame] | 14277 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 14278 | if(pHddCtx->cfg_ini && pHddCtx->cfg_ini->wlanLoggingEnable) |
| 14279 | { |
Deepthi Gowri | 78083a3 | 2014-11-04 12:55:51 +0530 | [diff] [blame] | 14280 | if(wlan_logging_sock_activate_svc( |
| 14281 | pHddCtx->cfg_ini->wlanLoggingFEToConsole, |
Sushant Kaushik | 3320057 | 2015-08-05 16:46:20 +0530 | [diff] [blame] | 14282 | pHddCtx->cfg_ini->wlanLoggingNumBuf, |
| 14283 | pHddCtx->cfg_ini->wlanPerPktStatsLogEnable, |
| 14284 | pHddCtx->cfg_ini->wlanPerPktStatsNumBuf)) |
Deepthi Gowri | 78083a3 | 2014-11-04 12:55:51 +0530 | [diff] [blame] | 14285 | { |
| 14286 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wlan_logging_sock_activate_svc" |
| 14287 | " failed", __func__); |
Hanumanth Reddy Pothula | 13789c4 | 2017-09-12 15:18:13 +0530 | [diff] [blame] | 14288 | goto err_open_cesium_nl_sock; |
Deepthi Gowri | 78083a3 | 2014-11-04 12:55:51 +0530 | [diff] [blame] | 14289 | } |
| 14290 | //TODO: To Remove enableDhcpDebug and use gEnableDebugLog for |
| 14291 | //EAPOL and DHCP |
Sachin Ahuja | 8c65f38 | 2014-12-12 15:34:21 +0530 | [diff] [blame] | 14292 | if (!pHddCtx->cfg_ini->gEnableDebugLog) |
| 14293 | pHddCtx->cfg_ini->gEnableDebugLog = |
Sushant Kaushik | 6e4e2bc | 2015-10-05 17:23:07 +0530 | [diff] [blame] | 14294 | VOS_PKT_PROTO_TYPE_EAPOL | VOS_PKT_PROTO_TYPE_DHCP | |
| 14295 | VOS_PKT_PROTO_TYPE_ARP; |
Vinay Krishna Eranna | d938c42 | 2014-03-10 17:14:21 +0530 | [diff] [blame] | 14296 | } |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 14297 | |
Siddharth Bhal | d1be97f | 2015-05-27 22:39:59 +0530 | [diff] [blame] | 14298 | if (pHddCtx->cfg_ini->wlanLoggingEnable && |
| 14299 | (pHddCtx->cfg_ini->enableFWLogging || |
Siddharth Bhal | db96323 | 2015-06-25 19:34:35 +0530 | [diff] [blame] | 14300 | pHddCtx->cfg_ini->enableMgmtLogging || |
sheenam monga | 1a0202d | 2020-01-03 15:20:57 +0530 | [diff] [blame] | 14301 | pHddCtx->cfg_ini->enableContFWLogging)) |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 14302 | { |
Siddharth Bhal | d1be97f | 2015-05-27 22:39:59 +0530 | [diff] [blame] | 14303 | hdd_init_frame_logging(pHddCtx); |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 14304 | } |
| 14305 | else |
| 14306 | { |
Siddharth Bhal | d1be97f | 2015-05-27 22:39:59 +0530 | [diff] [blame] | 14307 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Logging disabled in ini")); |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 14308 | } |
| 14309 | |
Vinay Krishna Eranna | d938c42 | 2014-03-10 17:14:21 +0530 | [diff] [blame] | 14310 | #endif |
Siddharth Bhal | b7c421c | 2015-02-27 00:26:09 +0530 | [diff] [blame] | 14311 | |
Sushant Kaushik | 215778f | 2015-05-21 14:05:36 +0530 | [diff] [blame] | 14312 | if (vos_is_multicast_logging()) |
| 14313 | wlan_logging_set_log_level(); |
| 14314 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14315 | hdd_register_mcast_bcast_filter(pHddCtx); |
Bala Venkatesh | e65810a | 2019-02-18 20:32:36 +0530 | [diff] [blame] | 14316 | |
| 14317 | /* Action frame registered in one adapter which will |
| 14318 | * applicable to all interfaces |
| 14319 | */ |
| 14320 | wlan_hdd_cfg80211_register_frames(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14321 | |
| 14322 | mutex_init(&pHddCtx->sap_lock); |
Mahesh A Saptasagar | 6062794 | 2014-10-13 13:55:14 +0530 | [diff] [blame] | 14323 | mutex_init(&pHddCtx->roc_lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14324 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 14325 | #ifdef WLAN_FEATURE_HOLD_RX_WAKELOCK |
| 14326 | /* Initialize the wake lcok */ |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 14327 | vos_wake_lock_init(&pHddCtx->rx_wake_lock, |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 14328 | "qcom_rx_wakelock"); |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 14329 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 14330 | #endif |
Madan Mohan Koyyalamudi | 69fc3ad | 2012-11-28 16:04:56 -0800 | [diff] [blame] | 14331 | /* Initialize the wake lcok */ |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 14332 | vos_wake_lock_init(&pHddCtx->sap_wake_lock, |
Madan Mohan Koyyalamudi | 69fc3ad | 2012-11-28 16:04:56 -0800 | [diff] [blame] | 14333 | "qcom_sap_wakelock"); |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 14334 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 14335 | |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 14336 | vos_event_init(&pHddCtx->scan_info.scan_finished_event); |
| 14337 | pHddCtx->scan_info.scan_pending_option = WEXT_SCAN_PENDING_GIVEUP; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14338 | |
Katya Nigam | 5c306ea | 2014-06-19 15:39:54 +0530 | [diff] [blame] | 14339 | pHddCtx->isLoadUnloadInProgress = WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14340 | vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, FALSE); |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 14341 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_DRIVER_INIT); |
Katya Nigam | 5c306ea | 2014-06-19 15:39:54 +0530 | [diff] [blame] | 14342 | |
| 14343 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 14344 | /*SME must send channel update configuration to RIVA*/ |
| 14345 | sme_UpdateChannelConfig(pHddCtx->hHal); |
| 14346 | #endif |
Abhishek Singh | f644b27 | 2014-08-21 02:59:39 +0530 | [diff] [blame] | 14347 | /* Send the update default channel list to the FW*/ |
| 14348 | sme_UpdateChannelList(pHddCtx->hHal); |
Mukul Sharma | 4506394 | 2015-04-01 20:07:59 +0530 | [diff] [blame] | 14349 | |
| 14350 | /* Fwr capabilities received, Set the Dot11 mode */ |
Abhishek Singh | 41ebce1 | 2016-02-03 10:43:21 +0530 | [diff] [blame] | 14351 | sme_SetPhyMode(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 14352 | hdd_cfg_xlate_to_csr_phy_mode(pHddCtx->cfg_ini->dot11Mode)); |
Mukul Sharma | 4506394 | 2015-04-01 20:07:59 +0530 | [diff] [blame] | 14353 | sme_SetDefDot11Mode(pHddCtx->hHal); |
| 14354 | |
Abhishek Singh | a306a44 | 2013-11-07 18:39:01 +0530 | [diff] [blame] | 14355 | #ifndef CONFIG_ENABLE_LINUX_REG |
| 14356 | /*updating wiphy so that regulatory user hints can be processed*/ |
| 14357 | if (wiphy) |
| 14358 | { |
| 14359 | regulatory_hint(wiphy, "00"); |
| 14360 | } |
| 14361 | #endif |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 14362 | // Initialize the restart logic |
| 14363 | wlan_hdd_restart_init(pHddCtx); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 14364 | |
Hanumanth Reddy Pothula | 146bca4 | 2016-11-08 12:01:07 +0530 | [diff] [blame] | 14365 | if (pHddCtx->cfg_ini->fIsLogpEnabled) { |
| 14366 | vos_wdthread_init_timer_work(vos_process_wd_timer); |
| 14367 | /* Initialize the timer to detect thread stuck issues */ |
| 14368 | vos_thread_stuck_timer_init( |
| 14369 | &((VosContextType*)pVosContext)->vosWatchdog); |
| 14370 | } |
| 14371 | |
Sudhir Sattayappa Kohalli | 3762069 | 2013-08-05 14:02:26 -0700 | [diff] [blame] | 14372 | //Register the traffic monitor timer now |
| 14373 | if ( pHddCtx->cfg_ini->dynSplitscan) |
| 14374 | { |
| 14375 | vos_timer_init(&pHddCtx->tx_rx_trafficTmr, |
| 14376 | VOS_TIMER_TYPE_SW, |
| 14377 | hdd_tx_rx_pkt_cnt_stat_timer_handler, |
| 14378 | (void *)pHddCtx); |
| 14379 | } |
Srinivas Dasari | 030bad3 | 2015-02-18 23:23:54 +0530 | [diff] [blame] | 14380 | wlan_hdd_cfg80211_nan_init(pHddCtx); |
| 14381 | |
Bhargav Shah | d071591 | 2015-10-01 18:17:37 +0530 | [diff] [blame] | 14382 | mutex_init(&pHddCtx->cur_rx_level_lock); |
| 14383 | vos_timer_init(&pHddCtx->delack_timer, VOS_TIMER_TYPE_SW, |
| 14384 | hdd_tcp_delack_compute_function,(void *)pHddCtx); |
Masti, Narayanraddi | 44b0db0 | 2015-12-22 11:54:35 +0530 | [diff] [blame] | 14385 | vos_timer_init(&pHddCtx->tdls_source_timer, VOS_TIMER_TYPE_SW, |
| 14386 | wlan_hdd_change_tdls_mode, (void *)pHddCtx); |
Bhargav Shah | d071591 | 2015-10-01 18:17:37 +0530 | [diff] [blame] | 14387 | |
Dino Mycle | 6fb96c1 | 2014-06-10 11:52:40 +0530 | [diff] [blame] | 14388 | #ifdef WLAN_FEATURE_EXTSCAN |
| 14389 | sme_EXTScanRegisterCallback(pHddCtx->hHal, |
| 14390 | wlan_hdd_cfg80211_extscan_callback, |
| 14391 | pHddCtx); |
| 14392 | #endif /* WLAN_FEATURE_EXTSCAN */ |
Vinay Krishna Eranna | f97ef5c | 2014-12-26 17:47:19 +0530 | [diff] [blame] | 14393 | |
Padma, Santhosh Kumar | 2ccac21 | 2015-10-20 17:27:27 +0530 | [diff] [blame] | 14394 | #ifdef FEATURE_OEM_DATA_SUPPORT |
| 14395 | sme_OemDataRegisterCallback(pHddCtx->hHal, |
| 14396 | wlan_hdd_cfg80211_oemdata_callback, |
| 14397 | pHddCtx); |
| 14398 | #endif /* FEATURE_OEM_DATA_SUPPORT */ |
| 14399 | |
Gupta, Kapil | 7c34b32 | 2015-09-30 13:12:35 +0530 | [diff] [blame] | 14400 | 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] | 14401 | #ifdef WLAN_NS_OFFLOAD |
| 14402 | // Register IPv6 notifier to notify if any change in IP |
| 14403 | // So that we can reconfigure the offload parameters |
| 14404 | pHddCtx->ipv6_notifier.notifier_call = wlan_hdd_ipv6_changed; |
| 14405 | ret = register_inet6addr_notifier(&pHddCtx->ipv6_notifier); |
| 14406 | if (ret) |
| 14407 | { |
Ratheesh S P | 36dbc93 | 2015-08-07 14:28:57 +0530 | [diff] [blame] | 14408 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to register IPv6 notifier")); |
Vinay Krishna Eranna | f97ef5c | 2014-12-26 17:47:19 +0530 | [diff] [blame] | 14409 | } |
| 14410 | else |
| 14411 | { |
Ratheesh S P | 36dbc93 | 2015-08-07 14:28:57 +0530 | [diff] [blame] | 14412 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Registered IPv6 notifier")); |
Vinay Krishna Eranna | f97ef5c | 2014-12-26 17:47:19 +0530 | [diff] [blame] | 14413 | } |
| 14414 | #endif |
| 14415 | |
Sravan Kumar Kairam | b0edc61 | 2016-10-26 13:55:24 +0530 | [diff] [blame] | 14416 | vos_mem_set((uint8_t *)&pHddCtx->bad_sta, HDD_MAX_STA_COUNT, 0); |
| 14417 | |
Vinay Krishna Eranna | f97ef5c | 2014-12-26 17:47:19 +0530 | [diff] [blame] | 14418 | // Register IPv4 notifier to notify if any change in IP |
| 14419 | // So that we can reconfigure the offload parameters |
| 14420 | pHddCtx->ipv4_notifier.notifier_call = wlan_hdd_ipv4_changed; |
| 14421 | ret = register_inetaddr_notifier(&pHddCtx->ipv4_notifier); |
| 14422 | if (ret) |
| 14423 | { |
Ratheesh S P | 36dbc93 | 2015-08-07 14:28:57 +0530 | [diff] [blame] | 14424 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to register IPv4 notifier")); |
Vinay Krishna Eranna | f97ef5c | 2014-12-26 17:47:19 +0530 | [diff] [blame] | 14425 | } |
| 14426 | else |
| 14427 | { |
Ratheesh S P | 36dbc93 | 2015-08-07 14:28:57 +0530 | [diff] [blame] | 14428 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Registered IPv4 notifier")); |
Vinay Krishna Eranna | f97ef5c | 2014-12-26 17:47:19 +0530 | [diff] [blame] | 14429 | } |
Bhargav shah | 23c9494 | 2015-10-13 12:48:35 +0530 | [diff] [blame] | 14430 | hdd_dp_util_send_rps_ind(pHddCtx); |
Vinay Krishna Eranna | f97ef5c | 2014-12-26 17:47:19 +0530 | [diff] [blame] | 14431 | |
Nishank Aggarwal | c11826c | 2016-12-15 18:54:10 +0530 | [diff] [blame] | 14432 | pHddCtx->is_ap_mode_wow_supported = |
| 14433 | sme_IsFeatureSupportedByFW(SAP_MODE_WOW); |
Sravan Kumar Kairam | 091e5b6 | 2017-01-23 14:14:20 +0530 | [diff] [blame] | 14434 | |
Hanumanth Reddy Pothula | e92bcc1 | 2017-05-19 13:56:35 +0530 | [diff] [blame] | 14435 | pHddCtx->is_fatal_event_log_sup = |
| 14436 | sme_IsFeatureSupportedByFW(FATAL_EVENT_LOGGING); |
| 14437 | hddLog(VOS_TRACE_LEVEL_INFO, FL("FATAL_EVENT_LOGGING: %d"), |
| 14438 | pHddCtx->is_fatal_event_log_sup); |
| 14439 | |
Sravan Kumar Kairam | 091e5b6 | 2017-01-23 14:14:20 +0530 | [diff] [blame] | 14440 | hdd_assoc_registerFwdEapolCB(pVosContext); |
| 14441 | |
Ashish Kumar Dhanotiya | 32d092b | 2018-02-20 21:43:57 +0530 | [diff] [blame] | 14442 | mutex_init(&pHddCtx->cache_channel_lock); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14443 | goto success; |
| 14444 | |
Hanumanth Reddy Pothula | 13789c4 | 2017-09-12 15:18:13 +0530 | [diff] [blame] | 14445 | err_open_cesium_nl_sock: |
| 14446 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 14447 | hdd_close_cesium_nl_sock(); |
| 14448 | #endif |
| 14449 | |
| 14450 | err_ptt_sock_activate_svc: |
| 14451 | #ifdef PTT_SOCK_SVC_ENABLE |
| 14452 | ptt_sock_deactivate_svc(pHddCtx); |
| 14453 | #endif |
| 14454 | |
| 14455 | err_oem_activate_service: |
| 14456 | #ifdef FEATURE_OEM_DATA_SUPPORT |
| 14457 | oem_deactivate_service(); |
| 14458 | #endif |
| 14459 | |
| 14460 | err_btc_activate_service: |
| 14461 | btc_deactivate_service(); |
| 14462 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14463 | err_reg_netdev: |
| 14464 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 14465 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14466 | err_unregister_pmops: |
| 14467 | hddDevTmUnregisterNotifyCallback(pHddCtx); |
| 14468 | hddDeregisterPmOps(pHddCtx); |
| 14469 | |
Yue Ma | 0d4891e | 2013-08-06 17:01:45 -0700 | [diff] [blame] | 14470 | hdd_debugfs_exit(pHddCtx); |
| 14471 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14472 | #ifdef WLAN_BTAMP_FEATURE |
| 14473 | err_bap_stop: |
| 14474 | WLANBAP_Stop(pVosContext); |
| 14475 | #endif |
| 14476 | |
| 14477 | #ifdef WLAN_BTAMP_FEATURE |
| 14478 | err_bap_close: |
| 14479 | WLANBAP_Close(pVosContext); |
| 14480 | #endif |
| 14481 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14482 | err_close_adapter: |
| 14483 | hdd_close_all_adapters( pHddCtx ); |
Mahesh A Saptasagar | 9ecefe4 | 2014-07-15 18:43:49 +0530 | [diff] [blame] | 14484 | #ifdef CONFIG_ENABLE_LINUX_REG |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 14485 | err_unregister_wiphy: |
Mahesh A Saptasagar | 9ecefe4 | 2014-07-15 18:43:49 +0530 | [diff] [blame] | 14486 | #endif |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 14487 | wiphy_unregister(wiphy) ; |
Agrawal Ashish | 33ec71e | 2015-11-26 20:20:58 +0530 | [diff] [blame] | 14488 | hdd_wlan_free_wiphy_channels(wiphy); |
| 14489 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14490 | err_vosstop: |
| 14491 | vos_stop(pVosContext); |
| 14492 | |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 14493 | err_vosclose: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14494 | status = vos_sched_close( pVosContext ); |
| 14495 | if (!VOS_IS_STATUS_SUCCESS(status)) { |
| 14496 | VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL, |
| 14497 | "%s: Failed to close VOSS Scheduler", __func__); |
| 14498 | VOS_ASSERT( VOS_IS_STATUS_SUCCESS( status ) ); |
| 14499 | } |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 14500 | vos_close(pVosContext ); |
| 14501 | |
Mahesh A Saptasagar | c3ed012 | 2016-01-19 16:45:11 +0530 | [diff] [blame] | 14502 | err_nl_srv: |
| 14503 | #ifdef WLAN_KD_READY_NOTIFIER |
| 14504 | nl_srv_exit(pHddCtx->ptt_pid); |
| 14505 | #else |
| 14506 | nl_srv_exit(); |
| 14507 | #endif /* WLAN_KD_READY_NOTIFIER */ |
Amar Singhal | 0a40223 | 2013-10-11 20:57:16 -0700 | [diff] [blame] | 14508 | err_vos_nv_close: |
| 14509 | |
c_hpothu | e6a3628 | 2014-03-19 12:27:38 +0530 | [diff] [blame] | 14510 | #ifdef CONFIG_ENABLE_LINUX_REG |
Amar Singhal | 0a40223 | 2013-10-11 20:57:16 -0700 | [diff] [blame] | 14511 | vos_nv_close(); |
| 14512 | |
c_hpothu | 70f8d81 | 2014-03-22 22:59:23 +0530 | [diff] [blame] | 14513 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14514 | |
| 14515 | err_wdclose: |
| 14516 | if(pHddCtx->cfg_ini->fIsLogpEnabled) |
| 14517 | vos_watchdog_close(pVosContext); |
| 14518 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14519 | err_config: |
Hanumanth Reddy Pothula | 1efcd16 | 2018-03-14 14:32:27 +0530 | [diff] [blame] | 14520 | hdd_request_manager_deinit(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14521 | kfree(pHddCtx->cfg_ini); |
| 14522 | pHddCtx->cfg_ini= NULL; |
| 14523 | |
| 14524 | err_free_hdd_context: |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 14525 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_DRIVER_INIT); |
Siddharth Bhal | cd92b78 | 2015-06-29 12:25:40 +0530 | [diff] [blame] | 14526 | free_riva_power_on_lock("wlan"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14527 | wiphy_free(wiphy) ; |
| 14528 | //kfree(wdev) ; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14529 | VOS_BUG(1); |
| 14530 | |
Madan Mohan Koyyalamudi | d57ae63 | 2012-11-06 18:42:48 -0800 | [diff] [blame] | 14531 | if (hdd_is_ssr_required()) |
| 14532 | { |
| 14533 | /* WDI timeout had happened during load, so SSR is needed here */ |
| 14534 | subsystem_restart("wcnss"); |
| 14535 | msleep(5000); |
| 14536 | } |
| 14537 | hdd_set_ssr_required (VOS_FALSE); |
| 14538 | |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 14539 | return -EIO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14540 | |
| 14541 | success: |
| 14542 | EXIT(); |
| 14543 | return 0; |
| 14544 | } |
| 14545 | |
| 14546 | /**--------------------------------------------------------------------------- |
| 14547 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 14548 | \brief hdd_driver_init() - Core Driver Init Function |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14549 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 14550 | This is the driver entry point - called in different timeline depending |
| 14551 | on whether the driver is statically or dynamically linked |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14552 | |
| 14553 | \param - None |
| 14554 | |
| 14555 | \return - 0 for success, non zero for failure |
| 14556 | |
| 14557 | --------------------------------------------------------------------------*/ |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 14558 | static int hdd_driver_init( void) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14559 | { |
| 14560 | VOS_STATUS status; |
| 14561 | v_CONTEXT_t pVosContext = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14562 | struct device *dev = NULL; |
| 14563 | int ret_status = 0; |
Sameer Thalappil | f58d7ec | 2013-04-25 20:17:12 -0700 | [diff] [blame] | 14564 | #ifdef HAVE_WCNSS_CAL_DOWNLOAD |
| 14565 | int max_retries = 0; |
| 14566 | #endif |
Siddharth Bhal | c7e79b6 | 2014-10-10 22:37:38 +0530 | [diff] [blame] | 14567 | #ifdef HAVE_CBC_DONE |
| 14568 | int max_cbc_retries = 0; |
| 14569 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14570 | |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 14571 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 14572 | wlan_logging_sock_init_svc(); |
| 14573 | #endif |
| 14574 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14575 | ENTER(); |
| 14576 | |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 14577 | vos_wake_lock_init(&wlan_wake_lock, "wlan"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14578 | |
| 14579 | pr_info("%s: loading driver v%s\n", WLAN_MODULE_NAME, |
| 14580 | QWLAN_VERSIONSTR TIMER_MANAGER_STR MEMORY_DEBUG_STR); |
| 14581 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14582 | #ifdef ANI_BUS_TYPE_PCI |
| 14583 | |
| 14584 | dev = wcnss_wlan_get_device(); |
| 14585 | |
| 14586 | #endif // ANI_BUS_TYPE_PCI |
| 14587 | |
| 14588 | #ifdef ANI_BUS_TYPE_PLATFORM |
Sameer Thalappil | f58d7ec | 2013-04-25 20:17:12 -0700 | [diff] [blame] | 14589 | |
| 14590 | #ifdef HAVE_WCNSS_CAL_DOWNLOAD |
| 14591 | /* wait until WCNSS driver downloads NV */ |
Ravi Kumar Bokka | 7a139e6 | 2016-11-17 21:32:55 +0530 | [diff] [blame] | 14592 | while (!wcnss_device_ready() && 10 >= ++max_retries) { |
Sameer Thalappil | f58d7ec | 2013-04-25 20:17:12 -0700 | [diff] [blame] | 14593 | msleep(1000); |
| 14594 | } |
Siddharth Bhal | c7e79b6 | 2014-10-10 22:37:38 +0530 | [diff] [blame] | 14595 | |
Ravi Kumar Bokka | 7a139e6 | 2016-11-17 21:32:55 +0530 | [diff] [blame] | 14596 | if (max_retries >= 10) { |
Sameer Thalappil | f58d7ec | 2013-04-25 20:17:12 -0700 | [diff] [blame] | 14597 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: WCNSS driver not ready", __func__); |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 14598 | vos_wake_lock_destroy(&wlan_wake_lock); |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 14599 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 14600 | wlan_logging_sock_deinit_svc(); |
| 14601 | #endif |
| 14602 | |
Sameer Thalappil | f58d7ec | 2013-04-25 20:17:12 -0700 | [diff] [blame] | 14603 | return -ENODEV; |
| 14604 | } |
| 14605 | #endif |
| 14606 | |
Siddharth Bhal | c7e79b6 | 2014-10-10 22:37:38 +0530 | [diff] [blame] | 14607 | #ifdef HAVE_CBC_DONE |
| 14608 | while (!wcnss_cbc_complete() && 10 >= ++max_cbc_retries) { |
| 14609 | msleep(1000); |
| 14610 | } |
| 14611 | if (max_cbc_retries >= 10) { |
| 14612 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s:CBC not completed", __func__); |
| 14613 | } |
| 14614 | #endif |
| 14615 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14616 | dev = wcnss_wlan_get_device(); |
| 14617 | #endif // ANI_BUS_TYPE_PLATFORM |
| 14618 | |
| 14619 | |
| 14620 | do { |
| 14621 | if (NULL == dev) { |
| 14622 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: WLAN device not found!!",__func__); |
| 14623 | ret_status = -1; |
| 14624 | break; |
| 14625 | } |
| 14626 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14627 | #ifdef TIMER_MANAGER |
| 14628 | vos_timer_manager_init(); |
| 14629 | #endif |
| 14630 | |
| 14631 | /* Preopen VOSS so that it is ready to start at least SAL */ |
| 14632 | status = vos_preOpen(&pVosContext); |
| 14633 | |
| 14634 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 14635 | { |
| 14636 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Failed to preOpen VOSS", __func__); |
| 14637 | ret_status = -1; |
| 14638 | break; |
| 14639 | } |
| 14640 | |
Sushant Kaushik | 02beb35 | 2015-06-04 15:15:01 +0530 | [diff] [blame] | 14641 | hddTraceInit(); |
Padma, Santhosh Kumar | 9093b20 | 2015-07-21 15:37:38 +0530 | [diff] [blame] | 14642 | hdd_register_debug_callback(); |
| 14643 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 14644 | #ifndef MODULE |
| 14645 | /* For statically linked driver, call hdd_set_conparam to update curr_con_mode |
| 14646 | */ |
| 14647 | hdd_set_conparam((v_UINT_t)con_mode); |
| 14648 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14649 | |
| 14650 | // Call our main init function |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 14651 | if (hdd_wlan_startup(dev)) |
| 14652 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14653 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: WLAN Driver Initialization failed", |
Jeff Johnson | bc676b4 | 2013-02-14 16:04:08 -0800 | [diff] [blame] | 14654 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14655 | vos_preClose( &pVosContext ); |
| 14656 | ret_status = -1; |
| 14657 | break; |
| 14658 | } |
| 14659 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14660 | } while (0); |
| 14661 | |
| 14662 | if (0 != ret_status) |
| 14663 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14664 | #ifdef TIMER_MANAGER |
| 14665 | vos_timer_exit(); |
| 14666 | #endif |
| 14667 | #ifdef MEMORY_DEBUG |
| 14668 | vos_mem_exit(); |
| 14669 | #endif |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 14670 | vos_wake_lock_destroy(&wlan_wake_lock); |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 14671 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 14672 | wlan_logging_sock_deinit_svc(); |
| 14673 | #endif |
| 14674 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14675 | pr_err("%s: driver load failure\n", WLAN_MODULE_NAME); |
| 14676 | } |
| 14677 | else |
| 14678 | { |
| 14679 | //Send WLAN UP indication to Nlink Service |
| 14680 | send_btc_nlink_msg(WLAN_MODULE_UP_IND, 0); |
| 14681 | |
| 14682 | pr_info("%s: driver loaded\n", WLAN_MODULE_NAME); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14683 | } |
| 14684 | |
| 14685 | EXIT(); |
| 14686 | |
| 14687 | return ret_status; |
| 14688 | } |
| 14689 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 14690 | /**--------------------------------------------------------------------------- |
| 14691 | |
| 14692 | \brief hdd_module_init() - Init Function |
| 14693 | |
| 14694 | This is the driver entry point (invoked when module is loaded using insmod) |
| 14695 | |
| 14696 | \param - None |
| 14697 | |
| 14698 | \return - 0 for success, non zero for failure |
| 14699 | |
| 14700 | --------------------------------------------------------------------------*/ |
| 14701 | #ifdef MODULE |
| 14702 | static int __init hdd_module_init ( void) |
| 14703 | { |
| 14704 | return hdd_driver_init(); |
| 14705 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 14706 | #else /* #ifdef MODULE */ |
| 14707 | static int __init hdd_module_init ( void) |
| 14708 | { |
| 14709 | /* Driver initialization is delayed to fwpath_changed_handler */ |
| 14710 | return 0; |
| 14711 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 14712 | #endif /* #ifdef MODULE */ |
| 14713 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14714 | |
| 14715 | /**--------------------------------------------------------------------------- |
| 14716 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 14717 | \brief hdd_driver_exit() - Exit function |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14718 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 14719 | This is the driver exit point (invoked when module is unloaded using rmmod |
| 14720 | or con_mode was changed by userspace) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14721 | |
| 14722 | \param - None |
| 14723 | |
| 14724 | \return - None |
| 14725 | |
| 14726 | --------------------------------------------------------------------------*/ |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 14727 | static void hdd_driver_exit(void) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14728 | { |
| 14729 | hdd_context_t *pHddCtx = NULL; |
| 14730 | v_CONTEXT_t pVosContext = NULL; |
Agarwal Ashish | 5e41479 | 2014-06-08 15:25:23 +0530 | [diff] [blame] | 14731 | v_REGDOMAIN_t regId; |
Arun Kumar Khandavalli | e0b046d | 2014-03-01 21:54:25 +0530 | [diff] [blame] | 14732 | unsigned long rc = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14733 | |
| 14734 | pr_info("%s: unloading driver v%s\n", WLAN_MODULE_NAME, QWLAN_VERSIONSTR); |
| 14735 | |
| 14736 | //Get the global vos context |
| 14737 | pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL); |
| 14738 | |
| 14739 | if(!pVosContext) |
| 14740 | { |
| 14741 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Global VOS context is Null", __func__); |
| 14742 | goto done; |
| 14743 | } |
| 14744 | |
| 14745 | //Get the HDD context. |
| 14746 | pHddCtx = (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, pVosContext ); |
| 14747 | |
| 14748 | if(!pHddCtx) |
| 14749 | { |
| 14750 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: module exit called before probe",__func__); |
| 14751 | } |
Katya Nigam | e7b69a8 | 2015-04-28 15:24:06 +0530 | [diff] [blame] | 14752 | else if (VOS_MONITOR_MODE == hdd_get_conparam()) |
| 14753 | { |
| 14754 | hddLog(VOS_TRACE_LEVEL_INFO,"%s: MONITOR MODE",__func__); |
| 14755 | pHddCtx->isLoadUnloadInProgress = WLAN_HDD_UNLOAD_IN_PROGRESS; |
| 14756 | vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, TRUE); |
| 14757 | hdd_wlan_exit(pHddCtx); |
| 14758 | vos_preClose( &pVosContext ); |
| 14759 | goto done; |
| 14760 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14761 | else |
| 14762 | { |
Siddharth Bhal | 2e5871b | 2015-03-24 16:20:51 +0530 | [diff] [blame] | 14763 | /* We wait for active entry threads to exit from driver |
| 14764 | * by waiting until rtnl_lock is available. |
| 14765 | */ |
| 14766 | rtnl_lock(); |
| 14767 | rtnl_unlock(); |
| 14768 | |
Siddharth Bhal | 3c29dca | 2015-02-19 00:41:40 +0530 | [diff] [blame] | 14769 | INIT_COMPLETION(pHddCtx->ssr_comp_var); |
| 14770 | if ((pHddCtx->isLogpInProgress) && (FALSE == |
| 14771 | vos_is_wlan_in_badState(VOS_MODULE_ID_HDD, NULL))) |
| 14772 | { |
Siddharth Bhal | a204f57 | 2015-01-17 02:03:36 +0530 | [diff] [blame] | 14773 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Siddharth Bhal | 3c29dca | 2015-02-19 00:41:40 +0530 | [diff] [blame] | 14774 | "%s:SSR in Progress; block rmmod !!!", __func__); |
Siddharth Bhal | a204f57 | 2015-01-17 02:03:36 +0530 | [diff] [blame] | 14775 | rc = wait_for_completion_timeout(&pHddCtx->ssr_comp_var, |
| 14776 | msecs_to_jiffies(30000)); |
| 14777 | if(!rc) |
| 14778 | { |
| 14779 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 14780 | "%s:SSR timedout, fatal error", __func__); |
| 14781 | VOS_BUG(0); |
| 14782 | } |
| 14783 | } |
| 14784 | |
Siddharth Bhal | 3c29dca | 2015-02-19 00:41:40 +0530 | [diff] [blame] | 14785 | pHddCtx->isLoadUnloadInProgress = WLAN_HDD_UNLOAD_IN_PROGRESS; |
| 14786 | vos_set_load_unload_in_progress(VOS_MODULE_ID_VOSS, TRUE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14787 | |
c_hpothu | 8adb97b | 2014-12-08 19:38:20 +0530 | [diff] [blame] | 14788 | /* Driver Need to send country code 00 in below condition |
| 14789 | * 1) If gCountryCodePriority is set to 1; and last country |
| 14790 | * code set is through 11d. This needs to be done in case |
| 14791 | * when NV country code is 00. |
| 14792 | * This Needs to be done as when kernel store last country |
| 14793 | * code and if stored country code is not through 11d, |
| 14794 | * in sme_HandleChangeCountryCodeByUser we will disable 11d |
| 14795 | * in next load/unload as soon as we get any country through |
| 14796 | * 11d. In sme_HandleChangeCountryCodeByUser |
| 14797 | * pMsg->countryCode will be last countryCode and |
| 14798 | * pMac->scan.countryCode11d will be country through 11d so |
| 14799 | * due to mismatch driver will disable 11d. |
| 14800 | * |
| 14801 | */ |
Agarwal Ashish | 8db3988 | 2014-07-30 21:56:07 +0530 | [diff] [blame] | 14802 | |
c_hpothu | 8adb97b | 2014-12-08 19:38:20 +0530 | [diff] [blame] | 14803 | if ((eANI_BOOLEAN_TRUE == sme_Is11dCountrycode(pHddCtx->hHal) && |
Agarwal Ashish | 8dcd286 | 2014-07-25 11:58:52 +0530 | [diff] [blame] | 14804 | pHddCtx->cfg_ini->fSupplicantCountryCodeHasPriority && |
Abhishek Singh | 2a70596 | 2014-10-30 14:47:28 +0530 | [diff] [blame] | 14805 | sme_Is11dSupported(pHddCtx->hHal))) |
c_hpothu | 8adb97b | 2014-12-08 19:38:20 +0530 | [diff] [blame] | 14806 | { |
| 14807 | hddLog(VOS_TRACE_LEVEL_INFO, |
Agarwal Ashish | 8dcd286 | 2014-07-25 11:58:52 +0530 | [diff] [blame] | 14808 | FL("CountryCode 00 is being set while unloading driver")); |
c_hpothu | 8adb97b | 2014-12-08 19:38:20 +0530 | [diff] [blame] | 14809 | vos_nv_getRegDomainFromCountryCode(®Id , "00", COUNTRY_USER); |
| 14810 | } |
Agarwal Ashish | 5e41479 | 2014-06-08 15:25:23 +0530 | [diff] [blame] | 14811 | |
c_hpothu | 8adb97b | 2014-12-08 19:38:20 +0530 | [diff] [blame] | 14812 | //Do all the cleanup before deregistering the driver |
| 14813 | hdd_wlan_exit(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14814 | } |
| 14815 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14816 | vos_preClose( &pVosContext ); |
| 14817 | |
| 14818 | #ifdef TIMER_MANAGER |
| 14819 | vos_timer_exit(); |
| 14820 | #endif |
| 14821 | #ifdef MEMORY_DEBUG |
| 14822 | vos_mem_exit(); |
| 14823 | #endif |
| 14824 | |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 14825 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 14826 | wlan_logging_sock_deinit_svc(); |
| 14827 | #endif |
| 14828 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14829 | done: |
Sushant Kaushik | 83392fa | 2015-05-05 17:44:40 +0530 | [diff] [blame] | 14830 | vos_wake_lock_destroy(&wlan_wake_lock); |
Vinay Krishna Eranna | 273ec5a | 2014-05-10 18:05:25 +0530 | [diff] [blame] | 14831 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14832 | pr_info("%s: driver unloaded\n", WLAN_MODULE_NAME); |
| 14833 | } |
| 14834 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 14835 | /**--------------------------------------------------------------------------- |
| 14836 | |
| 14837 | \brief hdd_module_exit() - Exit function |
| 14838 | |
| 14839 | This is the driver exit point (invoked when module is unloaded using rmmod) |
| 14840 | |
| 14841 | \param - None |
| 14842 | |
| 14843 | \return - None |
| 14844 | |
| 14845 | --------------------------------------------------------------------------*/ |
| 14846 | static void __exit hdd_module_exit(void) |
| 14847 | { |
| 14848 | hdd_driver_exit(); |
| 14849 | } |
| 14850 | |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 14851 | #ifdef MODULE |
| 14852 | static int fwpath_changed_handler(const char *kmessage, |
Ashish Kumar Dhanotiya | fb3fd97 | 2018-04-30 12:46:52 +0530 | [diff] [blame] | 14853 | const struct kernel_param *kp) |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 14854 | { |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 14855 | return param_set_copystring(kmessage, kp); |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 14856 | } |
| 14857 | |
| 14858 | static int con_mode_handler(const char *kmessage, |
Ashish Kumar Dhanotiya | fb3fd97 | 2018-04-30 12:46:52 +0530 | [diff] [blame] | 14859 | const struct kernel_param *kp) |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 14860 | { |
Madan Mohan Koyyalamudi | f2f8d8b | 2012-10-11 17:06:59 -0700 | [diff] [blame] | 14861 | return param_set_int(kmessage, kp); |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 14862 | } |
| 14863 | #else /* #ifdef MODULE */ |
| 14864 | /**--------------------------------------------------------------------------- |
| 14865 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 14866 | \brief kickstart_driver |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 14867 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 14868 | This is the driver entry point |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 14869 | - delayed driver initialization when driver is statically linked |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 14870 | - invoked when module parameter fwpath is modified from userspace to signal |
| 14871 | initializing the WLAN driver or when con_mode is modified from userspace |
| 14872 | to signal a switch in operating mode |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 14873 | |
| 14874 | \return - 0 for success, non zero for failure |
| 14875 | |
| 14876 | --------------------------------------------------------------------------*/ |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 14877 | static int kickstart_driver(void) |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 14878 | { |
Madan Mohan Koyyalamudi | 62e6005 | 2012-10-05 14:27:22 -0700 | [diff] [blame] | 14879 | int ret_status; |
| 14880 | |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 14881 | if (!wlan_hdd_inited) { |
Madan Mohan Koyyalamudi | 62e6005 | 2012-10-05 14:27:22 -0700 | [diff] [blame] | 14882 | ret_status = hdd_driver_init(); |
| 14883 | wlan_hdd_inited = ret_status ? 0 : 1; |
| 14884 | return ret_status; |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 14885 | } |
| 14886 | |
| 14887 | hdd_driver_exit(); |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 14888 | |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 14889 | msleep(200); |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 14890 | |
Madan Mohan Koyyalamudi | 62e6005 | 2012-10-05 14:27:22 -0700 | [diff] [blame] | 14891 | ret_status = hdd_driver_init(); |
| 14892 | wlan_hdd_inited = ret_status ? 0 : 1; |
| 14893 | return ret_status; |
Madan Mohan Koyyalamudi | c2ec3bd | 2012-09-18 19:49:40 -0700 | [diff] [blame] | 14894 | } |
| 14895 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14896 | /**--------------------------------------------------------------------------- |
| 14897 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 14898 | \brief fwpath_changed_handler() - Handler Function |
| 14899 | |
| 14900 | Handle changes to the fwpath parameter |
| 14901 | |
| 14902 | \return - 0 for success, non zero for failure |
| 14903 | |
| 14904 | --------------------------------------------------------------------------*/ |
| 14905 | static int fwpath_changed_handler(const char *kmessage, |
Ashish Kumar Dhanotiya | fb3fd97 | 2018-04-30 12:46:52 +0530 | [diff] [blame] | 14906 | const struct kernel_param *kp) |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 14907 | { |
| 14908 | int ret; |
| 14909 | |
| 14910 | ret = param_set_copystring(kmessage, kp); |
| 14911 | if (0 == ret) |
| 14912 | ret = kickstart_driver(); |
| 14913 | return ret; |
| 14914 | } |
| 14915 | |
| 14916 | /**--------------------------------------------------------------------------- |
| 14917 | |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 14918 | \brief con_mode_handler() - |
| 14919 | |
| 14920 | Handler function for module param con_mode when it is changed by userspace |
| 14921 | Dynamically linked - do nothing |
| 14922 | Statically linked - exit and init driver, as in rmmod and insmod |
| 14923 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 14924 | \param - |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 14925 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 14926 | \return - |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 14927 | |
| 14928 | --------------------------------------------------------------------------*/ |
Ashish Kumar Dhanotiya | fb3fd97 | 2018-04-30 12:46:52 +0530 | [diff] [blame] | 14929 | static int con_mode_handler(const char *kmessage, |
| 14930 | const struct kernel_param *kp) |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 14931 | { |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 14932 | int ret; |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 14933 | |
Jeff Johnson | 7605270 | 2013-04-16 13:55:05 -0700 | [diff] [blame] | 14934 | ret = param_set_int(kmessage, kp); |
| 14935 | if (0 == ret) |
| 14936 | ret = kickstart_driver(); |
| 14937 | return ret; |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 14938 | } |
| 14939 | #endif /* #ifdef MODULE */ |
| 14940 | |
| 14941 | /**--------------------------------------------------------------------------- |
| 14942 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14943 | \brief hdd_get_conparam() - |
| 14944 | |
| 14945 | This is the driver exit point (invoked when module is unloaded using rmmod) |
| 14946 | |
| 14947 | \param - None |
| 14948 | |
| 14949 | \return - tVOS_CON_MODE |
| 14950 | |
| 14951 | --------------------------------------------------------------------------*/ |
| 14952 | tVOS_CON_MODE hdd_get_conparam ( void ) |
| 14953 | { |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 14954 | #ifdef MODULE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14955 | return (tVOS_CON_MODE)con_mode; |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 14956 | #else |
| 14957 | return (tVOS_CON_MODE)curr_con_mode; |
| 14958 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14959 | } |
| 14960 | void hdd_set_conparam ( v_UINT_t newParam ) |
| 14961 | { |
| 14962 | con_mode = newParam; |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 14963 | #ifndef MODULE |
| 14964 | curr_con_mode = con_mode; |
| 14965 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14966 | } |
| 14967 | /**--------------------------------------------------------------------------- |
| 14968 | |
| 14969 | \brief hdd_softap_sta_deauth() - function |
| 14970 | |
| 14971 | This to take counter measure to handle deauth req from HDD |
| 14972 | |
| 14973 | \param - pAdapter - Pointer to the HDD |
| 14974 | |
| 14975 | \param - enable - boolean value |
| 14976 | |
| 14977 | \return - None |
| 14978 | |
| 14979 | --------------------------------------------------------------------------*/ |
| 14980 | |
Hanumantha Reddy Pothula | bfd06f7 | 2014-10-31 14:03:37 +0530 | [diff] [blame] | 14981 | VOS_STATUS hdd_softap_sta_deauth(hdd_adapter_t *pAdapter, |
| 14982 | struct tagCsrDelStaParams *pDelStaParams) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14983 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14984 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 14985 | VOS_STATUS vosStatus = VOS_STATUS_E_FAULT; |
Hanumanth Reddy Pothula | 5732363 | 2017-12-06 17:55:09 +0530 | [diff] [blame] | 14986 | struct hdd_cache_sta_info *cache_sta_info; |
| 14987 | ptSapContext pSapCtx = VOS_GET_SAP_CB(pVosContext); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14988 | |
| 14989 | ENTER(); |
| 14990 | |
Jeff Johnson | c135a9a | 2017-09-19 08:37:24 -0700 | [diff] [blame] | 14991 | hddLog(LOG1, "hdd_softap_sta_deauth:(%pK, false)", |
Rajesh Chauhan | 18488fc | 2013-08-22 10:15:03 -0700 | [diff] [blame] | 14992 | (WLAN_HDD_GET_CTX(pAdapter))->pvosContext); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 14993 | |
Hanumanth Reddy Pothula | 5732363 | 2017-12-06 17:55:09 +0530 | [diff] [blame] | 14994 | if (!pSapCtx) { |
| 14995 | hddLog(LOGE, "sap context is NULL"); |
| 14996 | return vosStatus; |
| 14997 | } |
| 14998 | |
| 14999 | cache_sta_info = hdd_get_cache_stainfo(pSapCtx->cache_sta_info, |
| 15000 | pDelStaParams->peerMacAddr); |
| 15001 | if (cache_sta_info) { |
| 15002 | cache_sta_info->reason_code = pDelStaParams->reason_code; |
| 15003 | cache_sta_info->rx_rate = |
| 15004 | wlan_tl_get_sta_rx_rate(pVosContext, cache_sta_info->ucSTAId); |
| 15005 | WLANTL_GetSAPStaRSSi(pVosContext, cache_sta_info->ucSTAId, |
| 15006 | &cache_sta_info->rssi); |
| 15007 | } |
| 15008 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15009 | //Ignore request to deauth bcmc station |
Hanumantha Reddy Pothula | bfd06f7 | 2014-10-31 14:03:37 +0530 | [diff] [blame] | 15010 | if (pDelStaParams->peerMacAddr[0] & 0x1) |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 15011 | return vosStatus; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15012 | |
Hanumantha Reddy Pothula | bfd06f7 | 2014-10-31 14:03:37 +0530 | [diff] [blame] | 15013 | vosStatus = WLANSAP_DeauthSta(pVosContext, pDelStaParams); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15014 | |
| 15015 | EXIT(); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 15016 | return vosStatus; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15017 | } |
| 15018 | |
| 15019 | /**--------------------------------------------------------------------------- |
| 15020 | |
Rashmi Ramanna | 1f0948d | 2014-08-28 15:33:48 +0530 | [diff] [blame] | 15021 | \brief hdd_del_all_sta() - function |
| 15022 | |
| 15023 | This function removes all the stations associated on stopping AP/P2P GO. |
| 15024 | |
| 15025 | \param - pAdapter - Pointer to the HDD |
| 15026 | |
| 15027 | \return - None |
| 15028 | |
| 15029 | --------------------------------------------------------------------------*/ |
| 15030 | |
| 15031 | int hdd_del_all_sta(hdd_adapter_t *pAdapter) |
| 15032 | { |
| 15033 | v_U16_t i; |
| 15034 | VOS_STATUS vos_status; |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 15035 | v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
| 15036 | ptSapContext pSapCtx = NULL; |
| 15037 | pSapCtx = VOS_GET_SAP_CB(pVosContext); |
| 15038 | if(pSapCtx == NULL){ |
| 15039 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 15040 | FL("psapCtx is NULL")); |
| 15041 | return 1; |
| 15042 | } |
Rashmi Ramanna | 1f0948d | 2014-08-28 15:33:48 +0530 | [diff] [blame] | 15043 | ENTER(); |
| 15044 | |
| 15045 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 15046 | "%s: Delete all STAs associated.",__func__); |
| 15047 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
| 15048 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
| 15049 | ) |
| 15050 | { |
| 15051 | for(i = 0; i < WLAN_MAX_STA_COUNT; i++) |
| 15052 | { |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 15053 | if ((pSapCtx->aStaInfo[i].isUsed) && |
| 15054 | (!pSapCtx->aStaInfo[i].isDeauthInProgress)) |
Rashmi Ramanna | 1f0948d | 2014-08-28 15:33:48 +0530 | [diff] [blame] | 15055 | { |
Hanumantha Reddy Pothula | bfd06f7 | 2014-10-31 14:03:37 +0530 | [diff] [blame] | 15056 | struct tagCsrDelStaParams delStaParams; |
| 15057 | |
| 15058 | WLANSAP_PopulateDelStaParams( |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 15059 | pSapCtx->aStaInfo[i].macAddrSTA.bytes, |
Sushant Kaushik | 4cd28f6 | 2014-12-26 14:23:50 +0530 | [diff] [blame] | 15060 | eSIR_MAC_DEAUTH_LEAVING_BSS_REASON, |
| 15061 | SIR_MAC_MGMT_DEAUTH >> 4, |
Hanumantha Reddy Pothula | bfd06f7 | 2014-10-31 14:03:37 +0530 | [diff] [blame] | 15062 | &delStaParams); |
| 15063 | vos_status = hdd_softap_sta_deauth(pAdapter, &delStaParams); |
Rashmi Ramanna | 1f0948d | 2014-08-28 15:33:48 +0530 | [diff] [blame] | 15064 | if (VOS_IS_STATUS_SUCCESS(vos_status)) |
Sachin Ahuja | bcb0b7e | 2014-11-07 13:01:24 +0530 | [diff] [blame] | 15065 | pSapCtx->aStaInfo[i].isDeauthInProgress = TRUE; |
Rashmi Ramanna | 1f0948d | 2014-08-28 15:33:48 +0530 | [diff] [blame] | 15066 | } |
| 15067 | } |
| 15068 | } |
| 15069 | |
| 15070 | EXIT(); |
| 15071 | return 0; |
| 15072 | } |
| 15073 | |
| 15074 | /**--------------------------------------------------------------------------- |
| 15075 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15076 | \brief hdd_softap_sta_disassoc() - function |
| 15077 | |
| 15078 | This to take counter measure to handle deauth req from HDD |
| 15079 | |
| 15080 | \param - pAdapter - Pointer to the HDD |
| 15081 | |
| 15082 | \param - enable - boolean value |
| 15083 | |
| 15084 | \return - None |
| 15085 | |
| 15086 | --------------------------------------------------------------------------*/ |
| 15087 | |
| 15088 | void hdd_softap_sta_disassoc(hdd_adapter_t *pAdapter,v_U8_t *pDestMacAddress) |
| 15089 | { |
Hanumanth Reddy Pothula | 5732363 | 2017-12-06 17:55:09 +0530 | [diff] [blame] | 15090 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
| 15091 | struct hdd_cache_sta_info *cache_sta_info; |
| 15092 | ptSapContext pSapCtx = VOS_GET_SAP_CB(pVosContext); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15093 | |
| 15094 | ENTER(); |
| 15095 | |
Jeff Johnson | c135a9a | 2017-09-19 08:37:24 -0700 | [diff] [blame] | 15096 | 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] | 15097 | |
Hanumanth Reddy Pothula | 5732363 | 2017-12-06 17:55:09 +0530 | [diff] [blame] | 15098 | if (!pSapCtx) { |
| 15099 | hddLog(LOGE, "sap context is NULL"); |
| 15100 | return ; |
| 15101 | } |
| 15102 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15103 | //Ignore request to disassoc bcmc station |
| 15104 | if( pDestMacAddress[0] & 0x1 ) |
| 15105 | return; |
| 15106 | |
Hanumanth Reddy Pothula | 5732363 | 2017-12-06 17:55:09 +0530 | [diff] [blame] | 15107 | cache_sta_info = hdd_get_cache_stainfo(pSapCtx->cache_sta_info, |
| 15108 | pDestMacAddress); |
| 15109 | if (cache_sta_info) { |
| 15110 | cache_sta_info->reason_code = eSIR_MAC_DEAUTH_LEAVING_BSS_REASON; |
| 15111 | cache_sta_info->rx_rate = |
| 15112 | wlan_tl_get_sta_rx_rate(pVosContext, cache_sta_info->ucSTAId); |
| 15113 | WLANTL_GetSAPStaRSSi(pVosContext, cache_sta_info->ucSTAId, |
| 15114 | &cache_sta_info->rssi); |
| 15115 | } |
| 15116 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15117 | WLANSAP_DisassocSta(pVosContext,pDestMacAddress); |
| 15118 | } |
| 15119 | |
| 15120 | void hdd_softap_tkip_mic_fail_counter_measure(hdd_adapter_t *pAdapter,v_BOOL_t enable) |
| 15121 | { |
| 15122 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
| 15123 | |
| 15124 | ENTER(); |
| 15125 | |
Jeff Johnson | c135a9a | 2017-09-19 08:37:24 -0700 | [diff] [blame] | 15126 | 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] | 15127 | |
| 15128 | WLANSAP_SetCounterMeasure(pVosContext, (v_BOOL_t)enable); |
| 15129 | } |
| 15130 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15131 | /**--------------------------------------------------------------------------- |
| 15132 | * |
| 15133 | * \brief hdd_get__concurrency_mode() - |
| 15134 | * |
| 15135 | * |
| 15136 | * \param - None |
| 15137 | * |
| 15138 | * \return - CONCURRENCY MODE |
| 15139 | * |
| 15140 | * --------------------------------------------------------------------------*/ |
| 15141 | tVOS_CONCURRENCY_MODE hdd_get_concurrency_mode ( void ) |
| 15142 | { |
| 15143 | v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL ); |
| 15144 | hdd_context_t *pHddCtx; |
| 15145 | |
| 15146 | if (NULL != pVosContext) |
| 15147 | { |
| 15148 | pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext); |
| 15149 | if (NULL != pHddCtx) |
| 15150 | { |
| 15151 | return (tVOS_CONCURRENCY_MODE)pHddCtx->concurrency_mode; |
| 15152 | } |
| 15153 | } |
| 15154 | |
| 15155 | /* we are in an invalid state :( */ |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 15156 | hddLog(LOGE, "%s: Invalid context", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15157 | return VOS_STA; |
| 15158 | } |
Sushant Kaushik | abb7ee6 | 2014-07-18 16:20:12 +0530 | [diff] [blame] | 15159 | v_BOOL_t |
| 15160 | wlan_hdd_is_GO_power_collapse_allowed (hdd_context_t* pHddCtx) |
| 15161 | { |
| 15162 | hdd_adapter_t *pAdapter = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15163 | |
Sushant Kaushik | abb7ee6 | 2014-07-18 16:20:12 +0530 | [diff] [blame] | 15164 | pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_GO); |
| 15165 | if (pAdapter == NULL) |
| 15166 | { |
| 15167 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 15168 | FL("GO doesn't exist")); |
| 15169 | return TRUE; |
| 15170 | } |
| 15171 | if (test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags)) |
| 15172 | { |
| 15173 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 15174 | FL("GO started")); |
| 15175 | return TRUE; |
| 15176 | } |
| 15177 | else |
| 15178 | /* wait till GO changes its interface to p2p device */ |
| 15179 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 15180 | FL("Del_bss called, avoid apps suspend")); |
| 15181 | return FALSE; |
| 15182 | |
| 15183 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15184 | /* Decide whether to allow/not the apps power collapse. |
| 15185 | * Allow apps power collapse if we are in connected state. |
| 15186 | * if not, allow only if we are in IMPS */ |
| 15187 | v_BOOL_t hdd_is_apps_power_collapse_allowed(hdd_context_t* pHddCtx) |
| 15188 | { |
| 15189 | tPmcState pmcState = pmcGetPmcState(pHddCtx->hHal); |
Srikant Kuppa | fef66a7 | 2013-01-30 17:32:44 -0800 | [diff] [blame] | 15190 | tANI_BOOLEAN scanRspPending = csrNeighborRoamScanRspPending(pHddCtx->hHal); |
Srinivas Girigowda | a553c46 | 2013-03-07 19:42:52 -0800 | [diff] [blame] | 15191 | tANI_BOOLEAN inMiddleOfRoaming = csrNeighborMiddleOfRoaming(pHddCtx->hHal); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15192 | hdd_config_t *pConfig = pHddCtx->cfg_ini; |
| 15193 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 15194 | hdd_adapter_t *pAdapter = NULL; |
| 15195 | VOS_STATUS status; |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 15196 | tVOS_CONCURRENCY_MODE concurrent_state = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15197 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15198 | if (VOS_STA_SAP_MODE == hdd_get_conparam()) |
| 15199 | return TRUE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15200 | |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 15201 | concurrent_state = hdd_get_concurrency_mode(); |
| 15202 | |
Sushant Kaushik | abb7ee6 | 2014-07-18 16:20:12 +0530 | [diff] [blame] | 15203 | if ((concurrent_state == (VOS_STA | VOS_P2P_GO)) && |
| 15204 | !(wlan_hdd_is_GO_power_collapse_allowed(pHddCtx))) |
| 15205 | return FALSE; |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 15206 | #ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE |
Sushant Kaushik | abb7ee6 | 2014-07-18 16:20:12 +0530 | [diff] [blame] | 15207 | |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 15208 | if(((concurrent_state == (VOS_STA | VOS_P2P_CLIENT)) || |
Sushant Kaushik | abb7ee6 | 2014-07-18 16:20:12 +0530 | [diff] [blame] | 15209 | (concurrent_state == (VOS_STA | VOS_P2P_GO)))&& |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 15210 | (IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)) |
| 15211 | return TRUE; |
| 15212 | #endif |
| 15213 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15214 | /*loop through all adapters. TBD fix for Concurrency */ |
| 15215 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 15216 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 15217 | { |
| 15218 | pAdapter = pAdapterNode->pAdapter; |
| 15219 | if ( (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) |
| 15220 | || (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ) |
| 15221 | { |
Srikant Kuppa | fef66a7 | 2013-01-30 17:32:44 -0800 | [diff] [blame] | 15222 | if (((pConfig->fIsImpsEnabled || pConfig->fIsBmpsEnabled) |
c_hpothu | 4e8faac | 2014-05-16 17:38:44 +0530 | [diff] [blame] | 15223 | && (pmcState != IMPS && pmcState != BMPS && pmcState != UAPSD |
c_hpothu | 1c6957d | 2015-01-06 18:19:47 +0530 | [diff] [blame] | 15224 | && pmcState != STOPPED && pmcState != STANDBY && |
| 15225 | pmcState != WOWL)) || |
Srinivas Girigowda | a553c46 | 2013-03-07 19:42:52 -0800 | [diff] [blame] | 15226 | (eANI_BOOLEAN_TRUE == scanRspPending) || |
| 15227 | (eANI_BOOLEAN_TRUE == inMiddleOfRoaming)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15228 | { |
Mukul Sharma | 4be8842 | 2015-03-09 20:29:07 +0530 | [diff] [blame] | 15229 | if(pmcState == FULL_POWER && |
| 15230 | sme_IsCoexScoIndicationSet(pHddCtx->hHal)) |
| 15231 | { |
| 15232 | /* |
| 15233 | * When SCO indication comes from Coex module , host will |
| 15234 | * enter in to full power mode, but this should not prevent |
| 15235 | * apps processor power collapse. |
| 15236 | */ |
| 15237 | hddLog(LOG1, |
| 15238 | FL("Allow apps power collapse" |
| 15239 | "even when sco indication is set")); |
| 15240 | return TRUE; |
| 15241 | } |
Srikant Kuppa | fef66a7 | 2013-01-30 17:32:44 -0800 | [diff] [blame] | 15242 | hddLog( LOGE, "%s: do not allow APPS power collapse-" |
Deepthi Gowri | 03a979f | 2016-11-03 15:20:19 +0530 | [diff] [blame] | 15243 | "pmcState = %d scanRspPending = %d " |
| 15244 | "inMiddleOfRoaming = %d connected = %d", |
| 15245 | __func__, pmcState, scanRspPending, |
| 15246 | inMiddleOfRoaming, hdd_connIsConnected( |
| 15247 | WLAN_HDD_GET_STATION_CTX_PTR( pAdapter ))); |
| 15248 | wlan_hdd_get_tdls_stats(pAdapter); |
| 15249 | return FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15250 | } |
| 15251 | } |
| 15252 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 15253 | pAdapterNode = pNext; |
| 15254 | } |
| 15255 | return TRUE; |
| 15256 | } |
| 15257 | |
Madan Mohan Koyyalamudi | c72a4d6 | 2012-11-08 14:59:34 -0800 | [diff] [blame] | 15258 | /* Decides whether to send suspend notification to Riva |
| 15259 | * if any adapter is in BMPS; then it is required */ |
| 15260 | v_BOOL_t hdd_is_suspend_notify_allowed(hdd_context_t* pHddCtx) |
| 15261 | { |
| 15262 | tPmcState pmcState = pmcGetPmcState(pHddCtx->hHal); |
| 15263 | hdd_config_t *pConfig = pHddCtx->cfg_ini; |
| 15264 | |
| 15265 | if (pConfig->fIsBmpsEnabled && (pmcState == BMPS)) |
| 15266 | { |
| 15267 | return TRUE; |
| 15268 | } |
| 15269 | return FALSE; |
| 15270 | } |
| 15271 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15272 | void wlan_hdd_set_concurrency_mode(hdd_context_t *pHddCtx, tVOS_CON_MODE mode) |
| 15273 | { |
| 15274 | switch(mode) |
| 15275 | { |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 15276 | case VOS_STA_MODE: |
| 15277 | case VOS_P2P_CLIENT_MODE: |
| 15278 | case VOS_P2P_GO_MODE: |
| 15279 | case VOS_STA_SAP_MODE: |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 15280 | case VOS_MONITOR_MODE: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 15281 | pHddCtx->concurrency_mode |= (1 << mode); |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 15282 | pHddCtx->no_of_open_sessions[mode]++; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15283 | break; |
| 15284 | default: |
| 15285 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15286 | } |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 15287 | hddLog(VOS_TRACE_LEVEL_INFO, FL("concurrency_mode = 0x%x " |
| 15288 | "Number of open sessions for mode %d = %d"), |
| 15289 | pHddCtx->concurrency_mode, mode, |
| 15290 | pHddCtx->no_of_open_sessions[mode]); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15291 | } |
| 15292 | |
| 15293 | |
| 15294 | void wlan_hdd_clear_concurrency_mode(hdd_context_t *pHddCtx, tVOS_CON_MODE mode) |
| 15295 | { |
| 15296 | switch(mode) |
| 15297 | { |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 15298 | case VOS_STA_MODE: |
| 15299 | case VOS_P2P_CLIENT_MODE: |
| 15300 | case VOS_P2P_GO_MODE: |
| 15301 | case VOS_STA_SAP_MODE: |
Rajeev Kumar Sirasanagandla | 8f11d54 | 2017-11-14 17:56:55 +0530 | [diff] [blame] | 15302 | case VOS_MONITOR_MODE: |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 15303 | pHddCtx->no_of_open_sessions[mode]--; |
| 15304 | if (!(pHddCtx->no_of_open_sessions[mode])) |
| 15305 | pHddCtx->concurrency_mode &= (~(1 << mode)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15306 | break; |
| 15307 | default: |
| 15308 | break; |
| 15309 | } |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 15310 | hddLog(VOS_TRACE_LEVEL_INFO, FL("concurrency_mode = 0x%x " |
| 15311 | "Number of open sessions for mode %d = %d"), |
| 15312 | pHddCtx->concurrency_mode, mode, pHddCtx->no_of_open_sessions[mode]); |
| 15313 | |
| 15314 | } |
| 15315 | /**--------------------------------------------------------------------------- |
| 15316 | * |
| 15317 | * \brief wlan_hdd_incr_active_session() |
| 15318 | * |
| 15319 | * This function increments the number of active sessions |
| 15320 | * maintained per device mode |
| 15321 | * Incase of STA/P2P CLI/IBSS upon connection indication it is incremented |
| 15322 | * Incase of SAP/P2P GO upon bss start it is incremented |
| 15323 | * |
| 15324 | * \param pHddCtx - HDD Context |
| 15325 | * \param mode - device mode |
| 15326 | * |
| 15327 | * \return - None |
| 15328 | * |
| 15329 | * --------------------------------------------------------------------------*/ |
| 15330 | void wlan_hdd_incr_active_session(hdd_context_t *pHddCtx, tVOS_CON_MODE mode) |
| 15331 | { |
| 15332 | switch (mode) { |
| 15333 | case VOS_STA_MODE: |
| 15334 | case VOS_P2P_CLIENT_MODE: |
| 15335 | case VOS_P2P_GO_MODE: |
| 15336 | case VOS_STA_SAP_MODE: |
| 15337 | pHddCtx->no_of_active_sessions[mode]++; |
| 15338 | break; |
| 15339 | default: |
| 15340 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Not Expected Mode %d"), mode); |
| 15341 | break; |
| 15342 | } |
| 15343 | hddLog(VOS_TRACE_LEVEL_INFO, FL("No.# of active sessions for mode %d = %d"), |
| 15344 | mode, |
| 15345 | pHddCtx->no_of_active_sessions[mode]); |
| 15346 | } |
| 15347 | |
| 15348 | /**--------------------------------------------------------------------------- |
| 15349 | * |
| 15350 | * \brief wlan_hdd_decr_active_session() |
| 15351 | * |
| 15352 | * This function decrements the number of active sessions |
| 15353 | * maintained per device mode |
| 15354 | * Incase of STA/P2P CLI/IBSS upon disconnection it is decremented |
| 15355 | * Incase of SAP/P2P GO upon bss stop it is decremented |
| 15356 | * |
| 15357 | * \param pHddCtx - HDD Context |
| 15358 | * \param mode - device mode |
| 15359 | * |
| 15360 | * \return - None |
| 15361 | * |
| 15362 | * --------------------------------------------------------------------------*/ |
| 15363 | void wlan_hdd_decr_active_session(hdd_context_t *pHddCtx, tVOS_CON_MODE mode) |
| 15364 | { |
Bhargav Shah | d071591 | 2015-10-01 18:17:37 +0530 | [diff] [blame] | 15365 | |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 15366 | switch (mode) { |
| 15367 | case VOS_STA_MODE: |
| 15368 | case VOS_P2P_CLIENT_MODE: |
| 15369 | case VOS_P2P_GO_MODE: |
| 15370 | case VOS_STA_SAP_MODE: |
Agarwal Ashish | 5325f52 | 2014-08-06 00:58:44 +0530 | [diff] [blame] | 15371 | if (pHddCtx->no_of_active_sessions[mode] > 0) |
| 15372 | pHddCtx->no_of_active_sessions[mode]--; |
| 15373 | else |
| 15374 | hddLog(VOS_TRACE_LEVEL_INFO, FL(" No.# of Active sessions" |
| 15375 | "is already Zero")); |
Agarwal Ashish | 51325b5 | 2014-06-16 16:50:49 +0530 | [diff] [blame] | 15376 | break; |
| 15377 | default: |
| 15378 | hddLog(VOS_TRACE_LEVEL_INFO, FL("Not Expected Mode %d"), mode); |
| 15379 | break; |
| 15380 | } |
| 15381 | hddLog(VOS_TRACE_LEVEL_INFO, FL("No.# of active sessions for mode %d = %d"), |
| 15382 | mode, |
| 15383 | pHddCtx->no_of_active_sessions[mode]); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15384 | } |
| 15385 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 15386 | /**--------------------------------------------------------------------------- |
| 15387 | * |
| 15388 | * \brief wlan_hdd_restart_init |
| 15389 | * |
| 15390 | * This function initalizes restart timer/flag. An internal function. |
| 15391 | * |
| 15392 | * \param - pHddCtx |
| 15393 | * |
| 15394 | * \return - None |
| 15395 | * |
| 15396 | * --------------------------------------------------------------------------*/ |
| 15397 | |
| 15398 | static void wlan_hdd_restart_init(hdd_context_t *pHddCtx) |
| 15399 | { |
| 15400 | /* Initialize */ |
| 15401 | pHddCtx->hdd_restart_retries = 0; |
| 15402 | atomic_set(&pHddCtx->isRestartInProgress, 0); |
| 15403 | vos_timer_init(&pHddCtx->hdd_restart_timer, |
| 15404 | VOS_TIMER_TYPE_SW, |
| 15405 | wlan_hdd_restart_timer_cb, |
| 15406 | pHddCtx); |
| 15407 | } |
| 15408 | /**--------------------------------------------------------------------------- |
| 15409 | * |
| 15410 | * \brief wlan_hdd_restart_deinit |
| 15411 | * |
| 15412 | * This function cleans up the resources used. An internal function. |
| 15413 | * |
| 15414 | * \param - pHddCtx |
| 15415 | * |
| 15416 | * \return - None |
| 15417 | * |
| 15418 | * --------------------------------------------------------------------------*/ |
| 15419 | |
| 15420 | static void wlan_hdd_restart_deinit(hdd_context_t* pHddCtx) |
| 15421 | { |
| 15422 | |
| 15423 | VOS_STATUS vos_status; |
| 15424 | /* Block any further calls */ |
| 15425 | atomic_set(&pHddCtx->isRestartInProgress, 1); |
| 15426 | /* Cleanup */ |
| 15427 | vos_status = vos_timer_stop( &pHddCtx->hdd_restart_timer ); |
| 15428 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 15429 | hddLog(LOGE, FL("Failed to stop HDD restart timer")); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 15430 | vos_status = vos_timer_destroy(&pHddCtx->hdd_restart_timer); |
| 15431 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 15432 | hddLog(LOGE, FL("Failed to destroy HDD restart timer")); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 15433 | |
| 15434 | } |
| 15435 | |
| 15436 | /**--------------------------------------------------------------------------- |
| 15437 | * |
| 15438 | * \brief wlan_hdd_framework_restart |
| 15439 | * |
| 15440 | * This function uses a cfg80211 API to start a framework initiated WLAN |
| 15441 | * driver module unload/load. |
| 15442 | * |
| 15443 | * Also this API keep retrying (WLAN_HDD_RESTART_RETRY_MAX_CNT). |
| 15444 | * |
| 15445 | * |
| 15446 | * \param - pHddCtx |
| 15447 | * |
| 15448 | * \return - VOS_STATUS_SUCCESS: Success |
| 15449 | * VOS_STATUS_E_EMPTY: Adapter is Empty |
| 15450 | * VOS_STATUS_E_NOMEM: No memory |
| 15451 | |
| 15452 | * --------------------------------------------------------------------------*/ |
| 15453 | |
| 15454 | static VOS_STATUS wlan_hdd_framework_restart(hdd_context_t *pHddCtx) |
| 15455 | { |
| 15456 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 15457 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
Madan Mohan Koyyalamudi | fc19e44 | 2013-05-09 18:24:08 -0700 | [diff] [blame] | 15458 | int len = (sizeof (struct ieee80211_mgmt)); |
| 15459 | struct ieee80211_mgmt *mgmt = NULL; |
| 15460 | |
| 15461 | /* Prepare the DEAUTH managment frame with reason code */ |
| 15462 | mgmt = kzalloc(len, GFP_KERNEL); |
| 15463 | if(mgmt == NULL) |
| 15464 | { |
| 15465 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 15466 | "%s: memory allocation failed (%d bytes)", __func__, len); |
| 15467 | return VOS_STATUS_E_NOMEM; |
| 15468 | } |
| 15469 | mgmt->u.deauth.reason_code = WLAN_REASON_DISASSOC_LOW_ACK; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 15470 | |
| 15471 | /* Iterate over all adapters/devices */ |
| 15472 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
Hanumantha Reddy Pothula | da0fe36 | 2015-02-27 18:37:03 +0530 | [diff] [blame] | 15473 | if ((NULL == pAdapterNode) || (VOS_STATUS_SUCCESS != status)) |
| 15474 | { |
| 15475 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | c135a9a | 2017-09-19 08:37:24 -0700 | [diff] [blame] | 15476 | FL("fail to get adapter: %pK %d"), pAdapterNode, status); |
Hanumantha Reddy Pothula | da0fe36 | 2015-02-27 18:37:03 +0530 | [diff] [blame] | 15477 | goto end; |
| 15478 | } |
| 15479 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 15480 | do |
| 15481 | { |
Hanumantha Reddy Pothula | da0fe36 | 2015-02-27 18:37:03 +0530 | [diff] [blame] | 15482 | if(pAdapterNode->pAdapter && |
| 15483 | WLAN_HDD_ADAPTER_MAGIC == pAdapterNode->pAdapter->magic) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 15484 | { |
| 15485 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 15486 | "restarting the driver(intf:\'%s\' mode:%d :try %d)", |
| 15487 | pAdapterNode->pAdapter->dev->name, |
| 15488 | pAdapterNode->pAdapter->device_mode, |
| 15489 | pHddCtx->hdd_restart_retries + 1); |
Madan Mohan Koyyalamudi | fc19e44 | 2013-05-09 18:24:08 -0700 | [diff] [blame] | 15490 | /* |
| 15491 | * CFG80211 event to restart the driver |
| 15492 | * |
| 15493 | * 'cfg80211_send_unprot_deauth' sends a |
| 15494 | * NL80211_CMD_UNPROT_DEAUTHENTICATE event to supplicant at any state |
| 15495 | * of SME(Linux Kernel) state machine. |
| 15496 | * |
| 15497 | * Reason code WLAN_REASON_DISASSOC_LOW_ACK is currently used to restart |
| 15498 | * the driver. |
| 15499 | * |
| 15500 | */ |
Abhishek Singh | 00b7197 | 2016-01-07 10:51:04 +0530 | [diff] [blame] | 15501 | |
Anand N Sunkad | e9adb1b | 2015-07-29 09:56:45 +0530 | [diff] [blame] | 15502 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 15503 | cfg80211_rx_unprot_mlme_mgmt(pAdapterNode->pAdapter->dev, (u_int8_t*)mgmt, len); |
| 15504 | #else |
Madan Mohan Koyyalamudi | fc19e44 | 2013-05-09 18:24:08 -0700 | [diff] [blame] | 15505 | 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] | 15506 | #endif |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 15507 | } |
| 15508 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 15509 | pAdapterNode = pNext; |
| 15510 | } while((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status)); |
| 15511 | |
Hanumantha Reddy Pothula | da0fe36 | 2015-02-27 18:37:03 +0530 | [diff] [blame] | 15512 | end: |
Madan Mohan Koyyalamudi | fc19e44 | 2013-05-09 18:24:08 -0700 | [diff] [blame] | 15513 | /* Free the allocated management frame */ |
| 15514 | kfree(mgmt); |
| 15515 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 15516 | /* Retry until we unload or reach max count */ |
| 15517 | if(++pHddCtx->hdd_restart_retries < WLAN_HDD_RESTART_RETRY_MAX_CNT) |
| 15518 | vos_timer_start(&pHddCtx->hdd_restart_timer, WLAN_HDD_RESTART_RETRY_DELAY_MS); |
| 15519 | |
| 15520 | return status; |
| 15521 | |
| 15522 | } |
| 15523 | /**--------------------------------------------------------------------------- |
| 15524 | * |
| 15525 | * \brief wlan_hdd_restart_timer_cb |
| 15526 | * |
| 15527 | * Restart timer callback. An internal function. |
| 15528 | * |
| 15529 | * \param - User data: |
| 15530 | * |
| 15531 | * \return - None |
| 15532 | * |
| 15533 | * --------------------------------------------------------------------------*/ |
| 15534 | |
| 15535 | void wlan_hdd_restart_timer_cb(v_PVOID_t usrDataForCallback) |
| 15536 | { |
| 15537 | hdd_context_t *pHddCtx = usrDataForCallback; |
| 15538 | wlan_hdd_framework_restart(pHddCtx); |
| 15539 | return; |
| 15540 | |
| 15541 | } |
| 15542 | |
| 15543 | |
| 15544 | /**--------------------------------------------------------------------------- |
| 15545 | * |
| 15546 | * \brief wlan_hdd_restart_driver |
| 15547 | * |
| 15548 | * This function sends an event to supplicant to restart the WLAN driver. |
| 15549 | * |
| 15550 | * This function is called from vos_wlanRestart. |
| 15551 | * |
| 15552 | * \param - pHddCtx |
| 15553 | * |
| 15554 | * \return - VOS_STATUS_SUCCESS: Success |
| 15555 | * VOS_STATUS_E_EMPTY: Adapter is Empty |
| 15556 | * VOS_STATUS_E_ALREADY: Request already in progress |
| 15557 | |
| 15558 | * --------------------------------------------------------------------------*/ |
| 15559 | VOS_STATUS wlan_hdd_restart_driver(hdd_context_t *pHddCtx) |
| 15560 | { |
| 15561 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 15562 | |
| 15563 | /* A tight check to make sure reentrancy */ |
| 15564 | if(atomic_xchg(&pHddCtx->isRestartInProgress, 1)) |
| 15565 | { |
Mihir Shete | fd52865 | 2014-06-23 19:07:50 +0530 | [diff] [blame] | 15566 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 15567 | "%s: WLAN restart is already in progress", __func__); |
| 15568 | |
| 15569 | return VOS_STATUS_E_ALREADY; |
| 15570 | } |
Sameer Thalappil | 0c164f5 | 2013-03-28 15:27:56 -0700 | [diff] [blame] | 15571 | /* Send reset FIQ to WCNSS to invoke SSR. */ |
Madan Mohan Koyyalamudi | e388b34 | 2012-11-08 15:03:16 -0800 | [diff] [blame] | 15572 | #ifdef HAVE_WCNSS_RESET_INTR |
Siddharth Bhal | 864e7e8 | 2015-04-07 20:07:24 +0530 | [diff] [blame] | 15573 | wcnss_reset_fiq(TRUE); |
Madan Mohan Koyyalamudi | bb8f017 | 2012-09-28 15:36:06 -0700 | [diff] [blame] | 15574 | #endif |
Madan Mohan Koyyalamudi | 5aef2af | 2012-10-05 11:56:27 -0700 | [diff] [blame] | 15575 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 15576 | return status; |
| 15577 | } |
| 15578 | |
Bhargav Shah | d071591 | 2015-10-01 18:17:37 +0530 | [diff] [blame] | 15579 | /** |
| 15580 | * hdd_get_total_sessions() - provide total number of active sessions |
| 15581 | * @pHddCtx: Valid Global HDD context pointer |
| 15582 | * |
| 15583 | * This function iterates through pAdaptors and find the number of all active |
| 15584 | * sessions. This active sessions includes connected sta, p2p client and number |
| 15585 | * of client connected to sap/p2p go. |
| 15586 | * |
| 15587 | * Return: Total number of active sessions. |
| 15588 | */ |
| 15589 | v_U8_t hdd_get_total_sessions(hdd_context_t *pHddCtx) |
| 15590 | { |
| 15591 | v_U8_t active_session = 0; |
| 15592 | hdd_station_ctx_t *pHddStaCtx; |
| 15593 | hdd_adapter_list_node_t *pAdapterNode, *pNext; |
| 15594 | hdd_adapter_t *pAdapter; |
| 15595 | VOS_STATUS status; |
| 15596 | |
| 15597 | status = hdd_get_front_adapter(pHddCtx, &pAdapterNode); |
| 15598 | while (NULL != pAdapterNode && VOS_STATUS_SUCCESS == status) { |
| 15599 | pAdapter = pAdapterNode->pAdapter; |
| 15600 | switch (pAdapter->device_mode) { |
| 15601 | case VOS_STA_MODE: |
| 15602 | case VOS_P2P_CLIENT_MODE: |
| 15603 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 15604 | if(eConnectionState_Associated == pHddStaCtx->conn_info.connState) |
| 15605 | active_session += 1; |
| 15606 | break; |
| 15607 | case VOS_STA_SAP_MODE: |
| 15608 | case VOS_P2P_GO_MODE: |
| 15609 | active_session += hdd_softap_get_connected_sta(pAdapter); |
| 15610 | break; |
| 15611 | default: |
| 15612 | break; |
| 15613 | } |
| 15614 | |
| 15615 | status = hdd_get_next_adapter(pHddCtx, pAdapterNode, &pNext); |
| 15616 | pAdapterNode = pNext; |
| 15617 | } |
| 15618 | |
| 15619 | return active_session; |
| 15620 | } |
| 15621 | |
| 15622 | /** |
| 15623 | * hdd_set_delack_value() - Set delack value |
| 15624 | * @pHddCtx: Valid Global HDD context pointer |
| 15625 | * @next_rx_level: Value to set for delack |
| 15626 | * |
| 15627 | * This function compare present value and next value of delack. If the both |
| 15628 | * are diffrent then it sets next value . |
| 15629 | * |
| 15630 | * Return: void. |
| 15631 | */ |
| 15632 | void hdd_set_delack_value(hdd_context_t *pHddCtx, v_U32_t next_rx_level) |
| 15633 | { |
| 15634 | if (pHddCtx->cur_rx_level != next_rx_level) { |
Alok Kumar | f372446 | 2018-04-05 15:18:54 +0530 | [diff] [blame] | 15635 | struct wlan_rx_tp_data rx_tp_data = {0}; |
| 15636 | |
Bhargav Shah | d071591 | 2015-10-01 18:17:37 +0530 | [diff] [blame] | 15637 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_DEBUG, |
| 15638 | "%s: TCP DELACK trigger level %d", |
| 15639 | __func__, next_rx_level); |
| 15640 | mutex_lock(&pHddCtx->cur_rx_level_lock); |
| 15641 | pHddCtx->cur_rx_level = next_rx_level; |
| 15642 | mutex_unlock(&pHddCtx->cur_rx_level_lock); |
Alok Kumar | f372446 | 2018-04-05 15:18:54 +0530 | [diff] [blame] | 15643 | |
| 15644 | rx_tp_data.rx_tp_flags |= TCP_DEL_ACK_IND; |
| 15645 | rx_tp_data.level = next_rx_level; |
| 15646 | |
| 15647 | wlan_hdd_send_svc_nlink_msg(WLAN_SVC_WLAN_TP_IND, &rx_tp_data, |
| 15648 | sizeof(rx_tp_data)); |
Bhargav Shah | d071591 | 2015-10-01 18:17:37 +0530 | [diff] [blame] | 15649 | } |
| 15650 | } |
| 15651 | |
| 15652 | /** |
| 15653 | * hdd_set_default_stop_delack_timer() - Start delack timer |
| 15654 | * @pHddCtx: Valid Global HDD context pointer |
| 15655 | * |
| 15656 | * This function stop delack timer and set delack value to default.. |
| 15657 | * |
| 15658 | * Return: void. |
| 15659 | */ |
| 15660 | |
| 15661 | void hdd_set_default_stop_delack_timer(hdd_context_t *pHddCtx) |
| 15662 | { |
| 15663 | if (VOS_TIMER_STATE_RUNNING != |
| 15664 | vos_timer_getCurrentState(&pHddCtx->delack_timer)) { |
| 15665 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_DEBUG, |
| 15666 | "%s: Can not stop timer", __func__); |
| 15667 | return; |
| 15668 | } |
| 15669 | |
| 15670 | vos_timer_stop(&pHddCtx->delack_timer); |
Alok Kumar | f372446 | 2018-04-05 15:18:54 +0530 | [diff] [blame] | 15671 | hdd_set_delack_value(pHddCtx, WLAN_SVC_TP_LOW); |
Bhargav Shah | d071591 | 2015-10-01 18:17:37 +0530 | [diff] [blame] | 15672 | } |
| 15673 | |
| 15674 | /** |
| 15675 | * hdd_start_delack_timer() - Start delack timer |
| 15676 | * @pHddCtx: Valid Global HDD context pointer |
| 15677 | * |
| 15678 | * This function starts the delack timer for tcpDelAckComputeInterval time |
| 15679 | * interval.The default timer value is 2 second. |
| 15680 | * |
| 15681 | * Return: void. |
| 15682 | */ |
| 15683 | void hdd_start_delack_timer(hdd_context_t *pHddCtx) |
| 15684 | { |
| 15685 | if (VOS_TIMER_STATE_RUNNING == |
| 15686 | vos_timer_getCurrentState(&pHddCtx->delack_timer)) { |
| 15687 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_DEBUG, |
| 15688 | "%s: Timer is already running", __func__); |
| 15689 | return; |
| 15690 | } |
| 15691 | |
| 15692 | vos_timer_start(&pHddCtx->delack_timer, |
| 15693 | pHddCtx->cfg_ini->tcpDelAckComputeInterval); |
| 15694 | } |
| 15695 | |
| 15696 | /** |
| 15697 | * hdd_update_prev_rx_packet_count() - Update previous rx packet count |
| 15698 | * @pHddCtx: Valid Global HDD context pointer |
| 15699 | * |
| 15700 | * This function updates the prev_rx_packets count from the corresponding |
| 15701 | * pAdapter states. This prev_rx_packets will diffed with the packet count |
| 15702 | * at the end of delack timer. That can give number of RX packet is spacific |
| 15703 | * time. |
| 15704 | * |
| 15705 | * Return: void. |
| 15706 | */ |
| 15707 | void hdd_update_prev_rx_packet_count(hdd_context_t *pHddCtx) |
| 15708 | { |
| 15709 | hdd_adapter_list_node_t *pAdapterNode, *pNext; |
| 15710 | hdd_adapter_t *pAdapter; |
| 15711 | VOS_STATUS status; |
| 15712 | |
| 15713 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 15714 | while (NULL != pAdapterNode && VOS_STATUS_SUCCESS == status) { |
| 15715 | pAdapter = pAdapterNode->pAdapter; |
| 15716 | pAdapter->prev_rx_packets = pAdapter->stats.rx_packets; |
| 15717 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 15718 | pAdapterNode = pNext; |
| 15719 | } |
| 15720 | } |
| 15721 | |
| 15722 | /** |
| 15723 | * hdd_manage_delack_timer() - start\stop delack timer |
| 15724 | * @pHddCtx: Valid Global HDD context pointer |
| 15725 | * |
| 15726 | * This function check the number of concerent session present, it starts the |
| 15727 | * delack timer if only one session is present. |
| 15728 | * In the case of BT_COEX and TDLS mode it blindly stop delack functionality. |
| 15729 | * |
| 15730 | * Return: void. |
| 15731 | */ |
| 15732 | void hdd_manage_delack_timer(hdd_context_t *pHddCtx) |
| 15733 | { |
| 15734 | uint8_t sessions; |
| 15735 | |
| 15736 | if (!pHddCtx->cfg_ini->enable_delack) { |
| 15737 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_DEBUG, |
| 15738 | "%s: TCP DELACK is not enabled", __func__); |
| 15739 | return; |
| 15740 | } |
| 15741 | |
| 15742 | /* Blindly stop timer of BTCOEX and TDLS Session is up */ |
| 15743 | if (pHddCtx->mode != 0) { |
| 15744 | hdd_set_default_stop_delack_timer(pHddCtx); |
| 15745 | return; |
| 15746 | } |
| 15747 | |
| 15748 | sessions = hdd_get_total_sessions(pHddCtx); |
| 15749 | if (sessions == 1) { |
| 15750 | hdd_update_prev_rx_packet_count(pHddCtx); |
| 15751 | hdd_start_delack_timer(pHddCtx); |
| 15752 | } else { |
| 15753 | hdd_set_default_stop_delack_timer(pHddCtx); |
| 15754 | } |
| 15755 | } |
| 15756 | |
Mihir Shete | e1093ba | 2014-01-21 20:13:32 +0530 | [diff] [blame] | 15757 | /**--------------------------------------------------------------------------- |
| 15758 | * |
| 15759 | * \brief wlan_hdd_init_channels |
| 15760 | * |
| 15761 | * This function is used to initialize the channel list in CSR |
| 15762 | * |
| 15763 | * This function is called from hdd_wlan_startup |
| 15764 | * |
| 15765 | * \param - pHddCtx: HDD context |
| 15766 | * |
| 15767 | * \return - VOS_STATUS_SUCCESS: Success |
| 15768 | * VOS_STATUS_E_FAULT: Failure reported by SME |
| 15769 | |
| 15770 | * --------------------------------------------------------------------------*/ |
| 15771 | static VOS_STATUS wlan_hdd_init_channels(hdd_context_t *pHddCtx) |
| 15772 | { |
| 15773 | eHalStatus status; |
| 15774 | |
| 15775 | status = sme_InitChannels(pHddCtx->hHal); |
| 15776 | if (HAL_STATUS_SUCCESS(status)) |
| 15777 | { |
| 15778 | return VOS_STATUS_SUCCESS; |
| 15779 | } |
| 15780 | else |
| 15781 | { |
| 15782 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Channel initialization failed(%d)", |
| 15783 | __func__, status); |
| 15784 | return VOS_STATUS_E_FAULT; |
| 15785 | } |
| 15786 | } |
| 15787 | |
Mihir Shete | 0420645 | 2014-11-20 17:50:58 +0530 | [diff] [blame] | 15788 | #ifdef CONFIG_ENABLE_LINUX_REG |
Agarwal Ashish | 6db9d53 | 2014-09-30 18:19:10 +0530 | [diff] [blame] | 15789 | 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] | 15790 | { |
| 15791 | eHalStatus status; |
| 15792 | |
Rajeev Kumar Sirasanagandla | f8fc27c | 2018-12-06 14:56:43 +0530 | [diff] [blame] | 15793 | if (init == INIT && init_by_reg_core_user) { |
| 15794 | init_by_reg_core_user = false; |
| 15795 | pr_info("driver regulatory hint is not required"); |
| 15796 | |
| 15797 | return VOS_STATUS_SUCCESS; |
| 15798 | } |
| 15799 | |
Agarwal Ashish | 6db9d53 | 2014-09-30 18:19:10 +0530 | [diff] [blame] | 15800 | status = sme_InitChannelsForCC(pHddCtx->hHal, init); |
Mahesh A Saptasagar | 74289d2 | 2014-05-14 12:43:37 +0530 | [diff] [blame] | 15801 | if (HAL_STATUS_SUCCESS(status)) |
| 15802 | { |
| 15803 | return VOS_STATUS_SUCCESS; |
| 15804 | } |
| 15805 | else |
| 15806 | { |
| 15807 | hddLog(VOS_TRACE_LEVEL_FATAL,"%s: Issue reg hint failed(%d)", |
| 15808 | __func__, status); |
| 15809 | return VOS_STATUS_E_FAULT; |
| 15810 | } |
| 15811 | } |
Mihir Shete | 0420645 | 2014-11-20 17:50:58 +0530 | [diff] [blame] | 15812 | #endif |
Sudhir Sattayappa Kohalli | b1d8c3a | 2013-06-18 14:47:20 -0700 | [diff] [blame] | 15813 | /* |
| 15814 | * API to find if there is any STA or P2P-Client is connected |
| 15815 | */ |
| 15816 | VOS_STATUS hdd_issta_p2p_clientconnected(hdd_context_t *pHddCtx) |
| 15817 | { |
| 15818 | return sme_isSta_p2p_clientConnected(pHddCtx->hHal); |
| 15819 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 15820 | |
Mihir Shete | e2ae82a | 2015-03-16 14:08:49 +0530 | [diff] [blame] | 15821 | |
| 15822 | /* |
| 15823 | * API to find if the firmware will send logs using DXE channel |
| 15824 | */ |
| 15825 | v_U8_t hdd_is_fw_logging_enabled(void) |
| 15826 | { |
| 15827 | hdd_context_t *pHddCtx; |
| 15828 | |
| 15829 | pHddCtx = vos_get_context(VOS_MODULE_ID_HDD, |
| 15830 | vos_get_global_context(VOS_MODULE_ID_HDD, NULL)); |
| 15831 | |
Sravan Kumar Kairam | 1d5bf8e | 2019-03-21 00:33:56 +0530 | [diff] [blame] | 15832 | return (pHddCtx && pHddCtx->cfg_ini->wlanLoggingEnable && |
| 15833 | pHddCtx->cfg_ini->enableMgmtLogging); |
Mihir Shete | e2ae82a | 2015-03-16 14:08:49 +0530 | [diff] [blame] | 15834 | } |
| 15835 | |
Agarwal Ashish | 57e8437 | 2014-12-05 18:26:53 +0530 | [diff] [blame] | 15836 | /* |
Mihir Shete | be94ebb | 2015-05-26 12:07:14 +0530 | [diff] [blame] | 15837 | * API to find if the firmware will send trace logs using DXE channel |
| 15838 | */ |
| 15839 | v_U8_t hdd_is_fw_ev_logging_enabled(void) |
| 15840 | { |
| 15841 | hdd_context_t *pHddCtx; |
| 15842 | |
| 15843 | pHddCtx = vos_get_context(VOS_MODULE_ID_HDD, |
| 15844 | vos_get_global_context(VOS_MODULE_ID_HDD, NULL)); |
| 15845 | |
Sravan Kumar Kairam | 1d5bf8e | 2019-03-21 00:33:56 +0530 | [diff] [blame] | 15846 | return (pHddCtx && pHddCtx->cfg_ini->wlanLoggingEnable && |
| 15847 | pHddCtx->cfg_ini->enableFWLogging); |
Mihir Shete | be94ebb | 2015-05-26 12:07:14 +0530 | [diff] [blame] | 15848 | } |
Sravan Kumar Kairam | 1d5bf8e | 2019-03-21 00:33:56 +0530 | [diff] [blame] | 15849 | |
Mihir Shete | be94ebb | 2015-05-26 12:07:14 +0530 | [diff] [blame] | 15850 | /* |
Agarwal Ashish | 57e8437 | 2014-12-05 18:26:53 +0530 | [diff] [blame] | 15851 | * API to find if there is any session connected |
| 15852 | */ |
| 15853 | VOS_STATUS hdd_is_any_session_connected(hdd_context_t *pHddCtx) |
| 15854 | { |
| 15855 | return sme_is_any_session_connected(pHddCtx->hHal); |
| 15856 | } |
| 15857 | |
| 15858 | |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 15859 | int wlan_hdd_scan_abort(hdd_adapter_t *pAdapter) |
| 15860 | { |
| 15861 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 15862 | hdd_scaninfo_t *pScanInfo = NULL; |
Girish Gowli | 4bf7a63 | 2014-06-12 13:42:11 +0530 | [diff] [blame] | 15863 | long status = 0; |
c_hpothu | a3d45d5 | 2015-01-05 14:11:17 +0530 | [diff] [blame] | 15864 | tSirAbortScanStatus abortScanStatus; |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 15865 | |
| 15866 | pScanInfo = &pHddCtx->scan_info; |
Ratnam Rachuri | c768113 | 2015-06-30 10:35:13 +0530 | [diff] [blame] | 15867 | INIT_COMPLETION(pScanInfo->abortscan_event_var); |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 15868 | if (pScanInfo->mScanPending) |
| 15869 | { |
c_hpothu | a3d45d5 | 2015-01-05 14:11:17 +0530 | [diff] [blame] | 15870 | abortScanStatus = hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId, |
| 15871 | eCSR_SCAN_ABORT_DEFAULT); |
| 15872 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 15873 | FL("abortScanStatus: %d"), abortScanStatus); |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 15874 | |
c_hpothu | a3d45d5 | 2015-01-05 14:11:17 +0530 | [diff] [blame] | 15875 | /* If there is active scan command lets wait for the completion else |
| 15876 | * there is no need to wait as scan command might be in the SME pending |
| 15877 | * command list. |
| 15878 | */ |
| 15879 | if (abortScanStatus == eSIR_ABORT_ACTIVE_SCAN_LIST_NOT_EMPTY) |
| 15880 | { |
Mukul Sharma | b392b64 | 2017-08-17 17:45:29 +0530 | [diff] [blame] | 15881 | status = wait_for_completion_timeout( |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 15882 | &pScanInfo->abortscan_event_var, |
| 15883 | msecs_to_jiffies(5000)); |
c_hpothu | a3d45d5 | 2015-01-05 14:11:17 +0530 | [diff] [blame] | 15884 | if (0 >= status) |
| 15885 | { |
| 15886 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Girish Gowli | 4bf7a63 | 2014-06-12 13:42:11 +0530 | [diff] [blame] | 15887 | "%s: Timeout or Interrupt occurred while waiting for abort" |
| 15888 | "scan, status- %ld", __func__, status); |
c_hpothu | a3d45d5 | 2015-01-05 14:11:17 +0530 | [diff] [blame] | 15889 | return -ETIMEDOUT; |
| 15890 | } |
| 15891 | } |
| 15892 | else if (abortScanStatus == eSIR_ABORT_SCAN_FAILURE) |
| 15893 | { |
| 15894 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 15895 | FL("hdd_abort_mac_scan failed")); |
| 15896 | return -VOS_STATUS_E_FAILURE; |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 15897 | } |
| 15898 | } |
Girish Gowli | 4bf7a63 | 2014-06-12 13:42:11 +0530 | [diff] [blame] | 15899 | return 0; |
Mahesh A Saptasagar | 2395ee6 | 2014-05-21 19:12:21 +0530 | [diff] [blame] | 15900 | } |
| 15901 | |
Abhishek Singh | 7d624e1 | 2015-11-30 14:29:27 +0530 | [diff] [blame] | 15902 | /** |
| 15903 | * hdd_indicate_mgmt_frame() - Wrapper to indicate management frame to |
| 15904 | * user space |
| 15905 | * @frame_ind: Management frame data to be informed. |
| 15906 | * |
| 15907 | * This function is used to indicate management frame to |
| 15908 | * user space |
| 15909 | * |
| 15910 | * Return: None |
| 15911 | * |
| 15912 | */ |
| 15913 | void hdd_indicate_mgmt_frame(tSirSmeMgmtFrameInd *frame_ind) |
| 15914 | { |
| 15915 | hdd_context_t *hdd_ctx = NULL; |
| 15916 | hdd_adapter_t *adapter = NULL; |
| 15917 | v_CONTEXT_t vos_context = NULL; |
Pragaspathi Thilagaraj | 4aa58d5 | 2019-05-27 18:35:26 +0530 | [diff] [blame] | 15918 | struct ieee80211_mgmt *mgmt = |
| 15919 | (struct ieee80211_mgmt *)frame_ind->frameBuf; |
Abhishek Singh | 7d624e1 | 2015-11-30 14:29:27 +0530 | [diff] [blame] | 15920 | |
| 15921 | /* Get the global VOSS context.*/ |
| 15922 | vos_context = vos_get_global_context(VOS_MODULE_ID_SYS, NULL); |
| 15923 | if (!vos_context) { |
| 15924 | hddLog(LOGE, FL("Global VOS context is Null")); |
| 15925 | return; |
| 15926 | } |
| 15927 | /* Get the HDD context.*/ |
| 15928 | hdd_ctx = |
| 15929 | (hdd_context_t *)vos_get_context(VOS_MODULE_ID_HDD, vos_context ); |
| 15930 | |
| 15931 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
| 15932 | { |
| 15933 | return; |
| 15934 | } |
Pragaspathi Thilagaraj | 4aa58d5 | 2019-05-27 18:35:26 +0530 | [diff] [blame] | 15935 | |
| 15936 | if (frame_ind->frameLen < ieee80211_hdrlen(mgmt->frame_control)) { |
| 15937 | hddLog(LOGE, FL(" Invalid frame length")); |
| 15938 | return; |
| 15939 | } |
| 15940 | |
Abhishek Singh | 7d624e1 | 2015-11-30 14:29:27 +0530 | [diff] [blame] | 15941 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, |
| 15942 | frame_ind->sessionId); |
| 15943 | |
| 15944 | if ((NULL != adapter) && |
| 15945 | (WLAN_HDD_ADAPTER_MAGIC == adapter->magic)) |
| 15946 | __hdd_indicate_mgmt_frame(adapter, |
| 15947 | frame_ind->frameLen, |
| 15948 | frame_ind->frameBuf, |
| 15949 | frame_ind->frameType, |
| 15950 | frame_ind->rxChan, |
| 15951 | frame_ind->rxRssi); |
| 15952 | return; |
| 15953 | |
| 15954 | } |
| 15955 | |
c_hpothu | 225aa7c | 2014-10-22 17:45:13 +0530 | [diff] [blame] | 15956 | VOS_STATUS wlan_hdd_cancel_remain_on_channel(hdd_context_t *pHddCtx) |
| 15957 | { |
| 15958 | hdd_adapter_t *pAdapter; |
| 15959 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 15960 | VOS_STATUS vosStatus; |
| 15961 | |
| 15962 | vosStatus = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 15963 | while (NULL != pAdapterNode && VOS_STATUS_E_EMPTY != vosStatus) |
| 15964 | { |
| 15965 | pAdapter = pAdapterNode->pAdapter; |
| 15966 | if (NULL != pAdapter) |
| 15967 | { |
| 15968 | if (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode || |
| 15969 | WLAN_HDD_P2P_CLIENT == pAdapter->device_mode || |
| 15970 | WLAN_HDD_P2P_GO == pAdapter->device_mode) |
| 15971 | { |
| 15972 | hddLog(LOG1, FL("abort ROC deviceMode: %d"), |
| 15973 | pAdapter->device_mode); |
| 15974 | if (VOS_STATUS_SUCCESS != |
| 15975 | wlan_hdd_cancel_existing_remain_on_channel(pAdapter)) |
| 15976 | { |
| 15977 | hddLog(LOGE, FL("failed to abort ROC")); |
| 15978 | return VOS_STATUS_E_FAILURE; |
| 15979 | } |
| 15980 | } |
| 15981 | } |
| 15982 | vosStatus = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 15983 | pAdapterNode = pNext; |
| 15984 | } |
| 15985 | return VOS_STATUS_SUCCESS; |
| 15986 | } |
Mahesh A Saptasagar | d477b09 | 2015-02-06 15:12:16 +0530 | [diff] [blame] | 15987 | |
Mihir Shete | 0be2877 | 2015-02-17 18:42:14 +0530 | [diff] [blame] | 15988 | hdd_remain_on_chan_ctx_t *hdd_get_remain_on_channel_ctx(hdd_context_t *pHddCtx) |
| 15989 | { |
| 15990 | hdd_adapter_t *pAdapter; |
| 15991 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 15992 | hdd_cfg80211_state_t *cfgState; |
| 15993 | hdd_remain_on_chan_ctx_t *pRemainChanCtx = NULL; |
| 15994 | VOS_STATUS vosStatus; |
| 15995 | |
| 15996 | vosStatus = hdd_get_front_adapter (pHddCtx, &pAdapterNode); |
| 15997 | while (NULL != pAdapterNode && VOS_STATUS_E_EMPTY != vosStatus) |
| 15998 | { |
| 15999 | pAdapter = pAdapterNode->pAdapter; |
| 16000 | if (NULL != pAdapter) |
| 16001 | { |
| 16002 | cfgState = WLAN_HDD_GET_CFG_STATE_PTR(pAdapter); |
| 16003 | pRemainChanCtx = cfgState->remain_on_chan_ctx; |
| 16004 | if (pRemainChanCtx) |
| 16005 | break; |
| 16006 | } |
| 16007 | vosStatus = hdd_get_next_adapter (pHddCtx, pAdapterNode, &pNext); |
| 16008 | pAdapterNode = pNext; |
| 16009 | } |
| 16010 | return pRemainChanCtx; |
| 16011 | } |
| 16012 | |
Padma, Santhosh Kumar | 778d838 | 2015-03-04 17:41:22 +0530 | [diff] [blame] | 16013 | /** |
| 16014 | * wlan_hdd_handle_dfs_chan_scan () - handles disable/enable DFS channels |
| 16015 | * |
| 16016 | * @pHddCtx: HDD context within host driver |
| 16017 | * @dfsScanMode: dfsScanMode passed from ioctl |
| 16018 | * |
| 16019 | */ |
| 16020 | |
| 16021 | VOS_STATUS wlan_hdd_handle_dfs_chan_scan(hdd_context_t *pHddCtx, |
| 16022 | tANI_U8 dfsScanMode) |
| 16023 | { |
| 16024 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 16025 | hdd_adapter_t *pAdapter; |
| 16026 | VOS_STATUS vosStatus; |
| 16027 | hdd_station_ctx_t *pHddStaCtx; |
| 16028 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 16029 | |
| 16030 | if(!pHddCtx) |
| 16031 | { |
| 16032 | hddLog(LOGE, FL("HDD context is Null")); |
| 16033 | return eHAL_STATUS_FAILURE; |
| 16034 | } |
| 16035 | |
| 16036 | if (pHddCtx->scan_info.mScanPending) |
| 16037 | { |
| 16038 | hddLog(LOG1, FL("Aborting scan for sessionId: %d"), |
| 16039 | pHddCtx->scan_info.sessionId); |
| 16040 | hdd_abort_mac_scan(pHddCtx, |
| 16041 | pHddCtx->scan_info.sessionId, |
| 16042 | eCSR_SCAN_ABORT_DEFAULT); |
| 16043 | } |
| 16044 | |
| 16045 | if (!dfsScanMode) |
| 16046 | { |
| 16047 | vosStatus = hdd_get_front_adapter( pHddCtx, &pAdapterNode); |
| 16048 | while ((NULL != pAdapterNode) && |
| 16049 | (VOS_STATUS_SUCCESS == vosStatus)) |
| 16050 | { |
| 16051 | pAdapter = pAdapterNode->pAdapter; |
| 16052 | |
| 16053 | if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) |
| 16054 | { |
| 16055 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 16056 | |
| 16057 | if(!pHddStaCtx) |
| 16058 | { |
| 16059 | hddLog(LOGE, FL("HDD STA context is Null")); |
| 16060 | return eHAL_STATUS_FAILURE; |
| 16061 | } |
| 16062 | |
| 16063 | /* if STA is already connected on DFS channel, |
| 16064 | disconnect immediately*/ |
| 16065 | if (hdd_connIsConnected(pHddStaCtx) && |
| 16066 | (NV_CHANNEL_DFS == |
| 16067 | vos_nv_getChannelEnabledState( |
| 16068 | pHddStaCtx->conn_info.operationChannel))) |
| 16069 | { |
| 16070 | status = sme_RoamDisconnect(pHddCtx->hHal, |
| 16071 | pAdapter->sessionId, |
| 16072 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
| 16073 | hddLog(LOG1, FL("Client connected on DFS channel %d," |
| 16074 | "sme_RoamDisconnect returned with status: %d" |
| 16075 | "for sessionid: %d"), pHddStaCtx->conn_info. |
| 16076 | operationChannel, status, pAdapter->sessionId); |
| 16077 | } |
| 16078 | } |
| 16079 | |
| 16080 | vosStatus = hdd_get_next_adapter(pHddCtx, pAdapterNode, |
| 16081 | &pNext); |
| 16082 | pAdapterNode = pNext; |
| 16083 | } |
| 16084 | } |
| 16085 | |
| 16086 | sme_UpdateDFSScanMode(pHddCtx->hHal, dfsScanMode); |
| 16087 | sme_UpdateDFSRoamMode(pHddCtx->hHal, |
| 16088 | (dfsScanMode != DFS_CHNL_SCAN_DISABLED)); |
| 16089 | |
| 16090 | status = sme_HandleDFSChanScan(pHddCtx->hHal); |
| 16091 | if (!HAL_STATUS_SUCCESS(status)) |
| 16092 | { |
| 16093 | hddLog(LOGE, |
| 16094 | FL("Failed in sme_HandleDFSChanScan (err=%d)"), status); |
| 16095 | return status; |
| 16096 | } |
| 16097 | |
| 16098 | return status; |
| 16099 | } |
| 16100 | |
Nirav Shah | 7e3c813 | 2015-06-22 23:51:42 +0530 | [diff] [blame] | 16101 | static int hdd_log2_ceil(unsigned value) |
| 16102 | { |
| 16103 | /* need to switch to unsigned math so that negative values |
| 16104 | * will right-shift towards 0 instead of -1 |
| 16105 | */ |
| 16106 | unsigned tmp = value; |
| 16107 | int log2 = -1; |
| 16108 | |
| 16109 | if (value == 0) |
| 16110 | return 0; |
| 16111 | |
| 16112 | while (tmp) { |
| 16113 | log2++; |
| 16114 | tmp >>= 1; |
| 16115 | } |
| 16116 | if (1U << log2 != value) |
| 16117 | log2++; |
| 16118 | |
| 16119 | return log2; |
| 16120 | } |
| 16121 | |
| 16122 | /** |
| 16123 | * hdd_sta_id_hash_attach() - initialize sta id to macaddr hash |
| 16124 | * @pAdapter: adapter handle |
| 16125 | * |
| 16126 | * Return: vos status |
| 16127 | */ |
| 16128 | VOS_STATUS hdd_sta_id_hash_attach(hdd_adapter_t *pAdapter) |
| 16129 | { |
| 16130 | int hash_elem, log2, i; |
| 16131 | |
| 16132 | spin_lock_bh( &pAdapter->sta_hash_lock); |
| 16133 | if (pAdapter->is_sta_id_hash_initialized == VOS_TRUE) { |
| 16134 | spin_unlock_bh( &pAdapter->sta_hash_lock); |
| 16135 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 16136 | "%s: hash already attached for session id %d", |
| 16137 | __func__, pAdapter->sessionId); |
| 16138 | return VOS_STATUS_SUCCESS; |
| 16139 | } |
| 16140 | spin_unlock_bh( &pAdapter->sta_hash_lock); |
| 16141 | |
| 16142 | hash_elem = WLAN_MAX_STA_COUNT; |
| 16143 | hash_elem *= HDD_STA_ID_HASH_MULTIPLIER; |
| 16144 | log2 = hdd_log2_ceil(hash_elem); |
| 16145 | hash_elem = 1 << log2; |
| 16146 | |
| 16147 | pAdapter->sta_id_hash.mask = hash_elem - 1; |
| 16148 | pAdapter->sta_id_hash.idx_bits = log2; |
| 16149 | pAdapter->sta_id_hash.bins = |
| 16150 | vos_mem_malloc(hash_elem *sizeof(hdd_list_t)); |
| 16151 | if (!pAdapter->sta_id_hash.bins) { |
| 16152 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 16153 | "%s: malloc failed for session %d", |
| 16154 | __func__, pAdapter->sessionId); |
| 16155 | return VOS_STATUS_E_NOMEM; |
| 16156 | } |
| 16157 | |
| 16158 | for (i = 0; i < hash_elem; i++) |
| 16159 | hdd_list_init(&pAdapter->sta_id_hash.bins[i], WLAN_MAX_STA_COUNT); |
| 16160 | |
| 16161 | spin_lock_bh( &pAdapter->sta_hash_lock); |
| 16162 | pAdapter->is_sta_id_hash_initialized = VOS_TRUE; |
| 16163 | spin_unlock_bh( &pAdapter->sta_hash_lock); |
| 16164 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 16165 | "%s: Station ID Hash attached for session id %d", |
| 16166 | __func__, pAdapter->sessionId); |
| 16167 | |
| 16168 | return VOS_STATUS_SUCCESS; |
| 16169 | } |
| 16170 | |
| 16171 | /** |
| 16172 | * hdd_sta_id_hash_detach() - deinit sta_id to macaddr hash |
| 16173 | * @pAdapter: adapter handle |
| 16174 | * |
| 16175 | * Return: vos status |
| 16176 | */ |
| 16177 | VOS_STATUS hdd_sta_id_hash_detach(hdd_adapter_t *pAdapter) |
| 16178 | { |
| 16179 | int hash_elem, i; |
| 16180 | v_SIZE_t size; |
| 16181 | |
| 16182 | spin_lock_bh( &pAdapter->sta_hash_lock); |
| 16183 | if (pAdapter->is_sta_id_hash_initialized != VOS_TRUE) { |
| 16184 | spin_unlock_bh( &pAdapter->sta_hash_lock); |
| 16185 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 16186 | "%s: hash not initialized for session id %d", |
| 16187 | __func__, pAdapter->sessionId); |
| 16188 | return VOS_STATUS_SUCCESS; |
| 16189 | } |
| 16190 | |
| 16191 | pAdapter->is_sta_id_hash_initialized = VOS_FALSE; |
| 16192 | spin_unlock_bh( &pAdapter->sta_hash_lock); |
| 16193 | |
| 16194 | hash_elem = 1 << pAdapter->sta_id_hash.idx_bits; |
| 16195 | |
| 16196 | /* free all station info*/ |
| 16197 | for (i = 0; i < hash_elem; i++) { |
| 16198 | hdd_list_size(&pAdapter->sta_id_hash.bins[i], &size); |
| 16199 | if (size != 0) { |
| 16200 | VOS_STATUS status; |
| 16201 | hdd_staid_hash_node_t *sta_info_node = NULL; |
| 16202 | hdd_staid_hash_node_t *next_node = NULL; |
| 16203 | status = hdd_list_peek_front ( &pAdapter->sta_id_hash.bins[i], |
| 16204 | (hdd_list_node_t**) &sta_info_node ); |
| 16205 | |
| 16206 | while ( NULL != sta_info_node && VOS_STATUS_SUCCESS == status ) |
| 16207 | { |
| 16208 | status = hdd_list_remove_node( &pAdapter->sta_id_hash.bins[i], |
| 16209 | &sta_info_node->node); |
| 16210 | vos_mem_free(sta_info_node); |
| 16211 | |
| 16212 | status = hdd_list_peek_next (&pAdapter->sta_id_hash.bins[i], |
| 16213 | (hdd_list_node_t*)sta_info_node, |
| 16214 | (hdd_list_node_t**)&next_node); |
| 16215 | sta_info_node = next_node; |
| 16216 | } |
| 16217 | } |
| 16218 | } |
| 16219 | |
| 16220 | vos_mem_free(pAdapter->sta_id_hash.bins); |
| 16221 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 16222 | "%s: Station ID Hash detached for session id %d", |
| 16223 | __func__, pAdapter->sessionId); |
| 16224 | return VOS_STATUS_SUCCESS; |
| 16225 | } |
| 16226 | |
| 16227 | /** |
| 16228 | * hdd_sta_id_hash_calculate_index() - derive index from macaddr |
| 16229 | * @pAdapter: adapter handle |
| 16230 | * @mac_addr_in: input mac address |
| 16231 | * |
| 16232 | * Return: index derived from mac address |
| 16233 | */ |
| 16234 | int hdd_sta_id_hash_calculate_index(hdd_adapter_t *pAdapter, |
| 16235 | v_MACADDR_t *mac_addr_in) |
| 16236 | { |
| 16237 | uint16 index; |
| 16238 | struct hdd_align_mac_addr_t * mac_addr = |
| 16239 | (struct hdd_align_mac_addr_t *)mac_addr_in; |
| 16240 | |
| 16241 | index = mac_addr->bytes_ab ^ |
| 16242 | mac_addr->bytes_cd ^ mac_addr->bytes_ef; |
| 16243 | index ^= index >> pAdapter->sta_id_hash.idx_bits; |
| 16244 | index &= pAdapter->sta_id_hash.mask; |
| 16245 | return index; |
| 16246 | } |
| 16247 | |
| 16248 | /** |
| 16249 | * hdd_sta_id_hash_add_entry() - add entry in hash |
| 16250 | * @pAdapter: adapter handle |
| 16251 | * @sta_id: station id |
| 16252 | * @mac_addr: mac address |
| 16253 | * |
| 16254 | * Return: vos status |
| 16255 | */ |
| 16256 | VOS_STATUS hdd_sta_id_hash_add_entry(hdd_adapter_t *pAdapter, |
| 16257 | v_U8_t sta_id, v_MACADDR_t *mac_addr) |
| 16258 | { |
| 16259 | uint16 index; |
| 16260 | hdd_staid_hash_node_t *sta_info_node = NULL; |
| 16261 | |
Nirav Shah | 7e3c813 | 2015-06-22 23:51:42 +0530 | [diff] [blame] | 16262 | index = hdd_sta_id_hash_calculate_index(pAdapter, mac_addr); |
| 16263 | sta_info_node = vos_mem_malloc(sizeof(hdd_staid_hash_node_t)); |
| 16264 | if (!sta_info_node) { |
Nirav Shah | 7e3c813 | 2015-06-22 23:51:42 +0530 | [diff] [blame] | 16265 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 16266 | "%s: malloc failed", __func__); |
| 16267 | return VOS_STATUS_E_NOMEM; |
| 16268 | } |
| 16269 | |
| 16270 | sta_info_node->sta_id = sta_id; |
| 16271 | vos_mem_copy(&sta_info_node->mac_addr, mac_addr, sizeof(v_MACADDR_t)); |
| 16272 | |
Nirav Shah | 303ed5c | 2015-08-24 10:29:25 +0530 | [diff] [blame] | 16273 | spin_lock_bh( &pAdapter->sta_hash_lock); |
| 16274 | if (pAdapter->is_sta_id_hash_initialized != VOS_TRUE) { |
| 16275 | spin_unlock_bh( &pAdapter->sta_hash_lock); |
| 16276 | vos_mem_free(sta_info_node); |
| 16277 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 16278 | "%s: hash is not initialized for session id %d", |
| 16279 | __func__, pAdapter->sessionId); |
| 16280 | return VOS_STATUS_E_FAILURE; |
| 16281 | } |
| 16282 | |
Nirav Shah | 7e3c813 | 2015-06-22 23:51:42 +0530 | [diff] [blame] | 16283 | hdd_list_insert_back ( &pAdapter->sta_id_hash.bins[index], |
| 16284 | (hdd_list_node_t*) sta_info_node ); |
| 16285 | spin_unlock_bh( &pAdapter->sta_hash_lock); |
| 16286 | return VOS_STATUS_SUCCESS; |
| 16287 | } |
| 16288 | |
| 16289 | /** |
| 16290 | * hdd_sta_id_hash_remove_entry() - remove entry from hash |
| 16291 | * @pAdapter: adapter handle |
| 16292 | * @sta_id: station id |
| 16293 | * @mac_addr: mac address |
| 16294 | * |
| 16295 | * Return: vos status |
| 16296 | */ |
| 16297 | VOS_STATUS hdd_sta_id_hash_remove_entry(hdd_adapter_t *pAdapter, |
| 16298 | v_U8_t sta_id, v_MACADDR_t *mac_addr) |
| 16299 | { |
| 16300 | uint16 index; |
| 16301 | VOS_STATUS status; |
| 16302 | hdd_staid_hash_node_t *sta_info_node = NULL; |
| 16303 | hdd_staid_hash_node_t *next_node = NULL; |
| 16304 | |
| 16305 | spin_lock_bh( &pAdapter->sta_hash_lock); |
| 16306 | if (pAdapter->is_sta_id_hash_initialized != VOS_TRUE) { |
| 16307 | spin_unlock_bh( &pAdapter->sta_hash_lock); |
| 16308 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 16309 | "%s: hash is not initialized for session id %d", |
| 16310 | __func__, pAdapter->sessionId); |
| 16311 | return VOS_STATUS_E_FAILURE; |
| 16312 | } |
| 16313 | |
| 16314 | index = hdd_sta_id_hash_calculate_index(pAdapter, mac_addr); |
| 16315 | status = hdd_list_peek_front ( &pAdapter->sta_id_hash.bins[index], |
| 16316 | (hdd_list_node_t**) &sta_info_node ); |
| 16317 | |
| 16318 | while ( NULL != sta_info_node && VOS_STATUS_SUCCESS == status ) |
| 16319 | { |
| 16320 | if (sta_info_node->sta_id == sta_id) { |
| 16321 | status = hdd_list_remove_node( &pAdapter->sta_id_hash.bins[index], |
| 16322 | &sta_info_node->node); |
| 16323 | vos_mem_free(sta_info_node); |
| 16324 | break; |
| 16325 | } |
| 16326 | status = hdd_list_peek_next (&pAdapter->sta_id_hash.bins[index], |
| 16327 | (hdd_list_node_t*)sta_info_node, (hdd_list_node_t**)&next_node); |
| 16328 | sta_info_node = next_node; |
| 16329 | } |
| 16330 | spin_unlock_bh( &pAdapter->sta_hash_lock); |
| 16331 | return status; |
| 16332 | } |
| 16333 | |
| 16334 | /** |
| 16335 | * hdd_sta_id_find_from_mac_addr() - find sta id from mac address |
| 16336 | * @pAdapter: adapter handle |
| 16337 | * @mac_addr_in: mac address |
| 16338 | * |
| 16339 | * Return: station id |
| 16340 | */ |
| 16341 | int hdd_sta_id_find_from_mac_addr(hdd_adapter_t *pAdapter, |
| 16342 | v_MACADDR_t *mac_addr_in) |
| 16343 | { |
| 16344 | uint8 is_found = 0; |
| 16345 | uint8 sta_id = HDD_WLAN_INVALID_STA_ID; |
| 16346 | uint16 index; |
| 16347 | VOS_STATUS status; |
| 16348 | hdd_staid_hash_node_t *sta_info_node = NULL; |
| 16349 | hdd_staid_hash_node_t *next_node = NULL; |
| 16350 | |
| 16351 | spin_lock_bh( &pAdapter->sta_hash_lock); |
| 16352 | if (pAdapter->is_sta_id_hash_initialized != VOS_TRUE) { |
| 16353 | spin_unlock_bh( &pAdapter->sta_hash_lock); |
Bhargav Shah | ce3b32c | 2015-08-10 12:29:24 +0530 | [diff] [blame] | 16354 | hddLog(VOS_TRACE_LEVEL_INFO, |
Nirav Shah | 7e3c813 | 2015-06-22 23:51:42 +0530 | [diff] [blame] | 16355 | FL("hash is not initialized for session id %d"), |
| 16356 | pAdapter->sessionId); |
| 16357 | return HDD_WLAN_INVALID_STA_ID; |
| 16358 | } |
| 16359 | |
| 16360 | index = hdd_sta_id_hash_calculate_index(pAdapter, mac_addr_in); |
| 16361 | status = hdd_list_peek_front ( &pAdapter->sta_id_hash.bins[index], |
| 16362 | (hdd_list_node_t**) &sta_info_node ); |
| 16363 | |
| 16364 | while ( NULL != sta_info_node && VOS_STATUS_SUCCESS == status ) |
| 16365 | { |
| 16366 | if (vos_mem_compare(&sta_info_node->mac_addr, |
| 16367 | mac_addr_in, sizeof(v_MACADDR_t))) { |
| 16368 | is_found = 1; |
| 16369 | sta_id = sta_info_node->sta_id; |
| 16370 | break; |
| 16371 | } |
| 16372 | status = hdd_list_peek_next (&pAdapter->sta_id_hash.bins[index], |
| 16373 | (hdd_list_node_t*)sta_info_node, |
| 16374 | (hdd_list_node_t**)&next_node); |
| 16375 | sta_info_node = next_node; |
| 16376 | } |
| 16377 | spin_unlock_bh( &pAdapter->sta_hash_lock); |
| 16378 | return sta_id; |
| 16379 | } |
| 16380 | |
Mahesh A Saptasagar | 67ab922 | 2015-10-21 15:38:41 +0530 | [diff] [blame] | 16381 | void hdd_initialize_adapter_common(hdd_adapter_t *pAdapter) |
| 16382 | { |
| 16383 | if (NULL == pAdapter) |
| 16384 | { |
| 16385 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: pAdapter is NULL ", __func__); |
| 16386 | return; |
| 16387 | } |
| 16388 | init_completion(&pAdapter->session_open_comp_var); |
| 16389 | init_completion(&pAdapter->session_close_comp_var); |
| 16390 | init_completion(&pAdapter->disconnect_comp_var); |
| 16391 | init_completion(&pAdapter->linkup_event_var); |
| 16392 | init_completion(&pAdapter->cancel_rem_on_chan_var); |
| 16393 | init_completion(&pAdapter->rem_on_chan_ready_event); |
| 16394 | init_completion(&pAdapter->pno_comp_var); |
| 16395 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 16396 | init_completion(&pAdapter->offchannel_tx_event); |
| 16397 | #endif |
| 16398 | init_completion(&pAdapter->tx_action_cnf_event); |
| 16399 | #ifdef FEATURE_WLAN_TDLS |
| 16400 | init_completion(&pAdapter->tdls_add_station_comp); |
| 16401 | init_completion(&pAdapter->tdls_del_station_comp); |
| 16402 | init_completion(&pAdapter->tdls_mgmt_comp); |
| 16403 | init_completion(&pAdapter->tdls_link_establish_req_comp); |
| 16404 | #endif |
| 16405 | |
| 16406 | #ifdef WLAN_FEATURE_RMC |
| 16407 | init_completion(&pAdapter->ibss_peer_info_comp); |
| 16408 | #endif /* WLAN_FEATURE_RMC */ |
| 16409 | init_completion(&pAdapter->ula_complete); |
| 16410 | init_completion(&pAdapter->change_country_code); |
| 16411 | |
| 16412 | #ifdef FEATURE_WLAN_BATCH_SCAN |
| 16413 | init_completion(&pAdapter->hdd_set_batch_scan_req_var); |
| 16414 | init_completion(&pAdapter->hdd_get_batch_scan_req_var); |
| 16415 | #endif |
Kapil Gupta | 2b44acb | 2016-12-30 16:49:51 +0530 | [diff] [blame] | 16416 | init_completion(&pAdapter->wlan_suspend_comp_var); |
Mahesh A Saptasagar | 67ab922 | 2015-10-21 15:38:41 +0530 | [diff] [blame] | 16417 | |
| 16418 | return; |
| 16419 | } |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 16420 | |
Anurag Chouhan | 0b29de0 | 2016-12-16 13:18:40 +0530 | [diff] [blame] | 16421 | #ifdef MDNS_OFFLOAD |
| 16422 | |
| 16423 | /** |
| 16424 | * hdd_mdns_enable_offload_done() - mdns enable offload response api |
| 16425 | * @padapter: holds adapter |
| 16426 | * @status: response status |
| 16427 | * |
| 16428 | * Return - None |
| 16429 | */ |
| 16430 | void hdd_mdns_enable_offload_done(void *padapter, VOS_STATUS status) |
| 16431 | { |
| 16432 | hdd_adapter_t* adapter = (hdd_adapter_t*) padapter; |
| 16433 | |
| 16434 | ENTER(); |
| 16435 | |
| 16436 | if (NULL == adapter) |
| 16437 | { |
| 16438 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 16439 | "%s: adapter is NULL",__func__); |
| 16440 | return; |
| 16441 | } |
| 16442 | |
| 16443 | adapter->mdns_status.mdns_enable_status = status; |
| 16444 | vos_event_set(&adapter->mdns_status.vos_event); |
| 16445 | return; |
| 16446 | } |
| 16447 | |
| 16448 | /** |
| 16449 | * hdd_mdns_fqdn_offload_done() - mdns fqdn offload response api |
| 16450 | * @padapter: holds adapter |
| 16451 | * @status: responce status |
| 16452 | * |
| 16453 | * Return - None |
| 16454 | */ |
| 16455 | void hdd_mdns_fqdn_offload_done(void *padapter, VOS_STATUS status) |
| 16456 | { |
| 16457 | hdd_adapter_t* adapter = (hdd_adapter_t*) padapter; |
| 16458 | |
| 16459 | ENTER(); |
| 16460 | |
| 16461 | if (NULL == adapter) |
| 16462 | { |
| 16463 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 16464 | "%s: adapter is NULL",__func__); |
| 16465 | return; |
| 16466 | } |
| 16467 | |
| 16468 | adapter->mdns_status.mdns_fqdn_status = status; |
| 16469 | return; |
| 16470 | } |
| 16471 | |
| 16472 | /** |
| 16473 | * hdd_mdns_resp_offload_done() - mdns resp offload response api |
| 16474 | * @padapter: holds adapter |
| 16475 | * @status: responce status |
| 16476 | * |
| 16477 | * Return - None |
| 16478 | */ |
| 16479 | void hdd_mdns_resp_offload_done(void *padapter, VOS_STATUS status) |
| 16480 | { |
| 16481 | hdd_adapter_t* adapter = (hdd_adapter_t*) padapter; |
| 16482 | |
| 16483 | ENTER(); |
| 16484 | |
| 16485 | if (NULL == adapter) |
| 16486 | { |
| 16487 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 16488 | "%s: adapter is NULL",__func__); |
| 16489 | return; |
| 16490 | } |
| 16491 | |
| 16492 | adapter->mdns_status.mdns_resp_status = status; |
| 16493 | return; |
| 16494 | } |
| 16495 | |
| 16496 | /** |
| 16497 | * wlan_hdd_mdns_process_response_dname() - Process mDNS domain name |
| 16498 | * @response: Pointer to a struct hdd_mdns_resp_info |
| 16499 | * @resp_info: Pointer to a struct tSirMDNSResponseInfo |
| 16500 | * |
| 16501 | * This function will pack the whole domain name without compression. It will |
| 16502 | * add the leading len for each field and add zero length octet to terminate |
| 16503 | * the domain name. |
| 16504 | * |
| 16505 | * Return: Return boolean. TRUE for success, FALSE for fail. |
| 16506 | */ |
| 16507 | static bool |
| 16508 | wlan_hdd_mdns_process_response_dname(struct hdd_mdns_resp_info *response, |
| 16509 | sir_mdns_resp_info resp_info) |
| 16510 | { |
| 16511 | uint8_t num; |
| 16512 | uint16_t idx; |
| 16513 | uint8_t len = 0; |
| 16514 | |
| 16515 | if ((response == NULL) || (response->data == NULL) || |
| 16516 | (response->offset == NULL)) { |
| 16517 | hddLog(LOGE, FL("Either data or offset in response is NULL!")); |
| 16518 | return FALSE; |
| 16519 | } |
| 16520 | |
| 16521 | if ((resp_info == NULL) || |
| 16522 | (resp_info->resp_len >= MAX_MDNS_RESP_LEN)) { |
| 16523 | hddLog(LOGE, FL("resp_len exceeds %d!"), MAX_MDNS_RESP_LEN); |
| 16524 | return FALSE; |
| 16525 | } |
| 16526 | |
| 16527 | for (num = 0; num < response->num_entries; num++) { |
| 16528 | response->offset[num] = |
| 16529 | resp_info->resp_len + MDNS_HEADER_LEN; |
| 16530 | idx = num * MAX_LEN_DOMAINNAME_FIELD; |
| 16531 | len = strlen((char *)&response->data[idx]); |
| 16532 | if ((resp_info->resp_len + len + 1) >= MAX_MDNS_RESP_LEN) { |
| 16533 | hddLog(LOGE, FL("resp_len exceeds %d!"), |
| 16534 | MAX_MDNS_RESP_LEN); |
| 16535 | return FALSE; |
| 16536 | } |
| 16537 | resp_info->resp_data[resp_info->resp_len] = len; |
| 16538 | resp_info->resp_len++; |
| 16539 | vos_mem_copy(&resp_info->resp_data[resp_info->resp_len], |
| 16540 | &response->data[idx], len); |
| 16541 | resp_info->resp_len += len; |
| 16542 | } |
| 16543 | |
| 16544 | /* The domain name terminates with the zero length octet */ |
| 16545 | if (num == response->num_entries) { |
| 16546 | if (resp_info->resp_len >= MAX_MDNS_RESP_LEN) { |
| 16547 | hddLog(LOGE, FL("resp_len exceeds %d!"), |
| 16548 | MAX_MDNS_RESP_LEN); |
| 16549 | return FALSE; |
| 16550 | } |
| 16551 | resp_info->resp_data[resp_info->resp_len] = 0; |
| 16552 | resp_info->resp_len++; |
| 16553 | } |
| 16554 | |
| 16555 | return TRUE; |
| 16556 | } |
| 16557 | |
| 16558 | /** |
| 16559 | * wlan_hdd_mdns_format_response_u16() - Form uint16_t response data |
| 16560 | * @value: The uint16_t value is formed to the struct tSirMDNSResponseInfo |
| 16561 | * @resp_info: Pointer to a struct tSirMDNSResponseInfo |
| 16562 | * |
| 16563 | * Return: None |
| 16564 | */ |
| 16565 | static void wlan_hdd_mdns_format_response_u16(uint16_t value, |
| 16566 | sir_mdns_resp_info resp_info) |
| 16567 | { |
| 16568 | uint8_t val_u8; |
| 16569 | |
| 16570 | if ((resp_info == NULL) || (resp_info->resp_data == NULL)) |
| 16571 | return; |
| 16572 | val_u8 = (value & 0xff00) >> 8; |
| 16573 | resp_info->resp_data[resp_info->resp_len++] = val_u8; |
| 16574 | val_u8 = value & 0xff; |
| 16575 | resp_info->resp_data[resp_info->resp_len++] = val_u8; |
| 16576 | } |
| 16577 | |
| 16578 | /** |
| 16579 | * wlan_hdd_mdns_format_response_u32() - Form uint32_t response data |
| 16580 | * @value: The uint32_t value is formed to the struct tSirMDNSResponseInfo |
| 16581 | * @resp_info: Pointer to a struct tSirMDNSResponseInfo |
| 16582 | * |
| 16583 | * Return: None |
| 16584 | */ |
| 16585 | static void wlan_hdd_mdns_format_response_u32(uint32_t value, |
| 16586 | sir_mdns_resp_info resp_info) |
| 16587 | { |
| 16588 | uint8_t val_u8; |
| 16589 | |
| 16590 | if ((resp_info == NULL) || (resp_info->resp_data == NULL)) |
| 16591 | return; |
| 16592 | val_u8 = (value & 0xff000000) >> 24; |
| 16593 | resp_info->resp_data[resp_info->resp_len++] = val_u8; |
| 16594 | val_u8 = (value & 0xff0000) >> 16; |
| 16595 | resp_info->resp_data[resp_info->resp_len++] = val_u8; |
| 16596 | val_u8 = (value & 0xff00) >> 8; |
| 16597 | resp_info->resp_data[resp_info->resp_len++] = val_u8; |
| 16598 | val_u8 = value & 0xff; |
| 16599 | resp_info->resp_data[resp_info->resp_len++] = val_u8; |
| 16600 | } |
| 16601 | |
| 16602 | /** |
| 16603 | * wlan_hdd_mdns_process_response_misc() - Process misc info in mDNS response |
| 16604 | * @resp_type: Response type for mDNS |
| 16605 | * @resp_info: Pointer to a struct tSirMDNSResponseInfo |
| 16606 | * |
| 16607 | * This function will pack the response type, class and TTL (Time To Live). |
| 16608 | * |
| 16609 | * Return: Return boolean. TRUE for success, FALSE for fail. |
| 16610 | */ |
| 16611 | static bool wlan_hdd_mdns_process_response_misc(uint16_t resp_type, |
| 16612 | sir_mdns_resp_info resp_info) |
| 16613 | { |
| 16614 | uint16_t len; |
| 16615 | |
| 16616 | if (resp_info == NULL) { |
| 16617 | hddLog(LOGE, FL("resp_info is NULL!")); |
| 16618 | return FALSE; |
| 16619 | } |
| 16620 | |
| 16621 | len = resp_info->resp_len + (2 * sizeof(uint16_t) + sizeof(uint32_t)); |
| 16622 | if (len >= MAX_MDNS_RESP_LEN) { |
| 16623 | hddLog(LOGE, FL("resp_len exceeds %d!"), MAX_MDNS_RESP_LEN); |
| 16624 | return FALSE; |
| 16625 | } |
| 16626 | |
| 16627 | /* Fill Type, Class, TTL */ |
| 16628 | wlan_hdd_mdns_format_response_u16(resp_type, resp_info); |
| 16629 | wlan_hdd_mdns_format_response_u16(MDNS_CLASS, resp_info); |
| 16630 | wlan_hdd_mdns_format_response_u32(MDNS_TTL, resp_info); |
| 16631 | |
| 16632 | return TRUE; |
| 16633 | } |
| 16634 | |
| 16635 | /** |
| 16636 | * wlan_hdd_mdns_compress_data() - Compress the domain name in mDNS response |
| 16637 | * @resp_info: Pointer to a struct tSirMDNSResponseInfo |
| 16638 | * @response_dst: The response which domain name is compressed. |
| 16639 | * @response_src: The response which domain name is matched with response_dst. |
| 16640 | * Its offset is used for data compression. |
| 16641 | * @num_matched: The number of matched entries between response_dst and |
| 16642 | * response_src |
| 16643 | * |
| 16644 | * This function will form the different fields of domain name in response_dst |
| 16645 | * if any. Then use the offset of the matched domain name in response_src to |
| 16646 | * compress the matched domain name. |
| 16647 | * |
| 16648 | * Return: Return boolean. TRUE for success, FALSE for fail. |
| 16649 | */ |
| 16650 | static bool |
| 16651 | wlan_hdd_mdns_compress_data(sir_mdns_resp_info resp_info, |
| 16652 | struct hdd_mdns_resp_info *response_dst, |
| 16653 | struct hdd_mdns_resp_info *response_src, |
| 16654 | uint8_t num_matched) |
| 16655 | { |
| 16656 | uint8_t num, num_diff; |
| 16657 | uint16_t value, idx; |
| 16658 | uint8_t len = 0; |
| 16659 | |
| 16660 | if ((response_src == NULL) || (response_dst == NULL) || |
| 16661 | (resp_info == NULL)) { |
| 16662 | hddLog(LOGE, FL("response info is NULL!")); |
| 16663 | return FALSE; |
| 16664 | } |
| 16665 | |
| 16666 | if (response_dst->num_entries < num_matched) { |
| 16667 | hddLog(LOGE, FL("num_entries is less than num_matched!")); |
| 16668 | return FALSE; |
| 16669 | } |
| 16670 | |
| 16671 | if (resp_info->resp_len >= MAX_MDNS_RESP_LEN) { |
| 16672 | hddLog(LOGE, FL("resp_len exceeds %d!"), MAX_MDNS_RESP_LEN); |
| 16673 | return FALSE; |
| 16674 | } |
| 16675 | |
| 16676 | num_diff = response_dst->num_entries - num_matched; |
| 16677 | if ((num_diff > 0) && (response_dst->data == NULL)) { |
| 16678 | hddLog(LOGE, FL("response_dst->data is NULL!")); |
| 16679 | return FALSE; |
| 16680 | } |
| 16681 | |
| 16682 | /* |
| 16683 | * Handle the unmatched string at the beginning |
| 16684 | * Store the length of octets and the octets |
| 16685 | */ |
| 16686 | for (num = 0; num < num_diff; num++) { |
| 16687 | response_dst->offset[num] = |
| 16688 | resp_info->resp_len + MDNS_HEADER_LEN; |
| 16689 | idx = num * MAX_LEN_DOMAINNAME_FIELD; |
| 16690 | len = strlen((char *)&response_dst->data[idx]); |
| 16691 | if ((resp_info->resp_len + len + 1) >= MAX_MDNS_RESP_LEN) { |
| 16692 | hddLog(LOGE, FL("resp_len exceeds %d!"), |
| 16693 | MAX_MDNS_RESP_LEN); |
| 16694 | return FALSE; |
| 16695 | } |
| 16696 | resp_info->resp_data[resp_info->resp_len] = len; |
| 16697 | resp_info->resp_len++; |
| 16698 | vos_mem_copy(&resp_info->resp_data[resp_info->resp_len], |
| 16699 | &response_dst->data[idx], len); |
| 16700 | resp_info->resp_len += len; |
| 16701 | } |
| 16702 | /* |
| 16703 | * Handle the matched string from the end |
| 16704 | * Just keep the offset and mask the leading two bit |
| 16705 | */ |
| 16706 | if (response_src->num_entries >= num_matched) { |
| 16707 | num_diff = response_src->num_entries - num_matched; |
| 16708 | value = response_src->offset[num_diff]; |
| 16709 | if (value > 0) { |
| 16710 | value |= 0xc000; |
| 16711 | if ((resp_info->resp_len + sizeof(uint16_t)) >= |
| 16712 | MAX_MDNS_RESP_LEN) { |
| 16713 | hddLog(LOGE, FL("resp_len exceeds %d!"), |
| 16714 | MAX_MDNS_RESP_LEN); |
| 16715 | return FALSE; |
| 16716 | } |
| 16717 | wlan_hdd_mdns_format_response_u16(value, resp_info); |
| 16718 | return TRUE; |
| 16719 | } |
| 16720 | } |
| 16721 | return FALSE; |
| 16722 | } |
| 16723 | |
| 16724 | /** |
| 16725 | * wlan_hdd_mdns_reset_response() - Reset the response info |
| 16726 | * @response: The response which info is reset. |
| 16727 | * |
| 16728 | * Return: None |
| 16729 | */ |
| 16730 | static void wlan_hdd_mdns_reset_response(struct hdd_mdns_resp_info *response) |
| 16731 | { |
| 16732 | if (response == NULL) |
| 16733 | return; |
| 16734 | response->num_entries = 0; |
| 16735 | response->data = NULL; |
| 16736 | response->offset = NULL; |
| 16737 | } |
| 16738 | |
| 16739 | /** |
| 16740 | * wlan_hdd_mdns_init_response() - Initialize the response info |
| 16741 | * @response: The response which info is initiatized. |
| 16742 | * @resp_dname: The domain name string which might be tokenized. |
| 16743 | * |
| 16744 | * This function will allocate the memory for both response->data and |
| 16745 | * response->offset. Besides, it will also tokenize the domain name to some |
| 16746 | * entries and fill response->num_entries with the num of entries. |
| 16747 | * |
| 16748 | * Return: Return boolean. TRUE for success, FALSE for fail. |
| 16749 | */ |
| 16750 | static bool wlan_hdd_mdns_init_response(struct hdd_mdns_resp_info *response, |
| 16751 | uint8_t *resp_dname, char separator) |
| 16752 | { |
| 16753 | uint16_t size; |
| 16754 | |
| 16755 | if ((resp_dname == NULL) || (response == NULL)) { |
| 16756 | hddLog(LOGE, FL("resp_dname or response is NULL!")); |
| 16757 | return FALSE; |
| 16758 | } |
| 16759 | |
| 16760 | size = MAX_NUM_FIELD_DOMAINNAME * MAX_LEN_DOMAINNAME_FIELD; |
| 16761 | response->data = vos_mem_malloc(size); |
| 16762 | if (response->data) { |
| 16763 | vos_mem_zero(response->data, size); |
| 16764 | if (VOS_STATUS_SUCCESS != |
| 16765 | hdd_string_to_string_array((char *)resp_dname, |
| 16766 | response->data, |
| 16767 | separator, |
| 16768 | &response->num_entries, |
| 16769 | MAX_NUM_FIELD_DOMAINNAME, |
| 16770 | MAX_LEN_DOMAINNAME_FIELD)) { |
| 16771 | hddLog(LOGE, FL("hdd_string_to_string_array fail!")); |
| 16772 | goto err_init_resp; |
| 16773 | } |
| 16774 | |
| 16775 | if ((response->num_entries > 0) && |
| 16776 | (strlen((char *)&response->data[0]) > 0)) { |
| 16777 | size = sizeof(uint16_t) * response->num_entries; |
| 16778 | response->offset = vos_mem_malloc(size); |
| 16779 | if (response->offset) { |
| 16780 | vos_mem_zero(response->offset, size); |
| 16781 | return TRUE; |
| 16782 | } |
| 16783 | } |
| 16784 | } |
| 16785 | |
| 16786 | err_init_resp: |
| 16787 | if (response->data) |
| 16788 | vos_mem_free(response->data); |
| 16789 | wlan_hdd_mdns_reset_response(response); |
| 16790 | return FALSE; |
| 16791 | } |
| 16792 | |
| 16793 | /** |
| 16794 | * wlan_hdd_mdns_find_entries_from_end() - Find the matched entries |
| 16795 | * @response1: The response info is used to be compared. |
| 16796 | * @response2: The response info is used to be compared. |
| 16797 | * |
| 16798 | * This function will find the matched entries from the end. |
| 16799 | * |
| 16800 | * Return: Return the number of the matched entries. |
| 16801 | */ |
| 16802 | static uint8_t |
| 16803 | wlan_hdd_mdns_find_entries_from_end(struct hdd_mdns_resp_info *response1, |
| 16804 | struct hdd_mdns_resp_info *response2) |
| 16805 | { |
| 16806 | uint8_t min, len1, i; |
| 16807 | uint16_t num1, num2; |
| 16808 | uint8_t num_matched = 0; |
| 16809 | |
| 16810 | min = VOS_MIN(response1->num_entries, response2->num_entries); |
| 16811 | |
| 16812 | for (i = 1; i <= min; i++) { |
| 16813 | num1 = (response1->num_entries - i); |
| 16814 | num1 *= MAX_LEN_DOMAINNAME_FIELD; |
| 16815 | num2 = (response2->num_entries - i); |
| 16816 | num2 *= MAX_LEN_DOMAINNAME_FIELD; |
| 16817 | len1 = strlen((char *)&response1->data[num1]); |
| 16818 | |
| 16819 | if ((len1 == 0) || |
| 16820 | (len1 != strlen((char *)&response2->data[num2]))) |
| 16821 | break; |
| 16822 | if (memcmp(&response1->data[num1], |
| 16823 | &response2->data[num2], len1)) |
| 16824 | break; |
| 16825 | else |
| 16826 | num_matched++; |
| 16827 | } |
| 16828 | |
| 16829 | return num_matched; |
| 16830 | } |
| 16831 | |
| 16832 | /** |
| 16833 | * wlan_hdd_mdns_find_max() - Find the maximum number of the matched entries |
| 16834 | * @matchedlist: Pointer to the array of struct hdd_mdns_resp_matched |
| 16835 | * @numlist: The number of the elements in the array matchedlist. |
| 16836 | * |
| 16837 | * Find the max number of the matched entries among the array matchedlist. |
| 16838 | * |
| 16839 | * Return: None |
| 16840 | */ |
| 16841 | static void wlan_hdd_mdns_find_max(struct hdd_mdns_resp_matched *matchedlist, |
| 16842 | uint8_t numlist) |
| 16843 | { |
| 16844 | int j; |
| 16845 | struct hdd_mdns_resp_matched tmp; |
| 16846 | |
| 16847 | /* At least two values are used for sorting */ |
| 16848 | if ((numlist < 2) || (matchedlist == NULL)) { |
| 16849 | hddLog(LOGE, FL("At least two values are used for sorting!")); |
| 16850 | return; |
| 16851 | } |
| 16852 | |
| 16853 | for (j = 0; j < numlist-1; j++) { |
| 16854 | if (matchedlist[j].num_matched > |
| 16855 | matchedlist[j+1].num_matched) { |
| 16856 | vos_mem_copy(&tmp, &matchedlist[j], |
| 16857 | sizeof(struct hdd_mdns_resp_matched)); |
| 16858 | vos_mem_copy(&matchedlist[j], &matchedlist[j+1], |
| 16859 | sizeof(struct hdd_mdns_resp_matched)); |
| 16860 | vos_mem_copy(&matchedlist[j+1], &tmp, |
| 16861 | sizeof(struct hdd_mdns_resp_matched)); |
| 16862 | } |
| 16863 | } |
| 16864 | } |
| 16865 | |
| 16866 | /** |
| 16867 | * wlan_hdd_mdns_pack_response_type_a() - Pack Type A response |
| 16868 | * @ini_config: Pointer to the struct hdd_config_t |
| 16869 | * @resp_info: Pointer to the struct tSirMDNSResponseInfo |
| 16870 | * @resptype_a: Pointer to the struct hdd_mdns_resp_info of Type A |
| 16871 | * |
| 16872 | * Type A response include QName, response type, class, TTL and Ipv4. |
| 16873 | * |
| 16874 | * Return: Return boolean. TRUE for success, FALSE for fail. |
| 16875 | */ |
| 16876 | static bool |
| 16877 | wlan_hdd_mdns_pack_response_type_a(hdd_config_t *ini_config, |
| 16878 | sir_mdns_resp_info resp_info, |
| 16879 | struct hdd_mdns_resp_info *resptype_a) |
| 16880 | { |
| 16881 | uint16_t value; |
| 16882 | uint32_t len; |
| 16883 | |
| 16884 | ENTER(); |
| 16885 | if ((ini_config == NULL) || (resp_info == NULL) || |
| 16886 | (resptype_a == NULL)) { |
| 16887 | hddLog(LOGE, FL("ini_config or response info is NULL!")); |
| 16888 | return FALSE; |
| 16889 | } |
| 16890 | |
| 16891 | /* No Type A response */ |
| 16892 | if (strlen((char *)ini_config->mdns_resp_type_a) <= 0) |
| 16893 | return TRUE; |
| 16894 | |
| 16895 | /* Wrong response is assigned, just ignore this response */ |
| 16896 | if (!wlan_hdd_mdns_init_response(resptype_a, |
| 16897 | ini_config->mdns_resp_type_a, '.')) |
| 16898 | return TRUE; |
| 16899 | |
| 16900 | /* Process response domain name */ |
| 16901 | if (!wlan_hdd_mdns_process_response_dname(resptype_a, resp_info)) { |
| 16902 | hddLog(LOGE, FL("Fail to process mDNS response (%d)!"), |
| 16903 | MDNS_TYPE_A); |
| 16904 | return FALSE; |
| 16905 | } |
| 16906 | |
| 16907 | /* Process response Type, Class, TTL */ |
| 16908 | if (!wlan_hdd_mdns_process_response_misc(MDNS_TYPE_A, resp_info)) { |
| 16909 | hddLog(LOGE, FL("Fail to process mDNS misc response (%d)!"), |
| 16910 | MDNS_TYPE_A); |
| 16911 | return FALSE; |
| 16912 | } |
| 16913 | |
| 16914 | /* Process response RDLength, RData */ |
| 16915 | len = sizeof(uint16_t) + sizeof(uint32_t); |
| 16916 | len += resp_info->resp_len; |
| 16917 | if (len >= MAX_MDNS_RESP_LEN) { |
| 16918 | hddLog(LOGE, FL("resp_len exceeds %d!"), MAX_MDNS_RESP_LEN); |
| 16919 | return FALSE; |
| 16920 | } |
| 16921 | value = sizeof(uint32_t); |
| 16922 | wlan_hdd_mdns_format_response_u16(value, resp_info); |
| 16923 | wlan_hdd_mdns_format_response_u32(ini_config->mdns_resp_type_a_ipv4, |
| 16924 | resp_info); |
| 16925 | |
| 16926 | EXIT(); |
| 16927 | return TRUE; |
| 16928 | } |
| 16929 | |
| 16930 | /** |
| 16931 | * wlan_hdd_mdns_pack_response_type_txt() - Pack Type Txt response |
| 16932 | * @ini_config: Pointer to the struct hdd_config_t |
| 16933 | * @resp_info: Pointer to the struct tSirMDNSResponseInfo |
| 16934 | * @resptype_txt: Pointer to the struct hdd_mdns_resp_info of Type txt |
| 16935 | * @resptype_a: Pointer to the struct hdd_mdns_resp_info of Type A |
| 16936 | * |
| 16937 | * Type Txt response include QName, response type, class, TTL and text content. |
| 16938 | * Also, it will find the matched QName from resptype_A and compress the data. |
| 16939 | * |
| 16940 | * Return: Return boolean. TRUE for success, FALSE for fail. |
| 16941 | */ |
| 16942 | static bool |
| 16943 | wlan_hdd_mdns_pack_response_type_txt(hdd_config_t *ini_config, |
| 16944 | sir_mdns_resp_info resp_info, |
| 16945 | struct hdd_mdns_resp_info *resptype_txt, |
| 16946 | struct hdd_mdns_resp_info *resptype_a) |
| 16947 | { |
| 16948 | uint8_t num_matched; |
| 16949 | uint8_t num; |
| 16950 | uint16_t idx; |
| 16951 | uint16_t value = 0; |
| 16952 | uint32_t len; |
| 16953 | uint32_t total_len; |
| 16954 | bool status; |
| 16955 | struct hdd_mdns_resp_info resptype_content; |
| 16956 | |
| 16957 | ENTER(); |
| 16958 | |
| 16959 | if ((ini_config == NULL) || (resp_info == NULL) || |
| 16960 | (resptype_txt == NULL)) { |
| 16961 | hddLog(LOGE, FL("ini_config or response info is NULL!")); |
| 16962 | return FALSE; |
| 16963 | } |
| 16964 | |
| 16965 | /* No Type Txt response */ |
| 16966 | if (strlen((char *)ini_config->mdns_resp_type_txt) <= 0) |
| 16967 | return TRUE; |
| 16968 | |
| 16969 | /* Wrong response is assigned, just ignore this response */ |
| 16970 | if (!wlan_hdd_mdns_init_response(resptype_txt, |
| 16971 | ini_config->mdns_resp_type_txt, '.')) |
| 16972 | return TRUE; |
| 16973 | |
| 16974 | /* |
| 16975 | * For data compression |
| 16976 | * Check if any strings are matched with Type A response |
| 16977 | */ |
| 16978 | if (resptype_a && (resptype_a->num_entries > 0)) { |
| 16979 | num_matched = wlan_hdd_mdns_find_entries_from_end(resptype_txt, |
| 16980 | resptype_a); |
| 16981 | if (num_matched > 0) { |
| 16982 | if (!wlan_hdd_mdns_compress_data(resp_info, |
| 16983 | resptype_txt, resptype_a, num_matched)) { |
| 16984 | hddLog(LOGE, FL("Fail to compress mDNS " |
| 16985 | "response (%d)!"), MDNS_TYPE_TXT); |
| 16986 | return FALSE; |
| 16987 | } |
| 16988 | } else { |
| 16989 | /* |
| 16990 | * num_matched is zero. Error! |
| 16991 | * At least ".local" is needed. |
| 16992 | */ |
| 16993 | hddLog(LOGE, FL("No matched string! Fail to pack mDNS " |
| 16994 | "response (%d)!"), MDNS_TYPE_TXT); |
| 16995 | return FALSE; |
| 16996 | } |
| 16997 | } else { |
| 16998 | /* no TypeA response, so show the whole data */ |
| 16999 | if (!wlan_hdd_mdns_process_response_dname(resptype_txt, |
| 17000 | resp_info)) { |
| 17001 | hddLog(LOGE, FL("Fail to process mDNS response (%d)!"), |
| 17002 | MDNS_TYPE_TXT); |
| 17003 | return FALSE; |
| 17004 | } |
| 17005 | } |
| 17006 | |
| 17007 | /* Process response Type, Class, TTL */ |
| 17008 | if (!wlan_hdd_mdns_process_response_misc(MDNS_TYPE_TXT, resp_info)) { |
| 17009 | hddLog(LOGE, FL("Fail to process mDNS misc response (%d)!"), |
| 17010 | MDNS_TYPE_TXT); |
| 17011 | return FALSE; |
| 17012 | } |
| 17013 | |
| 17014 | /* |
| 17015 | * Process response RDLength, RData. |
| 17016 | * TypeTxt RData include len. |
| 17017 | */ |
| 17018 | status = wlan_hdd_mdns_init_response(&resptype_content, |
| 17019 | ini_config->mdns_resp_type_txt_content, |
| 17020 | '/'); |
| 17021 | if (status == FALSE) { |
| 17022 | hddLog(LOGE, FL("wlan_hdd_mdns_init_response FAIL")); |
| 17023 | return FALSE; |
| 17024 | } |
| 17025 | |
| 17026 | for (num = 0; num < resptype_content.num_entries; num++) { |
| 17027 | idx = num * MAX_LEN_DOMAINNAME_FIELD; |
| 17028 | value += strlen((char *)&resptype_content.data[idx]); |
| 17029 | } |
| 17030 | |
| 17031 | /* content len is uint16_t */ |
| 17032 | total_len = sizeof(uint16_t); |
| 17033 | total_len += resp_info->resp_len + value + |
| 17034 | resptype_content.num_entries; |
| 17035 | |
| 17036 | if (total_len >= MAX_MDNS_RESP_LEN) { |
| 17037 | hddLog(LOGE, FL("resp_len exceeds %d!"), MAX_MDNS_RESP_LEN); |
| 17038 | return FALSE; |
| 17039 | } |
| 17040 | wlan_hdd_mdns_format_response_u16(value + resptype_content.num_entries, |
| 17041 | resp_info); |
| 17042 | |
| 17043 | for (num = 0; num < resptype_content.num_entries; num++) { |
| 17044 | idx = num * MAX_LEN_DOMAINNAME_FIELD; |
| 17045 | len = strlen((char *)&resptype_content.data[idx]); |
| 17046 | resp_info->resp_data[resp_info->resp_len] = len; |
| 17047 | resp_info->resp_len++; |
| 17048 | |
| 17049 | vos_mem_copy(&resp_info->resp_data[resp_info->resp_len], |
| 17050 | &resptype_content.data[idx], len); |
| 17051 | |
| 17052 | resp_info->resp_len += len; |
| 17053 | hddLog(LOG1, FL("index = %d, len = %d, str = %s"), |
| 17054 | num, len, &resptype_content.data[idx]); |
| 17055 | } |
| 17056 | |
| 17057 | EXIT(); |
| 17058 | return TRUE; |
| 17059 | } |
| 17060 | |
| 17061 | /** |
| 17062 | * wlan_hdd_mdns_pack_response_type_ptr_dname() - Pack Type PTR domain name |
| 17063 | * @ini_config: Pointer to the struct hdd_config_t |
| 17064 | * @resp_info: Pointer to the struct tSirMDNSResponseInfo |
| 17065 | * @resptype_ptr_dn: Pointer to the struct hdd_mdns_resp_info of Type Ptr |
| 17066 | * domain name |
| 17067 | * @resptype_ptr: Pointer to the struct hdd_mdns_resp_info of Type Ptr |
| 17068 | * @resptype_txt: Pointer to the struct hdd_mdns_resp_info of Type Txt |
| 17069 | * @resptype_a: Pointer to the struct hdd_mdns_resp_info of Type A |
| 17070 | * |
| 17071 | * The Type Ptr response include Type PTR domain name in its data field. |
| 17072 | * Also, it will find the matched QName from the existing resptype_ptr, |
| 17073 | * resptype_txt, resptype_a and then compress the data. |
| 17074 | * |
| 17075 | * Return: Return boolean. TRUE for success, FALSE for fail. |
| 17076 | */ |
| 17077 | static bool |
| 17078 | wlan_hdd_mdns_pack_response_type_ptr_dname(hdd_config_t *ini_config, |
| 17079 | sir_mdns_resp_info resp_info, |
| 17080 | struct hdd_mdns_resp_info *resptype_ptr_dn, |
| 17081 | struct hdd_mdns_resp_info *resptype_ptr, |
| 17082 | struct hdd_mdns_resp_info *resptype_txt, |
| 17083 | struct hdd_mdns_resp_info *resptype_a) |
| 17084 | { |
| 17085 | uint8_t num_matched, numlist, size; |
| 17086 | struct hdd_mdns_resp_matched matchedlist[MAX_MDNS_RESP_TYPE-1]; |
| 17087 | struct hdd_mdns_resp_info *resp; |
| 17088 | |
| 17089 | if ((ini_config == NULL) || (resp_info == NULL) || |
| 17090 | (resptype_ptr == NULL) || (resptype_ptr_dn == NULL)) { |
| 17091 | hddLog(LOGE, FL("ini_config or response info is NULL!")); |
| 17092 | return FALSE; |
| 17093 | } |
| 17094 | |
| 17095 | /* No Type Ptr domain name response */ |
| 17096 | if (strlen((char *)ini_config->mdns_resp_type_ptr_dname) <= 0) |
| 17097 | return TRUE; |
| 17098 | |
| 17099 | /* Wrong response is assigned, just ignore this response */ |
| 17100 | if (!wlan_hdd_mdns_init_response(resptype_ptr_dn, |
| 17101 | ini_config->mdns_resp_type_ptr_dname, '.')) |
| 17102 | return TRUE; |
| 17103 | |
| 17104 | /* |
| 17105 | * For data compression |
| 17106 | * Check if any strings are matched with previous |
| 17107 | * response. |
| 17108 | */ |
| 17109 | numlist = 0; |
| 17110 | size = (MAX_MDNS_RESP_TYPE-1); |
| 17111 | size *= sizeof(struct hdd_mdns_resp_matched); |
| 17112 | vos_mem_zero(matchedlist, size); |
| 17113 | num_matched = wlan_hdd_mdns_find_entries_from_end(resptype_ptr_dn, |
| 17114 | resptype_ptr); |
| 17115 | if (num_matched > 0) { |
| 17116 | matchedlist[numlist].num_matched = num_matched; |
| 17117 | matchedlist[numlist].type = MDNS_TYPE_PTR; |
| 17118 | numlist++; |
| 17119 | } |
| 17120 | if (resptype_txt && (resptype_txt->num_entries > 0)) { |
| 17121 | num_matched = wlan_hdd_mdns_find_entries_from_end( |
| 17122 | resptype_ptr_dn, resptype_txt); |
| 17123 | if (num_matched > 0) { |
| 17124 | matchedlist[numlist].num_matched = num_matched; |
| 17125 | matchedlist[numlist].type = MDNS_TYPE_TXT; |
| 17126 | numlist++; |
| 17127 | } |
| 17128 | } |
| 17129 | if (resptype_a && (resptype_a->num_entries > 0)) { |
| 17130 | num_matched = wlan_hdd_mdns_find_entries_from_end( |
| 17131 | resptype_ptr_dn,resptype_a); |
| 17132 | if (num_matched > 0) { |
| 17133 | matchedlist[numlist].num_matched = num_matched; |
| 17134 | matchedlist[numlist].type = MDNS_TYPE_A; |
| 17135 | numlist++; |
| 17136 | } |
| 17137 | } |
| 17138 | if (numlist > 0) { |
| 17139 | if (numlist > 1) |
| 17140 | wlan_hdd_mdns_find_max(matchedlist, numlist); |
| 17141 | resp = NULL; |
| 17142 | switch (matchedlist[numlist-1].type) { |
| 17143 | case MDNS_TYPE_A: |
| 17144 | resp = resptype_a; |
| 17145 | break; |
| 17146 | case MDNS_TYPE_TXT: |
| 17147 | resp = resptype_txt; |
| 17148 | break; |
| 17149 | case MDNS_TYPE_PTR: |
| 17150 | resp = resptype_ptr; |
| 17151 | break; |
| 17152 | default: |
| 17153 | hddLog(LOGE, FL("Fail to compress mDNS response " |
| 17154 | "(%d)!"), MDNS_TYPE_PTR_DNAME); |
| 17155 | return FALSE; |
| 17156 | } |
| 17157 | num_matched = matchedlist[numlist-1].num_matched; |
| 17158 | if (!wlan_hdd_mdns_compress_data(resp_info, resptype_ptr_dn, |
| 17159 | resp, num_matched)) { |
| 17160 | hddLog(LOGE, FL("Fail to compress mDNS response " |
| 17161 | "(%d)!"), MDNS_TYPE_PTR_DNAME); |
| 17162 | return FALSE; |
| 17163 | } |
| 17164 | } else { |
| 17165 | /* num = 0 -> no matched string */ |
| 17166 | if (!wlan_hdd_mdns_process_response_dname(resptype_ptr_dn, |
| 17167 | resp_info)) { |
| 17168 | hddLog(LOGE, FL("Fail to process mDNS response (%d)!"), |
| 17169 | MDNS_TYPE_PTR_DNAME); |
| 17170 | return FALSE; |
| 17171 | } |
| 17172 | } |
| 17173 | |
| 17174 | return TRUE; |
| 17175 | } |
| 17176 | |
| 17177 | /** |
| 17178 | * wlan_hdd_mdns_pack_response_type_ptr() - Pack Type PTR response |
| 17179 | * @ini_config: Pointer to the struct hdd_config_t |
| 17180 | * @resp_info: Pointer to the struct tSirMDNSResponseInfo |
| 17181 | * @resptype_ptr: Pointer to the struct hdd_mdns_resp_info of Type Ptr |
| 17182 | * @resptype_ptr_dn: Pointer to the struct hdd_mdns_resp_info of Type Ptr |
| 17183 | * domain name |
| 17184 | * @resptype_txt: Pointer to the struct hdd_mdns_resp_info of Type Txt |
| 17185 | * @resptype_a: Pointer to the struct hdd_mdns_resp_info of Type A |
| 17186 | * |
| 17187 | * The Type Ptr response include QName, response type, class, TTL and |
| 17188 | * Type PTR domain name. Also, it will find the matched QName from the |
| 17189 | * existing resptype_txt, resptype_a and then compress the data. |
| 17190 | * |
| 17191 | * Return: Return boolean. TRUE for success, FALSE for fail. |
| 17192 | */ |
| 17193 | static bool |
| 17194 | wlan_hdd_mdns_pack_response_type_ptr(hdd_config_t *ini_config, |
| 17195 | sir_mdns_resp_info resp_info, |
| 17196 | struct hdd_mdns_resp_info *resptype_ptr, |
| 17197 | struct hdd_mdns_resp_info *resptype_ptr_dn, |
| 17198 | struct hdd_mdns_resp_info *resptype_txt, |
| 17199 | struct hdd_mdns_resp_info *resptype_a) |
| 17200 | { |
| 17201 | uint8_t num_matched, num_matched1; |
| 17202 | uint16_t value; |
| 17203 | uint8_t val_u8; |
| 17204 | uint32_t offset_data_len, len; |
| 17205 | |
| 17206 | ENTER(); |
| 17207 | if ((ini_config == NULL) || (resp_info == NULL) || |
| 17208 | (resptype_ptr == NULL) || (resptype_ptr_dn == NULL)) { |
| 17209 | hddLog(LOGE, FL("ini_config or response info is NULL!")); |
| 17210 | return FALSE; |
| 17211 | } |
| 17212 | |
| 17213 | /* No Type Ptr response */ |
| 17214 | if (strlen((char *)ini_config->mdns_resp_type_ptr) <= 0) |
| 17215 | return TRUE; |
| 17216 | |
| 17217 | /* Wrong response is assigned, just ignore this response */ |
| 17218 | if (!wlan_hdd_mdns_init_response(resptype_ptr, |
| 17219 | ini_config->mdns_resp_type_ptr, '.')) |
| 17220 | return TRUE; |
| 17221 | |
| 17222 | /* |
| 17223 | * For data compression |
| 17224 | * Check if any strings are matched with Type A response |
| 17225 | */ |
| 17226 | num_matched = 0; |
| 17227 | num_matched1 = 0; |
| 17228 | if (resptype_a && (resptype_a->num_entries > 0)) { |
| 17229 | num_matched = wlan_hdd_mdns_find_entries_from_end(resptype_ptr, |
| 17230 | resptype_a); |
| 17231 | } |
| 17232 | if (resptype_txt && (resptype_txt->num_entries > 0)) { |
| 17233 | num_matched1 = wlan_hdd_mdns_find_entries_from_end( |
| 17234 | resptype_ptr, resptype_txt); |
| 17235 | } |
| 17236 | if ((num_matched != num_matched1) || |
| 17237 | ((num_matched > 0) && (num_matched1 > 0))) { |
| 17238 | if (num_matched >= num_matched1) { |
| 17239 | if (!wlan_hdd_mdns_compress_data(resp_info, |
| 17240 | resptype_ptr, resptype_a, num_matched)) { |
| 17241 | hddLog(LOGE, FL("Fail to compress mDNS " |
| 17242 | "response (%d)!"), MDNS_TYPE_PTR); |
| 17243 | return FALSE; |
| 17244 | } |
| 17245 | } else { |
| 17246 | /* num_matched is less than num_matched1 */ |
| 17247 | if (!wlan_hdd_mdns_compress_data(resp_info, |
| 17248 | resptype_ptr, resptype_txt, num_matched1)) { |
| 17249 | hddLog(LOGE, FL("Fail to compress mDNS " |
| 17250 | "response (%d)!"), MDNS_TYPE_PTR); |
| 17251 | return FALSE; |
| 17252 | } |
| 17253 | } |
| 17254 | } else { |
| 17255 | /* |
| 17256 | * Both num_matched and num_matched1 are zero. |
| 17257 | * no TypeA & TypeTxt |
| 17258 | */ |
| 17259 | if (!wlan_hdd_mdns_process_response_dname(resptype_ptr, |
| 17260 | resp_info)) { |
| 17261 | hddLog(LOGE, FL("Fail to process mDNS response (%d)!"), |
| 17262 | MDNS_TYPE_PTR); |
| 17263 | return FALSE; |
| 17264 | } |
| 17265 | } |
| 17266 | |
| 17267 | /* Process response Type, Class, TTL */ |
| 17268 | if (!wlan_hdd_mdns_process_response_misc(MDNS_TYPE_PTR, resp_info)) { |
| 17269 | hddLog(LOGE, FL("Fail to process mDNS misc response (%d)!"), |
| 17270 | MDNS_TYPE_PTR); |
| 17271 | return FALSE; |
| 17272 | } |
| 17273 | |
| 17274 | /* |
| 17275 | * Process response RDLength, RData (Ptr domain name) |
| 17276 | * Save the offset of RData length |
| 17277 | */ |
| 17278 | offset_data_len = resp_info->resp_len; |
| 17279 | resp_info->resp_len += sizeof(uint16_t); |
| 17280 | |
| 17281 | if (!wlan_hdd_mdns_pack_response_type_ptr_dname(ini_config, resp_info, |
| 17282 | resptype_ptr_dn, resptype_ptr, |
| 17283 | resptype_txt, resptype_a)) { |
| 17284 | return FALSE; |
| 17285 | } |
| 17286 | /* Set the RData length */ |
| 17287 | len = offset_data_len + sizeof(uint16_t); |
| 17288 | if ((resptype_ptr_dn->num_entries > 0) && |
| 17289 | (resp_info->resp_len > len)) { |
| 17290 | value = resp_info->resp_len - len; |
| 17291 | val_u8 = (value & 0xff00) >> 8; |
| 17292 | resp_info->resp_data[offset_data_len] = val_u8; |
| 17293 | val_u8 = value & 0xff; |
| 17294 | resp_info->resp_data[offset_data_len+1] = val_u8; |
| 17295 | } else { |
| 17296 | hddLog(LOGE, FL("Fail to process mDNS response (%d)!"), |
| 17297 | MDNS_TYPE_PTR); |
| 17298 | return FALSE; |
| 17299 | } |
| 17300 | |
| 17301 | EXIT(); |
| 17302 | return TRUE; |
| 17303 | } |
| 17304 | |
| 17305 | /** |
| 17306 | * wlan_hdd_mdns_pack_response_type_srv_target()- Pack Type Service Target |
| 17307 | * @ini_config: Pointer to the struct hdd_config_t |
| 17308 | * @resp_info: Pointer to the struct tSirMDNSResponseInfo |
| 17309 | * @resptype_srv_tgt: Pointer to the struct hdd_mdns_resp_info of Type Srv |
| 17310 | * target |
| 17311 | * @resptype_srv: Pointer to the struct hdd_mdns_resp_info of Type Srv |
| 17312 | * @resptype_ptr: Pointer to the struct hdd_mdns_resp_info of Type Ptr |
| 17313 | * @resptype_ptr_dn: Pointer to the struct hdd_mdns_resp_info of Type Ptr |
| 17314 | * domain name |
| 17315 | * @resptype_txt: Pointer to the struct hdd_mdns_resp_info of Type Txt |
| 17316 | * @resptype_a: Pointer to the struct hdd_mdns_resp_info of Type A |
| 17317 | * |
| 17318 | * The Type service target is one of the data field in the Type SRV response. |
| 17319 | * Also, it will find the matched QName from the existing resptype_srv, |
| 17320 | * resptype_ptr, resptype_ptr_dn, resptype_txt, resptype_a and then compress |
| 17321 | * the data. |
| 17322 | * |
| 17323 | * Return: Return boolean. TRUE for success, FALSE for fail. |
| 17324 | */ |
| 17325 | static bool |
| 17326 | wlan_hdd_mdns_pack_response_type_srv_target(hdd_config_t *ini_config, |
| 17327 | sir_mdns_resp_info resp_info, |
| 17328 | struct hdd_mdns_resp_info *resptype_srv_tgt, |
| 17329 | struct hdd_mdns_resp_info *resptype_srv, |
| 17330 | struct hdd_mdns_resp_info *resptype_ptr, |
| 17331 | struct hdd_mdns_resp_info *resptype_ptr_dn, |
| 17332 | struct hdd_mdns_resp_info *resptype_txt, |
| 17333 | struct hdd_mdns_resp_info *resptype_a) |
| 17334 | { |
| 17335 | uint8_t num_matched, num, size; |
| 17336 | struct hdd_mdns_resp_matched matchedlist[MAX_MDNS_RESP_TYPE-1]; |
| 17337 | struct hdd_mdns_resp_info *resp; |
| 17338 | |
| 17339 | if ((ini_config == NULL) || (resp_info == NULL) || |
| 17340 | (resptype_srv == NULL) || (resptype_srv_tgt == NULL)) { |
| 17341 | hddLog(LOGE, FL("ini_config or response info is NULL!")); |
| 17342 | return FALSE; |
| 17343 | } |
| 17344 | |
| 17345 | /* No Type Srv Target response */ |
| 17346 | if (strlen((char *)ini_config->mdns_resp_type_srv_target) <= 0) |
| 17347 | return TRUE; |
| 17348 | |
| 17349 | /* Wrong response is assigned, just ignore this response */ |
| 17350 | if (!wlan_hdd_mdns_init_response(resptype_srv_tgt, |
| 17351 | ini_config->mdns_resp_type_srv_target, '.')) |
| 17352 | return TRUE; |
| 17353 | |
| 17354 | /* |
| 17355 | * For data compression |
| 17356 | * Check if any strings are matched with previous response. |
| 17357 | */ |
| 17358 | num = 0; |
| 17359 | size = (MAX_MDNS_RESP_TYPE-1); |
| 17360 | size *= sizeof(struct hdd_mdns_resp_matched); |
| 17361 | vos_mem_zero(matchedlist, size); |
| 17362 | num_matched = wlan_hdd_mdns_find_entries_from_end(resptype_srv_tgt, |
| 17363 | resptype_srv); |
| 17364 | if (num_matched > 0) { |
| 17365 | matchedlist[num].num_matched = num_matched; |
| 17366 | matchedlist[num].type = MDNS_TYPE_SRV; |
| 17367 | num++; |
| 17368 | } |
| 17369 | if (resptype_ptr && (resptype_ptr->num_entries > 0)) { |
| 17370 | if (resptype_ptr_dn && (resptype_ptr_dn->num_entries > 0)) { |
| 17371 | num_matched = wlan_hdd_mdns_find_entries_from_end( |
| 17372 | resptype_srv_tgt, resptype_ptr_dn); |
| 17373 | if (num_matched > 0) { |
| 17374 | matchedlist[num].num_matched = num_matched; |
| 17375 | matchedlist[num].type = MDNS_TYPE_PTR_DNAME; |
| 17376 | num++; |
| 17377 | } |
| 17378 | } |
| 17379 | num_matched = wlan_hdd_mdns_find_entries_from_end( |
| 17380 | resptype_srv_tgt, resptype_ptr); |
| 17381 | if (num_matched > 0) { |
| 17382 | matchedlist[num].num_matched = num_matched; |
| 17383 | matchedlist[num].type = MDNS_TYPE_PTR; |
| 17384 | num++; |
| 17385 | } |
| 17386 | } |
| 17387 | if (resptype_txt && (resptype_txt->num_entries > 0)) { |
| 17388 | num_matched = wlan_hdd_mdns_find_entries_from_end( |
| 17389 | resptype_srv_tgt, resptype_txt); |
| 17390 | if (num_matched > 0) { |
| 17391 | matchedlist[num].num_matched = num_matched; |
| 17392 | matchedlist[num].type = MDNS_TYPE_TXT; |
| 17393 | num++; |
| 17394 | } |
| 17395 | } |
| 17396 | if (resptype_a && (resptype_a->num_entries > 0)) { |
| 17397 | num_matched = wlan_hdd_mdns_find_entries_from_end( |
| 17398 | resptype_srv_tgt, resptype_a); |
| 17399 | if (num_matched > 0) { |
| 17400 | matchedlist[num].num_matched = num_matched; |
| 17401 | matchedlist[num].type = MDNS_TYPE_A; |
| 17402 | num++; |
| 17403 | } |
| 17404 | } |
| 17405 | if (num > 0) { |
| 17406 | if (num > 1) |
| 17407 | wlan_hdd_mdns_find_max(matchedlist, num); |
| 17408 | resp = NULL; |
| 17409 | switch (matchedlist[num-1].type) { |
| 17410 | case MDNS_TYPE_A: |
| 17411 | resp = resptype_a; |
| 17412 | break; |
| 17413 | case MDNS_TYPE_TXT: |
| 17414 | resp = resptype_txt; |
| 17415 | break; |
| 17416 | case MDNS_TYPE_PTR: |
| 17417 | resp = resptype_ptr; |
| 17418 | break; |
| 17419 | case MDNS_TYPE_PTR_DNAME: |
| 17420 | resp = resptype_ptr_dn; |
| 17421 | break; |
| 17422 | case MDNS_TYPE_SRV: |
| 17423 | resp = resptype_srv; |
| 17424 | break; |
| 17425 | default: |
| 17426 | hddLog(LOGE, FL("Fail to compress mDNS response " |
| 17427 | "(%d)!"), MDNS_TYPE_SRV_TARGET); |
| 17428 | return FALSE; |
| 17429 | } |
| 17430 | num_matched = matchedlist[num-1].num_matched; |
| 17431 | if (!wlan_hdd_mdns_compress_data(resp_info, resptype_srv_tgt, |
| 17432 | resp, num_matched)) { |
| 17433 | hddLog(LOGE, FL("Fail to compress mDNS response " |
| 17434 | "(%d)!"), MDNS_TYPE_SRV_TARGET); |
| 17435 | return FALSE; |
| 17436 | } |
| 17437 | } else { |
| 17438 | /* num = 0 -> no matched string */ |
| 17439 | if (!wlan_hdd_mdns_process_response_dname(resptype_srv_tgt, |
| 17440 | resp_info)) { |
| 17441 | hddLog(LOGE, FL("Fail to process mDNS response (%d)!"), |
| 17442 | MDNS_TYPE_SRV_TARGET); |
| 17443 | return FALSE; |
| 17444 | } |
| 17445 | } |
| 17446 | |
| 17447 | return TRUE; |
| 17448 | } |
| 17449 | |
| 17450 | /** |
| 17451 | * wlan_hdd_mdns_pack_response_type_srv()- Pack Type Service response |
| 17452 | * @ini_config: Pointer to the struct hdd_config_t |
| 17453 | * @resp_info: Pointer to the struct tSirMDNSResponseInfo |
| 17454 | * @resptype_srv: Pointer to the struct hdd_mdns_resp_info of Type Srv |
| 17455 | * @resptype_srv_tgt: Pointer to the struct hdd_mdns_resp_info of Type Srv |
| 17456 | * target |
| 17457 | * @resptype_ptr: Pointer to the struct hdd_mdns_resp_info of Type Ptr |
| 17458 | * @resptype_ptr_dn: Pointer to the struct hdd_mdns_resp_info of Type Ptr |
| 17459 | * domain name |
| 17460 | * @resptype_txt: Pointer to the struct hdd_mdns_resp_info of Type Txt |
| 17461 | * @resptype_a: Pointer to the struct hdd_mdns_resp_info of Type A |
| 17462 | * |
| 17463 | * The Type SRV (Service) response include QName, response type, class, TTL |
| 17464 | * and four kinds of data fields. Also, it will find the matched QName from |
| 17465 | * the existing resptype_ptr, resptype_ptr_dn, resptype_txt, resptype_a and |
| 17466 | * then compress the data. |
| 17467 | * |
| 17468 | * Return: Return boolean. TRUE for success, FALSE for fail. |
| 17469 | */ |
| 17470 | static bool |
| 17471 | wlan_hdd_mdns_pack_response_type_srv(hdd_config_t *ini_config, |
| 17472 | sir_mdns_resp_info resp_info, |
| 17473 | struct hdd_mdns_resp_info *resptype_srv, |
| 17474 | struct hdd_mdns_resp_info *resptype_srv_tgt, |
| 17475 | struct hdd_mdns_resp_info *resptype_ptr, |
| 17476 | struct hdd_mdns_resp_info *resptype_ptr_dn, |
| 17477 | struct hdd_mdns_resp_info *resptype_txt, |
| 17478 | struct hdd_mdns_resp_info *resptype_a) |
| 17479 | { |
| 17480 | uint8_t num_matched, num, size; |
| 17481 | uint16_t value; |
| 17482 | uint8_t val_u8; |
| 17483 | uint32_t offset_data_len, len; |
| 17484 | struct hdd_mdns_resp_info *resp; |
| 17485 | struct hdd_mdns_resp_matched matchedlist[MAX_MDNS_RESP_TYPE-1]; |
| 17486 | |
| 17487 | ENTER(); |
| 17488 | |
| 17489 | if ((ini_config == NULL) || (resp_info == NULL) || |
| 17490 | (resptype_srv == NULL) || (resptype_srv_tgt == NULL)) { |
| 17491 | hddLog(LOGE, FL("ini_config or response info is NULL!")); |
| 17492 | return FALSE; |
| 17493 | } |
| 17494 | |
| 17495 | /* No Type Srv response */ |
| 17496 | if (strlen((char *)ini_config->mdns_resp_type_srv) <= 0) |
| 17497 | return TRUE; |
| 17498 | |
| 17499 | /* Wrong response is assigned, just ignore this response */ |
| 17500 | if (!wlan_hdd_mdns_init_response(resptype_srv, |
| 17501 | ini_config->mdns_resp_type_srv, '.')) |
| 17502 | return TRUE; |
| 17503 | |
| 17504 | /* |
| 17505 | * For data compression |
| 17506 | * Check if any strings are matched with Type A response |
| 17507 | */ |
| 17508 | num = 0; |
| 17509 | size = (MAX_MDNS_RESP_TYPE-1); |
| 17510 | size *= sizeof(struct hdd_mdns_resp_matched); |
| 17511 | vos_mem_zero(matchedlist, size); |
| 17512 | if (resptype_ptr && (resptype_ptr->num_entries > 0)) { |
| 17513 | if (resptype_ptr_dn && (resptype_ptr_dn->num_entries > 0)) { |
| 17514 | num_matched = wlan_hdd_mdns_find_entries_from_end( |
| 17515 | resptype_srv, |
| 17516 | resptype_ptr_dn); |
| 17517 | if (num_matched > 0) { |
| 17518 | matchedlist[num].num_matched = num_matched; |
| 17519 | matchedlist[num].type = MDNS_TYPE_PTR_DNAME; |
| 17520 | num++; |
| 17521 | } |
| 17522 | } |
| 17523 | num_matched = wlan_hdd_mdns_find_entries_from_end(resptype_srv, |
| 17524 | resptype_ptr); |
| 17525 | if (num_matched > 0) { |
| 17526 | matchedlist[num].num_matched = num_matched; |
| 17527 | matchedlist[num].type = MDNS_TYPE_PTR; |
| 17528 | num++; |
| 17529 | } |
| 17530 | } |
| 17531 | if (resptype_txt && (resptype_txt->num_entries > 0)) { |
| 17532 | num_matched = wlan_hdd_mdns_find_entries_from_end(resptype_srv, |
| 17533 | resptype_txt); |
| 17534 | if (num_matched > 0) { |
| 17535 | matchedlist[num].num_matched =num_matched; |
| 17536 | matchedlist[num].type = MDNS_TYPE_TXT; |
| 17537 | num++; |
| 17538 | } |
| 17539 | } |
| 17540 | if (resptype_a && (resptype_a->num_entries > 0)) { |
| 17541 | num_matched = wlan_hdd_mdns_find_entries_from_end(resptype_srv, |
| 17542 | resptype_a); |
| 17543 | if (num_matched > 0) { |
| 17544 | matchedlist[num].num_matched = num_matched; |
| 17545 | matchedlist[num].type = MDNS_TYPE_A; |
| 17546 | num++; |
| 17547 | } |
| 17548 | } |
| 17549 | if (num > 0) { |
| 17550 | if (num > 1) |
| 17551 | wlan_hdd_mdns_find_max(matchedlist, num); |
| 17552 | resp = NULL; |
| 17553 | switch (matchedlist[num-1].type) { |
| 17554 | case MDNS_TYPE_A: |
| 17555 | resp = resptype_a; |
| 17556 | break; |
| 17557 | case MDNS_TYPE_TXT: |
| 17558 | resp = resptype_txt; |
| 17559 | break; |
| 17560 | case MDNS_TYPE_PTR: |
| 17561 | resp = resptype_ptr; |
| 17562 | break; |
| 17563 | case MDNS_TYPE_PTR_DNAME: |
| 17564 | resp = resptype_ptr_dn; |
| 17565 | break; |
| 17566 | default: |
| 17567 | hddLog(LOGE, FL("Fail to compress mDNS response " |
| 17568 | "(%d)!"), MDNS_TYPE_SRV); |
| 17569 | return FALSE; |
| 17570 | } |
| 17571 | num_matched = matchedlist[num-1].num_matched; |
| 17572 | if (!wlan_hdd_mdns_compress_data(resp_info, resptype_srv, |
| 17573 | resp, num_matched)) { |
| 17574 | hddLog(LOGE, FL("Fail to compress mDNS response " |
| 17575 | "(%d)!"), MDNS_TYPE_SRV); |
| 17576 | return FALSE; |
| 17577 | } |
| 17578 | } else { |
| 17579 | /* num = 0 -> no matched string */ |
| 17580 | if (!wlan_hdd_mdns_process_response_dname(resptype_srv, |
| 17581 | resp_info)) { |
| 17582 | hddLog(LOGE, FL("Fail to process mDNS response (%d)!"), |
| 17583 | MDNS_TYPE_SRV); |
| 17584 | return FALSE; |
| 17585 | } |
| 17586 | } |
| 17587 | |
| 17588 | /* Process response Type, Class, TTL */ |
| 17589 | if (!wlan_hdd_mdns_process_response_misc(MDNS_TYPE_SRV, resp_info)) { |
| 17590 | hddLog(LOGE, FL("Fail to process mDNS misc response (%d)!"), |
| 17591 | MDNS_TYPE_SRV); |
| 17592 | return FALSE; |
| 17593 | } |
| 17594 | |
| 17595 | /* |
| 17596 | * Process response RDLength, RData (Srv target name) |
| 17597 | * Save the offset of RData length |
| 17598 | */ |
| 17599 | offset_data_len = resp_info->resp_len; |
| 17600 | resp_info->resp_len += sizeof(uint16_t); |
| 17601 | |
| 17602 | len = resp_info->resp_len + (3 * sizeof(uint16_t)); |
| 17603 | if (len >= MAX_MDNS_RESP_LEN) { |
| 17604 | hddLog(LOGE, FL("resp_len exceeds %d!"), MAX_MDNS_RESP_LEN); |
| 17605 | return FALSE; |
| 17606 | } |
| 17607 | |
| 17608 | /* set Srv Priority */ |
| 17609 | value = ini_config->mdns_resp_type_srv_priority; |
| 17610 | wlan_hdd_mdns_format_response_u16(value, resp_info); |
| 17611 | /* set Srv Weight */ |
| 17612 | value = ini_config->mdns_resp_type_srv_weight; |
| 17613 | wlan_hdd_mdns_format_response_u16(value, resp_info); |
| 17614 | /* set Srv Port */ |
| 17615 | value = ini_config->mdns_resp_type_srv_port; |
| 17616 | wlan_hdd_mdns_format_response_u16(value, resp_info); |
| 17617 | |
| 17618 | if (!wlan_hdd_mdns_pack_response_type_srv_target(ini_config, resp_info, |
| 17619 | resptype_srv_tgt, resptype_srv, |
| 17620 | resptype_ptr, resptype_ptr_dn, |
| 17621 | resptype_txt, resptype_a)) { |
| 17622 | return FALSE; |
| 17623 | } |
| 17624 | /* Set the RData length */ |
| 17625 | len = offset_data_len + sizeof(uint16_t); |
| 17626 | if ((resptype_srv_tgt->num_entries > 0) && |
| 17627 | (resp_info->resp_len > len)) { |
| 17628 | value = resp_info->resp_len - len; |
| 17629 | val_u8 = (value & 0xff00) >> 8; |
| 17630 | resp_info->resp_data[offset_data_len] = val_u8; |
| 17631 | val_u8 = value & 0xff; |
| 17632 | resp_info->resp_data[offset_data_len+1] = val_u8; |
| 17633 | } else { |
| 17634 | hddLog(LOGE, FL("Fail to process mDNS response (%d)!"), |
| 17635 | MDNS_TYPE_SRV); |
| 17636 | return FALSE; |
| 17637 | } |
| 17638 | |
| 17639 | EXIT(); |
| 17640 | return TRUE; |
| 17641 | } |
| 17642 | |
| 17643 | /** |
| 17644 | * wlan_hdd_mdns_free_mem() - Free the allocated memory |
| 17645 | * @response: Pointer to the struct hdd_mdns_resp_info |
| 17646 | * |
| 17647 | * Return: None |
| 17648 | */ |
| 17649 | static void wlan_hdd_mdns_free_mem(struct hdd_mdns_resp_info *response) |
| 17650 | { |
| 17651 | if (response && response->data) |
| 17652 | vos_mem_free(response->data); |
| 17653 | if (response && response->offset) |
| 17654 | vos_mem_free(response->offset); |
| 17655 | } |
| 17656 | |
| 17657 | /** |
| 17658 | * wlan_hdd_mdns_pack_response() - Pack mDNS response |
| 17659 | * @ini_config: Pointer to the struct hdd_config_t |
| 17660 | * @resp_info: Pointer to the struct tSirMDNSResponseInfo |
| 17661 | * |
| 17662 | * This function will pack four types of responses (Type A, Type Txt, Type Ptr |
| 17663 | * and Type Service). Each response contains QName, response type, class, TTL |
| 17664 | * and data fields. |
| 17665 | * |
| 17666 | * Return: Return boolean. TRUE for success, FALSE for fail. |
| 17667 | */ |
| 17668 | static bool wlan_hdd_mdns_pack_response(hdd_config_t *ini_config, |
| 17669 | sir_mdns_resp_info resp_info) |
| 17670 | { |
| 17671 | struct hdd_mdns_resp_info resptype_a, resptype_txt; |
| 17672 | struct hdd_mdns_resp_info resptype_ptr, resptype_ptr_dn; |
| 17673 | struct hdd_mdns_resp_info resptype_srv, resptype_srv_tgt; |
| 17674 | uint32_t num_res_records = 0; |
| 17675 | bool status = FALSE; |
| 17676 | |
| 17677 | ENTER(); |
| 17678 | |
| 17679 | wlan_hdd_mdns_reset_response(&resptype_a); |
| 17680 | wlan_hdd_mdns_reset_response(&resptype_txt); |
| 17681 | wlan_hdd_mdns_reset_response(&resptype_ptr); |
| 17682 | wlan_hdd_mdns_reset_response(&resptype_ptr_dn); |
| 17683 | wlan_hdd_mdns_reset_response(&resptype_srv); |
| 17684 | wlan_hdd_mdns_reset_response(&resptype_srv_tgt); |
| 17685 | |
| 17686 | resp_info->resp_len = 0; |
| 17687 | |
| 17688 | /* Process Type A response */ |
| 17689 | if (!wlan_hdd_mdns_pack_response_type_a(ini_config, resp_info, |
| 17690 | &resptype_a)) |
| 17691 | goto err_resptype_a; |
| 17692 | |
| 17693 | if ((resptype_a.num_entries > 0) && |
| 17694 | (strlen((char *)&resptype_a.data[0]) > 0)) |
| 17695 | num_res_records++; |
| 17696 | |
| 17697 | /* Process Type TXT response */ |
| 17698 | if (!wlan_hdd_mdns_pack_response_type_txt(ini_config, resp_info, |
| 17699 | &resptype_txt, &resptype_a)) |
| 17700 | goto err_resptype_txt; |
| 17701 | |
| 17702 | if ((resptype_txt.num_entries > 0) && |
| 17703 | (strlen((char *)&resptype_txt.data[0]) > 0)) |
| 17704 | num_res_records++; |
| 17705 | |
| 17706 | /* Process Type PTR response */ |
| 17707 | if (!wlan_hdd_mdns_pack_response_type_ptr(ini_config, resp_info, |
| 17708 | &resptype_ptr, &resptype_ptr_dn, |
| 17709 | &resptype_txt, &resptype_a)) |
| 17710 | goto err_resptype_ptr; |
| 17711 | |
| 17712 | if ((resptype_ptr.num_entries > 0) && |
| 17713 | (strlen((char *)&resptype_ptr.data[0]) > 0)) |
| 17714 | num_res_records++; |
| 17715 | |
| 17716 | /* Process Type SRV response */ |
| 17717 | if (!wlan_hdd_mdns_pack_response_type_srv(ini_config, resp_info, |
| 17718 | &resptype_srv, &resptype_srv_tgt, |
| 17719 | &resptype_ptr, &resptype_ptr_dn, |
| 17720 | &resptype_txt, &resptype_a)) |
| 17721 | goto err_resptype_srv; |
| 17722 | |
| 17723 | if ((resptype_srv.num_entries > 0) && |
| 17724 | (strlen((char *)&resptype_srv.data[0]) > 0)) |
| 17725 | num_res_records++; |
| 17726 | |
| 17727 | resp_info->resourceRecord_count = num_res_records; |
| 17728 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, |
| 17729 | "%s: Pack mDNS response data successfully!", __func__); |
| 17730 | status = TRUE; |
| 17731 | |
| 17732 | err_resptype_srv: |
| 17733 | wlan_hdd_mdns_free_mem(&resptype_srv); |
| 17734 | wlan_hdd_mdns_free_mem(&resptype_srv_tgt); |
| 17735 | |
| 17736 | err_resptype_ptr: |
| 17737 | wlan_hdd_mdns_free_mem(&resptype_ptr); |
| 17738 | wlan_hdd_mdns_free_mem(&resptype_ptr_dn); |
| 17739 | |
| 17740 | err_resptype_txt: |
| 17741 | wlan_hdd_mdns_free_mem(&resptype_txt); |
| 17742 | |
| 17743 | err_resptype_a: |
| 17744 | wlan_hdd_mdns_free_mem(&resptype_a); |
| 17745 | |
| 17746 | EXIT(); |
| 17747 | return status; |
| 17748 | } |
| 17749 | |
| 17750 | /** |
| 17751 | * wlan_hdd_set_mdns_offload() - Enable mDNS offload |
| 17752 | * @hostapd_adapter: Pointer to the struct hdd_adapter_t |
| 17753 | * |
| 17754 | * This function will set FQDN/unique FQDN (full qualified domain name) |
| 17755 | * and the mDNS response. Then send them to SME. |
| 17756 | * |
| 17757 | * Return: Return boolean. TRUE for success, FALSE for fail. |
| 17758 | */ |
| 17759 | bool wlan_hdd_set_mdns_offload(hdd_adapter_t *hostapd_adapter) |
| 17760 | { |
| 17761 | hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(hostapd_adapter); |
| 17762 | sir_mdns_offload_info mdns_offload_info; |
| 17763 | sir_mdns_fqdn_info mdns_fqdn_info; |
| 17764 | sir_mdns_resp_info mdns_resp_info; |
| 17765 | uint32_t fqdn_len, ufqdn_len; |
| 17766 | |
| 17767 | ENTER(); |
| 17768 | |
| 17769 | /* 1. Prepare the MDNS fqdn request to send to SME */ |
| 17770 | fqdn_len = strlen(hdd_ctx->cfg_ini->mdns_fqdn); |
| 17771 | ufqdn_len = strlen(hdd_ctx->cfg_ini->mdns_uniquefqdn); |
| 17772 | if ((fqdn_len == 0) && (ufqdn_len == 0)) { |
| 17773 | hddLog(LOGE, FL("No mDNS FQDN or UFQDN is assigned fqdn_len %d," |
| 17774 | "ufqdn_len %d!"), fqdn_len, ufqdn_len); |
| 17775 | return FALSE; |
| 17776 | } |
| 17777 | |
| 17778 | mdns_fqdn_info = vos_mem_malloc(sizeof(*mdns_fqdn_info)); |
| 17779 | if (NULL == mdns_fqdn_info) { |
| 17780 | hddLog(LOGE, FL("could not allocate tSirMDNSFqdnInfo!")); |
| 17781 | return FALSE; |
| 17782 | } |
| 17783 | /* MDNS fqdn request */ |
| 17784 | if (fqdn_len > 0) { |
| 17785 | vos_mem_zero(mdns_fqdn_info, sizeof(*mdns_fqdn_info)); |
| 17786 | mdns_fqdn_info->bss_idx = hostapd_adapter->sessionId; |
| 17787 | mdns_fqdn_info->fqdn_type = MDNS_FQDN_TYPE_GENERAL; |
| 17788 | mdns_fqdn_info->fqdn_len = fqdn_len; |
| 17789 | mdns_fqdn_info->mdns_fqdn_callback = hdd_mdns_fqdn_offload_done; |
| 17790 | mdns_fqdn_info->mdns_fqdn_cb_context = hostapd_adapter; |
| 17791 | vos_mem_copy(mdns_fqdn_info->fqdn_data, |
| 17792 | hdd_ctx->cfg_ini->mdns_fqdn, |
| 17793 | mdns_fqdn_info->fqdn_len); |
| 17794 | |
| 17795 | if (eHAL_STATUS_SUCCESS != |
| 17796 | sme_set_mdns_fqdn(hdd_ctx->hHal, mdns_fqdn_info)) { |
| 17797 | hddLog(LOGE, FL("sme_set_mdns_fqdn fail!")); |
| 17798 | vos_mem_free(mdns_fqdn_info); |
| 17799 | return FALSE; |
| 17800 | } |
| 17801 | } |
| 17802 | /* MDNS unique fqdn request */ |
| 17803 | if (ufqdn_len > 0) { |
| 17804 | vos_mem_zero(mdns_fqdn_info, sizeof(*mdns_fqdn_info)); |
| 17805 | mdns_fqdn_info->bss_idx = hostapd_adapter->sessionId; |
| 17806 | mdns_fqdn_info->fqdn_type = MDNS_FQDN_TYPE_UNIQUE; |
| 17807 | mdns_fqdn_info->fqdn_len = ufqdn_len; |
| 17808 | mdns_fqdn_info->mdns_fqdn_callback = hdd_mdns_fqdn_offload_done; |
| 17809 | mdns_fqdn_info->mdns_fqdn_cb_context = hostapd_adapter; |
| 17810 | vos_mem_copy(mdns_fqdn_info->fqdn_data, |
| 17811 | hdd_ctx->cfg_ini->mdns_uniquefqdn, |
| 17812 | mdns_fqdn_info->fqdn_len); |
| 17813 | if (eHAL_STATUS_SUCCESS != |
| 17814 | sme_set_mdns_fqdn(hdd_ctx->hHal, mdns_fqdn_info)) { |
| 17815 | hddLog(LOGE, FL("sme_set_mdns_fqdn fail!")); |
| 17816 | vos_mem_free(mdns_fqdn_info); |
| 17817 | return FALSE; |
| 17818 | } |
| 17819 | } |
| 17820 | vos_mem_free(mdns_fqdn_info); |
| 17821 | |
| 17822 | /* 2. Prepare the MDNS response request to send to SME */ |
| 17823 | mdns_resp_info = vos_mem_malloc(sizeof(*mdns_resp_info)); |
| 17824 | if (NULL == mdns_resp_info) { |
| 17825 | hddLog(LOGE, FL("could not allocate tSirMDNSResponseInfo!")); |
| 17826 | return FALSE; |
| 17827 | } |
| 17828 | |
| 17829 | vos_mem_zero(mdns_resp_info, sizeof(*mdns_resp_info)); |
| 17830 | mdns_resp_info->bss_idx = hostapd_adapter->sessionId; |
| 17831 | mdns_resp_info->mdns_resp_callback = hdd_mdns_resp_offload_done; |
| 17832 | mdns_resp_info->mdns_resp_cb_context = hostapd_adapter; |
| 17833 | if (!wlan_hdd_mdns_pack_response(hdd_ctx->cfg_ini, mdns_resp_info)) { |
| 17834 | hddLog(LOGE, FL("wlan_hdd_pack_mdns_response fail!")); |
| 17835 | vos_mem_free(mdns_resp_info); |
| 17836 | return FALSE; |
| 17837 | } |
| 17838 | if (eHAL_STATUS_SUCCESS != |
| 17839 | sme_set_mdns_resp(hdd_ctx->hHal, mdns_resp_info)) { |
| 17840 | hddLog(LOGE, FL("sme_set_mdns_resp fail!")); |
| 17841 | vos_mem_free(mdns_resp_info); |
| 17842 | return FALSE; |
| 17843 | } |
| 17844 | vos_mem_free(mdns_resp_info); |
| 17845 | |
| 17846 | /* 3. Prepare the MDNS Enable request to send to SME */ |
| 17847 | mdns_offload_info = vos_mem_malloc(sizeof(*mdns_offload_info)); |
| 17848 | if (NULL == mdns_offload_info) { |
| 17849 | hddLog(LOGE, FL("could not allocate tSirMDNSOffloadInfo!")); |
| 17850 | return FALSE; |
| 17851 | } |
| 17852 | |
| 17853 | vos_mem_zero(mdns_offload_info, sizeof(*mdns_offload_info)); |
| 17854 | |
| 17855 | mdns_offload_info->bss_idx = hostapd_adapter->sessionId; |
| 17856 | mdns_offload_info->enable = hdd_ctx->cfg_ini->enable_mdns_offload; |
| 17857 | mdns_offload_info->mdns_enable_callback = hdd_mdns_enable_offload_done; |
| 17858 | mdns_offload_info->mdns_enable_cb_context = hostapd_adapter; |
| 17859 | if (eHAL_STATUS_SUCCESS != |
| 17860 | sme_set_mdns_offload(hdd_ctx->hHal, mdns_offload_info)) { |
| 17861 | hddLog(LOGE, FL("sme_set_mdns_offload fail!")); |
| 17862 | vos_mem_free(mdns_offload_info); |
| 17863 | return FALSE; |
| 17864 | } |
| 17865 | |
| 17866 | vos_mem_free(mdns_offload_info); |
| 17867 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, |
| 17868 | "%s: enable mDNS offload successfully!", __func__); |
| 17869 | return TRUE; |
| 17870 | } |
Manjeet Singh | 3ed7924 | 2017-01-11 19:04:32 +0530 | [diff] [blame] | 17871 | |
| 17872 | |
Anurag Chouhan | 0b29de0 | 2016-12-16 13:18:40 +0530 | [diff] [blame] | 17873 | #endif /* MDNS_OFFLOAD */ |
c_manjee | cfd1efb | 2015-09-25 19:32:34 +0530 | [diff] [blame] | 17874 | |
Hanumanth Reddy Pothula | d864f31 | 2017-01-18 16:16:08 +0530 | [diff] [blame] | 17875 | /** |
| 17876 | * wlan_hdd_start_sap() - This function starts bss of SAP. |
| 17877 | * @ap_adapter: SAP adapter |
| 17878 | * |
| 17879 | * This function will process the starting of sap adapter. |
| 17880 | * |
| 17881 | * Return: void. |
| 17882 | */ |
| 17883 | void wlan_hdd_start_sap(hdd_adapter_t *ap_adapter) |
| 17884 | { |
| 17885 | hdd_ap_ctx_t *hdd_ap_ctx; |
| 17886 | hdd_hostapd_state_t *hostapd_state; |
| 17887 | VOS_STATUS vos_status; |
| 17888 | hdd_context_t *hdd_ctx; |
| 17889 | tsap_Config_t *pConfig; |
| 17890 | |
| 17891 | if (NULL == ap_adapter) { |
| 17892 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 17893 | FL("ap_adapter is NULL here")); |
| 17894 | return; |
| 17895 | } |
| 17896 | |
| 17897 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
| 17898 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 17899 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
| 17900 | pConfig = &ap_adapter->sessionCtx.ap.sapConfig; |
| 17901 | |
| 17902 | mutex_lock(&hdd_ctx->sap_lock); |
| 17903 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) |
| 17904 | goto end; |
| 17905 | |
| 17906 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
| 17907 | hddLog(LOGE, FL("SAP Not able to set AP IEs")); |
| 17908 | goto end; |
| 17909 | } |
| 17910 | |
| 17911 | vos_event_reset(&hostapd_state->vosEvent); |
| 17912 | if (WLANSAP_StartBss(hdd_ctx->pvosContext, hdd_hostapd_SAPEventCB, |
| 17913 | &hdd_ap_ctx->sapConfig, (v_PVOID_t)ap_adapter->dev) |
| 17914 | != VOS_STATUS_SUCCESS) { |
| 17915 | goto end; |
| 17916 | } |
| 17917 | |
| 17918 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
| 17919 | FL("Waiting for SAP to start")); |
| 17920 | vos_status = vos_wait_single_event(&hostapd_state->vosEvent, 10000); |
| 17921 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) { |
| 17922 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 17923 | FL("SAP Start failed")); |
| 17924 | goto end; |
| 17925 | } |
| 17926 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
| 17927 | FL("SAP Start Success")); |
| 17928 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
| 17929 | |
| 17930 | wlan_hdd_incr_active_session(hdd_ctx, ap_adapter->device_mode); |
| 17931 | hostapd_state->bCommit = TRUE; |
| 17932 | |
| 17933 | end: |
| 17934 | mutex_unlock(&hdd_ctx->sap_lock); |
| 17935 | return; |
| 17936 | } |
| 17937 | |
Manjeet Singh | 3ed7924 | 2017-01-11 19:04:32 +0530 | [diff] [blame] | 17938 | #ifdef WLAN_FEATURE_TSF |
| 17939 | |
| 17940 | /** |
| 17941 | * hdd_tsf_cb() - handle tsf request callback |
| 17942 | * |
| 17943 | * @pcb_cxt: pointer to the hdd_contex |
| 17944 | * @ptsf: pointer to struct stsf |
| 17945 | * |
| 17946 | * Based on the request sent . |
| 17947 | * |
| 17948 | * Return: Describe the execute result of this routine |
| 17949 | */ |
| 17950 | static int hdd_tsf_cb(void *pcb_ctx, struct stsf *ptsf) |
| 17951 | { |
| 17952 | hdd_context_t *hddctx; |
| 17953 | int status; |
| 17954 | hdd_adapter_t* adapter = (hdd_adapter_t*)pcb_ctx; |
| 17955 | |
| 17956 | if (pcb_ctx == NULL || ptsf == NULL) { |
| 17957 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 17958 | FL("HDD context is not valid")); |
| 17959 | return -EINVAL; |
| 17960 | } |
| 17961 | |
| 17962 | hddctx = (hdd_context_t *)pcb_ctx; |
| 17963 | status = wlan_hdd_validate_context(hddctx); |
| 17964 | if (0 != status) |
| 17965 | return -EINVAL; |
| 17966 | |
| 17967 | if (NULL == adapter) { |
| 17968 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 17969 | FL("failed to find adapter")); |
| 17970 | return -EINVAL; |
| 17971 | } |
| 17972 | |
| 17973 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 17974 | FL("tsf cb handle event, device_mode is %d"), |
| 17975 | adapter->device_mode); |
| 17976 | |
| 17977 | /* copy the return value to hdd_tsf_ctx in adapter*/ |
| 17978 | if (ptsf->tsf_req_status) { |
| 17979 | |
| 17980 | vos_spin_lock_acquire(&adapter->tsf_cap_ctx.tsf_lock); |
| 17981 | adapter->tsf_cap_ctx.tsf_get_state = TSF_NOT_RETURNED_BY_FW; |
| 17982 | adapter->tsf_cap_ctx.tsf_capture_state = TSF_IDLE; |
| 17983 | vos_event_set (&adapter->tsf_cap_ctx.tsf_capture_done_event); |
| 17984 | vos_spin_lock_release(&adapter->tsf_cap_ctx.tsf_lock); |
| 17985 | |
| 17986 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("tsf req failure :%d"), |
| 17987 | ptsf->tsf_req_status); |
| 17988 | return ptsf->tsf_req_status; |
| 17989 | } |
| 17990 | /* If this is a get request.Store the tsf values in adapter. */ |
| 17991 | if (!ptsf->set_tsf_req) { |
| 17992 | vos_spin_lock_acquire(&adapter->tsf_cap_ctx.tsf_lock); |
| 17993 | adapter->tsf_cap_ctx.tsf_low = ptsf->tsf_low; |
| 17994 | adapter->tsf_cap_ctx.tsf_high = ptsf->tsf_high; |
| 17995 | adapter->tsf_cap_ctx.tsf_get_state = TSF_RETURN; |
| 17996 | adapter->tsf_cap_ctx.tsf_capture_state = TSF_IDLE; |
| 17997 | vos_spin_lock_release(&adapter->tsf_cap_ctx.tsf_lock); |
| 17998 | |
| 17999 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 18000 | FL("hdd_get_tsf_cb sta=%u, tsf_low=%u, tsf_high=%u"), |
| 18001 | adapter->sessionId, ptsf->tsf_low, ptsf->tsf_high); |
| 18002 | } |
| 18003 | else { |
| 18004 | vos_spin_lock_acquire(&adapter->tsf_cap_ctx.tsf_lock); |
| 18005 | adapter->tsf_cap_ctx.tsf_capture_state = TSF_CAP_STATE; |
| 18006 | adapter->tsf_cap_ctx.tsf_get_state = TSF_CURRENT_IN_CAP_STATE; |
| 18007 | vos_spin_lock_release(&adapter->tsf_cap_ctx.tsf_lock); |
| 18008 | } |
| 18009 | vos_spin_lock_acquire(&adapter->tsf_cap_ctx.tsf_lock); |
| 18010 | vos_event_set (&adapter->tsf_cap_ctx.tsf_capture_done_event); |
| 18011 | vos_spin_lock_release(&adapter->tsf_cap_ctx.tsf_lock); |
| 18012 | |
| 18013 | /* free allocated mem */ |
| 18014 | vos_mem_free(ptsf); |
| 18015 | |
| 18016 | return 0; |
| 18017 | } |
| 18018 | |
| 18019 | /** |
| 18020 | * hdd_capture_tsf() - capture tsf |
| 18021 | * |
| 18022 | * @adapter: pointer to adapter |
| 18023 | * @buf: pointer to upper layer buf |
| 18024 | * @len : the length of buf |
| 18025 | * |
| 18026 | * This function returns tsf value to uplayer. |
| 18027 | * |
| 18028 | * Return: Describe the execute result of this routine |
| 18029 | */ |
| 18030 | int hdd_capture_tsf(hdd_adapter_t *adapter, uint32_t *buf, int len) |
| 18031 | { |
| 18032 | int ret = 0; |
| 18033 | hdd_station_ctx_t *hdd_sta_ctx; |
| 18034 | hdd_context_t *hdd_ctx; |
| 18035 | tSirCapTsfParams cap_tsf_params; |
| 18036 | VOS_STATUS status; |
| 18037 | |
| 18038 | if (adapter == NULL || buf == NULL) { |
| 18039 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 18040 | FL("invalid pointer")); |
| 18041 | return -EINVAL; |
| 18042 | } |
| 18043 | if (len != 1) |
| 18044 | return -EINVAL; |
| 18045 | |
| 18046 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 18047 | |
| 18048 | if (wlan_hdd_validate_context(hdd_ctx)) { |
| 18049 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 18050 | FL("invalid hdd ctx")); |
| 18051 | return -EINVAL; |
| 18052 | } |
| 18053 | if (adapter->device_mode == WLAN_HDD_INFRA_STATION || |
| 18054 | adapter->device_mode == WLAN_HDD_P2P_CLIENT) { |
| 18055 | hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 18056 | if (hdd_sta_ctx->conn_info.connState != |
| 18057 | eConnectionState_Associated) { |
| 18058 | |
| 18059 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 18060 | FL("failed to cap tsf, not connect with ap")); |
| 18061 | buf[0] = TSF_STA_NOT_CONNECTED_NO_TSF; |
| 18062 | return ret; |
| 18063 | } |
| 18064 | } |
| 18065 | if ((adapter->device_mode == WLAN_HDD_SOFTAP || |
| 18066 | adapter->device_mode == WLAN_HDD_P2P_GO) && |
| 18067 | !(test_bit(SOFTAP_BSS_STARTED, &adapter->event_flags))) { |
| 18068 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 18069 | FL("Soft AP / P2p GO not beaconing")); |
| 18070 | buf[0] = TSF_SAP_NOT_STARTED_NO_TSF; |
| 18071 | return ret; |
| 18072 | } |
| 18073 | if (adapter->tsf_cap_ctx.tsf_capture_state == TSF_CAP_STATE) { |
| 18074 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 18075 | FL("current in capture state, pls reset")); |
| 18076 | buf[0] = TSF_CURRENT_IN_CAP_STATE; |
| 18077 | } else { |
| 18078 | hddLog(VOS_TRACE_LEVEL_INFO, FL("ioctl issue cap tsf cmd")); |
| 18079 | buf[0] = TSF_RETURN; |
| 18080 | cap_tsf_params.session_id = adapter->sessionId; |
| 18081 | cap_tsf_params.tsf_rsp_cb_func = hdd_tsf_cb; |
| 18082 | cap_tsf_params.tsf_rsp_cb_ctx = adapter; |
| 18083 | |
| 18084 | vos_spin_lock_acquire(&adapter->tsf_cap_ctx.tsf_lock); |
| 18085 | adapter->tsf_cap_ctx.tsf_capture_state = TSF_CAP_STATE; |
| 18086 | adapter->tsf_cap_ctx.tsf_get_state = TSF_CURRENT_IN_CAP_STATE; |
| 18087 | vos_spin_lock_release(&adapter->tsf_cap_ctx.tsf_lock); |
| 18088 | |
| 18089 | ret = sme_capture_tsf_req(hdd_ctx->hHal, cap_tsf_params); |
| 18090 | |
| 18091 | if (ret != VOS_STATUS_SUCCESS) { |
| 18092 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("capture fail")); |
| 18093 | buf[0] = TSF_CAPTURE_FAIL; |
| 18094 | vos_spin_lock_acquire(&adapter->tsf_cap_ctx.tsf_lock); |
| 18095 | adapter->tsf_cap_ctx.tsf_capture_state = TSF_IDLE; |
| 18096 | vos_spin_lock_release(&adapter->tsf_cap_ctx.tsf_lock); |
| 18097 | return -EINVAL; |
| 18098 | } |
| 18099 | /* wait till we get a response from fw */ |
| 18100 | status = vos_wait_single_event(&adapter->tsf_cap_ctx. |
| 18101 | tsf_capture_done_event, |
| 18102 | HDD_TSF_CAP_REQ_TIMEOUT); |
| 18103 | |
| 18104 | if (!VOS_IS_STATUS_SUCCESS(status)) { |
| 18105 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 18106 | ("capture tsf vos wait for single_event failed!! %d"), |
| 18107 | adapter->tsf_cap_ctx.tsf_get_state); |
| 18108 | |
| 18109 | vos_spin_lock_acquire(&adapter->tsf_cap_ctx.tsf_lock); |
| 18110 | adapter->tsf_cap_ctx.tsf_capture_state = TSF_IDLE; |
| 18111 | vos_spin_lock_release(&adapter->tsf_cap_ctx.tsf_lock); |
| 18112 | |
| 18113 | return -EINVAL; |
| 18114 | } |
| 18115 | } |
| 18116 | buf[0] = TSF_RETURN; |
| 18117 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 18118 | FL("ioctl return cap tsf cmd, ret = %d"), ret); |
| 18119 | return ret; |
| 18120 | } |
| 18121 | |
| 18122 | /** |
| 18123 | * hdd_indicate_tsf() - return tsf to uplayer |
| 18124 | * |
| 18125 | * @adapter: pointer to adapter |
| 18126 | * @buf: pointer to uplayer buf |
| 18127 | * @len : the length of buf |
| 18128 | * |
| 18129 | * This function returns tsf value to uplayer. |
| 18130 | * |
| 18131 | * Return: Describe the execute result of this routine |
| 18132 | */ |
| 18133 | int hdd_indicate_tsf(hdd_adapter_t *adapter, uint32_t *buf, int len) |
| 18134 | { |
| 18135 | int ret = 0; |
| 18136 | hdd_station_ctx_t *hdd_sta_ctx; |
| 18137 | hdd_context_t *hdd_ctx; |
| 18138 | tSirCapTsfParams cap_tsf_params; |
| 18139 | VOS_STATUS status; |
| 18140 | |
| 18141 | if (adapter == NULL || buf == NULL) { |
| 18142 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 18143 | FL("invalid pointer")); |
| 18144 | return -EINVAL; |
| 18145 | } |
| 18146 | if (len != 3) |
| 18147 | return -EINVAL; |
| 18148 | |
| 18149 | buf [1] = 0; |
| 18150 | buf [2] = 0; |
| 18151 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 18152 | |
| 18153 | if (wlan_hdd_validate_context(hdd_ctx)) { |
| 18154 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 18155 | FL("invalid hdd ctx")); |
| 18156 | return -EINVAL; |
| 18157 | } |
| 18158 | if (adapter->device_mode == WLAN_HDD_INFRA_STATION || |
| 18159 | adapter->device_mode == WLAN_HDD_P2P_CLIENT) { |
| 18160 | hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 18161 | if (hdd_sta_ctx->conn_info.connState != |
| 18162 | eConnectionState_Associated) { |
| 18163 | |
| 18164 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 18165 | FL("failed to cap tsf, not connect with ap")); |
| 18166 | buf[0] = TSF_STA_NOT_CONNECTED_NO_TSF; |
| 18167 | return ret; |
| 18168 | } |
| 18169 | } |
| 18170 | if ((adapter->device_mode == WLAN_HDD_SOFTAP || |
| 18171 | adapter->device_mode == WLAN_HDD_P2P_GO) && |
| 18172 | !(test_bit(SOFTAP_BSS_STARTED, &adapter->event_flags))) { |
| 18173 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 18174 | FL("Soft AP / P2p GO not beaconing")); |
| 18175 | buf[0] = TSF_SAP_NOT_STARTED_NO_TSF; |
| 18176 | return ret; |
| 18177 | } |
| 18178 | |
| 18179 | if (adapter->tsf_cap_ctx.tsf_capture_state != TSF_CAP_STATE || |
| 18180 | adapter->tsf_cap_ctx.tsf_get_state != TSF_CURRENT_IN_CAP_STATE ) { |
| 18181 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 18182 | FL("Not in capture state,Enter capture state first")); |
| 18183 | buf[0] = TSF_GET_FAIL; |
| 18184 | } else { |
| 18185 | hddLog(VOS_TRACE_LEVEL_INFO, FL("ioctl issue cap tsf cmd")); |
| 18186 | cap_tsf_params.session_id = adapter->sessionId; |
| 18187 | cap_tsf_params.tsf_rsp_cb_func = hdd_tsf_cb; |
| 18188 | cap_tsf_params.tsf_rsp_cb_ctx = adapter; |
| 18189 | |
| 18190 | ret = sme_get_tsf_req(hdd_ctx->hHal, cap_tsf_params); |
| 18191 | |
| 18192 | if (ret != VOS_STATUS_SUCCESS) { |
| 18193 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("capture fail")); |
| 18194 | buf[0] = TSF_CAPTURE_FAIL; |
| 18195 | vos_spin_lock_acquire(&adapter->tsf_cap_ctx.tsf_lock); |
| 18196 | adapter->tsf_cap_ctx.tsf_capture_state = TSF_IDLE; |
| 18197 | vos_spin_lock_release(&adapter->tsf_cap_ctx.tsf_lock); |
| 18198 | return -EINVAL; |
| 18199 | } |
| 18200 | /* wait till we get a response from fw */ |
| 18201 | status = vos_wait_single_event(&adapter->tsf_cap_ctx. |
| 18202 | tsf_capture_done_event, |
| 18203 | HDD_TSF_GET_REQ_TIMEOUT); |
| 18204 | |
| 18205 | if (!VOS_IS_STATUS_SUCCESS(status)) { |
| 18206 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 18207 | ("capture tsf vos wait for single_event failed!! %d"), |
| 18208 | status); |
| 18209 | |
| 18210 | vos_spin_lock_acquire(&adapter->tsf_cap_ctx.tsf_lock); |
| 18211 | adapter->tsf_cap_ctx.tsf_capture_state = TSF_IDLE; |
| 18212 | vos_spin_lock_release(&adapter->tsf_cap_ctx.tsf_lock); |
| 18213 | return status; |
| 18214 | } |
| 18215 | buf[1] = adapter->tsf_cap_ctx.tsf_low; |
| 18216 | buf[2] = adapter->tsf_cap_ctx.tsf_high; |
| 18217 | |
| 18218 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 18219 | FL("get tsf cmd,status=%u, tsf_low=%u, tsf_high=%u"), |
| 18220 | buf[0], buf[1], buf[2]); |
| 18221 | } |
| 18222 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 18223 | FL("ioctl return cap tsf cmd, ret = %d"), ret); |
| 18224 | return ret; |
| 18225 | } |
| 18226 | |
| 18227 | void wlan_hdd_tsf_init(hdd_adapter_t *adapter) |
| 18228 | { |
| 18229 | |
| 18230 | if (adapter == NULL) { |
| 18231 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 18232 | FL("TSF init on a null adapter!")); |
| 18233 | return; |
| 18234 | } |
| 18235 | |
| 18236 | adapter->tsf_cap_ctx.tsf_get_state = TSF_RETURN; |
| 18237 | adapter->tsf_cap_ctx.tsf_capture_state = TSF_IDLE; |
| 18238 | vos_event_init(&adapter->tsf_cap_ctx.tsf_capture_done_event); |
| 18239 | vos_spin_lock_init(&adapter->tsf_cap_ctx.tsf_lock); |
| 18240 | adapter->tsf_cap_ctx.tsf_high = 0; |
| 18241 | adapter->tsf_cap_ctx.tsf_low = 0; |
| 18242 | } |
| 18243 | |
| 18244 | #endif |
| 18245 | |
Hanumanth Reddy Pothula | 972e1df | 2018-06-14 13:33:47 +0530 | [diff] [blame] | 18246 | bool hdd_is_cli_iface_up(hdd_context_t *hdd_ctx) |
| 18247 | { |
| 18248 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
| 18249 | hdd_adapter_t *adapter; |
| 18250 | VOS_STATUS status; |
| 18251 | |
| 18252 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
| 18253 | while (NULL != adapter_node && VOS_STATUS_SUCCESS == status) { |
| 18254 | adapter = adapter_node->pAdapter; |
| 18255 | if ((adapter->device_mode == WLAN_HDD_INFRA_STATION || |
| 18256 | adapter->device_mode == WLAN_HDD_P2P_CLIENT) && |
| 18257 | test_bit(DEVICE_IFACE_OPENED, |
| 18258 | &adapter->event_flags)){ |
| 18259 | return true; |
| 18260 | } |
| 18261 | status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next); |
| 18262 | adapter_node = next; |
| 18263 | } |
| 18264 | |
| 18265 | return false; |
| 18266 | } |
| 18267 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 18268 | //Register the module init/exit functions |
| 18269 | module_init(hdd_module_init); |
| 18270 | module_exit(hdd_module_exit); |
| 18271 | |
| 18272 | MODULE_LICENSE("Dual BSD/GPL"); |
| 18273 | MODULE_AUTHOR("Qualcomm Atheros, Inc."); |
| 18274 | MODULE_DESCRIPTION("WLAN HOST DEVICE DRIVER"); |
| 18275 | |
Ashish Kumar Dhanotiya | fb3fd97 | 2018-04-30 12:46:52 +0530 | [diff] [blame] | 18276 | static const struct kernel_param_ops con_mode_ops = { |
| 18277 | .set = con_mode_handler, |
| 18278 | .get = param_get_int, |
| 18279 | }; |
| 18280 | |
| 18281 | static const struct kernel_param_ops fwpath_ops = { |
| 18282 | .set = fwpath_changed_handler, |
| 18283 | .get = param_get_string, |
| 18284 | }; |
| 18285 | |
Hanumanth Reddy Pothula | 9921987 | 2018-06-08 14:45:18 +0530 | [diff] [blame] | 18286 | #ifdef MODULE |
| 18287 | module_param(con_mode, int, 0); |
| 18288 | #else |
Ashish Kumar Dhanotiya | fb3fd97 | 2018-04-30 12:46:52 +0530 | [diff] [blame] | 18289 | module_param_cb(con_mode, &con_mode_ops, &con_mode, |
Madan Mohan Koyyalamudi | 2331c8a | 2012-09-18 18:14:48 -0700 | [diff] [blame] | 18290 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Hanumanth Reddy Pothula | 9921987 | 2018-06-08 14:45:18 +0530 | [diff] [blame] | 18291 | #endif |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 18292 | |
Ashish Kumar Dhanotiya | fb3fd97 | 2018-04-30 12:46:52 +0530 | [diff] [blame] | 18293 | module_param_cb(fwpath, &fwpath_ops, &fwpath, |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 18294 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Arif Hussain | 6655912 | 2013-11-21 10:11:40 -0800 | [diff] [blame] | 18295 | |
| 18296 | module_param(enable_dfs_chan_scan, int, |
| 18297 | S_IRUSR | S_IRGRP | S_IROTH); |
| 18298 | |
| 18299 | module_param(enable_11d, int, |
| 18300 | S_IRUSR | S_IRGRP | S_IROTH); |
| 18301 | |
| 18302 | module_param(country_code, charp, |
| 18303 | S_IRUSR | S_IRGRP | S_IROTH); |