Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1 | /* |
Jeff Johnson | d9f0860 | 2016-12-02 11:31:30 -0800 | [diff] [blame] | 2 | * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -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 | /* |
| 23 | * This file was originally distributed by Qualcomm Atheros, Inc. |
| 24 | * under proprietary terms before Copyright ownership was assigned |
| 25 | * to the Linux Foundation. |
| 26 | */ |
| 27 | |
| 28 | /** |
| 29 | * DOC: wlan_hdd_main.c |
| 30 | * |
| 31 | * WLAN Host Device Driver implementation |
| 32 | * |
| 33 | */ |
| 34 | |
| 35 | /* Include Files */ |
| 36 | #include <wlan_hdd_includes.h> |
| 37 | #include <cds_api.h> |
| 38 | #include <cds_sched.h> |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 39 | #include <linux/cpu.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 40 | #include <linux/etherdevice.h> |
| 41 | #include <linux/firmware.h> |
| 42 | #include <wlan_hdd_tx_rx.h> |
| 43 | #include <wni_api.h> |
| 44 | #include <wlan_hdd_cfg.h> |
| 45 | #include <wlan_ptt_sock_svc.h> |
| 46 | #include <dbglog_host.h> |
| 47 | #include <wlan_logging_sock_svc.h> |
| 48 | #include <wlan_hdd_wowl.h> |
| 49 | #include <wlan_hdd_misc.h> |
| 50 | #include <wlan_hdd_wext.h> |
| 51 | #include "wlan_hdd_trace.h" |
| 52 | #include "wlan_hdd_ioctl.h" |
| 53 | #include "wlan_hdd_ftm.h" |
| 54 | #include "wlan_hdd_power.h" |
| 55 | #include "wlan_hdd_stats.h" |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 56 | #include "wlan_hdd_scan.h" |
Jeff Johnson | ce0032c | 2017-01-20 07:18:27 -0800 | [diff] [blame] | 57 | #include "wlan_hdd_request_manager.h" |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 58 | #include "qdf_types.h" |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 59 | #include "qdf_trace.h" |
Manjunathappa Prakash | 3454fd6 | 2016-04-01 08:52:06 -0700 | [diff] [blame] | 60 | #include <cdp_txrx_peer_ops.h> |
Dhanashri Atre | a8f82f2 | 2017-01-23 12:58:24 -0800 | [diff] [blame] | 61 | #include <cdp_txrx_misc.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 62 | |
| 63 | #include <net/addrconf.h> |
| 64 | #include <linux/wireless.h> |
| 65 | #include <net/cfg80211.h> |
| 66 | #include <linux/inetdevice.h> |
| 67 | #include <net/addrconf.h> |
| 68 | #include "wlan_hdd_cfg80211.h" |
| 69 | #include "wlan_hdd_ext_scan.h" |
| 70 | #include "wlan_hdd_p2p.h" |
| 71 | #include <linux/rtnetlink.h> |
| 72 | #include "sap_api.h" |
| 73 | #include <linux/semaphore.h> |
| 74 | #include <linux/ctype.h> |
| 75 | #include <linux/compat.h> |
| 76 | #ifdef MSM_PLATFORM |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 77 | #include <soc/qcom/subsystem_restart.h> |
| 78 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 79 | #include <wlan_hdd_hostapd.h> |
| 80 | #include <wlan_hdd_softap_tx_rx.h> |
| 81 | #include "cfg_api.h" |
| 82 | #include "qwlan_version.h" |
| 83 | #include "wma_types.h" |
| 84 | #include "wlan_hdd_tdls.h" |
| 85 | #ifdef FEATURE_WLAN_CH_AVOID |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 86 | #include "cds_regdomain.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 87 | #endif /* FEATURE_WLAN_CH_AVOID */ |
Dustin Brown | ce46d1d | 2017-08-15 13:34:24 -0700 | [diff] [blame] | 88 | #include "cdp_txrx_flow_ctrl_v2.h" |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 89 | #include "pld_common.h" |
Tushnim Bhattacharyya | 15596cf | 2016-02-12 11:57:02 -0800 | [diff] [blame] | 90 | #include "wlan_hdd_ocb.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 91 | #include "wlan_hdd_nan.h" |
| 92 | #include "wlan_hdd_debugfs.h" |
| 93 | #include "wlan_hdd_driver_ops.h" |
| 94 | #include "epping_main.h" |
| 95 | #include "wlan_hdd_memdump.h" |
| 96 | |
| 97 | #include <wlan_hdd_ipa.h> |
| 98 | #include "hif.h" |
| 99 | #include "wma.h" |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 100 | #include "wlan_policy_mgr_api.h" |
Manikandan Mohan | dcc21ba | 2016-03-15 14:31:56 -0700 | [diff] [blame] | 101 | #include "wlan_hdd_tsf.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 102 | #include "wlan_hdd_green_ap.h" |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 103 | #include "bmi.h" |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 104 | #include <wlan_hdd_regulatory.h> |
Jeff Johnson | 2b0a7b8 | 2016-05-18 15:08:02 -0700 | [diff] [blame] | 105 | #include "wlan_hdd_lpass.h" |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 106 | #include "nan_api.h" |
Orhan K AKYILDIZ | 1481aff | 2016-05-16 12:40:13 -0700 | [diff] [blame] | 107 | #include <wlan_hdd_napi.h> |
Padma, Santhosh Kumar | d7cc079 | 2016-06-28 18:54:12 +0530 | [diff] [blame] | 108 | #include "wlan_hdd_disa.h" |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 109 | #include <dispatcher_init_deinit.h> |
Rajeev Kumar | 699debf | 2017-01-06 14:17:00 -0800 | [diff] [blame] | 110 | #include "wlan_hdd_object_manager.h" |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 111 | #include "cds_utils.h" |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 112 | #include <cdp_txrx_handle.h> |
Sandeep Puligilla | fdd201e | 2017-02-02 18:43:46 -0800 | [diff] [blame] | 113 | #include <qca_vendor.h> |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 114 | #include "wlan_pmo_ucfg_api.h" |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 115 | #include "sir_api.h" |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 116 | #include "os_if_wifi_pos.h" |
| 117 | #include "wifi_pos_api.h" |
| 118 | #include "wlan_hdd_oemdata.h" |
Krishna Kumaar Natarajan | 4f1d772 | 2017-03-03 21:12:51 -0800 | [diff] [blame] | 119 | #include "wlan_hdd_he.h" |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 120 | #include "os_if_nan.h" |
| 121 | #include "nan_public_structs.h" |
Kiran Kumar Lokere | 3beeb95 | 2017-05-02 18:40:24 -0700 | [diff] [blame] | 122 | #include "wlan_reg_ucfg_api.h" |
Ravi Joshi | 4f09595 | 2017-06-29 15:39:19 -0700 | [diff] [blame] | 123 | #include "wlan_hdd_rx_monitor.h" |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 124 | #include "sme_power_save_api.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 125 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 126 | #ifdef CNSS_GENL |
| 127 | #include <net/cnss_nl.h> |
| 128 | #endif |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 129 | #include "wlan_reg_ucfg_api.h" |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 130 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 131 | #ifdef MODULE |
| 132 | #define WLAN_MODULE_NAME module_name(THIS_MODULE) |
| 133 | #else |
| 134 | #define WLAN_MODULE_NAME "wlan" |
| 135 | #endif |
| 136 | |
| 137 | #ifdef TIMER_MANAGER |
| 138 | #define TIMER_MANAGER_STR " +TIMER_MANAGER" |
| 139 | #else |
| 140 | #define TIMER_MANAGER_STR "" |
| 141 | #endif |
| 142 | |
| 143 | #ifdef MEMORY_DEBUG |
| 144 | #define MEMORY_DEBUG_STR " +MEMORY_DEBUG" |
| 145 | #else |
| 146 | #define MEMORY_DEBUG_STR "" |
| 147 | #endif |
| 148 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 149 | int wlan_start_ret_val; |
| 150 | static DECLARE_COMPLETION(wlan_start_comp); |
| 151 | static unsigned int dev_num = 1; |
| 152 | static struct cdev wlan_hdd_state_cdev; |
| 153 | static struct class *class; |
| 154 | static dev_t device; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 155 | #ifndef MODULE |
| 156 | static struct gwlan_loader *wlan_loader; |
| 157 | static ssize_t wlan_boot_cb(struct kobject *kobj, |
| 158 | struct kobj_attribute *attr, |
| 159 | const char *buf, size_t count); |
| 160 | struct gwlan_loader { |
| 161 | bool loaded_state; |
| 162 | struct kobject *boot_wlan_obj; |
| 163 | struct attribute_group *attr_group; |
| 164 | }; |
| 165 | |
| 166 | static struct kobj_attribute wlan_boot_attribute = |
| 167 | __ATTR(boot_wlan, 0220, NULL, wlan_boot_cb); |
| 168 | |
| 169 | static struct attribute *attrs[] = { |
| 170 | &wlan_boot_attribute.attr, |
| 171 | NULL, |
| 172 | }; |
| 173 | |
| 174 | #define MODULE_INITIALIZED 1 |
| 175 | #endif |
| 176 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 177 | #define HDD_OPS_INACTIVITY_TIMEOUT (120000) |
| 178 | #define MAX_OPS_NAME_STRING_SIZE 20 |
| 179 | |
| 180 | static qdf_timer_t hdd_drv_ops_inactivity_timer; |
| 181 | static char drv_ops_string[MAX_OPS_NAME_STRING_SIZE]; |
| 182 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 183 | /* the Android framework expects this param even though we don't use it */ |
| 184 | #define BUF_LEN 20 |
| 185 | static char fwpath_buffer[BUF_LEN]; |
| 186 | static struct kparam_string fwpath = { |
| 187 | .string = fwpath_buffer, |
| 188 | .maxlen = BUF_LEN, |
| 189 | }; |
| 190 | |
| 191 | static char *country_code; |
| 192 | static int enable_11d = -1; |
| 193 | static int enable_dfs_chan_scan = -1; |
| 194 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 195 | /* |
| 196 | * spinlock for synchronizing asynchronous request/response |
| 197 | * (full description of use in wlan_hdd_main.h) |
| 198 | */ |
| 199 | DEFINE_SPINLOCK(hdd_context_lock); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 200 | DEFINE_MUTEX(hdd_init_deinit_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 201 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 202 | #define WLAN_NLINK_CESIUM 30 |
| 203 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 204 | static qdf_wake_lock_t wlan_wake_lock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 205 | |
| 206 | #define WOW_MAX_FILTER_LISTS 1 |
| 207 | #define WOW_MAX_FILTERS_PER_LIST 4 |
| 208 | #define WOW_MIN_PATTERN_SIZE 6 |
| 209 | #define WOW_MAX_PATTERN_SIZE 64 |
| 210 | |
| 211 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 212 | static const struct wiphy_wowlan_support wowlan_support_reg_init = { |
| 213 | .flags = WIPHY_WOWLAN_ANY | |
| 214 | WIPHY_WOWLAN_MAGIC_PKT | |
| 215 | WIPHY_WOWLAN_DISCONNECT | |
| 216 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 217 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 218 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 219 | WIPHY_WOWLAN_4WAY_HANDSHAKE | |
| 220 | WIPHY_WOWLAN_RFKILL_RELEASE, |
| 221 | .n_patterns = WOW_MAX_FILTER_LISTS * WOW_MAX_FILTERS_PER_LIST, |
| 222 | .pattern_min_len = WOW_MIN_PATTERN_SIZE, |
| 223 | .pattern_max_len = WOW_MAX_PATTERN_SIZE, |
| 224 | }; |
| 225 | #endif |
| 226 | |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 227 | static const struct category_info cinfo[MAX_SUPPORTED_CATEGORY] = { |
| 228 | [QDF_MODULE_ID_TLSHIM] = {QDF_TRACE_LEVEL_ALL}, |
| 229 | [QDF_MODULE_ID_WMI] = {QDF_TRACE_LEVEL_ALL}, |
| 230 | [QDF_MODULE_ID_HTT] = {QDF_TRACE_LEVEL_ALL}, |
| 231 | [QDF_MODULE_ID_HDD] = {QDF_TRACE_LEVEL_ALL}, |
| 232 | [QDF_MODULE_ID_SME] = {QDF_TRACE_LEVEL_ALL}, |
| 233 | [QDF_MODULE_ID_PE] = {QDF_TRACE_LEVEL_ALL}, |
| 234 | [QDF_MODULE_ID_WMA] = {QDF_TRACE_LEVEL_ALL}, |
| 235 | [QDF_MODULE_ID_SYS] = {QDF_TRACE_LEVEL_ALL}, |
| 236 | [QDF_MODULE_ID_QDF] = {QDF_TRACE_LEVEL_ALL}, |
| 237 | [QDF_MODULE_ID_SAP] = {QDF_TRACE_LEVEL_ALL}, |
| 238 | [QDF_MODULE_ID_HDD_SOFTAP] = {QDF_TRACE_LEVEL_ALL}, |
| 239 | [QDF_MODULE_ID_HDD_DATA] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 240 | [QDF_MODULE_ID_HDD_SAP_DATA] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 241 | [QDF_MODULE_ID_HIF] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 242 | [QDF_MODULE_ID_HTC] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 243 | [QDF_MODULE_ID_TXRX] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 244 | [QDF_MODULE_ID_QDF_DEVICE] = {QDF_TRACE_LEVEL_ALL}, |
| 245 | [QDF_MODULE_ID_CFG] = {QDF_TRACE_LEVEL_ALL}, |
| 246 | [QDF_MODULE_ID_BMI] = {QDF_TRACE_LEVEL_ALL}, |
| 247 | [QDF_MODULE_ID_EPPING] = {QDF_TRACE_LEVEL_ALL}, |
| 248 | [QDF_MODULE_ID_QVIT] = {QDF_TRACE_LEVEL_ALL}, |
| 249 | [QDF_MODULE_ID_DP] = {QDF_TRACE_LEVEL_ALL}, |
| 250 | [QDF_MODULE_ID_SOC] = {QDF_TRACE_LEVEL_ALL}, |
| 251 | [QDF_MODULE_ID_OS_IF] = {QDF_TRACE_LEVEL_ALL}, |
| 252 | [QDF_MODULE_ID_TARGET_IF] = {QDF_TRACE_LEVEL_ALL}, |
| 253 | [QDF_MODULE_ID_SCHEDULER] = {QDF_TRACE_LEVEL_ALL}, |
| 254 | [QDF_MODULE_ID_MGMT_TXRX] = {QDF_TRACE_LEVEL_ALL}, |
| 255 | [QDF_MODULE_ID_PMO] = {QDF_TRACE_LEVEL_ALL}, |
| 256 | [QDF_MODULE_ID_SCAN] = {QDF_TRACE_LEVEL_ALL}, |
| 257 | [QDF_MODULE_ID_POLICY_MGR] = {QDF_TRACE_LEVEL_ALL}, |
| 258 | [QDF_MODULE_ID_P2P] = {QDF_TRACE_LEVEL_ALL}, |
| 259 | [QDF_MODULE_ID_TDLS] = {QDF_TRACE_LEVEL_ALL}, |
| 260 | [QDF_MODULE_ID_REGULATORY] = {QDF_TRACE_LEVEL_ALL}, |
| 261 | [QDF_MODULE_ID_SERIALIZATION] = {QDF_TRACE_LEVEL_ALL}, |
Arif Hussain | fde76e7 | 2017-09-05 16:58:23 -0700 | [diff] [blame] | 262 | [QDF_MODULE_ID_DFS] = {QDF_TRACE_LEVEL_ALL}, |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 263 | }; |
| 264 | |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 265 | int limit_off_chan_tbl[HDD_MAX_AC][HDD_MAX_OFF_CHAN_ENTRIES] = { |
| 266 | { HDD_AC_BK_BIT, HDD_MAX_OFF_CHAN_TIME_FOR_BK }, |
| 267 | { HDD_AC_BE_BIT, HDD_MAX_OFF_CHAN_TIME_FOR_BE }, |
| 268 | { HDD_AC_VI_BIT, HDD_MAX_OFF_CHAN_TIME_FOR_VI }, |
| 269 | { HDD_AC_VO_BIT, HDD_MAX_OFF_CHAN_TIME_FOR_VO }, |
| 270 | }; |
| 271 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 272 | /* internal function declaration */ |
Ashish Kumar Dhanotiya | cf11bae | 2017-04-04 03:29:47 +0530 | [diff] [blame] | 273 | struct notifier_block hdd_netdev_notifier; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 274 | |
| 275 | struct sock *cesium_nl_srv_sock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 276 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 277 | static void wlan_hdd_auto_shutdown_cb(void); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 278 | #endif |
| 279 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 280 | void hdd_start_complete(int ret) |
| 281 | { |
| 282 | wlan_start_ret_val = ret; |
| 283 | |
| 284 | complete(&wlan_start_comp); |
| 285 | } |
| 286 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 287 | /** |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 288 | * hdd_set_rps_cpu_mask - set RPS CPU mask for interfaces |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 289 | * @hdd_ctx: pointer to struct hdd_context |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 290 | * |
| 291 | * Return: none |
| 292 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 293 | static void hdd_set_rps_cpu_mask(struct hdd_context *hdd_ctx) |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 294 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 295 | struct hdd_adapter *adapter; |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 296 | hdd_adapter_list_node_t *adapter_node, *next; |
| 297 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
| 298 | |
| 299 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
| 300 | while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) { |
| 301 | adapter = adapter_node->pAdapter; |
| 302 | if (NULL != adapter) |
| 303 | hdd_send_rps_ind(adapter); |
| 304 | status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next); |
| 305 | adapter_node = next; |
| 306 | } |
| 307 | } |
| 308 | |
| 309 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 310 | * wlan_hdd_txrx_pause_cb() - pause callback from txrx layer |
| 311 | * @vdev_id: vdev_id |
| 312 | * @action: action type |
| 313 | * @reason: reason type |
| 314 | * |
| 315 | * Return: none |
| 316 | */ |
| 317 | void wlan_hdd_txrx_pause_cb(uint8_t vdev_id, |
| 318 | enum netif_action_type action, enum netif_reason_type reason) |
| 319 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 320 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 321 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 322 | |
| 323 | if (!hdd_ctx) { |
| 324 | hdd_err("hdd ctx is NULL"); |
| 325 | return; |
| 326 | } |
| 327 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 328 | |
| 329 | wlan_hdd_netif_queue_control(adapter, action, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 330 | } |
| 331 | |
| 332 | /* |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 333 | * Store WLAN driver version and timestamp info in global variables such that |
| 334 | * crash debugger can extract them from driver debug symbol and crashdump for |
| 335 | * post processing |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 336 | */ |
| 337 | uint8_t g_wlan_driver_version[] = QWLAN_VERSIONSTR; |
Naveen Rawat | 9383625 | 2017-06-20 16:30:59 -0700 | [diff] [blame] | 338 | |
| 339 | #ifndef BUILD_TIMESTAMP |
| 340 | #define BUILD_TIMESTAMP "" |
| 341 | #endif |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 342 | uint8_t g_wlan_driver_timestamp[] = BUILD_TIMESTAMP; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 343 | |
| 344 | /** |
| 345 | * hdd_device_mode_to_string() - return string conversion of device mode |
| 346 | * @device_mode: device mode |
| 347 | * |
| 348 | * This utility function helps log string conversion of device mode. |
| 349 | * |
| 350 | * Return: string conversion of device mode, if match found; |
| 351 | * "Unknown" otherwise. |
| 352 | */ |
| 353 | const char *hdd_device_mode_to_string(uint8_t device_mode) |
| 354 | { |
| 355 | switch (device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 356 | CASE_RETURN_STRING(QDF_STA_MODE); |
| 357 | CASE_RETURN_STRING(QDF_SAP_MODE); |
| 358 | CASE_RETURN_STRING(QDF_P2P_CLIENT_MODE); |
| 359 | CASE_RETURN_STRING(QDF_P2P_GO_MODE); |
| 360 | CASE_RETURN_STRING(QDF_FTM_MODE); |
| 361 | CASE_RETURN_STRING(QDF_IBSS_MODE); |
| 362 | CASE_RETURN_STRING(QDF_P2P_DEVICE_MODE); |
| 363 | CASE_RETURN_STRING(QDF_OCB_MODE); |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 364 | CASE_RETURN_STRING(QDF_NDI_MODE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 365 | default: |
| 366 | return "Unknown"; |
| 367 | } |
| 368 | } |
| 369 | |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 370 | /** |
| 371 | * hdd_validate_channel_and_bandwidth() - Validate the channel-bandwidth combo |
| 372 | * @adapter: HDD adapter |
| 373 | * @chan_number: Channel number |
| 374 | * @chan_bw: Bandwidth |
| 375 | * |
| 376 | * Checks if the given bandwidth is valid for the given channel number. |
| 377 | * |
| 378 | * Return: 0 for success, non-zero for failure |
| 379 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 380 | int hdd_validate_channel_and_bandwidth(struct hdd_adapter *adapter, |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 381 | uint32_t chan_number, |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 382 | enum phy_ch_width chan_bw) |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 383 | { |
| 384 | uint8_t chan[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 385 | uint32_t len = WNI_CFG_VALID_CHANNEL_LIST_LEN, i; |
| 386 | bool found = false; |
| 387 | tHalHandle hal; |
| 388 | |
| 389 | hal = WLAN_HDD_GET_HAL_CTX(adapter); |
| 390 | if (!hal) { |
| 391 | hdd_err("Invalid HAL context"); |
| 392 | return -EINVAL; |
| 393 | } |
| 394 | |
| 395 | if (0 != sme_cfg_get_str(hal, WNI_CFG_VALID_CHANNEL_LIST, chan, &len)) { |
| 396 | hdd_err("No valid channel list"); |
| 397 | return -EOPNOTSUPP; |
| 398 | } |
| 399 | |
| 400 | for (i = 0; i < len; i++) { |
| 401 | if (chan[i] == chan_number) { |
| 402 | found = true; |
| 403 | break; |
| 404 | } |
| 405 | } |
| 406 | |
| 407 | if (found == false) { |
| 408 | hdd_err("Channel not in driver's valid channel list"); |
| 409 | return -EOPNOTSUPP; |
| 410 | } |
| 411 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 412 | if ((!WLAN_REG_IS_24GHZ_CH(chan_number)) && |
| 413 | (!WLAN_REG_IS_5GHZ_CH(chan_number))) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 414 | hdd_err("CH %d is not in 2.4GHz or 5GHz", chan_number); |
| 415 | return -EINVAL; |
| 416 | } |
| 417 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 418 | if (WLAN_REG_IS_24GHZ_CH(chan_number)) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 419 | if (chan_bw == CH_WIDTH_80MHZ) { |
| 420 | hdd_err("BW80 not possible in 2.4GHz band"); |
| 421 | return -EINVAL; |
| 422 | } |
| 423 | if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 14) && |
| 424 | (chan_bw != CH_WIDTH_MAX)) { |
| 425 | hdd_err("Only BW20 possible on channel 14"); |
| 426 | return -EINVAL; |
| 427 | } |
| 428 | } |
| 429 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 430 | if (WLAN_REG_IS_5GHZ_CH(chan_number)) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 431 | if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 165) && |
| 432 | (chan_bw != CH_WIDTH_MAX)) { |
| 433 | hdd_err("Only BW20 possible on channel 165"); |
| 434 | return -EINVAL; |
| 435 | } |
| 436 | } |
| 437 | |
| 438 | return 0; |
| 439 | } |
| 440 | |
Arunk Khandavalli | e1b3a38 | 2017-09-26 12:01:26 +0530 | [diff] [blame] | 441 | /** |
| 442 | * hdd_wait_for_recovery_completion() - Wait for cds recovery completion |
| 443 | * |
| 444 | * Block the unloading of the driver (or) interface up until the |
| 445 | * cds recovery is completed |
| 446 | * |
| 447 | * Return: true for recovery completion else false |
| 448 | */ |
| 449 | static bool hdd_wait_for_recovery_completion(void) |
| 450 | { |
| 451 | int retry = 0; |
| 452 | |
| 453 | /* Wait for recovery to complete */ |
| 454 | while (cds_is_driver_recovering()) { |
| 455 | if (retry == HDD_MOD_EXIT_SSR_MAX_RETRIES/2) |
| 456 | hdd_err("Recovery in progress; wait here!!!"); |
| 457 | msleep(1000); |
| 458 | if (retry++ == HDD_MOD_EXIT_SSR_MAX_RETRIES) { |
| 459 | hdd_err("SSR never completed, error"); |
| 460 | /* |
| 461 | * Trigger the bug_on in the internal builds, in the |
| 462 | * customer builds self-recovery will be enabled |
| 463 | * in those cases just return error. |
| 464 | */ |
| 465 | if (cds_is_self_recovery_enabled()) |
| 466 | return false; |
| 467 | QDF_BUG(0); |
| 468 | } |
| 469 | } |
| 470 | |
| 471 | hdd_info("Recovery completed successfully!"); |
| 472 | return true; |
| 473 | } |
| 474 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 475 | static int __hdd_netdev_notifier_call(struct notifier_block *nb, |
| 476 | unsigned long state, void *data) |
| 477 | { |
| 478 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 479 | struct netdev_notifier_info *dev_notif_info = data; |
| 480 | struct net_device *dev = dev_notif_info->dev; |
| 481 | #else |
| 482 | struct net_device *dev = data; |
| 483 | #endif |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 484 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 485 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 486 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 487 | ENTER_DEV(dev); |
| 488 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 489 | /* Make sure that this callback corresponds to our device. */ |
| 490 | if ((strncmp(dev->name, "wlan", 4)) && (strncmp(dev->name, "p2p", 3))) |
| 491 | return NOTIFY_DONE; |
| 492 | |
Samuel Ahn | c9c48ca | 2016-09-19 15:46:36 +0530 | [diff] [blame] | 493 | if ((adapter->magic != WLAN_HDD_ADAPTER_MAGIC) || |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 494 | (adapter->dev != dev)) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 495 | hdd_err("device adapter is not matching!!!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 496 | return NOTIFY_DONE; |
| 497 | } |
| 498 | |
| 499 | if (!dev->ieee80211_ptr) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 500 | hdd_err("ieee80211_ptr is NULL!!!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 501 | return NOTIFY_DONE; |
| 502 | } |
| 503 | |
| 504 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 505 | if (NULL == hdd_ctx) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 506 | hdd_err("HDD Context Null Pointer"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 507 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 508 | return NOTIFY_DONE; |
| 509 | } |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 510 | if (cds_is_driver_recovering() || cds_is_driver_in_bad_state()) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 511 | return NOTIFY_DONE; |
| 512 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 513 | hdd_debug("%s New Net Device State = %lu", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 514 | dev->name, state); |
| 515 | |
| 516 | switch (state) { |
| 517 | case NETDEV_REGISTER: |
| 518 | break; |
| 519 | |
| 520 | case NETDEV_UNREGISTER: |
| 521 | break; |
| 522 | |
| 523 | case NETDEV_UP: |
| 524 | sme_ch_avoid_update_req(hdd_ctx->hHal); |
| 525 | break; |
| 526 | |
| 527 | case NETDEV_DOWN: |
| 528 | break; |
| 529 | |
| 530 | case NETDEV_CHANGE: |
| 531 | if (true == adapter->isLinkUpSvcNeeded) |
| 532 | complete(&adapter->linkup_event_var); |
| 533 | break; |
| 534 | |
| 535 | case NETDEV_GOING_DOWN: |
| 536 | if (adapter->scan_info.mScanPending != false) { |
Abhishek Singh | 69ccb51 | 2017-04-25 11:58:16 +0530 | [diff] [blame] | 537 | wlan_abort_scan(hdd_ctx->hdd_pdev, INVAL_PDEV_ID, |
| 538 | adapter->sessionId, INVALID_SCAN_ID, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 539 | } else { |
hqu | eaa33ee | 2017-05-04 17:56:35 +0800 | [diff] [blame] | 540 | cds_flush_work(&adapter->scan_block_work); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 541 | hdd_debug("Scan is not Pending from user"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 542 | } |
| 543 | break; |
| 544 | |
| 545 | default: |
| 546 | break; |
| 547 | } |
| 548 | |
| 549 | return NOTIFY_DONE; |
| 550 | } |
| 551 | |
| 552 | /** |
| 553 | * hdd_netdev_notifier_call() - netdev notifier callback function |
| 554 | * @nb: pointer to notifier block |
| 555 | * @state: state |
| 556 | * @ndev: ndev pointer |
| 557 | * |
| 558 | * Return: 0 on success, error number otherwise. |
| 559 | */ |
| 560 | static int hdd_netdev_notifier_call(struct notifier_block *nb, |
| 561 | unsigned long state, |
| 562 | void *ndev) |
| 563 | { |
| 564 | int ret; |
| 565 | |
| 566 | cds_ssr_protect(__func__); |
| 567 | ret = __hdd_netdev_notifier_call(nb, state, ndev); |
| 568 | cds_ssr_unprotect(__func__); |
| 569 | |
| 570 | return ret; |
| 571 | } |
| 572 | |
| 573 | struct notifier_block hdd_netdev_notifier = { |
| 574 | .notifier_call = hdd_netdev_notifier_call, |
| 575 | }; |
| 576 | |
| 577 | /* variable to hold the insmod parameters */ |
| 578 | static int con_mode; |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 579 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 580 | static int con_mode_ftm; |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 581 | int con_mode_monitor; |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 582 | |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 583 | /* Variable to hold connection mode including module parameter con_mode */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 584 | static int curr_con_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 585 | |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 586 | /** |
| 587 | * hdd_map_nl_chan_width() - Map NL channel width to internal representation |
| 588 | * @ch_width: NL channel width |
| 589 | * |
| 590 | * Converts the NL channel width to the driver's internal representation |
| 591 | * |
| 592 | * Return: Converted channel width. In case of non matching NL channel width, |
| 593 | * CH_WIDTH_MAX will be returned. |
| 594 | */ |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 595 | enum phy_ch_width hdd_map_nl_chan_width(enum nl80211_chan_width ch_width) |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 596 | { |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 597 | uint8_t fw_ch_bw; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 598 | |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 599 | fw_ch_bw = wma_get_vht_ch_width(); |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 600 | switch (ch_width) { |
| 601 | case NL80211_CHAN_WIDTH_20_NOHT: |
| 602 | case NL80211_CHAN_WIDTH_20: |
| 603 | return CH_WIDTH_20MHZ; |
| 604 | case NL80211_CHAN_WIDTH_40: |
| 605 | return CH_WIDTH_40MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 606 | case NL80211_CHAN_WIDTH_80: |
| 607 | return CH_WIDTH_80MHZ; |
| 608 | case NL80211_CHAN_WIDTH_80P80: |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 609 | if (fw_ch_bw == WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ) |
| 610 | return CH_WIDTH_80P80MHZ; |
| 611 | else if (fw_ch_bw == WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ) |
| 612 | return CH_WIDTH_160MHZ; |
| 613 | else |
| 614 | return CH_WIDTH_80MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 615 | case NL80211_CHAN_WIDTH_160: |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 616 | if (fw_ch_bw >= WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ) |
| 617 | return CH_WIDTH_160MHZ; |
| 618 | else |
| 619 | return CH_WIDTH_80MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 620 | case NL80211_CHAN_WIDTH_5: |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 621 | return CH_WIDTH_5MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 622 | case NL80211_CHAN_WIDTH_10: |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 623 | return CH_WIDTH_10MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 624 | default: |
| 625 | hdd_err("Invalid channel width %d, setting to default", |
| 626 | ch_width); |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 627 | return CH_WIDTH_INVALID; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 628 | } |
| 629 | } |
| 630 | |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 631 | /* wlan_hdd_find_opclass() - Find operating class for a channel |
| 632 | * @hal: handler to HAL |
| 633 | * @channel: channel id |
| 634 | * @bw_offset: bandwidth offset |
| 635 | * |
| 636 | * Function invokes sme api to find the operating class |
| 637 | * |
| 638 | * Return: operating class |
| 639 | */ |
| 640 | uint8_t wlan_hdd_find_opclass(tHalHandle hal, uint8_t channel, |
| 641 | uint8_t bw_offset) |
| 642 | { |
| 643 | uint8_t opclass = 0; |
| 644 | |
| 645 | sme_get_opclass(hal, channel, bw_offset, &opclass); |
| 646 | return opclass; |
| 647 | } |
| 648 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 649 | /** |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 650 | * hdd_qdf_trace_enable() - configure initial QDF Trace enable |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 651 | * @module_id: Module whose trace level is being configured |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 652 | * @bitmask: Bitmask of log levels to be enabled |
| 653 | * |
| 654 | * Called immediately after the cfg.ini is read in order to configure |
| 655 | * the desired trace levels. |
| 656 | * |
| 657 | * Return: None |
| 658 | */ |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 659 | int hdd_qdf_trace_enable(QDF_MODULE_ID module_id, uint32_t bitmask) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 660 | { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 661 | QDF_TRACE_LEVEL level; |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 662 | int qdf_print_idx = -1; |
| 663 | int status = -1; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 664 | /* |
| 665 | * if the bitmask is the default value, then a bitmask was not |
| 666 | * specified in cfg.ini, so leave the logging level alone (it |
| 667 | * will remain at the "compiled in" default value) |
| 668 | */ |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 669 | if (CFG_QDF_TRACE_ENABLE_DEFAULT == bitmask) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 670 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 671 | |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 672 | qdf_print_idx = qdf_get_pidx(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 673 | |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 674 | /* a mask was specified. start by disabling all logging */ |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 675 | status = qdf_print_set_category_verbose(qdf_print_idx, module_id, |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 676 | QDF_TRACE_LEVEL_NONE, 0); |
| 677 | |
| 678 | if (QDF_STATUS_SUCCESS != status) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 679 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 680 | /* now cycle through the bitmask until all "set" bits are serviced */ |
Ashish Kumar Dhanotiya | 83f286b | 2017-09-15 19:52:58 +0530 | [diff] [blame] | 681 | level = QDF_TRACE_LEVEL_NONE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 682 | while (0 != bitmask) { |
| 683 | if (bitmask & 1) { |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 684 | status = qdf_print_set_category_verbose(qdf_print_idx, |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 685 | module_id, level, 1); |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 686 | if (QDF_STATUS_SUCCESS != status) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 687 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 688 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 689 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 690 | level++; |
| 691 | bitmask >>= 1; |
| 692 | } |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 693 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 694 | } |
| 695 | |
| 696 | /** |
Chris Guo | 1751acf | 2017-07-03 14:09:01 +0800 | [diff] [blame] | 697 | * wlan_hdd_validate_context_in_loading() - check the HDD context in loading |
| 698 | * @hdd_ctx: HDD context pointer |
| 699 | * |
| 700 | * Return: 0 if the context is valid. Error code otherwise |
| 701 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 702 | int wlan_hdd_validate_context_in_loading(struct hdd_context *hdd_ctx) |
Chris Guo | 1751acf | 2017-07-03 14:09:01 +0800 | [diff] [blame] | 703 | { |
| 704 | if (NULL == hdd_ctx || NULL == hdd_ctx->config) { |
| 705 | hdd_info("%pS HDD context is Null", (void *)_RET_IP_); |
| 706 | return -ENODEV; |
| 707 | } |
| 708 | |
| 709 | if (cds_is_driver_recovering()) { |
| 710 | hdd_info("%pS Recovery in Progress. State: 0x%x Ignore!!!", |
| 711 | (void *)_RET_IP_, cds_get_driver_state()); |
| 712 | return -EAGAIN; |
| 713 | } |
| 714 | |
| 715 | if (hdd_ctx->start_modules_in_progress || |
| 716 | hdd_ctx->stop_modules_in_progress) { |
| 717 | hdd_info("%pS Start/Stop Modules in progress. Ignore!!!", |
| 718 | (void *)_RET_IP_); |
| 719 | return -EAGAIN; |
| 720 | } |
| 721 | |
| 722 | return 0; |
| 723 | } |
| 724 | |
| 725 | |
| 726 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 727 | * wlan_hdd_validate_context() - check the HDD context |
| 728 | * @hdd_ctx: HDD context pointer |
| 729 | * |
| 730 | * Return: 0 if the context is valid. Error code otherwise |
| 731 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 732 | int wlan_hdd_validate_context(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 733 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 734 | if (NULL == hdd_ctx || NULL == hdd_ctx->config) { |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 735 | hdd_err("%pS HDD context is Null", (void *)_RET_IP_); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 736 | return -ENODEV; |
| 737 | } |
| 738 | |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 739 | if (cds_is_driver_recovering()) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 740 | hdd_debug("%pS Recovery in Progress. State: 0x%x Ignore!!!", |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 741 | (void *)_RET_IP_, cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 742 | return -EAGAIN; |
| 743 | } |
| 744 | |
Srinivas Girigowda | 576b235 | 2017-08-25 14:44:26 -0700 | [diff] [blame] | 745 | if (cds_is_load_or_unload_in_progress()) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 746 | return -EAGAIN; |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 747 | |
| 748 | if (hdd_ctx->start_modules_in_progress || |
| 749 | hdd_ctx->stop_modules_in_progress) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 750 | hdd_debug("%pS Start/Stop Modules in progress. Ignore!!!", |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 751 | (void *)_RET_IP_); |
| 752 | return -EAGAIN; |
| 753 | } |
| 754 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 755 | if (cds_is_driver_in_bad_state()) { |
| 756 | hdd_debug("%pS driver in bad State: 0x%x Ignore!!!", |
| 757 | (void *)_RET_IP_, cds_get_driver_state()); |
| 758 | return -ENODEV; |
| 759 | } |
| 760 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 761 | return 0; |
| 762 | } |
| 763 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 764 | int hdd_validate_adapter(struct hdd_adapter *adapter) |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 765 | { |
| 766 | if (!adapter) { |
| 767 | hdd_err("adapter is null"); |
| 768 | return -EINVAL; |
| 769 | } |
| 770 | |
| 771 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) { |
| 772 | hdd_err("bad adapter magic: 0x%x (should be 0x%x)", |
| 773 | adapter->magic, WLAN_HDD_ADAPTER_MAGIC); |
| 774 | return -EINVAL; |
| 775 | } |
| 776 | |
| 777 | if (!adapter->dev) { |
| 778 | hdd_err("adapter net_device is null"); |
| 779 | return -EINVAL; |
| 780 | } |
| 781 | |
| 782 | if (!(adapter->dev->flags & IFF_UP)) { |
| 783 | hdd_info("adapter net_device is not up"); |
| 784 | return -EAGAIN; |
| 785 | } |
| 786 | |
| 787 | if (adapter->sessionId == HDD_SESSION_ID_INVALID) { |
| 788 | hdd_info("adapter session is not open"); |
| 789 | return -EAGAIN; |
| 790 | } |
| 791 | |
| 792 | if (adapter->sessionId >= MAX_NUMBER_OF_ADAPTERS) { |
| 793 | hdd_err("bad adapter session Id: %u", adapter->sessionId); |
| 794 | return -EINVAL; |
| 795 | } |
| 796 | |
| 797 | return 0; |
| 798 | } |
| 799 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 800 | /** |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 801 | * wlan_hdd_validate_modules_state() - Check modules status |
| 802 | * @hdd_ctx: HDD context pointer |
| 803 | * |
| 804 | * Check's the driver module's state and returns true if the |
| 805 | * modules are enabled returns false if modules are closed. |
| 806 | * |
| 807 | * Return: True if modules are enabled or false. |
| 808 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 809 | bool wlan_hdd_validate_modules_state(struct hdd_context *hdd_ctx) |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 810 | { |
| 811 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 812 | if (hdd_ctx->driver_status != DRIVER_MODULES_ENABLED) { |
| 813 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 814 | hdd_notice("Modules not enabled, Present status: %d", |
| 815 | hdd_ctx->driver_status); |
| 816 | return false; |
| 817 | } |
| 818 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 819 | return true; |
| 820 | } |
| 821 | |
| 822 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 823 | * hdd_set_ibss_power_save_params() - update IBSS Power Save params to WMA. |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 824 | * @struct hdd_adapter Hdd adapter. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 825 | * |
| 826 | * This function sets the IBSS power save config parameters to WMA |
| 827 | * which will send it to firmware if FW supports IBSS power save |
| 828 | * before vdev start. |
| 829 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 830 | * Return: QDF_STATUS QDF_STATUS_SUCCESS on Success and QDF_STATUS_E_FAILURE |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 831 | * on failure. |
| 832 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 833 | QDF_STATUS hdd_set_ibss_power_save_params(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 834 | { |
| 835 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 836 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 837 | |
| 838 | if (hdd_ctx == NULL) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 839 | hdd_err("HDD context is null"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 840 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 841 | } |
| 842 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 843 | ret = sme_cli_set_command(adapter->sessionId, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 844 | WMA_VDEV_IBSS_SET_ATIM_WINDOW_SIZE, |
| 845 | hdd_ctx->config->ibssATIMWinSize, |
| 846 | VDEV_CMD); |
| 847 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 848 | hdd_err("WMA_VDEV_IBSS_SET_ATIM_WINDOW_SIZE failed %d", ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 849 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 850 | } |
| 851 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 852 | ret = sme_cli_set_command(adapter->sessionId, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 853 | WMA_VDEV_IBSS_SET_POWER_SAVE_ALLOWED, |
| 854 | hdd_ctx->config->isIbssPowerSaveAllowed, |
| 855 | VDEV_CMD); |
| 856 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 857 | hdd_err("WMA_VDEV_IBSS_SET_POWER_SAVE_ALLOWED failed %d", |
| 858 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 859 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 860 | } |
| 861 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 862 | ret = sme_cli_set_command(adapter->sessionId, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 863 | WMA_VDEV_IBSS_SET_POWER_COLLAPSE_ALLOWED, |
| 864 | hdd_ctx->config-> |
| 865 | isIbssPowerCollapseAllowed, VDEV_CMD); |
| 866 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 867 | hdd_err("WMA_VDEV_IBSS_SET_POWER_COLLAPSE_ALLOWED failed %d", |
| 868 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 869 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 870 | } |
| 871 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 872 | ret = sme_cli_set_command(adapter->sessionId, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 873 | WMA_VDEV_IBSS_SET_AWAKE_ON_TX_RX, |
| 874 | hdd_ctx->config->isIbssAwakeOnTxRx, |
| 875 | VDEV_CMD); |
| 876 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 877 | hdd_err("WMA_VDEV_IBSS_SET_AWAKE_ON_TX_RX failed %d", ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 878 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 879 | } |
| 880 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 881 | ret = sme_cli_set_command(adapter->sessionId, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 882 | WMA_VDEV_IBSS_SET_INACTIVITY_TIME, |
| 883 | hdd_ctx->config->ibssInactivityCount, |
| 884 | VDEV_CMD); |
| 885 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 886 | hdd_err("WMA_VDEV_IBSS_SET_INACTIVITY_TIME failed %d", ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 887 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 888 | } |
| 889 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 890 | ret = sme_cli_set_command(adapter->sessionId, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 891 | WMA_VDEV_IBSS_SET_TXSP_END_INACTIVITY_TIME, |
| 892 | hdd_ctx->config->ibssTxSpEndInactivityTime, |
| 893 | VDEV_CMD); |
| 894 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 895 | hdd_err("WMA_VDEV_IBSS_SET_TXSP_END_INACTIVITY_TIME failed %d", |
| 896 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 897 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 898 | } |
| 899 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 900 | ret = sme_cli_set_command(adapter->sessionId, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 901 | WMA_VDEV_IBSS_PS_SET_WARMUP_TIME_SECS, |
| 902 | hdd_ctx->config->ibssPsWarmupTime, |
| 903 | VDEV_CMD); |
| 904 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 905 | hdd_err("WMA_VDEV_IBSS_PS_SET_WARMUP_TIME_SECS failed %d", |
| 906 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 907 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 908 | } |
| 909 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 910 | ret = sme_cli_set_command(adapter->sessionId, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 911 | WMA_VDEV_IBSS_PS_SET_1RX_CHAIN_IN_ATIM_WINDOW, |
| 912 | hdd_ctx->config->ibssPs1RxChainInAtimEnable, |
| 913 | VDEV_CMD); |
| 914 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 915 | hdd_err("WMA_VDEV_IBSS_PS_SET_1RX_CHAIN_IN_ATIM_WINDOW failed %d", |
| 916 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 917 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 918 | } |
| 919 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 920 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 921 | } |
| 922 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 923 | #define INTF_MACADDR_MASK 0x7 |
| 924 | |
| 925 | /** |
| 926 | * hdd_update_macaddr() - update mac address |
| 927 | * @config: hdd configuration |
| 928 | * @hw_macaddr: mac address |
| 929 | * |
| 930 | * Mac address for multiple virtual interface is found as following |
| 931 | * i) The mac address of the first interface is just the actual hw mac address. |
| 932 | * ii) MSM 3 or 4 bits of byte5 of the actual mac address are used to |
| 933 | * define the mac address for the remaining interfaces and locally |
| 934 | * admistered bit is set. INTF_MACADDR_MASK is based on the number of |
| 935 | * supported virtual interfaces, right now this is 0x07 (meaning 8 |
| 936 | * interface). |
| 937 | * Byte[3] of second interface will be hw_macaddr[3](bit5..7) + 1, |
| 938 | * for third interface it will be hw_macaddr[3](bit5..7) + 2, etc. |
| 939 | * |
| 940 | * Return: None |
| 941 | */ |
| 942 | void hdd_update_macaddr(struct hdd_config *config, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 943 | struct qdf_mac_addr hw_macaddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 944 | { |
| 945 | int8_t i; |
| 946 | uint8_t macaddr_b3, tmp_br3; |
| 947 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 948 | qdf_mem_copy(config->intfMacAddr[0].bytes, hw_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 949 | QDF_MAC_ADDR_SIZE); |
| 950 | for (i = 1; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 951 | qdf_mem_copy(config->intfMacAddr[i].bytes, hw_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 952 | QDF_MAC_ADDR_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 953 | macaddr_b3 = config->intfMacAddr[i].bytes[3]; |
| 954 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + i) & |
| 955 | INTF_MACADDR_MASK; |
| 956 | macaddr_b3 += tmp_br3; |
| 957 | |
| 958 | /* XOR-ing bit-24 of the mac address. This will give enough |
| 959 | * mac address range before collision |
| 960 | */ |
| 961 | macaddr_b3 ^= (1 << 7); |
| 962 | |
| 963 | /* Set locally administered bit */ |
| 964 | config->intfMacAddr[i].bytes[0] |= 0x02; |
| 965 | config->intfMacAddr[i].bytes[3] = macaddr_b3; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 966 | hdd_debug("config->intfMacAddr[%d]: " |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 967 | MAC_ADDRESS_STR, i, |
| 968 | MAC_ADDR_ARRAY(config->intfMacAddr[i].bytes)); |
| 969 | } |
| 970 | } |
| 971 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 972 | static void hdd_update_tgt_services(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 973 | struct wma_tgt_services *cfg) |
| 974 | { |
| 975 | struct hdd_config *config = hdd_ctx->config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 976 | |
| 977 | /* Set up UAPSD */ |
| 978 | config->apUapsdEnabled &= cfg->uapsd; |
| 979 | |
Krishna Kumaar Natarajan | 4f1d772 | 2017-03-03 21:12:51 -0800 | [diff] [blame] | 980 | /* 11AX mode support */ |
| 981 | if ((config->dot11Mode == eHDD_DOT11_MODE_11ax || |
| 982 | config->dot11Mode == eHDD_DOT11_MODE_11ax_ONLY) && !cfg->en_11ax) |
| 983 | config->dot11Mode = eHDD_DOT11_MODE_11ac; |
| 984 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 985 | /* 11AC mode support */ |
| 986 | if ((config->dot11Mode == eHDD_DOT11_MODE_11ac || |
| 987 | config->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY) && !cfg->en_11ac) |
| 988 | config->dot11Mode = eHDD_DOT11_MODE_AUTO; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 989 | |
| 990 | /* ARP offload: override user setting if invalid */ |
| 991 | config->fhostArpOffload &= cfg->arp_offload; |
| 992 | |
| 993 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 994 | /* PNO offload */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 995 | hdd_debug("PNO Capability in f/w = %d", cfg->pno_offload); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 996 | if (cfg->pno_offload) |
| 997 | config->PnoOffload = true; |
| 998 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 999 | #ifdef FEATURE_WLAN_TDLS |
| 1000 | config->fEnableTDLSSupport &= cfg->en_tdls; |
Manjeet Singh | fdd2ac7 | 2016-09-02 18:11:43 +0530 | [diff] [blame] | 1001 | config->fEnableTDLSOffChannel = config->fEnableTDLSOffChannel && |
| 1002 | cfg->en_tdls_offchan; |
| 1003 | config->fEnableTDLSBufferSta = config->fEnableTDLSBufferSta && |
| 1004 | cfg->en_tdls_uapsd_buf_sta; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 1005 | if (config->fTDLSUapsdMask && cfg->en_tdls_uapsd_sleep_sta) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1006 | config->fEnableTDLSSleepSta = true; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 1007 | else |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1008 | config->fEnableTDLSSleepSta = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1009 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1010 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
| 1011 | config->isRoamOffloadEnabled &= cfg->en_roam_offload; |
| 1012 | #endif |
Will Huang | 496b36c | 2017-07-11 16:38:50 +0800 | [diff] [blame] | 1013 | config->sap_get_peer_info &= cfg->get_peer_info_enabled; |
Krishna Kumaar Natarajan | 052c6e6 | 2015-09-28 15:32:55 -0700 | [diff] [blame] | 1014 | sme_update_tgt_services(hdd_ctx->hHal, cfg); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1015 | |
| 1016 | } |
| 1017 | |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1018 | /** |
| 1019 | * hdd_update_vdev_nss() - sets the vdev nss |
| 1020 | * @hdd_ctx: HDD context |
| 1021 | * |
| 1022 | * Sets the Nss per vdev type based on INI |
| 1023 | * |
| 1024 | * Return: None |
| 1025 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1026 | static void hdd_update_vdev_nss(struct hdd_context *hdd_ctx) |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1027 | { |
| 1028 | struct hdd_config *cfg_ini = hdd_ctx->config; |
| 1029 | uint8_t max_supp_nss = 1; |
| 1030 | |
Naveen Rawat | 10b1c15 | 2017-01-18 11:16:06 -0800 | [diff] [blame] | 1031 | if (cfg_ini->enable2x2 && !cds_is_sub_20_mhz_enabled()) |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1032 | max_supp_nss = 2; |
| 1033 | |
| 1034 | sme_update_vdev_type_nss(hdd_ctx->hHal, max_supp_nss, |
| 1035 | cfg_ini->vdev_type_nss_2g, eCSR_BAND_24); |
| 1036 | |
| 1037 | sme_update_vdev_type_nss(hdd_ctx->hHal, max_supp_nss, |
| 1038 | cfg_ini->vdev_type_nss_5g, eCSR_BAND_5G); |
| 1039 | } |
| 1040 | |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1041 | /** |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1042 | * hdd_update_wiphy_vhtcap() - Updates wiphy vhtcap fields |
| 1043 | * @hdd_ctx: HDD context |
| 1044 | * |
| 1045 | * Updates wiphy vhtcap fields |
| 1046 | * |
| 1047 | * Return: None |
| 1048 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1049 | static void hdd_update_wiphy_vhtcap(struct hdd_context *hdd_ctx) |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1050 | { |
| 1051 | struct ieee80211_supported_band *band_5g = |
| 1052 | hdd_ctx->wiphy->bands[NL80211_BAND_5GHZ]; |
| 1053 | uint32_t val; |
| 1054 | |
| 1055 | if (!band_5g) { |
| 1056 | hdd_debug("5GHz band disabled, skipping capability population"); |
| 1057 | return; |
| 1058 | } |
| 1059 | |
| 1060 | val = hdd_ctx->config->txBFCsnValue; |
| 1061 | band_5g->vht_cap.cap |= (val << IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT); |
| 1062 | |
| 1063 | val = NUM_OF_SOUNDING_DIMENSIONS; |
| 1064 | band_5g->vht_cap.cap |= |
| 1065 | (val << IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_SHIFT); |
| 1066 | |
| 1067 | hdd_info("Updated wiphy vhtcap:0x%x, CSNAntSupp:%d, NumSoundDim:%d", |
| 1068 | band_5g->vht_cap.cap, hdd_ctx->config->txBFCsnValue, val); |
| 1069 | } |
| 1070 | |
| 1071 | /** |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1072 | * hdd_update_hw_dbs_capable() - sets the dbs capability of the device |
| 1073 | * @hdd_ctx: HDD context |
| 1074 | * |
| 1075 | * Sets the DBS capability as per INI and firmware capability |
| 1076 | * |
| 1077 | * Return: None |
| 1078 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1079 | static void hdd_update_hw_dbs_capable(struct hdd_context *hdd_ctx) |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1080 | { |
| 1081 | struct hdd_config *cfg_ini = hdd_ctx->config; |
| 1082 | uint8_t hw_dbs_capable = 0; |
| 1083 | |
Tushnim Bhattacharyya | 49ed8ab | 2017-05-26 18:20:10 -0700 | [diff] [blame] | 1084 | if (policy_mgr_is_hw_dbs_capable(hdd_ctx->hdd_psoc) && |
| 1085 | ((cfg_ini->dual_mac_feature_disable == |
| 1086 | ENABLE_DBS_CXN_AND_SCAN) || |
| 1087 | (cfg_ini->dual_mac_feature_disable == |
| 1088 | ENABLE_DBS_CXN_AND_ENABLE_SCAN_WITH_ASYNC_SCAN_OFF))) |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1089 | hw_dbs_capable = 1; |
| 1090 | |
| 1091 | sme_update_hw_dbs_capable(hdd_ctx->hHal, hw_dbs_capable); |
| 1092 | } |
| 1093 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1094 | static void hdd_update_tgt_ht_cap(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1095 | struct wma_tgt_ht_cap *cfg) |
| 1096 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1097 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1098 | uint32_t value, val32; |
| 1099 | uint16_t val16; |
| 1100 | struct hdd_config *pconfig = hdd_ctx->config; |
| 1101 | tSirMacHTCapabilityInfo *phtCapInfo; |
| 1102 | uint8_t mcs_set[SIZE_OF_SUPPORTED_MCS_SET]; |
| 1103 | uint8_t enable_tx_stbc; |
| 1104 | |
| 1105 | /* check and update RX STBC */ |
| 1106 | if (pconfig->enableRxSTBC && !cfg->ht_rx_stbc) |
| 1107 | pconfig->enableRxSTBC = cfg->ht_rx_stbc; |
| 1108 | |
| 1109 | /* get the MPDU density */ |
| 1110 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_MPDU_DENSITY, &value); |
| 1111 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1112 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1113 | hdd_err("could not get MPDU DENSITY"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1114 | value = 0; |
| 1115 | } |
| 1116 | |
| 1117 | /* |
| 1118 | * MPDU density: |
| 1119 | * override user's setting if value is larger |
| 1120 | * than the one supported by target |
| 1121 | */ |
| 1122 | if (value > cfg->mpdu_density) { |
| 1123 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_MPDU_DENSITY, |
| 1124 | cfg->mpdu_density); |
| 1125 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1126 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1127 | hdd_err("could not set MPDU DENSITY to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1128 | } |
| 1129 | |
| 1130 | /* get the HT capability info */ |
| 1131 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_HT_CAP_INFO, &val32); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1132 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1133 | hdd_err("could not get HT capability info"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1134 | return; |
| 1135 | } |
| 1136 | val16 = (uint16_t) val32; |
| 1137 | phtCapInfo = (tSirMacHTCapabilityInfo *) &val16; |
| 1138 | |
| 1139 | /* Set the LDPC capability */ |
| 1140 | phtCapInfo->advCodingCap = cfg->ht_rx_ldpc; |
| 1141 | |
| 1142 | if (pconfig->ShortGI20MhzEnable && !cfg->ht_sgi_20) |
| 1143 | pconfig->ShortGI20MhzEnable = cfg->ht_sgi_20; |
| 1144 | |
| 1145 | if (pconfig->ShortGI40MhzEnable && !cfg->ht_sgi_40) |
| 1146 | pconfig->ShortGI40MhzEnable = cfg->ht_sgi_40; |
| 1147 | |
| 1148 | hdd_ctx->num_rf_chains = cfg->num_rf_chains; |
| 1149 | hdd_ctx->ht_tx_stbc_supported = cfg->ht_tx_stbc; |
| 1150 | |
| 1151 | enable_tx_stbc = pconfig->enableTxSTBC; |
| 1152 | |
| 1153 | if (pconfig->enable2x2 && (cfg->num_rf_chains == 2)) { |
| 1154 | pconfig->enable2x2 = 1; |
| 1155 | } else { |
| 1156 | pconfig->enable2x2 = 0; |
| 1157 | enable_tx_stbc = 0; |
| 1158 | |
| 1159 | /* 1x1 */ |
| 1160 | /* Update Rx Highest Long GI data Rate */ |
| 1161 | if (sme_cfg_set_int(hdd_ctx->hHal, |
| 1162 | WNI_CFG_VHT_RX_HIGHEST_SUPPORTED_DATA_RATE, |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1163 | VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1164 | == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1165 | hdd_err("Could not pass on WNI_CFG_VHT_RX_HIGHEST_SUPPORTED_DATA_RATE to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1166 | } |
| 1167 | |
| 1168 | /* Update Tx Highest Long GI data Rate */ |
| 1169 | if (sme_cfg_set_int |
| 1170 | (hdd_ctx->hHal, |
| 1171 | WNI_CFG_VHT_TX_HIGHEST_SUPPORTED_DATA_RATE, |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1172 | VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1) == |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1173 | QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1174 | hdd_err("VHT_TX_HIGHEST_SUPP_RATE_1_1 to CCM fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1175 | } |
| 1176 | } |
| 1177 | if (!(cfg->ht_tx_stbc && pconfig->enable2x2)) |
| 1178 | enable_tx_stbc = 0; |
| 1179 | phtCapInfo->txSTBC = enable_tx_stbc; |
| 1180 | |
| 1181 | val32 = val16; |
| 1182 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_HT_CAP_INFO, val32); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1183 | if (status != QDF_STATUS_SUCCESS) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1184 | hdd_err("could not set HT capability to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1185 | #define WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES 0xff |
| 1186 | value = SIZE_OF_SUPPORTED_MCS_SET; |
| 1187 | if (sme_cfg_get_str(hdd_ctx->hHal, WNI_CFG_SUPPORTED_MCS_SET, mcs_set, |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1188 | &value) == QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1189 | hdd_debug("Read MCS rate set"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1190 | |
| 1191 | if (pconfig->enable2x2) { |
| 1192 | for (value = 0; value < cfg->num_rf_chains; value++) |
| 1193 | mcs_set[value] = |
| 1194 | WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES; |
| 1195 | |
| 1196 | status = |
| 1197 | sme_cfg_set_str(hdd_ctx->hHal, |
| 1198 | WNI_CFG_SUPPORTED_MCS_SET, |
| 1199 | mcs_set, |
| 1200 | SIZE_OF_SUPPORTED_MCS_SET); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1201 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1202 | hdd_err("could not set MCS SET to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1203 | } |
| 1204 | } |
| 1205 | #undef WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES |
| 1206 | } |
| 1207 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1208 | static void hdd_update_tgt_vht_cap(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1209 | struct wma_tgt_vht_cap *cfg) |
| 1210 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1211 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1212 | uint32_t value = 0; |
| 1213 | struct hdd_config *pconfig = hdd_ctx->config; |
| 1214 | struct wiphy *wiphy = hdd_ctx->wiphy; |
| 1215 | struct ieee80211_supported_band *band_5g = |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 1216 | wiphy->bands[HDD_NL80211_BAND_5GHZ]; |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1217 | uint32_t temp = 0; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1218 | uint32_t ch_width = eHT_CHANNEL_WIDTH_80MHZ; |
jiad | 4a7a33c | 2017-08-08 15:32:24 +0800 | [diff] [blame] | 1219 | uint32_t hw_rx_ldpc_enabled; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1220 | |
Dustin Brown | 5e06bd3 | 2016-10-04 12:49:10 -0700 | [diff] [blame] | 1221 | if (!band_5g) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1222 | hdd_debug("5GHz band disabled, skipping capability population"); |
Dustin Brown | 5e06bd3 | 2016-10-04 12:49:10 -0700 | [diff] [blame] | 1223 | return; |
| 1224 | } |
| 1225 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1226 | /* Get the current MPDU length */ |
| 1227 | status = |
| 1228 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_MAX_MPDU_LENGTH, |
| 1229 | &value); |
| 1230 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1231 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1232 | hdd_err("could not get MPDU LENGTH"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1233 | value = 0; |
| 1234 | } |
| 1235 | |
| 1236 | /* |
| 1237 | * VHT max MPDU length: |
| 1238 | * override if user configured value is too high |
| 1239 | * that the target cannot support |
| 1240 | */ |
| 1241 | if (value > cfg->vht_max_mpdu) { |
| 1242 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1243 | WNI_CFG_VHT_MAX_MPDU_LENGTH, |
| 1244 | cfg->vht_max_mpdu); |
| 1245 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1246 | if (status == QDF_STATUS_E_FAILURE) |
| 1247 | hdd_err("could not set VHT MAX MPDU LENGTH"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1248 | } |
| 1249 | |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1250 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_BASIC_MCS_SET, &temp); |
| 1251 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtRxMCS; |
| 1252 | |
| 1253 | if (pconfig->enable2x2) |
| 1254 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtRxMCS2x2 << 2); |
| 1255 | |
| 1256 | if (sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_BASIC_MCS_SET, temp) == |
| 1257 | QDF_STATUS_E_FAILURE) { |
| 1258 | hdd_err("Could not pass VHT_BASIC_MCS_SET to CCM"); |
| 1259 | } |
| 1260 | |
| 1261 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_RX_MCS_MAP, &temp); |
| 1262 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtRxMCS; |
| 1263 | if (pconfig->enable2x2) |
| 1264 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtRxMCS2x2 << 2); |
| 1265 | |
| 1266 | if (sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_RX_MCS_MAP, temp) == |
| 1267 | QDF_STATUS_E_FAILURE) { |
| 1268 | hdd_err("Could not pass WNI_CFG_VHT_RX_MCS_MAP to CCM"); |
| 1269 | } |
| 1270 | |
| 1271 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_TX_MCS_MAP, &temp); |
| 1272 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtTxMCS; |
| 1273 | if (pconfig->enable2x2) |
| 1274 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtTxMCS2x2 << 2); |
| 1275 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1276 | hdd_debug("vhtRxMCS2x2 - %x temp - %u enable2x2 %d", |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1277 | pconfig->vhtRxMCS2x2, temp, pconfig->enable2x2); |
| 1278 | |
| 1279 | if (sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_TX_MCS_MAP, temp) == |
| 1280 | QDF_STATUS_E_FAILURE) { |
| 1281 | hdd_err("Could not pass WNI_CFG_VHT_TX_MCS_MAP to CCM"); |
| 1282 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1283 | /* Get the current RX LDPC setting */ |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1284 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_LDPC_CODING_CAP, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1285 | &value); |
| 1286 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1287 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1288 | hdd_err("could not get VHT LDPC CODING CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1289 | value = 0; |
| 1290 | } |
| 1291 | |
jiad | 4a7a33c | 2017-08-08 15:32:24 +0800 | [diff] [blame] | 1292 | /* Set HW RX LDPC capability */ |
| 1293 | hw_rx_ldpc_enabled = !!cfg->vht_rx_ldpc; |
| 1294 | if (hw_rx_ldpc_enabled != value) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1295 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1296 | WNI_CFG_VHT_LDPC_CODING_CAP, |
jiad | 4a7a33c | 2017-08-08 15:32:24 +0800 | [diff] [blame] | 1297 | hw_rx_ldpc_enabled); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1298 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1299 | if (status == QDF_STATUS_E_FAILURE) |
| 1300 | hdd_err("could not set VHT LDPC CODING CAP to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1301 | } |
| 1302 | |
| 1303 | /* Get current GI 80 value */ |
| 1304 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_SHORT_GI_80MHZ, |
| 1305 | &value); |
| 1306 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1307 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1308 | hdd_err("could not get SHORT GI 80MHZ"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1309 | value = 0; |
| 1310 | } |
| 1311 | |
| 1312 | /* set the Guard interval 80MHz */ |
| 1313 | if (value && !cfg->vht_short_gi_80) { |
| 1314 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1315 | WNI_CFG_VHT_SHORT_GI_80MHZ, |
| 1316 | cfg->vht_short_gi_80); |
| 1317 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1318 | if (status == QDF_STATUS_E_FAILURE) |
| 1319 | hdd_err("could not set SHORT GI 80MHZ to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1320 | } |
| 1321 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1322 | /* Get VHT TX STBC cap */ |
| 1323 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_TXSTBC, &value); |
| 1324 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1325 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1326 | hdd_err("could not get VHT TX STBC"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1327 | value = 0; |
| 1328 | } |
| 1329 | |
| 1330 | /* VHT TX STBC cap */ |
| 1331 | if (value && !cfg->vht_tx_stbc) { |
| 1332 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_TXSTBC, |
| 1333 | cfg->vht_tx_stbc); |
| 1334 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1335 | if (status == QDF_STATUS_E_FAILURE) |
| 1336 | hdd_err("could not set the VHT TX STBC to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1337 | } |
| 1338 | |
| 1339 | /* Get VHT RX STBC cap */ |
| 1340 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_RXSTBC, &value); |
| 1341 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1342 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1343 | hdd_err("could not get VHT RX STBC"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1344 | value = 0; |
| 1345 | } |
| 1346 | |
| 1347 | /* VHT RX STBC cap */ |
| 1348 | if (value && !cfg->vht_rx_stbc) { |
| 1349 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_RXSTBC, |
| 1350 | cfg->vht_rx_stbc); |
| 1351 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1352 | if (status == QDF_STATUS_E_FAILURE) |
| 1353 | hdd_err("could not set the VHT RX STBC to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1354 | } |
| 1355 | |
| 1356 | /* Get VHT SU Beamformer cap */ |
| 1357 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_SU_BEAMFORMER_CAP, |
| 1358 | &value); |
| 1359 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1360 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1361 | hdd_err("could not get VHT SU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1362 | value = 0; |
| 1363 | } |
| 1364 | |
| 1365 | /* set VHT SU Beamformer cap */ |
| 1366 | if (value && !cfg->vht_su_bformer) { |
| 1367 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1368 | WNI_CFG_VHT_SU_BEAMFORMER_CAP, |
| 1369 | cfg->vht_su_bformer); |
| 1370 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1371 | if (status == QDF_STATUS_E_FAILURE) |
| 1372 | hdd_err("could not set VHT SU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1373 | } |
| 1374 | |
| 1375 | /* check and update SU BEAMFORMEE capabality */ |
| 1376 | if (pconfig->enableTxBF && !cfg->vht_su_bformee) |
| 1377 | pconfig->enableTxBF = cfg->vht_su_bformee; |
| 1378 | |
| 1379 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1380 | WNI_CFG_VHT_SU_BEAMFORMEE_CAP, |
| 1381 | pconfig->enableTxBF); |
| 1382 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1383 | if (status == QDF_STATUS_E_FAILURE) |
| 1384 | hdd_err("could not set VHT SU BEAMFORMEE CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1385 | |
| 1386 | /* Get VHT MU Beamformer cap */ |
| 1387 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_MU_BEAMFORMER_CAP, |
| 1388 | &value); |
| 1389 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1390 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1391 | hdd_err("could not get VHT MU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1392 | value = 0; |
| 1393 | } |
| 1394 | |
| 1395 | /* set VHT MU Beamformer cap */ |
| 1396 | if (value && !cfg->vht_mu_bformer) { |
| 1397 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1398 | WNI_CFG_VHT_MU_BEAMFORMER_CAP, |
| 1399 | cfg->vht_mu_bformer); |
| 1400 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1401 | if (status == QDF_STATUS_E_FAILURE) |
| 1402 | hdd_err("could not set the VHT MU BEAMFORMER CAP to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1403 | } |
| 1404 | |
| 1405 | /* Get VHT MU Beamformee cap */ |
| 1406 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_MU_BEAMFORMEE_CAP, |
| 1407 | &value); |
| 1408 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1409 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1410 | hdd_err("could not get VHT MU BEAMFORMEE CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1411 | value = 0; |
| 1412 | } |
| 1413 | |
| 1414 | /* set VHT MU Beamformee cap */ |
| 1415 | if (value && !cfg->vht_mu_bformee) { |
| 1416 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1417 | WNI_CFG_VHT_MU_BEAMFORMEE_CAP, |
| 1418 | cfg->vht_mu_bformee); |
| 1419 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1420 | if (status == QDF_STATUS_E_FAILURE) |
| 1421 | hdd_err("could not set VHT MU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1422 | } |
| 1423 | |
| 1424 | /* Get VHT MAX AMPDU Len exp */ |
| 1425 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_AMPDU_LEN_EXPONENT, |
| 1426 | &value); |
| 1427 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1428 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1429 | hdd_err("could not get VHT AMPDU LEN"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1430 | value = 0; |
| 1431 | } |
| 1432 | |
| 1433 | /* |
| 1434 | * VHT max AMPDU len exp: |
| 1435 | * override if user configured value is too high |
| 1436 | * that the target cannot support. |
| 1437 | * Even though Rome publish ampdu_len=7, it can |
| 1438 | * only support 4 because of some h/w bug. |
| 1439 | */ |
| 1440 | |
| 1441 | if (value > cfg->vht_max_ampdu_len_exp) { |
| 1442 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1443 | WNI_CFG_VHT_AMPDU_LEN_EXPONENT, |
| 1444 | cfg->vht_max_ampdu_len_exp); |
| 1445 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1446 | if (status == QDF_STATUS_E_FAILURE) |
| 1447 | hdd_err("could not set the VHT AMPDU LEN EXP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1448 | } |
| 1449 | |
| 1450 | /* Get VHT TXOP PS CAP */ |
| 1451 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_TXOP_PS, &value); |
| 1452 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1453 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1454 | hdd_err("could not get VHT TXOP PS"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1455 | value = 0; |
| 1456 | } |
| 1457 | |
| 1458 | /* set VHT TXOP PS cap */ |
| 1459 | if (value && !cfg->vht_txop_ps) { |
| 1460 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_TXOP_PS, |
| 1461 | cfg->vht_txop_ps); |
| 1462 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1463 | if (status == QDF_STATUS_E_FAILURE) |
| 1464 | hdd_err("could not set the VHT TXOP PS"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1465 | } |
| 1466 | |
| 1467 | if (WMI_VHT_CAP_MAX_MPDU_LEN_11454 == cfg->vht_max_mpdu) |
| 1468 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454; |
| 1469 | else if (WMI_VHT_CAP_MAX_MPDU_LEN_7935 == cfg->vht_max_mpdu) |
| 1470 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991; |
| 1471 | else |
| 1472 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895; |
| 1473 | |
| 1474 | |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1475 | if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_80P80MHZ)) { |
| 1476 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1477 | WNI_CFG_VHT_SUPPORTED_CHAN_WIDTH_SET, |
| 1478 | VHT_CAP_160_AND_80P80_SUPP); |
| 1479 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1480 | hdd_err("could not set the VHT CAP 160"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1481 | band_5g->vht_cap.cap |= |
| 1482 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1483 | ch_width = eHT_CHANNEL_WIDTH_80P80MHZ; |
| 1484 | } else if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_160MHZ)) { |
| 1485 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1486 | WNI_CFG_VHT_SUPPORTED_CHAN_WIDTH_SET, |
| 1487 | VHT_CAP_160_SUPP); |
| 1488 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1489 | hdd_err("could not set the VHT CAP 160"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1490 | band_5g->vht_cap.cap |= |
| 1491 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1492 | ch_width = eHT_CHANNEL_WIDTH_160MHZ; |
| 1493 | } |
| 1494 | pconfig->vhtChannelWidth = QDF_MIN(pconfig->vhtChannelWidth, |
| 1495 | ch_width); |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1496 | /* Get the current GI 160 value */ |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1497 | status = sme_cfg_get_int(hdd_ctx->hHal, |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1498 | WNI_CFG_VHT_SHORT_GI_160_AND_80_PLUS_80MHZ, |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1499 | &value); |
| 1500 | if (status != QDF_STATUS_SUCCESS) { |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1501 | hdd_err("could not get GI 80 & 160"); |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1502 | value = 0; |
| 1503 | } |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1504 | /* set the Guard interval 160MHz */ |
| 1505 | if (value && !cfg->vht_short_gi_160) { |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1506 | status = sme_cfg_set_int(hdd_ctx->hHal, |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1507 | WNI_CFG_VHT_SHORT_GI_160_AND_80_PLUS_80MHZ, |
| 1508 | cfg->vht_short_gi_160); |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1509 | |
| 1510 | if (status == QDF_STATUS_E_FAILURE) |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1511 | hdd_err("failed to set SHORT GI 160MHZ"); |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1512 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1513 | |
| 1514 | if (cfg->vht_rx_ldpc & WMI_VHT_CAP_RX_LDPC) |
| 1515 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXLDPC; |
| 1516 | |
| 1517 | if (cfg->vht_short_gi_80 & WMI_VHT_CAP_SGI_80MHZ) |
| 1518 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_80; |
| 1519 | if (cfg->vht_short_gi_160 & WMI_VHT_CAP_SGI_160MHZ) |
| 1520 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_160; |
| 1521 | |
| 1522 | if (cfg->vht_tx_stbc & WMI_VHT_CAP_TX_STBC) |
| 1523 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_TXSTBC; |
| 1524 | |
| 1525 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_1SS) |
| 1526 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_1; |
| 1527 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_2SS) |
| 1528 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_2; |
| 1529 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_3SS) |
| 1530 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_3; |
| 1531 | |
| 1532 | band_5g->vht_cap.cap |= |
| 1533 | (cfg->vht_max_ampdu_len_exp << |
| 1534 | IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT); |
| 1535 | |
| 1536 | if (cfg->vht_su_bformer & WMI_VHT_CAP_SU_BFORMER) |
| 1537 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE; |
| 1538 | if (cfg->vht_su_bformee & WMI_VHT_CAP_SU_BFORMEE) |
| 1539 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE; |
| 1540 | if (cfg->vht_mu_bformer & WMI_VHT_CAP_MU_BFORMER) |
| 1541 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE; |
| 1542 | if (cfg->vht_mu_bformee & WMI_VHT_CAP_MU_BFORMEE) |
| 1543 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE; |
| 1544 | |
| 1545 | if (cfg->vht_txop_ps & WMI_VHT_CAP_TXOP_PS) |
| 1546 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_VHT_TXOP_PS; |
| 1547 | |
| 1548 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1549 | |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1550 | /** |
| 1551 | * hdd_generate_macaddr_auto() - Auto-generate mac address |
| 1552 | * @hdd_ctx: Pointer to the HDD context |
| 1553 | * |
| 1554 | * Auto-generate mac address using device serial number. |
| 1555 | * Keep the first 3 bytes of OUI as before and replace |
| 1556 | * the last 3 bytes with the lower 3 bytes of serial number. |
| 1557 | * |
| 1558 | * Return: 0 for success |
| 1559 | * Non zero failure code for errors |
| 1560 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1561 | static int hdd_generate_macaddr_auto(struct hdd_context *hdd_ctx) |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1562 | { |
| 1563 | unsigned int serialno = 0; |
| 1564 | struct qdf_mac_addr mac_addr = { |
| 1565 | {0x00, 0x0A, 0xF5, 0x00, 0x00, 0x00} |
| 1566 | }; |
| 1567 | |
Yuanyuan Liu | f97e822 | 2016-09-21 10:31:38 -0700 | [diff] [blame] | 1568 | serialno = pld_socinfo_get_serial_number(hdd_ctx->parent_dev); |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1569 | if (serialno == 0) |
| 1570 | return -EINVAL; |
| 1571 | |
| 1572 | serialno &= 0x00ffffff; |
| 1573 | |
| 1574 | mac_addr.bytes[3] = (serialno >> 16) & 0xff; |
| 1575 | mac_addr.bytes[4] = (serialno >> 8) & 0xff; |
| 1576 | mac_addr.bytes[5] = serialno & 0xff; |
| 1577 | |
| 1578 | hdd_update_macaddr(hdd_ctx->config, mac_addr); |
| 1579 | return 0; |
| 1580 | } |
| 1581 | |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1582 | /** |
| 1583 | * hdd_update_ra_rate_limit() - Update RA rate limit from target |
| 1584 | * configuration to cfg_ini in HDD |
| 1585 | * @hdd_ctx: Pointer to hdd_ctx |
| 1586 | * @cfg: target configuration |
| 1587 | * |
| 1588 | * Return: None |
| 1589 | */ |
| 1590 | #ifdef FEATURE_WLAN_RA_FILTERING |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1591 | static void hdd_update_ra_rate_limit(struct hdd_context *hdd_ctx, |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1592 | struct wma_tgt_cfg *cfg) |
| 1593 | { |
| 1594 | hdd_ctx->config->IsRArateLimitEnabled = cfg->is_ra_rate_limit_enabled; |
| 1595 | } |
| 1596 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1597 | static void hdd_update_ra_rate_limit(struct hdd_context *hdd_ctx, |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1598 | struct wma_tgt_cfg *cfg) |
| 1599 | { |
| 1600 | } |
| 1601 | #endif |
| 1602 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1603 | void hdd_update_tgt_cfg(void *context, void *param) |
| 1604 | { |
Rajeev Kumar | f49dfdb | 2017-01-13 15:40:35 -0800 | [diff] [blame] | 1605 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1606 | struct hdd_context *hdd_ctx = (struct hdd_context *) context; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1607 | struct wma_tgt_cfg *cfg = param; |
| 1608 | uint8_t temp_band_cap; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1609 | struct cds_config_info *cds_cfg = cds_get_ini_config(); |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 1610 | uint8_t antenna_mode; |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1611 | |
Yue Ma | e3e86ab | 2017-05-08 10:48:24 -0700 | [diff] [blame] | 1612 | /* Reuse same pdev for module start/stop or SSR */ |
Ashish Kumar Dhanotiya | fd758ec | 2017-08-04 12:03:18 +0530 | [diff] [blame] | 1613 | if (((hdd_get_conparam() == QDF_GLOBAL_FTM_MODE) || |
| 1614 | (hdd_get_conparam() == QDF_GLOBAL_MONITOR_MODE) || |
| 1615 | !cds_is_driver_loading()) && (hdd_ctx->hdd_pdev != NULL)) { |
| 1616 | hdd_debug("Reuse pdev for module start/stop or SSR pdev_id = %u", |
| 1617 | hdd_ctx->hdd_pdev->pdev_objmgr.wlan_pdev_id); |
Yue Ma | e3e86ab | 2017-05-08 10:48:24 -0700 | [diff] [blame] | 1618 | /* Restore pdev to MAC/WMA contexts */ |
| 1619 | sme_store_pdev(hdd_ctx->hHal, hdd_ctx->hdd_pdev); |
Sandeep Puligilla | 1cf6ebe | 2017-04-04 14:40:27 -0700 | [diff] [blame] | 1620 | } else { |
| 1621 | ret = hdd_objmgr_create_and_store_pdev(hdd_ctx); |
| 1622 | if (ret) { |
| 1623 | hdd_err("pdev creation fails!"); |
| 1624 | QDF_BUG(0); |
Ashish Kumar Dhanotiya | fd758ec | 2017-08-04 12:03:18 +0530 | [diff] [blame] | 1625 | } else |
| 1626 | hdd_debug("New pdev has been created with pdev_id = %u", |
| 1627 | hdd_ctx->hdd_pdev->pdev_objmgr.wlan_pdev_id); |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1628 | } |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 1629 | |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1630 | if (cds_cfg) { |
| 1631 | if (hdd_ctx->config->enable_sub_20_channel_width != |
| 1632 | WLAN_SUB_20_CH_WIDTH_NONE && !cfg->sub_20_support) { |
| 1633 | hdd_err("User requested sub 20 MHz channel width but unsupported by FW."); |
| 1634 | cds_cfg->sub_20_channel_width = |
| 1635 | WLAN_SUB_20_CH_WIDTH_NONE; |
| 1636 | } else { |
| 1637 | cds_cfg->sub_20_channel_width = |
| 1638 | hdd_ctx->config->enable_sub_20_channel_width; |
| 1639 | } |
| 1640 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1641 | |
| 1642 | /* first store the INI band capability */ |
| 1643 | temp_band_cap = hdd_ctx->config->nBandCapability; |
| 1644 | |
| 1645 | hdd_ctx->config->nBandCapability = cfg->band_cap; |
| 1646 | |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 1647 | /* |
| 1648 | * now overwrite the target band capability with INI |
| 1649 | * setting if INI setting is a subset |
| 1650 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1651 | |
| 1652 | if ((hdd_ctx->config->nBandCapability == eCSR_BAND_ALL) && |
| 1653 | (temp_band_cap != eCSR_BAND_ALL)) |
| 1654 | hdd_ctx->config->nBandCapability = temp_band_cap; |
| 1655 | else if ((hdd_ctx->config->nBandCapability != eCSR_BAND_ALL) && |
| 1656 | (temp_band_cap != eCSR_BAND_ALL) && |
| 1657 | (hdd_ctx->config->nBandCapability != temp_band_cap)) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1658 | hdd_warn("ini BandCapability not supported by the target"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1659 | } |
| 1660 | |
Amar Singhal | 58b45ef | 2017-08-01 13:43:54 -0700 | [diff] [blame] | 1661 | hdd_ctx->curr_band = hdd_ctx->config->nBandCapability; |
| 1662 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 1663 | if (!cds_is_driver_recovering() || cds_is_driver_in_bad_state()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1664 | hdd_ctx->reg.reg_domain = cfg->reg_domain; |
| 1665 | hdd_ctx->reg.eeprom_rd_ext = cfg->eeprom_rd_ext; |
| 1666 | } |
| 1667 | |
| 1668 | /* This can be extended to other configurations like ht, vht cap... */ |
| 1669 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 1670 | if (!qdf_is_macaddr_zero(&cfg->hw_macaddr)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1671 | hdd_update_macaddr(hdd_ctx->config, cfg->hw_macaddr); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 1672 | hdd_ctx->update_mac_addr_to_fw = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1673 | } else { |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1674 | static struct qdf_mac_addr default_mac_addr = { |
| 1675 | {0x00, 0x0A, 0xF5, 0x89, 0x89, 0xFF} |
| 1676 | }; |
| 1677 | if (qdf_is_macaddr_equal(&hdd_ctx->config->intfMacAddr[0], |
| 1678 | &default_mac_addr)) { |
| 1679 | if (hdd_generate_macaddr_auto(hdd_ctx) != 0) |
| 1680 | hdd_err("Fail to auto-generate MAC, using MAC from ini file " |
| 1681 | MAC_ADDRESS_STR, |
| 1682 | MAC_ADDR_ARRAY(hdd_ctx->config-> |
| 1683 | intfMacAddr[0].bytes)); |
| 1684 | } else { |
| 1685 | hdd_err("Invalid MAC passed from target, using MAC from ini file " |
| 1686 | MAC_ADDRESS_STR, |
| 1687 | MAC_ADDR_ARRAY(hdd_ctx->config-> |
| 1688 | intfMacAddr[0].bytes)); |
| 1689 | } |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 1690 | hdd_ctx->update_mac_addr_to_fw = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1691 | } |
| 1692 | |
| 1693 | hdd_ctx->target_fw_version = cfg->target_fw_version; |
Sandeep Puligilla | 3d6a8e2 | 2016-10-11 18:57:14 -0700 | [diff] [blame] | 1694 | hdd_ctx->target_fw_vers_ext = cfg->target_fw_vers_ext; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1695 | |
| 1696 | hdd_ctx->max_intf_count = cfg->max_intf_count; |
| 1697 | |
Jeff Johnson | c875e24 | 2016-09-23 18:12:34 -0700 | [diff] [blame] | 1698 | hdd_lpass_target_config(hdd_ctx, cfg); |
Jeff Johnson | a7e5eed | 2016-09-28 15:19:13 -0700 | [diff] [blame] | 1699 | hdd_green_ap_target_config(hdd_ctx, cfg); |
Ryan Hsu | 3c8f79f | 2015-12-02 16:45:09 -0800 | [diff] [blame] | 1700 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1701 | hdd_ctx->ap_arpns_support = cfg->ap_arpns_support; |
| 1702 | hdd_update_tgt_services(hdd_ctx, &cfg->services); |
| 1703 | |
| 1704 | hdd_update_tgt_ht_cap(hdd_ctx, &cfg->ht_cap); |
| 1705 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1706 | hdd_update_tgt_vht_cap(hdd_ctx, &cfg->vht_cap); |
Krishna Kumaar Natarajan | ed1efd9 | 2016-09-24 18:05:47 -0700 | [diff] [blame] | 1707 | if (cfg->services.en_11ax) { |
| 1708 | hdd_info("11AX: 11ax is enabled - update HDD config"); |
| 1709 | hdd_update_tgt_he_cap(hdd_ctx, cfg); |
| 1710 | } |
Tushnim Bhattacharyya | f44a9d8 | 2016-07-05 10:52:06 -0700 | [diff] [blame] | 1711 | |
| 1712 | hdd_update_vdev_nss(hdd_ctx); |
| 1713 | |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1714 | hdd_update_hw_dbs_capable(hdd_ctx); |
| 1715 | |
Krishna Kumaar Natarajan | 1ae4911 | 2015-11-24 21:43:22 -0800 | [diff] [blame] | 1716 | hdd_ctx->config->fine_time_meas_cap &= cfg->fine_time_measurement_cap; |
Krunal Soni | e353194 | 2016-04-12 17:43:53 -0700 | [diff] [blame] | 1717 | hdd_ctx->fine_time_meas_cap_target = cfg->fine_time_measurement_cap; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1718 | hdd_debug("fine_time_meas_cap: 0x%x", |
Krishna Kumaar Natarajan | 1ae4911 | 2015-11-24 21:43:22 -0800 | [diff] [blame] | 1719 | hdd_ctx->config->fine_time_meas_cap); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 1720 | |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 1721 | antenna_mode = (hdd_ctx->config->enable2x2 == 0x01) ? |
| 1722 | HDD_ANTENNA_MODE_2X2 : HDD_ANTENNA_MODE_1X1; |
| 1723 | hdd_update_smps_antenna_mode(hdd_ctx, antenna_mode); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1724 | hdd_debug("Init current antenna mode: %d", |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 1725 | hdd_ctx->current_antenna_mode); |
| 1726 | |
Rajeev Kumar | dd3bc60 | 2016-08-16 14:21:05 -0700 | [diff] [blame] | 1727 | hdd_ctx->bpf_enabled = (cfg->bpf_enabled && |
| 1728 | hdd_ctx->config->bpf_packet_filter_enable); |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1729 | hdd_update_ra_rate_limit(hdd_ctx, cfg); |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 1730 | |
Nachiket Kukade | 8b4bfd8 | 2017-05-25 18:34:48 +0530 | [diff] [blame] | 1731 | if ((hdd_ctx->config->txBFCsnValue > |
| 1732 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED_FW_DEF) && |
| 1733 | !cfg->tx_bfee_8ss_enabled) |
| 1734 | hdd_ctx->config->txBFCsnValue = |
| 1735 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED_FW_DEF; |
| 1736 | |
| 1737 | if (sme_cfg_set_int(hdd_ctx->hHal, |
| 1738 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED, |
| 1739 | hdd_ctx->config->txBFCsnValue) == QDF_STATUS_E_FAILURE) |
| 1740 | hdd_err("fw update WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED to CFG fails"); |
| 1741 | |
| 1742 | |
| 1743 | hdd_debug("Target BPF %d Host BPF %d 8ss fw support %d txBFCsnValue %d", |
| 1744 | cfg->bpf_enabled, hdd_ctx->config->bpf_packet_filter_enable, |
| 1745 | cfg->tx_bfee_8ss_enabled, hdd_ctx->config->txBFCsnValue); |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1746 | |
| 1747 | /* |
| 1748 | * Update txBFCsnValue and NumSoundingDim values to vhtcap in wiphy |
| 1749 | */ |
| 1750 | hdd_update_wiphy_vhtcap(hdd_ctx); |
Manjeet Singh | 70d3d93 | 2016-12-20 20:41:10 +0530 | [diff] [blame] | 1751 | |
| 1752 | hdd_ctx->fw_mem_dump_enabled = cfg->fw_mem_dump_enabled; |
| 1753 | |
Arun Khandavalli | d454d42 | 2016-08-17 12:47:05 +0530 | [diff] [blame] | 1754 | /* |
| 1755 | * If BPF is enabled, maxWowFilters set to WMA_STA_WOW_DEFAULT_PTRN_MAX |
| 1756 | * because we need atleast WMA_STA_WOW_DEFAULT_PTRN_MAX free slots to |
| 1757 | * configure the STA mode wow pattern. |
| 1758 | */ |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 1759 | if (hdd_ctx->bpf_enabled) |
Arun Khandavalli | d454d42 | 2016-08-17 12:47:05 +0530 | [diff] [blame] | 1760 | hdd_ctx->config->maxWoWFilters = WMA_STA_WOW_DEFAULT_PTRN_MAX; |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 1761 | |
Rajeev Kumar Sirasanagandla | 4787300 | 2016-09-09 13:46:09 +0530 | [diff] [blame] | 1762 | hdd_ctx->wmi_max_len = cfg->wmi_max_len; |
| 1763 | |
Deepak Dhamdhere | 13230d3 | 2016-05-26 00:46:53 -0700 | [diff] [blame] | 1764 | /* Configure NAN datapath features */ |
| 1765 | hdd_nan_datapath_target_config(hdd_ctx, cfg); |
Arif Hussain | 759a023 | 2017-03-20 13:17:18 -0700 | [diff] [blame] | 1766 | hdd_ctx->dfs_cac_offload = cfg->dfs_cac_offload; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1767 | } |
| 1768 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1769 | bool hdd_dfs_indicate_radar(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1770 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1771 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 1772 | struct hdd_adapter *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1773 | QDF_STATUS status; |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 1774 | struct hdd_ap_ctx *ap_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1775 | |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 1776 | if (!hdd_ctx || hdd_ctx->config->disableDFSChSwitch) { |
Jeff Johnson | 36e74c4 | 2017-09-18 08:15:42 -0700 | [diff] [blame] | 1777 | hdd_info("skip tx block hdd_ctx=%pK, disableDFSChSwitch=%d", |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 1778 | hdd_ctx, hdd_ctx->config->disableDFSChSwitch); |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 1779 | return true; |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 1780 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1781 | |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 1782 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 1783 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
| 1784 | adapter = adapterNode->pAdapter; |
| 1785 | ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 1786 | |
| 1787 | if ((QDF_SAP_MODE == adapter->device_mode || |
| 1788 | QDF_P2P_GO_MODE == adapter->device_mode) && |
| 1789 | (wlan_reg_is_dfs_ch(hdd_ctx->hdd_pdev, |
| 1790 | ap_ctx->operatingChannel))) { |
| 1791 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->dfs_cac_block_tx = |
| 1792 | true; |
| 1793 | hdd_info("tx blocked for session: %d", |
| 1794 | adapter->sessionId); |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 1795 | } |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 1796 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 1797 | adapterNode = pNext; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1798 | } |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 1799 | |
| 1800 | return true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1801 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1802 | |
| 1803 | /** |
| 1804 | * hdd_is_valid_mac_address() - validate MAC address |
| 1805 | * @pMacAddr: Pointer to the input MAC address |
| 1806 | * |
| 1807 | * This function validates whether the given MAC address is valid or not |
| 1808 | * Expected MAC address is of the format XX:XX:XX:XX:XX:XX |
| 1809 | * where X is the hexa decimal digit character and separated by ':' |
| 1810 | * This algorithm works even if MAC address is not separated by ':' |
| 1811 | * |
| 1812 | * This code checks given input string mac contains exactly 12 hexadecimal |
| 1813 | * digits and a separator colon : appears in the input string only after |
| 1814 | * an even number of hex digits. |
| 1815 | * |
| 1816 | * Return: 1 for valid and 0 for invalid |
| 1817 | */ |
| 1818 | bool hdd_is_valid_mac_address(const uint8_t *pMacAddr) |
| 1819 | { |
| 1820 | int xdigit = 0; |
| 1821 | int separator = 0; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 1822 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1823 | while (*pMacAddr) { |
| 1824 | if (isxdigit(*pMacAddr)) { |
| 1825 | xdigit++; |
| 1826 | } else if (':' == *pMacAddr) { |
| 1827 | if (0 == xdigit || ((xdigit / 2) - 1) != separator) |
| 1828 | break; |
| 1829 | |
| 1830 | ++separator; |
| 1831 | } else { |
| 1832 | /* Invalid MAC found */ |
| 1833 | return 0; |
| 1834 | } |
| 1835 | ++pMacAddr; |
| 1836 | } |
| 1837 | return xdigit == 12 && (separator == 5 || separator == 0); |
| 1838 | } |
| 1839 | |
| 1840 | /** |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 1841 | * hdd_mon_mode_ether_setup() - Update monitor mode struct net_device. |
| 1842 | * @dev: Handle to struct net_device to be updated. |
| 1843 | * |
| 1844 | * Return: None |
| 1845 | */ |
| 1846 | static void hdd_mon_mode_ether_setup(struct net_device *dev) |
| 1847 | { |
| 1848 | dev->header_ops = NULL; |
| 1849 | dev->type = ARPHRD_IEEE80211_RADIOTAP; |
| 1850 | dev->hard_header_len = ETH_HLEN; |
| 1851 | dev->mtu = ETH_DATA_LEN; |
| 1852 | dev->addr_len = ETH_ALEN; |
| 1853 | dev->tx_queue_len = 1000; /* Ethernet wants good queues */ |
| 1854 | dev->flags = IFF_BROADCAST|IFF_MULTICAST; |
| 1855 | dev->priv_flags |= IFF_TX_SKB_SHARING; |
| 1856 | |
| 1857 | memset(dev->broadcast, 0xFF, ETH_ALEN); |
| 1858 | } |
| 1859 | |
| 1860 | /** |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 1861 | * __hdd__mon_open() - HDD Open function |
| 1862 | * @dev: Pointer to net_device structure |
| 1863 | * |
| 1864 | * This is called in response to ifconfig up |
| 1865 | * |
| 1866 | * Return: 0 for success; non-zero for failure |
| 1867 | */ |
| 1868 | static int __hdd_mon_open(struct net_device *dev) |
| 1869 | { |
| 1870 | int ret; |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 1871 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 1872 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 1873 | |
| 1874 | ENTER_DEV(dev); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 1875 | |
| 1876 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 1877 | if (ret) |
| 1878 | return ret; |
| 1879 | |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 1880 | hdd_mon_mode_ether_setup(dev); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 1881 | |
| 1882 | if (con_mode == QDF_GLOBAL_MONITOR_MODE) { |
| 1883 | ret = hdd_wlan_start_modules(hdd_ctx, adapter, false); |
| 1884 | if (ret) { |
| 1885 | hdd_err("Failed to start WLAN modules return"); |
| 1886 | return ret; |
| 1887 | } |
| 1888 | hdd_err("hdd_wlan_start_modules() successful !"); |
| 1889 | |
| 1890 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 1891 | ret = hdd_start_adapter(adapter); |
| 1892 | if (ret) { |
| 1893 | hdd_err("Failed to start adapter :%d", |
| 1894 | adapter->device_mode); |
| 1895 | return ret; |
| 1896 | } |
| 1897 | hdd_err("hdd_start_adapters() successful !"); |
| 1898 | } |
| 1899 | set_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 1900 | } |
| 1901 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 1902 | ret = hdd_set_mon_rx_cb(dev); |
Ravi Joshi | 4f09595 | 2017-06-29 15:39:19 -0700 | [diff] [blame] | 1903 | |
| 1904 | if (!ret) |
| 1905 | ret = hdd_enable_monitor_mode(dev); |
| 1906 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 1907 | return ret; |
| 1908 | } |
| 1909 | |
| 1910 | /** |
| 1911 | * hdd_mon_open() - Wrapper function for __hdd_mon_open to protect it from SSR |
| 1912 | * @dev: Pointer to net_device structure |
| 1913 | * |
| 1914 | * This is called in response to ifconfig up |
| 1915 | * |
| 1916 | * Return: 0 for success; non-zero for failure |
| 1917 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 1918 | static int hdd_mon_open(struct net_device *dev) |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 1919 | { |
| 1920 | int ret; |
| 1921 | |
| 1922 | cds_ssr_protect(__func__); |
| 1923 | ret = __hdd_mon_open(dev); |
| 1924 | cds_ssr_unprotect(__func__); |
| 1925 | |
| 1926 | return ret; |
| 1927 | } |
| 1928 | |
| 1929 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1930 | * hdd_start_adapter() - Wrapper function for device specific adapter |
| 1931 | * @adapter: pointer to HDD adapter |
| 1932 | * |
| 1933 | * This function is called to start the device specific adapter for |
| 1934 | * the mode passed in the adapter's device_mode. |
| 1935 | * |
| 1936 | * Return: 0 for success; non-zero for failure |
| 1937 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 1938 | int hdd_start_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1939 | { |
| 1940 | |
| 1941 | int ret; |
| 1942 | enum tQDF_ADAPTER_MODE device_mode = adapter->device_mode; |
| 1943 | |
| 1944 | ENTER_DEV(adapter->dev); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1945 | hdd_debug("Start_adapter for mode : %d", adapter->device_mode); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1946 | |
| 1947 | switch (device_mode) { |
| 1948 | case QDF_P2P_CLIENT_MODE: |
| 1949 | case QDF_P2P_DEVICE_MODE: |
| 1950 | case QDF_OCB_MODE: |
| 1951 | case QDF_STA_MODE: |
| 1952 | case QDF_MONITOR_MODE: |
| 1953 | ret = hdd_start_station_adapter(adapter); |
| 1954 | if (ret) |
| 1955 | goto err_start_adapter; |
| 1956 | break; |
| 1957 | case QDF_P2P_GO_MODE: |
| 1958 | case QDF_SAP_MODE: |
| 1959 | ret = hdd_start_ap_adapter(adapter); |
| 1960 | if (ret) |
| 1961 | goto err_start_adapter; |
| 1962 | break; |
Arun Khandavalli | b2f6c26 | 2016-08-18 19:07:19 +0530 | [diff] [blame] | 1963 | case QDF_IBSS_MODE: |
| 1964 | /* |
| 1965 | * For IBSS interface is initialized as part of |
| 1966 | * hdd_init_station_mode() |
| 1967 | */ |
| 1968 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1969 | case QDF_FTM_MODE: |
| 1970 | ret = hdd_start_ftm_adapter(adapter); |
| 1971 | if (ret) |
| 1972 | goto err_start_adapter; |
| 1973 | break; |
| 1974 | default: |
| 1975 | hdd_err("Invalid session type %d", device_mode); |
| 1976 | QDF_ASSERT(0); |
| 1977 | goto err_start_adapter; |
| 1978 | } |
| 1979 | if (hdd_set_fw_params(adapter)) |
| 1980 | hdd_err("Failed to set the FW params for the adapter!"); |
| 1981 | |
| 1982 | /* |
| 1983 | * Action frame registered in one adapter which will |
| 1984 | * applicable to all interfaces |
| 1985 | */ |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 1986 | ret = wlan_hdd_cfg80211_register_frames(adapter); |
| 1987 | if (ret < 0) { |
| 1988 | hdd_err("Failed to register frames - ret %d", ret); |
| 1989 | goto err_start_adapter; |
| 1990 | } |
| 1991 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 1992 | EXIT(); |
| 1993 | return 0; |
| 1994 | err_start_adapter: |
| 1995 | return -EINVAL; |
| 1996 | } |
| 1997 | |
| 1998 | /** |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 1999 | * hdd_enable_power_management() - API to Enable Power Management |
| 2000 | * |
| 2001 | * API invokes Bus Interface Layer power management functionality |
| 2002 | * |
| 2003 | * Return: None |
| 2004 | */ |
| 2005 | static void hdd_enable_power_management(void) |
| 2006 | { |
| 2007 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2008 | |
| 2009 | if (!hif_ctx) { |
| 2010 | hdd_err("Bus Interface Context is Invalid"); |
| 2011 | return; |
| 2012 | } |
| 2013 | |
| 2014 | hif_enable_power_management(hif_ctx, cds_is_packet_log_enabled()); |
| 2015 | } |
| 2016 | |
| 2017 | /** |
| 2018 | * hdd_disable_power_management() - API to disable Power Management |
| 2019 | * |
| 2020 | * API disable Bus Interface Layer Power management functionality |
| 2021 | * |
| 2022 | * Return: None |
| 2023 | */ |
| 2024 | static void hdd_disable_power_management(void) |
| 2025 | { |
| 2026 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2027 | |
| 2028 | if (!hif_ctx) { |
| 2029 | hdd_err("Bus Interface Context is Invalid"); |
| 2030 | return; |
| 2031 | } |
| 2032 | |
| 2033 | hif_disable_power_management(hif_ctx); |
| 2034 | } |
| 2035 | |
| 2036 | /** |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2037 | * hdd_update_hw_sw_info() - API to update the HW/SW information |
| 2038 | * |
| 2039 | * API to update the HW and SW information in the driver |
| 2040 | * |
| 2041 | * Return: None |
| 2042 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2043 | static void hdd_update_hw_sw_info(struct hdd_context *hdd_ctx) |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2044 | { |
| 2045 | void *hif_sc; |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2046 | size_t target_hw_name_len; |
| 2047 | const char *target_hw_name; |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2048 | |
| 2049 | hif_sc = cds_get_context(QDF_MODULE_ID_HIF); |
| 2050 | if (!hif_sc) { |
| 2051 | hdd_err("HIF context is NULL"); |
| 2052 | return; |
| 2053 | } |
| 2054 | |
| 2055 | /* |
| 2056 | * target hw version/revision would only be retrieved after firmware |
| 2057 | * download |
| 2058 | */ |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2059 | hif_get_hw_info(hif_sc, |
| 2060 | &hdd_ctx->target_hw_version, |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2061 | &hdd_ctx->target_hw_revision, |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2062 | &target_hw_name); |
| 2063 | |
| 2064 | if (hdd_ctx->target_hw_name) |
| 2065 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 2066 | |
| 2067 | target_hw_name_len = strlen(target_hw_name) + 1; |
| 2068 | hdd_ctx->target_hw_name = qdf_mem_malloc(target_hw_name_len); |
| 2069 | if (hdd_ctx->target_hw_name) |
| 2070 | qdf_mem_copy(hdd_ctx->target_hw_name, target_hw_name, |
| 2071 | target_hw_name_len); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2072 | |
| 2073 | /* Get the wlan hw/fw version */ |
| 2074 | hdd_wlan_get_version(hdd_ctx, NULL, NULL); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2075 | } |
| 2076 | |
| 2077 | /** |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2078 | * hdd_update_cds_ac_specs_params() - update cds ac_specs params |
| 2079 | * @hdd_ctx: Pointer to hdd context |
| 2080 | * |
| 2081 | * Return: none |
| 2082 | */ |
| 2083 | static void |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2084 | hdd_update_cds_ac_specs_params(struct hdd_context *hdd_ctx) |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2085 | { |
| 2086 | uint8_t num_entries = 0; |
| 2087 | uint8_t tx_sched_wrr_param[TX_SCHED_WRR_PARAMS_NUM]; |
| 2088 | uint8_t *tx_sched_wrr_ac; |
| 2089 | int i; |
| 2090 | cds_context_type *cds_ctx; |
| 2091 | |
| 2092 | if (NULL == hdd_ctx) |
| 2093 | return; |
| 2094 | |
| 2095 | if (NULL == hdd_ctx->config) { |
| 2096 | /* Do nothing if hdd_ctx is invalid */ |
| 2097 | hdd_err("%s: Warning: hdd_ctx->cfg_ini is NULL", __func__); |
| 2098 | return; |
| 2099 | } |
| 2100 | |
| 2101 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 2102 | |
| 2103 | if (!cds_ctx) { |
| 2104 | hdd_err("Invalid CDS Context"); |
| 2105 | return; |
| 2106 | } |
| 2107 | |
| 2108 | for (i = 0; i < OL_TX_NUM_WMM_AC; i++) { |
| 2109 | switch (i) { |
| 2110 | case OL_TX_WMM_AC_BE: |
| 2111 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_be; |
| 2112 | break; |
| 2113 | case OL_TX_WMM_AC_BK: |
| 2114 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_bk; |
| 2115 | break; |
| 2116 | case OL_TX_WMM_AC_VI: |
| 2117 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_vi; |
| 2118 | break; |
| 2119 | case OL_TX_WMM_AC_VO: |
| 2120 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_vo; |
| 2121 | break; |
| 2122 | default: |
| 2123 | tx_sched_wrr_ac = NULL; |
| 2124 | break; |
| 2125 | } |
| 2126 | |
| 2127 | hdd_string_to_u8_array(tx_sched_wrr_ac, |
| 2128 | tx_sched_wrr_param, |
| 2129 | &num_entries, |
| 2130 | sizeof(tx_sched_wrr_param)); |
| 2131 | |
| 2132 | if (num_entries == TX_SCHED_WRR_PARAMS_NUM) { |
| 2133 | cds_ctx->ac_specs[i].wrr_skip_weight = |
| 2134 | tx_sched_wrr_param[0]; |
| 2135 | cds_ctx->ac_specs[i].credit_threshold = |
| 2136 | tx_sched_wrr_param[1]; |
| 2137 | cds_ctx->ac_specs[i].send_limit = |
| 2138 | tx_sched_wrr_param[2]; |
| 2139 | cds_ctx->ac_specs[i].credit_reserve = |
| 2140 | tx_sched_wrr_param[3]; |
| 2141 | cds_ctx->ac_specs[i].discard_weight = |
| 2142 | tx_sched_wrr_param[4]; |
| 2143 | } |
| 2144 | |
| 2145 | num_entries = 0; |
| 2146 | } |
| 2147 | } |
| 2148 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2149 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2150 | static enum policy_mgr_con_mode wlan_hdd_get_mode_for_non_connected_vdev( |
| 2151 | struct wlan_objmgr_psoc *psoc, uint8_t vdev_id) |
| 2152 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2153 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2154 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2155 | |
| 2156 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 2157 | if (!adapter) { |
| 2158 | hdd_err("Adapter is NULL"); |
| 2159 | return PM_MAX_NUM_OF_MODE; |
| 2160 | } |
| 2161 | |
| 2162 | return policy_mgr_convert_device_mode_to_qdf_type( |
| 2163 | adapter->device_mode); |
| 2164 | } |
| 2165 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2166 | static void hdd_register_policy_manager_callback( |
| 2167 | struct wlan_objmgr_psoc *psoc) |
| 2168 | { |
| 2169 | struct policy_mgr_hdd_cbacks hdd_cbacks; |
| 2170 | hdd_cbacks.sap_restart_chan_switch_cb = |
| 2171 | sap_restart_chan_switch_cb; |
| 2172 | hdd_cbacks.wlan_hdd_get_channel_for_sap_restart = |
| 2173 | wlan_hdd_get_channel_for_sap_restart; |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2174 | hdd_cbacks.get_mode_for_non_connected_vdev = |
| 2175 | wlan_hdd_get_mode_for_non_connected_vdev; |
| 2176 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2177 | if (QDF_STATUS_SUCCESS != |
| 2178 | policy_mgr_register_hdd_cb(psoc, &hdd_cbacks)) { |
| 2179 | hdd_err("HDD callback registration with policy manager failed"); |
| 2180 | } |
| 2181 | } |
| 2182 | #else |
| 2183 | static void hdd_register_policy_manager_callback( |
| 2184 | struct wlan_objmgr_psoc *psoc) |
| 2185 | { |
| 2186 | } |
| 2187 | #endif |
| 2188 | |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2189 | #ifdef WLAN_FEATURE_NAN_CONVERGENCE |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2190 | static void hdd_nan_register_callbacks(struct hdd_context *hdd_ctx) |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2191 | { |
| 2192 | struct nan_callbacks cb_obj = {0}; |
| 2193 | |
| 2194 | cb_obj.ndi_open = hdd_ndi_open; |
| 2195 | cb_obj.ndi_close = hdd_ndi_close; |
| 2196 | cb_obj.ndi_start = hdd_ndi_start; |
| 2197 | cb_obj.ndi_delete = hdd_ndi_delete; |
| 2198 | cb_obj.drv_ndi_create_rsp_handler = hdd_ndi_drv_ndi_create_rsp_handler; |
| 2199 | cb_obj.drv_ndi_delete_rsp_handler = hdd_ndi_drv_ndi_delete_rsp_handler; |
| 2200 | |
Naveen Rawat | 37f62c8 | 2017-03-26 22:24:43 -0700 | [diff] [blame] | 2201 | cb_obj.new_peer_ind = hdd_ndp_new_peer_handler; |
| 2202 | cb_obj.get_peer_idx = hdd_ndp_get_peer_idx; |
Naveen Rawat | b3143ea | 2017-03-26 22:25:46 -0700 | [diff] [blame] | 2203 | cb_obj.peer_departed_ind = hdd_ndp_peer_departed_handler; |
Naveen Rawat | 37f62c8 | 2017-03-26 22:24:43 -0700 | [diff] [blame] | 2204 | |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2205 | os_if_nan_register_hdd_callbacks(hdd_ctx->hdd_psoc, &cb_obj); |
| 2206 | } |
| 2207 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2208 | static void hdd_nan_register_callbacks(struct hdd_context *hdd_ctx) |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2209 | { |
| 2210 | } |
| 2211 | #endif |
| 2212 | |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2213 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2214 | * hdd_wlan_start_modules() - Single driver state machine for starting modules |
| 2215 | * @hdd_ctx: HDD context |
| 2216 | * @adapter: HDD adapter |
| 2217 | * @reinit: flag to indicate from SSR or normal path |
| 2218 | * |
| 2219 | * This function maintains the driver state machine it will be invoked from |
| 2220 | * startup, reinit and change interface. Depending on the driver state shall |
| 2221 | * perform the opening of the modules. |
| 2222 | * |
| 2223 | * Return: 0 for success; non-zero for failure |
| 2224 | */ |
Jeff Johnson | 60dc2b1 | 2017-09-28 14:56:02 -0700 | [diff] [blame^] | 2225 | int hdd_wlan_start_modules(struct hdd_context *hdd_ctx, |
| 2226 | struct hdd_adapter *adapter, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2227 | bool reinit) |
| 2228 | { |
| 2229 | int ret; |
| 2230 | qdf_device_t qdf_dev; |
| 2231 | QDF_STATUS status; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2232 | bool unint = false; |
| 2233 | void *hif_ctx; |
| 2234 | |
Jeff Johnson | 60dc2b1 | 2017-09-28 14:56:02 -0700 | [diff] [blame^] | 2235 | hdd_debug("state:%d reinit:%d", hdd_ctx->driver_status, reinit); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2236 | |
| 2237 | qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 2238 | if (!qdf_dev) { |
| 2239 | hdd_err("QDF Device Context is Invalid return"); |
| 2240 | return -EINVAL; |
| 2241 | } |
| 2242 | |
| 2243 | mutex_lock(&hdd_ctx->iface_change_lock); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 2244 | hdd_ctx->start_modules_in_progress = true; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2245 | |
| 2246 | if (QDF_TIMER_STATE_RUNNING == |
| 2247 | qdf_mc_timer_get_current_state(&hdd_ctx->iface_change_timer)) { |
| 2248 | |
| 2249 | hdd_set_idle_ps_config(hdd_ctx, false); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2250 | hdd_debug("Interface change Timer running Stop timer"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2251 | qdf_mc_timer_stop(&hdd_ctx->iface_change_timer); |
| 2252 | } |
| 2253 | |
| 2254 | switch (hdd_ctx->driver_status) { |
| 2255 | case DRIVER_MODULES_UNINITIALIZED: |
| 2256 | unint = true; |
| 2257 | /* Fall through dont add break here */ |
| 2258 | case DRIVER_MODULES_CLOSED: |
| 2259 | if (!reinit && !unint) { |
| 2260 | ret = pld_power_on(qdf_dev->dev); |
| 2261 | if (ret) { |
| 2262 | hdd_err("Failed to Powerup the device: %d", ret); |
| 2263 | goto release_lock; |
| 2264 | } |
| 2265 | } |
Yuanyuan Liu | f8fe4bc | 2017-06-07 16:55:58 -0700 | [diff] [blame] | 2266 | |
| 2267 | pld_set_fw_log_mode(hdd_ctx->parent_dev, |
| 2268 | hdd_ctx->config->enable_fw_log); |
| 2269 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2270 | ret = hdd_hif_open(qdf_dev->dev, qdf_dev->drv_hdl, qdf_dev->bid, |
| 2271 | qdf_dev->bus_type, |
| 2272 | (reinit == true) ? HIF_ENABLE_TYPE_REINIT : |
| 2273 | HIF_ENABLE_TYPE_PROBE); |
| 2274 | if (ret) { |
| 2275 | hdd_err("Failed to open hif: %d", ret); |
| 2276 | goto power_down; |
| 2277 | } |
| 2278 | |
| 2279 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
Arun Khandavalli | 1318b99 | 2016-08-09 11:04:57 +0530 | [diff] [blame] | 2280 | if (!hif_ctx) { |
| 2281 | hdd_err("hif context is null!!"); |
| 2282 | goto power_down; |
| 2283 | } |
| 2284 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2285 | status = ol_cds_init(qdf_dev, hif_ctx); |
| 2286 | if (status != QDF_STATUS_SUCCESS) { |
| 2287 | hdd_err("No Memory to Create BMI Context :%d", status); |
| 2288 | goto hif_close; |
| 2289 | } |
| 2290 | |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 2291 | ret = hdd_update_config(hdd_ctx); |
| 2292 | if (ret) { |
| 2293 | hdd_err("Failed to update configuration :%d", ret); |
Abhishek Singh | e9068f1 | 2017-03-31 14:14:52 +0530 | [diff] [blame] | 2294 | goto ol_cds_free; |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 2295 | } |
| 2296 | |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2297 | hdd_update_cds_ac_specs_params(hdd_ctx); |
| 2298 | |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 2299 | status = cds_open(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2300 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 2301 | hdd_err("Failed to Open CDS: %d", status); |
Abhishek Singh | e9068f1 | 2017-03-31 14:14:52 +0530 | [diff] [blame] | 2302 | goto ol_cds_free; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2303 | } |
| 2304 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2305 | /* initalize components configurations after psoc open */ |
| 2306 | ret = hdd_update_components_config(hdd_ctx); |
| 2307 | if (ret) { |
| 2308 | hdd_err("Failed to update components configs :%d", |
| 2309 | ret); |
| 2310 | goto close; |
| 2311 | } |
| 2312 | |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2313 | /* |
| 2314 | * NAN compoenet requires certian operations like, open adapter, |
| 2315 | * close adapter, etc. to be initiated by HDD, for those |
| 2316 | * register HDD callbacks with UMAC's NAN componenet. |
| 2317 | */ |
| 2318 | hdd_nan_register_callbacks(hdd_ctx); |
| 2319 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2320 | hdd_ctx->hHal = cds_get_context(QDF_MODULE_ID_SME); |
| 2321 | |
Jeff Johnson | 3a28012 | 2017-09-13 07:42:00 -0700 | [diff] [blame] | 2322 | status = cds_pre_enable(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2323 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 2324 | hdd_err("Failed to pre-enable CDS: %d", status); |
| 2325 | goto close; |
| 2326 | } |
| 2327 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2328 | hdd_register_policy_manager_callback( |
| 2329 | hdd_ctx->hdd_psoc); |
| 2330 | |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2331 | hdd_update_hw_sw_info(hdd_ctx); |
Himanshu Agarwal | 0b9bbc3 | 2017-02-23 16:23:05 +0530 | [diff] [blame] | 2332 | hdd_ctx->driver_status = DRIVER_MODULES_OPENED; |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2333 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2334 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 2335 | sme_register_ftm_msg_processor(hdd_ctx->hHal, |
| 2336 | hdd_ftm_mc_process_msg); |
| 2337 | break; |
| 2338 | } |
| 2339 | if (unint) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2340 | hdd_debug("In phase-1 initialization don't enable modules"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2341 | break; |
| 2342 | } |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 2343 | |
| 2344 | if (reinit) { |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 2345 | if (hdd_ipa_uc_ssr_reinit(hdd_ctx)) { |
| 2346 | hdd_err("HDD IPA UC reinit failed"); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2347 | goto post_disable; |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 2348 | } |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 2349 | } |
| 2350 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2351 | /* Fall through dont add break here */ |
| 2352 | case DRIVER_MODULES_OPENED: |
| 2353 | if (!adapter) { |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2354 | hdd_alert("adapter is Null"); |
| 2355 | goto post_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2356 | } |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 2357 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 2358 | hdd_err("in ftm mode, no need to configure cds modules"); |
| 2359 | break; |
| 2360 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2361 | if (hdd_configure_cds(hdd_ctx, adapter)) { |
| 2362 | hdd_err("Failed to Enable cds modules"); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2363 | goto post_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2364 | } |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 2365 | hdd_enable_power_management(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2366 | hdd_info("Driver Modules Successfully Enabled"); |
| 2367 | hdd_ctx->driver_status = DRIVER_MODULES_ENABLED; |
| 2368 | break; |
| 2369 | case DRIVER_MODULES_ENABLED: |
| 2370 | hdd_info("Driver modules already Enabled"); |
| 2371 | break; |
| 2372 | default: |
| 2373 | hdd_err("WLAN start invoked in wrong state! :%d\n", |
| 2374 | hdd_ctx->driver_status); |
| 2375 | goto release_lock; |
| 2376 | } |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 2377 | hdd_ctx->start_modules_in_progress = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2378 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 2379 | EXIT(); |
| 2380 | return 0; |
| 2381 | |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2382 | post_disable: |
Rajeev Kumar | be02124 | 2017-02-16 16:12:23 -0800 | [diff] [blame] | 2383 | cds_post_disable(); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2384 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2385 | close: |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2386 | hdd_ctx->driver_status = DRIVER_MODULES_CLOSED; |
Jeff Johnson | e4b1459 | 2017-09-13 14:23:33 -0700 | [diff] [blame] | 2387 | cds_close(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2388 | |
| 2389 | ol_cds_free: |
| 2390 | ol_cds_free(); |
| 2391 | |
| 2392 | hif_close: |
Jeff Johnson | 60dc2b1 | 2017-09-28 14:56:02 -0700 | [diff] [blame^] | 2393 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2394 | hdd_hif_close(hdd_ctx, hif_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2395 | power_down: |
| 2396 | if (!reinit && !unint) |
| 2397 | pld_power_off(qdf_dev->dev); |
| 2398 | release_lock: |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 2399 | hdd_ctx->start_modules_in_progress = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2400 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 2401 | EXIT(); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2402 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2403 | return -EINVAL; |
| 2404 | } |
| 2405 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2406 | #ifdef WIFI_POS_CONVERGED |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2407 | static int hdd_activate_wifi_pos(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2408 | { |
| 2409 | int ret = os_if_wifi_pos_register_nl(); |
| 2410 | |
| 2411 | if (ret) |
| 2412 | hdd_err("os_if_wifi_pos_register_nl failed"); |
| 2413 | |
| 2414 | return ret; |
| 2415 | } |
| 2416 | |
| 2417 | static int hdd_deactivate_wifi_pos(void) |
| 2418 | { |
| 2419 | int ret = os_if_wifi_pos_deregister_nl(); |
| 2420 | |
| 2421 | if (ret) |
| 2422 | hdd_err("os_if_wifi_pos_deregister_nl failed"); |
| 2423 | |
| 2424 | return ret; |
| 2425 | } |
| 2426 | |
| 2427 | /** |
| 2428 | * hdd_populate_wifi_pos_cfg - populates wifi_pos parameters |
| 2429 | * @hdd_ctx: hdd context |
| 2430 | * |
| 2431 | * Return: status of operation |
| 2432 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2433 | static void hdd_populate_wifi_pos_cfg(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2434 | { |
| 2435 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 2436 | struct hdd_config *cfg = hdd_ctx->config; |
| 2437 | |
| 2438 | wifi_pos_set_oem_target_type(psoc, hdd_ctx->target_type); |
| 2439 | wifi_pos_set_oem_fw_version(psoc, hdd_ctx->target_fw_version); |
| 2440 | wifi_pos_set_drv_ver_major(psoc, QWLAN_VERSION_MAJOR); |
| 2441 | wifi_pos_set_drv_ver_minor(psoc, QWLAN_VERSION_MINOR); |
| 2442 | wifi_pos_set_drv_ver_patch(psoc, QWLAN_VERSION_PATCH); |
| 2443 | wifi_pos_set_drv_ver_build(psoc, QWLAN_VERSION_BUILD); |
| 2444 | wifi_pos_set_dwell_time_min(psoc, cfg->nNeighborScanMinChanTime); |
| 2445 | wifi_pos_set_dwell_time_max(psoc, cfg->nNeighborScanMaxChanTime); |
| 2446 | } |
| 2447 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2448 | static int hdd_activate_wifi_pos(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2449 | { |
| 2450 | return oem_activate_service(hdd_ctx); |
| 2451 | } |
| 2452 | |
| 2453 | static int hdd_deactivate_wifi_pos(void) |
| 2454 | { |
| 2455 | return 0; |
| 2456 | } |
| 2457 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2458 | static void hdd_populate_wifi_pos_cfg(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2459 | { |
| 2460 | } |
| 2461 | #endif |
| 2462 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2463 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2464 | * __hdd_open() - HDD Open function |
| 2465 | * @dev: Pointer to net_device structure |
| 2466 | * |
| 2467 | * This is called in response to ifconfig up |
| 2468 | * |
| 2469 | * Return: 0 for success; non-zero for failure |
| 2470 | */ |
| 2471 | static int __hdd_open(struct net_device *dev) |
| 2472 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2473 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2474 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2475 | int ret; |
| 2476 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 2477 | ENTER_DEV(dev); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 2478 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_OPEN_REQUEST, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2479 | adapter->sessionId, adapter->device_mode)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2480 | |
Arunk Khandavalli | e1b3a38 | 2017-09-26 12:01:26 +0530 | [diff] [blame] | 2481 | if (!hdd_wait_for_recovery_completion()) { |
| 2482 | hdd_err("Recovery failed"); |
| 2483 | return -EIO; |
| 2484 | } |
| 2485 | |
Ashish Kumar Dhanotiya | 15a7db5 | 2017-08-03 10:27:34 +0530 | [diff] [blame] | 2486 | /* Nothing to be done if device is unloading */ |
| 2487 | if (cds_is_driver_unloading()) { |
| 2488 | hdd_err("Driver is unloading can not open the hdd"); |
| 2489 | return -EBUSY; |
| 2490 | } |
| 2491 | |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2492 | mutex_lock(&hdd_init_deinit_lock); |
| 2493 | |
| 2494 | /* |
| 2495 | * This scenario can be hit in cases where in the wlan driver after |
| 2496 | * registering the netdevices and there is a failure in driver |
| 2497 | * initialization. So return error gracefully because the netdevices |
| 2498 | * will be de-registered as part of the load failure. |
| 2499 | */ |
| 2500 | |
| 2501 | if (!cds_is_driver_loaded()) { |
| 2502 | hdd_err("Failed to start the wlan driver!!"); |
| 2503 | ret = -EIO; |
| 2504 | goto err_hdd_hdd_init_deinit_lock; |
| 2505 | } |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 2506 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2507 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2508 | ret = hdd_wlan_start_modules(hdd_ctx, adapter, false); |
| 2509 | if (ret) { |
| 2510 | hdd_err("Failed to start WLAN modules return"); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2511 | goto err_hdd_hdd_init_deinit_lock; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2512 | } |
| 2513 | |
| 2514 | |
| 2515 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 2516 | ret = hdd_start_adapter(adapter); |
| 2517 | if (ret) { |
| 2518 | hdd_err("Failed to start adapter :%d", |
| 2519 | adapter->device_mode); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2520 | goto err_hdd_hdd_init_deinit_lock; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2521 | } |
| 2522 | } |
| 2523 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2524 | set_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 2525 | if (hdd_conn_is_connected(WLAN_HDD_GET_STATION_CTX_PTR(adapter))) { |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 2526 | hdd_debug("Enabling Tx Queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2527 | /* Enable TX queues only when we are connected */ |
| 2528 | wlan_hdd_netif_queue_control(adapter, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2529 | WLAN_START_ALL_NETIF_QUEUE, |
| 2530 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2531 | } |
| 2532 | |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 2533 | /* Enable carrier and transmit queues for NDI */ |
| 2534 | if (WLAN_HDD_IS_NDI(adapter)) { |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 2535 | hdd_debug("Enabling Tx Queues"); |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 2536 | wlan_hdd_netif_queue_control(adapter, |
| 2537 | WLAN_START_ALL_NETIF_QUEUE_N_CARRIER, |
| 2538 | WLAN_CONTROL_PATH); |
| 2539 | } |
| 2540 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2541 | hdd_populate_wifi_pos_cfg(hdd_ctx); |
| 2542 | |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2543 | err_hdd_hdd_init_deinit_lock: |
| 2544 | mutex_unlock(&hdd_init_deinit_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2545 | return ret; |
| 2546 | } |
| 2547 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2548 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2549 | /** |
| 2550 | * hdd_open() - Wrapper function for __hdd_open to protect it from SSR |
| 2551 | * @dev: Pointer to net_device structure |
| 2552 | * |
| 2553 | * This is called in response to ifconfig up |
| 2554 | * |
| 2555 | * Return: 0 for success; non-zero for failure |
| 2556 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2557 | static int hdd_open(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2558 | { |
| 2559 | int ret; |
| 2560 | |
| 2561 | cds_ssr_protect(__func__); |
| 2562 | ret = __hdd_open(dev); |
| 2563 | cds_ssr_unprotect(__func__); |
| 2564 | |
| 2565 | return ret; |
| 2566 | } |
| 2567 | |
| 2568 | /** |
| 2569 | * __hdd_stop() - HDD stop function |
| 2570 | * @dev: Pointer to net_device structure |
| 2571 | * |
| 2572 | * This is called in response to ifconfig down |
| 2573 | * |
| 2574 | * Return: 0 for success; non-zero for failure |
| 2575 | */ |
| 2576 | static int __hdd_stop(struct net_device *dev) |
| 2577 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2578 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2579 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2580 | int ret; |
| 2581 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 2582 | ENTER_DEV(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2583 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 2584 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_STOP_REQUEST, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2585 | adapter->sessionId, adapter->device_mode)); |
| 2586 | |
| 2587 | ret = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 2588 | if (0 != ret) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2589 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2590 | |
| 2591 | /* Nothing to be done if the interface is not opened */ |
| 2592 | if (false == test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2593 | hdd_err("NETDEV Interface is not OPENED"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2594 | return -ENODEV; |
| 2595 | } |
| 2596 | |
| 2597 | /* Make sure the interface is marked as closed */ |
| 2598 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 2599 | |
| 2600 | hdd_debug("Disabling Auto Power save timer"); |
| 2601 | sme_ps_disable_auto_ps_timer( |
| 2602 | WLAN_HDD_GET_HAL_CTX(adapter), |
| 2603 | adapter->sessionId); |
| 2604 | |
| 2605 | /* |
| 2606 | * Disable TX on the interface, after this hard_start_xmit() will not |
| 2607 | * be called on that interface |
| 2608 | */ |
| 2609 | hdd_notice("Disabling queues"); |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 2610 | wlan_hdd_netif_queue_control(adapter, |
| 2611 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 2612 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2613 | |
| 2614 | /* |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 2615 | * NAN data interface is different in some sense. The traffic on NDI is |
| 2616 | * bursty in nature and depends on the need to transfer. The service |
| 2617 | * layer may down the interface after the usage and up again when |
| 2618 | * required. In some sense, the NDI is expected to be available |
| 2619 | * (like SAP) iface until NDI delete request is issued by the service |
| 2620 | * layer. Skip BSS termination and adapter deletion for NAN Data |
| 2621 | * interface (NDI). |
| 2622 | */ |
| 2623 | if (WLAN_HDD_IS_NDI(adapter)) |
| 2624 | return 0; |
| 2625 | |
| 2626 | /* |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2627 | * The interface is marked as down for outside world (aka kernel) |
| 2628 | * But the driver is pretty much alive inside. The driver needs to |
| 2629 | * tear down the existing connection on the netdev (session) |
| 2630 | * cleanup the data pipes and wait until the control plane is stabilized |
| 2631 | * for this interface. The call also needs to wait until the above |
| 2632 | * mentioned actions are completed before returning to the caller. |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 2633 | * Notice that hdd_stop_adapter is requested not to close the session |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2634 | * That is intentional to be able to scan if it is a STA/P2P interface |
| 2635 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2636 | hdd_stop_adapter(hdd_ctx, adapter, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2637 | |
| 2638 | /* DeInit the adapter. This ensures datapath cleanup as well */ |
| 2639 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
| 2640 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2641 | |
| 2642 | /* |
| 2643 | * Find if any iface is up. If any iface is up then can't put device to |
| 2644 | * sleep/power save mode |
| 2645 | */ |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 2646 | if (hdd_check_for_opened_interfaces(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2647 | hdd_debug("Closing all modules from the hdd_stop"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2648 | qdf_mc_timer_start(&hdd_ctx->iface_change_timer, |
Hanumanth Reddy Pothula | 42e714a | 2016-12-21 19:33:57 +0530 | [diff] [blame] | 2649 | hdd_ctx->config->iface_change_wait_time); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2650 | } |
| 2651 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2652 | EXIT(); |
| 2653 | return 0; |
| 2654 | } |
| 2655 | |
| 2656 | /** |
| 2657 | * hdd_stop() - Wrapper function for __hdd_stop to protect it from SSR |
| 2658 | * @dev: pointer to net_device structure |
| 2659 | * |
| 2660 | * This is called in response to ifconfig down |
| 2661 | * |
| 2662 | * Return: 0 for success and error number for failure |
| 2663 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2664 | static int hdd_stop(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2665 | { |
| 2666 | int ret; |
| 2667 | |
| 2668 | cds_ssr_protect(__func__); |
| 2669 | ret = __hdd_stop(dev); |
| 2670 | cds_ssr_unprotect(__func__); |
| 2671 | |
| 2672 | return ret; |
| 2673 | } |
| 2674 | |
| 2675 | /** |
| 2676 | * __hdd_uninit() - HDD uninit function |
| 2677 | * @dev: Pointer to net_device structure |
| 2678 | * |
| 2679 | * This is called during the netdev unregister to uninitialize all data |
| 2680 | * associated with the device |
| 2681 | * |
| 2682 | * Return: None |
| 2683 | */ |
| 2684 | static void __hdd_uninit(struct net_device *dev) |
| 2685 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2686 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 2687 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2688 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 2689 | ENTER_DEV(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2690 | |
| 2691 | do { |
| 2692 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2693 | hdd_err("Invalid magic"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2694 | break; |
| 2695 | } |
| 2696 | |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 2697 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 2698 | if (!hdd_ctx) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2699 | hdd_err("NULL hdd_ctx"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2700 | break; |
| 2701 | } |
| 2702 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2703 | if (dev != adapter->dev) |
| 2704 | hdd_err("Invalid device reference"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2705 | |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 2706 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2707 | |
| 2708 | /* after uninit our adapter structure will no longer be valid */ |
| 2709 | adapter->dev = NULL; |
| 2710 | adapter->magic = 0; |
| 2711 | } while (0); |
| 2712 | |
| 2713 | EXIT(); |
| 2714 | } |
| 2715 | |
| 2716 | /** |
| 2717 | * hdd_uninit() - Wrapper function to protect __hdd_uninit from SSR |
| 2718 | * @dev: pointer to net_device structure |
| 2719 | * |
| 2720 | * This is called during the netdev unregister to uninitialize all data |
| 2721 | * associated with the device |
| 2722 | * |
| 2723 | * Return: none |
| 2724 | */ |
| 2725 | static void hdd_uninit(struct net_device *dev) |
| 2726 | { |
| 2727 | cds_ssr_protect(__func__); |
| 2728 | __hdd_uninit(dev); |
| 2729 | cds_ssr_unprotect(__func__); |
| 2730 | } |
| 2731 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2732 | static int hdd_open_cesium_nl_sock(void) |
| 2733 | { |
| 2734 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 2735 | struct netlink_kernel_cfg cfg = { |
| 2736 | .groups = WLAN_NLINK_MCAST_GRP_ID, |
| 2737 | .input = NULL |
| 2738 | }; |
| 2739 | #endif |
| 2740 | int ret = 0; |
| 2741 | |
| 2742 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 2743 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 2744 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 7, 0)) |
| 2745 | THIS_MODULE, |
| 2746 | #endif |
| 2747 | &cfg); |
| 2748 | #else |
| 2749 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 2750 | WLAN_NLINK_MCAST_GRP_ID, |
| 2751 | NULL, NULL, THIS_MODULE); |
| 2752 | #endif |
| 2753 | |
| 2754 | if (cesium_nl_srv_sock == NULL) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2755 | hdd_err("NLINK: cesium netlink_kernel_create failed"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2756 | ret = -ECONNREFUSED; |
| 2757 | } |
| 2758 | |
| 2759 | return ret; |
| 2760 | } |
| 2761 | |
| 2762 | static void hdd_close_cesium_nl_sock(void) |
| 2763 | { |
| 2764 | if (NULL != cesium_nl_srv_sock) { |
| 2765 | netlink_kernel_release(cesium_nl_srv_sock); |
| 2766 | cesium_nl_srv_sock = NULL; |
| 2767 | } |
| 2768 | } |
| 2769 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2770 | /** |
| 2771 | * __hdd_set_mac_address() - set the user specified mac address |
| 2772 | * @dev: Pointer to the net device. |
| 2773 | * @addr: Pointer to the sockaddr. |
| 2774 | * |
| 2775 | * This function sets the user specified mac address using |
| 2776 | * the command ifconfig wlanX hw ether <mac adress>. |
| 2777 | * |
| 2778 | * Return: 0 for success, non zero for failure |
| 2779 | */ |
| 2780 | static int __hdd_set_mac_address(struct net_device *dev, void *addr) |
| 2781 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2782 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2783 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2784 | struct sockaddr *psta_mac_addr = addr; |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 2785 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2786 | int ret; |
| 2787 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 2788 | ENTER_DEV(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2789 | |
| 2790 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 2791 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 2792 | if (0 != ret) |
| 2793 | return ret; |
| 2794 | |
| 2795 | memcpy(&adapter->macAddressCurrent, psta_mac_addr->sa_data, ETH_ALEN); |
| 2796 | memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN); |
| 2797 | |
| 2798 | EXIT(); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 2799 | return qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2800 | } |
| 2801 | |
| 2802 | /** |
| 2803 | * hdd_set_mac_address() - Wrapper function to protect __hdd_set_mac_address() |
| 2804 | * function from SSR |
| 2805 | * @dev: pointer to net_device structure |
| 2806 | * @addr: Pointer to the sockaddr |
| 2807 | * |
| 2808 | * This function sets the user specified mac address using |
| 2809 | * the command ifconfig wlanX hw ether <mac adress>. |
| 2810 | * |
| 2811 | * Return: 0 for success. |
| 2812 | */ |
| 2813 | static int hdd_set_mac_address(struct net_device *dev, void *addr) |
| 2814 | { |
| 2815 | int ret; |
| 2816 | |
| 2817 | cds_ssr_protect(__func__); |
| 2818 | ret = __hdd_set_mac_address(dev, addr); |
| 2819 | cds_ssr_unprotect(__func__); |
| 2820 | |
| 2821 | return ret; |
| 2822 | } |
| 2823 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2824 | uint8_t *wlan_hdd_get_intf_addr(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2825 | { |
| 2826 | int i; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 2827 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2828 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2829 | if (0 == ((hdd_ctx->config->intfAddrMask) & (1 << i))) |
| 2830 | break; |
| 2831 | } |
| 2832 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2833 | if (QDF_MAX_CONCURRENCY_PERSONA == i) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2834 | return NULL; |
| 2835 | |
| 2836 | hdd_ctx->config->intfAddrMask |= (1 << i); |
| 2837 | return &hdd_ctx->config->intfMacAddr[i].bytes[0]; |
| 2838 | } |
| 2839 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2840 | void wlan_hdd_release_intf_addr(struct hdd_context *hdd_ctx, uint8_t *releaseAddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2841 | { |
| 2842 | int i; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 2843 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2844 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2845 | if (!memcmp(releaseAddr, |
| 2846 | &hdd_ctx->config->intfMacAddr[i].bytes[0], |
| 2847 | 6)) { |
| 2848 | hdd_ctx->config->intfAddrMask &= ~(1 << i); |
| 2849 | break; |
| 2850 | } |
| 2851 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2852 | } |
| 2853 | |
| 2854 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 2855 | /** |
| 2856 | * __hdd_set_multicast_list() - set the multicast address list |
| 2857 | * @dev: Pointer to the WLAN device. |
| 2858 | * @skb: Pointer to OS packet (sk_buff). |
| 2859 | * |
| 2860 | * This funciton sets the multicast address list. |
| 2861 | * |
| 2862 | * Return: None |
| 2863 | */ |
| 2864 | static void __hdd_set_multicast_list(struct net_device *dev) |
| 2865 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2866 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2867 | int i = 0, status; |
| 2868 | struct netdev_hw_addr *ha; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2869 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 2870 | struct pmo_mc_addr_list_params *mc_list_request = NULL; |
| 2871 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 2872 | int mc_count = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2873 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 2874 | ENTER_DEV(dev); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2875 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 2876 | goto out; |
Mukul Sharma | 51c4494 | 2015-10-30 19:30:19 +0530 | [diff] [blame] | 2877 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2878 | status = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 2879 | if (0 != status) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 2880 | goto out; |
| 2881 | |
Dustin Brown | c788acb | 2017-08-01 17:43:51 -0700 | [diff] [blame] | 2882 | status = hdd_validate_adapter(adapter); |
| 2883 | if (status) |
| 2884 | goto out; |
| 2885 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 2886 | mc_list_request = qdf_mem_malloc(sizeof(*mc_list_request)); |
| 2887 | if (!mc_list_request) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2888 | hdd_err("Cannot allocate mc_list_request"); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 2889 | goto out; |
| 2890 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2891 | |
Hanumanth Reddy Pothula | ca84ec5 | 2017-02-21 12:09:45 +0530 | [diff] [blame] | 2892 | /* Delete already configured multicast address list */ |
| 2893 | if (adapter->mc_addr_list.mc_cnt > 0) { |
| 2894 | hdd_info("clear previously configured MC address list"); |
| 2895 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 2896 | pmo_mc_list_change_notify); |
| 2897 | } |
| 2898 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2899 | if (dev->flags & IFF_ALLMULTI) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2900 | hdd_debug("allow all multicast frames"); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 2901 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 2902 | pmo_mc_list_change_notify); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2903 | } else { |
| 2904 | mc_count = netdev_mc_count(dev); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 2905 | if (mc_count > pmo_ucfg_max_mc_addr_supported(psoc)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2906 | hdd_debug("Exceeded max MC filter addresses (%d). Allowing all MC frames by disabling MC address filtering", |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 2907 | pmo_ucfg_max_mc_addr_supported(psoc)); |
| 2908 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 2909 | pmo_mc_list_change_notify); |
| 2910 | goto out; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2911 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2912 | netdev_for_each_mc_addr(ha, dev) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2913 | hdd_debug("ha_addr[%d] "MAC_ADDRESS_STR, |
Sachin Ahuja | a69c72a | 2016-09-03 15:59:33 +0530 | [diff] [blame] | 2914 | i, MAC_ADDR_ARRAY(ha->addr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2915 | if (i == mc_count) |
| 2916 | break; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 2917 | memset(&(mc_list_request->mc_addr[i].bytes), |
| 2918 | 0, ETH_ALEN); |
| 2919 | memcpy(&(mc_list_request->mc_addr[i].bytes), |
| 2920 | ha->addr, ETH_ALEN); |
| 2921 | hdd_info("mlist[%d] = %pM", i, |
| 2922 | mc_list_request->mc_addr[i].bytes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2923 | i++; |
| 2924 | } |
| 2925 | } |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 2926 | |
| 2927 | mc_list_request->psoc = psoc; |
| 2928 | mc_list_request->vdev_id = adapter->sessionId; |
| 2929 | mc_list_request->count = mc_count; |
| 2930 | status = hdd_cache_mc_addr_list(mc_list_request); |
| 2931 | if (status == 0) { |
| 2932 | hdd_enable_mc_addr_filtering(adapter, |
| 2933 | pmo_mc_list_change_notify); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2934 | } else { |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 2935 | hdd_err("error while caching mc list"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2936 | } |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 2937 | out: |
| 2938 | if (mc_list_request) |
| 2939 | qdf_mem_free(mc_list_request); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 2940 | EXIT(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2941 | } |
| 2942 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 2943 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2944 | /** |
| 2945 | * hdd_set_multicast_list() - SSR wrapper function for __hdd_set_multicast_list |
| 2946 | * @dev: pointer to net_device |
| 2947 | * |
| 2948 | * Return: none |
| 2949 | */ |
| 2950 | static void hdd_set_multicast_list(struct net_device *dev) |
| 2951 | { |
| 2952 | cds_ssr_protect(__func__); |
| 2953 | __hdd_set_multicast_list(dev); |
| 2954 | cds_ssr_unprotect(__func__); |
| 2955 | } |
| 2956 | #endif |
| 2957 | |
| 2958 | /** |
| 2959 | * hdd_select_queue() - used by Linux OS to decide which queue to use first |
| 2960 | * @dev: Pointer to the WLAN device. |
| 2961 | * @skb: Pointer to OS packet (sk_buff). |
| 2962 | * |
| 2963 | * This function is registered with the Linux OS for network |
| 2964 | * core to decide which queue to use first. |
| 2965 | * |
| 2966 | * Return: ac, Queue Index/access category corresponding to UP in IP header |
| 2967 | */ |
| 2968 | static uint16_t hdd_select_queue(struct net_device *dev, struct sk_buff *skb |
| 2969 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0)) |
| 2970 | , void *accel_priv |
| 2971 | #endif |
| 2972 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) |
| 2973 | , select_queue_fallback_t fallback |
| 2974 | #endif |
| 2975 | ) |
| 2976 | { |
| 2977 | return hdd_wmm_select_queue(dev, skb); |
| 2978 | } |
| 2979 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 2980 | static const struct net_device_ops wlan_drv_ops = { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2981 | .ndo_open = hdd_open, |
| 2982 | .ndo_stop = hdd_stop, |
| 2983 | .ndo_uninit = hdd_uninit, |
| 2984 | .ndo_start_xmit = hdd_hard_start_xmit, |
| 2985 | .ndo_tx_timeout = hdd_tx_timeout, |
| 2986 | .ndo_get_stats = hdd_get_stats, |
| 2987 | .ndo_do_ioctl = hdd_ioctl, |
| 2988 | .ndo_set_mac_address = hdd_set_mac_address, |
| 2989 | .ndo_select_queue = hdd_select_queue, |
| 2990 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2991 | .ndo_set_rx_mode = hdd_set_multicast_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2992 | #endif |
| 2993 | }; |
| 2994 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2995 | /* Monitor mode net_device_ops, doesnot Tx and most of operations. */ |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 2996 | static const struct net_device_ops wlan_mon_drv_ops = { |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2997 | .ndo_open = hdd_mon_open, |
| 2998 | .ndo_stop = hdd_stop, |
| 2999 | .ndo_get_stats = hdd_get_stats, |
| 3000 | }; |
| 3001 | |
| 3002 | /** |
| 3003 | * hdd_set_station_ops() - update net_device ops for monitor mode |
| 3004 | * @pWlanDev: Handle to struct net_device to be updated. |
| 3005 | * Return: None |
| 3006 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3007 | void hdd_set_station_ops(struct net_device *pWlanDev) |
| 3008 | { |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3009 | if (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam()) |
| 3010 | pWlanDev->netdev_ops = &wlan_mon_drv_ops; |
| 3011 | else |
| 3012 | pWlanDev->netdev_ops = &wlan_drv_ops; |
| 3013 | } |
| 3014 | |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 3015 | #ifdef FEATURE_RUNTIME_PM |
Komal Seelam | 8634b77 | 2016-09-29 12:12:24 +0530 | [diff] [blame] | 3016 | /** |
| 3017 | * hdd_runtime_suspend_context_init() - API to initialize HDD Runtime Contexts |
| 3018 | * @hdd_ctx: HDD context |
| 3019 | * |
| 3020 | * Return: None |
| 3021 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3022 | static void hdd_runtime_suspend_context_init(struct hdd_context *hdd_ctx) |
Komal Seelam | 8634b77 | 2016-09-29 12:12:24 +0530 | [diff] [blame] | 3023 | { |
| 3024 | struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; |
| 3025 | |
Prashanth Bhatta | 87b6dc0 | 2017-01-19 15:17:58 -0800 | [diff] [blame] | 3026 | qdf_runtime_lock_init(&ctx->roc); |
| 3027 | qdf_runtime_lock_init(&ctx->dfs); |
Komal Seelam | 8634b77 | 2016-09-29 12:12:24 +0530 | [diff] [blame] | 3028 | } |
| 3029 | |
| 3030 | /** |
| 3031 | * hdd_runtime_suspend_context_deinit() - API to deinit HDD runtime context |
| 3032 | * @hdd_ctx: HDD Context |
| 3033 | * |
| 3034 | * Return: None |
| 3035 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3036 | static void hdd_runtime_suspend_context_deinit(struct hdd_context *hdd_ctx) |
Komal Seelam | 8634b77 | 2016-09-29 12:12:24 +0530 | [diff] [blame] | 3037 | { |
| 3038 | struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; |
| 3039 | |
Prashanth Bhatta | 87b6dc0 | 2017-01-19 15:17:58 -0800 | [diff] [blame] | 3040 | qdf_runtime_lock_deinit(&ctx->roc); |
| 3041 | qdf_runtime_lock_deinit(&ctx->dfs); |
Sravan Kumar Kairam | 6457495 | 2017-06-22 11:48:18 +0530 | [diff] [blame] | 3042 | |
| 3043 | wlan_scan_runtime_pm_deinit(hdd_ctx->hdd_pdev); |
Komal Seelam | 8634b77 | 2016-09-29 12:12:24 +0530 | [diff] [blame] | 3044 | } |
| 3045 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3046 | static void hdd_adapter_runtime_suspend_init(struct hdd_adapter *adapter) |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 3047 | { |
| 3048 | struct hdd_connect_pm_context *ctx = &adapter->connect_rpm_ctx; |
| 3049 | |
Prashanth Bhatta | 87b6dc0 | 2017-01-19 15:17:58 -0800 | [diff] [blame] | 3050 | qdf_runtime_lock_init(&ctx->connect); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 3051 | } |
| 3052 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3053 | static void hdd_adapter_runtime_suspend_denit(struct hdd_adapter *adapter) |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 3054 | { |
| 3055 | struct hdd_connect_pm_context *ctx = &adapter->connect_rpm_ctx; |
| 3056 | |
Prashanth Bhatta | 87b6dc0 | 2017-01-19 15:17:58 -0800 | [diff] [blame] | 3057 | qdf_runtime_lock_deinit(&ctx->connect); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 3058 | } |
| 3059 | #else /* FEATURE_RUNTIME_PM */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3060 | static void hdd_runtime_suspend_context_init(struct hdd_context *hdd_ctx) {} |
| 3061 | static void hdd_runtime_suspend_context_deinit(struct hdd_context *hdd_ctx) {} |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3062 | static inline void hdd_adapter_runtime_suspend_init(struct hdd_adapter *adapter) {} |
| 3063 | static inline void hdd_adapter_runtime_suspend_denit(struct hdd_adapter *adapter) {} |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 3064 | #endif /* FEATURE_RUNTIME_PM */ |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3065 | /** |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3066 | * hdd_alloc_station_adapter() - allocate the station hdd adapter |
| 3067 | * @hdd_ctx: global hdd context |
| 3068 | * @macAddr: mac address to assign to the interface |
| 3069 | * @name: User-visible name of the interface |
| 3070 | * |
| 3071 | * hdd adapter pointer would point to the netdev->priv space, this function |
| 3072 | * would retrive the pointer, and setup the hdd adapter configuration. |
| 3073 | * |
| 3074 | * Return: the pointer to hdd adapter, otherwise NULL |
| 3075 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3076 | static struct hdd_adapter *hdd_alloc_station_adapter(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3077 | tSirMacAddr macAddr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3078 | unsigned char name_assign_type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3079 | const char *name) |
| 3080 | { |
| 3081 | struct net_device *pWlanDev = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3082 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 3083 | struct hdd_station_ctx *sta_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3084 | /* |
| 3085 | * cfg80211 initialization and registration.... |
| 3086 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3087 | pWlanDev = alloc_netdev_mq(sizeof(struct hdd_adapter), name, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3088 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS) |
| 3089 | name_assign_type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3090 | #endif |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3091 | (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam() ? |
| 3092 | hdd_mon_mode_ether_setup : ether_setup), |
| 3093 | NUM_TX_QUEUES); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3094 | |
| 3095 | if (pWlanDev != NULL) { |
| 3096 | |
| 3097 | /* Save the pointer to the net_device in the HDD adapter */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3098 | adapter = (struct hdd_adapter *) netdev_priv(pWlanDev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3099 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3100 | qdf_mem_zero(adapter, sizeof(struct hdd_adapter)); |
Hanumanth Reddy Pothula | 18553ae | 2017-04-28 15:03:10 +0530 | [diff] [blame] | 3101 | sta_ctx = &adapter->sessionCtx.station; |
| 3102 | qdf_mem_set(sta_ctx->conn_info.staId, |
| 3103 | sizeof(sta_ctx->conn_info.staId), |
| 3104 | HDD_WLAN_INVALID_STA_ID); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3105 | adapter->dev = pWlanDev; |
Jeff Johnson | dba0db6 | 2017-08-30 11:12:39 -0700 | [diff] [blame] | 3106 | adapter->hdd_ctx = hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3107 | adapter->magic = WLAN_HDD_ADAPTER_MAGIC; |
Arun Khandavalli | 9ad88f0 | 2016-09-01 19:03:37 +0530 | [diff] [blame] | 3108 | adapter->sessionId = HDD_SESSION_ID_INVALID; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3109 | |
| 3110 | init_completion(&adapter->session_open_comp_var); |
| 3111 | init_completion(&adapter->session_close_comp_var); |
| 3112 | init_completion(&adapter->disconnect_comp_var); |
Abhishek Singh | 533c9da | 2017-05-04 10:23:34 +0530 | [diff] [blame] | 3113 | init_completion(&adapter->roaming_comp_var); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3114 | init_completion(&adapter->linkup_event_var); |
| 3115 | init_completion(&adapter->cancel_rem_on_chan_var); |
| 3116 | init_completion(&adapter->rem_on_chan_ready_event); |
| 3117 | init_completion(&adapter->sta_authorized_event); |
| 3118 | init_completion(&adapter->offchannel_tx_event); |
| 3119 | init_completion(&adapter->tx_action_cnf_event); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3120 | init_completion(&adapter->ibss_peer_info_comp); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3121 | init_completion(&adapter->change_country_code); |
| 3122 | |
| 3123 | |
| 3124 | init_completion(&adapter->scan_info.abortscan_event_var); |
Sreelakshmi Konamki | 88a2a41 | 2017-04-14 15:11:55 +0530 | [diff] [blame] | 3125 | init_completion(&adapter->lfr_fw_status.disable_lfr_event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3126 | |
| 3127 | adapter->offloads_configured = false; |
| 3128 | adapter->isLinkUpSvcNeeded = false; |
| 3129 | adapter->higherDtimTransition = true; |
| 3130 | /* Init the net_device structure */ |
| 3131 | strlcpy(pWlanDev->name, name, IFNAMSIZ); |
| 3132 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3133 | qdf_mem_copy(pWlanDev->dev_addr, (void *)macAddr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3134 | sizeof(tSirMacAddr)); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3135 | qdf_mem_copy(adapter->macAddressCurrent.bytes, macAddr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3136 | sizeof(tSirMacAddr)); |
| 3137 | pWlanDev->watchdog_timeo = HDD_TX_TIMEOUT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3138 | |
| 3139 | if (hdd_ctx->config->enable_ip_tcp_udp_checksum_offload) |
| 3140 | pWlanDev->features |= |
| 3141 | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM; |
| 3142 | pWlanDev->features |= NETIF_F_RXCSUM; |
| 3143 | |
Dhanashri Atre | 83d373d | 2015-07-28 16:45:59 -0700 | [diff] [blame] | 3144 | hdd_set_tso_flags(hdd_ctx, pWlanDev); |
| 3145 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3146 | hdd_set_station_ops(adapter->dev); |
| 3147 | |
Dustin Brown | c81dd41 | 2017-08-15 16:26:28 -0700 | [diff] [blame] | 3148 | hdd_dev_setup_destructor(pWlanDev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3149 | pWlanDev->ieee80211_ptr = &adapter->wdev; |
Mohit Khanna | ee9e80f | 2015-11-10 11:32:49 -0800 | [diff] [blame] | 3150 | pWlanDev->tx_queue_len = HDD_NETDEV_TX_QUEUE_LEN; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3151 | adapter->wdev.wiphy = hdd_ctx->wiphy; |
| 3152 | adapter->wdev.netdev = pWlanDev; |
| 3153 | /* set pWlanDev's parent to underlying device */ |
| 3154 | SET_NETDEV_DEV(pWlanDev, hdd_ctx->parent_dev); |
| 3155 | hdd_wmm_init(adapter); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 3156 | hdd_adapter_runtime_suspend_init(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3157 | spin_lock_init(&adapter->pause_map_lock); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 3158 | adapter->start_time = adapter->last_time = qdf_system_ticks(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3159 | } |
| 3160 | |
| 3161 | return adapter; |
| 3162 | } |
| 3163 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3164 | static QDF_STATUS hdd_register_interface(struct hdd_adapter *adapter, bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3165 | { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3166 | struct net_device *dev = adapter->dev; |
| 3167 | int ret; |
| 3168 | |
| 3169 | ENTER(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3170 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 3171 | if (rtnl_held) { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3172 | if (strnchr(dev->name, IFNAMSIZ - 1, '%')) { |
| 3173 | |
| 3174 | ret = dev_alloc_name(dev, dev->name); |
| 3175 | if (ret < 0) { |
| 3176 | hdd_err( |
| 3177 | "unable to get dev name: %s, err = 0x%x", |
| 3178 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3179 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3180 | } |
| 3181 | } |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3182 | |
| 3183 | ret = register_netdevice(dev); |
| 3184 | if (ret) { |
| 3185 | hdd_err("register_netdevice(%s) failed, err = 0x%x", |
| 3186 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3187 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3188 | } |
| 3189 | } else { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3190 | ret = register_netdev(dev); |
| 3191 | if (ret) { |
| 3192 | hdd_err("register_netdev(%s) failed, err = 0x%x", |
| 3193 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3194 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3195 | } |
| 3196 | } |
| 3197 | set_bit(NET_DEVICE_REGISTERED, &adapter->event_flags); |
| 3198 | |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3199 | EXIT(); |
| 3200 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3201 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3202 | } |
| 3203 | |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 3204 | QDF_STATUS hdd_sme_close_session_callback(void *pContext) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3205 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3206 | struct hdd_adapter *adapter = pContext; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3207 | |
| 3208 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3209 | hdd_err("NULL adapter"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3210 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3211 | } |
| 3212 | |
| 3213 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3214 | hdd_err("Invalid magic"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3215 | return QDF_STATUS_NOT_INITIALIZED; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3216 | } |
| 3217 | |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3218 | /* |
| 3219 | * For NAN Data interface, the close session results in the final |
| 3220 | * indication to the userspace |
| 3221 | */ |
Rakesh Sunki | 3480f96 | 2016-08-29 17:29:53 -0700 | [diff] [blame] | 3222 | if (adapter->device_mode == QDF_NDI_MODE) |
| 3223 | hdd_ndp_session_end_handler(adapter); |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3224 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3225 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 3226 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3227 | /* |
| 3228 | * We can be blocked while waiting for scheduled work to be |
| 3229 | * flushed, and the adapter structure can potentially be freed, in |
| 3230 | * which case the magic will have been reset. So make sure the |
| 3231 | * magic is still good, and hence the adapter structure is still |
| 3232 | * valid, before signaling completion |
| 3233 | */ |
| 3234 | if (WLAN_HDD_ADAPTER_MAGIC == adapter->magic) |
| 3235 | complete(&adapter->session_close_comp_var); |
| 3236 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3237 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3238 | } |
| 3239 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3240 | int hdd_vdev_ready(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3241 | { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3242 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3243 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3244 | status = pmo_vdev_ready(adapter->hdd_vdev); |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 3245 | if (QDF_IS_STATUS_ERROR(status)) |
| 3246 | return qdf_status_to_os_return(status); |
| 3247 | |
Kiran Kumar Lokere | 3beeb95 | 2017-05-02 18:40:24 -0700 | [diff] [blame] | 3248 | status = ucfg_reg_11d_vdev_created_update(adapter->hdd_vdev); |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 3249 | if (QDF_IS_STATUS_ERROR(status)) |
| 3250 | return qdf_status_to_os_return(status); |
| 3251 | |
| 3252 | if (wma_capability_enhanced_mcast_filter()) |
| 3253 | status = pmo_ucfg_enhanced_mc_filter_enable(adapter->hdd_vdev); |
| 3254 | else |
| 3255 | status = pmo_ucfg_enhanced_mc_filter_disable(adapter->hdd_vdev); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3256 | |
| 3257 | return qdf_status_to_os_return(status); |
| 3258 | } |
| 3259 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3260 | int hdd_vdev_destroy(struct hdd_adapter *adapter) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3261 | { |
| 3262 | QDF_STATUS status; |
| 3263 | int errno; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3264 | struct hdd_context *hdd_ctx; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3265 | unsigned long rc; |
| 3266 | |
| 3267 | hdd_info("destroying vdev %d", adapter->sessionId); |
| 3268 | |
| 3269 | /* vdev created sanity check */ |
| 3270 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 3271 | hdd_err("vdev for Id %d does not exist", adapter->sessionId); |
| 3272 | return -EINVAL; |
| 3273 | } |
Kiran Kumar Lokere | 3beeb95 | 2017-05-02 18:40:24 -0700 | [diff] [blame] | 3274 | status = ucfg_reg_11d_vdev_delete_update(adapter->hdd_vdev); |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 3275 | /* |
| 3276 | * In SSR case, there is no need to destroy vdev in firmware since |
| 3277 | * it has already asserted. vdev can be released directly. |
| 3278 | */ |
| 3279 | if (cds_is_driver_recovering()) |
| 3280 | goto release_vdev; |
| 3281 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3282 | /* close sme session (destroy vdev in firmware via legacy API) */ |
| 3283 | INIT_COMPLETION(adapter->session_close_comp_var); |
| 3284 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3285 | status = sme_close_session(hdd_ctx->hHal, adapter->sessionId, |
| 3286 | hdd_sme_close_session_callback, adapter); |
| 3287 | if (QDF_IS_STATUS_ERROR(status)) { |
| 3288 | hdd_err("failed to close sme session: %d", status); |
| 3289 | return qdf_status_to_os_return(status); |
| 3290 | } |
| 3291 | |
| 3292 | /* block on a completion variable until sme session is closed */ |
| 3293 | rc = wait_for_completion_timeout( |
| 3294 | &adapter->session_close_comp_var, |
| 3295 | msecs_to_jiffies(WLAN_WAIT_TIME_SESSIONOPENCLOSE)); |
| 3296 | if (!rc) { |
| 3297 | hdd_err("timed out waiting for close sme session: %ld", rc); |
| 3298 | if (adapter->device_mode == QDF_NDI_MODE) |
| 3299 | hdd_ndp_session_end_handler(adapter); |
| 3300 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 3301 | return -ETIMEDOUT; |
| 3302 | } |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 3303 | release_vdev: |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 3304 | /* do vdev logical destroy via objmgr */ |
| 3305 | errno = hdd_objmgr_destroy_vdev(adapter); |
| 3306 | if (errno) { |
| 3307 | hdd_err("failed to destroy objmgr vdev: %d", errno); |
| 3308 | return errno; |
| 3309 | } |
| 3310 | |
Dustin Brown | 0d2eeae | 2017-03-24 15:21:32 -0700 | [diff] [blame] | 3311 | /* now that sme session is closed, allow physical vdev destroy */ |
| 3312 | errno = hdd_objmgr_release_vdev(adapter); |
| 3313 | if (errno) { |
| 3314 | hdd_err("failed to release objmgr vdev: %d", errno); |
| 3315 | return errno; |
| 3316 | } |
| 3317 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3318 | hdd_info("vdev destroyed successfully"); |
| 3319 | |
| 3320 | return 0; |
| 3321 | } |
| 3322 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3323 | int hdd_vdev_create(struct hdd_adapter *adapter) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3324 | { |
| 3325 | QDF_STATUS status; |
| 3326 | int errno; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3327 | struct hdd_context *hdd_ctx; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3328 | uint32_t type; |
| 3329 | uint32_t sub_type; |
| 3330 | unsigned long rc; |
| 3331 | |
| 3332 | hdd_info("creating new vdev"); |
| 3333 | |
| 3334 | /* determine vdev (sub)type */ |
| 3335 | status = cds_get_vdev_types(adapter->device_mode, &type, &sub_type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3336 | if (QDF_STATUS_SUCCESS != status) { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3337 | hdd_err("failed to get vdev type: %d", status); |
| 3338 | return qdf_status_to_os_return(status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3339 | } |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3340 | |
| 3341 | /* do vdev create via objmgr */ |
| 3342 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Dustin Brown | 7d043f6 | 2017-03-27 12:07:36 -0700 | [diff] [blame] | 3343 | errno = hdd_objmgr_create_and_store_vdev(hdd_ctx->hdd_pdev, adapter); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3344 | if (errno) { |
| 3345 | hdd_err("failed to create objmgr vdev: %d", errno); |
| 3346 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3347 | } |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3348 | |
| 3349 | /* Open a SME session (prepare vdev in firmware via legacy API) */ |
| 3350 | INIT_COMPLETION(adapter->session_open_comp_var); |
| 3351 | status = sme_open_session(hdd_ctx->hHal, hdd_sme_roam_callback, adapter, |
| 3352 | (uint8_t *)&adapter->macAddressCurrent, |
| 3353 | adapter->sessionId, type, sub_type); |
| 3354 | if (QDF_IS_STATUS_ERROR(status)) { |
| 3355 | hdd_err("failed to open sme session: %d", status); |
| 3356 | errno = qdf_status_to_os_return(status); |
| 3357 | goto objmgr_vdev_destroy; |
| 3358 | } |
| 3359 | |
| 3360 | /* block on a completion variable until sme session is opened */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3361 | rc = wait_for_completion_timeout( |
| 3362 | &adapter->session_open_comp_var, |
| 3363 | msecs_to_jiffies(WLAN_WAIT_TIME_SESSIONOPENCLOSE)); |
| 3364 | if (!rc) { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3365 | hdd_err("timed out waiting for open sme session: %ld", rc); |
| 3366 | errno = -ETIMEDOUT; |
Abhishek Singh | 7e95dbc | 2017-07-06 17:57:50 +0530 | [diff] [blame] | 3367 | set_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 3368 | goto hdd_vdev_destroy; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3369 | } |
| 3370 | |
| 3371 | /* firmware ready for component communication, raise vdev_ready event */ |
| 3372 | errno = hdd_vdev_ready(adapter); |
| 3373 | if (errno) { |
| 3374 | hdd_err("failed to dispatch vdev ready event: %d", errno); |
| 3375 | goto hdd_vdev_destroy; |
| 3376 | } |
| 3377 | |
| 3378 | hdd_info("vdev %d created successfully", adapter->sessionId); |
| 3379 | |
| 3380 | return 0; |
| 3381 | |
| 3382 | /* |
| 3383 | * Due to legacy constraints, we need to destroy in the same order as |
| 3384 | * create. So, split error handling into 2 cases to accommodate. |
| 3385 | */ |
| 3386 | |
| 3387 | objmgr_vdev_destroy: |
Dustin Brown | 7d043f6 | 2017-03-27 12:07:36 -0700 | [diff] [blame] | 3388 | QDF_BUG(!hdd_objmgr_release_and_destroy_vdev(adapter)); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3389 | |
| 3390 | return errno; |
| 3391 | |
| 3392 | hdd_vdev_destroy: |
| 3393 | QDF_BUG(!hdd_vdev_destroy(adapter)); |
| 3394 | |
| 3395 | return errno; |
| 3396 | } |
| 3397 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3398 | QDF_STATUS hdd_init_station_mode(struct hdd_adapter *adapter) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3399 | { |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 3400 | struct hdd_station_ctx *pHddStaCtx = &adapter->sessionCtx.station; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3401 | struct hdd_context *hdd_ctx; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3402 | QDF_STATUS status; |
| 3403 | int ret_val; |
| 3404 | |
| 3405 | ret_val = hdd_vdev_create(adapter); |
| 3406 | if (ret_val) { |
| 3407 | hdd_err("failed to create vdev: %d", ret_val); |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 3408 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3409 | } |
| 3410 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3411 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3412 | sme_set_curr_device_mode(hdd_ctx->hHal, adapter->device_mode); |
| 3413 | sme_set_pdev_ht_vht_ies(hdd_ctx->hHal, hdd_ctx->config->enable2x2); |
Naveen Rawat | a410c5a | 2016-09-19 14:22:33 -0700 | [diff] [blame] | 3414 | sme_set_vdev_ies_per_band(hdd_ctx->hHal, adapter->sessionId); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3415 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3416 | /* Register wireless extensions */ |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3417 | status = hdd_register_wext(adapter->dev); |
| 3418 | if (QDF_IS_STATUS_ERROR(status)) { |
| 3419 | hdd_err("failed to register wireless extensions: %d", status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3420 | goto error_register_wext; |
| 3421 | } |
Varun Reddy Yeturu | 9e0032c | 2017-07-12 18:39:59 -0700 | [diff] [blame] | 3422 | hdd_conn_set_connection_state(adapter, eConnectionState_NotConnected); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3423 | |
Hanumanth Reddy Pothula | b2d729c | 2017-05-30 11:49:53 +0530 | [diff] [blame] | 3424 | qdf_mem_set(pHddStaCtx->conn_info.staId, |
| 3425 | sizeof(pHddStaCtx->conn_info.staId), HDD_WLAN_INVALID_STA_ID); |
| 3426 | |
Deepak Dhamdhere | a278582 | 2016-11-17 01:17:45 -0800 | [diff] [blame] | 3427 | /* set fast roaming capability in sme session */ |
| 3428 | status = sme_config_fast_roaming(hdd_ctx->hHal, adapter->sessionId, |
| 3429 | adapter->fast_roaming_allowed); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3430 | /* Set the default operation channel */ |
| 3431 | pHddStaCtx->conn_info.operationChannel = |
| 3432 | hdd_ctx->config->OperatingChannel; |
| 3433 | |
| 3434 | /* Make the default Auth Type as OPEN */ |
| 3435 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 3436 | |
| 3437 | status = hdd_init_tx_rx(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3438 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3439 | hdd_err("hdd_init_tx_rx() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3440 | status, status); |
| 3441 | goto error_init_txrx; |
| 3442 | } |
| 3443 | |
| 3444 | set_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 3445 | |
| 3446 | status = hdd_wmm_adapter_init(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3447 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3448 | hdd_err("hdd_wmm_adapter_init() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3449 | status, status); |
| 3450 | goto error_wmm_init; |
| 3451 | } |
| 3452 | |
| 3453 | set_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 3454 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 3455 | ret_val = sme_cli_set_command(adapter->sessionId, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3456 | WMI_PDEV_PARAM_BURST_ENABLE, |
| 3457 | hdd_ctx->config->enableSifsBurst, |
| 3458 | PDEV_CMD); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3459 | if (ret_val) |
| 3460 | hdd_err("WMI_PDEV_PARAM_BURST_ENABLE set failed %d", ret_val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3461 | |
Dhanashri Atre | 1a6a4ce | 2017-05-03 19:40:33 -0700 | [diff] [blame] | 3462 | adapter->dev->features |= NETIF_F_LRO; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3463 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3464 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3465 | error_wmm_init: |
| 3466 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 3467 | hdd_deinit_tx_rx(adapter); |
| 3468 | error_init_txrx: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3469 | hdd_unregister_wext(adapter->dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3470 | error_register_wext: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3471 | QDF_BUG(!hdd_vdev_destroy(adapter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3472 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3473 | return status; |
| 3474 | } |
| 3475 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3476 | void hdd_cleanup_actionframe(struct hdd_context *hdd_ctx, struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3477 | { |
| 3478 | hdd_cfg80211_state_t *cfgState; |
| 3479 | |
| 3480 | cfgState = WLAN_HDD_GET_CFG_STATE_PTR(adapter); |
| 3481 | |
| 3482 | if (NULL != cfgState->buf) { |
| 3483 | unsigned long rc; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3484 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3485 | rc = wait_for_completion_timeout( |
| 3486 | &adapter->tx_action_cnf_event, |
| 3487 | msecs_to_jiffies(ACTION_FRAME_TX_TIMEOUT)); |
| 3488 | if (!rc) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3489 | hdd_err("HDD Wait for Action Confirmation Failed!!"); |
Masti, Narayanraddi | f8f6e7e | 2015-08-25 10:22:46 +0530 | [diff] [blame] | 3490 | /* |
| 3491 | * Inform tx status as FAILURE to upper layer and free |
| 3492 | * cfgState->buf |
| 3493 | */ |
| 3494 | hdd_send_action_cnf(adapter, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3495 | } |
| 3496 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3497 | } |
| 3498 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3499 | /** |
| 3500 | * hdd_station_adapter_deinit() - De-initialize the station adapter |
| 3501 | * @hdd_ctx: global hdd context |
| 3502 | * @adapter: HDD adapter |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3503 | * @rtnl_held: Used to indicate whether or not the caller is holding |
| 3504 | * the kernel rtnl_mutex |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3505 | * |
| 3506 | * This function De-initializes the STA/P2P/OCB adapter. |
| 3507 | * |
| 3508 | * Return: None. |
| 3509 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3510 | static void hdd_station_adapter_deinit(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3511 | struct hdd_adapter *adapter, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3512 | bool rtnl_held) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3513 | { |
| 3514 | ENTER_DEV(adapter->dev); |
| 3515 | |
Hanumanth Reddy Pothula | 7a65740 | 2016-09-07 20:59:18 +0530 | [diff] [blame] | 3516 | if (adapter->dev) { |
| 3517 | if (rtnl_held) |
| 3518 | adapter->dev->wireless_handlers = NULL; |
| 3519 | else { |
| 3520 | rtnl_lock(); |
| 3521 | adapter->dev->wireless_handlers = NULL; |
| 3522 | rtnl_unlock(); |
| 3523 | } |
| 3524 | } |
| 3525 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3526 | if (test_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags)) { |
| 3527 | hdd_deinit_tx_rx(adapter); |
| 3528 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 3529 | } |
| 3530 | |
| 3531 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 3532 | hdd_wmm_adapter_close(adapter); |
| 3533 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 3534 | } |
| 3535 | |
| 3536 | hdd_cleanup_actionframe(hdd_ctx, adapter); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3537 | |
| 3538 | EXIT(); |
| 3539 | } |
| 3540 | |
| 3541 | /** |
| 3542 | * hdd_ap_adapter_deinit() - De-initialize the ap adapter |
| 3543 | * @hdd_ctx: global hdd context |
| 3544 | * @adapter: HDD adapter |
| 3545 | * @rtnl_held: the rtnl lock hold flag |
| 3546 | * This function De-initializes the AP/P2PGo adapter. |
| 3547 | * |
| 3548 | * Return: None. |
| 3549 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3550 | static void hdd_ap_adapter_deinit(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3551 | struct hdd_adapter *adapter, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3552 | bool rtnl_held) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3553 | { |
| 3554 | ENTER_DEV(adapter->dev); |
| 3555 | |
| 3556 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 3557 | hdd_wmm_adapter_close(adapter); |
| 3558 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 3559 | } |
Liangwei Dong | 8baf7c8 | 2016-10-11 01:26:59 -0400 | [diff] [blame] | 3560 | wlan_hdd_undo_acs(adapter); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3561 | |
| 3562 | hdd_cleanup_actionframe(hdd_ctx, adapter); |
| 3563 | |
| 3564 | hdd_unregister_hostapd(adapter, rtnl_held); |
| 3565 | |
| 3566 | EXIT(); |
| 3567 | } |
| 3568 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3569 | void hdd_deinit_adapter(struct hdd_context *hdd_ctx, struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3570 | bool rtnl_held) |
| 3571 | { |
| 3572 | ENTER(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3573 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3574 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3575 | case QDF_STA_MODE: |
| 3576 | case QDF_P2P_CLIENT_MODE: |
| 3577 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3578 | { |
Hanumanth Reddy Pothula | 7a65740 | 2016-09-07 20:59:18 +0530 | [diff] [blame] | 3579 | hdd_station_adapter_deinit(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3580 | break; |
| 3581 | } |
| 3582 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3583 | case QDF_SAP_MODE: |
| 3584 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3585 | { |
| 3586 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3587 | hdd_ap_adapter_deinit(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3588 | break; |
| 3589 | } |
| 3590 | |
| 3591 | default: |
| 3592 | break; |
| 3593 | } |
| 3594 | |
| 3595 | EXIT(); |
| 3596 | } |
| 3597 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3598 | static void hdd_cleanup_adapter(struct hdd_context *hdd_ctx, struct hdd_adapter *adapter, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3599 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3600 | { |
| 3601 | struct net_device *pWlanDev = NULL; |
| 3602 | |
| 3603 | if (adapter) |
| 3604 | pWlanDev = adapter->dev; |
| 3605 | else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3606 | hdd_err("adapter is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3607 | return; |
| 3608 | } |
| 3609 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 3610 | hdd_debugfs_exit(adapter); |
Selvaraj, Sridhar | 4ea106e | 2016-08-05 20:34:46 +0530 | [diff] [blame] | 3611 | |
| 3612 | if (adapter->scan_info.default_scan_ies) { |
| 3613 | qdf_mem_free(adapter->scan_info.default_scan_ies); |
| 3614 | adapter->scan_info.default_scan_ies = NULL; |
| 3615 | } |
| 3616 | |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 3617 | hdd_adapter_runtime_suspend_denit(adapter); |
| 3618 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3619 | /* |
| 3620 | * The adapter is marked as closed. When hdd_wlan_exit() call returns, |
| 3621 | * the driver is almost closed and cannot handle either control |
| 3622 | * messages or data. However, unregister_netdevice() call above will |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3623 | * eventually invoke hdd_stop(ndo_close) driver callback, which attempts |
| 3624 | * to close the active connections(basically excites control path) which |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3625 | * is not right. Setting this flag helps hdd_stop() to recognize that |
| 3626 | * the interface is closed and restricts any operations on that |
| 3627 | */ |
| 3628 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 3629 | |
| 3630 | if (test_bit(NET_DEVICE_REGISTERED, &adapter->event_flags)) { |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3631 | if (rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3632 | unregister_netdevice(pWlanDev); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3633 | else |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3634 | unregister_netdev(pWlanDev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3635 | /* |
| 3636 | * Note that the adapter is no longer valid at this point |
| 3637 | * since the memory has been reclaimed |
| 3638 | */ |
| 3639 | } |
| 3640 | } |
| 3641 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3642 | static QDF_STATUS hdd_check_for_existing_macaddr(struct hdd_context *hdd_ctx, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3643 | tSirMacAddr macAddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3644 | { |
| 3645 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3646 | struct hdd_adapter *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3647 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3648 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3649 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3650 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3651 | adapter = adapterNode->pAdapter; |
| 3652 | if (adapter |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3653 | && !qdf_mem_cmp(adapter->macAddressCurrent.bytes, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3654 | macAddr, sizeof(tSirMacAddr))) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3655 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3656 | } |
| 3657 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 3658 | adapterNode = pNext; |
| 3659 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3660 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3661 | } |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3662 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3663 | #ifdef CONFIG_FW_LOGS_BASED_ON_INI |
| 3664 | /** |
| 3665 | * hdd_set_fw_log_params() - Set log parameters to FW |
| 3666 | * @hdd_ctx: HDD Context |
| 3667 | * @adapter: HDD Adapter |
| 3668 | * |
| 3669 | * This function set the FW Debug log level based on the INI. |
| 3670 | * |
| 3671 | * Return: None |
| 3672 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3673 | static void hdd_set_fw_log_params(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3674 | struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3675 | { |
| 3676 | uint8_t count = 0, numentries = 0, |
| 3677 | moduleloglevel[FW_MODULE_LOG_LEVEL_STRING_LENGTH]; |
| 3678 | uint32_t value = 0; |
| 3679 | int ret; |
| 3680 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3681 | if (QDF_GLOBAL_FTM_MODE == cds_get_conparam() || |
| 3682 | (!hdd_ctx->config->enable_fw_log)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3683 | hdd_debug("enable_fw_log not enabled in INI or in FTM mode return"); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3684 | return; |
| 3685 | } |
| 3686 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3687 | /* Enable FW logs based on INI configuration */ |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3688 | hdd_ctx->fw_log_settings.dl_type = |
| 3689 | hdd_ctx->config->enableFwLogType; |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 3690 | ret = sme_cli_set_command(adapter->sessionId, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3691 | WMI_DBGLOG_TYPE, |
| 3692 | hdd_ctx->config->enableFwLogType, |
| 3693 | DBG_CMD); |
| 3694 | if (ret != 0) |
| 3695 | hdd_err("Failed to enable FW log type ret %d", |
| 3696 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3697 | |
| 3698 | hdd_ctx->fw_log_settings.dl_loglevel = |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3699 | hdd_ctx->config->enableFwLogLevel; |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 3700 | ret = sme_cli_set_command(adapter->sessionId, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3701 | WMI_DBGLOG_LOG_LEVEL, |
| 3702 | hdd_ctx->config->enableFwLogLevel, |
| 3703 | DBG_CMD); |
| 3704 | if (ret != 0) |
| 3705 | hdd_err("Failed to enable FW log level ret %d", |
| 3706 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3707 | |
| 3708 | hdd_string_to_u8_array( |
| 3709 | hdd_ctx->config->enableFwModuleLogLevel, |
| 3710 | moduleloglevel, |
| 3711 | &numentries, |
| 3712 | FW_MODULE_LOG_LEVEL_STRING_LENGTH); |
| 3713 | |
| 3714 | while (count < numentries) { |
| 3715 | /* |
| 3716 | * FW module log level input string looks like |
| 3717 | * below: |
| 3718 | * gFwDebugModuleLoglevel=<FW Module ID>, |
| 3719 | * <Log Level>,... |
| 3720 | * For example: |
| 3721 | * gFwDebugModuleLoglevel= |
| 3722 | * 1,0,2,1,3,2,4,3,5,4,6,5,7,6 |
| 3723 | * Above input string means : |
| 3724 | * For FW module ID 1 enable log level 0 |
| 3725 | * For FW module ID 2 enable log level 1 |
| 3726 | * For FW module ID 3 enable log level 2 |
| 3727 | * For FW module ID 4 enable log level 3 |
| 3728 | * For FW module ID 5 enable log level 4 |
| 3729 | * For FW module ID 6 enable log level 5 |
| 3730 | * For FW module ID 7 enable log level 6 |
| 3731 | */ |
| 3732 | |
Nishank Aggarwal | e239d96 | 2017-03-03 12:26:02 +0530 | [diff] [blame] | 3733 | if ((moduleloglevel[count] > WLAN_MODULE_ID_MAX) |
| 3734 | || (moduleloglevel[count + 1] > DBGLOG_LVL_MAX)) { |
| 3735 | hdd_err("Module id %d and dbglog level %d input length is more than max", |
| 3736 | moduleloglevel[count], |
| 3737 | moduleloglevel[count + 1]); |
| 3738 | return; |
| 3739 | } |
| 3740 | |
| 3741 | value = moduleloglevel[count] << 16; |
| 3742 | value |= moduleloglevel[count + 1]; |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 3743 | ret = sme_cli_set_command(adapter->sessionId, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3744 | WMI_DBGLOG_MOD_LOG_LEVEL, |
| 3745 | value, DBG_CMD); |
| 3746 | if (ret != 0) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3747 | hdd_err("Failed to enable FW module log level %d ret %d", |
| 3748 | value, ret); |
| 3749 | |
| 3750 | count += 2; |
| 3751 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3752 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3753 | } |
| 3754 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3755 | static void hdd_set_fw_log_params(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3756 | struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3757 | { |
| 3758 | } |
| 3759 | |
| 3760 | #endif |
| 3761 | |
| 3762 | /** |
| 3763 | * hdd_set_fw_params() - Set parameters to firmware |
| 3764 | * @adapter: HDD adapter |
| 3765 | * |
| 3766 | * This function Sets various parameters to fw once the |
| 3767 | * adapter is started. |
| 3768 | * |
| 3769 | * Return: 0 on success or errno on failure |
| 3770 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3771 | int hdd_set_fw_params(struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3772 | { |
| 3773 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3774 | struct hdd_context *hdd_ctx; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3775 | |
| 3776 | ENTER_DEV(adapter->dev); |
| 3777 | |
| 3778 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 3779 | if (!hdd_ctx) |
| 3780 | return -EINVAL; |
| 3781 | |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 3782 | if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE) { |
| 3783 | hdd_debug("FTM Mode is active; nothing to do"); |
| 3784 | return 0; |
| 3785 | } |
| 3786 | |
Ashish Kumar Dhanotiya | b8630ab | 2017-07-21 14:18:14 +0530 | [diff] [blame] | 3787 | ret = sme_cli_set_command(adapter->sessionId, |
| 3788 | WMI_PDEV_PARAM_DTIM_SYNTH, |
| 3789 | hdd_ctx->config->enable_lprx, PDEV_CMD); |
| 3790 | if (ret) { |
| 3791 | hdd_err("Failed to set LPRx"); |
| 3792 | goto error; |
| 3793 | } |
| 3794 | |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 3795 | if (adapter->device_mode == QDF_STA_MODE) { |
| 3796 | sme_set_smps_cfg(adapter->sessionId, |
| 3797 | HDD_STA_SMPS_PARAM_UPPER_BRSSI_THRESH, |
| 3798 | hdd_ctx->config->upper_brssi_thresh); |
| 3799 | |
| 3800 | sme_set_smps_cfg(adapter->sessionId, |
| 3801 | HDD_STA_SMPS_PARAM_LOWER_BRSSI_THRESH, |
| 3802 | hdd_ctx->config->lower_brssi_thresh); |
| 3803 | |
| 3804 | sme_set_smps_cfg(adapter->sessionId, |
| 3805 | HDD_STA_SMPS_PARAM_DTIM_1CHRX_ENABLE, |
| 3806 | hdd_ctx->config->enable_dtim_1chrx); |
| 3807 | } |
| 3808 | |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 3809 | if (hdd_ctx->config->enable2x2) { |
| 3810 | hdd_debug("configuring 2x2 mode fw params"); |
| 3811 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 3812 | ret = sme_cli_set_command(adapter->sessionId, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 3813 | WMI_PDEV_PARAM_ENABLE_CCK_TXFIR_OVERRIDE, |
| 3814 | hdd_ctx->config->enable_cck_tx_fir_override, |
| 3815 | PDEV_CMD); |
| 3816 | if (ret) { |
| 3817 | hdd_err("WMI_PDEV_PARAM_ENABLE_CCK_TXFIR_OVERRIDE set failed %d", |
| 3818 | ret); |
| 3819 | goto error; |
| 3820 | } |
| 3821 | } else { |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3822 | #define HDD_DTIM_1CHAIN_RX_ID 0x5 |
| 3823 | #define HDD_SMPS_PARAM_VALUE_S 29 |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 3824 | hdd_debug("configuring 1x1 mode fw params"); |
| 3825 | |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 3826 | /* |
| 3827 | * Disable DTIM 1 chain Rx when in 1x1, |
| 3828 | * we are passing two value |
| 3829 | * as param_id << 29 | param_value. |
| 3830 | * Below param_value = 0(disable) |
| 3831 | */ |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 3832 | ret = sme_cli_set_command(adapter->sessionId, |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 3833 | WMI_STA_SMPS_PARAM_CMDID, |
| 3834 | HDD_DTIM_1CHAIN_RX_ID << |
| 3835 | HDD_SMPS_PARAM_VALUE_S, |
| 3836 | VDEV_CMD); |
| 3837 | if (ret) { |
| 3838 | hdd_err("DTIM 1 chain set failed %d", ret); |
| 3839 | goto error; |
| 3840 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3841 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 3842 | ret = sme_cli_set_command(adapter->sessionId, |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 3843 | WMI_PDEV_PARAM_TX_CHAIN_MASK, |
| 3844 | hdd_ctx->config->txchainmask1x1, |
| 3845 | PDEV_CMD); |
| 3846 | if (ret) { |
| 3847 | hdd_err("WMI_PDEV_PARAM_TX_CHAIN_MASK set failed %d", |
| 3848 | ret); |
| 3849 | goto error; |
| 3850 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3851 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 3852 | ret = sme_cli_set_command(adapter->sessionId, |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 3853 | WMI_PDEV_PARAM_RX_CHAIN_MASK, |
| 3854 | hdd_ctx->config->rxchainmask1x1, |
| 3855 | PDEV_CMD); |
| 3856 | if (ret) { |
| 3857 | hdd_err("WMI_PDEV_PARAM_RX_CHAIN_MASK set failed %d", |
| 3858 | ret); |
| 3859 | goto error; |
| 3860 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3861 | #undef HDD_DTIM_1CHAIN_RX_ID |
| 3862 | #undef HDD_SMPS_PARAM_VALUE_S |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 3863 | } |
| 3864 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 3865 | ret = sme_cli_set_command(adapter->sessionId, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 3866 | WMI_PDEV_PARAM_HYST_EN, |
| 3867 | hdd_ctx->config->enableMemDeepSleep, |
| 3868 | PDEV_CMD); |
| 3869 | if (ret) { |
| 3870 | hdd_err("WMI_PDEV_PARAM_HYST_EN set failed %d", ret); |
| 3871 | goto error; |
| 3872 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3873 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 3874 | ret = sme_cli_set_command(adapter->sessionId, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 3875 | WMI_VDEV_PARAM_ENABLE_RTSCTS, |
| 3876 | hdd_ctx->config->rts_profile, |
| 3877 | VDEV_CMD); |
| 3878 | if (ret) { |
| 3879 | hdd_err("FAILED TO SET RTSCTS Profile ret:%d", ret); |
| 3880 | goto error; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3881 | } |
| 3882 | |
Deepak Dhamdhere | 612392c | 2016-08-28 02:56:51 -0700 | [diff] [blame] | 3883 | hdd_debug("SET AMSDU num %d", hdd_ctx->config->max_amsdu_num); |
| 3884 | |
| 3885 | ret = wma_cli_set_command(adapter->sessionId, |
| 3886 | GEN_VDEV_PARAM_AMSDU, |
| 3887 | hdd_ctx->config->max_amsdu_num, |
| 3888 | GEN_CMD); |
| 3889 | if (ret != 0) { |
| 3890 | hdd_err("GEN_VDEV_PARAM_AMSDU set failed %d", ret); |
| 3891 | goto error; |
| 3892 | } |
| 3893 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3894 | hdd_set_fw_log_params(hdd_ctx, adapter); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3895 | EXIT(); |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 3896 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3897 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3898 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3899 | error: |
| 3900 | return -EINVAL; |
| 3901 | } |
| 3902 | |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3903 | /** |
| 3904 | * hdd_open_adapter() - open and setup the hdd adatper |
| 3905 | * @hdd_ctx: global hdd context |
| 3906 | * @session_type: type of the interface to be created |
| 3907 | * @iface_name: User-visible name of the interface |
| 3908 | * @macAddr: MAC address to assign to the interface |
| 3909 | * @name_assign_type: the name of assign type of the netdev |
| 3910 | * @rtnl_held: the rtnl lock hold flag |
| 3911 | * |
| 3912 | * This function open and setup the hdd adpater according to the device |
| 3913 | * type request, assign the name, the mac address assigned, and then prepared |
| 3914 | * the hdd related parameters, queue, lock and ready to start. |
| 3915 | * |
| 3916 | * Return: the pointer of hdd adapter, otherwise NULL. |
| 3917 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3918 | struct hdd_adapter *hdd_open_adapter(struct hdd_context *hdd_ctx, uint8_t session_type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3919 | const char *iface_name, tSirMacAddr macAddr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3920 | unsigned char name_assign_type, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 3921 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3922 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3923 | struct hdd_adapter *adapter = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3924 | hdd_adapter_list_node_t *pHddAdapterNode = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3925 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3926 | hdd_cfg80211_state_t *cfgState; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3927 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3928 | |
| 3929 | if (hdd_ctx->current_intf_count >= hdd_ctx->max_intf_count) { |
| 3930 | /* |
| 3931 | * Max limit reached on the number of vdevs configured by the |
| 3932 | * host. Return error |
| 3933 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3934 | hdd_err("Unable to add virtual intf: currentVdevCnt=%d,hostConfiguredVdevCnt=%d", |
| 3935 | hdd_ctx->current_intf_count, hdd_ctx->max_intf_count); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3936 | return NULL; |
| 3937 | } |
| 3938 | |
| 3939 | if (macAddr == NULL) { |
| 3940 | /* Not received valid macAddr */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3941 | hdd_err("Unable to add virtual intf: Not able to get valid mac address"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3942 | return NULL; |
| 3943 | } |
| 3944 | status = hdd_check_for_existing_macaddr(hdd_ctx, macAddr); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3945 | if (QDF_STATUS_E_FAILURE == status) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3946 | hdd_err("Duplicate MAC addr: " MAC_ADDRESS_STR |
| 3947 | " already exists", |
| 3948 | MAC_ADDR_ARRAY(macAddr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3949 | return NULL; |
| 3950 | } |
| 3951 | |
| 3952 | switch (session_type) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3953 | case QDF_STA_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3954 | /* Reset locally administered bit if the device mode is STA */ |
| 3955 | WLAN_HDD_RESET_LOCALLY_ADMINISTERED_BIT(macAddr); |
Arunk Khandavalli | 794fdfc | 2017-09-13 18:00:40 +0530 | [diff] [blame] | 3956 | hdd_info("locally administered bit reset in sta mode: " |
| 3957 | MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3958 | /* fall through */ |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3959 | case QDF_P2P_CLIENT_MODE: |
| 3960 | case QDF_P2P_DEVICE_MODE: |
| 3961 | case QDF_OCB_MODE: |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 3962 | case QDF_NDI_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 3963 | case QDF_MONITOR_MODE: |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3964 | adapter = hdd_alloc_station_adapter(hdd_ctx, macAddr, |
| 3965 | name_assign_type, |
| 3966 | iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3967 | |
| 3968 | if (NULL == adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3969 | hdd_err("failed to allocate adapter for session %d", |
| 3970 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3971 | return NULL; |
| 3972 | } |
| 3973 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3974 | if (QDF_P2P_CLIENT_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3975 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_CLIENT; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3976 | else if (QDF_P2P_DEVICE_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3977 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_DEVICE; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 3978 | else if (QDF_MONITOR_MODE == session_type) |
| 3979 | adapter->wdev.iftype = NL80211_IFTYPE_MONITOR; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3980 | else |
| 3981 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 3982 | |
| 3983 | adapter->device_mode = session_type; |
| 3984 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3985 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3986 | /* |
| 3987 | * Workqueue which gets scheduled in IPv4 notification |
| 3988 | * callback |
| 3989 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3990 | INIT_WORK(&adapter->ipv4NotifierWorkQueue, |
| 3991 | hdd_ipv4_notifier_work_queue); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3992 | |
| 3993 | #ifdef WLAN_NS_OFFLOAD |
| 3994 | /* |
| 3995 | * Workqueue which gets scheduled in IPv6 |
| 3996 | * notification callback. |
| 3997 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3998 | INIT_WORK(&adapter->ipv6NotifierWorkQueue, |
| 3999 | hdd_ipv6_notifier_work_queue); |
| 4000 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4001 | status = hdd_register_interface(adapter, rtnl_held); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4002 | if (QDF_STATUS_SUCCESS != status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4003 | hdd_deinit_adapter(hdd_ctx, adapter, rtnl_held); |
Hanumanth Reddy Pothula | 00a39e7 | 2016-11-09 21:32:16 +0530 | [diff] [blame] | 4004 | goto err_free_netdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4005 | } |
| 4006 | |
| 4007 | /* Stop the Interface TX queue. */ |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4008 | hdd_debug("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4009 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4010 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4011 | WLAN_CONTROL_PATH); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4012 | |
Ravi Joshi | 1a29256 | 2017-05-18 16:28:54 -0700 | [diff] [blame] | 4013 | /* Initialize NAN Data Interface */ |
| 4014 | if (QDF_NDI_MODE == session_type) { |
| 4015 | status = hdd_init_nan_data_mode(adapter); |
| 4016 | if (QDF_STATUS_SUCCESS != status) |
| 4017 | goto err_free_netdev; |
| 4018 | } |
| 4019 | |
| 4020 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4021 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4022 | case QDF_P2P_GO_MODE: |
| 4023 | case QDF_SAP_MODE: |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4024 | adapter = hdd_wlan_create_ap_dev(hdd_ctx, macAddr, |
| 4025 | name_assign_type, |
| 4026 | (uint8_t *) iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4027 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4028 | hdd_err("failed to allocate adapter for session %d", |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4029 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4030 | return NULL; |
| 4031 | } |
| 4032 | |
| 4033 | adapter->wdev.iftype = |
| 4034 | (session_type == |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4035 | QDF_SAP_MODE) ? NL80211_IFTYPE_AP : |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4036 | NL80211_IFTYPE_P2P_GO; |
| 4037 | adapter->device_mode = session_type; |
| 4038 | |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 4039 | status = hdd_register_interface(adapter, rtnl_held); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4040 | if (QDF_STATUS_SUCCESS != status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4041 | hdd_deinit_adapter(hdd_ctx, adapter, rtnl_held); |
| 4042 | goto err_free_netdev; |
| 4043 | } |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4044 | hdd_debug("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4045 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4046 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4047 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4048 | break; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4049 | case QDF_FTM_MODE: |
| 4050 | adapter = hdd_alloc_station_adapter(hdd_ctx, macAddr, |
| 4051 | name_assign_type, |
| 4052 | "wlan0"); |
| 4053 | if (NULL == adapter) { |
| 4054 | hdd_err("Failed to allocate adapter for FTM mode"); |
| 4055 | return NULL; |
| 4056 | } |
| 4057 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 4058 | adapter->device_mode = session_type; |
| 4059 | status = hdd_register_interface(adapter, rtnl_held); |
| 4060 | if (QDF_STATUS_SUCCESS != status) { |
| 4061 | hdd_deinit_adapter(hdd_ctx, adapter, rtnl_held); |
| 4062 | goto err_free_netdev; |
| 4063 | } |
| 4064 | /* Stop the Interface TX queue. */ |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4065 | hdd_debug("Disabling queues"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4066 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4067 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4068 | WLAN_CONTROL_PATH); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4069 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4070 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4071 | hdd_err("Invalid session type %d", session_type); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4072 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4073 | return NULL; |
| 4074 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4075 | |
hqu | eaa33ee | 2017-05-04 17:56:35 +0800 | [diff] [blame] | 4076 | INIT_WORK(&adapter->scan_block_work, wlan_hdd_cfg80211_scan_block_cb); |
| 4077 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4078 | cfgState = WLAN_HDD_GET_CFG_STATE_PTR(adapter); |
| 4079 | mutex_init(&cfgState->remain_on_chan_ctx_lock); |
| 4080 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4081 | if (QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4082 | /* Add it to the hdd's session list. */ |
| 4083 | pHddAdapterNode = |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4084 | qdf_mem_malloc(sizeof(hdd_adapter_list_node_t)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4085 | if (NULL == pHddAdapterNode) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4086 | status = QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4087 | } else { |
| 4088 | pHddAdapterNode->pAdapter = adapter; |
| 4089 | status = hdd_add_adapter_back(hdd_ctx, pHddAdapterNode); |
| 4090 | } |
| 4091 | } |
| 4092 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4093 | if (QDF_STATUS_SUCCESS != status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4094 | if (NULL != adapter) { |
| 4095 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 4096 | adapter = NULL; |
| 4097 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4098 | if (NULL != pHddAdapterNode) |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4099 | qdf_mem_free(pHddAdapterNode); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4100 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4101 | return NULL; |
| 4102 | } |
| 4103 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4104 | if (QDF_STATUS_SUCCESS == status) { |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 4105 | policy_mgr_set_concurrency_mode(hdd_ctx->hdd_psoc, |
| 4106 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4107 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4108 | /* Adapter successfully added. Increment the vdev count */ |
| 4109 | hdd_ctx->current_intf_count++; |
| 4110 | |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4111 | hdd_debug("current_intf_count=%d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4112 | hdd_ctx->current_intf_count); |
| 4113 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 4114 | hdd_check_and_restart_sap_with_non_dfs_acs(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4115 | } |
| 4116 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 4117 | if (QDF_STATUS_SUCCESS != hdd_debugfs_init(adapter)) |
Mahesh Kumar Kalikot Veetil | 80dda9a | 2017-07-17 11:38:03 -0700 | [diff] [blame] | 4118 | hdd_err("Interface %s wow debug_fs init failed", |
| 4119 | netdev_name(adapter->dev)); |
| 4120 | |
| 4121 | hdd_info("%s interface created. iftype: %d", netdev_name(adapter->dev), |
| 4122 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4123 | |
| 4124 | return adapter; |
| 4125 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4126 | err_free_netdev: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4127 | wlan_hdd_release_intf_addr(hdd_ctx, adapter->macAddressCurrent.bytes); |
Hanumanth Reddy Pothula | 00a39e7 | 2016-11-09 21:32:16 +0530 | [diff] [blame] | 4128 | free_netdev(adapter->dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4129 | |
| 4130 | return NULL; |
| 4131 | } |
| 4132 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4133 | QDF_STATUS hdd_close_adapter(struct hdd_context *hdd_ctx, struct hdd_adapter *adapter, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 4134 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4135 | { |
| 4136 | hdd_adapter_list_node_t *adapterNode, *pCurrent, *pNext; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4137 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4138 | |
| 4139 | status = hdd_get_front_adapter(hdd_ctx, &pCurrent); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4140 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4141 | hdd_warn("adapter list empty %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4142 | status); |
| 4143 | return status; |
| 4144 | } |
| 4145 | |
| 4146 | while (pCurrent->pAdapter != adapter) { |
| 4147 | status = hdd_get_next_adapter(hdd_ctx, pCurrent, &pNext); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4148 | if (QDF_STATUS_SUCCESS != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4149 | break; |
| 4150 | |
| 4151 | pCurrent = pNext; |
| 4152 | } |
| 4153 | adapterNode = pCurrent; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4154 | if (QDF_STATUS_SUCCESS == status) { |
Lin Bai | c5c0688 | 2017-09-21 13:58:43 +0800 | [diff] [blame] | 4155 | /* |
| 4156 | * Here we are stopping global bus_bw timer & work per adapter. |
| 4157 | * |
| 4158 | * The reason is to fix one race condition between |
| 4159 | * bus bandwidth work and cleaning up an adapter. |
| 4160 | * Under some conditions, it is possible for the bus bandwidth |
| 4161 | * work to access a particularly destroyed adapter, leading to |
| 4162 | * use-after-free. |
| 4163 | */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4164 | hdd_debug("wait for bus bw work to flush"); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 4165 | hdd_bus_bw_compute_timer_stop(hdd_ctx); |
Lin Bai | c5c0688 | 2017-09-21 13:58:43 +0800 | [diff] [blame] | 4166 | hdd_bus_bw_cancel_work(hdd_ctx); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 4167 | |
| 4168 | /* cleanup adapter */ |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 4169 | policy_mgr_clear_concurrency_mode(hdd_ctx->hdd_psoc, |
| 4170 | adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4171 | hdd_cleanup_adapter(hdd_ctx, adapterNode->pAdapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4172 | hdd_remove_adapter(hdd_ctx, adapterNode); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4173 | qdf_mem_free(adapterNode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4174 | adapterNode = NULL; |
| 4175 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 4176 | /* conditionally restart the bw timer */ |
| 4177 | hdd_bus_bw_compute_timer_try_start(hdd_ctx); |
| 4178 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4179 | /* Adapter removed. Decrement vdev count */ |
| 4180 | if (hdd_ctx->current_intf_count != 0) |
| 4181 | hdd_ctx->current_intf_count--; |
| 4182 | |
| 4183 | /* Fw will take care incase of concurrency */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4184 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4185 | } |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4186 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4187 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4188 | } |
| 4189 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 4190 | /** |
| 4191 | * hdd_close_all_adapters - Close all open adapters |
| 4192 | * @hdd_ctx: Hdd context |
| 4193 | * rtnl_held: True if RTNL lock held |
| 4194 | * |
| 4195 | * Close all open adapters. |
| 4196 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 4197 | * Return: QDF status code |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 4198 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4199 | QDF_STATUS hdd_close_all_adapters(struct hdd_context *hdd_ctx, bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4200 | { |
| 4201 | hdd_adapter_list_node_t *pHddAdapterNode; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4202 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4203 | |
| 4204 | ENTER(); |
| 4205 | |
| 4206 | do { |
| 4207 | status = hdd_remove_front_adapter(hdd_ctx, &pHddAdapterNode); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4208 | if (pHddAdapterNode && QDF_STATUS_SUCCESS == status) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4209 | wlan_hdd_release_intf_addr(hdd_ctx, |
| 4210 | pHddAdapterNode->pAdapter->macAddressCurrent.bytes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4211 | hdd_cleanup_adapter(hdd_ctx, pHddAdapterNode->pAdapter, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 4212 | rtnl_held); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4213 | qdf_mem_free(pHddAdapterNode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4214 | /* Adapter removed. Decrement vdev count */ |
| 4215 | if (hdd_ctx->current_intf_count != 0) |
| 4216 | hdd_ctx->current_intf_count--; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4217 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4218 | } while (NULL != pHddAdapterNode && QDF_STATUS_E_EMPTY != status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4219 | |
| 4220 | EXIT(); |
| 4221 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4222 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4223 | } |
| 4224 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4225 | void wlan_hdd_reset_prob_rspies(struct hdd_adapter *pHostapdAdapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4226 | { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4227 | struct qdf_mac_addr *bssid = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4228 | tSirUpdateIE updateIE; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4229 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4230 | switch (pHostapdAdapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4231 | case QDF_STA_MODE: |
| 4232 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4233 | { |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 4234 | struct hdd_station_ctx *pHddStaCtx = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4235 | WLAN_HDD_GET_STATION_CTX_PTR(pHostapdAdapter); |
Srinivas Girigowda | 8b98396 | 2015-11-18 22:14:34 -0800 | [diff] [blame] | 4236 | bssid = &pHddStaCtx->conn_info.bssId; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4237 | break; |
| 4238 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4239 | case QDF_SAP_MODE: |
| 4240 | case QDF_P2P_GO_MODE: |
| 4241 | case QDF_IBSS_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4242 | { |
Srinivas Girigowda | 8b98396 | 2015-11-18 22:14:34 -0800 | [diff] [blame] | 4243 | bssid = &pHostapdAdapter->macAddressCurrent; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4244 | break; |
| 4245 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4246 | case QDF_FTM_MODE: |
| 4247 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4248 | default: |
| 4249 | /* |
| 4250 | * wlan_hdd_reset_prob_rspies should not have been called |
| 4251 | * for these kind of devices |
| 4252 | */ |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4253 | hdd_err("Unexpected request for the current device type %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4254 | pHostapdAdapter->device_mode); |
| 4255 | return; |
| 4256 | } |
| 4257 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 4258 | qdf_copy_macaddr(&updateIE.bssid, bssid); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4259 | updateIE.smeSessionId = pHostapdAdapter->sessionId; |
| 4260 | updateIE.ieBufferlength = 0; |
| 4261 | updateIE.pAdditionIEBuffer = NULL; |
| 4262 | updateIE.append = true; |
| 4263 | updateIE.notify = false; |
| 4264 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(pHostapdAdapter), |
| 4265 | &updateIE, |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4266 | eUPDATE_IE_PROBE_RESP) == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4267 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4268 | } |
| 4269 | } |
| 4270 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4271 | QDF_STATUS hdd_stop_adapter(struct hdd_context *hdd_ctx, struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4272 | const bool bCloseSession) |
| 4273 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 4274 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4275 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(adapter); |
| 4276 | union iwreq_data wrqu; |
| 4277 | tSirUpdateIE updateIE; |
| 4278 | unsigned long rc; |
Jeff Johnson | 3758894 | 2017-08-15 16:11:41 -0700 | [diff] [blame] | 4279 | struct hdd_scan_info *scan_info = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4280 | |
| 4281 | ENTER(); |
| 4282 | |
Sachin Ahuja | 988fd10 | 2016-09-15 17:16:25 +0530 | [diff] [blame] | 4283 | scan_info = &adapter->scan_info; |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4284 | hdd_debug("Disabling queues"); |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4285 | wlan_hdd_netif_queue_control(adapter, |
| 4286 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4287 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4288 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4289 | case QDF_STA_MODE: |
| 4290 | case QDF_P2P_CLIENT_MODE: |
| 4291 | case QDF_IBSS_MODE: |
| 4292 | case QDF_P2P_DEVICE_MODE: |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4293 | case QDF_NDI_MODE: |
| 4294 | if ((QDF_NDI_MODE == adapter->device_mode) || |
| 4295 | hdd_conn_is_connected( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4296 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)) || |
| 4297 | hdd_is_connecting( |
| 4298 | WLAN_HDD_GET_STATION_CTX_PTR(adapter))) { |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4299 | INIT_COMPLETION(adapter->disconnect_comp_var); |
| 4300 | /* |
| 4301 | * For NDI do not use pWextState from sta_ctx, if needed |
| 4302 | * extract from ndi_ctx. |
| 4303 | */ |
| 4304 | if (QDF_NDI_MODE == adapter->device_mode) |
| 4305 | qdf_ret_status = sme_roam_disconnect( |
| 4306 | hdd_ctx->hHal, |
| 4307 | adapter->sessionId, |
| 4308 | eCSR_DISCONNECT_REASON_NDI_DELETE); |
| 4309 | else if (pWextState->roamProfile.BSSType == |
| 4310 | eCSR_BSS_TYPE_START_IBSS) |
| 4311 | qdf_ret_status = sme_roam_disconnect( |
| 4312 | hdd_ctx->hHal, |
| 4313 | adapter->sessionId, |
| 4314 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 4315 | else if (QDF_STA_MODE == adapter->device_mode) |
| 4316 | qdf_ret_status = |
| 4317 | wlan_hdd_try_disconnect(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4318 | else |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4319 | qdf_ret_status = sme_roam_disconnect( |
| 4320 | hdd_ctx->hHal, |
| 4321 | adapter->sessionId, |
| 4322 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4323 | /* success implies disconnect command got |
| 4324 | * queued up successfully |
| 4325 | */ |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 4326 | if (qdf_ret_status == QDF_STATUS_SUCCESS && |
| 4327 | QDF_STA_MODE != adapter->device_mode) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4328 | rc = wait_for_completion_timeout( |
| 4329 | &adapter->disconnect_comp_var, |
| 4330 | msecs_to_jiffies |
| 4331 | (WLAN_WAIT_TIME_DISCONNECT)); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4332 | if (!rc) |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 4333 | hdd_warn("disconn_comp_var wait fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4334 | } |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 4335 | if (qdf_ret_status != QDF_STATUS_SUCCESS) |
| 4336 | hdd_warn("failed to post disconnect"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4337 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 4338 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 4339 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 4340 | wireless_send_event(adapter->dev, SIOCGIWAP, &wrqu, |
| 4341 | NULL); |
Sachin Ahuja | 988fd10 | 2016-09-15 17:16:25 +0530 | [diff] [blame] | 4342 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4343 | if (scan_info != NULL && scan_info->mScanPending) |
Mahesh A Saptasagar | ebb47fa | 2016-07-21 18:11:38 +0530 | [diff] [blame] | 4344 | wlan_hdd_scan_abort(adapter); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4345 | |
Abhishek Singh | 1e94d7a | 2015-11-30 17:26:54 +0530 | [diff] [blame] | 4346 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 4347 | hdd_clear_fils_connection_info(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4348 | |
| 4349 | #ifdef WLAN_OPEN_SOURCE |
| 4350 | cancel_work_sync(&adapter->ipv4NotifierWorkQueue); |
| 4351 | #endif |
| 4352 | |
| 4353 | hdd_deregister_tx_flow_control(adapter); |
| 4354 | |
| 4355 | #ifdef WLAN_NS_OFFLOAD |
| 4356 | #ifdef WLAN_OPEN_SOURCE |
| 4357 | cancel_work_sync(&adapter->ipv6NotifierWorkQueue); |
| 4358 | #endif |
| 4359 | #endif |
| 4360 | |
Hanumanth Reddy Pothula | 0586014 | 2017-07-26 18:45:27 +0530 | [diff] [blame] | 4361 | if (adapter->device_mode == QDF_STA_MODE) |
| 4362 | wlan_cfg80211_sched_scan_stop(hdd_ctx->hdd_pdev, |
| 4363 | adapter->dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4364 | /* |
| 4365 | * It is possible that the caller of this function does not |
| 4366 | * wish to close the session |
| 4367 | */ |
Krunal Soni | 985b813 | 2017-02-10 18:49:08 -0800 | [diff] [blame] | 4368 | if (true == bCloseSession) { |
| 4369 | if (0 != wlan_hdd_try_disconnect(adapter)) { |
| 4370 | hdd_err("Error: Can't disconnect adapter"); |
| 4371 | return QDF_STATUS_E_FAILURE; |
| 4372 | } |
Dustin Brown | 0d2eeae | 2017-03-24 15:21:32 -0700 | [diff] [blame] | 4373 | hdd_vdev_destroy(adapter); |
Krunal Soni | 985b813 | 2017-02-10 18:49:08 -0800 | [diff] [blame] | 4374 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4375 | break; |
| 4376 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4377 | case QDF_SAP_MODE: |
Govind Singh | 1dab23b | 2017-08-12 13:31:00 +0530 | [diff] [blame] | 4378 | /* Flush IPA exception path packets */ |
| 4379 | hdd_ipa_flush(hdd_ctx); |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4380 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4381 | /* Any softap specific cleanup here... */ |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4382 | if (adapter->device_mode == QDF_P2P_GO_MODE) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4383 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 4384 | |
| 4385 | hdd_deregister_tx_flow_control(adapter); |
| 4386 | |
Kapil Gupta | c1224bf | 2017-06-22 21:22:40 +0530 | [diff] [blame] | 4387 | hdd_destroy_acs_timer(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4388 | mutex_lock(&hdd_ctx->sap_lock); |
| 4389 | if (test_bit(SOFTAP_BSS_STARTED, &adapter->event_flags)) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4390 | QDF_STATUS status; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 4391 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4392 | |
| 4393 | /* Stop Bss. */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4394 | status = wlansap_stop_bss( |
| 4395 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4396 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4397 | if (QDF_IS_STATUS_SUCCESS(status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4398 | hdd_hostapd_state_t *hostapd_state = |
| 4399 | WLAN_HDD_GET_HOSTAP_STATE_PTR(adapter); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 4400 | qdf_event_reset(&hostapd_state-> |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 4401 | qdf_stop_bss_event); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 4402 | qdf_status = |
| 4403 | qdf_wait_single_event(&hostapd_state-> |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 4404 | qdf_stop_bss_event, |
| 4405 | SME_CMD_TIMEOUT_VALUE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4406 | |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 4407 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4408 | hdd_err("failure waiting for wlansap_stop_bss %d", |
| 4409 | qdf_status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4410 | } |
| 4411 | } else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4412 | hdd_err("failure in wlansap_stop_bss"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4413 | } |
| 4414 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 4415 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
| 4416 | adapter->device_mode, |
| 4417 | adapter->sessionId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4418 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 4419 | qdf_copy_macaddr(&updateIE.bssid, |
Srinivas Girigowda | 8b98396 | 2015-11-18 22:14:34 -0800 | [diff] [blame] | 4420 | &adapter->macAddressCurrent); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4421 | updateIE.smeSessionId = adapter->sessionId; |
| 4422 | updateIE.ieBufferlength = 0; |
| 4423 | updateIE.pAdditionIEBuffer = NULL; |
| 4424 | updateIE.append = false; |
| 4425 | updateIE.notify = false; |
| 4426 | /* Probe bcn reset */ |
| 4427 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(adapter), |
| 4428 | &updateIE, eUPDATE_IE_PROBE_BCN) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4429 | == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4430 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4431 | } |
| 4432 | /* Assoc resp reset */ |
| 4433 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(adapter), |
| 4434 | &updateIE, |
| 4435 | eUPDATE_IE_ASSOC_RESP) == |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4436 | QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4437 | hdd_err("Could not pass on ASSOC_RSP data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4438 | } |
| 4439 | /* Reset WNI_CFG_PROBE_RSP Flags */ |
| 4440 | wlan_hdd_reset_prob_rspies(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4441 | } |
Manikandan Mohan | 3dad1a4 | 2017-06-14 10:50:18 -0700 | [diff] [blame] | 4442 | qdf_mem_free(adapter->sessionCtx.ap.beacon); |
| 4443 | adapter->sessionCtx.ap.beacon = NULL; |
Ajit Pal Singh | 747b680 | 2017-05-24 15:42:03 +0530 | [diff] [blame] | 4444 | /* |
| 4445 | * If Do_Not_Break_Stream was enabled clear avoid channel list. |
| 4446 | */ |
| 4447 | if (policy_mgr_is_dnsc_set(adapter->hdd_vdev)) |
| 4448 | wlan_hdd_send_avoid_freq_for_dnbs(hdd_ctx, 0); |
| 4449 | |
Peng Xu | 66162de | 2016-02-11 17:01:20 -0800 | [diff] [blame] | 4450 | if (true == bCloseSession) |
Dustin Brown | 0d2eeae | 2017-03-24 15:21:32 -0700 | [diff] [blame] | 4451 | hdd_vdev_destroy(adapter); |
Manikandan Mohan | 5df7827 | 2017-03-22 16:28:50 -0700 | [diff] [blame] | 4452 | mutex_unlock(&hdd_ctx->sap_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4453 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4454 | case QDF_OCB_MODE: |
Krishna Kumaar Natarajan | e58b409 | 2017-01-25 15:47:35 -0800 | [diff] [blame] | 4455 | cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC), |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 4456 | (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX), |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 4457 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)->conn_info.staId[0]); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4458 | break; |
| 4459 | default: |
| 4460 | break; |
| 4461 | } |
| 4462 | |
| 4463 | EXIT(); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4464 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4465 | } |
| 4466 | |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 4467 | /** |
| 4468 | * hdd_deinit_all_adapters - deinit all adapters |
| 4469 | * @hdd_ctx: HDD context |
| 4470 | * @rtnl_held: True if RTNL lock held |
| 4471 | * |
| 4472 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4473 | void hdd_deinit_all_adapters(struct hdd_context *hdd_ctx, bool rtnl_held) |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 4474 | { |
| 4475 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
| 4476 | QDF_STATUS status; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4477 | struct hdd_adapter *adapter; |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 4478 | |
| 4479 | ENTER(); |
| 4480 | |
| 4481 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
| 4482 | |
| 4483 | while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) { |
| 4484 | adapter = adapter_node->pAdapter; |
| 4485 | hdd_deinit_adapter(hdd_ctx, adapter, rtnl_held); |
| 4486 | status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next); |
| 4487 | adapter_node = next; |
| 4488 | } |
| 4489 | |
| 4490 | EXIT(); |
| 4491 | } |
| 4492 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 4493 | QDF_STATUS hdd_stop_all_adapters(struct hdd_context *hdd_ctx, |
| 4494 | bool close_session) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4495 | { |
| 4496 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4497 | QDF_STATUS status; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4498 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4499 | |
| 4500 | ENTER(); |
| 4501 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 4502 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 4503 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4504 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 4505 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4506 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4507 | adapter = adapterNode->pAdapter; |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 4508 | hdd_stop_adapter(hdd_ctx, adapter, close_session); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4509 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 4510 | adapterNode = pNext; |
| 4511 | } |
| 4512 | |
| 4513 | EXIT(); |
| 4514 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4515 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4516 | } |
| 4517 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4518 | QDF_STATUS hdd_reset_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4519 | { |
| 4520 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4521 | QDF_STATUS status; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4522 | struct hdd_adapter *adapter; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 4523 | struct hdd_station_ctx *pHddStaCtx; |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 4524 | struct qdf_mac_addr peerMacAddr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4525 | |
| 4526 | ENTER(); |
| 4527 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 4528 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 4529 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4530 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 4531 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4532 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4533 | adapter = adapterNode->pAdapter; |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 4534 | hdd_notice("Disabling queues for adapter type: %d", |
| 4535 | adapter->device_mode); |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 4536 | |
| 4537 | if ((adapter->device_mode == QDF_STA_MODE) || |
Kabilan Kannan | 00d2041 | 2017-06-04 14:20:32 -0700 | [diff] [blame] | 4538 | (adapter->device_mode == QDF_P2P_CLIENT_MODE)) |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 4539 | /* Stop tdls timers */ |
Kabilan Kannan | 00d2041 | 2017-06-04 14:20:32 -0700 | [diff] [blame] | 4540 | hdd_notify_tdls_reset_adapter(adapter->hdd_vdev); |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 4541 | |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 4542 | if (hdd_ctx->config->sap_internal_restart && |
| 4543 | adapter->device_mode == QDF_SAP_MODE) { |
| 4544 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4545 | WLAN_STOP_ALL_NETIF_QUEUE, |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 4546 | WLAN_CONTROL_PATH); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 4547 | if (test_bit(SOFTAP_BSS_STARTED, |
| 4548 | &adapter->event_flags)) { |
| 4549 | hdd_sap_indicate_disconnect_for_sta(adapter); |
| 4550 | hdd_cleanup_actionframe(hdd_ctx, adapter); |
| 4551 | hdd_sap_destroy_events(adapter); |
| 4552 | } |
| 4553 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
| 4554 | } else { |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 4555 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4556 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4557 | WLAN_CONTROL_PATH); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 4558 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4559 | |
| 4560 | adapter->sessionCtx.station.hdd_ReassocScenario = false; |
| 4561 | |
| 4562 | hdd_deinit_tx_rx(adapter); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 4563 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
| 4564 | adapter->device_mode, adapter->sessionId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4565 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 4566 | hdd_wmm_adapter_close(adapter); |
| 4567 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 4568 | } |
| 4569 | |
Vignesh Viswanathan | 2eb1874 | 2017-09-08 11:18:59 +0530 | [diff] [blame] | 4570 | if (adapter->device_mode == QDF_STA_MODE) |
| 4571 | hdd_clear_fils_connection_info(adapter); |
| 4572 | |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 4573 | if (adapter->device_mode == QDF_SAP_MODE) { |
| 4574 | /* |
| 4575 | * If adapter is SAP, set session ID to invalid |
| 4576 | * since SAP session will be cleanup during SSR. |
| 4577 | */ |
Wu Gao | 3671743 | 2016-11-21 15:09:48 +0800 | [diff] [blame] | 4578 | wlansap_set_invalid_session( |
| 4579 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
| 4580 | |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 4581 | wlansap_cleanup_cac_timer( |
| 4582 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
| 4583 | } |
| 4584 | |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 4585 | /* Delete peers if any for STA and P2P client modes */ |
| 4586 | if (adapter->device_mode == QDF_STA_MODE || |
| 4587 | adapter->device_mode == QDF_P2P_CLIENT_MODE) { |
| 4588 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 4589 | qdf_copy_macaddr(&peerMacAddr, |
| 4590 | &pHddStaCtx->conn_info.bssId); |
| 4591 | |
| 4592 | hdd_objmgr_remove_peer_object(adapter->hdd_vdev, |
| 4593 | peerMacAddr.bytes); |
| 4594 | } |
| 4595 | |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 4596 | /* Destroy vdev which will be recreated during reinit. */ |
| 4597 | hdd_vdev_destroy(adapter); |
| 4598 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4599 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 4600 | adapterNode = pNext; |
| 4601 | } |
| 4602 | |
| 4603 | EXIT(); |
| 4604 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4605 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4606 | } |
| 4607 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4608 | bool hdd_check_for_opened_interfaces(struct hdd_context *hdd_ctx) |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 4609 | { |
| 4610 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
| 4611 | QDF_STATUS status; |
| 4612 | bool close_modules = true; |
| 4613 | |
Arun Khandavalli | ba479c4 | 2017-07-26 21:29:40 +0530 | [diff] [blame] | 4614 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 4615 | hdd_info("FTM mode, don't close the module"); |
| 4616 | return false; |
| 4617 | } |
| 4618 | |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 4619 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
| 4620 | while ((NULL != adapter_node) && (QDF_STATUS_SUCCESS == status)) { |
| 4621 | if (test_bit(DEVICE_IFACE_OPENED, |
| 4622 | &adapter_node->pAdapter->event_flags)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4623 | hdd_debug("Still other ifaces are up cannot close modules"); |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 4624 | close_modules = false; |
| 4625 | break; |
| 4626 | } |
| 4627 | status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next); |
| 4628 | adapter_node = next; |
| 4629 | } |
| 4630 | |
| 4631 | return close_modules; |
| 4632 | } |
| 4633 | |
yeshwanth sriram guntuka | ea63f63 | 2017-08-30 19:31:56 +0530 | [diff] [blame] | 4634 | bool hdd_is_interface_up(struct hdd_adapter *adapter) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4635 | { |
| 4636 | if (test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) |
| 4637 | return true; |
| 4638 | else |
| 4639 | return false; |
| 4640 | } |
| 4641 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4642 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)) \ |
bings | bdcd4a2 | 2017-06-20 09:27:00 +0800 | [diff] [blame] | 4643 | && !defined(WITH_BACKPORTS) && !defined(IEEE80211_PRIVACY) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4644 | struct cfg80211_bss *hdd_cfg80211_get_bss(struct wiphy *wiphy, |
| 4645 | struct ieee80211_channel *channel, |
| 4646 | const u8 *bssid, const u8 *ssid, |
| 4647 | size_t ssid_len) |
| 4648 | { |
| 4649 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 4650 | ssid, ssid_len, |
| 4651 | WLAN_CAPABILITY_ESS, |
| 4652 | WLAN_CAPABILITY_ESS); |
| 4653 | } |
| 4654 | #else |
| 4655 | struct cfg80211_bss *hdd_cfg80211_get_bss(struct wiphy *wiphy, |
| 4656 | struct ieee80211_channel *channel, |
| 4657 | const u8 *bssid, const u8 *ssid, |
| 4658 | size_t ssid_len) |
| 4659 | { |
| 4660 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 4661 | ssid, ssid_len, |
| 4662 | IEEE80211_BSS_TYPE_ESS, |
| 4663 | IEEE80211_PRIVACY_ANY); |
| 4664 | } |
| 4665 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4666 | |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 4667 | #if defined CFG80211_CONNECT_BSS |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 4668 | #if defined CFG80211_CONNECT_TIMEOUT_REASON_CODE || \ |
| 4669 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)) |
| 4670 | /** |
| 4671 | * hdd_convert_timeout_reason() - Convert to kernel specific enum |
| 4672 | * @timeout_reason: reason for connect timeout |
| 4673 | * |
| 4674 | * This function is used to convert host timeout |
| 4675 | * reason enum to kernel specific enum. |
| 4676 | * |
| 4677 | * Return: nl timeout enum |
| 4678 | */ |
| 4679 | static enum nl80211_timeout_reason hdd_convert_timeout_reason( |
| 4680 | tSirResultCodes timeout_reason) |
| 4681 | { |
| 4682 | switch (timeout_reason) { |
| 4683 | case eSIR_SME_JOIN_TIMEOUT_RESULT_CODE: |
| 4684 | return NL80211_TIMEOUT_SCAN; |
| 4685 | case eSIR_SME_AUTH_TIMEOUT_RESULT_CODE: |
| 4686 | return NL80211_TIMEOUT_AUTH; |
| 4687 | case eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE: |
| 4688 | return NL80211_TIMEOUT_ASSOC; |
| 4689 | default: |
| 4690 | return NL80211_TIMEOUT_UNSPECIFIED; |
| 4691 | } |
| 4692 | } |
| 4693 | |
| 4694 | /** |
| 4695 | * hdd_cfg80211_connect_timeout() - API to send connection timeout reason |
| 4696 | * @dev: network device |
| 4697 | * @bssid: bssid to which we want to associate |
| 4698 | * @timeout_reason: reason for connect timeout |
| 4699 | * |
| 4700 | * This API is used to send connection timeout reason to supplicant |
| 4701 | * |
| 4702 | * Return: void |
| 4703 | */ |
| 4704 | static void hdd_cfg80211_connect_timeout(struct net_device *dev, |
| 4705 | const u8 *bssid, |
| 4706 | tSirResultCodes timeout_reason) |
| 4707 | { |
| 4708 | enum nl80211_timeout_reason nl_timeout_reason; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4709 | |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 4710 | nl_timeout_reason = hdd_convert_timeout_reason(timeout_reason); |
| 4711 | |
| 4712 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL, |
| 4713 | nl_timeout_reason); |
| 4714 | } |
| 4715 | |
| 4716 | /** |
| 4717 | * __hdd_connect_bss() - API to send connection status to supplicant |
| 4718 | * @dev: network device |
| 4719 | * @bssid: bssid to which we want to associate |
| 4720 | * @req_ie: Request Information Element |
| 4721 | * @req_ie_len: len of the req IE |
| 4722 | * @resp_ie: Response IE |
| 4723 | * @resp_ie_len: len of ht response IE |
| 4724 | * @status: status |
| 4725 | * @gfp: Kernel Flag |
| 4726 | * @timeout_reason: reason for connect timeout |
| 4727 | * |
| 4728 | * Return: void |
| 4729 | */ |
| 4730 | static void __hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 4731 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 4732 | size_t req_ie_len, const u8 *resp_ie, |
| 4733 | size_t resp_ie_len, int status, gfp_t gfp, |
| 4734 | tSirResultCodes timeout_reason) |
| 4735 | { |
| 4736 | enum nl80211_timeout_reason nl_timeout_reason; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4737 | |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 4738 | nl_timeout_reason = hdd_convert_timeout_reason(timeout_reason); |
| 4739 | |
| 4740 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 4741 | resp_ie, resp_ie_len, status, gfp, |
| 4742 | nl_timeout_reason); |
| 4743 | } |
| 4744 | #else |
| 4745 | #if defined CFG80211_CONNECT_TIMEOUT |
| 4746 | static void hdd_cfg80211_connect_timeout(struct net_device *dev, |
| 4747 | const u8 *bssid, |
| 4748 | tSirResultCodes timeout_reason) |
| 4749 | { |
| 4750 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL); |
| 4751 | } |
| 4752 | #endif |
| 4753 | |
| 4754 | static void __hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 4755 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 4756 | size_t req_ie_len, const u8 *resp_ie, |
| 4757 | size_t resp_ie_len, int status, gfp_t gfp, |
| 4758 | tSirResultCodes timeout_reason) |
| 4759 | { |
| 4760 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 4761 | resp_ie, resp_ie_len, status, gfp); |
| 4762 | } |
| 4763 | #endif |
| 4764 | |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 4765 | /** |
| 4766 | * hdd_connect_bss() - API to send connection status to supplicant |
| 4767 | * @dev: network device |
| 4768 | * @bssid: bssid to which we want to associate |
| 4769 | * @req_ie: Request Information Element |
| 4770 | * @req_ie_len: len of the req IE |
| 4771 | * @resp_ie: Response IE |
| 4772 | * @resp_ie_len: len of ht response IE |
| 4773 | * @status: status |
| 4774 | * @gfp: Kernel Flag |
| 4775 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 4776 | * @timeout_reason: reason for connect timeout |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 4777 | * |
| 4778 | * The API is a wrapper to send connection status to supplicant |
| 4779 | * |
| 4780 | * Return: Void |
| 4781 | */ |
| 4782 | #if defined CFG80211_CONNECT_TIMEOUT |
| 4783 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 4784 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 4785 | size_t req_ie_len, const u8 *resp_ie, |
| 4786 | size_t resp_ie_len, int status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 4787 | bool connect_timeout, |
| 4788 | tSirResultCodes timeout_reason) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 4789 | { |
| 4790 | if (connect_timeout) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 4791 | hdd_cfg80211_connect_timeout(dev, bssid, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 4792 | else |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 4793 | __hdd_connect_bss(dev, bssid, bss, req_ie, req_ie_len, resp_ie, |
| 4794 | resp_ie_len, status, gfp, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 4795 | } |
| 4796 | #else |
| 4797 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 4798 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 4799 | size_t req_ie_len, const u8 *resp_ie, |
| 4800 | size_t resp_ie_len, int status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 4801 | bool connect_timeout, |
| 4802 | tSirResultCodes timeout_reason) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 4803 | { |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 4804 | __hdd_connect_bss(dev, bssid, bss, req_ie, req_ie_len, resp_ie, |
| 4805 | resp_ie_len, status, gfp, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 4806 | } |
| 4807 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4808 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 4809 | #ifdef WLAN_FEATURE_FILS_SK |
| 4810 | #ifdef CFG80211_CONNECT_DONE |
| 4811 | #ifdef CFG80211_FILS_SK_OFFLOAD_SUPPORT |
| 4812 | /** |
| 4813 | * hdd_populate_fils_params() - Populate FILS keys to connect response |
| 4814 | * @fils_params: connect response to supplicant |
| 4815 | * @fils_kek: FILS kek |
| 4816 | * @fils_kek_len: FILS kek length |
| 4817 | * @pmk: FILS PMK |
| 4818 | * @pmk_len: FILS PMK length |
| 4819 | * @pmkid: PMKID |
| 4820 | * @fils_seq_num: FILS Seq number |
| 4821 | * |
| 4822 | * Return: None |
| 4823 | */ |
| 4824 | static void hdd_populate_fils_params(struct cfg80211_connect_resp_params |
| 4825 | *fils_params, const uint8_t *fils_kek, |
| 4826 | size_t fils_kek_len, const uint8_t *pmk, |
| 4827 | size_t pmk_len, const uint8_t *pmkid, |
| 4828 | uint16_t fils_seq_num) |
| 4829 | { |
| 4830 | /* Increament seq number to be used for next FILS */ |
| 4831 | fils_params->fils_erp_next_seq_num = fils_seq_num + 1; |
| 4832 | fils_params->update_erp_next_seq_num = true; |
| 4833 | fils_params->fils_kek = fils_kek; |
| 4834 | fils_params->fils_kek_len = fils_kek_len; |
| 4835 | fils_params->pmk = pmk; |
| 4836 | fils_params->pmk_len = pmk_len; |
| 4837 | fils_params->pmkid = pmkid; |
| 4838 | } |
| 4839 | #else |
| 4840 | static inline void hdd_populate_fils_params(struct cfg80211_connect_resp_params |
| 4841 | *fils_params, const uint8_t |
| 4842 | *fils_kek, size_t fils_kek_len, |
| 4843 | const uint8_t *pmk, size_t pmk_len, |
| 4844 | const uint8_t *pmkid, |
| 4845 | uint16_t fils_seq_num) |
| 4846 | { } |
| 4847 | #endif |
| 4848 | |
| 4849 | /** |
| 4850 | * hdd_connect_done() - Wrapper API to call cfg80211_connect_done |
| 4851 | * @dev: network device |
| 4852 | * @bssid: bssid to which we want to associate |
| 4853 | * @bss: cfg80211 bss info |
| 4854 | * @roam_info: information about connected bss |
| 4855 | * @req_ie: Request Information Element |
| 4856 | * @req_ie_len: len of the req IE |
| 4857 | * @resp_ie: Response IE |
| 4858 | * @resp_ie_len: len of ht response IE |
| 4859 | * @status: status |
| 4860 | * @gfp: allocation flags |
| 4861 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
| 4862 | * @timeout_reason: reason for connect timeout |
| 4863 | * @roam_fils_params: FILS join response params |
| 4864 | * |
| 4865 | * This API is used as wrapper to send FILS key/sequence number |
| 4866 | * params etc. to supplicant in case of FILS connection |
| 4867 | * |
| 4868 | * Return: None |
| 4869 | */ |
| 4870 | static void hdd_connect_done(struct net_device *dev, const u8 *bssid, |
| 4871 | struct cfg80211_bss *bss, tCsrRoamInfo *roam_info, |
| 4872 | const u8 *req_ie, size_t req_ie_len, |
| 4873 | const u8 *resp_ie, size_t resp_ie_len, u16 status, |
| 4874 | gfp_t gfp, bool connect_timeout, tSirResultCodes |
| 4875 | timeout_reason, struct fils_join_rsp_params |
| 4876 | *roam_fils_params) |
| 4877 | { |
| 4878 | struct cfg80211_connect_resp_params fils_params; |
| 4879 | qdf_mem_zero(&fils_params, sizeof(fils_params)); |
| 4880 | |
| 4881 | if (!roam_fils_params) { |
| 4882 | fils_params.status = WLAN_STATUS_UNSPECIFIED_FAILURE; |
| 4883 | } else { |
| 4884 | fils_params.status = status; |
| 4885 | fils_params.bssid = bssid; |
| 4886 | fils_params.timeout_reason = timeout_reason; |
| 4887 | fils_params.req_ie = req_ie; |
| 4888 | fils_params.req_ie_len = req_ie_len; |
| 4889 | fils_params.resp_ie = resp_ie; |
| 4890 | fils_params.resp_ie_len = resp_ie_len; |
| 4891 | fils_params.bss = bss; |
| 4892 | hdd_populate_fils_params(&fils_params, roam_fils_params->kek, |
| 4893 | roam_fils_params->kek_len, |
| 4894 | roam_fils_params->fils_pmk, |
| 4895 | roam_fils_params->fils_pmk_len, |
| 4896 | roam_fils_params->fils_pmkid, |
| 4897 | roam_info->fils_seq_num); |
| 4898 | } |
| 4899 | hdd_debug("FILS indicate connect status %d seq no %d", |
| 4900 | fils_params.status, |
| 4901 | fils_params.fils_erp_next_seq_num); |
| 4902 | |
| 4903 | cfg80211_connect_done(dev, &fils_params, gfp); |
| 4904 | |
| 4905 | /* Clear all the FILS key info */ |
| 4906 | if (roam_fils_params && roam_fils_params->fils_pmk) |
| 4907 | qdf_mem_free(roam_fils_params->fils_pmk); |
| 4908 | if (roam_fils_params) |
| 4909 | qdf_mem_free(roam_fils_params); |
| 4910 | roam_info->fils_join_rsp = NULL; |
| 4911 | } |
| 4912 | #else |
| 4913 | static inline void hdd_connect_done(struct net_device *dev, const u8 *bssid, |
| 4914 | struct cfg80211_bss *bss, tCsrRoamInfo |
| 4915 | *roam_info, const u8 *req_ie, |
| 4916 | size_t req_ie_len, const u8 *resp_ie, |
| 4917 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 4918 | bool connect_timeout, tSirResultCodes |
| 4919 | timeout_reason, struct fils_join_rsp_params |
| 4920 | *roam_fils_params) |
| 4921 | { } |
| 4922 | #endif |
| 4923 | #endif |
| 4924 | |
| 4925 | #if defined(CFG80211_CONNECT_DONE) && defined(WLAN_FEATURE_FILS_SK) |
| 4926 | /** |
| 4927 | * hdd_fils_update_connect_results() - API to send fils connection status to |
| 4928 | * supplicant. |
| 4929 | * @dev: network device |
| 4930 | * @bssid: bssid to which we want to associate |
| 4931 | * @bss: cfg80211 bss info |
| 4932 | * @roam_info: information about connected bss |
| 4933 | * @req_ie: Request Information Element |
| 4934 | * @req_ie_len: len of the req IE |
| 4935 | * @resp_ie: Response IE |
| 4936 | * @resp_ie_len: len of ht response IE |
| 4937 | * @status: status |
| 4938 | * @gfp: allocation flags |
| 4939 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
| 4940 | * @timeout_reason: reason for connect timeout |
| 4941 | * |
| 4942 | * The API is a wrapper to send connection status to supplicant |
| 4943 | * |
| 4944 | * Return: 0 if success else failure |
| 4945 | */ |
| 4946 | static int hdd_fils_update_connect_results(struct net_device *dev, |
| 4947 | const u8 *bssid, |
| 4948 | struct cfg80211_bss *bss, |
| 4949 | tCsrRoamInfo *roam_info, const u8 *req_ie, |
| 4950 | size_t req_ie_len, const u8 *resp_ie, |
| 4951 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 4952 | bool connect_timeout, |
| 4953 | tSirResultCodes timeout_reason) |
| 4954 | { |
| 4955 | ENTER(); |
| 4956 | if (!roam_info || !roam_info->is_fils_connection) |
| 4957 | return -EINVAL; |
| 4958 | |
| 4959 | hdd_connect_done(dev, bssid, bss, roam_info, req_ie, req_ie_len, |
| 4960 | resp_ie, resp_ie_len, status, gfp, connect_timeout, |
| 4961 | timeout_reason, roam_info->fils_join_rsp); |
| 4962 | return 0; |
| 4963 | } |
| 4964 | #else |
| 4965 | static inline int hdd_fils_update_connect_results(struct net_device *dev, |
| 4966 | const u8 *bssid, |
| 4967 | struct cfg80211_bss *bss, |
| 4968 | tCsrRoamInfo *roam_info, const u8 *req_ie, |
| 4969 | size_t req_ie_len, const u8 *resp_ie, |
| 4970 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 4971 | bool connect_timeout, |
| 4972 | tSirResultCodes timeout_reason) |
| 4973 | { |
| 4974 | return -EINVAL; |
| 4975 | } |
| 4976 | #endif |
| 4977 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4978 | /** |
| 4979 | * hdd_connect_result() - API to send connection status to supplicant |
| 4980 | * @dev: network device |
| 4981 | * @bssid: bssid to which we want to associate |
| 4982 | * @roam_info: information about connected bss |
| 4983 | * @req_ie: Request Information Element |
| 4984 | * @req_ie_len: len of the req IE |
| 4985 | * @resp_ie: Response IE |
| 4986 | * @resp_ie_len: len of ht response IE |
| 4987 | * @status: status |
| 4988 | * @gfp: Kernel Flag |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 4989 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 4990 | * @timeout_reason: reason for connect timeout |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4991 | * |
| 4992 | * The API is a wrapper to send connection status to supplicant |
| 4993 | * and allow runtime suspend |
| 4994 | * |
| 4995 | * Return: Void |
| 4996 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4997 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
| 4998 | tCsrRoamInfo *roam_info, const u8 *req_ie, |
| 4999 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5000 | size_t resp_ie_len, u16 status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5001 | bool connect_timeout, |
| 5002 | tSirResultCodes timeout_reason) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5003 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5004 | struct hdd_adapter *padapter = (struct hdd_adapter *) netdev_priv(dev); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5005 | struct cfg80211_bss *bss = NULL; |
| 5006 | |
| 5007 | if (WLAN_STATUS_SUCCESS == status) { |
| 5008 | struct ieee80211_channel *chan; |
| 5009 | int freq; |
| 5010 | int chan_no = roam_info->pBssDesc->channelId; |
| 5011 | |
| 5012 | if (chan_no <= 14) |
| 5013 | freq = ieee80211_channel_to_frequency(chan_no, |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 5014 | HDD_NL80211_BAND_2GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5015 | else |
| 5016 | freq = ieee80211_channel_to_frequency(chan_no, |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 5017 | HDD_NL80211_BAND_5GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5018 | |
| 5019 | chan = ieee80211_get_channel(padapter->wdev.wiphy, freq); |
| 5020 | bss = hdd_cfg80211_get_bss(padapter->wdev.wiphy, chan, bssid, |
| 5021 | roam_info->u.pConnectedProfile->SSID.ssId, |
| 5022 | roam_info->u.pConnectedProfile->SSID.length); |
| 5023 | } |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 5024 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5025 | if (hdd_fils_update_connect_results(dev, bssid, bss, |
| 5026 | roam_info, req_ie, req_ie_len, resp_ie, |
| 5027 | resp_ie_len, status, gfp, connect_timeout, |
| 5028 | timeout_reason) != 0) { |
| 5029 | hdd_connect_bss(dev, bssid, bss, req_ie, |
| 5030 | req_ie_len, resp_ie, resp_ie_len, |
| 5031 | status, gfp, connect_timeout, timeout_reason); |
| 5032 | } |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 5033 | |
Prashanth Bhatta | 87b6dc0 | 2017-01-19 15:17:58 -0800 | [diff] [blame] | 5034 | qdf_runtime_pm_allow_suspend(&padapter->connect_rpm_ctx.connect); |
Dustin Brown | ceed67e | 2017-05-26 11:57:31 -0700 | [diff] [blame] | 5035 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5036 | } |
| 5037 | #else |
| 5038 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
| 5039 | tCsrRoamInfo *roam_info, const u8 *req_ie, |
| 5040 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5041 | size_t resp_ie_len, u16 status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5042 | bool connect_timeout, |
| 5043 | tSirResultCodes timeout_reason) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5044 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5045 | struct hdd_adapter *padapter = (struct hdd_adapter *) netdev_priv(dev); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 5046 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5047 | cfg80211_connect_result(dev, bssid, req_ie, req_ie_len, |
| 5048 | resp_ie, resp_ie_len, status, gfp); |
Prashanth Bhatta | 87b6dc0 | 2017-01-19 15:17:58 -0800 | [diff] [blame] | 5049 | |
| 5050 | qdf_runtime_pm_allow_suspend(&padapter->connect_rpm_ctx.connect); |
Dustin Brown | ceed67e | 2017-05-26 11:57:31 -0700 | [diff] [blame] | 5051 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5052 | } |
| 5053 | #endif |
| 5054 | |
| 5055 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5056 | QDF_STATUS hdd_start_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5057 | { |
| 5058 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5059 | QDF_STATUS status; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5060 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5061 | #ifndef MSM_PLATFORM |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 5062 | struct qdf_mac_addr bcastMac = QDF_MAC_ADDR_BROADCAST_INITIALIZER; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5063 | #endif |
| 5064 | eConnectionState connState; |
| 5065 | |
| 5066 | ENTER(); |
| 5067 | |
| 5068 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5069 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5070 | adapter = adapterNode->pAdapter; |
| 5071 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5072 | if (!hdd_is_interface_up(adapter)) |
Hanumanth Reddy Pothula | c1c4d2b | 2016-09-22 15:45:16 +0530 | [diff] [blame] | 5073 | goto get_adapter; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5074 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5075 | hdd_wmm_init(adapter); |
| 5076 | |
Dustin Brown | a7e6a5c | 2017-07-07 12:52:24 -0700 | [diff] [blame] | 5077 | adapter->scan_info.mScanPending = false; |
| 5078 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5079 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5080 | case QDF_STA_MODE: |
| 5081 | case QDF_P2P_CLIENT_MODE: |
| 5082 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5083 | |
| 5084 | connState = (WLAN_HDD_GET_STATION_CTX_PTR(adapter)) |
| 5085 | ->conn_info.connState; |
| 5086 | |
| 5087 | hdd_init_station_mode(adapter); |
| 5088 | /* Open the gates for HDD to receive Wext commands */ |
| 5089 | adapter->isLinkUpSvcNeeded = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5090 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5091 | /* Indicate disconnect event to supplicant |
| 5092 | * if associated previously |
| 5093 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5094 | if (eConnectionState_Associated == connState || |
Yue Ma | cd96144 | 2015-10-20 16:15:31 -0700 | [diff] [blame] | 5095 | eConnectionState_IbssConnected == connState || |
| 5096 | eConnectionState_NotConnected == connState || |
| 5097 | eConnectionState_IbssDisconnected == connState || |
| 5098 | eConnectionState_Disconnecting == connState) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5099 | union iwreq_data wrqu; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5100 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5101 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 5102 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 5103 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 5104 | wireless_send_event(adapter->dev, SIOCGIWAP, |
| 5105 | &wrqu, NULL); |
| 5106 | adapter->sessionCtx.station. |
| 5107 | hdd_ReassocScenario = false; |
| 5108 | |
| 5109 | /* indicate disconnected event to nl80211 */ |
Mahesh A Saptasagar | c35e8bf | 2016-06-17 20:03:46 +0530 | [diff] [blame] | 5110 | wlan_hdd_cfg80211_indicate_disconnect( |
| 5111 | adapter->dev, false, |
| 5112 | WLAN_REASON_UNSPECIFIED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5113 | } else if (eConnectionState_Connecting == connState) { |
| 5114 | /* |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5115 | * Indicate connect failure to supplicant if we |
| 5116 | * were in the process of connecting |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5117 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5118 | hdd_connect_result(adapter->dev, NULL, NULL, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5119 | NULL, 0, NULL, 0, |
| 5120 | WLAN_STATUS_ASSOC_DENIED_UNSPEC, |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5121 | GFP_KERNEL, false, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5122 | } |
| 5123 | |
| 5124 | hdd_register_tx_flow_control(adapter, |
| 5125 | hdd_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 5126 | hdd_tx_resume_cb, |
| 5127 | hdd_tx_flow_control_is_pause); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5128 | |
| 5129 | break; |
| 5130 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5131 | case QDF_SAP_MODE: |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5132 | if (hdd_ctx->config->sap_internal_restart) |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5133 | hdd_init_ap_mode(adapter, true); |
| 5134 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5135 | break; |
| 5136 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5137 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5138 | #ifdef MSM_PLATFORM |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5139 | hdd_debug("[SSR] send stop ap to supplicant"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5140 | cfg80211_ap_stopped(adapter->dev, GFP_KERNEL); |
| 5141 | #else |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5142 | hdd_debug("[SSR] send restart supplicant"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5143 | /* event supplicant to restart */ |
| 5144 | cfg80211_del_sta(adapter->dev, |
| 5145 | (const u8 *)&bcastMac.bytes[0], |
| 5146 | GFP_KERNEL); |
| 5147 | #endif |
| 5148 | break; |
| 5149 | |
| 5150 | default: |
| 5151 | break; |
| 5152 | } |
Krunal Soni | 9c2ee03 | 2017-07-18 13:49:54 -0700 | [diff] [blame] | 5153 | /* |
| 5154 | * Action frame registered in one adapter which will |
| 5155 | * applicable to all interfaces |
| 5156 | */ |
| 5157 | wlan_hdd_cfg80211_register_frames(adapter); |
| 5158 | |
Hanumanth Reddy Pothula | c1c4d2b | 2016-09-22 15:45:16 +0530 | [diff] [blame] | 5159 | get_adapter: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5160 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 5161 | adapterNode = pNext; |
| 5162 | } |
| 5163 | |
| 5164 | EXIT(); |
| 5165 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5166 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5167 | } |
| 5168 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5169 | QDF_STATUS hdd_get_front_adapter(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5170 | hdd_adapter_list_node_t **padapterNode) |
| 5171 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5172 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5173 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5174 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5175 | status = qdf_list_peek_front(&hdd_ctx->hddAdapters, |
| 5176 | (qdf_list_node_t **) padapterNode); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5177 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5178 | return status; |
| 5179 | } |
| 5180 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5181 | QDF_STATUS hdd_get_next_adapter(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5182 | hdd_adapter_list_node_t *adapterNode, |
| 5183 | hdd_adapter_list_node_t **pNextAdapterNode) |
| 5184 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5185 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5186 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5187 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5188 | status = qdf_list_peek_next(&hdd_ctx->hddAdapters, |
| 5189 | (qdf_list_node_t *) adapterNode, |
| 5190 | (qdf_list_node_t **) pNextAdapterNode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5191 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5192 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5193 | return status; |
| 5194 | } |
| 5195 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5196 | QDF_STATUS hdd_remove_adapter(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5197 | hdd_adapter_list_node_t *adapterNode) |
| 5198 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5199 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5200 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5201 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5202 | status = qdf_list_remove_node(&hdd_ctx->hddAdapters, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5203 | &adapterNode->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5204 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5205 | return status; |
| 5206 | } |
| 5207 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5208 | QDF_STATUS hdd_remove_front_adapter(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5209 | hdd_adapter_list_node_t **padapterNode) |
| 5210 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5211 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5212 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5213 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5214 | status = qdf_list_remove_front(&hdd_ctx->hddAdapters, |
| 5215 | (qdf_list_node_t **) padapterNode); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5216 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5217 | return status; |
| 5218 | } |
| 5219 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5220 | QDF_STATUS hdd_add_adapter_back(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5221 | hdd_adapter_list_node_t *adapterNode) |
| 5222 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5223 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5224 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5225 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5226 | status = qdf_list_insert_back(&hdd_ctx->hddAdapters, |
| 5227 | (qdf_list_node_t *) adapterNode); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5228 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5229 | return status; |
| 5230 | } |
| 5231 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5232 | QDF_STATUS hdd_add_adapter_front(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5233 | hdd_adapter_list_node_t *adapterNode) |
| 5234 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5235 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5236 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5237 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5238 | status = qdf_list_insert_front(&hdd_ctx->hddAdapters, |
| 5239 | (qdf_list_node_t *) adapterNode); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5240 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5241 | return status; |
| 5242 | } |
| 5243 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5244 | struct hdd_adapter *hdd_get_adapter_by_macaddr(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5245 | tSirMacAddr macAddr) |
| 5246 | { |
| 5247 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5248 | struct hdd_adapter *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5249 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5250 | |
| 5251 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 5252 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5253 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5254 | adapter = adapterNode->pAdapter; |
| 5255 | |
| 5256 | if (adapter |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 5257 | && !qdf_mem_cmp(adapter->macAddressCurrent.bytes, |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5258 | macAddr, sizeof(tSirMacAddr))) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5259 | return adapter; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5260 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5261 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 5262 | adapterNode = pNext; |
| 5263 | } |
| 5264 | |
| 5265 | return NULL; |
| 5266 | |
| 5267 | } |
| 5268 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5269 | struct hdd_adapter *hdd_get_adapter_by_vdev(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5270 | uint32_t vdev_id) |
| 5271 | { |
| 5272 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5273 | struct hdd_adapter *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5274 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5275 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5276 | qdf_status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5277 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5278 | while ((NULL != adapterNode) && (QDF_STATUS_SUCCESS == qdf_status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5279 | adapter = adapterNode->pAdapter; |
| 5280 | |
| 5281 | if (adapter->sessionId == vdev_id) |
| 5282 | return adapter; |
| 5283 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5284 | qdf_status = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5285 | hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 5286 | adapterNode = pNext; |
| 5287 | } |
| 5288 | |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5289 | hdd_err("vdev_id %d does not exist with host", vdev_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5290 | |
| 5291 | return NULL; |
| 5292 | } |
| 5293 | |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 5294 | /** |
| 5295 | * hdd_get_adapter_by_sme_session_id() - Return adapter with |
| 5296 | * the sessionid |
| 5297 | * @hdd_ctx: hdd context. |
| 5298 | * @sme_session_id: sme session is for the adapter to get. |
| 5299 | * |
| 5300 | * This function is used to get the adapter with provided session id |
| 5301 | * |
| 5302 | * Return: adapter pointer if found |
| 5303 | * |
| 5304 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5305 | struct hdd_adapter *hdd_get_adapter_by_sme_session_id(struct hdd_context *hdd_ctx, |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 5306 | uint32_t sme_session_id) |
| 5307 | { |
| 5308 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5309 | struct hdd_adapter *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5310 | QDF_STATUS qdf_status; |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 5311 | |
| 5312 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5313 | qdf_status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 5314 | |
| 5315 | while ((NULL != adapter_node) && |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5316 | (QDF_STATUS_SUCCESS == qdf_status)) { |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 5317 | adapter = adapter_node->pAdapter; |
| 5318 | |
| 5319 | if (adapter && |
| 5320 | adapter->sessionId == sme_session_id) |
| 5321 | return adapter; |
| 5322 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5323 | qdf_status = |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 5324 | hdd_get_next_adapter(hdd_ctx, |
| 5325 | adapter_node, &next); |
| 5326 | adapter_node = next; |
| 5327 | } |
| 5328 | return NULL; |
| 5329 | } |
| 5330 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5331 | struct hdd_adapter *hdd_get_adapter_by_iface_name(struct hdd_context *hdd_ctx, |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 5332 | const char *iface_name) |
| 5333 | { |
| 5334 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5335 | struct hdd_adapter *adapter; |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 5336 | QDF_STATUS qdf_status; |
| 5337 | |
| 5338 | qdf_status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
| 5339 | |
| 5340 | while ((NULL != adapter_node) && |
| 5341 | (QDF_STATUS_SUCCESS == qdf_status)) { |
| 5342 | adapter = adapter_node->pAdapter; |
| 5343 | |
| 5344 | if (adapter && |
| 5345 | !qdf_str_cmp(adapter->dev->name, iface_name)) |
| 5346 | return adapter; |
| 5347 | |
| 5348 | qdf_status = |
| 5349 | hdd_get_next_adapter(hdd_ctx, |
| 5350 | adapter_node, &next); |
| 5351 | adapter_node = next; |
| 5352 | } |
| 5353 | return NULL; |
| 5354 | } |
| 5355 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5356 | /** |
| 5357 | * hdd_get_adapter() - to get adapter matching the mode |
| 5358 | * @hdd_ctx: hdd context |
| 5359 | * @mode: adapter mode |
| 5360 | * |
| 5361 | * This routine will return the pointer to adapter matching |
| 5362 | * with the passed mode. |
| 5363 | * |
| 5364 | * Return: pointer to adapter or null |
| 5365 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5366 | struct hdd_adapter *hdd_get_adapter(struct hdd_context *hdd_ctx, |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5367 | enum tQDF_ADAPTER_MODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5368 | { |
| 5369 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5370 | struct hdd_adapter *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5371 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5372 | |
| 5373 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 5374 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5375 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5376 | adapter = adapterNode->pAdapter; |
| 5377 | |
| 5378 | if (adapter && (mode == adapter->device_mode)) |
| 5379 | return adapter; |
| 5380 | |
| 5381 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 5382 | adapterNode = pNext; |
| 5383 | } |
| 5384 | |
| 5385 | return NULL; |
| 5386 | |
| 5387 | } |
| 5388 | |
| 5389 | /** |
| 5390 | * hdd_get_operating_channel() - return operating channel of the device mode |
| 5391 | * @hdd_ctx: Pointer to the HDD context. |
| 5392 | * @mode: Device mode for which operating channel is required. |
| 5393 | * Suported modes: |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5394 | * QDF_STA_MODE, |
| 5395 | * QDF_P2P_CLIENT_MODE, |
| 5396 | * QDF_SAP_MODE, |
| 5397 | * QDF_P2P_GO_MODE. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5398 | * |
| 5399 | * This API returns the operating channel of the requested device mode |
| 5400 | * |
| 5401 | * Return: channel number. "0" id the requested device is not found OR it is |
| 5402 | * not connected. |
| 5403 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5404 | uint8_t hdd_get_operating_channel(struct hdd_context *hdd_ctx, |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5405 | enum tQDF_ADAPTER_MODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5406 | { |
| 5407 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5408 | QDF_STATUS status; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5409 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5410 | uint8_t operatingChannel = 0; |
| 5411 | |
| 5412 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 5413 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5414 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5415 | adapter = adapterNode->pAdapter; |
| 5416 | |
| 5417 | if (mode == adapter->device_mode) { |
| 5418 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5419 | case QDF_STA_MODE: |
| 5420 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5421 | if (hdd_conn_is_connected |
| 5422 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 5423 | (adapter))) { |
| 5424 | operatingChannel = |
| 5425 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 5426 | (adapter))->conn_info. |
| 5427 | operationChannel; |
| 5428 | } |
| 5429 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5430 | case QDF_SAP_MODE: |
| 5431 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5432 | /* softap connection info */ |
| 5433 | if (test_bit |
| 5434 | (SOFTAP_BSS_STARTED, |
| 5435 | &adapter->event_flags)) |
| 5436 | operatingChannel = |
| 5437 | (WLAN_HDD_GET_AP_CTX_PTR |
| 5438 | (adapter))->operatingChannel; |
| 5439 | break; |
| 5440 | default: |
| 5441 | break; |
| 5442 | } |
| 5443 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5444 | /* Found the device of interest. break the loop */ |
| 5445 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5446 | } |
| 5447 | |
| 5448 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 5449 | adapterNode = pNext; |
| 5450 | } |
| 5451 | return operatingChannel; |
| 5452 | } |
| 5453 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5454 | static inline QDF_STATUS hdd_unregister_wext_all_adapters(struct hdd_context * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5455 | hdd_ctx) |
| 5456 | { |
| 5457 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5458 | QDF_STATUS status; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5459 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5460 | |
| 5461 | ENTER(); |
| 5462 | |
| 5463 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 5464 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5465 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5466 | adapter = adapterNode->pAdapter; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5467 | if ((adapter->device_mode == QDF_STA_MODE) || |
| 5468 | (adapter->device_mode == QDF_P2P_CLIENT_MODE) || |
| 5469 | (adapter->device_mode == QDF_IBSS_MODE) || |
| 5470 | (adapter->device_mode == QDF_P2P_DEVICE_MODE) || |
| 5471 | (adapter->device_mode == QDF_SAP_MODE) || |
| 5472 | (adapter->device_mode == QDF_P2P_GO_MODE)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5473 | wlan_hdd_cfg80211_deregister_frames(adapter); |
| 5474 | hdd_unregister_wext(adapter->dev); |
| 5475 | } |
| 5476 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 5477 | adapterNode = pNext; |
| 5478 | } |
| 5479 | |
| 5480 | EXIT(); |
| 5481 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5482 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5483 | } |
| 5484 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5485 | QDF_STATUS hdd_abort_mac_scan_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5486 | { |
| 5487 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5488 | QDF_STATUS status; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5489 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5490 | |
| 5491 | ENTER(); |
| 5492 | |
| 5493 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 5494 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5495 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5496 | adapter = adapterNode->pAdapter; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5497 | if ((adapter->device_mode == QDF_STA_MODE) || |
| 5498 | (adapter->device_mode == QDF_P2P_CLIENT_MODE) || |
| 5499 | (adapter->device_mode == QDF_IBSS_MODE) || |
| 5500 | (adapter->device_mode == QDF_P2P_DEVICE_MODE) || |
| 5501 | (adapter->device_mode == QDF_SAP_MODE) || |
| 5502 | (adapter->device_mode == QDF_P2P_GO_MODE)) { |
Abhishek Singh | 69ccb51 | 2017-04-25 11:58:16 +0530 | [diff] [blame] | 5503 | wlan_abort_scan(hdd_ctx->hdd_pdev, INVAL_PDEV_ID, |
| 5504 | adapter->sessionId, INVALID_SCAN_ID, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5505 | } |
| 5506 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 5507 | adapterNode = pNext; |
| 5508 | } |
| 5509 | |
| 5510 | EXIT(); |
| 5511 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5512 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5513 | } |
| 5514 | |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 5515 | /** |
| 5516 | * hdd_abort_sched_scan_all_adapters() - stops scheduled (PNO) scans for all |
| 5517 | * adapters |
| 5518 | * @hdd_ctx: The HDD context containing the adapters to operate on |
| 5519 | * |
| 5520 | * return: QDF_STATUS_SUCCESS |
| 5521 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5522 | static QDF_STATUS hdd_abort_sched_scan_all_adapters(struct hdd_context *hdd_ctx) |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 5523 | { |
| 5524 | hdd_adapter_list_node_t *adapter_node = NULL, *next_node = NULL; |
| 5525 | QDF_STATUS status; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5526 | struct hdd_adapter *adapter; |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 5527 | int err; |
| 5528 | |
| 5529 | ENTER(); |
| 5530 | |
| 5531 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
| 5532 | |
| 5533 | while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) { |
| 5534 | adapter = adapter_node->pAdapter; |
| 5535 | if ((adapter->device_mode == QDF_STA_MODE) || |
| 5536 | (adapter->device_mode == QDF_P2P_CLIENT_MODE) || |
| 5537 | (adapter->device_mode == QDF_IBSS_MODE) || |
| 5538 | (adapter->device_mode == QDF_P2P_DEVICE_MODE) || |
| 5539 | (adapter->device_mode == QDF_SAP_MODE) || |
| 5540 | (adapter->device_mode == QDF_P2P_GO_MODE)) { |
| 5541 | err = wlan_hdd_sched_scan_stop(adapter->dev); |
| 5542 | if (err) |
| 5543 | hdd_err("Unable to stop scheduled scan"); |
| 5544 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5545 | status = hdd_get_next_adapter(hdd_ctx, adapter_node, |
| 5546 | &next_node); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 5547 | adapter_node = next_node; |
| 5548 | } |
| 5549 | |
| 5550 | EXIT(); |
| 5551 | |
| 5552 | return QDF_STATUS_SUCCESS; |
| 5553 | } |
| 5554 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5555 | #ifdef WLAN_NS_OFFLOAD |
| 5556 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5557 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5558 | * @hdd_ctx: Pointer to hdd context |
| 5559 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5560 | * Unregister for IPv6 address change notifications. |
| 5561 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5562 | * Return: None |
| 5563 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5564 | static void hdd_wlan_unregister_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5565 | { |
| 5566 | unregister_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5567 | } |
| 5568 | |
| 5569 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5570 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5571 | * @hdd_ctx: Pointer to hdd context |
| 5572 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5573 | * Register for IPv6 address change notifications. |
| 5574 | * |
| 5575 | * Return: 0 on success and errno on failure. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5576 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5577 | static int hdd_wlan_register_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5578 | { |
| 5579 | int ret; |
| 5580 | |
| 5581 | hdd_ctx->ipv6_notifier.notifier_call = wlan_hdd_ipv6_changed; |
| 5582 | ret = register_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5583 | if (ret) { |
| 5584 | hdd_err("Failed to register IPv6 notifier: %d", ret); |
| 5585 | goto out; |
| 5586 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5587 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5588 | hdd_debug("Registered IPv6 notifier"); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5589 | out: |
| 5590 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5591 | } |
| 5592 | #else |
| 5593 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5594 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5595 | * @hdd_ctx: Pointer to hdd context |
| 5596 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5597 | * Unregister for IPv6 address change notifications. |
| 5598 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5599 | * Return: None |
| 5600 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5601 | static void hdd_wlan_unregister_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5602 | { |
| 5603 | } |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5604 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5605 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5606 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5607 | * @hdd_ctx: Pointer to hdd context |
| 5608 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5609 | * Register for IPv6 address change notifications. |
| 5610 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5611 | * Return: None |
| 5612 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5613 | static int hdd_wlan_register_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5614 | { |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5615 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5616 | } |
| 5617 | #endif |
| 5618 | |
| 5619 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5620 | * hdd_register_notifiers - Register netdev notifiers. |
| 5621 | * @hdd_ctx: HDD context |
| 5622 | * |
| 5623 | * Register netdev notifiers like IPv4 and IPv6. |
| 5624 | * |
| 5625 | * Return: 0 on success and errno on failure |
| 5626 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5627 | static int hdd_register_notifiers(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5628 | { |
| 5629 | int ret; |
| 5630 | |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5631 | ret = hdd_wlan_register_ip6_notifier(hdd_ctx); |
| 5632 | if (ret) |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 5633 | goto out; |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5634 | |
| 5635 | hdd_ctx->ipv4_notifier.notifier_call = wlan_hdd_ipv4_changed; |
| 5636 | ret = register_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
| 5637 | if (ret) { |
| 5638 | hdd_err("Failed to register IPv4 notifier: %d", ret); |
| 5639 | goto unregister_ip6_notifier; |
| 5640 | } |
| 5641 | |
| 5642 | return 0; |
| 5643 | |
| 5644 | unregister_ip6_notifier: |
| 5645 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5646 | out: |
| 5647 | return ret; |
| 5648 | |
| 5649 | } |
| 5650 | |
| 5651 | /** |
| 5652 | * hdd_unregister_notifiers - Unregister netdev notifiers. |
| 5653 | * @hdd_ctx: HDD context |
| 5654 | * |
| 5655 | * Unregister netdev notifiers like IPv4 and IPv6. |
| 5656 | * |
| 5657 | * Return: None. |
| 5658 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5659 | void hdd_unregister_notifiers(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5660 | { |
| 5661 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
| 5662 | |
| 5663 | unregister_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5664 | } |
| 5665 | |
| 5666 | /** |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 5667 | * hdd_exit_netlink_services - Exit netlink services |
| 5668 | * @hdd_ctx: HDD context |
| 5669 | * |
| 5670 | * Exit netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 5671 | * nl service. |
| 5672 | * |
| 5673 | * Return: None. |
| 5674 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5675 | static void hdd_exit_netlink_services(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 5676 | { |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 5677 | hdd_close_cesium_nl_sock(); |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 5678 | hdd_deactivate_wifi_pos(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 5679 | ptt_sock_deactivate_svc(); |
| 5680 | |
| 5681 | nl_srv_exit(); |
| 5682 | } |
| 5683 | |
| 5684 | /** |
| 5685 | * hdd_init_netlink_services- Init netlink services |
| 5686 | * @hdd_ctx: HDD context |
| 5687 | * |
| 5688 | * Init netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 5689 | * nl service. |
| 5690 | * |
| 5691 | * Return: 0 on success and errno on failure. |
| 5692 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5693 | static int hdd_init_netlink_services(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 5694 | { |
| 5695 | int ret; |
| 5696 | |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 5697 | ret = wlan_hdd_nl_init(hdd_ctx); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 5698 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5699 | hdd_err("nl_srv_init failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 5700 | goto out; |
| 5701 | } |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 5702 | cds_set_radio_index(hdd_ctx->radio_index); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 5703 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 5704 | ret = hdd_activate_wifi_pos(hdd_ctx); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 5705 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5706 | hdd_err("hdd_activate_wifi_pos failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 5707 | goto err_nl_srv; |
| 5708 | } |
| 5709 | |
| 5710 | ret = ptt_sock_activate_svc(); |
| 5711 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5712 | hdd_err("ptt_sock_activate_svc failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 5713 | goto err_nl_srv; |
| 5714 | } |
| 5715 | |
| 5716 | ret = hdd_open_cesium_nl_sock(); |
Ryan Hsu | 5e2e205 | 2016-04-28 10:19:38 -0700 | [diff] [blame] | 5717 | if (ret) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5718 | hdd_err("hdd_open_cesium_nl_sock failed ret: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 5719 | |
| 5720 | ret = cnss_diag_activate_service(); |
| 5721 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5722 | hdd_err("cnss_diag_activate_service failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 5723 | goto err_close_cesium; |
| 5724 | } |
| 5725 | |
| 5726 | return 0; |
| 5727 | |
| 5728 | err_close_cesium: |
| 5729 | hdd_close_cesium_nl_sock(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 5730 | ptt_sock_deactivate_svc(); |
| 5731 | err_nl_srv: |
| 5732 | nl_srv_exit(); |
| 5733 | out: |
| 5734 | return ret; |
| 5735 | } |
| 5736 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 5737 | /** |
| 5738 | * hdd_rx_wake_lock_destroy() - Destroy RX wakelock |
| 5739 | * @hdd_ctx: HDD context. |
| 5740 | * |
| 5741 | * Destroy RX wakelock. |
| 5742 | * |
| 5743 | * Return: None. |
| 5744 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5745 | static void hdd_rx_wake_lock_destroy(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 5746 | { |
| 5747 | qdf_wake_lock_destroy(&hdd_ctx->rx_wake_lock); |
| 5748 | } |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 5749 | |
| 5750 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 5751 | * hdd_rx_wake_lock_create() - Create RX wakelock |
| 5752 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 5753 | * |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 5754 | * Create RX wakelock. |
| 5755 | * |
| 5756 | * Return: None. |
| 5757 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5758 | static void hdd_rx_wake_lock_create(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 5759 | { |
| 5760 | qdf_wake_lock_create(&hdd_ctx->rx_wake_lock, "qcom_rx_wakelock"); |
| 5761 | } |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 5762 | |
| 5763 | /** |
| 5764 | * hdd_roc_context_init() - Init ROC context |
| 5765 | * @hdd_ctx: HDD context. |
| 5766 | * |
| 5767 | * Initialize ROC context. |
| 5768 | * |
| 5769 | * Return: 0 on success and errno on failure. |
| 5770 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5771 | static int hdd_roc_context_init(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 5772 | { |
| 5773 | qdf_spinlock_create(&hdd_ctx->hdd_roc_req_q_lock); |
| 5774 | qdf_list_create(&hdd_ctx->hdd_roc_req_q, MAX_ROC_REQ_QUEUE_ENTRY); |
| 5775 | |
| 5776 | INIT_DELAYED_WORK(&hdd_ctx->roc_req_work, wlan_hdd_roc_request_dequeue); |
| 5777 | |
| 5778 | return 0; |
| 5779 | } |
| 5780 | |
| 5781 | /** |
Nachiket Kukade | 223ad8c | 2017-04-19 16:42:29 +0530 | [diff] [blame] | 5782 | * hdd_destroy_roc_req_q() - Free allocations in ROC Req Queue |
| 5783 | * @hdd_ctx: HDD context. |
| 5784 | * |
| 5785 | * Free memory allocations made in ROC Req Queue nodes. |
| 5786 | * |
| 5787 | * Return: None. |
| 5788 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5789 | static void hdd_destroy_roc_req_q(struct hdd_context *hdd_ctx) |
Nachiket Kukade | 223ad8c | 2017-04-19 16:42:29 +0530 | [diff] [blame] | 5790 | { |
| 5791 | hdd_roc_req_t *hdd_roc_req; |
| 5792 | QDF_STATUS status; |
| 5793 | |
| 5794 | qdf_spin_lock(&hdd_ctx->hdd_roc_req_q_lock); |
| 5795 | |
| 5796 | while (!qdf_list_empty(&hdd_ctx->hdd_roc_req_q)) { |
| 5797 | status = qdf_list_remove_front(&hdd_ctx->hdd_roc_req_q, |
| 5798 | (qdf_list_node_t **) &hdd_roc_req); |
| 5799 | |
| 5800 | if (QDF_STATUS_SUCCESS != status) { |
Nachiket Kukade | d45ab8c | 2017-05-08 16:12:02 +0530 | [diff] [blame] | 5801 | qdf_spin_unlock(&hdd_ctx->hdd_roc_req_q_lock); |
| 5802 | hdd_debug("unable to remove roc element from list"); |
Nachiket Kukade | 223ad8c | 2017-04-19 16:42:29 +0530 | [diff] [blame] | 5803 | QDF_ASSERT(0); |
| 5804 | return; |
| 5805 | } |
| 5806 | |
| 5807 | if (hdd_roc_req->pRemainChanCtx) |
| 5808 | qdf_mem_free(hdd_roc_req->pRemainChanCtx); |
| 5809 | |
| 5810 | qdf_mem_free(hdd_roc_req); |
| 5811 | } |
| 5812 | |
| 5813 | qdf_spin_unlock(&hdd_ctx->hdd_roc_req_q_lock); |
| 5814 | } |
| 5815 | |
| 5816 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 5817 | * hdd_roc_context_destroy() - Destroy ROC context |
| 5818 | * @hdd_ctx: HDD context. |
| 5819 | * |
| 5820 | * Destroy roc list and flush the pending roc work. |
| 5821 | * |
| 5822 | * Return: None. |
| 5823 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5824 | static void hdd_roc_context_destroy(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 5825 | { |
| 5826 | flush_delayed_work(&hdd_ctx->roc_req_work); |
Nachiket Kukade | 223ad8c | 2017-04-19 16:42:29 +0530 | [diff] [blame] | 5827 | hdd_destroy_roc_req_q(hdd_ctx); |
Houston Hoffman | 2eac7c4 | 2016-12-12 12:22:52 -0800 | [diff] [blame] | 5828 | qdf_spinlock_destroy(&hdd_ctx->hdd_roc_req_q_lock); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 5829 | } |
| 5830 | |
| 5831 | /** |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 5832 | * hdd_context_deinit() - Deinitialize HDD context |
| 5833 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 5834 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 5835 | * Deinitialize HDD context along with all the feature specific contexts but |
| 5836 | * do not free hdd context itself. Caller of this API is supposed to free |
| 5837 | * HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 5838 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 5839 | * return: 0 on success and errno on failure. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 5840 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5841 | static int hdd_context_deinit(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 5842 | { |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 5843 | wlan_hdd_cfg80211_deinit(hdd_ctx->wiphy); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 5844 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 5845 | hdd_roc_context_destroy(hdd_ctx); |
| 5846 | |
| 5847 | hdd_sap_context_destroy(hdd_ctx); |
| 5848 | |
| 5849 | hdd_rx_wake_lock_destroy(hdd_ctx); |
| 5850 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 5851 | hdd_scan_context_destroy(hdd_ctx); |
| 5852 | |
| 5853 | qdf_list_destroy(&hdd_ctx->hddAdapters); |
| 5854 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 5855 | return 0; |
| 5856 | } |
| 5857 | |
| 5858 | /** |
| 5859 | * hdd_context_destroy() - Destroy HDD context |
| 5860 | * @hdd_ctx: HDD context to be destroyed. |
| 5861 | * |
| 5862 | * Free config and HDD context as well as destroy all the resources. |
| 5863 | * |
| 5864 | * Return: None |
| 5865 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5866 | static void hdd_context_destroy(struct hdd_context *hdd_ctx) |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 5867 | { |
Arunk Khandavalli | 3d267b4 | 2017-05-02 18:58:59 +0530 | [diff] [blame] | 5868 | |
Hanumantha Reddy Pothula | 00c74f6 | 2016-11-24 20:13:32 +0530 | [diff] [blame] | 5869 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 5870 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 5871 | hdd_context_deinit(hdd_ctx); |
| 5872 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 5873 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 5874 | hdd_ctx->config = NULL; |
| 5875 | |
| 5876 | wiphy_free(hdd_ctx->wiphy); |
| 5877 | } |
| 5878 | |
| 5879 | /** |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 5880 | * wlan_destroy_bug_report_lock() - Destroy bug report lock |
| 5881 | * |
| 5882 | * This function is used to destroy bug report lock |
| 5883 | * |
| 5884 | * Return: None |
| 5885 | */ |
| 5886 | static void wlan_destroy_bug_report_lock(void) |
| 5887 | { |
| 5888 | p_cds_contextType p_cds_context; |
| 5889 | |
| 5890 | p_cds_context = cds_get_global_context(); |
| 5891 | if (!p_cds_context) { |
| 5892 | hdd_err("cds context is NULL"); |
| 5893 | return; |
| 5894 | } |
| 5895 | |
| 5896 | qdf_spinlock_destroy(&p_cds_context->bug_report_lock); |
| 5897 | } |
| 5898 | |
| 5899 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5900 | * hdd_wlan_exit() - HDD WLAN exit function |
| 5901 | * @hdd_ctx: Pointer to the HDD Context |
| 5902 | * |
| 5903 | * This is the driver exit point (invoked during rmmod) |
| 5904 | * |
| 5905 | * Return: None |
| 5906 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5907 | static void hdd_wlan_exit(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5908 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5909 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5910 | struct wiphy *wiphy = hdd_ctx->wiphy; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5911 | int driver_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5912 | |
| 5913 | ENTER(); |
| 5914 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5915 | if (QDF_TIMER_STATE_RUNNING == |
| 5916 | qdf_mc_timer_get_current_state(&hdd_ctx->iface_change_timer)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5917 | hdd_debug("Stop interface change timer"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5918 | qdf_mc_timer_stop(&hdd_ctx->iface_change_timer); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5919 | } |
| 5920 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5921 | if (!QDF_IS_STATUS_SUCCESS |
| 5922 | (qdf_mc_timer_destroy(&hdd_ctx->iface_change_timer))) |
| 5923 | hdd_err("Cannot delete interface change timer"); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5924 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5925 | |
| 5926 | hdd_unregister_notifiers(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5927 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 5928 | hdd_bus_bandwidth_destroy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5929 | |
| 5930 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 5931 | if (QDF_TIMER_STATE_RUNNING == |
| 5932 | qdf_mc_timer_get_current_state(&hdd_ctx->skip_acs_scan_timer)) { |
| 5933 | qdf_mc_timer_stop(&hdd_ctx->skip_acs_scan_timer); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5934 | } |
| 5935 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5936 | if (!QDF_IS_STATUS_SUCCESS |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 5937 | (qdf_mc_timer_destroy(&hdd_ctx->skip_acs_scan_timer))) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5938 | hdd_err("Cannot deallocate ACS Skip timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5939 | } |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 5940 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 5941 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 5942 | hdd_ctx->last_acs_channel_list = NULL; |
| 5943 | hdd_ctx->num_of_channels = 0; |
| 5944 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5945 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5946 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5947 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 5948 | driver_status = hdd_ctx->driver_status; |
| 5949 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 5950 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5951 | /* |
| 5952 | * Powersave Offload Case |
| 5953 | * Disable Idle Power Save Mode |
| 5954 | */ |
| 5955 | hdd_set_idle_ps_config(hdd_ctx, false); |
| 5956 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5957 | if (driver_status != DRIVER_MODULES_CLOSED) { |
| 5958 | hdd_unregister_wext_all_adapters(hdd_ctx); |
| 5959 | /* |
| 5960 | * Cancel any outstanding scan requests. We are about to close |
| 5961 | * all of our adapters, but an adapter structure is what SME |
| 5962 | * passes back to our callback function. Hence if there |
| 5963 | * are any outstanding scan requests then there is a |
| 5964 | * race condition between when the adapter is closed and |
| 5965 | * when the callback is invoked. We try to resolve that |
| 5966 | * race condition here by canceling any outstanding scans |
| 5967 | * before we close the adapters. |
| 5968 | * Note that the scans may be cancelled in an asynchronous |
| 5969 | * manner, so ideally there needs to be some kind of |
| 5970 | * synchronization. Rather than introduce a new |
| 5971 | * synchronization here, we will utilize the fact that we are |
| 5972 | * about to Request Full Power, and since that is synchronized, |
| 5973 | * the expectation is that by the time Request Full Power has |
| 5974 | * completed, all scans will be cancelled |
| 5975 | */ |
Sandeep Puligilla | 8de3c1c | 2017-04-13 17:56:18 -0700 | [diff] [blame] | 5976 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->hdd_pdev); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5977 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 5978 | hdd_abort_sched_scan_all_adapters(hdd_ctx); |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 5979 | hdd_stop_all_adapters(hdd_ctx, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5980 | } |
| 5981 | |
| 5982 | /* |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 5983 | * Close the scheduler before calling cds_close to make sure |
| 5984 | * no thread is scheduled after the each module close is |
| 5985 | * is called i.e after all the data structures are freed. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5986 | */ |
Jeff Johnson | 7d56227 | 2017-09-13 15:12:54 -0700 | [diff] [blame] | 5987 | qdf_status = cds_sched_close(); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5988 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 5989 | hdd_alert("Failed to close CDS Scheduler"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 5990 | QDF_ASSERT(QDF_IS_STATUS_SUCCESS(qdf_status)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5991 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5992 | |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 5993 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 5994 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 5995 | hdd_wlan_stop_modules(hdd_ctx, false); |
Hanumanth Reddy Pothula | 709a636 | 2016-10-18 18:19:44 +0530 | [diff] [blame] | 5996 | |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 5997 | qdf_spinlock_destroy(&hdd_ctx->hdd_adapter_lock); |
| 5998 | qdf_spinlock_destroy(&hdd_ctx->sta_update_info_lock); |
| 5999 | qdf_spinlock_destroy(&hdd_ctx->connection_status_lock); |
| 6000 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6001 | /* |
| 6002 | * Close CDS |
| 6003 | * This frees pMac(HAL) context. There should not be any call |
| 6004 | * that requires pMac access after this. |
| 6005 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6006 | |
Jeff Johnson | a7e5eed | 2016-09-28 15:19:13 -0700 | [diff] [blame] | 6007 | hdd_green_ap_deinit(hdd_ctx); |
Jeff Johnson | ce0032c | 2017-01-20 07:18:27 -0800 | [diff] [blame] | 6008 | hdd_request_manager_deinit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6009 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 6010 | hdd_close_all_adapters(hdd_ctx, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6011 | |
| 6012 | hdd_ipa_cleanup(hdd_ctx); |
| 6013 | |
| 6014 | /* Free up RoC request queue and flush workqueue */ |
| 6015 | cds_flush_work(&hdd_ctx->roc_req_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6016 | |
Manishekar Chandrasekaran | f7a1dad | 2016-06-23 06:43:47 +0530 | [diff] [blame] | 6017 | wlansap_global_deinit(); |
Kapil Gupta | 4f0c0c1 | 2017-02-07 15:21:15 +0530 | [diff] [blame] | 6018 | wlan_hdd_deinit_chan_info(hdd_ctx); |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 6019 | /* |
| 6020 | * If there is re_init failure wiphy would have already de-registered |
| 6021 | * check the wiphy status before un-registering again |
| 6022 | */ |
Ashish Kumar Dhanotiya | e16feb7 | 2017-03-31 19:39:37 +0530 | [diff] [blame] | 6023 | if (wiphy && wiphy->registered) { |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 6024 | wiphy_unregister(wiphy); |
| 6025 | wlan_hdd_cfg80211_deinit(wiphy); |
| 6026 | hdd_lpass_notify_stop(hdd_ctx); |
| 6027 | } |
Yuanyuan Liu | 3e918e5 | 2016-08-17 15:41:35 -0700 | [diff] [blame] | 6028 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6029 | hdd_exit_netlink_services(hdd_ctx); |
| 6030 | mutex_destroy(&hdd_ctx->iface_change_lock); |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 6031 | #ifdef FEATURE_WLAN_CH_AVOID |
| 6032 | mutex_destroy(&hdd_ctx->avoid_freq_lock); |
| 6033 | #endif |
Abhishek Singh | e9068f1 | 2017-03-31 14:14:52 +0530 | [diff] [blame] | 6034 | |
| 6035 | driver_status = hdd_objmgr_release_and_destroy_pdev(hdd_ctx); |
| 6036 | if (driver_status) |
| 6037 | hdd_err("Pdev delete failed"); |
| 6038 | |
| 6039 | driver_status = hdd_objmgr_release_and_destroy_psoc(hdd_ctx); |
| 6040 | if (driver_status) |
| 6041 | hdd_err("Psoc delete failed"); |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 6042 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6043 | hdd_context_destroy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6044 | } |
| 6045 | |
| 6046 | void __hdd_wlan_exit(void) |
| 6047 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6048 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6049 | |
| 6050 | ENTER(); |
| 6051 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 6052 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6053 | if (!hdd_ctx) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6054 | hdd_err("Invalid HDD Context"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6055 | EXIT(); |
| 6056 | return; |
| 6057 | } |
| 6058 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 6059 | memdump_deinit(); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 6060 | hdd_driver_memdump_deinit(); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 6061 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6062 | /* Do all the cleanup before deregistering the driver */ |
| 6063 | hdd_wlan_exit(hdd_ctx); |
Mohit Khanna | ebf8a86 | 2016-04-28 17:53:59 -0700 | [diff] [blame] | 6064 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6065 | EXIT(); |
| 6066 | } |
| 6067 | |
| 6068 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 6069 | /** |
| 6070 | * hdd_skip_acs_scan_timer_handler() - skip ACS scan timer timeout handler |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6071 | * @data: pointer to struct hdd_context |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 6072 | * |
| 6073 | * This function will reset acs_scan_status to eSAP_DO_NEW_ACS_SCAN. |
| 6074 | * Then new ACS request will do a fresh scan without reusing the cached |
| 6075 | * scan information. |
| 6076 | * |
| 6077 | * Return: void |
| 6078 | */ |
Tang Yingying | 523322d | 2017-01-17 23:28:43 +0800 | [diff] [blame] | 6079 | static void hdd_skip_acs_scan_timer_handler(void *data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6080 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6081 | struct hdd_context *hdd_ctx = (struct hdd_context *) data; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6082 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6083 | hdd_debug("ACS Scan result expired. Reset ACS scan skip"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6084 | hdd_ctx->skip_acs_scan_status = eSAP_DO_NEW_ACS_SCAN; |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 6085 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 6086 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 6087 | hdd_ctx->last_acs_channel_list = NULL; |
| 6088 | hdd_ctx->num_of_channels = 0; |
| 6089 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6090 | |
| 6091 | if (!hdd_ctx->hHal) |
| 6092 | return; |
| 6093 | sme_scan_flush_result(hdd_ctx->hHal); |
| 6094 | } |
| 6095 | #endif |
| 6096 | |
| 6097 | #ifdef QCA_HT_2040_COEX |
| 6098 | /** |
| 6099 | * hdd_wlan_set_ht2040_mode() - notify FW with HT20/HT40 mode |
| 6100 | * @adapter: pointer to adapter |
| 6101 | * @staId: station id |
| 6102 | * @macAddrSTA: station MAC address |
| 6103 | * @channel_type: channel type |
| 6104 | * |
| 6105 | * This function notifies FW with HT20/HT40 mode |
| 6106 | * |
| 6107 | * Return: 0 if successful, error number otherwise |
| 6108 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6109 | int hdd_wlan_set_ht2040_mode(struct hdd_adapter *adapter, uint16_t staId, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 6110 | struct qdf_mac_addr macAddrSTA, int channel_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6111 | { |
| 6112 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6113 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6114 | struct hdd_context *hdd_ctx = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6115 | |
| 6116 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 6117 | |
| 6118 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 6119 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6120 | return status; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 6121 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6122 | if (!hdd_ctx->hHal) |
| 6123 | return -EINVAL; |
| 6124 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6125 | qdf_status = sme_notify_ht2040_mode(hdd_ctx->hHal, staId, macAddrSTA, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6126 | adapter->sessionId, channel_type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6127 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6128 | hdd_err("Fail to send notification with ht2040 mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6129 | return -EINVAL; |
| 6130 | } |
| 6131 | |
| 6132 | return 0; |
| 6133 | } |
| 6134 | #endif |
| 6135 | |
| 6136 | /** |
| 6137 | * hdd_wlan_notify_modem_power_state() - notify FW with modem power status |
| 6138 | * @state: state |
| 6139 | * |
| 6140 | * This function notifies FW with modem power status |
| 6141 | * |
| 6142 | * Return: 0 if successful, error number otherwise |
| 6143 | */ |
| 6144 | int hdd_wlan_notify_modem_power_state(int state) |
| 6145 | { |
| 6146 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6147 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6148 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6149 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 6150 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6151 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 6152 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6153 | return status; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 6154 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6155 | if (!hdd_ctx->hHal) |
| 6156 | return -EINVAL; |
| 6157 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6158 | qdf_status = sme_notify_modem_power_state(hdd_ctx->hHal, state); |
| 6159 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6160 | hdd_err("Fail to send notification with modem power state %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6161 | state); |
| 6162 | return -EINVAL; |
| 6163 | } |
| 6164 | return 0; |
| 6165 | } |
| 6166 | |
| 6167 | /** |
| 6168 | * |
| 6169 | * hdd_post_cds_enable_config() - HDD post cds start config helper |
| 6170 | * @adapter - Pointer to the HDD |
| 6171 | * |
| 6172 | * Return: None |
| 6173 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6174 | QDF_STATUS hdd_post_cds_enable_config(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6175 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 6176 | QDF_STATUS qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6177 | |
| 6178 | /* |
| 6179 | * Send ready indication to the HDD. This will kick off the MAC |
| 6180 | * into a 'running' state and should kick off an initial scan. |
| 6181 | */ |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 6182 | qdf_ret_status = sme_hdd_ready_ind(hdd_ctx->hHal); |
| 6183 | if (!QDF_IS_STATUS_SUCCESS(qdf_ret_status)) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6184 | hdd_err("sme_hdd_ready_ind() failed with status code %08d [x%08x]", |
| 6185 | qdf_ret_status, qdf_ret_status); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6186 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6187 | } |
| 6188 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6189 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6190 | } |
| 6191 | |
| 6192 | /* wake lock APIs for HDD */ |
| 6193 | void hdd_prevent_suspend(uint32_t reason) |
| 6194 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 6195 | qdf_wake_lock_acquire(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6196 | } |
| 6197 | |
| 6198 | void hdd_allow_suspend(uint32_t reason) |
| 6199 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 6200 | qdf_wake_lock_release(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6201 | } |
| 6202 | |
| 6203 | void hdd_prevent_suspend_timeout(uint32_t timeout, uint32_t reason) |
| 6204 | { |
Anurag Chouhan | 01cfa4e | 2016-09-04 15:10:49 +0530 | [diff] [blame] | 6205 | cds_host_diag_log_work(&wlan_wake_lock, timeout, reason); |
| 6206 | qdf_wake_lock_timeout_acquire(&wlan_wake_lock, timeout); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6207 | } |
| 6208 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6209 | /* Initialize channel list in sme based on the country code */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6210 | QDF_STATUS hdd_set_sme_chan_list(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6211 | { |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 6212 | |
Amar Singhal | 6f8592b | 2017-04-26 14:31:58 -0700 | [diff] [blame] | 6213 | return sme_init_chan_list(hdd_ctx->hHal, |
| 6214 | hdd_ctx->reg.alpha2, |
| 6215 | hdd_ctx->reg.cc_src); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6216 | } |
| 6217 | |
| 6218 | /** |
| 6219 | * hdd_is_5g_supported() - check if hardware supports 5GHz |
| 6220 | * @hdd_ctx: Pointer to the hdd context |
| 6221 | * |
| 6222 | * HDD function to know if hardware supports 5GHz |
| 6223 | * |
| 6224 | * Return: true if hardware supports 5GHz |
| 6225 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6226 | bool hdd_is_5g_supported(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6227 | { |
Amar Singhal | 58b45ef | 2017-08-01 13:43:54 -0700 | [diff] [blame] | 6228 | if (!hdd_ctx) |
zding | f54169a | 2016-10-12 17:08:45 +0800 | [diff] [blame] | 6229 | return true; |
| 6230 | |
Amar Singhal | 58b45ef | 2017-08-01 13:43:54 -0700 | [diff] [blame] | 6231 | if (hdd_ctx->curr_band != eCSR_BAND_24) |
zding | f54169a | 2016-10-12 17:08:45 +0800 | [diff] [blame] | 6232 | return true; |
| 6233 | else |
| 6234 | return false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6235 | } |
| 6236 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6237 | static int hdd_wiphy_init(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6238 | { |
| 6239 | struct wiphy *wiphy; |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6240 | int ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6241 | |
| 6242 | wiphy = hdd_ctx->wiphy; |
| 6243 | |
| 6244 | /* |
| 6245 | * The channel information in |
| 6246 | * wiphy needs to be initialized before wiphy registration |
| 6247 | */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6248 | ret_val = hdd_regulatory_init(hdd_ctx, wiphy); |
| 6249 | if (ret_val) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6250 | hdd_err("regulatory init failed"); |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6251 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6252 | } |
| 6253 | |
| 6254 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 6255 | wiphy->wowlan = &wowlan_support_reg_init; |
| 6256 | #else |
| 6257 | wiphy->wowlan.flags = WIPHY_WOWLAN_ANY | |
| 6258 | WIPHY_WOWLAN_MAGIC_PKT | |
| 6259 | WIPHY_WOWLAN_DISCONNECT | |
| 6260 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 6261 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 6262 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 6263 | WIPHY_WOWLAN_4WAY_HANDSHAKE | |
| 6264 | WIPHY_WOWLAN_RFKILL_RELEASE; |
| 6265 | |
| 6266 | wiphy->wowlan.n_patterns = (WOW_MAX_FILTER_LISTS * |
| 6267 | WOW_MAX_FILTERS_PER_LIST); |
| 6268 | wiphy->wowlan.pattern_min_len = WOW_MIN_PATTERN_SIZE; |
| 6269 | wiphy->wowlan.pattern_max_len = WOW_MAX_PATTERN_SIZE; |
| 6270 | #endif |
| 6271 | |
| 6272 | /* registration of wiphy dev with cfg80211 */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6273 | ret_val = wlan_hdd_cfg80211_register(wiphy); |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 6274 | if (0 > ret_val) { |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6275 | hdd_err("wiphy registration failed"); |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 6276 | return ret_val; |
| 6277 | } |
| 6278 | |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 6279 | if (!hdd_ctx->reg_offload) |
| 6280 | hdd_program_country_code(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6281 | |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6282 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6283 | } |
| 6284 | |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 6285 | /** |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6286 | * hdd_pld_request_bus_bandwidth() - Function to control bus bandwidth |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 6287 | * @hdd_ctx - handle to hdd context |
| 6288 | * @tx_packets - transmit packet count |
| 6289 | * @rx_packets - receive packet count |
| 6290 | * |
| 6291 | * The function controls the bus bandwidth and dynamic control of |
| 6292 | * tcp delayed ack configuration |
| 6293 | * |
| 6294 | * Returns: None |
| 6295 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6296 | #ifdef MSM_PLATFORM |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6297 | static void hdd_pld_request_bus_bandwidth(struct hdd_context *hdd_ctx, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 6298 | const uint64_t tx_packets, |
| 6299 | const uint64_t rx_packets) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6300 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6301 | uint64_t total = tx_packets + rx_packets; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 6302 | uint64_t temp_rx = 0; |
| 6303 | uint64_t temp_tx = 0; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6304 | enum pld_bus_width_type next_vote_level = PLD_BUS_WIDTH_NONE; |
Mohit Khanna | c3da706 | 2017-02-08 21:08:56 -0800 | [diff] [blame] | 6305 | static enum wlan_tp_level next_rx_level = WLAN_SVC_TP_NONE; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 6306 | enum wlan_tp_level next_tx_level = WLAN_SVC_TP_NONE; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 6307 | uint32_t delack_timer_cnt = hdd_ctx->config->tcp_delack_timer_count; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 6308 | uint16_t index = 0; |
| 6309 | bool vote_level_change = false; |
| 6310 | bool rx_level_change = false; |
| 6311 | bool tx_level_change = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6312 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6313 | if (total > hdd_ctx->config->busBandwidthHighThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6314 | next_vote_level = PLD_BUS_WIDTH_HIGH; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6315 | else if (total > hdd_ctx->config->busBandwidthMediumThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6316 | next_vote_level = PLD_BUS_WIDTH_MEDIUM; |
Yue Ma | d6478e4 | 2015-10-20 18:49:24 -0700 | [diff] [blame] | 6317 | else if (total > hdd_ctx->config->busBandwidthLowThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6318 | next_vote_level = PLD_BUS_WIDTH_LOW; |
Yue Ma | d6478e4 | 2015-10-20 18:49:24 -0700 | [diff] [blame] | 6319 | else |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6320 | next_vote_level = PLD_BUS_WIDTH_NONE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6321 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6322 | if (hdd_ctx->cur_vote_level != next_vote_level) { |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 6323 | hdd_debug("trigger level %d, tx_packets: %lld, rx_packets: %lld", |
| 6324 | next_vote_level, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6325 | hdd_ctx->cur_vote_level = next_vote_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 6326 | vote_level_change = true; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6327 | pld_request_bus_bandwidth(hdd_ctx->parent_dev, next_vote_level); |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 6328 | if (next_vote_level == PLD_BUS_WIDTH_LOW) { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 6329 | if (hdd_ctx->hbw_requested) { |
| 6330 | pld_remove_pm_qos(hdd_ctx->parent_dev); |
| 6331 | hdd_ctx->hbw_requested = false; |
| 6332 | } |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 6333 | if (cds_sched_handle_throughput_req(false)) |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6334 | hdd_warn("low bandwidth set rx affinity fail"); |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 6335 | } else { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 6336 | if (!hdd_ctx->hbw_requested) { |
| 6337 | pld_request_pm_qos(hdd_ctx->parent_dev, 1); |
| 6338 | hdd_ctx->hbw_requested = true; |
| 6339 | } |
| 6340 | |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 6341 | if (cds_sched_handle_throughput_req(true)) |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6342 | hdd_warn("high bandwidth set rx affinity fail"); |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 6343 | } |
Orhan K AKYILDIZ | 1481aff | 2016-05-16 12:40:13 -0700 | [diff] [blame] | 6344 | hdd_napi_apply_throughput_policy(hdd_ctx, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6345 | } |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 6346 | |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 6347 | qdf_dp_trace_throttle_live_mode( |
| 6348 | (next_vote_level > PLD_BUS_WIDTH_NONE) ? true : false); |
| 6349 | |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 6350 | /* fine-tuning parameters for RX Flows */ |
| 6351 | temp_rx = (rx_packets + hdd_ctx->prev_rx) / 2; |
| 6352 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6353 | hdd_ctx->prev_rx = rx_packets; |
Mohit Khanna | b1dd1e8 | 2017-02-04 15:14:38 -0800 | [diff] [blame] | 6354 | |
Ravi Joshi | fed8357 | 2016-10-07 16:20:37 -0700 | [diff] [blame] | 6355 | if (temp_rx > hdd_ctx->config->tcpDelackThresholdHigh) { |
| 6356 | if ((hdd_ctx->cur_rx_level != WLAN_SVC_TP_HIGH) && |
| 6357 | (++hdd_ctx->rx_high_ind_cnt == delack_timer_cnt)) { |
| 6358 | next_rx_level = WLAN_SVC_TP_HIGH; |
| 6359 | } |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 6360 | } else { |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 6361 | hdd_ctx->rx_high_ind_cnt = 0; |
Mohit Khanna | c3da706 | 2017-02-08 21:08:56 -0800 | [diff] [blame] | 6362 | next_rx_level = WLAN_SVC_TP_LOW; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 6363 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6364 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6365 | if (hdd_ctx->cur_rx_level != next_rx_level) { |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 6366 | hdd_debug("TCP DELACK trigger level %d, average_rx: %llu", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6367 | next_rx_level, temp_rx); |
| 6368 | hdd_ctx->cur_rx_level = next_rx_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 6369 | rx_level_change = true; |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 6370 | /* Send throughput indication only if it is enabled. |
| 6371 | * Disabling tcp_del_ack will revert the tcp stack behavior |
| 6372 | * to default delayed ack. Note that this will disable the |
| 6373 | * dynamic delayed ack mechanism across the system |
| 6374 | */ |
| 6375 | if (hdd_ctx->config->enable_tcp_delack) |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 6376 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 6377 | WLAN_SVC_WLAN_TP_IND, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6378 | &next_rx_level, |
| 6379 | sizeof(next_rx_level)); |
| 6380 | } |
| 6381 | |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 6382 | /* fine-tuning parameters for TX Flows */ |
| 6383 | temp_tx = (tx_packets + hdd_ctx->prev_tx) / 2; |
| 6384 | hdd_ctx->prev_tx = tx_packets; |
| 6385 | if (temp_tx > hdd_ctx->config->tcp_tx_high_tput_thres) |
| 6386 | next_tx_level = WLAN_SVC_TP_HIGH; |
| 6387 | else |
| 6388 | next_tx_level = WLAN_SVC_TP_LOW; |
| 6389 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6390 | if (hdd_ctx->cur_tx_level != next_tx_level) { |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 6391 | hdd_debug("change TCP TX trigger level %d, average_tx: %llu", |
| 6392 | next_tx_level, temp_tx); |
| 6393 | hdd_ctx->cur_tx_level = next_tx_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 6394 | tx_level_change = true; |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 6395 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 6396 | WLAN_SVC_WLAN_TP_TX_IND, |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 6397 | &next_tx_level, |
| 6398 | sizeof(next_tx_level)); |
| 6399 | } |
| 6400 | |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 6401 | index = hdd_ctx->hdd_txrx_hist_idx; |
| 6402 | |
| 6403 | if (vote_level_change || tx_level_change || rx_level_change) { |
| 6404 | hdd_ctx->hdd_txrx_hist[index].next_tx_level = next_tx_level; |
| 6405 | hdd_ctx->hdd_txrx_hist[index].next_rx_level = next_rx_level; |
| 6406 | hdd_ctx->hdd_txrx_hist[index].next_vote_level = next_vote_level; |
| 6407 | hdd_ctx->hdd_txrx_hist[index].interval_rx = rx_packets; |
| 6408 | hdd_ctx->hdd_txrx_hist[index].interval_tx = tx_packets; |
| 6409 | hdd_ctx->hdd_txrx_hist[index].qtime = qdf_get_log_timestamp(); |
| 6410 | hdd_ctx->hdd_txrx_hist_idx++; |
| 6411 | hdd_ctx->hdd_txrx_hist_idx &= NUM_TX_RX_HISTOGRAM_MASK; |
| 6412 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6413 | } |
| 6414 | |
| 6415 | #define HDD_BW_GET_DIFF(_x, _y) (unsigned long)((ULONG_MAX - (_y)) + (_x) + 1) |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 6416 | static void hdd_bus_bw_work_handler(struct work_struct *work) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6417 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6418 | struct hdd_context *hdd_ctx = container_of(work, struct hdd_context, |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 6419 | bus_bw_work); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6420 | struct hdd_adapter *adapter = NULL; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 6421 | uint64_t tx_packets = 0, rx_packets = 0; |
Himanshu Agarwal | a6cedee | 2016-06-08 14:50:00 +0530 | [diff] [blame] | 6422 | uint64_t fwd_tx_packets = 0, fwd_rx_packets = 0; |
| 6423 | uint64_t fwd_tx_packets_diff = 0, fwd_rx_packets_diff = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6424 | uint64_t total_tx = 0, total_rx = 0; |
| 6425 | hdd_adapter_list_node_t *adapterNode = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6426 | QDF_STATUS status = 0; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 6427 | A_STATUS ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6428 | bool connected = false; |
| 6429 | uint32_t ipa_tx_packets = 0, ipa_rx_packets = 0; |
| 6430 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6431 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 6432 | return; |
| 6433 | |
Jingxiang Ge | c64e193 | 2017-08-22 14:38:59 +0800 | [diff] [blame] | 6434 | if (hdd_ctx->isWiphySuspended) |
| 6435 | goto restart_timer; |
| 6436 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6437 | for (status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6438 | NULL != adapterNode && QDF_STATUS_SUCCESS == status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6439 | status = |
| 6440 | hdd_get_next_adapter(hdd_ctx, adapterNode, &adapterNode)) { |
| 6441 | |
| 6442 | if (adapterNode->pAdapter == NULL) |
| 6443 | continue; |
| 6444 | adapter = adapterNode->pAdapter; |
Manjeet Singh | 01327cc | 2016-09-03 12:14:25 +0530 | [diff] [blame] | 6445 | /* |
| 6446 | * Validate magic so we don't end up accessing |
| 6447 | * an invalid adapter. |
| 6448 | */ |
| 6449 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) |
| 6450 | continue; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6451 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6452 | if ((adapter->device_mode == QDF_STA_MODE || |
| 6453 | adapter->device_mode == QDF_P2P_CLIENT_MODE) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6454 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)->conn_info.connState |
| 6455 | != eConnectionState_Associated) { |
| 6456 | |
| 6457 | continue; |
| 6458 | } |
| 6459 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6460 | if ((adapter->device_mode == QDF_SAP_MODE || |
| 6461 | adapter->device_mode == QDF_P2P_GO_MODE) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6462 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->bApActive == false) { |
| 6463 | |
| 6464 | continue; |
| 6465 | } |
| 6466 | |
| 6467 | tx_packets += HDD_BW_GET_DIFF(adapter->stats.tx_packets, |
| 6468 | adapter->prev_tx_packets); |
| 6469 | rx_packets += HDD_BW_GET_DIFF(adapter->stats.rx_packets, |
| 6470 | adapter->prev_rx_packets); |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 6471 | |
| 6472 | if (adapter->device_mode == QDF_SAP_MODE || |
| 6473 | adapter->device_mode == QDF_P2P_GO_MODE || |
| 6474 | adapter->device_mode == QDF_IBSS_MODE) { |
| 6475 | |
Dhanashri Atre | a8f82f2 | 2017-01-23 12:58:24 -0800 | [diff] [blame] | 6476 | ret = cdp_get_intra_bss_fwd_pkts_count( |
| 6477 | cds_get_context(QDF_MODULE_ID_SOC), |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 6478 | adapter->sessionId, |
| 6479 | &fwd_tx_packets, &fwd_rx_packets); |
| 6480 | if (ret == A_OK) { |
| 6481 | fwd_tx_packets_diff += HDD_BW_GET_DIFF( |
| 6482 | fwd_tx_packets, |
| 6483 | adapter->prev_fwd_tx_packets); |
| 6484 | fwd_rx_packets_diff += HDD_BW_GET_DIFF( |
| 6485 | fwd_tx_packets, |
| 6486 | adapter->prev_fwd_rx_packets); |
| 6487 | } |
| 6488 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6489 | |
| 6490 | total_rx += adapter->stats.rx_packets; |
| 6491 | total_tx += adapter->stats.tx_packets; |
| 6492 | |
| 6493 | spin_lock_bh(&hdd_ctx->bus_bw_lock); |
| 6494 | adapter->prev_tx_packets = adapter->stats.tx_packets; |
| 6495 | adapter->prev_rx_packets = adapter->stats.rx_packets; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 6496 | adapter->prev_fwd_tx_packets = fwd_tx_packets; |
| 6497 | adapter->prev_fwd_rx_packets = fwd_rx_packets; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6498 | spin_unlock_bh(&hdd_ctx->bus_bw_lock); |
| 6499 | connected = true; |
| 6500 | } |
| 6501 | |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 6502 | /* add intra bss forwarded tx and rx packets */ |
| 6503 | tx_packets += fwd_tx_packets_diff; |
| 6504 | rx_packets += fwd_rx_packets_diff; |
| 6505 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6506 | hdd_ipa_uc_stat_query(hdd_ctx, &ipa_tx_packets, &ipa_rx_packets); |
| 6507 | tx_packets += (uint64_t)ipa_tx_packets; |
| 6508 | rx_packets += (uint64_t)ipa_rx_packets; |
| 6509 | |
| 6510 | if (!connected) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6511 | hdd_err("bus bandwidth timer running in disconnected state"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6512 | return; |
| 6513 | } |
| 6514 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6515 | hdd_pld_request_bus_bandwidth(hdd_ctx, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6516 | |
| 6517 | hdd_ipa_set_perf_level(hdd_ctx, tx_packets, rx_packets); |
| 6518 | hdd_ipa_uc_stat_request(adapter, 2); |
| 6519 | |
Jingxiang Ge | c64e193 | 2017-08-22 14:38:59 +0800 | [diff] [blame] | 6520 | restart_timer: |
Dustin Brown | 2ed6036 | 2017-01-18 12:25:50 -0800 | [diff] [blame] | 6521 | /* ensure periodic timer should still be running before restarting it */ |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 6522 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 2ed6036 | 2017-01-18 12:25:50 -0800 | [diff] [blame] | 6523 | if (hdd_ctx->bus_bw_timer_running) |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 6524 | qdf_timer_mod(&hdd_ctx->bus_bw_timer, |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 6525 | hdd_ctx->config->busBandwidthComputeInterval); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 6526 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6527 | } |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6528 | |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 6529 | /** |
| 6530 | * __hdd_bus_bw_cbk() - Bus bandwidth data structure callback. |
| 6531 | * @arg: Argument of timer function |
| 6532 | * |
| 6533 | * Schedule a workqueue in this function where all the processing is done. |
| 6534 | * |
| 6535 | * Return: None. |
| 6536 | */ |
| 6537 | static void __hdd_bus_bw_cbk(void *arg) |
| 6538 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6539 | struct hdd_context *hdd_ctx = (struct hdd_context *) arg; |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 6540 | |
| 6541 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 6542 | return; |
| 6543 | |
| 6544 | schedule_work(&hdd_ctx->bus_bw_work); |
| 6545 | } |
| 6546 | |
| 6547 | /** |
| 6548 | * hdd_bus_bw_cbk() - Wrapper for bus bw callback for SSR protection. |
| 6549 | * @arg: Argument of timer function |
| 6550 | * |
| 6551 | * Return: None. |
| 6552 | */ |
| 6553 | static void hdd_bus_bw_cbk(void *arg) |
| 6554 | { |
| 6555 | cds_ssr_protect(__func__); |
| 6556 | __hdd_bus_bw_cbk(arg); |
| 6557 | cds_ssr_unprotect(__func__); |
| 6558 | } |
| 6559 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6560 | int hdd_bus_bandwidth_init(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6561 | { |
| 6562 | spin_lock_init(&hdd_ctx->bus_bw_lock); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 6563 | INIT_WORK(&hdd_ctx->bus_bw_work, |
| 6564 | hdd_bus_bw_work_handler); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 6565 | hdd_ctx->bus_bw_timer_running = false; |
| 6566 | qdf_spinlock_create(&hdd_ctx->bus_bw_timer_lock); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 6567 | qdf_timer_init(NULL, |
| 6568 | &hdd_ctx->bus_bw_timer, |
| 6569 | hdd_bus_bw_cbk, (void *)hdd_ctx, |
| 6570 | QDF_TIMER_TYPE_SW); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6571 | |
| 6572 | return 0; |
| 6573 | } |
| 6574 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6575 | void hdd_bus_bandwidth_destroy(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6576 | { |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 6577 | if (hdd_ctx->bus_bw_timer_running) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6578 | hdd_reset_tcp_delack(hdd_ctx); |
| 6579 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6580 | hdd_debug("wait for bus bw work to flush"); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 6581 | cancel_work_sync(&hdd_ctx->bus_bw_work); |
| 6582 | qdf_timer_free(&hdd_ctx->bus_bw_timer); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 6583 | hdd_ctx->bus_bw_timer_running = false; |
| 6584 | qdf_spinlock_destroy(&hdd_ctx->bus_bw_timer_lock); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6585 | } |
Lin Bai | c5c0688 | 2017-09-21 13:58:43 +0800 | [diff] [blame] | 6586 | |
| 6587 | void hdd_bus_bw_cancel_work(struct hdd_context *hdd_ctx) |
| 6588 | { |
| 6589 | if (hdd_ctx) |
| 6590 | cancel_work_sync(&hdd_ctx->bus_bw_work); |
| 6591 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6592 | #endif |
| 6593 | |
| 6594 | /** |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 6595 | * wlan_hdd_init_tx_rx_histogram() - init tx/rx histogram stats |
| 6596 | * @hdd_ctx: hdd context |
| 6597 | * |
| 6598 | * Return: 0 for success or error code |
| 6599 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6600 | static int wlan_hdd_init_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 6601 | { |
| 6602 | hdd_ctx->hdd_txrx_hist = qdf_mem_malloc( |
| 6603 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
| 6604 | if (hdd_ctx->hdd_txrx_hist == NULL) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6605 | hdd_err("Failed malloc for hdd_txrx_hist"); |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 6606 | return -ENOMEM; |
| 6607 | } |
| 6608 | return 0; |
| 6609 | } |
| 6610 | |
| 6611 | /** |
| 6612 | * wlan_hdd_deinit_tx_rx_histogram() - deinit tx/rx histogram stats |
| 6613 | * @hdd_ctx: hdd context |
| 6614 | * |
| 6615 | * Return: none |
| 6616 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6617 | void wlan_hdd_deinit_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 6618 | { |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 6619 | if (!hdd_ctx || hdd_ctx->hdd_txrx_hist == NULL) |
| 6620 | return; |
| 6621 | |
| 6622 | qdf_mem_free(hdd_ctx->hdd_txrx_hist); |
| 6623 | hdd_ctx->hdd_txrx_hist = NULL; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 6624 | } |
| 6625 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 6626 | static uint8_t *convert_level_to_string(uint32_t level) |
| 6627 | { |
| 6628 | switch (level) { |
| 6629 | /* initialize the wlan sub system */ |
| 6630 | case WLAN_SVC_TP_NONE: |
| 6631 | return "NONE"; |
| 6632 | case WLAN_SVC_TP_LOW: |
| 6633 | return "LOW"; |
| 6634 | case WLAN_SVC_TP_MEDIUM: |
| 6635 | return "MED"; |
| 6636 | case WLAN_SVC_TP_HIGH: |
| 6637 | return "HIGH"; |
| 6638 | default: |
| 6639 | return "INVAL"; |
| 6640 | } |
| 6641 | } |
| 6642 | |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 6643 | |
| 6644 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6645 | * wlan_hdd_display_tx_rx_histogram() - display tx rx histogram |
| 6646 | * @hdd_ctx: hdd context |
| 6647 | * |
| 6648 | * Return: none |
| 6649 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6650 | void wlan_hdd_display_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6651 | { |
| 6652 | int i; |
| 6653 | |
| 6654 | #ifdef MSM_PLATFORM |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6655 | hdd_debug("BW compute Interval: %dms", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 6656 | hdd_ctx->config->busBandwidthComputeInterval); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6657 | hdd_debug("BW High TH: %d BW Med TH: %d BW Low TH: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6658 | hdd_ctx->config->busBandwidthHighThreshold, |
| 6659 | hdd_ctx->config->busBandwidthMediumThreshold, |
| 6660 | hdd_ctx->config->busBandwidthLowThreshold); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6661 | hdd_debug("Enable TCP DEL ACK: %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 6662 | hdd_ctx->config->enable_tcp_delack); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6663 | hdd_debug("TCP DEL High TH: %d TCP DEL Low TH: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6664 | hdd_ctx->config->tcpDelackThresholdHigh, |
| 6665 | hdd_ctx->config->tcpDelackThresholdLow); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6666 | hdd_debug("TCP TX HIGH TP TH: %d (Use to set tcp_output_bytes_limit)", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 6667 | hdd_ctx->config->tcp_tx_high_tput_thres); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6668 | #endif |
| 6669 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6670 | hdd_debug("Total entries: %d Current index: %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 6671 | NUM_TX_RX_HISTOGRAM, hdd_ctx->hdd_txrx_hist_idx); |
| 6672 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6673 | hdd_debug("[index][timestamp]: interval_rx, interval_tx, bus_bw_level, RX TP Level, TX TP Level"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6674 | |
| 6675 | for (i = 0; i < NUM_TX_RX_HISTOGRAM; i++) { |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 6676 | /* using hdd_log to avoid printing function name */ |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 6677 | if (hdd_ctx->hdd_txrx_hist[i].qtime > 0) |
Houston Hoffman | 0022711 | 2017-08-14 23:58:18 -0700 | [diff] [blame] | 6678 | hdd_log(QDF_TRACE_LEVEL_DEBUG, |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 6679 | "[%3d][%15llu]: %6llu, %6llu, %s, %s, %s", |
| 6680 | i, hdd_ctx->hdd_txrx_hist[i].qtime, |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 6681 | hdd_ctx->hdd_txrx_hist[i].interval_rx, |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 6682 | hdd_ctx->hdd_txrx_hist[i].interval_tx, |
| 6683 | convert_level_to_string( |
| 6684 | hdd_ctx->hdd_txrx_hist[i]. |
| 6685 | next_vote_level), |
| 6686 | convert_level_to_string( |
| 6687 | hdd_ctx->hdd_txrx_hist[i]. |
| 6688 | next_rx_level), |
| 6689 | convert_level_to_string( |
| 6690 | hdd_ctx->hdd_txrx_hist[i]. |
| 6691 | next_tx_level)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6692 | } |
Mohit Khanna | c68622e | 2017-01-31 21:07:12 -0800 | [diff] [blame] | 6693 | |
| 6694 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6695 | } |
| 6696 | |
| 6697 | /** |
| 6698 | * wlan_hdd_clear_tx_rx_histogram() - clear tx rx histogram |
| 6699 | * @hdd_ctx: hdd context |
| 6700 | * |
| 6701 | * Return: none |
| 6702 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6703 | void wlan_hdd_clear_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6704 | { |
| 6705 | hdd_ctx->hdd_txrx_hist_idx = 0; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 6706 | qdf_mem_zero(hdd_ctx->hdd_txrx_hist, |
| 6707 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6708 | } |
| 6709 | |
| 6710 | /** |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6711 | * wlan_hdd_display_netif_queue_history() - display netif queue history |
Jeff Johnson | 58adbcf | 2017-09-03 08:53:31 -0700 | [diff] [blame] | 6712 | * @hdd_ctx: hdd context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6713 | * |
| 6714 | * Return: none |
| 6715 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6716 | void wlan_hdd_display_netif_queue_history(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6717 | { |
| 6718 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6719 | struct hdd_adapter *adapter = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6720 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6721 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6722 | int i; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 6723 | qdf_time_t total, pause, unpause, curr_time, delta; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6724 | |
| 6725 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6726 | while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6727 | adapter = adapter_node->pAdapter; |
| 6728 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6729 | hdd_debug("Netif queue operation statistics:"); |
| 6730 | hdd_debug("Session_id %d device mode %d", |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 6731 | adapter->sessionId, adapter->device_mode); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6732 | hdd_debug("Current pause_map value %x", adapter->pause_map); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 6733 | curr_time = qdf_system_ticks(); |
| 6734 | total = curr_time - adapter->start_time; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 6735 | delta = curr_time - adapter->last_time; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 6736 | if (adapter->pause_map) { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 6737 | pause = adapter->total_pause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 6738 | unpause = adapter->total_unpause_time; |
| 6739 | } else { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 6740 | unpause = adapter->total_unpause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 6741 | pause = adapter->total_pause_time; |
| 6742 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6743 | hdd_debug("Total: %ums Pause: %ums Unpause: %ums", |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 6744 | qdf_system_ticks_to_msecs(total), |
| 6745 | qdf_system_ticks_to_msecs(pause), |
| 6746 | qdf_system_ticks_to_msecs(unpause)); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6747 | hdd_debug("reason_type: pause_cnt: unpause_cnt: pause_time"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6748 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 6749 | for (i = WLAN_CONTROL_PATH; i < WLAN_REASON_TYPE_MAX; i++) { |
| 6750 | qdf_time_t pause_delta = 0; |
| 6751 | |
| 6752 | if (adapter->pause_map & (1 << i)) |
| 6753 | pause_delta = delta; |
| 6754 | |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 6755 | /* using hdd_log to avoid printing function name */ |
Houston Hoffman | 0022711 | 2017-08-14 23:58:18 -0700 | [diff] [blame] | 6756 | hdd_log(QDF_TRACE_LEVEL_DEBUG, |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 6757 | "%s: %d: %d: %ums", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6758 | hdd_reason_type_to_string(i), |
| 6759 | adapter->queue_oper_stats[i].pause_count, |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 6760 | adapter->queue_oper_stats[i].unpause_count, |
| 6761 | qdf_system_ticks_to_msecs( |
| 6762 | adapter->queue_oper_stats[i].total_pause_time + |
| 6763 | pause_delta)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6764 | } |
| 6765 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6766 | hdd_debug("Netif queue operation history:"); |
| 6767 | hdd_debug("Total entries: %d current index %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 6768 | WLAN_HDD_MAX_HISTORY_ENTRY, adapter->history_index); |
| 6769 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6770 | hdd_debug("index: time: action_type: reason_type: pause_map"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6771 | |
| 6772 | for (i = 0; i < WLAN_HDD_MAX_HISTORY_ENTRY; i++) { |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 6773 | /* using hdd_log to avoid printing function name */ |
| 6774 | if (adapter->queue_oper_history[i].time == 0) |
| 6775 | continue; |
Houston Hoffman | 0022711 | 2017-08-14 23:58:18 -0700 | [diff] [blame] | 6776 | hdd_log(QDF_TRACE_LEVEL_DEBUG, |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 6777 | "%d: %u: %s: %s: %x", |
Anurag Chouhan | 50220ce | 2016-02-18 20:11:33 +0530 | [diff] [blame] | 6778 | i, qdf_system_ticks_to_msecs( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6779 | adapter->queue_oper_history[i].time), |
| 6780 | hdd_action_type_to_string( |
| 6781 | adapter->queue_oper_history[i].netif_action), |
| 6782 | hdd_reason_type_to_string( |
| 6783 | adapter->queue_oper_history[i].netif_reason), |
| 6784 | adapter->queue_oper_history[i].pause_map); |
| 6785 | } |
| 6786 | |
| 6787 | status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next); |
| 6788 | adapter_node = next; |
| 6789 | } |
| 6790 | |
| 6791 | |
| 6792 | } |
| 6793 | |
| 6794 | /** |
| 6795 | * wlan_hdd_clear_netif_queue_history() - clear netif queue operation history |
| 6796 | * @hdd_ctx: hdd context |
| 6797 | * |
| 6798 | * Return: none |
| 6799 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6800 | void wlan_hdd_clear_netif_queue_history(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6801 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6802 | struct hdd_adapter *adapter = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6803 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6804 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6805 | |
| 6806 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6807 | while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6808 | adapter = adapter_node->pAdapter; |
| 6809 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6810 | qdf_mem_zero(adapter->queue_oper_stats, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6811 | sizeof(adapter->queue_oper_stats)); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6812 | qdf_mem_zero(adapter->queue_oper_history, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6813 | sizeof(adapter->queue_oper_history)); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 6814 | adapter->history_index = 0; |
| 6815 | adapter->start_time = adapter->last_time = qdf_system_ticks(); |
| 6816 | adapter->total_pause_time = 0; |
| 6817 | adapter->total_unpause_time = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6818 | status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next); |
| 6819 | adapter_node = next; |
| 6820 | } |
| 6821 | } |
| 6822 | |
| 6823 | /** |
| 6824 | * hdd_11d_scan_done() - callback for 11d scan completion of flushing results |
| 6825 | * @halHandle: Hal handle |
| 6826 | * @pContext: Pointer to the context |
| 6827 | * @sessionId: Session ID |
| 6828 | * @scanId: Scan ID |
| 6829 | * @status: Status |
| 6830 | * |
| 6831 | * This is the callback to be executed when 11d scan is completed to flush out |
| 6832 | * the scan results |
| 6833 | * |
| 6834 | * 11d scan is done during driver load and is a passive scan on all |
| 6835 | * channels supported by the device, 11d scans may find some APs on |
| 6836 | * frequencies which are forbidden to be used in the regulatory domain |
| 6837 | * the device is operating in. If these APs are notified to the supplicant |
| 6838 | * it may try to connect to these APs, thus flush out all the scan results |
| 6839 | * which are present in SME after 11d scan is done. |
| 6840 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6841 | * Return: QDF_STATUS_SUCCESS |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6842 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6843 | static QDF_STATUS hdd_11d_scan_done(tHalHandle halHandle, void *pContext, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6844 | uint8_t sessionId, uint32_t scanId, |
| 6845 | eCsrScanStatus status) |
| 6846 | { |
| 6847 | ENTER(); |
| 6848 | |
| 6849 | sme_scan_flush_result(halHandle); |
| 6850 | |
| 6851 | EXIT(); |
| 6852 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6853 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6854 | } |
| 6855 | |
| 6856 | #ifdef WLAN_FEATURE_OFFLOAD_PACKETS |
| 6857 | /** |
| 6858 | * hdd_init_offloaded_packets_ctx() - Initialize offload packets context |
| 6859 | * @hdd_ctx: hdd global context |
| 6860 | * |
| 6861 | * Return: none |
| 6862 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6863 | static void hdd_init_offloaded_packets_ctx(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6864 | { |
| 6865 | uint8_t i; |
| 6866 | |
| 6867 | mutex_init(&hdd_ctx->op_ctx.op_lock); |
| 6868 | for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++) { |
| 6869 | hdd_ctx->op_ctx.op_table[i].request_id = MAX_REQUEST_ID; |
| 6870 | hdd_ctx->op_ctx.op_table[i].pattern_id = i; |
| 6871 | } |
| 6872 | } |
| 6873 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6874 | static void hdd_init_offloaded_packets_ctx(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6875 | { |
| 6876 | } |
| 6877 | #endif |
| 6878 | |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 6879 | #ifdef WLAN_FEATURE_WOW_PULSE |
| 6880 | /** |
| 6881 | * wlan_hdd_set_wow_pulse() - call SME to send wmi cmd of wow pulse |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6882 | * @phddctx: struct hdd_context structure pointer |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 6883 | * @enable: enable or disable this behaviour |
| 6884 | * |
| 6885 | * Return: int |
| 6886 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6887 | static int wlan_hdd_set_wow_pulse(struct hdd_context *phddctx, bool enable) |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 6888 | { |
| 6889 | struct hdd_config *pcfg_ini = phddctx->config; |
| 6890 | struct wow_pulse_mode wow_pulse_set_info; |
| 6891 | QDF_STATUS status; |
| 6892 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6893 | hdd_debug("wow pulse enable flag is %d", enable); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 6894 | |
| 6895 | if (false == phddctx->config->wow_pulse_support) |
| 6896 | return 0; |
| 6897 | |
| 6898 | /* prepare the request to send to SME */ |
| 6899 | if (enable == true) { |
| 6900 | wow_pulse_set_info.wow_pulse_enable = true; |
| 6901 | wow_pulse_set_info.wow_pulse_pin = |
| 6902 | pcfg_ini->wow_pulse_pin; |
| 6903 | wow_pulse_set_info.wow_pulse_interval_low = |
| 6904 | pcfg_ini->wow_pulse_interval_low; |
| 6905 | wow_pulse_set_info.wow_pulse_interval_high = |
| 6906 | pcfg_ini->wow_pulse_interval_high; |
| 6907 | } else { |
| 6908 | wow_pulse_set_info.wow_pulse_enable = false; |
| 6909 | wow_pulse_set_info.wow_pulse_pin = 0; |
| 6910 | wow_pulse_set_info.wow_pulse_interval_low = 0; |
| 6911 | wow_pulse_set_info.wow_pulse_interval_high = 0; |
| 6912 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6913 | hdd_debug("enable %d pin %d low %d high %d", |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 6914 | wow_pulse_set_info.wow_pulse_enable, |
| 6915 | wow_pulse_set_info.wow_pulse_pin, |
| 6916 | wow_pulse_set_info.wow_pulse_interval_low, |
| 6917 | wow_pulse_set_info.wow_pulse_interval_high); |
| 6918 | |
| 6919 | status = sme_set_wow_pulse(&wow_pulse_set_info); |
| 6920 | if (QDF_STATUS_E_FAILURE == status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6921 | hdd_debug("sme_set_wow_pulse failure!"); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 6922 | return -EIO; |
| 6923 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6924 | hdd_debug("sme_set_wow_pulse success!"); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 6925 | return 0; |
| 6926 | } |
| 6927 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6928 | static inline int wlan_hdd_set_wow_pulse(struct hdd_context *phddctx, bool enable) |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 6929 | { |
| 6930 | return 0; |
| 6931 | } |
| 6932 | #endif |
| 6933 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6934 | #ifdef WLAN_FEATURE_FASTPATH |
| 6935 | /** |
| 6936 | * hdd_enable_fastpath() - Enable fastpath if enabled in config INI |
| 6937 | * @hdd_cfg: hdd config |
| 6938 | * @context: lower layer context |
| 6939 | * |
| 6940 | * Return: none |
| 6941 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6942 | void hdd_enable_fastpath(struct hdd_config *hdd_cfg, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6943 | void *context) |
| 6944 | { |
| 6945 | if (hdd_cfg->fastpath_enable) |
| 6946 | hif_enable_fastpath(context); |
| 6947 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6948 | #endif |
| 6949 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6950 | #if defined(FEATURE_WLAN_CH_AVOID) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6951 | /** |
| 6952 | * hdd_set_thermal_level_cb() - set thermal level callback function |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 6953 | * @context: hdd context pointer |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6954 | * @level: thermal level |
| 6955 | * |
| 6956 | * Change IPA data path to SW path when the thermal throttle level greater |
| 6957 | * than 0, and restore the original data path when throttle level is 0 |
| 6958 | * |
| 6959 | * Return: none |
| 6960 | */ |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 6961 | static void hdd_set_thermal_level_cb(void *context, u_int8_t level) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6962 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6963 | struct hdd_context *hdd_ctx = context; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 6964 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6965 | /* Change IPA to SW path when throttle level greater than 0 */ |
| 6966 | if (level > THROTTLE_LEVEL_0) |
| 6967 | hdd_ipa_send_mcc_scc_msg(hdd_ctx, true); |
| 6968 | else |
| 6969 | /* restore original concurrency mode */ |
| 6970 | hdd_ipa_send_mcc_scc_msg(hdd_ctx, hdd_ctx->mcc_mode); |
| 6971 | } |
| 6972 | |
| 6973 | /** |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6974 | * hdd_get_safe_channel_from_pcl_and_acs_range() - Get safe channel for SAP |
| 6975 | * restart |
Manishekar Chandrasekaran | db9b867 | 2016-06-10 23:31:19 +0530 | [diff] [blame] | 6976 | * @adapter: AP adapter, which should be checked for NULL |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6977 | * |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6978 | * Get a safe channel to restart SAP. PCL already takes into account the |
| 6979 | * unsafe channels. So, the PCL is validated with the ACS range to provide |
| 6980 | * a safe channel for the SAP to restart. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6981 | * |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6982 | * Return: Channel number to restart SAP in case of success. In case of any |
| 6983 | * failure, the channel number returned is zero. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6984 | */ |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6985 | static uint8_t hdd_get_safe_channel_from_pcl_and_acs_range( |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6986 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6987 | { |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6988 | struct sir_pcl_list pcl; |
| 6989 | QDF_STATUS status; |
| 6990 | uint32_t i, j; |
| 6991 | tHalHandle *hal_handle; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6992 | struct hdd_context *hdd_ctx; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6993 | bool found = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6994 | |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 6995 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 6996 | if (!hdd_ctx) { |
| 6997 | hdd_err("invalid HDD context"); |
| 6998 | return INVALID_CHANNEL_ID; |
| 6999 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7000 | |
Manishekar Chandrasekaran | 79746ac | 2016-06-24 04:45:33 +0530 | [diff] [blame] | 7001 | hal_handle = WLAN_HDD_GET_HAL_CTX(adapter); |
| 7002 | if (!hal_handle) { |
| 7003 | hdd_err("invalid HAL handle"); |
| 7004 | return INVALID_CHANNEL_ID; |
| 7005 | } |
| 7006 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7007 | status = policy_mgr_get_pcl_for_existing_conn(hdd_ctx->hdd_psoc, |
| 7008 | PM_SAP_MODE, pcl.pcl_list, &pcl.pcl_len, |
bings | 37bd58f | 2017-07-20 16:49:26 +0800 | [diff] [blame] | 7009 | pcl.weight_list, QDF_ARRAY_SIZE(pcl.weight_list), |
| 7010 | false); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7011 | if (QDF_IS_STATUS_ERROR(status)) { |
| 7012 | hdd_err("Get PCL failed"); |
| 7013 | return INVALID_CHANNEL_ID; |
| 7014 | } |
| 7015 | |
Frank Liu | dc2cefb | 2017-06-21 15:38:18 +0800 | [diff] [blame] | 7016 | /* |
| 7017 | * In some scenarios, like hw dbs disabled, sap+sap case, if operating |
| 7018 | * channel is unsafe channel, the pcl may be empty, instead of return, |
| 7019 | * try to choose a safe channel from acs range. |
| 7020 | */ |
| 7021 | if (!pcl.pcl_len) |
| 7022 | hdd_debug("pcl length is zero!"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7023 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7024 | hdd_debug("start:%d end:%d", |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7025 | adapter->sessionCtx.ap.sapConfig.acs_cfg.start_ch, |
| 7026 | adapter->sessionCtx.ap.sapConfig.acs_cfg.end_ch); |
| 7027 | |
| 7028 | /* PCL already takes unsafe channel into account */ |
| 7029 | for (i = 0; i < pcl.pcl_len; i++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7030 | hdd_debug("chan[%d]:%d", i, pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7031 | if ((pcl.pcl_list[i] >= |
| 7032 | adapter->sessionCtx.ap.sapConfig.acs_cfg.start_ch) && |
| 7033 | (pcl.pcl_list[i] <= |
| 7034 | adapter->sessionCtx.ap.sapConfig.acs_cfg.end_ch)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7035 | hdd_debug("found PCL safe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7036 | return pcl.pcl_list[i]; |
| 7037 | } |
| 7038 | } |
| 7039 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7040 | hdd_debug("no safe channel from PCL found in ACS range"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7041 | |
| 7042 | /* Try for safe channel from all valid channel */ |
| 7043 | pcl.pcl_len = MAX_NUM_CHAN; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7044 | status = sme_get_cfg_valid_channels(pcl.pcl_list, |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7045 | &pcl.pcl_len); |
| 7046 | if (QDF_IS_STATUS_ERROR(status)) { |
| 7047 | hdd_err("error in getting valid channel list"); |
| 7048 | return INVALID_CHANNEL_ID; |
| 7049 | } |
| 7050 | |
| 7051 | for (i = 0; i < pcl.pcl_len; i++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7052 | hdd_debug("chan[%d]:%d", i, pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7053 | found = false; |
| 7054 | for (j = 0; j < hdd_ctx->unsafe_channel_count; j++) { |
Krunal Soni | 15f0db1 | 2016-10-11 18:53:37 -0700 | [diff] [blame] | 7055 | if (pcl.pcl_list[i] == |
| 7056 | hdd_ctx->unsafe_channel_list[j]) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7057 | hdd_debug("unsafe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7058 | found = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7059 | break; |
| 7060 | } |
| 7061 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7062 | |
| 7063 | if (found) |
| 7064 | continue; |
| 7065 | |
| 7066 | if ((pcl.pcl_list[i] >= |
| 7067 | adapter->sessionCtx.ap.sapConfig.acs_cfg.start_ch) && |
| 7068 | (pcl.pcl_list[i] <= |
| 7069 | adapter->sessionCtx.ap.sapConfig.acs_cfg.end_ch)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7070 | hdd_debug("found safe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7071 | return pcl.pcl_list[i]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7072 | } |
| 7073 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7074 | |
| 7075 | return INVALID_CHANNEL_ID; |
| 7076 | } |
| 7077 | |
| 7078 | /** |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 7079 | * hdd_switch_sap_channel() - Move SAP to the given channel |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7080 | * @adapter: AP adapter |
| 7081 | * @channel: Channel |
| 7082 | * |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 7083 | * Moves the SAP interface by invoking the function which |
| 7084 | * executes the callback to perform channel switch using (E)CSA. |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7085 | * |
| 7086 | * Return: None |
| 7087 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7088 | void hdd_switch_sap_channel(struct hdd_adapter *adapter, uint8_t channel) |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7089 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 7090 | struct hdd_ap_ctx *hdd_ap_ctx; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7091 | tHalHandle *hal_handle; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7092 | struct hdd_context *hdd_ctx; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7093 | |
| 7094 | if (!adapter) { |
| 7095 | hdd_err("invalid adapter"); |
| 7096 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7097 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7098 | |
| 7099 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 7100 | |
| 7101 | hal_handle = WLAN_HDD_GET_HAL_CTX(adapter); |
| 7102 | if (!hal_handle) { |
| 7103 | hdd_err("invalid HAL handle"); |
| 7104 | return; |
| 7105 | } |
| 7106 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7107 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 7108 | |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7109 | hdd_ap_ctx->sapConfig.channel = channel; |
| 7110 | hdd_ap_ctx->sapConfig.ch_params.ch_width = |
| 7111 | hdd_ap_ctx->sapConfig.ch_width_orig; |
| 7112 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7113 | hdd_debug("chan:%d width:%d", |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7114 | channel, hdd_ap_ctx->sapConfig.ch_width_orig); |
| 7115 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 7116 | wlan_reg_set_channel_params(hdd_ctx->hdd_pdev, |
| 7117 | hdd_ap_ctx->sapConfig.channel, |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7118 | hdd_ap_ctx->sapConfig.sec_ch, |
| 7119 | &hdd_ap_ctx->sapConfig.ch_params); |
| 7120 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7121 | policy_mgr_change_sap_channel_with_csa(hdd_ctx->hdd_psoc, |
| 7122 | adapter->sessionId, channel, |
| 7123 | hdd_ap_ctx->sapConfig.ch_width_orig); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7124 | } |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7125 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7126 | int hdd_update_acs_timer_reason(struct hdd_adapter *adapter, uint8_t reason) |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7127 | { |
| 7128 | struct hdd_external_acs_timer_context *timer_context; |
| 7129 | |
| 7130 | set_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
| 7131 | |
| 7132 | if (QDF_TIMER_STATE_RUNNING == |
| 7133 | qdf_mc_timer_get_current_state(&adapter->sessionCtx. |
| 7134 | ap.vendor_acs_timer)) { |
| 7135 | qdf_mc_timer_stop(&adapter->sessionCtx.ap.vendor_acs_timer); |
| 7136 | } |
| 7137 | timer_context = (struct hdd_external_acs_timer_context *) |
| 7138 | adapter->sessionCtx.ap.vendor_acs_timer.user_data; |
| 7139 | timer_context->reason = reason; |
Nachiket Kukade | a485569 | 2017-08-21 21:19:09 +0530 | [diff] [blame] | 7140 | /* Update config to application and start the timer */ |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7141 | hdd_cfg80211_update_acs_config(adapter, reason); |
Nachiket Kukade | a485569 | 2017-08-21 21:19:09 +0530 | [diff] [blame] | 7142 | qdf_mc_timer_start(&adapter->sessionCtx.ap.vendor_acs_timer, |
| 7143 | WLAN_VENDOR_ACS_WAIT_TIME); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7144 | hdd_notice("Updated ACS config to nl with reason %d", reason); |
| 7145 | |
| 7146 | return 0; |
| 7147 | } |
| 7148 | |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7149 | /** |
| 7150 | * hdd_unsafe_channel_restart_sap() - restart sap if sap is on unsafe channel |
| 7151 | * @hdd_ctx: hdd context pointer |
| 7152 | * |
| 7153 | * hdd_unsafe_channel_restart_sap check all unsafe channel list |
| 7154 | * and if ACS is enabled, driver will ask userspace to restart the |
| 7155 | * sap. User space on LTE coex indication restart driver. |
| 7156 | * |
| 7157 | * Return - none |
| 7158 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7159 | void hdd_unsafe_channel_restart_sap(struct hdd_context *hdd_ctxt) |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7160 | { |
| 7161 | QDF_STATUS status; |
| 7162 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7163 | struct hdd_adapter *adapter_temp; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7164 | uint32_t i; |
| 7165 | bool found = false; |
| 7166 | uint8_t restart_chan; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7167 | |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7168 | status = hdd_get_front_adapter(hdd_ctxt, &adapter_node); |
| 7169 | while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) { |
| 7170 | adapter_temp = adapter_node->pAdapter; |
| 7171 | |
| 7172 | if (!adapter_temp) { |
| 7173 | hdd_err("adapter is NULL, moving to next one"); |
| 7174 | goto next_adapater; |
| 7175 | } |
| 7176 | |
| 7177 | if (!((adapter_temp->device_mode == QDF_SAP_MODE) && |
| 7178 | (adapter_temp->sessionCtx.ap.sapConfig.acs_cfg.acs_mode))) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7179 | hdd_debug("skip device mode:%d acs:%d", |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7180 | adapter_temp->device_mode, |
| 7181 | adapter_temp->sessionCtx.ap.sapConfig. |
| 7182 | acs_cfg.acs_mode); |
| 7183 | goto next_adapater; |
| 7184 | } |
| 7185 | |
| 7186 | found = false; |
| 7187 | for (i = 0; i < hdd_ctxt->unsafe_channel_count; i++) { |
Krunal Soni | 15f0db1 | 2016-10-11 18:53:37 -0700 | [diff] [blame] | 7188 | if (adapter_temp->sessionCtx.ap.operatingChannel == |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7189 | hdd_ctxt->unsafe_channel_list[i]) { |
| 7190 | found = true; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7191 | hdd_debug("operating ch:%d is unsafe", |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7192 | adapter_temp->sessionCtx.ap.operatingChannel); |
| 7193 | break; |
| 7194 | } |
| 7195 | } |
| 7196 | |
| 7197 | if (!found) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7198 | hdd_debug("ch:%d is safe. no need to change channel", |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7199 | adapter_temp->sessionCtx.ap.operatingChannel); |
| 7200 | goto next_adapater; |
| 7201 | } |
| 7202 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7203 | if (hdd_ctxt->config->vendor_acs_support && |
| 7204 | hdd_ctxt->config->acs_support_for_dfs_ltecoex) { |
| 7205 | hdd_update_acs_timer_reason(adapter_temp, |
| 7206 | QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX); |
| 7207 | goto next_adapater; |
| 7208 | } else |
| 7209 | restart_chan = |
| 7210 | hdd_get_safe_channel_from_pcl_and_acs_range( |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7211 | adapter_temp); |
| 7212 | if (!restart_chan) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7213 | hdd_err("fail to restart SAP"); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7214 | } else { |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 7215 | /* |
| 7216 | * SAP restart due to unsafe channel. While |
| 7217 | * restarting the SAP, make sure to clear |
| 7218 | * acs_channel, channel to reset to |
| 7219 | * 0. Otherwise these settings will override |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 7220 | * the ACS while restart. |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 7221 | */ |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 7222 | hdd_ctxt->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
| 7223 | adapter_temp->sessionCtx.ap.sapConfig.channel = |
| 7224 | AUTO_CHANNEL_SELECT; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7225 | hdd_debug("sending coex indication"); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7226 | wlan_hdd_send_svc_nlink_msg(hdd_ctxt->radio_index, |
| 7227 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
Liangwei Dong | 6663d16 | 2017-07-10 03:29:36 -0400 | [diff] [blame] | 7228 | hdd_debug("driver to start sap: %d", |
| 7229 | hdd_ctxt->config->sap_internal_restart); |
| 7230 | if (hdd_ctxt->config->sap_internal_restart) |
| 7231 | hdd_switch_sap_channel(adapter_temp, restart_chan); |
| 7232 | else |
| 7233 | return; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7234 | } |
| 7235 | |
| 7236 | next_adapater: |
| 7237 | status = hdd_get_next_adapter(hdd_ctxt, adapter_node, &next); |
| 7238 | adapter_node = next; |
| 7239 | } |
| 7240 | } |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 7241 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7242 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7243 | * hdd_init_channel_avoidance() - Initialize channel avoidance |
| 7244 | * @hdd_ctx: HDD global context |
| 7245 | * |
| 7246 | * Initialize the channel avoidance logic by retrieving the unsafe |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7247 | * channel list from the platform driver and plumbing the data |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7248 | * down to the lower layers. Then subscribe to subsequent channel |
| 7249 | * avoidance events. |
| 7250 | * |
| 7251 | * Return: None |
| 7252 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7253 | static void hdd_init_channel_avoidance(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7254 | { |
| 7255 | uint16_t unsafe_channel_count; |
| 7256 | int index; |
| 7257 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7258 | pld_get_wlan_unsafe_channel(hdd_ctx->parent_dev, |
| 7259 | hdd_ctx->unsafe_channel_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7260 | &(hdd_ctx->unsafe_channel_count), |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 7261 | sizeof(uint16_t) * NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7262 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7263 | hdd_debug("num of unsafe channels is %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7264 | hdd_ctx->unsafe_channel_count); |
| 7265 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 7266 | unsafe_channel_count = QDF_MIN((uint16_t)hdd_ctx->unsafe_channel_count, |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 7267 | (uint16_t)NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7268 | |
| 7269 | for (index = 0; index < unsafe_channel_count; index++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7270 | hdd_debug("channel %d is not safe", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7271 | hdd_ctx->unsafe_channel_list[index]); |
| 7272 | |
| 7273 | } |
| 7274 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7275 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 7276 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7277 | static void hdd_lte_coex_restart_sap(struct hdd_adapter *adapter, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7278 | struct hdd_context *hdd_ctx) |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 7279 | { |
| 7280 | uint8_t restart_chan; |
| 7281 | |
| 7282 | restart_chan = hdd_get_safe_channel_from_pcl_and_acs_range(adapter); |
| 7283 | if (!restart_chan) { |
| 7284 | hdd_alert("fail to restart SAP"); |
| 7285 | return; |
| 7286 | } |
| 7287 | |
| 7288 | /* SAP restart due to unsafe channel. While restarting |
| 7289 | * the SAP, make sure to clear acs_channel, channel to |
| 7290 | * reset to 0. Otherwise these settings will override |
| 7291 | * the ACS while restart. |
| 7292 | */ |
| 7293 | hdd_ctx->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
| 7294 | adapter->sessionCtx.ap.sapConfig.channel = AUTO_CHANNEL_SELECT; |
| 7295 | |
| 7296 | hdd_debug("sending coex indication"); |
| 7297 | |
| 7298 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 7299 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
| 7300 | hdd_switch_sap_channel(adapter, restart_chan); |
| 7301 | } |
Liangwei Dong | 6e1a209 | 2017-08-30 16:29:06 +0800 | [diff] [blame] | 7302 | |
| 7303 | int hdd_clone_local_unsafe_chan(struct hdd_context *hdd_ctx, |
| 7304 | uint16_t **local_unsafe_list, uint16_t *local_unsafe_list_count) |
| 7305 | { |
| 7306 | uint32_t size; |
| 7307 | uint16_t *unsafe_list; |
| 7308 | uint16_t chan_count; |
| 7309 | |
| 7310 | if (!hdd_ctx || !local_unsafe_list_count || !local_unsafe_list_count) |
| 7311 | return -EINVAL; |
| 7312 | |
| 7313 | chan_count = QDF_MIN(hdd_ctx->unsafe_channel_count, |
| 7314 | NUM_CHANNELS); |
| 7315 | if (chan_count) { |
| 7316 | size = chan_count * sizeof(hdd_ctx->unsafe_channel_list[0]); |
| 7317 | unsafe_list = qdf_mem_malloc(size); |
| 7318 | if (!unsafe_list) { |
| 7319 | hdd_err("No memory for unsafe chan list size%d", |
| 7320 | size); |
| 7321 | return -ENOMEM; |
| 7322 | } |
| 7323 | qdf_mem_copy(unsafe_list, hdd_ctx->unsafe_channel_list, size); |
| 7324 | } else { |
| 7325 | unsafe_list = NULL; |
| 7326 | } |
| 7327 | |
| 7328 | *local_unsafe_list = unsafe_list; |
| 7329 | *local_unsafe_list_count = chan_count; |
| 7330 | |
| 7331 | return 0; |
| 7332 | } |
| 7333 | |
| 7334 | bool hdd_local_unsafe_channel_updated(struct hdd_context *hdd_ctx, |
| 7335 | uint16_t *local_unsafe_list, uint16_t local_unsafe_list_count) |
| 7336 | { |
| 7337 | int i, j; |
| 7338 | |
| 7339 | if (local_unsafe_list_count != hdd_ctx->unsafe_channel_count) |
| 7340 | return true; |
| 7341 | if (local_unsafe_list_count == 0) |
| 7342 | return false; |
| 7343 | for (i = 0; i < local_unsafe_list_count; i++) { |
| 7344 | for (j = 0; j < local_unsafe_list_count; j++) |
| 7345 | if (local_unsafe_list[i] == |
| 7346 | hdd_ctx->unsafe_channel_list[j]) |
| 7347 | break; |
| 7348 | if (j >= local_unsafe_list_count) |
| 7349 | break; |
| 7350 | } |
| 7351 | if (i >= local_unsafe_list_count) { |
| 7352 | hdd_info("unsafe chan list same"); |
| 7353 | return false; |
| 7354 | } |
| 7355 | |
| 7356 | return true; |
| 7357 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7358 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7359 | static void hdd_init_channel_avoidance(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7360 | { |
| 7361 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 7362 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7363 | static void hdd_set_thermal_level_cb(void *context, u_int8_t level) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7364 | { |
| 7365 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 7366 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7367 | static inline void hdd_lte_coex_restart_sap(struct hdd_adapter *adapter, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7368 | struct hdd_context *hdd_ctx) |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 7369 | { |
| 7370 | hdd_debug("Channel avoidance is not enabled; Abort SAP restart"); |
| 7371 | } |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7372 | #endif /* defined(FEATURE_WLAN_CH_AVOID) */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7373 | |
| 7374 | /** |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 7375 | * hdd_indicate_mgmt_frame() - Wrapper to indicate management frame to |
| 7376 | * user space |
| 7377 | * @frame_ind: Management frame data to be informed. |
| 7378 | * |
| 7379 | * This function is used to indicate management frame to |
| 7380 | * user space |
| 7381 | * |
| 7382 | * Return: None |
| 7383 | * |
| 7384 | */ |
| 7385 | void hdd_indicate_mgmt_frame(tSirSmeMgmtFrameInd *frame_ind) |
| 7386 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7387 | struct hdd_context *hdd_ctx = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7388 | struct hdd_adapter *adapter = NULL; |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 7389 | int i; |
| 7390 | |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 7391 | /* Get the HDD context.*/ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7392 | hdd_ctx = (struct hdd_context *)cds_get_context(QDF_MODULE_ID_HDD); |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 7393 | |
| 7394 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
| 7395 | return; |
| 7396 | |
| 7397 | if (SME_SESSION_ID_ANY == frame_ind->sessionId) { |
| 7398 | for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) { |
| 7399 | adapter = |
| 7400 | hdd_get_adapter_by_sme_session_id(hdd_ctx, i); |
| 7401 | if (adapter) |
| 7402 | break; |
| 7403 | } |
| 7404 | } else { |
| 7405 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, |
| 7406 | frame_ind->sessionId); |
| 7407 | } |
| 7408 | |
| 7409 | if ((NULL != adapter) && |
| 7410 | (WLAN_HDD_ADAPTER_MAGIC == adapter->magic)) |
| 7411 | __hdd_indicate_mgmt_frame(adapter, |
| 7412 | frame_ind->frame_len, |
| 7413 | frame_ind->frameBuf, |
| 7414 | frame_ind->frameType, |
| 7415 | frame_ind->rxChan, |
| 7416 | frame_ind->rxRssi); |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 7417 | } |
| 7418 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7419 | void hdd_acs_response_timeout_handler(void *context) |
| 7420 | { |
| 7421 | struct hdd_external_acs_timer_context *timer_context = |
| 7422 | (struct hdd_external_acs_timer_context *)context; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7423 | struct hdd_adapter *adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7424 | struct hdd_context *hdd_ctx; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7425 | uint8_t reason; |
| 7426 | |
| 7427 | ENTER(); |
| 7428 | if (!timer_context) { |
| 7429 | hdd_err("invlaid timer context"); |
| 7430 | return; |
| 7431 | } |
| 7432 | adapter = timer_context->adapter; |
| 7433 | reason = timer_context->reason; |
| 7434 | |
| 7435 | |
| 7436 | if ((!adapter) || |
| 7437 | (adapter->magic != WLAN_HDD_ADAPTER_MAGIC)) { |
| 7438 | hdd_err("invalid adapter or adapter has invalid magic"); |
| 7439 | return; |
| 7440 | } |
| 7441 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 7442 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 7443 | return; |
| 7444 | |
| 7445 | if (test_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags)) |
| 7446 | clear_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
| 7447 | else |
| 7448 | return; |
| 7449 | |
| 7450 | hdd_err("ACS timeout happened for %s reason %d", |
| 7451 | adapter->dev->name, reason); |
| 7452 | switch (reason) { |
| 7453 | /* SAP init case */ |
| 7454 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_INIT: |
| 7455 | wlan_sap_set_vendor_acs(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 7456 | false); |
| 7457 | wlan_hdd_cfg80211_start_acs(adapter); |
| 7458 | break; |
| 7459 | /* DFS detected on current channel */ |
| 7460 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_DFS: |
| 7461 | wlan_sap_update_next_channel( |
| 7462 | WLAN_HDD_GET_SAP_CTX_PTR(adapter), 0, 0); |
| 7463 | sme_update_new_channel_event(WLAN_HDD_GET_HAL_CTX(adapter), |
| 7464 | adapter->sessionId); |
| 7465 | break; |
| 7466 | /* LTE coex event on current channel */ |
| 7467 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX: |
| 7468 | hdd_lte_coex_restart_sap(adapter, hdd_ctx); |
| 7469 | break; |
| 7470 | default: |
| 7471 | hdd_info("invalid reason for timer invoke"); |
| 7472 | |
| 7473 | } |
| 7474 | } |
| 7475 | |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 7476 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7477 | * wlan_hdd_disable_all_dual_mac_features() - Disable dual mac features |
| 7478 | * @hdd_ctx: HDD context |
| 7479 | * |
| 7480 | * Disables all the dual mac features like DBS, Agile DFS etc. |
| 7481 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7482 | * Return: QDF_STATUS_SUCCESS on success |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7483 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7484 | static QDF_STATUS wlan_hdd_disable_all_dual_mac_features(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7485 | { |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7486 | struct policy_mgr_dual_mac_config cfg = {0}; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7487 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7488 | |
| 7489 | if (!hdd_ctx) { |
| 7490 | hdd_err("HDD context is NULL"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7491 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7492 | } |
| 7493 | |
| 7494 | cfg.scan_config = 0; |
| 7495 | cfg.fw_mode_config = 0; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7496 | cfg.set_dual_mac_cb = policy_mgr_soc_set_dual_mac_cfg_cb; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7497 | |
| 7498 | hdd_debug("Disabling all dual mac features..."); |
| 7499 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7500 | status = sme_soc_set_dual_mac_config(cfg); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7501 | if (status != QDF_STATUS_SUCCESS) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7502 | hdd_err("sme_soc_set_dual_mac_config failed %d", status); |
| 7503 | return status; |
| 7504 | } |
| 7505 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7506 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7507 | } |
| 7508 | |
Tushnim Bhattacharyya | 49ed8ab | 2017-05-26 18:20:10 -0700 | [diff] [blame] | 7509 | static QDF_STATUS |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7510 | wlan_hdd_update_dbs_scan_and_fw_mode_config(struct hdd_context *hdd_ctx) |
Tushnim Bhattacharyya | 49ed8ab | 2017-05-26 18:20:10 -0700 | [diff] [blame] | 7511 | { |
| 7512 | struct policy_mgr_dual_mac_config cfg = {0}; |
| 7513 | QDF_STATUS status; |
| 7514 | |
| 7515 | if (!hdd_ctx) { |
| 7516 | hdd_err("HDD context is NULL"); |
| 7517 | return QDF_STATUS_E_FAILURE; |
| 7518 | } |
| 7519 | |
| 7520 | cfg.scan_config = 0; |
| 7521 | cfg.fw_mode_config = 0; |
| 7522 | cfg.set_dual_mac_cb = policy_mgr_soc_set_dual_mac_cfg_cb; |
| 7523 | status = policy_mgr_get_updated_scan_and_fw_mode_config( |
| 7524 | hdd_ctx->hdd_psoc, &cfg.scan_config, |
| 7525 | &cfg.fw_mode_config, |
| 7526 | hdd_ctx->config->dual_mac_feature_disable); |
| 7527 | |
| 7528 | if (status != QDF_STATUS_SUCCESS) { |
| 7529 | hdd_err("wma_get_updated_scan_and_fw_mode_config failed %d", |
| 7530 | status); |
| 7531 | return status; |
| 7532 | } |
| 7533 | |
| 7534 | hdd_debug("send scan_cfg: 0x%x fw_mode_cfg: 0x%x to fw", |
| 7535 | cfg.scan_config, cfg.fw_mode_config); |
| 7536 | |
| 7537 | status = sme_soc_set_dual_mac_config(cfg); |
| 7538 | if (status != QDF_STATUS_SUCCESS) { |
| 7539 | hdd_err("sme_soc_set_dual_mac_config failed %d", status); |
| 7540 | return status; |
| 7541 | } |
| 7542 | |
| 7543 | return QDF_STATUS_SUCCESS; |
| 7544 | } |
| 7545 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7546 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7547 | * hdd_override_ini_config - Override INI config |
| 7548 | * @hdd_ctx: HDD context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7549 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7550 | * Override INI config based on module parameter. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7551 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7552 | * Return: None |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7553 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7554 | static void hdd_override_ini_config(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7555 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7556 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7557 | if (0 == enable_dfs_chan_scan || 1 == enable_dfs_chan_scan) { |
| 7558 | hdd_ctx->config->enableDFSChnlScan = enable_dfs_chan_scan; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7559 | hdd_debug("Module enable_dfs_chan_scan set to %d", |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7560 | enable_dfs_chan_scan); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7561 | } |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7562 | if (0 == enable_11d || 1 == enable_11d) { |
| 7563 | hdd_ctx->config->Is11dSupportEnabled = enable_11d; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7564 | hdd_debug("Module enable_11d set to %d", enable_11d); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7565 | } |
Leo Chang | 11545d6 | 2016-10-17 14:53:50 -0700 | [diff] [blame] | 7566 | |
| 7567 | if (!hdd_ipa_is_present(hdd_ctx)) |
| 7568 | hdd_ctx->config->IpaConfig = 0; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7569 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7570 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7571 | /** |
| 7572 | * hdd_set_trace_level_for_each - Set trace level for each INI config |
| 7573 | * @hdd_ctx - HDD context |
| 7574 | * |
| 7575 | * Set trace level for each module based on INI config. |
| 7576 | * |
| 7577 | * Return: None |
| 7578 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7579 | static void hdd_set_trace_level_for_each(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7580 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 7581 | hdd_qdf_trace_enable(QDF_MODULE_ID_WMI, |
| 7582 | hdd_ctx->config->qdf_trace_enable_wdi); |
| 7583 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD, |
| 7584 | hdd_ctx->config->qdf_trace_enable_hdd); |
| 7585 | hdd_qdf_trace_enable(QDF_MODULE_ID_SME, |
| 7586 | hdd_ctx->config->qdf_trace_enable_sme); |
| 7587 | hdd_qdf_trace_enable(QDF_MODULE_ID_PE, |
| 7588 | hdd_ctx->config->qdf_trace_enable_pe); |
| 7589 | hdd_qdf_trace_enable(QDF_MODULE_ID_WMA, |
| 7590 | hdd_ctx->config->qdf_trace_enable_wma); |
| 7591 | hdd_qdf_trace_enable(QDF_MODULE_ID_SYS, |
| 7592 | hdd_ctx->config->qdf_trace_enable_sys); |
| 7593 | hdd_qdf_trace_enable(QDF_MODULE_ID_QDF, |
| 7594 | hdd_ctx->config->qdf_trace_enable_qdf); |
| 7595 | hdd_qdf_trace_enable(QDF_MODULE_ID_SAP, |
| 7596 | hdd_ctx->config->qdf_trace_enable_sap); |
| 7597 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_SOFTAP, |
| 7598 | hdd_ctx->config->qdf_trace_enable_hdd_sap); |
| 7599 | hdd_qdf_trace_enable(QDF_MODULE_ID_BMI, |
| 7600 | hdd_ctx->config->qdf_trace_enable_bmi); |
| 7601 | hdd_qdf_trace_enable(QDF_MODULE_ID_CFG, |
| 7602 | hdd_ctx->config->qdf_trace_enable_cfg); |
| 7603 | hdd_qdf_trace_enable(QDF_MODULE_ID_EPPING, |
| 7604 | hdd_ctx->config->qdf_trace_enable_epping); |
| 7605 | hdd_qdf_trace_enable(QDF_MODULE_ID_QDF_DEVICE, |
| 7606 | hdd_ctx->config->qdf_trace_enable_qdf_devices); |
| 7607 | hdd_qdf_trace_enable(QDF_MODULE_ID_TXRX, |
Houston Hoffman | fbf0510 | 2017-08-28 11:37:01 -0700 | [diff] [blame] | 7608 | hdd_ctx->config->qdf_trace_enable_txrx); |
| 7609 | hdd_qdf_trace_enable(QDF_MODULE_ID_DP, |
| 7610 | hdd_ctx->config->qdf_trace_enable_dp); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 7611 | hdd_qdf_trace_enable(QDF_MODULE_ID_HTC, |
| 7612 | hdd_ctx->config->qdf_trace_enable_htc); |
| 7613 | hdd_qdf_trace_enable(QDF_MODULE_ID_HIF, |
| 7614 | hdd_ctx->config->qdf_trace_enable_hif); |
| 7615 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_SAP_DATA, |
| 7616 | hdd_ctx->config->qdf_trace_enable_hdd_sap_data); |
| 7617 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_DATA, |
| 7618 | hdd_ctx->config->qdf_trace_enable_hdd_data); |
Naveen Rawat | 7df3186 | 2017-03-01 17:09:30 -0800 | [diff] [blame] | 7619 | hdd_qdf_trace_enable(QDF_MODULE_ID_WIFIPOS, |
| 7620 | hdd_ctx->config->qdf_trace_enable_wifi_pos); |
Naveen Rawat | f2b0dbd | 2017-03-27 10:00:15 -0700 | [diff] [blame] | 7621 | hdd_qdf_trace_enable(QDF_MODULE_ID_NAN, |
| 7622 | hdd_ctx->config->qdf_trace_enable_nan); |
Kiran Kumar Lokere | 798de7e | 2017-03-30 14:01:12 -0700 | [diff] [blame] | 7623 | hdd_qdf_trace_enable(QDF_MODULE_ID_REGULATORY, |
| 7624 | hdd_ctx->config->qdf_trace_enable_regulatory); |
| 7625 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7626 | hdd_cfg_print(hdd_ctx); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7627 | } |
| 7628 | |
| 7629 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7630 | * hdd_context_init() - Initialize HDD context |
| 7631 | * @hdd_ctx: HDD context. |
| 7632 | * |
| 7633 | * Initialize HDD context along with all the feature specific contexts. |
| 7634 | * |
| 7635 | * return: 0 on success and errno on failure. |
| 7636 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7637 | static int hdd_context_init(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7638 | { |
| 7639 | int ret; |
| 7640 | |
| 7641 | hdd_ctx->ioctl_scan_mode = eSIR_ACTIVE_SCAN; |
| 7642 | hdd_ctx->max_intf_count = CSR_ROAM_SESSION_MAX; |
| 7643 | |
| 7644 | hdd_init_ll_stats_ctx(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 7645 | hdd_init_nud_stats_ctx(hdd_ctx); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7646 | |
| 7647 | init_completion(&hdd_ctx->mc_sus_event_var); |
| 7648 | init_completion(&hdd_ctx->ready_to_suspend); |
| 7649 | |
| 7650 | qdf_spinlock_create(&hdd_ctx->connection_status_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 7651 | qdf_spinlock_create(&hdd_ctx->sta_update_info_lock); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7652 | qdf_spinlock_create(&hdd_ctx->hdd_adapter_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 7653 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7654 | qdf_list_create(&hdd_ctx->hddAdapters, MAX_NUMBER_OF_ADAPTERS); |
| 7655 | |
| 7656 | init_completion(&hdd_ctx->set_antenna_mode_cmpl); |
| 7657 | |
| 7658 | ret = hdd_scan_context_init(hdd_ctx); |
| 7659 | if (ret) |
| 7660 | goto list_destroy; |
| 7661 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7662 | hdd_rx_wake_lock_create(hdd_ctx); |
| 7663 | |
| 7664 | ret = hdd_sap_context_init(hdd_ctx); |
| 7665 | if (ret) |
| 7666 | goto scan_destroy; |
| 7667 | |
| 7668 | ret = hdd_roc_context_init(hdd_ctx); |
| 7669 | if (ret) |
| 7670 | goto sap_destroy; |
| 7671 | |
| 7672 | wlan_hdd_cfg80211_extscan_init(hdd_ctx); |
| 7673 | |
| 7674 | hdd_init_offloaded_packets_ctx(hdd_ctx); |
| 7675 | |
| 7676 | ret = wlan_hdd_cfg80211_init(hdd_ctx->parent_dev, hdd_ctx->wiphy, |
| 7677 | hdd_ctx->config); |
| 7678 | if (ret) |
| 7679 | goto roc_destroy; |
| 7680 | |
| 7681 | return 0; |
| 7682 | |
| 7683 | roc_destroy: |
| 7684 | hdd_roc_context_destroy(hdd_ctx); |
| 7685 | |
| 7686 | sap_destroy: |
| 7687 | hdd_sap_context_destroy(hdd_ctx); |
| 7688 | |
| 7689 | scan_destroy: |
| 7690 | hdd_scan_context_destroy(hdd_ctx); |
| 7691 | hdd_rx_wake_lock_destroy(hdd_ctx); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7692 | list_destroy: |
| 7693 | qdf_list_destroy(&hdd_ctx->hddAdapters); |
Sandeep Puligilla | d000421 | 2017-02-26 18:34:56 -0800 | [diff] [blame] | 7694 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7695 | return ret; |
| 7696 | } |
| 7697 | |
| 7698 | /** |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 7699 | * ie_whitelist_attrs_init() - initialize ie whitelisting attributes |
| 7700 | * @hdd_ctx: pointer to hdd context |
| 7701 | * |
| 7702 | * Return: status of initialization |
| 7703 | * 0 - success |
| 7704 | * negative value - failure |
| 7705 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7706 | static int ie_whitelist_attrs_init(struct hdd_context *hdd_ctx) |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 7707 | { |
| 7708 | int ret; |
| 7709 | |
| 7710 | if (!hdd_ctx->config->probe_req_ie_whitelist) |
| 7711 | return 0; |
| 7712 | |
| 7713 | if (!hdd_validate_prb_req_ie_bitmap(hdd_ctx)) { |
| 7714 | hdd_err("invalid ie bitmap and ouis: disable ie whitelisting"); |
| 7715 | hdd_ctx->config->probe_req_ie_whitelist = false; |
| 7716 | return -EINVAL; |
| 7717 | } |
| 7718 | |
| 7719 | /* parse ini string probe req oui */ |
| 7720 | ret = hdd_parse_probe_req_ouis(hdd_ctx); |
| 7721 | if (ret) { |
| 7722 | hdd_err("parsing error: disable ie whitelisting"); |
| 7723 | hdd_ctx->config->probe_req_ie_whitelist = false; |
| 7724 | } |
| 7725 | |
| 7726 | return ret; |
| 7727 | } |
| 7728 | |
| 7729 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7730 | * hdd_context_create() - Allocate and inialize HDD context. |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7731 | * @dev: Device Pointer to the underlying device |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7732 | * |
| 7733 | * Allocate and initialize HDD context. HDD context is allocated as part of |
| 7734 | * wiphy allocation and then context is initialized. |
| 7735 | * |
| 7736 | * Return: HDD context on success and ERR_PTR on failure |
| 7737 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7738 | static struct hdd_context *hdd_context_create(struct device *dev) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7739 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7740 | QDF_STATUS status; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7741 | int ret = 0; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7742 | struct hdd_context *hdd_ctx; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7743 | |
| 7744 | ENTER(); |
| 7745 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7746 | hdd_ctx = hdd_cfg80211_wiphy_alloc(sizeof(struct hdd_context)); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7747 | if (hdd_ctx == NULL) { |
| 7748 | ret = -ENOMEM; |
| 7749 | goto err_out; |
| 7750 | } |
| 7751 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7752 | hdd_ctx->parent_dev = dev; |
Sreelakshmi Konamki | b53c629 | 2017-03-01 13:13:23 +0530 | [diff] [blame] | 7753 | hdd_ctx->last_scan_reject_session_id = 0xFF; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7754 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7755 | hdd_ctx->config = qdf_mem_malloc(sizeof(struct hdd_config)); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7756 | if (hdd_ctx->config == NULL) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7757 | hdd_err("Failed to alloc memory for HDD config!"); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7758 | ret = -ENOMEM; |
| 7759 | goto err_free_hdd_context; |
| 7760 | } |
| 7761 | |
| 7762 | /* Read and parse the qcom_cfg.ini file */ |
| 7763 | status = hdd_parse_config_ini(hdd_ctx); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7764 | if (QDF_STATUS_SUCCESS != status) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7765 | hdd_err("Error (status: %d) parsing INI file: %s", status, |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7766 | WLAN_INI_FILE); |
| 7767 | ret = -EINVAL; |
| 7768 | goto err_free_config; |
| 7769 | } |
| 7770 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 7771 | ie_whitelist_attrs_init(hdd_ctx); |
| 7772 | |
Dustin Brown | 7f93993 | 2017-05-18 15:02:17 -0700 | [diff] [blame] | 7773 | hdd_debug("setting timer multiplier: %u", |
| 7774 | hdd_ctx->config->timer_multiplier); |
| 7775 | qdf_timer_set_multiplier(hdd_ctx->config->timer_multiplier); |
| 7776 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7777 | |
Sravan Kumar Kairam | fece87f | 2016-07-26 14:58:28 +0530 | [diff] [blame] | 7778 | if (hdd_ctx->config->fhostNSOffload) |
| 7779 | hdd_ctx->ns_offload_enable = true; |
| 7780 | |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 7781 | cds_set_fatal_event(hdd_ctx->config->enable_fatal_event); |
| 7782 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7783 | hdd_override_ini_config(hdd_ctx); |
| 7784 | |
Jeff Johnson | 3543fb2 | 2017-09-24 13:44:13 -0700 | [diff] [blame] | 7785 | cds_set_context(QDF_MODULE_ID_HDD, hdd_ctx); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7786 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7787 | ret = hdd_context_init(hdd_ctx); |
| 7788 | |
| 7789 | if (ret) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7790 | goto err_free_config; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7791 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7792 | /* Uses to enabled logging after SSR */ |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 7793 | hdd_ctx->fw_log_settings.enable = hdd_ctx->config->enable_fw_log; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7794 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 7795 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7796 | goto skip_multicast_logging; |
| 7797 | |
| 7798 | cds_set_multicast_logging(hdd_ctx->config->multicast_host_fw_msgs); |
| 7799 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 7800 | ret = wlan_hdd_init_tx_rx_histogram(hdd_ctx); |
| 7801 | if (ret) |
| 7802 | goto err_deinit_hdd_context; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7803 | |
Houston Hoffman | b18dc6e | 2017-08-11 17:43:07 -0700 | [diff] [blame] | 7804 | ret = hdd_init_netlink_services(hdd_ctx); |
| 7805 | if (ret) |
| 7806 | goto err_deinit_txrx_histogram; |
| 7807 | |
Dustin Brown | 7b3dea2 | 2017-07-10 13:02:47 -0700 | [diff] [blame] | 7808 | wlan_logging_set_log_to_console(hdd_ctx->config->wlanLoggingToConsole); |
| 7809 | wlan_logging_set_active(hdd_ctx->config->wlanLoggingEnable); |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7810 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7811 | skip_multicast_logging: |
| 7812 | hdd_set_trace_level_for_each(hdd_ctx); |
| 7813 | |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 7814 | EXIT(); |
| 7815 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7816 | return hdd_ctx; |
| 7817 | |
Houston Hoffman | b18dc6e | 2017-08-11 17:43:07 -0700 | [diff] [blame] | 7818 | err_deinit_txrx_histogram: |
| 7819 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 7820 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 7821 | err_deinit_hdd_context: |
| 7822 | hdd_context_deinit(hdd_ctx); |
| 7823 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7824 | err_free_config: |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7825 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7826 | |
| 7827 | err_free_hdd_context: |
| 7828 | wiphy_free(hdd_ctx->wiphy); |
| 7829 | |
| 7830 | err_out: |
| 7831 | return ERR_PTR(ret); |
| 7832 | } |
| 7833 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7834 | #ifdef WLAN_OPEN_P2P_INTERFACE |
| 7835 | /** |
| 7836 | * hdd_open_p2p_interface - Open P2P interface |
| 7837 | * @hdd_ctx: HDD context |
| 7838 | * @rtnl_held: True if RTNL lock held |
| 7839 | * |
| 7840 | * Open P2P interface during probe. This function called to open the P2P |
| 7841 | * interface at probe along with STA interface. |
| 7842 | * |
| 7843 | * Return: 0 on success and errno on failure |
| 7844 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7845 | static int hdd_open_p2p_interface(struct hdd_context *hdd_ctx, bool rtnl_held) |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7846 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7847 | struct hdd_adapter *adapter; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7848 | uint8_t *p2p_dev_addr; |
| 7849 | |
| 7850 | if (hdd_ctx->config->isP2pDeviceAddrAdministrated && |
| 7851 | !(hdd_ctx->config->intfMacAddr[0].bytes[0] & 0x02)) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7852 | qdf_mem_copy(hdd_ctx->p2pDeviceAddress.bytes, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7853 | hdd_ctx->config->intfMacAddr[0].bytes, |
| 7854 | sizeof(tSirMacAddr)); |
| 7855 | |
| 7856 | /* |
| 7857 | * Generate the P2P Device Address. This consists of |
| 7858 | * the device's primary MAC address with the locally |
| 7859 | * administered bit set. |
| 7860 | */ |
| 7861 | hdd_ctx->p2pDeviceAddress.bytes[0] |= 0x02; |
| 7862 | } else { |
| 7863 | p2p_dev_addr = wlan_hdd_get_intf_addr(hdd_ctx); |
| 7864 | if (p2p_dev_addr == NULL) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7865 | hdd_err("Failed to allocate mac_address for p2p_device"); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7866 | return -ENOSPC; |
| 7867 | } |
| 7868 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7869 | qdf_mem_copy(&hdd_ctx->p2pDeviceAddress.bytes[0], p2p_dev_addr, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 7870 | QDF_MAC_ADDR_SIZE); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7871 | } |
| 7872 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 7873 | adapter = hdd_open_adapter(hdd_ctx, QDF_P2P_DEVICE_MODE, "p2p%d", |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7874 | &hdd_ctx->p2pDeviceAddress.bytes[0], |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 7875 | NET_NAME_UNKNOWN, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7876 | |
| 7877 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7878 | hdd_err("Failed to do hdd_open_adapter for P2P Device Interface"); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7879 | return -ENOSPC; |
| 7880 | } |
| 7881 | |
| 7882 | return 0; |
| 7883 | } |
| 7884 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7885 | static inline int hdd_open_p2p_interface(struct hdd_context *hdd_ctx, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7886 | bool rtnl_held) |
| 7887 | { |
| 7888 | return 0; |
| 7889 | } |
| 7890 | #endif |
| 7891 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7892 | static int hdd_open_ocb_interface(struct hdd_context *hdd_ctx, bool rtnl_held) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 7893 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7894 | struct hdd_adapter *adapter; |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 7895 | int ret = 0; |
| 7896 | |
| 7897 | adapter = hdd_open_adapter(hdd_ctx, QDF_OCB_MODE, "wlanocb%d", |
| 7898 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 7899 | NET_NAME_UNKNOWN, rtnl_held); |
| 7900 | if (adapter == NULL) { |
| 7901 | hdd_err("Failed to open 802.11p interface"); |
| 7902 | ret = -ENOSPC; |
| 7903 | } |
| 7904 | |
| 7905 | return ret; |
| 7906 | } |
| 7907 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7908 | /** |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 7909 | * hdd_start_station_adapter()- Start the Station Adapter |
| 7910 | * @adapter: HDD adapter |
| 7911 | * |
| 7912 | * This function initializes the adapter for the station mode. |
| 7913 | * |
| 7914 | * Return: 0 on success or errno on failure. |
| 7915 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7916 | int hdd_start_station_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 7917 | { |
| 7918 | QDF_STATUS status; |
| 7919 | |
| 7920 | ENTER_DEV(adapter->dev); |
| 7921 | |
| 7922 | status = hdd_init_station_mode(adapter); |
| 7923 | |
| 7924 | if (QDF_STATUS_SUCCESS != status) { |
| 7925 | hdd_err("Error Initializing station mode: %d", status); |
| 7926 | return qdf_status_to_os_return(status); |
| 7927 | } |
| 7928 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7929 | hdd_register_tx_flow_control(adapter, |
| 7930 | hdd_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 7931 | hdd_tx_resume_cb, |
| 7932 | hdd_tx_flow_control_is_pause); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7933 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 7934 | EXIT(); |
| 7935 | return 0; |
| 7936 | } |
| 7937 | |
| 7938 | /** |
| 7939 | * hdd_start_ap_adapter()- Start AP Adapter |
| 7940 | * @adapter: HDD adapter |
| 7941 | * |
| 7942 | * This function initializes the adapter for the AP mode. |
| 7943 | * |
| 7944 | * Return: 0 on success errno on failure. |
| 7945 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7946 | int hdd_start_ap_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 7947 | { |
| 7948 | QDF_STATUS status; |
| 7949 | |
| 7950 | ENTER(); |
| 7951 | |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 7952 | status = hdd_init_ap_mode(adapter, false); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 7953 | |
| 7954 | if (QDF_STATUS_SUCCESS != status) { |
| 7955 | hdd_err("Error Initializing the AP mode: %d", status); |
| 7956 | return qdf_status_to_os_return(status); |
| 7957 | } |
| 7958 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7959 | hdd_register_tx_flow_control(adapter, |
| 7960 | hdd_softap_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 7961 | hdd_softap_tx_resume_cb, |
| 7962 | hdd_tx_flow_control_is_pause); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7963 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 7964 | EXIT(); |
| 7965 | return 0; |
| 7966 | } |
| 7967 | |
| 7968 | /** |
| 7969 | * hdd_start_ftm_adapter()- Start FTM adapter |
| 7970 | * @adapter: HDD adapter |
| 7971 | * |
| 7972 | * This function initializes the adapter for the FTM mode. |
| 7973 | * |
| 7974 | * Return: 0 on success or errno on failure. |
| 7975 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7976 | int hdd_start_ftm_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 7977 | { |
| 7978 | QDF_STATUS qdf_status; |
| 7979 | |
| 7980 | ENTER_DEV(adapter->dev); |
| 7981 | |
| 7982 | qdf_status = hdd_init_tx_rx(adapter); |
| 7983 | |
| 7984 | if (QDF_STATUS_SUCCESS != qdf_status) { |
| 7985 | hdd_err("Failed to start FTM adapter: %d", qdf_status); |
| 7986 | return qdf_status_to_os_return(qdf_status); |
| 7987 | } |
| 7988 | |
| 7989 | return 0; |
| 7990 | EXIT(); |
| 7991 | } |
| 7992 | |
| 7993 | /** |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 7994 | * hdd_open_interfaces - Open all required interfaces |
| 7995 | * hdd_ctx: HDD context |
| 7996 | * rtnl_held: True if RTNL lock is held |
| 7997 | * |
| 7998 | * Open all the interfaces like STA, P2P and OCB based on the configuration. |
| 7999 | * |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8000 | * Return: 0 if all interfaces were created, otherwise negative errno |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8001 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8002 | static int hdd_open_interfaces(struct hdd_context *hdd_ctx, bool rtnl_held) |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8003 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8004 | struct hdd_adapter *adapter; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8005 | int ret; |
| 8006 | |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 8007 | /* open monitor mode adapter if con_mode is monitor mode */ |
| 8008 | if (con_mode == QDF_GLOBAL_MONITOR_MODE) { |
| 8009 | adapter = hdd_open_adapter(hdd_ctx, QDF_MONITOR_MODE, "wlan%d", |
| 8010 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 8011 | NET_NAME_UNKNOWN, rtnl_held); |
| 8012 | if (!adapter) { |
| 8013 | hdd_err("open adapter failed"); |
| 8014 | return -ENOSPC; |
| 8015 | } |
| 8016 | return 0; |
| 8017 | } |
| 8018 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8019 | if (hdd_ctx->config->dot11p_mode == WLAN_HDD_11P_STANDALONE) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8020 | /* Create only 802.11p interface */ |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8021 | return hdd_open_ocb_interface(hdd_ctx, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8022 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 8023 | adapter = hdd_open_adapter(hdd_ctx, QDF_STA_MODE, "wlan%d", |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8024 | wlan_hdd_get_intf_addr(hdd_ctx), |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 8025 | NET_NAME_UNKNOWN, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8026 | |
| 8027 | if (adapter == NULL) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8028 | return -ENOSPC; |
| 8029 | |
Deepak Dhamdhere | a278582 | 2016-11-17 01:17:45 -0800 | [diff] [blame] | 8030 | /* fast roaming is allowed only on first STA, i.e. wlan adapter */ |
| 8031 | adapter->fast_roaming_allowed = true; |
| 8032 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8033 | ret = hdd_open_p2p_interface(hdd_ctx, rtnl_held); |
| 8034 | if (ret) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8035 | goto err_close_adapters; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8036 | |
| 8037 | /* Open 802.11p Interface */ |
| 8038 | if (hdd_ctx->config->dot11p_mode == WLAN_HDD_11P_CONCURRENT) { |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8039 | ret = hdd_open_ocb_interface(hdd_ctx, rtnl_held); |
| 8040 | if (ret) |
| 8041 | goto err_close_adapters; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8042 | } |
| 8043 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8044 | return 0; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8045 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8046 | err_close_adapters: |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8047 | hdd_close_all_adapters(hdd_ctx, rtnl_held); |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8048 | return ret; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8049 | } |
| 8050 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8051 | /** |
| 8052 | * hdd_update_country_code - Update country code |
| 8053 | * @hdd_ctx: HDD context |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8054 | * |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 8055 | * Update country code based on module parameter country_code |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8056 | * |
| 8057 | * Return: 0 on success and errno on failure |
| 8058 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8059 | static int hdd_update_country_code(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8060 | { |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 8061 | if (!country_code) |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8062 | return 0; |
| 8063 | |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 8064 | return hdd_reg_set_country(hdd_ctx, country_code); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8065 | } |
| 8066 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8067 | #ifdef QCA_LL_TX_FLOW_CONTROL_V2 |
| 8068 | /** |
| 8069 | * hdd_txrx_populate_cds_config() - Populate txrx cds configuration |
| 8070 | * @cds_cfg: CDS Configuration |
| 8071 | * @hdd_ctx: Pointer to hdd context |
| 8072 | * |
| 8073 | * Return: none |
| 8074 | */ |
| 8075 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 8076 | *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8077 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8078 | { |
| 8079 | cds_cfg->tx_flow_stop_queue_th = |
| 8080 | hdd_ctx->config->TxFlowStopQueueThreshold; |
| 8081 | cds_cfg->tx_flow_start_queue_offset = |
| 8082 | hdd_ctx->config->TxFlowStartQueueOffset; |
| 8083 | } |
| 8084 | #else |
| 8085 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 8086 | *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8087 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8088 | { |
| 8089 | } |
| 8090 | #endif |
| 8091 | |
| 8092 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 8093 | /** |
| 8094 | * hdd_ra_populate_cds_config() - Populate RA filtering cds configuration |
| 8095 | * @cds_cfg: CDS Configuration |
| 8096 | * @hdd_ctx: Pointer to hdd context |
| 8097 | * |
| 8098 | * Return: none |
| 8099 | */ |
Anand Kumar | 3b92a91 | 2016-12-05 12:01:26 +0530 | [diff] [blame] | 8100 | static inline void hdd_ra_populate_cds_config(struct cds_config_info *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8101 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8102 | { |
| 8103 | cds_cfg->ra_ratelimit_interval = |
| 8104 | hdd_ctx->config->RArateLimitInterval; |
| 8105 | cds_cfg->is_ra_ratelimit_enabled = |
| 8106 | hdd_ctx->config->IsRArateLimitEnabled; |
| 8107 | } |
| 8108 | #else |
Anand Kumar | 3b92a91 | 2016-12-05 12:01:26 +0530 | [diff] [blame] | 8109 | static inline void hdd_ra_populate_cds_config(struct cds_config_info *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8110 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8111 | { |
| 8112 | } |
| 8113 | #endif |
| 8114 | |
| 8115 | /** |
| 8116 | * hdd_update_cds_config() - API to update cds configuration parameters |
| 8117 | * @hdd_ctx: HDD Context |
| 8118 | * |
| 8119 | * Return: 0 for Success, errno on failure |
| 8120 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8121 | static int hdd_update_cds_config(struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8122 | { |
| 8123 | struct cds_config_info *cds_cfg; |
| 8124 | |
| 8125 | cds_cfg = (struct cds_config_info *)qdf_mem_malloc(sizeof(*cds_cfg)); |
| 8126 | if (!cds_cfg) { |
| 8127 | hdd_err("failed to allocate cds config"); |
| 8128 | return -ENOMEM; |
| 8129 | } |
| 8130 | |
Srinivas Girigowda | 35b0031 | 2017-06-27 21:52:03 -0700 | [diff] [blame] | 8131 | cds_cfg->driver_type = QDF_DRIVER_TYPE_PRODUCTION; |
Kiran Kumar Lokere | 7006e0a | 2017-03-07 19:28:36 -0800 | [diff] [blame] | 8132 | if (!hdd_ctx->config->nMaxPsPoll || |
| 8133 | !hdd_ctx->config->enablePowersaveOffload) { |
| 8134 | cds_cfg->powersave_offload_enabled = |
| 8135 | hdd_ctx->config->enablePowersaveOffload; |
| 8136 | } else { |
| 8137 | if ((hdd_ctx->config->enablePowersaveOffload == |
| 8138 | PS_QPOWER_NODEEPSLEEP) || |
| 8139 | (hdd_ctx->config->enablePowersaveOffload == |
| 8140 | PS_LEGACY_NODEEPSLEEP)) |
| 8141 | cds_cfg->powersave_offload_enabled = |
| 8142 | PS_LEGACY_NODEEPSLEEP; |
| 8143 | else |
| 8144 | cds_cfg->powersave_offload_enabled = |
| 8145 | PS_LEGACY_DEEPSLEEP; |
| 8146 | hdd_info("Qpower disabled in cds config, %d", |
| 8147 | cds_cfg->powersave_offload_enabled); |
| 8148 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8149 | cds_cfg->sta_dynamic_dtim = hdd_ctx->config->enableDynamicDTIM; |
| 8150 | cds_cfg->sta_mod_dtim = hdd_ctx->config->enableModulatedDTIM; |
| 8151 | cds_cfg->sta_maxlimod_dtim = hdd_ctx->config->fMaxLIModulatedDTIM; |
| 8152 | cds_cfg->wow_enable = hdd_ctx->config->wowEnable; |
| 8153 | cds_cfg->max_wow_filters = hdd_ctx->config->maxWoWFilters; |
| 8154 | |
| 8155 | /* Here ol_ini_info is used to store ini status of arp offload |
| 8156 | * ns offload and others. Currently 1st bit is used for arp |
| 8157 | * off load and 2nd bit for ns offload currently, rest bits are unused |
| 8158 | */ |
| 8159 | if (hdd_ctx->config->fhostArpOffload) |
| 8160 | cds_cfg->ol_ini_info = cds_cfg->ol_ini_info | 0x1; |
| 8161 | if (hdd_ctx->config->fhostNSOffload) |
| 8162 | cds_cfg->ol_ini_info = cds_cfg->ol_ini_info | 0x2; |
| 8163 | |
| 8164 | /* |
| 8165 | * Copy the DFS Phyerr Filtering Offload status. |
| 8166 | * This parameter reflects the value of the |
| 8167 | * dfs_phyerr_filter_offload flag as set in the ini. |
| 8168 | */ |
| 8169 | cds_cfg->dfs_phyerr_filter_offload = |
| 8170 | hdd_ctx->config->fDfsPhyerrFilterOffload; |
| 8171 | if (hdd_ctx->config->ssdp) |
| 8172 | cds_cfg->ssdp = hdd_ctx->config->ssdp; |
| 8173 | |
SaidiReddy Yenuga | cc733af | 2016-11-09 17:45:42 +0530 | [diff] [blame] | 8174 | cds_cfg->force_target_assert_enabled = |
| 8175 | hdd_ctx->config->crash_inject_enabled; |
| 8176 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8177 | cds_cfg->enable_mc_list = hdd_ctx->config->fEnableMCAddrList; |
| 8178 | cds_cfg->ap_maxoffload_peers = hdd_ctx->config->apMaxOffloadPeers; |
| 8179 | |
| 8180 | cds_cfg->ap_maxoffload_reorderbuffs = |
| 8181 | hdd_ctx->config->apMaxOffloadReorderBuffs; |
| 8182 | |
| 8183 | cds_cfg->ap_disable_intrabss_fwd = |
| 8184 | hdd_ctx->config->apDisableIntraBssFwd; |
| 8185 | |
| 8186 | cds_cfg->dfs_pri_multiplier = |
| 8187 | hdd_ctx->config->dfsRadarPriMultiplier; |
| 8188 | cds_cfg->reorder_offload = |
| 8189 | hdd_ctx->config->reorderOffloadSupport; |
| 8190 | |
| 8191 | /* IPA micro controller data path offload resource config item */ |
| 8192 | cds_cfg->uc_offload_enabled = hdd_ipa_uc_is_enabled(hdd_ctx); |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8193 | if (!is_power_of_2(hdd_ctx->config->IpaUcTxBufCount)) { |
| 8194 | /* IpaUcTxBufCount should be power of 2 */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8195 | hdd_debug("Round down IpaUcTxBufCount %d to nearest power of 2", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8196 | hdd_ctx->config->IpaUcTxBufCount); |
| 8197 | hdd_ctx->config->IpaUcTxBufCount = |
| 8198 | rounddown_pow_of_two( |
| 8199 | hdd_ctx->config->IpaUcTxBufCount); |
| 8200 | if (!hdd_ctx->config->IpaUcTxBufCount) { |
| 8201 | hdd_err("Failed to round down IpaUcTxBufCount"); |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 8202 | goto exit; |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8203 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8204 | hdd_debug("IpaUcTxBufCount rounded down to %d", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8205 | hdd_ctx->config->IpaUcTxBufCount); |
| 8206 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8207 | cds_cfg->uc_txbuf_count = hdd_ctx->config->IpaUcTxBufCount; |
| 8208 | cds_cfg->uc_txbuf_size = hdd_ctx->config->IpaUcTxBufSize; |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8209 | if (!is_power_of_2(hdd_ctx->config->IpaUcRxIndRingCount)) { |
| 8210 | /* IpaUcRxIndRingCount should be power of 2 */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8211 | hdd_debug("Round down IpaUcRxIndRingCount %d to nearest power of 2", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8212 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 8213 | hdd_ctx->config->IpaUcRxIndRingCount = |
| 8214 | rounddown_pow_of_two( |
| 8215 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 8216 | if (!hdd_ctx->config->IpaUcRxIndRingCount) { |
| 8217 | hdd_err("Failed to round down IpaUcRxIndRingCount"); |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 8218 | goto exit; |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8219 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8220 | hdd_debug("IpaUcRxIndRingCount rounded down to %d", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8221 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 8222 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8223 | cds_cfg->uc_rxind_ringcount = |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8224 | hdd_ctx->config->IpaUcRxIndRingCount; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8225 | cds_cfg->uc_tx_partition_base = |
| 8226 | hdd_ctx->config->IpaUcTxPartitionBase; |
| 8227 | cds_cfg->max_scan = hdd_ctx->config->max_scan_count; |
| 8228 | |
| 8229 | cds_cfg->ip_tcp_udp_checksum_offload = |
| 8230 | hdd_ctx->config->enable_ip_tcp_udp_checksum_offload; |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 8231 | cds_cfg->enable_rxthread = hdd_ctx->enableRxThread; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8232 | cds_cfg->ce_classify_enabled = |
| 8233 | hdd_ctx->config->ce_classify_enabled; |
Dustin Brown | d3fc9ee | 2016-09-14 13:57:27 -0700 | [diff] [blame] | 8234 | cds_cfg->bpf_packet_filter_enable = |
| 8235 | hdd_ctx->config->bpf_packet_filter_enable; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8236 | cds_cfg->tx_chain_mask_cck = hdd_ctx->config->tx_chain_mask_cck; |
| 8237 | cds_cfg->self_gen_frm_pwr = hdd_ctx->config->self_gen_frm_pwr; |
| 8238 | cds_cfg->max_station = hdd_ctx->config->maxNumberOfPeers; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 8239 | cds_cfg->sub_20_channel_width = WLAN_SUB_20_CH_WIDTH_NONE; |
Manjunathappa Prakash | fff753c | 2016-09-01 19:34:56 -0700 | [diff] [blame] | 8240 | cds_cfg->flow_steering_enabled = hdd_ctx->config->flow_steering_enable; |
Naveen Rawat | 91df30a | 2016-10-12 21:26:18 -0700 | [diff] [blame] | 8241 | cds_cfg->self_recovery_enabled = hdd_ctx->config->enableSelfRecovery; |
Sandeep Puligilla | afa5289 | 2016-10-26 19:03:16 -0700 | [diff] [blame] | 8242 | cds_cfg->fw_timeout_crash = hdd_ctx->config->fw_timeout_crash; |
Hanumanth Reddy Pothula | e87621b | 2017-04-12 20:53:35 +0530 | [diff] [blame] | 8243 | cds_cfg->active_uc_bpf_mode = hdd_ctx->config->active_uc_bpf_mode; |
| 8244 | cds_cfg->active_mc_bc_bpf_mode = hdd_ctx->config->active_mc_bc_bpf_mode; |
Ravi Kumar Bokka | 05c14e5 | 2017-03-27 14:48:23 +0530 | [diff] [blame] | 8245 | cds_cfg->auto_power_save_fail_mode = |
| 8246 | hdd_ctx->config->auto_pwr_save_fail_mode; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8247 | |
Ashish Kumar Dhanotiya | 9335d81 | 2017-06-30 16:57:20 +0530 | [diff] [blame] | 8248 | cds_cfg->ito_repeat_count = hdd_ctx->config->ito_repeat_count; |
| 8249 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8250 | hdd_ra_populate_cds_config(cds_cfg, hdd_ctx); |
| 8251 | hdd_txrx_populate_cds_config(cds_cfg, hdd_ctx); |
| 8252 | hdd_nan_populate_cds_config(cds_cfg, hdd_ctx); |
Jeff Johnson | 9078bdc | 2016-09-23 17:18:11 -0700 | [diff] [blame] | 8253 | hdd_lpass_populate_cds_config(cds_cfg, hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8254 | cds_init_ini_config(cds_cfg); |
| 8255 | return 0; |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 8256 | |
| 8257 | exit: |
| 8258 | qdf_mem_free(cds_cfg); |
| 8259 | return -EINVAL; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8260 | } |
| 8261 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8262 | /** |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 8263 | * hdd_update_user_config() - API to update user configuration |
| 8264 | * parameters to obj mgr which are used by multiple components |
| 8265 | * @hdd_ctx: HDD Context |
| 8266 | * |
| 8267 | * Return: 0 for Success, errno on failure |
| 8268 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8269 | static int hdd_update_user_config(struct hdd_context *hdd_ctx) |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 8270 | { |
| 8271 | struct wlan_objmgr_psoc_user_config *user_config; |
| 8272 | |
| 8273 | user_config = qdf_mem_malloc(sizeof(*user_config)); |
| 8274 | if (user_config == NULL) { |
| 8275 | hdd_alert("Failed to alloc memory for user_config!"); |
| 8276 | return -ENOMEM; |
| 8277 | } |
| 8278 | |
| 8279 | user_config->dot11_mode = hdd_ctx->config->dot11Mode; |
| 8280 | user_config->dual_mac_feature_disable = |
| 8281 | hdd_ctx->config->dual_mac_feature_disable; |
| 8282 | user_config->indoor_channel_support = |
| 8283 | hdd_ctx->config->indoor_channel_support; |
| 8284 | user_config->is_11d_support_enabled = |
| 8285 | hdd_ctx->config->Is11dSupportEnabled; |
| 8286 | user_config->is_11h_support_enabled = |
| 8287 | hdd_ctx->config->Is11hSupportEnabled; |
| 8288 | user_config->optimize_chan_avoid_event = |
| 8289 | hdd_ctx->config->goptimize_chan_avoid_event; |
| 8290 | user_config->skip_dfs_chnl_in_p2p_search = |
| 8291 | hdd_ctx->config->skipDfsChnlInP2pSearch; |
Naveen Rawat | 222b2e9 | 2017-03-16 09:52:21 -0700 | [diff] [blame] | 8292 | user_config->band_capability = hdd_ctx->config->nBandCapability; |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 8293 | wlan_objmgr_psoc_set_user_config(hdd_ctx->hdd_psoc, user_config); |
| 8294 | |
| 8295 | qdf_mem_free(user_config); |
| 8296 | return 0; |
| 8297 | } |
| 8298 | |
| 8299 | /** |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8300 | * hdd_init_thermal_info - Initialize thermal level |
| 8301 | * @hdd_ctx: HDD context |
| 8302 | * |
| 8303 | * Initialize thermal level at SME layer and set the thermal level callback |
| 8304 | * which would be called when a configured thermal threshold is hit. |
| 8305 | * |
| 8306 | * Return: 0 on success and errno on failure |
| 8307 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8308 | static int hdd_init_thermal_info(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8309 | { |
| 8310 | tSmeThermalParams thermal_param; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8311 | QDF_STATUS status; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8312 | |
| 8313 | thermal_param.smeThermalMgmtEnabled = |
| 8314 | hdd_ctx->config->thermalMitigationEnable; |
| 8315 | thermal_param.smeThrottlePeriod = hdd_ctx->config->throttlePeriod; |
| 8316 | |
Poddar, Siddarth | 8390502 | 2016-04-16 17:56:08 -0700 | [diff] [blame] | 8317 | thermal_param.sme_throttle_duty_cycle_tbl[0] = |
| 8318 | hdd_ctx->config->throttle_dutycycle_level0; |
| 8319 | thermal_param.sme_throttle_duty_cycle_tbl[1] = |
| 8320 | hdd_ctx->config->throttle_dutycycle_level1; |
| 8321 | thermal_param.sme_throttle_duty_cycle_tbl[2] = |
| 8322 | hdd_ctx->config->throttle_dutycycle_level2; |
| 8323 | thermal_param.sme_throttle_duty_cycle_tbl[3] = |
| 8324 | hdd_ctx->config->throttle_dutycycle_level3; |
| 8325 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8326 | thermal_param.smeThermalLevels[0].smeMinTempThreshold = |
| 8327 | hdd_ctx->config->thermalTempMinLevel0; |
| 8328 | thermal_param.smeThermalLevels[0].smeMaxTempThreshold = |
| 8329 | hdd_ctx->config->thermalTempMaxLevel0; |
| 8330 | thermal_param.smeThermalLevels[1].smeMinTempThreshold = |
| 8331 | hdd_ctx->config->thermalTempMinLevel1; |
| 8332 | thermal_param.smeThermalLevels[1].smeMaxTempThreshold = |
| 8333 | hdd_ctx->config->thermalTempMaxLevel1; |
| 8334 | thermal_param.smeThermalLevels[2].smeMinTempThreshold = |
| 8335 | hdd_ctx->config->thermalTempMinLevel2; |
| 8336 | thermal_param.smeThermalLevels[2].smeMaxTempThreshold = |
| 8337 | hdd_ctx->config->thermalTempMaxLevel2; |
| 8338 | thermal_param.smeThermalLevels[3].smeMinTempThreshold = |
| 8339 | hdd_ctx->config->thermalTempMinLevel3; |
| 8340 | thermal_param.smeThermalLevels[3].smeMaxTempThreshold = |
| 8341 | hdd_ctx->config->thermalTempMaxLevel3; |
| 8342 | |
| 8343 | status = sme_init_thermal_info(hdd_ctx->hHal, thermal_param); |
| 8344 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8345 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 8346 | return qdf_status_to_os_return(status); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8347 | |
| 8348 | sme_add_set_thermal_level_callback(hdd_ctx->hHal, |
| 8349 | hdd_set_thermal_level_cb); |
| 8350 | |
| 8351 | return 0; |
| 8352 | |
| 8353 | } |
| 8354 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8355 | #if defined(CONFIG_HDD_INIT_WITH_RTNL_LOCK) |
| 8356 | /** |
| 8357 | * hdd_hold_rtnl_lock - Hold RTNL lock |
| 8358 | * |
| 8359 | * Hold RTNL lock |
| 8360 | * |
| 8361 | * Return: True if held and false otherwise |
| 8362 | */ |
| 8363 | static inline bool hdd_hold_rtnl_lock(void) |
| 8364 | { |
| 8365 | rtnl_lock(); |
| 8366 | return true; |
| 8367 | } |
| 8368 | |
| 8369 | /** |
| 8370 | * hdd_release_rtnl_lock - Release RTNL lock |
| 8371 | * |
| 8372 | * Release RTNL lock |
| 8373 | * |
| 8374 | * Return: None |
| 8375 | */ |
| 8376 | static inline void hdd_release_rtnl_lock(void) |
| 8377 | { |
| 8378 | rtnl_unlock(); |
| 8379 | } |
| 8380 | #else |
| 8381 | static inline bool hdd_hold_rtnl_lock(void) { return false; } |
| 8382 | static inline void hdd_release_rtnl_lock(void) { } |
| 8383 | #endif |
| 8384 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 8385 | #if !defined(REMOVE_PKT_LOG) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8386 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8387 | /* MAX iwpriv command support */ |
| 8388 | #define PKTLOG_SET_BUFF_SIZE 3 |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 8389 | #define PKTLOG_CLEAR_BUFF 4 |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8390 | #define MAX_PKTLOG_SIZE 16 |
| 8391 | |
| 8392 | /** |
| 8393 | * hdd_pktlog_set_buff_size() - set pktlog buffer size |
| 8394 | * @hdd_ctx: hdd context |
| 8395 | * @set_value2: pktlog buffer size value |
| 8396 | * |
| 8397 | * |
| 8398 | * Return: 0 for success or error. |
| 8399 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8400 | static int hdd_pktlog_set_buff_size(struct hdd_context *hdd_ctx, int set_value2) |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8401 | { |
| 8402 | struct sir_wifi_start_log start_log = { 0 }; |
| 8403 | QDF_STATUS status; |
| 8404 | |
| 8405 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 8406 | start_log.verbose_level = WLAN_LOG_LEVEL_OFF; |
| 8407 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 8408 | start_log.user_triggered = 1; |
| 8409 | start_log.size = set_value2; |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 8410 | start_log.is_pktlog_buff_clear = false; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8411 | |
| 8412 | status = sme_wifi_start_logger(hdd_ctx->hHal, start_log); |
| 8413 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 8414 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
| 8415 | EXIT(); |
| 8416 | return -EINVAL; |
| 8417 | } |
| 8418 | |
| 8419 | return 0; |
| 8420 | } |
| 8421 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8422 | /** |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 8423 | * hdd_pktlog_clear_buff() - clear pktlog buffer |
| 8424 | * @hdd_ctx: hdd context |
| 8425 | * |
| 8426 | * Return: 0 for success or error. |
| 8427 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8428 | static int hdd_pktlog_clear_buff(struct hdd_context *hdd_ctx) |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 8429 | { |
| 8430 | struct sir_wifi_start_log start_log; |
| 8431 | QDF_STATUS status; |
| 8432 | |
| 8433 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 8434 | start_log.verbose_level = WLAN_LOG_LEVEL_OFF; |
| 8435 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 8436 | start_log.user_triggered = 1; |
| 8437 | start_log.size = 0; |
| 8438 | start_log.is_pktlog_buff_clear = true; |
| 8439 | |
| 8440 | status = sme_wifi_start_logger(hdd_ctx->hHal, start_log); |
| 8441 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 8442 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
| 8443 | EXIT(); |
| 8444 | return -EINVAL; |
| 8445 | } |
| 8446 | |
| 8447 | return 0; |
| 8448 | } |
| 8449 | |
| 8450 | |
| 8451 | /** |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8452 | * hdd_process_pktlog_command() - process pktlog command |
| 8453 | * @hdd_ctx: hdd context |
| 8454 | * @set_value: value set by user |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8455 | * @set_value2: pktlog buffer size value |
| 8456 | * |
| 8457 | * This function process pktlog command. |
| 8458 | * set_value2 only matters when set_value is 3 (set buff size) |
| 8459 | * otherwise we ignore it. |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8460 | * |
| 8461 | * Return: 0 for success or error. |
| 8462 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8463 | int hdd_process_pktlog_command(struct hdd_context *hdd_ctx, uint32_t set_value, |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8464 | int set_value2) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8465 | { |
| 8466 | int ret; |
| 8467 | bool enable; |
| 8468 | uint8_t user_triggered = 0; |
| 8469 | |
| 8470 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 8471 | if (0 != ret) |
| 8472 | return ret; |
| 8473 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8474 | hdd_debug("set pktlog %d, set size %d", set_value, set_value2); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8475 | |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 8476 | if (set_value > PKTLOG_CLEAR_BUFF) { |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8477 | hdd_err("invalid pktlog value %d", set_value); |
| 8478 | return -EINVAL; |
| 8479 | } |
| 8480 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8481 | if (set_value == PKTLOG_SET_BUFF_SIZE) { |
| 8482 | if (set_value2 <= 0) { |
| 8483 | hdd_err("invalid pktlog size %d", set_value2); |
| 8484 | return -EINVAL; |
| 8485 | } else if (set_value2 > MAX_PKTLOG_SIZE) { |
| 8486 | hdd_err("Pktlog buff size is too large. max value is 16MB.\n"); |
| 8487 | return -EINVAL; |
| 8488 | } |
| 8489 | return hdd_pktlog_set_buff_size(hdd_ctx, set_value2); |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 8490 | } else if (set_value == PKTLOG_CLEAR_BUFF) { |
| 8491 | return hdd_pktlog_clear_buff(hdd_ctx); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8492 | } |
| 8493 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8494 | /* |
| 8495 | * set_value = 0 then disable packetlog |
| 8496 | * set_value = 1 enable packetlog forcefully |
| 8497 | * set_vlaue = 2 then disable packetlog if disabled through ini or |
| 8498 | * enable packetlog with AUTO type. |
| 8499 | */ |
| 8500 | enable = ((set_value > 0) && cds_is_packet_log_enabled()) ? |
| 8501 | true : false; |
| 8502 | |
| 8503 | if (1 == set_value) { |
| 8504 | enable = true; |
| 8505 | user_triggered = 1; |
| 8506 | } |
| 8507 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8508 | return hdd_pktlog_enable_disable(hdd_ctx, enable, user_triggered, 0); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8509 | } |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 8510 | /** |
| 8511 | * hdd_pktlog_enable_disable() - Enable/Disable packet logging |
| 8512 | * @hdd_ctx: HDD context |
| 8513 | * @enable: Flag to enable/disable |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8514 | * @user_triggered: triggered through iwpriv |
| 8515 | * @size: buffer size to be used for packetlog |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 8516 | * |
| 8517 | * Return: 0 on success; error number otherwise |
| 8518 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8519 | int hdd_pktlog_enable_disable(struct hdd_context *hdd_ctx, bool enable, |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8520 | uint8_t user_triggered, int size) |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 8521 | { |
| 8522 | struct sir_wifi_start_log start_log; |
| 8523 | QDF_STATUS status; |
| 8524 | |
| 8525 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 8526 | start_log.verbose_level = |
| 8527 | enable ? WLAN_LOG_LEVEL_ACTIVE : WLAN_LOG_LEVEL_OFF; |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8528 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 8529 | start_log.user_triggered = user_triggered; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8530 | start_log.size = size; |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 8531 | start_log.is_pktlog_buff_clear = false; |
Poddar, Siddarth | eefe348 | 2016-09-21 18:12:59 +0530 | [diff] [blame] | 8532 | /* |
| 8533 | * Use "is_iwpriv_command" flag to distinguish iwpriv command from other |
| 8534 | * commands. Host uses this flag to decide whether to send pktlog |
| 8535 | * disable command to fw without sending pktlog enable command |
| 8536 | * previously. For eg, If vendor sends pktlog disable command without |
| 8537 | * sending pktlog enable command, then host discards the packet |
| 8538 | * but for iwpriv command, host will send it to fw. |
| 8539 | */ |
| 8540 | start_log.is_iwpriv_command = 1; |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 8541 | status = sme_wifi_start_logger(hdd_ctx->hHal, start_log); |
| 8542 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 8543 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
| 8544 | EXIT(); |
| 8545 | return -EINVAL; |
| 8546 | } |
| 8547 | |
| 8548 | return 0; |
| 8549 | } |
| 8550 | #endif /* REMOVE_PKT_LOG */ |
| 8551 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 8552 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 8553 | * hdd_get_platform_wlan_mac_buff() - API to query platform driver |
| 8554 | * for MAC address |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 8555 | * @dev: Device Pointer |
| 8556 | * @num: Number of Valid Mac address |
| 8557 | * |
| 8558 | * Return: Pointer to MAC address buffer |
| 8559 | */ |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 8560 | static uint8_t *hdd_get_platform_wlan_mac_buff(struct device *dev, |
| 8561 | uint32_t *num) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 8562 | { |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 8563 | return pld_get_wlan_mac_address(dev, num); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 8564 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 8565 | |
| 8566 | /** |
| 8567 | * hdd_populate_random_mac_addr() - API to populate random mac addresses |
| 8568 | * @hdd_ctx: HDD Context |
| 8569 | * @num: Number of random mac addresses needed |
| 8570 | * |
| 8571 | * Generate random addresses using bit manipulation on the base mac address |
| 8572 | * |
| 8573 | * Return: None |
| 8574 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8575 | void hdd_populate_random_mac_addr(struct hdd_context *hdd_ctx, uint32_t num) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 8576 | { |
| 8577 | uint32_t start_idx = QDF_MAX_CONCURRENCY_PERSONA - num; |
| 8578 | uint32_t iter; |
| 8579 | struct hdd_config *ini = hdd_ctx->config; |
| 8580 | uint8_t *buf = NULL; |
| 8581 | uint8_t macaddr_b3, tmp_br3; |
| 8582 | uint8_t *src = ini->intfMacAddr[0].bytes; |
| 8583 | |
| 8584 | for (iter = start_idx; iter < QDF_MAX_CONCURRENCY_PERSONA; ++iter) { |
| 8585 | buf = ini->intfMacAddr[iter].bytes; |
| 8586 | qdf_mem_copy(buf, src, QDF_MAC_ADDR_SIZE); |
| 8587 | macaddr_b3 = buf[3]; |
| 8588 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + iter) & |
| 8589 | INTF_MACADDR_MASK; |
| 8590 | macaddr_b3 += tmp_br3; |
| 8591 | macaddr_b3 ^= (1 << INTF_MACADDR_MASK); |
| 8592 | buf[0] |= 0x02; |
| 8593 | buf[3] = macaddr_b3; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8594 | hdd_debug(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(buf)); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 8595 | } |
| 8596 | } |
| 8597 | |
| 8598 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 8599 | * hdd_platform_wlan_mac() - API to get mac addresses from platform driver |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 8600 | * @hdd_ctx: HDD Context |
| 8601 | * |
| 8602 | * API to get mac addresses from platform driver and update the driver |
| 8603 | * structures and configure FW with the base mac address. |
| 8604 | * Return: int |
| 8605 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8606 | static int hdd_platform_wlan_mac(struct hdd_context *hdd_ctx) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 8607 | { |
| 8608 | uint32_t no_of_mac_addr, iter; |
| 8609 | uint32_t max_mac_addr = QDF_MAX_CONCURRENCY_PERSONA; |
| 8610 | uint32_t mac_addr_size = QDF_MAC_ADDR_SIZE; |
| 8611 | uint8_t *addr, *buf; |
| 8612 | struct device *dev = hdd_ctx->parent_dev; |
| 8613 | struct hdd_config *ini = hdd_ctx->config; |
| 8614 | tSirMacAddr mac_addr; |
| 8615 | QDF_STATUS status; |
| 8616 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 8617 | addr = hdd_get_platform_wlan_mac_buff(dev, &no_of_mac_addr); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 8618 | |
| 8619 | if (no_of_mac_addr == 0 || !addr) { |
| 8620 | hdd_warn("Platform Driver Doesn't have wlan mac addresses"); |
| 8621 | return -EINVAL; |
| 8622 | } |
| 8623 | |
| 8624 | if (no_of_mac_addr > max_mac_addr) |
| 8625 | no_of_mac_addr = max_mac_addr; |
| 8626 | |
| 8627 | qdf_mem_copy(&mac_addr, addr, mac_addr_size); |
| 8628 | |
| 8629 | for (iter = 0; iter < no_of_mac_addr; ++iter, addr += mac_addr_size) { |
| 8630 | buf = ini->intfMacAddr[iter].bytes; |
| 8631 | qdf_mem_copy(buf, addr, QDF_MAC_ADDR_SIZE); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8632 | hdd_debug(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(buf)); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 8633 | } |
| 8634 | |
| 8635 | status = sme_set_custom_mac_addr(mac_addr); |
| 8636 | |
| 8637 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8638 | return -EAGAIN; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 8639 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 8640 | if (no_of_mac_addr < max_mac_addr) |
| 8641 | hdd_populate_random_mac_addr(hdd_ctx, max_mac_addr - |
| 8642 | no_of_mac_addr); |
| 8643 | return 0; |
| 8644 | } |
| 8645 | |
| 8646 | /** |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 8647 | * hdd_update_mac_addr_to_fw() - API to update wlan mac addresses to FW |
| 8648 | * @hdd_ctx: HDD Context |
| 8649 | * |
| 8650 | * Update MAC address to FW. If MAC address passed by FW is invalid, host |
| 8651 | * will generate its own MAC and update it to FW. |
| 8652 | * |
| 8653 | * Return: 0 for success |
| 8654 | * Non-zero error code for failure |
| 8655 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8656 | static int hdd_update_mac_addr_to_fw(struct hdd_context *hdd_ctx) |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 8657 | { |
| 8658 | tSirMacAddr customMacAddr; |
| 8659 | QDF_STATUS status; |
| 8660 | |
| 8661 | qdf_mem_copy(&customMacAddr, |
| 8662 | &hdd_ctx->config->intfMacAddr[0].bytes[0], |
| 8663 | sizeof(tSirMacAddr)); |
| 8664 | status = sme_set_custom_mac_addr(customMacAddr); |
| 8665 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8666 | return -EAGAIN; |
| 8667 | return 0; |
| 8668 | } |
| 8669 | |
| 8670 | /** |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 8671 | * hdd_initialize_mac_address() - API to get wlan mac addresses |
| 8672 | * @hdd_ctx: HDD Context |
| 8673 | * |
| 8674 | * Get MAC addresses from platform driver or wlan_mac.bin. If platform driver |
| 8675 | * is provisioned with mac addresses, driver uses it, else it will use |
| 8676 | * wlan_mac.bin to update HW MAC addresses. |
| 8677 | * |
| 8678 | * Return: None |
| 8679 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8680 | static void hdd_initialize_mac_address(struct hdd_context *hdd_ctx) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 8681 | { |
| 8682 | QDF_STATUS status; |
| 8683 | int ret; |
| 8684 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 8685 | ret = hdd_platform_wlan_mac(hdd_ctx); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 8686 | if (ret == 0) |
| 8687 | return; |
| 8688 | |
Yuanyuan Liu | 3d62f6a | 2017-06-08 11:08:46 -0700 | [diff] [blame] | 8689 | hdd_info("MAC is not programmed in platform driver ret: %d, use wlan_mac.bin", |
| 8690 | ret); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 8691 | |
| 8692 | status = hdd_update_mac_config(hdd_ctx); |
| 8693 | |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 8694 | if (QDF_IS_STATUS_SUCCESS(status)) |
| 8695 | return; |
| 8696 | |
Yuanyuan Liu | 3d62f6a | 2017-06-08 11:08:46 -0700 | [diff] [blame] | 8697 | hdd_info("MAC is not programmed in wlan_mac.bin ret %d, use default MAC", |
| 8698 | status); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 8699 | |
Yuanyuan Liu | 1c2caa3 | 2016-11-07 17:13:48 -0800 | [diff] [blame] | 8700 | if (hdd_ctx->update_mac_addr_to_fw) { |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 8701 | ret = hdd_update_mac_addr_to_fw(hdd_ctx); |
Yuanyuan Liu | 1c2caa3 | 2016-11-07 17:13:48 -0800 | [diff] [blame] | 8702 | if (ret != 0) { |
| 8703 | hdd_err("MAC address out-of-sync, ret:%d", ret); |
| 8704 | QDF_ASSERT(ret); |
| 8705 | } |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 8706 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 8707 | } |
| 8708 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8709 | static int hdd_set_smart_chainmask_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 8710 | { |
| 8711 | int vdev_id = 0; |
| 8712 | int param_id = WMI_PDEV_PARAM_SMART_CHAINMASK_SCHEME; |
| 8713 | int value = hdd_ctx->config->smart_chainmask_enabled; |
| 8714 | int vpdev = PDEV_CMD; |
| 8715 | int ret; |
| 8716 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 8717 | ret = sme_cli_set_command(vdev_id, param_id, value, vpdev); |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 8718 | if (ret) |
| 8719 | hdd_err("WMI_PDEV_PARAM_SMART_CHAINMASK_SCHEME failed %d", ret); |
| 8720 | |
| 8721 | return ret; |
| 8722 | } |
| 8723 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8724 | static int hdd_set_alternative_chainmask_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 8725 | { |
| 8726 | int vdev_id = 0; |
| 8727 | int param_id = WMI_PDEV_PARAM_ALTERNATIVE_CHAINMASK_SCHEME; |
| 8728 | int value = hdd_ctx->config->alternative_chainmask_enabled; |
| 8729 | int vpdev = PDEV_CMD; |
| 8730 | int ret; |
| 8731 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 8732 | ret = sme_cli_set_command(vdev_id, param_id, value, vpdev); |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 8733 | if (ret) |
| 8734 | hdd_err("WMI_PDEV_PARAM_ALTERNATIVE_CHAINMASK_SCHEME failed %d", |
| 8735 | ret); |
| 8736 | |
| 8737 | return ret; |
| 8738 | } |
| 8739 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8740 | static int hdd_set_ani_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 8741 | { |
| 8742 | int vdev_id = 0; |
| 8743 | int param_id = WMI_PDEV_PARAM_ANI_ENABLE; |
| 8744 | int value = hdd_ctx->config->ani_enabled; |
| 8745 | int vpdev = PDEV_CMD; |
| 8746 | int ret; |
| 8747 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 8748 | ret = sme_cli_set_command(vdev_id, param_id, value, vpdev); |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 8749 | if (ret) |
| 8750 | hdd_err("WMI_PDEV_PARAM_ANI_ENABLE failed %d", ret); |
| 8751 | |
| 8752 | return ret; |
| 8753 | } |
| 8754 | |
Jeff Johnson | 89c66ff | 2016-04-22 15:21:37 -0700 | [diff] [blame] | 8755 | /** |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 8756 | * hdd_pre_enable_configure() - Configurations prior to cds_enable |
| 8757 | * @hdd_ctx: HDD context |
| 8758 | * |
| 8759 | * Pre configurations to be done at lower layer before calling cds enable. |
| 8760 | * |
| 8761 | * Return: 0 on success and errno on failure. |
| 8762 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8763 | static int hdd_pre_enable_configure(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 8764 | { |
| 8765 | int ret; |
| 8766 | QDF_STATUS status; |
| 8767 | tSirRetStatus hal_status; |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 8768 | void *soc = cds_get_context(QDF_MODULE_ID_SOC); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 8769 | |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 8770 | cdp_register_pause_cb(soc, wlan_hdd_txrx_pause_cb); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 8771 | /* |
| 8772 | * Set 802.11p config |
| 8773 | * TODO-OCB: This has been temporarily added here to ensure this |
| 8774 | * parameter is set in CSR when we init the channel list. This should |
| 8775 | * be removed once the 5.9 GHz channels are added to the regulatory |
| 8776 | * domain. |
| 8777 | */ |
| 8778 | hdd_set_dot11p_config(hdd_ctx); |
| 8779 | |
| 8780 | /* |
| 8781 | * Note that the cds_pre_enable() sequence triggers the cfg download. |
| 8782 | * The cfg download must occur before we update the SME config |
| 8783 | * since the SME config operation must access the cfg database |
| 8784 | */ |
| 8785 | status = hdd_set_sme_config(hdd_ctx); |
| 8786 | |
| 8787 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8788 | hdd_err("Failed hdd_set_sme_config: %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 8789 | ret = qdf_status_to_os_return(status); |
| 8790 | goto out; |
| 8791 | } |
| 8792 | |
Tushnim Bhattacharyya | ba8ee93 | 2017-03-23 09:27:40 -0700 | [diff] [blame] | 8793 | status = hdd_set_policy_mgr_user_cfg(hdd_ctx); |
| 8794 | if (QDF_STATUS_SUCCESS != status) { |
| 8795 | hdd_alert("Failed hdd_set_policy_mgr_user_cfg: %d", status); |
| 8796 | ret = qdf_status_to_os_return(status); |
| 8797 | goto out; |
| 8798 | } |
| 8799 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 8800 | ret = sme_cli_set_command(0, WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS, |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 8801 | hdd_ctx->config->tx_chain_mask_1ss, |
| 8802 | PDEV_CMD); |
| 8803 | if (0 != ret) { |
| 8804 | hdd_err("WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS failed %d", ret); |
| 8805 | goto out; |
| 8806 | } |
| 8807 | |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 8808 | ret = hdd_set_smart_chainmask_enabled(hdd_ctx); |
| 8809 | if (ret) |
| 8810 | goto out; |
| 8811 | |
| 8812 | ret = hdd_set_alternative_chainmask_enabled(hdd_ctx); |
| 8813 | if (ret) |
| 8814 | goto out; |
| 8815 | |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 8816 | ret = hdd_set_ani_enabled(hdd_ctx); |
| 8817 | if (ret) |
| 8818 | goto out; |
| 8819 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 8820 | ret = sme_cli_set_command(0, WMI_PDEV_PARAM_ARP_AC_OVERRIDE, |
Srinivas Girigowda | 70e169a | 2017-03-07 23:55:57 -0800 | [diff] [blame] | 8821 | hdd_ctx->config->arp_ac_category, |
| 8822 | PDEV_CMD); |
| 8823 | if (0 != ret) { |
| 8824 | hdd_err("WMI_PDEV_PARAM_ARP_AC_OVERRIDE ac: %d ret: %d", |
| 8825 | hdd_ctx->config->arp_ac_category, ret); |
| 8826 | goto out; |
| 8827 | } |
| 8828 | |
| 8829 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 8830 | status = hdd_set_sme_chan_list(hdd_ctx); |
| 8831 | if (status != QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8832 | hdd_err("Failed to init channel list: %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 8833 | ret = qdf_status_to_os_return(status); |
| 8834 | goto out; |
| 8835 | } |
| 8836 | |
| 8837 | /* Apply the cfg.ini to cfg.dat */ |
Krunal Soni | df0f874 | 2016-09-26 14:56:31 -0700 | [diff] [blame] | 8838 | if (!hdd_update_config_cfg(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8839 | hdd_err("config update failed"); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 8840 | ret = -EINVAL; |
| 8841 | goto out; |
| 8842 | } |
| 8843 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 8844 | /* |
| 8845 | * Set the MAC Address Currently this is used by HAL to add self sta. |
| 8846 | * Remove this once self sta is added as part of session open. |
| 8847 | */ |
| 8848 | hal_status = cfg_set_str(hdd_ctx->hHal, WNI_CFG_STA_ID, |
| 8849 | hdd_ctx->config->intfMacAddr[0].bytes, |
| 8850 | sizeof(hdd_ctx->config->intfMacAddr[0])); |
| 8851 | |
| 8852 | if (!IS_SIR_STATUS_SUCCESS(hal_status)) { |
| 8853 | hdd_err("Failed to set MAC Address. HALStatus is %08d [x%08x]", |
| 8854 | hal_status, hal_status); |
| 8855 | ret = -EINVAL; |
| 8856 | goto out; |
| 8857 | } |
| 8858 | |
| 8859 | hdd_init_channel_avoidance(hdd_ctx); |
| 8860 | |
Ganesh Kondabattini | 408fb8d | 2017-08-08 22:00:20 +0530 | [diff] [blame] | 8861 | /* update enable sap mandatory chan list */ |
| 8862 | policy_mgr_enable_disable_sap_mandatory_chan_list(hdd_ctx->hdd_psoc, |
| 8863 | hdd_ctx->config->enable_sap_mandatory_chan_list); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 8864 | out: |
| 8865 | return ret; |
| 8866 | } |
| 8867 | |
| 8868 | /** |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 8869 | * wlan_hdd_p2p_lo_event_callback - P2P listen offload stop event handler |
| 8870 | * @context_ptr - hdd context pointer |
| 8871 | * @event_ptr - event structure pointer |
| 8872 | * |
| 8873 | * This is the p2p listen offload stop event handler, it sends vendor |
| 8874 | * event back to supplicant to notify the stop reason. |
| 8875 | * |
| 8876 | * Return: None |
| 8877 | */ |
| 8878 | static void wlan_hdd_p2p_lo_event_callback(void *context_ptr, |
| 8879 | void *event_ptr) |
| 8880 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8881 | struct hdd_context *hdd_ctx = (struct hdd_context *)context_ptr; |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 8882 | struct sir_p2p_lo_event *evt = event_ptr; |
| 8883 | struct sk_buff *vendor_event; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8884 | struct hdd_adapter *adapter; |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 8885 | |
| 8886 | ENTER(); |
| 8887 | |
| 8888 | if (hdd_ctx == NULL) { |
| 8889 | hdd_err("Invalid HDD context pointer"); |
| 8890 | return; |
| 8891 | } |
| 8892 | |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 8893 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, evt->vdev_id); |
| 8894 | if (!adapter) { |
| 8895 | hdd_err("Cannot find adapter by vdev_id = %d", |
| 8896 | evt->vdev_id); |
| 8897 | return; |
| 8898 | } |
| 8899 | |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 8900 | vendor_event = |
| 8901 | cfg80211_vendor_event_alloc(hdd_ctx->wiphy, |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 8902 | &(adapter->wdev), sizeof(uint32_t) + NLMSG_HDRLEN, |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 8903 | QCA_NL80211_VENDOR_SUBCMD_P2P_LO_EVENT_INDEX, |
| 8904 | GFP_KERNEL); |
| 8905 | |
| 8906 | if (!vendor_event) { |
| 8907 | hdd_err("cfg80211_vendor_event_alloc failed"); |
| 8908 | return; |
| 8909 | } |
| 8910 | |
| 8911 | if (nla_put_u32(vendor_event, |
| 8912 | QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_STOP_REASON, |
| 8913 | evt->reason_code)) { |
| 8914 | hdd_err("nla put failed"); |
| 8915 | kfree_skb(vendor_event); |
| 8916 | return; |
| 8917 | } |
| 8918 | |
| 8919 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 8920 | hdd_debug("Sent P2P_LISTEN_OFFLOAD_STOP event for vdev_id = %d", |
| 8921 | evt->vdev_id); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 8922 | } |
| 8923 | |
| 8924 | /** |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 8925 | * hdd_adaptive_dwelltime_init() - initialization for adaptive dwell time config |
| 8926 | * @hdd_ctx: HDD context |
| 8927 | * |
| 8928 | * This function sends the adaptive dwell time config configuration to the |
| 8929 | * firmware via WMA |
| 8930 | * |
| 8931 | * Return: 0 - success, < 0 - failure |
| 8932 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8933 | static int hdd_adaptive_dwelltime_init(struct hdd_context *hdd_ctx) |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 8934 | { |
| 8935 | QDF_STATUS status; |
| 8936 | struct adaptive_dwelltime_params dwelltime_params; |
| 8937 | |
| 8938 | dwelltime_params.is_enabled = |
| 8939 | hdd_ctx->config->adaptive_dwell_mode_enabled; |
| 8940 | dwelltime_params.dwelltime_mode = |
| 8941 | hdd_ctx->config->global_adapt_dwelltime_mode; |
| 8942 | dwelltime_params.lpf_weight = |
| 8943 | hdd_ctx->config->adapt_dwell_lpf_weight; |
| 8944 | dwelltime_params.passive_mon_intval = |
| 8945 | hdd_ctx->config->adapt_dwell_passive_mon_intval; |
| 8946 | dwelltime_params.wifi_act_threshold = |
| 8947 | hdd_ctx->config->adapt_dwell_wifi_act_threshold; |
| 8948 | |
| 8949 | status = sme_set_adaptive_dwelltime_config(hdd_ctx->hHal, |
| 8950 | &dwelltime_params); |
| 8951 | |
| 8952 | hdd_debug("Sending Adaptive Dwelltime Configuration to fw"); |
| 8953 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 8954 | hdd_err("Failed to send Adaptive Dwelltime configuration!"); |
| 8955 | return -EAGAIN; |
| 8956 | } |
| 8957 | return 0; |
| 8958 | } |
| 8959 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8960 | int hdd_dbs_scan_selection_init(struct hdd_context *hdd_ctx) |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 8961 | { |
| 8962 | QDF_STATUS status; |
| 8963 | struct wmi_dbs_scan_sel_params dbs_scan_params; |
| 8964 | uint32_t i = 0; |
| 8965 | uint8_t count = 0, numentries = 0; |
| 8966 | uint8_t dbs_scan_config[CDS_DBS_SCAN_PARAM_PER_CLIENT |
| 8967 | * CDS_DBS_SCAN_CLIENTS_MAX]; |
| 8968 | |
| 8969 | /* check if DBS is enabled or supported */ |
Tushnim Bhattacharyya | 49ed8ab | 2017-05-26 18:20:10 -0700 | [diff] [blame] | 8970 | if (hdd_ctx->config->dual_mac_feature_disable == |
| 8971 | DISABLE_DBS_CXN_AND_SCAN) |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 8972 | return -EINVAL; |
| 8973 | |
| 8974 | hdd_string_to_u8_array(hdd_ctx->config->dbs_scan_selection, |
| 8975 | dbs_scan_config, &numentries, |
| 8976 | (CDS_DBS_SCAN_PARAM_PER_CLIENT |
| 8977 | * CDS_DBS_SCAN_CLIENTS_MAX)); |
| 8978 | |
| 8979 | hdd_info("numentries %hu", numentries); |
| 8980 | if (!numentries) { |
| 8981 | hdd_info("Donot send scan_selection_config"); |
| 8982 | return 0; |
| 8983 | } |
| 8984 | |
| 8985 | /* hdd_set_fw_log_params */ |
| 8986 | dbs_scan_params.num_clients = 0; |
| 8987 | while (count < (numentries - 2)) { |
| 8988 | dbs_scan_params.module_id[i] = dbs_scan_config[count]; |
| 8989 | dbs_scan_params.num_dbs_scans[i] = dbs_scan_config[count + 1]; |
| 8990 | dbs_scan_params.num_non_dbs_scans[i] = |
| 8991 | dbs_scan_config[count + 2]; |
| 8992 | dbs_scan_params.num_clients++; |
| 8993 | hdd_debug("module:%d NDS:%d NNDS:%d", |
| 8994 | dbs_scan_params.module_id[i], |
| 8995 | dbs_scan_params.num_dbs_scans[i], |
| 8996 | dbs_scan_params.num_non_dbs_scans[i]); |
| 8997 | count += CDS_DBS_SCAN_PARAM_PER_CLIENT; |
| 8998 | i++; |
| 8999 | } |
| 9000 | |
| 9001 | dbs_scan_params.pdev_id = 0; |
| 9002 | |
| 9003 | hdd_debug("clients:%d pdev:%d", |
| 9004 | dbs_scan_params.num_clients, dbs_scan_params.pdev_id); |
| 9005 | |
| 9006 | status = sme_set_dbs_scan_selection_config(hdd_ctx->hHal, |
| 9007 | &dbs_scan_params); |
| 9008 | hdd_debug("Sending DBS Scan Selection Configuration to fw"); |
| 9009 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9010 | hdd_err("Failed to send DBS Scan selection configuration!"); |
| 9011 | return -EAGAIN; |
| 9012 | } |
| 9013 | return 0; |
| 9014 | } |
| 9015 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9016 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 9017 | /** |
| 9018 | * hdd_set_auto_shutdown_cb() - Set auto shutdown callback |
| 9019 | * @hdd_ctx: HDD context |
| 9020 | * |
| 9021 | * Set auto shutdown callback to get indications from firmware to indicate |
| 9022 | * userspace to shutdown WLAN after a configured amount of inactivity. |
| 9023 | * |
| 9024 | * Return: 0 on success and errno on failure. |
| 9025 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9026 | static int hdd_set_auto_shutdown_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9027 | { |
| 9028 | QDF_STATUS status; |
| 9029 | |
| 9030 | if (!hdd_ctx->config->WlanAutoShutdown) |
| 9031 | return 0; |
| 9032 | |
| 9033 | status = sme_set_auto_shutdown_cb(hdd_ctx->hHal, |
| 9034 | wlan_hdd_auto_shutdown_cb); |
| 9035 | if (status != QDF_STATUS_SUCCESS) |
| 9036 | hdd_err("Auto shutdown feature could not be enabled: %d", |
| 9037 | status); |
| 9038 | |
| 9039 | return qdf_status_to_os_return(status); |
| 9040 | } |
| 9041 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9042 | static int hdd_set_auto_shutdown_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9043 | { |
| 9044 | return 0; |
| 9045 | } |
| 9046 | #endif |
| 9047 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9048 | static QDF_STATUS hdd_set_dbs_scan_and_fw_mode_cfg(struct hdd_context *hdd_ctx) |
Tushnim Bhattacharyya | 49ed8ab | 2017-05-26 18:20:10 -0700 | [diff] [blame] | 9049 | { |
| 9050 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
| 9051 | |
| 9052 | switch (hdd_ctx->config->dual_mac_feature_disable) { |
| 9053 | case DISABLE_DBS_CXN_AND_SCAN: |
| 9054 | status = wlan_hdd_disable_all_dual_mac_features(hdd_ctx); |
| 9055 | if (status != QDF_STATUS_SUCCESS) |
| 9056 | hdd_err("Failed to disable dual mac features"); |
| 9057 | break; |
| 9058 | case DISABLE_DBS_CXN_AND_ENABLE_DBS_SCAN: |
| 9059 | case DISABLE_DBS_CXN_AND_ENABLE_DBS_SCAN_WITH_ASYNC_SCAN_OFF: |
| 9060 | case ENABLE_DBS_CXN_AND_ENABLE_SCAN_WITH_ASYNC_SCAN_OFF: |
| 9061 | status = wlan_hdd_update_dbs_scan_and_fw_mode_config(hdd_ctx); |
| 9062 | if (status != QDF_STATUS_SUCCESS) |
| 9063 | hdd_err("Failed to set dbs scan and fw mode config"); |
| 9064 | break; |
| 9065 | default: |
| 9066 | break; |
| 9067 | } |
| 9068 | |
| 9069 | return status; |
| 9070 | } |
| 9071 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9072 | /** |
| 9073 | * hdd_features_init() - Init features |
| 9074 | * @hdd_ctx: HDD context |
| 9075 | * @adapter: Primary adapter context |
| 9076 | * |
| 9077 | * Initialize features and their feature context after WLAN firmware is up. |
| 9078 | * |
| 9079 | * Return: 0 on success and errno on failure. |
| 9080 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9081 | static int hdd_features_init(struct hdd_context *hdd_ctx, struct hdd_adapter *adapter) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9082 | { |
| 9083 | tSirTxPowerLimit hddtxlimit; |
| 9084 | QDF_STATUS status; |
Manjeet Singh | a9cae43 | 2017-02-28 11:58:22 +0530 | [diff] [blame] | 9085 | struct sme_5g_band_pref_params band_pref_params; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9086 | int ret; |
| 9087 | |
| 9088 | ENTER(); |
| 9089 | |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 9090 | ret = hdd_update_country_code(hdd_ctx); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9091 | if (ret) { |
| 9092 | hdd_err("Failed to update country code: %d", ret); |
| 9093 | goto out; |
| 9094 | } |
| 9095 | |
| 9096 | /* FW capabilities received, Set the Dot11 mode */ |
| 9097 | sme_setdef_dot11mode(hdd_ctx->hHal); |
Kiran Kumar Lokere | 1aa9c9a | 2016-10-05 18:50:59 -0700 | [diff] [blame] | 9098 | sme_set_prefer_80MHz_over_160MHz(hdd_ctx->hHal, |
| 9099 | hdd_ctx->config->sta_prefer_80MHz_over_160MHz); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9100 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9101 | |
| 9102 | if (hdd_ctx->config->fIsImpsEnabled) |
| 9103 | hdd_set_idle_ps_config(hdd_ctx, true); |
| 9104 | else |
| 9105 | hdd_set_idle_ps_config(hdd_ctx, false); |
| 9106 | |
Agrawal Ashish | 642ec9b | 2017-02-22 14:45:30 +0530 | [diff] [blame] | 9107 | if (hdd_ctx->config->enable_go_cts2self_for_sta) |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 9108 | sme_set_cts2self_for_p2p_go(hdd_ctx->hHal); |
Agrawal Ashish | 642ec9b | 2017-02-22 14:45:30 +0530 | [diff] [blame] | 9109 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9110 | if (hdd_lro_init(hdd_ctx)) |
| 9111 | hdd_err("Unable to initialize LRO in fw"); |
| 9112 | |
| 9113 | if (hdd_adaptive_dwelltime_init(hdd_ctx)) |
| 9114 | hdd_err("Unable to send adaptive dwelltime setting to FW"); |
| 9115 | |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 9116 | if (hdd_dbs_scan_selection_init(hdd_ctx)) |
| 9117 | hdd_err("Unable to send DBS scan selection setting to FW"); |
| 9118 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9119 | ret = hdd_init_thermal_info(hdd_ctx); |
| 9120 | if (ret) { |
| 9121 | hdd_err("Error while initializing thermal information"); |
| 9122 | goto deregister_frames; |
| 9123 | } |
| 9124 | |
Poddar, Siddarth | 66a4659 | 2017-02-22 11:44:44 +0530 | [diff] [blame] | 9125 | if (cds_is_packet_log_enabled()) |
| 9126 | hdd_pktlog_enable_disable(hdd_ctx, true, 0, 0); |
| 9127 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9128 | hddtxlimit.txPower2g = hdd_ctx->config->TxPower2g; |
| 9129 | hddtxlimit.txPower5g = hdd_ctx->config->TxPower5g; |
| 9130 | status = sme_txpower_limit(hdd_ctx->hHal, &hddtxlimit); |
| 9131 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9132 | hdd_err("Error setting txlimit in sme: %d", status); |
| 9133 | |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 9134 | wlan_hdd_tsf_init(hdd_ctx); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9135 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9136 | ret = hdd_register_cb(hdd_ctx); |
| 9137 | if (ret) { |
| 9138 | hdd_err("Failed to register HDD callbacks!"); |
| 9139 | goto deregister_frames; |
| 9140 | } |
| 9141 | |
Tushnim Bhattacharyya | 49ed8ab | 2017-05-26 18:20:10 -0700 | [diff] [blame] | 9142 | status = hdd_set_dbs_scan_and_fw_mode_cfg(hdd_ctx); |
| 9143 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9144 | hdd_err("Failed to set dbs scan and fw mode cfg"); |
| 9145 | goto deregister_cb; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9146 | } |
Tushnim Bhattacharyya | 49ed8ab | 2017-05-26 18:20:10 -0700 | [diff] [blame] | 9147 | |
Selvaraj, Sridhar | 371f55e | 2017-02-21 10:36:15 +0530 | [diff] [blame] | 9148 | if (hdd_ctx->config->goptimize_chan_avoid_event) { |
| 9149 | status = sme_enable_disable_chanavoidind_event( |
| 9150 | hdd_ctx->hHal, 0); |
| 9151 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9152 | hdd_err("Failed to disable Chan Avoidance Indication"); |
| 9153 | goto deregister_cb; |
| 9154 | } |
| 9155 | } |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9156 | |
Manjeet Singh | a9cae43 | 2017-02-28 11:58:22 +0530 | [diff] [blame] | 9157 | if (hdd_ctx->config->enable_5g_band_pref) { |
| 9158 | band_pref_params.rssi_boost_threshold_5g = |
| 9159 | hdd_ctx->config->rssi_boost_threshold_5g; |
| 9160 | band_pref_params.rssi_boost_factor_5g = |
| 9161 | hdd_ctx->config->rssi_boost_factor_5g; |
| 9162 | band_pref_params.max_rssi_boost_5g = |
| 9163 | hdd_ctx->config->max_rssi_boost_5g; |
| 9164 | band_pref_params.rssi_penalize_threshold_5g = |
| 9165 | hdd_ctx->config->rssi_penalize_threshold_5g; |
| 9166 | band_pref_params.rssi_penalize_factor_5g = |
| 9167 | hdd_ctx->config->rssi_penalize_factor_5g; |
| 9168 | band_pref_params.max_rssi_penalize_5g = |
| 9169 | hdd_ctx->config->max_rssi_penalize_5g; |
| 9170 | sme_set_5g_band_pref(hdd_ctx->hHal, &band_pref_params); |
| 9171 | } |
| 9172 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9173 | /* register P2P Listen Offload event callback */ |
| 9174 | if (wma_is_p2p_lo_capable()) |
| 9175 | sme_register_p2p_lo_event(hdd_ctx->hHal, hdd_ctx, |
| 9176 | wlan_hdd_p2p_lo_event_callback); |
| 9177 | |
| 9178 | ret = hdd_set_auto_shutdown_cb(hdd_ctx); |
| 9179 | |
| 9180 | if (ret) |
| 9181 | goto deregister_cb; |
| 9182 | |
| 9183 | EXIT(); |
| 9184 | return 0; |
| 9185 | |
| 9186 | deregister_cb: |
| 9187 | hdd_deregister_cb(hdd_ctx); |
| 9188 | deregister_frames: |
| 9189 | wlan_hdd_cfg80211_deregister_frames(adapter); |
| 9190 | out: |
| 9191 | return -EINVAL; |
| 9192 | |
| 9193 | } |
| 9194 | |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 9195 | /** |
| 9196 | * hdd_features_deinit() - Deinit features |
| 9197 | * @hdd_ctx: HDD context |
| 9198 | * |
| 9199 | * De-Initialize features and their feature context. |
| 9200 | * |
| 9201 | * Return: none. |
| 9202 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9203 | static void hdd_features_deinit(struct hdd_context *hdd_ctx) |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 9204 | { |
| 9205 | wlan_hdd_tsf_deinit(hdd_ctx); |
| 9206 | } |
| 9207 | |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 9208 | /** |
Sandeep Puligilla | 0a11f8d | 2017-06-23 15:53:29 -0700 | [diff] [blame] | 9209 | * hdd_register_bcn_cb() - register scan beacon callback |
| 9210 | * @hdd_ctx - Pointer to the HDD context |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 9211 | * |
Sandeep Puligilla | 0a11f8d | 2017-06-23 15:53:29 -0700 | [diff] [blame] | 9212 | * Return: QDF_STATUS |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 9213 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9214 | static inline QDF_STATUS hdd_register_bcn_cb(struct hdd_context *hdd_ctx) |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 9215 | { |
| 9216 | QDF_STATUS status; |
| 9217 | |
| 9218 | status = ucfg_scan_register_bcn_cb(hdd_ctx->hdd_psoc, |
| 9219 | wlan_cfg80211_inform_bss_frame, |
| 9220 | SCAN_CB_TYPE_INFORM_BCN); |
| 9221 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9222 | hdd_err("failed with status code %08d [x%08x]", |
| 9223 | status, status); |
| 9224 | return status; |
| 9225 | } |
| 9226 | |
| 9227 | return QDF_STATUS_SUCCESS; |
| 9228 | } |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9229 | |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 9230 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9231 | * hdd_configure_cds() - Configure cds modules |
| 9232 | * @hdd_ctx: HDD context |
| 9233 | * @adapter: Primary adapter context |
| 9234 | * |
| 9235 | * Enable Cds modules after WLAN firmware is up. |
| 9236 | * |
| 9237 | * Return: 0 on success and errno on failure. |
| 9238 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9239 | int hdd_configure_cds(struct hdd_context *hdd_ctx, struct hdd_adapter *adapter) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9240 | { |
| 9241 | int ret; |
| 9242 | QDF_STATUS status; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9243 | |
| 9244 | ret = hdd_pre_enable_configure(hdd_ctx); |
| 9245 | if (ret) { |
| 9246 | hdd_err("Failed to pre-configure cds"); |
| 9247 | goto out; |
| 9248 | } |
| 9249 | |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 9250 | /* Always get latest IPA resources allocated from cds_open and configure |
| 9251 | * IPA module before configuring them to FW. Sequence required as crash |
| 9252 | * observed otherwise. |
| 9253 | */ |
Manikandan Mohan | 2e803a0 | 2017-02-14 14:57:53 -0800 | [diff] [blame] | 9254 | if (hdd_ipa_uc_ol_init(hdd_ctx)) { |
| 9255 | hdd_err("Failed to setup pipes"); |
| 9256 | goto out; |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 9257 | } |
| 9258 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9259 | /* |
| 9260 | * Start CDS which starts up the SME/MAC/HAL modules and everything |
| 9261 | * else |
| 9262 | */ |
Jeff Johnson | 8f9dd5f | 2017-09-13 14:16:08 -0700 | [diff] [blame] | 9263 | status = cds_enable(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9264 | |
| 9265 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9266 | hdd_err("cds_enable failed"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9267 | goto out; |
| 9268 | } |
| 9269 | |
| 9270 | status = hdd_post_cds_enable_config(hdd_ctx); |
| 9271 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9272 | hdd_err("hdd_post_cds_enable_config failed"); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 9273 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9274 | } |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 9275 | status = hdd_register_bcn_cb(hdd_ctx); |
| 9276 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9277 | hdd_alert("hdd_post_cds_enable_config failed"); |
| 9278 | goto cds_disable; |
| 9279 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9280 | |
| 9281 | ret = hdd_features_init(hdd_ctx, adapter); |
| 9282 | if (ret) |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 9283 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9284 | |
Nachiket Kukade | fbd1afc | 2017-07-12 17:41:54 +0530 | [diff] [blame] | 9285 | if (hdd_enable_egap(hdd_ctx)) |
| 9286 | hdd_debug("enhance green ap is not enabled"); |
| 9287 | |
Nachiket Kukade | dd30266 | 2017-07-13 17:31:44 +0530 | [diff] [blame] | 9288 | if (0 != wlan_hdd_set_wow_pulse(hdd_ctx, true)) |
| 9289 | hdd_debug("Failed to set wow pulse"); |
| 9290 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9291 | return 0; |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 9292 | |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 9293 | cds_disable: |
Jeff Johnson | ea5c2aa1 | 2017-09-13 14:18:59 -0700 | [diff] [blame] | 9294 | cds_disable(hdd_ctx->hdd_psoc); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 9295 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9296 | out: |
| 9297 | return -EINVAL; |
| 9298 | } |
| 9299 | |
| 9300 | /** |
| 9301 | * hdd_deconfigure_cds() -De-Configure cds |
| 9302 | * @hdd_ctx: HDD context |
| 9303 | * |
| 9304 | * Deconfigure Cds modules before WLAN firmware is down. |
| 9305 | * |
| 9306 | * Return: 0 on success and errno on failure. |
| 9307 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9308 | static int hdd_deconfigure_cds(struct hdd_context *hdd_ctx) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9309 | { |
| 9310 | QDF_STATUS qdf_status; |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 9311 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9312 | |
| 9313 | ENTER(); |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 9314 | |
| 9315 | /* De-init features */ |
| 9316 | hdd_features_deinit(hdd_ctx); |
| 9317 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9318 | /* De-register the SME callbacks */ |
| 9319 | hdd_deregister_cb(hdd_ctx); |
| 9320 | |
Jeff Johnson | ea5c2aa1 | 2017-09-13 14:18:59 -0700 | [diff] [blame] | 9321 | qdf_status = cds_disable(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9322 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 9323 | hdd_err("Failed to Disable the CDS Modules! :%d", |
| 9324 | qdf_status); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 9325 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9326 | } |
| 9327 | |
Sravan Kumar Kairam | 7112171 | 2017-04-15 00:34:42 +0530 | [diff] [blame] | 9328 | if (hdd_ipa_uc_ol_deinit(hdd_ctx)) { |
| 9329 | hdd_err("Failed to disconnect pipes"); |
| 9330 | ret = -EINVAL; |
| 9331 | } |
| 9332 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9333 | EXIT(); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 9334 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9335 | } |
| 9336 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 9337 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
| 9338 | static void hdd_deregister_policy_manager_callback( |
| 9339 | struct wlan_objmgr_psoc *psoc) |
| 9340 | { |
| 9341 | if (QDF_STATUS_SUCCESS != |
| 9342 | policy_mgr_deregister_hdd_cb(psoc)) { |
| 9343 | hdd_err("HDD callback deregister with policy manager failed"); |
| 9344 | } |
| 9345 | } |
| 9346 | #else |
| 9347 | static void hdd_deregister_policy_manager_callback( |
| 9348 | struct wlan_objmgr_psoc *psoc) |
| 9349 | { |
| 9350 | } |
| 9351 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9352 | |
| 9353 | /** |
| 9354 | * hdd_wlan_stop_modules - Single driver state machine for stoping modules |
| 9355 | * @hdd_ctx: HDD context |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 9356 | * @ftm_mode: ftm mode |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9357 | * |
| 9358 | * This function maintains the driver state machine it will be invoked from |
| 9359 | * exit, shutdown and con_mode change handler. Depending on the driver state |
| 9360 | * shall perform the stopping/closing of the modules. |
| 9361 | * |
| 9362 | * Return: 0 for success; non-zero for failure |
| 9363 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9364 | int hdd_wlan_stop_modules(struct hdd_context *hdd_ctx, bool ftm_mode) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9365 | { |
| 9366 | void *hif_ctx; |
| 9367 | qdf_device_t qdf_ctx; |
| 9368 | QDF_STATUS qdf_status; |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 9369 | int ret = 0; |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 9370 | bool is_idle_stop = !cds_is_driver_unloading() && |
| 9371 | !cds_is_driver_recovering(); |
| 9372 | int active_threads; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9373 | |
| 9374 | ENTER(); |
| 9375 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 9376 | hdd_deregister_policy_manager_callback(hdd_ctx->hdd_psoc); |
| 9377 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9378 | qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 9379 | if (!qdf_ctx) { |
| 9380 | hdd_err("QDF device context NULL"); |
| 9381 | return -EINVAL; |
| 9382 | } |
| 9383 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 9384 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 9385 | hdd_ctx->stop_modules_in_progress = true; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9386 | |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 9387 | active_threads = cds_return_external_threads_count(); |
| 9388 | if (active_threads > 0 || hdd_ctx->isWiphySuspended) { |
Rajeev Kumar | 86177c2 | 2017-03-16 19:44:39 -0700 | [diff] [blame] | 9389 | hdd_warn("External threads %d wiphy suspend %d", |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 9390 | active_threads, hdd_ctx->isWiphySuspended); |
| 9391 | |
| 9392 | cds_print_external_threads(); |
| 9393 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 9394 | if (is_idle_stop && !ftm_mode) { |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 9395 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 9396 | qdf_mc_timer_start(&hdd_ctx->iface_change_timer, |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 9397 | hdd_ctx->config->iface_change_wait_time); |
| 9398 | hdd_ctx->stop_modules_in_progress = false; |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 9399 | return 0; |
| 9400 | } |
Rajeev Kumar | 86177c2 | 2017-03-16 19:44:39 -0700 | [diff] [blame] | 9401 | } |
| 9402 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9403 | hdd_info("Present Driver Status: %d", hdd_ctx->driver_status); |
| 9404 | |
| 9405 | switch (hdd_ctx->driver_status) { |
| 9406 | case DRIVER_MODULES_UNINITIALIZED: |
| 9407 | hdd_info("Modules not initialized just return"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 9408 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9409 | case DRIVER_MODULES_CLOSED: |
| 9410 | hdd_info("Modules already closed"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 9411 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9412 | case DRIVER_MODULES_ENABLED: |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 9413 | hdd_disable_power_management(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9414 | if (hdd_deconfigure_cds(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9415 | hdd_err("Failed to de-configure CDS"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9416 | QDF_ASSERT(0); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 9417 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9418 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9419 | hdd_debug("successfully Disabled the CDS modules!"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9420 | hdd_ctx->driver_status = DRIVER_MODULES_OPENED; |
| 9421 | break; |
| 9422 | case DRIVER_MODULES_OPENED: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9423 | hdd_debug("Closing CDS modules!"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9424 | break; |
| 9425 | default: |
| 9426 | hdd_err("Trying to stop wlan in a wrong state: %d", |
| 9427 | hdd_ctx->driver_status); |
| 9428 | QDF_ASSERT(0); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 9429 | ret = -EINVAL; |
| 9430 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9431 | } |
| 9432 | |
Rajeev Kumar | be02124 | 2017-02-16 16:12:23 -0800 | [diff] [blame] | 9433 | qdf_status = cds_post_disable(); |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 9434 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 9435 | hdd_err("Failed to process post CDS disable Modules! :%d", |
| 9436 | qdf_status); |
| 9437 | ret = -EINVAL; |
| 9438 | QDF_ASSERT(0); |
| 9439 | } |
Jeff Johnson | e4b1459 | 2017-09-13 14:23:33 -0700 | [diff] [blame] | 9440 | qdf_status = cds_close(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9441 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9442 | hdd_warn("Failed to stop CDS: %d", qdf_status); |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 9443 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9444 | QDF_ASSERT(0); |
| 9445 | } |
Krunal Soni | d32c6bc | 2016-10-18 18:00:21 -0700 | [diff] [blame] | 9446 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9447 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 9448 | if (!hif_ctx) { |
| 9449 | hdd_err("Hif context is Null"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 9450 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9451 | } |
| 9452 | |
Sravan Kumar Kairam | 6457495 | 2017-06-22 11:48:18 +0530 | [diff] [blame] | 9453 | hdd_runtime_suspend_context_deinit(hdd_ctx); |
| 9454 | |
Arunk Khandavalli | 4b40433 | 2017-09-26 12:46:00 +0530 | [diff] [blame] | 9455 | if (hdd_ctx->target_hw_name) { |
| 9456 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 9457 | hdd_ctx->target_hw_name = NULL; |
| 9458 | } |
| 9459 | |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 9460 | hdd_hif_close(hdd_ctx, hif_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9461 | |
| 9462 | ol_cds_free(); |
| 9463 | |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 9464 | if (is_idle_stop) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9465 | ret = pld_power_off(qdf_ctx->dev); |
| 9466 | if (ret) |
| 9467 | hdd_err("CNSS power down failed put device into Low power mode:%d", |
| 9468 | ret); |
| 9469 | } |
| 9470 | hdd_ctx->driver_status = DRIVER_MODULES_CLOSED; |
Sandeep Puligilla | 1cf6ebe | 2017-04-04 14:40:27 -0700 | [diff] [blame] | 9471 | /* |
| 9472 | * Reset total mac phy during module stop such that during |
| 9473 | * next module start same psoc is used to populate new service |
| 9474 | * ready data |
| 9475 | */ |
| 9476 | hdd_ctx->hdd_psoc->total_mac_phy = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9477 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 9478 | done: |
| 9479 | hdd_ctx->stop_modules_in_progress = false; |
| 9480 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9481 | EXIT(); |
| 9482 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 9483 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9484 | |
| 9485 | } |
| 9486 | |
| 9487 | /** |
| 9488 | * hdd_iface_change_callback() - Function invoked when stop modules expires |
| 9489 | * @priv: pointer to hdd context |
| 9490 | * |
| 9491 | * This function is invoked when the timer waiting for the interface change |
| 9492 | * expires, it shall cut-down the power to wlan and stop all the modules. |
| 9493 | * |
| 9494 | * Return: void |
| 9495 | */ |
| 9496 | static void hdd_iface_change_callback(void *priv) |
| 9497 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9498 | struct hdd_context *hdd_ctx = (struct hdd_context *) priv; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9499 | int ret; |
| 9500 | int status = wlan_hdd_validate_context(hdd_ctx); |
| 9501 | |
| 9502 | if (status) |
| 9503 | return; |
| 9504 | |
| 9505 | ENTER(); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9506 | hdd_debug("Interface change timer expired close the modules!"); |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 9507 | ret = hdd_wlan_stop_modules(hdd_ctx, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9508 | if (ret) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9509 | hdd_err("Failed to stop modules"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9510 | EXIT(); |
| 9511 | } |
| 9512 | |
| 9513 | /** |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 9514 | * hdd_state_info_dump() - prints state information of hdd layer |
| 9515 | * @buf: buffer pointer |
| 9516 | * @size: size of buffer to be filled |
| 9517 | * |
| 9518 | * This function is used to dump state information of hdd layer |
| 9519 | * |
| 9520 | * Return: None |
| 9521 | */ |
| 9522 | static void hdd_state_info_dump(char **buf_ptr, uint16_t *size) |
| 9523 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9524 | struct hdd_context *hdd_ctx; |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 9525 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
| 9526 | QDF_STATUS status; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 9527 | struct hdd_station_ctx *hdd_sta_ctx; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9528 | struct hdd_adapter *adapter; |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 9529 | uint16_t len = 0; |
| 9530 | char *buf = *buf_ptr; |
| 9531 | |
| 9532 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 9533 | if (!hdd_ctx) { |
| 9534 | hdd_err("Failed to get hdd context "); |
| 9535 | return; |
| 9536 | } |
| 9537 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9538 | hdd_debug("size of buffer: %d", *size); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 9539 | |
| 9540 | len += scnprintf(buf + len, *size - len, |
| 9541 | "\n isWiphySuspended %d", hdd_ctx->isWiphySuspended); |
| 9542 | len += scnprintf(buf + len, *size - len, |
Rajeev Kumar | eada0d0 | 2016-12-08 17:44:17 -0800 | [diff] [blame] | 9543 | "\n is_scheduler_suspended %d", |
| 9544 | hdd_ctx->is_scheduler_suspended); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 9545 | |
| 9546 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
| 9547 | |
| 9548 | while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) { |
| 9549 | adapter = adapter_node->pAdapter; |
| 9550 | if (adapter->dev) |
| 9551 | len += scnprintf(buf + len, *size - len, |
| 9552 | "\n device name: %s", adapter->dev->name); |
wadesong | 42968e9 | 2017-06-08 14:11:21 +0800 | [diff] [blame] | 9553 | len += scnprintf(buf + len, *size - len, |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 9554 | "\n device_mode: %d", adapter->device_mode); |
| 9555 | switch (adapter->device_mode) { |
| 9556 | case QDF_STA_MODE: |
| 9557 | case QDF_P2P_CLIENT_MODE: |
| 9558 | hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 9559 | len += scnprintf(buf + len, *size - len, |
| 9560 | "\n connState: %d", |
| 9561 | hdd_sta_ctx->conn_info.connState); |
| 9562 | break; |
| 9563 | |
| 9564 | default: |
| 9565 | break; |
| 9566 | } |
| 9567 | status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next); |
| 9568 | adapter_node = next; |
| 9569 | } |
| 9570 | |
| 9571 | *size -= len; |
| 9572 | *buf_ptr += len; |
| 9573 | } |
| 9574 | |
| 9575 | /** |
| 9576 | * hdd_register_debug_callback() - registration function for hdd layer |
| 9577 | * to print hdd state information |
| 9578 | * |
| 9579 | * Return: None |
| 9580 | */ |
| 9581 | static void hdd_register_debug_callback(void) |
| 9582 | { |
| 9583 | qdf_register_debug_callback(QDF_MODULE_ID_HDD, &hdd_state_info_dump); |
| 9584 | } |
| 9585 | |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 9586 | /* |
| 9587 | * wlan_init_bug_report_lock() - Initialize bug report lock |
| 9588 | * |
| 9589 | * This function is used to create bug report lock |
| 9590 | * |
| 9591 | * Return: None |
| 9592 | */ |
| 9593 | static void wlan_init_bug_report_lock(void) |
| 9594 | { |
| 9595 | p_cds_contextType p_cds_context; |
| 9596 | |
| 9597 | p_cds_context = cds_get_global_context(); |
| 9598 | if (!p_cds_context) { |
| 9599 | hdd_err("cds context is NULL"); |
| 9600 | return; |
| 9601 | } |
| 9602 | |
| 9603 | qdf_spinlock_create(&p_cds_context->bug_report_lock); |
| 9604 | } |
| 9605 | |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 9606 | void hdd_dp_trace_init(struct hdd_config *config) |
| 9607 | { |
| 9608 | |
| 9609 | bool live_mode = DP_TRACE_CONFIG_DEFAULT_LIVE_MODE; |
| 9610 | uint8_t thresh = DP_TRACE_CONFIG_DEFAULT_THRESH; |
| 9611 | uint16_t thresh_time_limit = DP_TRACE_CONFIG_DEFAULT_THRESH_TIME_LIMIT; |
| 9612 | uint8_t verbosity = DP_TRACE_CONFIG_DEFAULT_VERBOSTY; |
| 9613 | uint8_t proto_bitmap = DP_TRACE_CONFIG_DEFAULT_BITMAP; |
| 9614 | uint8_t config_params[DP_TRACE_CONFIG_NUM_PARAMS]; |
| 9615 | uint8_t num_entries = 0; |
| 9616 | |
| 9617 | hdd_string_to_u8_array(config->dp_trace_config, config_params, |
| 9618 | &num_entries, sizeof(config_params)); |
| 9619 | |
| 9620 | /* calculating, num bw timer intervals in a second (1000ms) */ |
| 9621 | if (config->busBandwidthComputeInterval) |
| 9622 | thresh_time_limit = |
| 9623 | (1000 / config->busBandwidthComputeInterval); |
| 9624 | else |
| 9625 | hdd_err("busBandwidthComputeInterval is 0, using defaults"); |
| 9626 | |
| 9627 | switch (num_entries) { |
| 9628 | case 4: |
| 9629 | proto_bitmap = config_params[3]; |
| 9630 | case 3: |
| 9631 | verbosity = config_params[2]; |
| 9632 | case 2: |
| 9633 | thresh = config_params[1]; |
| 9634 | case 1: |
| 9635 | live_mode = config_params[0]; |
| 9636 | default: |
| 9637 | hdd_info("live_mode %u thresh %u time_limit %u verbosity %u bitmap 0x%x", |
| 9638 | live_mode, thresh, thresh_time_limit, |
| 9639 | verbosity, proto_bitmap); |
| 9640 | }; |
| 9641 | |
| 9642 | qdf_dp_trace_init(live_mode, thresh, thresh_time_limit, |
| 9643 | verbosity, proto_bitmap); |
| 9644 | |
| 9645 | } |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 9646 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9647 | * hdd_wlan_startup() - HDD init function |
| 9648 | * @dev: Pointer to the underlying device |
| 9649 | * |
| 9650 | * This is the driver startup code executed once a WLAN device has been detected |
| 9651 | * |
| 9652 | * Return: 0 for success, < 0 for failure |
| 9653 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9654 | int hdd_wlan_startup(struct device *dev) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9655 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9656 | QDF_STATUS status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9657 | struct hdd_context *hdd_ctx; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9658 | int ret; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9659 | bool rtnl_held; |
Manjeet Singh | e7ecb7c | 2016-09-03 12:34:53 +0530 | [diff] [blame] | 9660 | int set_value; |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9661 | uint32_t num_abg_tx_chains = 0; |
| 9662 | uint32_t num_11b_tx_chains = 0; |
| 9663 | uint32_t num_11ag_tx_chains = 0; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9664 | |
| 9665 | ENTER(); |
| 9666 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9667 | hdd_ctx = hdd_context_create(dev); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9668 | |
| 9669 | if (IS_ERR(hdd_ctx)) |
| 9670 | return PTR_ERR(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9671 | |
Abhishek Singh | e9068f1 | 2017-03-31 14:14:52 +0530 | [diff] [blame] | 9672 | ret = hdd_objmgr_create_and_store_psoc(hdd_ctx, |
| 9673 | DEFAULT_PSOC_ID); |
| 9674 | if (ret) { |
| 9675 | hdd_err("Psoc creation fails!"); |
| 9676 | QDF_BUG(0); |
| 9677 | goto err_hdd_free_context; |
| 9678 | } |
| 9679 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9680 | qdf_mc_timer_init(&hdd_ctx->iface_change_timer, QDF_TIMER_TYPE_SW, |
| 9681 | hdd_iface_change_callback, (void *)hdd_ctx); |
| 9682 | |
| 9683 | mutex_init(&hdd_ctx->iface_change_lock); |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 9684 | #ifdef FEATURE_WLAN_CH_AVOID |
| 9685 | mutex_init(&hdd_ctx->avoid_freq_lock); |
| 9686 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9687 | |
Jeff Johnson | ce0032c | 2017-01-20 07:18:27 -0800 | [diff] [blame] | 9688 | hdd_request_manager_init(); |
Jeff Johnson | a7e5eed | 2016-09-28 15:19:13 -0700 | [diff] [blame] | 9689 | hdd_green_ap_init(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9690 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9691 | ret = hdd_wlan_start_modules(hdd_ctx, NULL, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9692 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9693 | hdd_err("Failed to start modules: %d", ret); |
Houston Hoffman | b18dc6e | 2017-08-11 17:43:07 -0700 | [diff] [blame] | 9694 | goto err_hdd_free_psoc; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9695 | } |
| 9696 | |
Yingying Tang | 80e15f3 | 2016-09-27 18:23:01 +0800 | [diff] [blame] | 9697 | wlan_hdd_update_wiphy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9698 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 9699 | hdd_ctx->hHal = cds_get_context(QDF_MODULE_ID_SME); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9700 | |
| 9701 | if (NULL == hdd_ctx->hHal) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9702 | hdd_err("HAL context is null"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9703 | goto err_stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9704 | } |
| 9705 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9706 | ret = hdd_wiphy_init(hdd_ctx); |
| 9707 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9708 | hdd_err("Failed to initialize wiphy: %d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9709 | goto err_stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9710 | } |
| 9711 | |
Nirav Shah | cc1f1ae | 2016-04-26 11:41:29 +0530 | [diff] [blame] | 9712 | if (hdd_ctx->config->enable_dp_trace) |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 9713 | hdd_dp_trace_init(hdd_ctx->config); |
Nirav Shah | cc1f1ae | 2016-04-26 11:41:29 +0530 | [diff] [blame] | 9714 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9715 | if (hdd_ipa_init(hdd_ctx) == QDF_STATUS_E_FAILURE) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9716 | goto err_wiphy_unregister; |
| 9717 | |
Kapil Gupta | 4f0c0c1 | 2017-02-07 15:21:15 +0530 | [diff] [blame] | 9718 | wlan_hdd_init_chan_info(hdd_ctx); |
| 9719 | |
Yuanyuan Liu | c98370e | 2016-10-13 11:22:13 -0700 | [diff] [blame] | 9720 | hdd_initialize_mac_address(hdd_ctx); |
Prashanth Bhatta | 75fa9a1 | 2016-01-11 18:30:08 -0800 | [diff] [blame] | 9721 | |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 9722 | ret = hdd_register_notifiers(hdd_ctx); |
| 9723 | if (ret) |
| 9724 | goto err_ipa_cleanup; |
| 9725 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9726 | rtnl_held = hdd_hold_rtnl_lock(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9727 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9728 | ret = hdd_open_interfaces(hdd_ctx, rtnl_held); |
| 9729 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9730 | hdd_err("Failed to open interfaces: %d", ret); |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 9731 | goto err_release_rtnl_lock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9732 | } |
| 9733 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9734 | hdd_release_rtnl_lock(); |
| 9735 | rtnl_held = false; |
| 9736 | |
Yingying Tang | 3ba3dbc | 2016-09-27 16:36:58 +0800 | [diff] [blame] | 9737 | wlan_hdd_update_11n_mode(hdd_ctx->config); |
| 9738 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9739 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 9740 | status = qdf_mc_timer_init(&hdd_ctx->skip_acs_scan_timer, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 9741 | QDF_TIMER_TYPE_SW, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9742 | hdd_skip_acs_scan_timer_handler, |
| 9743 | (void *)hdd_ctx); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9744 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 9745 | hdd_err("Failed to init ACS Skip timer"); |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 9746 | qdf_spinlock_create(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9747 | #endif |
| 9748 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 9749 | hdd_bus_bandwidth_init(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9750 | |
Jeff Johnson | 9afc501 | 2016-09-23 13:56:27 -0700 | [diff] [blame] | 9751 | hdd_lpass_notify_start(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9752 | |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 9753 | if (hdd_ctx->rps) |
| 9754 | hdd_set_rps_cpu_mask(hdd_ctx); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9755 | |
Manishekar Chandrasekaran | f7a1dad | 2016-06-23 06:43:47 +0530 | [diff] [blame] | 9756 | status = wlansap_global_init(); |
| 9757 | if (QDF_IS_STATUS_ERROR(status)) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9758 | goto err_close_adapters; |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 9759 | |
Komal Seelam | 8634b77 | 2016-09-29 12:12:24 +0530 | [diff] [blame] | 9760 | hdd_runtime_suspend_context_init(hdd_ctx); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9761 | memdump_init(); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 9762 | hdd_driver_memdump_init(); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 9763 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9764 | if (hdd_ctx->config->fIsImpsEnabled) |
| 9765 | hdd_set_idle_ps_config(hdd_ctx, true); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 9766 | |
Manjeet Singh | e7ecb7c | 2016-09-03 12:34:53 +0530 | [diff] [blame] | 9767 | if (hdd_ctx->config->sifs_burst_duration) { |
| 9768 | set_value = (SIFS_BURST_DUR_MULTIPLIER) * |
| 9769 | hdd_ctx->config->sifs_burst_duration; |
| 9770 | |
| 9771 | if ((set_value > 0) && (set_value <= SIFS_BURST_DUR_MAX)) |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9772 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_BURST_DUR, |
Manjeet Singh | e7ecb7c | 2016-09-03 12:34:53 +0530 | [diff] [blame] | 9773 | set_value, PDEV_CMD); |
| 9774 | } |
| 9775 | |
Paul Zhang | 42dade0 | 2017-05-12 19:20:37 +0800 | [diff] [blame] | 9776 | if (hdd_ctx->config->is_force_1x1) |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9777 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_SET_IOT_PATTERN, |
Paul Zhang | 42dade0 | 2017-05-12 19:20:37 +0800 | [diff] [blame] | 9778 | 1, PDEV_CMD); |
Ravi Kumar Bokka | 05c14e5 | 2017-03-27 14:48:23 +0530 | [diff] [blame] | 9779 | /* set chip power save failure detected callback */ |
| 9780 | sme_set_chip_pwr_save_fail_cb(hdd_ctx->hHal, |
| 9781 | hdd_chip_pwr_save_fail_detected_cb); |
Paul Zhang | 42dade0 | 2017-05-12 19:20:37 +0800 | [diff] [blame] | 9782 | |
lifeng | 959a04c | 2017-05-10 14:21:28 +0800 | [diff] [blame] | 9783 | if (hdd_ctx->config->max_mpdus_inampdu) { |
| 9784 | set_value = hdd_ctx->config->max_mpdus_inampdu; |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9785 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_MAX_MPDUS_IN_AMPDU, |
lifeng | 959a04c | 2017-05-10 14:21:28 +0800 | [diff] [blame] | 9786 | set_value, PDEV_CMD); |
| 9787 | } |
| 9788 | |
| 9789 | if (hdd_ctx->config->enable_rts_sifsbursting) { |
| 9790 | set_value = hdd_ctx->config->enable_rts_sifsbursting; |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9791 | sme_cli_set_command(0, |
lifeng | 959a04c | 2017-05-10 14:21:28 +0800 | [diff] [blame] | 9792 | (int)WMI_PDEV_PARAM_ENABLE_RTS_SIFS_BURSTING, |
| 9793 | set_value, PDEV_CMD); |
| 9794 | } |
| 9795 | |
Will Huang | 496b36c | 2017-07-11 16:38:50 +0800 | [diff] [blame] | 9796 | if (hdd_ctx->config->sap_get_peer_info) { |
| 9797 | set_value = hdd_ctx->config->sap_get_peer_info; |
| 9798 | sme_cli_set_command(0, |
| 9799 | (int)WMI_PDEV_PARAM_PEER_STATS_INFO_ENABLE, |
| 9800 | set_value, PDEV_CMD); |
| 9801 | } |
| 9802 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9803 | num_11b_tx_chains = hdd_ctx->config->num_11b_tx_chains; |
| 9804 | num_11ag_tx_chains = hdd_ctx->config->num_11ag_tx_chains; |
| 9805 | if (!hdd_ctx->config->enable2x2) { |
| 9806 | if (num_11b_tx_chains > 1) |
| 9807 | num_11b_tx_chains = 1; |
| 9808 | if (num_11ag_tx_chains > 1) |
| 9809 | num_11ag_tx_chains = 1; |
| 9810 | } |
| 9811 | WMI_PDEV_PARAM_SET_11B_TX_CHAIN_NUM(num_abg_tx_chains, |
| 9812 | num_11b_tx_chains); |
| 9813 | WMI_PDEV_PARAM_SET_11AG_TX_CHAIN_NUM(num_abg_tx_chains, |
| 9814 | num_11ag_tx_chains); |
| 9815 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_ABG_MODE_TX_CHAIN_NUM, |
| 9816 | num_abg_tx_chains, PDEV_CMD); |
| 9817 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 9818 | if (QDF_GLOBAL_FTM_MODE != hdd_get_conparam()) |
| 9819 | qdf_mc_timer_start(&hdd_ctx->iface_change_timer, |
Hanumanth Reddy Pothula | 42e714a | 2016-12-21 19:33:57 +0530 | [diff] [blame] | 9820 | hdd_ctx->config->iface_change_wait_time); |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 9821 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 9822 | hdd_start_complete(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9823 | goto success; |
| 9824 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9825 | err_close_adapters: |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 9826 | hdd_close_all_adapters(hdd_ctx, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9827 | |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 9828 | err_release_rtnl_lock: |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9829 | if (rtnl_held) |
| 9830 | hdd_release_rtnl_lock(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9831 | |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 9832 | err_ipa_cleanup: |
Anurag Chouhan | ce6a405 | 2016-09-14 18:20:42 +0530 | [diff] [blame] | 9833 | hdd_ipa_cleanup(hdd_ctx); |
Yun Park | 6a46ad8 | 2016-01-04 16:48:19 -0800 | [diff] [blame] | 9834 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9835 | err_wiphy_unregister: |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9836 | wiphy_unregister(hdd_ctx->wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9837 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9838 | err_stop_modules: |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 9839 | hdd_wlan_stop_modules(hdd_ctx, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9840 | |
Houston Hoffman | b18dc6e | 2017-08-11 17:43:07 -0700 | [diff] [blame] | 9841 | err_hdd_free_psoc: |
Arunk Khandavalli | fbc1ef0 | 2017-03-14 21:25:05 +0530 | [diff] [blame] | 9842 | if (DRIVER_MODULES_CLOSED == hdd_ctx->driver_status) { |
Jeff Johnson | 7d56227 | 2017-09-13 15:12:54 -0700 | [diff] [blame] | 9843 | status = cds_sched_close(); |
Arunk Khandavalli | fbc1ef0 | 2017-03-14 21:25:05 +0530 | [diff] [blame] | 9844 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9845 | hdd_err("Failed to close CDS Scheduler"); |
| 9846 | QDF_ASSERT(QDF_IS_STATUS_SUCCESS(status)); |
| 9847 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9848 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9849 | |
Houston Hoffman | 47a4a05 | 2016-11-14 23:22:44 -0800 | [diff] [blame] | 9850 | hdd_green_ap_deinit(hdd_ctx); |
Jeff Johnson | ce0032c | 2017-01-20 07:18:27 -0800 | [diff] [blame] | 9851 | hdd_request_manager_deinit(); |
Ryan Hsu | cfef0ae | 2016-04-28 10:20:46 -0700 | [diff] [blame] | 9852 | hdd_exit_netlink_services(hdd_ctx); |
| 9853 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9854 | cds_deinit_ini_config(); |
Dustin Brown | 2091246 | 2017-06-07 13:48:25 -0700 | [diff] [blame] | 9855 | |
Dustin Brown | 2091246 | 2017-06-07 13:48:25 -0700 | [diff] [blame] | 9856 | hdd_objmgr_release_and_destroy_psoc(hdd_ctx); |
| 9857 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9858 | err_hdd_free_context: |
Nachiket Kukade | 8003d25 | 2017-03-30 15:55:58 +0530 | [diff] [blame] | 9859 | if (cds_is_fw_down()) |
| 9860 | hdd_err("Not setting the complete event as fw is down"); |
| 9861 | else |
| 9862 | hdd_start_complete(ret); |
| 9863 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9864 | qdf_mc_timer_destroy(&hdd_ctx->iface_change_timer); |
| 9865 | mutex_destroy(&hdd_ctx->iface_change_lock); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9866 | hdd_context_destroy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9867 | return -EIO; |
| 9868 | |
| 9869 | success: |
| 9870 | EXIT(); |
| 9871 | return 0; |
| 9872 | } |
| 9873 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9874 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9875 | * hdd_wlan_update_target_info() - update target type info |
| 9876 | * @hdd_ctx: HDD context |
| 9877 | * @context: hif context |
| 9878 | * |
| 9879 | * Update target info received from firmware in hdd context |
| 9880 | * Return:None |
| 9881 | */ |
| 9882 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9883 | void hdd_wlan_update_target_info(struct hdd_context *hdd_ctx, void *context) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9884 | { |
| 9885 | struct hif_target_info *tgt_info = hif_get_target_info_handle(context); |
| 9886 | |
| 9887 | if (!tgt_info) { |
| 9888 | hdd_err("Target info is Null"); |
| 9889 | return; |
| 9890 | } |
| 9891 | |
| 9892 | hdd_ctx->target_type = tgt_info->target_type; |
| 9893 | } |
| 9894 | |
| 9895 | /** |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 9896 | * hdd_get_nud_stats_cb() - callback api to update the stats |
| 9897 | * received from the firmware |
| 9898 | * @data: pointer to adapter. |
| 9899 | * @rsp: pointer to data received from FW. |
| 9900 | * |
| 9901 | * This is called when wlan driver received response event for |
| 9902 | * get arp stats to firmware. |
| 9903 | * |
| 9904 | * Return: None |
| 9905 | */ |
| 9906 | static void hdd_get_nud_stats_cb(void *data, struct rsp_stats *rsp) |
| 9907 | { |
| 9908 | struct hdd_context *hdd_ctx = (struct hdd_context *)data; |
| 9909 | struct hdd_nud_stats_context *context; |
| 9910 | int status; |
| 9911 | struct hdd_adapter *adapter = NULL; |
| 9912 | |
| 9913 | ENTER(); |
| 9914 | |
| 9915 | if (!rsp) { |
| 9916 | hdd_err("data is null"); |
| 9917 | return; |
| 9918 | } |
| 9919 | |
| 9920 | status = wlan_hdd_validate_context(hdd_ctx); |
| 9921 | if (0 != status) |
| 9922 | return; |
| 9923 | |
| 9924 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, rsp->vdev_id); |
| 9925 | if ((NULL == adapter) || (WLAN_HDD_ADAPTER_MAGIC != adapter->magic)) { |
| 9926 | hdd_err("Invalid adapter or adapter has invalid magic"); |
| 9927 | return; |
| 9928 | } |
| 9929 | |
| 9930 | hdd_notice("rsp->arp_req_enqueue :%x", rsp->arp_req_enqueue); |
| 9931 | hdd_notice("rsp->arp_req_tx_success :%x", rsp->arp_req_tx_success); |
| 9932 | hdd_notice("rsp->arp_req_tx_failure :%x", rsp->arp_req_tx_failure); |
| 9933 | hdd_notice("rsp->arp_rsp_recvd :%x", rsp->arp_rsp_recvd); |
| 9934 | hdd_notice("rsp->out_of_order_arp_rsp_drop_cnt :%x", |
| 9935 | rsp->out_of_order_arp_rsp_drop_cnt); |
| 9936 | hdd_notice("rsp->dad_detected :%x", rsp->dad_detected); |
| 9937 | hdd_notice("rsp->connect_status :%x", rsp->connect_status); |
| 9938 | hdd_notice("rsp->ba_session_establishment_status :%x", |
| 9939 | rsp->ba_session_establishment_status); |
| 9940 | |
| 9941 | adapter->hdd_stats.hdd_arp_stats.tx_fw_cnt = rsp->arp_req_enqueue; |
| 9942 | adapter->hdd_stats.hdd_arp_stats.rx_fw_cnt = rsp->arp_rsp_recvd; |
| 9943 | adapter->hdd_stats.hdd_arp_stats.tx_ack_cnt = rsp->arp_req_tx_success; |
| 9944 | adapter->dad |= rsp->dad_detected; |
| 9945 | adapter->con_status = rsp->connect_status; |
| 9946 | |
| 9947 | spin_lock(&hdd_context_lock); |
| 9948 | context = &hdd_ctx->nud_stats_context; |
| 9949 | complete(&context->response_event); |
| 9950 | spin_unlock(&hdd_context_lock); |
| 9951 | |
| 9952 | EXIT(); |
| 9953 | |
| 9954 | return; |
| 9955 | } |
| 9956 | |
| 9957 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9958 | * hdd_register_cb - Register HDD callbacks. |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 9959 | * @hdd_ctx: HDD context |
| 9960 | * |
| 9961 | * Register the HDD callbacks to CDS/SME. |
| 9962 | * |
| 9963 | * Return: 0 for success or Error code for failure |
| 9964 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9965 | int hdd_register_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 9966 | { |
| 9967 | QDF_STATUS status; |
| 9968 | int ret = 0; |
| 9969 | |
| 9970 | ENTER(); |
| 9971 | |
| 9972 | sme_register11d_scan_done_callback(hdd_ctx->hHal, hdd_11d_scan_done); |
| 9973 | |
| 9974 | sme_register_oem_data_rsp_callback(hdd_ctx->hHal, |
| 9975 | hdd_send_oem_data_rsp_msg); |
| 9976 | |
| 9977 | status = sme_fw_mem_dump_register_cb(hdd_ctx->hHal, |
| 9978 | wlan_hdd_cfg80211_fw_mem_dump_cb); |
| 9979 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9980 | hdd_err("Failed to register memdump callback"); |
| 9981 | ret = -EINVAL; |
| 9982 | return ret; |
| 9983 | } |
Deepthi Gowri | d5a58fe | 2016-09-03 16:01:28 +0530 | [diff] [blame] | 9984 | sme_register_mgmt_frame_ind_callback(hdd_ctx->hHal, |
| 9985 | hdd_indicate_mgmt_frame); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 9986 | sme_set_tsfcb(hdd_ctx->hHal, hdd_get_tsf_cb, hdd_ctx); |
| 9987 | sme_nan_register_callback(hdd_ctx->hHal, |
| 9988 | wlan_hdd_cfg80211_nan_callback); |
| 9989 | sme_stats_ext_register_callback(hdd_ctx->hHal, |
| 9990 | wlan_hdd_cfg80211_stats_ext_callback); |
| 9991 | |
| 9992 | sme_ext_scan_register_callback(hdd_ctx->hHal, |
| 9993 | wlan_hdd_cfg80211_extscan_callback); |
lifeng | 6683166 | 2017-05-19 16:01:35 +0800 | [diff] [blame] | 9994 | sme_stats_ext2_register_callback(hdd_ctx->hHal, |
| 9995 | wlan_hdd_cfg80211_stats_ext2_callback); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 9996 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 9997 | sme_set_rssi_threshold_breached_cb(hdd_ctx->hHal, |
| 9998 | hdd_rssi_threshold_breached); |
| 9999 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10000 | sme_set_nud_debug_stats_cb(hdd_ctx->hHal, hdd_get_nud_stats_cb); |
| 10001 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10002 | sme_set_link_layer_stats_ind_cb(hdd_ctx->hHal, |
| 10003 | wlan_hdd_cfg80211_link_layer_stats_callback); |
| 10004 | |
Sreelakshmi Konamki | 88a2a41 | 2017-04-14 15:11:55 +0530 | [diff] [blame] | 10005 | sme_rso_cmd_status_cb(hdd_ctx->hHal, wlan_hdd_rso_cmd_status_cb); |
| 10006 | |
Zhang Qian | ca38fb1 | 2016-12-23 11:10:48 +0800 | [diff] [blame] | 10007 | sme_set_link_layer_ext_cb(hdd_ctx->hHal, |
| 10008 | wlan_hdd_cfg80211_link_layer_stats_ext_callback); |
| 10009 | |
Sreelakshmi Konamki | 58c7243 | 2016-11-09 17:06:44 +0530 | [diff] [blame] | 10010 | status = sme_set_lost_link_info_cb(hdd_ctx->hHal, |
| 10011 | hdd_lost_link_info_cb); |
| 10012 | /* print error and not block the startup process */ |
| 10013 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10014 | hdd_err("set lost link info callback failed"); |
| 10015 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10016 | wlan_hdd_dcc_register_for_dcc_stats_event(hdd_ctx); |
| 10017 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 10018 | sme_register_set_connection_info_cb(hdd_ctx->hHal, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 10019 | hdd_set_connection_in_progress, |
| 10020 | hdd_is_connection_in_progress); |
Padma, Santhosh Kumar | 16dacfb | 2017-03-21 19:05:40 +0530 | [diff] [blame] | 10021 | |
| 10022 | status = sme_congestion_register_callback(hdd_ctx->hHal, |
| 10023 | hdd_update_cca_info_cb); |
| 10024 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10025 | hdd_err("set congestion callback failed"); |
| 10026 | |
Vidyullatha Kanchanapally | be0ebb3 | 2017-03-23 14:36:21 +0530 | [diff] [blame] | 10027 | status = sme_set_bt_activity_info_cb(hdd_ctx->hHal, |
| 10028 | hdd_bt_activity_cb); |
| 10029 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10030 | hdd_err("set bt activity info callback failed"); |
| 10031 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10032 | EXIT(); |
| 10033 | |
| 10034 | return ret; |
| 10035 | } |
| 10036 | |
| 10037 | /** |
| 10038 | * hdd_deregister_cb() - De-Register HDD callbacks. |
| 10039 | * @hdd_ctx: HDD context |
| 10040 | * |
| 10041 | * De-Register the HDD callbacks to CDS/SME. |
| 10042 | * |
| 10043 | * Return: void |
| 10044 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10045 | void hdd_deregister_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10046 | { |
| 10047 | QDF_STATUS status; |
| 10048 | |
| 10049 | ENTER(); |
| 10050 | |
| 10051 | status = sme_deregister_for_dcc_stats_event(hdd_ctx->hHal); |
| 10052 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10053 | hdd_err("De-register of dcc stats callback failed: %d", |
| 10054 | status); |
| 10055 | |
| 10056 | sme_reset_link_layer_stats_ind_cb(hdd_ctx->hHal); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10057 | sme_reset_rssi_threshold_breached_cb(hdd_ctx->hHal); |
| 10058 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10059 | sme_stats_ext_register_callback(hdd_ctx->hHal, |
| 10060 | wlan_hdd_cfg80211_stats_ext_callback); |
| 10061 | |
| 10062 | sme_nan_deregister_callback(hdd_ctx->hHal); |
| 10063 | status = sme_reset_tsfcb(hdd_ctx->hHal); |
| 10064 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10065 | hdd_err("Failed to de-register tsfcb the callback:%d", |
| 10066 | status); |
| 10067 | status = sme_fw_mem_dump_unregister_cb(hdd_ctx->hHal); |
| 10068 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10069 | hdd_err("Failed to de-register the fw mem dump callback: %d", |
| 10070 | status); |
| 10071 | |
| 10072 | sme_deregister_oem_data_rsp_callback(hdd_ctx->hHal); |
| 10073 | sme_deregister11d_scan_done_callback(hdd_ctx->hHal); |
| 10074 | |
| 10075 | EXIT(); |
| 10076 | } |
| 10077 | |
| 10078 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10079 | * hdd_softap_sta_deauth() - handle deauth req from HDD |
| 10080 | * @adapter: Pointer to the HDD |
| 10081 | * @enable: bool value |
| 10082 | * |
| 10083 | * This to take counter measure to handle deauth req from HDD |
| 10084 | * |
| 10085 | * Return: None |
| 10086 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10087 | QDF_STATUS hdd_softap_sta_deauth(struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10088 | struct tagCsrDelStaParams *pDelStaParams) |
| 10089 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10090 | QDF_STATUS qdf_status = QDF_STATUS_E_FAULT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10091 | |
| 10092 | ENTER(); |
| 10093 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10094 | /* Ignore request to deauth bcmc station */ |
| 10095 | if (pDelStaParams->peerMacAddr.bytes[0] & 0x1) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10096 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10097 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10098 | qdf_status = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10099 | wlansap_deauth_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 10100 | pDelStaParams); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10101 | |
| 10102 | EXIT(); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10103 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10104 | } |
| 10105 | |
| 10106 | /** |
| 10107 | * hdd_softap_sta_disassoc() - take counter measure to handle deauth req from HDD |
| 10108 | * @adapter: Pointer to the HDD |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 10109 | * @p_del_sta_params: pointer to station deletion parameters |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10110 | * |
| 10111 | * This to take counter measure to handle deauth req from HDD |
| 10112 | * |
| 10113 | * Return: None |
| 10114 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10115 | void hdd_softap_sta_disassoc(struct hdd_adapter *adapter, |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 10116 | struct tagCsrDelStaParams *pDelStaParams) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10117 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10118 | ENTER(); |
| 10119 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10120 | /* Ignore request to disassoc bcmc station */ |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 10121 | if (pDelStaParams->peerMacAddr.bytes[0] & 0x1) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10122 | return; |
| 10123 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10124 | wlansap_disassoc_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 10125 | pDelStaParams); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10126 | } |
| 10127 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10128 | /** |
| 10129 | * hdd_issta_p2p_clientconnected() - check if sta or p2p client is connected |
| 10130 | * @hdd_ctx: HDD Context |
| 10131 | * |
| 10132 | * API to find if there is any STA or P2P-Client is connected |
| 10133 | * |
| 10134 | * Return: true if connected; false otherwise |
| 10135 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10136 | QDF_STATUS hdd_issta_p2p_clientconnected(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10137 | { |
| 10138 | return sme_is_sta_p2p_client_connected(hdd_ctx->hHal); |
| 10139 | } |
| 10140 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10141 | /** |
| 10142 | * wlan_hdd_disable_roaming() - disable roaming on all STAs except the input one |
| 10143 | * @adapter: HDD adapter pointer |
| 10144 | * |
| 10145 | * This function loop through each adapter and disable roaming on each STA |
| 10146 | * device mode except the input adapter. |
| 10147 | * |
| 10148 | * Note: On the input adapter roaming is not enabled yet hence no need to |
| 10149 | * disable. |
| 10150 | * |
| 10151 | * Return: None |
| 10152 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10153 | void wlan_hdd_disable_roaming(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10154 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10155 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10156 | struct hdd_adapter *adapterIdx = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10157 | hdd_adapter_list_node_t *adapterNode = NULL; |
| 10158 | hdd_adapter_list_node_t *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10159 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10160 | |
| 10161 | if (hdd_ctx->config->isFastRoamIniFeatureEnabled && |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 10162 | hdd_ctx->config->isRoamOffloadScanEnabled && |
| 10163 | QDF_STA_MODE == adapter->device_mode && |
| 10164 | policy_mgr_is_sta_active_connection_exists( |
| 10165 | hdd_ctx->hdd_psoc)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10166 | hdd_debug("Connect received on STA sessionId(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10167 | adapter->sessionId); |
| 10168 | /* |
| 10169 | * Loop through adapter and disable roaming for each STA device |
| 10170 | * mode except the input adapter. |
| 10171 | */ |
| 10172 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 10173 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10174 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10175 | adapterIdx = adapterNode->pAdapter; |
| 10176 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 10177 | if (QDF_STA_MODE == adapterIdx->device_mode |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10178 | && adapter->sessionId != adapterIdx->sessionId) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10179 | hdd_debug("Disable Roaming on sessionId(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10180 | adapterIdx->sessionId); |
| 10181 | sme_stop_roaming(WLAN_HDD_GET_HAL_CTX |
| 10182 | (adapterIdx), |
| 10183 | adapterIdx->sessionId, 0); |
| 10184 | } |
| 10185 | |
| 10186 | status = hdd_get_next_adapter(hdd_ctx, |
| 10187 | adapterNode, |
| 10188 | &pNext); |
| 10189 | adapterNode = pNext; |
| 10190 | } |
| 10191 | } |
| 10192 | } |
| 10193 | |
| 10194 | /** |
| 10195 | * wlan_hdd_enable_roaming() - enable roaming on all STAs except the input one |
| 10196 | * @adapter: HDD adapter pointer |
| 10197 | * |
| 10198 | * This function loop through each adapter and enable roaming on each STA |
| 10199 | * device mode except the input adapter. |
| 10200 | * Note: On the input adapter no need to enable roaming because link got |
| 10201 | * disconnected on this. |
| 10202 | * |
| 10203 | * Return: None |
| 10204 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10205 | void wlan_hdd_enable_roaming(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10206 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10207 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10208 | struct hdd_adapter *adapterIdx = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10209 | hdd_adapter_list_node_t *adapterNode = NULL; |
| 10210 | hdd_adapter_list_node_t *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10211 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10212 | |
| 10213 | if (hdd_ctx->config->isFastRoamIniFeatureEnabled && |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 10214 | hdd_ctx->config->isRoamOffloadScanEnabled && |
| 10215 | QDF_STA_MODE == adapter->device_mode && |
| 10216 | policy_mgr_is_sta_active_connection_exists( |
| 10217 | hdd_ctx->hdd_psoc)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10218 | hdd_debug("Disconnect received on STA sessionId(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10219 | adapter->sessionId); |
| 10220 | /* |
| 10221 | * Loop through adapter and enable roaming for each STA device |
| 10222 | * mode except the input adapter. |
| 10223 | */ |
| 10224 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 10225 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10226 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10227 | adapterIdx = adapterNode->pAdapter; |
| 10228 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 10229 | if (QDF_STA_MODE == adapterIdx->device_mode |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10230 | && adapter->sessionId != adapterIdx->sessionId) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10231 | hdd_debug("Enabling Roaming on sessionId(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10232 | adapterIdx->sessionId); |
| 10233 | sme_start_roaming(WLAN_HDD_GET_HAL_CTX |
| 10234 | (adapterIdx), |
| 10235 | adapterIdx->sessionId, |
| 10236 | REASON_CONNECT); |
| 10237 | } |
| 10238 | |
| 10239 | status = hdd_get_next_adapter(hdd_ctx, |
| 10240 | adapterNode, |
| 10241 | &pNext); |
| 10242 | adapterNode = pNext; |
| 10243 | } |
| 10244 | } |
| 10245 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10246 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 10247 | /** |
| 10248 | * nl_srv_bcast_svc() - Wrapper function to send bcast msgs to SVC mcast group |
| 10249 | * @skb: sk buffer pointer |
| 10250 | * |
| 10251 | * Sends the bcast message to SVC multicast group with generic nl socket |
| 10252 | * if CNSS_GENL is enabled. Else, use the legacy netlink socket to send. |
| 10253 | * |
| 10254 | * Return: None |
| 10255 | */ |
| 10256 | static void nl_srv_bcast_svc(struct sk_buff *skb) |
| 10257 | { |
| 10258 | #ifdef CNSS_GENL |
| 10259 | nl_srv_bcast(skb, CLD80211_MCGRP_SVC_MSGS, WLAN_NL_MSG_SVC); |
| 10260 | #else |
| 10261 | nl_srv_bcast(skb); |
| 10262 | #endif |
| 10263 | } |
| 10264 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10265 | void wlan_hdd_send_svc_nlink_msg(int radio, int type, void *data, int len) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10266 | { |
| 10267 | struct sk_buff *skb; |
| 10268 | struct nlmsghdr *nlh; |
| 10269 | tAniMsgHdr *ani_hdr; |
| 10270 | void *nl_data = NULL; |
| 10271 | int flags = GFP_KERNEL; |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10272 | struct radio_index_tlv *radio_info; |
| 10273 | int tlv_len; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10274 | |
| 10275 | if (in_interrupt() || irqs_disabled() || in_atomic()) |
| 10276 | flags = GFP_ATOMIC; |
| 10277 | |
| 10278 | skb = alloc_skb(NLMSG_SPACE(WLAN_NL_MAX_PAYLOAD), flags); |
| 10279 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 10280 | if (skb == NULL) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10281 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10282 | |
| 10283 | nlh = (struct nlmsghdr *)skb->data; |
| 10284 | nlh->nlmsg_pid = 0; /* from kernel */ |
| 10285 | nlh->nlmsg_flags = 0; |
| 10286 | nlh->nlmsg_seq = 0; |
| 10287 | nlh->nlmsg_type = WLAN_NL_MSG_SVC; |
| 10288 | |
| 10289 | ani_hdr = NLMSG_DATA(nlh); |
| 10290 | ani_hdr->type = type; |
| 10291 | |
| 10292 | switch (type) { |
| 10293 | case WLAN_SVC_FW_CRASHED_IND: |
Komal Seelam | 78ff65a | 2016-08-18 15:25:24 +0530 | [diff] [blame] | 10294 | case WLAN_SVC_FW_SHUTDOWN_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10295 | case WLAN_SVC_LTE_COEX_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10296 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND: |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 10297 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10298 | ani_hdr->length = 0; |
| 10299 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr))); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10300 | break; |
| 10301 | case WLAN_SVC_WLAN_STATUS_IND: |
| 10302 | case WLAN_SVC_WLAN_VERSION_IND: |
| 10303 | case WLAN_SVC_DFS_CAC_START_IND: |
| 10304 | case WLAN_SVC_DFS_CAC_END_IND: |
| 10305 | case WLAN_SVC_DFS_RADAR_DETECT_IND: |
| 10306 | case WLAN_SVC_DFS_ALL_CHANNEL_UNAVAIL_IND: |
| 10307 | case WLAN_SVC_WLAN_TP_IND: |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 10308 | case WLAN_SVC_WLAN_TP_TX_IND: |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 10309 | case WLAN_SVC_RPS_ENABLE_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10310 | ani_hdr->length = len; |
| 10311 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr) + len)); |
| 10312 | nl_data = (char *)ani_hdr + sizeof(tAniMsgHdr); |
| 10313 | memcpy(nl_data, data, len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10314 | break; |
| 10315 | |
| 10316 | default: |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 10317 | hdd_err("WLAN SVC: Attempt to send unknown nlink message %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10318 | type); |
| 10319 | kfree_skb(skb); |
| 10320 | return; |
| 10321 | } |
| 10322 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10323 | /* |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 10324 | * Add radio index at the end of the svc event in TLV format |
| 10325 | * to maintain the backward compatibility with userspace |
| 10326 | * applications. |
| 10327 | */ |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10328 | |
| 10329 | tlv_len = 0; |
| 10330 | |
| 10331 | if ((sizeof(*ani_hdr) + len + sizeof(struct radio_index_tlv)) |
| 10332 | < WLAN_NL_MAX_PAYLOAD) { |
| 10333 | radio_info = (struct radio_index_tlv *)((char *) ani_hdr + |
| 10334 | sizeof(*ani_hdr) + len); |
| 10335 | radio_info->type = (unsigned short) WLAN_SVC_WLAN_RADIO_INDEX; |
| 10336 | radio_info->length = (unsigned short) sizeof(radio_info->radio); |
| 10337 | radio_info->radio = radio; |
| 10338 | tlv_len = sizeof(*radio_info); |
Srinivas Girigowda | c06543c | 2017-03-09 15:10:03 -0800 | [diff] [blame] | 10339 | QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG, |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10340 | "Added radio index tlv - radio index %d", |
| 10341 | radio_info->radio); |
| 10342 | } |
| 10343 | |
| 10344 | nlh->nlmsg_len += tlv_len; |
| 10345 | skb_put(skb, NLMSG_SPACE(sizeof(tAniMsgHdr) + len + tlv_len)); |
| 10346 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 10347 | nl_srv_bcast_svc(skb); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10348 | } |
| 10349 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10350 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 10351 | void wlan_hdd_auto_shutdown_cb(void) |
| 10352 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10353 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10354 | |
| 10355 | if (!hdd_ctx) |
| 10356 | return; |
| 10357 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10358 | hdd_debug("Wlan Idle. Sending Shutdown event.."); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10359 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 10360 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10361 | } |
| 10362 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10363 | void wlan_hdd_auto_shutdown_enable(struct hdd_context *hdd_ctx, bool enable) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10364 | { |
| 10365 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10366 | QDF_STATUS status; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10367 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10368 | bool ap_connected = false, sta_connected = false; |
| 10369 | tHalHandle hal_handle; |
| 10370 | |
| 10371 | hal_handle = hdd_ctx->hHal; |
| 10372 | if (hal_handle == NULL) |
| 10373 | return; |
| 10374 | |
| 10375 | if (hdd_ctx->config->WlanAutoShutdown == 0) |
| 10376 | return; |
| 10377 | |
| 10378 | if (enable == false) { |
| 10379 | if (sme_set_auto_shutdown_timer(hal_handle, 0) != |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10380 | QDF_STATUS_SUCCESS) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 10381 | hdd_err("Failed to stop wlan auto shutdown timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10382 | } |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10383 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 10384 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10385 | return; |
| 10386 | } |
| 10387 | |
| 10388 | /* To enable shutdown timer check conncurrency */ |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 10389 | if (policy_mgr_concurrent_open_sessions_running( |
| 10390 | hdd_ctx->hdd_psoc)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10391 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 10392 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10393 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10394 | adapter = adapterNode->pAdapter; |
| 10395 | if (adapter |
| 10396 | && adapter->device_mode == |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 10397 | QDF_STA_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10398 | if (WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
| 10399 | conn_info.connState == |
| 10400 | eConnectionState_Associated) { |
| 10401 | sta_connected = true; |
| 10402 | break; |
| 10403 | } |
| 10404 | } |
| 10405 | if (adapter |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 10406 | && adapter->device_mode == QDF_SAP_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10407 | if (WLAN_HDD_GET_AP_CTX_PTR(adapter)-> |
| 10408 | bApActive == true) { |
| 10409 | ap_connected = true; |
| 10410 | break; |
| 10411 | } |
| 10412 | } |
| 10413 | status = hdd_get_next_adapter(hdd_ctx, |
| 10414 | adapterNode, |
| 10415 | &pNext); |
| 10416 | adapterNode = pNext; |
| 10417 | } |
| 10418 | } |
| 10419 | |
| 10420 | if (ap_connected == true || sta_connected == true) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10421 | hdd_debug("CC Session active. Shutdown timer not enabled"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10422 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10423 | } |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 10424 | |
| 10425 | if (sme_set_auto_shutdown_timer(hal_handle, |
| 10426 | hdd_ctx->config->WlanAutoShutdown) |
| 10427 | != QDF_STATUS_SUCCESS) |
| 10428 | hdd_err("Failed to start wlan auto shutdown timer"); |
| 10429 | else |
| 10430 | hdd_notice("Auto Shutdown timer for %d seconds enabled", |
| 10431 | hdd_ctx->config->WlanAutoShutdown); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10432 | } |
| 10433 | #endif |
| 10434 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10435 | struct hdd_adapter *hdd_get_con_sap_adapter(struct hdd_adapter *this_sap_adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10436 | bool check_start_bss) |
| 10437 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10438 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(this_sap_adapter); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10439 | struct hdd_adapter *adapter, *con_sap_adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10440 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10441 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
| 10442 | |
| 10443 | con_sap_adapter = NULL; |
| 10444 | |
| 10445 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10446 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10447 | adapter = adapterNode->pAdapter; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 10448 | if (adapter && ((adapter->device_mode == QDF_SAP_MODE) || |
| 10449 | (adapter->device_mode == QDF_P2P_GO_MODE)) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10450 | adapter != this_sap_adapter) { |
| 10451 | if (check_start_bss) { |
| 10452 | if (test_bit(SOFTAP_BSS_STARTED, |
| 10453 | &adapter->event_flags)) { |
| 10454 | con_sap_adapter = adapter; |
| 10455 | break; |
| 10456 | } |
| 10457 | } else { |
| 10458 | con_sap_adapter = adapter; |
| 10459 | break; |
| 10460 | } |
| 10461 | } |
| 10462 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 10463 | adapterNode = pNext; |
| 10464 | } |
| 10465 | |
| 10466 | return con_sap_adapter; |
| 10467 | } |
| 10468 | |
| 10469 | #ifdef MSM_PLATFORM |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10470 | static inline bool hdd_adapter_is_sta(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10471 | { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10472 | return adapter->device_mode == QDF_STA_MODE || |
| 10473 | adapter->device_mode == QDF_P2P_CLIENT_MODE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10474 | } |
| 10475 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10476 | static inline bool hdd_adapter_is_ap(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10477 | { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10478 | return adapter->device_mode == QDF_SAP_MODE || |
| 10479 | adapter->device_mode == QDF_P2P_GO_MODE; |
| 10480 | } |
| 10481 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10482 | static bool hdd_any_adapter_is_assoc(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10483 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10484 | QDF_STATUS status; |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10485 | hdd_adapter_list_node_t *node; |
| 10486 | |
| 10487 | status = hdd_get_front_adapter(hdd_ctx, &node); |
| 10488 | while (QDF_IS_STATUS_SUCCESS(status) && node) { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10489 | struct hdd_adapter *adapter = node->pAdapter; |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10490 | |
| 10491 | if (adapter && |
| 10492 | hdd_adapter_is_sta(adapter) && |
| 10493 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
| 10494 | conn_info.connState == eConnectionState_Associated) { |
| 10495 | return true; |
| 10496 | } |
| 10497 | |
| 10498 | if (adapter && |
| 10499 | hdd_adapter_is_ap(adapter) && |
| 10500 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->bApActive) { |
| 10501 | return true; |
| 10502 | } |
| 10503 | |
| 10504 | status = hdd_get_next_adapter(hdd_ctx, node, &node); |
| 10505 | } |
| 10506 | |
| 10507 | return false; |
| 10508 | } |
| 10509 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10510 | static bool hdd_bus_bw_compute_timer_is_running(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10511 | { |
| 10512 | bool is_running; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10513 | |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 10514 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10515 | is_running = hdd_ctx->bus_bw_timer_running; |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 10516 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10517 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10518 | return is_running; |
| 10519 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10520 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10521 | static void __hdd_bus_bw_compute_timer_start(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10522 | { |
| 10523 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
| 10524 | hdd_ctx->bus_bw_timer_running = true; |
| 10525 | qdf_timer_start(&hdd_ctx->bus_bw_timer, |
| 10526 | hdd_ctx->config->busBandwidthComputeInterval); |
| 10527 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
| 10528 | } |
| 10529 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10530 | void hdd_bus_bw_compute_timer_start(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10531 | { |
| 10532 | ENTER(); |
| 10533 | |
| 10534 | if (hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 10535 | hdd_debug("Bandwidth compute timer already started"); |
| 10536 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10537 | } |
| 10538 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10539 | __hdd_bus_bw_compute_timer_start(hdd_ctx); |
| 10540 | |
| 10541 | EXIT(); |
| 10542 | } |
| 10543 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10544 | void hdd_bus_bw_compute_timer_try_start(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10545 | { |
| 10546 | ENTER(); |
| 10547 | |
| 10548 | if (hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 10549 | hdd_debug("Bandwidth compute timer already started"); |
| 10550 | return; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 10551 | } |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10552 | |
| 10553 | if (hdd_any_adapter_is_assoc(hdd_ctx)) |
| 10554 | __hdd_bus_bw_compute_timer_start(hdd_ctx); |
| 10555 | |
| 10556 | EXIT(); |
| 10557 | } |
| 10558 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10559 | static void __hdd_bus_bw_compute_timer_stop(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10560 | { |
| 10561 | hdd_ipa_set_perf_level(hdd_ctx, 0, 0); |
| 10562 | |
| 10563 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
| 10564 | qdf_timer_stop(&hdd_ctx->bus_bw_timer); |
| 10565 | hdd_ctx->bus_bw_timer_running = false; |
| 10566 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
| 10567 | |
| 10568 | hdd_reset_tcp_delack(hdd_ctx); |
| 10569 | } |
| 10570 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10571 | void hdd_bus_bw_compute_timer_stop(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10572 | { |
| 10573 | ENTER(); |
| 10574 | |
| 10575 | if (!hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 10576 | hdd_debug("Bandwidth compute timer already stopped"); |
| 10577 | return; |
| 10578 | } |
| 10579 | |
| 10580 | __hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 10581 | |
| 10582 | EXIT(); |
| 10583 | } |
| 10584 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10585 | void hdd_bus_bw_compute_timer_try_stop(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10586 | { |
| 10587 | ENTER(); |
| 10588 | |
| 10589 | if (!hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 10590 | hdd_debug("Bandwidth compute timer already stopped"); |
| 10591 | return; |
| 10592 | } |
| 10593 | |
| 10594 | if (!hdd_any_adapter_is_assoc(hdd_ctx)) |
| 10595 | __hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 10596 | |
| 10597 | EXIT(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10598 | } |
| 10599 | #endif |
| 10600 | |
| 10601 | /** |
| 10602 | * wlan_hdd_check_custom_con_channel_rules() - This function checks the sap's |
| 10603 | * and sta's operating channel. |
| 10604 | * @sta_adapter: Describe the first argument to foobar. |
| 10605 | * @ap_adapter: Describe the second argument to foobar. |
| 10606 | * @roam_profile: Roam profile of AP to which STA wants to connect. |
| 10607 | * @concurrent_chnl_same: If both SAP and STA channels are same then |
| 10608 | * set this flag to true else false. |
| 10609 | * |
| 10610 | * This function checks the sap's operating channel and sta's operating channel. |
| 10611 | * if both are same then it will return false else it will restart the sap in |
| 10612 | * sta's channel and return true. |
| 10613 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10614 | * Return: QDF_STATUS_SUCCESS or QDF_STATUS_E_FAILURE. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10615 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10616 | QDF_STATUS wlan_hdd_check_custom_con_channel_rules(struct hdd_adapter *sta_adapter, |
| 10617 | struct hdd_adapter *ap_adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10618 | tCsrRoamProfile *roam_profile, |
| 10619 | tScanResultHandle *scan_cache, |
| 10620 | bool *concurrent_chnl_same) |
| 10621 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 10622 | struct hdd_ap_ctx *hdd_ap_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10623 | uint8_t channel_id; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10624 | QDF_STATUS status; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 10625 | enum tQDF_ADAPTER_MODE device_mode = ap_adapter->device_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10626 | *concurrent_chnl_same = true; |
| 10627 | |
| 10628 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 10629 | status = |
Archana Ramachandran | 2eb7a61 | 2017-03-23 22:58:42 -0700 | [diff] [blame] | 10630 | sme_get_ap_channel_from_scan_cache(roam_profile, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10631 | scan_cache, |
| 10632 | &channel_id); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 10633 | if (QDF_STATUS_SUCCESS == status) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 10634 | if ((QDF_SAP_MODE == device_mode) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10635 | (channel_id < SIR_11A_CHANNEL_BEGIN)) { |
| 10636 | if (hdd_ap_ctx->operatingChannel != channel_id) { |
| 10637 | *concurrent_chnl_same = false; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10638 | hdd_debug("channels are different"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10639 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 10640 | } else if ((QDF_P2P_GO_MODE == device_mode) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10641 | (channel_id >= SIR_11A_CHANNEL_BEGIN)) { |
| 10642 | if (hdd_ap_ctx->operatingChannel != channel_id) { |
| 10643 | *concurrent_chnl_same = false; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10644 | hdd_debug("channels are different"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10645 | } |
| 10646 | } |
| 10647 | } else { |
| 10648 | /* |
| 10649 | * Lets handle worst case scenario here, Scan cache lookup is |
| 10650 | * failed so we have to stop the SAP to avoid any channel |
| 10651 | * discrepancy between SAP's channel and STA's channel. |
| 10652 | * Return the status as failure so caller function could know |
| 10653 | * that scan look up is failed. |
| 10654 | */ |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 10655 | hdd_err("Finding AP from scan cache failed"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10656 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10657 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10658 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10659 | } |
| 10660 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10661 | /** |
| 10662 | * wlan_hdd_stop_sap() - This function stops bss of SAP. |
| 10663 | * @ap_adapter: SAP adapter |
| 10664 | * |
| 10665 | * This function will process the stopping of sap adapter. |
| 10666 | * |
| 10667 | * Return: None |
| 10668 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10669 | void wlan_hdd_stop_sap(struct hdd_adapter *ap_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10670 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 10671 | struct hdd_ap_ctx *hdd_ap_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10672 | hdd_hostapd_state_t *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 10673 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10674 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10675 | |
| 10676 | if (NULL == ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 10677 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10678 | return; |
| 10679 | } |
| 10680 | |
| 10681 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 10682 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 10683 | if (wlan_hdd_validate_context(hdd_ctx)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10684 | return; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 10685 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10686 | mutex_lock(&hdd_ctx->sap_lock); |
| 10687 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
Ryan Hsu | 8ecb0fa | 2016-01-18 15:40:55 -0800 | [diff] [blame] | 10688 | wlan_hdd_del_station(ap_adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10689 | hdd_cleanup_actionframe(hdd_ctx, ap_adapter); |
| 10690 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10691 | hdd_debug("Now doing SAP STOPBSS"); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 10692 | qdf_event_reset(&hostapd_state->qdf_stop_bss_event); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10693 | if (QDF_STATUS_SUCCESS == wlansap_stop_bss(hdd_ap_ctx-> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10694 | sapContext)) { |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 10695 | qdf_status = qdf_wait_single_event(&hostapd_state-> |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 10696 | qdf_stop_bss_event, |
| 10697 | SME_CMD_TIMEOUT_VALUE); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 10698 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10699 | mutex_unlock(&hdd_ctx->sap_lock); |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 10700 | hdd_err("SAP Stop Failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10701 | return; |
| 10702 | } |
| 10703 | } |
| 10704 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 10705 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
| 10706 | ap_adapter->device_mode, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10707 | ap_adapter->sessionId); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10708 | hdd_debug("SAP Stop Success"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10709 | } else { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 10710 | hdd_err("Can't stop ap because its not started"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10711 | } |
| 10712 | mutex_unlock(&hdd_ctx->sap_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10713 | } |
| 10714 | |
| 10715 | /** |
| 10716 | * wlan_hdd_start_sap() - this function starts bss of SAP. |
| 10717 | * @ap_adapter: SAP adapter |
| 10718 | * |
| 10719 | * This function will process the starting of sap adapter. |
| 10720 | * |
| 10721 | * Return: None |
| 10722 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10723 | void wlan_hdd_start_sap(struct hdd_adapter *ap_adapter, bool reinit) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10724 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 10725 | struct hdd_ap_ctx *hdd_ap_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10726 | hdd_hostapd_state_t *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 10727 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10728 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10729 | tsap_Config_t *sap_config; |
| 10730 | |
| 10731 | if (NULL == ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 10732 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10733 | return; |
| 10734 | } |
| 10735 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 10736 | if (QDF_SAP_MODE != ap_adapter->device_mode) { |
Peng Xu | f5d60c8 | 2015-10-02 17:17:03 -0700 | [diff] [blame] | 10737 | hdd_err("SoftAp role has not been enabled"); |
| 10738 | return; |
| 10739 | } |
| 10740 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10741 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
| 10742 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 10743 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
| 10744 | sap_config = &ap_adapter->sessionCtx.ap.sapConfig; |
| 10745 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10746 | mutex_lock(&hdd_ctx->sap_lock); |
| 10747 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) |
| 10748 | goto end; |
| 10749 | |
| 10750 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 10751 | hdd_err("SAP Not able to set AP IEs"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10752 | wlansap_reset_sap_config_add_ie(sap_config, eUPDATE_IE_ALL); |
| 10753 | goto end; |
| 10754 | } |
| 10755 | |
Wei Song | 2f76f64 | 2016-11-18 16:32:53 +0800 | [diff] [blame] | 10756 | qdf_event_reset(&hostapd_state->qdf_event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10757 | if (wlansap_start_bss(hdd_ap_ctx->sapContext, hdd_hostapd_sap_event_cb, |
| 10758 | &hdd_ap_ctx->sapConfig, |
| 10759 | ap_adapter->dev) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10760 | != QDF_STATUS_SUCCESS) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10761 | goto end; |
| 10762 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10763 | hdd_debug("Waiting for SAP to start"); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 10764 | qdf_status = qdf_wait_single_event(&hostapd_state->qdf_event, |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 10765 | SME_CMD_TIMEOUT_VALUE); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 10766 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 10767 | hdd_err("SAP Start failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10768 | goto end; |
| 10769 | } |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 10770 | hdd_info("SAP Start Success"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10771 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Krunal Soni | b37bb35 | 2016-12-20 14:12:21 -0800 | [diff] [blame] | 10772 | if (hostapd_state->bssState == BSS_START) |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 10773 | policy_mgr_incr_active_session(hdd_ctx->hdd_psoc, |
| 10774 | ap_adapter->device_mode, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10775 | ap_adapter->sessionId); |
| 10776 | hostapd_state->bCommit = true; |
| 10777 | |
| 10778 | end: |
| 10779 | mutex_unlock(&hdd_ctx->sap_lock); |
Manikandan Mohan | 3dad1a4 | 2017-06-14 10:50:18 -0700 | [diff] [blame] | 10780 | /* SAP context and beacon cleanup will happen during driver unload |
| 10781 | * in hdd_stop_adapter |
| 10782 | */ |
| 10783 | hdd_err("SAP restart after SSR failed! Reload WLAN and try SAP again"); |
| 10784 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10785 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10786 | |
| 10787 | /** |
Archana Ramachandran | a20ef81 | 2015-11-13 16:12:13 -0800 | [diff] [blame] | 10788 | * wlan_hdd_soc_set_antenna_mode_cb() - Callback for set dual |
| 10789 | * mac scan config |
| 10790 | * @status: Status of set antenna mode |
| 10791 | * |
| 10792 | * Callback on setting the dual mac configuration |
| 10793 | * |
| 10794 | * Return: None |
| 10795 | */ |
| 10796 | void wlan_hdd_soc_set_antenna_mode_cb( |
| 10797 | enum set_antenna_mode_status status) |
| 10798 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10799 | struct hdd_context *hdd_ctx; |
Archana Ramachandran | a20ef81 | 2015-11-13 16:12:13 -0800 | [diff] [blame] | 10800 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10801 | hdd_debug("Status: %d", status); |
Archana Ramachandran | a20ef81 | 2015-11-13 16:12:13 -0800 | [diff] [blame] | 10802 | |
| 10803 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 10804 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
| 10805 | return; |
| 10806 | |
| 10807 | /* Signal the completion of set dual mac config */ |
| 10808 | complete(&hdd_ctx->set_antenna_mode_cmpl); |
| 10809 | } |
| 10810 | |
| 10811 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10812 | * hdd_get_fw_version() - Get FW version |
| 10813 | * @hdd_ctx: pointer to HDD context. |
| 10814 | * @major_spid: FW version - major spid. |
| 10815 | * @minor_spid: FW version - minor spid |
| 10816 | * @ssid: FW version - ssid |
| 10817 | * @crmid: FW version - crmid |
| 10818 | * |
| 10819 | * This function is called to get the firmware build version stored |
| 10820 | * as part of the HDD context |
| 10821 | * |
| 10822 | * Return: None |
| 10823 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10824 | void hdd_get_fw_version(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10825 | uint32_t *major_spid, uint32_t *minor_spid, |
| 10826 | uint32_t *siid, uint32_t *crmid) |
| 10827 | { |
| 10828 | *major_spid = (hdd_ctx->target_fw_version & 0xf0000000) >> 28; |
| 10829 | *minor_spid = (hdd_ctx->target_fw_version & 0xf000000) >> 24; |
| 10830 | *siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20; |
| 10831 | *crmid = hdd_ctx->target_fw_version & 0x7fff; |
| 10832 | } |
| 10833 | |
| 10834 | #ifdef QCA_CONFIG_SMP |
| 10835 | /** |
| 10836 | * wlan_hdd_get_cpu() - get cpu_index |
| 10837 | * |
| 10838 | * Return: cpu_index |
| 10839 | */ |
| 10840 | int wlan_hdd_get_cpu(void) |
| 10841 | { |
| 10842 | int cpu_index = get_cpu(); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 10843 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10844 | put_cpu(); |
| 10845 | return cpu_index; |
| 10846 | } |
| 10847 | #endif |
| 10848 | |
| 10849 | /** |
| 10850 | * hdd_get_fwpath() - get framework path |
| 10851 | * |
| 10852 | * This function is used to get the string written by |
| 10853 | * userspace to start the wlan driver |
| 10854 | * |
| 10855 | * Return: string |
| 10856 | */ |
| 10857 | const char *hdd_get_fwpath(void) |
| 10858 | { |
| 10859 | return fwpath.string; |
| 10860 | } |
| 10861 | |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 10862 | static int hdd_qdf_print_init(void) |
| 10863 | { |
| 10864 | int qdf_print_idx; |
| 10865 | QDF_STATUS status; |
| 10866 | |
| 10867 | status = qdf_print_setup(); |
| 10868 | if (status != QDF_STATUS_SUCCESS) { |
| 10869 | pr_err("qdf_print_setup failed\n"); |
| 10870 | return -EINVAL; |
| 10871 | } |
| 10872 | |
| 10873 | qdf_print_idx = qdf_print_ctrl_register(cinfo, NULL, NULL, "MCL_WLAN"); |
| 10874 | |
| 10875 | if (qdf_print_idx < 0) { |
| 10876 | pr_err("qdf_print_ctrl_register failed, ret = %d\n", |
| 10877 | qdf_print_idx); |
| 10878 | return -EINVAL; |
| 10879 | } |
| 10880 | |
| 10881 | qdf_set_pidx(qdf_print_idx); |
| 10882 | |
| 10883 | return 0; |
| 10884 | } |
| 10885 | |
| 10886 | static void hdd_qdf_print_deinit(void) |
| 10887 | { |
| 10888 | int qdf_print_idx; |
| 10889 | |
| 10890 | qdf_print_idx = qdf_get_pidx(); |
| 10891 | qdf_print_ctrl_cleanup(qdf_print_idx); |
| 10892 | } |
| 10893 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10894 | /** |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 10895 | * hdd_init() - Initialize Driver |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10896 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 10897 | * This function initilizes CDS global context with the help of cds_init. This |
| 10898 | * has to be the first function called after probe to get a valid global |
| 10899 | * context. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10900 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 10901 | * Return: 0 for success, errno on failure |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10902 | */ |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 10903 | int hdd_init(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10904 | { |
Jeff Johnson | 7aaeeea | 2017-09-26 13:16:24 -0700 | [diff] [blame] | 10905 | QDF_STATUS status; |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 10906 | int ret = 0; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10907 | |
Jeff Johnson | 7aaeeea | 2017-09-26 13:16:24 -0700 | [diff] [blame] | 10908 | status = cds_init(); |
Hanumanth Reddy Pothula | 788a37e | 2017-08-17 18:40:11 +0530 | [diff] [blame] | 10909 | |
| 10910 | wlan_init_bug_report_lock(); |
| 10911 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10912 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 10913 | wlan_logging_sock_init_svc(); |
| 10914 | #endif |
| 10915 | |
Jeff Johnson | 7aaeeea | 2017-09-26 13:16:24 -0700 | [diff] [blame] | 10916 | if (QDF_IS_STATUS_ERROR(status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10917 | hdd_err("Failed to allocate CDS context"); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 10918 | ret = -ENOMEM; |
| 10919 | goto err_out; |
| 10920 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10921 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 10922 | qdf_timer_init(NULL, &hdd_drv_ops_inactivity_timer, |
| 10923 | (void *)hdd_drv_ops_inactivity_handler, NULL, |
| 10924 | QDF_TIMER_TYPE_SW); |
| 10925 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 10926 | hdd_trace_init(); |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 10927 | hdd_qdf_print_init(); |
| 10928 | |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10929 | hdd_register_debug_callback(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10930 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 10931 | err_out: |
| 10932 | return ret; |
| 10933 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10934 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 10935 | /** |
| 10936 | * hdd_deinit() - Deinitialize Driver |
| 10937 | * |
| 10938 | * This function frees CDS global context with the help of cds_deinit. This |
| 10939 | * has to be the last function call in remove callback to free the global |
| 10940 | * context. |
| 10941 | */ |
| 10942 | void hdd_deinit(void) |
| 10943 | { |
Dustin Brown | edce4a5 | 2017-05-10 11:59:15 -0700 | [diff] [blame] | 10944 | hdd_deinit_wowl(); |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 10945 | qdf_timer_free(&hdd_drv_ops_inactivity_timer); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10946 | |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 10947 | hdd_qdf_print_deinit(); |
| 10948 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 10949 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 10950 | wlan_logging_sock_deinit_svc(); |
| 10951 | #endif |
Hanumanth Reddy Pothula | 788a37e | 2017-08-17 18:40:11 +0530 | [diff] [blame] | 10952 | |
| 10953 | wlan_destroy_bug_report_lock(); |
| 10954 | cds_deinit(); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 10955 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10956 | |
Yue Ma | 6e7b1a0 | 2017-04-03 14:17:46 -0700 | [diff] [blame] | 10957 | #ifdef QCA_WIFI_NAPIER_EMULATION |
| 10958 | #define HDD_WLAN_START_WAIT_TIME ((CDS_WMA_TIMEOUT + 5000) * 100) |
| 10959 | #else |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10960 | #define HDD_WLAN_START_WAIT_TIME (CDS_WMA_TIMEOUT + 5000) |
Yue Ma | 6e7b1a0 | 2017-04-03 14:17:46 -0700 | [diff] [blame] | 10961 | #endif |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 10962 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 10963 | static int wlan_hdd_state_ctrl_param_open(struct inode *inode, |
| 10964 | struct file *file) |
| 10965 | { |
| 10966 | return 0; |
| 10967 | } |
| 10968 | |
| 10969 | static ssize_t wlan_hdd_state_ctrl_param_write(struct file *filp, |
| 10970 | const char __user *user_buf, |
| 10971 | size_t count, |
| 10972 | loff_t *f_pos) |
| 10973 | { |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 10974 | char buf[3]; |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 10975 | static const char wlan_off_str[] = "OFF"; |
| 10976 | static const char wlan_on_str[] = "ON"; |
| 10977 | int ret; |
| 10978 | unsigned long rc; |
| 10979 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 10980 | if (copy_from_user(buf, user_buf, 3)) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 10981 | pr_err("Failed to read buffer\n"); |
| 10982 | return -EINVAL; |
| 10983 | } |
| 10984 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 10985 | if (strncmp(buf, wlan_off_str, strlen(wlan_off_str)) == 0) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 10986 | pr_debug("Wifi turning off from UI\n"); |
| 10987 | goto exit; |
| 10988 | } |
| 10989 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 10990 | if (strncmp(buf, wlan_on_str, strlen(wlan_on_str)) != 0) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 10991 | pr_err("Invalid value received from framework"); |
| 10992 | goto exit; |
| 10993 | } |
| 10994 | |
| 10995 | if (!cds_is_driver_loaded()) { |
Sachin Ahuja | ee62b54 | 2017-04-21 14:14:16 +0530 | [diff] [blame] | 10996 | init_completion(&wlan_start_comp); |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 10997 | rc = wait_for_completion_timeout(&wlan_start_comp, |
| 10998 | msecs_to_jiffies(HDD_WLAN_START_WAIT_TIME)); |
| 10999 | if (!rc) { |
| 11000 | hdd_alert("Timed-out waiting in wlan_hdd_state_ctrl_param_write"); |
| 11001 | ret = -EINVAL; |
| 11002 | hdd_start_complete(ret); |
| 11003 | return ret; |
| 11004 | } |
| 11005 | |
| 11006 | hdd_start_complete(0); |
| 11007 | } |
| 11008 | |
| 11009 | exit: |
| 11010 | return count; |
| 11011 | } |
| 11012 | |
| 11013 | |
| 11014 | const struct file_operations wlan_hdd_state_fops = { |
| 11015 | .owner = THIS_MODULE, |
| 11016 | .open = wlan_hdd_state_ctrl_param_open, |
| 11017 | .write = wlan_hdd_state_ctrl_param_write, |
| 11018 | }; |
| 11019 | |
| 11020 | static int wlan_hdd_state_ctrl_param_create(void) |
| 11021 | { |
| 11022 | unsigned int wlan_hdd_state_major = 0; |
| 11023 | int ret; |
| 11024 | struct device *dev; |
| 11025 | |
| 11026 | device = MKDEV(wlan_hdd_state_major, 0); |
| 11027 | |
| 11028 | ret = alloc_chrdev_region(&device, 0, dev_num, "qcwlanstate"); |
| 11029 | if (ret) { |
| 11030 | pr_err("Failed to register qcwlanstate"); |
| 11031 | goto dev_alloc_err; |
| 11032 | } |
| 11033 | wlan_hdd_state_major = MAJOR(device); |
| 11034 | |
| 11035 | class = class_create(THIS_MODULE, WLAN_MODULE_NAME); |
| 11036 | if (IS_ERR(class)) { |
| 11037 | pr_err("wlan_hdd_state class_create error"); |
| 11038 | goto class_err; |
| 11039 | } |
| 11040 | |
| 11041 | dev = device_create(class, NULL, device, NULL, WLAN_MODULE_NAME); |
| 11042 | if (IS_ERR(dev)) { |
| 11043 | pr_err("wlan_hdd_statedevice_create error"); |
| 11044 | goto err_class_destroy; |
| 11045 | } |
| 11046 | |
| 11047 | cdev_init(&wlan_hdd_state_cdev, &wlan_hdd_state_fops); |
| 11048 | ret = cdev_add(&wlan_hdd_state_cdev, device, dev_num); |
| 11049 | if (ret) { |
| 11050 | pr_err("Failed to add cdev error"); |
| 11051 | goto cdev_add_err; |
| 11052 | } |
| 11053 | |
| 11054 | pr_info("wlan_hdd_state %s major(%d) initialized", |
| 11055 | WLAN_MODULE_NAME, wlan_hdd_state_major); |
| 11056 | |
| 11057 | return 0; |
| 11058 | |
| 11059 | cdev_add_err: |
| 11060 | device_destroy(class, device); |
| 11061 | err_class_destroy: |
| 11062 | class_destroy(class); |
| 11063 | class_err: |
| 11064 | unregister_chrdev_region(device, dev_num); |
| 11065 | dev_alloc_err: |
| 11066 | return -ENODEV; |
| 11067 | } |
| 11068 | |
| 11069 | static void wlan_hdd_state_ctrl_param_destroy(void) |
| 11070 | { |
| 11071 | cdev_del(&wlan_hdd_state_cdev); |
| 11072 | device_destroy(class, device); |
| 11073 | class_destroy(class); |
| 11074 | unregister_chrdev_region(device, dev_num); |
| 11075 | |
| 11076 | pr_info("Device node unregistered"); |
| 11077 | } |
| 11078 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11079 | /** |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 11080 | * component_init - API to init cld component's |
| 11081 | * |
| 11082 | * Return: None |
| 11083 | */ |
| 11084 | static void component_init(void) |
| 11085 | { |
| 11086 | pmo_init(); |
| 11087 | } |
| 11088 | |
| 11089 | /** |
| 11090 | * component_deinit - API to deinit cld component's |
| 11091 | * |
| 11092 | * Return: None |
| 11093 | */ |
| 11094 | static void component_deinit(void) |
| 11095 | { |
| 11096 | pmo_deinit(); |
| 11097 | } |
| 11098 | |
| 11099 | /** |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11100 | * __hdd_module_init - Module init helper |
| 11101 | * |
| 11102 | * Module init helper function used by both module and static driver. |
| 11103 | * |
| 11104 | * Return: 0 for success, errno on failure |
| 11105 | */ |
| 11106 | static int __hdd_module_init(void) |
| 11107 | { |
| 11108 | int ret = 0; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11109 | |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 11110 | pr_err("%s: Loading driver v%s (%s)%s\n", |
| 11111 | WLAN_MODULE_NAME, |
| 11112 | QWLAN_VERSIONSTR, |
Naveen Rawat | 9383625 | 2017-06-20 16:30:59 -0700 | [diff] [blame] | 11113 | g_wlan_driver_timestamp, |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 11114 | TIMER_MANAGER_STR MEMORY_DEBUG_STR); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11115 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11116 | ret = wlan_hdd_state_ctrl_param_create(); |
| 11117 | if (ret) { |
| 11118 | pr_err("wlan_hdd_state_create:%x\n", ret); |
| 11119 | goto err_dev_state; |
| 11120 | } |
| 11121 | |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 11122 | pld_init(); |
| 11123 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 11124 | ret = hdd_init(); |
| 11125 | if (ret) { |
| 11126 | pr_err("hdd_init failed %x\n", ret); |
| 11127 | goto err_hdd_init; |
| 11128 | } |
| 11129 | |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 11130 | dispatcher_init(); |
| 11131 | |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 11132 | /* Ensure to call post objmgr init */ |
| 11133 | component_init(); |
| 11134 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 11135 | qdf_wake_lock_create(&wlan_wake_lock, "wlan"); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11136 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11137 | hdd_set_conparam((uint32_t) con_mode); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11138 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11139 | ret = wlan_hdd_register_driver(); |
| 11140 | if (ret) { |
Mohit Khanna | fa99aea | 2016-05-12 21:43:13 -0700 | [diff] [blame] | 11141 | pr_err("%s: driver load failure, err %d\n", WLAN_MODULE_NAME, |
| 11142 | ret); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11143 | goto out; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11144 | } |
| 11145 | |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 11146 | pr_info("%s: driver loaded\n", WLAN_MODULE_NAME); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11147 | |
| 11148 | return 0; |
| 11149 | out: |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 11150 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 11151 | dispatcher_deinit(); |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 11152 | hdd_deinit(); |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 11153 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 11154 | err_hdd_init: |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 11155 | pld_deinit(); |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11156 | wlan_hdd_state_ctrl_param_destroy(); |
| 11157 | err_dev_state: |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11158 | return ret; |
| 11159 | } |
| 11160 | |
| 11161 | /** |
| 11162 | * __hdd_module_exit - Module exit helper |
| 11163 | * |
| 11164 | * Module exit helper function used by both module and static driver. |
| 11165 | */ |
| 11166 | static void __hdd_module_exit(void) |
| 11167 | { |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 11168 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11169 | pr_info("%s: Unloading driver v%s\n", WLAN_MODULE_NAME, |
| 11170 | QWLAN_VERSIONSTR); |
| 11171 | |
bings | 6028ee8 | 2017-03-29 07:51:40 +0800 | [diff] [blame] | 11172 | cds_set_unload_in_progress(true); |
| 11173 | |
Arunk Khandavalli | 07ec8f6 | 2016-09-27 21:51:01 +0530 | [diff] [blame] | 11174 | hdd_wait_for_recovery_completion(); |
| 11175 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11176 | wlan_hdd_unregister_driver(); |
| 11177 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 11178 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11179 | |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 11180 | /* Ensure to call prior to objmgr deinit */ |
| 11181 | component_deinit(); |
| 11182 | |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 11183 | dispatcher_deinit(); |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 11184 | hdd_deinit(); |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 11185 | pld_deinit(); |
| 11186 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11187 | wlan_hdd_state_ctrl_param_destroy(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11188 | } |
| 11189 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11190 | #ifndef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11191 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11192 | * wlan_boot_cb() - Wlan boot callback |
| 11193 | * @kobj: object whose directory we're creating the link in. |
| 11194 | * @attr: attribute the user is interacting with |
| 11195 | * @buff: the buffer containing the user data |
| 11196 | * @count: number of bytes in the buffer |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11197 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11198 | * This callback is invoked when the fs is ready to start the |
| 11199 | * wlan driver initialization. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11200 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11201 | * Return: 'count' on success or a negative error code in case of failure |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11202 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11203 | static ssize_t wlan_boot_cb(struct kobject *kobj, |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11204 | struct kobj_attribute *attr, |
| 11205 | const char *buf, |
| 11206 | size_t count) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11207 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11208 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11209 | if (wlan_loader->loaded_state) { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11210 | pr_err("%s: wlan driver already initialized\n", __func__); |
| 11211 | return -EALREADY; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11212 | } |
| 11213 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11214 | if (__hdd_module_init()) { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11215 | pr_err("%s: wlan driver initialization failed\n", __func__); |
| 11216 | return -EIO; |
| 11217 | } |
| 11218 | |
| 11219 | wlan_loader->loaded_state = MODULE_INITIALIZED; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11220 | |
| 11221 | return count; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11222 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11223 | |
| 11224 | /** |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11225 | * hdd_sysfs_cleanup() - cleanup sysfs |
| 11226 | * |
| 11227 | * Return: None |
| 11228 | * |
| 11229 | */ |
| 11230 | static void hdd_sysfs_cleanup(void) |
| 11231 | { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11232 | /* remove from group */ |
| 11233 | if (wlan_loader->boot_wlan_obj && wlan_loader->attr_group) |
| 11234 | sysfs_remove_group(wlan_loader->boot_wlan_obj, |
| 11235 | wlan_loader->attr_group); |
| 11236 | |
| 11237 | /* unlink the object from parent */ |
| 11238 | kobject_del(wlan_loader->boot_wlan_obj); |
| 11239 | |
| 11240 | /* free the object */ |
| 11241 | kobject_put(wlan_loader->boot_wlan_obj); |
| 11242 | |
| 11243 | kfree(wlan_loader->attr_group); |
| 11244 | kfree(wlan_loader); |
| 11245 | |
| 11246 | wlan_loader = NULL; |
| 11247 | } |
| 11248 | |
| 11249 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11250 | * wlan_init_sysfs() - Creates the sysfs to be invoked when the fs is |
| 11251 | * ready |
| 11252 | * |
| 11253 | * This is creates the syfs entry boot_wlan. Which shall be invoked |
| 11254 | * when the filesystem is ready. |
| 11255 | * |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11256 | * QDF API cannot be used here since this function is called even before |
| 11257 | * initializing WLAN driver. |
| 11258 | * |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 11259 | * Return: 0 for success, errno on failure |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11260 | */ |
| 11261 | static int wlan_init_sysfs(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11262 | { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11263 | int ret = -ENOMEM; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11264 | |
| 11265 | wlan_loader = kzalloc(sizeof(*wlan_loader), GFP_KERNEL); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 11266 | if (!wlan_loader) |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11267 | return -ENOMEM; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11268 | |
| 11269 | wlan_loader->boot_wlan_obj = NULL; |
| 11270 | wlan_loader->attr_group = kzalloc(sizeof(*(wlan_loader->attr_group)), |
| 11271 | GFP_KERNEL); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 11272 | if (!wlan_loader->attr_group) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11273 | goto error_return; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11274 | |
| 11275 | wlan_loader->loaded_state = 0; |
| 11276 | wlan_loader->attr_group->attrs = attrs; |
| 11277 | |
| 11278 | wlan_loader->boot_wlan_obj = kobject_create_and_add("boot_wlan", |
| 11279 | kernel_kobj); |
| 11280 | if (!wlan_loader->boot_wlan_obj) { |
| 11281 | pr_err("%s: sysfs create and add failed\n", __func__); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11282 | goto error_return; |
| 11283 | } |
| 11284 | |
| 11285 | ret = sysfs_create_group(wlan_loader->boot_wlan_obj, |
| 11286 | wlan_loader->attr_group); |
| 11287 | if (ret) { |
| 11288 | pr_err("%s: sysfs create group failed %d\n", __func__, ret); |
| 11289 | goto error_return; |
| 11290 | } |
| 11291 | |
| 11292 | return 0; |
| 11293 | |
| 11294 | error_return: |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11295 | hdd_sysfs_cleanup(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11296 | |
| 11297 | return ret; |
| 11298 | } |
| 11299 | |
| 11300 | /** |
| 11301 | * wlan_deinit_sysfs() - Removes the sysfs created to initialize the wlan |
| 11302 | * |
| 11303 | * Return: 0 on success or errno on failure |
| 11304 | */ |
| 11305 | static int wlan_deinit_sysfs(void) |
| 11306 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11307 | if (!wlan_loader) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11308 | hdd_err("wlan loader context is Null!"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11309 | return -EINVAL; |
| 11310 | } |
| 11311 | |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11312 | hdd_sysfs_cleanup(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11313 | return 0; |
| 11314 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11315 | |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11316 | #endif /* MODULE */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11317 | |
| 11318 | #ifdef MODULE |
| 11319 | /** |
| 11320 | * __hdd_module_init - Module init helper |
| 11321 | * |
| 11322 | * Module init helper function used by both module and static driver. |
| 11323 | * |
| 11324 | * Return: 0 for success, errno on failure |
| 11325 | */ |
| 11326 | static int hdd_module_init(void) |
| 11327 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11328 | if (__hdd_module_init()) { |
| 11329 | pr_err("%s: Failed to register handler\n", __func__); |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 11330 | return -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11331 | } |
| 11332 | |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 11333 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11334 | } |
| 11335 | #else |
| 11336 | static int __init hdd_module_init(void) |
| 11337 | { |
| 11338 | int ret = -EINVAL; |
| 11339 | |
| 11340 | ret = wlan_init_sysfs(); |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 11341 | if (ret) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11342 | pr_err("Failed to create sysfs entry for loading wlan"); |
| 11343 | |
| 11344 | return ret; |
| 11345 | } |
| 11346 | #endif |
| 11347 | |
| 11348 | |
| 11349 | #ifdef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11350 | /** |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11351 | * hdd_module_exit() - Exit function |
| 11352 | * |
| 11353 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 11354 | * |
| 11355 | * Return: None |
| 11356 | */ |
| 11357 | static void __exit hdd_module_exit(void) |
| 11358 | { |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11359 | __hdd_module_exit(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11360 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11361 | #else |
| 11362 | static void __exit hdd_module_exit(void) |
| 11363 | { |
| 11364 | __hdd_module_exit(); |
| 11365 | wlan_deinit_sysfs(); |
| 11366 | } |
| 11367 | #endif |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11368 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11369 | static int fwpath_changed_handler(const char *kmessage, struct kernel_param *kp) |
| 11370 | { |
| 11371 | return param_set_copystring(kmessage, kp); |
| 11372 | } |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11373 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11374 | /** |
| 11375 | * is_con_mode_valid() check con mode is valid or not |
| 11376 | * @mode: global con mode |
| 11377 | * |
| 11378 | * Return: TRUE on success FALSE on failure |
| 11379 | */ |
| 11380 | static bool is_con_mode_valid(enum tQDF_GLOBAL_CON_MODE mode) |
| 11381 | { |
| 11382 | switch (mode) { |
| 11383 | case QDF_GLOBAL_MONITOR_MODE: |
| 11384 | case QDF_GLOBAL_FTM_MODE: |
| 11385 | case QDF_GLOBAL_EPPING_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11386 | case QDF_GLOBAL_MISSION_MODE: |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11387 | return true; |
| 11388 | default: |
| 11389 | return false; |
| 11390 | } |
| 11391 | } |
| 11392 | |
| 11393 | /** |
| 11394 | * hdd_get_adpter_mode() - returns adapter mode based on global con mode |
| 11395 | * @mode: global con mode |
| 11396 | * |
| 11397 | * Return: adapter mode |
| 11398 | */ |
| 11399 | static enum tQDF_ADAPTER_MODE hdd_get_adpter_mode( |
| 11400 | enum tQDF_GLOBAL_CON_MODE mode) |
| 11401 | { |
| 11402 | |
| 11403 | switch (mode) { |
| 11404 | case QDF_GLOBAL_MISSION_MODE: |
| 11405 | return QDF_STA_MODE; |
| 11406 | case QDF_GLOBAL_MONITOR_MODE: |
| 11407 | return QDF_MONITOR_MODE; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11408 | case QDF_GLOBAL_EPPING_MODE: |
| 11409 | return QDF_EPPING_MODE; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11410 | case QDF_GLOBAL_FTM_MODE: |
| 11411 | return QDF_FTM_MODE; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11412 | case QDF_GLOBAL_QVIT_MODE: |
| 11413 | return QDF_QVIT_MODE; |
| 11414 | default: |
| 11415 | return QDF_MAX_NO_OF_MODE; |
| 11416 | } |
| 11417 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11418 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 11419 | static void hdd_stop_present_mode(struct hdd_context *hdd_ctx, |
| 11420 | enum tQDF_GLOBAL_CON_MODE curr_mode) |
| 11421 | { |
| 11422 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) |
| 11423 | return; |
| 11424 | |
| 11425 | switch (curr_mode) { |
| 11426 | case QDF_GLOBAL_MISSION_MODE: |
| 11427 | case QDF_GLOBAL_MONITOR_MODE: |
| 11428 | case QDF_GLOBAL_FTM_MODE: |
| 11429 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
| 11430 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->hdd_pdev); |
| 11431 | |
| 11432 | /* re-use the existing session */ |
| 11433 | hdd_stop_all_adapters(hdd_ctx, false); |
| 11434 | break; |
| 11435 | default: |
| 11436 | break; |
| 11437 | } |
| 11438 | } |
| 11439 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11440 | static void hdd_cleanup_present_mode(struct hdd_context *hdd_ctx, |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11441 | enum tQDF_GLOBAL_CON_MODE curr_mode) |
| 11442 | { |
Ashish Kumar Dhanotiya | 0024313 | 2017-01-24 16:37:34 +0530 | [diff] [blame] | 11443 | int driver_status; |
| 11444 | |
| 11445 | driver_status = hdd_ctx->driver_status; |
| 11446 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11447 | switch (curr_mode) { |
| 11448 | case QDF_GLOBAL_MISSION_MODE: |
| 11449 | case QDF_GLOBAL_MONITOR_MODE: |
| 11450 | case QDF_GLOBAL_FTM_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11451 | hdd_deinit_all_adapters(hdd_ctx, false); |
| 11452 | hdd_close_all_adapters(hdd_ctx, false); |
| 11453 | break; |
| 11454 | case QDF_GLOBAL_EPPING_MODE: |
| 11455 | epping_disable(); |
| 11456 | epping_close(); |
| 11457 | break; |
| 11458 | default: |
| 11459 | return; |
| 11460 | } |
| 11461 | } |
| 11462 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11463 | static int hdd_register_req_mode(struct hdd_context *hdd_ctx, |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11464 | enum tQDF_GLOBAL_CON_MODE mode) |
| 11465 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11466 | struct hdd_adapter *adapter; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11467 | int ret = 0; |
| 11468 | bool rtnl_held; |
| 11469 | qdf_device_t qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 11470 | QDF_STATUS status; |
| 11471 | |
| 11472 | if (!qdf_dev) { |
| 11473 | hdd_err("qdf device context is Null return!"); |
| 11474 | return -EINVAL; |
| 11475 | } |
| 11476 | |
| 11477 | rtnl_held = hdd_hold_rtnl_lock(); |
| 11478 | switch (mode) { |
| 11479 | case QDF_GLOBAL_MISSION_MODE: |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 11480 | ret = hdd_open_interfaces(hdd_ctx, rtnl_held); |
| 11481 | if (ret) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11482 | hdd_err("Failed to open interfaces: %d", ret); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11483 | break; |
| 11484 | case QDF_GLOBAL_FTM_MODE: |
| 11485 | adapter = hdd_open_adapter(hdd_ctx, QDF_FTM_MODE, "wlan%d", |
| 11486 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 11487 | NET_NAME_UNKNOWN, rtnl_held); |
| 11488 | if (adapter == NULL) |
| 11489 | ret = -EINVAL; |
| 11490 | break; |
| 11491 | case QDF_GLOBAL_MONITOR_MODE: |
| 11492 | adapter = hdd_open_adapter(hdd_ctx, QDF_MONITOR_MODE, "wlan%d", |
| 11493 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 11494 | NET_NAME_UNKNOWN, rtnl_held); |
| 11495 | if (adapter == NULL) |
| 11496 | ret = -EINVAL; |
| 11497 | break; |
| 11498 | case QDF_GLOBAL_EPPING_MODE: |
| 11499 | status = epping_open(); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 11500 | if (status != QDF_STATUS_SUCCESS) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11501 | hdd_err("Failed to open in eeping mode: %d", status); |
| 11502 | ret = -EINVAL; |
| 11503 | break; |
| 11504 | } |
| 11505 | ret = epping_enable(qdf_dev->dev); |
| 11506 | if (ret) { |
| 11507 | hdd_err("Failed to enable in epping mode : %d", ret); |
| 11508 | epping_close(); |
| 11509 | } |
| 11510 | break; |
| 11511 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11512 | hdd_err("Mode not supported"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11513 | ret = -ENOTSUPP; |
| 11514 | break; |
| 11515 | } |
| 11516 | hdd_release_rtnl_lock(); |
| 11517 | rtnl_held = false; |
| 11518 | return ret; |
| 11519 | } |
| 11520 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11521 | /** |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 11522 | * __con_mode_handler() - Handles module param con_mode change |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11523 | * @kmessage: con mode name on which driver to be bring up |
| 11524 | * @kp: The associated kernel parameter |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 11525 | * @hdd_ctx: Pointer to the global HDD context |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11526 | * |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11527 | * This function is invoked when user updates con mode using sys entry, |
| 11528 | * to initialize and bring-up driver in that specific mode. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11529 | * |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11530 | * Return - 0 on success and failure code on failure |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11531 | */ |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11532 | static int __con_mode_handler(const char *kmessage, struct kernel_param *kp, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11533 | struct hdd_context *hdd_ctx) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11534 | { |
| 11535 | int ret; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11536 | struct hdd_adapter *adapter; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11537 | enum tQDF_GLOBAL_CON_MODE curr_mode; |
| 11538 | enum tQDF_ADAPTER_MODE adapter_mode; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11539 | |
Dustin Brown | ab6029b | 2017-05-24 13:04:19 -0700 | [diff] [blame] | 11540 | hdd_info("con_mode handler: %s", kmessage); |
| 11541 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 11542 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 11543 | if (ret) |
| 11544 | return ret; |
| 11545 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11546 | cds_set_load_in_progress(true); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11547 | |
| 11548 | ret = param_set_int(kmessage, kp); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11549 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11550 | if (!(is_con_mode_valid(con_mode))) { |
| 11551 | hdd_err("invlaid con_mode %d", con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11552 | ret = -EINVAL; |
| 11553 | goto reset_flags; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11554 | } |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11555 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11556 | curr_mode = hdd_get_conparam(); |
| 11557 | if (curr_mode == con_mode) { |
| 11558 | hdd_err("curr mode: %d is same as user triggered mode %d", |
| 11559 | curr_mode, con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11560 | ret = 0; |
| 11561 | goto reset_flags; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11562 | } |
| 11563 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 11564 | /* ensure adapters are stopped */ |
| 11565 | hdd_stop_present_mode(hdd_ctx, curr_mode); |
| 11566 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 11567 | ret = hdd_wlan_stop_modules(hdd_ctx, true); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11568 | if (ret) { |
| 11569 | hdd_err("Stop wlan modules failed"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11570 | goto reset_flags; |
| 11571 | } |
| 11572 | |
Ashish Kumar Dhanotiya | cda5766 | 2017-08-14 14:45:25 +0530 | [diff] [blame] | 11573 | /* Cleanup present mode before switching to new mode */ |
| 11574 | hdd_cleanup_present_mode(hdd_ctx, curr_mode); |
| 11575 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11576 | hdd_set_conparam(con_mode); |
| 11577 | |
| 11578 | /* Register for new con_mode & then kick_start modules again */ |
| 11579 | ret = hdd_register_req_mode(hdd_ctx, con_mode); |
| 11580 | if (ret) { |
| 11581 | hdd_err("Failed to register for new mode"); |
| 11582 | goto reset_flags; |
| 11583 | } |
| 11584 | |
| 11585 | adapter_mode = hdd_get_adpter_mode(con_mode); |
| 11586 | if (adapter_mode == QDF_MAX_NO_OF_MODE) { |
| 11587 | hdd_err("invalid adapter"); |
| 11588 | ret = -EINVAL; |
| 11589 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11590 | } |
| 11591 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11592 | adapter = hdd_get_adapter(hdd_ctx, adapter_mode); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11593 | if (!adapter) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11594 | hdd_err("Failed to get adapter:%d", adapter_mode); |
| 11595 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11596 | } |
| 11597 | |
| 11598 | ret = hdd_wlan_start_modules(hdd_ctx, adapter, false); |
| 11599 | if (ret) { |
| 11600 | hdd_err("Start wlan modules failed: %d", ret); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11601 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11602 | } |
| 11603 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11604 | if (con_mode == QDF_GLOBAL_MONITOR_MODE || |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 11605 | con_mode == QDF_GLOBAL_FTM_MODE) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11606 | if (hdd_start_adapter(adapter)) { |
| 11607 | hdd_err("Failed to start %s adapter", kmessage); |
| 11608 | ret = -EINVAL; |
| 11609 | goto reset_flags; |
| 11610 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11611 | } |
| 11612 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11613 | hdd_info("Mode successfully changed to %s", kmessage); |
| 11614 | ret = 0; |
| 11615 | |
| 11616 | reset_flags: |
| 11617 | cds_set_load_in_progress(false); |
| 11618 | return ret; |
| 11619 | } |
| 11620 | |
| 11621 | |
| 11622 | static int con_mode_handler(const char *kmessage, struct kernel_param *kp) |
| 11623 | { |
| 11624 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11625 | struct hdd_context *hdd_ctx; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11626 | |
| 11627 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 11628 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 11629 | if (ret) |
| 11630 | return ret; |
| 11631 | |
| 11632 | cds_ssr_protect(__func__); |
| 11633 | ret = __con_mode_handler(kmessage, kp, hdd_ctx); |
| 11634 | cds_ssr_unprotect(__func__); |
| 11635 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11636 | return ret; |
| 11637 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11638 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 11639 | static int con_mode_handler_ftm(const char *kmessage, |
| 11640 | struct kernel_param *kp) |
| 11641 | { |
| 11642 | int ret; |
| 11643 | |
| 11644 | ret = param_set_int(kmessage, kp); |
| 11645 | |
| 11646 | if (con_mode_ftm != QDF_GLOBAL_FTM_MODE) { |
| 11647 | pr_err("Only FTM mode supported!"); |
| 11648 | return -ENOTSUPP; |
| 11649 | } |
| 11650 | |
| 11651 | hdd_set_conparam(con_mode_ftm); |
| 11652 | con_mode = con_mode_ftm; |
| 11653 | |
| 11654 | return ret; |
| 11655 | } |
| 11656 | |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 11657 | static int con_mode_handler_monitor(const char *kmessage, |
| 11658 | struct kernel_param *kp) |
| 11659 | { |
| 11660 | int ret; |
| 11661 | |
| 11662 | ret = param_set_int(kmessage, kp); |
| 11663 | |
| 11664 | if (con_mode_monitor != QDF_GLOBAL_MONITOR_MODE) { |
| 11665 | pr_err("Only Monitor mode supported!"); |
| 11666 | return -ENOTSUPP; |
| 11667 | } |
| 11668 | |
| 11669 | hdd_set_conparam(con_mode_monitor); |
| 11670 | con_mode = con_mode_monitor; |
| 11671 | |
| 11672 | return ret; |
| 11673 | } |
| 11674 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11675 | /** |
| 11676 | * hdd_get_conparam() - driver exit point |
| 11677 | * |
| 11678 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 11679 | * |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 11680 | * Return: enum tQDF_GLOBAL_CON_MODE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11681 | */ |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 11682 | enum tQDF_GLOBAL_CON_MODE hdd_get_conparam(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11683 | { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 11684 | return (enum tQDF_GLOBAL_CON_MODE) curr_con_mode; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11685 | } |
| 11686 | |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 11687 | void hdd_set_conparam(uint32_t con_param) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11688 | { |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 11689 | curr_con_mode = con_param; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11690 | } |
| 11691 | |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 11692 | /** |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 11693 | * hdd_clean_up_pre_cac_interface() - Clean up the pre cac interface |
| 11694 | * @hdd_ctx: HDD context |
| 11695 | * |
| 11696 | * Cleans up the pre cac interface, if it exists |
| 11697 | * |
| 11698 | * Return: None |
| 11699 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11700 | void hdd_clean_up_pre_cac_interface(struct hdd_context *hdd_ctx) |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 11701 | { |
| 11702 | uint8_t session_id; |
| 11703 | QDF_STATUS status; |
Jeff Johnson | 85b5c11 | 2017-08-11 15:15:23 -0700 | [diff] [blame] | 11704 | struct hdd_adapter *precac_adapter; |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 11705 | |
| 11706 | status = wlan_sap_get_pre_cac_vdev_id(hdd_ctx->hHal, &session_id); |
| 11707 | if (QDF_IS_STATUS_ERROR(status)) { |
| 11708 | hdd_err("failed to get pre cac vdev id"); |
| 11709 | return; |
| 11710 | } |
| 11711 | |
| 11712 | precac_adapter = hdd_get_adapter_by_vdev(hdd_ctx, session_id); |
| 11713 | if (!precac_adapter) { |
| 11714 | hdd_err("invalid pre cac adapater"); |
| 11715 | return; |
| 11716 | } |
| 11717 | |
| 11718 | qdf_create_work(0, &hdd_ctx->sap_pre_cac_work, |
| 11719 | wlan_hdd_sap_pre_cac_failure, |
| 11720 | (void *)precac_adapter); |
| 11721 | qdf_sched_work(0, &hdd_ctx->sap_pre_cac_work); |
| 11722 | |
| 11723 | } |
| 11724 | |
| 11725 | /** |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 11726 | * hdd_update_ol_config - API to update ol configuration parameters |
| 11727 | * @hdd_ctx: HDD context |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 11728 | * |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 11729 | * Return: void |
| 11730 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11731 | static void hdd_update_ol_config(struct hdd_context *hdd_ctx) |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 11732 | { |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 11733 | struct ol_config_info cfg; |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 11734 | struct ol_context *ol_ctx = cds_get_context(QDF_MODULE_ID_BMI); |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 11735 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 11736 | if (!ol_ctx) |
| 11737 | return; |
| 11738 | |
| 11739 | cfg.enable_self_recovery = hdd_ctx->config->enableSelfRecovery; |
| 11740 | cfg.enable_uart_print = hdd_ctx->config->enablefwprint; |
| 11741 | cfg.enable_fw_log = hdd_ctx->config->enable_fw_log; |
| 11742 | cfg.enable_ramdump_collection = hdd_ctx->config->is_ramdump_enabled; |
Jeff Johnson | b8bf907 | 2016-09-23 17:39:27 -0700 | [diff] [blame] | 11743 | cfg.enable_lpass_support = hdd_lpass_is_supported(hdd_ctx); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 11744 | |
| 11745 | ol_init_ini_config(ol_ctx, &cfg); |
| 11746 | } |
| 11747 | |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 11748 | #ifdef FEATURE_RUNTIME_PM |
| 11749 | /** |
| 11750 | * hdd_populate_runtime_cfg() - populate runtime configuration |
| 11751 | * @hdd_ctx: hdd context |
| 11752 | * @cfg: pointer to the configuration memory being populated |
| 11753 | * |
| 11754 | * Return: void |
| 11755 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11756 | static void hdd_populate_runtime_cfg(struct hdd_context *hdd_ctx, |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 11757 | struct hif_config_info *cfg) |
| 11758 | { |
| 11759 | cfg->enable_runtime_pm = hdd_ctx->config->runtime_pm; |
| 11760 | cfg->runtime_pm_delay = hdd_ctx->config->runtime_pm_delay; |
| 11761 | } |
| 11762 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11763 | static void hdd_populate_runtime_cfg(struct hdd_context *hdd_ctx, |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 11764 | struct hif_config_info *cfg) |
| 11765 | { |
| 11766 | } |
| 11767 | #endif |
| 11768 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 11769 | /** |
| 11770 | * hdd_update_hif_config - API to update HIF configuration parameters |
| 11771 | * @hdd_ctx: HDD Context |
| 11772 | * |
| 11773 | * Return: void |
| 11774 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11775 | static void hdd_update_hif_config(struct hdd_context *hdd_ctx) |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 11776 | { |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 11777 | struct hif_opaque_softc *scn = cds_get_context(QDF_MODULE_ID_HIF); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 11778 | struct hif_config_info cfg; |
| 11779 | |
| 11780 | if (!scn) |
| 11781 | return; |
| 11782 | |
| 11783 | cfg.enable_self_recovery = hdd_ctx->config->enableSelfRecovery; |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 11784 | hdd_populate_runtime_cfg(hdd_ctx, &cfg); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 11785 | hif_init_ini_config(scn, &cfg); |
Dustin Brown | ee3e059 | 2017-09-07 13:50:11 -0700 | [diff] [blame] | 11786 | |
| 11787 | if (hdd_ctx->config->prevent_link_down) |
| 11788 | hif_vote_link_up(scn); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 11789 | } |
| 11790 | |
| 11791 | /** |
| 11792 | * hdd_update_config() - Initialize driver per module ini parameters |
| 11793 | * @hdd_ctx: HDD Context |
| 11794 | * |
| 11795 | * API is used to initialize all driver per module configuration parameters |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 11796 | * Return: 0 for success, errno for failure |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 11797 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11798 | int hdd_update_config(struct hdd_context *hdd_ctx) |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 11799 | { |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 11800 | int ret; |
| 11801 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 11802 | hdd_update_ol_config(hdd_ctx); |
| 11803 | hdd_update_hif_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 11804 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
| 11805 | ret = hdd_update_cds_config_ftm(hdd_ctx); |
| 11806 | else |
| 11807 | ret = hdd_update_cds_config(hdd_ctx); |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 11808 | ret = hdd_update_user_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 11809 | |
| 11810 | return ret; |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 11811 | } |
| 11812 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 11813 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 11814 | /** |
| 11815 | * hdd_ra_populate_cds_config() - Populate RA filtering cds configuration |
| 11816 | * @psoc_cfg: pmo psoc Configuration |
| 11817 | * @hdd_ctx: Pointer to hdd context |
| 11818 | * |
| 11819 | * Return: none |
| 11820 | */ |
| 11821 | static inline void hdd_ra_populate_pmo_config( |
| 11822 | struct pmo_psoc_cfg *psoc_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11823 | struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 11824 | { |
| 11825 | psoc_cfg->ra_ratelimit_interval = |
| 11826 | hdd_ctx->config->RArateLimitInterval; |
| 11827 | psoc_cfg->ra_ratelimit_enable = |
| 11828 | hdd_ctx->config->IsRArateLimitEnabled; |
| 11829 | } |
| 11830 | #else |
| 11831 | static inline void hdd_ra_populate_pmo_config( |
| 11832 | struct cds_config_info *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11833 | struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 11834 | { |
| 11835 | } |
| 11836 | #endif |
| 11837 | /** |
| 11838 | * hdd_update_pmo_config - API to update pmo configuration parameters |
| 11839 | * @hdd_ctx: HDD context |
| 11840 | * |
| 11841 | * Return: void |
| 11842 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11843 | static int hdd_update_pmo_config(struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 11844 | { |
| 11845 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 11846 | struct pmo_psoc_cfg psoc_cfg; |
| 11847 | QDF_STATUS status; |
| 11848 | |
| 11849 | /* |
| 11850 | * Value of hdd_ctx->wowEnable can be, |
| 11851 | * 0 - Disable both magic pattern match and pattern byte match. |
| 11852 | * 1 - Enable magic pattern match on all interfaces. |
| 11853 | * 2 - Enable pattern byte match on all interfaces. |
| 11854 | * 3 - Enable both magic patter and pattern byte match on |
| 11855 | * all interfaces. |
| 11856 | */ |
| 11857 | psoc_cfg.magic_ptrn_enable = |
| 11858 | (hdd_ctx->config->wowEnable & 0x01) ? true : false; |
| 11859 | psoc_cfg.ptrn_match_enable_all_vdev = |
| 11860 | (hdd_ctx->config->wowEnable & 0x02) ? true : false; |
Will Huang | fe64917 | 2017-09-06 16:52:18 +0800 | [diff] [blame] | 11861 | psoc_cfg.ptrn_id_per_vdev = wma_is_service_enabled( |
| 11862 | WMI_SERVICE_UNIFIED_WOW_CAPABILITY); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 11863 | psoc_cfg.bpf_enable = |
| 11864 | hdd_ctx->config->bpf_packet_filter_enable; |
| 11865 | psoc_cfg.arp_offload_enable = hdd_ctx->config->fhostArpOffload; |
Dustin Brown | 1224e21 | 2017-05-12 14:02:12 -0700 | [diff] [blame] | 11866 | psoc_cfg.hw_filter_mode = hdd_ctx->config->hw_filter_mode; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 11867 | psoc_cfg.ns_offload_enable_static = hdd_ctx->config->fhostNSOffload; |
| 11868 | if (hdd_ctx->config->fhostNSOffload) |
| 11869 | psoc_cfg.ns_offload_enable_dynamic = true; |
| 11870 | psoc_cfg.ssdp = hdd_ctx->config->ssdp; |
| 11871 | psoc_cfg.enable_mc_list = hdd_ctx->config->fEnableMCAddrList; |
| 11872 | psoc_cfg.active_mode_offload = |
| 11873 | hdd_ctx->config->active_mode_offload; |
| 11874 | psoc_cfg.ap_arpns_support = hdd_ctx->ap_arpns_support; |
| 11875 | psoc_cfg.max_wow_filters = hdd_ctx->config->maxWoWFilters; |
Mukul Sharma | 9223f23 | 2017-03-08 18:42:27 +0530 | [diff] [blame] | 11876 | psoc_cfg.sta_dynamic_dtim = hdd_ctx->config->enableDynamicDTIM; |
| 11877 | psoc_cfg.sta_mod_dtim = hdd_ctx->config->enableModulatedDTIM; |
| 11878 | psoc_cfg.sta_max_li_mod_dtim = hdd_ctx->config->fMaxLIModulatedDTIM; |
| 11879 | psoc_cfg.power_save_mode = |
| 11880 | hdd_ctx->config->enablePowersaveOffload; |
Ravi Kumar Bokka | 05c14e5 | 2017-03-27 14:48:23 +0530 | [diff] [blame] | 11881 | psoc_cfg.auto_power_save_fail_mode = |
| 11882 | hdd_ctx->config->auto_pwr_save_fail_mode; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 11883 | |
| 11884 | hdd_ra_populate_pmo_config(&psoc_cfg, hdd_ctx); |
Mukul Sharma | 9223f23 | 2017-03-08 18:42:27 +0530 | [diff] [blame] | 11885 | hdd_nan_populate_pmo_config(&psoc_cfg, hdd_ctx); |
| 11886 | hdd_lpass_populate_pmo_config(&psoc_cfg, hdd_ctx); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 11887 | status = pmo_ucfg_update_psoc_config(psoc, &psoc_cfg); |
| 11888 | if (status != QDF_STATUS_SUCCESS) { |
| 11889 | hdd_err("failed pmo psoc configuration"); |
| 11890 | return -EINVAL; |
| 11891 | } |
| 11892 | |
| 11893 | return 0; |
| 11894 | } |
| 11895 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 11896 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 11897 | static inline void hdd_update_pno_config(struct pno_user_cfg *pno_cfg, |
| 11898 | struct hdd_config *cfg) |
| 11899 | { |
Varun Reddy Yeturu | bba32e9 | 2017-09-06 13:31:40 -0700 | [diff] [blame] | 11900 | struct nlo_mawc_params *mawc_cfg = &pno_cfg->mawc_params; |
| 11901 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 11902 | pno_cfg->channel_prediction = cfg->pno_channel_prediction; |
| 11903 | pno_cfg->top_k_num_of_channels = cfg->top_k_num_of_channels; |
| 11904 | pno_cfg->stationary_thresh = cfg->stationary_thresh; |
| 11905 | pno_cfg->adaptive_dwell_mode = cfg->adaptive_dwell_mode_enabled; |
| 11906 | pno_cfg->channel_prediction_full_scan = |
| 11907 | cfg->channel_prediction_full_scan; |
Varun Reddy Yeturu | bba32e9 | 2017-09-06 13:31:40 -0700 | [diff] [blame] | 11908 | mawc_cfg->enable = cfg->MAWCEnabled && cfg->mawc_nlo_enabled; |
| 11909 | mawc_cfg->exp_backoff_ratio = cfg->mawc_nlo_exp_backoff_ratio; |
| 11910 | mawc_cfg->init_scan_interval = cfg->mawc_nlo_init_scan_interval; |
| 11911 | mawc_cfg->max_scan_interval = cfg->mawc_nlo_max_scan_interval; |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 11912 | } |
| 11913 | #else |
| 11914 | static inline void |
| 11915 | hdd_update_pno_config(struct pno_user_cfg *pno_cfg, |
| 11916 | struct hdd_config *cfg) |
| 11917 | { |
| 11918 | return; |
| 11919 | } |
| 11920 | #endif |
| 11921 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 11922 | void hdd_update_ie_whitelist_attr(struct probe_req_whitelist_attr *ie_whitelist, |
| 11923 | struct hdd_config *cfg) |
| 11924 | { |
| 11925 | uint8_t i = 0; |
| 11926 | |
| 11927 | ie_whitelist->white_list = cfg->probe_req_ie_whitelist; |
| 11928 | if (!ie_whitelist->white_list) |
| 11929 | return; |
| 11930 | |
| 11931 | ie_whitelist->ie_bitmap[0] = cfg->probe_req_ie_bitmap_0; |
| 11932 | ie_whitelist->ie_bitmap[1] = cfg->probe_req_ie_bitmap_1; |
| 11933 | ie_whitelist->ie_bitmap[2] = cfg->probe_req_ie_bitmap_2; |
| 11934 | ie_whitelist->ie_bitmap[3] = cfg->probe_req_ie_bitmap_3; |
| 11935 | ie_whitelist->ie_bitmap[4] = cfg->probe_req_ie_bitmap_4; |
| 11936 | ie_whitelist->ie_bitmap[5] = cfg->probe_req_ie_bitmap_5; |
| 11937 | ie_whitelist->ie_bitmap[6] = cfg->probe_req_ie_bitmap_6; |
| 11938 | ie_whitelist->ie_bitmap[7] = cfg->probe_req_ie_bitmap_7; |
| 11939 | |
| 11940 | ie_whitelist->num_vendor_oui = cfg->no_of_probe_req_ouis; |
| 11941 | for (i = 0; i < ie_whitelist->num_vendor_oui; i++) |
| 11942 | ie_whitelist->voui[i] = cfg->probe_req_voui[i]; |
| 11943 | } |
| 11944 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 11945 | /** |
| 11946 | * hdd_update_scan_config - API to update scan configuration parameters |
| 11947 | * @hdd_ctx: HDD context |
| 11948 | * |
| 11949 | * Return: 0 if success else err |
| 11950 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11951 | static int hdd_update_scan_config(struct hdd_context *hdd_ctx) |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 11952 | { |
| 11953 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 11954 | struct scan_user_cfg scan_cfg; |
| 11955 | struct hdd_config *cfg = hdd_ctx->config; |
| 11956 | QDF_STATUS status; |
| 11957 | |
| 11958 | scan_cfg.active_dwell = cfg->nActiveMaxChnTime; |
| 11959 | scan_cfg.passive_dwell = cfg->nPassiveMaxChnTime; |
| 11960 | scan_cfg.conc_active_dwell = cfg->nActiveMaxChnTimeConc; |
| 11961 | scan_cfg.conc_passive_dwell = cfg->nPassiveMaxChnTimeConc; |
| 11962 | scan_cfg.conc_max_rest_time = cfg->nRestTimeConc; |
| 11963 | scan_cfg.conc_min_rest_time = cfg->min_rest_time_conc; |
| 11964 | scan_cfg.conc_idle_time = cfg->idle_time_conc; |
Abhishek Singh | 158fe25 | 2017-03-23 11:09:34 +0530 | [diff] [blame] | 11965 | /* convert to ms */ |
| 11966 | scan_cfg.scan_cache_aging_time = |
| 11967 | cfg->scanAgingTimeout * 1000; |
| 11968 | scan_cfg.prefer_5ghz = cfg->nRoamPrefer5GHz; |
| 11969 | scan_cfg.select_5ghz_margin = cfg->nSelect5GHzMargin; |
| 11970 | scan_cfg.scan_bucket_threshold = cfg->first_scan_bucket_threshold; |
| 11971 | scan_cfg.rssi_cat_gap = cfg->nRssiCatGap; |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 11972 | scan_cfg.scan_dwell_time_mode = cfg->scan_adaptive_dwell_mode; |
Kapil Gupta | fa9a8c6 | 2017-04-10 15:25:40 +0530 | [diff] [blame] | 11973 | scan_cfg.is_snr_monitoring_enabled = cfg->fEnableSNRMonitoring; |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 11974 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 11975 | hdd_update_pno_config(&scan_cfg.pno_cfg, cfg); |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 11976 | hdd_update_ie_whitelist_attr(&scan_cfg.ie_whitelist, cfg); |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 11977 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 11978 | status = ucfg_scan_update_user_config(psoc, &scan_cfg); |
| 11979 | if (status != QDF_STATUS_SUCCESS) { |
| 11980 | hdd_err("failed pmo psoc configuration"); |
| 11981 | return -EINVAL; |
| 11982 | } |
| 11983 | |
| 11984 | return 0; |
| 11985 | } |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 11986 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11987 | static int hdd_update_tdls_config(struct hdd_context *hdd_ctx) |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 11988 | { |
| 11989 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 11990 | struct tdls_start_params tdls_cfg; |
| 11991 | struct tdls_user_config *config = &tdls_cfg.config; |
| 11992 | struct hdd_config *cfg = hdd_ctx->config; |
| 11993 | QDF_STATUS status; |
| 11994 | |
| 11995 | config->tdls_tx_states_period = cfg->fTDLSTxStatsPeriod; |
| 11996 | config->tdls_tx_pkt_threshold = cfg->fTDLSTxPacketThreshold; |
| 11997 | config->tdls_rx_pkt_threshold = cfg->fTDLSRxFrameThreshold; |
| 11998 | config->tdls_max_discovery_attempt = cfg->fTDLSMaxDiscoveryAttempt; |
| 11999 | config->tdls_idle_timeout = cfg->tdls_idle_timeout; |
| 12000 | config->tdls_idle_pkt_threshold = cfg->fTDLSIdlePacketThreshold; |
| 12001 | config->tdls_rssi_trigger_threshold = cfg->fTDLSRSSITriggerThreshold; |
| 12002 | config->tdls_rssi_teardown_threshold = cfg->fTDLSRSSITeardownThreshold; |
| 12003 | config->tdls_rssi_delta = cfg->fTDLSRSSIDelta; |
| 12004 | config->tdls_uapsd_mask = cfg->fTDLSUapsdMask; |
| 12005 | config->tdls_uapsd_inactivity_time = cfg->fTDLSPuapsdInactivityTimer; |
| 12006 | config->tdls_uapsd_pti_window = cfg->fTDLSPuapsdPTIWindow; |
| 12007 | config->tdls_uapsd_ptr_timeout = cfg->fTDLSPuapsdPTRTimeout; |
| 12008 | config->tdls_pre_off_chan_num = cfg->fTDLSPrefOffChanNum; |
| 12009 | config->tdls_pre_off_chan_bw = cfg->fTDLSPrefOffChanBandwidth; |
| 12010 | config->tdls_peer_kickout_threshold = cfg->tdls_peer_kickout_threshold; |
| 12011 | config->delayed_trig_framint = cfg->DelayedTriggerFrmInt; |
| 12012 | config->tdls_feature_flags = ((cfg->fEnableTDLSOffChannel ? |
| 12013 | 1 << TDLS_FEATURE_OFF_CHANNEL : 0) | |
| 12014 | (cfg->fEnableTDLSWmmMode ? 1 << TDLS_FEATURE_WMM : 0) | |
| 12015 | (cfg->fEnableTDLSBufferSta ? 1 << TDLS_FEATURE_BUFFER_STA : 0) | |
| 12016 | (cfg->fEnableTDLSSleepSta ? 1 << TDLS_FEATURE_SLEEP_STA : 0) | |
| 12017 | (cfg->enable_tdls_scan ? 1 << TDLS_FEATURE_SCAN : 0) | |
| 12018 | (cfg->fEnableTDLSSupport ? 1 << TDLS_FEATURE_ENABLE : 0) | |
| 12019 | (cfg->fEnableTDLSImplicitTrigger ? |
| 12020 | 1 << TDLS_FEAUTRE_IMPLICIT_TRIGGER : 0) | |
| 12021 | (cfg->fTDLSExternalControl ? |
| 12022 | 1 << TDLS_FEATURE_EXTERNAL_CONTROL : 0)); |
| 12023 | |
| 12024 | tdls_cfg.tdls_send_mgmt_req = eWNI_SME_TDLS_SEND_MGMT_REQ; |
| 12025 | tdls_cfg.tdls_add_sta_req = eWNI_SME_TDLS_ADD_STA_REQ; |
| 12026 | tdls_cfg.tdls_del_sta_req = eWNI_SME_TDLS_DEL_STA_REQ; |
| 12027 | tdls_cfg.tdls_update_peer_state = WMA_UPDATE_TDLS_PEER_STATE; |
Kabilan Kannan | 1c1c402 | 2017-04-06 22:49:26 -0700 | [diff] [blame] | 12028 | tdls_cfg.tdls_del_all_peers = eWNI_SME_DEL_ALL_TDLS_PEERS; |
Kabilan Kannan | 256e318 | 2017-05-02 16:02:37 -0700 | [diff] [blame] | 12029 | tdls_cfg.tdls_update_dp_vdev_flags = CDP_UPDATE_TDLS_FLAGS; |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 12030 | tdls_cfg.tdls_event_cb = wlan_cfg80211_tdls_event_callback; |
| 12031 | tdls_cfg.tdls_evt_cb_data = psoc; |
| 12032 | tdls_cfg.tdls_tl_peer_data = hdd_ctx; |
| 12033 | tdls_cfg.tdls_reg_tl_peer = hdd_tdls_register_tdls_peer; |
| 12034 | tdls_cfg.tdls_dereg_tl_peer = hdd_tdls_deregister_tdl_peer; |
Kabilan Kannan | f56f9d5 | 2017-04-05 03:31:34 -0700 | [diff] [blame] | 12035 | tdls_cfg.tdls_wmm_cb = hdd_wmm_is_acm_allowed; |
| 12036 | tdls_cfg.tdls_wmm_cb_data = psoc; |
| 12037 | tdls_cfg.tdls_rx_cb = wlan_cfg80211_tdls_rx_callback; |
| 12038 | tdls_cfg.tdls_rx_cb_data = psoc; |
Kabilan Kannan | 256e318 | 2017-05-02 16:02:37 -0700 | [diff] [blame] | 12039 | tdls_cfg.tdls_dp_vdev_update = hdd_update_dp_vdev_flags; |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 12040 | |
| 12041 | status = ucfg_tdls_update_config(psoc, &tdls_cfg); |
| 12042 | if (status != QDF_STATUS_SUCCESS) { |
| 12043 | hdd_err("failed pmo psoc configuration"); |
| 12044 | return -EINVAL; |
| 12045 | } |
| 12046 | |
Kabilan Kannan | 1c1c402 | 2017-04-06 22:49:26 -0700 | [diff] [blame] | 12047 | hdd_ctx->tdls_umac_comp_active = true; |
Kabilan Kannan | c0e3d58 | 2017-09-13 00:26:33 -0700 | [diff] [blame] | 12048 | /* enable napier specific tdls data path */ |
| 12049 | hdd_ctx->tdls_nap_active = true; |
Kabilan Kannan | 1c1c402 | 2017-04-06 22:49:26 -0700 | [diff] [blame] | 12050 | |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 12051 | return 0; |
| 12052 | } |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 12053 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12054 | int hdd_update_components_config(struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12055 | { |
| 12056 | int ret; |
| 12057 | |
| 12058 | ret = hdd_update_pmo_config(hdd_ctx); |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12059 | if (ret) |
| 12060 | return ret; |
| 12061 | ret = hdd_update_scan_config(hdd_ctx); |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 12062 | if (ret) |
| 12063 | return ret; |
| 12064 | ret = hdd_update_tdls_config(hdd_ctx); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12065 | |
| 12066 | return ret; |
| 12067 | } |
| 12068 | |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 12069 | /** |
| 12070 | * wlan_hdd_get_dfs_mode() - get ACS DFS mode |
| 12071 | * @mode : cfg80211 DFS mode |
| 12072 | * |
| 12073 | * Return: return SAP ACS DFS mode else return ACS_DFS_MODE_NONE |
| 12074 | */ |
| 12075 | enum sap_acs_dfs_mode wlan_hdd_get_dfs_mode(enum dfs_mode mode) |
| 12076 | { |
| 12077 | switch (mode) { |
| 12078 | case DFS_MODE_ENABLE: |
| 12079 | return ACS_DFS_MODE_ENABLE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 12080 | case DFS_MODE_DISABLE: |
| 12081 | return ACS_DFS_MODE_DISABLE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 12082 | case DFS_MODE_DEPRIORITIZE: |
| 12083 | return ACS_DFS_MODE_DEPRIORITIZE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 12084 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12085 | hdd_debug("ACS dfs mode is NONE"); |
| 12086 | return ACS_DFS_MODE_NONE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 12087 | } |
| 12088 | } |
| 12089 | |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 12090 | /** |
| 12091 | * hdd_enable_disable_ca_event() - enable/disable channel avoidance event |
| 12092 | * @hddctx: pointer to hdd context |
| 12093 | * @set_value: enable/disable |
| 12094 | * |
| 12095 | * When Host sends vendor command enable, FW will send *ONE* CA ind to |
| 12096 | * Host(even though it is duplicate). When Host send vendor command |
| 12097 | * disable,FW doesn't perform any action. Whenever any change in |
| 12098 | * CA *and* WLAN is in SAP/P2P-GO mode, FW sends CA ind to host. |
| 12099 | * |
| 12100 | * return - 0 on success, appropriate error values on failure. |
| 12101 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12102 | int hdd_enable_disable_ca_event(struct hdd_context *hddctx, uint8_t set_value) |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 12103 | { |
| 12104 | QDF_STATUS status; |
| 12105 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 12106 | if (0 != wlan_hdd_validate_context(hddctx)) |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 12107 | return -EAGAIN; |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 12108 | |
| 12109 | if (!hddctx->config->goptimize_chan_avoid_event) { |
| 12110 | hdd_warn("goptimize_chan_avoid_event ini param disabled"); |
| 12111 | return -EINVAL; |
| 12112 | } |
| 12113 | |
| 12114 | status = sme_enable_disable_chanavoidind_event(hddctx->hHal, set_value); |
| 12115 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 12116 | hdd_err("Failed to send chan avoid command to SME"); |
| 12117 | return -EINVAL; |
| 12118 | } |
| 12119 | return 0; |
| 12120 | } |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 12121 | |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12122 | /** |
| 12123 | * hdd_set_roaming_in_progress() - to set the roaming in progress flag |
| 12124 | * @value: value to set |
| 12125 | * |
| 12126 | * This function will set the passed value to roaming in progress flag. |
| 12127 | * |
| 12128 | * Return: None |
| 12129 | */ |
| 12130 | void hdd_set_roaming_in_progress(bool value) |
| 12131 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12132 | struct hdd_context *hdd_ctx; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12133 | |
| 12134 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 12135 | if (!hdd_ctx) { |
| 12136 | hdd_err("HDD context is NULL"); |
| 12137 | return; |
| 12138 | } |
| 12139 | |
| 12140 | hdd_ctx->roaming_in_progress = value; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12141 | hdd_debug("Roaming in Progress set to %d", value); |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12142 | } |
| 12143 | |
| 12144 | /** |
| 12145 | * hdd_is_roaming_in_progress() - check if roaming is in progress |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 12146 | * @adapter - HDD adapter |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12147 | * |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 12148 | * Return: true if roaming is in progress for STA type, else false |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12149 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12150 | bool hdd_is_roaming_in_progress(struct hdd_adapter *adapter) |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12151 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12152 | struct hdd_context *hdd_ctx; |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 12153 | bool ret_status = false; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12154 | |
| 12155 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 12156 | if (!hdd_ctx) { |
| 12157 | hdd_err("HDD context is NULL"); |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 12158 | return ret_status; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12159 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12160 | hdd_debug("dev mode = %d, roaming_in_progress = %d", |
| 12161 | adapter->device_mode, hdd_ctx->roaming_in_progress); |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 12162 | ret_status = ((adapter->device_mode == QDF_STA_MODE) && |
| 12163 | hdd_ctx->roaming_in_progress); |
| 12164 | |
| 12165 | return ret_status; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12166 | } |
| 12167 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12168 | /** |
| 12169 | * hdd_is_connection_in_progress() - check if connection is in |
| 12170 | * progress |
| 12171 | * @session_id: session id |
| 12172 | * @reason: scan reject reason |
| 12173 | * |
| 12174 | * Go through each adapter and check if Connection is in progress |
| 12175 | * |
| 12176 | * Return: true if connection is in progress else false |
| 12177 | */ |
| 12178 | bool hdd_is_connection_in_progress(uint8_t *session_id, |
| 12179 | enum scan_reject_states *reason) |
| 12180 | { |
| 12181 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 12182 | struct hdd_station_ctx *hdd_sta_ctx = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12183 | struct hdd_adapter *adapter = NULL; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12184 | QDF_STATUS status = 0; |
| 12185 | uint8_t sta_id = 0; |
| 12186 | uint8_t *sta_mac = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12187 | struct hdd_context *hdd_ctx; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12188 | |
| 12189 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 12190 | if (!hdd_ctx) { |
| 12191 | hdd_err("HDD context is NULL"); |
| 12192 | return false; |
| 12193 | } |
| 12194 | |
| 12195 | if (true == hdd_ctx->btCoexModeSet) { |
| 12196 | hdd_info("BTCoex Mode operation in progress"); |
| 12197 | return true; |
| 12198 | } |
| 12199 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
| 12200 | while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) { |
| 12201 | adapter = adapter_node->pAdapter; |
| 12202 | if (!adapter) |
| 12203 | goto end; |
| 12204 | |
| 12205 | hdd_info("Adapter with device mode %s(%d) exists", |
| 12206 | hdd_device_mode_to_string(adapter->device_mode), |
| 12207 | adapter->device_mode); |
| 12208 | if (((QDF_STA_MODE == adapter->device_mode) |
| 12209 | || (QDF_P2P_CLIENT_MODE == adapter->device_mode) |
| 12210 | || (QDF_P2P_DEVICE_MODE == adapter->device_mode)) |
| 12211 | && (eConnectionState_Connecting == |
| 12212 | (WLAN_HDD_GET_STATION_CTX_PTR(adapter))-> |
| 12213 | conn_info.connState)) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 12214 | hdd_debug("%pK(%d) Connection is in progress", |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12215 | WLAN_HDD_GET_STATION_CTX_PTR(adapter), |
| 12216 | adapter->sessionId); |
| 12217 | if (session_id && reason) { |
| 12218 | *session_id = adapter->sessionId; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12219 | *reason = CONNECTION_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12220 | } |
| 12221 | return true; |
| 12222 | } |
Archana Ramachandran | 62886ce | 2017-03-24 14:46:32 -0700 | [diff] [blame] | 12223 | /* |
| 12224 | * sme_neighbor_middle_of_roaming is for LFR2 |
| 12225 | * hdd_is_roaming_in_progress is for LFR3 |
| 12226 | */ |
| 12227 | if (((QDF_STA_MODE == adapter->device_mode) && |
| 12228 | sme_neighbor_middle_of_roaming( |
| 12229 | WLAN_HDD_GET_HAL_CTX(adapter), |
| 12230 | adapter->sessionId)) || |
| 12231 | hdd_is_roaming_in_progress(adapter)) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 12232 | hdd_debug("%pK(%d) Reassociation in progress", |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12233 | WLAN_HDD_GET_STATION_CTX_PTR(adapter), |
| 12234 | adapter->sessionId); |
| 12235 | if (session_id && reason) { |
| 12236 | *session_id = adapter->sessionId; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12237 | *reason = REASSOC_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12238 | } |
| 12239 | return true; |
| 12240 | } |
| 12241 | if ((QDF_STA_MODE == adapter->device_mode) || |
| 12242 | (QDF_P2P_CLIENT_MODE == adapter->device_mode) || |
| 12243 | (QDF_P2P_DEVICE_MODE == adapter->device_mode)) { |
| 12244 | hdd_sta_ctx = |
| 12245 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 12246 | if ((eConnectionState_Associated == |
| 12247 | hdd_sta_ctx->conn_info.connState) |
| 12248 | && (false == |
| 12249 | hdd_sta_ctx->conn_info.uIsAuthenticated)) { |
| 12250 | sta_mac = (uint8_t *) |
| 12251 | &(adapter->macAddressCurrent.bytes[0]); |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 12252 | hdd_debug("client " MAC_ADDRESS_STR |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12253 | " is in middle of WPS/EAPOL exchange.", |
| 12254 | MAC_ADDR_ARRAY(sta_mac)); |
| 12255 | if (session_id && reason) { |
| 12256 | *session_id = adapter->sessionId; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12257 | *reason = EAPOL_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12258 | } |
| 12259 | return true; |
| 12260 | } |
| 12261 | } else if ((QDF_SAP_MODE == adapter->device_mode) || |
| 12262 | (QDF_P2P_GO_MODE == adapter->device_mode)) { |
| 12263 | for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; |
| 12264 | sta_id++) { |
| 12265 | if (!((adapter->aStaInfo[sta_id].isUsed) |
| 12266 | && (OL_TXRX_PEER_STATE_CONN == |
| 12267 | adapter->aStaInfo[sta_id].tlSTAState))) |
| 12268 | continue; |
| 12269 | |
| 12270 | sta_mac = (uint8_t *) |
| 12271 | &(adapter->aStaInfo[sta_id]. |
| 12272 | macAddrSTA.bytes[0]); |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 12273 | hdd_debug("client " MAC_ADDRESS_STR |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12274 | " of SAP/GO is in middle of WPS/EAPOL exchange", |
| 12275 | MAC_ADDR_ARRAY(sta_mac)); |
| 12276 | if (session_id && reason) { |
| 12277 | *session_id = adapter->sessionId; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12278 | *reason = SAP_EAPOL_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12279 | } |
| 12280 | return true; |
| 12281 | } |
| 12282 | if (hdd_ctx->connection_in_progress) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 12283 | hdd_debug("AP/GO: connection is in progress"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12284 | return true; |
| 12285 | } |
| 12286 | } |
| 12287 | end: |
| 12288 | status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next); |
| 12289 | adapter_node = next; |
| 12290 | } |
| 12291 | return false; |
| 12292 | } |
| 12293 | |
| 12294 | /** |
| 12295 | * hdd_restart_sap() - to restart SAP in driver internally |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12296 | * @ap_adapter: Pointer to SAP struct hdd_adapter structure |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12297 | * |
| 12298 | * Return: None |
| 12299 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12300 | void hdd_restart_sap(struct hdd_adapter *ap_adapter) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12301 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 12302 | struct hdd_ap_ctx *hdd_ap_ctx; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12303 | hdd_hostapd_state_t *hostapd_state; |
| 12304 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12305 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12306 | tsap_Config_t *sap_config; |
| 12307 | void *sap_ctx; |
| 12308 | |
| 12309 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 12310 | sap_config = &hdd_ap_ctx->sapConfig; |
| 12311 | sap_ctx = hdd_ap_ctx->sapContext; |
| 12312 | |
| 12313 | mutex_lock(&hdd_ctx->sap_lock); |
| 12314 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
| 12315 | wlan_hdd_del_station(ap_adapter); |
| 12316 | hdd_cleanup_actionframe(hdd_ctx, ap_adapter); |
| 12317 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
| 12318 | qdf_event_reset(&hostapd_state->qdf_stop_bss_event); |
| 12319 | if (QDF_STATUS_SUCCESS == wlansap_stop_bss(sap_ctx)) { |
| 12320 | qdf_status = |
| 12321 | qdf_wait_single_event(&hostapd_state-> |
| 12322 | qdf_stop_bss_event, |
| 12323 | SME_CMD_TIMEOUT_VALUE); |
| 12324 | |
| 12325 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 12326 | cds_err("SAP Stop Failed"); |
| 12327 | goto end; |
| 12328 | } |
| 12329 | } |
| 12330 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12331 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12332 | ap_adapter->device_mode, ap_adapter->sessionId); |
| 12333 | cds_err("SAP Stop Success"); |
| 12334 | |
| 12335 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
| 12336 | cds_err("SAP Not able to set AP IEs"); |
| 12337 | wlansap_reset_sap_config_add_ie(sap_config, |
| 12338 | eUPDATE_IE_ALL); |
| 12339 | goto end; |
| 12340 | } |
| 12341 | |
| 12342 | qdf_event_reset(&hostapd_state->qdf_event); |
| 12343 | if (wlansap_start_bss(sap_ctx, hdd_hostapd_sap_event_cb, |
| 12344 | sap_config, |
| 12345 | ap_adapter->dev) != QDF_STATUS_SUCCESS) { |
| 12346 | cds_err("SAP Start Bss fail"); |
| 12347 | wlansap_reset_sap_config_add_ie(sap_config, |
| 12348 | eUPDATE_IE_ALL); |
| 12349 | goto end; |
| 12350 | } |
| 12351 | |
| 12352 | cds_info("Waiting for SAP to start"); |
| 12353 | qdf_status = |
| 12354 | qdf_wait_single_event(&hostapd_state->qdf_event, |
| 12355 | SME_CMD_TIMEOUT_VALUE); |
| 12356 | wlansap_reset_sap_config_add_ie(sap_config, |
| 12357 | eUPDATE_IE_ALL); |
| 12358 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 12359 | cds_err("SAP Start failed"); |
| 12360 | goto end; |
| 12361 | } |
| 12362 | cds_err("SAP Start Success"); |
| 12363 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
| 12364 | if (hostapd_state->bssState == BSS_START) |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12365 | policy_mgr_incr_active_session(hdd_ctx->hdd_psoc, |
| 12366 | ap_adapter->device_mode, |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12367 | ap_adapter->sessionId); |
| 12368 | hostapd_state->bCommit = true; |
| 12369 | } |
| 12370 | end: |
| 12371 | mutex_unlock(&hdd_ctx->sap_lock); |
| 12372 | return; |
| 12373 | } |
| 12374 | |
| 12375 | /** |
| 12376 | * hdd_check_and_restart_sap_with_non_dfs_acs() - Restart SAP |
| 12377 | * with non dfs acs |
| 12378 | * |
| 12379 | * Restarts SAP in non-DFS ACS mode when STA-AP mode DFS is not supported |
| 12380 | * |
| 12381 | * Return: None |
| 12382 | */ |
| 12383 | void hdd_check_and_restart_sap_with_non_dfs_acs(void) |
| 12384 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12385 | struct hdd_adapter *ap_adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12386 | struct hdd_context *hdd_ctx; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12387 | cds_context_type *cds_ctx; |
| 12388 | |
| 12389 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 12390 | if (!hdd_ctx) { |
| 12391 | cds_err("HDD context is NULL"); |
| 12392 | return; |
| 12393 | } |
| 12394 | |
| 12395 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 12396 | if (!cds_ctx) { |
| 12397 | cds_err("Invalid CDS Context"); |
| 12398 | return; |
| 12399 | } |
| 12400 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12401 | if (policy_mgr_get_concurrency_mode(hdd_ctx->hdd_psoc) |
| 12402 | != (QDF_STA_MASK | QDF_SAP_MASK)) { |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12403 | cds_info("Concurrency mode is not SAP"); |
| 12404 | return; |
| 12405 | } |
| 12406 | |
| 12407 | ap_adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE); |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 12408 | if (ap_adapter != NULL && test_bit(SOFTAP_BSS_STARTED, |
| 12409 | &ap_adapter->event_flags) && |
| 12410 | wlan_reg_is_dfs_ch(hdd_ctx->hdd_pdev, |
| 12411 | ap_adapter->sessionCtx.ap.operatingChannel)) { |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12412 | |
| 12413 | cds_warn("STA-AP Mode DFS not supported. Restart SAP with Non DFS ACS"); |
| 12414 | ap_adapter->sessionCtx.ap.sapConfig.channel = |
| 12415 | AUTO_CHANNEL_SELECT; |
| 12416 | ap_adapter->sessionCtx.ap.sapConfig. |
| 12417 | acs_cfg.acs_mode = true; |
| 12418 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12419 | hdd_restart_sap(ap_adapter); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12420 | } |
| 12421 | } |
| 12422 | |
| 12423 | /** |
| 12424 | * hdd_set_connection_in_progress() - to set the connection in |
| 12425 | * progress flag |
| 12426 | * @value: value to set |
| 12427 | * |
| 12428 | * This function will set the passed value to connection in progress flag. |
| 12429 | * If value is previously being set to true then no need to set it again. |
| 12430 | * |
| 12431 | * Return: true if value is being set correctly and false otherwise. |
| 12432 | */ |
| 12433 | bool hdd_set_connection_in_progress(bool value) |
| 12434 | { |
| 12435 | bool status = true; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12436 | struct hdd_context *hdd_ctx; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12437 | |
| 12438 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 12439 | if (!hdd_ctx) { |
| 12440 | cds_err("HDD context is NULL"); |
| 12441 | return false; |
| 12442 | } |
| 12443 | |
| 12444 | qdf_spin_lock(&hdd_ctx->connection_status_lock); |
| 12445 | /* |
| 12446 | * if the value is set to true previously and if someone is |
| 12447 | * trying to make it true again then it could be some race |
| 12448 | * condition being triggered. Avoid this situation by returning |
| 12449 | * false |
| 12450 | */ |
| 12451 | if (hdd_ctx->connection_in_progress && value) |
| 12452 | status = false; |
| 12453 | else |
| 12454 | hdd_ctx->connection_in_progress = value; |
| 12455 | qdf_spin_unlock(&hdd_ctx->connection_status_lock); |
| 12456 | return status; |
| 12457 | } |
| 12458 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12459 | int wlan_hdd_send_p2p_quota(struct hdd_adapter *adapter, int set_value) |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 12460 | { |
| 12461 | if (!adapter) { |
| 12462 | hdd_err("Invalid adapter"); |
| 12463 | return -EINVAL; |
| 12464 | } |
| 12465 | hdd_info("Send MCC P2P QUOTA to WMA: %d", set_value); |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 12466 | sme_cli_set_command(adapter->sessionId, |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 12467 | WMA_VDEV_MCC_SET_TIME_QUOTA, |
| 12468 | set_value, VDEV_CMD); |
| 12469 | return 0; |
| 12470 | |
| 12471 | } |
| 12472 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12473 | int wlan_hdd_send_mcc_latency(struct hdd_adapter *adapter, int set_value) |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 12474 | { |
| 12475 | if (!adapter) { |
| 12476 | hdd_err("Invalid adapter"); |
| 12477 | return -EINVAL; |
| 12478 | } |
| 12479 | |
| 12480 | hdd_info("Send MCC latency WMA: %d", set_value); |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 12481 | sme_cli_set_command(adapter->sessionId, |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 12482 | WMA_VDEV_MCC_SET_TIME_LATENCY, |
| 12483 | set_value, VDEV_CMD); |
| 12484 | return 0; |
| 12485 | } |
| 12486 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12487 | struct hdd_adapter *wlan_hdd_get_adapter_from_vdev(struct wlan_objmgr_psoc |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 12488 | *psoc, uint8_t vdev_id) |
| 12489 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12490 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12491 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 12492 | |
| 12493 | /* |
| 12494 | * Currently PSOC is not being used. But this logic will |
| 12495 | * change once we have the converged implementation of |
| 12496 | * HDD context per PSOC in place. This would break if |
| 12497 | * multiple vdev objects reuse the vdev id. |
| 12498 | */ |
| 12499 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 12500 | if (!adapter) |
| 12501 | hdd_err("Get adapter by vdev id failed"); |
| 12502 | |
| 12503 | return adapter; |
| 12504 | } |
| 12505 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12506 | int hdd_get_rssi_snr_by_bssid(struct hdd_adapter *adapter, const uint8_t *bssid, |
Hanumanth Reddy Pothula | 9005178 | 2017-05-04 22:14:43 +0530 | [diff] [blame] | 12507 | int8_t *rssi, int8_t *snr) |
| 12508 | { |
| 12509 | QDF_STATUS status; |
| 12510 | hdd_wext_state_t *wext_state = WLAN_HDD_GET_WEXT_STATE_PTR(adapter); |
| 12511 | tCsrRoamProfile *profile = &wext_state->roamProfile; |
| 12512 | |
| 12513 | status = sme_get_rssi_snr_by_bssid(WLAN_HDD_GET_HAL_CTX(adapter), |
| 12514 | profile, bssid, rssi, snr); |
| 12515 | if (QDF_STATUS_SUCCESS != status) { |
| 12516 | hdd_warn("sme_get_rssi_snr_by_bssid failed"); |
| 12517 | return -EINVAL; |
| 12518 | } |
| 12519 | |
| 12520 | return 0; |
| 12521 | } |
| 12522 | |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 12523 | /** |
| 12524 | * hdd_send_limit_off_chan_cmd() - send limit off-channel command parameters |
| 12525 | * @param - pointer to sir_limit_off_chan |
| 12526 | * |
| 12527 | * Return: 0 on success and non zero value on failure |
| 12528 | */ |
| 12529 | static int hdd_send_limit_off_chan_cmd(struct sir_limit_off_chan *param) |
| 12530 | { |
| 12531 | struct scheduler_msg msg = {0}; |
| 12532 | |
| 12533 | msg.type = WMA_SET_LIMIT_OFF_CHAN; |
| 12534 | msg.reserved = 0; |
| 12535 | msg.bodyptr = param; |
| 12536 | |
| 12537 | if (!QDF_IS_STATUS_SUCCESS(scheduler_post_msg(QDF_MODULE_ID_WMA, |
| 12538 | &msg))) { |
| 12539 | QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, |
| 12540 | FL("Not able to post WMA_SET_LIMIT_OFF_CHAN to WMA")); |
| 12541 | return QDF_STATUS_E_FAILURE; |
| 12542 | } |
| 12543 | |
| 12544 | return 0; |
| 12545 | } |
| 12546 | |
| 12547 | /** |
| 12548 | * hdd_set_limit_off_chan_for_tos() - set limit off-channel command parameters |
| 12549 | * @adapter - HDD adapter |
| 12550 | * @tos - type of service |
| 12551 | * @status - status of the traffic |
| 12552 | * |
| 12553 | * Return: 0 on success and non zero value on failure |
| 12554 | */ |
| 12555 | |
| 12556 | int hdd_set_limit_off_chan_for_tos(struct hdd_adapter *adapter, enum tos tos, |
| 12557 | bool is_tos_active) |
| 12558 | { |
| 12559 | int ac_bit; |
| 12560 | struct sir_limit_off_chan *cmd; |
| 12561 | struct hdd_context *hdd_ctx; |
| 12562 | int ret; |
| 12563 | |
| 12564 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 12565 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 12566 | |
| 12567 | if (ret < 0) { |
| 12568 | hdd_err("failed to set limit off chan params"); |
| 12569 | return ret; |
| 12570 | } |
| 12571 | |
| 12572 | cmd = qdf_mem_malloc(sizeof(struct sir_limit_off_chan)); |
| 12573 | if (!cmd) { |
| 12574 | hdd_err("qdf_mem_malloc failed for limit off channel"); |
| 12575 | return -ENOMEM; |
| 12576 | } |
| 12577 | |
| 12578 | ac_bit = limit_off_chan_tbl[tos][HDD_AC_BIT_INDX]; |
| 12579 | |
| 12580 | if (is_tos_active) |
| 12581 | hdd_ctx->active_ac |= ac_bit; |
| 12582 | else |
| 12583 | hdd_ctx->active_ac &= ~ac_bit; |
| 12584 | |
| 12585 | if (hdd_ctx->active_ac) { |
| 12586 | if (hdd_ctx->active_ac & HDD_AC_VO_BIT) { |
| 12587 | cmd->max_off_chan_time = |
| 12588 | limit_off_chan_tbl[TOS_VO][HDD_DWELL_TIME_INDX]; |
| 12589 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 12590 | PM_LATENCY); |
| 12591 | } else if (hdd_ctx->active_ac & HDD_AC_VI_BIT) { |
| 12592 | cmd->max_off_chan_time = |
| 12593 | limit_off_chan_tbl[TOS_VI][HDD_DWELL_TIME_INDX]; |
| 12594 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 12595 | PM_LATENCY); |
| 12596 | } else { |
| 12597 | /*ignore this command if only BE/BK is active */ |
| 12598 | is_tos_active = false; |
| 12599 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 12600 | hdd_ctx->config->conc_system_pref); |
| 12601 | } |
| 12602 | } else { |
| 12603 | /* No active tos */ |
| 12604 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 12605 | hdd_ctx->config->conc_system_pref); |
| 12606 | } |
| 12607 | |
| 12608 | cmd->vdev_id = adapter->sessionId; |
| 12609 | cmd->is_tos_active = is_tos_active; |
| 12610 | cmd->rest_time = hdd_ctx->config->nRestTimeConc; |
| 12611 | cmd->skip_dfs_chans = true; |
| 12612 | |
| 12613 | ret = hdd_send_limit_off_chan_cmd(cmd); |
| 12614 | if (ret) |
| 12615 | qdf_mem_free(cmd); |
| 12616 | |
| 12617 | return ret; |
| 12618 | } |
| 12619 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 12620 | /** |
| 12621 | * hdd_start_driver_ops_timer() - Starts driver ops inactivity timer |
| 12622 | * @drv_op: Enum indicating driver op |
| 12623 | * |
| 12624 | * Return: none |
| 12625 | */ |
| 12626 | void hdd_start_driver_ops_timer(int drv_op) |
| 12627 | { |
| 12628 | memset(drv_ops_string, 0, MAX_OPS_NAME_STRING_SIZE); |
| 12629 | switch (drv_op) { |
| 12630 | case eHDD_DRV_OP_PROBE: |
| 12631 | memcpy(drv_ops_string, "probe", sizeof("probe")); |
| 12632 | break; |
| 12633 | case eHDD_DRV_OP_REMOVE: |
| 12634 | memcpy(drv_ops_string, "remove", sizeof("remove")); |
| 12635 | break; |
| 12636 | case eHDD_DRV_OP_SHUTDOWN: |
| 12637 | memcpy(drv_ops_string, "shutdown", sizeof("shutdown")); |
| 12638 | break; |
| 12639 | case eHDD_DRV_OP_REINIT: |
| 12640 | memcpy(drv_ops_string, "reinit", sizeof("reinit")); |
| 12641 | break; |
| 12642 | } |
| 12643 | |
| 12644 | qdf_timer_start(&hdd_drv_ops_inactivity_timer, |
| 12645 | HDD_OPS_INACTIVITY_TIMEOUT); |
| 12646 | } |
| 12647 | |
| 12648 | /** |
| 12649 | * hdd_stop_driver_ops_timer() - Stops driver ops inactivity timer |
| 12650 | * |
| 12651 | * Return: none |
| 12652 | */ |
| 12653 | void hdd_stop_driver_ops_timer(void) |
| 12654 | { |
| 12655 | qdf_timer_sync_cancel(&hdd_drv_ops_inactivity_timer); |
| 12656 | } |
| 12657 | |
| 12658 | /** |
| 12659 | * hdd_drv_ops_inactivity_handler() - Timeout handler for driver ops |
| 12660 | * inactivity timer |
| 12661 | * |
| 12662 | * Return: None |
| 12663 | */ |
| 12664 | void hdd_drv_ops_inactivity_handler(void) |
| 12665 | { |
| 12666 | hdd_err("%s: %d Sec timer expired while in .%s", |
| 12667 | __func__, HDD_OPS_INACTIVITY_TIMEOUT/1000, drv_ops_string); |
| 12668 | |
| 12669 | /* Driver shutdown is stuck, no recovery possible at this point */ |
| 12670 | if (0 == qdf_mem_cmp(&drv_ops_string[0], "shutdown", |
| 12671 | sizeof("shutdown"))) |
| 12672 | QDF_BUG(0); |
| 12673 | |
| 12674 | if (cds_is_self_recovery_enabled()) |
| 12675 | cds_trigger_recovery(); |
| 12676 | else |
| 12677 | QDF_BUG(0); |
| 12678 | } |
| 12679 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12680 | /* Register the module init/exit functions */ |
| 12681 | module_init(hdd_module_init); |
| 12682 | module_exit(hdd_module_exit); |
| 12683 | |
| 12684 | MODULE_LICENSE("Dual BSD/GPL"); |
| 12685 | MODULE_AUTHOR("Qualcomm Atheros, Inc."); |
| 12686 | MODULE_DESCRIPTION("WLAN HOST DEVICE DRIVER"); |
| 12687 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12688 | module_param_call(con_mode, con_mode_handler, param_get_int, &con_mode, |
| 12689 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12690 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 12691 | module_param_call(con_mode_ftm, con_mode_handler_ftm, param_get_int, |
| 12692 | &con_mode_ftm, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 12693 | |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 12694 | module_param_call(con_mode_monitor, con_mode_handler_monitor, param_get_int, |
| 12695 | &con_mode_monitor, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 12696 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12697 | module_param_call(fwpath, fwpath_changed_handler, param_get_string, &fwpath, |
| 12698 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 12699 | |
| 12700 | module_param(enable_dfs_chan_scan, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 12701 | |
| 12702 | module_param(enable_11d, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 12703 | |
| 12704 | module_param(country_code, charp, S_IRUSR | S_IRGRP | S_IROTH); |