Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1 | /* |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2 | * Copyright (c) 2012-2018 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" |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 58 | #ifdef CONFIG_LEAK_DETECTION |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 59 | #include "qdf_debug_domain.h" |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 60 | #endif |
Dustin Brown | d424194 | 2018-02-26 12:51:37 -0800 | [diff] [blame] | 61 | #include "qdf_str.h" |
| 62 | #include "qdf_trace.h" |
| 63 | #include "qdf_types.h" |
Manjunathappa Prakash | 3454fd6 | 2016-04-01 08:52:06 -0700 | [diff] [blame] | 64 | #include <cdp_txrx_peer_ops.h> |
Dhanashri Atre | a8f82f2 | 2017-01-23 12:58:24 -0800 | [diff] [blame] | 65 | #include <cdp_txrx_misc.h> |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 66 | #include <cdp_txrx_stats.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 67 | |
| 68 | #include <net/addrconf.h> |
| 69 | #include <linux/wireless.h> |
| 70 | #include <net/cfg80211.h> |
| 71 | #include <linux/inetdevice.h> |
| 72 | #include <net/addrconf.h> |
| 73 | #include "wlan_hdd_cfg80211.h" |
| 74 | #include "wlan_hdd_ext_scan.h" |
| 75 | #include "wlan_hdd_p2p.h" |
| 76 | #include <linux/rtnetlink.h> |
| 77 | #include "sap_api.h" |
| 78 | #include <linux/semaphore.h> |
| 79 | #include <linux/ctype.h> |
| 80 | #include <linux/compat.h> |
| 81 | #ifdef MSM_PLATFORM |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 82 | #include <soc/qcom/subsystem_restart.h> |
| 83 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 84 | #include <wlan_hdd_hostapd.h> |
| 85 | #include <wlan_hdd_softap_tx_rx.h> |
| 86 | #include "cfg_api.h" |
| 87 | #include "qwlan_version.h" |
| 88 | #include "wma_types.h" |
| 89 | #include "wlan_hdd_tdls.h" |
| 90 | #ifdef FEATURE_WLAN_CH_AVOID |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 91 | #include "cds_regdomain.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 92 | #endif /* FEATURE_WLAN_CH_AVOID */ |
Dustin Brown | ce46d1d | 2017-08-15 13:34:24 -0700 | [diff] [blame] | 93 | #include "cdp_txrx_flow_ctrl_v2.h" |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 94 | #include "pld_common.h" |
Tushnim Bhattacharyya | 15596cf | 2016-02-12 11:57:02 -0800 | [diff] [blame] | 95 | #include "wlan_hdd_ocb.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 96 | #include "wlan_hdd_nan.h" |
| 97 | #include "wlan_hdd_debugfs.h" |
| 98 | #include "wlan_hdd_driver_ops.h" |
| 99 | #include "epping_main.h" |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 100 | #include "wlan_hdd_data_stall_detection.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 101 | |
| 102 | #include <wlan_hdd_ipa.h> |
| 103 | #include "hif.h" |
| 104 | #include "wma.h" |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 105 | #include "wlan_policy_mgr_api.h" |
Manikandan Mohan | dcc21ba | 2016-03-15 14:31:56 -0700 | [diff] [blame] | 106 | #include "wlan_hdd_tsf.h" |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 107 | #include "bmi.h" |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 108 | #include <wlan_hdd_regulatory.h> |
Jeff Johnson | 2b0a7b8 | 2016-05-18 15:08:02 -0700 | [diff] [blame] | 109 | #include "wlan_hdd_lpass.h" |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 110 | #include "nan_api.h" |
Orhan K AKYILDIZ | 1481aff | 2016-05-16 12:40:13 -0700 | [diff] [blame] | 111 | #include <wlan_hdd_napi.h> |
Padma, Santhosh Kumar | d7cc079 | 2016-06-28 18:54:12 +0530 | [diff] [blame] | 112 | #include "wlan_hdd_disa.h" |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 113 | #include <dispatcher_init_deinit.h> |
Rajeev Kumar | 699debf | 2017-01-06 14:17:00 -0800 | [diff] [blame] | 114 | #include "wlan_hdd_object_manager.h" |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 115 | #include "cds_utils.h" |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 116 | #include <cdp_txrx_handle.h> |
Sandeep Puligilla | fdd201e | 2017-02-02 18:43:46 -0800 | [diff] [blame] | 117 | #include <qca_vendor.h> |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 118 | #include "wlan_pmo_ucfg_api.h" |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 119 | #include "sir_api.h" |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 120 | #include "os_if_wifi_pos.h" |
| 121 | #include "wifi_pos_api.h" |
| 122 | #include "wlan_hdd_oemdata.h" |
Krishna Kumaar Natarajan | 4f1d772 | 2017-03-03 21:12:51 -0800 | [diff] [blame] | 123 | #include "wlan_hdd_he.h" |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 124 | #include "os_if_nan.h" |
| 125 | #include "nan_public_structs.h" |
Kiran Kumar Lokere | 3beeb95 | 2017-05-02 18:40:24 -0700 | [diff] [blame] | 126 | #include "wlan_reg_ucfg_api.h" |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 127 | #include "wlan_dfs_ucfg_api.h" |
Ravi Joshi | 4f09595 | 2017-06-29 15:39:19 -0700 | [diff] [blame] | 128 | #include "wlan_hdd_rx_monitor.h" |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 129 | #include "sme_power_save_api.h" |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 130 | #include "enet.h" |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 131 | #include <cdp_txrx_cmn_struct.h> |
Amar Singhal | 0928b19 | 2017-12-01 10:50:54 -0800 | [diff] [blame] | 132 | #include "wlan_hdd_sysfs.h" |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 133 | #include "wlan_disa_ucfg_api.h" |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 134 | #include "wlan_ipa_ucfg_api.h" |
Arunk Khandavalli | a6305a3 | 2018-01-25 11:19:18 +0530 | [diff] [blame] | 135 | #include <target_if.h> |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 136 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 137 | #ifdef CNSS_GENL |
| 138 | #include <net/cnss_nl.h> |
| 139 | #endif |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 140 | #include "wlan_reg_ucfg_api.h" |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 141 | #include "wlan_ocb_ucfg_api.h" |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 142 | |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 143 | #include <wlan_green_ap_ucfg_api.h> |
Sandeep Puligilla | 019a1bd | 2018-02-04 22:57:44 -0800 | [diff] [blame] | 144 | #include <wlan_hdd_spectralscan.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 145 | #ifdef MODULE |
| 146 | #define WLAN_MODULE_NAME module_name(THIS_MODULE) |
| 147 | #else |
| 148 | #define WLAN_MODULE_NAME "wlan" |
| 149 | #endif |
| 150 | |
| 151 | #ifdef TIMER_MANAGER |
| 152 | #define TIMER_MANAGER_STR " +TIMER_MANAGER" |
| 153 | #else |
| 154 | #define TIMER_MANAGER_STR "" |
| 155 | #endif |
| 156 | |
| 157 | #ifdef MEMORY_DEBUG |
| 158 | #define MEMORY_DEBUG_STR " +MEMORY_DEBUG" |
| 159 | #else |
| 160 | #define MEMORY_DEBUG_STR "" |
| 161 | #endif |
| 162 | |
Dustin Brown | c1034df | 2018-02-07 14:51:32 -0800 | [diff] [blame] | 163 | #ifdef PANIC_ON_BUG |
| 164 | #define PANIC_ON_BUG_STR " +PANIC_ON_BUG" |
| 165 | #else |
| 166 | #define PANIC_ON_BUG_STR "" |
| 167 | #endif |
| 168 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 169 | int wlan_start_ret_val; |
| 170 | static DECLARE_COMPLETION(wlan_start_comp); |
| 171 | static unsigned int dev_num = 1; |
| 172 | static struct cdev wlan_hdd_state_cdev; |
| 173 | static struct class *class; |
| 174 | static dev_t device; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 175 | #ifndef MODULE |
| 176 | static struct gwlan_loader *wlan_loader; |
| 177 | static ssize_t wlan_boot_cb(struct kobject *kobj, |
| 178 | struct kobj_attribute *attr, |
| 179 | const char *buf, size_t count); |
| 180 | struct gwlan_loader { |
| 181 | bool loaded_state; |
| 182 | struct kobject *boot_wlan_obj; |
| 183 | struct attribute_group *attr_group; |
| 184 | }; |
| 185 | |
| 186 | static struct kobj_attribute wlan_boot_attribute = |
| 187 | __ATTR(boot_wlan, 0220, NULL, wlan_boot_cb); |
| 188 | |
| 189 | static struct attribute *attrs[] = { |
| 190 | &wlan_boot_attribute.attr, |
| 191 | NULL, |
| 192 | }; |
| 193 | |
| 194 | #define MODULE_INITIALIZED 1 |
| 195 | #endif |
| 196 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 197 | #define HDD_OPS_INACTIVITY_TIMEOUT (120000) |
| 198 | #define MAX_OPS_NAME_STRING_SIZE 20 |
Rajeev Kumar | 6d0b2ea | 2017-12-26 17:55:33 -0800 | [diff] [blame] | 199 | #define RATE_LIMIT_ERROR_LOG (256) |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 200 | |
| 201 | static qdf_timer_t hdd_drv_ops_inactivity_timer; |
Dustin Brown | 45ed4bb | 2017-12-18 12:00:13 -0800 | [diff] [blame] | 202 | static struct task_struct *hdd_drv_ops_task; |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 203 | static char drv_ops_string[MAX_OPS_NAME_STRING_SIZE]; |
| 204 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 205 | /* the Android framework expects this param even though we don't use it */ |
| 206 | #define BUF_LEN 20 |
| 207 | static char fwpath_buffer[BUF_LEN]; |
| 208 | static struct kparam_string fwpath = { |
| 209 | .string = fwpath_buffer, |
| 210 | .maxlen = BUF_LEN, |
| 211 | }; |
| 212 | |
| 213 | static char *country_code; |
| 214 | static int enable_11d = -1; |
| 215 | static int enable_dfs_chan_scan = -1; |
| 216 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 217 | /* |
| 218 | * spinlock for synchronizing asynchronous request/response |
| 219 | * (full description of use in wlan_hdd_main.h) |
| 220 | */ |
| 221 | DEFINE_SPINLOCK(hdd_context_lock); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 222 | DEFINE_MUTEX(hdd_init_deinit_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 223 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 224 | #define WLAN_NLINK_CESIUM 30 |
| 225 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 226 | static qdf_wake_lock_t wlan_wake_lock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 227 | |
| 228 | #define WOW_MAX_FILTER_LISTS 1 |
| 229 | #define WOW_MAX_FILTERS_PER_LIST 4 |
| 230 | #define WOW_MIN_PATTERN_SIZE 6 |
| 231 | #define WOW_MAX_PATTERN_SIZE 64 |
| 232 | |
| 233 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 234 | static const struct wiphy_wowlan_support wowlan_support_reg_init = { |
| 235 | .flags = WIPHY_WOWLAN_ANY | |
| 236 | WIPHY_WOWLAN_MAGIC_PKT | |
| 237 | WIPHY_WOWLAN_DISCONNECT | |
| 238 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 239 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 240 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 241 | WIPHY_WOWLAN_4WAY_HANDSHAKE | |
| 242 | WIPHY_WOWLAN_RFKILL_RELEASE, |
| 243 | .n_patterns = WOW_MAX_FILTER_LISTS * WOW_MAX_FILTERS_PER_LIST, |
| 244 | .pattern_min_len = WOW_MIN_PATTERN_SIZE, |
| 245 | .pattern_max_len = WOW_MAX_PATTERN_SIZE, |
| 246 | }; |
| 247 | #endif |
| 248 | |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 249 | static const struct category_info cinfo[MAX_SUPPORTED_CATEGORY] = { |
| 250 | [QDF_MODULE_ID_TLSHIM] = {QDF_TRACE_LEVEL_ALL}, |
| 251 | [QDF_MODULE_ID_WMI] = {QDF_TRACE_LEVEL_ALL}, |
| 252 | [QDF_MODULE_ID_HTT] = {QDF_TRACE_LEVEL_ALL}, |
| 253 | [QDF_MODULE_ID_HDD] = {QDF_TRACE_LEVEL_ALL}, |
| 254 | [QDF_MODULE_ID_SME] = {QDF_TRACE_LEVEL_ALL}, |
| 255 | [QDF_MODULE_ID_PE] = {QDF_TRACE_LEVEL_ALL}, |
| 256 | [QDF_MODULE_ID_WMA] = {QDF_TRACE_LEVEL_ALL}, |
| 257 | [QDF_MODULE_ID_SYS] = {QDF_TRACE_LEVEL_ALL}, |
| 258 | [QDF_MODULE_ID_QDF] = {QDF_TRACE_LEVEL_ALL}, |
| 259 | [QDF_MODULE_ID_SAP] = {QDF_TRACE_LEVEL_ALL}, |
| 260 | [QDF_MODULE_ID_HDD_SOFTAP] = {QDF_TRACE_LEVEL_ALL}, |
| 261 | [QDF_MODULE_ID_HDD_DATA] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 262 | [QDF_MODULE_ID_HDD_SAP_DATA] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 263 | [QDF_MODULE_ID_HIF] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 264 | [QDF_MODULE_ID_HTC] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 265 | [QDF_MODULE_ID_TXRX] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 266 | [QDF_MODULE_ID_QDF_DEVICE] = {QDF_TRACE_LEVEL_ALL}, |
| 267 | [QDF_MODULE_ID_CFG] = {QDF_TRACE_LEVEL_ALL}, |
| 268 | [QDF_MODULE_ID_BMI] = {QDF_TRACE_LEVEL_ALL}, |
| 269 | [QDF_MODULE_ID_EPPING] = {QDF_TRACE_LEVEL_ALL}, |
| 270 | [QDF_MODULE_ID_QVIT] = {QDF_TRACE_LEVEL_ALL}, |
| 271 | [QDF_MODULE_ID_DP] = {QDF_TRACE_LEVEL_ALL}, |
| 272 | [QDF_MODULE_ID_SOC] = {QDF_TRACE_LEVEL_ALL}, |
| 273 | [QDF_MODULE_ID_OS_IF] = {QDF_TRACE_LEVEL_ALL}, |
| 274 | [QDF_MODULE_ID_TARGET_IF] = {QDF_TRACE_LEVEL_ALL}, |
| 275 | [QDF_MODULE_ID_SCHEDULER] = {QDF_TRACE_LEVEL_ALL}, |
| 276 | [QDF_MODULE_ID_MGMT_TXRX] = {QDF_TRACE_LEVEL_ALL}, |
| 277 | [QDF_MODULE_ID_PMO] = {QDF_TRACE_LEVEL_ALL}, |
| 278 | [QDF_MODULE_ID_SCAN] = {QDF_TRACE_LEVEL_ALL}, |
| 279 | [QDF_MODULE_ID_POLICY_MGR] = {QDF_TRACE_LEVEL_ALL}, |
| 280 | [QDF_MODULE_ID_P2P] = {QDF_TRACE_LEVEL_ALL}, |
| 281 | [QDF_MODULE_ID_TDLS] = {QDF_TRACE_LEVEL_ALL}, |
| 282 | [QDF_MODULE_ID_REGULATORY] = {QDF_TRACE_LEVEL_ALL}, |
| 283 | [QDF_MODULE_ID_SERIALIZATION] = {QDF_TRACE_LEVEL_ALL}, |
Arif Hussain | fde76e7 | 2017-09-05 16:58:23 -0700 | [diff] [blame] | 284 | [QDF_MODULE_ID_DFS] = {QDF_TRACE_LEVEL_ALL}, |
Rajeev Kumar | ca8ef9d | 2017-10-06 10:43:21 -0700 | [diff] [blame] | 285 | [QDF_MODULE_ID_OBJ_MGR] = {QDF_TRACE_LEVEL_ALL}, |
Deepak Dhamdhere | f918d42 | 2017-07-06 12:56:29 -0700 | [diff] [blame] | 286 | [QDF_MODULE_ID_ROAM_DEBUG] = {QDF_TRACE_LEVEL_ALL}, |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 287 | [QDF_MODULE_ID_GREEN_AP] = {QDF_TRACE_LEVEL_ALL}, |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 288 | [QDF_MODULE_ID_OCB] = {QDF_TRACE_LEVEL_ALL}, |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 289 | }; |
| 290 | |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 291 | int limit_off_chan_tbl[HDD_MAX_AC][HDD_MAX_OFF_CHAN_ENTRIES] = { |
| 292 | { HDD_AC_BK_BIT, HDD_MAX_OFF_CHAN_TIME_FOR_BK }, |
| 293 | { HDD_AC_BE_BIT, HDD_MAX_OFF_CHAN_TIME_FOR_BE }, |
| 294 | { HDD_AC_VI_BIT, HDD_MAX_OFF_CHAN_TIME_FOR_VI }, |
| 295 | { HDD_AC_VO_BIT, HDD_MAX_OFF_CHAN_TIME_FOR_VO }, |
| 296 | }; |
| 297 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 298 | /* internal function declaration */ |
Ashish Kumar Dhanotiya | cf11bae | 2017-04-04 03:29:47 +0530 | [diff] [blame] | 299 | struct notifier_block hdd_netdev_notifier; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 300 | |
| 301 | struct sock *cesium_nl_srv_sock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 302 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 303 | static void wlan_hdd_auto_shutdown_cb(void); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 304 | #endif |
| 305 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 306 | void hdd_start_complete(int ret) |
| 307 | { |
| 308 | wlan_start_ret_val = ret; |
| 309 | |
| 310 | complete(&wlan_start_comp); |
| 311 | } |
| 312 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 313 | /** |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 314 | * hdd_check_green_ap_enable() - to check whether to enable green ap or not |
| 315 | * @hdd_ctx: hdd context |
| 316 | * @enable_green_ap: 1 - enable green ap enabled, 0 - disbale green ap |
| 317 | * |
| 318 | * Return: 0 - success, < 0 - failure |
| 319 | */ |
| 320 | static int hdd_check_green_ap_enable(struct hdd_context *hdd_ctx, |
| 321 | bool *enable_green_ap) |
| 322 | { |
| 323 | uint8_t num_sessions, mode; |
| 324 | QDF_STATUS status; |
| 325 | |
| 326 | for (mode = 0; |
| 327 | mode < QDF_MAX_NO_OF_MODE; |
| 328 | mode++) { |
| 329 | if (mode == QDF_SAP_MODE || mode == QDF_P2P_GO_MODE) |
| 330 | continue; |
| 331 | |
| 332 | status = policy_mgr_mode_specific_num_active_sessions( |
| 333 | hdd_ctx->hdd_psoc, mode, &num_sessions); |
| 334 | hdd_debug("No. of active sessions for mode: %d is %d", |
| 335 | mode, num_sessions); |
| 336 | if (status != QDF_STATUS_SUCCESS) { |
| 337 | hdd_err("Failed to get num sessions for mode: %d", |
| 338 | mode); |
| 339 | return -EINVAL; |
| 340 | } else if (num_sessions) { |
| 341 | *enable_green_ap = false; |
| 342 | return 0; |
| 343 | } |
| 344 | } |
| 345 | *enable_green_ap = true; |
| 346 | return 0; |
| 347 | } |
| 348 | |
| 349 | int hdd_start_green_ap_state_mc(struct hdd_context *hdd_ctx, |
| 350 | enum QDF_OPMODE mode, bool is_session_start) |
| 351 | { |
| 352 | struct hdd_config *cfg; |
| 353 | bool enable_green_ap = false; |
| 354 | uint8_t num_sap_sessions = 0, num_p2p_go_sessions = 0, ret = 0; |
| 355 | |
| 356 | cfg = hdd_ctx->config; |
| 357 | if (!cfg) { |
| 358 | hdd_err("NULL hdd config"); |
| 359 | return -EINVAL; |
| 360 | } |
| 361 | |
| 362 | if (!cfg->enable2x2 || !cfg->enableGreenAP) { |
| 363 | hdd_info("Green AP support not present: enable2x2: %d, enableGreenAp: %d", |
| 364 | cfg->enable2x2, cfg->enableGreenAP); |
| 365 | return 0; |
| 366 | } |
| 367 | |
| 368 | policy_mgr_mode_specific_num_active_sessions(hdd_ctx->hdd_psoc, |
| 369 | QDF_SAP_MODE, |
| 370 | &num_sap_sessions); |
| 371 | policy_mgr_mode_specific_num_active_sessions(hdd_ctx->hdd_psoc, |
| 372 | QDF_P2P_GO_MODE, |
| 373 | &num_p2p_go_sessions); |
| 374 | |
| 375 | switch (mode) { |
| 376 | case QDF_STA_MODE: |
| 377 | case QDF_P2P_CLIENT_MODE: |
| 378 | case QDF_IBSS_MODE: |
| 379 | if (!num_sap_sessions && !num_p2p_go_sessions) |
| 380 | return 0; |
| 381 | |
| 382 | if (is_session_start) { |
| 383 | hdd_debug("Disabling Green AP"); |
| 384 | ucfg_green_ap_set_ps_config(hdd_ctx->hdd_pdev, |
| 385 | false); |
| 386 | wlan_green_ap_stop(hdd_ctx->hdd_pdev); |
| 387 | } else { |
| 388 | ret = hdd_check_green_ap_enable(hdd_ctx, |
| 389 | &enable_green_ap); |
| 390 | if (!ret) { |
| 391 | if (enable_green_ap) { |
| 392 | hdd_debug("Enabling Green AP"); |
| 393 | ucfg_green_ap_set_ps_config( |
| 394 | hdd_ctx->hdd_pdev, true); |
| 395 | wlan_green_ap_start(hdd_ctx->hdd_pdev); |
| 396 | } |
| 397 | } else { |
| 398 | hdd_err("Failed to check Green AP enable status"); |
| 399 | } |
| 400 | } |
| 401 | break; |
| 402 | case QDF_SAP_MODE: |
| 403 | case QDF_P2P_GO_MODE: |
| 404 | if (is_session_start) { |
| 405 | ret = hdd_check_green_ap_enable(hdd_ctx, |
| 406 | &enable_green_ap); |
| 407 | if (!ret) { |
| 408 | if (enable_green_ap) { |
| 409 | hdd_debug("Enabling Green AP"); |
| 410 | ucfg_green_ap_set_ps_config( |
| 411 | hdd_ctx->hdd_pdev, true); |
| 412 | wlan_green_ap_start(hdd_ctx->hdd_pdev); |
| 413 | } |
| 414 | } else { |
| 415 | hdd_err("Failed to check Green AP enable status"); |
| 416 | } |
| 417 | } else { |
| 418 | if (!num_sap_sessions && !num_p2p_go_sessions) { |
| 419 | hdd_debug("Disabling Green AP"); |
| 420 | ucfg_green_ap_set_ps_config(hdd_ctx->hdd_pdev, |
| 421 | false); |
| 422 | wlan_green_ap_stop(hdd_ctx->hdd_pdev); |
| 423 | } |
| 424 | } |
| 425 | break; |
| 426 | default: |
| 427 | break; |
| 428 | } |
| 429 | return ret; |
| 430 | } |
| 431 | |
| 432 | /** |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 433 | * hdd_set_rps_cpu_mask - set RPS CPU mask for interfaces |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 434 | * @hdd_ctx: pointer to struct hdd_context |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 435 | * |
| 436 | * Return: none |
| 437 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 438 | static void hdd_set_rps_cpu_mask(struct hdd_context *hdd_ctx) |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 439 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 440 | struct hdd_adapter *adapter; |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 441 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 442 | hdd_for_each_adapter(hdd_ctx, adapter) |
| 443 | hdd_send_rps_ind(adapter); |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 444 | } |
| 445 | |
| 446 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 447 | * wlan_hdd_txrx_pause_cb() - pause callback from txrx layer |
| 448 | * @vdev_id: vdev_id |
| 449 | * @action: action type |
| 450 | * @reason: reason type |
| 451 | * |
| 452 | * Return: none |
| 453 | */ |
| 454 | void wlan_hdd_txrx_pause_cb(uint8_t vdev_id, |
| 455 | enum netif_action_type action, enum netif_reason_type reason) |
| 456 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 457 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 458 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 459 | |
| 460 | if (!hdd_ctx) { |
| 461 | hdd_err("hdd ctx is NULL"); |
| 462 | return; |
| 463 | } |
| 464 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 465 | |
| 466 | wlan_hdd_netif_queue_control(adapter, action, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 467 | } |
| 468 | |
| 469 | /* |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 470 | * Store WLAN driver version and timestamp info in global variables such that |
| 471 | * crash debugger can extract them from driver debug symbol and crashdump for |
| 472 | * post processing |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 473 | */ |
Dustin Brown | 96cd963 | 2017-11-13 12:45:04 -0800 | [diff] [blame] | 474 | #ifdef BUILD_TAG |
| 475 | uint8_t g_wlan_driver_version[] = QWLAN_VERSIONSTR "; " BUILD_TAG; |
| 476 | #else |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 477 | uint8_t g_wlan_driver_version[] = QWLAN_VERSIONSTR; |
Naveen Rawat | 9383625 | 2017-06-20 16:30:59 -0700 | [diff] [blame] | 478 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 479 | |
| 480 | /** |
| 481 | * hdd_device_mode_to_string() - return string conversion of device mode |
| 482 | * @device_mode: device mode |
| 483 | * |
| 484 | * This utility function helps log string conversion of device mode. |
| 485 | * |
| 486 | * Return: string conversion of device mode, if match found; |
| 487 | * "Unknown" otherwise. |
| 488 | */ |
| 489 | const char *hdd_device_mode_to_string(uint8_t device_mode) |
| 490 | { |
| 491 | switch (device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 492 | CASE_RETURN_STRING(QDF_STA_MODE); |
| 493 | CASE_RETURN_STRING(QDF_SAP_MODE); |
| 494 | CASE_RETURN_STRING(QDF_P2P_CLIENT_MODE); |
| 495 | CASE_RETURN_STRING(QDF_P2P_GO_MODE); |
| 496 | CASE_RETURN_STRING(QDF_FTM_MODE); |
| 497 | CASE_RETURN_STRING(QDF_IBSS_MODE); |
| 498 | CASE_RETURN_STRING(QDF_P2P_DEVICE_MODE); |
| 499 | CASE_RETURN_STRING(QDF_OCB_MODE); |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 500 | CASE_RETURN_STRING(QDF_NDI_MODE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 501 | default: |
| 502 | return "Unknown"; |
| 503 | } |
| 504 | } |
| 505 | |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 506 | /** |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 507 | * hdd_get_valid_chan() - return current chan list from regulatory. |
| 508 | * @hdd_ctx: HDD context |
| 509 | * @chan_list: buf hold returned chan list |
| 510 | * @chan_num: input buf size and output returned chan num |
| 511 | * |
| 512 | * This function helps get current available chan list from regulatory |
| 513 | * module. It excludes the "disabled" and "invalid" channels. |
| 514 | * |
| 515 | * Return: 0 for success. |
| 516 | */ |
| 517 | static int hdd_get_valid_chan(struct hdd_context *hdd_ctx, |
| 518 | uint8_t *chan_list, |
| 519 | uint32_t *chan_num) |
| 520 | { |
| 521 | int i = 0, j = 0; |
| 522 | struct regulatory_channel *cur_chan_list; |
| 523 | struct wlan_objmgr_pdev *pdev; |
| 524 | |
| 525 | if (!hdd_ctx || !hdd_ctx->hdd_pdev || !chan_list || !chan_num) |
| 526 | return -EINVAL; |
| 527 | |
| 528 | pdev = hdd_ctx->hdd_pdev; |
| 529 | cur_chan_list = qdf_mem_malloc(NUM_CHANNELS * |
| 530 | sizeof(struct regulatory_channel)); |
| 531 | if (!cur_chan_list) |
| 532 | return -ENOMEM; |
| 533 | |
| 534 | if (wlan_reg_get_current_chan_list(pdev, cur_chan_list) != |
| 535 | QDF_STATUS_SUCCESS) { |
| 536 | qdf_mem_free(cur_chan_list); |
| 537 | return -EINVAL; |
| 538 | } |
| 539 | |
| 540 | for (i = 0; i < NUM_CHANNELS; i++) { |
| 541 | uint32_t ch = cur_chan_list[i].chan_num; |
| 542 | enum channel_state state = wlan_reg_get_channel_state(pdev, |
| 543 | ch); |
| 544 | |
| 545 | if (state != CHANNEL_STATE_DISABLE && |
| 546 | state != CHANNEL_STATE_INVALID && |
| 547 | j < *chan_num) { |
| 548 | chan_list[j] = (uint8_t)ch; |
| 549 | j++; |
| 550 | } |
| 551 | } |
| 552 | *chan_num = j; |
| 553 | qdf_mem_free(cur_chan_list); |
| 554 | return 0; |
| 555 | } |
| 556 | |
| 557 | /** |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 558 | * hdd_validate_channel_and_bandwidth() - Validate the channel-bandwidth combo |
| 559 | * @adapter: HDD adapter |
| 560 | * @chan_number: Channel number |
| 561 | * @chan_bw: Bandwidth |
| 562 | * |
| 563 | * Checks if the given bandwidth is valid for the given channel number. |
| 564 | * |
| 565 | * Return: 0 for success, non-zero for failure |
| 566 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 567 | int hdd_validate_channel_and_bandwidth(struct hdd_adapter *adapter, |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 568 | uint32_t chan_number, |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 569 | enum phy_ch_width chan_bw) |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 570 | { |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 571 | uint8_t chan[NUM_CHANNELS]; |
| 572 | uint32_t len = NUM_CHANNELS, i; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 573 | bool found = false; |
| 574 | tHalHandle hal; |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 575 | int ret; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 576 | |
| 577 | hal = WLAN_HDD_GET_HAL_CTX(adapter); |
| 578 | if (!hal) { |
| 579 | hdd_err("Invalid HAL context"); |
| 580 | return -EINVAL; |
| 581 | } |
| 582 | |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 583 | ret = hdd_get_valid_chan(adapter->hdd_ctx, chan, |
| 584 | &len); |
| 585 | if (ret) { |
| 586 | hdd_err("error %d in getting valid channel list", ret); |
| 587 | return ret; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 588 | } |
| 589 | |
| 590 | for (i = 0; i < len; i++) { |
| 591 | if (chan[i] == chan_number) { |
| 592 | found = true; |
| 593 | break; |
| 594 | } |
| 595 | } |
| 596 | |
| 597 | if (found == false) { |
| 598 | hdd_err("Channel not in driver's valid channel list"); |
| 599 | return -EOPNOTSUPP; |
| 600 | } |
| 601 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 602 | if ((!WLAN_REG_IS_24GHZ_CH(chan_number)) && |
| 603 | (!WLAN_REG_IS_5GHZ_CH(chan_number))) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 604 | hdd_err("CH %d is not in 2.4GHz or 5GHz", chan_number); |
| 605 | return -EINVAL; |
| 606 | } |
| 607 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 608 | if (WLAN_REG_IS_24GHZ_CH(chan_number)) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 609 | if (chan_bw == CH_WIDTH_80MHZ) { |
| 610 | hdd_err("BW80 not possible in 2.4GHz band"); |
| 611 | return -EINVAL; |
| 612 | } |
| 613 | if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 14) && |
| 614 | (chan_bw != CH_WIDTH_MAX)) { |
| 615 | hdd_err("Only BW20 possible on channel 14"); |
| 616 | return -EINVAL; |
| 617 | } |
| 618 | } |
| 619 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 620 | if (WLAN_REG_IS_5GHZ_CH(chan_number)) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 621 | if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 165) && |
| 622 | (chan_bw != CH_WIDTH_MAX)) { |
| 623 | hdd_err("Only BW20 possible on channel 165"); |
| 624 | return -EINVAL; |
| 625 | } |
| 626 | } |
| 627 | |
| 628 | return 0; |
| 629 | } |
| 630 | |
Arunk Khandavalli | e1b3a38 | 2017-09-26 12:01:26 +0530 | [diff] [blame] | 631 | /** |
| 632 | * hdd_wait_for_recovery_completion() - Wait for cds recovery completion |
| 633 | * |
| 634 | * Block the unloading of the driver (or) interface up until the |
| 635 | * cds recovery is completed |
| 636 | * |
| 637 | * Return: true for recovery completion else false |
| 638 | */ |
| 639 | static bool hdd_wait_for_recovery_completion(void) |
| 640 | { |
| 641 | int retry = 0; |
| 642 | |
| 643 | /* Wait for recovery to complete */ |
| 644 | while (cds_is_driver_recovering()) { |
| 645 | if (retry == HDD_MOD_EXIT_SSR_MAX_RETRIES/2) |
| 646 | hdd_err("Recovery in progress; wait here!!!"); |
| 647 | msleep(1000); |
| 648 | if (retry++ == HDD_MOD_EXIT_SSR_MAX_RETRIES) { |
| 649 | hdd_err("SSR never completed, error"); |
| 650 | /* |
| 651 | * Trigger the bug_on in the internal builds, in the |
| 652 | * customer builds self-recovery will be enabled |
| 653 | * in those cases just return error. |
| 654 | */ |
| 655 | if (cds_is_self_recovery_enabled()) |
| 656 | return false; |
| 657 | QDF_BUG(0); |
| 658 | } |
| 659 | } |
| 660 | |
| 661 | hdd_info("Recovery completed successfully!"); |
| 662 | return true; |
| 663 | } |
| 664 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 665 | static int __hdd_netdev_notifier_call(struct notifier_block *nb, |
| 666 | unsigned long state, void *data) |
| 667 | { |
| 668 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 669 | struct netdev_notifier_info *dev_notif_info = data; |
| 670 | struct net_device *dev = dev_notif_info->dev; |
| 671 | #else |
| 672 | struct net_device *dev = data; |
| 673 | #endif |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 674 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 675 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 676 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 677 | hdd_enter_dev(dev); |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 678 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 679 | /* Make sure that this callback corresponds to our device. */ |
| 680 | if ((strncmp(dev->name, "wlan", 4)) && (strncmp(dev->name, "p2p", 3))) |
| 681 | return NOTIFY_DONE; |
| 682 | |
Samuel Ahn | c9c48ca | 2016-09-19 15:46:36 +0530 | [diff] [blame] | 683 | if ((adapter->magic != WLAN_HDD_ADAPTER_MAGIC) || |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 684 | (adapter->dev != dev)) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 685 | hdd_err("device adapter is not matching!!!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 686 | return NOTIFY_DONE; |
| 687 | } |
| 688 | |
| 689 | if (!dev->ieee80211_ptr) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 690 | hdd_err("ieee80211_ptr is NULL!!!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 691 | return NOTIFY_DONE; |
| 692 | } |
| 693 | |
| 694 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 695 | if (NULL == hdd_ctx) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 696 | hdd_err("HDD Context Null Pointer"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 697 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 698 | return NOTIFY_DONE; |
| 699 | } |
Jingxiang Ge | 9db9d23 | 2017-10-14 17:22:15 +0800 | [diff] [blame] | 700 | |
| 701 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) { |
| 702 | hdd_err("%s: Driver module is closed", __func__); |
| 703 | return NOTIFY_DONE; |
| 704 | } |
| 705 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 706 | if (cds_is_driver_recovering() || cds_is_driver_in_bad_state()) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 707 | return NOTIFY_DONE; |
| 708 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 709 | hdd_debug("%s New Net Device State = %lu", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 710 | dev->name, state); |
| 711 | |
| 712 | switch (state) { |
| 713 | case NETDEV_REGISTER: |
| 714 | break; |
| 715 | |
| 716 | case NETDEV_UNREGISTER: |
| 717 | break; |
| 718 | |
| 719 | case NETDEV_UP: |
| 720 | sme_ch_avoid_update_req(hdd_ctx->hHal); |
| 721 | break; |
| 722 | |
| 723 | case NETDEV_DOWN: |
| 724 | break; |
| 725 | |
| 726 | case NETDEV_CHANGE: |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 727 | if (adapter->is_link_up_service_needed) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 728 | complete(&adapter->linkup_event_var); |
| 729 | break; |
| 730 | |
| 731 | case NETDEV_GOING_DOWN: |
Sandeep Puligilla | 5f86d99 | 2017-10-29 14:58:53 -0700 | [diff] [blame] | 732 | if (ucfg_scan_get_vdev_status(adapter->hdd_vdev) != |
| 733 | SCAN_NOT_IN_PROGRESS) { |
Abhishek Singh | 69ccb51 | 2017-04-25 11:58:16 +0530 | [diff] [blame] | 734 | wlan_abort_scan(hdd_ctx->hdd_pdev, INVAL_PDEV_ID, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 735 | adapter->session_id, INVALID_SCAN_ID, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 736 | } else { |
hqu | eaa33ee | 2017-05-04 17:56:35 +0800 | [diff] [blame] | 737 | cds_flush_work(&adapter->scan_block_work); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 738 | hdd_debug("Scan is not Pending from user"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 739 | } |
Arunk Khandavalli | f0c0d76 | 2017-12-07 10:18:50 +0530 | [diff] [blame] | 740 | /* |
| 741 | * After NETDEV_GOING_DOWN, kernel calls hdd_stop.Irrespective |
| 742 | * of return status of hdd_stop call, kernel resets the IFF_UP |
| 743 | * flag after which driver does not send the cfg80211_scan_done. |
| 744 | * Ensure to cleanup the scan queue in NETDEV_GOING_DOWN |
| 745 | */ |
Sourav Mohapatra | 001cfaf | 2018-02-28 11:30:46 +0530 | [diff] [blame] | 746 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->hdd_pdev, dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 747 | break; |
| 748 | |
| 749 | default: |
| 750 | break; |
| 751 | } |
| 752 | |
| 753 | return NOTIFY_DONE; |
| 754 | } |
| 755 | |
| 756 | /** |
| 757 | * hdd_netdev_notifier_call() - netdev notifier callback function |
| 758 | * @nb: pointer to notifier block |
| 759 | * @state: state |
| 760 | * @ndev: ndev pointer |
| 761 | * |
| 762 | * Return: 0 on success, error number otherwise. |
| 763 | */ |
| 764 | static int hdd_netdev_notifier_call(struct notifier_block *nb, |
| 765 | unsigned long state, |
| 766 | void *ndev) |
| 767 | { |
| 768 | int ret; |
| 769 | |
| 770 | cds_ssr_protect(__func__); |
| 771 | ret = __hdd_netdev_notifier_call(nb, state, ndev); |
| 772 | cds_ssr_unprotect(__func__); |
| 773 | |
| 774 | return ret; |
| 775 | } |
| 776 | |
| 777 | struct notifier_block hdd_netdev_notifier = { |
| 778 | .notifier_call = hdd_netdev_notifier_call, |
| 779 | }; |
| 780 | |
| 781 | /* variable to hold the insmod parameters */ |
| 782 | static int con_mode; |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 783 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 784 | static int con_mode_ftm; |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 785 | int con_mode_monitor; |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 786 | |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 787 | /* Variable to hold connection mode including module parameter con_mode */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 788 | static int curr_con_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 789 | |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 790 | /** |
| 791 | * hdd_map_nl_chan_width() - Map NL channel width to internal representation |
| 792 | * @ch_width: NL channel width |
| 793 | * |
| 794 | * Converts the NL channel width to the driver's internal representation |
| 795 | * |
| 796 | * Return: Converted channel width. In case of non matching NL channel width, |
| 797 | * CH_WIDTH_MAX will be returned. |
| 798 | */ |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 799 | 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] | 800 | { |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 801 | uint8_t fw_ch_bw; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 802 | |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 803 | fw_ch_bw = wma_get_vht_ch_width(); |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 804 | switch (ch_width) { |
| 805 | case NL80211_CHAN_WIDTH_20_NOHT: |
| 806 | case NL80211_CHAN_WIDTH_20: |
| 807 | return CH_WIDTH_20MHZ; |
| 808 | case NL80211_CHAN_WIDTH_40: |
| 809 | return CH_WIDTH_40MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 810 | case NL80211_CHAN_WIDTH_80: |
| 811 | return CH_WIDTH_80MHZ; |
| 812 | case NL80211_CHAN_WIDTH_80P80: |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 813 | if (fw_ch_bw == WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ) |
| 814 | return CH_WIDTH_80P80MHZ; |
| 815 | else if (fw_ch_bw == WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ) |
| 816 | return CH_WIDTH_160MHZ; |
| 817 | else |
| 818 | return CH_WIDTH_80MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 819 | case NL80211_CHAN_WIDTH_160: |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 820 | if (fw_ch_bw >= WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ) |
| 821 | return CH_WIDTH_160MHZ; |
| 822 | else |
| 823 | return CH_WIDTH_80MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 824 | case NL80211_CHAN_WIDTH_5: |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 825 | return CH_WIDTH_5MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 826 | case NL80211_CHAN_WIDTH_10: |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 827 | return CH_WIDTH_10MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 828 | default: |
| 829 | hdd_err("Invalid channel width %d, setting to default", |
| 830 | ch_width); |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 831 | return CH_WIDTH_INVALID; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 832 | } |
| 833 | } |
| 834 | |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 835 | /* wlan_hdd_find_opclass() - Find operating class for a channel |
| 836 | * @hal: handler to HAL |
| 837 | * @channel: channel id |
| 838 | * @bw_offset: bandwidth offset |
| 839 | * |
| 840 | * Function invokes sme api to find the operating class |
| 841 | * |
| 842 | * Return: operating class |
| 843 | */ |
| 844 | uint8_t wlan_hdd_find_opclass(tHalHandle hal, uint8_t channel, |
| 845 | uint8_t bw_offset) |
| 846 | { |
| 847 | uint8_t opclass = 0; |
| 848 | |
| 849 | sme_get_opclass(hal, channel, bw_offset, &opclass); |
| 850 | return opclass; |
| 851 | } |
| 852 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 853 | /** |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 854 | * hdd_qdf_trace_enable() - configure initial QDF Trace enable |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 855 | * @module_id: Module whose trace level is being configured |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 856 | * @bitmask: Bitmask of log levels to be enabled |
| 857 | * |
| 858 | * Called immediately after the cfg.ini is read in order to configure |
| 859 | * the desired trace levels. |
| 860 | * |
| 861 | * Return: None |
| 862 | */ |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 863 | 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] | 864 | { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 865 | QDF_TRACE_LEVEL level; |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 866 | int qdf_print_idx = -1; |
| 867 | int status = -1; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 868 | /* |
| 869 | * if the bitmask is the default value, then a bitmask was not |
| 870 | * specified in cfg.ini, so leave the logging level alone (it |
| 871 | * will remain at the "compiled in" default value) |
| 872 | */ |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 873 | if (CFG_QDF_TRACE_ENABLE_DEFAULT == bitmask) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 874 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 875 | |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 876 | qdf_print_idx = qdf_get_pidx(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 877 | |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 878 | /* a mask was specified. start by disabling all logging */ |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 879 | status = qdf_print_set_category_verbose(qdf_print_idx, module_id, |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 880 | QDF_TRACE_LEVEL_NONE, 0); |
| 881 | |
| 882 | if (QDF_STATUS_SUCCESS != status) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 883 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 884 | /* now cycle through the bitmask until all "set" bits are serviced */ |
Ashish Kumar Dhanotiya | 83f286b | 2017-09-15 19:52:58 +0530 | [diff] [blame] | 885 | level = QDF_TRACE_LEVEL_NONE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 886 | while (0 != bitmask) { |
| 887 | if (bitmask & 1) { |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 888 | status = qdf_print_set_category_verbose(qdf_print_idx, |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 889 | module_id, level, 1); |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 890 | if (QDF_STATUS_SUCCESS != status) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 891 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 892 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 893 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 894 | level++; |
| 895 | bitmask >>= 1; |
| 896 | } |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 897 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 898 | } |
| 899 | |
| 900 | /** |
Chris Guo | 1751acf | 2017-07-03 14:09:01 +0800 | [diff] [blame] | 901 | * wlan_hdd_validate_context_in_loading() - check the HDD context in loading |
| 902 | * @hdd_ctx: HDD context pointer |
| 903 | * |
| 904 | * Return: 0 if the context is valid. Error code otherwise |
| 905 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 906 | int wlan_hdd_validate_context_in_loading(struct hdd_context *hdd_ctx) |
Chris Guo | 1751acf | 2017-07-03 14:09:01 +0800 | [diff] [blame] | 907 | { |
| 908 | if (NULL == hdd_ctx || NULL == hdd_ctx->config) { |
| 909 | hdd_info("%pS HDD context is Null", (void *)_RET_IP_); |
| 910 | return -ENODEV; |
| 911 | } |
| 912 | |
| 913 | if (cds_is_driver_recovering()) { |
| 914 | hdd_info("%pS Recovery in Progress. State: 0x%x Ignore!!!", |
| 915 | (void *)_RET_IP_, cds_get_driver_state()); |
| 916 | return -EAGAIN; |
| 917 | } |
| 918 | |
| 919 | if (hdd_ctx->start_modules_in_progress || |
| 920 | hdd_ctx->stop_modules_in_progress) { |
| 921 | hdd_info("%pS Start/Stop Modules in progress. Ignore!!!", |
| 922 | (void *)_RET_IP_); |
| 923 | return -EAGAIN; |
| 924 | } |
| 925 | |
| 926 | return 0; |
| 927 | } |
| 928 | |
| 929 | |
| 930 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 931 | * wlan_hdd_validate_context() - check the HDD context |
| 932 | * @hdd_ctx: HDD context pointer |
| 933 | * |
| 934 | * Return: 0 if the context is valid. Error code otherwise |
| 935 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 936 | int wlan_hdd_validate_context(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 937 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 938 | if (NULL == hdd_ctx || NULL == hdd_ctx->config) { |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 939 | hdd_err("%pS HDD context is Null", (void *)_RET_IP_); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 940 | return -ENODEV; |
| 941 | } |
| 942 | |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 943 | if (cds_is_driver_recovering()) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 944 | hdd_debug("%pS Recovery in Progress. State: 0x%x Ignore!!!", |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 945 | (void *)_RET_IP_, cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 946 | return -EAGAIN; |
| 947 | } |
| 948 | |
Yue Ma | 9f275d9 | 2017-09-14 16:58:41 -0700 | [diff] [blame] | 949 | if (cds_is_load_or_unload_in_progress()) { |
| 950 | hdd_debug("%pS Load or unload in progress, state: 0x%x, ignore!", |
| 951 | (void *)_RET_IP_, cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 952 | return -EAGAIN; |
Yue Ma | 9f275d9 | 2017-09-14 16:58:41 -0700 | [diff] [blame] | 953 | } |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 954 | |
| 955 | if (hdd_ctx->start_modules_in_progress || |
| 956 | hdd_ctx->stop_modules_in_progress) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 957 | hdd_debug("%pS Start/Stop Modules in progress. Ignore!!!", |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 958 | (void *)_RET_IP_); |
| 959 | return -EAGAIN; |
| 960 | } |
| 961 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 962 | if (cds_is_driver_in_bad_state()) { |
| 963 | hdd_debug("%pS driver in bad State: 0x%x Ignore!!!", |
| 964 | (void *)_RET_IP_, cds_get_driver_state()); |
| 965 | return -ENODEV; |
| 966 | } |
| 967 | |
Arunk Khandavalli | 2859fa1 | 2018-02-14 10:46:26 +0530 | [diff] [blame] | 968 | if (cds_is_fw_down()) { |
| 969 | hdd_debug("%pS FW is down: 0x%x Ignore!!!", |
| 970 | (void *)_RET_IP_, cds_get_driver_state()); |
| 971 | return -ENODEV; |
| 972 | } |
| 973 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 974 | return 0; |
| 975 | } |
| 976 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 977 | int hdd_validate_adapter(struct hdd_adapter *adapter) |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 978 | { |
| 979 | if (!adapter) { |
| 980 | hdd_err("adapter is null"); |
| 981 | return -EINVAL; |
| 982 | } |
| 983 | |
| 984 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) { |
| 985 | hdd_err("bad adapter magic: 0x%x (should be 0x%x)", |
| 986 | adapter->magic, WLAN_HDD_ADAPTER_MAGIC); |
| 987 | return -EINVAL; |
| 988 | } |
| 989 | |
| 990 | if (!adapter->dev) { |
| 991 | hdd_err("adapter net_device is null"); |
| 992 | return -EINVAL; |
| 993 | } |
| 994 | |
| 995 | if (!(adapter->dev->flags & IFF_UP)) { |
| 996 | hdd_info("adapter net_device is not up"); |
| 997 | return -EAGAIN; |
| 998 | } |
| 999 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1000 | if (wlan_hdd_validate_session_id(adapter->session_id)) { |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 1001 | hdd_info("adapter session is not open"); |
| 1002 | return -EAGAIN; |
| 1003 | } |
| 1004 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1005 | if (adapter->session_id >= MAX_NUMBER_OF_ADAPTERS) { |
| 1006 | hdd_err("bad adapter session Id: %u", adapter->session_id); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 1007 | return -EINVAL; |
| 1008 | } |
| 1009 | |
| 1010 | return 0; |
| 1011 | } |
| 1012 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1013 | /** |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 1014 | * wlan_hdd_validate_modules_state() - Check modules status |
| 1015 | * @hdd_ctx: HDD context pointer |
| 1016 | * |
| 1017 | * Check's the driver module's state and returns true if the |
| 1018 | * modules are enabled returns false if modules are closed. |
| 1019 | * |
| 1020 | * Return: True if modules are enabled or false. |
| 1021 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1022 | bool wlan_hdd_validate_modules_state(struct hdd_context *hdd_ctx) |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 1023 | { |
| 1024 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 1025 | if (hdd_ctx->driver_status != DRIVER_MODULES_ENABLED) { |
| 1026 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 1027 | hdd_info("Modules not enabled, Present status: %d", |
| 1028 | hdd_ctx->driver_status); |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 1029 | return false; |
| 1030 | } |
| 1031 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 1032 | return true; |
| 1033 | } |
| 1034 | |
| 1035 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1036 | * 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] | 1037 | * @struct hdd_adapter Hdd adapter. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1038 | * |
| 1039 | * This function sets the IBSS power save config parameters to WMA |
| 1040 | * which will send it to firmware if FW supports IBSS power save |
| 1041 | * before vdev start. |
| 1042 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1043 | * 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] | 1044 | * on failure. |
| 1045 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 1046 | QDF_STATUS hdd_set_ibss_power_save_params(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1047 | { |
| 1048 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1049 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1050 | |
| 1051 | if (hdd_ctx == NULL) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1052 | hdd_err("HDD context is null"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1053 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1054 | } |
| 1055 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1056 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1057 | WMA_VDEV_IBSS_SET_ATIM_WINDOW_SIZE, |
| 1058 | hdd_ctx->config->ibssATIMWinSize, |
| 1059 | VDEV_CMD); |
| 1060 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1061 | hdd_err("WMA_VDEV_IBSS_SET_ATIM_WINDOW_SIZE failed %d", ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1062 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1063 | } |
| 1064 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1065 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1066 | WMA_VDEV_IBSS_SET_POWER_SAVE_ALLOWED, |
| 1067 | hdd_ctx->config->isIbssPowerSaveAllowed, |
| 1068 | VDEV_CMD); |
| 1069 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1070 | hdd_err("WMA_VDEV_IBSS_SET_POWER_SAVE_ALLOWED failed %d", |
| 1071 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1072 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1073 | } |
| 1074 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1075 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1076 | WMA_VDEV_IBSS_SET_POWER_COLLAPSE_ALLOWED, |
| 1077 | hdd_ctx->config-> |
| 1078 | isIbssPowerCollapseAllowed, VDEV_CMD); |
| 1079 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1080 | hdd_err("WMA_VDEV_IBSS_SET_POWER_COLLAPSE_ALLOWED failed %d", |
| 1081 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1082 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1083 | } |
| 1084 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1085 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1086 | WMA_VDEV_IBSS_SET_AWAKE_ON_TX_RX, |
| 1087 | hdd_ctx->config->isIbssAwakeOnTxRx, |
| 1088 | VDEV_CMD); |
| 1089 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1090 | 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] | 1091 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1092 | } |
| 1093 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1094 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1095 | WMA_VDEV_IBSS_SET_INACTIVITY_TIME, |
| 1096 | hdd_ctx->config->ibssInactivityCount, |
| 1097 | VDEV_CMD); |
| 1098 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1099 | hdd_err("WMA_VDEV_IBSS_SET_INACTIVITY_TIME failed %d", ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1100 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1101 | } |
| 1102 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1103 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1104 | WMA_VDEV_IBSS_SET_TXSP_END_INACTIVITY_TIME, |
| 1105 | hdd_ctx->config->ibssTxSpEndInactivityTime, |
| 1106 | VDEV_CMD); |
| 1107 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1108 | hdd_err("WMA_VDEV_IBSS_SET_TXSP_END_INACTIVITY_TIME failed %d", |
| 1109 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1110 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1111 | } |
| 1112 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1113 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1114 | WMA_VDEV_IBSS_PS_SET_WARMUP_TIME_SECS, |
| 1115 | hdd_ctx->config->ibssPsWarmupTime, |
| 1116 | VDEV_CMD); |
| 1117 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1118 | hdd_err("WMA_VDEV_IBSS_PS_SET_WARMUP_TIME_SECS failed %d", |
| 1119 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1120 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1121 | } |
| 1122 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1123 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1124 | WMA_VDEV_IBSS_PS_SET_1RX_CHAIN_IN_ATIM_WINDOW, |
| 1125 | hdd_ctx->config->ibssPs1RxChainInAtimEnable, |
| 1126 | VDEV_CMD); |
| 1127 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1128 | hdd_err("WMA_VDEV_IBSS_PS_SET_1RX_CHAIN_IN_ATIM_WINDOW failed %d", |
| 1129 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1130 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1131 | } |
| 1132 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1133 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1134 | } |
| 1135 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1136 | #ifdef FEATURE_RUNTIME_PM |
| 1137 | /** |
| 1138 | * hdd_runtime_suspend_context_init() - API to initialize HDD Runtime Contexts |
| 1139 | * @hdd_ctx: HDD context |
| 1140 | * |
| 1141 | * Return: None |
| 1142 | */ |
| 1143 | static void hdd_runtime_suspend_context_init(struct hdd_context *hdd_ctx) |
| 1144 | { |
| 1145 | struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; |
| 1146 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1147 | qdf_runtime_lock_init(&ctx->dfs); |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 1148 | qdf_runtime_lock_init(&ctx->connect); |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1149 | |
| 1150 | wlan_scan_runtime_pm_init(hdd_ctx->hdd_pdev); |
| 1151 | } |
| 1152 | |
| 1153 | /** |
| 1154 | * hdd_runtime_suspend_context_deinit() - API to deinit HDD runtime context |
| 1155 | * @hdd_ctx: HDD Context |
| 1156 | * |
| 1157 | * Return: None |
| 1158 | */ |
| 1159 | static void hdd_runtime_suspend_context_deinit(struct hdd_context *hdd_ctx) |
| 1160 | { |
| 1161 | struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; |
| 1162 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1163 | qdf_runtime_lock_deinit(&ctx->dfs); |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 1164 | qdf_runtime_lock_deinit(&ctx->connect); |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1165 | |
| 1166 | wlan_scan_runtime_pm_deinit(hdd_ctx->hdd_pdev); |
| 1167 | } |
| 1168 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1169 | #else /* FEATURE_RUNTIME_PM */ |
| 1170 | static void hdd_runtime_suspend_context_init(struct hdd_context *hdd_ctx) {} |
| 1171 | static void hdd_runtime_suspend_context_deinit(struct hdd_context *hdd_ctx) {} |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1172 | #endif /* FEATURE_RUNTIME_PM */ |
| 1173 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1174 | #define INTF_MACADDR_MASK 0x7 |
| 1175 | |
| 1176 | /** |
| 1177 | * hdd_update_macaddr() - update mac address |
| 1178 | * @config: hdd configuration |
| 1179 | * @hw_macaddr: mac address |
| 1180 | * |
| 1181 | * Mac address for multiple virtual interface is found as following |
| 1182 | * i) The mac address of the first interface is just the actual hw mac address. |
| 1183 | * ii) MSM 3 or 4 bits of byte5 of the actual mac address are used to |
| 1184 | * define the mac address for the remaining interfaces and locally |
| 1185 | * admistered bit is set. INTF_MACADDR_MASK is based on the number of |
| 1186 | * supported virtual interfaces, right now this is 0x07 (meaning 8 |
| 1187 | * interface). |
| 1188 | * Byte[3] of second interface will be hw_macaddr[3](bit5..7) + 1, |
| 1189 | * for third interface it will be hw_macaddr[3](bit5..7) + 2, etc. |
| 1190 | * |
| 1191 | * Return: None |
| 1192 | */ |
| 1193 | void hdd_update_macaddr(struct hdd_config *config, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1194 | struct qdf_mac_addr hw_macaddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1195 | { |
| 1196 | int8_t i; |
| 1197 | uint8_t macaddr_b3, tmp_br3; |
| 1198 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1199 | qdf_mem_copy(config->intfMacAddr[0].bytes, hw_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1200 | QDF_MAC_ADDR_SIZE); |
| 1201 | for (i = 1; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1202 | qdf_mem_copy(config->intfMacAddr[i].bytes, hw_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1203 | QDF_MAC_ADDR_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1204 | macaddr_b3 = config->intfMacAddr[i].bytes[3]; |
| 1205 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + i) & |
| 1206 | INTF_MACADDR_MASK; |
| 1207 | macaddr_b3 += tmp_br3; |
| 1208 | |
| 1209 | /* XOR-ing bit-24 of the mac address. This will give enough |
| 1210 | * mac address range before collision |
| 1211 | */ |
| 1212 | macaddr_b3 ^= (1 << 7); |
| 1213 | |
| 1214 | /* Set locally administered bit */ |
| 1215 | config->intfMacAddr[i].bytes[0] |= 0x02; |
| 1216 | config->intfMacAddr[i].bytes[3] = macaddr_b3; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1217 | hdd_debug("config->intfMacAddr[%d]: " |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1218 | MAC_ADDRESS_STR, i, |
| 1219 | MAC_ADDR_ARRAY(config->intfMacAddr[i].bytes)); |
| 1220 | } |
| 1221 | } |
| 1222 | |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1223 | static int hdd_update_tdls_config(struct hdd_context *hdd_ctx) |
| 1224 | { |
| 1225 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 1226 | struct tdls_start_params tdls_cfg; |
| 1227 | struct tdls_user_config *config = &tdls_cfg.config; |
| 1228 | struct hdd_config *cfg = hdd_ctx->config; |
| 1229 | QDF_STATUS status; |
| 1230 | |
| 1231 | config->tdls_tx_states_period = cfg->fTDLSTxStatsPeriod; |
| 1232 | config->tdls_tx_pkt_threshold = cfg->fTDLSTxPacketThreshold; |
| 1233 | config->tdls_rx_pkt_threshold = cfg->fTDLSRxFrameThreshold; |
| 1234 | config->tdls_max_discovery_attempt = cfg->fTDLSMaxDiscoveryAttempt; |
| 1235 | config->tdls_idle_timeout = cfg->tdls_idle_timeout; |
| 1236 | config->tdls_idle_pkt_threshold = cfg->fTDLSIdlePacketThreshold; |
| 1237 | config->tdls_rssi_trigger_threshold = cfg->fTDLSRSSITriggerThreshold; |
| 1238 | config->tdls_rssi_teardown_threshold = cfg->fTDLSRSSITeardownThreshold; |
| 1239 | config->tdls_rssi_delta = cfg->fTDLSRSSIDelta; |
| 1240 | config->tdls_uapsd_mask = cfg->fTDLSUapsdMask; |
| 1241 | config->tdls_uapsd_inactivity_time = cfg->fTDLSPuapsdInactivityTimer; |
| 1242 | config->tdls_uapsd_pti_window = cfg->fTDLSPuapsdPTIWindow; |
| 1243 | config->tdls_uapsd_ptr_timeout = cfg->fTDLSPuapsdPTRTimeout; |
| 1244 | config->tdls_pre_off_chan_num = cfg->fTDLSPrefOffChanNum; |
| 1245 | config->tdls_pre_off_chan_bw = cfg->fTDLSPrefOffChanBandwidth; |
| 1246 | config->tdls_peer_kickout_threshold = cfg->tdls_peer_kickout_threshold; |
| 1247 | config->delayed_trig_framint = cfg->DelayedTriggerFrmInt; |
| 1248 | config->tdls_feature_flags = ((cfg->fEnableTDLSOffChannel ? |
| 1249 | 1 << TDLS_FEATURE_OFF_CHANNEL : 0) | |
| 1250 | (cfg->fEnableTDLSWmmMode ? 1 << TDLS_FEATURE_WMM : 0) | |
| 1251 | (cfg->fEnableTDLSBufferSta ? 1 << TDLS_FEATURE_BUFFER_STA : 0) | |
| 1252 | (cfg->fEnableTDLSSleepSta ? 1 << TDLS_FEATURE_SLEEP_STA : 0) | |
| 1253 | (cfg->enable_tdls_scan ? 1 << TDLS_FEATURE_SCAN : 0) | |
| 1254 | (cfg->fEnableTDLSSupport ? 1 << TDLS_FEATURE_ENABLE : 0) | |
| 1255 | (cfg->fEnableTDLSImplicitTrigger ? |
| 1256 | 1 << TDLS_FEAUTRE_IMPLICIT_TRIGGER : 0) | |
| 1257 | (cfg->fTDLSExternalControl ? |
| 1258 | 1 << TDLS_FEATURE_EXTERNAL_CONTROL : 0)); |
| 1259 | config->tdls_vdev_nss_2g = CFG_TDLS_NSS(cfg->vdev_type_nss_2g); |
| 1260 | config->tdls_vdev_nss_5g = CFG_TDLS_NSS(cfg->vdev_type_nss_5g); |
| 1261 | |
| 1262 | tdls_cfg.tdls_send_mgmt_req = eWNI_SME_TDLS_SEND_MGMT_REQ; |
| 1263 | tdls_cfg.tdls_add_sta_req = eWNI_SME_TDLS_ADD_STA_REQ; |
| 1264 | tdls_cfg.tdls_del_sta_req = eWNI_SME_TDLS_DEL_STA_REQ; |
| 1265 | tdls_cfg.tdls_update_peer_state = WMA_UPDATE_TDLS_PEER_STATE; |
| 1266 | tdls_cfg.tdls_del_all_peers = eWNI_SME_DEL_ALL_TDLS_PEERS; |
| 1267 | tdls_cfg.tdls_update_dp_vdev_flags = CDP_UPDATE_TDLS_FLAGS; |
| 1268 | tdls_cfg.tdls_event_cb = wlan_cfg80211_tdls_event_callback; |
| 1269 | tdls_cfg.tdls_evt_cb_data = psoc; |
Jeff Johnson | 1d40f5b | 2018-03-02 08:35:53 -0800 | [diff] [blame] | 1270 | tdls_cfg.tdls_peer_context = hdd_ctx; |
| 1271 | tdls_cfg.tdls_reg_peer = hdd_tdls_register_peer; |
| 1272 | tdls_cfg.tdls_dereg_peer = hdd_tdls_deregister_peer; |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1273 | tdls_cfg.tdls_wmm_cb = hdd_wmm_is_acm_allowed; |
| 1274 | tdls_cfg.tdls_wmm_cb_data = psoc; |
| 1275 | tdls_cfg.tdls_rx_cb = wlan_cfg80211_tdls_rx_callback; |
| 1276 | tdls_cfg.tdls_rx_cb_data = psoc; |
| 1277 | tdls_cfg.tdls_dp_vdev_update = hdd_update_dp_vdev_flags; |
| 1278 | |
| 1279 | status = ucfg_tdls_update_config(psoc, &tdls_cfg); |
| 1280 | if (status != QDF_STATUS_SUCCESS) { |
| 1281 | hdd_err("failed pmo psoc configuration"); |
| 1282 | return -EINVAL; |
| 1283 | } |
| 1284 | |
| 1285 | hdd_ctx->tdls_umac_comp_active = true; |
| 1286 | /* enable napier specific tdls data path */ |
| 1287 | hdd_ctx->tdls_nap_active = true; |
| 1288 | |
| 1289 | return 0; |
| 1290 | } |
| 1291 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1292 | static void hdd_update_tgt_services(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1293 | struct wma_tgt_services *cfg) |
| 1294 | { |
| 1295 | struct hdd_config *config = hdd_ctx->config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1296 | |
| 1297 | /* Set up UAPSD */ |
| 1298 | config->apUapsdEnabled &= cfg->uapsd; |
| 1299 | |
Krishna Kumaar Natarajan | 4f1d772 | 2017-03-03 21:12:51 -0800 | [diff] [blame] | 1300 | /* 11AX mode support */ |
| 1301 | if ((config->dot11Mode == eHDD_DOT11_MODE_11ax || |
| 1302 | config->dot11Mode == eHDD_DOT11_MODE_11ax_ONLY) && !cfg->en_11ax) |
| 1303 | config->dot11Mode = eHDD_DOT11_MODE_11ac; |
| 1304 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1305 | /* 11AC mode support */ |
| 1306 | if ((config->dot11Mode == eHDD_DOT11_MODE_11ac || |
| 1307 | config->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY) && !cfg->en_11ac) |
| 1308 | config->dot11Mode = eHDD_DOT11_MODE_AUTO; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1309 | |
| 1310 | /* ARP offload: override user setting if invalid */ |
| 1311 | config->fhostArpOffload &= cfg->arp_offload; |
| 1312 | |
| 1313 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 1314 | /* PNO offload */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1315 | hdd_debug("PNO Capability in f/w = %d", cfg->pno_offload); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1316 | if (cfg->pno_offload) |
| 1317 | config->PnoOffload = true; |
| 1318 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1319 | #ifdef FEATURE_WLAN_TDLS |
| 1320 | config->fEnableTDLSSupport &= cfg->en_tdls; |
Manjeet Singh | fdd2ac7 | 2016-09-02 18:11:43 +0530 | [diff] [blame] | 1321 | config->fEnableTDLSOffChannel = config->fEnableTDLSOffChannel && |
| 1322 | cfg->en_tdls_offchan; |
| 1323 | config->fEnableTDLSBufferSta = config->fEnableTDLSBufferSta && |
| 1324 | cfg->en_tdls_uapsd_buf_sta; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 1325 | if (config->fTDLSUapsdMask && cfg->en_tdls_uapsd_sleep_sta) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1326 | config->fEnableTDLSSleepSta = true; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 1327 | else |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1328 | config->fEnableTDLSSleepSta = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1329 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1330 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
| 1331 | config->isRoamOffloadEnabled &= cfg->en_roam_offload; |
| 1332 | #endif |
Will Huang | 496b36c | 2017-07-11 16:38:50 +0800 | [diff] [blame] | 1333 | config->sap_get_peer_info &= cfg->get_peer_info_enabled; |
Varun Reddy Yeturu | 62c3265 | 2017-10-26 15:32:35 -0700 | [diff] [blame] | 1334 | config->MAWCEnabled &= cfg->is_fw_mawc_capable; |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1335 | hdd_update_tdls_config(hdd_ctx); |
Krishna Kumaar Natarajan | 052c6e6 | 2015-09-28 15:32:55 -0700 | [diff] [blame] | 1336 | sme_update_tgt_services(hdd_ctx->hHal, cfg); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1337 | |
| 1338 | } |
| 1339 | |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1340 | /** |
| 1341 | * hdd_update_vdev_nss() - sets the vdev nss |
| 1342 | * @hdd_ctx: HDD context |
| 1343 | * |
| 1344 | * Sets the Nss per vdev type based on INI |
| 1345 | * |
| 1346 | * Return: None |
| 1347 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1348 | static void hdd_update_vdev_nss(struct hdd_context *hdd_ctx) |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1349 | { |
| 1350 | struct hdd_config *cfg_ini = hdd_ctx->config; |
| 1351 | uint8_t max_supp_nss = 1; |
| 1352 | |
Naveen Rawat | 10b1c15 | 2017-01-18 11:16:06 -0800 | [diff] [blame] | 1353 | if (cfg_ini->enable2x2 && !cds_is_sub_20_mhz_enabled()) |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1354 | max_supp_nss = 2; |
| 1355 | |
| 1356 | sme_update_vdev_type_nss(hdd_ctx->hHal, max_supp_nss, |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1357 | cfg_ini->vdev_type_nss_2g, BAND_2G); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1358 | |
| 1359 | sme_update_vdev_type_nss(hdd_ctx->hHal, max_supp_nss, |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1360 | cfg_ini->vdev_type_nss_5g, BAND_5G); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1361 | } |
| 1362 | |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1363 | /** |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1364 | * hdd_update_wiphy_vhtcap() - Updates wiphy vhtcap fields |
| 1365 | * @hdd_ctx: HDD context |
| 1366 | * |
| 1367 | * Updates wiphy vhtcap fields |
| 1368 | * |
| 1369 | * Return: None |
| 1370 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1371 | static void hdd_update_wiphy_vhtcap(struct hdd_context *hdd_ctx) |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1372 | { |
| 1373 | struct ieee80211_supported_band *band_5g = |
| 1374 | hdd_ctx->wiphy->bands[NL80211_BAND_5GHZ]; |
| 1375 | uint32_t val; |
| 1376 | |
| 1377 | if (!band_5g) { |
| 1378 | hdd_debug("5GHz band disabled, skipping capability population"); |
| 1379 | return; |
| 1380 | } |
| 1381 | |
| 1382 | val = hdd_ctx->config->txBFCsnValue; |
| 1383 | band_5g->vht_cap.cap |= (val << IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT); |
| 1384 | |
| 1385 | val = NUM_OF_SOUNDING_DIMENSIONS; |
| 1386 | band_5g->vht_cap.cap |= |
| 1387 | (val << IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_SHIFT); |
| 1388 | |
| 1389 | hdd_info("Updated wiphy vhtcap:0x%x, CSNAntSupp:%d, NumSoundDim:%d", |
| 1390 | band_5g->vht_cap.cap, hdd_ctx->config->txBFCsnValue, val); |
| 1391 | } |
| 1392 | |
| 1393 | /** |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1394 | * hdd_update_hw_dbs_capable() - sets the dbs capability of the device |
| 1395 | * @hdd_ctx: HDD context |
| 1396 | * |
| 1397 | * Sets the DBS capability as per INI and firmware capability |
| 1398 | * |
| 1399 | * Return: None |
| 1400 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1401 | static void hdd_update_hw_dbs_capable(struct hdd_context *hdd_ctx) |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1402 | { |
| 1403 | struct hdd_config *cfg_ini = hdd_ctx->config; |
| 1404 | uint8_t hw_dbs_capable = 0; |
| 1405 | |
Tushnim Bhattacharyya | 49ed8ab | 2017-05-26 18:20:10 -0700 | [diff] [blame] | 1406 | if (policy_mgr_is_hw_dbs_capable(hdd_ctx->hdd_psoc) && |
| 1407 | ((cfg_ini->dual_mac_feature_disable == |
| 1408 | ENABLE_DBS_CXN_AND_SCAN) || |
| 1409 | (cfg_ini->dual_mac_feature_disable == |
| 1410 | ENABLE_DBS_CXN_AND_ENABLE_SCAN_WITH_ASYNC_SCAN_OFF))) |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1411 | hw_dbs_capable = 1; |
| 1412 | |
| 1413 | sme_update_hw_dbs_capable(hdd_ctx->hHal, hw_dbs_capable); |
| 1414 | } |
| 1415 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1416 | static void hdd_update_tgt_ht_cap(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1417 | struct wma_tgt_ht_cap *cfg) |
| 1418 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1419 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1420 | uint32_t value, val32; |
| 1421 | uint16_t val16; |
| 1422 | struct hdd_config *pconfig = hdd_ctx->config; |
| 1423 | tSirMacHTCapabilityInfo *phtCapInfo; |
| 1424 | uint8_t mcs_set[SIZE_OF_SUPPORTED_MCS_SET]; |
| 1425 | uint8_t enable_tx_stbc; |
| 1426 | |
| 1427 | /* check and update RX STBC */ |
| 1428 | if (pconfig->enableRxSTBC && !cfg->ht_rx_stbc) |
| 1429 | pconfig->enableRxSTBC = cfg->ht_rx_stbc; |
| 1430 | |
| 1431 | /* get the MPDU density */ |
| 1432 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_MPDU_DENSITY, &value); |
| 1433 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1434 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1435 | hdd_err("could not get MPDU DENSITY"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1436 | value = 0; |
| 1437 | } |
| 1438 | |
| 1439 | /* |
| 1440 | * MPDU density: |
| 1441 | * override user's setting if value is larger |
| 1442 | * than the one supported by target |
| 1443 | */ |
| 1444 | if (value > cfg->mpdu_density) { |
| 1445 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_MPDU_DENSITY, |
| 1446 | cfg->mpdu_density); |
| 1447 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1448 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1449 | hdd_err("could not set MPDU DENSITY to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1450 | } |
| 1451 | |
| 1452 | /* get the HT capability info */ |
| 1453 | 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] | 1454 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1455 | hdd_err("could not get HT capability info"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1456 | return; |
| 1457 | } |
| 1458 | val16 = (uint16_t) val32; |
| 1459 | phtCapInfo = (tSirMacHTCapabilityInfo *) &val16; |
| 1460 | |
| 1461 | /* Set the LDPC capability */ |
| 1462 | phtCapInfo->advCodingCap = cfg->ht_rx_ldpc; |
| 1463 | |
| 1464 | if (pconfig->ShortGI20MhzEnable && !cfg->ht_sgi_20) |
| 1465 | pconfig->ShortGI20MhzEnable = cfg->ht_sgi_20; |
| 1466 | |
| 1467 | if (pconfig->ShortGI40MhzEnable && !cfg->ht_sgi_40) |
| 1468 | pconfig->ShortGI40MhzEnable = cfg->ht_sgi_40; |
| 1469 | |
| 1470 | hdd_ctx->num_rf_chains = cfg->num_rf_chains; |
| 1471 | hdd_ctx->ht_tx_stbc_supported = cfg->ht_tx_stbc; |
| 1472 | |
| 1473 | enable_tx_stbc = pconfig->enableTxSTBC; |
| 1474 | |
| 1475 | if (pconfig->enable2x2 && (cfg->num_rf_chains == 2)) { |
| 1476 | pconfig->enable2x2 = 1; |
| 1477 | } else { |
| 1478 | pconfig->enable2x2 = 0; |
| 1479 | enable_tx_stbc = 0; |
| 1480 | |
| 1481 | /* 1x1 */ |
| 1482 | /* Update Rx Highest Long GI data Rate */ |
| 1483 | if (sme_cfg_set_int(hdd_ctx->hHal, |
| 1484 | WNI_CFG_VHT_RX_HIGHEST_SUPPORTED_DATA_RATE, |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1485 | VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1486 | == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1487 | 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] | 1488 | } |
| 1489 | |
| 1490 | /* Update Tx Highest Long GI data Rate */ |
| 1491 | if (sme_cfg_set_int |
| 1492 | (hdd_ctx->hHal, |
| 1493 | WNI_CFG_VHT_TX_HIGHEST_SUPPORTED_DATA_RATE, |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1494 | VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1) == |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1495 | QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1496 | hdd_err("VHT_TX_HIGHEST_SUPP_RATE_1_1 to CCM fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1497 | } |
| 1498 | } |
| 1499 | if (!(cfg->ht_tx_stbc && pconfig->enable2x2)) |
| 1500 | enable_tx_stbc = 0; |
| 1501 | phtCapInfo->txSTBC = enable_tx_stbc; |
| 1502 | |
| 1503 | val32 = val16; |
| 1504 | 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] | 1505 | if (status != QDF_STATUS_SUCCESS) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1506 | hdd_err("could not set HT capability to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1507 | #define WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES 0xff |
| 1508 | value = SIZE_OF_SUPPORTED_MCS_SET; |
| 1509 | 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] | 1510 | &value) == QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1511 | hdd_debug("Read MCS rate set"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1512 | |
| 1513 | if (pconfig->enable2x2) { |
| 1514 | for (value = 0; value < cfg->num_rf_chains; value++) |
| 1515 | mcs_set[value] = |
| 1516 | WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES; |
| 1517 | |
| 1518 | status = |
| 1519 | sme_cfg_set_str(hdd_ctx->hHal, |
| 1520 | WNI_CFG_SUPPORTED_MCS_SET, |
| 1521 | mcs_set, |
| 1522 | SIZE_OF_SUPPORTED_MCS_SET); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1523 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1524 | hdd_err("could not set MCS SET to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1525 | } |
| 1526 | } |
| 1527 | #undef WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES |
| 1528 | } |
| 1529 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1530 | static void hdd_update_tgt_vht_cap(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1531 | struct wma_tgt_vht_cap *cfg) |
| 1532 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1533 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1534 | uint32_t value = 0; |
| 1535 | struct hdd_config *pconfig = hdd_ctx->config; |
| 1536 | struct wiphy *wiphy = hdd_ctx->wiphy; |
| 1537 | struct ieee80211_supported_band *band_5g = |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 1538 | wiphy->bands[HDD_NL80211_BAND_5GHZ]; |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1539 | uint32_t temp = 0; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1540 | uint32_t ch_width = eHT_CHANNEL_WIDTH_80MHZ; |
jiad | 4a7a33c | 2017-08-08 15:32:24 +0800 | [diff] [blame] | 1541 | uint32_t hw_rx_ldpc_enabled; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1542 | |
Dustin Brown | 5e06bd3 | 2016-10-04 12:49:10 -0700 | [diff] [blame] | 1543 | if (!band_5g) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1544 | hdd_debug("5GHz band disabled, skipping capability population"); |
Dustin Brown | 5e06bd3 | 2016-10-04 12:49:10 -0700 | [diff] [blame] | 1545 | return; |
| 1546 | } |
| 1547 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1548 | /* Get the current MPDU length */ |
| 1549 | status = |
| 1550 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_MAX_MPDU_LENGTH, |
| 1551 | &value); |
| 1552 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1553 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1554 | hdd_err("could not get MPDU LENGTH"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1555 | value = 0; |
| 1556 | } |
| 1557 | |
| 1558 | /* |
| 1559 | * VHT max MPDU length: |
| 1560 | * override if user configured value is too high |
| 1561 | * that the target cannot support |
| 1562 | */ |
| 1563 | if (value > cfg->vht_max_mpdu) { |
| 1564 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1565 | WNI_CFG_VHT_MAX_MPDU_LENGTH, |
| 1566 | cfg->vht_max_mpdu); |
| 1567 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1568 | if (status == QDF_STATUS_E_FAILURE) |
| 1569 | hdd_err("could not set VHT MAX MPDU LENGTH"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1570 | } |
| 1571 | |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1572 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_BASIC_MCS_SET, &temp); |
| 1573 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtRxMCS; |
| 1574 | |
| 1575 | if (pconfig->enable2x2) |
| 1576 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtRxMCS2x2 << 2); |
| 1577 | |
| 1578 | if (sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_BASIC_MCS_SET, temp) == |
| 1579 | QDF_STATUS_E_FAILURE) { |
| 1580 | hdd_err("Could not pass VHT_BASIC_MCS_SET to CCM"); |
| 1581 | } |
| 1582 | |
| 1583 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_RX_MCS_MAP, &temp); |
| 1584 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtRxMCS; |
| 1585 | if (pconfig->enable2x2) |
| 1586 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtRxMCS2x2 << 2); |
| 1587 | |
| 1588 | if (sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_RX_MCS_MAP, temp) == |
| 1589 | QDF_STATUS_E_FAILURE) { |
| 1590 | hdd_err("Could not pass WNI_CFG_VHT_RX_MCS_MAP to CCM"); |
| 1591 | } |
| 1592 | |
| 1593 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_TX_MCS_MAP, &temp); |
| 1594 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtTxMCS; |
| 1595 | if (pconfig->enable2x2) |
| 1596 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtTxMCS2x2 << 2); |
| 1597 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1598 | hdd_debug("vhtRxMCS2x2 - %x temp - %u enable2x2 %d", |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1599 | pconfig->vhtRxMCS2x2, temp, pconfig->enable2x2); |
| 1600 | |
| 1601 | if (sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_TX_MCS_MAP, temp) == |
| 1602 | QDF_STATUS_E_FAILURE) { |
| 1603 | hdd_err("Could not pass WNI_CFG_VHT_TX_MCS_MAP to CCM"); |
| 1604 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1605 | /* Get the current RX LDPC setting */ |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1606 | 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] | 1607 | &value); |
| 1608 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1609 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1610 | hdd_err("could not get VHT LDPC CODING CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1611 | value = 0; |
| 1612 | } |
| 1613 | |
jiad | 4a7a33c | 2017-08-08 15:32:24 +0800 | [diff] [blame] | 1614 | /* Set HW RX LDPC capability */ |
| 1615 | hw_rx_ldpc_enabled = !!cfg->vht_rx_ldpc; |
| 1616 | if (hw_rx_ldpc_enabled != value) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1617 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1618 | WNI_CFG_VHT_LDPC_CODING_CAP, |
jiad | 4a7a33c | 2017-08-08 15:32:24 +0800 | [diff] [blame] | 1619 | hw_rx_ldpc_enabled); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1620 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1621 | if (status == QDF_STATUS_E_FAILURE) |
| 1622 | hdd_err("could not set VHT LDPC CODING CAP to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1623 | } |
| 1624 | |
| 1625 | /* Get current GI 80 value */ |
| 1626 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_SHORT_GI_80MHZ, |
| 1627 | &value); |
| 1628 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1629 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1630 | hdd_err("could not get SHORT GI 80MHZ"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1631 | value = 0; |
| 1632 | } |
| 1633 | |
| 1634 | /* set the Guard interval 80MHz */ |
| 1635 | if (value && !cfg->vht_short_gi_80) { |
| 1636 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1637 | WNI_CFG_VHT_SHORT_GI_80MHZ, |
| 1638 | cfg->vht_short_gi_80); |
| 1639 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1640 | if (status == QDF_STATUS_E_FAILURE) |
| 1641 | hdd_err("could not set SHORT GI 80MHZ to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1642 | } |
| 1643 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1644 | /* Get VHT TX STBC cap */ |
| 1645 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_TXSTBC, &value); |
| 1646 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1647 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1648 | hdd_err("could not get VHT TX STBC"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1649 | value = 0; |
| 1650 | } |
| 1651 | |
| 1652 | /* VHT TX STBC cap */ |
| 1653 | if (value && !cfg->vht_tx_stbc) { |
| 1654 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_TXSTBC, |
| 1655 | cfg->vht_tx_stbc); |
| 1656 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1657 | if (status == QDF_STATUS_E_FAILURE) |
| 1658 | hdd_err("could not set the VHT TX STBC to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1659 | } |
| 1660 | |
| 1661 | /* Get VHT RX STBC cap */ |
| 1662 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_RXSTBC, &value); |
| 1663 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1664 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1665 | hdd_err("could not get VHT RX STBC"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1666 | value = 0; |
| 1667 | } |
| 1668 | |
| 1669 | /* VHT RX STBC cap */ |
| 1670 | if (value && !cfg->vht_rx_stbc) { |
| 1671 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_RXSTBC, |
| 1672 | cfg->vht_rx_stbc); |
| 1673 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1674 | if (status == QDF_STATUS_E_FAILURE) |
| 1675 | hdd_err("could not set the VHT RX STBC to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1676 | } |
| 1677 | |
| 1678 | /* Get VHT SU Beamformer cap */ |
| 1679 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_SU_BEAMFORMER_CAP, |
| 1680 | &value); |
| 1681 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1682 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1683 | hdd_err("could not get VHT SU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1684 | value = 0; |
| 1685 | } |
| 1686 | |
| 1687 | /* set VHT SU Beamformer cap */ |
| 1688 | if (value && !cfg->vht_su_bformer) { |
| 1689 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1690 | WNI_CFG_VHT_SU_BEAMFORMER_CAP, |
| 1691 | cfg->vht_su_bformer); |
| 1692 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1693 | if (status == QDF_STATUS_E_FAILURE) |
| 1694 | hdd_err("could not set VHT SU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1695 | } |
| 1696 | |
| 1697 | /* check and update SU BEAMFORMEE capabality */ |
| 1698 | if (pconfig->enableTxBF && !cfg->vht_su_bformee) |
| 1699 | pconfig->enableTxBF = cfg->vht_su_bformee; |
| 1700 | |
| 1701 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1702 | WNI_CFG_VHT_SU_BEAMFORMEE_CAP, |
| 1703 | pconfig->enableTxBF); |
| 1704 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1705 | if (status == QDF_STATUS_E_FAILURE) |
| 1706 | hdd_err("could not set VHT SU BEAMFORMEE CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1707 | |
| 1708 | /* Get VHT MU Beamformer cap */ |
| 1709 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_MU_BEAMFORMER_CAP, |
| 1710 | &value); |
| 1711 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1712 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1713 | hdd_err("could not get VHT MU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1714 | value = 0; |
| 1715 | } |
| 1716 | |
| 1717 | /* set VHT MU Beamformer cap */ |
| 1718 | if (value && !cfg->vht_mu_bformer) { |
| 1719 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1720 | WNI_CFG_VHT_MU_BEAMFORMER_CAP, |
| 1721 | cfg->vht_mu_bformer); |
| 1722 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1723 | if (status == QDF_STATUS_E_FAILURE) |
| 1724 | hdd_err("could not set the VHT MU BEAMFORMER CAP to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1725 | } |
| 1726 | |
| 1727 | /* Get VHT MU Beamformee cap */ |
| 1728 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_MU_BEAMFORMEE_CAP, |
| 1729 | &value); |
| 1730 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1731 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1732 | hdd_err("could not get VHT MU BEAMFORMEE CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1733 | value = 0; |
| 1734 | } |
| 1735 | |
| 1736 | /* set VHT MU Beamformee cap */ |
| 1737 | if (value && !cfg->vht_mu_bformee) { |
| 1738 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1739 | WNI_CFG_VHT_MU_BEAMFORMEE_CAP, |
| 1740 | cfg->vht_mu_bformee); |
| 1741 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1742 | if (status == QDF_STATUS_E_FAILURE) |
| 1743 | hdd_err("could not set VHT MU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1744 | } |
| 1745 | |
| 1746 | /* Get VHT MAX AMPDU Len exp */ |
| 1747 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_AMPDU_LEN_EXPONENT, |
| 1748 | &value); |
| 1749 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1750 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1751 | hdd_err("could not get VHT AMPDU LEN"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1752 | value = 0; |
| 1753 | } |
| 1754 | |
| 1755 | /* |
| 1756 | * VHT max AMPDU len exp: |
| 1757 | * override if user configured value is too high |
| 1758 | * that the target cannot support. |
| 1759 | * Even though Rome publish ampdu_len=7, it can |
| 1760 | * only support 4 because of some h/w bug. |
| 1761 | */ |
| 1762 | |
| 1763 | if (value > cfg->vht_max_ampdu_len_exp) { |
| 1764 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1765 | WNI_CFG_VHT_AMPDU_LEN_EXPONENT, |
| 1766 | cfg->vht_max_ampdu_len_exp); |
| 1767 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1768 | if (status == QDF_STATUS_E_FAILURE) |
| 1769 | hdd_err("could not set the VHT AMPDU LEN EXP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1770 | } |
| 1771 | |
| 1772 | /* Get VHT TXOP PS CAP */ |
| 1773 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_TXOP_PS, &value); |
| 1774 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1775 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1776 | hdd_err("could not get VHT TXOP PS"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1777 | value = 0; |
| 1778 | } |
| 1779 | |
| 1780 | /* set VHT TXOP PS cap */ |
| 1781 | if (value && !cfg->vht_txop_ps) { |
| 1782 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_TXOP_PS, |
| 1783 | cfg->vht_txop_ps); |
| 1784 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1785 | if (status == QDF_STATUS_E_FAILURE) |
| 1786 | hdd_err("could not set the VHT TXOP PS"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1787 | } |
| 1788 | |
| 1789 | if (WMI_VHT_CAP_MAX_MPDU_LEN_11454 == cfg->vht_max_mpdu) |
| 1790 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454; |
| 1791 | else if (WMI_VHT_CAP_MAX_MPDU_LEN_7935 == cfg->vht_max_mpdu) |
| 1792 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991; |
| 1793 | else |
| 1794 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895; |
| 1795 | |
| 1796 | |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1797 | if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_80P80MHZ)) { |
| 1798 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1799 | WNI_CFG_VHT_SUPPORTED_CHAN_WIDTH_SET, |
| 1800 | VHT_CAP_160_AND_80P80_SUPP); |
| 1801 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1802 | hdd_err("could not set the VHT CAP 160"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1803 | band_5g->vht_cap.cap |= |
| 1804 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1805 | ch_width = eHT_CHANNEL_WIDTH_80P80MHZ; |
| 1806 | } else if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_160MHZ)) { |
| 1807 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1808 | WNI_CFG_VHT_SUPPORTED_CHAN_WIDTH_SET, |
| 1809 | VHT_CAP_160_SUPP); |
| 1810 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1811 | hdd_err("could not set the VHT CAP 160"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1812 | band_5g->vht_cap.cap |= |
| 1813 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1814 | ch_width = eHT_CHANNEL_WIDTH_160MHZ; |
| 1815 | } |
| 1816 | pconfig->vhtChannelWidth = QDF_MIN(pconfig->vhtChannelWidth, |
| 1817 | ch_width); |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1818 | /* Get the current GI 160 value */ |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1819 | status = sme_cfg_get_int(hdd_ctx->hHal, |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1820 | WNI_CFG_VHT_SHORT_GI_160_AND_80_PLUS_80MHZ, |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1821 | &value); |
| 1822 | if (status != QDF_STATUS_SUCCESS) { |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1823 | hdd_err("could not get GI 80 & 160"); |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1824 | value = 0; |
| 1825 | } |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1826 | /* set the Guard interval 160MHz */ |
| 1827 | if (value && !cfg->vht_short_gi_160) { |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1828 | status = sme_cfg_set_int(hdd_ctx->hHal, |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1829 | WNI_CFG_VHT_SHORT_GI_160_AND_80_PLUS_80MHZ, |
| 1830 | cfg->vht_short_gi_160); |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1831 | |
| 1832 | if (status == QDF_STATUS_E_FAILURE) |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1833 | hdd_err("failed to set SHORT GI 160MHZ"); |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1834 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1835 | |
| 1836 | if (cfg->vht_rx_ldpc & WMI_VHT_CAP_RX_LDPC) |
| 1837 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXLDPC; |
| 1838 | |
| 1839 | if (cfg->vht_short_gi_80 & WMI_VHT_CAP_SGI_80MHZ) |
| 1840 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_80; |
| 1841 | if (cfg->vht_short_gi_160 & WMI_VHT_CAP_SGI_160MHZ) |
| 1842 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_160; |
| 1843 | |
| 1844 | if (cfg->vht_tx_stbc & WMI_VHT_CAP_TX_STBC) |
| 1845 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_TXSTBC; |
| 1846 | |
| 1847 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_1SS) |
| 1848 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_1; |
| 1849 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_2SS) |
| 1850 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_2; |
| 1851 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_3SS) |
| 1852 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_3; |
| 1853 | |
| 1854 | band_5g->vht_cap.cap |= |
| 1855 | (cfg->vht_max_ampdu_len_exp << |
| 1856 | IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT); |
| 1857 | |
| 1858 | if (cfg->vht_su_bformer & WMI_VHT_CAP_SU_BFORMER) |
| 1859 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE; |
| 1860 | if (cfg->vht_su_bformee & WMI_VHT_CAP_SU_BFORMEE) |
| 1861 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE; |
| 1862 | if (cfg->vht_mu_bformer & WMI_VHT_CAP_MU_BFORMER) |
| 1863 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE; |
| 1864 | if (cfg->vht_mu_bformee & WMI_VHT_CAP_MU_BFORMEE) |
| 1865 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE; |
| 1866 | |
| 1867 | if (cfg->vht_txop_ps & WMI_VHT_CAP_TXOP_PS) |
| 1868 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_VHT_TXOP_PS; |
| 1869 | |
| 1870 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1871 | |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1872 | /** |
| 1873 | * hdd_generate_macaddr_auto() - Auto-generate mac address |
| 1874 | * @hdd_ctx: Pointer to the HDD context |
| 1875 | * |
| 1876 | * Auto-generate mac address using device serial number. |
| 1877 | * Keep the first 3 bytes of OUI as before and replace |
| 1878 | * the last 3 bytes with the lower 3 bytes of serial number. |
| 1879 | * |
| 1880 | * Return: 0 for success |
| 1881 | * Non zero failure code for errors |
| 1882 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1883 | static int hdd_generate_macaddr_auto(struct hdd_context *hdd_ctx) |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1884 | { |
| 1885 | unsigned int serialno = 0; |
| 1886 | struct qdf_mac_addr mac_addr = { |
| 1887 | {0x00, 0x0A, 0xF5, 0x00, 0x00, 0x00} |
| 1888 | }; |
| 1889 | |
Yuanyuan Liu | f97e822 | 2016-09-21 10:31:38 -0700 | [diff] [blame] | 1890 | serialno = pld_socinfo_get_serial_number(hdd_ctx->parent_dev); |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1891 | if (serialno == 0) |
| 1892 | return -EINVAL; |
| 1893 | |
| 1894 | serialno &= 0x00ffffff; |
| 1895 | |
| 1896 | mac_addr.bytes[3] = (serialno >> 16) & 0xff; |
| 1897 | mac_addr.bytes[4] = (serialno >> 8) & 0xff; |
| 1898 | mac_addr.bytes[5] = serialno & 0xff; |
| 1899 | |
| 1900 | hdd_update_macaddr(hdd_ctx->config, mac_addr); |
| 1901 | return 0; |
| 1902 | } |
| 1903 | |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1904 | /** |
| 1905 | * hdd_update_ra_rate_limit() - Update RA rate limit from target |
| 1906 | * configuration to cfg_ini in HDD |
| 1907 | * @hdd_ctx: Pointer to hdd_ctx |
| 1908 | * @cfg: target configuration |
| 1909 | * |
| 1910 | * Return: None |
| 1911 | */ |
| 1912 | #ifdef FEATURE_WLAN_RA_FILTERING |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1913 | static void hdd_update_ra_rate_limit(struct hdd_context *hdd_ctx, |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1914 | struct wma_tgt_cfg *cfg) |
| 1915 | { |
| 1916 | hdd_ctx->config->IsRArateLimitEnabled = cfg->is_ra_rate_limit_enabled; |
| 1917 | } |
| 1918 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1919 | static void hdd_update_ra_rate_limit(struct hdd_context *hdd_ctx, |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1920 | struct wma_tgt_cfg *cfg) |
| 1921 | { |
| 1922 | } |
| 1923 | #endif |
| 1924 | |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 1925 | static int hdd_update_green_ap_config(struct hdd_context *hdd_ctx) |
| 1926 | { |
| 1927 | struct green_ap_user_cfg green_ap_cfg; |
| 1928 | struct hdd_config *cfg = hdd_ctx->config; |
| 1929 | QDF_STATUS status; |
| 1930 | |
| 1931 | green_ap_cfg.host_enable_egap = cfg->enable_egap; |
| 1932 | green_ap_cfg.egap_inactivity_time = cfg->egap_inact_time; |
| 1933 | green_ap_cfg.egap_wait_time = cfg->egap_wait_time; |
| 1934 | green_ap_cfg.egap_feature_flags = cfg->egap_feature_flag; |
| 1935 | |
| 1936 | status = ucfg_green_ap_update_user_config(hdd_ctx->hdd_pdev, |
| 1937 | &green_ap_cfg); |
| 1938 | if (status != QDF_STATUS_SUCCESS) { |
| 1939 | hdd_err("failed to update green ap user configuration"); |
| 1940 | return -EINVAL; |
| 1941 | } |
| 1942 | |
| 1943 | return 0; |
| 1944 | } |
| 1945 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1946 | void hdd_update_tgt_cfg(void *context, void *param) |
| 1947 | { |
Rajeev Kumar | f49dfdb | 2017-01-13 15:40:35 -0800 | [diff] [blame] | 1948 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1949 | struct hdd_context *hdd_ctx = (struct hdd_context *) context; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1950 | struct wma_tgt_cfg *cfg = param; |
| 1951 | uint8_t temp_band_cap; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1952 | struct cds_config_info *cds_cfg = cds_get_ini_config(); |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 1953 | uint8_t antenna_mode; |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 1954 | QDF_STATUS status; |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1955 | |
Dustin Brown | bd68fe1 | 2017-11-21 15:28:52 -0800 | [diff] [blame] | 1956 | ret = hdd_objmgr_create_and_store_pdev(hdd_ctx); |
| 1957 | if (ret) { |
| 1958 | hdd_err("Failed to create pdev; errno:%d", ret); |
| 1959 | QDF_BUG(0); |
Sandeep Puligilla | 1cf6ebe | 2017-04-04 14:40:27 -0700 | [diff] [blame] | 1960 | } else { |
Dustin Brown | bd68fe1 | 2017-11-21 15:28:52 -0800 | [diff] [blame] | 1961 | hdd_debug("New pdev has been created with pdev_id = %u", |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 1962 | hdd_ctx->hdd_pdev->pdev_objmgr.wlan_pdev_id); |
Amar Singhal | 410675c | 2018-01-10 12:14:21 -0800 | [diff] [blame] | 1963 | if (dispatcher_pdev_open(hdd_ctx->hdd_pdev)) { |
| 1964 | hdd_err("dispatcher pdev open failed"); |
| 1965 | QDF_BUG(0); |
| 1966 | } |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1967 | } |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 1968 | |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 1969 | ret = hdd_update_green_ap_config(hdd_ctx); |
| 1970 | |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame^] | 1971 | ucfg_ipa_set_dp_handle(hdd_ctx->hdd_psoc, |
| 1972 | cds_get_context(QDF_MODULE_ID_SOC)); |
| 1973 | ucfg_ipa_set_txrx_handle(hdd_ctx->hdd_psoc, |
| 1974 | cds_get_context(QDF_MODULE_ID_TXRX)); |
| 1975 | |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1976 | if (cds_cfg) { |
| 1977 | if (hdd_ctx->config->enable_sub_20_channel_width != |
| 1978 | WLAN_SUB_20_CH_WIDTH_NONE && !cfg->sub_20_support) { |
| 1979 | hdd_err("User requested sub 20 MHz channel width but unsupported by FW."); |
| 1980 | cds_cfg->sub_20_channel_width = |
| 1981 | WLAN_SUB_20_CH_WIDTH_NONE; |
| 1982 | } else { |
| 1983 | cds_cfg->sub_20_channel_width = |
| 1984 | hdd_ctx->config->enable_sub_20_channel_width; |
| 1985 | } |
| 1986 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1987 | |
| 1988 | /* first store the INI band capability */ |
| 1989 | temp_band_cap = hdd_ctx->config->nBandCapability; |
| 1990 | |
| 1991 | hdd_ctx->config->nBandCapability = cfg->band_cap; |
Vignesh Viswanathan | 731186f | 2017-09-18 13:47:37 +0530 | [diff] [blame] | 1992 | hdd_ctx->is_fils_roaming_supported = |
| 1993 | cfg->services.is_fils_roaming_supported; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1994 | |
Vignesh Viswanathan | 694e28e | 2018-01-18 20:53:57 +0530 | [diff] [blame] | 1995 | hdd_ctx->config->is_11k_offload_supported = |
| 1996 | cfg->services.is_11k_offload_supported; |
| 1997 | |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 1998 | /* |
| 1999 | * now overwrite the target band capability with INI |
| 2000 | * setting if INI setting is a subset |
| 2001 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2002 | |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 2003 | if ((hdd_ctx->config->nBandCapability == BAND_ALL) && |
| 2004 | (temp_band_cap != BAND_ALL)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2005 | hdd_ctx->config->nBandCapability = temp_band_cap; |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 2006 | else if ((hdd_ctx->config->nBandCapability != BAND_ALL) && |
| 2007 | (temp_band_cap != BAND_ALL) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2008 | (hdd_ctx->config->nBandCapability != temp_band_cap)) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 2009 | hdd_warn("ini BandCapability not supported by the target"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2010 | } |
| 2011 | |
Amar Singhal | 58b45ef | 2017-08-01 13:43:54 -0700 | [diff] [blame] | 2012 | hdd_ctx->curr_band = hdd_ctx->config->nBandCapability; |
| 2013 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 2014 | if (!cds_is_driver_recovering() || cds_is_driver_in_bad_state()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2015 | hdd_ctx->reg.reg_domain = cfg->reg_domain; |
| 2016 | hdd_ctx->reg.eeprom_rd_ext = cfg->eeprom_rd_ext; |
| 2017 | } |
| 2018 | |
| 2019 | /* This can be extended to other configurations like ht, vht cap... */ |
| 2020 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 2021 | if (!qdf_is_macaddr_zero(&cfg->hw_macaddr)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2022 | hdd_update_macaddr(hdd_ctx->config, cfg->hw_macaddr); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 2023 | hdd_ctx->update_mac_addr_to_fw = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2024 | } else { |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 2025 | static struct qdf_mac_addr default_mac_addr = { |
| 2026 | {0x00, 0x0A, 0xF5, 0x89, 0x89, 0xFF} |
| 2027 | }; |
| 2028 | if (qdf_is_macaddr_equal(&hdd_ctx->config->intfMacAddr[0], |
| 2029 | &default_mac_addr)) { |
| 2030 | if (hdd_generate_macaddr_auto(hdd_ctx) != 0) |
| 2031 | hdd_err("Fail to auto-generate MAC, using MAC from ini file " |
| 2032 | MAC_ADDRESS_STR, |
| 2033 | MAC_ADDR_ARRAY(hdd_ctx->config-> |
| 2034 | intfMacAddr[0].bytes)); |
| 2035 | } else { |
| 2036 | hdd_err("Invalid MAC passed from target, using MAC from ini file " |
| 2037 | MAC_ADDRESS_STR, |
| 2038 | MAC_ADDR_ARRAY(hdd_ctx->config-> |
| 2039 | intfMacAddr[0].bytes)); |
| 2040 | } |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 2041 | hdd_ctx->update_mac_addr_to_fw = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2042 | } |
| 2043 | |
| 2044 | hdd_ctx->target_fw_version = cfg->target_fw_version; |
Sandeep Puligilla | 3d6a8e2 | 2016-10-11 18:57:14 -0700 | [diff] [blame] | 2045 | hdd_ctx->target_fw_vers_ext = cfg->target_fw_vers_ext; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2046 | |
| 2047 | hdd_ctx->max_intf_count = cfg->max_intf_count; |
| 2048 | |
Jeff Johnson | c875e24 | 2016-09-23 18:12:34 -0700 | [diff] [blame] | 2049 | hdd_lpass_target_config(hdd_ctx, cfg); |
Ryan Hsu | 3c8f79f | 2015-12-02 16:45:09 -0800 | [diff] [blame] | 2050 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2051 | hdd_ctx->ap_arpns_support = cfg->ap_arpns_support; |
| 2052 | hdd_update_tgt_services(hdd_ctx, &cfg->services); |
| 2053 | |
| 2054 | hdd_update_tgt_ht_cap(hdd_ctx, &cfg->ht_cap); |
| 2055 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2056 | hdd_update_tgt_vht_cap(hdd_ctx, &cfg->vht_cap); |
Krishna Kumaar Natarajan | ed1efd9 | 2016-09-24 18:05:47 -0700 | [diff] [blame] | 2057 | if (cfg->services.en_11ax) { |
| 2058 | hdd_info("11AX: 11ax is enabled - update HDD config"); |
| 2059 | hdd_update_tgt_he_cap(hdd_ctx, cfg); |
| 2060 | } |
Tushnim Bhattacharyya | f44a9d8 | 2016-07-05 10:52:06 -0700 | [diff] [blame] | 2061 | |
| 2062 | hdd_update_vdev_nss(hdd_ctx); |
| 2063 | |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 2064 | hdd_update_hw_dbs_capable(hdd_ctx); |
| 2065 | |
Krishna Kumaar Natarajan | 1ae4911 | 2015-11-24 21:43:22 -0800 | [diff] [blame] | 2066 | hdd_ctx->config->fine_time_meas_cap &= cfg->fine_time_measurement_cap; |
Krunal Soni | e353194 | 2016-04-12 17:43:53 -0700 | [diff] [blame] | 2067 | hdd_ctx->fine_time_meas_cap_target = cfg->fine_time_measurement_cap; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2068 | hdd_debug("fine_time_meas_cap: 0x%x", |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 2069 | hdd_ctx->config->fine_time_meas_cap); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 2070 | |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 2071 | antenna_mode = (hdd_ctx->config->enable2x2 == 0x01) ? |
| 2072 | HDD_ANTENNA_MODE_2X2 : HDD_ANTENNA_MODE_1X1; |
| 2073 | hdd_update_smps_antenna_mode(hdd_ctx, antenna_mode); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2074 | hdd_debug("Init current antenna mode: %d", |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 2075 | hdd_ctx->current_antenna_mode); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 2076 | |
Rajeev Kumar | dd3bc60 | 2016-08-16 14:21:05 -0700 | [diff] [blame] | 2077 | hdd_ctx->bpf_enabled = (cfg->bpf_enabled && |
| 2078 | hdd_ctx->config->bpf_packet_filter_enable); |
Rajeev Kumar Sirasanagandla | 996e529 | 2016-11-22 21:20:33 +0530 | [diff] [blame] | 2079 | hdd_ctx->rcpi_enabled = cfg->rcpi_enabled; |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 2080 | hdd_update_ra_rate_limit(hdd_ctx, cfg); |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 2081 | |
Nachiket Kukade | 8b4bfd8 | 2017-05-25 18:34:48 +0530 | [diff] [blame] | 2082 | if ((hdd_ctx->config->txBFCsnValue > |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 2083 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED_FW_DEF) && |
| 2084 | !cfg->tx_bfee_8ss_enabled) |
Nachiket Kukade | 8b4bfd8 | 2017-05-25 18:34:48 +0530 | [diff] [blame] | 2085 | hdd_ctx->config->txBFCsnValue = |
| 2086 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED_FW_DEF; |
| 2087 | |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 2088 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 2089 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED, |
| 2090 | hdd_ctx->config->txBFCsnValue); |
| 2091 | if (QDF_IS_STATUS_ERROR(status)) |
Nachiket Kukade | 8b4bfd8 | 2017-05-25 18:34:48 +0530 | [diff] [blame] | 2092 | hdd_err("fw update WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED to CFG fails"); |
| 2093 | |
| 2094 | |
| 2095 | hdd_debug("Target BPF %d Host BPF %d 8ss fw support %d txBFCsnValue %d", |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 2096 | cfg->bpf_enabled, hdd_ctx->config->bpf_packet_filter_enable, |
| 2097 | cfg->tx_bfee_8ss_enabled, hdd_ctx->config->txBFCsnValue); |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 2098 | |
| 2099 | /* |
| 2100 | * Update txBFCsnValue and NumSoundingDim values to vhtcap in wiphy |
| 2101 | */ |
| 2102 | hdd_update_wiphy_vhtcap(hdd_ctx); |
Manjeet Singh | 70d3d93 | 2016-12-20 20:41:10 +0530 | [diff] [blame] | 2103 | |
Rajeev Kumar Sirasanagandla | 4787300 | 2016-09-09 13:46:09 +0530 | [diff] [blame] | 2104 | hdd_ctx->wmi_max_len = cfg->wmi_max_len; |
| 2105 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 2106 | /* |
| 2107 | * This needs to be done after HDD pdev is created and stored since |
| 2108 | * it will access the HDD pdev object lock. |
| 2109 | */ |
| 2110 | hdd_runtime_suspend_context_init(hdd_ctx); |
| 2111 | |
Deepak Dhamdhere | 13230d3 | 2016-05-26 00:46:53 -0700 | [diff] [blame] | 2112 | /* Configure NAN datapath features */ |
| 2113 | hdd_nan_datapath_target_config(hdd_ctx, cfg); |
Arif Hussain | 759a023 | 2017-03-20 13:17:18 -0700 | [diff] [blame] | 2114 | hdd_ctx->dfs_cac_offload = cfg->dfs_cac_offload; |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 2115 | hdd_ctx->lte_coex_ant_share = cfg->services.lte_coex_ant_share; |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 2116 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_OBSS_DETECTION_OFFLOAD, |
| 2117 | cfg->obss_detection_offloaded); |
| 2118 | if (QDF_IS_STATUS_ERROR(status)) |
| 2119 | hdd_err("Couldn't pass WNI_CFG_OBSS_DETECTION_OFFLOAD to CFG"); |
Arif Hussain | 05fb487 | 2018-01-03 16:02:55 -0800 | [diff] [blame] | 2120 | |
| 2121 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 2122 | WNI_CFG_OBSS_COLOR_COLLISION_OFFLOAD, |
| 2123 | cfg->obss_color_collision_offloaded); |
| 2124 | if (QDF_IS_STATUS_ERROR(status)) |
| 2125 | hdd_err("Failed to set WNI_CFG_OBSS_COLOR_COLLISION_OFFLOAD"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2126 | } |
| 2127 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2128 | bool hdd_dfs_indicate_radar(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2129 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2130 | struct hdd_adapter *adapter; |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 2131 | struct hdd_ap_ctx *ap_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2132 | |
Jiachao Wu | f610d91 | 2018-01-23 17:47:32 +0800 | [diff] [blame] | 2133 | if (!hdd_ctx) { |
| 2134 | hdd_info("Couldn't get hdd_ctx"); |
| 2135 | return true; |
| 2136 | } |
| 2137 | |
| 2138 | if (hdd_ctx->config->disableDFSChSwitch) { |
Jeff Johnson | 36e74c4 | 2017-09-18 08:15:42 -0700 | [diff] [blame] | 2139 | hdd_info("skip tx block hdd_ctx=%pK, disableDFSChSwitch=%d", |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2140 | hdd_ctx, hdd_ctx->config->disableDFSChSwitch); |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 2141 | return true; |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2142 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2143 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 2144 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2145 | ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 2146 | |
| 2147 | if ((QDF_SAP_MODE == adapter->device_mode || |
| 2148 | QDF_P2P_GO_MODE == adapter->device_mode) && |
| 2149 | (wlan_reg_is_dfs_ch(hdd_ctx->hdd_pdev, |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 2150 | ap_ctx->operating_channel))) { |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2151 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->dfs_cac_block_tx = |
| 2152 | true; |
| 2153 | hdd_info("tx blocked for session: %d", |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 2154 | adapter->session_id); |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 2155 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2156 | } |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 2157 | |
| 2158 | return true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2159 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2160 | |
| 2161 | /** |
| 2162 | * hdd_is_valid_mac_address() - validate MAC address |
| 2163 | * @pMacAddr: Pointer to the input MAC address |
| 2164 | * |
| 2165 | * This function validates whether the given MAC address is valid or not |
| 2166 | * Expected MAC address is of the format XX:XX:XX:XX:XX:XX |
| 2167 | * where X is the hexa decimal digit character and separated by ':' |
| 2168 | * This algorithm works even if MAC address is not separated by ':' |
| 2169 | * |
| 2170 | * This code checks given input string mac contains exactly 12 hexadecimal |
| 2171 | * digits and a separator colon : appears in the input string only after |
| 2172 | * an even number of hex digits. |
| 2173 | * |
| 2174 | * Return: 1 for valid and 0 for invalid |
| 2175 | */ |
| 2176 | bool hdd_is_valid_mac_address(const uint8_t *pMacAddr) |
| 2177 | { |
| 2178 | int xdigit = 0; |
| 2179 | int separator = 0; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 2180 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2181 | while (*pMacAddr) { |
| 2182 | if (isxdigit(*pMacAddr)) { |
| 2183 | xdigit++; |
| 2184 | } else if (':' == *pMacAddr) { |
| 2185 | if (0 == xdigit || ((xdigit / 2) - 1) != separator) |
| 2186 | break; |
| 2187 | |
| 2188 | ++separator; |
| 2189 | } else { |
| 2190 | /* Invalid MAC found */ |
| 2191 | return 0; |
| 2192 | } |
| 2193 | ++pMacAddr; |
| 2194 | } |
| 2195 | return xdigit == 12 && (separator == 5 || separator == 0); |
| 2196 | } |
| 2197 | |
| 2198 | /** |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 2199 | * hdd_mon_mode_ether_setup() - Update monitor mode struct net_device. |
| 2200 | * @dev: Handle to struct net_device to be updated. |
| 2201 | * |
| 2202 | * Return: None |
| 2203 | */ |
| 2204 | static void hdd_mon_mode_ether_setup(struct net_device *dev) |
| 2205 | { |
| 2206 | dev->header_ops = NULL; |
| 2207 | dev->type = ARPHRD_IEEE80211_RADIOTAP; |
| 2208 | dev->hard_header_len = ETH_HLEN; |
| 2209 | dev->mtu = ETH_DATA_LEN; |
| 2210 | dev->addr_len = ETH_ALEN; |
| 2211 | dev->tx_queue_len = 1000; /* Ethernet wants good queues */ |
| 2212 | dev->flags = IFF_BROADCAST|IFF_MULTICAST; |
| 2213 | dev->priv_flags |= IFF_TX_SKB_SHARING; |
| 2214 | |
| 2215 | memset(dev->broadcast, 0xFF, ETH_ALEN); |
| 2216 | } |
| 2217 | |
| 2218 | /** |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2219 | * __hdd__mon_open() - HDD Open function |
| 2220 | * @dev: Pointer to net_device structure |
| 2221 | * |
| 2222 | * This is called in response to ifconfig up |
| 2223 | * |
| 2224 | * Return: 0 for success; non-zero for failure |
| 2225 | */ |
| 2226 | static int __hdd_mon_open(struct net_device *dev) |
| 2227 | { |
| 2228 | int ret; |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2229 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2230 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2231 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 2232 | hdd_enter_dev(dev); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2233 | |
| 2234 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 2235 | if (ret) |
| 2236 | return ret; |
| 2237 | |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 2238 | hdd_mon_mode_ether_setup(dev); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2239 | |
| 2240 | if (con_mode == QDF_GLOBAL_MONITOR_MODE) { |
| 2241 | ret = hdd_wlan_start_modules(hdd_ctx, adapter, false); |
| 2242 | if (ret) { |
| 2243 | hdd_err("Failed to start WLAN modules return"); |
| 2244 | return ret; |
| 2245 | } |
| 2246 | hdd_err("hdd_wlan_start_modules() successful !"); |
| 2247 | |
| 2248 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 2249 | ret = hdd_start_adapter(adapter); |
| 2250 | if (ret) { |
| 2251 | hdd_err("Failed to start adapter :%d", |
| 2252 | adapter->device_mode); |
| 2253 | return ret; |
| 2254 | } |
| 2255 | hdd_err("hdd_start_adapters() successful !"); |
| 2256 | } |
| 2257 | set_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 2258 | } |
| 2259 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2260 | ret = hdd_set_mon_rx_cb(dev); |
Ravi Joshi | 4f09595 | 2017-06-29 15:39:19 -0700 | [diff] [blame] | 2261 | |
| 2262 | if (!ret) |
| 2263 | ret = hdd_enable_monitor_mode(dev); |
| 2264 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2265 | return ret; |
| 2266 | } |
| 2267 | |
| 2268 | /** |
| 2269 | * hdd_mon_open() - Wrapper function for __hdd_mon_open to protect it from SSR |
| 2270 | * @dev: Pointer to net_device structure |
| 2271 | * |
| 2272 | * This is called in response to ifconfig up |
| 2273 | * |
| 2274 | * Return: 0 for success; non-zero for failure |
| 2275 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2276 | static int hdd_mon_open(struct net_device *dev) |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2277 | { |
| 2278 | int ret; |
| 2279 | |
| 2280 | cds_ssr_protect(__func__); |
| 2281 | ret = __hdd_mon_open(dev); |
| 2282 | cds_ssr_unprotect(__func__); |
| 2283 | |
| 2284 | return ret; |
| 2285 | } |
| 2286 | |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2287 | static QDF_STATUS |
| 2288 | wlan_hdd_update_dbs_scan_and_fw_mode_config(void) |
| 2289 | { |
| 2290 | struct policy_mgr_dual_mac_config cfg = {0}; |
| 2291 | QDF_STATUS status; |
| 2292 | uint32_t channel_select_logic_conc; |
| 2293 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 2294 | |
| 2295 | if (!hdd_ctx) { |
| 2296 | hdd_err("HDD context is NULL"); |
| 2297 | return QDF_STATUS_E_FAILURE; |
| 2298 | } |
| 2299 | |
| 2300 | |
| 2301 | if (!policy_mgr_is_hw_dbs_capable(hdd_ctx->hdd_psoc)) |
| 2302 | return QDF_STATUS_SUCCESS; |
| 2303 | |
| 2304 | cfg.scan_config = 0; |
| 2305 | cfg.fw_mode_config = 0; |
| 2306 | cfg.set_dual_mac_cb = policy_mgr_soc_set_dual_mac_cfg_cb; |
| 2307 | |
| 2308 | channel_select_logic_conc = hdd_ctx->config-> |
| 2309 | channel_select_logic_conc; |
| 2310 | |
| 2311 | if (hdd_ctx->config->dual_mac_feature_disable != |
| 2312 | DISABLE_DBS_CXN_AND_SCAN) { |
| 2313 | status = policy_mgr_get_updated_scan_and_fw_mode_config( |
| 2314 | hdd_ctx->hdd_psoc, &cfg.scan_config, |
| 2315 | &cfg.fw_mode_config, |
| 2316 | hdd_ctx->config->dual_mac_feature_disable, |
| 2317 | channel_select_logic_conc); |
| 2318 | |
| 2319 | if (status != QDF_STATUS_SUCCESS) { |
| 2320 | hdd_err("wma_get_updated_scan_and_fw_mode_config failed %d", |
| 2321 | status); |
| 2322 | return status; |
| 2323 | } |
| 2324 | } |
| 2325 | |
| 2326 | hdd_debug("send scan_cfg: 0x%x fw_mode_cfg: 0x%x to fw", |
| 2327 | cfg.scan_config, cfg.fw_mode_config); |
| 2328 | |
| 2329 | status = sme_soc_set_dual_mac_config(cfg); |
| 2330 | if (status != QDF_STATUS_SUCCESS) { |
| 2331 | hdd_err("sme_soc_set_dual_mac_config failed %d", status); |
| 2332 | return status; |
| 2333 | } |
| 2334 | |
| 2335 | return QDF_STATUS_SUCCESS; |
| 2336 | } |
| 2337 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2338 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2339 | * hdd_start_adapter() - Wrapper function for device specific adapter |
| 2340 | * @adapter: pointer to HDD adapter |
| 2341 | * |
| 2342 | * This function is called to start the device specific adapter for |
| 2343 | * the mode passed in the adapter's device_mode. |
| 2344 | * |
| 2345 | * Return: 0 for success; non-zero for failure |
| 2346 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2347 | int hdd_start_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2348 | { |
| 2349 | |
| 2350 | int ret; |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 2351 | enum QDF_OPMODE device_mode = adapter->device_mode; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2352 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 2353 | hdd_enter_dev(adapter->dev); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2354 | hdd_debug("Start_adapter for mode : %d", adapter->device_mode); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2355 | |
| 2356 | switch (device_mode) { |
| 2357 | case QDF_P2P_CLIENT_MODE: |
| 2358 | case QDF_P2P_DEVICE_MODE: |
| 2359 | case QDF_OCB_MODE: |
| 2360 | case QDF_STA_MODE: |
| 2361 | case QDF_MONITOR_MODE: |
| 2362 | ret = hdd_start_station_adapter(adapter); |
| 2363 | if (ret) |
| 2364 | goto err_start_adapter; |
| 2365 | break; |
| 2366 | case QDF_P2P_GO_MODE: |
| 2367 | case QDF_SAP_MODE: |
| 2368 | ret = hdd_start_ap_adapter(adapter); |
| 2369 | if (ret) |
| 2370 | goto err_start_adapter; |
| 2371 | break; |
Arun Khandavalli | b2f6c26 | 2016-08-18 19:07:19 +0530 | [diff] [blame] | 2372 | case QDF_IBSS_MODE: |
| 2373 | /* |
| 2374 | * For IBSS interface is initialized as part of |
| 2375 | * hdd_init_station_mode() |
| 2376 | */ |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2377 | goto exit_with_success; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2378 | case QDF_FTM_MODE: |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2379 | /* vdevs are dynamically managed by firmware in FTM */ |
| 2380 | goto exit_with_success; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2381 | default: |
| 2382 | hdd_err("Invalid session type %d", device_mode); |
| 2383 | QDF_ASSERT(0); |
| 2384 | goto err_start_adapter; |
| 2385 | } |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2386 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2387 | if (hdd_set_fw_params(adapter)) |
| 2388 | hdd_err("Failed to set the FW params for the adapter!"); |
| 2389 | |
| 2390 | /* |
| 2391 | * Action frame registered in one adapter which will |
| 2392 | * applicable to all interfaces |
| 2393 | */ |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 2394 | ret = wlan_hdd_cfg80211_register_frames(adapter); |
| 2395 | if (ret < 0) { |
| 2396 | hdd_err("Failed to register frames - ret %d", ret); |
| 2397 | goto err_start_adapter; |
| 2398 | } |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2399 | wlan_hdd_update_dbs_scan_and_fw_mode_config(); |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 2400 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2401 | exit_with_success: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2402 | hdd_exit(); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2403 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2404 | return 0; |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2405 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2406 | err_start_adapter: |
| 2407 | return -EINVAL; |
| 2408 | } |
| 2409 | |
| 2410 | /** |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 2411 | * hdd_enable_power_management() - API to Enable Power Management |
| 2412 | * |
| 2413 | * API invokes Bus Interface Layer power management functionality |
| 2414 | * |
| 2415 | * Return: None |
| 2416 | */ |
| 2417 | static void hdd_enable_power_management(void) |
| 2418 | { |
| 2419 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2420 | |
| 2421 | if (!hif_ctx) { |
| 2422 | hdd_err("Bus Interface Context is Invalid"); |
| 2423 | return; |
| 2424 | } |
| 2425 | |
| 2426 | hif_enable_power_management(hif_ctx, cds_is_packet_log_enabled()); |
| 2427 | } |
| 2428 | |
| 2429 | /** |
| 2430 | * hdd_disable_power_management() - API to disable Power Management |
| 2431 | * |
| 2432 | * API disable Bus Interface Layer Power management functionality |
| 2433 | * |
| 2434 | * Return: None |
| 2435 | */ |
| 2436 | static void hdd_disable_power_management(void) |
| 2437 | { |
| 2438 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2439 | |
| 2440 | if (!hif_ctx) { |
| 2441 | hdd_err("Bus Interface Context is Invalid"); |
| 2442 | return; |
| 2443 | } |
| 2444 | |
| 2445 | hif_disable_power_management(hif_ctx); |
| 2446 | } |
| 2447 | |
| 2448 | /** |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2449 | * hdd_update_hw_sw_info() - API to update the HW/SW information |
| 2450 | * |
| 2451 | * API to update the HW and SW information in the driver |
| 2452 | * |
| 2453 | * Return: None |
| 2454 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2455 | static void hdd_update_hw_sw_info(struct hdd_context *hdd_ctx) |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2456 | { |
| 2457 | void *hif_sc; |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2458 | size_t target_hw_name_len; |
| 2459 | const char *target_hw_name; |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2460 | |
| 2461 | hif_sc = cds_get_context(QDF_MODULE_ID_HIF); |
| 2462 | if (!hif_sc) { |
| 2463 | hdd_err("HIF context is NULL"); |
| 2464 | return; |
| 2465 | } |
| 2466 | |
| 2467 | /* |
| 2468 | * target hw version/revision would only be retrieved after firmware |
| 2469 | * download |
| 2470 | */ |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2471 | hif_get_hw_info(hif_sc, |
| 2472 | &hdd_ctx->target_hw_version, |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2473 | &hdd_ctx->target_hw_revision, |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2474 | &target_hw_name); |
| 2475 | |
| 2476 | if (hdd_ctx->target_hw_name) |
| 2477 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 2478 | |
| 2479 | target_hw_name_len = strlen(target_hw_name) + 1; |
| 2480 | hdd_ctx->target_hw_name = qdf_mem_malloc(target_hw_name_len); |
| 2481 | if (hdd_ctx->target_hw_name) |
| 2482 | qdf_mem_copy(hdd_ctx->target_hw_name, target_hw_name, |
| 2483 | target_hw_name_len); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2484 | |
| 2485 | /* Get the wlan hw/fw version */ |
| 2486 | hdd_wlan_get_version(hdd_ctx, NULL, NULL); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2487 | } |
| 2488 | |
| 2489 | /** |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2490 | * hdd_update_cds_ac_specs_params() - update cds ac_specs params |
| 2491 | * @hdd_ctx: Pointer to hdd context |
| 2492 | * |
| 2493 | * Return: none |
| 2494 | */ |
| 2495 | static void |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2496 | hdd_update_cds_ac_specs_params(struct hdd_context *hdd_ctx) |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2497 | { |
| 2498 | uint8_t num_entries = 0; |
| 2499 | uint8_t tx_sched_wrr_param[TX_SCHED_WRR_PARAMS_NUM]; |
| 2500 | uint8_t *tx_sched_wrr_ac; |
| 2501 | int i; |
| 2502 | cds_context_type *cds_ctx; |
| 2503 | |
| 2504 | if (NULL == hdd_ctx) |
| 2505 | return; |
| 2506 | |
| 2507 | if (NULL == hdd_ctx->config) { |
| 2508 | /* Do nothing if hdd_ctx is invalid */ |
| 2509 | hdd_err("%s: Warning: hdd_ctx->cfg_ini is NULL", __func__); |
| 2510 | return; |
| 2511 | } |
| 2512 | |
| 2513 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 2514 | |
| 2515 | if (!cds_ctx) { |
| 2516 | hdd_err("Invalid CDS Context"); |
| 2517 | return; |
| 2518 | } |
| 2519 | |
| 2520 | for (i = 0; i < OL_TX_NUM_WMM_AC; i++) { |
| 2521 | switch (i) { |
| 2522 | case OL_TX_WMM_AC_BE: |
| 2523 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_be; |
| 2524 | break; |
| 2525 | case OL_TX_WMM_AC_BK: |
| 2526 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_bk; |
| 2527 | break; |
| 2528 | case OL_TX_WMM_AC_VI: |
| 2529 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_vi; |
| 2530 | break; |
| 2531 | case OL_TX_WMM_AC_VO: |
| 2532 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_vo; |
| 2533 | break; |
| 2534 | default: |
| 2535 | tx_sched_wrr_ac = NULL; |
| 2536 | break; |
| 2537 | } |
| 2538 | |
| 2539 | hdd_string_to_u8_array(tx_sched_wrr_ac, |
| 2540 | tx_sched_wrr_param, |
| 2541 | &num_entries, |
| 2542 | sizeof(tx_sched_wrr_param)); |
| 2543 | |
| 2544 | if (num_entries == TX_SCHED_WRR_PARAMS_NUM) { |
| 2545 | cds_ctx->ac_specs[i].wrr_skip_weight = |
| 2546 | tx_sched_wrr_param[0]; |
| 2547 | cds_ctx->ac_specs[i].credit_threshold = |
| 2548 | tx_sched_wrr_param[1]; |
| 2549 | cds_ctx->ac_specs[i].send_limit = |
| 2550 | tx_sched_wrr_param[2]; |
| 2551 | cds_ctx->ac_specs[i].credit_reserve = |
| 2552 | tx_sched_wrr_param[3]; |
| 2553 | cds_ctx->ac_specs[i].discard_weight = |
| 2554 | tx_sched_wrr_param[4]; |
| 2555 | } |
| 2556 | |
| 2557 | num_entries = 0; |
| 2558 | } |
| 2559 | } |
| 2560 | |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame^] | 2561 | #ifdef IPA_OFFLOAD |
| 2562 | /** |
| 2563 | * hdd_update_ipa_component_config() - update ipa config |
| 2564 | * @hdd_ctx: Pointer to hdd context |
| 2565 | * |
| 2566 | * Return: none |
| 2567 | */ |
| 2568 | static void hdd_update_ipa_component_config(struct hdd_context *hdd_ctx) |
| 2569 | { |
| 2570 | struct hdd_config *cfg = hdd_ctx->config; |
| 2571 | struct wlan_ipa_config ipa_cfg; |
| 2572 | |
| 2573 | ipa_cfg.ipa_config = cfg->IpaConfig; |
| 2574 | ipa_cfg.desc_size = cfg->IpaDescSize; |
| 2575 | ipa_cfg.txbuf_count = cfg->IpaUcTxBufCount; |
| 2576 | ipa_cfg.bus_bw_high = cfg->busBandwidthHighThreshold; |
| 2577 | ipa_cfg.bus_bw_medium = cfg->busBandwidthMediumThreshold; |
| 2578 | ipa_cfg.bus_bw_low = cfg->busBandwidthLowThreshold; |
| 2579 | ipa_cfg.ipa_bw_high = cfg->IpaHighBandwidthMbps; |
| 2580 | ipa_cfg.ipa_bw_medium = cfg->IpaMediumBandwidthMbps; |
| 2581 | ipa_cfg.ipa_bw_low = cfg->IpaLowBandwidthMbps; |
| 2582 | |
| 2583 | ucfg_ipa_update_config(&ipa_cfg); |
| 2584 | } |
| 2585 | #else |
| 2586 | static void hdd_update_ipa_component_config(struct hdd_context *hdd_ctx) |
| 2587 | { |
| 2588 | } |
| 2589 | #endif |
| 2590 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2591 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2592 | static enum policy_mgr_con_mode wlan_hdd_get_mode_for_non_connected_vdev( |
| 2593 | struct wlan_objmgr_psoc *psoc, uint8_t vdev_id) |
| 2594 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2595 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2596 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2597 | |
| 2598 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 2599 | if (!adapter) { |
| 2600 | hdd_err("Adapter is NULL"); |
| 2601 | return PM_MAX_NUM_OF_MODE; |
| 2602 | } |
| 2603 | |
| 2604 | return policy_mgr_convert_device_mode_to_qdf_type( |
| 2605 | adapter->device_mode); |
| 2606 | } |
| 2607 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2608 | static void hdd_register_policy_manager_callback( |
| 2609 | struct wlan_objmgr_psoc *psoc) |
| 2610 | { |
| 2611 | struct policy_mgr_hdd_cbacks hdd_cbacks; |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 2612 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2613 | hdd_cbacks.sap_restart_chan_switch_cb = |
Jeff Johnson | 2381294 | 2017-10-06 11:33:55 -0700 | [diff] [blame] | 2614 | hdd_sap_restart_chan_switch_cb; |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2615 | hdd_cbacks.wlan_hdd_get_channel_for_sap_restart = |
| 2616 | wlan_hdd_get_channel_for_sap_restart; |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2617 | hdd_cbacks.get_mode_for_non_connected_vdev = |
| 2618 | wlan_hdd_get_mode_for_non_connected_vdev; |
Yeshwanth Sriram Guntuka | 469f957 | 2018-02-12 13:28:22 +0530 | [diff] [blame] | 2619 | hdd_cbacks.hdd_get_device_mode = hdd_get_device_mode; |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2620 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2621 | if (QDF_STATUS_SUCCESS != |
| 2622 | policy_mgr_register_hdd_cb(psoc, &hdd_cbacks)) { |
| 2623 | hdd_err("HDD callback registration with policy manager failed"); |
| 2624 | } |
| 2625 | } |
| 2626 | #else |
| 2627 | static void hdd_register_policy_manager_callback( |
| 2628 | struct wlan_objmgr_psoc *psoc) |
| 2629 | { |
| 2630 | } |
| 2631 | #endif |
| 2632 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2633 | static void hdd_nan_register_callbacks(struct hdd_context *hdd_ctx) |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2634 | { |
| 2635 | struct nan_callbacks cb_obj = {0}; |
| 2636 | |
| 2637 | cb_obj.ndi_open = hdd_ndi_open; |
| 2638 | cb_obj.ndi_close = hdd_ndi_close; |
| 2639 | cb_obj.ndi_start = hdd_ndi_start; |
| 2640 | cb_obj.ndi_delete = hdd_ndi_delete; |
| 2641 | cb_obj.drv_ndi_create_rsp_handler = hdd_ndi_drv_ndi_create_rsp_handler; |
| 2642 | cb_obj.drv_ndi_delete_rsp_handler = hdd_ndi_drv_ndi_delete_rsp_handler; |
| 2643 | |
Naveen Rawat | 37f62c8 | 2017-03-26 22:24:43 -0700 | [diff] [blame] | 2644 | cb_obj.new_peer_ind = hdd_ndp_new_peer_handler; |
| 2645 | cb_obj.get_peer_idx = hdd_ndp_get_peer_idx; |
Naveen Rawat | b3143ea | 2017-03-26 22:25:46 -0700 | [diff] [blame] | 2646 | cb_obj.peer_departed_ind = hdd_ndp_peer_departed_handler; |
Naveen Rawat | 37f62c8 | 2017-03-26 22:24:43 -0700 | [diff] [blame] | 2647 | |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2648 | os_if_nan_register_hdd_callbacks(hdd_ctx->hdd_psoc, &cb_obj); |
| 2649 | } |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2650 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2651 | #ifdef CONFIG_LEAK_DETECTION |
Dustin Brown | 4c5b990 | 2017-12-19 11:17:19 -0800 | [diff] [blame] | 2652 | /** |
| 2653 | * hdd_check_for_leaks() - Perform runtime memory leak checks |
| 2654 | * |
| 2655 | * This API triggers runtime memory leak detection. This feature enforces the |
| 2656 | * policy that any memory allocated at runtime must also be released at runtime. |
| 2657 | * |
| 2658 | * Allocating memory at runtime and releasing it at unload is effectively a |
| 2659 | * memory leak for configurations which never unload (e.g. LONU, statically |
| 2660 | * compiled driver). Such memory leaks are NOT false positives, and must be |
| 2661 | * fixed. |
| 2662 | * |
| 2663 | * Return: None |
| 2664 | */ |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2665 | static void hdd_check_for_leaks(void) |
| 2666 | { |
Dustin Brown | 4c5b990 | 2017-12-19 11:17:19 -0800 | [diff] [blame] | 2667 | /* DO NOT REMOVE these checks; for false positives, read above first */ |
| 2668 | |
Dustin Brown | 677e086 | 2017-10-10 16:30:09 -0700 | [diff] [blame] | 2669 | qdf_mc_timer_check_for_leaks(); |
Dustin Brown | 8e71150 | 2017-12-07 16:49:11 -0800 | [diff] [blame] | 2670 | qdf_nbuf_map_check_for_leaks(); |
Dustin Brown | e6b9d5a | 2017-12-14 15:18:49 -0800 | [diff] [blame] | 2671 | qdf_mem_check_for_leaks(); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2672 | } |
| 2673 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2674 | #define hdd_debug_domain_set(domain) qdf_debug_domain_set(domain) |
| 2675 | #else |
| 2676 | static inline void hdd_check_for_leaks(void) {} |
| 2677 | |
| 2678 | #define hdd_debug_domain_set(domain) |
| 2679 | #endif /* CONFIG_LEAK_DETECTION */ |
| 2680 | |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2681 | /** |
Paul Zhang | e03cf4c | 2018-01-19 18:33:22 +0800 | [diff] [blame] | 2682 | * hdd_update_country_code - Update country code |
| 2683 | * @hdd_ctx: HDD context |
| 2684 | * |
| 2685 | * Update country code based on module parameter country_code |
| 2686 | * |
| 2687 | * Return: 0 on success and errno on failure |
| 2688 | */ |
| 2689 | static int hdd_update_country_code(struct hdd_context *hdd_ctx) |
| 2690 | { |
| 2691 | if (!country_code) |
| 2692 | return 0; |
| 2693 | |
| 2694 | return hdd_reg_set_country(hdd_ctx, country_code); |
| 2695 | } |
| 2696 | |
| 2697 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2698 | * hdd_wlan_start_modules() - Single driver state machine for starting modules |
| 2699 | * @hdd_ctx: HDD context |
| 2700 | * @adapter: HDD adapter |
| 2701 | * @reinit: flag to indicate from SSR or normal path |
| 2702 | * |
| 2703 | * This function maintains the driver state machine it will be invoked from |
| 2704 | * startup, reinit and change interface. Depending on the driver state shall |
| 2705 | * perform the opening of the modules. |
| 2706 | * |
| 2707 | * Return: 0 for success; non-zero for failure |
| 2708 | */ |
Jeff Johnson | 60dc2b1 | 2017-09-28 14:56:02 -0700 | [diff] [blame] | 2709 | int hdd_wlan_start_modules(struct hdd_context *hdd_ctx, |
| 2710 | struct hdd_adapter *adapter, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2711 | bool reinit) |
| 2712 | { |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 2713 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2714 | qdf_device_t qdf_dev; |
| 2715 | QDF_STATUS status; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2716 | bool unint = false; |
| 2717 | void *hif_ctx; |
| 2718 | |
Jeff Johnson | 60dc2b1 | 2017-09-28 14:56:02 -0700 | [diff] [blame] | 2719 | hdd_debug("state:%d reinit:%d", hdd_ctx->driver_status, reinit); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2720 | |
| 2721 | qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 2722 | if (!qdf_dev) { |
| 2723 | hdd_err("QDF Device Context is Invalid return"); |
| 2724 | return -EINVAL; |
| 2725 | } |
| 2726 | |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 2727 | hdd_set_idle_ps_config(hdd_ctx, false); |
| 2728 | qdf_cancel_delayed_work(&hdd_ctx->iface_idle_work); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2729 | |
Dustin Brown | 1fe30a8 | 2017-10-03 16:13:36 -0700 | [diff] [blame] | 2730 | mutex_lock(&hdd_ctx->iface_change_lock); |
Arun Khandavalli | 5a62a82 | 2017-11-14 19:43:00 +0530 | [diff] [blame] | 2731 | if (hdd_ctx->driver_status == DRIVER_MODULES_ENABLED) { |
| 2732 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 2733 | hdd_info("Driver modules already Enabled"); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2734 | hdd_exit(); |
Arun Khandavalli | 5a62a82 | 2017-11-14 19:43:00 +0530 | [diff] [blame] | 2735 | return 0; |
| 2736 | } |
| 2737 | |
Dustin Brown | 1fe30a8 | 2017-10-03 16:13:36 -0700 | [diff] [blame] | 2738 | hdd_ctx->start_modules_in_progress = true; |
| 2739 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2740 | switch (hdd_ctx->driver_status) { |
| 2741 | case DRIVER_MODULES_UNINITIALIZED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2742 | hdd_info("Wlan transitioning (UNINITIALIZED -> CLOSED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2743 | unint = true; |
| 2744 | /* Fall through dont add break here */ |
| 2745 | case DRIVER_MODULES_CLOSED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2746 | hdd_info("Wlan transitioning (CLOSED -> OPENED)"); |
| 2747 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2748 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_ACTIVE); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2749 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2750 | if (!reinit && !unint) { |
| 2751 | ret = pld_power_on(qdf_dev->dev); |
| 2752 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2753 | hdd_err("Failed to Powerup the device; errno: %d", |
| 2754 | ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2755 | goto release_lock; |
| 2756 | } |
| 2757 | } |
Yuanyuan Liu | f8fe4bc | 2017-06-07 16:55:58 -0700 | [diff] [blame] | 2758 | |
| 2759 | pld_set_fw_log_mode(hdd_ctx->parent_dev, |
| 2760 | hdd_ctx->config->enable_fw_log); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2761 | ret = hdd_hif_open(qdf_dev->dev, qdf_dev->drv_hdl, qdf_dev->bid, |
| 2762 | qdf_dev->bus_type, |
| 2763 | (reinit == true) ? HIF_ENABLE_TYPE_REINIT : |
| 2764 | HIF_ENABLE_TYPE_PROBE); |
| 2765 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2766 | hdd_err("Failed to open hif; errno: %d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2767 | goto power_down; |
| 2768 | } |
| 2769 | |
| 2770 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
Arun Khandavalli | 1318b99 | 2016-08-09 11:04:57 +0530 | [diff] [blame] | 2771 | if (!hif_ctx) { |
| 2772 | hdd_err("hif context is null!!"); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2773 | ret = -EINVAL; |
Arun Khandavalli | 1318b99 | 2016-08-09 11:04:57 +0530 | [diff] [blame] | 2774 | goto power_down; |
| 2775 | } |
| 2776 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2777 | status = ol_cds_init(qdf_dev, hif_ctx); |
| 2778 | if (status != QDF_STATUS_SUCCESS) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2779 | hdd_err("No Memory to Create BMI Context; status: %d", |
| 2780 | status); |
| 2781 | ret = qdf_status_to_os_return(status); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2782 | goto hif_close; |
| 2783 | } |
| 2784 | |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame^] | 2785 | hdd_update_ipa_component_config(hdd_ctx); |
| 2786 | |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 2787 | ret = hdd_update_config(hdd_ctx); |
| 2788 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2789 | hdd_err("Failed to update configuration; errno: %d", |
| 2790 | ret); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2791 | goto cds_free; |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 2792 | } |
| 2793 | |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2794 | hdd_update_cds_ac_specs_params(hdd_ctx); |
| 2795 | |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 2796 | status = cds_open(hdd_ctx->hdd_psoc); |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2797 | if (QDF_IS_STATUS_ERROR(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2798 | hdd_err("Failed to Open CDS; status: %d", status); |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2799 | ret = qdf_status_to_os_return(status); |
| 2800 | goto deinit_config; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2801 | } |
| 2802 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2803 | /* initalize components configurations after psoc open */ |
| 2804 | ret = hdd_update_components_config(hdd_ctx); |
| 2805 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2806 | hdd_err("Failed to update component configs; errno: %d", |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2807 | ret); |
| 2808 | goto close; |
| 2809 | } |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2810 | status = cds_dp_open(hdd_ctx->hdd_psoc); |
| 2811 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2812 | hdd_err("Failed to Open cds post open; status: %d", |
| 2813 | status); |
| 2814 | ret = qdf_status_to_os_return(status); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2815 | goto close; |
| 2816 | } |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2817 | |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2818 | /* |
| 2819 | * NAN compoenet requires certian operations like, open adapter, |
| 2820 | * close adapter, etc. to be initiated by HDD, for those |
| 2821 | * register HDD callbacks with UMAC's NAN componenet. |
| 2822 | */ |
| 2823 | hdd_nan_register_callbacks(hdd_ctx); |
| 2824 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2825 | hdd_ctx->hHal = cds_get_context(QDF_MODULE_ID_SME); |
| 2826 | |
Jeff Johnson | 3a28012 | 2017-09-13 07:42:00 -0700 | [diff] [blame] | 2827 | status = cds_pre_enable(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2828 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2829 | hdd_err("Failed to pre-enable CDS; status: %d", status); |
| 2830 | ret = qdf_status_to_os_return(status); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2831 | goto cds_txrx_free; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2832 | } |
| 2833 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2834 | hdd_register_policy_manager_callback( |
| 2835 | hdd_ctx->hdd_psoc); |
| 2836 | |
Amar Singhal | 0928b19 | 2017-12-01 10:50:54 -0800 | [diff] [blame] | 2837 | hdd_sysfs_create_version_interface(hdd_ctx->hdd_psoc); |
| 2838 | |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2839 | hdd_update_hw_sw_info(hdd_ctx); |
Himanshu Agarwal | 0b9bbc3 | 2017-02-23 16:23:05 +0530 | [diff] [blame] | 2840 | hdd_ctx->driver_status = DRIVER_MODULES_OPENED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2841 | hdd_info("Wlan transitioned (now OPENED)"); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2842 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2843 | if (unint) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2844 | hdd_debug("In phase-1 initialization don't enable modules"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2845 | break; |
| 2846 | } |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 2847 | |
| 2848 | if (reinit) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2849 | ret = hdd_ipa_uc_ssr_reinit(hdd_ctx); |
| 2850 | if (ret) { |
| 2851 | hdd_err("HDD IPA UC reinit failed; errno: %d", |
| 2852 | ret); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2853 | goto post_disable; |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 2854 | } |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 2855 | } |
| 2856 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2857 | /* Fall through dont add break here */ |
| 2858 | case DRIVER_MODULES_OPENED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2859 | hdd_info("Wlan transitioning (OPENED -> ENABLED)"); |
| 2860 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2861 | if (!adapter) { |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2862 | hdd_alert("adapter is Null"); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2863 | ret = -EINVAL; |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2864 | goto post_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2865 | } |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 2866 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 2867 | hdd_err("in ftm mode, no need to configure cds modules"); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2868 | ret = -EINVAL; |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 2869 | break; |
| 2870 | } |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2871 | |
| 2872 | ret = hdd_configure_cds(hdd_ctx, adapter); |
| 2873 | if (ret) { |
| 2874 | hdd_err("Failed to Enable cds modules; errno: %d", ret); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2875 | goto post_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2876 | } |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2877 | |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 2878 | hdd_enable_power_management(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2879 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2880 | hdd_ctx->driver_status = DRIVER_MODULES_ENABLED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2881 | hdd_info("Wlan transitioned (now ENABLED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2882 | break; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2883 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2884 | default: |
| 2885 | hdd_err("WLAN start invoked in wrong state! :%d\n", |
| 2886 | hdd_ctx->driver_status); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2887 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2888 | goto release_lock; |
| 2889 | } |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2890 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 2891 | hdd_ctx->start_modules_in_progress = false; |
Paul Zhang | e03cf4c | 2018-01-19 18:33:22 +0800 | [diff] [blame] | 2892 | if (DRIVER_MODULES_ENABLED == hdd_ctx->driver_status) { |
| 2893 | ret = hdd_update_country_code(hdd_ctx); |
| 2894 | if (ret) |
| 2895 | hdd_err("Failed to update command line country code!"); |
| 2896 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2897 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2898 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2899 | hdd_exit(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2900 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2901 | return 0; |
| 2902 | |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2903 | post_disable: |
Rajeev Kumar | be02124 | 2017-02-16 16:12:23 -0800 | [diff] [blame] | 2904 | cds_post_disable(); |
Amar Singhal | 410675c | 2018-01-10 12:14:21 -0800 | [diff] [blame] | 2905 | dispatcher_pdev_close(hdd_ctx->hdd_pdev); |
Dustin Brown | bd68fe1 | 2017-11-21 15:28:52 -0800 | [diff] [blame] | 2906 | hdd_objmgr_release_and_destroy_pdev(hdd_ctx); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2907 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2908 | cds_txrx_free: |
| 2909 | cds_dp_close(hdd_ctx->hdd_psoc); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2910 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2911 | close: |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2912 | hdd_ctx->driver_status = DRIVER_MODULES_CLOSED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2913 | hdd_info("Wlan transition aborted (now CLOSED)"); |
| 2914 | |
Jeff Johnson | e4b1459 | 2017-09-13 14:23:33 -0700 | [diff] [blame] | 2915 | cds_close(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2916 | |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2917 | deinit_config: |
| 2918 | cds_deinit_ini_config(); |
| 2919 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2920 | cds_free: |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2921 | ol_cds_free(); |
| 2922 | |
| 2923 | hif_close: |
Jeff Johnson | 60dc2b1 | 2017-09-28 14:56:02 -0700 | [diff] [blame] | 2924 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2925 | hdd_hif_close(hdd_ctx, hif_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2926 | power_down: |
| 2927 | if (!reinit && !unint) |
| 2928 | pld_power_off(qdf_dev->dev); |
| 2929 | release_lock: |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 2930 | hdd_ctx->start_modules_in_progress = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2931 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2932 | |
| 2933 | /* many adapter resources are not freed by design in SSR case */ |
| 2934 | if (!reinit) |
| 2935 | hdd_check_for_leaks(); |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2936 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_INIT); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2937 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2938 | hdd_exit(); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2939 | |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 2940 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2941 | } |
| 2942 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2943 | #ifdef WIFI_POS_CONVERGED |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2944 | static int hdd_activate_wifi_pos(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2945 | { |
| 2946 | int ret = os_if_wifi_pos_register_nl(); |
| 2947 | |
| 2948 | if (ret) |
| 2949 | hdd_err("os_if_wifi_pos_register_nl failed"); |
| 2950 | |
| 2951 | return ret; |
| 2952 | } |
| 2953 | |
| 2954 | static int hdd_deactivate_wifi_pos(void) |
| 2955 | { |
| 2956 | int ret = os_if_wifi_pos_deregister_nl(); |
| 2957 | |
| 2958 | if (ret) |
| 2959 | hdd_err("os_if_wifi_pos_deregister_nl failed"); |
| 2960 | |
| 2961 | return ret; |
| 2962 | } |
| 2963 | |
| 2964 | /** |
| 2965 | * hdd_populate_wifi_pos_cfg - populates wifi_pos parameters |
| 2966 | * @hdd_ctx: hdd context |
| 2967 | * |
| 2968 | * Return: status of operation |
| 2969 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2970 | static void hdd_populate_wifi_pos_cfg(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2971 | { |
| 2972 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 2973 | struct hdd_config *cfg = hdd_ctx->config; |
| 2974 | |
| 2975 | wifi_pos_set_oem_target_type(psoc, hdd_ctx->target_type); |
| 2976 | wifi_pos_set_oem_fw_version(psoc, hdd_ctx->target_fw_version); |
| 2977 | wifi_pos_set_drv_ver_major(psoc, QWLAN_VERSION_MAJOR); |
| 2978 | wifi_pos_set_drv_ver_minor(psoc, QWLAN_VERSION_MINOR); |
| 2979 | wifi_pos_set_drv_ver_patch(psoc, QWLAN_VERSION_PATCH); |
| 2980 | wifi_pos_set_drv_ver_build(psoc, QWLAN_VERSION_BUILD); |
| 2981 | wifi_pos_set_dwell_time_min(psoc, cfg->nNeighborScanMinChanTime); |
| 2982 | wifi_pos_set_dwell_time_max(psoc, cfg->nNeighborScanMaxChanTime); |
| 2983 | } |
| 2984 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2985 | static int hdd_activate_wifi_pos(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2986 | { |
| 2987 | return oem_activate_service(hdd_ctx); |
| 2988 | } |
| 2989 | |
| 2990 | static int hdd_deactivate_wifi_pos(void) |
| 2991 | { |
| 2992 | return 0; |
| 2993 | } |
| 2994 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2995 | static void hdd_populate_wifi_pos_cfg(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2996 | { |
| 2997 | } |
| 2998 | #endif |
| 2999 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3000 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3001 | * __hdd_open() - HDD Open function |
| 3002 | * @dev: Pointer to net_device structure |
| 3003 | * |
| 3004 | * This is called in response to ifconfig up |
| 3005 | * |
| 3006 | * Return: 0 for success; non-zero for failure |
| 3007 | */ |
| 3008 | static int __hdd_open(struct net_device *dev) |
| 3009 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3010 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3011 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3012 | int ret; |
| 3013 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3014 | hdd_enter_dev(dev); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 3015 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_OPEN_REQUEST, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3016 | adapter->session_id, adapter->device_mode)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3017 | |
Ashish Kumar Dhanotiya | 15a7db5 | 2017-08-03 10:27:34 +0530 | [diff] [blame] | 3018 | /* Nothing to be done if device is unloading */ |
| 3019 | if (cds_is_driver_unloading()) { |
| 3020 | hdd_err("Driver is unloading can not open the hdd"); |
| 3021 | return -EBUSY; |
| 3022 | } |
| 3023 | |
Dustin Brown | 0184775 | 2017-10-25 13:56:27 -0700 | [diff] [blame] | 3024 | if (cds_is_driver_recovering()) { |
| 3025 | hdd_err("WLAN is currently recovering; Please try again."); |
| 3026 | return -EBUSY; |
| 3027 | } |
| 3028 | |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 3029 | if (qdf_atomic_read(&hdd_ctx->con_mode_flag)) { |
| 3030 | hdd_err("con_mode_handler is in progress; Please try again."); |
| 3031 | return -EBUSY; |
| 3032 | } |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3033 | |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 3034 | mutex_lock(&hdd_init_deinit_lock); |
Hanumanth Reddy Pothula | 006f383 | 2017-10-12 15:52:43 +0530 | [diff] [blame] | 3035 | hdd_start_driver_ops_timer(eHDD_DRV_OP_IFF_UP); |
| 3036 | |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3037 | /* |
| 3038 | * This scenario can be hit in cases where in the wlan driver after |
| 3039 | * registering the netdevices and there is a failure in driver |
| 3040 | * initialization. So return error gracefully because the netdevices |
| 3041 | * will be de-registered as part of the load failure. |
| 3042 | */ |
| 3043 | |
| 3044 | if (!cds_is_driver_loaded()) { |
| 3045 | hdd_err("Failed to start the wlan driver!!"); |
| 3046 | ret = -EIO; |
| 3047 | goto err_hdd_hdd_init_deinit_lock; |
| 3048 | } |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 3049 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3050 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3051 | ret = hdd_wlan_start_modules(hdd_ctx, adapter, false); |
| 3052 | if (ret) { |
| 3053 | hdd_err("Failed to start WLAN modules return"); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3054 | goto err_hdd_hdd_init_deinit_lock; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3055 | } |
| 3056 | |
| 3057 | |
| 3058 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 3059 | ret = hdd_start_adapter(adapter); |
| 3060 | if (ret) { |
| 3061 | hdd_err("Failed to start adapter :%d", |
| 3062 | adapter->device_mode); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3063 | goto err_hdd_hdd_init_deinit_lock; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3064 | } |
| 3065 | } |
| 3066 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3067 | set_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 3068 | 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] | 3069 | hdd_debug("Enabling Tx Queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3070 | /* Enable TX queues only when we are connected */ |
| 3071 | wlan_hdd_netif_queue_control(adapter, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3072 | WLAN_START_ALL_NETIF_QUEUE, |
| 3073 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3074 | } |
| 3075 | |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 3076 | /* Enable carrier and transmit queues for NDI */ |
| 3077 | if (WLAN_HDD_IS_NDI(adapter)) { |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 3078 | hdd_debug("Enabling Tx Queues"); |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 3079 | wlan_hdd_netif_queue_control(adapter, |
| 3080 | WLAN_START_ALL_NETIF_QUEUE_N_CARRIER, |
| 3081 | WLAN_CONTROL_PATH); |
| 3082 | } |
| 3083 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3084 | hdd_populate_wifi_pos_cfg(hdd_ctx); |
| 3085 | |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3086 | err_hdd_hdd_init_deinit_lock: |
Hanumanth Reddy Pothula | 006f383 | 2017-10-12 15:52:43 +0530 | [diff] [blame] | 3087 | hdd_stop_driver_ops_timer(); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3088 | mutex_unlock(&hdd_init_deinit_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3089 | return ret; |
| 3090 | } |
| 3091 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3092 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3093 | /** |
| 3094 | * hdd_open() - Wrapper function for __hdd_open to protect it from SSR |
| 3095 | * @dev: Pointer to net_device structure |
| 3096 | * |
| 3097 | * This is called in response to ifconfig up |
| 3098 | * |
| 3099 | * Return: 0 for success; non-zero for failure |
| 3100 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3101 | static int hdd_open(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3102 | { |
| 3103 | int ret; |
| 3104 | |
| 3105 | cds_ssr_protect(__func__); |
| 3106 | ret = __hdd_open(dev); |
| 3107 | cds_ssr_unprotect(__func__); |
| 3108 | |
| 3109 | return ret; |
| 3110 | } |
| 3111 | |
| 3112 | /** |
| 3113 | * __hdd_stop() - HDD stop function |
| 3114 | * @dev: Pointer to net_device structure |
| 3115 | * |
| 3116 | * This is called in response to ifconfig down |
| 3117 | * |
| 3118 | * Return: 0 for success; non-zero for failure |
| 3119 | */ |
| 3120 | static int __hdd_stop(struct net_device *dev) |
| 3121 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3122 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3123 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3124 | int ret; |
| 3125 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3126 | hdd_enter_dev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3127 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 3128 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_STOP_REQUEST, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3129 | adapter->session_id, adapter->device_mode)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3130 | |
| 3131 | ret = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 3132 | if (0 != ret) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3133 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3134 | |
| 3135 | /* Nothing to be done if the interface is not opened */ |
| 3136 | if (false == test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 3137 | hdd_err("NETDEV Interface is not OPENED"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3138 | return -ENODEV; |
| 3139 | } |
| 3140 | |
| 3141 | /* Make sure the interface is marked as closed */ |
| 3142 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 3143 | |
| 3144 | hdd_debug("Disabling Auto Power save timer"); |
| 3145 | sme_ps_disable_auto_ps_timer( |
| 3146 | WLAN_HDD_GET_HAL_CTX(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3147 | adapter->session_id); |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 3148 | |
| 3149 | /* |
| 3150 | * Disable TX on the interface, after this hard_start_xmit() will not |
| 3151 | * be called on that interface |
| 3152 | */ |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 3153 | hdd_info("Disabling queues, adapter device mode: %s(%d)", |
Kabilan Kannan | 8dac350 | 2017-10-30 12:40:27 -0700 | [diff] [blame] | 3154 | hdd_device_mode_to_string(adapter->device_mode), |
| 3155 | adapter->device_mode); |
| 3156 | |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 3157 | wlan_hdd_netif_queue_control(adapter, |
| 3158 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 3159 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3160 | |
| 3161 | /* |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 3162 | * NAN data interface is different in some sense. The traffic on NDI is |
| 3163 | * bursty in nature and depends on the need to transfer. The service |
| 3164 | * layer may down the interface after the usage and up again when |
| 3165 | * required. In some sense, the NDI is expected to be available |
| 3166 | * (like SAP) iface until NDI delete request is issued by the service |
| 3167 | * layer. Skip BSS termination and adapter deletion for NAN Data |
| 3168 | * interface (NDI). |
| 3169 | */ |
| 3170 | if (WLAN_HDD_IS_NDI(adapter)) |
| 3171 | return 0; |
| 3172 | |
| 3173 | /* |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3174 | * The interface is marked as down for outside world (aka kernel) |
| 3175 | * But the driver is pretty much alive inside. The driver needs to |
| 3176 | * tear down the existing connection on the netdev (session) |
| 3177 | * cleanup the data pipes and wait until the control plane is stabilized |
| 3178 | * for this interface. The call also needs to wait until the above |
| 3179 | * mentioned actions are completed before returning to the caller. |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3180 | * Notice that hdd_stop_adapter is requested not to close the session |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3181 | * That is intentional to be able to scan if it is a STA/P2P interface |
| 3182 | */ |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 3183 | hdd_stop_adapter(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3184 | |
| 3185 | /* DeInit the adapter. This ensures datapath cleanup as well */ |
| 3186 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
| 3187 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3188 | |
| 3189 | /* |
Hanumanth Reddy Pothula | 3862ca9 | 2018-01-12 16:44:10 +0530 | [diff] [blame] | 3190 | * Upon wifi turn off, DUT has to flush the scan results so if |
| 3191 | * this is the last cli iface, flush the scan database. |
| 3192 | */ |
| 3193 | if (!hdd_is_cli_iface_up(hdd_ctx)) |
| 3194 | sme_scan_flush_result(hdd_ctx->hHal); |
| 3195 | |
| 3196 | /* |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3197 | * Find if any iface is up. If any iface is up then can't put device to |
| 3198 | * sleep/power save mode |
| 3199 | */ |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 3200 | if (hdd_check_for_opened_interfaces(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3201 | hdd_debug("Closing all modules from the hdd_stop"); |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 3202 | qdf_sched_delayed_work(&hdd_ctx->iface_idle_work, |
| 3203 | hdd_ctx->config->iface_change_wait_time); |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 3204 | hdd_prevent_suspend_timeout( |
| 3205 | hdd_ctx->config->iface_change_wait_time, |
| 3206 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3207 | } |
| 3208 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3209 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3210 | return 0; |
| 3211 | } |
| 3212 | |
| 3213 | /** |
| 3214 | * hdd_stop() - Wrapper function for __hdd_stop to protect it from SSR |
| 3215 | * @dev: pointer to net_device structure |
| 3216 | * |
| 3217 | * This is called in response to ifconfig down |
| 3218 | * |
| 3219 | * Return: 0 for success and error number for failure |
| 3220 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3221 | static int hdd_stop(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3222 | { |
| 3223 | int ret; |
| 3224 | |
| 3225 | cds_ssr_protect(__func__); |
| 3226 | ret = __hdd_stop(dev); |
| 3227 | cds_ssr_unprotect(__func__); |
| 3228 | |
| 3229 | return ret; |
| 3230 | } |
| 3231 | |
| 3232 | /** |
| 3233 | * __hdd_uninit() - HDD uninit function |
| 3234 | * @dev: Pointer to net_device structure |
| 3235 | * |
| 3236 | * This is called during the netdev unregister to uninitialize all data |
| 3237 | * associated with the device |
| 3238 | * |
| 3239 | * Return: None |
| 3240 | */ |
| 3241 | static void __hdd_uninit(struct net_device *dev) |
| 3242 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3243 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 3244 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3245 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3246 | hdd_enter_dev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3247 | |
| 3248 | do { |
| 3249 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3250 | hdd_err("Invalid magic"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3251 | break; |
| 3252 | } |
| 3253 | |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 3254 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3255 | if (!hdd_ctx) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3256 | hdd_err("NULL hdd_ctx"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3257 | break; |
| 3258 | } |
| 3259 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3260 | if (dev != adapter->dev) |
| 3261 | hdd_err("Invalid device reference"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3262 | |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 3263 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3264 | |
| 3265 | /* after uninit our adapter structure will no longer be valid */ |
| 3266 | adapter->dev = NULL; |
| 3267 | adapter->magic = 0; |
| 3268 | } while (0); |
| 3269 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3270 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3271 | } |
| 3272 | |
| 3273 | /** |
| 3274 | * hdd_uninit() - Wrapper function to protect __hdd_uninit from SSR |
| 3275 | * @dev: pointer to net_device structure |
| 3276 | * |
| 3277 | * This is called during the netdev unregister to uninitialize all data |
| 3278 | * associated with the device |
| 3279 | * |
| 3280 | * Return: none |
| 3281 | */ |
| 3282 | static void hdd_uninit(struct net_device *dev) |
| 3283 | { |
| 3284 | cds_ssr_protect(__func__); |
| 3285 | __hdd_uninit(dev); |
| 3286 | cds_ssr_unprotect(__func__); |
| 3287 | } |
| 3288 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3289 | static int hdd_open_cesium_nl_sock(void) |
| 3290 | { |
| 3291 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 3292 | struct netlink_kernel_cfg cfg = { |
| 3293 | .groups = WLAN_NLINK_MCAST_GRP_ID, |
| 3294 | .input = NULL |
| 3295 | }; |
| 3296 | #endif |
| 3297 | int ret = 0; |
| 3298 | |
| 3299 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 3300 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 3301 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 7, 0)) |
| 3302 | THIS_MODULE, |
| 3303 | #endif |
| 3304 | &cfg); |
| 3305 | #else |
| 3306 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 3307 | WLAN_NLINK_MCAST_GRP_ID, |
| 3308 | NULL, NULL, THIS_MODULE); |
| 3309 | #endif |
| 3310 | |
| 3311 | if (cesium_nl_srv_sock == NULL) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 3312 | hdd_err("NLINK: cesium netlink_kernel_create failed"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3313 | ret = -ECONNREFUSED; |
| 3314 | } |
| 3315 | |
| 3316 | return ret; |
| 3317 | } |
| 3318 | |
| 3319 | static void hdd_close_cesium_nl_sock(void) |
| 3320 | { |
| 3321 | if (NULL != cesium_nl_srv_sock) { |
| 3322 | netlink_kernel_release(cesium_nl_srv_sock); |
| 3323 | cesium_nl_srv_sock = NULL; |
| 3324 | } |
| 3325 | } |
| 3326 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3327 | /** |
| 3328 | * __hdd_set_mac_address() - set the user specified mac address |
| 3329 | * @dev: Pointer to the net device. |
| 3330 | * @addr: Pointer to the sockaddr. |
| 3331 | * |
| 3332 | * This function sets the user specified mac address using |
| 3333 | * the command ifconfig wlanX hw ether <mac adress>. |
| 3334 | * |
| 3335 | * Return: 0 for success, non zero for failure |
| 3336 | */ |
| 3337 | static int __hdd_set_mac_address(struct net_device *dev, void *addr) |
| 3338 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3339 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3340 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3341 | struct sockaddr *psta_mac_addr = addr; |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3342 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3343 | int ret; |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3344 | struct qdf_mac_addr mac_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3345 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3346 | hdd_enter_dev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3347 | |
Hanumanth Reddy Pothula | 5c7a781 | 2018-03-09 12:55:32 +0530 | [diff] [blame] | 3348 | if (netif_running(dev)) { |
| 3349 | hdd_err("On iface up, set mac address change isn't supported"); |
| 3350 | return -EBUSY; |
| 3351 | } |
| 3352 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3353 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3354 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 3355 | if (0 != ret) |
| 3356 | return ret; |
| 3357 | |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3358 | qdf_mem_copy(&mac_addr, psta_mac_addr->sa_data, sizeof(mac_addr)); |
| 3359 | |
| 3360 | if (qdf_is_macaddr_zero(&mac_addr)) { |
| 3361 | hdd_err("MAC is all zero"); |
| 3362 | return -EINVAL; |
| 3363 | } |
| 3364 | |
| 3365 | if (qdf_is_macaddr_broadcast(&mac_addr)) { |
| 3366 | hdd_err("MAC is Broadcast"); |
| 3367 | return -EINVAL; |
| 3368 | } |
| 3369 | |
| 3370 | if (ETHER_IS_MULTICAST(psta_mac_addr->sa_data)) { |
| 3371 | hdd_err("MAC is Multicast"); |
| 3372 | return -EINVAL; |
| 3373 | } |
| 3374 | |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 3375 | memcpy(&adapter->mac_addr, psta_mac_addr->sa_data, ETH_ALEN); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3376 | memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN); |
| 3377 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3378 | hdd_exit(); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3379 | return qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3380 | } |
| 3381 | |
| 3382 | /** |
| 3383 | * hdd_set_mac_address() - Wrapper function to protect __hdd_set_mac_address() |
| 3384 | * function from SSR |
| 3385 | * @dev: pointer to net_device structure |
| 3386 | * @addr: Pointer to the sockaddr |
| 3387 | * |
| 3388 | * This function sets the user specified mac address using |
| 3389 | * the command ifconfig wlanX hw ether <mac adress>. |
| 3390 | * |
| 3391 | * Return: 0 for success. |
| 3392 | */ |
| 3393 | static int hdd_set_mac_address(struct net_device *dev, void *addr) |
| 3394 | { |
| 3395 | int ret; |
| 3396 | |
| 3397 | cds_ssr_protect(__func__); |
| 3398 | ret = __hdd_set_mac_address(dev, addr); |
| 3399 | cds_ssr_unprotect(__func__); |
| 3400 | |
| 3401 | return ret; |
| 3402 | } |
| 3403 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3404 | uint8_t *wlan_hdd_get_intf_addr(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3405 | { |
| 3406 | int i; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3407 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3408 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3409 | if (0 == ((hdd_ctx->config->intfAddrMask) & (1 << i))) |
| 3410 | break; |
| 3411 | } |
| 3412 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3413 | if (QDF_MAX_CONCURRENCY_PERSONA == i) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3414 | return NULL; |
| 3415 | |
| 3416 | hdd_ctx->config->intfAddrMask |= (1 << i); |
| 3417 | return &hdd_ctx->config->intfMacAddr[i].bytes[0]; |
| 3418 | } |
| 3419 | |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 3420 | void wlan_hdd_release_intf_addr(struct hdd_context *hdd_ctx, |
| 3421 | uint8_t *releaseAddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3422 | { |
| 3423 | int i; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3424 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3425 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3426 | if (!memcmp(releaseAddr, |
| 3427 | &hdd_ctx->config->intfMacAddr[i].bytes[0], |
| 3428 | 6)) { |
| 3429 | hdd_ctx->config->intfAddrMask &= ~(1 << i); |
| 3430 | break; |
| 3431 | } |
| 3432 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3433 | } |
| 3434 | |
| 3435 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 3436 | /** |
| 3437 | * __hdd_set_multicast_list() - set the multicast address list |
| 3438 | * @dev: Pointer to the WLAN device. |
| 3439 | * @skb: Pointer to OS packet (sk_buff). |
| 3440 | * |
| 3441 | * This funciton sets the multicast address list. |
| 3442 | * |
| 3443 | * Return: None |
| 3444 | */ |
| 3445 | static void __hdd_set_multicast_list(struct net_device *dev) |
| 3446 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3447 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3448 | int i = 0, status; |
| 3449 | struct netdev_hw_addr *ha; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3450 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3451 | struct pmo_mc_addr_list_params *mc_list_request = NULL; |
| 3452 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 3453 | int mc_count = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3454 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3455 | hdd_enter_dev(dev); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3456 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3457 | goto out; |
Mukul Sharma | 51c4494 | 2015-10-30 19:30:19 +0530 | [diff] [blame] | 3458 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3459 | status = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 3460 | if (0 != status) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3461 | goto out; |
| 3462 | |
Dustin Brown | c788acb | 2017-08-01 17:43:51 -0700 | [diff] [blame] | 3463 | status = hdd_validate_adapter(adapter); |
| 3464 | if (status) |
| 3465 | goto out; |
| 3466 | |
Arunk Khandavalli | 6a22788 | 2017-12-12 19:31:08 +0530 | [diff] [blame] | 3467 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) { |
| 3468 | hdd_err("%s: Driver module is closed", __func__); |
| 3469 | return; |
| 3470 | } |
| 3471 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3472 | mc_list_request = qdf_mem_malloc(sizeof(*mc_list_request)); |
| 3473 | if (!mc_list_request) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3474 | hdd_err("Cannot allocate mc_list_request"); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3475 | goto out; |
| 3476 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3477 | |
Hanumanth Reddy Pothula | ca84ec5 | 2017-02-21 12:09:45 +0530 | [diff] [blame] | 3478 | /* Delete already configured multicast address list */ |
| 3479 | if (adapter->mc_addr_list.mc_cnt > 0) { |
| 3480 | hdd_info("clear previously configured MC address list"); |
| 3481 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3482 | pmo_mc_list_change_notify); |
| 3483 | } |
| 3484 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3485 | if (dev->flags & IFF_ALLMULTI) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3486 | hdd_debug("allow all multicast frames"); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3487 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3488 | pmo_mc_list_change_notify); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3489 | } else { |
| 3490 | mc_count = netdev_mc_count(dev); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3491 | if (mc_count > pmo_ucfg_max_mc_addr_supported(psoc)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3492 | 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] | 3493 | pmo_ucfg_max_mc_addr_supported(psoc)); |
| 3494 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3495 | pmo_mc_list_change_notify); |
| 3496 | goto out; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3497 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3498 | netdev_for_each_mc_addr(ha, dev) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3499 | hdd_debug("ha_addr[%d] "MAC_ADDRESS_STR, |
Sachin Ahuja | a69c72a | 2016-09-03 15:59:33 +0530 | [diff] [blame] | 3500 | i, MAC_ADDR_ARRAY(ha->addr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3501 | if (i == mc_count) |
| 3502 | break; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3503 | memset(&(mc_list_request->mc_addr[i].bytes), |
| 3504 | 0, ETH_ALEN); |
| 3505 | memcpy(&(mc_list_request->mc_addr[i].bytes), |
| 3506 | ha->addr, ETH_ALEN); |
| 3507 | hdd_info("mlist[%d] = %pM", i, |
| 3508 | mc_list_request->mc_addr[i].bytes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3509 | i++; |
| 3510 | } |
| 3511 | } |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3512 | |
| 3513 | mc_list_request->psoc = psoc; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3514 | mc_list_request->vdev_id = adapter->session_id; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3515 | mc_list_request->count = mc_count; |
| 3516 | status = hdd_cache_mc_addr_list(mc_list_request); |
| 3517 | if (status == 0) { |
| 3518 | hdd_enable_mc_addr_filtering(adapter, |
| 3519 | pmo_mc_list_change_notify); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3520 | } else { |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3521 | hdd_err("error while caching mc list"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3522 | } |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3523 | out: |
| 3524 | if (mc_list_request) |
| 3525 | qdf_mem_free(mc_list_request); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3526 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3527 | } |
| 3528 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3529 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3530 | /** |
| 3531 | * hdd_set_multicast_list() - SSR wrapper function for __hdd_set_multicast_list |
| 3532 | * @dev: pointer to net_device |
| 3533 | * |
| 3534 | * Return: none |
| 3535 | */ |
| 3536 | static void hdd_set_multicast_list(struct net_device *dev) |
| 3537 | { |
| 3538 | cds_ssr_protect(__func__); |
| 3539 | __hdd_set_multicast_list(dev); |
| 3540 | cds_ssr_unprotect(__func__); |
| 3541 | } |
| 3542 | #endif |
| 3543 | |
| 3544 | /** |
| 3545 | * hdd_select_queue() - used by Linux OS to decide which queue to use first |
| 3546 | * @dev: Pointer to the WLAN device. |
| 3547 | * @skb: Pointer to OS packet (sk_buff). |
| 3548 | * |
| 3549 | * This function is registered with the Linux OS for network |
| 3550 | * core to decide which queue to use first. |
| 3551 | * |
| 3552 | * Return: ac, Queue Index/access category corresponding to UP in IP header |
| 3553 | */ |
| 3554 | static uint16_t hdd_select_queue(struct net_device *dev, struct sk_buff *skb |
| 3555 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0)) |
| 3556 | , void *accel_priv |
| 3557 | #endif |
| 3558 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) |
| 3559 | , select_queue_fallback_t fallback |
| 3560 | #endif |
| 3561 | ) |
| 3562 | { |
| 3563 | return hdd_wmm_select_queue(dev, skb); |
| 3564 | } |
| 3565 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3566 | static const struct net_device_ops wlan_drv_ops = { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3567 | .ndo_open = hdd_open, |
| 3568 | .ndo_stop = hdd_stop, |
| 3569 | .ndo_uninit = hdd_uninit, |
| 3570 | .ndo_start_xmit = hdd_hard_start_xmit, |
| 3571 | .ndo_tx_timeout = hdd_tx_timeout, |
| 3572 | .ndo_get_stats = hdd_get_stats, |
| 3573 | .ndo_do_ioctl = hdd_ioctl, |
| 3574 | .ndo_set_mac_address = hdd_set_mac_address, |
| 3575 | .ndo_select_queue = hdd_select_queue, |
| 3576 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3577 | .ndo_set_rx_mode = hdd_set_multicast_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3578 | #endif |
| 3579 | }; |
| 3580 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3581 | /* Monitor mode net_device_ops, doesnot Tx and most of operations. */ |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3582 | static const struct net_device_ops wlan_mon_drv_ops = { |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3583 | .ndo_open = hdd_mon_open, |
| 3584 | .ndo_stop = hdd_stop, |
| 3585 | .ndo_get_stats = hdd_get_stats, |
| 3586 | }; |
| 3587 | |
| 3588 | /** |
| 3589 | * hdd_set_station_ops() - update net_device ops for monitor mode |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3590 | * @dev: Handle to struct net_device to be updated. |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3591 | * Return: None |
| 3592 | */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3593 | void hdd_set_station_ops(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3594 | { |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3595 | if (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam()) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3596 | dev->netdev_ops = &wlan_mon_drv_ops; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3597 | else |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3598 | dev->netdev_ops = &wlan_drv_ops; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3599 | } |
| 3600 | |
| 3601 | /** |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3602 | * hdd_alloc_station_adapter() - allocate the station hdd adapter |
| 3603 | * @hdd_ctx: global hdd context |
| 3604 | * @macAddr: mac address to assign to the interface |
| 3605 | * @name: User-visible name of the interface |
| 3606 | * |
| 3607 | * hdd adapter pointer would point to the netdev->priv space, this function |
| 3608 | * would retrive the pointer, and setup the hdd adapter configuration. |
| 3609 | * |
| 3610 | * Return: the pointer to hdd adapter, otherwise NULL |
| 3611 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3612 | 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] | 3613 | tSirMacAddr macAddr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3614 | unsigned char name_assign_type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3615 | const char *name) |
| 3616 | { |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3617 | struct net_device *dev = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3618 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 3619 | struct hdd_station_ctx *sta_ctx; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3620 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3621 | /* |
| 3622 | * cfg80211 initialization and registration.... |
| 3623 | */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3624 | dev = alloc_netdev_mq(sizeof(struct hdd_adapter), name, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3625 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS) |
| 3626 | name_assign_type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3627 | #endif |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3628 | (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam() ? |
| 3629 | hdd_mon_mode_ether_setup : ether_setup), |
| 3630 | NUM_TX_QUEUES); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3631 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3632 | if (dev != NULL) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3633 | |
| 3634 | /* Save the pointer to the net_device in the HDD adapter */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3635 | adapter = (struct hdd_adapter *) netdev_priv(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3636 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3637 | qdf_mem_zero(adapter, sizeof(struct hdd_adapter)); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 3638 | sta_ctx = &adapter->session.station; |
Hanumanth Reddy Pothula | 18553ae | 2017-04-28 15:03:10 +0530 | [diff] [blame] | 3639 | qdf_mem_set(sta_ctx->conn_info.staId, |
| 3640 | sizeof(sta_ctx->conn_info.staId), |
| 3641 | HDD_WLAN_INVALID_STA_ID); |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3642 | adapter->dev = dev; |
Jeff Johnson | dba0db6 | 2017-08-30 11:12:39 -0700 | [diff] [blame] | 3643 | adapter->hdd_ctx = hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3644 | adapter->magic = WLAN_HDD_ADAPTER_MAGIC; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3645 | adapter->session_id = HDD_SESSION_ID_INVALID; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3646 | |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3647 | qdf_status = qdf_event_create( |
| 3648 | &adapter->qdf_session_open_event); |
| 3649 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 3650 | hdd_err("Session open QDF event init failed!"); |
| 3651 | free_netdev(adapter->dev); |
| 3652 | return NULL; |
| 3653 | } |
| 3654 | |
| 3655 | qdf_status = qdf_event_create( |
| 3656 | &adapter->qdf_session_close_event); |
| 3657 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 3658 | hdd_err("Session close QDF event init failed!"); |
| 3659 | free_netdev(adapter->dev); |
| 3660 | return NULL; |
| 3661 | } |
| 3662 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3663 | init_completion(&adapter->disconnect_comp_var); |
Abhishek Singh | 533c9da | 2017-05-04 10:23:34 +0530 | [diff] [blame] | 3664 | init_completion(&adapter->roaming_comp_var); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3665 | init_completion(&adapter->linkup_event_var); |
| 3666 | init_completion(&adapter->cancel_rem_on_chan_var); |
| 3667 | init_completion(&adapter->rem_on_chan_ready_event); |
| 3668 | init_completion(&adapter->sta_authorized_event); |
| 3669 | init_completion(&adapter->offchannel_tx_event); |
| 3670 | init_completion(&adapter->tx_action_cnf_event); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3671 | init_completion(&adapter->ibss_peer_info_comp); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3672 | init_completion(&adapter->change_country_code); |
Sreelakshmi Konamki | 88a2a41 | 2017-04-14 15:11:55 +0530 | [diff] [blame] | 3673 | init_completion(&adapter->lfr_fw_status.disable_lfr_event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3674 | |
| 3675 | adapter->offloads_configured = false; |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 3676 | adapter->is_link_up_service_needed = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3677 | /* Init the net_device structure */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3678 | strlcpy(dev->name, name, IFNAMSIZ); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3679 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3680 | qdf_mem_copy(dev->dev_addr, (void *)macAddr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3681 | sizeof(tSirMacAddr)); |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 3682 | qdf_mem_copy(adapter->mac_addr.bytes, macAddr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3683 | sizeof(tSirMacAddr)); |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3684 | dev->watchdog_timeo = HDD_TX_TIMEOUT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3685 | |
| 3686 | if (hdd_ctx->config->enable_ip_tcp_udp_checksum_offload) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3687 | dev->features |= |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3688 | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM; |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3689 | dev->features |= NETIF_F_RXCSUM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3690 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3691 | hdd_set_tso_flags(hdd_ctx, dev); |
Dhanashri Atre | 83d373d | 2015-07-28 16:45:59 -0700 | [diff] [blame] | 3692 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3693 | hdd_set_station_ops(adapter->dev); |
| 3694 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3695 | hdd_dev_setup_destructor(dev); |
| 3696 | dev->ieee80211_ptr = &adapter->wdev; |
| 3697 | dev->tx_queue_len = HDD_NETDEV_TX_QUEUE_LEN; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3698 | adapter->wdev.wiphy = hdd_ctx->wiphy; |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3699 | adapter->wdev.netdev = dev; |
| 3700 | /* set dev's parent to underlying device */ |
| 3701 | SET_NETDEV_DEV(dev, hdd_ctx->parent_dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3702 | hdd_wmm_init(adapter); |
| 3703 | spin_lock_init(&adapter->pause_map_lock); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 3704 | adapter->start_time = adapter->last_time = qdf_system_ticks(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3705 | } |
| 3706 | |
| 3707 | return adapter; |
| 3708 | } |
| 3709 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3710 | 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] | 3711 | { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3712 | struct net_device *dev = adapter->dev; |
| 3713 | int ret; |
| 3714 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 3715 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3716 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 3717 | if (rtnl_held) { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3718 | if (strnchr(dev->name, IFNAMSIZ - 1, '%')) { |
| 3719 | |
| 3720 | ret = dev_alloc_name(dev, dev->name); |
| 3721 | if (ret < 0) { |
| 3722 | hdd_err( |
| 3723 | "unable to get dev name: %s, err = 0x%x", |
| 3724 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3725 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3726 | } |
| 3727 | } |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3728 | |
| 3729 | ret = register_netdevice(dev); |
| 3730 | if (ret) { |
| 3731 | hdd_err("register_netdevice(%s) failed, err = 0x%x", |
| 3732 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3733 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3734 | } |
| 3735 | } else { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3736 | ret = register_netdev(dev); |
| 3737 | if (ret) { |
| 3738 | hdd_err("register_netdev(%s) failed, err = 0x%x", |
| 3739 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3740 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3741 | } |
| 3742 | } |
| 3743 | set_bit(NET_DEVICE_REGISTERED, &adapter->event_flags); |
| 3744 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3745 | hdd_exit(); |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3746 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3747 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3748 | } |
| 3749 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3750 | QDF_STATUS hdd_sme_open_session_callback(uint8_t session_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3751 | { |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3752 | struct hdd_adapter *adapter; |
| 3753 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3754 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3755 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 3756 | if (!hdd_ctx) { |
| 3757 | hdd_err("Invalid HDD_CTX"); |
| 3758 | return QDF_STATUS_E_FAILURE; |
| 3759 | } |
| 3760 | |
| 3761 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, session_id); |
| 3762 | if (NULL == adapter) { |
| 3763 | hdd_err("NULL adapter"); |
| 3764 | return QDF_STATUS_E_INVAL; |
| 3765 | } |
| 3766 | set_bit(SME_SESSION_OPENED, &adapter->event_flags); |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3767 | qdf_event_set(&adapter->qdf_session_open_event); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3768 | hdd_debug("session %d opened", adapter->session_id); |
| 3769 | |
| 3770 | return QDF_STATUS_SUCCESS; |
| 3771 | } |
| 3772 | |
| 3773 | QDF_STATUS hdd_sme_close_session_callback(uint8_t session_id) |
| 3774 | { |
| 3775 | struct hdd_adapter *adapter; |
| 3776 | struct hdd_context *hdd_ctx; |
| 3777 | |
| 3778 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 3779 | if (!hdd_ctx) { |
| 3780 | hdd_err("Invalid HDD_CTX"); |
| 3781 | return QDF_STATUS_E_FAILURE; |
| 3782 | } |
| 3783 | |
| 3784 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3785 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3786 | hdd_err("NULL adapter"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3787 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3788 | } |
| 3789 | |
| 3790 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3791 | hdd_err("Invalid magic"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3792 | return QDF_STATUS_NOT_INITIALIZED; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3793 | } |
| 3794 | |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3795 | /* |
| 3796 | * For NAN Data interface, the close session results in the final |
| 3797 | * indication to the userspace |
| 3798 | */ |
Rakesh Sunki | 3480f96 | 2016-08-29 17:29:53 -0700 | [diff] [blame] | 3799 | if (adapter->device_mode == QDF_NDI_MODE) |
| 3800 | hdd_ndp_session_end_handler(adapter); |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3801 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3802 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 3803 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3804 | /* |
| 3805 | * We can be blocked while waiting for scheduled work to be |
| 3806 | * flushed, and the adapter structure can potentially be freed, in |
| 3807 | * which case the magic will have been reset. So make sure the |
| 3808 | * magic is still good, and hence the adapter structure is still |
| 3809 | * valid, before signaling completion |
| 3810 | */ |
| 3811 | if (WLAN_HDD_ADAPTER_MAGIC == adapter->magic) |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3812 | qdf_event_set(&adapter->qdf_session_close_event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3813 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3814 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3815 | } |
| 3816 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3817 | int hdd_vdev_ready(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3818 | { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3819 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3820 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3821 | status = pmo_vdev_ready(adapter->hdd_vdev); |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 3822 | if (QDF_IS_STATUS_ERROR(status)) |
| 3823 | return qdf_status_to_os_return(status); |
| 3824 | |
Kiran Kumar Lokere | 3beeb95 | 2017-05-02 18:40:24 -0700 | [diff] [blame] | 3825 | status = ucfg_reg_11d_vdev_created_update(adapter->hdd_vdev); |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 3826 | if (QDF_IS_STATUS_ERROR(status)) |
| 3827 | return qdf_status_to_os_return(status); |
| 3828 | |
| 3829 | if (wma_capability_enhanced_mcast_filter()) |
| 3830 | status = pmo_ucfg_enhanced_mc_filter_enable(adapter->hdd_vdev); |
| 3831 | else |
| 3832 | status = pmo_ucfg_enhanced_mc_filter_disable(adapter->hdd_vdev); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3833 | |
| 3834 | return qdf_status_to_os_return(status); |
| 3835 | } |
| 3836 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3837 | int hdd_vdev_destroy(struct hdd_adapter *adapter) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3838 | { |
| 3839 | QDF_STATUS status; |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3840 | int errno = 0; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3841 | struct hdd_context *hdd_ctx; |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 3842 | uint8_t vdev_id; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3843 | |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 3844 | vdev_id = adapter->session_id; |
| 3845 | hdd_info("destroying vdev %d", vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3846 | |
| 3847 | /* vdev created sanity check */ |
| 3848 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3849 | hdd_err("vdev for Id %d does not exist", adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3850 | return -EINVAL; |
| 3851 | } |
Kiran Kumar Lokere | 3beeb95 | 2017-05-02 18:40:24 -0700 | [diff] [blame] | 3852 | status = ucfg_reg_11d_vdev_delete_update(adapter->hdd_vdev); |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 3853 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3854 | /* close sme session (destroy vdev in firmware via legacy API) */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3855 | qdf_event_reset(&adapter->qdf_session_close_event); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3856 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3857 | status = sme_close_session(hdd_ctx->hHal, adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3858 | if (QDF_IS_STATUS_ERROR(status)) { |
| 3859 | hdd_err("failed to close sme session: %d", status); |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3860 | errno = qdf_status_to_os_return(status); |
| 3861 | goto release_vdev; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3862 | } |
| 3863 | |
| 3864 | /* block on a completion variable until sme session is closed */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3865 | status = qdf_wait_for_event_completion( |
| 3866 | &adapter->qdf_session_close_event, |
| 3867 | WLAN_WAIT_TIME_SESSIONOPENCLOSE); |
| 3868 | if (QDF_STATUS_SUCCESS != status) { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3869 | if (adapter->device_mode == QDF_NDI_MODE) |
| 3870 | hdd_ndp_session_end_handler(adapter); |
| 3871 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3872 | adapter->session_id = HDD_SESSION_ID_INVALID; |
| 3873 | if (QDF_STATUS_E_TIMEOUT != status) { |
| 3874 | hdd_err("timed out waiting for close sme session: %u", status); |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3875 | errno = -ETIMEDOUT; |
| 3876 | goto release_vdev; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3877 | } else if (adapter->qdf_session_close_event.force_set) { |
| 3878 | hdd_err("Session close evt focefully set, SSR/PDR has occurred"); |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3879 | errno = -EINVAL; |
| 3880 | goto release_vdev; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3881 | } else { |
| 3882 | hdd_err("Failed to close sme session (%u)", status); |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3883 | errno = -EINVAL; |
| 3884 | goto release_vdev; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3885 | } |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3886 | } |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3887 | |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 3888 | release_vdev: |
Frank Liu | c66d4bf | 2018-01-26 16:18:18 +0800 | [diff] [blame] | 3889 | /* |
| 3890 | * In SSR or driver unloading case, directly exit may cause objects |
| 3891 | * leak, if sme_close_session failed. Free objects anyway. |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3892 | */ |
Kabilan Kannan | b867c31 | 2018-02-15 17:43:21 -0800 | [diff] [blame] | 3893 | if (errno && !cds_is_driver_recovering() && !cds_is_driver_unloading()) |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3894 | return errno; |
| 3895 | |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 3896 | /* do vdev logical destroy via objmgr */ |
Dustin Brown | b277dd6 | 2018-01-26 15:17:33 -0800 | [diff] [blame] | 3897 | errno = hdd_objmgr_release_and_destroy_vdev(adapter); |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 3898 | if (errno) { |
Dustin Brown | b277dd6 | 2018-01-26 15:17:33 -0800 | [diff] [blame] | 3899 | hdd_err("failed to destroy objmgr vdev; errno:%d", errno); |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 3900 | return errno; |
| 3901 | } |
| 3902 | |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 3903 | hdd_info("vdev %d destroyed successfully", vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3904 | |
| 3905 | return 0; |
| 3906 | } |
| 3907 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3908 | static int hdd_set_sme_session_param(struct hdd_adapter *adapter, |
| 3909 | struct sme_session_params *session_param, |
| 3910 | csr_roam_completeCallback callback, |
| 3911 | void *callback_ctx) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3912 | { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3913 | uint32_t type; |
| 3914 | uint32_t sub_type; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3915 | QDF_STATUS status; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3916 | |
| 3917 | /* determine vdev (sub)type */ |
| 3918 | status = cds_get_vdev_types(adapter->device_mode, &type, &sub_type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3919 | if (QDF_STATUS_SUCCESS != status) { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3920 | hdd_err("failed to get vdev type: %d", status); |
| 3921 | return qdf_status_to_os_return(status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3922 | } |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3923 | session_param->sme_session_id = adapter->session_id; |
| 3924 | session_param->self_mac_addr = (uint8_t *)&adapter->mac_addr; |
| 3925 | session_param->type_of_persona = type; |
| 3926 | session_param->subtype_of_persona = sub_type; |
| 3927 | session_param->session_open_cb = hdd_sme_open_session_callback; |
| 3928 | session_param->session_close_cb = hdd_sme_close_session_callback; |
| 3929 | session_param->callback = callback; |
| 3930 | session_param->callback_ctx = callback_ctx; |
| 3931 | |
| 3932 | return 0; |
| 3933 | } |
| 3934 | |
| 3935 | int hdd_vdev_create(struct hdd_adapter *adapter, |
| 3936 | csr_roam_completeCallback callback, void *ctx) |
| 3937 | { |
| 3938 | QDF_STATUS status; |
| 3939 | int errno; |
| 3940 | struct hdd_context *hdd_ctx; |
| 3941 | struct sme_session_params sme_session_params = {0}; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3942 | |
| 3943 | hdd_info("creating new vdev"); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3944 | |
| 3945 | /* do vdev create via objmgr */ |
| 3946 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Dustin Brown | 7d043f6 | 2017-03-27 12:07:36 -0700 | [diff] [blame] | 3947 | errno = hdd_objmgr_create_and_store_vdev(hdd_ctx->hdd_pdev, adapter); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3948 | if (errno) { |
| 3949 | hdd_err("failed to create objmgr vdev: %d", errno); |
| 3950 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3951 | } |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3952 | |
| 3953 | /* Open a SME session (prepare vdev in firmware via legacy API) */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3954 | status = qdf_event_reset(&adapter->qdf_session_open_event); |
| 3955 | if (QDF_STATUS_SUCCESS != status) { |
| 3956 | hdd_err("failed to reinit session open event"); |
| 3957 | return -EINVAL; |
| 3958 | } |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3959 | errno = hdd_set_sme_session_param(adapter, &sme_session_params, |
| 3960 | callback, ctx); |
| 3961 | if (errno) { |
| 3962 | hdd_err("failed to populating SME params"); |
| 3963 | goto objmgr_vdev_destroy_procedure; |
| 3964 | } |
| 3965 | |
| 3966 | status = sme_open_session(hdd_ctx->hHal, &sme_session_params); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3967 | if (QDF_IS_STATUS_ERROR(status)) { |
| 3968 | hdd_err("failed to open sme session: %d", status); |
| 3969 | errno = qdf_status_to_os_return(status); |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3970 | goto objmgr_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3971 | } |
| 3972 | |
| 3973 | /* block on a completion variable until sme session is opened */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3974 | status = qdf_wait_for_event_completion(&adapter->qdf_session_open_event, |
| 3975 | WLAN_WAIT_TIME_SESSIONOPENCLOSE); |
| 3976 | if (QDF_STATUS_SUCCESS != status) { |
| 3977 | if (adapter->qdf_session_open_event.force_set) { |
| 3978 | /* |
| 3979 | * SSR/PDR has caused shutdown, which has forcefully |
| 3980 | * set the event. Return without the closing session. |
| 3981 | */ |
| 3982 | adapter->session_id = HDD_SESSION_ID_INVALID; |
| 3983 | hdd_err("Session open event forcefully set"); |
| 3984 | return -EINVAL; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3985 | } |
Jeff Johnson | c66d310 | 2018-02-28 11:58:26 -0800 | [diff] [blame] | 3986 | |
| 3987 | if (QDF_STATUS_E_TIMEOUT == status) |
| 3988 | hdd_err("Session failed to open within timeout period"); |
| 3989 | else |
| 3990 | hdd_err("Failed to wait for session open event(status-%d)", |
| 3991 | status); |
| 3992 | errno = -ETIMEDOUT; |
| 3993 | set_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 3994 | goto hdd_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3995 | } |
| 3996 | |
| 3997 | /* firmware ready for component communication, raise vdev_ready event */ |
| 3998 | errno = hdd_vdev_ready(adapter); |
| 3999 | if (errno) { |
| 4000 | hdd_err("failed to dispatch vdev ready event: %d", errno); |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4001 | goto hdd_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4002 | } |
| 4003 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4004 | hdd_info("vdev %d created successfully", adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4005 | |
| 4006 | return 0; |
| 4007 | |
| 4008 | /* |
| 4009 | * Due to legacy constraints, we need to destroy in the same order as |
| 4010 | * create. So, split error handling into 2 cases to accommodate. |
| 4011 | */ |
| 4012 | |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4013 | objmgr_vdev_destroy_procedure: |
Dustin Brown | 7d043f6 | 2017-03-27 12:07:36 -0700 | [diff] [blame] | 4014 | QDF_BUG(!hdd_objmgr_release_and_destroy_vdev(adapter)); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4015 | |
| 4016 | return errno; |
| 4017 | |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4018 | hdd_vdev_destroy_procedure: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4019 | QDF_BUG(!hdd_vdev_destroy(adapter)); |
| 4020 | |
| 4021 | return errno; |
| 4022 | } |
| 4023 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4024 | QDF_STATUS hdd_init_station_mode(struct hdd_adapter *adapter) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4025 | { |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 4026 | struct hdd_station_ctx *sta_ctx = &adapter->session.station; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4027 | struct hdd_context *hdd_ctx; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4028 | QDF_STATUS status; |
| 4029 | int ret_val; |
| 4030 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4031 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 4032 | sme_set_curr_device_mode(hdd_ctx->hHal, adapter->device_mode); |
| 4033 | sme_set_pdev_ht_vht_ies(hdd_ctx->hHal, hdd_ctx->config->enable2x2); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4034 | sme_set_vdev_ies_per_band(hdd_ctx->hHal, adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4035 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4036 | /* Register wireless extensions */ |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4037 | status = hdd_register_wext(adapter->dev); |
| 4038 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4039 | hdd_err("failed to register wireless extensions: %d", status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4040 | goto error_register_wext; |
| 4041 | } |
Varun Reddy Yeturu | 9e0032c | 2017-07-12 18:39:59 -0700 | [diff] [blame] | 4042 | hdd_conn_set_connection_state(adapter, eConnectionState_NotConnected); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4043 | |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4044 | qdf_mem_set(sta_ctx->conn_info.staId, |
| 4045 | sizeof(sta_ctx->conn_info.staId), HDD_WLAN_INVALID_STA_ID); |
Hanumanth Reddy Pothula | b2d729c | 2017-05-30 11:49:53 +0530 | [diff] [blame] | 4046 | |
Deepak Dhamdhere | a278582 | 2016-11-17 01:17:45 -0800 | [diff] [blame] | 4047 | /* set fast roaming capability in sme session */ |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4048 | status = sme_config_fast_roaming(hdd_ctx->hHal, adapter->session_id, |
Abhishek Singh | 1f217ec | 2017-12-22 11:48:27 +0530 | [diff] [blame] | 4049 | true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4050 | /* Set the default operation channel */ |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4051 | sta_ctx->conn_info.operationChannel = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4052 | hdd_ctx->config->OperatingChannel; |
| 4053 | |
| 4054 | /* Make the default Auth Type as OPEN */ |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4055 | sta_ctx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4056 | |
| 4057 | status = hdd_init_tx_rx(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4058 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4059 | hdd_err("hdd_init_tx_rx() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4060 | status, status); |
| 4061 | goto error_init_txrx; |
| 4062 | } |
| 4063 | |
| 4064 | set_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 4065 | |
| 4066 | status = hdd_wmm_adapter_init(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4067 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4068 | hdd_err("hdd_wmm_adapter_init() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4069 | status, status); |
| 4070 | goto error_wmm_init; |
| 4071 | } |
| 4072 | |
| 4073 | set_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 4074 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4075 | ret_val = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4076 | WMI_PDEV_PARAM_BURST_ENABLE, |
| 4077 | hdd_ctx->config->enableSifsBurst, |
| 4078 | PDEV_CMD); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4079 | if (ret_val) |
| 4080 | hdd_err("WMI_PDEV_PARAM_BURST_ENABLE set failed %d", ret_val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4081 | |
Poddar, Siddarth | 4b3f731 | 2017-11-02 17:00:20 +0530 | [diff] [blame] | 4082 | /* |
| 4083 | * In case of USB tethering, LRO is disabled. If SSR happened |
| 4084 | * during that time, then as part of SSR init, do not enable |
| 4085 | * the LRO again. Keep the LRO state same as before SSR. |
| 4086 | */ |
| 4087 | if (!(qdf_atomic_read(&hdd_ctx->vendor_disable_lro_flag))) |
Dhanashri Atre | 1a6a4ce | 2017-05-03 19:40:33 -0700 | [diff] [blame] | 4088 | adapter->dev->features |= NETIF_F_LRO; |
Rajeev Kumar Sirasanagandla | 996e529 | 2016-11-22 21:20:33 +0530 | [diff] [blame] | 4089 | |
| 4090 | /* rcpi info initialization */ |
| 4091 | qdf_mem_zero(&adapter->rcpi, sizeof(adapter->rcpi)); |
| 4092 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4093 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4094 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4095 | error_wmm_init: |
| 4096 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 4097 | hdd_deinit_tx_rx(adapter); |
| 4098 | error_init_txrx: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4099 | hdd_unregister_wext(adapter->dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4100 | error_register_wext: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4101 | QDF_BUG(!hdd_vdev_destroy(adapter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4102 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4103 | return status; |
| 4104 | } |
| 4105 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4106 | /** |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4107 | * hdd_deinit_station_mode() - De-initialize the station adapter |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4108 | * @hdd_ctx: global hdd context |
| 4109 | * @adapter: HDD adapter |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 4110 | * @rtnl_held: Used to indicate whether or not the caller is holding |
| 4111 | * the kernel rtnl_mutex |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4112 | * |
| 4113 | * This function De-initializes the STA/P2P/OCB adapter. |
| 4114 | * |
| 4115 | * Return: None. |
| 4116 | */ |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4117 | static void hdd_deinit_station_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4118 | struct hdd_adapter *adapter, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 4119 | bool rtnl_held) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4120 | { |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 4121 | hdd_enter_dev(adapter->dev); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4122 | |
Hanumanth Reddy Pothula | 7a65740 | 2016-09-07 20:59:18 +0530 | [diff] [blame] | 4123 | if (adapter->dev) { |
| 4124 | if (rtnl_held) |
| 4125 | adapter->dev->wireless_handlers = NULL; |
| 4126 | else { |
| 4127 | rtnl_lock(); |
| 4128 | adapter->dev->wireless_handlers = NULL; |
| 4129 | rtnl_unlock(); |
| 4130 | } |
| 4131 | } |
| 4132 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4133 | if (test_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags)) { |
| 4134 | hdd_deinit_tx_rx(adapter); |
| 4135 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 4136 | } |
| 4137 | |
| 4138 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 4139 | hdd_wmm_adapter_close(adapter); |
| 4140 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 4141 | } |
| 4142 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4143 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4144 | hdd_exit(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4145 | } |
| 4146 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4147 | void hdd_deinit_adapter(struct hdd_context *hdd_ctx, |
| 4148 | struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4149 | bool rtnl_held) |
| 4150 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 4151 | hdd_enter(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4152 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4153 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4154 | case QDF_STA_MODE: |
| 4155 | case QDF_P2P_CLIENT_MODE: |
| 4156 | case QDF_P2P_DEVICE_MODE: |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4157 | case QDF_IBSS_MODE: |
| 4158 | case QDF_NDI_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4159 | { |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4160 | hdd_deinit_station_mode(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4161 | break; |
| 4162 | } |
| 4163 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4164 | case QDF_SAP_MODE: |
| 4165 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4166 | { |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4167 | hdd_deinit_ap_mode(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4168 | break; |
| 4169 | } |
| 4170 | |
| 4171 | default: |
| 4172 | break; |
| 4173 | } |
| 4174 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4175 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4176 | } |
| 4177 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4178 | 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] | 4179 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4180 | { |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4181 | struct net_device *dev = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4182 | |
| 4183 | if (adapter) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4184 | dev = adapter->dev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4185 | else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4186 | hdd_err("adapter is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4187 | return; |
| 4188 | } |
| 4189 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 4190 | hdd_debugfs_exit(adapter); |
Selvaraj, Sridhar | 4ea106e | 2016-08-05 20:34:46 +0530 | [diff] [blame] | 4191 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4192 | /* |
| 4193 | * The adapter is marked as closed. When hdd_wlan_exit() call returns, |
| 4194 | * the driver is almost closed and cannot handle either control |
| 4195 | * messages or data. However, unregister_netdevice() call above will |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4196 | * eventually invoke hdd_stop(ndo_close) driver callback, which attempts |
| 4197 | * to close the active connections(basically excites control path) which |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4198 | * is not right. Setting this flag helps hdd_stop() to recognize that |
| 4199 | * the interface is closed and restricts any operations on that |
| 4200 | */ |
| 4201 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 4202 | |
| 4203 | if (test_bit(NET_DEVICE_REGISTERED, &adapter->event_flags)) { |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4204 | if (rtnl_held) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4205 | unregister_netdevice(dev); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4206 | else |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4207 | unregister_netdev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4208 | /* |
| 4209 | * Note that the adapter is no longer valid at this point |
| 4210 | * since the memory has been reclaimed |
| 4211 | */ |
| 4212 | } |
| 4213 | } |
| 4214 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4215 | 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] | 4216 | tSirMacAddr macAddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4217 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4218 | struct hdd_adapter *adapter; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4219 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4220 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 4221 | if (!qdf_mem_cmp(adapter->mac_addr.bytes, |
| 4222 | macAddr, sizeof(tSirMacAddr))) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4223 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4224 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4225 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4226 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4227 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4228 | } |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4229 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4230 | #ifdef CONFIG_FW_LOGS_BASED_ON_INI |
| 4231 | /** |
| 4232 | * hdd_set_fw_log_params() - Set log parameters to FW |
| 4233 | * @hdd_ctx: HDD Context |
| 4234 | * @adapter: HDD Adapter |
| 4235 | * |
| 4236 | * This function set the FW Debug log level based on the INI. |
| 4237 | * |
| 4238 | * Return: None |
| 4239 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4240 | static void hdd_set_fw_log_params(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4241 | struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4242 | { |
| 4243 | uint8_t count = 0, numentries = 0, |
| 4244 | moduleloglevel[FW_MODULE_LOG_LEVEL_STRING_LENGTH]; |
| 4245 | uint32_t value = 0; |
| 4246 | int ret; |
| 4247 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4248 | if (QDF_GLOBAL_FTM_MODE == cds_get_conparam() || |
| 4249 | (!hdd_ctx->config->enable_fw_log)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4250 | 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] | 4251 | return; |
| 4252 | } |
| 4253 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4254 | /* Enable FW logs based on INI configuration */ |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4255 | hdd_ctx->fw_log_settings.dl_type = |
| 4256 | hdd_ctx->config->enableFwLogType; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4257 | ret = sme_cli_set_command(adapter->session_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4258 | WMI_DBGLOG_TYPE, |
| 4259 | hdd_ctx->config->enableFwLogType, |
| 4260 | DBG_CMD); |
| 4261 | if (ret != 0) |
| 4262 | hdd_err("Failed to enable FW log type ret %d", |
| 4263 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4264 | |
| 4265 | hdd_ctx->fw_log_settings.dl_loglevel = |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4266 | hdd_ctx->config->enableFwLogLevel; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4267 | ret = sme_cli_set_command(adapter->session_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4268 | WMI_DBGLOG_LOG_LEVEL, |
| 4269 | hdd_ctx->config->enableFwLogLevel, |
| 4270 | DBG_CMD); |
| 4271 | if (ret != 0) |
| 4272 | hdd_err("Failed to enable FW log level ret %d", |
| 4273 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4274 | |
| 4275 | hdd_string_to_u8_array( |
| 4276 | hdd_ctx->config->enableFwModuleLogLevel, |
| 4277 | moduleloglevel, |
| 4278 | &numentries, |
| 4279 | FW_MODULE_LOG_LEVEL_STRING_LENGTH); |
| 4280 | |
| 4281 | while (count < numentries) { |
| 4282 | /* |
| 4283 | * FW module log level input string looks like |
| 4284 | * below: |
| 4285 | * gFwDebugModuleLoglevel=<FW Module ID>, |
| 4286 | * <Log Level>,... |
| 4287 | * For example: |
| 4288 | * gFwDebugModuleLoglevel= |
| 4289 | * 1,0,2,1,3,2,4,3,5,4,6,5,7,6 |
| 4290 | * Above input string means : |
| 4291 | * For FW module ID 1 enable log level 0 |
| 4292 | * For FW module ID 2 enable log level 1 |
| 4293 | * For FW module ID 3 enable log level 2 |
| 4294 | * For FW module ID 4 enable log level 3 |
| 4295 | * For FW module ID 5 enable log level 4 |
| 4296 | * For FW module ID 6 enable log level 5 |
| 4297 | * For FW module ID 7 enable log level 6 |
| 4298 | */ |
| 4299 | |
Nishank Aggarwal | e239d96 | 2017-03-03 12:26:02 +0530 | [diff] [blame] | 4300 | if ((moduleloglevel[count] > WLAN_MODULE_ID_MAX) |
| 4301 | || (moduleloglevel[count + 1] > DBGLOG_LVL_MAX)) { |
| 4302 | hdd_err("Module id %d and dbglog level %d input length is more than max", |
| 4303 | moduleloglevel[count], |
| 4304 | moduleloglevel[count + 1]); |
| 4305 | return; |
| 4306 | } |
| 4307 | |
| 4308 | value = moduleloglevel[count] << 16; |
| 4309 | value |= moduleloglevel[count + 1]; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4310 | ret = sme_cli_set_command(adapter->session_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4311 | WMI_DBGLOG_MOD_LOG_LEVEL, |
| 4312 | value, DBG_CMD); |
| 4313 | if (ret != 0) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4314 | hdd_err("Failed to enable FW module log level %d ret %d", |
| 4315 | value, ret); |
| 4316 | |
| 4317 | count += 2; |
| 4318 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4319 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4320 | } |
| 4321 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4322 | static void hdd_set_fw_log_params(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4323 | struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4324 | { |
| 4325 | } |
| 4326 | |
| 4327 | #endif |
| 4328 | |
| 4329 | /** |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4330 | * hdd_configure_chain_mask() - programs chain mask to firmware |
| 4331 | * @adapter: HDD adapter |
| 4332 | * |
| 4333 | * Return: 0 on success or errno on failure |
| 4334 | */ |
| 4335 | static int hdd_configure_chain_mask(struct hdd_adapter *adapter) |
| 4336 | { |
| 4337 | int ret_val; |
| 4338 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 4339 | |
| 4340 | hdd_debug("enable2x2: %d, lte_coex: %d, ChainMask1x1: tx: %d rx: %d", |
| 4341 | hdd_ctx->config->enable2x2, hdd_ctx->lte_coex_ant_share, |
| 4342 | hdd_ctx->config->txchainmask1x1, |
| 4343 | hdd_ctx->config->rxchainmask1x1); |
| 4344 | hdd_debug("disable_DBS: %d, tx_chain_mask_2g: %d, rx_chain_mask_2g: %d", |
| 4345 | hdd_ctx->config->dual_mac_feature_disable, |
| 4346 | hdd_ctx->config->tx_chain_mask_2g, |
| 4347 | hdd_ctx->config->rx_chain_mask_2g); |
| 4348 | hdd_debug("tx_chain_mask_5g: %d, rx_chain_mask_5g: %d", |
| 4349 | hdd_ctx->config->tx_chain_mask_5g, |
| 4350 | hdd_ctx->config->rx_chain_mask_5g); |
| 4351 | |
| 4352 | if (hdd_ctx->config->enable2x2) { |
| 4353 | hdd_info("2x2 enabled. skip chain mask programming"); |
| 4354 | return 0; |
| 4355 | } |
| 4356 | |
Naveen Rawat | b54c72b | 2018-02-05 10:39:06 -0800 | [diff] [blame] | 4357 | if (hdd_ctx->config->dual_mac_feature_disable != |
| 4358 | DISABLE_DBS_CXN_AND_SCAN) { |
| 4359 | hdd_info("DBS enabled(%d). skip chain mask programming", |
| 4360 | hdd_ctx->config->dual_mac_feature_disable); |
| 4361 | return 0; |
| 4362 | } |
| 4363 | |
Naveen Rawat | dacb503 | 2018-02-08 15:23:24 -0800 | [diff] [blame] | 4364 | if (hdd_ctx->lte_coex_ant_share) { |
| 4365 | hdd_info("lte ant sharing enabled. skip chainmask programming"); |
| 4366 | return 0; |
| 4367 | } |
| 4368 | |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4369 | if (hdd_ctx->config->txchainmask1x1) { |
| 4370 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4371 | WMI_PDEV_PARAM_TX_CHAIN_MASK, |
| 4372 | hdd_ctx->config->txchainmask1x1, |
| 4373 | PDEV_CMD); |
| 4374 | if (ret_val) |
| 4375 | goto error; |
| 4376 | } |
| 4377 | |
| 4378 | if (hdd_ctx->config->rxchainmask1x1) { |
| 4379 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4380 | WMI_PDEV_PARAM_RX_CHAIN_MASK, |
| 4381 | hdd_ctx->config->rxchainmask1x1, |
| 4382 | PDEV_CMD); |
| 4383 | if (ret_val) |
| 4384 | goto error; |
| 4385 | } |
| 4386 | |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4387 | if (hdd_ctx->config->txchainmask1x1 || |
| 4388 | hdd_ctx->config->rxchainmask1x1) { |
| 4389 | hdd_info("band agnostic tx/rx chain mask set. skip per band chain mask"); |
| 4390 | return 0; |
| 4391 | } |
| 4392 | |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4393 | if (hdd_ctx->config->tx_chain_mask_2g) { |
| 4394 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4395 | WMI_PDEV_PARAM_TX_CHAIN_MASK_2G, |
| 4396 | hdd_ctx->config->tx_chain_mask_2g, PDEV_CMD); |
| 4397 | if (0 != ret_val) |
| 4398 | goto error; |
| 4399 | } |
| 4400 | |
| 4401 | if (hdd_ctx->config->rx_chain_mask_2g) { |
| 4402 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4403 | WMI_PDEV_PARAM_RX_CHAIN_MASK_2G, |
| 4404 | hdd_ctx->config->rx_chain_mask_2g, PDEV_CMD); |
| 4405 | if (0 != ret_val) |
| 4406 | goto error; |
| 4407 | } |
| 4408 | |
| 4409 | if (hdd_ctx->config->tx_chain_mask_5g) { |
| 4410 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4411 | WMI_PDEV_PARAM_TX_CHAIN_MASK_5G, |
| 4412 | hdd_ctx->config->tx_chain_mask_5g, PDEV_CMD); |
| 4413 | if (0 != ret_val) |
| 4414 | goto error; |
| 4415 | } |
| 4416 | |
| 4417 | if (hdd_ctx->config->rx_chain_mask_5g) { |
| 4418 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4419 | WMI_PDEV_PARAM_RX_CHAIN_MASK_5G, |
| 4420 | hdd_ctx->config->rx_chain_mask_5g, PDEV_CMD); |
| 4421 | if (0 != ret_val) |
| 4422 | goto error; |
| 4423 | } |
| 4424 | |
| 4425 | return 0; |
| 4426 | |
| 4427 | error: |
| 4428 | hdd_err("WMI PDEV set param failed %d", ret_val); |
| 4429 | return -EINVAL; |
| 4430 | } |
| 4431 | |
| 4432 | /** |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4433 | * hdd_set_fw_params() - Set parameters to firmware |
| 4434 | * @adapter: HDD adapter |
| 4435 | * |
| 4436 | * This function Sets various parameters to fw once the |
| 4437 | * adapter is started. |
| 4438 | * |
| 4439 | * Return: 0 on success or errno on failure |
| 4440 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4441 | int hdd_set_fw_params(struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4442 | { |
| 4443 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4444 | struct hdd_context *hdd_ctx; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4445 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 4446 | hdd_enter_dev(adapter->dev); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4447 | |
| 4448 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 4449 | if (!hdd_ctx) |
| 4450 | return -EINVAL; |
| 4451 | |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4452 | if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE) { |
| 4453 | hdd_debug("FTM Mode is active; nothing to do"); |
| 4454 | return 0; |
| 4455 | } |
| 4456 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4457 | ret = sme_cli_set_command(adapter->session_id, |
Ashish Kumar Dhanotiya | b8630ab | 2017-07-21 14:18:14 +0530 | [diff] [blame] | 4458 | WMI_PDEV_PARAM_DTIM_SYNTH, |
| 4459 | hdd_ctx->config->enable_lprx, PDEV_CMD); |
| 4460 | if (ret) { |
| 4461 | hdd_err("Failed to set LPRx"); |
| 4462 | goto error; |
| 4463 | } |
| 4464 | |
Ashish Kumar Dhanotiya | 191d164 | 2018-02-08 17:43:09 +0530 | [diff] [blame] | 4465 | |
| 4466 | ret = sme_cli_set_command( |
| 4467 | adapter->session_id, |
| 4468 | WMI_PDEV_PARAM_1CH_DTIM_OPTIMIZED_CHAIN_SELECTION, |
| 4469 | hdd_ctx->config->enable_dtim_selection_diversity, |
| 4470 | PDEV_CMD); |
| 4471 | if (ret) { |
| 4472 | hdd_err("Failed to set DTIM_OPTIMIZED_CHAIN_SELECTION"); |
| 4473 | goto error; |
| 4474 | } |
| 4475 | |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4476 | if (adapter->device_mode == QDF_STA_MODE) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4477 | sme_set_smps_cfg(adapter->session_id, |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4478 | HDD_STA_SMPS_PARAM_UPPER_BRSSI_THRESH, |
| 4479 | hdd_ctx->config->upper_brssi_thresh); |
| 4480 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4481 | sme_set_smps_cfg(adapter->session_id, |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4482 | HDD_STA_SMPS_PARAM_LOWER_BRSSI_THRESH, |
| 4483 | hdd_ctx->config->lower_brssi_thresh); |
| 4484 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4485 | sme_set_smps_cfg(adapter->session_id, |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4486 | HDD_STA_SMPS_PARAM_DTIM_1CHRX_ENABLE, |
| 4487 | hdd_ctx->config->enable_dtim_1chrx); |
| 4488 | } |
| 4489 | |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4490 | if (hdd_ctx->config->enable2x2) { |
| 4491 | hdd_debug("configuring 2x2 mode fw params"); |
| 4492 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4493 | ret = sme_cli_set_command(adapter->session_id, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4494 | WMI_PDEV_PARAM_ENABLE_CCK_TXFIR_OVERRIDE, |
| 4495 | hdd_ctx->config->enable_cck_tx_fir_override, |
| 4496 | PDEV_CMD); |
| 4497 | if (ret) { |
| 4498 | hdd_err("WMI_PDEV_PARAM_ENABLE_CCK_TXFIR_OVERRIDE set failed %d", |
| 4499 | ret); |
| 4500 | goto error; |
| 4501 | } |
| 4502 | } else { |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4503 | #define HDD_DTIM_1CHAIN_RX_ID 0x5 |
| 4504 | #define HDD_SMPS_PARAM_VALUE_S 29 |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4505 | hdd_debug("configuring 1x1 mode fw params"); |
| 4506 | |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4507 | /* |
| 4508 | * Disable DTIM 1 chain Rx when in 1x1, |
| 4509 | * we are passing two value |
| 4510 | * as param_id << 29 | param_value. |
| 4511 | * Below param_value = 0(disable) |
| 4512 | */ |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4513 | ret = sme_cli_set_command(adapter->session_id, |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4514 | WMI_STA_SMPS_PARAM_CMDID, |
| 4515 | HDD_DTIM_1CHAIN_RX_ID << |
| 4516 | HDD_SMPS_PARAM_VALUE_S, |
| 4517 | VDEV_CMD); |
| 4518 | if (ret) { |
| 4519 | hdd_err("DTIM 1 chain set failed %d", ret); |
| 4520 | goto error; |
| 4521 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4522 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4523 | #undef HDD_DTIM_1CHAIN_RX_ID |
| 4524 | #undef HDD_SMPS_PARAM_VALUE_S |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4525 | |
| 4526 | if (hdd_configure_chain_mask(adapter)) |
| 4527 | goto error; |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4528 | } |
| 4529 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4530 | ret = sme_cli_set_command(adapter->session_id, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4531 | WMI_PDEV_PARAM_HYST_EN, |
| 4532 | hdd_ctx->config->enableMemDeepSleep, |
| 4533 | PDEV_CMD); |
| 4534 | if (ret) { |
| 4535 | hdd_err("WMI_PDEV_PARAM_HYST_EN set failed %d", ret); |
| 4536 | goto error; |
| 4537 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4538 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4539 | ret = sme_cli_set_command(adapter->session_id, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4540 | WMI_VDEV_PARAM_ENABLE_RTSCTS, |
| 4541 | hdd_ctx->config->rts_profile, |
| 4542 | VDEV_CMD); |
| 4543 | if (ret) { |
| 4544 | hdd_err("FAILED TO SET RTSCTS Profile ret:%d", ret); |
| 4545 | goto error; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4546 | } |
| 4547 | |
Deepak Dhamdhere | 612392c | 2016-08-28 02:56:51 -0700 | [diff] [blame] | 4548 | hdd_debug("SET AMSDU num %d", hdd_ctx->config->max_amsdu_num); |
| 4549 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4550 | ret = wma_cli_set_command(adapter->session_id, |
Deepak Dhamdhere | 612392c | 2016-08-28 02:56:51 -0700 | [diff] [blame] | 4551 | GEN_VDEV_PARAM_AMSDU, |
| 4552 | hdd_ctx->config->max_amsdu_num, |
| 4553 | GEN_CMD); |
| 4554 | if (ret != 0) { |
| 4555 | hdd_err("GEN_VDEV_PARAM_AMSDU set failed %d", ret); |
| 4556 | goto error; |
| 4557 | } |
| 4558 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4559 | hdd_set_fw_log_params(hdd_ctx, adapter); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4560 | hdd_exit(); |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4561 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4562 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4563 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4564 | error: |
| 4565 | return -EINVAL; |
| 4566 | } |
| 4567 | |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4568 | /** |
| 4569 | * hdd_open_adapter() - open and setup the hdd adatper |
| 4570 | * @hdd_ctx: global hdd context |
| 4571 | * @session_type: type of the interface to be created |
| 4572 | * @iface_name: User-visible name of the interface |
| 4573 | * @macAddr: MAC address to assign to the interface |
| 4574 | * @name_assign_type: the name of assign type of the netdev |
| 4575 | * @rtnl_held: the rtnl lock hold flag |
| 4576 | * |
| 4577 | * This function open and setup the hdd adpater according to the device |
| 4578 | * type request, assign the name, the mac address assigned, and then prepared |
| 4579 | * the hdd related parameters, queue, lock and ready to start. |
| 4580 | * |
| 4581 | * Return: the pointer of hdd adapter, otherwise NULL. |
| 4582 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4583 | 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] | 4584 | const char *iface_name, tSirMacAddr macAddr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4585 | unsigned char name_assign_type, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 4586 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4587 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4588 | struct hdd_adapter *adapter = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4589 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4590 | |
| 4591 | if (hdd_ctx->current_intf_count >= hdd_ctx->max_intf_count) { |
| 4592 | /* |
| 4593 | * Max limit reached on the number of vdevs configured by the |
| 4594 | * host. Return error |
| 4595 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4596 | hdd_err("Unable to add virtual intf: currentVdevCnt=%d,hostConfiguredVdevCnt=%d", |
| 4597 | hdd_ctx->current_intf_count, hdd_ctx->max_intf_count); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4598 | return NULL; |
| 4599 | } |
| 4600 | |
| 4601 | if (macAddr == NULL) { |
| 4602 | /* Not received valid macAddr */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4603 | 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] | 4604 | return NULL; |
| 4605 | } |
| 4606 | status = hdd_check_for_existing_macaddr(hdd_ctx, macAddr); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4607 | if (QDF_STATUS_E_FAILURE == status) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4608 | hdd_err("Duplicate MAC addr: " MAC_ADDRESS_STR |
| 4609 | " already exists", |
| 4610 | MAC_ADDR_ARRAY(macAddr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4611 | return NULL; |
| 4612 | } |
| 4613 | |
| 4614 | switch (session_type) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4615 | case QDF_STA_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4616 | /* Reset locally administered bit if the device mode is STA */ |
| 4617 | WLAN_HDD_RESET_LOCALLY_ADMINISTERED_BIT(macAddr); |
Arunk Khandavalli | 794fdfc | 2017-09-13 18:00:40 +0530 | [diff] [blame] | 4618 | hdd_info("locally administered bit reset in sta mode: " |
| 4619 | MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4620 | /* fall through */ |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4621 | case QDF_P2P_CLIENT_MODE: |
| 4622 | case QDF_P2P_DEVICE_MODE: |
| 4623 | case QDF_OCB_MODE: |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 4624 | case QDF_NDI_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4625 | case QDF_MONITOR_MODE: |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4626 | adapter = hdd_alloc_station_adapter(hdd_ctx, macAddr, |
| 4627 | name_assign_type, |
| 4628 | iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4629 | |
| 4630 | if (NULL == adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4631 | hdd_err("failed to allocate adapter for session %d", |
| 4632 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4633 | return NULL; |
| 4634 | } |
| 4635 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4636 | if (QDF_P2P_CLIENT_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4637 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_CLIENT; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4638 | else if (QDF_P2P_DEVICE_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4639 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_DEVICE; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4640 | else if (QDF_MONITOR_MODE == session_type) |
| 4641 | adapter->wdev.iftype = NL80211_IFTYPE_MONITOR; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4642 | else |
| 4643 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 4644 | |
| 4645 | adapter->device_mode = session_type; |
| 4646 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4647 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4648 | /* |
| 4649 | * Workqueue which gets scheduled in IPv4 notification |
| 4650 | * callback |
| 4651 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4652 | INIT_WORK(&adapter->ipv4_notifier_work, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4653 | hdd_ipv4_notifier_work_queue); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4654 | |
| 4655 | #ifdef WLAN_NS_OFFLOAD |
| 4656 | /* |
| 4657 | * Workqueue which gets scheduled in IPv6 |
| 4658 | * notification callback. |
| 4659 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4660 | INIT_WORK(&adapter->ipv6_notifier_work, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4661 | hdd_ipv6_notifier_work_queue); |
| 4662 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4663 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4664 | if (QDF_STATUS_SUCCESS != status) |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 4665 | goto err_free_netdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4666 | |
| 4667 | /* Stop the Interface TX queue. */ |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4668 | hdd_debug("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4669 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4670 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4671 | WLAN_CONTROL_PATH); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4672 | |
Ravi Joshi | 1a29256 | 2017-05-18 16:28:54 -0700 | [diff] [blame] | 4673 | /* Initialize NAN Data Interface */ |
| 4674 | if (QDF_NDI_MODE == session_type) { |
| 4675 | status = hdd_init_nan_data_mode(adapter); |
| 4676 | if (QDF_STATUS_SUCCESS != status) |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 4677 | goto err_free_netdev; |
Ravi Joshi | 1a29256 | 2017-05-18 16:28:54 -0700 | [diff] [blame] | 4678 | } |
| 4679 | |
| 4680 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4681 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4682 | case QDF_P2P_GO_MODE: |
| 4683 | case QDF_SAP_MODE: |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4684 | adapter = hdd_wlan_create_ap_dev(hdd_ctx, macAddr, |
| 4685 | name_assign_type, |
| 4686 | (uint8_t *) iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4687 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4688 | hdd_err("failed to allocate adapter for session %d", |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4689 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4690 | return NULL; |
| 4691 | } |
| 4692 | |
| 4693 | adapter->wdev.iftype = |
| 4694 | (session_type == |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4695 | QDF_SAP_MODE) ? NL80211_IFTYPE_AP : |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4696 | NL80211_IFTYPE_P2P_GO; |
| 4697 | adapter->device_mode = session_type; |
| 4698 | |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 4699 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4700 | if (QDF_STATUS_SUCCESS != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4701 | goto err_free_netdev; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4702 | |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4703 | hdd_debug("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4704 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4705 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4706 | WLAN_CONTROL_PATH); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4707 | |
| 4708 | /* |
| 4709 | * Workqueue which gets scheduled in IPv4 notification |
| 4710 | * callback |
| 4711 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4712 | INIT_WORK(&adapter->ipv4_notifier_work, |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4713 | hdd_ipv4_notifier_work_queue); |
| 4714 | |
| 4715 | #ifdef WLAN_NS_OFFLOAD |
| 4716 | /* |
| 4717 | * Workqueue which gets scheduled in IPv6 |
| 4718 | * notification callback. |
| 4719 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4720 | INIT_WORK(&adapter->ipv6_notifier_work, |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4721 | hdd_ipv6_notifier_work_queue); |
| 4722 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4723 | break; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4724 | case QDF_FTM_MODE: |
| 4725 | adapter = hdd_alloc_station_adapter(hdd_ctx, macAddr, |
| 4726 | name_assign_type, |
Lin Bai | 1c67848 | 2017-12-18 18:29:11 +0800 | [diff] [blame] | 4727 | iface_name); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4728 | if (NULL == adapter) { |
| 4729 | hdd_err("Failed to allocate adapter for FTM mode"); |
| 4730 | return NULL; |
| 4731 | } |
| 4732 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 4733 | adapter->device_mode = session_type; |
| 4734 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4735 | if (QDF_STATUS_SUCCESS != status) |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 4736 | goto err_free_netdev; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4737 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4738 | /* Stop the Interface TX queue. */ |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4739 | hdd_debug("Disabling queues"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4740 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4741 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4742 | WLAN_CONTROL_PATH); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4743 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4744 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4745 | hdd_err("Invalid session type %d", session_type); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4746 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4747 | return NULL; |
| 4748 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4749 | |
hqu | eaa33ee | 2017-05-04 17:56:35 +0800 | [diff] [blame] | 4750 | INIT_WORK(&adapter->scan_block_work, wlan_hdd_cfg80211_scan_block_cb); |
| 4751 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4752 | if (QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4753 | /* Add it to the hdd's session list. */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4754 | status = hdd_add_adapter_back(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4755 | } |
| 4756 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4757 | if (QDF_STATUS_SUCCESS != status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4758 | if (NULL != adapter) { |
| 4759 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 4760 | adapter = NULL; |
| 4761 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4762 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4763 | return NULL; |
| 4764 | } |
| 4765 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4766 | if (QDF_STATUS_SUCCESS == status) { |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 4767 | policy_mgr_set_concurrency_mode(hdd_ctx->hdd_psoc, |
| 4768 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4769 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4770 | /* Adapter successfully added. Increment the vdev count */ |
| 4771 | hdd_ctx->current_intf_count++; |
| 4772 | |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4773 | hdd_debug("current_intf_count=%d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4774 | hdd_ctx->current_intf_count); |
| 4775 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 4776 | hdd_check_and_restart_sap_with_non_dfs_acs(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4777 | } |
| 4778 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 4779 | if (QDF_STATUS_SUCCESS != hdd_debugfs_init(adapter)) |
Mahesh Kumar Kalikot Veetil | 80dda9a | 2017-07-17 11:38:03 -0700 | [diff] [blame] | 4780 | hdd_err("Interface %s wow debug_fs init failed", |
| 4781 | netdev_name(adapter->dev)); |
| 4782 | |
| 4783 | hdd_info("%s interface created. iftype: %d", netdev_name(adapter->dev), |
| 4784 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4785 | |
| 4786 | return adapter; |
| 4787 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4788 | err_free_netdev: |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 4789 | wlan_hdd_release_intf_addr(hdd_ctx, adapter->mac_addr.bytes); |
Hanumanth Reddy Pothula | 00a39e7 | 2016-11-09 21:32:16 +0530 | [diff] [blame] | 4790 | free_netdev(adapter->dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4791 | |
| 4792 | return NULL; |
| 4793 | } |
| 4794 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 4795 | #ifdef MSM_PLATFORM |
| 4796 | static inline |
| 4797 | void hdd_cancel_bus_bw_work(struct hdd_context *hdd_ctx) |
| 4798 | { |
| 4799 | cancel_work_sync(&hdd_ctx->bus_bw_work); |
| 4800 | } |
| 4801 | #else |
| 4802 | static inline |
| 4803 | void hdd_cancel_bus_bw_work(struct hdd_context *hdd_ctx) |
| 4804 | { |
| 4805 | } |
| 4806 | #endif |
| 4807 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4808 | 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] | 4809 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4810 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4811 | /* |
| 4812 | * Here we are stopping global bus_bw timer & work per adapter. |
| 4813 | * |
| 4814 | * The reason is to fix one race condition between |
| 4815 | * bus bandwidth work and cleaning up an adapter. |
| 4816 | * Under some conditions, it is possible for the bus bandwidth |
| 4817 | * work to access a particularly destroyed adapter, leading to |
| 4818 | * use-after-free. |
| 4819 | */ |
| 4820 | hdd_debug("wait for bus bw work to flush"); |
| 4821 | hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 4822 | hdd_bus_bw_cancel_work(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4823 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4824 | /* cleanup adapter */ |
| 4825 | policy_mgr_clear_concurrency_mode(hdd_ctx->hdd_psoc, |
| 4826 | adapter->device_mode); |
| 4827 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 4828 | hdd_remove_adapter(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4829 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4830 | /* conditionally restart the bw timer */ |
| 4831 | hdd_bus_bw_compute_timer_try_start(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4832 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4833 | /* Adapter removed. Decrement vdev count */ |
| 4834 | if (hdd_ctx->current_intf_count != 0) |
| 4835 | hdd_ctx->current_intf_count--; |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 4836 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4837 | /* Fw will take care incase of concurrency */ |
| 4838 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4839 | } |
| 4840 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 4841 | /** |
| 4842 | * hdd_close_all_adapters - Close all open adapters |
| 4843 | * @hdd_ctx: Hdd context |
| 4844 | * rtnl_held: True if RTNL lock held |
| 4845 | * |
| 4846 | * Close all open adapters. |
| 4847 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 4848 | * Return: QDF status code |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 4849 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4850 | 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] | 4851 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4852 | struct hdd_adapter *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4853 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4854 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 4855 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4856 | |
| 4857 | do { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4858 | status = hdd_remove_front_adapter(hdd_ctx, &adapter); |
| 4859 | if (QDF_IS_STATUS_SUCCESS(status)) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4860 | wlan_hdd_release_intf_addr(hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4861 | adapter->mac_addr.bytes); |
| 4862 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 4863 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4864 | /* Adapter removed. Decrement vdev count */ |
| 4865 | if (hdd_ctx->current_intf_count != 0) |
| 4866 | hdd_ctx->current_intf_count--; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4867 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4868 | } while (QDF_IS_STATUS_SUCCESS(status)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4869 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4870 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4871 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4872 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4873 | } |
| 4874 | |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4875 | void wlan_hdd_reset_prob_rspies(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4876 | { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4877 | struct qdf_mac_addr *bssid = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4878 | tSirUpdateIE updateIE; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4879 | |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4880 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4881 | case QDF_STA_MODE: |
| 4882 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4883 | { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4884 | struct hdd_station_ctx *sta_ctx = |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4885 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4886 | bssid = &sta_ctx->conn_info.bssId; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4887 | break; |
| 4888 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4889 | case QDF_SAP_MODE: |
| 4890 | case QDF_P2P_GO_MODE: |
| 4891 | case QDF_IBSS_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4892 | { |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 4893 | bssid = &adapter->mac_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4894 | break; |
| 4895 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4896 | case QDF_FTM_MODE: |
| 4897 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4898 | default: |
| 4899 | /* |
| 4900 | * wlan_hdd_reset_prob_rspies should not have been called |
| 4901 | * for these kind of devices |
| 4902 | */ |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4903 | hdd_err("Unexpected request for the current device type %d", |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4904 | adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4905 | return; |
| 4906 | } |
| 4907 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 4908 | qdf_copy_macaddr(&updateIE.bssid, bssid); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4909 | updateIE.smeSessionId = adapter->session_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4910 | updateIE.ieBufferlength = 0; |
| 4911 | updateIE.pAdditionIEBuffer = NULL; |
| 4912 | updateIE.append = true; |
| 4913 | updateIE.notify = false; |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4914 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(adapter), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4915 | &updateIE, |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4916 | eUPDATE_IE_PROBE_RESP) == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4917 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4918 | } |
| 4919 | } |
| 4920 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 4921 | QDF_STATUS hdd_stop_adapter(struct hdd_context *hdd_ctx, |
| 4922 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4923 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 4924 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 4925 | struct csr_roam_profile *roam_profile; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4926 | union iwreq_data wrqu; |
| 4927 | tSirUpdateIE updateIE; |
| 4928 | unsigned long rc; |
Arunk Khandavalli | 96c122f | 2017-10-17 11:49:36 +0530 | [diff] [blame] | 4929 | tsap_Config_t *sap_config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4930 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 4931 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4932 | |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4933 | hdd_debug("Disabling queues"); |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4934 | wlan_hdd_netif_queue_control(adapter, |
| 4935 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4936 | WLAN_CONTROL_PATH); |
Tushnim Bhattacharyya | 9bd058f | 2017-12-27 14:01:31 -0800 | [diff] [blame] | 4937 | /* |
| 4938 | * if this is the last active connection check & stop the |
| 4939 | * opportunistic timer first |
| 4940 | */ |
| 4941 | if (((policy_mgr_get_connection_count(hdd_ctx->hdd_psoc) == 1) && |
| 4942 | (policy_mgr_mode_specific_connection_count(hdd_ctx->hdd_psoc, |
| 4943 | policy_mgr_convert_device_mode_to_qdf_type( |
| 4944 | adapter->device_mode), NULL) == 1)) || |
| 4945 | !policy_mgr_get_connection_count(hdd_ctx->hdd_psoc)) |
| 4946 | policy_mgr_check_and_stop_opportunistic_timer( |
| 4947 | hdd_ctx->hdd_psoc, adapter->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4948 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4949 | case QDF_STA_MODE: |
| 4950 | case QDF_P2P_CLIENT_MODE: |
| 4951 | case QDF_IBSS_MODE: |
| 4952 | case QDF_P2P_DEVICE_MODE: |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4953 | case QDF_NDI_MODE: |
| 4954 | if ((QDF_NDI_MODE == adapter->device_mode) || |
| 4955 | hdd_conn_is_connected( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4956 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)) || |
| 4957 | hdd_is_connecting( |
| 4958 | WLAN_HDD_GET_STATION_CTX_PTR(adapter))) { |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4959 | INIT_COMPLETION(adapter->disconnect_comp_var); |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 4960 | roam_profile = hdd_roam_profile(adapter); |
| 4961 | /* For NDI do not use roam_profile */ |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4962 | if (QDF_NDI_MODE == adapter->device_mode) |
| 4963 | qdf_ret_status = sme_roam_disconnect( |
| 4964 | hdd_ctx->hHal, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4965 | adapter->session_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4966 | eCSR_DISCONNECT_REASON_NDI_DELETE); |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 4967 | else if (roam_profile->BSSType == |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4968 | eCSR_BSS_TYPE_START_IBSS) |
| 4969 | qdf_ret_status = sme_roam_disconnect( |
| 4970 | hdd_ctx->hHal, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4971 | adapter->session_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4972 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
Jingxiang Ge | cc7e1f4 | 2017-11-14 16:21:27 +0800 | [diff] [blame] | 4973 | else if (QDF_STA_MODE == adapter->device_mode) { |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 4974 | qdf_ret_status = |
| 4975 | wlan_hdd_try_disconnect(adapter); |
Jingxiang Ge | cc7e1f4 | 2017-11-14 16:21:27 +0800 | [diff] [blame] | 4976 | hdd_debug("Send disconnected event to userspace"); |
| 4977 | wlan_hdd_cfg80211_indicate_disconnect( |
| 4978 | adapter->dev, true, |
| 4979 | WLAN_REASON_UNSPECIFIED); |
Jeff Johnson | 109e79d | 2018-02-27 15:10:04 -0800 | [diff] [blame] | 4980 | } else |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4981 | qdf_ret_status = sme_roam_disconnect( |
| 4982 | hdd_ctx->hHal, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4983 | adapter->session_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4984 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4985 | /* success implies disconnect command got |
| 4986 | * queued up successfully |
| 4987 | */ |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 4988 | if (qdf_ret_status == QDF_STATUS_SUCCESS && |
| 4989 | QDF_STA_MODE != adapter->device_mode) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4990 | rc = wait_for_completion_timeout( |
| 4991 | &adapter->disconnect_comp_var, |
| 4992 | msecs_to_jiffies |
| 4993 | (WLAN_WAIT_TIME_DISCONNECT)); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4994 | if (!rc) |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 4995 | hdd_warn("disconn_comp_var wait fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4996 | } |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 4997 | if (qdf_ret_status != QDF_STATUS_SUCCESS) |
| 4998 | hdd_warn("failed to post disconnect"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4999 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 5000 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 5001 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 5002 | wireless_send_event(adapter->dev, SIOCGIWAP, &wrqu, |
| 5003 | NULL); |
Sachin Ahuja | 988fd10 | 2016-09-15 17:16:25 +0530 | [diff] [blame] | 5004 | } |
Wu Gao | aceec6c | 2017-08-30 16:08:21 +0800 | [diff] [blame] | 5005 | wlan_hdd_scan_abort(adapter); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5006 | |
Abhishek Singh | 1e94d7a | 2015-11-30 17:26:54 +0530 | [diff] [blame] | 5007 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 5008 | hdd_clear_fils_connection_info(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5009 | |
| 5010 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5011 | cancel_work_sync(&adapter->ipv4_notifier_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5012 | #endif |
| 5013 | |
| 5014 | hdd_deregister_tx_flow_control(adapter); |
| 5015 | |
| 5016 | #ifdef WLAN_NS_OFFLOAD |
| 5017 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5018 | cancel_work_sync(&adapter->ipv6_notifier_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5019 | #endif |
| 5020 | #endif |
| 5021 | |
Hanumanth Reddy Pothula | 0586014 | 2017-07-26 18:45:27 +0530 | [diff] [blame] | 5022 | if (adapter->device_mode == QDF_STA_MODE) |
| 5023 | wlan_cfg80211_sched_scan_stop(hdd_ctx->hdd_pdev, |
| 5024 | adapter->dev); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5025 | |
| 5026 | if (wlan_hdd_try_disconnect(adapter)) { |
| 5027 | hdd_err("Error: Can't disconnect adapter"); |
| 5028 | return QDF_STATUS_E_FAILURE; |
Krunal Soni | 985b813 | 2017-02-10 18:49:08 -0800 | [diff] [blame] | 5029 | } |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5030 | |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 5031 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5032 | break; |
| 5033 | |
Rajeev Kumar | 3b90620 | 2018-02-01 10:55:14 -0800 | [diff] [blame] | 5034 | case QDF_MONITOR_MODE: |
| 5035 | wlan_hdd_scan_abort(adapter); |
| 5036 | hdd_deregister_tx_flow_control(adapter); |
| 5037 | hdd_vdev_destroy(adapter); |
| 5038 | break; |
| 5039 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5040 | case QDF_SAP_MODE: |
wadesong | f9b15ed | 2017-12-14 14:12:32 +0800 | [diff] [blame] | 5041 | wlan_hdd_scan_abort(adapter); |
Govind Singh | 1dab23b | 2017-08-12 13:31:00 +0530 | [diff] [blame] | 5042 | /* Flush IPA exception path packets */ |
Arunk Khandavalli | 96c122f | 2017-10-17 11:49:36 +0530 | [diff] [blame] | 5043 | sap_config = &adapter->session.ap.sap_config; |
| 5044 | if (sap_config) |
| 5045 | wlansap_reset_sap_config_add_ie(sap_config, |
| 5046 | eUPDATE_IE_ALL); |
Govind Singh | 1dab23b | 2017-08-12 13:31:00 +0530 | [diff] [blame] | 5047 | hdd_ipa_flush(hdd_ctx); |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 5048 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 5049 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5050 | case QDF_P2P_GO_MODE: |
Kiran Kumar Lokere | 85cb36b | 2017-09-14 15:19:14 -0700 | [diff] [blame] | 5051 | if (QDF_SAP_MODE == adapter->device_mode) { |
| 5052 | if (test_bit(ACS_PENDING, &adapter->event_flags)) { |
| 5053 | cds_flush_delayed_work( |
| 5054 | &adapter->acs_pending_work); |
| 5055 | clear_bit(ACS_PENDING, &adapter->event_flags); |
| 5056 | } |
| 5057 | } |
Krunal Soni | 2220839 | 2017-09-29 18:10:34 -0700 | [diff] [blame] | 5058 | cds_flush_work(&adapter->sap_stop_bss_work); |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 5059 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5060 | /* Any softap specific cleanup here... */ |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 5061 | wlan_hdd_undo_acs(adapter); |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5062 | if (adapter->device_mode == QDF_P2P_GO_MODE) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5063 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 5064 | |
| 5065 | hdd_deregister_tx_flow_control(adapter); |
| 5066 | |
Kapil Gupta | c1224bf | 2017-06-22 21:22:40 +0530 | [diff] [blame] | 5067 | hdd_destroy_acs_timer(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5068 | mutex_lock(&hdd_ctx->sap_lock); |
| 5069 | if (test_bit(SOFTAP_BSS_STARTED, &adapter->event_flags)) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5070 | QDF_STATUS status; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 5071 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5072 | |
| 5073 | /* Stop Bss. */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5074 | status = wlansap_stop_bss( |
| 5075 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5076 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5077 | if (QDF_IS_STATUS_SUCCESS(status)) { |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 5078 | struct hdd_hostapd_state *hostapd_state = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5079 | WLAN_HDD_GET_HOSTAP_STATE_PTR(adapter); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 5080 | qdf_event_reset(&hostapd_state-> |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 5081 | qdf_stop_bss_event); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 5082 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 5083 | qdf_wait_for_event_completion( |
| 5084 | &hostapd_state->qdf_stop_bss_event, |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 5085 | SME_CMD_TIMEOUT_VALUE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5086 | |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 5087 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5088 | hdd_err("failure waiting for wlansap_stop_bss %d", |
| 5089 | qdf_status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5090 | } |
| 5091 | } else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5092 | hdd_err("failure in wlansap_stop_bss"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5093 | } |
| 5094 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 5095 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
| 5096 | adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5097 | adapter->session_id); |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 5098 | hdd_start_green_ap_state_mc(hdd_ctx, |
| 5099 | adapter->device_mode, |
| 5100 | false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5101 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 5102 | qdf_copy_macaddr(&updateIE.bssid, |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 5103 | &adapter->mac_addr); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5104 | updateIE.smeSessionId = adapter->session_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5105 | updateIE.ieBufferlength = 0; |
| 5106 | updateIE.pAdditionIEBuffer = NULL; |
| 5107 | updateIE.append = false; |
| 5108 | updateIE.notify = false; |
| 5109 | /* Probe bcn reset */ |
| 5110 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(adapter), |
| 5111 | &updateIE, eUPDATE_IE_PROBE_BCN) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5112 | == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5113 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5114 | } |
| 5115 | /* Assoc resp reset */ |
| 5116 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(adapter), |
| 5117 | &updateIE, |
| 5118 | eUPDATE_IE_ASSOC_RESP) == |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5119 | QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5120 | hdd_err("Could not pass on ASSOC_RSP data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5121 | } |
| 5122 | /* Reset WNI_CFG_PROBE_RSP Flags */ |
| 5123 | wlan_hdd_reset_prob_rspies(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5124 | } |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 5125 | qdf_mem_free(adapter->session.ap.beacon); |
| 5126 | adapter->session.ap.beacon = NULL; |
Ajit Pal Singh | 747b680 | 2017-05-24 15:42:03 +0530 | [diff] [blame] | 5127 | /* |
| 5128 | * If Do_Not_Break_Stream was enabled clear avoid channel list. |
| 5129 | */ |
| 5130 | if (policy_mgr_is_dnsc_set(adapter->hdd_vdev)) |
| 5131 | wlan_hdd_send_avoid_freq_for_dnbs(hdd_ctx, 0); |
| 5132 | |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5133 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5134 | cancel_work_sync(&adapter->ipv4_notifier_work); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5135 | #endif |
| 5136 | |
| 5137 | #ifdef WLAN_NS_OFFLOAD |
| 5138 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5139 | cancel_work_sync(&adapter->ipv6_notifier_work); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5140 | #endif |
| 5141 | #endif |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5142 | |
| 5143 | hdd_vdev_destroy(adapter); |
| 5144 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5145 | mutex_unlock(&hdd_ctx->sap_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5146 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5147 | case QDF_OCB_MODE: |
Krishna Kumaar Natarajan | e58b409 | 2017-01-25 15:47:35 -0800 | [diff] [blame] | 5148 | cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC), |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 5149 | (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX), |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 5150 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)->conn_info.staId[0]); |
Zhang Qian | 79d0d13 | 2018-02-05 13:40:16 +0800 | [diff] [blame] | 5151 | hdd_deregister_tx_flow_control(adapter); |
| 5152 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5153 | break; |
| 5154 | default: |
| 5155 | break; |
| 5156 | } |
| 5157 | |
Dustin Brown | 0434837 | 2017-12-14 16:13:39 -0800 | [diff] [blame] | 5158 | if (adapter->scan_info.default_scan_ies) { |
| 5159 | qdf_mem_free(adapter->scan_info.default_scan_ies); |
| 5160 | adapter->scan_info.default_scan_ies = NULL; |
| 5161 | } |
| 5162 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5163 | hdd_exit(); |
Dustin Brown | 0434837 | 2017-12-14 16:13:39 -0800 | [diff] [blame] | 5164 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5165 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5166 | } |
| 5167 | |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5168 | /** |
| 5169 | * hdd_deinit_all_adapters - deinit all adapters |
| 5170 | * @hdd_ctx: HDD context |
| 5171 | * @rtnl_held: True if RTNL lock held |
| 5172 | * |
| 5173 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5174 | 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] | 5175 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5176 | struct hdd_adapter *adapter; |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5177 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5178 | hdd_enter(); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5179 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5180 | hdd_for_each_adapter(hdd_ctx, adapter) |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5181 | hdd_deinit_adapter(hdd_ctx, adapter, rtnl_held); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5182 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5183 | hdd_exit(); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5184 | } |
| 5185 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5186 | QDF_STATUS hdd_stop_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5187 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5188 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5189 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5190 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5191 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 5192 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 5193 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5194 | hdd_for_each_adapter(hdd_ctx, adapter) |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5195 | hdd_stop_adapter(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5196 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5197 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5198 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5199 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5200 | } |
| 5201 | |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5202 | static void hdd_reset_scan_operation(struct hdd_context *hdd_ctx, |
| 5203 | struct hdd_adapter *adapter) |
| 5204 | { |
| 5205 | switch (adapter->device_mode) { |
| 5206 | case QDF_STA_MODE: |
| 5207 | case QDF_P2P_CLIENT_MODE: |
| 5208 | case QDF_IBSS_MODE: |
| 5209 | case QDF_P2P_DEVICE_MODE: |
| 5210 | case QDF_NDI_MODE: |
| 5211 | wlan_hdd_scan_abort(adapter); |
| 5212 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 5213 | if (adapter->device_mode == QDF_STA_MODE) |
| 5214 | wlan_cfg80211_sched_scan_stop(hdd_ctx->hdd_pdev, |
| 5215 | adapter->dev); |
| 5216 | break; |
| 5217 | case QDF_P2P_GO_MODE: |
| 5218 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 5219 | break; |
| 5220 | case QDF_SAP_MODE: |
| 5221 | wlan_hdd_undo_acs(adapter); |
| 5222 | break; |
| 5223 | default: |
| 5224 | break; |
| 5225 | } |
| 5226 | } |
| 5227 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5228 | QDF_STATUS hdd_reset_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5229 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5230 | struct hdd_adapter *adapter; |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5231 | struct hdd_station_ctx *sta_ctx; |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5232 | struct qdf_mac_addr peerMacAddr; |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5233 | int sta_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5234 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5235 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5236 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 5237 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 5238 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5239 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 5240 | hdd_info("[SSR] reset adapter with device mode %s(%d)", |
| 5241 | hdd_device_mode_to_string(adapter->device_mode), |
| 5242 | adapter->device_mode); |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 5243 | |
| 5244 | if ((adapter->device_mode == QDF_STA_MODE) || |
Paul Zhang | 679025e | 2018-03-08 22:39:44 +0800 | [diff] [blame] | 5245 | (adapter->device_mode == QDF_P2P_CLIENT_MODE)) { |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 5246 | /* Stop tdls timers */ |
Kabilan Kannan | 00d2041 | 2017-06-04 14:20:32 -0700 | [diff] [blame] | 5247 | hdd_notify_tdls_reset_adapter(adapter->hdd_vdev); |
Paul Zhang | 679025e | 2018-03-08 22:39:44 +0800 | [diff] [blame] | 5248 | adapter->session.station.hdd_reassoc_scenario = false; |
| 5249 | } |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 5250 | |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5251 | if (hdd_ctx->config->sap_internal_restart && |
| 5252 | adapter->device_mode == QDF_SAP_MODE) { |
| 5253 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5254 | WLAN_STOP_ALL_NETIF_QUEUE, |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5255 | WLAN_CONTROL_PATH); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5256 | if (test_bit(SOFTAP_BSS_STARTED, |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5257 | &adapter->event_flags)) |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5258 | hdd_sap_indicate_disconnect_for_sta(adapter); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5259 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
| 5260 | } else { |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5261 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5262 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5263 | WLAN_CONTROL_PATH); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5264 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5265 | |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5266 | hdd_reset_scan_operation(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5267 | |
| 5268 | hdd_deinit_tx_rx(adapter); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 5269 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5270 | adapter->device_mode, adapter->session_id); |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 5271 | hdd_start_green_ap_state_mc(hdd_ctx, adapter->device_mode, |
| 5272 | false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5273 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 5274 | hdd_wmm_adapter_close(adapter); |
| 5275 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 5276 | } |
| 5277 | |
Vignesh Viswanathan | 2eb1874 | 2017-09-08 11:18:59 +0530 | [diff] [blame] | 5278 | if (adapter->device_mode == QDF_STA_MODE) |
| 5279 | hdd_clear_fils_connection_info(adapter); |
| 5280 | |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 5281 | if (adapter->device_mode == QDF_SAP_MODE) { |
| 5282 | /* |
| 5283 | * If adapter is SAP, set session ID to invalid |
| 5284 | * since SAP session will be cleanup during SSR. |
| 5285 | */ |
Wu Gao | 3671743 | 2016-11-21 15:09:48 +0800 | [diff] [blame] | 5286 | wlansap_set_invalid_session( |
| 5287 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
| 5288 | |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 5289 | wlansap_cleanup_cac_timer( |
| 5290 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
| 5291 | } |
| 5292 | |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5293 | /* Delete connection peers if any to avoid peer object leaks */ |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5294 | if (adapter->device_mode == QDF_STA_MODE || |
| 5295 | adapter->device_mode == QDF_P2P_CLIENT_MODE) { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5296 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5297 | qdf_copy_macaddr(&peerMacAddr, |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5298 | &sta_ctx->conn_info.bssId); |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5299 | |
| 5300 | hdd_objmgr_remove_peer_object(adapter->hdd_vdev, |
| 5301 | peerMacAddr.bytes); |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5302 | } else if (adapter->device_mode == QDF_P2P_GO_MODE) { |
| 5303 | for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; sta_id++) { |
| 5304 | if (adapter->sta_info[sta_id].in_use) { |
| 5305 | hdd_debug("[SSR] deregister STA with ID %d", |
| 5306 | sta_id); |
| 5307 | hdd_softap_deregister_sta(adapter, |
| 5308 | sta_id); |
| 5309 | adapter->sta_info[sta_id].in_use = 0; |
| 5310 | } |
| 5311 | } |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5312 | } |
| 5313 | |
Tiger Yu | 94a5a5c | 2018-03-09 21:22:26 +0800 | [diff] [blame] | 5314 | hdd_softap_deinit_tx_rx(adapter); |
| 5315 | |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 5316 | /* Destroy vdev which will be recreated during reinit. */ |
| 5317 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5318 | } |
| 5319 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5320 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5321 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5322 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5323 | } |
| 5324 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5325 | bool hdd_check_for_opened_interfaces(struct hdd_context *hdd_ctx) |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5326 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5327 | struct hdd_adapter *adapter; |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5328 | bool close_modules = true; |
| 5329 | |
Arun Khandavalli | ba479c4 | 2017-07-26 21:29:40 +0530 | [diff] [blame] | 5330 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 5331 | hdd_info("FTM mode, don't close the module"); |
| 5332 | return false; |
| 5333 | } |
| 5334 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5335 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 5336 | if (test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags) || |
| 5337 | test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5338 | hdd_debug("Still other ifaces are up cannot close modules"); |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5339 | close_modules = false; |
| 5340 | break; |
| 5341 | } |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5342 | } |
| 5343 | |
| 5344 | return close_modules; |
| 5345 | } |
| 5346 | |
yeshwanth sriram guntuka | ea63f63 | 2017-08-30 19:31:56 +0530 | [diff] [blame] | 5347 | bool hdd_is_interface_up(struct hdd_adapter *adapter) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5348 | { |
| 5349 | if (test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) |
| 5350 | return true; |
| 5351 | else |
| 5352 | return false; |
| 5353 | } |
| 5354 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5355 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)) \ |
bings | bdcd4a2 | 2017-06-20 09:27:00 +0800 | [diff] [blame] | 5356 | && !defined(WITH_BACKPORTS) && !defined(IEEE80211_PRIVACY) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5357 | struct cfg80211_bss *hdd_cfg80211_get_bss(struct wiphy *wiphy, |
| 5358 | struct ieee80211_channel *channel, |
| 5359 | const u8 *bssid, const u8 *ssid, |
| 5360 | size_t ssid_len) |
| 5361 | { |
| 5362 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 5363 | ssid, ssid_len, |
| 5364 | WLAN_CAPABILITY_ESS, |
| 5365 | WLAN_CAPABILITY_ESS); |
| 5366 | } |
| 5367 | #else |
| 5368 | struct cfg80211_bss *hdd_cfg80211_get_bss(struct wiphy *wiphy, |
| 5369 | struct ieee80211_channel *channel, |
| 5370 | const u8 *bssid, const u8 *ssid, |
| 5371 | size_t ssid_len) |
| 5372 | { |
| 5373 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 5374 | ssid, ssid_len, |
| 5375 | IEEE80211_BSS_TYPE_ESS, |
| 5376 | IEEE80211_PRIVACY_ANY); |
| 5377 | } |
| 5378 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5379 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5380 | #if defined CFG80211_CONNECT_BSS || \ |
| 5381 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5382 | #if defined CFG80211_CONNECT_TIMEOUT_REASON_CODE || \ |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5383 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5384 | /** |
| 5385 | * hdd_convert_timeout_reason() - Convert to kernel specific enum |
| 5386 | * @timeout_reason: reason for connect timeout |
| 5387 | * |
| 5388 | * This function is used to convert host timeout |
| 5389 | * reason enum to kernel specific enum. |
| 5390 | * |
| 5391 | * Return: nl timeout enum |
| 5392 | */ |
| 5393 | static enum nl80211_timeout_reason hdd_convert_timeout_reason( |
| 5394 | tSirResultCodes timeout_reason) |
| 5395 | { |
| 5396 | switch (timeout_reason) { |
| 5397 | case eSIR_SME_JOIN_TIMEOUT_RESULT_CODE: |
| 5398 | return NL80211_TIMEOUT_SCAN; |
| 5399 | case eSIR_SME_AUTH_TIMEOUT_RESULT_CODE: |
| 5400 | return NL80211_TIMEOUT_AUTH; |
| 5401 | case eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE: |
| 5402 | return NL80211_TIMEOUT_ASSOC; |
| 5403 | default: |
| 5404 | return NL80211_TIMEOUT_UNSPECIFIED; |
| 5405 | } |
| 5406 | } |
| 5407 | |
| 5408 | /** |
| 5409 | * hdd_cfg80211_connect_timeout() - API to send connection timeout reason |
| 5410 | * @dev: network device |
| 5411 | * @bssid: bssid to which we want to associate |
| 5412 | * @timeout_reason: reason for connect timeout |
| 5413 | * |
| 5414 | * This API is used to send connection timeout reason to supplicant |
| 5415 | * |
| 5416 | * Return: void |
| 5417 | */ |
| 5418 | static void hdd_cfg80211_connect_timeout(struct net_device *dev, |
| 5419 | const u8 *bssid, |
| 5420 | tSirResultCodes timeout_reason) |
| 5421 | { |
| 5422 | enum nl80211_timeout_reason nl_timeout_reason; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5423 | |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5424 | nl_timeout_reason = hdd_convert_timeout_reason(timeout_reason); |
| 5425 | |
| 5426 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL, |
| 5427 | nl_timeout_reason); |
| 5428 | } |
| 5429 | |
| 5430 | /** |
| 5431 | * __hdd_connect_bss() - API to send connection status to supplicant |
| 5432 | * @dev: network device |
| 5433 | * @bssid: bssid to which we want to associate |
| 5434 | * @req_ie: Request Information Element |
| 5435 | * @req_ie_len: len of the req IE |
| 5436 | * @resp_ie: Response IE |
| 5437 | * @resp_ie_len: len of ht response IE |
| 5438 | * @status: status |
| 5439 | * @gfp: Kernel Flag |
| 5440 | * @timeout_reason: reason for connect timeout |
| 5441 | * |
| 5442 | * Return: void |
| 5443 | */ |
| 5444 | static void __hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5445 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5446 | size_t req_ie_len, const u8 *resp_ie, |
| 5447 | size_t resp_ie_len, int status, gfp_t gfp, |
| 5448 | tSirResultCodes timeout_reason) |
| 5449 | { |
| 5450 | enum nl80211_timeout_reason nl_timeout_reason; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5451 | |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5452 | nl_timeout_reason = hdd_convert_timeout_reason(timeout_reason); |
| 5453 | |
| 5454 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 5455 | resp_ie, resp_ie_len, status, gfp, |
| 5456 | nl_timeout_reason); |
| 5457 | } |
| 5458 | #else |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5459 | #if defined CFG80211_CONNECT_TIMEOUT || \ |
| 5460 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5461 | static void hdd_cfg80211_connect_timeout(struct net_device *dev, |
| 5462 | const u8 *bssid, |
| 5463 | tSirResultCodes timeout_reason) |
| 5464 | { |
| 5465 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL); |
| 5466 | } |
| 5467 | #endif |
| 5468 | |
| 5469 | static void __hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5470 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5471 | size_t req_ie_len, const u8 *resp_ie, |
| 5472 | size_t resp_ie_len, int status, gfp_t gfp, |
| 5473 | tSirResultCodes timeout_reason) |
| 5474 | { |
| 5475 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 5476 | resp_ie, resp_ie_len, status, gfp); |
| 5477 | } |
| 5478 | #endif |
| 5479 | |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5480 | /** |
| 5481 | * hdd_connect_bss() - API to send connection status to supplicant |
| 5482 | * @dev: network device |
| 5483 | * @bssid: bssid to which we want to associate |
| 5484 | * @req_ie: Request Information Element |
| 5485 | * @req_ie_len: len of the req IE |
| 5486 | * @resp_ie: Response IE |
| 5487 | * @resp_ie_len: len of ht response IE |
| 5488 | * @status: status |
| 5489 | * @gfp: Kernel Flag |
| 5490 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5491 | * @timeout_reason: reason for connect timeout |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5492 | * |
| 5493 | * The API is a wrapper to send connection status to supplicant |
| 5494 | * |
| 5495 | * Return: Void |
| 5496 | */ |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5497 | #if defined CFG80211_CONNECT_TIMEOUT || \ |
| 5498 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5499 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5500 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5501 | size_t req_ie_len, const u8 *resp_ie, |
| 5502 | size_t resp_ie_len, int status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5503 | bool connect_timeout, |
| 5504 | tSirResultCodes timeout_reason) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5505 | { |
| 5506 | if (connect_timeout) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5507 | hdd_cfg80211_connect_timeout(dev, bssid, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5508 | else |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5509 | __hdd_connect_bss(dev, bssid, bss, req_ie, req_ie_len, resp_ie, |
| 5510 | resp_ie_len, status, gfp, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5511 | } |
| 5512 | #else |
| 5513 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5514 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5515 | size_t req_ie_len, const u8 *resp_ie, |
| 5516 | size_t resp_ie_len, int status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5517 | bool connect_timeout, |
| 5518 | tSirResultCodes timeout_reason) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5519 | { |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5520 | __hdd_connect_bss(dev, bssid, bss, req_ie, req_ie_len, resp_ie, |
| 5521 | resp_ie_len, status, gfp, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5522 | } |
| 5523 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5524 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5525 | #if defined(WLAN_FEATURE_FILS_SK) |
| 5526 | #if defined(CFG80211_CONNECT_DONE) || \ |
| 5527 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)) |
| 5528 | #if defined(CFG80211_FILS_SK_OFFLOAD_SUPPORT) || \ |
| 5529 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5530 | /** |
| 5531 | * hdd_populate_fils_params() - Populate FILS keys to connect response |
| 5532 | * @fils_params: connect response to supplicant |
| 5533 | * @fils_kek: FILS kek |
| 5534 | * @fils_kek_len: FILS kek length |
| 5535 | * @pmk: FILS PMK |
| 5536 | * @pmk_len: FILS PMK length |
| 5537 | * @pmkid: PMKID |
| 5538 | * @fils_seq_num: FILS Seq number |
| 5539 | * |
| 5540 | * Return: None |
| 5541 | */ |
| 5542 | static void hdd_populate_fils_params(struct cfg80211_connect_resp_params |
| 5543 | *fils_params, const uint8_t *fils_kek, |
| 5544 | size_t fils_kek_len, const uint8_t *pmk, |
| 5545 | size_t pmk_len, const uint8_t *pmkid, |
| 5546 | uint16_t fils_seq_num) |
| 5547 | { |
| 5548 | /* Increament seq number to be used for next FILS */ |
| 5549 | fils_params->fils_erp_next_seq_num = fils_seq_num + 1; |
| 5550 | fils_params->update_erp_next_seq_num = true; |
| 5551 | fils_params->fils_kek = fils_kek; |
| 5552 | fils_params->fils_kek_len = fils_kek_len; |
| 5553 | fils_params->pmk = pmk; |
| 5554 | fils_params->pmk_len = pmk_len; |
| 5555 | fils_params->pmkid = pmkid; |
| 5556 | } |
| 5557 | #else |
| 5558 | static inline void hdd_populate_fils_params(struct cfg80211_connect_resp_params |
| 5559 | *fils_params, const uint8_t |
| 5560 | *fils_kek, size_t fils_kek_len, |
| 5561 | const uint8_t *pmk, size_t pmk_len, |
| 5562 | const uint8_t *pmkid, |
| 5563 | uint16_t fils_seq_num) |
| 5564 | { } |
| 5565 | #endif |
| 5566 | |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5567 | void hdd_update_hlp_info(struct net_device *dev, |
| 5568 | struct csr_roam_info *roam_info) |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5569 | { |
| 5570 | struct sk_buff *skb; |
| 5571 | uint16_t skb_len; |
| 5572 | struct llc_snap_hdr_t *llc_hdr; |
| 5573 | QDF_STATUS status; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5574 | uint8_t *hlp_data; |
| 5575 | uint16_t hlp_data_len; |
| 5576 | struct fils_join_rsp_params *roam_fils_params |
| 5577 | = roam_info->fils_join_rsp; |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5578 | struct hdd_adapter *padapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5579 | |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5580 | if (!roam_fils_params) { |
| 5581 | hdd_err("FILS Roam Param NULL"); |
| 5582 | return; |
| 5583 | } |
| 5584 | |
Srinivas Girigowda | 3cc8e91 | 2017-11-28 18:11:57 -0800 | [diff] [blame] | 5585 | if (!roam_fils_params->hlp_data_len) { |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5586 | hdd_err("FILS HLP Data NULL, len %d", |
| 5587 | roam_fils_params->hlp_data_len); |
| 5588 | return; |
| 5589 | } |
| 5590 | |
| 5591 | hlp_data = roam_fils_params->hlp_data; |
| 5592 | hlp_data_len = roam_fils_params->hlp_data_len; |
| 5593 | |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5594 | /* Calculate skb length */ |
| 5595 | skb_len = (2 * ETH_ALEN) + hlp_data_len; |
| 5596 | skb = qdf_nbuf_alloc(NULL, skb_len, 0, 4, false); |
| 5597 | if (skb == NULL) { |
| 5598 | hdd_err("HLP packet nbuf alloc fails"); |
| 5599 | return; |
| 5600 | } |
| 5601 | |
| 5602 | qdf_mem_copy(skb_put(skb, ETH_ALEN), roam_fils_params->dst_mac.bytes, |
| 5603 | QDF_MAC_ADDR_SIZE); |
| 5604 | qdf_mem_copy(skb_put(skb, ETH_ALEN), roam_fils_params->src_mac.bytes, |
| 5605 | QDF_MAC_ADDR_SIZE); |
| 5606 | |
| 5607 | llc_hdr = (struct llc_snap_hdr_t *) hlp_data; |
| 5608 | if (IS_SNAP(llc_hdr)) { |
| 5609 | hlp_data += LLC_SNAP_HDR_OFFSET_ETHERTYPE; |
| 5610 | hlp_data_len += LLC_SNAP_HDR_OFFSET_ETHERTYPE; |
| 5611 | } |
| 5612 | |
| 5613 | qdf_mem_copy(skb_put(skb, hlp_data_len), hlp_data, hlp_data_len); |
| 5614 | |
| 5615 | /* |
| 5616 | * This HLP packet is formed from HLP info encapsulated |
| 5617 | * in assoc response frame which is AEAD encrypted. |
| 5618 | * Hence, this checksum validation can be set unnecessary. |
| 5619 | * i.e. network layer need not worry about checksum. |
| 5620 | */ |
| 5621 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
| 5622 | |
| 5623 | status = hdd_rx_packet_cbk(padapter, skb); |
| 5624 | if (QDF_IS_STATUS_ERROR(status)) { |
| 5625 | hdd_err("Sending HLP packet fails"); |
| 5626 | return; |
| 5627 | } |
| 5628 | hdd_debug("send HLP packet to netif successfully"); |
| 5629 | } |
| 5630 | |
| 5631 | /** |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5632 | * hdd_connect_done() - Wrapper API to call cfg80211_connect_done |
| 5633 | * @dev: network device |
| 5634 | * @bssid: bssid to which we want to associate |
| 5635 | * @bss: cfg80211 bss info |
| 5636 | * @roam_info: information about connected bss |
| 5637 | * @req_ie: Request Information Element |
| 5638 | * @req_ie_len: len of the req IE |
| 5639 | * @resp_ie: Response IE |
| 5640 | * @resp_ie_len: len of ht response IE |
| 5641 | * @status: status |
| 5642 | * @gfp: allocation flags |
| 5643 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
| 5644 | * @timeout_reason: reason for connect timeout |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5645 | * |
| 5646 | * This API is used as wrapper to send FILS key/sequence number |
| 5647 | * params etc. to supplicant in case of FILS connection |
| 5648 | * |
| 5649 | * Return: None |
| 5650 | */ |
| 5651 | static void hdd_connect_done(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5652 | struct cfg80211_bss *bss, |
| 5653 | struct csr_roam_info *roam_info, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5654 | const u8 *req_ie, size_t req_ie_len, |
| 5655 | const u8 *resp_ie, size_t resp_ie_len, u16 status, |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5656 | gfp_t gfp, bool connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5657 | tSirResultCodes timeout_reason) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5658 | { |
| 5659 | struct cfg80211_connect_resp_params fils_params; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5660 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5661 | struct fils_join_rsp_params *roam_fils_params = |
| 5662 | roam_info->fils_join_rsp; |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5663 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5664 | qdf_mem_zero(&fils_params, sizeof(fils_params)); |
| 5665 | |
| 5666 | if (!roam_fils_params) { |
| 5667 | fils_params.status = WLAN_STATUS_UNSPECIFIED_FAILURE; |
| 5668 | } else { |
| 5669 | fils_params.status = status; |
| 5670 | fils_params.bssid = bssid; |
Srinivas Girigowda | e975f53 | 2018-01-05 14:03:05 -0800 | [diff] [blame] | 5671 | fils_params.timeout_reason = |
| 5672 | hdd_convert_timeout_reason(timeout_reason); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5673 | fils_params.req_ie = req_ie; |
| 5674 | fils_params.req_ie_len = req_ie_len; |
| 5675 | fils_params.resp_ie = resp_ie; |
| 5676 | fils_params.resp_ie_len = resp_ie_len; |
| 5677 | fils_params.bss = bss; |
| 5678 | hdd_populate_fils_params(&fils_params, roam_fils_params->kek, |
| 5679 | roam_fils_params->kek_len, |
| 5680 | roam_fils_params->fils_pmk, |
| 5681 | roam_fils_params->fils_pmk_len, |
| 5682 | roam_fils_params->fils_pmkid, |
| 5683 | roam_info->fils_seq_num); |
Sridhar Selvaraj | e526044 | 2017-08-19 10:12:03 +0530 | [diff] [blame] | 5684 | hdd_save_gtk_params(adapter, roam_info, false); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5685 | } |
| 5686 | hdd_debug("FILS indicate connect status %d seq no %d", |
| 5687 | fils_params.status, |
| 5688 | fils_params.fils_erp_next_seq_num); |
| 5689 | |
| 5690 | cfg80211_connect_done(dev, &fils_params, gfp); |
| 5691 | |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5692 | if (roam_fils_params && roam_fils_params->hlp_data_len) |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5693 | hdd_update_hlp_info(dev, roam_info); |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5694 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5695 | /* Clear all the FILS key info */ |
| 5696 | if (roam_fils_params && roam_fils_params->fils_pmk) |
| 5697 | qdf_mem_free(roam_fils_params->fils_pmk); |
| 5698 | if (roam_fils_params) |
| 5699 | qdf_mem_free(roam_fils_params); |
| 5700 | roam_info->fils_join_rsp = NULL; |
| 5701 | } |
| 5702 | #else |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5703 | static inline void |
| 5704 | hdd_connect_done(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5705 | struct cfg80211_bss *bss, struct csr_roam_info *roam_info, |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5706 | const u8 *req_ie, size_t req_ie_len, |
| 5707 | const u8 *resp_ie, size_t resp_ie_len, u16 status, |
| 5708 | gfp_t gfp, bool connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5709 | tSirResultCodes timeout_reason) |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5710 | { } |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5711 | #endif |
| 5712 | #endif |
| 5713 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5714 | #if defined(WLAN_FEATURE_FILS_SK) && \ |
| 5715 | (defined(CFG80211_CONNECT_DONE) || \ |
| 5716 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0))) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5717 | /** |
| 5718 | * hdd_fils_update_connect_results() - API to send fils connection status to |
| 5719 | * supplicant. |
| 5720 | * @dev: network device |
| 5721 | * @bssid: bssid to which we want to associate |
| 5722 | * @bss: cfg80211 bss info |
| 5723 | * @roam_info: information about connected bss |
| 5724 | * @req_ie: Request Information Element |
| 5725 | * @req_ie_len: len of the req IE |
| 5726 | * @resp_ie: Response IE |
| 5727 | * @resp_ie_len: len of ht response IE |
| 5728 | * @status: status |
| 5729 | * @gfp: allocation flags |
| 5730 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
| 5731 | * @timeout_reason: reason for connect timeout |
| 5732 | * |
| 5733 | * The API is a wrapper to send connection status to supplicant |
| 5734 | * |
| 5735 | * Return: 0 if success else failure |
| 5736 | */ |
| 5737 | static int hdd_fils_update_connect_results(struct net_device *dev, |
| 5738 | const u8 *bssid, |
| 5739 | struct cfg80211_bss *bss, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5740 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5741 | size_t req_ie_len, const u8 *resp_ie, |
| 5742 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 5743 | bool connect_timeout, |
| 5744 | tSirResultCodes timeout_reason) |
| 5745 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5746 | hdd_enter(); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5747 | if (!roam_info || !roam_info->is_fils_connection) |
| 5748 | return -EINVAL; |
| 5749 | |
| 5750 | hdd_connect_done(dev, bssid, bss, roam_info, req_ie, req_ie_len, |
| 5751 | resp_ie, resp_ie_len, status, gfp, connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5752 | timeout_reason); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5753 | return 0; |
| 5754 | } |
| 5755 | #else |
| 5756 | static inline int hdd_fils_update_connect_results(struct net_device *dev, |
| 5757 | const u8 *bssid, |
| 5758 | struct cfg80211_bss *bss, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5759 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5760 | size_t req_ie_len, const u8 *resp_ie, |
| 5761 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 5762 | bool connect_timeout, |
| 5763 | tSirResultCodes timeout_reason) |
| 5764 | { |
| 5765 | return -EINVAL; |
| 5766 | } |
| 5767 | #endif |
| 5768 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5769 | /** |
| 5770 | * hdd_connect_result() - API to send connection status to supplicant |
| 5771 | * @dev: network device |
| 5772 | * @bssid: bssid to which we want to associate |
| 5773 | * @roam_info: information about connected bss |
| 5774 | * @req_ie: Request Information Element |
| 5775 | * @req_ie_len: len of the req IE |
| 5776 | * @resp_ie: Response IE |
| 5777 | * @resp_ie_len: len of ht response IE |
| 5778 | * @status: status |
| 5779 | * @gfp: Kernel Flag |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5780 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5781 | * @timeout_reason: reason for connect timeout |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5782 | * |
| 5783 | * The API is a wrapper to send connection status to supplicant |
| 5784 | * and allow runtime suspend |
| 5785 | * |
| 5786 | * Return: Void |
| 5787 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5788 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5789 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5790 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5791 | size_t resp_ie_len, u16 status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5792 | bool connect_timeout, |
| 5793 | tSirResultCodes timeout_reason) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5794 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5795 | struct hdd_adapter *padapter = (struct hdd_adapter *) netdev_priv(dev); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5796 | struct cfg80211_bss *bss = NULL; |
Jingxiang Ge | 929c793 | 2018-01-24 14:01:12 +0800 | [diff] [blame] | 5797 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(padapter); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5798 | |
| 5799 | if (WLAN_STATUS_SUCCESS == status) { |
| 5800 | struct ieee80211_channel *chan; |
| 5801 | int freq; |
| 5802 | int chan_no = roam_info->pBssDesc->channelId; |
| 5803 | |
| 5804 | if (chan_no <= 14) |
| 5805 | freq = ieee80211_channel_to_frequency(chan_no, |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 5806 | HDD_NL80211_BAND_2GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5807 | else |
| 5808 | freq = ieee80211_channel_to_frequency(chan_no, |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 5809 | HDD_NL80211_BAND_5GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5810 | |
| 5811 | chan = ieee80211_get_channel(padapter->wdev.wiphy, freq); |
| 5812 | bss = hdd_cfg80211_get_bss(padapter->wdev.wiphy, chan, bssid, |
| 5813 | roam_info->u.pConnectedProfile->SSID.ssId, |
| 5814 | roam_info->u.pConnectedProfile->SSID.length); |
| 5815 | } |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 5816 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5817 | if (hdd_fils_update_connect_results(dev, bssid, bss, |
| 5818 | roam_info, req_ie, req_ie_len, resp_ie, |
| 5819 | resp_ie_len, status, gfp, connect_timeout, |
| 5820 | timeout_reason) != 0) { |
| 5821 | hdd_connect_bss(dev, bssid, bss, req_ie, |
| 5822 | req_ie_len, resp_ie, resp_ie_len, |
| 5823 | status, gfp, connect_timeout, timeout_reason); |
| 5824 | } |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 5825 | |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 5826 | qdf_runtime_pm_allow_suspend(&hdd_ctx->runtime_context.connect); |
Dustin Brown | ceed67e | 2017-05-26 11:57:31 -0700 | [diff] [blame] | 5827 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5828 | } |
| 5829 | #else |
| 5830 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5831 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5832 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5833 | size_t resp_ie_len, u16 status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5834 | bool connect_timeout, |
| 5835 | tSirResultCodes timeout_reason) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5836 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5837 | struct hdd_adapter *padapter = (struct hdd_adapter *) netdev_priv(dev); |
Jingxiang Ge | 929c793 | 2018-01-24 14:01:12 +0800 | [diff] [blame] | 5838 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(padapter); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 5839 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5840 | cfg80211_connect_result(dev, bssid, req_ie, req_ie_len, |
| 5841 | resp_ie, resp_ie_len, status, gfp); |
Prashanth Bhatta | 87b6dc0 | 2017-01-19 15:17:58 -0800 | [diff] [blame] | 5842 | |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 5843 | qdf_runtime_pm_allow_suspend(&hdd_ctx->runtime_context.connect); |
Dustin Brown | ceed67e | 2017-05-26 11:57:31 -0700 | [diff] [blame] | 5844 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5845 | } |
| 5846 | #endif |
| 5847 | |
| 5848 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5849 | QDF_STATUS hdd_start_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5850 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5851 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5852 | #ifndef MSM_PLATFORM |
Dustin Brown | ce5b3d3 | 2018-01-17 15:07:38 -0800 | [diff] [blame] | 5853 | struct qdf_mac_addr bcastMac = QDF_MAC_ADDR_BCAST_INIT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5854 | #endif |
| 5855 | eConnectionState connState; |
| 5856 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5857 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5858 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5859 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5860 | if (!hdd_is_interface_up(adapter)) |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5861 | continue; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5862 | |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5863 | hdd_debug("[SSR] start adapter with device mode %s(%d)", |
| 5864 | hdd_device_mode_to_string(adapter->device_mode), |
| 5865 | adapter->device_mode); |
| 5866 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5867 | hdd_wmm_init(adapter); |
| 5868 | |
| 5869 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5870 | case QDF_STA_MODE: |
| 5871 | case QDF_P2P_CLIENT_MODE: |
| 5872 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5873 | |
| 5874 | connState = (WLAN_HDD_GET_STATION_CTX_PTR(adapter)) |
| 5875 | ->conn_info.connState; |
| 5876 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5877 | hdd_start_station_adapter(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5878 | /* Open the gates for HDD to receive Wext commands */ |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 5879 | adapter->is_link_up_service_needed = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5880 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5881 | /* Indicate disconnect event to supplicant |
| 5882 | * if associated previously |
| 5883 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5884 | if (eConnectionState_Associated == connState || |
Yue Ma | cd96144 | 2015-10-20 16:15:31 -0700 | [diff] [blame] | 5885 | eConnectionState_IbssConnected == connState || |
| 5886 | eConnectionState_NotConnected == connState || |
| 5887 | eConnectionState_IbssDisconnected == connState || |
| 5888 | eConnectionState_Disconnecting == connState) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5889 | union iwreq_data wrqu; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5890 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5891 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 5892 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 5893 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 5894 | wireless_send_event(adapter->dev, SIOCGIWAP, |
| 5895 | &wrqu, NULL); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 5896 | adapter->session.station. |
Jeff Johnson | 690fe95 | 2017-10-25 11:48:39 -0700 | [diff] [blame] | 5897 | hdd_reassoc_scenario = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5898 | |
| 5899 | /* indicate disconnected event to nl80211 */ |
Mahesh A Saptasagar | c35e8bf | 2016-06-17 20:03:46 +0530 | [diff] [blame] | 5900 | wlan_hdd_cfg80211_indicate_disconnect( |
| 5901 | adapter->dev, false, |
| 5902 | WLAN_REASON_UNSPECIFIED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5903 | } else if (eConnectionState_Connecting == connState) { |
| 5904 | /* |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5905 | * Indicate connect failure to supplicant if we |
| 5906 | * were in the process of connecting |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5907 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5908 | hdd_connect_result(adapter->dev, NULL, NULL, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5909 | NULL, 0, NULL, 0, |
| 5910 | WLAN_STATUS_ASSOC_DENIED_UNSPEC, |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5911 | GFP_KERNEL, false, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5912 | } |
| 5913 | |
| 5914 | hdd_register_tx_flow_control(adapter, |
| 5915 | hdd_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 5916 | hdd_tx_resume_cb, |
| 5917 | hdd_tx_flow_control_is_pause); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5918 | |
| 5919 | break; |
| 5920 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5921 | case QDF_SAP_MODE: |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5922 | if (hdd_ctx->config->sap_internal_restart) |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5923 | hdd_start_ap_adapter(adapter); |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5924 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5925 | break; |
| 5926 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5927 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5928 | #ifdef MSM_PLATFORM |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5929 | hdd_debug("[SSR] send stop ap to supplicant"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5930 | cfg80211_ap_stopped(adapter->dev, GFP_KERNEL); |
| 5931 | #else |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5932 | hdd_debug("[SSR] send restart supplicant"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5933 | /* event supplicant to restart */ |
| 5934 | cfg80211_del_sta(adapter->dev, |
| 5935 | (const u8 *)&bcastMac.bytes[0], |
| 5936 | GFP_KERNEL); |
| 5937 | #endif |
| 5938 | break; |
Arunk Khandavalli | 062fb03 | 2017-10-04 12:18:15 +0530 | [diff] [blame] | 5939 | case QDF_MONITOR_MODE: |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5940 | hdd_start_station_adapter(adapter); |
Arunk Khandavalli | 062fb03 | 2017-10-04 12:18:15 +0530 | [diff] [blame] | 5941 | hdd_set_mon_rx_cb(adapter->dev); |
| 5942 | wlan_hdd_set_mon_chan(adapter, adapter->mon_chan, |
| 5943 | adapter->mon_bandwidth); |
| 5944 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5945 | default: |
| 5946 | break; |
| 5947 | } |
Krunal Soni | 9c2ee03 | 2017-07-18 13:49:54 -0700 | [diff] [blame] | 5948 | /* |
| 5949 | * Action frame registered in one adapter which will |
| 5950 | * applicable to all interfaces |
| 5951 | */ |
| 5952 | wlan_hdd_cfg80211_register_frames(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5953 | } |
| 5954 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5955 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5956 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5957 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5958 | } |
| 5959 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5960 | QDF_STATUS hdd_get_front_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5961 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5962 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5963 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5964 | qdf_list_node_t *node; |
| 5965 | |
| 5966 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5967 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5968 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5969 | status = qdf_list_peek_front(&hdd_ctx->hdd_adapters, &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5970 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5971 | |
| 5972 | if (QDF_IS_STATUS_ERROR(status)) |
| 5973 | return status; |
| 5974 | |
| 5975 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 5976 | |
| 5977 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5978 | } |
| 5979 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5980 | QDF_STATUS hdd_get_next_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5981 | struct hdd_adapter *current_adapter, |
| 5982 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5983 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5984 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5985 | qdf_list_node_t *node; |
| 5986 | |
| 5987 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5988 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5989 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 5990 | status = qdf_list_peek_next(&hdd_ctx->hdd_adapters, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5991 | ¤t_adapter->node, |
| 5992 | &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5993 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5994 | |
| 5995 | if (QDF_IS_STATUS_ERROR(status)) |
| 5996 | return status; |
| 5997 | |
| 5998 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 5999 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6000 | return status; |
| 6001 | } |
| 6002 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6003 | QDF_STATUS hdd_remove_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6004 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6005 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6006 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6007 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6008 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6009 | status = qdf_list_remove_node(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6010 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6011 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6012 | return status; |
| 6013 | } |
| 6014 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6015 | QDF_STATUS hdd_remove_front_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6016 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6017 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6018 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6019 | qdf_list_node_t *node; |
| 6020 | |
| 6021 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6022 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6023 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6024 | status = qdf_list_remove_front(&hdd_ctx->hdd_adapters, &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6025 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6026 | |
| 6027 | if (QDF_IS_STATUS_ERROR(status)) |
| 6028 | return status; |
| 6029 | |
| 6030 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 6031 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6032 | return status; |
| 6033 | } |
| 6034 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6035 | QDF_STATUS hdd_add_adapter_back(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6036 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6037 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6038 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6039 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6040 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6041 | status = qdf_list_insert_back(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6042 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6043 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6044 | return status; |
| 6045 | } |
| 6046 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6047 | QDF_STATUS hdd_add_adapter_front(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6048 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6049 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6050 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6051 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6052 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6053 | status = qdf_list_insert_front(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6054 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6055 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6056 | return status; |
| 6057 | } |
| 6058 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6059 | 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] | 6060 | tSirMacAddr macAddr) |
| 6061 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6062 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6063 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6064 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6065 | if (!qdf_mem_cmp(adapter->mac_addr.bytes, |
| 6066 | macAddr, sizeof(tSirMacAddr))) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6067 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6068 | } |
| 6069 | |
| 6070 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6071 | } |
| 6072 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6073 | 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] | 6074 | uint32_t vdev_id) |
| 6075 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6076 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6077 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6078 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 6079 | if (adapter->session_id == vdev_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6080 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6081 | } |
| 6082 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6083 | return NULL; |
| 6084 | } |
| 6085 | |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6086 | /** |
| 6087 | * hdd_get_adapter_by_sme_session_id() - Return adapter with |
| 6088 | * the sessionid |
| 6089 | * @hdd_ctx: hdd context. |
| 6090 | * @sme_session_id: sme session is for the adapter to get. |
| 6091 | * |
| 6092 | * This function is used to get the adapter with provided session id |
| 6093 | * |
| 6094 | * Return: adapter pointer if found |
| 6095 | * |
| 6096 | */ |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 6097 | struct hdd_adapter * |
| 6098 | hdd_get_adapter_by_sme_session_id(struct hdd_context *hdd_ctx, |
| 6099 | uint32_t sme_session_id) |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6100 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6101 | struct hdd_adapter *adapter; |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6102 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6103 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6104 | if (adapter->session_id == sme_session_id) |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6105 | return adapter; |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6106 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6107 | |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6108 | return NULL; |
| 6109 | } |
| 6110 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6111 | 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] | 6112 | const char *iface_name) |
| 6113 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6114 | struct hdd_adapter *adapter; |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6115 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6116 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6117 | if (!qdf_str_cmp(adapter->dev->name, iface_name)) |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6118 | return adapter; |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6119 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6120 | |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6121 | return NULL; |
| 6122 | } |
| 6123 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6124 | /** |
| 6125 | * hdd_get_adapter() - to get adapter matching the mode |
| 6126 | * @hdd_ctx: hdd context |
| 6127 | * @mode: adapter mode |
| 6128 | * |
| 6129 | * This routine will return the pointer to adapter matching |
| 6130 | * with the passed mode. |
| 6131 | * |
| 6132 | * Return: pointer to adapter or null |
| 6133 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6134 | struct hdd_adapter *hdd_get_adapter(struct hdd_context *hdd_ctx, |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 6135 | enum QDF_OPMODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6136 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6137 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6138 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6139 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6140 | if (adapter->device_mode == mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6141 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6142 | } |
| 6143 | |
| 6144 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6145 | } |
| 6146 | |
Yeshwanth Sriram Guntuka | 469f957 | 2018-02-12 13:28:22 +0530 | [diff] [blame] | 6147 | enum tQDF_ADAPTER_MODE hdd_get_device_mode(uint32_t session_id) |
| 6148 | { |
| 6149 | struct hdd_context *hdd_ctx; |
| 6150 | struct hdd_adapter *adapter; |
| 6151 | |
| 6152 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 6153 | if (!hdd_ctx) { |
| 6154 | hdd_err("Invalid HDD context"); |
| 6155 | return QDF_MAX_NO_OF_MODE; |
| 6156 | } |
| 6157 | |
| 6158 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, session_id); |
| 6159 | if (!adapter) { |
| 6160 | hdd_err("Invalid HDD adapter"); |
| 6161 | return QDF_MAX_NO_OF_MODE; |
| 6162 | } |
| 6163 | |
| 6164 | return adapter->device_mode; |
| 6165 | } |
| 6166 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6167 | /** |
| 6168 | * hdd_get_operating_channel() - return operating channel of the device mode |
| 6169 | * @hdd_ctx: Pointer to the HDD context. |
| 6170 | * @mode: Device mode for which operating channel is required. |
| 6171 | * Suported modes: |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6172 | * QDF_STA_MODE, |
| 6173 | * QDF_P2P_CLIENT_MODE, |
| 6174 | * QDF_SAP_MODE, |
| 6175 | * QDF_P2P_GO_MODE. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6176 | * |
| 6177 | * This API returns the operating channel of the requested device mode |
| 6178 | * |
| 6179 | * Return: channel number. "0" id the requested device is not found OR it is |
| 6180 | * not connected. |
| 6181 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6182 | uint8_t hdd_get_operating_channel(struct hdd_context *hdd_ctx, |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 6183 | enum QDF_OPMODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6184 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6185 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6186 | uint8_t operatingChannel = 0; |
| 6187 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6188 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6189 | if (mode == adapter->device_mode) { |
| 6190 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6191 | case QDF_STA_MODE: |
| 6192 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6193 | if (hdd_conn_is_connected |
| 6194 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 6195 | (adapter))) { |
| 6196 | operatingChannel = |
| 6197 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 6198 | (adapter))->conn_info. |
| 6199 | operationChannel; |
| 6200 | } |
| 6201 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6202 | case QDF_SAP_MODE: |
| 6203 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6204 | /* softap connection info */ |
| 6205 | if (test_bit |
| 6206 | (SOFTAP_BSS_STARTED, |
| 6207 | &adapter->event_flags)) |
| 6208 | operatingChannel = |
| 6209 | (WLAN_HDD_GET_AP_CTX_PTR |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 6210 | (adapter))->operating_channel; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6211 | break; |
| 6212 | default: |
| 6213 | break; |
| 6214 | } |
| 6215 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6216 | /* Found the device of interest. break the loop */ |
| 6217 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6218 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6219 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6220 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6221 | return operatingChannel; |
| 6222 | } |
| 6223 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6224 | static inline QDF_STATUS hdd_unregister_wext_all_adapters(struct hdd_context * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6225 | hdd_ctx) |
| 6226 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6227 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6228 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6229 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6230 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6231 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6232 | if (adapter->device_mode == QDF_STA_MODE || |
| 6233 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 6234 | adapter->device_mode == QDF_IBSS_MODE || |
| 6235 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 6236 | adapter->device_mode == QDF_SAP_MODE || |
| 6237 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6238 | wlan_hdd_cfg80211_deregister_frames(adapter); |
| 6239 | hdd_unregister_wext(adapter->dev); |
| 6240 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6241 | } |
| 6242 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6243 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6244 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6245 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6246 | } |
| 6247 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6248 | 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] | 6249 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6250 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6251 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6252 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6253 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6254 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6255 | if (adapter->device_mode == QDF_STA_MODE || |
| 6256 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 6257 | adapter->device_mode == QDF_IBSS_MODE || |
| 6258 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 6259 | adapter->device_mode == QDF_SAP_MODE || |
| 6260 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 6261 | wlan_abort_scan(hdd_ctx->hdd_pdev, INVAL_PDEV_ID, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 6262 | adapter->session_id, INVALID_SCAN_ID, |
Vignesh Viswanathan | 19611c8 | 2018-01-16 16:20:40 +0530 | [diff] [blame] | 6263 | true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6264 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6265 | } |
| 6266 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6267 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6268 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6269 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6270 | } |
| 6271 | |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6272 | /** |
| 6273 | * hdd_abort_sched_scan_all_adapters() - stops scheduled (PNO) scans for all |
| 6274 | * adapters |
| 6275 | * @hdd_ctx: The HDD context containing the adapters to operate on |
| 6276 | * |
| 6277 | * return: QDF_STATUS_SUCCESS |
| 6278 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6279 | 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] | 6280 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6281 | struct hdd_adapter *adapter; |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6282 | int err; |
| 6283 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6284 | hdd_enter(); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6285 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6286 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6287 | if (adapter->device_mode == QDF_STA_MODE || |
| 6288 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 6289 | adapter->device_mode == QDF_IBSS_MODE || |
| 6290 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 6291 | adapter->device_mode == QDF_SAP_MODE || |
| 6292 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6293 | err = wlan_hdd_sched_scan_stop(adapter->dev); |
| 6294 | if (err) |
| 6295 | hdd_err("Unable to stop scheduled scan"); |
| 6296 | } |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6297 | } |
| 6298 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6299 | hdd_exit(); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6300 | |
| 6301 | return QDF_STATUS_SUCCESS; |
| 6302 | } |
| 6303 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6304 | #ifdef WLAN_NS_OFFLOAD |
| 6305 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6306 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6307 | * @hdd_ctx: Pointer to hdd context |
| 6308 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6309 | * Unregister for IPv6 address change notifications. |
| 6310 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6311 | * Return: None |
| 6312 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6313 | static void hdd_wlan_unregister_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6314 | { |
| 6315 | unregister_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6316 | } |
| 6317 | |
| 6318 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6319 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6320 | * @hdd_ctx: Pointer to hdd context |
| 6321 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6322 | * Register for IPv6 address change notifications. |
| 6323 | * |
| 6324 | * Return: 0 on success and errno on failure. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6325 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6326 | static int hdd_wlan_register_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6327 | { |
| 6328 | int ret; |
| 6329 | |
| 6330 | hdd_ctx->ipv6_notifier.notifier_call = wlan_hdd_ipv6_changed; |
| 6331 | ret = register_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6332 | if (ret) { |
| 6333 | hdd_err("Failed to register IPv6 notifier: %d", ret); |
| 6334 | goto out; |
| 6335 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6336 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6337 | hdd_debug("Registered IPv6 notifier"); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6338 | out: |
| 6339 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6340 | } |
| 6341 | #else |
| 6342 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6343 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6344 | * @hdd_ctx: Pointer to hdd context |
| 6345 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6346 | * Unregister for IPv6 address change notifications. |
| 6347 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6348 | * Return: None |
| 6349 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6350 | static void hdd_wlan_unregister_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6351 | { |
| 6352 | } |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6353 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6354 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6355 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6356 | * @hdd_ctx: Pointer to hdd context |
| 6357 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6358 | * Register for IPv6 address change notifications. |
| 6359 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6360 | * Return: None |
| 6361 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6362 | static int hdd_wlan_register_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6363 | { |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6364 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6365 | } |
| 6366 | #endif |
| 6367 | |
| 6368 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6369 | * hdd_register_notifiers - Register netdev notifiers. |
| 6370 | * @hdd_ctx: HDD context |
| 6371 | * |
| 6372 | * Register netdev notifiers like IPv4 and IPv6. |
| 6373 | * |
| 6374 | * Return: 0 on success and errno on failure |
| 6375 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6376 | static int hdd_register_notifiers(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6377 | { |
| 6378 | int ret; |
| 6379 | |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6380 | ret = hdd_wlan_register_ip6_notifier(hdd_ctx); |
| 6381 | if (ret) |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 6382 | goto out; |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6383 | |
| 6384 | hdd_ctx->ipv4_notifier.notifier_call = wlan_hdd_ipv4_changed; |
| 6385 | ret = register_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
| 6386 | if (ret) { |
| 6387 | hdd_err("Failed to register IPv4 notifier: %d", ret); |
| 6388 | goto unregister_ip6_notifier; |
| 6389 | } |
| 6390 | |
| 6391 | return 0; |
| 6392 | |
| 6393 | unregister_ip6_notifier: |
| 6394 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6395 | out: |
| 6396 | return ret; |
| 6397 | |
| 6398 | } |
| 6399 | |
| 6400 | /** |
| 6401 | * hdd_unregister_notifiers - Unregister netdev notifiers. |
| 6402 | * @hdd_ctx: HDD context |
| 6403 | * |
| 6404 | * Unregister netdev notifiers like IPv4 and IPv6. |
| 6405 | * |
| 6406 | * Return: None. |
| 6407 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6408 | void hdd_unregister_notifiers(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6409 | { |
| 6410 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
| 6411 | |
| 6412 | unregister_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6413 | } |
| 6414 | |
| 6415 | /** |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6416 | * hdd_exit_netlink_services - Exit netlink services |
| 6417 | * @hdd_ctx: HDD context |
| 6418 | * |
| 6419 | * Exit netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 6420 | * nl service. |
| 6421 | * |
| 6422 | * Return: None. |
| 6423 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6424 | static void hdd_exit_netlink_services(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6425 | { |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6426 | hdd_close_cesium_nl_sock(); |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 6427 | hdd_deactivate_wifi_pos(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6428 | ptt_sock_deactivate_svc(); |
| 6429 | |
| 6430 | nl_srv_exit(); |
| 6431 | } |
| 6432 | |
| 6433 | /** |
| 6434 | * hdd_init_netlink_services- Init netlink services |
| 6435 | * @hdd_ctx: HDD context |
| 6436 | * |
| 6437 | * Init netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 6438 | * nl service. |
| 6439 | * |
| 6440 | * Return: 0 on success and errno on failure. |
| 6441 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6442 | static int hdd_init_netlink_services(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6443 | { |
| 6444 | int ret; |
| 6445 | |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 6446 | ret = wlan_hdd_nl_init(hdd_ctx); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6447 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6448 | hdd_err("nl_srv_init failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6449 | goto out; |
| 6450 | } |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 6451 | cds_set_radio_index(hdd_ctx->radio_index); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6452 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 6453 | ret = hdd_activate_wifi_pos(hdd_ctx); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6454 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6455 | hdd_err("hdd_activate_wifi_pos failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6456 | goto err_nl_srv; |
| 6457 | } |
| 6458 | |
| 6459 | ret = ptt_sock_activate_svc(); |
| 6460 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6461 | hdd_err("ptt_sock_activate_svc failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6462 | goto err_nl_srv; |
| 6463 | } |
| 6464 | |
| 6465 | ret = hdd_open_cesium_nl_sock(); |
Ryan Hsu | 5e2e205 | 2016-04-28 10:19:38 -0700 | [diff] [blame] | 6466 | if (ret) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6467 | hdd_err("hdd_open_cesium_nl_sock failed ret: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6468 | |
| 6469 | ret = cnss_diag_activate_service(); |
| 6470 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6471 | hdd_err("cnss_diag_activate_service failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6472 | goto err_close_cesium; |
| 6473 | } |
| 6474 | |
Sandeep Puligilla | 019a1bd | 2018-02-04 22:57:44 -0800 | [diff] [blame] | 6475 | ret = spectral_scan_activate_service(); |
| 6476 | if (ret) { |
| 6477 | hdd_alert("spectral_scan_activate_service failed: %d", ret); |
| 6478 | goto err_close_cesium; |
| 6479 | } |
| 6480 | |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6481 | return 0; |
| 6482 | |
| 6483 | err_close_cesium: |
| 6484 | hdd_close_cesium_nl_sock(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6485 | ptt_sock_deactivate_svc(); |
| 6486 | err_nl_srv: |
| 6487 | nl_srv_exit(); |
| 6488 | out: |
| 6489 | return ret; |
| 6490 | } |
| 6491 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6492 | /** |
| 6493 | * hdd_rx_wake_lock_destroy() - Destroy RX wakelock |
| 6494 | * @hdd_ctx: HDD context. |
| 6495 | * |
| 6496 | * Destroy RX wakelock. |
| 6497 | * |
| 6498 | * Return: None. |
| 6499 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6500 | static void hdd_rx_wake_lock_destroy(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6501 | { |
| 6502 | qdf_wake_lock_destroy(&hdd_ctx->rx_wake_lock); |
| 6503 | } |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6504 | |
| 6505 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6506 | * hdd_rx_wake_lock_create() - Create RX wakelock |
| 6507 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6508 | * |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6509 | * Create RX wakelock. |
| 6510 | * |
| 6511 | * Return: None. |
| 6512 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6513 | static void hdd_rx_wake_lock_create(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6514 | { |
| 6515 | qdf_wake_lock_create(&hdd_ctx->rx_wake_lock, "qcom_rx_wakelock"); |
| 6516 | } |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6517 | |
| 6518 | /** |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6519 | * hdd_context_deinit() - Deinitialize HDD context |
| 6520 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6521 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6522 | * Deinitialize HDD context along with all the feature specific contexts but |
| 6523 | * do not free hdd context itself. Caller of this API is supposed to free |
| 6524 | * HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6525 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6526 | * return: 0 on success and errno on failure. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6527 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6528 | static int hdd_context_deinit(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6529 | { |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 6530 | qdf_wake_lock_destroy(&hdd_ctx->monitor_mode_wakelock); |
| 6531 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6532 | wlan_hdd_cfg80211_deinit(hdd_ctx->wiphy); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6533 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6534 | hdd_sap_context_destroy(hdd_ctx); |
| 6535 | |
| 6536 | hdd_rx_wake_lock_destroy(hdd_ctx); |
| 6537 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6538 | hdd_scan_context_destroy(hdd_ctx); |
| 6539 | |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 6540 | qdf_list_destroy(&hdd_ctx->hdd_adapters); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6541 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6542 | return 0; |
| 6543 | } |
| 6544 | |
| 6545 | /** |
| 6546 | * hdd_context_destroy() - Destroy HDD context |
| 6547 | * @hdd_ctx: HDD context to be destroyed. |
| 6548 | * |
| 6549 | * Free config and HDD context as well as destroy all the resources. |
| 6550 | * |
| 6551 | * Return: None |
| 6552 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6553 | static void hdd_context_destroy(struct hdd_context *hdd_ctx) |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6554 | { |
Rajeev Kumar | 493a31b | 2017-09-29 14:01:24 -0700 | [diff] [blame] | 6555 | cds_set_context(QDF_MODULE_ID_HDD, NULL); |
Arunk Khandavalli | 3d267b4 | 2017-05-02 18:58:59 +0530 | [diff] [blame] | 6556 | |
Hanumantha Reddy Pothula | 00c74f6 | 2016-11-24 20:13:32 +0530 | [diff] [blame] | 6557 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 6558 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6559 | hdd_context_deinit(hdd_ctx); |
| 6560 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6561 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6562 | hdd_ctx->config = NULL; |
| 6563 | |
| 6564 | wiphy_free(hdd_ctx->wiphy); |
| 6565 | } |
| 6566 | |
| 6567 | /** |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 6568 | * wlan_destroy_bug_report_lock() - Destroy bug report lock |
| 6569 | * |
| 6570 | * This function is used to destroy bug report lock |
| 6571 | * |
| 6572 | * Return: None |
| 6573 | */ |
| 6574 | static void wlan_destroy_bug_report_lock(void) |
| 6575 | { |
| 6576 | p_cds_contextType p_cds_context; |
| 6577 | |
| 6578 | p_cds_context = cds_get_global_context(); |
| 6579 | if (!p_cds_context) { |
| 6580 | hdd_err("cds context is NULL"); |
| 6581 | return; |
| 6582 | } |
| 6583 | |
| 6584 | qdf_spinlock_destroy(&p_cds_context->bug_report_lock); |
| 6585 | } |
| 6586 | |
| 6587 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6588 | * hdd_wlan_exit() - HDD WLAN exit function |
| 6589 | * @hdd_ctx: Pointer to the HDD Context |
| 6590 | * |
| 6591 | * This is the driver exit point (invoked during rmmod) |
| 6592 | * |
| 6593 | * Return: None |
| 6594 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6595 | static void hdd_wlan_exit(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6596 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6597 | struct wiphy *wiphy = hdd_ctx->wiphy; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6598 | int driver_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6599 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6600 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6601 | |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 6602 | qdf_cancel_delayed_work(&hdd_ctx->iface_idle_work); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6603 | |
| 6604 | hdd_unregister_notifiers(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6605 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6606 | hdd_bus_bandwidth_destroy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6607 | |
| 6608 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 6609 | if (QDF_TIMER_STATE_RUNNING == |
| 6610 | qdf_mc_timer_get_current_state(&hdd_ctx->skip_acs_scan_timer)) { |
| 6611 | qdf_mc_timer_stop(&hdd_ctx->skip_acs_scan_timer); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6612 | } |
| 6613 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6614 | if (!QDF_IS_STATUS_SUCCESS |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 6615 | (qdf_mc_timer_destroy(&hdd_ctx->skip_acs_scan_timer))) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 6616 | hdd_err("Cannot deallocate ACS Skip timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6617 | } |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 6618 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 6619 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 6620 | hdd_ctx->last_acs_channel_list = NULL; |
| 6621 | hdd_ctx->num_of_channels = 0; |
| 6622 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6623 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6624 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6625 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 6626 | driver_status = hdd_ctx->driver_status; |
| 6627 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 6628 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6629 | /* |
| 6630 | * Powersave Offload Case |
| 6631 | * Disable Idle Power Save Mode |
| 6632 | */ |
| 6633 | hdd_set_idle_ps_config(hdd_ctx, false); |
Sandeep Puligilla | 8fa28fd | 2017-11-02 12:19:33 -0700 | [diff] [blame] | 6634 | /* clear the scan queue in all the scenarios */ |
Sourav Mohapatra | 001cfaf | 2018-02-28 11:30:46 +0530 | [diff] [blame] | 6635 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->hdd_pdev, NULL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6636 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6637 | if (driver_status != DRIVER_MODULES_CLOSED) { |
| 6638 | hdd_unregister_wext_all_adapters(hdd_ctx); |
| 6639 | /* |
| 6640 | * Cancel any outstanding scan requests. We are about to close |
| 6641 | * all of our adapters, but an adapter structure is what SME |
| 6642 | * passes back to our callback function. Hence if there |
| 6643 | * are any outstanding scan requests then there is a |
| 6644 | * race condition between when the adapter is closed and |
| 6645 | * when the callback is invoked. We try to resolve that |
| 6646 | * race condition here by canceling any outstanding scans |
| 6647 | * before we close the adapters. |
| 6648 | * Note that the scans may be cancelled in an asynchronous |
| 6649 | * manner, so ideally there needs to be some kind of |
| 6650 | * synchronization. Rather than introduce a new |
| 6651 | * synchronization here, we will utilize the fact that we are |
| 6652 | * about to Request Full Power, and since that is synchronized, |
| 6653 | * the expectation is that by the time Request Full Power has |
| 6654 | * completed, all scans will be cancelled |
| 6655 | */ |
| 6656 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6657 | hdd_abort_sched_scan_all_adapters(hdd_ctx); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 6658 | hdd_stop_all_adapters(hdd_ctx); |
bings | 29c9986 | 2017-11-01 13:54:13 +0800 | [diff] [blame] | 6659 | hdd_deinit_all_adapters(hdd_ctx, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6660 | } |
| 6661 | |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 6662 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 6663 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 6664 | hdd_wlan_stop_modules(hdd_ctx, false); |
Hanumanth Reddy Pothula | 709a636 | 2016-10-18 18:19:44 +0530 | [diff] [blame] | 6665 | |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 6666 | hdd_driver_memdump_deinit(); |
| 6667 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 6668 | qdf_nbuf_deinit_replenish_timer(); |
| 6669 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 6670 | if (QDF_GLOBAL_MONITOR_MODE == hdd_get_conparam()) { |
| 6671 | hdd_info("Release wakelock for monitor mode!"); |
| 6672 | qdf_wake_lock_release(&hdd_ctx->monitor_mode_wakelock, |
| 6673 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 6674 | } |
| 6675 | |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 6676 | qdf_spinlock_destroy(&hdd_ctx->hdd_adapter_lock); |
| 6677 | qdf_spinlock_destroy(&hdd_ctx->sta_update_info_lock); |
| 6678 | qdf_spinlock_destroy(&hdd_ctx->connection_status_lock); |
| 6679 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6680 | /* |
| 6681 | * Close CDS |
| 6682 | * This frees pMac(HAL) context. There should not be any call |
| 6683 | * that requires pMac access after this. |
| 6684 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6685 | |
Jeff Johnson | ce0032c | 2017-01-20 07:18:27 -0800 | [diff] [blame] | 6686 | hdd_request_manager_deinit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6687 | |
Dustin Brown | d005ad8 | 2018-01-19 10:32:13 -0800 | [diff] [blame] | 6688 | hdd_close_all_adapters(hdd_ctx, false); |
| 6689 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6690 | hdd_ipa_cleanup(hdd_ctx); |
| 6691 | |
Manishekar Chandrasekaran | f7a1dad | 2016-06-23 06:43:47 +0530 | [diff] [blame] | 6692 | wlansap_global_deinit(); |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 6693 | /* |
| 6694 | * If there is re_init failure wiphy would have already de-registered |
| 6695 | * check the wiphy status before un-registering again |
| 6696 | */ |
Ashish Kumar Dhanotiya | e16feb7 | 2017-03-31 19:39:37 +0530 | [diff] [blame] | 6697 | if (wiphy && wiphy->registered) { |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 6698 | wiphy_unregister(wiphy); |
| 6699 | wlan_hdd_cfg80211_deinit(wiphy); |
| 6700 | hdd_lpass_notify_stop(hdd_ctx); |
| 6701 | } |
Yuanyuan Liu | 3e918e5 | 2016-08-17 15:41:35 -0700 | [diff] [blame] | 6702 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6703 | hdd_exit_netlink_services(hdd_ctx); |
| 6704 | mutex_destroy(&hdd_ctx->iface_change_lock); |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 6705 | #ifdef FEATURE_WLAN_CH_AVOID |
| 6706 | mutex_destroy(&hdd_ctx->avoid_freq_lock); |
| 6707 | #endif |
Abhishek Singh | e9068f1 | 2017-03-31 14:14:52 +0530 | [diff] [blame] | 6708 | |
Abhishek Singh | e9068f1 | 2017-03-31 14:14:52 +0530 | [diff] [blame] | 6709 | driver_status = hdd_objmgr_release_and_destroy_psoc(hdd_ctx); |
| 6710 | if (driver_status) |
| 6711 | hdd_err("Psoc delete failed"); |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 6712 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6713 | hdd_context_destroy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6714 | } |
| 6715 | |
| 6716 | void __hdd_wlan_exit(void) |
| 6717 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6718 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6719 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6720 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6721 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 6722 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6723 | if (!hdd_ctx) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6724 | hdd_err("Invalid HDD Context"); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6725 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6726 | return; |
| 6727 | } |
| 6728 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6729 | /* Do all the cleanup before deregistering the driver */ |
| 6730 | hdd_wlan_exit(hdd_ctx); |
Mohit Khanna | ebf8a86 | 2016-04-28 17:53:59 -0700 | [diff] [blame] | 6731 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6732 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6733 | } |
| 6734 | |
| 6735 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 6736 | /** |
| 6737 | * hdd_skip_acs_scan_timer_handler() - skip ACS scan timer timeout handler |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6738 | * @data: pointer to struct hdd_context |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 6739 | * |
| 6740 | * This function will reset acs_scan_status to eSAP_DO_NEW_ACS_SCAN. |
| 6741 | * Then new ACS request will do a fresh scan without reusing the cached |
| 6742 | * scan information. |
| 6743 | * |
| 6744 | * Return: void |
| 6745 | */ |
Tang Yingying | 523322d | 2017-01-17 23:28:43 +0800 | [diff] [blame] | 6746 | static void hdd_skip_acs_scan_timer_handler(void *data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6747 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6748 | struct hdd_context *hdd_ctx = (struct hdd_context *) data; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6749 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6750 | hdd_debug("ACS Scan result expired. Reset ACS scan skip"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6751 | hdd_ctx->skip_acs_scan_status = eSAP_DO_NEW_ACS_SCAN; |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 6752 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 6753 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 6754 | hdd_ctx->last_acs_channel_list = NULL; |
| 6755 | hdd_ctx->num_of_channels = 0; |
| 6756 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6757 | |
| 6758 | if (!hdd_ctx->hHal) |
| 6759 | return; |
| 6760 | sme_scan_flush_result(hdd_ctx->hHal); |
| 6761 | } |
| 6762 | #endif |
| 6763 | |
| 6764 | #ifdef QCA_HT_2040_COEX |
Jeff Johnson | e7672e7 | 2017-10-21 15:10:04 -0700 | [diff] [blame] | 6765 | int hdd_wlan_set_ht2040_mode(struct hdd_adapter *adapter, uint16_t sta_id, |
| 6766 | struct qdf_mac_addr sta_mac, int channel_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6767 | { |
| 6768 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6769 | QDF_STATUS qdf_status; |
Jeff Johnson | e7672e7 | 2017-10-21 15:10:04 -0700 | [diff] [blame] | 6770 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6771 | |
| 6772 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 6773 | |
| 6774 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 6775 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6776 | return status; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 6777 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6778 | if (!hdd_ctx->hHal) |
| 6779 | return -EINVAL; |
| 6780 | |
Jeff Johnson | e7672e7 | 2017-10-21 15:10:04 -0700 | [diff] [blame] | 6781 | qdf_status = sme_notify_ht2040_mode(hdd_ctx->hHal, sta_id, sta_mac, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 6782 | adapter->session_id, channel_type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6783 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6784 | hdd_err("Fail to send notification with ht2040 mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6785 | return -EINVAL; |
| 6786 | } |
| 6787 | |
| 6788 | return 0; |
| 6789 | } |
| 6790 | #endif |
| 6791 | |
| 6792 | /** |
| 6793 | * hdd_wlan_notify_modem_power_state() - notify FW with modem power status |
| 6794 | * @state: state |
| 6795 | * |
| 6796 | * This function notifies FW with modem power status |
| 6797 | * |
| 6798 | * Return: 0 if successful, error number otherwise |
| 6799 | */ |
| 6800 | int hdd_wlan_notify_modem_power_state(int state) |
| 6801 | { |
| 6802 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6803 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6804 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6805 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 6806 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6807 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 6808 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6809 | return status; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 6810 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6811 | if (!hdd_ctx->hHal) |
| 6812 | return -EINVAL; |
| 6813 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6814 | qdf_status = sme_notify_modem_power_state(hdd_ctx->hHal, state); |
| 6815 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6816 | hdd_err("Fail to send notification with modem power state %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6817 | state); |
| 6818 | return -EINVAL; |
| 6819 | } |
| 6820 | return 0; |
| 6821 | } |
| 6822 | |
| 6823 | /** |
| 6824 | * |
| 6825 | * hdd_post_cds_enable_config() - HDD post cds start config helper |
| 6826 | * @adapter - Pointer to the HDD |
| 6827 | * |
| 6828 | * Return: None |
| 6829 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6830 | QDF_STATUS hdd_post_cds_enable_config(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6831 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 6832 | QDF_STATUS qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6833 | |
| 6834 | /* |
| 6835 | * Send ready indication to the HDD. This will kick off the MAC |
| 6836 | * into a 'running' state and should kick off an initial scan. |
| 6837 | */ |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 6838 | qdf_ret_status = sme_hdd_ready_ind(hdd_ctx->hHal); |
| 6839 | if (!QDF_IS_STATUS_SUCCESS(qdf_ret_status)) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6840 | hdd_err("sme_hdd_ready_ind() failed with status code %08d [x%08x]", |
| 6841 | qdf_ret_status, qdf_ret_status); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6842 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6843 | } |
| 6844 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6845 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6846 | } |
| 6847 | |
Sourav Mohapatra | 92ea8d6 | 2018-02-05 10:03:10 +0530 | [diff] [blame] | 6848 | struct hdd_adapter *hdd_get_first_valid_adapter(struct hdd_context *hdd_ctx) |
| 6849 | { |
| 6850 | struct hdd_adapter *adapter; |
| 6851 | |
| 6852 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6853 | if (adapter && adapter->magic == WLAN_HDD_ADAPTER_MAGIC) |
| 6854 | return adapter; |
| 6855 | } |
| 6856 | |
| 6857 | return NULL; |
| 6858 | } |
| 6859 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6860 | /* wake lock APIs for HDD */ |
| 6861 | void hdd_prevent_suspend(uint32_t reason) |
| 6862 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 6863 | qdf_wake_lock_acquire(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6864 | } |
| 6865 | |
| 6866 | void hdd_allow_suspend(uint32_t reason) |
| 6867 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 6868 | qdf_wake_lock_release(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6869 | } |
| 6870 | |
| 6871 | void hdd_prevent_suspend_timeout(uint32_t timeout, uint32_t reason) |
| 6872 | { |
Anurag Chouhan | 01cfa4e | 2016-09-04 15:10:49 +0530 | [diff] [blame] | 6873 | cds_host_diag_log_work(&wlan_wake_lock, timeout, reason); |
| 6874 | qdf_wake_lock_timeout_acquire(&wlan_wake_lock, timeout); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6875 | } |
| 6876 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6877 | /* Initialize channel list in sme based on the country code */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6878 | QDF_STATUS hdd_set_sme_chan_list(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6879 | { |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 6880 | |
Amar Singhal | 6f8592b | 2017-04-26 14:31:58 -0700 | [diff] [blame] | 6881 | return sme_init_chan_list(hdd_ctx->hHal, |
| 6882 | hdd_ctx->reg.alpha2, |
| 6883 | hdd_ctx->reg.cc_src); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6884 | } |
| 6885 | |
| 6886 | /** |
| 6887 | * hdd_is_5g_supported() - check if hardware supports 5GHz |
| 6888 | * @hdd_ctx: Pointer to the hdd context |
| 6889 | * |
| 6890 | * HDD function to know if hardware supports 5GHz |
| 6891 | * |
| 6892 | * Return: true if hardware supports 5GHz |
| 6893 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6894 | bool hdd_is_5g_supported(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6895 | { |
Amar Singhal | 58b45ef | 2017-08-01 13:43:54 -0700 | [diff] [blame] | 6896 | if (!hdd_ctx) |
zding | f54169a | 2016-10-12 17:08:45 +0800 | [diff] [blame] | 6897 | return true; |
| 6898 | |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 6899 | if (hdd_ctx->curr_band != BAND_2G) |
zding | f54169a | 2016-10-12 17:08:45 +0800 | [diff] [blame] | 6900 | return true; |
| 6901 | else |
| 6902 | return false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6903 | } |
| 6904 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6905 | static int hdd_wiphy_init(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6906 | { |
| 6907 | struct wiphy *wiphy; |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6908 | int ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6909 | |
| 6910 | wiphy = hdd_ctx->wiphy; |
| 6911 | |
| 6912 | /* |
| 6913 | * The channel information in |
| 6914 | * wiphy needs to be initialized before wiphy registration |
| 6915 | */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6916 | ret_val = hdd_regulatory_init(hdd_ctx, wiphy); |
| 6917 | if (ret_val) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6918 | hdd_err("regulatory init failed"); |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6919 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6920 | } |
| 6921 | |
| 6922 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 6923 | wiphy->wowlan = &wowlan_support_reg_init; |
| 6924 | #else |
| 6925 | wiphy->wowlan.flags = WIPHY_WOWLAN_ANY | |
| 6926 | WIPHY_WOWLAN_MAGIC_PKT | |
| 6927 | WIPHY_WOWLAN_DISCONNECT | |
| 6928 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 6929 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 6930 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 6931 | WIPHY_WOWLAN_4WAY_HANDSHAKE | |
| 6932 | WIPHY_WOWLAN_RFKILL_RELEASE; |
| 6933 | |
| 6934 | wiphy->wowlan.n_patterns = (WOW_MAX_FILTER_LISTS * |
| 6935 | WOW_MAX_FILTERS_PER_LIST); |
| 6936 | wiphy->wowlan.pattern_min_len = WOW_MIN_PATTERN_SIZE; |
| 6937 | wiphy->wowlan.pattern_max_len = WOW_MAX_PATTERN_SIZE; |
| 6938 | #endif |
| 6939 | |
| 6940 | /* registration of wiphy dev with cfg80211 */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6941 | ret_val = wlan_hdd_cfg80211_register(wiphy); |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 6942 | if (0 > ret_val) { |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6943 | hdd_err("wiphy registration failed"); |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 6944 | return ret_val; |
| 6945 | } |
| 6946 | |
Amar Singhal | 2d81201 | 2018-02-03 15:06:47 +0800 | [diff] [blame] | 6947 | pld_increment_driver_load_cnt(hdd_ctx->parent_dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6948 | |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6949 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6950 | } |
| 6951 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 6952 | #ifdef MSM_PLATFORM |
| 6953 | /** |
| 6954 | * hdd_display_periodic_stats() - Function to display periodic stats |
| 6955 | * @hdd_ctx - handle to hdd context |
| 6956 | * @bool data_in_interval - true, if data detected in bw time interval |
| 6957 | * |
| 6958 | * The periodicity is determined by hdd_ctx->config->periodic_stats_disp_time. |
| 6959 | * Stats show up in wlan driver logs. |
| 6960 | * |
| 6961 | * Returns: None |
| 6962 | */ |
| 6963 | static inline |
| 6964 | void hdd_display_periodic_stats(struct hdd_context *hdd_ctx, |
| 6965 | bool data_in_interval) |
| 6966 | { |
| 6967 | static u32 counter; |
| 6968 | static bool data_in_time_period; |
| 6969 | ol_txrx_pdev_handle pdev; |
| 6970 | |
| 6971 | if (hdd_ctx->config->periodic_stats_disp_time == 0) |
| 6972 | return; |
| 6973 | |
| 6974 | pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
| 6975 | if (!pdev) { |
| 6976 | hdd_err("pdev is NULL"); |
| 6977 | return; |
| 6978 | } |
| 6979 | |
| 6980 | counter++; |
| 6981 | if (data_in_interval) |
| 6982 | data_in_time_period = data_in_interval; |
| 6983 | |
| 6984 | if (counter * hdd_ctx->config->busBandwidthComputeInterval >= |
| 6985 | hdd_ctx->config->periodic_stats_disp_time * 1000) { |
| 6986 | if (data_in_time_period) { |
| 6987 | cdp_display_stats(cds_get_context(QDF_MODULE_ID_SOC), |
| 6988 | CDP_TXRX_PATH_STATS, |
| 6989 | QDF_STATS_VERBOSITY_LEVEL_LOW); |
| 6990 | wlan_hdd_display_netif_queue_history |
| 6991 | (hdd_ctx, QDF_STATS_VERBOSITY_LEVEL_LOW); |
| 6992 | qdf_dp_trace_dump_stats(); |
| 6993 | } |
| 6994 | counter = 0; |
| 6995 | data_in_time_period = false; |
| 6996 | } |
| 6997 | } |
| 6998 | |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 6999 | /** |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7000 | * hdd_pld_request_bus_bandwidth() - Function to control bus bandwidth |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7001 | * @hdd_ctx - handle to hdd context |
| 7002 | * @tx_packets - transmit packet count |
| 7003 | * @rx_packets - receive packet count |
| 7004 | * |
| 7005 | * The function controls the bus bandwidth and dynamic control of |
| 7006 | * tcp delayed ack configuration |
| 7007 | * |
| 7008 | * Returns: None |
| 7009 | */ |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7010 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7011 | static void hdd_pld_request_bus_bandwidth(struct hdd_context *hdd_ctx, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 7012 | const uint64_t tx_packets, |
| 7013 | const uint64_t rx_packets) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7014 | { |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7015 | u64 total_pkts = tx_packets + rx_packets; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7016 | uint64_t temp_rx = 0; |
| 7017 | uint64_t temp_tx = 0; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7018 | enum pld_bus_width_type next_vote_level = PLD_BUS_WIDTH_NONE; |
Mohit Khanna | c3da706 | 2017-02-08 21:08:56 -0800 | [diff] [blame] | 7019 | static enum wlan_tp_level next_rx_level = WLAN_SVC_TP_NONE; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7020 | enum wlan_tp_level next_tx_level = WLAN_SVC_TP_NONE; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7021 | uint32_t delack_timer_cnt = hdd_ctx->config->tcp_delack_timer_count; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7022 | uint16_t index = 0; |
| 7023 | bool vote_level_change = false; |
| 7024 | bool rx_level_change = false; |
| 7025 | bool tx_level_change = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7026 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7027 | if (total_pkts > hdd_ctx->config->busBandwidthHighThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7028 | next_vote_level = PLD_BUS_WIDTH_HIGH; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7029 | else if (total_pkts > hdd_ctx->config->busBandwidthMediumThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7030 | next_vote_level = PLD_BUS_WIDTH_MEDIUM; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7031 | else if (total_pkts > hdd_ctx->config->busBandwidthLowThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7032 | next_vote_level = PLD_BUS_WIDTH_LOW; |
Yue Ma | d6478e4 | 2015-10-20 18:49:24 -0700 | [diff] [blame] | 7033 | else |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7034 | next_vote_level = PLD_BUS_WIDTH_NONE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7035 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7036 | if (hdd_ctx->cur_vote_level != next_vote_level) { |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7037 | hdd_debug("trigger level %d, tx_packets: %lld, rx_packets: %lld", |
| 7038 | next_vote_level, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7039 | hdd_ctx->cur_vote_level = next_vote_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7040 | vote_level_change = true; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7041 | pld_request_bus_bandwidth(hdd_ctx->parent_dev, next_vote_level); |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 7042 | if (next_vote_level == PLD_BUS_WIDTH_LOW) { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 7043 | if (hdd_ctx->hbw_requested) { |
| 7044 | pld_remove_pm_qos(hdd_ctx->parent_dev); |
| 7045 | hdd_ctx->hbw_requested = false; |
| 7046 | } |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 7047 | if (cds_sched_handle_throughput_req(false)) |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 7048 | hdd_warn("low bandwidth set rx affinity fail"); |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 7049 | } else { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 7050 | if (!hdd_ctx->hbw_requested) { |
| 7051 | pld_request_pm_qos(hdd_ctx->parent_dev, 1); |
| 7052 | hdd_ctx->hbw_requested = true; |
| 7053 | } |
| 7054 | |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 7055 | if (cds_sched_handle_throughput_req(true)) |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 7056 | hdd_warn("high bandwidth set rx affinity fail"); |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 7057 | } |
Orhan K AKYILDIZ | 1481aff | 2016-05-16 12:40:13 -0700 | [diff] [blame] | 7058 | hdd_napi_apply_throughput_policy(hdd_ctx, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7059 | } |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7060 | |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 7061 | qdf_dp_trace_throttle_live_mode( |
| 7062 | (next_vote_level > PLD_BUS_WIDTH_NONE) ? true : false); |
| 7063 | |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7064 | /* fine-tuning parameters for RX Flows */ |
| 7065 | temp_rx = (rx_packets + hdd_ctx->prev_rx) / 2; |
| 7066 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7067 | hdd_ctx->prev_rx = rx_packets; |
Mohit Khanna | b1dd1e8 | 2017-02-04 15:14:38 -0800 | [diff] [blame] | 7068 | |
Poddar, Siddarth | 47c2340 | 2017-10-25 12:17:39 +0530 | [diff] [blame] | 7069 | if (temp_rx < hdd_ctx->config->busBandwidthLowThreshold) |
| 7070 | hdd_disable_lro_for_low_tput(hdd_ctx, true); |
| 7071 | else |
| 7072 | hdd_disable_lro_for_low_tput(hdd_ctx, false); |
| 7073 | |
Ravi Joshi | fed8357 | 2016-10-07 16:20:37 -0700 | [diff] [blame] | 7074 | if (temp_rx > hdd_ctx->config->tcpDelackThresholdHigh) { |
| 7075 | if ((hdd_ctx->cur_rx_level != WLAN_SVC_TP_HIGH) && |
| 7076 | (++hdd_ctx->rx_high_ind_cnt == delack_timer_cnt)) { |
| 7077 | next_rx_level = WLAN_SVC_TP_HIGH; |
| 7078 | } |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7079 | } else { |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7080 | hdd_ctx->rx_high_ind_cnt = 0; |
Mohit Khanna | c3da706 | 2017-02-08 21:08:56 -0800 | [diff] [blame] | 7081 | next_rx_level = WLAN_SVC_TP_LOW; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7082 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7083 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7084 | if (hdd_ctx->cur_rx_level != next_rx_level) { |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 7085 | struct wlan_rx_tp_data rx_tp_data = {0}; |
| 7086 | |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7087 | hdd_debug("TCP DELACK trigger level %d, average_rx: %llu", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7088 | next_rx_level, temp_rx); |
| 7089 | hdd_ctx->cur_rx_level = next_rx_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7090 | rx_level_change = true; |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7091 | /* Send throughput indication only if it is enabled. |
| 7092 | * Disabling tcp_del_ack will revert the tcp stack behavior |
| 7093 | * to default delayed ack. Note that this will disable the |
| 7094 | * dynamic delayed ack mechanism across the system |
| 7095 | */ |
| 7096 | if (hdd_ctx->config->enable_tcp_delack) |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 7097 | rx_tp_data.rx_tp_flags |= TCP_DEL_ACK_IND; |
| 7098 | |
Mohit Khanna | 6272fb68 | 2017-04-13 09:34:36 -0700 | [diff] [blame] | 7099 | if (hdd_ctx->config->enable_tcp_adv_win_scale) |
| 7100 | rx_tp_data.rx_tp_flags |= TCP_ADV_WIN_SCL; |
| 7101 | |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 7102 | rx_tp_data.level = next_rx_level; |
| 7103 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 7104 | WLAN_SVC_WLAN_TP_IND, &rx_tp_data, |
| 7105 | sizeof(rx_tp_data)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7106 | } |
| 7107 | |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7108 | /* fine-tuning parameters for TX Flows */ |
| 7109 | temp_tx = (tx_packets + hdd_ctx->prev_tx) / 2; |
| 7110 | hdd_ctx->prev_tx = tx_packets; |
| 7111 | if (temp_tx > hdd_ctx->config->tcp_tx_high_tput_thres) |
| 7112 | next_tx_level = WLAN_SVC_TP_HIGH; |
| 7113 | else |
| 7114 | next_tx_level = WLAN_SVC_TP_LOW; |
| 7115 | |
Prakash Manjunathappa | e73e3b5 | 2018-02-27 18:56:22 -0800 | [diff] [blame] | 7116 | if ((hdd_ctx->config->enable_tcp_limit_output) && |
| 7117 | (hdd_ctx->cur_tx_level != next_tx_level)) { |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7118 | hdd_debug("change TCP TX trigger level %d, average_tx: %llu", |
| 7119 | next_tx_level, temp_tx); |
| 7120 | hdd_ctx->cur_tx_level = next_tx_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7121 | tx_level_change = true; |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 7122 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 7123 | WLAN_SVC_WLAN_TP_TX_IND, |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7124 | &next_tx_level, |
| 7125 | sizeof(next_tx_level)); |
| 7126 | } |
| 7127 | |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7128 | index = hdd_ctx->hdd_txrx_hist_idx; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7129 | if (vote_level_change || tx_level_change || rx_level_change) { |
| 7130 | hdd_ctx->hdd_txrx_hist[index].next_tx_level = next_tx_level; |
| 7131 | hdd_ctx->hdd_txrx_hist[index].next_rx_level = next_rx_level; |
| 7132 | hdd_ctx->hdd_txrx_hist[index].next_vote_level = next_vote_level; |
| 7133 | hdd_ctx->hdd_txrx_hist[index].interval_rx = rx_packets; |
| 7134 | hdd_ctx->hdd_txrx_hist[index].interval_tx = tx_packets; |
| 7135 | hdd_ctx->hdd_txrx_hist[index].qtime = qdf_get_log_timestamp(); |
| 7136 | hdd_ctx->hdd_txrx_hist_idx++; |
| 7137 | hdd_ctx->hdd_txrx_hist_idx &= NUM_TX_RX_HISTOGRAM_MASK; |
| 7138 | } |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7139 | |
| 7140 | hdd_display_periodic_stats(hdd_ctx, (total_pkts > 0) ? true : false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7141 | } |
| 7142 | |
| 7143 | #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] | 7144 | static void hdd_bus_bw_work_handler(struct work_struct *work) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7145 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7146 | struct hdd_context *hdd_ctx = container_of(work, struct hdd_context, |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7147 | bus_bw_work); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7148 | struct hdd_adapter *adapter = NULL; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7149 | uint64_t tx_packets = 0, rx_packets = 0; |
Himanshu Agarwal | a6cedee | 2016-06-08 14:50:00 +0530 | [diff] [blame] | 7150 | uint64_t fwd_tx_packets = 0, fwd_rx_packets = 0; |
| 7151 | uint64_t fwd_tx_packets_diff = 0, fwd_rx_packets_diff = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7152 | uint64_t total_tx = 0, total_rx = 0; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7153 | A_STATUS ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7154 | bool connected = false; |
| 7155 | uint32_t ipa_tx_packets = 0, ipa_rx_packets = 0; |
| 7156 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7157 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 7158 | return; |
| 7159 | |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 7160 | if (hdd_ctx->is_wiphy_suspended) |
Jingxiang Ge | c64e193 | 2017-08-22 14:38:59 +0800 | [diff] [blame] | 7161 | goto restart_timer; |
| 7162 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7163 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Manjeet Singh | 01327cc | 2016-09-03 12:14:25 +0530 | [diff] [blame] | 7164 | /* |
| 7165 | * Validate magic so we don't end up accessing |
| 7166 | * an invalid adapter. |
| 7167 | */ |
| 7168 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) |
| 7169 | continue; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7170 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 7171 | if ((adapter->device_mode == QDF_STA_MODE || |
| 7172 | adapter->device_mode == QDF_P2P_CLIENT_MODE) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7173 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)->conn_info.connState |
| 7174 | != eConnectionState_Associated) { |
| 7175 | |
| 7176 | continue; |
| 7177 | } |
| 7178 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 7179 | if ((adapter->device_mode == QDF_SAP_MODE || |
| 7180 | adapter->device_mode == QDF_P2P_GO_MODE) && |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 7181 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->ap_active == false) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7182 | |
| 7183 | continue; |
| 7184 | } |
| 7185 | |
| 7186 | tx_packets += HDD_BW_GET_DIFF(adapter->stats.tx_packets, |
| 7187 | adapter->prev_tx_packets); |
| 7188 | rx_packets += HDD_BW_GET_DIFF(adapter->stats.rx_packets, |
| 7189 | adapter->prev_rx_packets); |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7190 | |
| 7191 | if (adapter->device_mode == QDF_SAP_MODE || |
| 7192 | adapter->device_mode == QDF_P2P_GO_MODE || |
| 7193 | adapter->device_mode == QDF_IBSS_MODE) { |
| 7194 | |
Dhanashri Atre | a8f82f2 | 2017-01-23 12:58:24 -0800 | [diff] [blame] | 7195 | ret = cdp_get_intra_bss_fwd_pkts_count( |
| 7196 | cds_get_context(QDF_MODULE_ID_SOC), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 7197 | adapter->session_id, |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7198 | &fwd_tx_packets, &fwd_rx_packets); |
| 7199 | if (ret == A_OK) { |
| 7200 | fwd_tx_packets_diff += HDD_BW_GET_DIFF( |
| 7201 | fwd_tx_packets, |
| 7202 | adapter->prev_fwd_tx_packets); |
| 7203 | fwd_rx_packets_diff += HDD_BW_GET_DIFF( |
| 7204 | fwd_tx_packets, |
| 7205 | adapter->prev_fwd_rx_packets); |
| 7206 | } |
| 7207 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7208 | |
| 7209 | total_rx += adapter->stats.rx_packets; |
| 7210 | total_tx += adapter->stats.tx_packets; |
| 7211 | |
| 7212 | spin_lock_bh(&hdd_ctx->bus_bw_lock); |
| 7213 | adapter->prev_tx_packets = adapter->stats.tx_packets; |
| 7214 | adapter->prev_rx_packets = adapter->stats.rx_packets; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7215 | adapter->prev_fwd_tx_packets = fwd_tx_packets; |
| 7216 | adapter->prev_fwd_rx_packets = fwd_rx_packets; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7217 | spin_unlock_bh(&hdd_ctx->bus_bw_lock); |
| 7218 | connected = true; |
| 7219 | } |
| 7220 | |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7221 | /* add intra bss forwarded tx and rx packets */ |
| 7222 | tx_packets += fwd_tx_packets_diff; |
| 7223 | rx_packets += fwd_rx_packets_diff; |
| 7224 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7225 | hdd_ipa_uc_stat_query(hdd_ctx, &ipa_tx_packets, &ipa_rx_packets); |
| 7226 | tx_packets += (uint64_t)ipa_tx_packets; |
| 7227 | rx_packets += (uint64_t)ipa_rx_packets; |
| 7228 | |
Yun Park | 2aa880c | 2017-08-22 10:58:10 -0700 | [diff] [blame] | 7229 | if (adapter) { |
| 7230 | adapter->stats.tx_packets += ipa_tx_packets; |
| 7231 | adapter->stats.rx_packets += ipa_rx_packets; |
| 7232 | } |
| 7233 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7234 | if (!connected) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 7235 | hdd_err("bus bandwidth timer running in disconnected state"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7236 | return; |
| 7237 | } |
| 7238 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7239 | hdd_pld_request_bus_bandwidth(hdd_ctx, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7240 | |
| 7241 | hdd_ipa_set_perf_level(hdd_ctx, tx_packets, rx_packets); |
| 7242 | hdd_ipa_uc_stat_request(adapter, 2); |
| 7243 | |
Jingxiang Ge | c64e193 | 2017-08-22 14:38:59 +0800 | [diff] [blame] | 7244 | restart_timer: |
Dustin Brown | 2ed6036 | 2017-01-18 12:25:50 -0800 | [diff] [blame] | 7245 | /* ensure periodic timer should still be running before restarting it */ |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7246 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 2ed6036 | 2017-01-18 12:25:50 -0800 | [diff] [blame] | 7247 | if (hdd_ctx->bus_bw_timer_running) |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 7248 | qdf_timer_mod(&hdd_ctx->bus_bw_timer, |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7249 | hdd_ctx->config->busBandwidthComputeInterval); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7250 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7251 | } |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7252 | |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7253 | /** |
| 7254 | * __hdd_bus_bw_cbk() - Bus bandwidth data structure callback. |
| 7255 | * @arg: Argument of timer function |
| 7256 | * |
| 7257 | * Schedule a workqueue in this function where all the processing is done. |
| 7258 | * |
| 7259 | * Return: None. |
| 7260 | */ |
| 7261 | static void __hdd_bus_bw_cbk(void *arg) |
| 7262 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7263 | struct hdd_context *hdd_ctx = (struct hdd_context *) arg; |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7264 | |
| 7265 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 7266 | return; |
| 7267 | |
| 7268 | schedule_work(&hdd_ctx->bus_bw_work); |
| 7269 | } |
| 7270 | |
| 7271 | /** |
| 7272 | * hdd_bus_bw_cbk() - Wrapper for bus bw callback for SSR protection. |
| 7273 | * @arg: Argument of timer function |
| 7274 | * |
| 7275 | * Return: None. |
| 7276 | */ |
| 7277 | static void hdd_bus_bw_cbk(void *arg) |
| 7278 | { |
| 7279 | cds_ssr_protect(__func__); |
| 7280 | __hdd_bus_bw_cbk(arg); |
| 7281 | cds_ssr_unprotect(__func__); |
| 7282 | } |
| 7283 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7284 | int hdd_bus_bandwidth_init(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7285 | { |
| 7286 | spin_lock_init(&hdd_ctx->bus_bw_lock); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7287 | INIT_WORK(&hdd_ctx->bus_bw_work, |
| 7288 | hdd_bus_bw_work_handler); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7289 | hdd_ctx->bus_bw_timer_running = false; |
| 7290 | qdf_spinlock_create(&hdd_ctx->bus_bw_timer_lock); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7291 | qdf_timer_init(NULL, |
| 7292 | &hdd_ctx->bus_bw_timer, |
| 7293 | hdd_bus_bw_cbk, (void *)hdd_ctx, |
| 7294 | QDF_TIMER_TYPE_SW); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7295 | |
| 7296 | return 0; |
| 7297 | } |
| 7298 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7299 | void hdd_bus_bandwidth_destroy(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7300 | { |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7301 | if (hdd_ctx->bus_bw_timer_running) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7302 | hdd_reset_tcp_delack(hdd_ctx); |
| 7303 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7304 | hdd_debug("wait for bus bw work to flush"); |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 7305 | hdd_cancel_bus_bw_work(hdd_ctx); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7306 | qdf_timer_free(&hdd_ctx->bus_bw_timer); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7307 | hdd_ctx->bus_bw_timer_running = false; |
| 7308 | qdf_spinlock_destroy(&hdd_ctx->bus_bw_timer_lock); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7309 | } |
Lin Bai | c5c0688 | 2017-09-21 13:58:43 +0800 | [diff] [blame] | 7310 | |
| 7311 | void hdd_bus_bw_cancel_work(struct hdd_context *hdd_ctx) |
| 7312 | { |
| 7313 | if (hdd_ctx) |
| 7314 | cancel_work_sync(&hdd_ctx->bus_bw_work); |
| 7315 | } |
jiad | cdaf9bd | 2017-10-26 12:20:21 +0800 | [diff] [blame] | 7316 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7317 | #endif |
| 7318 | |
| 7319 | /** |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7320 | * wlan_hdd_init_tx_rx_histogram() - init tx/rx histogram stats |
| 7321 | * @hdd_ctx: hdd context |
| 7322 | * |
| 7323 | * Return: 0 for success or error code |
| 7324 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7325 | 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] | 7326 | { |
| 7327 | hdd_ctx->hdd_txrx_hist = qdf_mem_malloc( |
| 7328 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
| 7329 | if (hdd_ctx->hdd_txrx_hist == NULL) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 7330 | hdd_err("Failed malloc for hdd_txrx_hist"); |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7331 | return -ENOMEM; |
| 7332 | } |
| 7333 | return 0; |
| 7334 | } |
| 7335 | |
| 7336 | /** |
| 7337 | * wlan_hdd_deinit_tx_rx_histogram() - deinit tx/rx histogram stats |
| 7338 | * @hdd_ctx: hdd context |
| 7339 | * |
| 7340 | * Return: none |
| 7341 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7342 | void wlan_hdd_deinit_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7343 | { |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 7344 | if (!hdd_ctx || hdd_ctx->hdd_txrx_hist == NULL) |
| 7345 | return; |
| 7346 | |
| 7347 | qdf_mem_free(hdd_ctx->hdd_txrx_hist); |
| 7348 | hdd_ctx->hdd_txrx_hist = NULL; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7349 | } |
| 7350 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7351 | static uint8_t *convert_level_to_string(uint32_t level) |
| 7352 | { |
| 7353 | switch (level) { |
| 7354 | /* initialize the wlan sub system */ |
| 7355 | case WLAN_SVC_TP_NONE: |
| 7356 | return "NONE"; |
| 7357 | case WLAN_SVC_TP_LOW: |
| 7358 | return "LOW"; |
| 7359 | case WLAN_SVC_TP_MEDIUM: |
| 7360 | return "MED"; |
| 7361 | case WLAN_SVC_TP_HIGH: |
| 7362 | return "HIGH"; |
| 7363 | default: |
| 7364 | return "INVAL"; |
| 7365 | } |
| 7366 | } |
| 7367 | |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7368 | |
| 7369 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7370 | * wlan_hdd_display_tx_rx_histogram() - display tx rx histogram |
| 7371 | * @hdd_ctx: hdd context |
| 7372 | * |
| 7373 | * Return: none |
| 7374 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7375 | void wlan_hdd_display_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7376 | { |
| 7377 | int i; |
| 7378 | |
| 7379 | #ifdef MSM_PLATFORM |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7380 | hdd_debug("BW compute Interval: %dms", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7381 | hdd_ctx->config->busBandwidthComputeInterval); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7382 | 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] | 7383 | hdd_ctx->config->busBandwidthHighThreshold, |
| 7384 | hdd_ctx->config->busBandwidthMediumThreshold, |
| 7385 | hdd_ctx->config->busBandwidthLowThreshold); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7386 | hdd_debug("Enable TCP DEL ACK: %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7387 | hdd_ctx->config->enable_tcp_delack); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7388 | hdd_debug("TCP DEL High TH: %d TCP DEL Low TH: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7389 | hdd_ctx->config->tcpDelackThresholdHigh, |
| 7390 | hdd_ctx->config->tcpDelackThresholdLow); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7391 | 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] | 7392 | hdd_ctx->config->tcp_tx_high_tput_thres); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7393 | #endif |
| 7394 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7395 | hdd_debug("Total entries: %d Current index: %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7396 | NUM_TX_RX_HISTOGRAM, hdd_ctx->hdd_txrx_hist_idx); |
| 7397 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7398 | 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] | 7399 | |
| 7400 | for (i = 0; i < NUM_TX_RX_HISTOGRAM; i++) { |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7401 | /* using hdd_log to avoid printing function name */ |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7402 | if (hdd_ctx->hdd_txrx_hist[i].qtime > 0) |
Dustin Brown | 632af71 | 2018-03-14 15:03:55 -0700 | [diff] [blame] | 7403 | hdd_debug("[%3d][%15llu]: %6llu, %6llu, %s, %s, %s", |
| 7404 | i, hdd_ctx->hdd_txrx_hist[i].qtime, |
| 7405 | hdd_ctx->hdd_txrx_hist[i].interval_rx, |
| 7406 | hdd_ctx->hdd_txrx_hist[i].interval_tx, |
| 7407 | convert_level_to_string( |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7408 | hdd_ctx->hdd_txrx_hist[i]. |
| 7409 | next_vote_level), |
Dustin Brown | 632af71 | 2018-03-14 15:03:55 -0700 | [diff] [blame] | 7410 | convert_level_to_string( |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7411 | hdd_ctx->hdd_txrx_hist[i]. |
| 7412 | next_rx_level), |
Dustin Brown | 632af71 | 2018-03-14 15:03:55 -0700 | [diff] [blame] | 7413 | convert_level_to_string( |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7414 | hdd_ctx->hdd_txrx_hist[i]. |
| 7415 | next_tx_level)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7416 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7417 | } |
| 7418 | |
| 7419 | /** |
| 7420 | * wlan_hdd_clear_tx_rx_histogram() - clear tx rx histogram |
| 7421 | * @hdd_ctx: hdd context |
| 7422 | * |
| 7423 | * Return: none |
| 7424 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7425 | void wlan_hdd_clear_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7426 | { |
| 7427 | hdd_ctx->hdd_txrx_hist_idx = 0; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7428 | qdf_mem_zero(hdd_ctx->hdd_txrx_hist, |
| 7429 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7430 | } |
| 7431 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7432 | /* length of the netif queue log needed per adapter */ |
| 7433 | #define ADAP_NETIFQ_LOG_LEN ((20 * WLAN_REASON_TYPE_MAX) + 50) |
| 7434 | |
| 7435 | /** |
| 7436 | * |
| 7437 | * hdd_display_netif_queue_history_compact() - display compact netifq history |
| 7438 | * @hdd_ctx: hdd context |
| 7439 | * |
| 7440 | * Return: none |
| 7441 | */ |
| 7442 | static void |
| 7443 | hdd_display_netif_queue_history_compact(struct hdd_context *hdd_ctx) |
| 7444 | { |
| 7445 | int adapter_num = 0; |
| 7446 | int i; |
| 7447 | int bytes_written; |
| 7448 | u32 tbytes; |
| 7449 | qdf_time_t total, pause, unpause, curr_time, delta; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7450 | char temp_str[20 * WLAN_REASON_TYPE_MAX]; |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 7451 | char *comb_log_str; |
| 7452 | uint32_t comb_log_str_size; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7453 | struct hdd_adapter *adapter = NULL; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7454 | |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 7455 | comb_log_str_size = (ADAP_NETIFQ_LOG_LEN * MAX_NUMBER_OF_ADAPTERS) + 1; |
| 7456 | comb_log_str = qdf_mem_malloc(comb_log_str_size); |
| 7457 | if (!comb_log_str) { |
| 7458 | hdd_err("failed to alloc comb_log_str"); |
| 7459 | return; |
| 7460 | } |
| 7461 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7462 | bytes_written = 0; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7463 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7464 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7465 | curr_time = qdf_system_ticks(); |
| 7466 | total = curr_time - adapter->start_time; |
| 7467 | delta = curr_time - adapter->last_time; |
| 7468 | |
| 7469 | if (adapter->pause_map) { |
| 7470 | pause = adapter->total_pause_time + delta; |
| 7471 | unpause = adapter->total_unpause_time; |
| 7472 | } else { |
| 7473 | unpause = adapter->total_unpause_time + delta; |
| 7474 | pause = adapter->total_pause_time; |
| 7475 | } |
| 7476 | |
| 7477 | tbytes = 0; |
| 7478 | qdf_mem_set(temp_str, 0, sizeof(temp_str)); |
| 7479 | for (i = WLAN_CONTROL_PATH; i < WLAN_REASON_TYPE_MAX; i++) { |
| 7480 | if (adapter->queue_oper_stats[i].pause_count == 0) |
| 7481 | continue; |
| 7482 | tbytes += |
| 7483 | snprintf( |
| 7484 | &temp_str[tbytes], |
| 7485 | (tbytes >= sizeof(temp_str) ? |
| 7486 | 0 : sizeof(temp_str) - tbytes), |
| 7487 | "%d(%d,%d) ", |
| 7488 | i, |
| 7489 | adapter->queue_oper_stats[i]. |
| 7490 | pause_count, |
| 7491 | adapter->queue_oper_stats[i]. |
| 7492 | unpause_count); |
| 7493 | } |
| 7494 | if (tbytes >= sizeof(temp_str)) |
| 7495 | hdd_warn("log truncated"); |
| 7496 | |
| 7497 | bytes_written += snprintf(&comb_log_str[bytes_written], |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 7498 | bytes_written >= comb_log_str_size ? 0 : |
| 7499 | comb_log_str_size - bytes_written, |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7500 | "[%d %d] (%d) %u/%ums %s|", |
| 7501 | adapter->session_id, adapter->device_mode, |
| 7502 | adapter->pause_map, |
| 7503 | qdf_system_ticks_to_msecs(pause), |
| 7504 | qdf_system_ticks_to_msecs(total), |
| 7505 | temp_str); |
| 7506 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7507 | adapter_num++; |
| 7508 | } |
| 7509 | |
| 7510 | /* using QDF_TRACE to avoid printing function name */ |
| 7511 | QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_INFO_LOW, |
| 7512 | "STATS |%s", comb_log_str); |
| 7513 | |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 7514 | if (bytes_written >= comb_log_str_size) |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7515 | hdd_warn("log string truncated"); |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 7516 | |
| 7517 | qdf_mem_free(comb_log_str); |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7518 | } |
| 7519 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7520 | /** |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 7521 | * wlan_hdd_display_netif_queue_history() - display netif queue history |
Jeff Johnson | 58adbcf | 2017-09-03 08:53:31 -0700 | [diff] [blame] | 7522 | * @hdd_ctx: hdd context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7523 | * |
| 7524 | * Return: none |
| 7525 | */ |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7526 | void |
| 7527 | wlan_hdd_display_netif_queue_history(struct hdd_context *hdd_ctx, |
| 7528 | enum qdf_stats_verbosity_level verb_lvl) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7529 | { |
| 7530 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7531 | struct hdd_adapter *adapter = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7532 | int i; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7533 | qdf_time_t total, pause, unpause, curr_time, delta; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7534 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7535 | if (verb_lvl == QDF_STATS_VERBOSITY_LEVEL_LOW) { |
| 7536 | hdd_display_netif_queue_history_compact(hdd_ctx); |
| 7537 | return; |
| 7538 | } |
| 7539 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7540 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7541 | hdd_debug("Netif queue operation statistics:"); |
| 7542 | hdd_debug("Session_id %d device mode %d", |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 7543 | adapter->session_id, adapter->device_mode); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7544 | hdd_debug("Current pause_map value %x", adapter->pause_map); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7545 | curr_time = qdf_system_ticks(); |
| 7546 | total = curr_time - adapter->start_time; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7547 | delta = curr_time - adapter->last_time; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7548 | if (adapter->pause_map) { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7549 | pause = adapter->total_pause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7550 | unpause = adapter->total_unpause_time; |
| 7551 | } else { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7552 | unpause = adapter->total_unpause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7553 | pause = adapter->total_pause_time; |
| 7554 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7555 | hdd_debug("Total: %ums Pause: %ums Unpause: %ums", |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7556 | qdf_system_ticks_to_msecs(total), |
| 7557 | qdf_system_ticks_to_msecs(pause), |
| 7558 | qdf_system_ticks_to_msecs(unpause)); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7559 | hdd_debug("reason_type: pause_cnt: unpause_cnt: pause_time"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7560 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7561 | for (i = WLAN_CONTROL_PATH; i < WLAN_REASON_TYPE_MAX; i++) { |
| 7562 | qdf_time_t pause_delta = 0; |
| 7563 | |
| 7564 | if (adapter->pause_map & (1 << i)) |
| 7565 | pause_delta = delta; |
| 7566 | |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7567 | /* using hdd_log to avoid printing function name */ |
Dustin Brown | 632af71 | 2018-03-14 15:03:55 -0700 | [diff] [blame] | 7568 | hdd_debug("%s: %d: %d: %ums", |
| 7569 | hdd_reason_type_to_string(i), |
| 7570 | adapter->queue_oper_stats[i].pause_count, |
| 7571 | adapter->queue_oper_stats[i].unpause_count, |
| 7572 | qdf_system_ticks_to_msecs( |
| 7573 | adapter->queue_oper_stats[i].total_pause_time + |
| 7574 | pause_delta)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7575 | } |
| 7576 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7577 | hdd_debug("Netif queue operation history:"); |
| 7578 | hdd_debug("Total entries: %d current index %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7579 | WLAN_HDD_MAX_HISTORY_ENTRY, adapter->history_index); |
| 7580 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7581 | hdd_debug("index: time: action_type: reason_type: pause_map"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7582 | |
| 7583 | for (i = 0; i < WLAN_HDD_MAX_HISTORY_ENTRY; i++) { |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7584 | /* using hdd_log to avoid printing function name */ |
| 7585 | if (adapter->queue_oper_history[i].time == 0) |
| 7586 | continue; |
Dustin Brown | 632af71 | 2018-03-14 15:03:55 -0700 | [diff] [blame] | 7587 | hdd_debug("%d: %u: %s: %s: %x", |
| 7588 | i, qdf_system_ticks_to_msecs( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7589 | adapter->queue_oper_history[i].time), |
Dustin Brown | 632af71 | 2018-03-14 15:03:55 -0700 | [diff] [blame] | 7590 | hdd_action_type_to_string( |
| 7591 | adapter->queue_oper_history[i].netif_action), |
| 7592 | hdd_reason_type_to_string( |
| 7593 | adapter->queue_oper_history[i].netif_reason), |
| 7594 | adapter->queue_oper_history[i].pause_map); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7595 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7596 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7597 | } |
| 7598 | |
| 7599 | /** |
| 7600 | * wlan_hdd_clear_netif_queue_history() - clear netif queue operation history |
| 7601 | * @hdd_ctx: hdd context |
| 7602 | * |
| 7603 | * Return: none |
| 7604 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7605 | void wlan_hdd_clear_netif_queue_history(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7606 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7607 | struct hdd_adapter *adapter = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7608 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7609 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7610 | qdf_mem_zero(adapter->queue_oper_stats, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7611 | sizeof(adapter->queue_oper_stats)); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7612 | qdf_mem_zero(adapter->queue_oper_history, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7613 | sizeof(adapter->queue_oper_history)); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7614 | adapter->history_index = 0; |
| 7615 | adapter->start_time = adapter->last_time = qdf_system_ticks(); |
| 7616 | adapter->total_pause_time = 0; |
| 7617 | adapter->total_unpause_time = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7618 | } |
| 7619 | } |
| 7620 | |
| 7621 | /** |
| 7622 | * hdd_11d_scan_done() - callback for 11d scan completion of flushing results |
| 7623 | * @halHandle: Hal handle |
| 7624 | * @pContext: Pointer to the context |
| 7625 | * @sessionId: Session ID |
| 7626 | * @scanId: Scan ID |
| 7627 | * @status: Status |
| 7628 | * |
| 7629 | * This is the callback to be executed when 11d scan is completed to flush out |
| 7630 | * the scan results |
| 7631 | * |
| 7632 | * 11d scan is done during driver load and is a passive scan on all |
| 7633 | * channels supported by the device, 11d scans may find some APs on |
| 7634 | * frequencies which are forbidden to be used in the regulatory domain |
| 7635 | * the device is operating in. If these APs are notified to the supplicant |
| 7636 | * it may try to connect to these APs, thus flush out all the scan results |
| 7637 | * which are present in SME after 11d scan is done. |
| 7638 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7639 | * Return: QDF_STATUS_SUCCESS |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7640 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7641 | static QDF_STATUS hdd_11d_scan_done(tHalHandle halHandle, void *pContext, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7642 | uint8_t sessionId, uint32_t scanId, |
| 7643 | eCsrScanStatus status) |
| 7644 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 7645 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7646 | |
| 7647 | sme_scan_flush_result(halHandle); |
| 7648 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 7649 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7650 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7651 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7652 | } |
| 7653 | |
| 7654 | #ifdef WLAN_FEATURE_OFFLOAD_PACKETS |
| 7655 | /** |
| 7656 | * hdd_init_offloaded_packets_ctx() - Initialize offload packets context |
| 7657 | * @hdd_ctx: hdd global context |
| 7658 | * |
| 7659 | * Return: none |
| 7660 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7661 | static void hdd_init_offloaded_packets_ctx(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7662 | { |
| 7663 | uint8_t i; |
| 7664 | |
| 7665 | mutex_init(&hdd_ctx->op_ctx.op_lock); |
| 7666 | for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++) { |
| 7667 | hdd_ctx->op_ctx.op_table[i].request_id = MAX_REQUEST_ID; |
| 7668 | hdd_ctx->op_ctx.op_table[i].pattern_id = i; |
| 7669 | } |
| 7670 | } |
| 7671 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7672 | static void hdd_init_offloaded_packets_ctx(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7673 | { |
| 7674 | } |
| 7675 | #endif |
| 7676 | |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7677 | #ifdef WLAN_FEATURE_WOW_PULSE |
| 7678 | /** |
| 7679 | * 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] | 7680 | * @phddctx: struct hdd_context structure pointer |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7681 | * @enable: enable or disable this behaviour |
| 7682 | * |
| 7683 | * Return: int |
| 7684 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7685 | 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] | 7686 | { |
| 7687 | struct hdd_config *pcfg_ini = phddctx->config; |
| 7688 | struct wow_pulse_mode wow_pulse_set_info; |
| 7689 | QDF_STATUS status; |
| 7690 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7691 | hdd_debug("wow pulse enable flag is %d", enable); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7692 | |
| 7693 | if (false == phddctx->config->wow_pulse_support) |
| 7694 | return 0; |
| 7695 | |
| 7696 | /* prepare the request to send to SME */ |
| 7697 | if (enable == true) { |
| 7698 | wow_pulse_set_info.wow_pulse_enable = true; |
| 7699 | wow_pulse_set_info.wow_pulse_pin = |
| 7700 | pcfg_ini->wow_pulse_pin; |
| 7701 | wow_pulse_set_info.wow_pulse_interval_low = |
| 7702 | pcfg_ini->wow_pulse_interval_low; |
| 7703 | wow_pulse_set_info.wow_pulse_interval_high = |
| 7704 | pcfg_ini->wow_pulse_interval_high; |
| 7705 | } else { |
| 7706 | wow_pulse_set_info.wow_pulse_enable = false; |
| 7707 | wow_pulse_set_info.wow_pulse_pin = 0; |
| 7708 | wow_pulse_set_info.wow_pulse_interval_low = 0; |
| 7709 | wow_pulse_set_info.wow_pulse_interval_high = 0; |
| 7710 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7711 | hdd_debug("enable %d pin %d low %d high %d", |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7712 | wow_pulse_set_info.wow_pulse_enable, |
| 7713 | wow_pulse_set_info.wow_pulse_pin, |
| 7714 | wow_pulse_set_info.wow_pulse_interval_low, |
| 7715 | wow_pulse_set_info.wow_pulse_interval_high); |
| 7716 | |
| 7717 | status = sme_set_wow_pulse(&wow_pulse_set_info); |
| 7718 | if (QDF_STATUS_E_FAILURE == status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7719 | hdd_debug("sme_set_wow_pulse failure!"); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7720 | return -EIO; |
| 7721 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7722 | hdd_debug("sme_set_wow_pulse success!"); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7723 | return 0; |
| 7724 | } |
| 7725 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7726 | 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] | 7727 | { |
| 7728 | return 0; |
| 7729 | } |
| 7730 | #endif |
| 7731 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7732 | #ifdef WLAN_FEATURE_FASTPATH |
| 7733 | /** |
| 7734 | * hdd_enable_fastpath() - Enable fastpath if enabled in config INI |
| 7735 | * @hdd_cfg: hdd config |
| 7736 | * @context: lower layer context |
| 7737 | * |
| 7738 | * Return: none |
| 7739 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7740 | void hdd_enable_fastpath(struct hdd_config *hdd_cfg, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7741 | void *context) |
| 7742 | { |
| 7743 | if (hdd_cfg->fastpath_enable) |
| 7744 | hif_enable_fastpath(context); |
| 7745 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7746 | #endif |
| 7747 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7748 | #if defined(FEATURE_WLAN_CH_AVOID) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7749 | /** |
| 7750 | * hdd_set_thermal_level_cb() - set thermal level callback function |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7751 | * @context: hdd context pointer |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7752 | * @level: thermal level |
| 7753 | * |
| 7754 | * Change IPA data path to SW path when the thermal throttle level greater |
| 7755 | * than 0, and restore the original data path when throttle level is 0 |
| 7756 | * |
| 7757 | * Return: none |
| 7758 | */ |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7759 | 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] | 7760 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7761 | struct hdd_context *hdd_ctx = context; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7762 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7763 | /* Change IPA to SW path when throttle level greater than 0 */ |
| 7764 | if (level > THROTTLE_LEVEL_0) |
| 7765 | hdd_ipa_send_mcc_scc_msg(hdd_ctx, true); |
| 7766 | else |
| 7767 | /* restore original concurrency mode */ |
| 7768 | hdd_ipa_send_mcc_scc_msg(hdd_ctx, hdd_ctx->mcc_mode); |
| 7769 | } |
| 7770 | |
| 7771 | /** |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7772 | * hdd_get_safe_channel_from_pcl_and_acs_range() - Get safe channel for SAP |
| 7773 | * restart |
Manishekar Chandrasekaran | db9b867 | 2016-06-10 23:31:19 +0530 | [diff] [blame] | 7774 | * @adapter: AP adapter, which should be checked for NULL |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7775 | * |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7776 | * Get a safe channel to restart SAP. PCL already takes into account the |
| 7777 | * unsafe channels. So, the PCL is validated with the ACS range to provide |
| 7778 | * a safe channel for the SAP to restart. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7779 | * |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7780 | * Return: Channel number to restart SAP in case of success. In case of any |
| 7781 | * failure, the channel number returned is zero. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7782 | */ |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7783 | static uint8_t hdd_get_safe_channel_from_pcl_and_acs_range( |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7784 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7785 | { |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7786 | struct sir_pcl_list pcl; |
| 7787 | QDF_STATUS status; |
| 7788 | uint32_t i, j; |
| 7789 | tHalHandle *hal_handle; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7790 | struct hdd_context *hdd_ctx; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7791 | bool found = false; |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 7792 | int ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7793 | |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7794 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 7795 | if (!hdd_ctx) { |
| 7796 | hdd_err("invalid HDD context"); |
| 7797 | return INVALID_CHANNEL_ID; |
| 7798 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7799 | |
Manishekar Chandrasekaran | 79746ac | 2016-06-24 04:45:33 +0530 | [diff] [blame] | 7800 | hal_handle = WLAN_HDD_GET_HAL_CTX(adapter); |
| 7801 | if (!hal_handle) { |
| 7802 | hdd_err("invalid HAL handle"); |
| 7803 | return INVALID_CHANNEL_ID; |
| 7804 | } |
| 7805 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7806 | status = policy_mgr_get_pcl_for_existing_conn(hdd_ctx->hdd_psoc, |
| 7807 | PM_SAP_MODE, pcl.pcl_list, &pcl.pcl_len, |
bings | 37bd58f | 2017-07-20 16:49:26 +0800 | [diff] [blame] | 7808 | pcl.weight_list, QDF_ARRAY_SIZE(pcl.weight_list), |
| 7809 | false); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7810 | if (QDF_IS_STATUS_ERROR(status)) { |
| 7811 | hdd_err("Get PCL failed"); |
| 7812 | return INVALID_CHANNEL_ID; |
| 7813 | } |
| 7814 | |
Frank Liu | dc2cefb | 2017-06-21 15:38:18 +0800 | [diff] [blame] | 7815 | /* |
| 7816 | * In some scenarios, like hw dbs disabled, sap+sap case, if operating |
| 7817 | * channel is unsafe channel, the pcl may be empty, instead of return, |
| 7818 | * try to choose a safe channel from acs range. |
| 7819 | */ |
| 7820 | if (!pcl.pcl_len) |
| 7821 | hdd_debug("pcl length is zero!"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7822 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7823 | hdd_debug("start:%d end:%d", |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7824 | adapter->session.ap.sap_config.acs_cfg.start_ch, |
| 7825 | adapter->session.ap.sap_config.acs_cfg.end_ch); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7826 | |
| 7827 | /* PCL already takes unsafe channel into account */ |
| 7828 | for (i = 0; i < pcl.pcl_len; i++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7829 | hdd_debug("chan[%d]:%d", i, pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7830 | if ((pcl.pcl_list[i] >= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7831 | adapter->session.ap.sap_config.acs_cfg.start_ch) && |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7832 | (pcl.pcl_list[i] <= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7833 | adapter->session.ap.sap_config.acs_cfg.end_ch)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7834 | hdd_debug("found PCL safe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7835 | return pcl.pcl_list[i]; |
| 7836 | } |
| 7837 | } |
| 7838 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7839 | hdd_debug("no safe channel from PCL found in ACS range"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7840 | |
| 7841 | /* Try for safe channel from all valid channel */ |
| 7842 | pcl.pcl_len = MAX_NUM_CHAN; |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 7843 | ret = hdd_get_valid_chan(hdd_ctx, pcl.pcl_list, |
| 7844 | &pcl.pcl_len); |
| 7845 | if (ret) { |
| 7846 | hdd_err("error %d in getting valid channel list", ret); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7847 | return INVALID_CHANNEL_ID; |
| 7848 | } |
| 7849 | |
| 7850 | for (i = 0; i < pcl.pcl_len; i++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7851 | hdd_debug("chan[%d]:%d", i, pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7852 | found = false; |
| 7853 | for (j = 0; j < hdd_ctx->unsafe_channel_count; j++) { |
Krunal Soni | 15f0db1 | 2016-10-11 18:53:37 -0700 | [diff] [blame] | 7854 | if (pcl.pcl_list[i] == |
| 7855 | hdd_ctx->unsafe_channel_list[j]) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7856 | hdd_debug("unsafe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7857 | found = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7858 | break; |
| 7859 | } |
| 7860 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7861 | |
| 7862 | if (found) |
| 7863 | continue; |
| 7864 | |
| 7865 | if ((pcl.pcl_list[i] >= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7866 | adapter->session.ap.sap_config.acs_cfg.start_ch) && |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7867 | (pcl.pcl_list[i] <= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7868 | adapter->session.ap.sap_config.acs_cfg.end_ch)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7869 | hdd_debug("found safe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7870 | return pcl.pcl_list[i]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7871 | } |
| 7872 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7873 | |
| 7874 | return INVALID_CHANNEL_ID; |
| 7875 | } |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 7876 | #endif |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7877 | |
| 7878 | /** |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 7879 | * hdd_switch_sap_channel() - Move SAP to the given channel |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7880 | * @adapter: AP adapter |
| 7881 | * @channel: Channel |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 7882 | * @forced: Force to switch channel, ignore SCC/MCC check |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7883 | * |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 7884 | * Moves the SAP interface by invoking the function which |
| 7885 | * executes the callback to perform channel switch using (E)CSA. |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7886 | * |
| 7887 | * Return: None |
| 7888 | */ |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 7889 | void hdd_switch_sap_channel(struct hdd_adapter *adapter, uint8_t channel, |
| 7890 | bool forced) |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7891 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 7892 | struct hdd_ap_ctx *hdd_ap_ctx; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7893 | tHalHandle *hal_handle; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7894 | struct hdd_context *hdd_ctx; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7895 | |
| 7896 | if (!adapter) { |
| 7897 | hdd_err("invalid adapter"); |
| 7898 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7899 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7900 | |
| 7901 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 7902 | |
| 7903 | hal_handle = WLAN_HDD_GET_HAL_CTX(adapter); |
| 7904 | if (!hal_handle) { |
| 7905 | hdd_err("invalid HAL handle"); |
| 7906 | return; |
| 7907 | } |
| 7908 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7909 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 7910 | |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 7911 | hdd_ap_ctx->sap_config.channel = channel; |
| 7912 | hdd_ap_ctx->sap_config.ch_params.ch_width = |
| 7913 | hdd_ap_ctx->sap_config.ch_width_orig; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7914 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7915 | hdd_debug("chan:%d width:%d", |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 7916 | channel, hdd_ap_ctx->sap_config.ch_width_orig); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7917 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 7918 | wlan_reg_set_channel_params(hdd_ctx->hdd_pdev, |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 7919 | hdd_ap_ctx->sap_config.channel, |
| 7920 | hdd_ap_ctx->sap_config.sec_ch, |
| 7921 | &hdd_ap_ctx->sap_config.ch_params); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7922 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7923 | policy_mgr_change_sap_channel_with_csa(hdd_ctx->hdd_psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 7924 | adapter->session_id, channel, |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 7925 | hdd_ap_ctx->sap_config.ch_width_orig, forced); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7926 | } |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7927 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7928 | 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] | 7929 | { |
| 7930 | struct hdd_external_acs_timer_context *timer_context; |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 7931 | int status; |
| 7932 | QDF_STATUS qdf_status; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7933 | |
| 7934 | set_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
| 7935 | |
| 7936 | if (QDF_TIMER_STATE_RUNNING == |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7937 | qdf_mc_timer_get_current_state(&adapter->session. |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7938 | ap.vendor_acs_timer)) { |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7939 | qdf_mc_timer_stop(&adapter->session.ap.vendor_acs_timer); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7940 | } |
| 7941 | timer_context = (struct hdd_external_acs_timer_context *) |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7942 | adapter->session.ap.vendor_acs_timer.user_data; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7943 | timer_context->reason = reason; |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 7944 | qdf_status = |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7945 | qdf_mc_timer_start(&adapter->session.ap.vendor_acs_timer, |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 7946 | WLAN_VENDOR_ACS_WAIT_TIME); |
| 7947 | if (qdf_status != QDF_STATUS_SUCCESS) { |
| 7948 | hdd_err("failed to start external acs timer"); |
| 7949 | return -ENOSPC; |
| 7950 | } |
| 7951 | /* Update config to application */ |
| 7952 | status = hdd_cfg80211_update_acs_config(adapter, reason); |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 7953 | hdd_info("Updated ACS config to nl with reason %d", reason); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7954 | |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 7955 | return status; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7956 | } |
| 7957 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 7958 | #if defined(FEATURE_WLAN_CH_AVOID) |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7959 | /** |
| 7960 | * hdd_unsafe_channel_restart_sap() - restart sap if sap is on unsafe channel |
| 7961 | * @hdd_ctx: hdd context pointer |
| 7962 | * |
| 7963 | * hdd_unsafe_channel_restart_sap check all unsafe channel list |
| 7964 | * and if ACS is enabled, driver will ask userspace to restart the |
| 7965 | * sap. User space on LTE coex indication restart driver. |
| 7966 | * |
| 7967 | * Return - none |
| 7968 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7969 | void hdd_unsafe_channel_restart_sap(struct hdd_context *hdd_ctxt) |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7970 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7971 | struct hdd_adapter *adapter; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7972 | uint32_t i; |
| 7973 | bool found = false; |
| 7974 | uint8_t restart_chan; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7975 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7976 | hdd_for_each_adapter(hdd_ctxt, adapter) { |
| 7977 | if (!(adapter->device_mode == QDF_SAP_MODE && |
| 7978 | adapter->session.ap.sap_config.acs_cfg.acs_mode)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7979 | hdd_debug("skip device mode:%d acs:%d", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7980 | adapter->device_mode, |
| 7981 | adapter->session.ap.sap_config. |
| 7982 | acs_cfg.acs_mode); |
| 7983 | continue; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7984 | } |
| 7985 | |
| 7986 | found = false; |
| 7987 | for (i = 0; i < hdd_ctxt->unsafe_channel_count; i++) { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7988 | if (adapter->session.ap.operating_channel == |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7989 | hdd_ctxt->unsafe_channel_list[i]) { |
| 7990 | found = true; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7991 | hdd_debug("operating ch:%d is unsafe", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7992 | adapter->session.ap.operating_channel); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7993 | break; |
| 7994 | } |
| 7995 | } |
| 7996 | |
| 7997 | if (!found) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7998 | hdd_debug("ch:%d is safe. no need to change channel", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7999 | adapter->session.ap.operating_channel); |
| 8000 | continue; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8001 | } |
| 8002 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8003 | if (hdd_ctxt->config->vendor_acs_support && |
| 8004 | hdd_ctxt->config->acs_support_for_dfs_ltecoex) { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8005 | hdd_update_acs_timer_reason(adapter, |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8006 | QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8007 | continue; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8008 | } else |
| 8009 | restart_chan = |
| 8010 | hdd_get_safe_channel_from_pcl_and_acs_range( |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8011 | adapter); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8012 | if (!restart_chan) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8013 | hdd_err("fail to restart SAP"); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8014 | } else { |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 8015 | /* |
| 8016 | * SAP restart due to unsafe channel. While |
| 8017 | * restarting the SAP, make sure to clear |
| 8018 | * acs_channel, channel to reset to |
| 8019 | * 0. Otherwise these settings will override |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 8020 | * the ACS while restart. |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 8021 | */ |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 8022 | hdd_ctxt->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8023 | adapter->session.ap.sap_config.channel = |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 8024 | AUTO_CHANNEL_SELECT; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8025 | hdd_debug("sending coex indication"); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8026 | wlan_hdd_send_svc_nlink_msg(hdd_ctxt->radio_index, |
| 8027 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
Liangwei Dong | 6663d16 | 2017-07-10 03:29:36 -0400 | [diff] [blame] | 8028 | hdd_debug("driver to start sap: %d", |
| 8029 | hdd_ctxt->config->sap_internal_restart); |
| 8030 | if (hdd_ctxt->config->sap_internal_restart) |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8031 | hdd_switch_sap_channel(adapter, restart_chan, |
| 8032 | true); |
Liangwei Dong | 6663d16 | 2017-07-10 03:29:36 -0400 | [diff] [blame] | 8033 | else |
| 8034 | return; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8035 | } |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8036 | } |
| 8037 | } |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 8038 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8039 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8040 | * hdd_init_channel_avoidance() - Initialize channel avoidance |
| 8041 | * @hdd_ctx: HDD global context |
| 8042 | * |
| 8043 | * Initialize the channel avoidance logic by retrieving the unsafe |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8044 | * channel list from the platform driver and plumbing the data |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8045 | * down to the lower layers. Then subscribe to subsequent channel |
| 8046 | * avoidance events. |
| 8047 | * |
| 8048 | * Return: None |
| 8049 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8050 | static void hdd_init_channel_avoidance(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8051 | { |
| 8052 | uint16_t unsafe_channel_count; |
| 8053 | int index; |
| 8054 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8055 | pld_get_wlan_unsafe_channel(hdd_ctx->parent_dev, |
| 8056 | hdd_ctx->unsafe_channel_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8057 | &(hdd_ctx->unsafe_channel_count), |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 8058 | sizeof(uint16_t) * NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8059 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8060 | hdd_debug("num of unsafe channels is %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8061 | hdd_ctx->unsafe_channel_count); |
| 8062 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8063 | unsafe_channel_count = QDF_MIN((uint16_t)hdd_ctx->unsafe_channel_count, |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 8064 | (uint16_t)NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8065 | |
| 8066 | for (index = 0; index < unsafe_channel_count; index++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8067 | hdd_debug("channel %d is not safe", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8068 | hdd_ctx->unsafe_channel_list[index]); |
| 8069 | |
| 8070 | } |
| 8071 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8072 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8073 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8074 | static void hdd_lte_coex_restart_sap(struct hdd_adapter *adapter, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8075 | struct hdd_context *hdd_ctx) |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8076 | { |
| 8077 | uint8_t restart_chan; |
| 8078 | |
| 8079 | restart_chan = hdd_get_safe_channel_from_pcl_and_acs_range(adapter); |
| 8080 | if (!restart_chan) { |
| 8081 | hdd_alert("fail to restart SAP"); |
| 8082 | return; |
| 8083 | } |
| 8084 | |
| 8085 | /* SAP restart due to unsafe channel. While restarting |
| 8086 | * the SAP, make sure to clear acs_channel, channel to |
| 8087 | * reset to 0. Otherwise these settings will override |
| 8088 | * the ACS while restart. |
| 8089 | */ |
| 8090 | hdd_ctx->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8091 | adapter->session.ap.sap_config.channel = AUTO_CHANNEL_SELECT; |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8092 | |
| 8093 | hdd_debug("sending coex indication"); |
| 8094 | |
| 8095 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 8096 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8097 | hdd_switch_sap_channel(adapter, restart_chan, true); |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8098 | } |
Liangwei Dong | 6e1a209 | 2017-08-30 16:29:06 +0800 | [diff] [blame] | 8099 | |
| 8100 | int hdd_clone_local_unsafe_chan(struct hdd_context *hdd_ctx, |
| 8101 | uint16_t **local_unsafe_list, uint16_t *local_unsafe_list_count) |
| 8102 | { |
| 8103 | uint32_t size; |
| 8104 | uint16_t *unsafe_list; |
| 8105 | uint16_t chan_count; |
| 8106 | |
| 8107 | if (!hdd_ctx || !local_unsafe_list_count || !local_unsafe_list_count) |
| 8108 | return -EINVAL; |
| 8109 | |
| 8110 | chan_count = QDF_MIN(hdd_ctx->unsafe_channel_count, |
| 8111 | NUM_CHANNELS); |
| 8112 | if (chan_count) { |
| 8113 | size = chan_count * sizeof(hdd_ctx->unsafe_channel_list[0]); |
| 8114 | unsafe_list = qdf_mem_malloc(size); |
| 8115 | if (!unsafe_list) { |
| 8116 | hdd_err("No memory for unsafe chan list size%d", |
| 8117 | size); |
| 8118 | return -ENOMEM; |
| 8119 | } |
| 8120 | qdf_mem_copy(unsafe_list, hdd_ctx->unsafe_channel_list, size); |
| 8121 | } else { |
| 8122 | unsafe_list = NULL; |
| 8123 | } |
| 8124 | |
| 8125 | *local_unsafe_list = unsafe_list; |
| 8126 | *local_unsafe_list_count = chan_count; |
| 8127 | |
| 8128 | return 0; |
| 8129 | } |
| 8130 | |
| 8131 | bool hdd_local_unsafe_channel_updated(struct hdd_context *hdd_ctx, |
| 8132 | uint16_t *local_unsafe_list, uint16_t local_unsafe_list_count) |
| 8133 | { |
| 8134 | int i, j; |
| 8135 | |
| 8136 | if (local_unsafe_list_count != hdd_ctx->unsafe_channel_count) |
| 8137 | return true; |
| 8138 | if (local_unsafe_list_count == 0) |
| 8139 | return false; |
| 8140 | for (i = 0; i < local_unsafe_list_count; i++) { |
| 8141 | for (j = 0; j < local_unsafe_list_count; j++) |
| 8142 | if (local_unsafe_list[i] == |
| 8143 | hdd_ctx->unsafe_channel_list[j]) |
| 8144 | break; |
| 8145 | if (j >= local_unsafe_list_count) |
| 8146 | break; |
| 8147 | } |
| 8148 | if (i >= local_unsafe_list_count) { |
| 8149 | hdd_info("unsafe chan list same"); |
| 8150 | return false; |
| 8151 | } |
| 8152 | |
| 8153 | return true; |
| 8154 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8155 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8156 | static void hdd_init_channel_avoidance(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8157 | { |
| 8158 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8159 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8160 | 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] | 8161 | { |
| 8162 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8163 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8164 | static inline void hdd_lte_coex_restart_sap(struct hdd_adapter *adapter, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8165 | struct hdd_context *hdd_ctx) |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8166 | { |
| 8167 | hdd_debug("Channel avoidance is not enabled; Abort SAP restart"); |
| 8168 | } |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8169 | #endif /* defined(FEATURE_WLAN_CH_AVOID) */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8170 | |
| 8171 | /** |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8172 | * hdd_indicate_mgmt_frame() - Wrapper to indicate management frame to |
| 8173 | * user space |
| 8174 | * @frame_ind: Management frame data to be informed. |
| 8175 | * |
| 8176 | * This function is used to indicate management frame to |
| 8177 | * user space |
| 8178 | * |
| 8179 | * Return: None |
| 8180 | * |
| 8181 | */ |
| 8182 | void hdd_indicate_mgmt_frame(tSirSmeMgmtFrameInd *frame_ind) |
| 8183 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8184 | struct hdd_context *hdd_ctx = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8185 | struct hdd_adapter *adapter = NULL; |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8186 | int i; |
| 8187 | |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8188 | /* Get the HDD context.*/ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8189 | hdd_ctx = (struct hdd_context *)cds_get_context(QDF_MODULE_ID_HDD); |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8190 | |
| 8191 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
| 8192 | return; |
| 8193 | |
| 8194 | if (SME_SESSION_ID_ANY == frame_ind->sessionId) { |
| 8195 | for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) { |
| 8196 | adapter = |
| 8197 | hdd_get_adapter_by_sme_session_id(hdd_ctx, i); |
| 8198 | if (adapter) |
| 8199 | break; |
| 8200 | } |
Wu Gao | a0230a6 | 2018-01-04 20:56:57 +0800 | [diff] [blame] | 8201 | } else if (SME_SESSION_ID_BROADCAST == frame_ind->sessionId) { |
| 8202 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 8203 | if ((NULL != adapter) && |
| 8204 | (WLAN_HDD_ADAPTER_MAGIC == adapter->magic)) { |
| 8205 | __hdd_indicate_mgmt_frame(adapter, |
| 8206 | frame_ind->frame_len, |
| 8207 | frame_ind->frameBuf, |
| 8208 | frame_ind->frameType, |
| 8209 | frame_ind->rxChan, |
| 8210 | frame_ind->rxRssi); |
| 8211 | } |
| 8212 | } |
| 8213 | adapter = NULL; |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8214 | } else { |
| 8215 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, |
| 8216 | frame_ind->sessionId); |
| 8217 | } |
| 8218 | |
| 8219 | if ((NULL != adapter) && |
| 8220 | (WLAN_HDD_ADAPTER_MAGIC == adapter->magic)) |
| 8221 | __hdd_indicate_mgmt_frame(adapter, |
| 8222 | frame_ind->frame_len, |
| 8223 | frame_ind->frameBuf, |
| 8224 | frame_ind->frameType, |
| 8225 | frame_ind->rxChan, |
| 8226 | frame_ind->rxRssi); |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8227 | } |
| 8228 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8229 | void hdd_acs_response_timeout_handler(void *context) |
| 8230 | { |
| 8231 | struct hdd_external_acs_timer_context *timer_context = |
| 8232 | (struct hdd_external_acs_timer_context *)context; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8233 | struct hdd_adapter *adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8234 | struct hdd_context *hdd_ctx; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8235 | uint8_t reason; |
| 8236 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 8237 | hdd_enter(); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8238 | if (!timer_context) { |
| 8239 | hdd_err("invlaid timer context"); |
| 8240 | return; |
| 8241 | } |
| 8242 | adapter = timer_context->adapter; |
| 8243 | reason = timer_context->reason; |
| 8244 | |
| 8245 | |
| 8246 | if ((!adapter) || |
| 8247 | (adapter->magic != WLAN_HDD_ADAPTER_MAGIC)) { |
| 8248 | hdd_err("invalid adapter or adapter has invalid magic"); |
| 8249 | return; |
| 8250 | } |
| 8251 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 8252 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 8253 | return; |
| 8254 | |
| 8255 | if (test_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags)) |
| 8256 | clear_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
| 8257 | else |
| 8258 | return; |
| 8259 | |
| 8260 | hdd_err("ACS timeout happened for %s reason %d", |
| 8261 | adapter->dev->name, reason); |
| 8262 | switch (reason) { |
| 8263 | /* SAP init case */ |
| 8264 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_INIT: |
| 8265 | wlan_sap_set_vendor_acs(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 8266 | false); |
| 8267 | wlan_hdd_cfg80211_start_acs(adapter); |
| 8268 | break; |
| 8269 | /* DFS detected on current channel */ |
| 8270 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_DFS: |
| 8271 | wlan_sap_update_next_channel( |
| 8272 | WLAN_HDD_GET_SAP_CTX_PTR(adapter), 0, 0); |
| 8273 | sme_update_new_channel_event(WLAN_HDD_GET_HAL_CTX(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 8274 | adapter->session_id); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8275 | break; |
| 8276 | /* LTE coex event on current channel */ |
| 8277 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX: |
| 8278 | hdd_lte_coex_restart_sap(adapter, hdd_ctx); |
| 8279 | break; |
| 8280 | default: |
| 8281 | hdd_info("invalid reason for timer invoke"); |
| 8282 | |
| 8283 | } |
| 8284 | } |
| 8285 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8286 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8287 | * hdd_override_ini_config - Override INI config |
| 8288 | * @hdd_ctx: HDD context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8289 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8290 | * Override INI config based on module parameter. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8291 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8292 | * Return: None |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8293 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8294 | static void hdd_override_ini_config(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8295 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8296 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8297 | if (0 == enable_dfs_chan_scan || 1 == enable_dfs_chan_scan) { |
| 8298 | hdd_ctx->config->enableDFSChnlScan = enable_dfs_chan_scan; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8299 | hdd_debug("Module enable_dfs_chan_scan set to %d", |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8300 | enable_dfs_chan_scan); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8301 | } |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8302 | if (0 == enable_11d || 1 == enable_11d) { |
| 8303 | hdd_ctx->config->Is11dSupportEnabled = enable_11d; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8304 | hdd_debug("Module enable_11d set to %d", enable_11d); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8305 | } |
Leo Chang | 11545d6 | 2016-10-17 14:53:50 -0700 | [diff] [blame] | 8306 | |
Yun Park | 45d3597 | 2018-03-02 09:57:54 -0800 | [diff] [blame] | 8307 | if (!hdd_ipa_is_present()) { |
Leo Chang | 11545d6 | 2016-10-17 14:53:50 -0700 | [diff] [blame] | 8308 | hdd_ctx->config->IpaConfig = 0; |
Jingxiang Ge | 7a040dc | 2018-02-02 11:07:59 +0800 | [diff] [blame] | 8309 | hdd_debug("IpaConfig override to %d", |
| 8310 | hdd_ctx->config->IpaConfig); |
| 8311 | } |
Yeshwanth Sriram Guntuka | 2ba6fe9 | 2017-10-04 14:40:45 +0530 | [diff] [blame] | 8312 | |
| 8313 | if (!hdd_ctx->config->rssi_assoc_reject_enabled || |
| 8314 | !hdd_ctx->config->enable_bcast_probe_rsp) { |
| 8315 | hdd_debug("OCE disabled, rssi_assoc_reject_enabled: %d enable_bcast_probe_rsp: %d", |
| 8316 | hdd_ctx->config->rssi_assoc_reject_enabled, |
| 8317 | hdd_ctx->config->enable_bcast_probe_rsp); |
| 8318 | hdd_ctx->config->oce_sta_enabled = 0; |
| 8319 | } |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8320 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8321 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8322 | /** |
| 8323 | * hdd_set_trace_level_for_each - Set trace level for each INI config |
| 8324 | * @hdd_ctx - HDD context |
| 8325 | * |
| 8326 | * Set trace level for each module based on INI config. |
| 8327 | * |
| 8328 | * Return: None |
| 8329 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8330 | 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] | 8331 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 8332 | hdd_qdf_trace_enable(QDF_MODULE_ID_WMI, |
| 8333 | hdd_ctx->config->qdf_trace_enable_wdi); |
| 8334 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD, |
| 8335 | hdd_ctx->config->qdf_trace_enable_hdd); |
| 8336 | hdd_qdf_trace_enable(QDF_MODULE_ID_SME, |
| 8337 | hdd_ctx->config->qdf_trace_enable_sme); |
| 8338 | hdd_qdf_trace_enable(QDF_MODULE_ID_PE, |
| 8339 | hdd_ctx->config->qdf_trace_enable_pe); |
| 8340 | hdd_qdf_trace_enable(QDF_MODULE_ID_WMA, |
| 8341 | hdd_ctx->config->qdf_trace_enable_wma); |
| 8342 | hdd_qdf_trace_enable(QDF_MODULE_ID_SYS, |
| 8343 | hdd_ctx->config->qdf_trace_enable_sys); |
| 8344 | hdd_qdf_trace_enable(QDF_MODULE_ID_QDF, |
| 8345 | hdd_ctx->config->qdf_trace_enable_qdf); |
| 8346 | hdd_qdf_trace_enable(QDF_MODULE_ID_SAP, |
| 8347 | hdd_ctx->config->qdf_trace_enable_sap); |
| 8348 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_SOFTAP, |
| 8349 | hdd_ctx->config->qdf_trace_enable_hdd_sap); |
| 8350 | hdd_qdf_trace_enable(QDF_MODULE_ID_BMI, |
| 8351 | hdd_ctx->config->qdf_trace_enable_bmi); |
| 8352 | hdd_qdf_trace_enable(QDF_MODULE_ID_CFG, |
| 8353 | hdd_ctx->config->qdf_trace_enable_cfg); |
| 8354 | hdd_qdf_trace_enable(QDF_MODULE_ID_EPPING, |
| 8355 | hdd_ctx->config->qdf_trace_enable_epping); |
| 8356 | hdd_qdf_trace_enable(QDF_MODULE_ID_QDF_DEVICE, |
| 8357 | hdd_ctx->config->qdf_trace_enable_qdf_devices); |
| 8358 | hdd_qdf_trace_enable(QDF_MODULE_ID_TXRX, |
Houston Hoffman | fbf0510 | 2017-08-28 11:37:01 -0700 | [diff] [blame] | 8359 | hdd_ctx->config->qdf_trace_enable_txrx); |
| 8360 | hdd_qdf_trace_enable(QDF_MODULE_ID_DP, |
| 8361 | hdd_ctx->config->qdf_trace_enable_dp); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 8362 | hdd_qdf_trace_enable(QDF_MODULE_ID_HTC, |
| 8363 | hdd_ctx->config->qdf_trace_enable_htc); |
| 8364 | hdd_qdf_trace_enable(QDF_MODULE_ID_HIF, |
| 8365 | hdd_ctx->config->qdf_trace_enable_hif); |
| 8366 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_SAP_DATA, |
| 8367 | hdd_ctx->config->qdf_trace_enable_hdd_sap_data); |
| 8368 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_DATA, |
| 8369 | hdd_ctx->config->qdf_trace_enable_hdd_data); |
Naveen Rawat | 7df3186 | 2017-03-01 17:09:30 -0800 | [diff] [blame] | 8370 | hdd_qdf_trace_enable(QDF_MODULE_ID_WIFIPOS, |
| 8371 | hdd_ctx->config->qdf_trace_enable_wifi_pos); |
Naveen Rawat | f2b0dbd | 2017-03-27 10:00:15 -0700 | [diff] [blame] | 8372 | hdd_qdf_trace_enable(QDF_MODULE_ID_NAN, |
| 8373 | hdd_ctx->config->qdf_trace_enable_nan); |
Kiran Kumar Lokere | 798de7e | 2017-03-30 14:01:12 -0700 | [diff] [blame] | 8374 | hdd_qdf_trace_enable(QDF_MODULE_ID_REGULATORY, |
| 8375 | hdd_ctx->config->qdf_trace_enable_regulatory); |
| 8376 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8377 | hdd_cfg_print(hdd_ctx); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8378 | } |
| 8379 | |
| 8380 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8381 | * hdd_context_init() - Initialize HDD context |
| 8382 | * @hdd_ctx: HDD context. |
| 8383 | * |
| 8384 | * Initialize HDD context along with all the feature specific contexts. |
| 8385 | * |
| 8386 | * return: 0 on success and errno on failure. |
| 8387 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8388 | static int hdd_context_init(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8389 | { |
| 8390 | int ret; |
| 8391 | |
| 8392 | hdd_ctx->ioctl_scan_mode = eSIR_ACTIVE_SCAN; |
| 8393 | hdd_ctx->max_intf_count = CSR_ROAM_SESSION_MAX; |
| 8394 | |
| 8395 | hdd_init_ll_stats_ctx(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 8396 | hdd_init_nud_stats_ctx(hdd_ctx); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8397 | |
| 8398 | init_completion(&hdd_ctx->mc_sus_event_var); |
| 8399 | init_completion(&hdd_ctx->ready_to_suspend); |
| 8400 | |
| 8401 | qdf_spinlock_create(&hdd_ctx->connection_status_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 8402 | qdf_spinlock_create(&hdd_ctx->sta_update_info_lock); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8403 | qdf_spinlock_create(&hdd_ctx->hdd_adapter_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 8404 | |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 8405 | qdf_list_create(&hdd_ctx->hdd_adapters, MAX_NUMBER_OF_ADAPTERS); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8406 | |
| 8407 | init_completion(&hdd_ctx->set_antenna_mode_cmpl); |
| 8408 | |
| 8409 | ret = hdd_scan_context_init(hdd_ctx); |
| 8410 | if (ret) |
| 8411 | goto list_destroy; |
| 8412 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8413 | hdd_rx_wake_lock_create(hdd_ctx); |
| 8414 | |
| 8415 | ret = hdd_sap_context_init(hdd_ctx); |
| 8416 | if (ret) |
| 8417 | goto scan_destroy; |
| 8418 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8419 | wlan_hdd_cfg80211_extscan_init(hdd_ctx); |
| 8420 | |
| 8421 | hdd_init_offloaded_packets_ctx(hdd_ctx); |
| 8422 | |
| 8423 | ret = wlan_hdd_cfg80211_init(hdd_ctx->parent_dev, hdd_ctx->wiphy, |
| 8424 | hdd_ctx->config); |
| 8425 | if (ret) |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 8426 | goto sap_destroy; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8427 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 8428 | qdf_wake_lock_create(&hdd_ctx->monitor_mode_wakelock, |
| 8429 | "monitor_mode_wakelock"); |
| 8430 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8431 | return 0; |
| 8432 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8433 | sap_destroy: |
| 8434 | hdd_sap_context_destroy(hdd_ctx); |
| 8435 | |
| 8436 | scan_destroy: |
| 8437 | hdd_scan_context_destroy(hdd_ctx); |
| 8438 | hdd_rx_wake_lock_destroy(hdd_ctx); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8439 | list_destroy: |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 8440 | qdf_list_destroy(&hdd_ctx->hdd_adapters); |
Sandeep Puligilla | d000421 | 2017-02-26 18:34:56 -0800 | [diff] [blame] | 8441 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8442 | return ret; |
| 8443 | } |
| 8444 | |
| 8445 | /** |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 8446 | * ie_whitelist_attrs_init() - initialize ie whitelisting attributes |
| 8447 | * @hdd_ctx: pointer to hdd context |
| 8448 | * |
| 8449 | * Return: status of initialization |
| 8450 | * 0 - success |
| 8451 | * negative value - failure |
| 8452 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8453 | static int ie_whitelist_attrs_init(struct hdd_context *hdd_ctx) |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 8454 | { |
| 8455 | int ret; |
| 8456 | |
| 8457 | if (!hdd_ctx->config->probe_req_ie_whitelist) |
| 8458 | return 0; |
| 8459 | |
| 8460 | if (!hdd_validate_prb_req_ie_bitmap(hdd_ctx)) { |
| 8461 | hdd_err("invalid ie bitmap and ouis: disable ie whitelisting"); |
| 8462 | hdd_ctx->config->probe_req_ie_whitelist = false; |
| 8463 | return -EINVAL; |
| 8464 | } |
| 8465 | |
| 8466 | /* parse ini string probe req oui */ |
| 8467 | ret = hdd_parse_probe_req_ouis(hdd_ctx); |
| 8468 | if (ret) { |
| 8469 | hdd_err("parsing error: disable ie whitelisting"); |
| 8470 | hdd_ctx->config->probe_req_ie_whitelist = false; |
| 8471 | } |
| 8472 | |
| 8473 | return ret; |
| 8474 | } |
| 8475 | |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8476 | /** |
| 8477 | * hdd_iface_change_callback() - Function invoked when stop modules expires |
| 8478 | * @priv: pointer to hdd context |
| 8479 | * |
| 8480 | * This function is invoked when the timer waiting for the interface change |
| 8481 | * expires, it shall cut-down the power to wlan and stop all the modules. |
| 8482 | * |
| 8483 | * Return: void |
| 8484 | */ |
| 8485 | static void hdd_iface_change_callback(void *priv) |
| 8486 | { |
| 8487 | struct hdd_context *hdd_ctx = (struct hdd_context *) priv; |
| 8488 | int ret; |
| 8489 | int status = wlan_hdd_validate_context(hdd_ctx); |
| 8490 | |
| 8491 | if (status) |
| 8492 | return; |
| 8493 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 8494 | hdd_enter(); |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8495 | hdd_debug("Interface change timer expired close the modules!"); |
| 8496 | ret = hdd_wlan_stop_modules(hdd_ctx, false); |
| 8497 | if (ret) |
| 8498 | hdd_err("Failed to stop modules"); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 8499 | hdd_exit(); |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8500 | } |
| 8501 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 8502 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 8503 | static void hdd_set_wlan_logging(struct hdd_context *hdd_ctx) |
| 8504 | { |
| 8505 | wlan_logging_set_log_to_console(hdd_ctx->config-> |
| 8506 | wlan_logging_to_console); |
| 8507 | wlan_logging_set_active(hdd_ctx->config->wlan_logging_enable); |
| 8508 | } |
| 8509 | #else |
| 8510 | static void hdd_set_wlan_logging(struct hdd_context *hdd_ctx) |
| 8511 | { } |
| 8512 | #endif |
| 8513 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 8514 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8515 | * hdd_context_create() - Allocate and inialize HDD context. |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8516 | * @dev: Device Pointer to the underlying device |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8517 | * |
| 8518 | * Allocate and initialize HDD context. HDD context is allocated as part of |
| 8519 | * wiphy allocation and then context is initialized. |
| 8520 | * |
| 8521 | * Return: HDD context on success and ERR_PTR on failure |
| 8522 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8523 | static struct hdd_context *hdd_context_create(struct device *dev) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8524 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8525 | QDF_STATUS status; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8526 | int ret = 0; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8527 | struct hdd_context *hdd_ctx; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8528 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 8529 | hdd_enter(); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8530 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8531 | hdd_ctx = hdd_cfg80211_wiphy_alloc(sizeof(struct hdd_context)); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8532 | if (hdd_ctx == NULL) { |
| 8533 | ret = -ENOMEM; |
| 8534 | goto err_out; |
| 8535 | } |
| 8536 | |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 8537 | qdf_create_delayed_work(&hdd_ctx->iface_idle_work, |
| 8538 | hdd_iface_change_callback, |
| 8539 | (void *)hdd_ctx); |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8540 | |
| 8541 | mutex_init(&hdd_ctx->iface_change_lock); |
| 8542 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8543 | hdd_ctx->parent_dev = dev; |
Sreelakshmi Konamki | b53c629 | 2017-03-01 13:13:23 +0530 | [diff] [blame] | 8544 | hdd_ctx->last_scan_reject_session_id = 0xFF; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8545 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 8546 | hdd_ctx->config = qdf_mem_malloc(sizeof(struct hdd_config)); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8547 | if (hdd_ctx->config == NULL) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8548 | hdd_err("Failed to alloc memory for HDD config!"); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8549 | ret = -ENOMEM; |
| 8550 | goto err_free_hdd_context; |
| 8551 | } |
| 8552 | |
| 8553 | /* Read and parse the qcom_cfg.ini file */ |
| 8554 | status = hdd_parse_config_ini(hdd_ctx); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8555 | if (QDF_STATUS_SUCCESS != status) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8556 | hdd_err("Error (status: %d) parsing INI file: %s", status, |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8557 | WLAN_INI_FILE); |
| 8558 | ret = -EINVAL; |
| 8559 | goto err_free_config; |
| 8560 | } |
| 8561 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 8562 | ie_whitelist_attrs_init(hdd_ctx); |
| 8563 | |
Dustin Brown | 7f93993 | 2017-05-18 15:02:17 -0700 | [diff] [blame] | 8564 | hdd_debug("setting timer multiplier: %u", |
| 8565 | hdd_ctx->config->timer_multiplier); |
| 8566 | qdf_timer_set_multiplier(hdd_ctx->config->timer_multiplier); |
| 8567 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8568 | |
Sravan Kumar Kairam | fece87f | 2016-07-26 14:58:28 +0530 | [diff] [blame] | 8569 | if (hdd_ctx->config->fhostNSOffload) |
| 8570 | hdd_ctx->ns_offload_enable = true; |
| 8571 | |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 8572 | cds_set_fatal_event(hdd_ctx->config->enable_fatal_event); |
| 8573 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8574 | hdd_override_ini_config(hdd_ctx); |
| 8575 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8576 | ret = hdd_context_init(hdd_ctx); |
| 8577 | |
| 8578 | if (ret) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8579 | goto err_free_config; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8580 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8581 | /* Uses to enabled logging after SSR */ |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 8582 | hdd_ctx->fw_log_settings.enable = hdd_ctx->config->enable_fw_log; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8583 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8584 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8585 | goto skip_multicast_logging; |
| 8586 | |
| 8587 | cds_set_multicast_logging(hdd_ctx->config->multicast_host_fw_msgs); |
| 8588 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 8589 | ret = wlan_hdd_init_tx_rx_histogram(hdd_ctx); |
| 8590 | if (ret) |
| 8591 | goto err_deinit_hdd_context; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8592 | |
Houston Hoffman | b18dc6e | 2017-08-11 17:43:07 -0700 | [diff] [blame] | 8593 | ret = hdd_init_netlink_services(hdd_ctx); |
| 8594 | if (ret) |
| 8595 | goto err_deinit_txrx_histogram; |
| 8596 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 8597 | hdd_set_wlan_logging(hdd_ctx); |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8598 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8599 | skip_multicast_logging: |
| 8600 | hdd_set_trace_level_for_each(hdd_ctx); |
| 8601 | |
Rajeev Kumar | 493a31b | 2017-09-29 14:01:24 -0700 | [diff] [blame] | 8602 | cds_set_context(QDF_MODULE_ID_HDD, hdd_ctx); |
| 8603 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 8604 | hdd_exit(); |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 8605 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8606 | return hdd_ctx; |
| 8607 | |
Houston Hoffman | b18dc6e | 2017-08-11 17:43:07 -0700 | [diff] [blame] | 8608 | err_deinit_txrx_histogram: |
| 8609 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 8610 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 8611 | err_deinit_hdd_context: |
| 8612 | hdd_context_deinit(hdd_ctx); |
| 8613 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8614 | err_free_config: |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 8615 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8616 | |
| 8617 | err_free_hdd_context: |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8618 | mutex_destroy(&hdd_ctx->iface_change_lock); |
Rajeev Kumar | fa55a69 | 2018-01-09 14:12:41 -0800 | [diff] [blame] | 8619 | wiphy_free(hdd_ctx->wiphy); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8620 | |
| 8621 | err_out: |
| 8622 | return ERR_PTR(ret); |
| 8623 | } |
| 8624 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8625 | #ifdef WLAN_OPEN_P2P_INTERFACE |
| 8626 | /** |
| 8627 | * hdd_open_p2p_interface - Open P2P interface |
| 8628 | * @hdd_ctx: HDD context |
| 8629 | * @rtnl_held: True if RTNL lock held |
| 8630 | * |
| 8631 | * Open P2P interface during probe. This function called to open the P2P |
| 8632 | * interface at probe along with STA interface. |
| 8633 | * |
| 8634 | * Return: 0 on success and errno on failure |
| 8635 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8636 | 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] | 8637 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8638 | struct hdd_adapter *adapter; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8639 | uint8_t *p2p_dev_addr; |
| 8640 | |
| 8641 | if (hdd_ctx->config->isP2pDeviceAddrAdministrated && |
| 8642 | !(hdd_ctx->config->intfMacAddr[0].bytes[0] & 0x02)) { |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 8643 | qdf_mem_copy(hdd_ctx->p2p_device_address.bytes, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8644 | hdd_ctx->config->intfMacAddr[0].bytes, |
| 8645 | sizeof(tSirMacAddr)); |
| 8646 | |
| 8647 | /* |
| 8648 | * Generate the P2P Device Address. This consists of |
| 8649 | * the device's primary MAC address with the locally |
| 8650 | * administered bit set. |
| 8651 | */ |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 8652 | hdd_ctx->p2p_device_address.bytes[0] |= 0x02; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8653 | } else { |
| 8654 | p2p_dev_addr = wlan_hdd_get_intf_addr(hdd_ctx); |
| 8655 | if (p2p_dev_addr == NULL) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8656 | hdd_err("Failed to allocate mac_address for p2p_device"); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8657 | return -ENOSPC; |
| 8658 | } |
| 8659 | |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 8660 | qdf_mem_copy(&hdd_ctx->p2p_device_address.bytes[0], |
| 8661 | p2p_dev_addr, QDF_MAC_ADDR_SIZE); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8662 | } |
| 8663 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 8664 | adapter = hdd_open_adapter(hdd_ctx, QDF_P2P_DEVICE_MODE, "p2p%d", |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 8665 | &hdd_ctx->p2p_device_address.bytes[0], |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 8666 | NET_NAME_UNKNOWN, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8667 | |
| 8668 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8669 | hdd_err("Failed to do hdd_open_adapter for P2P Device Interface"); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8670 | return -ENOSPC; |
| 8671 | } |
| 8672 | |
| 8673 | return 0; |
| 8674 | } |
| 8675 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8676 | static inline int hdd_open_p2p_interface(struct hdd_context *hdd_ctx, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8677 | bool rtnl_held) |
| 8678 | { |
| 8679 | return 0; |
| 8680 | } |
| 8681 | #endif |
| 8682 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8683 | 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] | 8684 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8685 | struct hdd_adapter *adapter; |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8686 | int ret = 0; |
| 8687 | |
| 8688 | adapter = hdd_open_adapter(hdd_ctx, QDF_OCB_MODE, "wlanocb%d", |
| 8689 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 8690 | NET_NAME_UNKNOWN, rtnl_held); |
| 8691 | if (adapter == NULL) { |
| 8692 | hdd_err("Failed to open 802.11p interface"); |
| 8693 | ret = -ENOSPC; |
| 8694 | } |
| 8695 | |
| 8696 | return ret; |
| 8697 | } |
| 8698 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8699 | /** |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8700 | * hdd_start_station_adapter()- Start the Station Adapter |
| 8701 | * @adapter: HDD adapter |
| 8702 | * |
| 8703 | * This function initializes the adapter for the station mode. |
| 8704 | * |
| 8705 | * Return: 0 on success or errno on failure. |
| 8706 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8707 | int hdd_start_station_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8708 | { |
| 8709 | QDF_STATUS status; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8710 | int ret; |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8711 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 8712 | hdd_enter_dev(adapter->dev); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8713 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 8714 | hdd_err("session is already opened, %d", |
| 8715 | adapter->session_id); |
| 8716 | return qdf_status_to_os_return(QDF_STATUS_SUCCESS); |
| 8717 | } |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8718 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8719 | ret = hdd_vdev_create(adapter, hdd_sme_roam_callback, adapter); |
| 8720 | if (ret) { |
| 8721 | hdd_err("failed to create vdev: %d", ret); |
| 8722 | return ret; |
| 8723 | } |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8724 | status = hdd_init_station_mode(adapter); |
| 8725 | |
| 8726 | if (QDF_STATUS_SUCCESS != status) { |
| 8727 | hdd_err("Error Initializing station mode: %d", status); |
| 8728 | return qdf_status_to_os_return(status); |
| 8729 | } |
| 8730 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8731 | hdd_register_tx_flow_control(adapter, |
| 8732 | hdd_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 8733 | hdd_tx_resume_cb, |
| 8734 | hdd_tx_flow_control_is_pause); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8735 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 8736 | hdd_exit(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8737 | return 0; |
| 8738 | } |
| 8739 | |
| 8740 | /** |
| 8741 | * hdd_start_ap_adapter()- Start AP Adapter |
| 8742 | * @adapter: HDD adapter |
| 8743 | * |
| 8744 | * This function initializes the adapter for the AP mode. |
| 8745 | * |
| 8746 | * Return: 0 on success errno on failure. |
| 8747 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8748 | int hdd_start_ap_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8749 | { |
| 8750 | QDF_STATUS status; |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 8751 | bool is_ssr = false; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8752 | int ret; |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 8753 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8754 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 8755 | hdd_enter(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8756 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8757 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 8758 | hdd_err("session is already opened, %d", |
| 8759 | adapter->session_id); |
| 8760 | return qdf_status_to_os_return(QDF_STATUS_SUCCESS); |
| 8761 | } |
| 8762 | /* |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 8763 | * In SSR case no need to create new sap context. |
| 8764 | * Otherwise create sap context first and then create |
| 8765 | * vdev as while creating the vdev, driver needs to |
| 8766 | * register SAP callback and that callback uses sap context |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8767 | */ |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 8768 | if (adapter->session.ap.sap_context) { |
| 8769 | is_ssr = true; |
| 8770 | } else if (!hdd_sap_create_ctx(adapter)) { |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8771 | hdd_err("sap creation failed"); |
| 8772 | return qdf_status_to_os_return(QDF_STATUS_E_FAILURE); |
| 8773 | } |
| 8774 | |
| 8775 | ret = hdd_vdev_create(adapter, wlansap_roam_callback, |
| 8776 | adapter->session.ap.sap_context); |
| 8777 | if (ret) { |
| 8778 | hdd_err("failed to create vdev, status:%d", ret); |
| 8779 | hdd_sap_destroy_ctx(adapter); |
| 8780 | return ret; |
| 8781 | } |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 8782 | |
| 8783 | if (adapter->device_mode == QDF_SAP_MODE) |
| 8784 | sme_cli_set_command(adapter->session_id, |
| 8785 | WMI_VDEV_PARAM_ENABLE_DISABLE_RTT_RESPONDER_ROLE, |
| 8786 | (bool)(hdd_ctx->config->fine_time_meas_cap & |
| 8787 | WMI_FW_AP_RTT_RESPR), |
| 8788 | VDEV_CMD); |
| 8789 | |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 8790 | status = hdd_init_ap_mode(adapter, is_ssr); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8791 | |
| 8792 | if (QDF_STATUS_SUCCESS != status) { |
| 8793 | hdd_err("Error Initializing the AP mode: %d", status); |
| 8794 | return qdf_status_to_os_return(status); |
| 8795 | } |
| 8796 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8797 | hdd_register_tx_flow_control(adapter, |
| 8798 | hdd_softap_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 8799 | hdd_softap_tx_resume_cb, |
| 8800 | hdd_tx_flow_control_is_pause); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8801 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 8802 | hdd_exit(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8803 | return 0; |
| 8804 | } |
| 8805 | |
Sourav Mohapatra | 57006c7 | 2017-11-19 16:15:55 +0530 | [diff] [blame] | 8806 | static int hdd_open_concurrent_interface(struct hdd_context *hdd_ctx, |
| 8807 | bool rtnl_held) |
| 8808 | { |
| 8809 | struct hdd_adapter *adapter; |
| 8810 | |
| 8811 | adapter = hdd_open_adapter(hdd_ctx, QDF_STA_MODE, |
| 8812 | hdd_ctx->config->enableConcurrentSTA, |
| 8813 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 8814 | NET_NAME_UNKNOWN, rtnl_held); |
| 8815 | |
| 8816 | if (!adapter) |
| 8817 | return -ENOSPC; |
| 8818 | |
| 8819 | return 0; |
| 8820 | } |
| 8821 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8822 | /** |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8823 | * hdd_open_interfaces - Open all required interfaces |
| 8824 | * hdd_ctx: HDD context |
| 8825 | * rtnl_held: True if RTNL lock is held |
| 8826 | * |
| 8827 | * Open all the interfaces like STA, P2P and OCB based on the configuration. |
| 8828 | * |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8829 | * Return: 0 if all interfaces were created, otherwise negative errno |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8830 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8831 | 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] | 8832 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8833 | struct hdd_adapter *adapter; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8834 | int ret; |
| 8835 | |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 8836 | /* open monitor mode adapter if con_mode is monitor mode */ |
Lin Bai | 1c67848 | 2017-12-18 18:29:11 +0800 | [diff] [blame] | 8837 | if (con_mode == QDF_GLOBAL_MONITOR_MODE || |
| 8838 | con_mode == QDF_GLOBAL_FTM_MODE) { |
| 8839 | uint8_t session_type = (con_mode == QDF_GLOBAL_MONITOR_MODE) ? |
| 8840 | QDF_MONITOR_MODE : QDF_FTM_MODE; |
| 8841 | |
| 8842 | adapter = hdd_open_adapter(hdd_ctx, session_type, "wlan%d", |
| 8843 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 8844 | NET_NAME_UNKNOWN, rtnl_held); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 8845 | if (!adapter) { |
| 8846 | hdd_err("open adapter failed"); |
| 8847 | return -ENOSPC; |
| 8848 | } |
Lin Bai | 1c67848 | 2017-12-18 18:29:11 +0800 | [diff] [blame] | 8849 | |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 8850 | return 0; |
| 8851 | } |
| 8852 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8853 | if (hdd_ctx->config->dot11p_mode == WLAN_HDD_11P_STANDALONE) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8854 | /* Create only 802.11p interface */ |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8855 | return hdd_open_ocb_interface(hdd_ctx, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8856 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 8857 | adapter = hdd_open_adapter(hdd_ctx, QDF_STA_MODE, "wlan%d", |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8858 | wlan_hdd_get_intf_addr(hdd_ctx), |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 8859 | NET_NAME_UNKNOWN, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8860 | |
| 8861 | if (adapter == NULL) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8862 | return -ENOSPC; |
| 8863 | |
Sourav Mohapatra | 57006c7 | 2017-11-19 16:15:55 +0530 | [diff] [blame] | 8864 | if (strlen(hdd_ctx->config->enableConcurrentSTA) != 0) { |
| 8865 | ret = hdd_open_concurrent_interface(hdd_ctx, rtnl_held); |
| 8866 | if (ret) |
| 8867 | hdd_err("Cannot create concurrent STA interface"); |
| 8868 | } |
| 8869 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8870 | ret = hdd_open_p2p_interface(hdd_ctx, rtnl_held); |
| 8871 | if (ret) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8872 | goto err_close_adapters; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8873 | |
| 8874 | /* Open 802.11p Interface */ |
| 8875 | if (hdd_ctx->config->dot11p_mode == WLAN_HDD_11P_CONCURRENT) { |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8876 | ret = hdd_open_ocb_interface(hdd_ctx, rtnl_held); |
| 8877 | if (ret) |
| 8878 | goto err_close_adapters; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8879 | } |
| 8880 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8881 | return 0; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8882 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8883 | err_close_adapters: |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8884 | hdd_close_all_adapters(hdd_ctx, rtnl_held); |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8885 | return ret; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8886 | } |
| 8887 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8888 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8889 | #ifdef QCA_LL_TX_FLOW_CONTROL_V2 |
| 8890 | /** |
| 8891 | * hdd_txrx_populate_cds_config() - Populate txrx cds configuration |
| 8892 | * @cds_cfg: CDS Configuration |
| 8893 | * @hdd_ctx: Pointer to hdd context |
| 8894 | * |
| 8895 | * Return: none |
| 8896 | */ |
| 8897 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 8898 | *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8899 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8900 | { |
| 8901 | cds_cfg->tx_flow_stop_queue_th = |
| 8902 | hdd_ctx->config->TxFlowStopQueueThreshold; |
| 8903 | cds_cfg->tx_flow_start_queue_offset = |
| 8904 | hdd_ctx->config->TxFlowStartQueueOffset; |
| 8905 | } |
| 8906 | #else |
| 8907 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 8908 | *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8909 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8910 | { |
| 8911 | } |
| 8912 | #endif |
| 8913 | |
| 8914 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 8915 | /** |
| 8916 | * hdd_ra_populate_cds_config() - Populate RA filtering cds configuration |
| 8917 | * @cds_cfg: CDS Configuration |
| 8918 | * @hdd_ctx: Pointer to hdd context |
| 8919 | * |
| 8920 | * Return: none |
| 8921 | */ |
Anand Kumar | 3b92a91 | 2016-12-05 12:01:26 +0530 | [diff] [blame] | 8922 | 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] | 8923 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8924 | { |
| 8925 | cds_cfg->ra_ratelimit_interval = |
| 8926 | hdd_ctx->config->RArateLimitInterval; |
| 8927 | cds_cfg->is_ra_ratelimit_enabled = |
| 8928 | hdd_ctx->config->IsRArateLimitEnabled; |
| 8929 | } |
| 8930 | #else |
Anand Kumar | 3b92a91 | 2016-12-05 12:01:26 +0530 | [diff] [blame] | 8931 | 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] | 8932 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8933 | { |
| 8934 | } |
| 8935 | #endif |
| 8936 | |
| 8937 | /** |
| 8938 | * hdd_update_cds_config() - API to update cds configuration parameters |
| 8939 | * @hdd_ctx: HDD Context |
| 8940 | * |
| 8941 | * Return: 0 for Success, errno on failure |
| 8942 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8943 | static int hdd_update_cds_config(struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8944 | { |
| 8945 | struct cds_config_info *cds_cfg; |
| 8946 | |
| 8947 | cds_cfg = (struct cds_config_info *)qdf_mem_malloc(sizeof(*cds_cfg)); |
| 8948 | if (!cds_cfg) { |
| 8949 | hdd_err("failed to allocate cds config"); |
| 8950 | return -ENOMEM; |
| 8951 | } |
| 8952 | |
Srinivas Girigowda | 35b0031 | 2017-06-27 21:52:03 -0700 | [diff] [blame] | 8953 | cds_cfg->driver_type = QDF_DRIVER_TYPE_PRODUCTION; |
Kiran Kumar Lokere | 7006e0a | 2017-03-07 19:28:36 -0800 | [diff] [blame] | 8954 | if (!hdd_ctx->config->nMaxPsPoll || |
| 8955 | !hdd_ctx->config->enablePowersaveOffload) { |
| 8956 | cds_cfg->powersave_offload_enabled = |
| 8957 | hdd_ctx->config->enablePowersaveOffload; |
| 8958 | } else { |
| 8959 | if ((hdd_ctx->config->enablePowersaveOffload == |
| 8960 | PS_QPOWER_NODEEPSLEEP) || |
| 8961 | (hdd_ctx->config->enablePowersaveOffload == |
| 8962 | PS_LEGACY_NODEEPSLEEP)) |
| 8963 | cds_cfg->powersave_offload_enabled = |
| 8964 | PS_LEGACY_NODEEPSLEEP; |
| 8965 | else |
| 8966 | cds_cfg->powersave_offload_enabled = |
| 8967 | PS_LEGACY_DEEPSLEEP; |
| 8968 | hdd_info("Qpower disabled in cds config, %d", |
| 8969 | cds_cfg->powersave_offload_enabled); |
| 8970 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8971 | cds_cfg->sta_dynamic_dtim = hdd_ctx->config->enableDynamicDTIM; |
| 8972 | cds_cfg->sta_mod_dtim = hdd_ctx->config->enableModulatedDTIM; |
| 8973 | cds_cfg->sta_maxlimod_dtim = hdd_ctx->config->fMaxLIModulatedDTIM; |
| 8974 | cds_cfg->wow_enable = hdd_ctx->config->wowEnable; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8975 | |
| 8976 | /* |
| 8977 | * Copy the DFS Phyerr Filtering Offload status. |
| 8978 | * This parameter reflects the value of the |
| 8979 | * dfs_phyerr_filter_offload flag as set in the ini. |
| 8980 | */ |
| 8981 | cds_cfg->dfs_phyerr_filter_offload = |
| 8982 | hdd_ctx->config->fDfsPhyerrFilterOffload; |
| 8983 | if (hdd_ctx->config->ssdp) |
| 8984 | cds_cfg->ssdp = hdd_ctx->config->ssdp; |
| 8985 | |
SaidiReddy Yenuga | cc733af | 2016-11-09 17:45:42 +0530 | [diff] [blame] | 8986 | cds_cfg->force_target_assert_enabled = |
| 8987 | hdd_ctx->config->crash_inject_enabled; |
| 8988 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8989 | cds_cfg->enable_mc_list = hdd_ctx->config->fEnableMCAddrList; |
| 8990 | cds_cfg->ap_maxoffload_peers = hdd_ctx->config->apMaxOffloadPeers; |
| 8991 | |
| 8992 | cds_cfg->ap_maxoffload_reorderbuffs = |
| 8993 | hdd_ctx->config->apMaxOffloadReorderBuffs; |
| 8994 | |
| 8995 | cds_cfg->ap_disable_intrabss_fwd = |
| 8996 | hdd_ctx->config->apDisableIntraBssFwd; |
| 8997 | |
| 8998 | cds_cfg->dfs_pri_multiplier = |
| 8999 | hdd_ctx->config->dfsRadarPriMultiplier; |
| 9000 | cds_cfg->reorder_offload = |
| 9001 | hdd_ctx->config->reorderOffloadSupport; |
| 9002 | |
| 9003 | /* IPA micro controller data path offload resource config item */ |
| 9004 | cds_cfg->uc_offload_enabled = hdd_ipa_uc_is_enabled(hdd_ctx); |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9005 | if (!is_power_of_2(hdd_ctx->config->IpaUcTxBufCount)) { |
| 9006 | /* IpaUcTxBufCount should be power of 2 */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9007 | hdd_debug("Round down IpaUcTxBufCount %d to nearest power of 2", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9008 | hdd_ctx->config->IpaUcTxBufCount); |
| 9009 | hdd_ctx->config->IpaUcTxBufCount = |
| 9010 | rounddown_pow_of_two( |
| 9011 | hdd_ctx->config->IpaUcTxBufCount); |
| 9012 | if (!hdd_ctx->config->IpaUcTxBufCount) { |
| 9013 | hdd_err("Failed to round down IpaUcTxBufCount"); |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 9014 | goto exit; |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9015 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9016 | hdd_debug("IpaUcTxBufCount rounded down to %d", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9017 | hdd_ctx->config->IpaUcTxBufCount); |
| 9018 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9019 | cds_cfg->uc_txbuf_count = hdd_ctx->config->IpaUcTxBufCount; |
| 9020 | cds_cfg->uc_txbuf_size = hdd_ctx->config->IpaUcTxBufSize; |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9021 | if (!is_power_of_2(hdd_ctx->config->IpaUcRxIndRingCount)) { |
| 9022 | /* IpaUcRxIndRingCount should be power of 2 */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9023 | hdd_debug("Round down IpaUcRxIndRingCount %d to nearest power of 2", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9024 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 9025 | hdd_ctx->config->IpaUcRxIndRingCount = |
| 9026 | rounddown_pow_of_two( |
| 9027 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 9028 | if (!hdd_ctx->config->IpaUcRxIndRingCount) { |
| 9029 | hdd_err("Failed to round down IpaUcRxIndRingCount"); |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 9030 | goto exit; |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9031 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9032 | hdd_debug("IpaUcRxIndRingCount rounded down to %d", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9033 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 9034 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9035 | cds_cfg->uc_rxind_ringcount = |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9036 | hdd_ctx->config->IpaUcRxIndRingCount; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9037 | cds_cfg->uc_tx_partition_base = |
| 9038 | hdd_ctx->config->IpaUcTxPartitionBase; |
| 9039 | cds_cfg->max_scan = hdd_ctx->config->max_scan_count; |
| 9040 | |
| 9041 | cds_cfg->ip_tcp_udp_checksum_offload = |
| 9042 | hdd_ctx->config->enable_ip_tcp_udp_checksum_offload; |
Jeff Johnson | e2ba3cd | 2017-10-30 20:02:09 -0700 | [diff] [blame] | 9043 | cds_cfg->enable_rxthread = hdd_ctx->enable_rxthread; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9044 | cds_cfg->ce_classify_enabled = |
| 9045 | hdd_ctx->config->ce_classify_enabled; |
Dustin Brown | d3fc9ee | 2016-09-14 13:57:27 -0700 | [diff] [blame] | 9046 | cds_cfg->bpf_packet_filter_enable = |
| 9047 | hdd_ctx->config->bpf_packet_filter_enable; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9048 | cds_cfg->tx_chain_mask_cck = hdd_ctx->config->tx_chain_mask_cck; |
| 9049 | cds_cfg->self_gen_frm_pwr = hdd_ctx->config->self_gen_frm_pwr; |
| 9050 | cds_cfg->max_station = hdd_ctx->config->maxNumberOfPeers; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 9051 | cds_cfg->sub_20_channel_width = WLAN_SUB_20_CH_WIDTH_NONE; |
Manjunathappa Prakash | fff753c | 2016-09-01 19:34:56 -0700 | [diff] [blame] | 9052 | cds_cfg->flow_steering_enabled = hdd_ctx->config->flow_steering_enable; |
Orhan K AKYILDIZ | 30e8cbc | 2017-08-11 18:00:28 -0700 | [diff] [blame] | 9053 | cds_cfg->max_msdus_per_rxinorderind = |
| 9054 | hdd_ctx->config->max_msdus_per_rxinorderind; |
Naveen Rawat | 91df30a | 2016-10-12 21:26:18 -0700 | [diff] [blame] | 9055 | cds_cfg->self_recovery_enabled = hdd_ctx->config->enableSelfRecovery; |
Sandeep Puligilla | afa5289 | 2016-10-26 19:03:16 -0700 | [diff] [blame] | 9056 | cds_cfg->fw_timeout_crash = hdd_ctx->config->fw_timeout_crash; |
Hanumanth Reddy Pothula | e87621b | 2017-04-12 20:53:35 +0530 | [diff] [blame] | 9057 | cds_cfg->active_uc_bpf_mode = hdd_ctx->config->active_uc_bpf_mode; |
| 9058 | 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] | 9059 | cds_cfg->auto_power_save_fail_mode = |
| 9060 | hdd_ctx->config->auto_pwr_save_fail_mode; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9061 | |
Ashish Kumar Dhanotiya | 9335d81 | 2017-06-30 16:57:20 +0530 | [diff] [blame] | 9062 | cds_cfg->ito_repeat_count = hdd_ctx->config->ito_repeat_count; |
Sandeep Puligilla | 819d94f | 2017-10-10 18:33:56 -0700 | [diff] [blame] | 9063 | cds_cfg->bandcapability = hdd_ctx->config->nBandCapability; |
Zhu Jianmin | a2f8e8d | 2018-02-11 16:37:10 +0800 | [diff] [blame] | 9064 | cds_cfg->delay_before_vdev_stop = |
| 9065 | hdd_ctx->config->delay_before_vdev_stop; |
Ashish Kumar Dhanotiya | 9335d81 | 2017-06-30 16:57:20 +0530 | [diff] [blame] | 9066 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9067 | hdd_ra_populate_cds_config(cds_cfg, hdd_ctx); |
| 9068 | hdd_txrx_populate_cds_config(cds_cfg, hdd_ctx); |
| 9069 | hdd_nan_populate_cds_config(cds_cfg, hdd_ctx); |
Jeff Johnson | 9078bdc | 2016-09-23 17:18:11 -0700 | [diff] [blame] | 9070 | hdd_lpass_populate_cds_config(cds_cfg, hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9071 | cds_init_ini_config(cds_cfg); |
| 9072 | return 0; |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 9073 | |
| 9074 | exit: |
| 9075 | qdf_mem_free(cds_cfg); |
| 9076 | return -EINVAL; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9077 | } |
| 9078 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9079 | /** |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9080 | * hdd_update_user_config() - API to update user configuration |
| 9081 | * parameters to obj mgr which are used by multiple components |
| 9082 | * @hdd_ctx: HDD Context |
| 9083 | * |
| 9084 | * Return: 0 for Success, errno on failure |
| 9085 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9086 | static int hdd_update_user_config(struct hdd_context *hdd_ctx) |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9087 | { |
| 9088 | struct wlan_objmgr_psoc_user_config *user_config; |
| 9089 | |
| 9090 | user_config = qdf_mem_malloc(sizeof(*user_config)); |
| 9091 | if (user_config == NULL) { |
| 9092 | hdd_alert("Failed to alloc memory for user_config!"); |
| 9093 | return -ENOMEM; |
| 9094 | } |
| 9095 | |
| 9096 | user_config->dot11_mode = hdd_ctx->config->dot11Mode; |
| 9097 | user_config->dual_mac_feature_disable = |
| 9098 | hdd_ctx->config->dual_mac_feature_disable; |
| 9099 | user_config->indoor_channel_support = |
| 9100 | hdd_ctx->config->indoor_channel_support; |
| 9101 | user_config->is_11d_support_enabled = |
| 9102 | hdd_ctx->config->Is11dSupportEnabled; |
| 9103 | user_config->is_11h_support_enabled = |
| 9104 | hdd_ctx->config->Is11hSupportEnabled; |
| 9105 | user_config->optimize_chan_avoid_event = |
| 9106 | hdd_ctx->config->goptimize_chan_avoid_event; |
| 9107 | user_config->skip_dfs_chnl_in_p2p_search = |
| 9108 | hdd_ctx->config->skipDfsChnlInP2pSearch; |
Naveen Rawat | 222b2e9 | 2017-03-16 09:52:21 -0700 | [diff] [blame] | 9109 | user_config->band_capability = hdd_ctx->config->nBandCapability; |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9110 | wlan_objmgr_psoc_set_user_config(hdd_ctx->hdd_psoc, user_config); |
| 9111 | |
| 9112 | qdf_mem_free(user_config); |
| 9113 | return 0; |
| 9114 | } |
| 9115 | |
| 9116 | /** |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9117 | * hdd_init_thermal_info - Initialize thermal level |
| 9118 | * @hdd_ctx: HDD context |
| 9119 | * |
| 9120 | * Initialize thermal level at SME layer and set the thermal level callback |
| 9121 | * which would be called when a configured thermal threshold is hit. |
| 9122 | * |
| 9123 | * Return: 0 on success and errno on failure |
| 9124 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9125 | static int hdd_init_thermal_info(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9126 | { |
| 9127 | tSmeThermalParams thermal_param; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9128 | QDF_STATUS status; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9129 | |
| 9130 | thermal_param.smeThermalMgmtEnabled = |
| 9131 | hdd_ctx->config->thermalMitigationEnable; |
| 9132 | thermal_param.smeThrottlePeriod = hdd_ctx->config->throttlePeriod; |
| 9133 | |
Poddar, Siddarth | 8390502 | 2016-04-16 17:56:08 -0700 | [diff] [blame] | 9134 | thermal_param.sme_throttle_duty_cycle_tbl[0] = |
| 9135 | hdd_ctx->config->throttle_dutycycle_level0; |
| 9136 | thermal_param.sme_throttle_duty_cycle_tbl[1] = |
| 9137 | hdd_ctx->config->throttle_dutycycle_level1; |
| 9138 | thermal_param.sme_throttle_duty_cycle_tbl[2] = |
| 9139 | hdd_ctx->config->throttle_dutycycle_level2; |
| 9140 | thermal_param.sme_throttle_duty_cycle_tbl[3] = |
| 9141 | hdd_ctx->config->throttle_dutycycle_level3; |
| 9142 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9143 | thermal_param.smeThermalLevels[0].smeMinTempThreshold = |
| 9144 | hdd_ctx->config->thermalTempMinLevel0; |
| 9145 | thermal_param.smeThermalLevels[0].smeMaxTempThreshold = |
| 9146 | hdd_ctx->config->thermalTempMaxLevel0; |
| 9147 | thermal_param.smeThermalLevels[1].smeMinTempThreshold = |
| 9148 | hdd_ctx->config->thermalTempMinLevel1; |
| 9149 | thermal_param.smeThermalLevels[1].smeMaxTempThreshold = |
| 9150 | hdd_ctx->config->thermalTempMaxLevel1; |
| 9151 | thermal_param.smeThermalLevels[2].smeMinTempThreshold = |
| 9152 | hdd_ctx->config->thermalTempMinLevel2; |
| 9153 | thermal_param.smeThermalLevels[2].smeMaxTempThreshold = |
| 9154 | hdd_ctx->config->thermalTempMaxLevel2; |
| 9155 | thermal_param.smeThermalLevels[3].smeMinTempThreshold = |
| 9156 | hdd_ctx->config->thermalTempMinLevel3; |
| 9157 | thermal_param.smeThermalLevels[3].smeMaxTempThreshold = |
| 9158 | hdd_ctx->config->thermalTempMaxLevel3; |
| 9159 | |
| 9160 | status = sme_init_thermal_info(hdd_ctx->hHal, thermal_param); |
| 9161 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9162 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 9163 | return qdf_status_to_os_return(status); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9164 | |
| 9165 | sme_add_set_thermal_level_callback(hdd_ctx->hHal, |
| 9166 | hdd_set_thermal_level_cb); |
| 9167 | |
| 9168 | return 0; |
| 9169 | |
| 9170 | } |
| 9171 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9172 | #if defined(CONFIG_HDD_INIT_WITH_RTNL_LOCK) |
| 9173 | /** |
| 9174 | * hdd_hold_rtnl_lock - Hold RTNL lock |
| 9175 | * |
| 9176 | * Hold RTNL lock |
| 9177 | * |
| 9178 | * Return: True if held and false otherwise |
| 9179 | */ |
| 9180 | static inline bool hdd_hold_rtnl_lock(void) |
| 9181 | { |
| 9182 | rtnl_lock(); |
| 9183 | return true; |
| 9184 | } |
| 9185 | |
| 9186 | /** |
| 9187 | * hdd_release_rtnl_lock - Release RTNL lock |
| 9188 | * |
| 9189 | * Release RTNL lock |
| 9190 | * |
| 9191 | * Return: None |
| 9192 | */ |
| 9193 | static inline void hdd_release_rtnl_lock(void) |
| 9194 | { |
| 9195 | rtnl_unlock(); |
| 9196 | } |
| 9197 | #else |
| 9198 | static inline bool hdd_hold_rtnl_lock(void) { return false; } |
| 9199 | static inline void hdd_release_rtnl_lock(void) { } |
| 9200 | #endif |
| 9201 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9202 | #if !defined(REMOVE_PKT_LOG) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9203 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9204 | /* MAX iwpriv command support */ |
| 9205 | #define PKTLOG_SET_BUFF_SIZE 3 |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9206 | #define PKTLOG_CLEAR_BUFF 4 |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9207 | #define MAX_PKTLOG_SIZE 16 |
| 9208 | |
| 9209 | /** |
| 9210 | * hdd_pktlog_set_buff_size() - set pktlog buffer size |
| 9211 | * @hdd_ctx: hdd context |
| 9212 | * @set_value2: pktlog buffer size value |
| 9213 | * |
| 9214 | * |
| 9215 | * Return: 0 for success or error. |
| 9216 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9217 | 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] | 9218 | { |
| 9219 | struct sir_wifi_start_log start_log = { 0 }; |
| 9220 | QDF_STATUS status; |
| 9221 | |
| 9222 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 9223 | start_log.verbose_level = WLAN_LOG_LEVEL_OFF; |
| 9224 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 9225 | start_log.user_triggered = 1; |
| 9226 | start_log.size = set_value2; |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9227 | start_log.is_pktlog_buff_clear = false; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9228 | |
| 9229 | status = sme_wifi_start_logger(hdd_ctx->hHal, start_log); |
| 9230 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9231 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9232 | hdd_exit(); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9233 | return -EINVAL; |
| 9234 | } |
| 9235 | |
| 9236 | return 0; |
| 9237 | } |
| 9238 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9239 | /** |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9240 | * hdd_pktlog_clear_buff() - clear pktlog buffer |
| 9241 | * @hdd_ctx: hdd context |
| 9242 | * |
| 9243 | * Return: 0 for success or error. |
| 9244 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9245 | static int hdd_pktlog_clear_buff(struct hdd_context *hdd_ctx) |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9246 | { |
| 9247 | struct sir_wifi_start_log start_log; |
| 9248 | QDF_STATUS status; |
| 9249 | |
| 9250 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 9251 | start_log.verbose_level = WLAN_LOG_LEVEL_OFF; |
| 9252 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 9253 | start_log.user_triggered = 1; |
| 9254 | start_log.size = 0; |
| 9255 | start_log.is_pktlog_buff_clear = true; |
| 9256 | |
| 9257 | status = sme_wifi_start_logger(hdd_ctx->hHal, start_log); |
| 9258 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9259 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9260 | hdd_exit(); |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9261 | return -EINVAL; |
| 9262 | } |
| 9263 | |
| 9264 | return 0; |
| 9265 | } |
| 9266 | |
| 9267 | |
| 9268 | /** |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9269 | * hdd_process_pktlog_command() - process pktlog command |
| 9270 | * @hdd_ctx: hdd context |
| 9271 | * @set_value: value set by user |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9272 | * @set_value2: pktlog buffer size value |
| 9273 | * |
| 9274 | * This function process pktlog command. |
| 9275 | * set_value2 only matters when set_value is 3 (set buff size) |
| 9276 | * otherwise we ignore it. |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9277 | * |
| 9278 | * Return: 0 for success or error. |
| 9279 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9280 | 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] | 9281 | int set_value2) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9282 | { |
| 9283 | int ret; |
| 9284 | bool enable; |
| 9285 | uint8_t user_triggered = 0; |
| 9286 | |
| 9287 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 9288 | if (0 != ret) |
| 9289 | return ret; |
| 9290 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9291 | hdd_debug("set pktlog %d, set size %d", set_value, set_value2); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9292 | |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9293 | if (set_value > PKTLOG_CLEAR_BUFF) { |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9294 | hdd_err("invalid pktlog value %d", set_value); |
| 9295 | return -EINVAL; |
| 9296 | } |
| 9297 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9298 | if (set_value == PKTLOG_SET_BUFF_SIZE) { |
| 9299 | if (set_value2 <= 0) { |
| 9300 | hdd_err("invalid pktlog size %d", set_value2); |
| 9301 | return -EINVAL; |
| 9302 | } else if (set_value2 > MAX_PKTLOG_SIZE) { |
| 9303 | hdd_err("Pktlog buff size is too large. max value is 16MB.\n"); |
| 9304 | return -EINVAL; |
| 9305 | } |
| 9306 | return hdd_pktlog_set_buff_size(hdd_ctx, set_value2); |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9307 | } else if (set_value == PKTLOG_CLEAR_BUFF) { |
| 9308 | return hdd_pktlog_clear_buff(hdd_ctx); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9309 | } |
| 9310 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9311 | /* |
| 9312 | * set_value = 0 then disable packetlog |
| 9313 | * set_value = 1 enable packetlog forcefully |
| 9314 | * set_vlaue = 2 then disable packetlog if disabled through ini or |
| 9315 | * enable packetlog with AUTO type. |
| 9316 | */ |
| 9317 | enable = ((set_value > 0) && cds_is_packet_log_enabled()) ? |
| 9318 | true : false; |
| 9319 | |
| 9320 | if (1 == set_value) { |
| 9321 | enable = true; |
| 9322 | user_triggered = 1; |
| 9323 | } |
| 9324 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9325 | return hdd_pktlog_enable_disable(hdd_ctx, enable, user_triggered, 0); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9326 | } |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 9327 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9328 | /** |
| 9329 | * hdd_pktlog_enable_disable() - Enable/Disable packet logging |
| 9330 | * @hdd_ctx: HDD context |
| 9331 | * @enable: Flag to enable/disable |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9332 | * @user_triggered: triggered through iwpriv |
| 9333 | * @size: buffer size to be used for packetlog |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9334 | * |
| 9335 | * Return: 0 on success; error number otherwise |
| 9336 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9337 | int hdd_pktlog_enable_disable(struct hdd_context *hdd_ctx, bool enable, |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9338 | uint8_t user_triggered, int size) |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9339 | { |
| 9340 | struct sir_wifi_start_log start_log; |
| 9341 | QDF_STATUS status; |
| 9342 | |
| 9343 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 9344 | start_log.verbose_level = |
| 9345 | enable ? WLAN_LOG_LEVEL_ACTIVE : WLAN_LOG_LEVEL_OFF; |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9346 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 9347 | start_log.user_triggered = user_triggered; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9348 | start_log.size = size; |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9349 | start_log.is_pktlog_buff_clear = false; |
Poddar, Siddarth | eefe348 | 2016-09-21 18:12:59 +0530 | [diff] [blame] | 9350 | /* |
| 9351 | * Use "is_iwpriv_command" flag to distinguish iwpriv command from other |
| 9352 | * commands. Host uses this flag to decide whether to send pktlog |
| 9353 | * disable command to fw without sending pktlog enable command |
| 9354 | * previously. For eg, If vendor sends pktlog disable command without |
| 9355 | * sending pktlog enable command, then host discards the packet |
| 9356 | * but for iwpriv command, host will send it to fw. |
| 9357 | */ |
| 9358 | start_log.is_iwpriv_command = 1; |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9359 | status = sme_wifi_start_logger(hdd_ctx->hHal, start_log); |
| 9360 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9361 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9362 | hdd_exit(); |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9363 | return -EINVAL; |
| 9364 | } |
| 9365 | |
Poddar, Siddarth | 61fbc93 | 2017-12-19 14:27:55 +0530 | [diff] [blame] | 9366 | if (enable == true) |
| 9367 | hdd_ctx->is_pktlog_enabled = 1; |
| 9368 | else |
| 9369 | hdd_ctx->is_pktlog_enabled = 0; |
| 9370 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9371 | return 0; |
| 9372 | } |
| 9373 | #endif /* REMOVE_PKT_LOG */ |
| 9374 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9375 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9376 | * hdd_get_platform_wlan_mac_buff() - API to query platform driver |
| 9377 | * for MAC address |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9378 | * @dev: Device Pointer |
| 9379 | * @num: Number of Valid Mac address |
| 9380 | * |
| 9381 | * Return: Pointer to MAC address buffer |
| 9382 | */ |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9383 | static uint8_t *hdd_get_platform_wlan_mac_buff(struct device *dev, |
| 9384 | uint32_t *num) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9385 | { |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9386 | return pld_get_wlan_mac_address(dev, num); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9387 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9388 | |
| 9389 | /** |
| 9390 | * hdd_populate_random_mac_addr() - API to populate random mac addresses |
| 9391 | * @hdd_ctx: HDD Context |
| 9392 | * @num: Number of random mac addresses needed |
| 9393 | * |
| 9394 | * Generate random addresses using bit manipulation on the base mac address |
| 9395 | * |
| 9396 | * Return: None |
| 9397 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9398 | 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] | 9399 | { |
| 9400 | uint32_t start_idx = QDF_MAX_CONCURRENCY_PERSONA - num; |
| 9401 | uint32_t iter; |
| 9402 | struct hdd_config *ini = hdd_ctx->config; |
| 9403 | uint8_t *buf = NULL; |
| 9404 | uint8_t macaddr_b3, tmp_br3; |
| 9405 | uint8_t *src = ini->intfMacAddr[0].bytes; |
| 9406 | |
| 9407 | for (iter = start_idx; iter < QDF_MAX_CONCURRENCY_PERSONA; ++iter) { |
| 9408 | buf = ini->intfMacAddr[iter].bytes; |
| 9409 | qdf_mem_copy(buf, src, QDF_MAC_ADDR_SIZE); |
| 9410 | macaddr_b3 = buf[3]; |
| 9411 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + iter) & |
| 9412 | INTF_MACADDR_MASK; |
| 9413 | macaddr_b3 += tmp_br3; |
| 9414 | macaddr_b3 ^= (1 << INTF_MACADDR_MASK); |
| 9415 | buf[0] |= 0x02; |
| 9416 | buf[3] = macaddr_b3; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9417 | hdd_debug(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(buf)); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9418 | } |
| 9419 | } |
| 9420 | |
| 9421 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9422 | * hdd_platform_wlan_mac() - API to get mac addresses from platform driver |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9423 | * @hdd_ctx: HDD Context |
| 9424 | * |
| 9425 | * API to get mac addresses from platform driver and update the driver |
| 9426 | * structures and configure FW with the base mac address. |
| 9427 | * Return: int |
| 9428 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9429 | static int hdd_platform_wlan_mac(struct hdd_context *hdd_ctx) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9430 | { |
| 9431 | uint32_t no_of_mac_addr, iter; |
| 9432 | uint32_t max_mac_addr = QDF_MAX_CONCURRENCY_PERSONA; |
| 9433 | uint32_t mac_addr_size = QDF_MAC_ADDR_SIZE; |
| 9434 | uint8_t *addr, *buf; |
| 9435 | struct device *dev = hdd_ctx->parent_dev; |
| 9436 | struct hdd_config *ini = hdd_ctx->config; |
| 9437 | tSirMacAddr mac_addr; |
| 9438 | QDF_STATUS status; |
| 9439 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9440 | addr = hdd_get_platform_wlan_mac_buff(dev, &no_of_mac_addr); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9441 | |
| 9442 | if (no_of_mac_addr == 0 || !addr) { |
| 9443 | hdd_warn("Platform Driver Doesn't have wlan mac addresses"); |
| 9444 | return -EINVAL; |
| 9445 | } |
| 9446 | |
| 9447 | if (no_of_mac_addr > max_mac_addr) |
| 9448 | no_of_mac_addr = max_mac_addr; |
| 9449 | |
| 9450 | qdf_mem_copy(&mac_addr, addr, mac_addr_size); |
| 9451 | |
| 9452 | for (iter = 0; iter < no_of_mac_addr; ++iter, addr += mac_addr_size) { |
| 9453 | buf = ini->intfMacAddr[iter].bytes; |
| 9454 | qdf_mem_copy(buf, addr, QDF_MAC_ADDR_SIZE); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9455 | hdd_debug(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(buf)); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9456 | } |
| 9457 | |
| 9458 | status = sme_set_custom_mac_addr(mac_addr); |
| 9459 | |
| 9460 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9461 | return -EAGAIN; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 9462 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9463 | if (no_of_mac_addr < max_mac_addr) |
| 9464 | hdd_populate_random_mac_addr(hdd_ctx, max_mac_addr - |
| 9465 | no_of_mac_addr); |
| 9466 | return 0; |
| 9467 | } |
| 9468 | |
| 9469 | /** |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9470 | * hdd_update_mac_addr_to_fw() - API to update wlan mac addresses to FW |
| 9471 | * @hdd_ctx: HDD Context |
| 9472 | * |
| 9473 | * Update MAC address to FW. If MAC address passed by FW is invalid, host |
| 9474 | * will generate its own MAC and update it to FW. |
| 9475 | * |
| 9476 | * Return: 0 for success |
| 9477 | * Non-zero error code for failure |
| 9478 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9479 | 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] | 9480 | { |
| 9481 | tSirMacAddr customMacAddr; |
| 9482 | QDF_STATUS status; |
| 9483 | |
| 9484 | qdf_mem_copy(&customMacAddr, |
| 9485 | &hdd_ctx->config->intfMacAddr[0].bytes[0], |
| 9486 | sizeof(tSirMacAddr)); |
| 9487 | status = sme_set_custom_mac_addr(customMacAddr); |
| 9488 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9489 | return -EAGAIN; |
| 9490 | return 0; |
| 9491 | } |
| 9492 | |
| 9493 | /** |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9494 | * hdd_initialize_mac_address() - API to get wlan mac addresses |
| 9495 | * @hdd_ctx: HDD Context |
| 9496 | * |
| 9497 | * Get MAC addresses from platform driver or wlan_mac.bin. If platform driver |
| 9498 | * is provisioned with mac addresses, driver uses it, else it will use |
| 9499 | * wlan_mac.bin to update HW MAC addresses. |
| 9500 | * |
| 9501 | * Return: None |
| 9502 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9503 | static void hdd_initialize_mac_address(struct hdd_context *hdd_ctx) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9504 | { |
| 9505 | QDF_STATUS status; |
| 9506 | int ret; |
| 9507 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9508 | ret = hdd_platform_wlan_mac(hdd_ctx); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9509 | if (ret == 0) |
| 9510 | return; |
| 9511 | |
Yuanyuan Liu | 3d62f6a | 2017-06-08 11:08:46 -0700 | [diff] [blame] | 9512 | hdd_info("MAC is not programmed in platform driver ret: %d, use wlan_mac.bin", |
| 9513 | ret); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9514 | |
| 9515 | status = hdd_update_mac_config(hdd_ctx); |
| 9516 | |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9517 | if (QDF_IS_STATUS_SUCCESS(status)) |
| 9518 | return; |
| 9519 | |
Yuanyuan Liu | 3d62f6a | 2017-06-08 11:08:46 -0700 | [diff] [blame] | 9520 | hdd_info("MAC is not programmed in wlan_mac.bin ret %d, use default MAC", |
| 9521 | status); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9522 | |
Yuanyuan Liu | 1c2caa3 | 2016-11-07 17:13:48 -0800 | [diff] [blame] | 9523 | if (hdd_ctx->update_mac_addr_to_fw) { |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9524 | ret = hdd_update_mac_addr_to_fw(hdd_ctx); |
Yuanyuan Liu | 1c2caa3 | 2016-11-07 17:13:48 -0800 | [diff] [blame] | 9525 | if (ret != 0) { |
| 9526 | hdd_err("MAC address out-of-sync, ret:%d", ret); |
| 9527 | QDF_ASSERT(ret); |
| 9528 | } |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9529 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9530 | } |
| 9531 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9532 | static int hdd_set_smart_chainmask_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9533 | { |
| 9534 | int vdev_id = 0; |
| 9535 | int param_id = WMI_PDEV_PARAM_SMART_CHAINMASK_SCHEME; |
| 9536 | int value = hdd_ctx->config->smart_chainmask_enabled; |
| 9537 | int vpdev = PDEV_CMD; |
| 9538 | int ret; |
| 9539 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9540 | ret = sme_cli_set_command(vdev_id, param_id, value, vpdev); |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9541 | if (ret) |
| 9542 | hdd_err("WMI_PDEV_PARAM_SMART_CHAINMASK_SCHEME failed %d", ret); |
| 9543 | |
| 9544 | return ret; |
| 9545 | } |
| 9546 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9547 | static int hdd_set_alternative_chainmask_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9548 | { |
| 9549 | int vdev_id = 0; |
| 9550 | int param_id = WMI_PDEV_PARAM_ALTERNATIVE_CHAINMASK_SCHEME; |
| 9551 | int value = hdd_ctx->config->alternative_chainmask_enabled; |
| 9552 | int vpdev = PDEV_CMD; |
| 9553 | int ret; |
| 9554 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9555 | ret = sme_cli_set_command(vdev_id, param_id, value, vpdev); |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9556 | if (ret) |
| 9557 | hdd_err("WMI_PDEV_PARAM_ALTERNATIVE_CHAINMASK_SCHEME failed %d", |
| 9558 | ret); |
| 9559 | |
| 9560 | return ret; |
| 9561 | } |
| 9562 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9563 | static int hdd_set_ani_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 9564 | { |
| 9565 | int vdev_id = 0; |
| 9566 | int param_id = WMI_PDEV_PARAM_ANI_ENABLE; |
| 9567 | int value = hdd_ctx->config->ani_enabled; |
| 9568 | int vpdev = PDEV_CMD; |
| 9569 | int ret; |
| 9570 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9571 | ret = sme_cli_set_command(vdev_id, param_id, value, vpdev); |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 9572 | if (ret) |
| 9573 | hdd_err("WMI_PDEV_PARAM_ANI_ENABLE failed %d", ret); |
| 9574 | |
| 9575 | return ret; |
| 9576 | } |
| 9577 | |
Jeff Johnson | 89c66ff | 2016-04-22 15:21:37 -0700 | [diff] [blame] | 9578 | /** |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9579 | * hdd_pre_enable_configure() - Configurations prior to cds_enable |
| 9580 | * @hdd_ctx: HDD context |
| 9581 | * |
| 9582 | * Pre configurations to be done at lower layer before calling cds enable. |
| 9583 | * |
| 9584 | * Return: 0 on success and errno on failure. |
| 9585 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9586 | static int hdd_pre_enable_configure(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9587 | { |
| 9588 | int ret; |
| 9589 | QDF_STATUS status; |
| 9590 | tSirRetStatus hal_status; |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 9591 | void *soc = cds_get_context(QDF_MODULE_ID_SOC); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9592 | |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 9593 | cdp_register_pause_cb(soc, wlan_hdd_txrx_pause_cb); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9594 | /* |
| 9595 | * Set 802.11p config |
| 9596 | * TODO-OCB: This has been temporarily added here to ensure this |
| 9597 | * parameter is set in CSR when we init the channel list. This should |
| 9598 | * be removed once the 5.9 GHz channels are added to the regulatory |
| 9599 | * domain. |
| 9600 | */ |
| 9601 | hdd_set_dot11p_config(hdd_ctx); |
| 9602 | |
| 9603 | /* |
| 9604 | * Note that the cds_pre_enable() sequence triggers the cfg download. |
| 9605 | * The cfg download must occur before we update the SME config |
| 9606 | * since the SME config operation must access the cfg database |
| 9607 | */ |
| 9608 | status = hdd_set_sme_config(hdd_ctx); |
| 9609 | |
| 9610 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9611 | hdd_err("Failed hdd_set_sme_config: %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9612 | ret = qdf_status_to_os_return(status); |
| 9613 | goto out; |
| 9614 | } |
| 9615 | |
Tushnim Bhattacharyya | ba8ee93 | 2017-03-23 09:27:40 -0700 | [diff] [blame] | 9616 | status = hdd_set_policy_mgr_user_cfg(hdd_ctx); |
| 9617 | if (QDF_STATUS_SUCCESS != status) { |
| 9618 | hdd_alert("Failed hdd_set_policy_mgr_user_cfg: %d", status); |
| 9619 | ret = qdf_status_to_os_return(status); |
| 9620 | goto out; |
| 9621 | } |
| 9622 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9623 | 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] | 9624 | hdd_ctx->config->tx_chain_mask_1ss, |
| 9625 | PDEV_CMD); |
| 9626 | if (0 != ret) { |
| 9627 | hdd_err("WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS failed %d", ret); |
| 9628 | goto out; |
| 9629 | } |
| 9630 | |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9631 | ret = hdd_set_smart_chainmask_enabled(hdd_ctx); |
| 9632 | if (ret) |
| 9633 | goto out; |
| 9634 | |
| 9635 | ret = hdd_set_alternative_chainmask_enabled(hdd_ctx); |
| 9636 | if (ret) |
| 9637 | goto out; |
| 9638 | |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 9639 | ret = hdd_set_ani_enabled(hdd_ctx); |
| 9640 | if (ret) |
| 9641 | goto out; |
| 9642 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9643 | ret = sme_cli_set_command(0, WMI_PDEV_PARAM_ARP_AC_OVERRIDE, |
Srinivas Girigowda | 70e169a | 2017-03-07 23:55:57 -0800 | [diff] [blame] | 9644 | hdd_ctx->config->arp_ac_category, |
| 9645 | PDEV_CMD); |
| 9646 | if (0 != ret) { |
| 9647 | hdd_err("WMI_PDEV_PARAM_ARP_AC_OVERRIDE ac: %d ret: %d", |
| 9648 | hdd_ctx->config->arp_ac_category, ret); |
| 9649 | goto out; |
| 9650 | } |
| 9651 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9652 | status = hdd_set_sme_chan_list(hdd_ctx); |
| 9653 | if (status != QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9654 | hdd_err("Failed to init channel list: %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9655 | ret = qdf_status_to_os_return(status); |
| 9656 | goto out; |
| 9657 | } |
| 9658 | |
| 9659 | /* Apply the cfg.ini to cfg.dat */ |
Krunal Soni | df0f874 | 2016-09-26 14:56:31 -0700 | [diff] [blame] | 9660 | if (!hdd_update_config_cfg(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9661 | hdd_err("config update failed"); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9662 | ret = -EINVAL; |
| 9663 | goto out; |
| 9664 | } |
| 9665 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9666 | /* |
| 9667 | * Set the MAC Address Currently this is used by HAL to add self sta. |
| 9668 | * Remove this once self sta is added as part of session open. |
| 9669 | */ |
| 9670 | hal_status = cfg_set_str(hdd_ctx->hHal, WNI_CFG_STA_ID, |
| 9671 | hdd_ctx->config->intfMacAddr[0].bytes, |
| 9672 | sizeof(hdd_ctx->config->intfMacAddr[0])); |
| 9673 | |
| 9674 | if (!IS_SIR_STATUS_SUCCESS(hal_status)) { |
| 9675 | hdd_err("Failed to set MAC Address. HALStatus is %08d [x%08x]", |
| 9676 | hal_status, hal_status); |
| 9677 | ret = -EINVAL; |
| 9678 | goto out; |
| 9679 | } |
| 9680 | |
| 9681 | hdd_init_channel_avoidance(hdd_ctx); |
| 9682 | |
Ganesh Kondabattini | 408fb8d | 2017-08-08 22:00:20 +0530 | [diff] [blame] | 9683 | /* update enable sap mandatory chan list */ |
| 9684 | policy_mgr_enable_disable_sap_mandatory_chan_list(hdd_ctx->hdd_psoc, |
| 9685 | hdd_ctx->config->enable_sap_mandatory_chan_list); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9686 | out: |
| 9687 | return ret; |
| 9688 | } |
| 9689 | |
| 9690 | /** |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9691 | * wlan_hdd_p2p_lo_event_callback - P2P listen offload stop event handler |
| 9692 | * @context_ptr - hdd context pointer |
| 9693 | * @event_ptr - event structure pointer |
| 9694 | * |
| 9695 | * This is the p2p listen offload stop event handler, it sends vendor |
| 9696 | * event back to supplicant to notify the stop reason. |
| 9697 | * |
| 9698 | * Return: None |
| 9699 | */ |
| 9700 | static void wlan_hdd_p2p_lo_event_callback(void *context_ptr, |
| 9701 | void *event_ptr) |
| 9702 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9703 | struct hdd_context *hdd_ctx = (struct hdd_context *)context_ptr; |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9704 | struct sir_p2p_lo_event *evt = event_ptr; |
| 9705 | struct sk_buff *vendor_event; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9706 | struct hdd_adapter *adapter; |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9707 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 9708 | hdd_enter(); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9709 | |
| 9710 | if (hdd_ctx == NULL) { |
| 9711 | hdd_err("Invalid HDD context pointer"); |
| 9712 | return; |
| 9713 | } |
| 9714 | |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 9715 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, evt->vdev_id); |
| 9716 | if (!adapter) { |
| 9717 | hdd_err("Cannot find adapter by vdev_id = %d", |
| 9718 | evt->vdev_id); |
| 9719 | return; |
| 9720 | } |
| 9721 | |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9722 | vendor_event = |
| 9723 | cfg80211_vendor_event_alloc(hdd_ctx->wiphy, |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 9724 | &(adapter->wdev), sizeof(uint32_t) + NLMSG_HDRLEN, |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9725 | QCA_NL80211_VENDOR_SUBCMD_P2P_LO_EVENT_INDEX, |
| 9726 | GFP_KERNEL); |
| 9727 | |
| 9728 | if (!vendor_event) { |
| 9729 | hdd_err("cfg80211_vendor_event_alloc failed"); |
| 9730 | return; |
| 9731 | } |
| 9732 | |
| 9733 | if (nla_put_u32(vendor_event, |
| 9734 | QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_STOP_REASON, |
| 9735 | evt->reason_code)) { |
| 9736 | hdd_err("nla put failed"); |
| 9737 | kfree_skb(vendor_event); |
| 9738 | return; |
| 9739 | } |
| 9740 | |
| 9741 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 9742 | hdd_debug("Sent P2P_LISTEN_OFFLOAD_STOP event for vdev_id = %d", |
| 9743 | evt->vdev_id); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9744 | } |
| 9745 | |
| 9746 | /** |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 9747 | * hdd_adaptive_dwelltime_init() - initialization for adaptive dwell time config |
| 9748 | * @hdd_ctx: HDD context |
| 9749 | * |
| 9750 | * This function sends the adaptive dwell time config configuration to the |
| 9751 | * firmware via WMA |
| 9752 | * |
| 9753 | * Return: 0 - success, < 0 - failure |
| 9754 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9755 | static int hdd_adaptive_dwelltime_init(struct hdd_context *hdd_ctx) |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 9756 | { |
| 9757 | QDF_STATUS status; |
| 9758 | struct adaptive_dwelltime_params dwelltime_params; |
| 9759 | |
| 9760 | dwelltime_params.is_enabled = |
| 9761 | hdd_ctx->config->adaptive_dwell_mode_enabled; |
| 9762 | dwelltime_params.dwelltime_mode = |
| 9763 | hdd_ctx->config->global_adapt_dwelltime_mode; |
| 9764 | dwelltime_params.lpf_weight = |
| 9765 | hdd_ctx->config->adapt_dwell_lpf_weight; |
| 9766 | dwelltime_params.passive_mon_intval = |
| 9767 | hdd_ctx->config->adapt_dwell_passive_mon_intval; |
| 9768 | dwelltime_params.wifi_act_threshold = |
| 9769 | hdd_ctx->config->adapt_dwell_wifi_act_threshold; |
| 9770 | |
| 9771 | status = sme_set_adaptive_dwelltime_config(hdd_ctx->hHal, |
| 9772 | &dwelltime_params); |
| 9773 | |
| 9774 | hdd_debug("Sending Adaptive Dwelltime Configuration to fw"); |
| 9775 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9776 | hdd_err("Failed to send Adaptive Dwelltime configuration!"); |
| 9777 | return -EAGAIN; |
| 9778 | } |
| 9779 | return 0; |
| 9780 | } |
| 9781 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9782 | int hdd_dbs_scan_selection_init(struct hdd_context *hdd_ctx) |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 9783 | { |
| 9784 | QDF_STATUS status; |
| 9785 | struct wmi_dbs_scan_sel_params dbs_scan_params; |
| 9786 | uint32_t i = 0; |
| 9787 | uint8_t count = 0, numentries = 0; |
| 9788 | uint8_t dbs_scan_config[CDS_DBS_SCAN_PARAM_PER_CLIENT |
| 9789 | * CDS_DBS_SCAN_CLIENTS_MAX]; |
| 9790 | |
| 9791 | /* check if DBS is enabled or supported */ |
Tushnim Bhattacharyya | 49ed8ab | 2017-05-26 18:20:10 -0700 | [diff] [blame] | 9792 | if (hdd_ctx->config->dual_mac_feature_disable == |
| 9793 | DISABLE_DBS_CXN_AND_SCAN) |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 9794 | return -EINVAL; |
| 9795 | |
| 9796 | hdd_string_to_u8_array(hdd_ctx->config->dbs_scan_selection, |
| 9797 | dbs_scan_config, &numentries, |
| 9798 | (CDS_DBS_SCAN_PARAM_PER_CLIENT |
| 9799 | * CDS_DBS_SCAN_CLIENTS_MAX)); |
| 9800 | |
| 9801 | hdd_info("numentries %hu", numentries); |
| 9802 | if (!numentries) { |
| 9803 | hdd_info("Donot send scan_selection_config"); |
| 9804 | return 0; |
| 9805 | } |
| 9806 | |
| 9807 | /* hdd_set_fw_log_params */ |
| 9808 | dbs_scan_params.num_clients = 0; |
| 9809 | while (count < (numentries - 2)) { |
| 9810 | dbs_scan_params.module_id[i] = dbs_scan_config[count]; |
| 9811 | dbs_scan_params.num_dbs_scans[i] = dbs_scan_config[count + 1]; |
| 9812 | dbs_scan_params.num_non_dbs_scans[i] = |
| 9813 | dbs_scan_config[count + 2]; |
| 9814 | dbs_scan_params.num_clients++; |
| 9815 | hdd_debug("module:%d NDS:%d NNDS:%d", |
| 9816 | dbs_scan_params.module_id[i], |
| 9817 | dbs_scan_params.num_dbs_scans[i], |
| 9818 | dbs_scan_params.num_non_dbs_scans[i]); |
| 9819 | count += CDS_DBS_SCAN_PARAM_PER_CLIENT; |
| 9820 | i++; |
| 9821 | } |
| 9822 | |
| 9823 | dbs_scan_params.pdev_id = 0; |
| 9824 | |
| 9825 | hdd_debug("clients:%d pdev:%d", |
| 9826 | dbs_scan_params.num_clients, dbs_scan_params.pdev_id); |
| 9827 | |
| 9828 | status = sme_set_dbs_scan_selection_config(hdd_ctx->hHal, |
| 9829 | &dbs_scan_params); |
| 9830 | hdd_debug("Sending DBS Scan Selection Configuration to fw"); |
| 9831 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9832 | hdd_err("Failed to send DBS Scan selection configuration!"); |
| 9833 | return -EAGAIN; |
| 9834 | } |
| 9835 | return 0; |
| 9836 | } |
| 9837 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9838 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 9839 | /** |
| 9840 | * hdd_set_auto_shutdown_cb() - Set auto shutdown callback |
| 9841 | * @hdd_ctx: HDD context |
| 9842 | * |
| 9843 | * Set auto shutdown callback to get indications from firmware to indicate |
| 9844 | * userspace to shutdown WLAN after a configured amount of inactivity. |
| 9845 | * |
| 9846 | * Return: 0 on success and errno on failure. |
| 9847 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9848 | static int hdd_set_auto_shutdown_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9849 | { |
| 9850 | QDF_STATUS status; |
| 9851 | |
| 9852 | if (!hdd_ctx->config->WlanAutoShutdown) |
| 9853 | return 0; |
| 9854 | |
| 9855 | status = sme_set_auto_shutdown_cb(hdd_ctx->hHal, |
| 9856 | wlan_hdd_auto_shutdown_cb); |
| 9857 | if (status != QDF_STATUS_SUCCESS) |
| 9858 | hdd_err("Auto shutdown feature could not be enabled: %d", |
| 9859 | status); |
| 9860 | |
| 9861 | return qdf_status_to_os_return(status); |
| 9862 | } |
| 9863 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9864 | static int hdd_set_auto_shutdown_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9865 | { |
| 9866 | return 0; |
| 9867 | } |
| 9868 | #endif |
| 9869 | |
| 9870 | /** |
| 9871 | * hdd_features_init() - Init features |
| 9872 | * @hdd_ctx: HDD context |
| 9873 | * @adapter: Primary adapter context |
| 9874 | * |
| 9875 | * Initialize features and their feature context after WLAN firmware is up. |
| 9876 | * |
| 9877 | * Return: 0 on success and errno on failure. |
| 9878 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9879 | 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] | 9880 | { |
| 9881 | tSirTxPowerLimit hddtxlimit; |
| 9882 | QDF_STATUS status; |
Manjeet Singh | a9cae43 | 2017-02-28 11:58:22 +0530 | [diff] [blame] | 9883 | struct sme_5g_band_pref_params band_pref_params; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9884 | int ret; |
| 9885 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 9886 | hdd_enter(); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9887 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9888 | /* FW capabilities received, Set the Dot11 mode */ |
| 9889 | sme_setdef_dot11mode(hdd_ctx->hHal); |
Kiran Kumar Lokere | 1aa9c9a | 2016-10-05 18:50:59 -0700 | [diff] [blame] | 9890 | sme_set_prefer_80MHz_over_160MHz(hdd_ctx->hHal, |
| 9891 | hdd_ctx->config->sta_prefer_80MHz_over_160MHz); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9892 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9893 | |
| 9894 | if (hdd_ctx->config->fIsImpsEnabled) |
| 9895 | hdd_set_idle_ps_config(hdd_ctx, true); |
| 9896 | else |
| 9897 | hdd_set_idle_ps_config(hdd_ctx, false); |
| 9898 | |
Poddar, Siddarth | 3703303 | 2017-10-11 15:47:40 +0530 | [diff] [blame] | 9899 | /* Send Enable/Disable data stall detection cmd to FW */ |
| 9900 | sme_cli_set_command(0, WMI_PDEV_PARAM_DATA_STALL_DETECT_ENABLE, |
| 9901 | hdd_ctx->config->enable_data_stall_det, PDEV_CMD); |
| 9902 | |
Agrawal Ashish | 642ec9b | 2017-02-22 14:45:30 +0530 | [diff] [blame] | 9903 | if (hdd_ctx->config->enable_go_cts2self_for_sta) |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 9904 | sme_set_cts2self_for_p2p_go(hdd_ctx->hHal); |
Agrawal Ashish | 642ec9b | 2017-02-22 14:45:30 +0530 | [diff] [blame] | 9905 | |
Nachiket Kukade | 8983cf6 | 2017-10-12 18:14:48 +0530 | [diff] [blame] | 9906 | if (sme_set_vc_mode_config(hdd_ctx->config->vc_mode_cfg_bitmap)) |
| 9907 | hdd_warn("Error in setting Voltage Corner mode config to FW"); |
| 9908 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9909 | if (hdd_lro_init(hdd_ctx)) |
| 9910 | hdd_err("Unable to initialize LRO in fw"); |
| 9911 | |
| 9912 | if (hdd_adaptive_dwelltime_init(hdd_ctx)) |
| 9913 | hdd_err("Unable to send adaptive dwelltime setting to FW"); |
| 9914 | |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 9915 | if (hdd_dbs_scan_selection_init(hdd_ctx)) |
| 9916 | hdd_err("Unable to send DBS scan selection setting to FW"); |
| 9917 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9918 | ret = hdd_init_thermal_info(hdd_ctx); |
| 9919 | if (ret) { |
| 9920 | hdd_err("Error while initializing thermal information"); |
| 9921 | goto deregister_frames; |
| 9922 | } |
| 9923 | |
Poddar, Siddarth | 61fbc93 | 2017-12-19 14:27:55 +0530 | [diff] [blame] | 9924 | /** |
| 9925 | * In case of SSR/PDR, if pktlog was enabled manually before |
| 9926 | * SSR/PDR, Then enabled it again automatically after Wlan |
| 9927 | * device up. |
| 9928 | */ |
| 9929 | if (cds_is_driver_recovering()) { |
| 9930 | if (hdd_ctx->is_pktlog_enabled) |
| 9931 | hdd_pktlog_enable_disable(hdd_ctx, true, 0, 0); |
Tiger Yu | f3d5d7f | 2018-03-15 14:48:11 +0800 | [diff] [blame] | 9932 | } |
Poddar, Siddarth | 66a4659 | 2017-02-22 11:44:44 +0530 | [diff] [blame] | 9933 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9934 | hddtxlimit.txPower2g = hdd_ctx->config->TxPower2g; |
| 9935 | hddtxlimit.txPower5g = hdd_ctx->config->TxPower5g; |
| 9936 | status = sme_txpower_limit(hdd_ctx->hHal, &hddtxlimit); |
| 9937 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9938 | hdd_err("Error setting txlimit in sme: %d", status); |
| 9939 | |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 9940 | wlan_hdd_tsf_init(hdd_ctx); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9941 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9942 | ret = hdd_register_cb(hdd_ctx); |
| 9943 | if (ret) { |
| 9944 | hdd_err("Failed to register HDD callbacks!"); |
| 9945 | goto deregister_frames; |
| 9946 | } |
| 9947 | |
Selvaraj, Sridhar | 371f55e | 2017-02-21 10:36:15 +0530 | [diff] [blame] | 9948 | if (hdd_ctx->config->goptimize_chan_avoid_event) { |
| 9949 | status = sme_enable_disable_chanavoidind_event( |
| 9950 | hdd_ctx->hHal, 0); |
| 9951 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9952 | hdd_err("Failed to disable Chan Avoidance Indication"); |
| 9953 | goto deregister_cb; |
| 9954 | } |
| 9955 | } |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9956 | |
Manjeet Singh | a9cae43 | 2017-02-28 11:58:22 +0530 | [diff] [blame] | 9957 | if (hdd_ctx->config->enable_5g_band_pref) { |
| 9958 | band_pref_params.rssi_boost_threshold_5g = |
| 9959 | hdd_ctx->config->rssi_boost_threshold_5g; |
| 9960 | band_pref_params.rssi_boost_factor_5g = |
| 9961 | hdd_ctx->config->rssi_boost_factor_5g; |
| 9962 | band_pref_params.max_rssi_boost_5g = |
| 9963 | hdd_ctx->config->max_rssi_boost_5g; |
| 9964 | band_pref_params.rssi_penalize_threshold_5g = |
| 9965 | hdd_ctx->config->rssi_penalize_threshold_5g; |
| 9966 | band_pref_params.rssi_penalize_factor_5g = |
| 9967 | hdd_ctx->config->rssi_penalize_factor_5g; |
| 9968 | band_pref_params.max_rssi_penalize_5g = |
| 9969 | hdd_ctx->config->max_rssi_penalize_5g; |
| 9970 | sme_set_5g_band_pref(hdd_ctx->hHal, &band_pref_params); |
| 9971 | } |
| 9972 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9973 | /* register P2P Listen Offload event callback */ |
| 9974 | if (wma_is_p2p_lo_capable()) |
| 9975 | sme_register_p2p_lo_event(hdd_ctx->hHal, hdd_ctx, |
| 9976 | wlan_hdd_p2p_lo_event_callback); |
| 9977 | |
| 9978 | ret = hdd_set_auto_shutdown_cb(hdd_ctx); |
| 9979 | |
| 9980 | if (ret) |
| 9981 | goto deregister_cb; |
| 9982 | |
Dustin Brown | 11638b7 | 2018-01-25 17:37:25 +0530 | [diff] [blame] | 9983 | wlan_hdd_init_chan_info(hdd_ctx); |
| 9984 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9985 | hdd_exit(); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9986 | return 0; |
| 9987 | |
| 9988 | deregister_cb: |
| 9989 | hdd_deregister_cb(hdd_ctx); |
| 9990 | deregister_frames: |
| 9991 | wlan_hdd_cfg80211_deregister_frames(adapter); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9992 | return -EINVAL; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9993 | } |
| 9994 | |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 9995 | /** |
| 9996 | * hdd_features_deinit() - Deinit features |
| 9997 | * @hdd_ctx: HDD context |
| 9998 | * |
| 9999 | * De-Initialize features and their feature context. |
| 10000 | * |
| 10001 | * Return: none. |
| 10002 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10003 | static void hdd_features_deinit(struct hdd_context *hdd_ctx) |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10004 | { |
Dustin Brown | 11638b7 | 2018-01-25 17:37:25 +0530 | [diff] [blame] | 10005 | wlan_hdd_deinit_chan_info(hdd_ctx); |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10006 | wlan_hdd_tsf_deinit(hdd_ctx); |
| 10007 | } |
| 10008 | |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10009 | /** |
Sandeep Puligilla | 0a11f8d | 2017-06-23 15:53:29 -0700 | [diff] [blame] | 10010 | * hdd_register_bcn_cb() - register scan beacon callback |
| 10011 | * @hdd_ctx - Pointer to the HDD context |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10012 | * |
Sandeep Puligilla | 0a11f8d | 2017-06-23 15:53:29 -0700 | [diff] [blame] | 10013 | * Return: QDF_STATUS |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10014 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10015 | 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] | 10016 | { |
| 10017 | QDF_STATUS status; |
| 10018 | |
| 10019 | status = ucfg_scan_register_bcn_cb(hdd_ctx->hdd_psoc, |
| 10020 | wlan_cfg80211_inform_bss_frame, |
| 10021 | SCAN_CB_TYPE_INFORM_BCN); |
| 10022 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10023 | hdd_err("failed with status code %08d [x%08x]", |
| 10024 | status, status); |
| 10025 | return status; |
| 10026 | } |
| 10027 | |
| 10028 | return QDF_STATUS_SUCCESS; |
| 10029 | } |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10030 | |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 10031 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10032 | * hdd_configure_cds() - Configure cds modules |
| 10033 | * @hdd_ctx: HDD context |
| 10034 | * @adapter: Primary adapter context |
| 10035 | * |
| 10036 | * Enable Cds modules after WLAN firmware is up. |
| 10037 | * |
| 10038 | * Return: 0 on success and errno on failure. |
| 10039 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10040 | 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] | 10041 | { |
| 10042 | int ret; |
| 10043 | QDF_STATUS status; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 10044 | int set_value; |
| 10045 | uint32_t num_abg_tx_chains = 0; |
| 10046 | uint32_t num_11b_tx_chains = 0; |
| 10047 | uint32_t num_11ag_tx_chains = 0; |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 10048 | struct policy_mgr_dp_cbacks dp_cbs; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 10049 | |
| 10050 | if (hdd_ctx->config->sifs_burst_duration) { |
| 10051 | set_value = (SIFS_BURST_DUR_MULTIPLIER) * |
| 10052 | hdd_ctx->config->sifs_burst_duration; |
| 10053 | |
| 10054 | if ((set_value > 0) && (set_value <= SIFS_BURST_DUR_MAX)) |
| 10055 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_BURST_DUR, |
| 10056 | set_value, PDEV_CMD); |
| 10057 | } |
| 10058 | |
| 10059 | if (hdd_ctx->config->is_force_1x1) |
| 10060 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_SET_IOT_PATTERN, |
| 10061 | 1, PDEV_CMD); |
| 10062 | /* set chip power save failure detected callback */ |
| 10063 | sme_set_chip_pwr_save_fail_cb(hdd_ctx->hHal, |
| 10064 | hdd_chip_pwr_save_fail_detected_cb); |
| 10065 | |
| 10066 | if (hdd_ctx->config->max_mpdus_inampdu) { |
| 10067 | set_value = hdd_ctx->config->max_mpdus_inampdu; |
| 10068 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_MAX_MPDUS_IN_AMPDU, |
| 10069 | set_value, PDEV_CMD); |
| 10070 | } |
| 10071 | |
| 10072 | if (hdd_ctx->config->enable_rts_sifsbursting) { |
| 10073 | set_value = hdd_ctx->config->enable_rts_sifsbursting; |
| 10074 | sme_cli_set_command(0, |
| 10075 | (int)WMI_PDEV_PARAM_ENABLE_RTS_SIFS_BURSTING, |
| 10076 | set_value, PDEV_CMD); |
| 10077 | } |
| 10078 | |
| 10079 | if (hdd_ctx->config->sap_get_peer_info) { |
| 10080 | set_value = hdd_ctx->config->sap_get_peer_info; |
| 10081 | sme_cli_set_command(0, |
| 10082 | (int)WMI_PDEV_PARAM_PEER_STATS_INFO_ENABLE, |
| 10083 | set_value, PDEV_CMD); |
| 10084 | } |
| 10085 | |
| 10086 | num_11b_tx_chains = hdd_ctx->config->num_11b_tx_chains; |
| 10087 | num_11ag_tx_chains = hdd_ctx->config->num_11ag_tx_chains; |
| 10088 | if (!hdd_ctx->config->enable2x2) { |
| 10089 | if (num_11b_tx_chains > 1) |
| 10090 | num_11b_tx_chains = 1; |
| 10091 | if (num_11ag_tx_chains > 1) |
| 10092 | num_11ag_tx_chains = 1; |
| 10093 | } |
| 10094 | WMI_PDEV_PARAM_SET_11B_TX_CHAIN_NUM(num_abg_tx_chains, |
| 10095 | num_11b_tx_chains); |
| 10096 | WMI_PDEV_PARAM_SET_11AG_TX_CHAIN_NUM(num_abg_tx_chains, |
| 10097 | num_11ag_tx_chains); |
| 10098 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_ABG_MODE_TX_CHAIN_NUM, |
| 10099 | num_abg_tx_chains, PDEV_CMD); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10100 | |
| 10101 | ret = hdd_pre_enable_configure(hdd_ctx); |
| 10102 | if (ret) { |
| 10103 | hdd_err("Failed to pre-configure cds"); |
| 10104 | goto out; |
| 10105 | } |
| 10106 | |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 10107 | /* Always get latest IPA resources allocated from cds_open and configure |
| 10108 | * IPA module before configuring them to FW. Sequence required as crash |
| 10109 | * observed otherwise. |
| 10110 | */ |
Manikandan Mohan | 2e803a0 | 2017-02-14 14:57:53 -0800 | [diff] [blame] | 10111 | if (hdd_ipa_uc_ol_init(hdd_ctx)) { |
| 10112 | hdd_err("Failed to setup pipes"); |
| 10113 | goto out; |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 10114 | } |
| 10115 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10116 | /* |
| 10117 | * Start CDS which starts up the SME/MAC/HAL modules and everything |
| 10118 | * else |
| 10119 | */ |
Jeff Johnson | 8f9dd5f | 2017-09-13 14:16:08 -0700 | [diff] [blame] | 10120 | status = cds_enable(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10121 | |
| 10122 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10123 | hdd_err("cds_enable failed"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10124 | goto out; |
| 10125 | } |
| 10126 | |
| 10127 | status = hdd_post_cds_enable_config(hdd_ctx); |
| 10128 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10129 | hdd_err("hdd_post_cds_enable_config failed"); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 10130 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10131 | } |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10132 | status = hdd_register_bcn_cb(hdd_ctx); |
| 10133 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Paul Zhang | e03cf4c | 2018-01-19 18:33:22 +0800 | [diff] [blame] | 10134 | hdd_err("hdd_register_bcn_cb failed"); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10135 | goto cds_disable; |
| 10136 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10137 | |
| 10138 | ret = hdd_features_init(hdd_ctx, adapter); |
| 10139 | if (ret) |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 10140 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10141 | |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 10142 | dp_cbs.hdd_disable_lro_in_concurrency = hdd_disable_lro_in_concurrency; |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 10143 | dp_cbs.hdd_set_rx_mode_rps_cb = hdd_set_rx_mode_rps; |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 10144 | status = policy_mgr_register_dp_cb(hdd_ctx->hdd_psoc, &dp_cbs); |
| 10145 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 10146 | hdd_debug("Failed to register DP cb with Policy Manager"); |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 10147 | goto cds_disable; |
| 10148 | } |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 10149 | status = policy_mgr_register_mode_change_cb(hdd_ctx->hdd_psoc, |
| 10150 | wlan_hdd_send_mode_change_event); |
| 10151 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10152 | hdd_debug("Failed to register mode change cb with Policy Manager"); |
| 10153 | goto cds_disable; |
| 10154 | } |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 10155 | |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 10156 | if (ucfg_green_ap_enable_egap(hdd_ctx->hdd_pdev)) |
Nachiket Kukade | fbd1afc | 2017-07-12 17:41:54 +0530 | [diff] [blame] | 10157 | hdd_debug("enhance green ap is not enabled"); |
| 10158 | |
Nachiket Kukade | dd30266 | 2017-07-13 17:31:44 +0530 | [diff] [blame] | 10159 | if (0 != wlan_hdd_set_wow_pulse(hdd_ctx, true)) |
| 10160 | hdd_debug("Failed to set wow pulse"); |
| 10161 | |
Ashish Kumar Dhanotiya | cb14b11 | 2018-01-19 19:26:44 +0530 | [diff] [blame] | 10162 | sme_cli_set_command(0, WMI_PDEV_PARAM_GCMP_SUPPORT_ENABLE, |
| 10163 | hdd_ctx->config->gcmp_enabled, PDEV_CMD); |
Hanumanth Reddy Pothula | ab39595 | 2017-09-05 19:12:26 +0530 | [diff] [blame] | 10164 | sme_cli_set_command(0, WMI_PDEV_AUTO_DETECT_POWER_FAILURE, |
| 10165 | hdd_ctx->config->auto_pwr_save_fail_mode, PDEV_CMD); |
| 10166 | |
Ravi Kumar Bokka | 990edcc | 2017-01-09 20:02:58 +0530 | [diff] [blame] | 10167 | |
| 10168 | if (hdd_ctx->config->enable_phy_reg_retention) |
| 10169 | wma_cli_set_command(0, WMI_PDEV_PARAM_FAST_PWR_TRANSITION, |
| 10170 | hdd_ctx->config->enable_phy_reg_retention, PDEV_CMD); |
| 10171 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10172 | return 0; |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 10173 | |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 10174 | cds_disable: |
Jeff Johnson | ea5c2aa1 | 2017-09-13 14:18:59 -0700 | [diff] [blame] | 10175 | cds_disable(hdd_ctx->hdd_psoc); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 10176 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10177 | out: |
| 10178 | return -EINVAL; |
| 10179 | } |
| 10180 | |
| 10181 | /** |
| 10182 | * hdd_deconfigure_cds() -De-Configure cds |
| 10183 | * @hdd_ctx: HDD context |
| 10184 | * |
| 10185 | * Deconfigure Cds modules before WLAN firmware is down. |
| 10186 | * |
| 10187 | * Return: 0 on success and errno on failure. |
| 10188 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10189 | static int hdd_deconfigure_cds(struct hdd_context *hdd_ctx) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10190 | { |
| 10191 | QDF_STATUS qdf_status; |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 10192 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10193 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10194 | hdd_enter(); |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10195 | |
| 10196 | /* De-init features */ |
| 10197 | hdd_features_deinit(hdd_ctx); |
| 10198 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10199 | /* De-register the SME callbacks */ |
| 10200 | hdd_deregister_cb(hdd_ctx); |
| 10201 | |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 10202 | qdf_status = policy_mgr_deregister_mode_change_cb(hdd_ctx->hdd_psoc); |
| 10203 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 10204 | hdd_debug("Failed to deregister mode change cb with Policy Manager"); |
| 10205 | } |
| 10206 | |
Jeff Johnson | ea5c2aa1 | 2017-09-13 14:18:59 -0700 | [diff] [blame] | 10207 | qdf_status = cds_disable(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10208 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 10209 | hdd_err("Failed to Disable the CDS Modules! :%d", |
| 10210 | qdf_status); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 10211 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10212 | } |
| 10213 | |
Sravan Kumar Kairam | 7112171 | 2017-04-15 00:34:42 +0530 | [diff] [blame] | 10214 | if (hdd_ipa_uc_ol_deinit(hdd_ctx)) { |
| 10215 | hdd_err("Failed to disconnect pipes"); |
| 10216 | ret = -EINVAL; |
| 10217 | } |
| 10218 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10219 | hdd_exit(); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 10220 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10221 | } |
| 10222 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 10223 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
| 10224 | static void hdd_deregister_policy_manager_callback( |
| 10225 | struct wlan_objmgr_psoc *psoc) |
| 10226 | { |
| 10227 | if (QDF_STATUS_SUCCESS != |
| 10228 | policy_mgr_deregister_hdd_cb(psoc)) { |
| 10229 | hdd_err("HDD callback deregister with policy manager failed"); |
| 10230 | } |
| 10231 | } |
| 10232 | #else |
| 10233 | static void hdd_deregister_policy_manager_callback( |
| 10234 | struct wlan_objmgr_psoc *psoc) |
| 10235 | { |
| 10236 | } |
| 10237 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10238 | |
| 10239 | /** |
| 10240 | * hdd_wlan_stop_modules - Single driver state machine for stoping modules |
| 10241 | * @hdd_ctx: HDD context |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 10242 | * @ftm_mode: ftm mode |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10243 | * |
| 10244 | * This function maintains the driver state machine it will be invoked from |
| 10245 | * exit, shutdown and con_mode change handler. Depending on the driver state |
| 10246 | * shall perform the stopping/closing of the modules. |
| 10247 | * |
| 10248 | * Return: 0 for success; non-zero for failure |
| 10249 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10250 | 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] | 10251 | { |
| 10252 | void *hif_ctx; |
| 10253 | qdf_device_t qdf_ctx; |
| 10254 | QDF_STATUS qdf_status; |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10255 | int ret = 0; |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 10256 | bool is_recovery_stop = cds_is_driver_recovering(); |
Liangwei Dong | a78cc1d | 2018-02-01 02:19:30 -0500 | [diff] [blame] | 10257 | bool is_idle_stop = !cds_is_driver_unloading() && !is_recovery_stop && |
| 10258 | !cds_is_driver_loading(); |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10259 | int active_threads; |
Arunk Khandavalli | a6305a3 | 2018-01-25 11:19:18 +0530 | [diff] [blame] | 10260 | struct target_psoc_info *tgt_hdl; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10261 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10262 | hdd_enter(); |
Yun Park | fec73dc | 2017-09-06 10:40:07 -0700 | [diff] [blame] | 10263 | hdd_alert("stop WLAN module: entering driver status=%d", |
| 10264 | hdd_ctx->driver_status); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10265 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 10266 | hdd_deregister_policy_manager_callback(hdd_ctx->hdd_psoc); |
| 10267 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10268 | qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 10269 | if (!qdf_ctx) { |
| 10270 | hdd_err("QDF device context NULL"); |
| 10271 | return -EINVAL; |
| 10272 | } |
| 10273 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10274 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 10275 | hdd_ctx->stop_modules_in_progress = true; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 10276 | cds_set_module_stop_in_progress(true); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10277 | |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10278 | active_threads = cds_return_external_threads_count(); |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 10279 | if (active_threads > 0 || hdd_ctx->is_wiphy_suspended) { |
Rajeev Kumar | 86177c2 | 2017-03-16 19:44:39 -0700 | [diff] [blame] | 10280 | hdd_warn("External threads %d wiphy suspend %d", |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 10281 | active_threads, hdd_ctx->is_wiphy_suspended); |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10282 | |
| 10283 | cds_print_external_threads(); |
| 10284 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 10285 | if (is_idle_stop && !ftm_mode) { |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10286 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 10287 | qdf_sched_delayed_work(&hdd_ctx->iface_idle_work, |
| 10288 | hdd_ctx->config->iface_change_wait_time); |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 10289 | hdd_prevent_suspend_timeout( |
| 10290 | hdd_ctx->config->iface_change_wait_time, |
| 10291 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER); |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 10292 | hdd_ctx->stop_modules_in_progress = false; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 10293 | cds_set_module_stop_in_progress(false); |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10294 | return 0; |
| 10295 | } |
Rajeev Kumar | 86177c2 | 2017-03-16 19:44:39 -0700 | [diff] [blame] | 10296 | } |
| 10297 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10298 | hdd_info("Present Driver Status: %d", hdd_ctx->driver_status); |
| 10299 | |
Kabilan Kannan | 6edafeb | 2017-11-16 16:34:34 -0800 | [diff] [blame] | 10300 | /* free user wowl patterns */ |
| 10301 | hdd_free_user_wowl_ptrns(); |
| 10302 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10303 | switch (hdd_ctx->driver_status) { |
| 10304 | case DRIVER_MODULES_UNINITIALIZED: |
| 10305 | hdd_info("Modules not initialized just return"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10306 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10307 | case DRIVER_MODULES_CLOSED: |
| 10308 | hdd_info("Modules already closed"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10309 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10310 | case DRIVER_MODULES_ENABLED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10311 | hdd_info("Wlan transitioning (OPENED <- ENABLED)"); |
| 10312 | |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 10313 | hdd_disable_power_management(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10314 | if (hdd_deconfigure_cds(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10315 | hdd_err("Failed to de-configure CDS"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10316 | QDF_ASSERT(0); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10317 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10318 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10319 | hdd_debug("successfully Disabled the CDS modules!"); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10320 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10321 | hdd_ctx->driver_status = DRIVER_MODULES_OPENED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10322 | hdd_info("Wlan transitioned (now OPENED)"); |
| 10323 | |
| 10324 | /* fall through */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10325 | case DRIVER_MODULES_OPENED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10326 | hdd_info("Wlan transitioning (CLOSED <- OPENED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10327 | break; |
| 10328 | default: |
| 10329 | hdd_err("Trying to stop wlan in a wrong state: %d", |
| 10330 | hdd_ctx->driver_status); |
| 10331 | QDF_ASSERT(0); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10332 | ret = -EINVAL; |
| 10333 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10334 | } |
| 10335 | |
Amar Singhal | 1808164 | 2018-01-26 16:04:13 -0800 | [diff] [blame] | 10336 | hdd_sysfs_destroy_version_interface(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10337 | hdd_debug("Closing CDS modules!"); |
Amar Singhal | 1808164 | 2018-01-26 16:04:13 -0800 | [diff] [blame] | 10338 | |
Rajeev Kumar | be02124 | 2017-02-16 16:12:23 -0800 | [diff] [blame] | 10339 | qdf_status = cds_post_disable(); |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 10340 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 10341 | hdd_err("Failed to process post CDS disable Modules! :%d", |
| 10342 | qdf_status); |
| 10343 | ret = -EINVAL; |
| 10344 | QDF_ASSERT(0); |
| 10345 | } |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 10346 | |
psimha | deea0a1 | 2017-12-18 14:50:02 -0800 | [diff] [blame] | 10347 | hdd_runtime_suspend_context_deinit(hdd_ctx); |
| 10348 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 10349 | qdf_status = cds_dp_close(hdd_ctx->hdd_psoc); |
| 10350 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 10351 | hdd_warn("Failed to stop CDS DP: %d", qdf_status); |
| 10352 | ret = -EINVAL; |
| 10353 | QDF_ASSERT(0); |
| 10354 | } |
| 10355 | |
Jeff Johnson | e4b1459 | 2017-09-13 14:23:33 -0700 | [diff] [blame] | 10356 | qdf_status = cds_close(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10357 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10358 | hdd_warn("Failed to stop CDS: %d", qdf_status); |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 10359 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10360 | QDF_ASSERT(0); |
| 10361 | } |
Krunal Soni | d32c6bc | 2016-10-18 18:00:21 -0700 | [diff] [blame] | 10362 | |
Amar Singhal | 410675c | 2018-01-10 12:14:21 -0800 | [diff] [blame] | 10363 | dispatcher_pdev_close(hdd_ctx->hdd_pdev); |
Liangwei Dong | 50a64a7 | 2018-01-11 01:17:00 -0500 | [diff] [blame] | 10364 | ret = hdd_objmgr_release_and_destroy_pdev(hdd_ctx); |
| 10365 | if (ret) { |
| 10366 | hdd_err("Failed to destroy pdev; errno:%d", ret); |
| 10367 | QDF_ASSERT(0); |
| 10368 | } |
| 10369 | |
| 10370 | /* |
| 10371 | * Reset total mac phy during module stop such that during |
| 10372 | * next module start same psoc is used to populate new service |
| 10373 | * ready data |
| 10374 | */ |
Arunk Khandavalli | a6305a3 | 2018-01-25 11:19:18 +0530 | [diff] [blame] | 10375 | tgt_hdl = wlan_psoc_get_tgt_if_handle(hdd_ctx->hdd_psoc); |
| 10376 | if (tgt_hdl) |
| 10377 | target_psoc_set_total_mac_phy_cnt(tgt_hdl, 0); |
| 10378 | |
Liangwei Dong | 50a64a7 | 2018-01-11 01:17:00 -0500 | [diff] [blame] | 10379 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10380 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 10381 | if (!hif_ctx) { |
| 10382 | hdd_err("Hif context is Null"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10383 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10384 | } |
| 10385 | |
Arunk Khandavalli | 4b40433 | 2017-09-26 12:46:00 +0530 | [diff] [blame] | 10386 | if (hdd_ctx->target_hw_name) { |
| 10387 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 10388 | hdd_ctx->target_hw_name = NULL; |
| 10389 | } |
| 10390 | |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 10391 | hdd_hif_close(hdd_ctx, hif_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10392 | |
| 10393 | ol_cds_free(); |
| 10394 | |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10395 | if (is_idle_stop) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10396 | ret = pld_power_off(qdf_ctx->dev); |
| 10397 | if (ret) |
| 10398 | hdd_err("CNSS power down failed put device into Low power mode:%d", |
| 10399 | ret); |
| 10400 | } |
Arunk Khandavalli | 847969d | 2017-09-25 15:15:36 +0530 | [diff] [blame] | 10401 | |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 10402 | /* many adapter resources are not freed by design in SSR case */ |
| 10403 | if (!is_recovery_stop) |
| 10404 | hdd_check_for_leaks(); |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 10405 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_INIT); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 10406 | |
Arunk Khandavalli | 847969d | 2017-09-25 15:15:36 +0530 | [diff] [blame] | 10407 | /* Once the firmware sequence is completed reset this flag */ |
| 10408 | hdd_ctx->imps_enabled = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10409 | hdd_ctx->driver_status = DRIVER_MODULES_CLOSED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10410 | hdd_info("Wlan transitioned (now CLOSED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10411 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10412 | done: |
| 10413 | hdd_ctx->stop_modules_in_progress = false; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 10414 | cds_set_module_stop_in_progress(false); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10415 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Yun Park | fec73dc | 2017-09-06 10:40:07 -0700 | [diff] [blame] | 10416 | hdd_alert("stop WLAN module: exit driver status=%d", |
| 10417 | hdd_ctx->driver_status); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 10418 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10419 | hdd_exit(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10420 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10421 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10422 | } |
| 10423 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10424 | |
| 10425 | /** |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10426 | * hdd_state_info_dump() - prints state information of hdd layer |
| 10427 | * @buf: buffer pointer |
| 10428 | * @size: size of buffer to be filled |
| 10429 | * |
| 10430 | * This function is used to dump state information of hdd layer |
| 10431 | * |
| 10432 | * Return: None |
| 10433 | */ |
| 10434 | static void hdd_state_info_dump(char **buf_ptr, uint16_t *size) |
| 10435 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10436 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 10437 | struct hdd_station_ctx *hdd_sta_ctx; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10438 | struct hdd_adapter *adapter; |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10439 | uint16_t len = 0; |
| 10440 | char *buf = *buf_ptr; |
| 10441 | |
| 10442 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 10443 | if (!hdd_ctx) { |
| 10444 | hdd_err("Failed to get hdd context "); |
| 10445 | return; |
| 10446 | } |
| 10447 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10448 | hdd_debug("size of buffer: %d", *size); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10449 | |
| 10450 | len += scnprintf(buf + len, *size - len, |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 10451 | "\n is_wiphy_suspended %d", hdd_ctx->is_wiphy_suspended); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10452 | len += scnprintf(buf + len, *size - len, |
Rajeev Kumar | eada0d0 | 2016-12-08 17:44:17 -0800 | [diff] [blame] | 10453 | "\n is_scheduler_suspended %d", |
| 10454 | hdd_ctx->is_scheduler_suspended); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10455 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 10456 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10457 | if (adapter->dev) |
| 10458 | len += scnprintf(buf + len, *size - len, |
| 10459 | "\n device name: %s", adapter->dev->name); |
wadesong | 42968e9 | 2017-06-08 14:11:21 +0800 | [diff] [blame] | 10460 | len += scnprintf(buf + len, *size - len, |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10461 | "\n device_mode: %d", adapter->device_mode); |
| 10462 | switch (adapter->device_mode) { |
| 10463 | case QDF_STA_MODE: |
| 10464 | case QDF_P2P_CLIENT_MODE: |
| 10465 | hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 10466 | len += scnprintf(buf + len, *size - len, |
| 10467 | "\n connState: %d", |
| 10468 | hdd_sta_ctx->conn_info.connState); |
| 10469 | break; |
| 10470 | |
| 10471 | default: |
| 10472 | break; |
| 10473 | } |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10474 | } |
| 10475 | |
| 10476 | *size -= len; |
| 10477 | *buf_ptr += len; |
| 10478 | } |
| 10479 | |
| 10480 | /** |
| 10481 | * hdd_register_debug_callback() - registration function for hdd layer |
| 10482 | * to print hdd state information |
| 10483 | * |
| 10484 | * Return: None |
| 10485 | */ |
| 10486 | static void hdd_register_debug_callback(void) |
| 10487 | { |
| 10488 | qdf_register_debug_callback(QDF_MODULE_ID_HDD, &hdd_state_info_dump); |
| 10489 | } |
| 10490 | |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 10491 | /* |
| 10492 | * wlan_init_bug_report_lock() - Initialize bug report lock |
| 10493 | * |
| 10494 | * This function is used to create bug report lock |
| 10495 | * |
| 10496 | * Return: None |
| 10497 | */ |
| 10498 | static void wlan_init_bug_report_lock(void) |
| 10499 | { |
| 10500 | p_cds_contextType p_cds_context; |
| 10501 | |
| 10502 | p_cds_context = cds_get_global_context(); |
| 10503 | if (!p_cds_context) { |
| 10504 | hdd_err("cds context is NULL"); |
| 10505 | return; |
| 10506 | } |
| 10507 | |
| 10508 | qdf_spinlock_create(&p_cds_context->bug_report_lock); |
| 10509 | } |
| 10510 | |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10511 | void hdd_dp_trace_init(struct hdd_config *config) |
| 10512 | { |
| 10513 | |
| 10514 | bool live_mode = DP_TRACE_CONFIG_DEFAULT_LIVE_MODE; |
| 10515 | uint8_t thresh = DP_TRACE_CONFIG_DEFAULT_THRESH; |
| 10516 | uint16_t thresh_time_limit = DP_TRACE_CONFIG_DEFAULT_THRESH_TIME_LIMIT; |
| 10517 | uint8_t verbosity = DP_TRACE_CONFIG_DEFAULT_VERBOSTY; |
| 10518 | uint8_t proto_bitmap = DP_TRACE_CONFIG_DEFAULT_BITMAP; |
| 10519 | uint8_t config_params[DP_TRACE_CONFIG_NUM_PARAMS]; |
| 10520 | uint8_t num_entries = 0; |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 10521 | uint32_t bw_compute_interval; |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10522 | |
| 10523 | hdd_string_to_u8_array(config->dp_trace_config, config_params, |
| 10524 | &num_entries, sizeof(config_params)); |
| 10525 | |
| 10526 | /* calculating, num bw timer intervals in a second (1000ms) */ |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 10527 | bw_compute_interval = GET_BW_COMPUTE_INTV(config); |
Jiachao Wu | 1b00ecb | 2017-07-05 19:13:41 +0800 | [diff] [blame] | 10528 | if (bw_compute_interval <= 1000 && bw_compute_interval > 0) |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 10529 | thresh_time_limit = 1000 / bw_compute_interval; |
Jiachao Wu | 1b00ecb | 2017-07-05 19:13:41 +0800 | [diff] [blame] | 10530 | else if (bw_compute_interval > 1000) { |
| 10531 | hdd_err("busBandwidthComputeInterval > 1000, using 1000"); |
| 10532 | thresh_time_limit = 1; |
| 10533 | } else |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10534 | hdd_err("busBandwidthComputeInterval is 0, using defaults"); |
| 10535 | |
| 10536 | switch (num_entries) { |
| 10537 | case 4: |
| 10538 | proto_bitmap = config_params[3]; |
| 10539 | case 3: |
| 10540 | verbosity = config_params[2]; |
| 10541 | case 2: |
| 10542 | thresh = config_params[1]; |
| 10543 | case 1: |
| 10544 | live_mode = config_params[0]; |
| 10545 | default: |
Rajeev Kumar | 3887f9b | 2018-01-10 11:24:01 -0800 | [diff] [blame] | 10546 | hdd_debug("live_mode %u thresh %u time_limit %u verbosity %u bitmap 0x%x", |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10547 | live_mode, thresh, thresh_time_limit, |
| 10548 | verbosity, proto_bitmap); |
| 10549 | }; |
| 10550 | |
| 10551 | qdf_dp_trace_init(live_mode, thresh, thresh_time_limit, |
| 10552 | verbosity, proto_bitmap); |
| 10553 | |
| 10554 | } |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10555 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10556 | * hdd_wlan_startup() - HDD init function |
| 10557 | * @dev: Pointer to the underlying device |
| 10558 | * |
| 10559 | * This is the driver startup code executed once a WLAN device has been detected |
| 10560 | * |
| 10561 | * Return: 0 for success, < 0 for failure |
| 10562 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10563 | int hdd_wlan_startup(struct device *dev) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10564 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10565 | QDF_STATUS status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10566 | struct hdd_context *hdd_ctx; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10567 | int ret; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 10568 | bool rtnl_held; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10569 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10570 | hdd_enter(); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10571 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10572 | hdd_ctx = hdd_context_create(dev); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10573 | |
| 10574 | if (IS_ERR(hdd_ctx)) |
| 10575 | return PTR_ERR(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10576 | |
Abhishek Singh | e9068f1 | 2017-03-31 14:14:52 +0530 | [diff] [blame] | 10577 | ret = hdd_objmgr_create_and_store_psoc(hdd_ctx, |
| 10578 | DEFAULT_PSOC_ID); |
| 10579 | if (ret) { |
| 10580 | hdd_err("Psoc creation fails!"); |
| 10581 | QDF_BUG(0); |
| 10582 | goto err_hdd_free_context; |
| 10583 | } |
| 10584 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 10585 | qdf_nbuf_init_replenish_timer(); |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 10586 | #ifdef FEATURE_WLAN_CH_AVOID |
| 10587 | mutex_init(&hdd_ctx->avoid_freq_lock); |
| 10588 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10589 | |
Jeff Johnson | ce0032c | 2017-01-20 07:18:27 -0800 | [diff] [blame] | 10590 | hdd_request_manager_init(); |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 10591 | qdf_atomic_init(&hdd_ctx->con_mode_flag); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10592 | |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 10593 | hdd_driver_memdump_init(); |
| 10594 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 10595 | ret = hdd_wlan_start_modules(hdd_ctx, NULL, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10596 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10597 | hdd_err("Failed to start modules: %d", ret); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 10598 | goto err_memdump_deinit; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10599 | } |
| 10600 | |
Yingying Tang | 80e15f3 | 2016-09-27 18:23:01 +0800 | [diff] [blame] | 10601 | wlan_hdd_update_wiphy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10602 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 10603 | hdd_ctx->hHal = cds_get_context(QDF_MODULE_ID_SME); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10604 | |
| 10605 | if (NULL == hdd_ctx->hHal) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10606 | hdd_err("HAL context is null"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10607 | goto err_stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10608 | } |
| 10609 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10610 | ret = hdd_wiphy_init(hdd_ctx); |
| 10611 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10612 | hdd_err("Failed to initialize wiphy: %d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10613 | goto err_stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10614 | } |
| 10615 | |
Nirav Shah | cc1f1ae | 2016-04-26 11:41:29 +0530 | [diff] [blame] | 10616 | if (hdd_ctx->config->enable_dp_trace) |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10617 | hdd_dp_trace_init(hdd_ctx->config); |
Nirav Shah | cc1f1ae | 2016-04-26 11:41:29 +0530 | [diff] [blame] | 10618 | |
jiad | 195f703 | 2018-01-31 15:18:09 +0800 | [diff] [blame] | 10619 | ret = hdd_ipa_init(hdd_ctx); |
| 10620 | if (ret == QDF_STATUS_E_FAILURE) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10621 | goto err_wiphy_unregister; |
| 10622 | |
Yuanyuan Liu | c98370e | 2016-10-13 11:22:13 -0700 | [diff] [blame] | 10623 | hdd_initialize_mac_address(hdd_ctx); |
Prashanth Bhatta | 75fa9a1 | 2016-01-11 18:30:08 -0800 | [diff] [blame] | 10624 | |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 10625 | ret = register_netdevice_notifier(&hdd_netdev_notifier); |
| 10626 | if (ret) { |
| 10627 | hdd_err("register_netdevice_notifier failed: %d", ret); |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 10628 | goto err_ipa_cleanup; |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 10629 | } |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 10630 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 10631 | rtnl_held = hdd_hold_rtnl_lock(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10632 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 10633 | ret = hdd_open_interfaces(hdd_ctx, rtnl_held); |
| 10634 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10635 | hdd_err("Failed to open interfaces: %d", ret); |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 10636 | goto err_release_rtnl_lock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10637 | } |
| 10638 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 10639 | hdd_release_rtnl_lock(); |
| 10640 | rtnl_held = false; |
| 10641 | |
Yingying Tang | 3ba3dbc | 2016-09-27 16:36:58 +0800 | [diff] [blame] | 10642 | wlan_hdd_update_11n_mode(hdd_ctx->config); |
| 10643 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10644 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 10645 | status = qdf_mc_timer_init(&hdd_ctx->skip_acs_scan_timer, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 10646 | QDF_TIMER_TYPE_SW, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10647 | hdd_skip_acs_scan_timer_handler, |
| 10648 | (void *)hdd_ctx); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10649 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 10650 | hdd_err("Failed to init ACS Skip timer"); |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 10651 | qdf_spinlock_create(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10652 | #endif |
| 10653 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 10654 | hdd_bus_bandwidth_init(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10655 | |
Jeff Johnson | 9afc501 | 2016-09-23 13:56:27 -0700 | [diff] [blame] | 10656 | hdd_lpass_notify_start(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10657 | |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 10658 | if (hdd_ctx->rps) |
| 10659 | hdd_set_rps_cpu_mask(hdd_ctx); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10660 | |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 10661 | ret = hdd_register_notifiers(hdd_ctx); |
| 10662 | if (ret) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 10663 | goto err_close_adapters; |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 10664 | |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 10665 | status = wlansap_global_init(); |
| 10666 | if (QDF_IS_STATUS_ERROR(status)) { |
| 10667 | hdd_unregister_notifiers(hdd_ctx); |
| 10668 | goto err_close_adapters; |
| 10669 | } |
| 10670 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10671 | if (hdd_ctx->config->fIsImpsEnabled) |
| 10672 | hdd_set_idle_ps_config(hdd_ctx, true); |
Kiran Kumar Lokere | b0f19c3 | 2017-10-13 12:23:26 -0700 | [diff] [blame] | 10673 | else |
| 10674 | hdd_set_idle_ps_config(hdd_ctx, false); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10675 | |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 10676 | if (QDF_GLOBAL_FTM_MODE != hdd_get_conparam()) { |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 10677 | qdf_sched_delayed_work(&hdd_ctx->iface_idle_work, |
| 10678 | hdd_ctx->config->iface_change_wait_time); |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 10679 | hdd_prevent_suspend_timeout( |
| 10680 | hdd_ctx->config->iface_change_wait_time, |
| 10681 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER); |
| 10682 | } |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 10683 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10684 | goto success; |
| 10685 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 10686 | err_close_adapters: |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 10687 | hdd_close_all_adapters(hdd_ctx, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10688 | |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 10689 | err_release_rtnl_lock: |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10690 | if (rtnl_held) |
| 10691 | hdd_release_rtnl_lock(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10692 | |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 10693 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 10694 | |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 10695 | err_ipa_cleanup: |
Anurag Chouhan | ce6a405 | 2016-09-14 18:20:42 +0530 | [diff] [blame] | 10696 | hdd_ipa_cleanup(hdd_ctx); |
Yun Park | 6a46ad8 | 2016-01-04 16:48:19 -0800 | [diff] [blame] | 10697 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10698 | err_wiphy_unregister: |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10699 | wiphy_unregister(hdd_ctx->wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10700 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10701 | err_stop_modules: |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 10702 | hdd_wlan_stop_modules(hdd_ctx, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10703 | |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 10704 | err_memdump_deinit: |
| 10705 | hdd_driver_memdump_deinit(); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 10706 | |
Jeff Johnson | ce0032c | 2017-01-20 07:18:27 -0800 | [diff] [blame] | 10707 | hdd_request_manager_deinit(); |
Ryan Hsu | cfef0ae | 2016-04-28 10:20:46 -0700 | [diff] [blame] | 10708 | hdd_exit_netlink_services(hdd_ctx); |
| 10709 | |
Dustin Brown | 2091246 | 2017-06-07 13:48:25 -0700 | [diff] [blame] | 10710 | hdd_objmgr_release_and_destroy_psoc(hdd_ctx); |
| 10711 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10712 | err_hdd_free_context: |
Nachiket Kukade | 8003d25 | 2017-03-30 15:55:58 +0530 | [diff] [blame] | 10713 | if (cds_is_fw_down()) |
| 10714 | hdd_err("Not setting the complete event as fw is down"); |
| 10715 | else |
| 10716 | hdd_start_complete(ret); |
| 10717 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 10718 | qdf_nbuf_deinit_replenish_timer(); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 10719 | hdd_context_destroy(hdd_ctx); |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 10720 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10721 | |
| 10722 | success: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10723 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10724 | return 0; |
| 10725 | } |
| 10726 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10727 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10728 | * hdd_wlan_update_target_info() - update target type info |
| 10729 | * @hdd_ctx: HDD context |
| 10730 | * @context: hif context |
| 10731 | * |
| 10732 | * Update target info received from firmware in hdd context |
| 10733 | * Return:None |
| 10734 | */ |
| 10735 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10736 | 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] | 10737 | { |
| 10738 | struct hif_target_info *tgt_info = hif_get_target_info_handle(context); |
| 10739 | |
| 10740 | if (!tgt_info) { |
| 10741 | hdd_err("Target info is Null"); |
| 10742 | return; |
| 10743 | } |
| 10744 | |
| 10745 | hdd_ctx->target_type = tgt_info->target_type; |
| 10746 | } |
| 10747 | |
| 10748 | /** |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10749 | * hdd_get_nud_stats_cb() - callback api to update the stats |
| 10750 | * received from the firmware |
| 10751 | * @data: pointer to adapter. |
| 10752 | * @rsp: pointer to data received from FW. |
| 10753 | * |
| 10754 | * This is called when wlan driver received response event for |
| 10755 | * get arp stats to firmware. |
| 10756 | * |
| 10757 | * Return: None |
| 10758 | */ |
| 10759 | static void hdd_get_nud_stats_cb(void *data, struct rsp_stats *rsp) |
| 10760 | { |
| 10761 | struct hdd_context *hdd_ctx = (struct hdd_context *)data; |
| 10762 | struct hdd_nud_stats_context *context; |
| 10763 | int status; |
| 10764 | struct hdd_adapter *adapter = NULL; |
| 10765 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10766 | hdd_enter(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10767 | |
| 10768 | if (!rsp) { |
| 10769 | hdd_err("data is null"); |
| 10770 | return; |
| 10771 | } |
| 10772 | |
| 10773 | status = wlan_hdd_validate_context(hdd_ctx); |
| 10774 | if (0 != status) |
| 10775 | return; |
| 10776 | |
| 10777 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, rsp->vdev_id); |
| 10778 | if ((NULL == adapter) || (WLAN_HDD_ADAPTER_MAGIC != adapter->magic)) { |
| 10779 | hdd_err("Invalid adapter or adapter has invalid magic"); |
| 10780 | return; |
| 10781 | } |
| 10782 | |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 10783 | hdd_info("rsp->arp_req_enqueue :%x", rsp->arp_req_enqueue); |
| 10784 | hdd_info("rsp->arp_req_tx_success :%x", rsp->arp_req_tx_success); |
| 10785 | hdd_info("rsp->arp_req_tx_failure :%x", rsp->arp_req_tx_failure); |
| 10786 | hdd_info("rsp->arp_rsp_recvd :%x", rsp->arp_rsp_recvd); |
| 10787 | hdd_info("rsp->out_of_order_arp_rsp_drop_cnt :%x", |
| 10788 | rsp->out_of_order_arp_rsp_drop_cnt); |
| 10789 | hdd_info("rsp->dad_detected :%x", rsp->dad_detected); |
| 10790 | hdd_info("rsp->connect_status :%x", rsp->connect_status); |
| 10791 | hdd_info("rsp->ba_session_establishment_status :%x", |
| 10792 | rsp->ba_session_establishment_status); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10793 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10794 | adapter->hdd_stats.hdd_arp_stats.rx_fw_cnt = rsp->arp_rsp_recvd; |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10795 | adapter->dad |= rsp->dad_detected; |
| 10796 | adapter->con_status = rsp->connect_status; |
| 10797 | |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 10798 | /* Flag true indicates connectivity check stats present. */ |
| 10799 | if (rsp->connect_stats_present) { |
| 10800 | hdd_info("rsp->tcp_ack_recvd :%x", rsp->tcp_ack_recvd); |
| 10801 | hdd_info("rsp->icmpv4_rsp_recvd :%x", rsp->icmpv4_rsp_recvd); |
| 10802 | adapter->hdd_stats.hdd_tcp_stats.rx_fw_cnt = rsp->tcp_ack_recvd; |
| 10803 | adapter->hdd_stats.hdd_icmpv4_stats.rx_fw_cnt = |
| 10804 | rsp->icmpv4_rsp_recvd; |
| 10805 | } |
| 10806 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10807 | spin_lock(&hdd_context_lock); |
| 10808 | context = &hdd_ctx->nud_stats_context; |
| 10809 | complete(&context->response_event); |
| 10810 | spin_unlock(&hdd_context_lock); |
| 10811 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10812 | hdd_exit(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10813 | } |
| 10814 | |
| 10815 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10816 | * hdd_register_cb - Register HDD callbacks. |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10817 | * @hdd_ctx: HDD context |
| 10818 | * |
| 10819 | * Register the HDD callbacks to CDS/SME. |
| 10820 | * |
| 10821 | * Return: 0 for success or Error code for failure |
| 10822 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10823 | int hdd_register_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10824 | { |
| 10825 | QDF_STATUS status; |
| 10826 | int ret = 0; |
| 10827 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10828 | hdd_enter(); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10829 | |
| 10830 | sme_register11d_scan_done_callback(hdd_ctx->hHal, hdd_11d_scan_done); |
| 10831 | |
| 10832 | sme_register_oem_data_rsp_callback(hdd_ctx->hHal, |
| 10833 | hdd_send_oem_data_rsp_msg); |
| 10834 | |
Deepthi Gowri | d5a58fe | 2016-09-03 16:01:28 +0530 | [diff] [blame] | 10835 | sme_register_mgmt_frame_ind_callback(hdd_ctx->hHal, |
| 10836 | hdd_indicate_mgmt_frame); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10837 | sme_set_tsfcb(hdd_ctx->hHal, hdd_get_tsf_cb, hdd_ctx); |
| 10838 | sme_nan_register_callback(hdd_ctx->hHal, |
| 10839 | wlan_hdd_cfg80211_nan_callback); |
| 10840 | sme_stats_ext_register_callback(hdd_ctx->hHal, |
| 10841 | wlan_hdd_cfg80211_stats_ext_callback); |
| 10842 | |
| 10843 | sme_ext_scan_register_callback(hdd_ctx->hHal, |
| 10844 | wlan_hdd_cfg80211_extscan_callback); |
lifeng | 6683166 | 2017-05-19 16:01:35 +0800 | [diff] [blame] | 10845 | sme_stats_ext2_register_callback(hdd_ctx->hHal, |
| 10846 | wlan_hdd_cfg80211_stats_ext2_callback); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10847 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10848 | sme_set_rssi_threshold_breached_cb(hdd_ctx->hHal, |
| 10849 | hdd_rssi_threshold_breached); |
| 10850 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10851 | sme_set_nud_debug_stats_cb(hdd_ctx->hHal, hdd_get_nud_stats_cb); |
| 10852 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10853 | sme_set_link_layer_stats_ind_cb(hdd_ctx->hHal, |
| 10854 | wlan_hdd_cfg80211_link_layer_stats_callback); |
| 10855 | |
Sreelakshmi Konamki | 88a2a41 | 2017-04-14 15:11:55 +0530 | [diff] [blame] | 10856 | sme_rso_cmd_status_cb(hdd_ctx->hHal, wlan_hdd_rso_cmd_status_cb); |
| 10857 | |
Zhang Qian | ca38fb1 | 2016-12-23 11:10:48 +0800 | [diff] [blame] | 10858 | sme_set_link_layer_ext_cb(hdd_ctx->hHal, |
| 10859 | wlan_hdd_cfg80211_link_layer_stats_ext_callback); |
| 10860 | |
Sreelakshmi Konamki | 58c7243 | 2016-11-09 17:06:44 +0530 | [diff] [blame] | 10861 | status = sme_set_lost_link_info_cb(hdd_ctx->hHal, |
| 10862 | hdd_lost_link_info_cb); |
| 10863 | /* print error and not block the startup process */ |
| 10864 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10865 | hdd_err("set lost link info callback failed"); |
| 10866 | |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 10867 | ret = hdd_register_data_stall_detect_cb(); |
| 10868 | if (ret) { |
| 10869 | hdd_err("Register data stall detect detect callback failed."); |
| 10870 | return ret; |
| 10871 | } |
| 10872 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10873 | wlan_hdd_dcc_register_for_dcc_stats_event(hdd_ctx); |
| 10874 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 10875 | sme_register_set_connection_info_cb(hdd_ctx->hHal, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 10876 | hdd_set_connection_in_progress, |
| 10877 | hdd_is_connection_in_progress); |
Padma, Santhosh Kumar | 16dacfb | 2017-03-21 19:05:40 +0530 | [diff] [blame] | 10878 | |
| 10879 | status = sme_congestion_register_callback(hdd_ctx->hHal, |
| 10880 | hdd_update_cca_info_cb); |
| 10881 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10882 | hdd_err("set congestion callback failed"); |
| 10883 | |
Vidyullatha Kanchanapally | be0ebb3 | 2017-03-23 14:36:21 +0530 | [diff] [blame] | 10884 | status = sme_set_bt_activity_info_cb(hdd_ctx->hHal, |
| 10885 | hdd_bt_activity_cb); |
| 10886 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10887 | hdd_err("set bt activity info callback failed"); |
| 10888 | |
Varun Reddy Yeturu | 076eaa8 | 2018-01-16 12:16:14 -0800 | [diff] [blame] | 10889 | status = sme_register_tx_queue_cb(hdd_ctx->hHal, |
| 10890 | hdd_tx_queue_cb); |
| 10891 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10892 | hdd_err("Register tx queue callback failed"); |
| 10893 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10894 | hdd_exit(); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10895 | |
| 10896 | return ret; |
| 10897 | } |
| 10898 | |
| 10899 | /** |
| 10900 | * hdd_deregister_cb() - De-Register HDD callbacks. |
| 10901 | * @hdd_ctx: HDD context |
| 10902 | * |
| 10903 | * De-Register the HDD callbacks to CDS/SME. |
| 10904 | * |
| 10905 | * Return: void |
| 10906 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10907 | void hdd_deregister_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10908 | { |
| 10909 | QDF_STATUS status; |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 10910 | int ret; |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10911 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10912 | hdd_enter(); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10913 | |
Varun Reddy Yeturu | 076eaa8 | 2018-01-16 12:16:14 -0800 | [diff] [blame] | 10914 | sme_deregister_tx_queue_cb(hdd_ctx->hHal); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10915 | status = sme_deregister_for_dcc_stats_event(hdd_ctx->hHal); |
| 10916 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10917 | hdd_err("De-register of dcc stats callback failed: %d", |
| 10918 | status); |
| 10919 | |
| 10920 | sme_reset_link_layer_stats_ind_cb(hdd_ctx->hHal); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10921 | sme_reset_rssi_threshold_breached_cb(hdd_ctx->hHal); |
| 10922 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10923 | sme_stats_ext_register_callback(hdd_ctx->hHal, |
| 10924 | wlan_hdd_cfg80211_stats_ext_callback); |
| 10925 | |
| 10926 | sme_nan_deregister_callback(hdd_ctx->hHal); |
| 10927 | status = sme_reset_tsfcb(hdd_ctx->hHal); |
| 10928 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10929 | hdd_err("Failed to de-register tsfcb the callback:%d", |
| 10930 | status); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10931 | |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 10932 | ret = hdd_deregister_data_stall_detect_cb(); |
| 10933 | if (ret) |
| 10934 | hdd_err("Failed to de-register data stall detect event callback"); |
| 10935 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10936 | sme_deregister_oem_data_rsp_callback(hdd_ctx->hHal); |
| 10937 | sme_deregister11d_scan_done_callback(hdd_ctx->hHal); |
| 10938 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10939 | hdd_exit(); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10940 | } |
| 10941 | |
| 10942 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10943 | * hdd_softap_sta_deauth() - handle deauth req from HDD |
| 10944 | * @adapter: Pointer to the HDD |
| 10945 | * @enable: bool value |
| 10946 | * |
| 10947 | * This to take counter measure to handle deauth req from HDD |
| 10948 | * |
| 10949 | * Return: None |
| 10950 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10951 | QDF_STATUS hdd_softap_sta_deauth(struct hdd_adapter *adapter, |
Jeff Johnson | e6bf719 | 2017-11-07 15:16:09 -0800 | [diff] [blame] | 10952 | struct csr_del_sta_params *pDelStaParams) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10953 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10954 | QDF_STATUS qdf_status = QDF_STATUS_E_FAULT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10955 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10956 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10957 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10958 | /* Ignore request to deauth bcmc station */ |
| 10959 | if (pDelStaParams->peerMacAddr.bytes[0] & 0x1) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10960 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10961 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10962 | qdf_status = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10963 | wlansap_deauth_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 10964 | pDelStaParams); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10965 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10966 | hdd_exit(); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10967 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10968 | } |
| 10969 | |
| 10970 | /** |
| 10971 | * hdd_softap_sta_disassoc() - take counter measure to handle deauth req from HDD |
| 10972 | * @adapter: Pointer to the HDD |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 10973 | * @p_del_sta_params: pointer to station deletion parameters |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10974 | * |
| 10975 | * This to take counter measure to handle deauth req from HDD |
| 10976 | * |
| 10977 | * Return: None |
| 10978 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10979 | void hdd_softap_sta_disassoc(struct hdd_adapter *adapter, |
Jeff Johnson | e6bf719 | 2017-11-07 15:16:09 -0800 | [diff] [blame] | 10980 | struct csr_del_sta_params *pDelStaParams) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10981 | { |
Ashish Kumar Dhanotiya | 443d31f | 2017-10-13 12:41:19 +0530 | [diff] [blame] | 10982 | struct sir_peer_sta_info peer_sta_info; |
| 10983 | struct hdd_station_info *stainfo; |
Jeff Johnson | e0847ba | 2018-03-01 12:34:50 -0800 | [diff] [blame] | 10984 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10985 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10986 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10987 | /* Ignore request to disassoc bcmc station */ |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 10988 | if (pDelStaParams->peerMacAddr.bytes[0] & 0x1) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10989 | return; |
| 10990 | |
Ashish Kumar Dhanotiya | 443d31f | 2017-10-13 12:41:19 +0530 | [diff] [blame] | 10991 | wlan_hdd_get_peer_rssi(adapter, &pDelStaParams->peerMacAddr, |
| 10992 | &peer_sta_info); |
| 10993 | stainfo = hdd_get_stainfo(adapter->cache_sta_info, |
| 10994 | pDelStaParams->peerMacAddr); |
| 10995 | if (stainfo) { |
| 10996 | stainfo->rssi = peer_sta_info.info[0].rssi; |
| 10997 | stainfo->tx_rate = peer_sta_info.info[0].tx_rate; |
| 10998 | stainfo->rx_rate = peer_sta_info.info[0].rx_rate; |
Jiachao Wu | f610d91 | 2018-01-23 17:47:32 +0800 | [diff] [blame] | 10999 | stainfo->reason_code = pDelStaParams->reason_code; |
Ashish Kumar Dhanotiya | 443d31f | 2017-10-13 12:41:19 +0530 | [diff] [blame] | 11000 | } |
| 11001 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11002 | wlansap_disassoc_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 11003 | pDelStaParams); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11004 | } |
| 11005 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11006 | /** |
| 11007 | * hdd_issta_p2p_clientconnected() - check if sta or p2p client is connected |
| 11008 | * @hdd_ctx: HDD Context |
| 11009 | * |
| 11010 | * API to find if there is any STA or P2P-Client is connected |
| 11011 | * |
| 11012 | * Return: true if connected; false otherwise |
| 11013 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11014 | QDF_STATUS hdd_issta_p2p_clientconnected(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11015 | { |
| 11016 | return sme_is_sta_p2p_client_connected(hdd_ctx->hHal); |
| 11017 | } |
| 11018 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11019 | /** |
| 11020 | * wlan_hdd_disable_roaming() - disable roaming on all STAs except the input one |
| 11021 | * @adapter: HDD adapter pointer |
| 11022 | * |
| 11023 | * This function loop through each adapter and disable roaming on each STA |
| 11024 | * device mode except the input adapter. |
| 11025 | * |
| 11026 | * Note: On the input adapter roaming is not enabled yet hence no need to |
| 11027 | * disable. |
| 11028 | * |
| 11029 | * Return: None |
| 11030 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11031 | void wlan_hdd_disable_roaming(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11032 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11033 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11034 | struct hdd_adapter *adapterIdx = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11035 | |
| 11036 | if (hdd_ctx->config->isFastRoamIniFeatureEnabled && |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 11037 | hdd_ctx->config->isRoamOffloadScanEnabled && |
| 11038 | QDF_STA_MODE == adapter->device_mode && |
| 11039 | policy_mgr_is_sta_active_connection_exists( |
| 11040 | hdd_ctx->hdd_psoc)) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11041 | hdd_debug("Connect received on STA session Id(%d)", |
| 11042 | adapter->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11043 | /* |
| 11044 | * Loop through adapter and disable roaming for each STA device |
| 11045 | * mode except the input adapter. |
| 11046 | */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11047 | hdd_for_each_adapter(hdd_ctx, adapterIdx) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11048 | if (QDF_STA_MODE == adapterIdx->device_mode && |
| 11049 | adapter->session_id != adapterIdx->session_id) { |
| 11050 | hdd_debug("Disable Roaming on session Id(%d)", |
| 11051 | adapterIdx->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11052 | sme_stop_roaming(WLAN_HDD_GET_HAL_CTX |
| 11053 | (adapterIdx), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11054 | adapterIdx->session_id, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11055 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11056 | } |
| 11057 | } |
| 11058 | } |
| 11059 | |
| 11060 | /** |
| 11061 | * wlan_hdd_enable_roaming() - enable roaming on all STAs except the input one |
| 11062 | * @adapter: HDD adapter pointer |
| 11063 | * |
| 11064 | * This function loop through each adapter and enable roaming on each STA |
| 11065 | * device mode except the input adapter. |
| 11066 | * Note: On the input adapter no need to enable roaming because link got |
| 11067 | * disconnected on this. |
| 11068 | * |
| 11069 | * Return: None |
| 11070 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11071 | void wlan_hdd_enable_roaming(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11072 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11073 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11074 | struct hdd_adapter *adapterIdx = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11075 | |
| 11076 | if (hdd_ctx->config->isFastRoamIniFeatureEnabled && |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 11077 | hdd_ctx->config->isRoamOffloadScanEnabled && |
| 11078 | QDF_STA_MODE == adapter->device_mode && |
| 11079 | policy_mgr_is_sta_active_connection_exists( |
| 11080 | hdd_ctx->hdd_psoc)) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11081 | hdd_debug("Disconnect received on STA session Id(%d)", |
| 11082 | adapter->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11083 | /* |
| 11084 | * Loop through adapter and enable roaming for each STA device |
| 11085 | * mode except the input adapter. |
| 11086 | */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11087 | hdd_for_each_adapter(hdd_ctx, adapterIdx) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11088 | if (QDF_STA_MODE == adapterIdx->device_mode && |
| 11089 | adapter->session_id != adapterIdx->session_id) { |
| 11090 | hdd_debug("Enabling Roaming on session Id(%d)", |
| 11091 | adapterIdx->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11092 | sme_start_roaming(WLAN_HDD_GET_HAL_CTX |
| 11093 | (adapterIdx), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11094 | adapterIdx->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11095 | REASON_CONNECT); |
| 11096 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11097 | } |
| 11098 | } |
| 11099 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11100 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 11101 | /** |
| 11102 | * nl_srv_bcast_svc() - Wrapper function to send bcast msgs to SVC mcast group |
| 11103 | * @skb: sk buffer pointer |
| 11104 | * |
| 11105 | * Sends the bcast message to SVC multicast group with generic nl socket |
| 11106 | * if CNSS_GENL is enabled. Else, use the legacy netlink socket to send. |
| 11107 | * |
| 11108 | * Return: None |
| 11109 | */ |
| 11110 | static void nl_srv_bcast_svc(struct sk_buff *skb) |
| 11111 | { |
| 11112 | #ifdef CNSS_GENL |
| 11113 | nl_srv_bcast(skb, CLD80211_MCGRP_SVC_MSGS, WLAN_NL_MSG_SVC); |
| 11114 | #else |
| 11115 | nl_srv_bcast(skb); |
| 11116 | #endif |
| 11117 | } |
| 11118 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11119 | 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] | 11120 | { |
| 11121 | struct sk_buff *skb; |
| 11122 | struct nlmsghdr *nlh; |
| 11123 | tAniMsgHdr *ani_hdr; |
| 11124 | void *nl_data = NULL; |
| 11125 | int flags = GFP_KERNEL; |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11126 | struct radio_index_tlv *radio_info; |
| 11127 | int tlv_len; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11128 | |
| 11129 | if (in_interrupt() || irqs_disabled() || in_atomic()) |
| 11130 | flags = GFP_ATOMIC; |
| 11131 | |
| 11132 | skb = alloc_skb(NLMSG_SPACE(WLAN_NL_MAX_PAYLOAD), flags); |
| 11133 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 11134 | if (skb == NULL) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11135 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11136 | |
| 11137 | nlh = (struct nlmsghdr *)skb->data; |
| 11138 | nlh->nlmsg_pid = 0; /* from kernel */ |
| 11139 | nlh->nlmsg_flags = 0; |
| 11140 | nlh->nlmsg_seq = 0; |
| 11141 | nlh->nlmsg_type = WLAN_NL_MSG_SVC; |
| 11142 | |
| 11143 | ani_hdr = NLMSG_DATA(nlh); |
| 11144 | ani_hdr->type = type; |
| 11145 | |
| 11146 | switch (type) { |
| 11147 | case WLAN_SVC_FW_CRASHED_IND: |
Komal Seelam | 78ff65a | 2016-08-18 15:25:24 +0530 | [diff] [blame] | 11148 | case WLAN_SVC_FW_SHUTDOWN_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11149 | case WLAN_SVC_LTE_COEX_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11150 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND: |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 11151 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11152 | ani_hdr->length = 0; |
| 11153 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr))); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11154 | break; |
| 11155 | case WLAN_SVC_WLAN_STATUS_IND: |
| 11156 | case WLAN_SVC_WLAN_VERSION_IND: |
| 11157 | case WLAN_SVC_DFS_CAC_START_IND: |
| 11158 | case WLAN_SVC_DFS_CAC_END_IND: |
| 11159 | case WLAN_SVC_DFS_RADAR_DETECT_IND: |
| 11160 | case WLAN_SVC_DFS_ALL_CHANNEL_UNAVAIL_IND: |
| 11161 | case WLAN_SVC_WLAN_TP_IND: |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 11162 | case WLAN_SVC_WLAN_TP_TX_IND: |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 11163 | case WLAN_SVC_RPS_ENABLE_IND: |
Orhan K AKYILDIZ | e7445a2 | 2017-01-19 21:21:47 -0800 | [diff] [blame] | 11164 | case WLAN_SVC_CORE_MINFREQ: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11165 | ani_hdr->length = len; |
| 11166 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr) + len)); |
| 11167 | nl_data = (char *)ani_hdr + sizeof(tAniMsgHdr); |
| 11168 | memcpy(nl_data, data, len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11169 | break; |
| 11170 | |
| 11171 | default: |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 11172 | hdd_err("WLAN SVC: Attempt to send unknown nlink message %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11173 | type); |
| 11174 | kfree_skb(skb); |
| 11175 | return; |
| 11176 | } |
| 11177 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11178 | /* |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 11179 | * Add radio index at the end of the svc event in TLV format |
| 11180 | * to maintain the backward compatibility with userspace |
| 11181 | * applications. |
| 11182 | */ |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11183 | |
| 11184 | tlv_len = 0; |
| 11185 | |
| 11186 | if ((sizeof(*ani_hdr) + len + sizeof(struct radio_index_tlv)) |
| 11187 | < WLAN_NL_MAX_PAYLOAD) { |
| 11188 | radio_info = (struct radio_index_tlv *)((char *) ani_hdr + |
| 11189 | sizeof(*ani_hdr) + len); |
| 11190 | radio_info->type = (unsigned short) WLAN_SVC_WLAN_RADIO_INDEX; |
| 11191 | radio_info->length = (unsigned short) sizeof(radio_info->radio); |
| 11192 | radio_info->radio = radio; |
| 11193 | tlv_len = sizeof(*radio_info); |
Dustin Brown | a286862 | 2018-03-20 11:38:14 -0700 | [diff] [blame] | 11194 | hdd_debug("Added radio index tlv - radio index %d", |
| 11195 | radio_info->radio); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11196 | } |
| 11197 | |
| 11198 | nlh->nlmsg_len += tlv_len; |
| 11199 | skb_put(skb, NLMSG_SPACE(sizeof(tAniMsgHdr) + len + tlv_len)); |
| 11200 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 11201 | nl_srv_bcast_svc(skb); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11202 | } |
| 11203 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11204 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 11205 | void wlan_hdd_auto_shutdown_cb(void) |
| 11206 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11207 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11208 | |
| 11209 | if (!hdd_ctx) |
| 11210 | return; |
| 11211 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11212 | hdd_debug("Wlan Idle. Sending Shutdown event.."); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11213 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 11214 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11215 | } |
| 11216 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11217 | 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] | 11218 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11219 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11220 | bool ap_connected = false, sta_connected = false; |
| 11221 | tHalHandle hal_handle; |
| 11222 | |
| 11223 | hal_handle = hdd_ctx->hHal; |
| 11224 | if (hal_handle == NULL) |
| 11225 | return; |
| 11226 | |
| 11227 | if (hdd_ctx->config->WlanAutoShutdown == 0) |
| 11228 | return; |
| 11229 | |
| 11230 | if (enable == false) { |
| 11231 | if (sme_set_auto_shutdown_timer(hal_handle, 0) != |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11232 | QDF_STATUS_SUCCESS) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11233 | hdd_err("Failed to stop wlan auto shutdown timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11234 | } |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11235 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 11236 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11237 | return; |
| 11238 | } |
| 11239 | |
| 11240 | /* To enable shutdown timer check conncurrency */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11241 | if (policy_mgr_concurrent_open_sessions_running(hdd_ctx->hdd_psoc)) { |
| 11242 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 11243 | if (adapter->device_mode == QDF_STA_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11244 | if (WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
| 11245 | conn_info.connState == |
| 11246 | eConnectionState_Associated) { |
| 11247 | sta_connected = true; |
| 11248 | break; |
| 11249 | } |
| 11250 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11251 | |
| 11252 | if (adapter->device_mode == QDF_SAP_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11253 | if (WLAN_HDD_GET_AP_CTX_PTR(adapter)-> |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 11254 | ap_active == true) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11255 | ap_connected = true; |
| 11256 | break; |
| 11257 | } |
| 11258 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11259 | } |
| 11260 | } |
| 11261 | |
| 11262 | if (ap_connected == true || sta_connected == true) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11263 | hdd_debug("CC Session active. Shutdown timer not enabled"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11264 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11265 | } |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 11266 | |
| 11267 | if (sme_set_auto_shutdown_timer(hal_handle, |
| 11268 | hdd_ctx->config->WlanAutoShutdown) |
| 11269 | != QDF_STATUS_SUCCESS) |
| 11270 | hdd_err("Failed to start wlan auto shutdown timer"); |
| 11271 | else |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 11272 | hdd_info("Auto Shutdown timer for %d seconds enabled", |
| 11273 | hdd_ctx->config->WlanAutoShutdown); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11274 | } |
| 11275 | #endif |
| 11276 | |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 11277 | struct hdd_adapter * |
| 11278 | hdd_get_con_sap_adapter(struct hdd_adapter *this_sap_adapter, |
| 11279 | bool check_start_bss) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11280 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11281 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(this_sap_adapter); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11282 | struct hdd_adapter *adapter, *con_sap_adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11283 | |
| 11284 | con_sap_adapter = NULL; |
| 11285 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11286 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 11287 | if (adapter && ((adapter->device_mode == QDF_SAP_MODE) || |
| 11288 | (adapter->device_mode == QDF_P2P_GO_MODE)) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11289 | adapter != this_sap_adapter) { |
| 11290 | if (check_start_bss) { |
| 11291 | if (test_bit(SOFTAP_BSS_STARTED, |
| 11292 | &adapter->event_flags)) { |
| 11293 | con_sap_adapter = adapter; |
| 11294 | break; |
| 11295 | } |
| 11296 | } else { |
| 11297 | con_sap_adapter = adapter; |
| 11298 | break; |
| 11299 | } |
| 11300 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11301 | } |
| 11302 | |
| 11303 | return con_sap_adapter; |
| 11304 | } |
| 11305 | |
| 11306 | #ifdef MSM_PLATFORM |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11307 | static inline bool hdd_adapter_is_sta(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11308 | { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11309 | return adapter->device_mode == QDF_STA_MODE || |
| 11310 | adapter->device_mode == QDF_P2P_CLIENT_MODE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11311 | } |
| 11312 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11313 | static inline bool hdd_adapter_is_ap(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11314 | { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11315 | return adapter->device_mode == QDF_SAP_MODE || |
| 11316 | adapter->device_mode == QDF_P2P_GO_MODE; |
| 11317 | } |
| 11318 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11319 | static bool hdd_any_adapter_is_assoc(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11320 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11321 | struct hdd_adapter *adapter; |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11322 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11323 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 11324 | if (hdd_adapter_is_sta(adapter) && |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11325 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
| 11326 | conn_info.connState == eConnectionState_Associated) { |
| 11327 | return true; |
| 11328 | } |
| 11329 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11330 | if (hdd_adapter_is_ap(adapter) && |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 11331 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->ap_active) { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11332 | return true; |
| 11333 | } |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11334 | } |
| 11335 | |
| 11336 | return false; |
| 11337 | } |
| 11338 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11339 | 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] | 11340 | { |
| 11341 | bool is_running; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11342 | |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 11343 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11344 | is_running = hdd_ctx->bus_bw_timer_running; |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 11345 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11346 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11347 | return is_running; |
| 11348 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11349 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11350 | 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] | 11351 | { |
| 11352 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
| 11353 | hdd_ctx->bus_bw_timer_running = true; |
| 11354 | qdf_timer_start(&hdd_ctx->bus_bw_timer, |
| 11355 | hdd_ctx->config->busBandwidthComputeInterval); |
| 11356 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
| 11357 | } |
| 11358 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11359 | void hdd_bus_bw_compute_timer_start(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11360 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11361 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11362 | |
| 11363 | if (hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 11364 | hdd_debug("Bandwidth compute timer already started"); |
| 11365 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11366 | } |
| 11367 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11368 | __hdd_bus_bw_compute_timer_start(hdd_ctx); |
| 11369 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11370 | hdd_exit(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11371 | } |
| 11372 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11373 | 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] | 11374 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11375 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11376 | |
| 11377 | if (hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 11378 | hdd_debug("Bandwidth compute timer already started"); |
| 11379 | return; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 11380 | } |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11381 | |
| 11382 | if (hdd_any_adapter_is_assoc(hdd_ctx)) |
| 11383 | __hdd_bus_bw_compute_timer_start(hdd_ctx); |
| 11384 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11385 | hdd_exit(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11386 | } |
| 11387 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11388 | 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] | 11389 | { |
| 11390 | hdd_ipa_set_perf_level(hdd_ctx, 0, 0); |
| 11391 | |
| 11392 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
| 11393 | qdf_timer_stop(&hdd_ctx->bus_bw_timer); |
| 11394 | hdd_ctx->bus_bw_timer_running = false; |
| 11395 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
| 11396 | |
| 11397 | hdd_reset_tcp_delack(hdd_ctx); |
| 11398 | } |
| 11399 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11400 | void hdd_bus_bw_compute_timer_stop(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11401 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11402 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11403 | |
| 11404 | if (!hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 11405 | hdd_debug("Bandwidth compute timer already stopped"); |
| 11406 | return; |
| 11407 | } |
| 11408 | |
| 11409 | __hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 11410 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11411 | hdd_exit(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11412 | } |
| 11413 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11414 | 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] | 11415 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11416 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11417 | |
| 11418 | if (!hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 11419 | hdd_debug("Bandwidth compute timer already stopped"); |
| 11420 | return; |
| 11421 | } |
| 11422 | |
| 11423 | if (!hdd_any_adapter_is_assoc(hdd_ctx)) |
| 11424 | __hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 11425 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11426 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11427 | } |
| 11428 | #endif |
| 11429 | |
| 11430 | /** |
| 11431 | * wlan_hdd_check_custom_con_channel_rules() - This function checks the sap's |
| 11432 | * and sta's operating channel. |
| 11433 | * @sta_adapter: Describe the first argument to foobar. |
| 11434 | * @ap_adapter: Describe the second argument to foobar. |
| 11435 | * @roam_profile: Roam profile of AP to which STA wants to connect. |
| 11436 | * @concurrent_chnl_same: If both SAP and STA channels are same then |
| 11437 | * set this flag to true else false. |
| 11438 | * |
| 11439 | * This function checks the sap's operating channel and sta's operating channel. |
| 11440 | * if both are same then it will return false else it will restart the sap in |
| 11441 | * sta's channel and return true. |
| 11442 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11443 | * Return: QDF_STATUS_SUCCESS or QDF_STATUS_E_FAILURE. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11444 | */ |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 11445 | QDF_STATUS |
| 11446 | wlan_hdd_check_custom_con_channel_rules(struct hdd_adapter *sta_adapter, |
| 11447 | struct hdd_adapter *ap_adapter, |
Jeff Johnson | 61b5e98 | 2018-03-15 11:33:31 -0700 | [diff] [blame] | 11448 | struct csr_roam_profile *roam_profile, |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 11449 | tScanResultHandle *scan_cache, |
| 11450 | bool *concurrent_chnl_same) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11451 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 11452 | struct hdd_ap_ctx *hdd_ap_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11453 | uint8_t channel_id; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11454 | QDF_STATUS status; |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 11455 | enum QDF_OPMODE device_mode = ap_adapter->device_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11456 | *concurrent_chnl_same = true; |
| 11457 | |
| 11458 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 11459 | status = |
Archana Ramachandran | 2eb7a61 | 2017-03-23 22:58:42 -0700 | [diff] [blame] | 11460 | sme_get_ap_channel_from_scan_cache(roam_profile, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11461 | scan_cache, |
| 11462 | &channel_id); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 11463 | if (QDF_STATUS_SUCCESS == status) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 11464 | if ((QDF_SAP_MODE == device_mode) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11465 | (channel_id < SIR_11A_CHANNEL_BEGIN)) { |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 11466 | if (hdd_ap_ctx->operating_channel != channel_id) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11467 | *concurrent_chnl_same = false; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11468 | hdd_debug("channels are different"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11469 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 11470 | } else if ((QDF_P2P_GO_MODE == device_mode) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11471 | (channel_id >= SIR_11A_CHANNEL_BEGIN)) { |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 11472 | if (hdd_ap_ctx->operating_channel != channel_id) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11473 | *concurrent_chnl_same = false; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11474 | hdd_debug("channels are different"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11475 | } |
| 11476 | } |
| 11477 | } else { |
| 11478 | /* |
| 11479 | * Lets handle worst case scenario here, Scan cache lookup is |
| 11480 | * failed so we have to stop the SAP to avoid any channel |
| 11481 | * discrepancy between SAP's channel and STA's channel. |
| 11482 | * Return the status as failure so caller function could know |
| 11483 | * that scan look up is failed. |
| 11484 | */ |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11485 | hdd_err("Finding AP from scan cache failed"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11486 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11487 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11488 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11489 | } |
| 11490 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11491 | /** |
| 11492 | * wlan_hdd_stop_sap() - This function stops bss of SAP. |
| 11493 | * @ap_adapter: SAP adapter |
| 11494 | * |
| 11495 | * This function will process the stopping of sap adapter. |
| 11496 | * |
| 11497 | * Return: None |
| 11498 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11499 | void wlan_hdd_stop_sap(struct hdd_adapter *ap_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11500 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 11501 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 11502 | struct hdd_hostapd_state *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 11503 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11504 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11505 | |
| 11506 | if (NULL == ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11507 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11508 | return; |
| 11509 | } |
| 11510 | |
| 11511 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 11512 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 11513 | if (wlan_hdd_validate_context(hdd_ctx)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11514 | return; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 11515 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11516 | mutex_lock(&hdd_ctx->sap_lock); |
| 11517 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
Ryan Hsu | 8ecb0fa | 2016-01-18 15:40:55 -0800 | [diff] [blame] | 11518 | wlan_hdd_del_station(ap_adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11519 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11520 | hdd_debug("Now doing SAP STOPBSS"); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 11521 | qdf_event_reset(&hostapd_state->qdf_stop_bss_event); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11522 | if (QDF_STATUS_SUCCESS == wlansap_stop_bss(hdd_ap_ctx-> |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 11523 | sap_context)) { |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 11524 | qdf_status = qdf_wait_for_event_completion(&hostapd_state-> |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 11525 | qdf_stop_bss_event, |
| 11526 | SME_CMD_TIMEOUT_VALUE); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 11527 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11528 | mutex_unlock(&hdd_ctx->sap_lock); |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11529 | hdd_err("SAP Stop Failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11530 | return; |
| 11531 | } |
| 11532 | } |
| 11533 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 11534 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
| 11535 | ap_adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11536 | ap_adapter->session_id); |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 11537 | hdd_start_green_ap_state_mc(hdd_ctx, ap_adapter->device_mode, |
| 11538 | false); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11539 | hdd_debug("SAP Stop Success"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11540 | } else { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11541 | hdd_err("Can't stop ap because its not started"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11542 | } |
| 11543 | mutex_unlock(&hdd_ctx->sap_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11544 | } |
| 11545 | |
| 11546 | /** |
| 11547 | * wlan_hdd_start_sap() - this function starts bss of SAP. |
| 11548 | * @ap_adapter: SAP adapter |
| 11549 | * |
| 11550 | * This function will process the starting of sap adapter. |
| 11551 | * |
| 11552 | * Return: None |
| 11553 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11554 | void wlan_hdd_start_sap(struct hdd_adapter *ap_adapter, bool reinit) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11555 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 11556 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 11557 | struct hdd_hostapd_state *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 11558 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11559 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11560 | tsap_Config_t *sap_config; |
| 11561 | |
| 11562 | if (NULL == ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11563 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11564 | return; |
| 11565 | } |
| 11566 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 11567 | if (QDF_SAP_MODE != ap_adapter->device_mode) { |
Peng Xu | f5d60c8 | 2015-10-02 17:17:03 -0700 | [diff] [blame] | 11568 | hdd_err("SoftAp role has not been enabled"); |
| 11569 | return; |
| 11570 | } |
| 11571 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11572 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
| 11573 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 11574 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 11575 | sap_config = &ap_adapter->session.ap.sap_config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11576 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11577 | mutex_lock(&hdd_ctx->sap_lock); |
| 11578 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) |
| 11579 | goto end; |
| 11580 | |
| 11581 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11582 | hdd_err("SAP Not able to set AP IEs"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11583 | goto end; |
| 11584 | } |
| 11585 | |
Wei Song | 2f76f64 | 2016-11-18 16:32:53 +0800 | [diff] [blame] | 11586 | qdf_event_reset(&hostapd_state->qdf_event); |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 11587 | if (wlansap_start_bss(hdd_ap_ctx->sap_context, hdd_hostapd_sap_event_cb, |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 11588 | &hdd_ap_ctx->sap_config, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11589 | ap_adapter->dev) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11590 | != QDF_STATUS_SUCCESS) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11591 | goto end; |
| 11592 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11593 | hdd_debug("Waiting for SAP to start"); |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 11594 | qdf_status = qdf_wait_for_event_completion(&hostapd_state->qdf_event, |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 11595 | SME_CMD_TIMEOUT_VALUE); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 11596 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11597 | hdd_err("SAP Start failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11598 | goto end; |
| 11599 | } |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11600 | hdd_info("SAP Start Success"); |
Vignesh Viswanathan | 85b455e | 2018-01-17 19:54:33 +0530 | [diff] [blame] | 11601 | wlansap_reset_sap_config_add_ie(sap_config, eUPDATE_IE_ALL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11602 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 11603 | if (hostapd_state->bss_state == BSS_START) { |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 11604 | policy_mgr_incr_active_session(hdd_ctx->hdd_psoc, |
| 11605 | ap_adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11606 | ap_adapter->session_id); |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 11607 | hdd_start_green_ap_state_mc(hdd_ctx, ap_adapter->device_mode, |
| 11608 | true); |
| 11609 | } |
Sourav Mohapatra | 9bc6711 | 2017-11-08 09:36:11 +0530 | [diff] [blame] | 11610 | mutex_unlock(&hdd_ctx->sap_lock); |
| 11611 | |
| 11612 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11613 | end: |
Vignesh Viswanathan | 85b455e | 2018-01-17 19:54:33 +0530 | [diff] [blame] | 11614 | wlansap_reset_sap_config_add_ie(sap_config, eUPDATE_IE_ALL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11615 | mutex_unlock(&hdd_ctx->sap_lock); |
Manikandan Mohan | 3dad1a4 | 2017-06-14 10:50:18 -0700 | [diff] [blame] | 11616 | /* SAP context and beacon cleanup will happen during driver unload |
| 11617 | * in hdd_stop_adapter |
| 11618 | */ |
| 11619 | hdd_err("SAP restart after SSR failed! Reload WLAN and try SAP again"); |
| 11620 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11621 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11622 | |
| 11623 | /** |
Archana Ramachandran | a20ef81 | 2015-11-13 16:12:13 -0800 | [diff] [blame] | 11624 | * wlan_hdd_soc_set_antenna_mode_cb() - Callback for set dual |
| 11625 | * mac scan config |
| 11626 | * @status: Status of set antenna mode |
| 11627 | * |
| 11628 | * Callback on setting the dual mac configuration |
| 11629 | * |
| 11630 | * Return: None |
| 11631 | */ |
| 11632 | void wlan_hdd_soc_set_antenna_mode_cb( |
| 11633 | enum set_antenna_mode_status status) |
| 11634 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11635 | struct hdd_context *hdd_ctx; |
Archana Ramachandran | a20ef81 | 2015-11-13 16:12:13 -0800 | [diff] [blame] | 11636 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11637 | hdd_debug("Status: %d", status); |
Archana Ramachandran | a20ef81 | 2015-11-13 16:12:13 -0800 | [diff] [blame] | 11638 | |
| 11639 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 11640 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
| 11641 | return; |
| 11642 | |
| 11643 | /* Signal the completion of set dual mac config */ |
| 11644 | complete(&hdd_ctx->set_antenna_mode_cmpl); |
| 11645 | } |
| 11646 | |
| 11647 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11648 | * hdd_get_fw_version() - Get FW version |
| 11649 | * @hdd_ctx: pointer to HDD context. |
| 11650 | * @major_spid: FW version - major spid. |
| 11651 | * @minor_spid: FW version - minor spid |
| 11652 | * @ssid: FW version - ssid |
| 11653 | * @crmid: FW version - crmid |
| 11654 | * |
| 11655 | * This function is called to get the firmware build version stored |
| 11656 | * as part of the HDD context |
| 11657 | * |
| 11658 | * Return: None |
| 11659 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11660 | void hdd_get_fw_version(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11661 | uint32_t *major_spid, uint32_t *minor_spid, |
| 11662 | uint32_t *siid, uint32_t *crmid) |
| 11663 | { |
| 11664 | *major_spid = (hdd_ctx->target_fw_version & 0xf0000000) >> 28; |
| 11665 | *minor_spid = (hdd_ctx->target_fw_version & 0xf000000) >> 24; |
| 11666 | *siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20; |
| 11667 | *crmid = hdd_ctx->target_fw_version & 0x7fff; |
| 11668 | } |
| 11669 | |
| 11670 | #ifdef QCA_CONFIG_SMP |
| 11671 | /** |
| 11672 | * wlan_hdd_get_cpu() - get cpu_index |
| 11673 | * |
| 11674 | * Return: cpu_index |
| 11675 | */ |
| 11676 | int wlan_hdd_get_cpu(void) |
| 11677 | { |
| 11678 | int cpu_index = get_cpu(); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 11679 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11680 | put_cpu(); |
| 11681 | return cpu_index; |
| 11682 | } |
| 11683 | #endif |
| 11684 | |
| 11685 | /** |
| 11686 | * hdd_get_fwpath() - get framework path |
| 11687 | * |
| 11688 | * This function is used to get the string written by |
| 11689 | * userspace to start the wlan driver |
| 11690 | * |
| 11691 | * Return: string |
| 11692 | */ |
| 11693 | const char *hdd_get_fwpath(void) |
| 11694 | { |
| 11695 | return fwpath.string; |
| 11696 | } |
| 11697 | |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 11698 | static int hdd_qdf_print_init(void) |
| 11699 | { |
| 11700 | int qdf_print_idx; |
| 11701 | QDF_STATUS status; |
| 11702 | |
| 11703 | status = qdf_print_setup(); |
| 11704 | if (status != QDF_STATUS_SUCCESS) { |
| 11705 | pr_err("qdf_print_setup failed\n"); |
| 11706 | return -EINVAL; |
| 11707 | } |
| 11708 | |
| 11709 | qdf_print_idx = qdf_print_ctrl_register(cinfo, NULL, NULL, "MCL_WLAN"); |
| 11710 | |
| 11711 | if (qdf_print_idx < 0) { |
| 11712 | pr_err("qdf_print_ctrl_register failed, ret = %d\n", |
| 11713 | qdf_print_idx); |
| 11714 | return -EINVAL; |
| 11715 | } |
| 11716 | |
| 11717 | qdf_set_pidx(qdf_print_idx); |
| 11718 | |
| 11719 | return 0; |
| 11720 | } |
| 11721 | |
| 11722 | static void hdd_qdf_print_deinit(void) |
| 11723 | { |
| 11724 | int qdf_print_idx; |
| 11725 | |
| 11726 | qdf_print_idx = qdf_get_pidx(); |
| 11727 | qdf_print_ctrl_cleanup(qdf_print_idx); |
| 11728 | } |
| 11729 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11730 | /** |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11731 | * hdd_init() - Initialize Driver |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11732 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11733 | * This function initilizes CDS global context with the help of cds_init. This |
| 11734 | * has to be the first function called after probe to get a valid global |
| 11735 | * context. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11736 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11737 | * Return: 0 for success, errno on failure |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11738 | */ |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11739 | int hdd_init(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11740 | { |
Jeff Johnson | 7aaeeea | 2017-09-26 13:16:24 -0700 | [diff] [blame] | 11741 | QDF_STATUS status; |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11742 | int ret = 0; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11743 | |
Jeff Johnson | 7aaeeea | 2017-09-26 13:16:24 -0700 | [diff] [blame] | 11744 | status = cds_init(); |
wadesong | ae4ffd1 | 2017-10-24 16:45:54 +0800 | [diff] [blame] | 11745 | if (QDF_IS_STATUS_ERROR(status)) { |
| 11746 | hdd_err("Failed to allocate CDS context"); |
| 11747 | ret = -ENOMEM; |
| 11748 | goto err_out; |
| 11749 | } |
Hanumanth Reddy Pothula | 788a37e | 2017-08-17 18:40:11 +0530 | [diff] [blame] | 11750 | |
| 11751 | wlan_init_bug_report_lock(); |
| 11752 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11753 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 11754 | wlan_logging_sock_init_svc(); |
| 11755 | #endif |
| 11756 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 11757 | qdf_timer_init(NULL, &hdd_drv_ops_inactivity_timer, |
| 11758 | (void *)hdd_drv_ops_inactivity_handler, NULL, |
| 11759 | QDF_TIMER_TYPE_SW); |
| 11760 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11761 | hdd_trace_init(); |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 11762 | hdd_qdf_print_init(); |
| 11763 | |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11764 | hdd_register_debug_callback(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11765 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11766 | err_out: |
| 11767 | return ret; |
| 11768 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11769 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11770 | /** |
| 11771 | * hdd_deinit() - Deinitialize Driver |
| 11772 | * |
| 11773 | * This function frees CDS global context with the help of cds_deinit. This |
| 11774 | * has to be the last function call in remove callback to free the global |
| 11775 | * context. |
| 11776 | */ |
| 11777 | void hdd_deinit(void) |
| 11778 | { |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 11779 | qdf_timer_free(&hdd_drv_ops_inactivity_timer); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11780 | |
Rajeev Kumar | 2d0f219 | 2017-10-18 19:48:21 -0700 | [diff] [blame] | 11781 | wlan_destroy_bug_report_lock(); |
| 11782 | cds_deinit(); |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 11783 | |
Rajeev Kumar | 2d0f219 | 2017-10-18 19:48:21 -0700 | [diff] [blame] | 11784 | hdd_qdf_print_deinit(); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11785 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 11786 | wlan_logging_sock_deinit_svc(); |
| 11787 | #endif |
| 11788 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11789 | |
Yue Ma | 6e7b1a0 | 2017-04-03 14:17:46 -0700 | [diff] [blame] | 11790 | #ifdef QCA_WIFI_NAPIER_EMULATION |
| 11791 | #define HDD_WLAN_START_WAIT_TIME ((CDS_WMA_TIMEOUT + 5000) * 100) |
| 11792 | #else |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11793 | #define HDD_WLAN_START_WAIT_TIME (CDS_WMA_TIMEOUT + 5000) |
Yue Ma | 6e7b1a0 | 2017-04-03 14:17:46 -0700 | [diff] [blame] | 11794 | #endif |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11795 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11796 | static int wlan_hdd_state_ctrl_param_open(struct inode *inode, |
| 11797 | struct file *file) |
| 11798 | { |
| 11799 | return 0; |
| 11800 | } |
| 11801 | |
| 11802 | static ssize_t wlan_hdd_state_ctrl_param_write(struct file *filp, |
| 11803 | const char __user *user_buf, |
| 11804 | size_t count, |
| 11805 | loff_t *f_pos) |
| 11806 | { |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 11807 | char buf[3]; |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11808 | static const char wlan_off_str[] = "OFF"; |
| 11809 | static const char wlan_on_str[] = "ON"; |
| 11810 | int ret; |
| 11811 | unsigned long rc; |
| 11812 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 11813 | if (copy_from_user(buf, user_buf, 3)) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11814 | pr_err("Failed to read buffer\n"); |
| 11815 | return -EINVAL; |
| 11816 | } |
| 11817 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 11818 | if (strncmp(buf, wlan_off_str, strlen(wlan_off_str)) == 0) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11819 | pr_debug("Wifi turning off from UI\n"); |
| 11820 | goto exit; |
| 11821 | } |
| 11822 | |
Sachin Ahuja | 16904db | 2017-12-13 19:56:57 +0530 | [diff] [blame] | 11823 | if (strncmp(buf, wlan_on_str, strlen(wlan_on_str)) == 0) { |
| 11824 | pr_info("Wifi Turning On from UI\n"); |
| 11825 | } |
| 11826 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 11827 | if (strncmp(buf, wlan_on_str, strlen(wlan_on_str)) != 0) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11828 | pr_err("Invalid value received from framework"); |
| 11829 | goto exit; |
| 11830 | } |
| 11831 | |
| 11832 | if (!cds_is_driver_loaded()) { |
Sachin Ahuja | ee62b54 | 2017-04-21 14:14:16 +0530 | [diff] [blame] | 11833 | init_completion(&wlan_start_comp); |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11834 | rc = wait_for_completion_timeout(&wlan_start_comp, |
| 11835 | msecs_to_jiffies(HDD_WLAN_START_WAIT_TIME)); |
| 11836 | if (!rc) { |
| 11837 | hdd_alert("Timed-out waiting in wlan_hdd_state_ctrl_param_write"); |
| 11838 | ret = -EINVAL; |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11839 | return ret; |
| 11840 | } |
| 11841 | |
| 11842 | hdd_start_complete(0); |
| 11843 | } |
| 11844 | |
| 11845 | exit: |
| 11846 | return count; |
| 11847 | } |
| 11848 | |
| 11849 | |
| 11850 | const struct file_operations wlan_hdd_state_fops = { |
| 11851 | .owner = THIS_MODULE, |
| 11852 | .open = wlan_hdd_state_ctrl_param_open, |
| 11853 | .write = wlan_hdd_state_ctrl_param_write, |
| 11854 | }; |
| 11855 | |
| 11856 | static int wlan_hdd_state_ctrl_param_create(void) |
| 11857 | { |
| 11858 | unsigned int wlan_hdd_state_major = 0; |
| 11859 | int ret; |
| 11860 | struct device *dev; |
| 11861 | |
| 11862 | device = MKDEV(wlan_hdd_state_major, 0); |
| 11863 | |
| 11864 | ret = alloc_chrdev_region(&device, 0, dev_num, "qcwlanstate"); |
| 11865 | if (ret) { |
| 11866 | pr_err("Failed to register qcwlanstate"); |
| 11867 | goto dev_alloc_err; |
| 11868 | } |
| 11869 | wlan_hdd_state_major = MAJOR(device); |
| 11870 | |
| 11871 | class = class_create(THIS_MODULE, WLAN_MODULE_NAME); |
| 11872 | if (IS_ERR(class)) { |
| 11873 | pr_err("wlan_hdd_state class_create error"); |
| 11874 | goto class_err; |
| 11875 | } |
| 11876 | |
| 11877 | dev = device_create(class, NULL, device, NULL, WLAN_MODULE_NAME); |
| 11878 | if (IS_ERR(dev)) { |
| 11879 | pr_err("wlan_hdd_statedevice_create error"); |
| 11880 | goto err_class_destroy; |
| 11881 | } |
| 11882 | |
| 11883 | cdev_init(&wlan_hdd_state_cdev, &wlan_hdd_state_fops); |
| 11884 | ret = cdev_add(&wlan_hdd_state_cdev, device, dev_num); |
| 11885 | if (ret) { |
| 11886 | pr_err("Failed to add cdev error"); |
| 11887 | goto cdev_add_err; |
| 11888 | } |
| 11889 | |
| 11890 | pr_info("wlan_hdd_state %s major(%d) initialized", |
| 11891 | WLAN_MODULE_NAME, wlan_hdd_state_major); |
| 11892 | |
| 11893 | return 0; |
| 11894 | |
| 11895 | cdev_add_err: |
| 11896 | device_destroy(class, device); |
| 11897 | err_class_destroy: |
| 11898 | class_destroy(class); |
| 11899 | class_err: |
| 11900 | unregister_chrdev_region(device, dev_num); |
| 11901 | dev_alloc_err: |
| 11902 | return -ENODEV; |
| 11903 | } |
| 11904 | |
| 11905 | static void wlan_hdd_state_ctrl_param_destroy(void) |
| 11906 | { |
| 11907 | cdev_del(&wlan_hdd_state_cdev); |
| 11908 | device_destroy(class, device); |
| 11909 | class_destroy(class); |
| 11910 | unregister_chrdev_region(device, dev_num); |
| 11911 | |
| 11912 | pr_info("Device node unregistered"); |
| 11913 | } |
| 11914 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11915 | /** |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 11916 | * component_init - API to init cld component's |
| 11917 | * |
| 11918 | * Return: None |
| 11919 | */ |
| 11920 | static void component_init(void) |
| 11921 | { |
| 11922 | pmo_init(); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 11923 | disa_init(); |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 11924 | ucfg_ocb_init(); |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 11925 | ipa_init(); |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 11926 | } |
| 11927 | |
| 11928 | /** |
| 11929 | * component_deinit - API to deinit cld component's |
| 11930 | * |
| 11931 | * Return: None |
| 11932 | */ |
| 11933 | static void component_deinit(void) |
| 11934 | { |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 11935 | ipa_deinit(); |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 11936 | ucfg_ocb_deinit(); |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 11937 | pmo_deinit(); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 11938 | disa_deinit(); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 11939 | } |
| 11940 | |
| 11941 | void hdd_component_psoc_enable(struct wlan_objmgr_psoc *psoc) |
| 11942 | { |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 11943 | ocb_psoc_enable(psoc); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 11944 | disa_psoc_enable(psoc); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 11945 | } |
| 11946 | |
| 11947 | void hdd_component_psoc_disable(struct wlan_objmgr_psoc *psoc) |
| 11948 | { |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 11949 | disa_psoc_disable(psoc); |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 11950 | ocb_psoc_disable(psoc); |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 11951 | } |
| 11952 | |
| 11953 | /** |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11954 | * __hdd_module_init - Module init helper |
| 11955 | * |
| 11956 | * Module init helper function used by both module and static driver. |
| 11957 | * |
| 11958 | * Return: 0 for success, errno on failure |
| 11959 | */ |
| 11960 | static int __hdd_module_init(void) |
| 11961 | { |
| 11962 | int ret = 0; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11963 | |
Dustin Brown | 96cd963 | 2017-11-13 12:45:04 -0800 | [diff] [blame] | 11964 | pr_err("%s: Loading driver v%s (%s)\n", |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 11965 | WLAN_MODULE_NAME, |
Dustin Brown | 96cd963 | 2017-11-13 12:45:04 -0800 | [diff] [blame] | 11966 | g_wlan_driver_version, |
Dustin Brown | c1034df | 2018-02-07 14:51:32 -0800 | [diff] [blame] | 11967 | TIMER_MANAGER_STR MEMORY_DEBUG_STR PANIC_ON_BUG_STR); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11968 | |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 11969 | pld_init(); |
| 11970 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 11971 | ret = hdd_init(); |
| 11972 | if (ret) { |
| 11973 | pr_err("hdd_init failed %x\n", ret); |
| 11974 | goto err_hdd_init; |
| 11975 | } |
| 11976 | |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 11977 | dispatcher_init(); |
| 11978 | |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 11979 | /* Ensure to call post objmgr init */ |
| 11980 | component_init(); |
| 11981 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 11982 | qdf_wake_lock_create(&wlan_wake_lock, "wlan"); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11983 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11984 | hdd_set_conparam((uint32_t) con_mode); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11985 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11986 | ret = wlan_hdd_register_driver(); |
| 11987 | if (ret) { |
Mohit Khanna | fa99aea | 2016-05-12 21:43:13 -0700 | [diff] [blame] | 11988 | pr_err("%s: driver load failure, err %d\n", WLAN_MODULE_NAME, |
| 11989 | ret); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11990 | goto out; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11991 | } |
| 11992 | |
Sachin Ahuja | 16904db | 2017-12-13 19:56:57 +0530 | [diff] [blame] | 11993 | ret = wlan_hdd_state_ctrl_param_create(); |
| 11994 | if (ret) { |
| 11995 | pr_err("wlan_hdd_state_create:%x\n", ret); |
| 11996 | goto out; |
| 11997 | } |
| 11998 | |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 11999 | pr_info("%s: driver loaded\n", WLAN_MODULE_NAME); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12000 | |
| 12001 | return 0; |
| 12002 | out: |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 12003 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Liangwei Dong | 9fcc721 | 2017-10-24 13:43:52 +0800 | [diff] [blame] | 12004 | component_deinit(); |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 12005 | dispatcher_deinit(); |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12006 | hdd_deinit(); |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 12007 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12008 | err_hdd_init: |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 12009 | pld_deinit(); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12010 | return ret; |
| 12011 | } |
| 12012 | |
| 12013 | /** |
| 12014 | * __hdd_module_exit - Module exit helper |
| 12015 | * |
| 12016 | * Module exit helper function used by both module and static driver. |
| 12017 | */ |
| 12018 | static void __hdd_module_exit(void) |
| 12019 | { |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 12020 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12021 | pr_info("%s: Unloading driver v%s\n", WLAN_MODULE_NAME, |
| 12022 | QWLAN_VERSIONSTR); |
| 12023 | |
Arunk Khandavalli | 07ec8f6 | 2016-09-27 21:51:01 +0530 | [diff] [blame] | 12024 | hdd_wait_for_recovery_completion(); |
| 12025 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12026 | wlan_hdd_unregister_driver(); |
| 12027 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 12028 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12029 | |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 12030 | /* Ensure to call prior to objmgr deinit */ |
| 12031 | component_deinit(); |
| 12032 | |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 12033 | dispatcher_deinit(); |
Amar Singhal | 0928b19 | 2017-12-01 10:50:54 -0800 | [diff] [blame] | 12034 | |
| 12035 | hdd_sysfs_destroy_version_interface(); |
| 12036 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12037 | hdd_deinit(); |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 12038 | pld_deinit(); |
| 12039 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12040 | wlan_hdd_state_ctrl_param_destroy(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12041 | } |
| 12042 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12043 | #ifndef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12044 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12045 | * wlan_boot_cb() - Wlan boot callback |
| 12046 | * @kobj: object whose directory we're creating the link in. |
| 12047 | * @attr: attribute the user is interacting with |
| 12048 | * @buff: the buffer containing the user data |
| 12049 | * @count: number of bytes in the buffer |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12050 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12051 | * This callback is invoked when the fs is ready to start the |
| 12052 | * wlan driver initialization. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12053 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12054 | * 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] | 12055 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12056 | static ssize_t wlan_boot_cb(struct kobject *kobj, |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12057 | struct kobj_attribute *attr, |
| 12058 | const char *buf, |
| 12059 | size_t count) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12060 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12061 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12062 | if (wlan_loader->loaded_state) { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12063 | pr_err("%s: wlan driver already initialized\n", __func__); |
| 12064 | return -EALREADY; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12065 | } |
| 12066 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12067 | if (__hdd_module_init()) { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12068 | pr_err("%s: wlan driver initialization failed\n", __func__); |
| 12069 | return -EIO; |
| 12070 | } |
| 12071 | |
| 12072 | wlan_loader->loaded_state = MODULE_INITIALIZED; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12073 | |
| 12074 | return count; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12075 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12076 | |
| 12077 | /** |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12078 | * hdd_sysfs_cleanup() - cleanup sysfs |
| 12079 | * |
| 12080 | * Return: None |
| 12081 | * |
| 12082 | */ |
| 12083 | static void hdd_sysfs_cleanup(void) |
| 12084 | { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12085 | /* remove from group */ |
| 12086 | if (wlan_loader->boot_wlan_obj && wlan_loader->attr_group) |
| 12087 | sysfs_remove_group(wlan_loader->boot_wlan_obj, |
| 12088 | wlan_loader->attr_group); |
| 12089 | |
| 12090 | /* unlink the object from parent */ |
| 12091 | kobject_del(wlan_loader->boot_wlan_obj); |
| 12092 | |
| 12093 | /* free the object */ |
| 12094 | kobject_put(wlan_loader->boot_wlan_obj); |
| 12095 | |
| 12096 | kfree(wlan_loader->attr_group); |
| 12097 | kfree(wlan_loader); |
| 12098 | |
| 12099 | wlan_loader = NULL; |
| 12100 | } |
| 12101 | |
| 12102 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12103 | * wlan_init_sysfs() - Creates the sysfs to be invoked when the fs is |
| 12104 | * ready |
| 12105 | * |
| 12106 | * This is creates the syfs entry boot_wlan. Which shall be invoked |
| 12107 | * when the filesystem is ready. |
| 12108 | * |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12109 | * QDF API cannot be used here since this function is called even before |
| 12110 | * initializing WLAN driver. |
| 12111 | * |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 12112 | * Return: 0 for success, errno on failure |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12113 | */ |
| 12114 | static int wlan_init_sysfs(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12115 | { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12116 | int ret = -ENOMEM; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12117 | |
| 12118 | wlan_loader = kzalloc(sizeof(*wlan_loader), GFP_KERNEL); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 12119 | if (!wlan_loader) |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12120 | return -ENOMEM; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12121 | |
| 12122 | wlan_loader->boot_wlan_obj = NULL; |
| 12123 | wlan_loader->attr_group = kzalloc(sizeof(*(wlan_loader->attr_group)), |
| 12124 | GFP_KERNEL); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 12125 | if (!wlan_loader->attr_group) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12126 | goto error_return; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12127 | |
| 12128 | wlan_loader->loaded_state = 0; |
| 12129 | wlan_loader->attr_group->attrs = attrs; |
| 12130 | |
| 12131 | wlan_loader->boot_wlan_obj = kobject_create_and_add("boot_wlan", |
| 12132 | kernel_kobj); |
| 12133 | if (!wlan_loader->boot_wlan_obj) { |
| 12134 | pr_err("%s: sysfs create and add failed\n", __func__); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12135 | goto error_return; |
| 12136 | } |
| 12137 | |
| 12138 | ret = sysfs_create_group(wlan_loader->boot_wlan_obj, |
| 12139 | wlan_loader->attr_group); |
| 12140 | if (ret) { |
| 12141 | pr_err("%s: sysfs create group failed %d\n", __func__, ret); |
| 12142 | goto error_return; |
| 12143 | } |
| 12144 | |
| 12145 | return 0; |
| 12146 | |
| 12147 | error_return: |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12148 | hdd_sysfs_cleanup(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12149 | |
| 12150 | return ret; |
| 12151 | } |
| 12152 | |
| 12153 | /** |
| 12154 | * wlan_deinit_sysfs() - Removes the sysfs created to initialize the wlan |
| 12155 | * |
| 12156 | * Return: 0 on success or errno on failure |
| 12157 | */ |
| 12158 | static int wlan_deinit_sysfs(void) |
| 12159 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12160 | if (!wlan_loader) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12161 | hdd_err("wlan loader context is Null!"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12162 | return -EINVAL; |
| 12163 | } |
| 12164 | |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12165 | hdd_sysfs_cleanup(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12166 | return 0; |
| 12167 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12168 | |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12169 | #endif /* MODULE */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12170 | |
| 12171 | #ifdef MODULE |
| 12172 | /** |
| 12173 | * __hdd_module_init - Module init helper |
| 12174 | * |
| 12175 | * Module init helper function used by both module and static driver. |
| 12176 | * |
| 12177 | * Return: 0 for success, errno on failure |
| 12178 | */ |
| 12179 | static int hdd_module_init(void) |
| 12180 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12181 | if (__hdd_module_init()) { |
| 12182 | pr_err("%s: Failed to register handler\n", __func__); |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 12183 | return -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12184 | } |
| 12185 | |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 12186 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12187 | } |
| 12188 | #else |
| 12189 | static int __init hdd_module_init(void) |
| 12190 | { |
| 12191 | int ret = -EINVAL; |
| 12192 | |
| 12193 | ret = wlan_init_sysfs(); |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 12194 | if (ret) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12195 | pr_err("Failed to create sysfs entry for loading wlan"); |
| 12196 | |
| 12197 | return ret; |
| 12198 | } |
| 12199 | #endif |
| 12200 | |
| 12201 | |
| 12202 | #ifdef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12203 | /** |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12204 | * hdd_module_exit() - Exit function |
| 12205 | * |
| 12206 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 12207 | * |
| 12208 | * Return: None |
| 12209 | */ |
| 12210 | static void __exit hdd_module_exit(void) |
| 12211 | { |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12212 | __hdd_module_exit(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12213 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12214 | #else |
| 12215 | static void __exit hdd_module_exit(void) |
| 12216 | { |
| 12217 | __hdd_module_exit(); |
| 12218 | wlan_deinit_sysfs(); |
| 12219 | } |
| 12220 | #endif |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12221 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12222 | static int fwpath_changed_handler(const char *kmessage, struct kernel_param *kp) |
| 12223 | { |
| 12224 | return param_set_copystring(kmessage, kp); |
| 12225 | } |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12226 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12227 | /** |
| 12228 | * is_con_mode_valid() check con mode is valid or not |
| 12229 | * @mode: global con mode |
| 12230 | * |
| 12231 | * Return: TRUE on success FALSE on failure |
| 12232 | */ |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12233 | static bool is_con_mode_valid(enum QDF_GLOBAL_MODE mode) |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12234 | { |
| 12235 | switch (mode) { |
| 12236 | case QDF_GLOBAL_MONITOR_MODE: |
| 12237 | case QDF_GLOBAL_FTM_MODE: |
| 12238 | case QDF_GLOBAL_EPPING_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12239 | case QDF_GLOBAL_MISSION_MODE: |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12240 | return true; |
| 12241 | default: |
| 12242 | return false; |
| 12243 | } |
| 12244 | } |
| 12245 | |
| 12246 | /** |
| 12247 | * hdd_get_adpter_mode() - returns adapter mode based on global con mode |
| 12248 | * @mode: global con mode |
| 12249 | * |
| 12250 | * Return: adapter mode |
| 12251 | */ |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 12252 | static enum QDF_OPMODE hdd_get_adpter_mode( |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12253 | enum QDF_GLOBAL_MODE mode) |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12254 | { |
| 12255 | |
| 12256 | switch (mode) { |
| 12257 | case QDF_GLOBAL_MISSION_MODE: |
| 12258 | return QDF_STA_MODE; |
| 12259 | case QDF_GLOBAL_MONITOR_MODE: |
| 12260 | return QDF_MONITOR_MODE; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12261 | case QDF_GLOBAL_EPPING_MODE: |
| 12262 | return QDF_EPPING_MODE; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12263 | case QDF_GLOBAL_FTM_MODE: |
| 12264 | return QDF_FTM_MODE; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12265 | case QDF_GLOBAL_QVIT_MODE: |
| 12266 | return QDF_QVIT_MODE; |
| 12267 | default: |
| 12268 | return QDF_MAX_NO_OF_MODE; |
| 12269 | } |
| 12270 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12271 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12272 | static void hdd_stop_present_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12273 | enum QDF_GLOBAL_MODE curr_mode) |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12274 | { |
| 12275 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) |
| 12276 | return; |
| 12277 | |
| 12278 | switch (curr_mode) { |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12279 | case QDF_GLOBAL_MONITOR_MODE: |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 12280 | hdd_info("Release wakelock for monitor mode!"); |
| 12281 | qdf_wake_lock_release(&hdd_ctx->monitor_mode_wakelock, |
| 12282 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 12283 | case QDF_GLOBAL_MISSION_MODE: |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12284 | case QDF_GLOBAL_FTM_MODE: |
| 12285 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
Sourav Mohapatra | 001cfaf | 2018-02-28 11:30:46 +0530 | [diff] [blame] | 12286 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->hdd_pdev, NULL); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 12287 | hdd_stop_all_adapters(hdd_ctx); |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12288 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12289 | break; |
| 12290 | default: |
| 12291 | break; |
| 12292 | } |
| 12293 | } |
| 12294 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12295 | static void hdd_cleanup_present_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12296 | enum QDF_GLOBAL_MODE curr_mode) |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12297 | { |
Ashish Kumar Dhanotiya | 0024313 | 2017-01-24 16:37:34 +0530 | [diff] [blame] | 12298 | int driver_status; |
| 12299 | |
| 12300 | driver_status = hdd_ctx->driver_status; |
| 12301 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12302 | switch (curr_mode) { |
| 12303 | case QDF_GLOBAL_MISSION_MODE: |
| 12304 | case QDF_GLOBAL_MONITOR_MODE: |
| 12305 | case QDF_GLOBAL_FTM_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12306 | hdd_deinit_all_adapters(hdd_ctx, false); |
| 12307 | hdd_close_all_adapters(hdd_ctx, false); |
| 12308 | break; |
| 12309 | case QDF_GLOBAL_EPPING_MODE: |
| 12310 | epping_disable(); |
| 12311 | epping_close(); |
| 12312 | break; |
| 12313 | default: |
| 12314 | return; |
| 12315 | } |
| 12316 | } |
| 12317 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12318 | static int hdd_register_req_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12319 | enum QDF_GLOBAL_MODE mode) |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12320 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12321 | struct hdd_adapter *adapter; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12322 | int ret = 0; |
| 12323 | bool rtnl_held; |
| 12324 | qdf_device_t qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 12325 | QDF_STATUS status; |
| 12326 | |
| 12327 | if (!qdf_dev) { |
| 12328 | hdd_err("qdf device context is Null return!"); |
| 12329 | return -EINVAL; |
| 12330 | } |
| 12331 | |
| 12332 | rtnl_held = hdd_hold_rtnl_lock(); |
| 12333 | switch (mode) { |
| 12334 | case QDF_GLOBAL_MISSION_MODE: |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 12335 | ret = hdd_open_interfaces(hdd_ctx, rtnl_held); |
| 12336 | if (ret) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12337 | hdd_err("Failed to open interfaces: %d", ret); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12338 | break; |
| 12339 | case QDF_GLOBAL_FTM_MODE: |
| 12340 | adapter = hdd_open_adapter(hdd_ctx, QDF_FTM_MODE, "wlan%d", |
| 12341 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 12342 | NET_NAME_UNKNOWN, rtnl_held); |
| 12343 | if (adapter == NULL) |
| 12344 | ret = -EINVAL; |
| 12345 | break; |
| 12346 | case QDF_GLOBAL_MONITOR_MODE: |
| 12347 | adapter = hdd_open_adapter(hdd_ctx, QDF_MONITOR_MODE, "wlan%d", |
| 12348 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 12349 | NET_NAME_UNKNOWN, rtnl_held); |
| 12350 | if (adapter == NULL) |
| 12351 | ret = -EINVAL; |
| 12352 | break; |
| 12353 | case QDF_GLOBAL_EPPING_MODE: |
| 12354 | status = epping_open(); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 12355 | if (status != QDF_STATUS_SUCCESS) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12356 | hdd_err("Failed to open in eeping mode: %d", status); |
| 12357 | ret = -EINVAL; |
| 12358 | break; |
| 12359 | } |
| 12360 | ret = epping_enable(qdf_dev->dev); |
| 12361 | if (ret) { |
| 12362 | hdd_err("Failed to enable in epping mode : %d", ret); |
| 12363 | epping_close(); |
| 12364 | } |
| 12365 | break; |
| 12366 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12367 | hdd_err("Mode not supported"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12368 | ret = -ENOTSUPP; |
| 12369 | break; |
| 12370 | } |
| 12371 | hdd_release_rtnl_lock(); |
| 12372 | rtnl_held = false; |
| 12373 | return ret; |
| 12374 | } |
| 12375 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12376 | /** |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12377 | * __con_mode_handler() - Handles module param con_mode change |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12378 | * @kmessage: con mode name on which driver to be bring up |
| 12379 | * @kp: The associated kernel parameter |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12380 | * @hdd_ctx: Pointer to the global HDD context |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12381 | * |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12382 | * This function is invoked when user updates con mode using sys entry, |
| 12383 | * to initialize and bring-up driver in that specific mode. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12384 | * |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12385 | * Return - 0 on success and failure code on failure |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12386 | */ |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12387 | static int __con_mode_handler(const char *kmessage, struct kernel_param *kp, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12388 | struct hdd_context *hdd_ctx) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12389 | { |
| 12390 | int ret; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12391 | struct hdd_adapter *adapter; |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12392 | enum QDF_GLOBAL_MODE curr_mode; |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 12393 | enum QDF_OPMODE adapter_mode; |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12394 | int new_con_mode; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12395 | |
Dustin Brown | ab6029b | 2017-05-24 13:04:19 -0700 | [diff] [blame] | 12396 | hdd_info("con_mode handler: %s", kmessage); |
| 12397 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12398 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 12399 | if (ret) |
| 12400 | return ret; |
| 12401 | |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 12402 | qdf_atomic_set(&hdd_ctx->con_mode_flag, 1); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12403 | cds_set_load_in_progress(true); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12404 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12405 | ret = kstrtoint(kmessage, 0, &new_con_mode); |
| 12406 | if (ret) { |
| 12407 | hdd_err("Failed to parse con_mode '%s'", kmessage); |
| 12408 | goto reset_flags; |
| 12409 | } |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 12410 | mutex_lock(&hdd_init_deinit_lock); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12411 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12412 | if (!is_con_mode_valid(new_con_mode)) { |
| 12413 | hdd_err("invalid con_mode %d", new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12414 | ret = -EINVAL; |
| 12415 | goto reset_flags; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12416 | } |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12417 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12418 | curr_mode = hdd_get_conparam(); |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12419 | if (curr_mode == new_con_mode) { |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12420 | hdd_err("curr mode: %d is same as user triggered mode %d", |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12421 | curr_mode, new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12422 | ret = 0; |
| 12423 | goto reset_flags; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12424 | } |
| 12425 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12426 | /* ensure adapters are stopped */ |
| 12427 | hdd_stop_present_mode(hdd_ctx, curr_mode); |
| 12428 | |
Frank Liu | 6666f83 | 2018-01-04 10:06:05 +0800 | [diff] [blame] | 12429 | /* Cleanup present mode before switching to new mode */ |
| 12430 | hdd_cleanup_present_mode(hdd_ctx, curr_mode); |
| 12431 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 12432 | ret = hdd_wlan_stop_modules(hdd_ctx, true); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12433 | if (ret) { |
| 12434 | hdd_err("Stop wlan modules failed"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12435 | goto reset_flags; |
| 12436 | } |
| 12437 | |
Ashish Kumar Dhanotiya | cda5766 | 2017-08-14 14:45:25 +0530 | [diff] [blame] | 12438 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12439 | hdd_set_conparam(new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12440 | |
Frank Liu | 6666f83 | 2018-01-04 10:06:05 +0800 | [diff] [blame] | 12441 | /* |
| 12442 | * Set ACTIVE domain before adapters created, otherwise check domain |
| 12443 | * match will fail when cleanup adapters. |
| 12444 | */ |
| 12445 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_ACTIVE); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12446 | /* Register for new con_mode & then kick_start modules again */ |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12447 | ret = hdd_register_req_mode(hdd_ctx, new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12448 | if (ret) { |
| 12449 | hdd_err("Failed to register for new mode"); |
| 12450 | goto reset_flags; |
| 12451 | } |
| 12452 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12453 | adapter_mode = hdd_get_adpter_mode(new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12454 | if (adapter_mode == QDF_MAX_NO_OF_MODE) { |
| 12455 | hdd_err("invalid adapter"); |
| 12456 | ret = -EINVAL; |
| 12457 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12458 | } |
| 12459 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12460 | adapter = hdd_get_adapter(hdd_ctx, adapter_mode); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12461 | if (!adapter) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12462 | hdd_err("Failed to get adapter:%d", adapter_mode); |
| 12463 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12464 | } |
| 12465 | |
| 12466 | ret = hdd_wlan_start_modules(hdd_ctx, adapter, false); |
| 12467 | if (ret) { |
| 12468 | hdd_err("Start wlan modules failed: %d", ret); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12469 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12470 | } |
| 12471 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12472 | if (new_con_mode == QDF_GLOBAL_MONITOR_MODE) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12473 | if (hdd_start_adapter(adapter)) { |
| 12474 | hdd_err("Failed to start %s adapter", kmessage); |
| 12475 | ret = -EINVAL; |
| 12476 | goto reset_flags; |
| 12477 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12478 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 12479 | hdd_info("Acquire wakelock for monitor mode!"); |
| 12480 | qdf_wake_lock_acquire(&hdd_ctx->monitor_mode_wakelock, |
| 12481 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 12482 | } |
| 12483 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12484 | /* con_mode is a global module parameter */ |
| 12485 | con_mode = new_con_mode; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12486 | hdd_info("Mode successfully changed to %s", kmessage); |
| 12487 | ret = 0; |
| 12488 | |
| 12489 | reset_flags: |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 12490 | mutex_unlock(&hdd_init_deinit_lock); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12491 | cds_set_load_in_progress(false); |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 12492 | qdf_atomic_set(&hdd_ctx->con_mode_flag, 0); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12493 | return ret; |
| 12494 | } |
| 12495 | |
| 12496 | |
| 12497 | static int con_mode_handler(const char *kmessage, struct kernel_param *kp) |
| 12498 | { |
| 12499 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12500 | struct hdd_context *hdd_ctx; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12501 | |
| 12502 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 12503 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 12504 | if (ret) |
| 12505 | return ret; |
| 12506 | |
| 12507 | cds_ssr_protect(__func__); |
| 12508 | ret = __con_mode_handler(kmessage, kp, hdd_ctx); |
| 12509 | cds_ssr_unprotect(__func__); |
| 12510 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12511 | return ret; |
| 12512 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12513 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 12514 | static int con_mode_handler_ftm(const char *kmessage, |
| 12515 | struct kernel_param *kp) |
| 12516 | { |
| 12517 | int ret; |
| 12518 | |
| 12519 | ret = param_set_int(kmessage, kp); |
| 12520 | |
| 12521 | if (con_mode_ftm != QDF_GLOBAL_FTM_MODE) { |
| 12522 | pr_err("Only FTM mode supported!"); |
| 12523 | return -ENOTSUPP; |
| 12524 | } |
| 12525 | |
| 12526 | hdd_set_conparam(con_mode_ftm); |
| 12527 | con_mode = con_mode_ftm; |
| 12528 | |
| 12529 | return ret; |
| 12530 | } |
| 12531 | |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 12532 | static int con_mode_handler_monitor(const char *kmessage, |
| 12533 | struct kernel_param *kp) |
| 12534 | { |
| 12535 | int ret; |
| 12536 | |
| 12537 | ret = param_set_int(kmessage, kp); |
| 12538 | |
| 12539 | if (con_mode_monitor != QDF_GLOBAL_MONITOR_MODE) { |
| 12540 | pr_err("Only Monitor mode supported!"); |
| 12541 | return -ENOTSUPP; |
| 12542 | } |
| 12543 | |
| 12544 | hdd_set_conparam(con_mode_monitor); |
| 12545 | con_mode = con_mode_monitor; |
| 12546 | |
| 12547 | return ret; |
| 12548 | } |
| 12549 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12550 | /** |
| 12551 | * hdd_get_conparam() - driver exit point |
| 12552 | * |
| 12553 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 12554 | * |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12555 | * Return: enum QDF_GLOBAL_MODE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12556 | */ |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12557 | enum QDF_GLOBAL_MODE hdd_get_conparam(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12558 | { |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12559 | return (enum QDF_GLOBAL_MODE) curr_con_mode; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12560 | } |
| 12561 | |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 12562 | void hdd_set_conparam(uint32_t con_param) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12563 | { |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 12564 | curr_con_mode = con_param; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12565 | } |
| 12566 | |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12567 | /** |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 12568 | * hdd_clean_up_pre_cac_interface() - Clean up the pre cac interface |
| 12569 | * @hdd_ctx: HDD context |
| 12570 | * |
| 12571 | * Cleans up the pre cac interface, if it exists |
| 12572 | * |
| 12573 | * Return: None |
| 12574 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12575 | void hdd_clean_up_pre_cac_interface(struct hdd_context *hdd_ctx) |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 12576 | { |
| 12577 | uint8_t session_id; |
| 12578 | QDF_STATUS status; |
Jeff Johnson | 85b5c11 | 2017-08-11 15:15:23 -0700 | [diff] [blame] | 12579 | struct hdd_adapter *precac_adapter; |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 12580 | |
| 12581 | status = wlan_sap_get_pre_cac_vdev_id(hdd_ctx->hHal, &session_id); |
| 12582 | if (QDF_IS_STATUS_ERROR(status)) { |
| 12583 | hdd_err("failed to get pre cac vdev id"); |
| 12584 | return; |
| 12585 | } |
| 12586 | |
| 12587 | precac_adapter = hdd_get_adapter_by_vdev(hdd_ctx, session_id); |
| 12588 | if (!precac_adapter) { |
| 12589 | hdd_err("invalid pre cac adapater"); |
| 12590 | return; |
| 12591 | } |
| 12592 | |
| 12593 | qdf_create_work(0, &hdd_ctx->sap_pre_cac_work, |
| 12594 | wlan_hdd_sap_pre_cac_failure, |
| 12595 | (void *)precac_adapter); |
| 12596 | qdf_sched_work(0, &hdd_ctx->sap_pre_cac_work); |
| 12597 | |
| 12598 | } |
| 12599 | |
| 12600 | /** |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12601 | * hdd_update_ol_config - API to update ol configuration parameters |
| 12602 | * @hdd_ctx: HDD context |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12603 | * |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12604 | * Return: void |
| 12605 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12606 | static void hdd_update_ol_config(struct hdd_context *hdd_ctx) |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12607 | { |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12608 | struct ol_config_info cfg; |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 12609 | struct ol_context *ol_ctx = cds_get_context(QDF_MODULE_ID_BMI); |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12610 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12611 | if (!ol_ctx) |
| 12612 | return; |
| 12613 | |
| 12614 | cfg.enable_self_recovery = hdd_ctx->config->enableSelfRecovery; |
| 12615 | cfg.enable_uart_print = hdd_ctx->config->enablefwprint; |
| 12616 | cfg.enable_fw_log = hdd_ctx->config->enable_fw_log; |
| 12617 | cfg.enable_ramdump_collection = hdd_ctx->config->is_ramdump_enabled; |
Jeff Johnson | b8bf907 | 2016-09-23 17:39:27 -0700 | [diff] [blame] | 12618 | cfg.enable_lpass_support = hdd_lpass_is_supported(hdd_ctx); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12619 | |
| 12620 | ol_init_ini_config(ol_ctx, &cfg); |
| 12621 | } |
| 12622 | |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 12623 | #ifdef FEATURE_RUNTIME_PM |
| 12624 | /** |
| 12625 | * hdd_populate_runtime_cfg() - populate runtime configuration |
| 12626 | * @hdd_ctx: hdd context |
| 12627 | * @cfg: pointer to the configuration memory being populated |
| 12628 | * |
| 12629 | * Return: void |
| 12630 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12631 | static void hdd_populate_runtime_cfg(struct hdd_context *hdd_ctx, |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 12632 | struct hif_config_info *cfg) |
| 12633 | { |
| 12634 | cfg->enable_runtime_pm = hdd_ctx->config->runtime_pm; |
| 12635 | cfg->runtime_pm_delay = hdd_ctx->config->runtime_pm_delay; |
| 12636 | } |
| 12637 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12638 | static void hdd_populate_runtime_cfg(struct hdd_context *hdd_ctx, |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 12639 | struct hif_config_info *cfg) |
| 12640 | { |
| 12641 | } |
| 12642 | #endif |
| 12643 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12644 | /** |
| 12645 | * hdd_update_hif_config - API to update HIF configuration parameters |
| 12646 | * @hdd_ctx: HDD Context |
| 12647 | * |
| 12648 | * Return: void |
| 12649 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12650 | static void hdd_update_hif_config(struct hdd_context *hdd_ctx) |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12651 | { |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 12652 | struct hif_opaque_softc *scn = cds_get_context(QDF_MODULE_ID_HIF); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12653 | struct hif_config_info cfg; |
| 12654 | |
| 12655 | if (!scn) |
| 12656 | return; |
| 12657 | |
| 12658 | cfg.enable_self_recovery = hdd_ctx->config->enableSelfRecovery; |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 12659 | hdd_populate_runtime_cfg(hdd_ctx, &cfg); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12660 | hif_init_ini_config(scn, &cfg); |
Dustin Brown | ee3e059 | 2017-09-07 13:50:11 -0700 | [diff] [blame] | 12661 | |
| 12662 | if (hdd_ctx->config->prevent_link_down) |
| 12663 | hif_vote_link_up(scn); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12664 | } |
| 12665 | |
| 12666 | /** |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 12667 | * hdd_update_dp_config() - Propagate config parameters to Lithium |
| 12668 | * datapath |
| 12669 | * @hdd_ctx: HDD Context |
| 12670 | * |
| 12671 | * Return: 0 for success/errno for failure |
| 12672 | */ |
| 12673 | static int hdd_update_dp_config(struct hdd_context *hdd_ctx) |
| 12674 | { |
| 12675 | struct cdp_config_params params; |
| 12676 | QDF_STATUS status; |
| 12677 | |
| 12678 | params.tso_enable = hdd_ctx->config->tso_enable; |
| 12679 | params.lro_enable = hdd_ctx->config->lro_enable; |
| 12680 | #ifdef QCA_LL_TX_FLOW_CONTROL_V2 |
| 12681 | params.tx_flow_stop_queue_threshold = |
| 12682 | hdd_ctx->config->TxFlowStopQueueThreshold; |
| 12683 | params.tx_flow_start_queue_offset = |
| 12684 | hdd_ctx->config->TxFlowStartQueueOffset; |
| 12685 | #endif |
| 12686 | params.flow_steering_enable = hdd_ctx->config->flow_steering_enable; |
| 12687 | params.napi_enable = hdd_ctx->napi_enable; |
| 12688 | params.tcp_udp_checksumoffload = |
| 12689 | hdd_ctx->config->enable_ip_tcp_udp_checksum_offload; |
| 12690 | |
| 12691 | status = cdp_update_config_parameters( |
| 12692 | cds_get_context(QDF_MODULE_ID_SOC), |
| 12693 | ¶ms); |
| 12694 | if (status) { |
Dustin Brown | a286862 | 2018-03-20 11:38:14 -0700 | [diff] [blame] | 12695 | hdd_err("Failed to attach config parameters"); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 12696 | return status; |
| 12697 | } |
| 12698 | |
| 12699 | return 0; |
| 12700 | } |
| 12701 | |
| 12702 | /** |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12703 | * hdd_update_config() - Initialize driver per module ini parameters |
| 12704 | * @hdd_ctx: HDD Context |
| 12705 | * |
| 12706 | * API is used to initialize all driver per module configuration parameters |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 12707 | * Return: 0 for success, errno for failure |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12708 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12709 | int hdd_update_config(struct hdd_context *hdd_ctx) |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12710 | { |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 12711 | int ret; |
| 12712 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12713 | hdd_update_ol_config(hdd_ctx); |
| 12714 | hdd_update_hif_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 12715 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
| 12716 | ret = hdd_update_cds_config_ftm(hdd_ctx); |
| 12717 | else |
| 12718 | ret = hdd_update_cds_config(hdd_ctx); |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 12719 | ret = hdd_update_user_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 12720 | |
| 12721 | return ret; |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12722 | } |
| 12723 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12724 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 12725 | /** |
| 12726 | * hdd_ra_populate_cds_config() - Populate RA filtering cds configuration |
| 12727 | * @psoc_cfg: pmo psoc Configuration |
| 12728 | * @hdd_ctx: Pointer to hdd context |
| 12729 | * |
| 12730 | * Return: none |
| 12731 | */ |
| 12732 | static inline void hdd_ra_populate_pmo_config( |
| 12733 | struct pmo_psoc_cfg *psoc_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12734 | struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12735 | { |
| 12736 | psoc_cfg->ra_ratelimit_interval = |
| 12737 | hdd_ctx->config->RArateLimitInterval; |
| 12738 | psoc_cfg->ra_ratelimit_enable = |
| 12739 | hdd_ctx->config->IsRArateLimitEnabled; |
| 12740 | } |
| 12741 | #else |
| 12742 | static inline void hdd_ra_populate_pmo_config( |
| 12743 | struct cds_config_info *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12744 | struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12745 | { |
| 12746 | } |
| 12747 | #endif |
Will Huang | 3cd2b7c | 2017-11-17 13:16:56 +0800 | [diff] [blame] | 12748 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12749 | /** |
| 12750 | * hdd_update_pmo_config - API to update pmo configuration parameters |
| 12751 | * @hdd_ctx: HDD context |
| 12752 | * |
| 12753 | * Return: void |
| 12754 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12755 | static int hdd_update_pmo_config(struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12756 | { |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12757 | struct pmo_psoc_cfg psoc_cfg; |
| 12758 | QDF_STATUS status; |
| 12759 | |
| 12760 | /* |
| 12761 | * Value of hdd_ctx->wowEnable can be, |
| 12762 | * 0 - Disable both magic pattern match and pattern byte match. |
| 12763 | * 1 - Enable magic pattern match on all interfaces. |
| 12764 | * 2 - Enable pattern byte match on all interfaces. |
| 12765 | * 3 - Enable both magic patter and pattern byte match on |
| 12766 | * all interfaces. |
| 12767 | */ |
| 12768 | psoc_cfg.magic_ptrn_enable = |
| 12769 | (hdd_ctx->config->wowEnable & 0x01) ? true : false; |
| 12770 | psoc_cfg.ptrn_match_enable_all_vdev = |
| 12771 | (hdd_ctx->config->wowEnable & 0x02) ? true : false; |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 12772 | psoc_cfg.ptrn_id_per_vdev = |
| 12773 | wma_is_service_enabled(wmi_service_unified_wow_capability); |
| 12774 | psoc_cfg.apf_enable = hdd_ctx->config->bpf_packet_filter_enable; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12775 | psoc_cfg.arp_offload_enable = hdd_ctx->config->fhostArpOffload; |
Dustin Brown | 1224e21 | 2017-05-12 14:02:12 -0700 | [diff] [blame] | 12776 | psoc_cfg.hw_filter_mode = hdd_ctx->config->hw_filter_mode; |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 12777 | psoc_cfg.ns_offload_enable_dynamic = hdd_ctx->config->fhostNSOffload; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12778 | psoc_cfg.ns_offload_enable_static = hdd_ctx->config->fhostNSOffload; |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 12779 | psoc_cfg.packet_filter_enabled = !hdd_ctx->config->disablePacketFilter; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12780 | psoc_cfg.ssdp = hdd_ctx->config->ssdp; |
| 12781 | psoc_cfg.enable_mc_list = hdd_ctx->config->fEnableMCAddrList; |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 12782 | psoc_cfg.active_mode_offload = hdd_ctx->config->active_mode_offload; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12783 | psoc_cfg.ap_arpns_support = hdd_ctx->ap_arpns_support; |
Will Huang | 3cd2b7c | 2017-11-17 13:16:56 +0800 | [diff] [blame] | 12784 | psoc_cfg.d0_wow_supported = wma_d0_wow_is_supported(); |
Mukul Sharma | 9223f23 | 2017-03-08 18:42:27 +0530 | [diff] [blame] | 12785 | psoc_cfg.sta_dynamic_dtim = hdd_ctx->config->enableDynamicDTIM; |
| 12786 | psoc_cfg.sta_mod_dtim = hdd_ctx->config->enableModulatedDTIM; |
| 12787 | psoc_cfg.sta_max_li_mod_dtim = hdd_ctx->config->fMaxLIModulatedDTIM; |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 12788 | psoc_cfg.power_save_mode = hdd_ctx->config->enablePowersaveOffload; |
Ravi Kumar Bokka | 05c14e5 | 2017-03-27 14:48:23 +0530 | [diff] [blame] | 12789 | psoc_cfg.auto_power_save_fail_mode = |
| 12790 | hdd_ctx->config->auto_pwr_save_fail_mode; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12791 | |
| 12792 | hdd_ra_populate_pmo_config(&psoc_cfg, hdd_ctx); |
Mukul Sharma | 9223f23 | 2017-03-08 18:42:27 +0530 | [diff] [blame] | 12793 | hdd_nan_populate_pmo_config(&psoc_cfg, hdd_ctx); |
| 12794 | hdd_lpass_populate_pmo_config(&psoc_cfg, hdd_ctx); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12795 | |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 12796 | status = ucfg_pmo_update_psoc_config(hdd_ctx->hdd_psoc, &psoc_cfg); |
| 12797 | if (QDF_IS_STATUS_ERROR(status)) |
| 12798 | hdd_err("failed pmo psoc configuration; status:%d", status); |
| 12799 | |
| 12800 | return qdf_status_to_os_return(status); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12801 | } |
| 12802 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12803 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 12804 | static inline void hdd_update_pno_config(struct pno_user_cfg *pno_cfg, |
| 12805 | struct hdd_config *cfg) |
| 12806 | { |
Varun Reddy Yeturu | bba32e9 | 2017-09-06 13:31:40 -0700 | [diff] [blame] | 12807 | struct nlo_mawc_params *mawc_cfg = &pno_cfg->mawc_params; |
| 12808 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12809 | pno_cfg->channel_prediction = cfg->pno_channel_prediction; |
| 12810 | pno_cfg->top_k_num_of_channels = cfg->top_k_num_of_channels; |
| 12811 | pno_cfg->stationary_thresh = cfg->stationary_thresh; |
| 12812 | pno_cfg->adaptive_dwell_mode = cfg->adaptive_dwell_mode_enabled; |
| 12813 | pno_cfg->channel_prediction_full_scan = |
| 12814 | cfg->channel_prediction_full_scan; |
Varun Reddy Yeturu | bba32e9 | 2017-09-06 13:31:40 -0700 | [diff] [blame] | 12815 | mawc_cfg->enable = cfg->MAWCEnabled && cfg->mawc_nlo_enabled; |
| 12816 | mawc_cfg->exp_backoff_ratio = cfg->mawc_nlo_exp_backoff_ratio; |
| 12817 | mawc_cfg->init_scan_interval = cfg->mawc_nlo_init_scan_interval; |
| 12818 | mawc_cfg->max_scan_interval = cfg->mawc_nlo_max_scan_interval; |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12819 | } |
| 12820 | #else |
| 12821 | static inline void |
| 12822 | hdd_update_pno_config(struct pno_user_cfg *pno_cfg, |
Jeff Johnson | 33a0792 | 2017-10-05 09:08:46 -0700 | [diff] [blame] | 12823 | struct hdd_config *cfg) |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12824 | { |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12825 | } |
| 12826 | #endif |
| 12827 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 12828 | void hdd_update_ie_whitelist_attr(struct probe_req_whitelist_attr *ie_whitelist, |
| 12829 | struct hdd_config *cfg) |
| 12830 | { |
| 12831 | uint8_t i = 0; |
| 12832 | |
| 12833 | ie_whitelist->white_list = cfg->probe_req_ie_whitelist; |
| 12834 | if (!ie_whitelist->white_list) |
| 12835 | return; |
| 12836 | |
| 12837 | ie_whitelist->ie_bitmap[0] = cfg->probe_req_ie_bitmap_0; |
| 12838 | ie_whitelist->ie_bitmap[1] = cfg->probe_req_ie_bitmap_1; |
| 12839 | ie_whitelist->ie_bitmap[2] = cfg->probe_req_ie_bitmap_2; |
| 12840 | ie_whitelist->ie_bitmap[3] = cfg->probe_req_ie_bitmap_3; |
| 12841 | ie_whitelist->ie_bitmap[4] = cfg->probe_req_ie_bitmap_4; |
| 12842 | ie_whitelist->ie_bitmap[5] = cfg->probe_req_ie_bitmap_5; |
| 12843 | ie_whitelist->ie_bitmap[6] = cfg->probe_req_ie_bitmap_6; |
| 12844 | ie_whitelist->ie_bitmap[7] = cfg->probe_req_ie_bitmap_7; |
| 12845 | |
| 12846 | ie_whitelist->num_vendor_oui = cfg->no_of_probe_req_ouis; |
| 12847 | for (i = 0; i < ie_whitelist->num_vendor_oui; i++) |
| 12848 | ie_whitelist->voui[i] = cfg->probe_req_voui[i]; |
| 12849 | } |
| 12850 | |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 12851 | uint32_t hdd_limit_max_per_index_score(uint32_t per_index_score) |
| 12852 | { |
| 12853 | uint8_t i, score; |
| 12854 | |
| 12855 | for (i = 0; i < MAX_INDEX_PER_INI; i++) { |
| 12856 | score = WLAN_GET_SCORE_PERCENTAGE(per_index_score, i); |
| 12857 | if (score > MAX_INDEX_SCORE) |
| 12858 | WLAN_SET_SCORE_PERCENTAGE(per_index_score, |
| 12859 | MAX_INDEX_SCORE, i); |
| 12860 | } |
| 12861 | |
| 12862 | return per_index_score; |
| 12863 | } |
| 12864 | |
| 12865 | /** |
| 12866 | * hdd_update_score_config - API to update candidate scoring related params |
| 12867 | * configuration parameters |
| 12868 | * @score_config: score config to update |
| 12869 | * @cfg: config params |
| 12870 | * |
| 12871 | * Return: 0 if success else err |
| 12872 | */ |
| 12873 | static void hdd_update_score_config( |
| 12874 | struct scoring_config *score_config, struct hdd_config *cfg) |
| 12875 | { |
| 12876 | int total_weight; |
| 12877 | |
| 12878 | score_config->weight_cfg.rssi_weightage = cfg->rssi_weightage; |
| 12879 | score_config->weight_cfg.ht_caps_weightage = cfg->ht_caps_weightage; |
| 12880 | score_config->weight_cfg.vht_caps_weightage = |
| 12881 | cfg->vht_caps_weightage; |
| 12882 | score_config->weight_cfg.he_caps_weightage = |
| 12883 | cfg->he_caps_weightage; |
| 12884 | score_config->weight_cfg.chan_width_weightage = |
| 12885 | cfg->chan_width_weightage; |
| 12886 | score_config->weight_cfg.chan_band_weightage = |
| 12887 | cfg->chan_band_weightage; |
| 12888 | score_config->weight_cfg.nss_weightage = cfg->nss_weightage; |
| 12889 | score_config->weight_cfg.beamforming_cap_weightage = |
| 12890 | cfg->beamforming_cap_weightage; |
| 12891 | score_config->weight_cfg.pcl_weightage = cfg->pcl_weightage; |
| 12892 | score_config->weight_cfg.channel_congestion_weightage = |
| 12893 | cfg->channel_congestion_weightage; |
| 12894 | score_config->weight_cfg.oce_wan_weightage = cfg->oce_wan_weightage; |
| 12895 | |
| 12896 | total_weight = score_config->weight_cfg.rssi_weightage + |
| 12897 | score_config->weight_cfg.ht_caps_weightage + |
| 12898 | score_config->weight_cfg.vht_caps_weightage + |
| 12899 | score_config->weight_cfg.he_caps_weightage + |
| 12900 | score_config->weight_cfg.chan_width_weightage + |
| 12901 | score_config->weight_cfg.chan_band_weightage + |
| 12902 | score_config->weight_cfg.nss_weightage + |
| 12903 | score_config->weight_cfg.beamforming_cap_weightage + |
| 12904 | score_config->weight_cfg.pcl_weightage + |
| 12905 | score_config->weight_cfg.channel_congestion_weightage + |
| 12906 | score_config->weight_cfg.oce_wan_weightage; |
| 12907 | |
| 12908 | if (total_weight > BEST_CANDIDATE_MAX_WEIGHT) { |
| 12909 | hdd_err("total weight is greater than %d fallback to default values", |
| 12910 | BEST_CANDIDATE_MAX_WEIGHT); |
| 12911 | |
| 12912 | score_config->weight_cfg.rssi_weightage = RSSI_WEIGHTAGE; |
| 12913 | score_config->weight_cfg.ht_caps_weightage = |
| 12914 | HT_CAPABILITY_WEIGHTAGE; |
| 12915 | score_config->weight_cfg.vht_caps_weightage = VHT_CAP_WEIGHTAGE; |
| 12916 | score_config->weight_cfg.he_caps_weightage = HE_CAP_WEIGHTAGE; |
| 12917 | score_config->weight_cfg.chan_width_weightage = |
| 12918 | CHAN_WIDTH_WEIGHTAGE; |
| 12919 | score_config->weight_cfg.chan_band_weightage = |
| 12920 | CHAN_BAND_WEIGHTAGE; |
| 12921 | score_config->weight_cfg.nss_weightage = NSS_WEIGHTAGE; |
| 12922 | score_config->weight_cfg.beamforming_cap_weightage = |
| 12923 | BEAMFORMING_CAP_WEIGHTAGE; |
| 12924 | score_config->weight_cfg.pcl_weightage = PCL_WEIGHT; |
| 12925 | score_config->weight_cfg.channel_congestion_weightage = |
| 12926 | CHANNEL_CONGESTION_WEIGHTAGE; |
| 12927 | score_config->weight_cfg.oce_wan_weightage = OCE_WAN_WEIGHTAGE; |
| 12928 | } |
| 12929 | |
| 12930 | score_config->bandwidth_weight_per_index = |
| 12931 | hdd_limit_max_per_index_score( |
| 12932 | cfg->bandwidth_weight_per_index); |
| 12933 | score_config->nss_weight_per_index = |
| 12934 | hdd_limit_max_per_index_score(cfg->nss_weight_per_index); |
| 12935 | score_config->band_weight_per_index = |
| 12936 | hdd_limit_max_per_index_score(cfg->band_weight_per_index); |
| 12937 | |
| 12938 | score_config->rssi_score.best_rssi_threshold = |
| 12939 | cfg->best_rssi_threshold; |
| 12940 | score_config->rssi_score.good_rssi_threshold = |
| 12941 | cfg->good_rssi_threshold; |
| 12942 | score_config->rssi_score.bad_rssi_threshold = |
| 12943 | cfg->bad_rssi_threshold; |
| 12944 | score_config->rssi_score.good_rssi_pcnt = cfg->good_rssi_pcnt; |
| 12945 | score_config->rssi_score.bad_rssi_pcnt = cfg->bad_rssi_pcnt; |
| 12946 | score_config->rssi_score.good_rssi_bucket_size = |
| 12947 | cfg->good_rssi_bucket_size; |
| 12948 | score_config->rssi_score.bad_rssi_bucket_size = |
| 12949 | cfg->bad_rssi_bucket_size; |
| 12950 | score_config->rssi_score.rssi_pref_5g_rssi_thresh = |
| 12951 | cfg->rssi_pref_5g_rssi_thresh; |
| 12952 | |
| 12953 | score_config->esp_qbss_scoring.num_slot = cfg->num_esp_qbss_slots; |
| 12954 | score_config->esp_qbss_scoring.score_pcnt3_to_0 = |
| 12955 | hdd_limit_max_per_index_score( |
| 12956 | cfg->esp_qbss_score_slots3_to_0); |
| 12957 | score_config->esp_qbss_scoring.score_pcnt7_to_4 = |
| 12958 | hdd_limit_max_per_index_score( |
| 12959 | cfg->esp_qbss_score_slots7_to_4); |
| 12960 | score_config->esp_qbss_scoring.score_pcnt11_to_8 = |
| 12961 | hdd_limit_max_per_index_score( |
| 12962 | cfg->esp_qbss_score_slots11_to_8); |
| 12963 | score_config->esp_qbss_scoring.score_pcnt15_to_12 = |
| 12964 | hdd_limit_max_per_index_score( |
| 12965 | cfg->esp_qbss_score_slots15_to_12); |
| 12966 | |
| 12967 | score_config->oce_wan_scoring.num_slot = cfg->num_oce_wan_slots; |
| 12968 | score_config->oce_wan_scoring.score_pcnt3_to_0 = |
| 12969 | hdd_limit_max_per_index_score( |
| 12970 | cfg->oce_wan_score_slots3_to_0); |
| 12971 | score_config->oce_wan_scoring.score_pcnt7_to_4 = |
| 12972 | hdd_limit_max_per_index_score( |
| 12973 | cfg->oce_wan_score_slots7_to_4); |
| 12974 | score_config->oce_wan_scoring.score_pcnt11_to_8 = |
| 12975 | hdd_limit_max_per_index_score( |
| 12976 | cfg->oce_wan_score_slots11_to_8); |
| 12977 | score_config->oce_wan_scoring.score_pcnt15_to_12 = |
| 12978 | hdd_limit_max_per_index_score( |
| 12979 | cfg->oce_wan_score_slots15_to_12); |
| 12980 | |
| 12981 | |
| 12982 | score_config->cb_mode_24G = cfg->nChannelBondingMode24GHz; |
| 12983 | score_config->cb_mode_5G = cfg->nChannelBondingMode5GHz; |
| 12984 | score_config->nss = cfg->enable2x2 ? 2 : 1; |
| 12985 | |
| 12986 | if (cfg->dot11Mode == eHDD_DOT11_MODE_AUTO || |
| 12987 | cfg->dot11Mode == eHDD_DOT11_MODE_11ax || |
| 12988 | cfg->dot11Mode == eHDD_DOT11_MODE_11ax_ONLY) |
| 12989 | score_config->he_cap = 1; |
| 12990 | |
| 12991 | if (score_config->he_cap || |
| 12992 | cfg->dot11Mode == eHDD_DOT11_MODE_11ac || |
| 12993 | cfg->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY) |
| 12994 | score_config->vht_cap = 1; |
| 12995 | |
| 12996 | if (score_config->vht_cap || cfg->dot11Mode == eHDD_DOT11_MODE_11n || |
| 12997 | cfg->dot11Mode == eHDD_DOT11_MODE_11n_ONLY) |
| 12998 | score_config->ht_cap = 1; |
| 12999 | |
| 13000 | if (score_config->vht_cap && cfg->enableVhtFor24GHzBand) |
| 13001 | score_config->vht_24G_cap = 1; |
| 13002 | |
| 13003 | if (cfg->enableTxBF) |
| 13004 | score_config->beamformee_cap = 1; |
| 13005 | |
| 13006 | } |
| 13007 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13008 | /** |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 13009 | * hdd_update_dfs_config() - API to update dfs configuration parameters. |
| 13010 | * @hdd_ctx: HDD context |
| 13011 | * |
| 13012 | * Return: 0 if success else err |
| 13013 | */ |
| 13014 | static int hdd_update_dfs_config(struct hdd_context *hdd_ctx) |
| 13015 | { |
| 13016 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 13017 | struct hdd_config *cfg = hdd_ctx->config; |
| 13018 | struct dfs_user_config dfs_cfg; |
| 13019 | QDF_STATUS status; |
| 13020 | |
| 13021 | dfs_cfg.dfs_is_phyerr_filter_offload = !!cfg->fDfsPhyerrFilterOffload; |
| 13022 | status = ucfg_dfs_update_config(psoc, &dfs_cfg); |
| 13023 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13024 | hdd_err("failed dfs psoc configuration"); |
| 13025 | return -EINVAL; |
| 13026 | } |
| 13027 | |
| 13028 | return 0; |
| 13029 | } |
| 13030 | |
| 13031 | /** |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13032 | * hdd_update_scan_config - API to update scan configuration parameters |
| 13033 | * @hdd_ctx: HDD context |
| 13034 | * |
| 13035 | * Return: 0 if success else err |
| 13036 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13037 | static int hdd_update_scan_config(struct hdd_context *hdd_ctx) |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13038 | { |
| 13039 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 13040 | struct scan_user_cfg scan_cfg; |
| 13041 | struct hdd_config *cfg = hdd_ctx->config; |
| 13042 | QDF_STATUS status; |
| 13043 | |
| 13044 | scan_cfg.active_dwell = cfg->nActiveMaxChnTime; |
| 13045 | scan_cfg.passive_dwell = cfg->nPassiveMaxChnTime; |
| 13046 | scan_cfg.conc_active_dwell = cfg->nActiveMaxChnTimeConc; |
| 13047 | scan_cfg.conc_passive_dwell = cfg->nPassiveMaxChnTimeConc; |
| 13048 | scan_cfg.conc_max_rest_time = cfg->nRestTimeConc; |
| 13049 | scan_cfg.conc_min_rest_time = cfg->min_rest_time_conc; |
| 13050 | scan_cfg.conc_idle_time = cfg->idle_time_conc; |
Abhishek Singh | 158fe25 | 2017-03-23 11:09:34 +0530 | [diff] [blame] | 13051 | /* convert to ms */ |
| 13052 | scan_cfg.scan_cache_aging_time = |
| 13053 | cfg->scanAgingTimeout * 1000; |
| 13054 | scan_cfg.prefer_5ghz = cfg->nRoamPrefer5GHz; |
| 13055 | scan_cfg.select_5ghz_margin = cfg->nSelect5GHzMargin; |
| 13056 | scan_cfg.scan_bucket_threshold = cfg->first_scan_bucket_threshold; |
| 13057 | scan_cfg.rssi_cat_gap = cfg->nRssiCatGap; |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13058 | scan_cfg.scan_dwell_time_mode = cfg->scan_adaptive_dwell_mode; |
Kapil Gupta | fa9a8c6 | 2017-04-10 15:25:40 +0530 | [diff] [blame] | 13059 | scan_cfg.is_snr_monitoring_enabled = cfg->fEnableSNRMonitoring; |
Jeff Johnson | 81c00d0 | 2017-11-07 12:34:36 -0800 | [diff] [blame] | 13060 | scan_cfg.usr_cfg_probe_rpt_time = cfg->scan_probe_repeat_time; |
| 13061 | scan_cfg.usr_cfg_num_probes = cfg->scan_num_probes; |
Abhishek Singh | b58164a | 2017-07-19 18:47:23 +0530 | [diff] [blame] | 13062 | scan_cfg.is_bssid_hint_priority = cfg->is_bssid_hint_priority; |
Kiran Kumar Lokere | d547fdd | 2017-09-13 17:20:55 -0700 | [diff] [blame] | 13063 | scan_cfg.enable_mac_spoofing = cfg->enable_mac_spoofing; |
Abhishek Singh | c87bb04 | 2018-01-30 17:10:42 +0530 | [diff] [blame] | 13064 | scan_cfg.sta_miracast_mcc_rest_time = |
| 13065 | cfg->sta_miracast_mcc_rest_time_val; |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13066 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 13067 | hdd_update_pno_config(&scan_cfg.pno_cfg, cfg); |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 13068 | hdd_update_ie_whitelist_attr(&scan_cfg.ie_whitelist, cfg); |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 13069 | hdd_update_score_config(&scan_cfg.score_config, cfg); |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 13070 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13071 | status = ucfg_scan_update_user_config(psoc, &scan_cfg); |
| 13072 | if (status != QDF_STATUS_SUCCESS) { |
| 13073 | hdd_err("failed pmo psoc configuration"); |
| 13074 | return -EINVAL; |
| 13075 | } |
| 13076 | |
| 13077 | return 0; |
| 13078 | } |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13079 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13080 | int hdd_update_components_config(struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13081 | { |
| 13082 | int ret; |
| 13083 | |
| 13084 | ret = hdd_update_pmo_config(hdd_ctx); |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13085 | if (ret) |
| 13086 | return ret; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 13087 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13088 | ret = hdd_update_scan_config(hdd_ctx); |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 13089 | if (ret) |
| 13090 | return ret; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 13091 | |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 13092 | ret = hdd_update_tdls_config(hdd_ctx); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 13093 | if (ret) |
| 13094 | return ret; |
| 13095 | |
| 13096 | ret = hdd_update_dp_config(hdd_ctx); |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 13097 | if (ret) |
| 13098 | return ret; |
| 13099 | |
| 13100 | ret = hdd_update_dfs_config(hdd_ctx); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13101 | |
| 13102 | return ret; |
| 13103 | } |
| 13104 | |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 13105 | /** |
| 13106 | * wlan_hdd_get_dfs_mode() - get ACS DFS mode |
| 13107 | * @mode : cfg80211 DFS mode |
| 13108 | * |
| 13109 | * Return: return SAP ACS DFS mode else return ACS_DFS_MODE_NONE |
| 13110 | */ |
| 13111 | enum sap_acs_dfs_mode wlan_hdd_get_dfs_mode(enum dfs_mode mode) |
| 13112 | { |
| 13113 | switch (mode) { |
| 13114 | case DFS_MODE_ENABLE: |
| 13115 | return ACS_DFS_MODE_ENABLE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 13116 | case DFS_MODE_DISABLE: |
| 13117 | return ACS_DFS_MODE_DISABLE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 13118 | case DFS_MODE_DEPRIORITIZE: |
| 13119 | return ACS_DFS_MODE_DEPRIORITIZE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 13120 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 13121 | hdd_debug("ACS dfs mode is NONE"); |
| 13122 | return ACS_DFS_MODE_NONE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 13123 | } |
| 13124 | } |
| 13125 | |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 13126 | /** |
| 13127 | * hdd_enable_disable_ca_event() - enable/disable channel avoidance event |
| 13128 | * @hddctx: pointer to hdd context |
| 13129 | * @set_value: enable/disable |
| 13130 | * |
| 13131 | * When Host sends vendor command enable, FW will send *ONE* CA ind to |
| 13132 | * Host(even though it is duplicate). When Host send vendor command |
| 13133 | * disable,FW doesn't perform any action. Whenever any change in |
| 13134 | * CA *and* WLAN is in SAP/P2P-GO mode, FW sends CA ind to host. |
| 13135 | * |
| 13136 | * return - 0 on success, appropriate error values on failure. |
| 13137 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13138 | 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] | 13139 | { |
| 13140 | QDF_STATUS status; |
| 13141 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 13142 | if (0 != wlan_hdd_validate_context(hddctx)) |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 13143 | return -EAGAIN; |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 13144 | |
| 13145 | if (!hddctx->config->goptimize_chan_avoid_event) { |
| 13146 | hdd_warn("goptimize_chan_avoid_event ini param disabled"); |
| 13147 | return -EINVAL; |
| 13148 | } |
| 13149 | |
| 13150 | status = sme_enable_disable_chanavoidind_event(hddctx->hHal, set_value); |
| 13151 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 13152 | hdd_err("Failed to send chan avoid command to SME"); |
| 13153 | return -EINVAL; |
| 13154 | } |
| 13155 | return 0; |
| 13156 | } |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 13157 | |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13158 | /** |
| 13159 | * hdd_set_roaming_in_progress() - to set the roaming in progress flag |
| 13160 | * @value: value to set |
| 13161 | * |
| 13162 | * This function will set the passed value to roaming in progress flag. |
| 13163 | * |
| 13164 | * Return: None |
| 13165 | */ |
| 13166 | void hdd_set_roaming_in_progress(bool value) |
| 13167 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13168 | struct hdd_context *hdd_ctx; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13169 | |
| 13170 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13171 | if (!hdd_ctx) { |
| 13172 | hdd_err("HDD context is NULL"); |
| 13173 | return; |
| 13174 | } |
| 13175 | |
| 13176 | hdd_ctx->roaming_in_progress = value; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 13177 | hdd_debug("Roaming in Progress set to %d", value); |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13178 | } |
| 13179 | |
| 13180 | /** |
| 13181 | * hdd_is_roaming_in_progress() - check if roaming is in progress |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 13182 | * @adapter - HDD adapter |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13183 | * |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 13184 | * 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] | 13185 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13186 | bool hdd_is_roaming_in_progress(struct hdd_adapter *adapter) |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13187 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13188 | struct hdd_context *hdd_ctx; |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 13189 | bool ret_status = false; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13190 | |
| 13191 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13192 | if (!hdd_ctx) { |
| 13193 | hdd_err("HDD context is NULL"); |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 13194 | return ret_status; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13195 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 13196 | hdd_debug("dev mode = %d, roaming_in_progress = %d", |
| 13197 | adapter->device_mode, hdd_ctx->roaming_in_progress); |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 13198 | ret_status = ((adapter->device_mode == QDF_STA_MODE) && |
| 13199 | hdd_ctx->roaming_in_progress); |
| 13200 | |
| 13201 | return ret_status; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13202 | } |
| 13203 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13204 | /** |
| 13205 | * hdd_is_connection_in_progress() - check if connection is in |
| 13206 | * progress |
| 13207 | * @session_id: session id |
| 13208 | * @reason: scan reject reason |
| 13209 | * |
| 13210 | * Go through each adapter and check if Connection is in progress |
| 13211 | * |
| 13212 | * Return: true if connection is in progress else false |
| 13213 | */ |
| 13214 | bool hdd_is_connection_in_progress(uint8_t *session_id, |
| 13215 | enum scan_reject_states *reason) |
| 13216 | { |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 13217 | struct hdd_station_ctx *hdd_sta_ctx = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13218 | struct hdd_adapter *adapter = NULL; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13219 | uint8_t sta_id = 0; |
| 13220 | uint8_t *sta_mac = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13221 | struct hdd_context *hdd_ctx; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13222 | |
| 13223 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13224 | if (!hdd_ctx) { |
| 13225 | hdd_err("HDD context is NULL"); |
| 13226 | return false; |
| 13227 | } |
| 13228 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 13229 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13230 | hdd_info("Adapter with device mode %s(%d) exists", |
| 13231 | hdd_device_mode_to_string(adapter->device_mode), |
| 13232 | adapter->device_mode); |
| 13233 | if (((QDF_STA_MODE == adapter->device_mode) |
| 13234 | || (QDF_P2P_CLIENT_MODE == adapter->device_mode) |
| 13235 | || (QDF_P2P_DEVICE_MODE == adapter->device_mode)) |
| 13236 | && (eConnectionState_Connecting == |
| 13237 | (WLAN_HDD_GET_STATION_CTX_PTR(adapter))-> |
| 13238 | conn_info.connState)) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 13239 | hdd_debug("%pK(%d) Connection is in progress", |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13240 | WLAN_HDD_GET_STATION_CTX_PTR(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13241 | adapter->session_id); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13242 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13243 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13244 | *reason = CONNECTION_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13245 | } |
| 13246 | return true; |
| 13247 | } |
Archana Ramachandran | 62886ce | 2017-03-24 14:46:32 -0700 | [diff] [blame] | 13248 | /* |
| 13249 | * sme_neighbor_middle_of_roaming is for LFR2 |
| 13250 | * hdd_is_roaming_in_progress is for LFR3 |
| 13251 | */ |
| 13252 | if (((QDF_STA_MODE == adapter->device_mode) && |
| 13253 | sme_neighbor_middle_of_roaming( |
| 13254 | WLAN_HDD_GET_HAL_CTX(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13255 | adapter->session_id)) || |
Archana Ramachandran | 62886ce | 2017-03-24 14:46:32 -0700 | [diff] [blame] | 13256 | hdd_is_roaming_in_progress(adapter)) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 13257 | hdd_debug("%pK(%d) Reassociation in progress", |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13258 | WLAN_HDD_GET_STATION_CTX_PTR(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13259 | adapter->session_id); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13260 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13261 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13262 | *reason = REASSOC_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13263 | } |
| 13264 | return true; |
| 13265 | } |
| 13266 | if ((QDF_STA_MODE == adapter->device_mode) || |
| 13267 | (QDF_P2P_CLIENT_MODE == adapter->device_mode) || |
| 13268 | (QDF_P2P_DEVICE_MODE == adapter->device_mode)) { |
| 13269 | hdd_sta_ctx = |
| 13270 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 13271 | if ((eConnectionState_Associated == |
Vignesh Viswanathan | 0a56929 | 2018-02-14 15:34:47 +0530 | [diff] [blame] | 13272 | hdd_sta_ctx->conn_info.connState) |
| 13273 | && sme_is_sta_key_exchange_in_progress( |
| 13274 | hdd_ctx->hHal, adapter->session_id)) { |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13275 | sta_mac = (uint8_t *) |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 13276 | &(adapter->mac_addr.bytes[0]); |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 13277 | hdd_debug("client " MAC_ADDRESS_STR |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13278 | " is in middle of WPS/EAPOL exchange.", |
| 13279 | MAC_ADDR_ARRAY(sta_mac)); |
| 13280 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13281 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13282 | *reason = EAPOL_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13283 | } |
| 13284 | return true; |
| 13285 | } |
| 13286 | } else if ((QDF_SAP_MODE == adapter->device_mode) || |
| 13287 | (QDF_P2P_GO_MODE == adapter->device_mode)) { |
| 13288 | for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; |
| 13289 | sta_id++) { |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 13290 | if (!((adapter->sta_info[sta_id].in_use) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13291 | && (OL_TXRX_PEER_STATE_CONN == |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 13292 | adapter->sta_info[sta_id].peer_state))) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13293 | continue; |
| 13294 | |
| 13295 | sta_mac = (uint8_t *) |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 13296 | &(adapter->sta_info[sta_id]. |
Jeff Johnson | f235651 | 2017-10-21 16:04:12 -0700 | [diff] [blame] | 13297 | sta_mac.bytes[0]); |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 13298 | hdd_debug("client " MAC_ADDRESS_STR |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13299 | " of SAP/GO is in middle of WPS/EAPOL exchange", |
| 13300 | MAC_ADDR_ARRAY(sta_mac)); |
| 13301 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13302 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13303 | *reason = SAP_EAPOL_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13304 | } |
| 13305 | return true; |
| 13306 | } |
| 13307 | if (hdd_ctx->connection_in_progress) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 13308 | hdd_debug("AP/GO: connection is in progress"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13309 | return true; |
| 13310 | } |
| 13311 | } |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13312 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 13313 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13314 | return false; |
| 13315 | } |
| 13316 | |
| 13317 | /** |
| 13318 | * hdd_restart_sap() - to restart SAP in driver internally |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13319 | * @ap_adapter: Pointer to SAP struct hdd_adapter structure |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13320 | * |
| 13321 | * Return: None |
| 13322 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13323 | void hdd_restart_sap(struct hdd_adapter *ap_adapter) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13324 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 13325 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 13326 | struct hdd_hostapd_state *hostapd_state; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13327 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13328 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13329 | tsap_Config_t *sap_config; |
| 13330 | void *sap_ctx; |
| 13331 | |
| 13332 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 13333 | sap_config = &hdd_ap_ctx->sap_config; |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 13334 | sap_ctx = hdd_ap_ctx->sap_context; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13335 | |
| 13336 | mutex_lock(&hdd_ctx->sap_lock); |
| 13337 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
| 13338 | wlan_hdd_del_station(ap_adapter); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13339 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
| 13340 | qdf_event_reset(&hostapd_state->qdf_stop_bss_event); |
| 13341 | if (QDF_STATUS_SUCCESS == wlansap_stop_bss(sap_ctx)) { |
| 13342 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 13343 | qdf_wait_for_event_completion(&hostapd_state-> |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13344 | qdf_stop_bss_event, |
| 13345 | SME_CMD_TIMEOUT_VALUE); |
| 13346 | |
| 13347 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13348 | hdd_err("SAP Stop Failed"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13349 | goto end; |
| 13350 | } |
| 13351 | } |
| 13352 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13353 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13354 | ap_adapter->device_mode, ap_adapter->session_id); |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 13355 | hdd_start_green_ap_state_mc(hdd_ctx, ap_adapter->device_mode, |
| 13356 | false); |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13357 | hdd_err("SAP Stop Success"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13358 | |
| 13359 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13360 | hdd_err("SAP Not able to set AP IEs"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13361 | wlansap_reset_sap_config_add_ie(sap_config, |
| 13362 | eUPDATE_IE_ALL); |
| 13363 | goto end; |
| 13364 | } |
| 13365 | |
| 13366 | qdf_event_reset(&hostapd_state->qdf_event); |
| 13367 | if (wlansap_start_bss(sap_ctx, hdd_hostapd_sap_event_cb, |
| 13368 | sap_config, |
| 13369 | ap_adapter->dev) != QDF_STATUS_SUCCESS) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13370 | hdd_err("SAP Start Bss fail"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13371 | wlansap_reset_sap_config_add_ie(sap_config, |
| 13372 | eUPDATE_IE_ALL); |
| 13373 | goto end; |
| 13374 | } |
| 13375 | |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13376 | hdd_info("Waiting for SAP to start"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13377 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 13378 | qdf_wait_for_event_completion(&hostapd_state->qdf_event, |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13379 | SME_CMD_TIMEOUT_VALUE); |
| 13380 | wlansap_reset_sap_config_add_ie(sap_config, |
| 13381 | eUPDATE_IE_ALL); |
| 13382 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13383 | hdd_err("SAP Start failed"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13384 | goto end; |
| 13385 | } |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13386 | hdd_err("SAP Start Success"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13387 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 13388 | if (hostapd_state->bss_state == BSS_START) { |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13389 | policy_mgr_incr_active_session(hdd_ctx->hdd_psoc, |
| 13390 | ap_adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13391 | ap_adapter->session_id); |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 13392 | hdd_start_green_ap_state_mc(hdd_ctx, |
| 13393 | ap_adapter->device_mode, |
| 13394 | true); |
| 13395 | } |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13396 | } |
| 13397 | end: |
| 13398 | mutex_unlock(&hdd_ctx->sap_lock); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13399 | } |
| 13400 | |
| 13401 | /** |
| 13402 | * hdd_check_and_restart_sap_with_non_dfs_acs() - Restart SAP |
| 13403 | * with non dfs acs |
| 13404 | * |
| 13405 | * Restarts SAP in non-DFS ACS mode when STA-AP mode DFS is not supported |
| 13406 | * |
| 13407 | * Return: None |
| 13408 | */ |
| 13409 | void hdd_check_and_restart_sap_with_non_dfs_acs(void) |
| 13410 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13411 | struct hdd_adapter *ap_adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13412 | struct hdd_context *hdd_ctx; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13413 | cds_context_type *cds_ctx; |
| 13414 | |
| 13415 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13416 | if (!hdd_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13417 | hdd_err("HDD context is NULL"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13418 | return; |
| 13419 | } |
| 13420 | |
| 13421 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 13422 | if (!cds_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13423 | hdd_err("Invalid CDS Context"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13424 | return; |
| 13425 | } |
| 13426 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13427 | if (policy_mgr_get_concurrency_mode(hdd_ctx->hdd_psoc) |
| 13428 | != (QDF_STA_MASK | QDF_SAP_MASK)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13429 | hdd_info("Concurrency mode is not SAP"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13430 | return; |
| 13431 | } |
| 13432 | |
| 13433 | ap_adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE); |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 13434 | if (ap_adapter != NULL && test_bit(SOFTAP_BSS_STARTED, |
| 13435 | &ap_adapter->event_flags) && |
| 13436 | wlan_reg_is_dfs_ch(hdd_ctx->hdd_pdev, |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 13437 | ap_adapter->session.ap.operating_channel)) { |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13438 | |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13439 | hdd_warn("STA-AP Mode DFS not supported. Restart SAP with Non DFS ACS"); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 13440 | ap_adapter->session.ap.sap_config.channel = |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13441 | AUTO_CHANNEL_SELECT; |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 13442 | ap_adapter->session.ap.sap_config. |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13443 | acs_cfg.acs_mode = true; |
| 13444 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13445 | hdd_restart_sap(ap_adapter); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13446 | } |
| 13447 | } |
| 13448 | |
| 13449 | /** |
| 13450 | * hdd_set_connection_in_progress() - to set the connection in |
| 13451 | * progress flag |
| 13452 | * @value: value to set |
| 13453 | * |
| 13454 | * This function will set the passed value to connection in progress flag. |
| 13455 | * If value is previously being set to true then no need to set it again. |
| 13456 | * |
| 13457 | * Return: true if value is being set correctly and false otherwise. |
| 13458 | */ |
| 13459 | bool hdd_set_connection_in_progress(bool value) |
| 13460 | { |
| 13461 | bool status = true; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13462 | struct hdd_context *hdd_ctx; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13463 | |
| 13464 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13465 | if (!hdd_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13466 | hdd_err("HDD context is NULL"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13467 | return false; |
| 13468 | } |
| 13469 | |
| 13470 | qdf_spin_lock(&hdd_ctx->connection_status_lock); |
| 13471 | /* |
| 13472 | * if the value is set to true previously and if someone is |
| 13473 | * trying to make it true again then it could be some race |
| 13474 | * condition being triggered. Avoid this situation by returning |
| 13475 | * false |
| 13476 | */ |
| 13477 | if (hdd_ctx->connection_in_progress && value) |
| 13478 | status = false; |
| 13479 | else |
| 13480 | hdd_ctx->connection_in_progress = value; |
| 13481 | qdf_spin_unlock(&hdd_ctx->connection_status_lock); |
| 13482 | return status; |
| 13483 | } |
| 13484 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13485 | 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] | 13486 | { |
| 13487 | if (!adapter) { |
| 13488 | hdd_err("Invalid adapter"); |
| 13489 | return -EINVAL; |
| 13490 | } |
| 13491 | hdd_info("Send MCC P2P QUOTA to WMA: %d", set_value); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13492 | sme_cli_set_command(adapter->session_id, |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 13493 | WMA_VDEV_MCC_SET_TIME_QUOTA, |
| 13494 | set_value, VDEV_CMD); |
| 13495 | return 0; |
| 13496 | |
| 13497 | } |
| 13498 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13499 | 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] | 13500 | { |
| 13501 | if (!adapter) { |
| 13502 | hdd_err("Invalid adapter"); |
| 13503 | return -EINVAL; |
| 13504 | } |
| 13505 | |
| 13506 | hdd_info("Send MCC latency WMA: %d", set_value); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13507 | sme_cli_set_command(adapter->session_id, |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 13508 | WMA_VDEV_MCC_SET_TIME_LATENCY, |
| 13509 | set_value, VDEV_CMD); |
| 13510 | return 0; |
| 13511 | } |
| 13512 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13513 | 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] | 13514 | *psoc, uint8_t vdev_id) |
| 13515 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13516 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13517 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 13518 | |
| 13519 | /* |
| 13520 | * Currently PSOC is not being used. But this logic will |
| 13521 | * change once we have the converged implementation of |
| 13522 | * HDD context per PSOC in place. This would break if |
| 13523 | * multiple vdev objects reuse the vdev id. |
| 13524 | */ |
| 13525 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 13526 | if (!adapter) |
| 13527 | hdd_err("Get adapter by vdev id failed"); |
| 13528 | |
| 13529 | return adapter; |
| 13530 | } |
| 13531 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13532 | 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] | 13533 | int8_t *rssi, int8_t *snr) |
| 13534 | { |
| 13535 | QDF_STATUS status; |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 13536 | struct csr_roam_profile *roam_profile; |
Hanumanth Reddy Pothula | 9005178 | 2017-05-04 22:14:43 +0530 | [diff] [blame] | 13537 | |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 13538 | roam_profile = hdd_roam_profile(adapter); |
Hanumanth Reddy Pothula | 9005178 | 2017-05-04 22:14:43 +0530 | [diff] [blame] | 13539 | status = sme_get_rssi_snr_by_bssid(WLAN_HDD_GET_HAL_CTX(adapter), |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 13540 | roam_profile, bssid, rssi, snr); |
Hanumanth Reddy Pothula | 9005178 | 2017-05-04 22:14:43 +0530 | [diff] [blame] | 13541 | if (QDF_STATUS_SUCCESS != status) { |
| 13542 | hdd_warn("sme_get_rssi_snr_by_bssid failed"); |
| 13543 | return -EINVAL; |
| 13544 | } |
| 13545 | |
| 13546 | return 0; |
| 13547 | } |
| 13548 | |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13549 | /** |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13550 | * hdd_set_limit_off_chan_for_tos() - set limit off-channel command parameters |
| 13551 | * @adapter - HDD adapter |
| 13552 | * @tos - type of service |
| 13553 | * @status - status of the traffic |
| 13554 | * |
| 13555 | * Return: 0 on success and non zero value on failure |
| 13556 | */ |
| 13557 | |
| 13558 | int hdd_set_limit_off_chan_for_tos(struct hdd_adapter *adapter, enum tos tos, |
| 13559 | bool is_tos_active) |
| 13560 | { |
| 13561 | int ac_bit; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13562 | struct hdd_context *hdd_ctx; |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13563 | uint32_t max_off_chan_time = 0; |
| 13564 | QDF_STATUS status; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13565 | int ret; |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13566 | tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter); |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13567 | |
| 13568 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 13569 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 13570 | |
| 13571 | if (ret < 0) { |
| 13572 | hdd_err("failed to set limit off chan params"); |
| 13573 | return ret; |
| 13574 | } |
| 13575 | |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13576 | ac_bit = limit_off_chan_tbl[tos][HDD_AC_BIT_INDX]; |
| 13577 | |
| 13578 | if (is_tos_active) |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 13579 | adapter->active_ac |= ac_bit; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13580 | else |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 13581 | adapter->active_ac &= ~ac_bit; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13582 | |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 13583 | if (adapter->active_ac) { |
| 13584 | if (adapter->active_ac & HDD_AC_VO_BIT) { |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13585 | max_off_chan_time = |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13586 | limit_off_chan_tbl[TOS_VO][HDD_DWELL_TIME_INDX]; |
| 13587 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13588 | PM_LATENCY); |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 13589 | } else if (adapter->active_ac & HDD_AC_VI_BIT) { |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13590 | max_off_chan_time = |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13591 | limit_off_chan_tbl[TOS_VI][HDD_DWELL_TIME_INDX]; |
| 13592 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13593 | PM_LATENCY); |
| 13594 | } else { |
| 13595 | /*ignore this command if only BE/BK is active */ |
| 13596 | is_tos_active = false; |
| 13597 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13598 | hdd_ctx->config->conc_system_pref); |
| 13599 | } |
| 13600 | } else { |
| 13601 | /* No active tos */ |
| 13602 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13603 | hdd_ctx->config->conc_system_pref); |
| 13604 | } |
| 13605 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13606 | status = sme_send_limit_off_channel_params(hal, adapter->session_id, |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13607 | is_tos_active, max_off_chan_time, |
| 13608 | hdd_ctx->config->nRestTimeConc, true); |
| 13609 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 13610 | hdd_err("failed to set limit off chan params"); |
| 13611 | ret = -EINVAL; |
| 13612 | } |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13613 | |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13614 | return ret; |
| 13615 | } |
| 13616 | |
| 13617 | /** |
| 13618 | * hdd_reset_limit_off_chan() - reset limit off-channel command parameters |
| 13619 | * @adapter - HDD adapter |
| 13620 | * |
| 13621 | * Return: 0 on success and non zero value on failure |
| 13622 | */ |
| 13623 | int hdd_reset_limit_off_chan(struct hdd_adapter *adapter) |
| 13624 | { |
| 13625 | struct hdd_context *hdd_ctx; |
| 13626 | int ret; |
| 13627 | QDF_STATUS status; |
| 13628 | tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter); |
| 13629 | |
| 13630 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 13631 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 13632 | if (ret < 0) |
| 13633 | return ret; |
| 13634 | |
| 13635 | /* set the system preferece to default */ |
| 13636 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13637 | hdd_ctx->config->conc_system_pref); |
| 13638 | |
| 13639 | /* clear the bitmap */ |
| 13640 | adapter->active_ac = 0; |
| 13641 | |
| 13642 | hdd_debug("reset ac_bitmap for session %hu active_ac %0x", |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13643 | adapter->session_id, adapter->active_ac); |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13644 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13645 | status = sme_send_limit_off_channel_params(hal, adapter->session_id, |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13646 | false, 0, 0, false); |
| 13647 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 13648 | hdd_err("failed to reset limit off chan params"); |
| 13649 | ret = -EINVAL; |
| 13650 | } |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13651 | |
| 13652 | return ret; |
| 13653 | } |
| 13654 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13655 | /** |
| 13656 | * hdd_start_driver_ops_timer() - Starts driver ops inactivity timer |
| 13657 | * @drv_op: Enum indicating driver op |
| 13658 | * |
| 13659 | * Return: none |
| 13660 | */ |
| 13661 | void hdd_start_driver_ops_timer(int drv_op) |
| 13662 | { |
| 13663 | memset(drv_ops_string, 0, MAX_OPS_NAME_STRING_SIZE); |
| 13664 | switch (drv_op) { |
| 13665 | case eHDD_DRV_OP_PROBE: |
| 13666 | memcpy(drv_ops_string, "probe", sizeof("probe")); |
| 13667 | break; |
| 13668 | case eHDD_DRV_OP_REMOVE: |
| 13669 | memcpy(drv_ops_string, "remove", sizeof("remove")); |
| 13670 | break; |
| 13671 | case eHDD_DRV_OP_SHUTDOWN: |
| 13672 | memcpy(drv_ops_string, "shutdown", sizeof("shutdown")); |
| 13673 | break; |
| 13674 | case eHDD_DRV_OP_REINIT: |
| 13675 | memcpy(drv_ops_string, "reinit", sizeof("reinit")); |
| 13676 | break; |
Arunk Khandavalli | e9ef42a | 2017-10-04 14:49:51 +0530 | [diff] [blame] | 13677 | case eHDD_DRV_OP_IFF_UP: |
| 13678 | memcpy(drv_ops_string, "iff_up", sizeof("iff_up")); |
| 13679 | break; |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13680 | } |
| 13681 | |
Dustin Brown | 45ed4bb | 2017-12-18 12:00:13 -0800 | [diff] [blame] | 13682 | hdd_drv_ops_task = current; |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13683 | qdf_timer_start(&hdd_drv_ops_inactivity_timer, |
| 13684 | HDD_OPS_INACTIVITY_TIMEOUT); |
| 13685 | } |
| 13686 | |
| 13687 | /** |
| 13688 | * hdd_stop_driver_ops_timer() - Stops driver ops inactivity timer |
| 13689 | * |
| 13690 | * Return: none |
| 13691 | */ |
| 13692 | void hdd_stop_driver_ops_timer(void) |
| 13693 | { |
| 13694 | qdf_timer_sync_cancel(&hdd_drv_ops_inactivity_timer); |
| 13695 | } |
| 13696 | |
| 13697 | /** |
| 13698 | * hdd_drv_ops_inactivity_handler() - Timeout handler for driver ops |
| 13699 | * inactivity timer |
| 13700 | * |
| 13701 | * Return: None |
| 13702 | */ |
| 13703 | void hdd_drv_ops_inactivity_handler(void) |
| 13704 | { |
| 13705 | hdd_err("%s: %d Sec timer expired while in .%s", |
| 13706 | __func__, HDD_OPS_INACTIVITY_TIMEOUT/1000, drv_ops_string); |
| 13707 | |
Dustin Brown | 45ed4bb | 2017-12-18 12:00:13 -0800 | [diff] [blame] | 13708 | if (hdd_drv_ops_task) { |
| 13709 | printk("Call stack for \"%s\"\n", hdd_drv_ops_task->comm); |
| 13710 | qdf_print_thread_trace(hdd_drv_ops_task); |
| 13711 | } else { |
| 13712 | hdd_err("hdd_drv_ops_task is null"); |
| 13713 | } |
| 13714 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13715 | /* Driver shutdown is stuck, no recovery possible at this point */ |
| 13716 | if (0 == qdf_mem_cmp(&drv_ops_string[0], "shutdown", |
| 13717 | sizeof("shutdown"))) |
| 13718 | QDF_BUG(0); |
| 13719 | |
Rajeev Kumar | 1e57b9c | 2018-01-04 16:17:10 -0800 | [diff] [blame] | 13720 | if (cds_is_fw_down()) { |
| 13721 | hdd_err("FW is down"); |
| 13722 | return; |
| 13723 | } |
| 13724 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13725 | if (cds_is_self_recovery_enabled()) |
Anurag Chouhan | 4085ff7 | 2017-10-05 18:09:56 +0530 | [diff] [blame] | 13726 | cds_trigger_recovery(QDF_REASON_UNSPECIFIED); |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13727 | else |
| 13728 | QDF_BUG(0); |
| 13729 | } |
| 13730 | |
Sravan Kumar Kairam | d80c766 | 2017-10-03 16:11:05 +0530 | [diff] [blame] | 13731 | void hdd_pld_ipa_uc_shutdown_pipes(void) |
| 13732 | { |
| 13733 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13734 | |
| 13735 | if (!hdd_ctx) |
| 13736 | return; |
| 13737 | |
| 13738 | hdd_ipa_uc_force_pipe_shutdown(hdd_ctx); |
| 13739 | } |
| 13740 | |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 13741 | /** |
| 13742 | * hdd_set_rx_mode_rps() - Enable/disable RPS in SAP mode |
| 13743 | * @struct hdd_context *hdd_ctx |
| 13744 | * @struct hdd_adapter *padapter |
| 13745 | * @bool enble |
| 13746 | * |
| 13747 | * Return: none |
| 13748 | */ |
| 13749 | void hdd_set_rx_mode_rps(bool enable) |
| 13750 | { |
| 13751 | struct cds_config_info *cds_cfg = cds_get_ini_config(); |
| 13752 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13753 | struct hdd_adapter *adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE); |
| 13754 | |
| 13755 | if (adapter && hdd_ctx && |
| 13756 | !hdd_ctx->rps && cds_cfg->uc_offload_enabled) { |
| 13757 | if (enable && !cds_cfg->rps_enabled) |
| 13758 | hdd_send_rps_ind(adapter); |
| 13759 | else if (!enable && cds_cfg->rps_enabled) |
| 13760 | hdd_send_rps_disable_ind(adapter); |
| 13761 | } |
| 13762 | } |
| 13763 | |
Hanumanth Reddy Pothula | 3862ca9 | 2018-01-12 16:44:10 +0530 | [diff] [blame] | 13764 | bool hdd_is_cli_iface_up(struct hdd_context *hdd_ctx) |
| 13765 | { |
| 13766 | struct hdd_adapter *adapter = NULL; |
| 13767 | |
| 13768 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 13769 | if ((adapter->device_mode == QDF_STA_MODE || |
| 13770 | adapter->device_mode == QDF_P2P_CLIENT_MODE) && |
| 13771 | qdf_atomic_test_bit(DEVICE_IFACE_OPENED, |
| 13772 | &adapter->event_flags)){ |
| 13773 | return true; |
| 13774 | } |
| 13775 | } |
| 13776 | |
| 13777 | return false; |
| 13778 | } |
| 13779 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13780 | /* Register the module init/exit functions */ |
| 13781 | module_init(hdd_module_init); |
| 13782 | module_exit(hdd_module_exit); |
| 13783 | |
| 13784 | MODULE_LICENSE("Dual BSD/GPL"); |
| 13785 | MODULE_AUTHOR("Qualcomm Atheros, Inc."); |
| 13786 | MODULE_DESCRIPTION("WLAN HOST DEVICE DRIVER"); |
| 13787 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13788 | module_param_call(con_mode, con_mode_handler, param_get_int, &con_mode, |
| 13789 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13790 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 13791 | module_param_call(con_mode_ftm, con_mode_handler_ftm, param_get_int, |
| 13792 | &con_mode_ftm, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 13793 | |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 13794 | module_param_call(con_mode_monitor, con_mode_handler_monitor, param_get_int, |
| 13795 | &con_mode_monitor, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 13796 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13797 | module_param_call(fwpath, fwpath_changed_handler, param_get_string, &fwpath, |
| 13798 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 13799 | |
| 13800 | module_param(enable_dfs_chan_scan, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 13801 | |
| 13802 | module_param(enable_11d, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 13803 | |
| 13804 | module_param(country_code, charp, S_IRUSR | S_IRGRP | S_IROTH); |