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> |
Jeff Johnson | 8bb6111 | 2018-03-31 13:33:54 -0700 | [diff] [blame] | 86 | #include <wlan_hdd_green_ap.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 87 | #include "cfg_api.h" |
| 88 | #include "qwlan_version.h" |
| 89 | #include "wma_types.h" |
| 90 | #include "wlan_hdd_tdls.h" |
| 91 | #ifdef FEATURE_WLAN_CH_AVOID |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 92 | #include "cds_regdomain.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 93 | #endif /* FEATURE_WLAN_CH_AVOID */ |
Dustin Brown | ce46d1d | 2017-08-15 13:34:24 -0700 | [diff] [blame] | 94 | #include "cdp_txrx_flow_ctrl_v2.h" |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 95 | #include "pld_common.h" |
Tushnim Bhattacharyya | 15596cf | 2016-02-12 11:57:02 -0800 | [diff] [blame] | 96 | #include "wlan_hdd_ocb.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 97 | #include "wlan_hdd_nan.h" |
| 98 | #include "wlan_hdd_debugfs.h" |
| 99 | #include "wlan_hdd_driver_ops.h" |
| 100 | #include "epping_main.h" |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 101 | #include "wlan_hdd_data_stall_detection.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 102 | |
| 103 | #include <wlan_hdd_ipa.h> |
| 104 | #include "hif.h" |
| 105 | #include "wma.h" |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 106 | #include "wlan_policy_mgr_api.h" |
Manikandan Mohan | dcc21ba | 2016-03-15 14:31:56 -0700 | [diff] [blame] | 107 | #include "wlan_hdd_tsf.h" |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 108 | #include "bmi.h" |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 109 | #include <wlan_hdd_regulatory.h> |
Jeff Johnson | 2b0a7b8 | 2016-05-18 15:08:02 -0700 | [diff] [blame] | 110 | #include "wlan_hdd_lpass.h" |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 111 | #include "nan_api.h" |
Orhan K AKYILDIZ | 1481aff | 2016-05-16 12:40:13 -0700 | [diff] [blame] | 112 | #include <wlan_hdd_napi.h> |
Padma, Santhosh Kumar | d7cc079 | 2016-06-28 18:54:12 +0530 | [diff] [blame] | 113 | #include "wlan_hdd_disa.h" |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 114 | #include <dispatcher_init_deinit.h> |
Rajeev Kumar | 699debf | 2017-01-06 14:17:00 -0800 | [diff] [blame] | 115 | #include "wlan_hdd_object_manager.h" |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 116 | #include "cds_utils.h" |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 117 | #include <cdp_txrx_handle.h> |
Sandeep Puligilla | fdd201e | 2017-02-02 18:43:46 -0800 | [diff] [blame] | 118 | #include <qca_vendor.h> |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 119 | #include "wlan_pmo_ucfg_api.h" |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 120 | #include "sir_api.h" |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 121 | #include "os_if_wifi_pos.h" |
| 122 | #include "wifi_pos_api.h" |
| 123 | #include "wlan_hdd_oemdata.h" |
Krishna Kumaar Natarajan | 4f1d772 | 2017-03-03 21:12:51 -0800 | [diff] [blame] | 124 | #include "wlan_hdd_he.h" |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 125 | #include "os_if_nan.h" |
| 126 | #include "nan_public_structs.h" |
Kiran Kumar Lokere | 3beeb95 | 2017-05-02 18:40:24 -0700 | [diff] [blame] | 127 | #include "wlan_reg_ucfg_api.h" |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 128 | #include "wlan_dfs_ucfg_api.h" |
Ravi Joshi | 4f09595 | 2017-06-29 15:39:19 -0700 | [diff] [blame] | 129 | #include "wlan_hdd_rx_monitor.h" |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 130 | #include "sme_power_save_api.h" |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 131 | #include "enet.h" |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 132 | #include <cdp_txrx_cmn_struct.h> |
Amar Singhal | 0928b19 | 2017-12-01 10:50:54 -0800 | [diff] [blame] | 133 | #include "wlan_hdd_sysfs.h" |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 134 | #include "wlan_disa_ucfg_api.h" |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 135 | #include "wlan_ipa_ucfg_api.h" |
Arunk Khandavalli | a6305a3 | 2018-01-25 11:19:18 +0530 | [diff] [blame] | 136 | #include <target_if.h> |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 137 | #include "wlan_hdd_nud_tracking.h" |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 138 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 139 | #ifdef CNSS_GENL |
| 140 | #include <net/cnss_nl.h> |
| 141 | #endif |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 142 | #include "wlan_reg_ucfg_api.h" |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 143 | #include "wlan_ocb_ucfg_api.h" |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 144 | |
Sandeep Puligilla | 019a1bd | 2018-02-04 22:57:44 -0800 | [diff] [blame] | 145 | #include <wlan_hdd_spectralscan.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 146 | #ifdef MODULE |
| 147 | #define WLAN_MODULE_NAME module_name(THIS_MODULE) |
| 148 | #else |
| 149 | #define WLAN_MODULE_NAME "wlan" |
| 150 | #endif |
| 151 | |
| 152 | #ifdef TIMER_MANAGER |
| 153 | #define TIMER_MANAGER_STR " +TIMER_MANAGER" |
| 154 | #else |
| 155 | #define TIMER_MANAGER_STR "" |
| 156 | #endif |
| 157 | |
| 158 | #ifdef MEMORY_DEBUG |
| 159 | #define MEMORY_DEBUG_STR " +MEMORY_DEBUG" |
| 160 | #else |
| 161 | #define MEMORY_DEBUG_STR "" |
| 162 | #endif |
| 163 | |
Dustin Brown | c1034df | 2018-02-07 14:51:32 -0800 | [diff] [blame] | 164 | #ifdef PANIC_ON_BUG |
| 165 | #define PANIC_ON_BUG_STR " +PANIC_ON_BUG" |
| 166 | #else |
| 167 | #define PANIC_ON_BUG_STR "" |
| 168 | #endif |
| 169 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 170 | int wlan_start_ret_val; |
| 171 | static DECLARE_COMPLETION(wlan_start_comp); |
| 172 | static unsigned int dev_num = 1; |
| 173 | static struct cdev wlan_hdd_state_cdev; |
| 174 | static struct class *class; |
| 175 | static dev_t device; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 176 | #ifndef MODULE |
| 177 | static struct gwlan_loader *wlan_loader; |
| 178 | static ssize_t wlan_boot_cb(struct kobject *kobj, |
| 179 | struct kobj_attribute *attr, |
| 180 | const char *buf, size_t count); |
| 181 | struct gwlan_loader { |
| 182 | bool loaded_state; |
| 183 | struct kobject *boot_wlan_obj; |
| 184 | struct attribute_group *attr_group; |
| 185 | }; |
| 186 | |
| 187 | static struct kobj_attribute wlan_boot_attribute = |
| 188 | __ATTR(boot_wlan, 0220, NULL, wlan_boot_cb); |
| 189 | |
| 190 | static struct attribute *attrs[] = { |
| 191 | &wlan_boot_attribute.attr, |
| 192 | NULL, |
| 193 | }; |
| 194 | |
| 195 | #define MODULE_INITIALIZED 1 |
| 196 | #endif |
| 197 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 198 | #define HDD_OPS_INACTIVITY_TIMEOUT (120000) |
| 199 | #define MAX_OPS_NAME_STRING_SIZE 20 |
Rajeev Kumar | 6d0b2ea | 2017-12-26 17:55:33 -0800 | [diff] [blame] | 200 | #define RATE_LIMIT_ERROR_LOG (256) |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 201 | |
| 202 | static qdf_timer_t hdd_drv_ops_inactivity_timer; |
Dustin Brown | 45ed4bb | 2017-12-18 12:00:13 -0800 | [diff] [blame] | 203 | static struct task_struct *hdd_drv_ops_task; |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 204 | static char drv_ops_string[MAX_OPS_NAME_STRING_SIZE]; |
| 205 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 206 | /* the Android framework expects this param even though we don't use it */ |
| 207 | #define BUF_LEN 20 |
| 208 | static char fwpath_buffer[BUF_LEN]; |
| 209 | static struct kparam_string fwpath = { |
| 210 | .string = fwpath_buffer, |
| 211 | .maxlen = BUF_LEN, |
| 212 | }; |
| 213 | |
| 214 | static char *country_code; |
| 215 | static int enable_11d = -1; |
| 216 | static int enable_dfs_chan_scan = -1; |
| 217 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 218 | /* |
| 219 | * spinlock for synchronizing asynchronous request/response |
| 220 | * (full description of use in wlan_hdd_main.h) |
| 221 | */ |
| 222 | DEFINE_SPINLOCK(hdd_context_lock); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 223 | DEFINE_MUTEX(hdd_init_deinit_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 224 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 225 | #define WLAN_NLINK_CESIUM 30 |
| 226 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 227 | static qdf_wake_lock_t wlan_wake_lock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 228 | |
| 229 | #define WOW_MAX_FILTER_LISTS 1 |
| 230 | #define WOW_MAX_FILTERS_PER_LIST 4 |
| 231 | #define WOW_MIN_PATTERN_SIZE 6 |
| 232 | #define WOW_MAX_PATTERN_SIZE 64 |
| 233 | |
| 234 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 235 | static const struct wiphy_wowlan_support wowlan_support_reg_init = { |
| 236 | .flags = WIPHY_WOWLAN_ANY | |
| 237 | WIPHY_WOWLAN_MAGIC_PKT | |
| 238 | WIPHY_WOWLAN_DISCONNECT | |
| 239 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 240 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 241 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 242 | WIPHY_WOWLAN_4WAY_HANDSHAKE | |
| 243 | WIPHY_WOWLAN_RFKILL_RELEASE, |
| 244 | .n_patterns = WOW_MAX_FILTER_LISTS * WOW_MAX_FILTERS_PER_LIST, |
| 245 | .pattern_min_len = WOW_MIN_PATTERN_SIZE, |
| 246 | .pattern_max_len = WOW_MAX_PATTERN_SIZE, |
| 247 | }; |
| 248 | #endif |
| 249 | |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 250 | static const struct category_info cinfo[MAX_SUPPORTED_CATEGORY] = { |
| 251 | [QDF_MODULE_ID_TLSHIM] = {QDF_TRACE_LEVEL_ALL}, |
| 252 | [QDF_MODULE_ID_WMI] = {QDF_TRACE_LEVEL_ALL}, |
| 253 | [QDF_MODULE_ID_HTT] = {QDF_TRACE_LEVEL_ALL}, |
| 254 | [QDF_MODULE_ID_HDD] = {QDF_TRACE_LEVEL_ALL}, |
| 255 | [QDF_MODULE_ID_SME] = {QDF_TRACE_LEVEL_ALL}, |
| 256 | [QDF_MODULE_ID_PE] = {QDF_TRACE_LEVEL_ALL}, |
| 257 | [QDF_MODULE_ID_WMA] = {QDF_TRACE_LEVEL_ALL}, |
| 258 | [QDF_MODULE_ID_SYS] = {QDF_TRACE_LEVEL_ALL}, |
| 259 | [QDF_MODULE_ID_QDF] = {QDF_TRACE_LEVEL_ALL}, |
| 260 | [QDF_MODULE_ID_SAP] = {QDF_TRACE_LEVEL_ALL}, |
| 261 | [QDF_MODULE_ID_HDD_SOFTAP] = {QDF_TRACE_LEVEL_ALL}, |
| 262 | [QDF_MODULE_ID_HDD_DATA] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 263 | [QDF_MODULE_ID_HDD_SAP_DATA] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 264 | [QDF_MODULE_ID_HIF] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 265 | [QDF_MODULE_ID_HTC] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 266 | [QDF_MODULE_ID_TXRX] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 267 | [QDF_MODULE_ID_QDF_DEVICE] = {QDF_TRACE_LEVEL_ALL}, |
| 268 | [QDF_MODULE_ID_CFG] = {QDF_TRACE_LEVEL_ALL}, |
| 269 | [QDF_MODULE_ID_BMI] = {QDF_TRACE_LEVEL_ALL}, |
| 270 | [QDF_MODULE_ID_EPPING] = {QDF_TRACE_LEVEL_ALL}, |
| 271 | [QDF_MODULE_ID_QVIT] = {QDF_TRACE_LEVEL_ALL}, |
| 272 | [QDF_MODULE_ID_DP] = {QDF_TRACE_LEVEL_ALL}, |
| 273 | [QDF_MODULE_ID_SOC] = {QDF_TRACE_LEVEL_ALL}, |
| 274 | [QDF_MODULE_ID_OS_IF] = {QDF_TRACE_LEVEL_ALL}, |
| 275 | [QDF_MODULE_ID_TARGET_IF] = {QDF_TRACE_LEVEL_ALL}, |
| 276 | [QDF_MODULE_ID_SCHEDULER] = {QDF_TRACE_LEVEL_ALL}, |
| 277 | [QDF_MODULE_ID_MGMT_TXRX] = {QDF_TRACE_LEVEL_ALL}, |
| 278 | [QDF_MODULE_ID_PMO] = {QDF_TRACE_LEVEL_ALL}, |
| 279 | [QDF_MODULE_ID_SCAN] = {QDF_TRACE_LEVEL_ALL}, |
| 280 | [QDF_MODULE_ID_POLICY_MGR] = {QDF_TRACE_LEVEL_ALL}, |
| 281 | [QDF_MODULE_ID_P2P] = {QDF_TRACE_LEVEL_ALL}, |
| 282 | [QDF_MODULE_ID_TDLS] = {QDF_TRACE_LEVEL_ALL}, |
| 283 | [QDF_MODULE_ID_REGULATORY] = {QDF_TRACE_LEVEL_ALL}, |
| 284 | [QDF_MODULE_ID_SERIALIZATION] = {QDF_TRACE_LEVEL_ALL}, |
Arif Hussain | fde76e7 | 2017-09-05 16:58:23 -0700 | [diff] [blame] | 285 | [QDF_MODULE_ID_DFS] = {QDF_TRACE_LEVEL_ALL}, |
Rajeev Kumar | ca8ef9d | 2017-10-06 10:43:21 -0700 | [diff] [blame] | 286 | [QDF_MODULE_ID_OBJ_MGR] = {QDF_TRACE_LEVEL_ALL}, |
Deepak Dhamdhere | f918d42 | 2017-07-06 12:56:29 -0700 | [diff] [blame] | 287 | [QDF_MODULE_ID_ROAM_DEBUG] = {QDF_TRACE_LEVEL_ALL}, |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 288 | [QDF_MODULE_ID_GREEN_AP] = {QDF_TRACE_LEVEL_ALL}, |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 289 | [QDF_MODULE_ID_OCB] = {QDF_TRACE_LEVEL_ALL}, |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 290 | [QDF_MODULE_ID_IPA] = {QDF_TRACE_LEVEL_ALL}, |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 291 | }; |
| 292 | |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 293 | int limit_off_chan_tbl[HDD_MAX_AC][HDD_MAX_OFF_CHAN_ENTRIES] = { |
| 294 | { HDD_AC_BK_BIT, HDD_MAX_OFF_CHAN_TIME_FOR_BK }, |
| 295 | { HDD_AC_BE_BIT, HDD_MAX_OFF_CHAN_TIME_FOR_BE }, |
| 296 | { HDD_AC_VI_BIT, HDD_MAX_OFF_CHAN_TIME_FOR_VI }, |
| 297 | { HDD_AC_VO_BIT, HDD_MAX_OFF_CHAN_TIME_FOR_VO }, |
| 298 | }; |
| 299 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 300 | /* internal function declaration */ |
Ashish Kumar Dhanotiya | cf11bae | 2017-04-04 03:29:47 +0530 | [diff] [blame] | 301 | struct notifier_block hdd_netdev_notifier; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 302 | |
| 303 | struct sock *cesium_nl_srv_sock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 304 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 305 | static void wlan_hdd_auto_shutdown_cb(void); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 306 | #endif |
| 307 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 308 | void hdd_start_complete(int ret) |
| 309 | { |
| 310 | wlan_start_ret_val = ret; |
| 311 | |
| 312 | complete(&wlan_start_comp); |
| 313 | } |
| 314 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 315 | /** |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 316 | * hdd_set_rps_cpu_mask - set RPS CPU mask for interfaces |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 317 | * @hdd_ctx: pointer to struct hdd_context |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 318 | * |
| 319 | * Return: none |
| 320 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 321 | static void hdd_set_rps_cpu_mask(struct hdd_context *hdd_ctx) |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 322 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 323 | struct hdd_adapter *adapter; |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 324 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 325 | hdd_for_each_adapter(hdd_ctx, adapter) |
| 326 | hdd_send_rps_ind(adapter); |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 327 | } |
| 328 | |
| 329 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 330 | * wlan_hdd_txrx_pause_cb() - pause callback from txrx layer |
| 331 | * @vdev_id: vdev_id |
| 332 | * @action: action type |
| 333 | * @reason: reason type |
| 334 | * |
| 335 | * Return: none |
| 336 | */ |
| 337 | void wlan_hdd_txrx_pause_cb(uint8_t vdev_id, |
| 338 | enum netif_action_type action, enum netif_reason_type reason) |
| 339 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 340 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 341 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 342 | |
| 343 | if (!hdd_ctx) { |
| 344 | hdd_err("hdd ctx is NULL"); |
| 345 | return; |
| 346 | } |
| 347 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 348 | |
| 349 | wlan_hdd_netif_queue_control(adapter, action, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 350 | } |
| 351 | |
| 352 | /* |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 353 | * Store WLAN driver version and timestamp info in global variables such that |
| 354 | * crash debugger can extract them from driver debug symbol and crashdump for |
| 355 | * post processing |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 356 | */ |
Dustin Brown | 96cd963 | 2017-11-13 12:45:04 -0800 | [diff] [blame] | 357 | #ifdef BUILD_TAG |
| 358 | uint8_t g_wlan_driver_version[] = QWLAN_VERSIONSTR "; " BUILD_TAG; |
| 359 | #else |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 360 | uint8_t g_wlan_driver_version[] = QWLAN_VERSIONSTR; |
Naveen Rawat | 9383625 | 2017-06-20 16:30:59 -0700 | [diff] [blame] | 361 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 362 | |
| 363 | /** |
| 364 | * hdd_device_mode_to_string() - return string conversion of device mode |
| 365 | * @device_mode: device mode |
| 366 | * |
| 367 | * This utility function helps log string conversion of device mode. |
| 368 | * |
| 369 | * Return: string conversion of device mode, if match found; |
| 370 | * "Unknown" otherwise. |
| 371 | */ |
| 372 | const char *hdd_device_mode_to_string(uint8_t device_mode) |
| 373 | { |
| 374 | switch (device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 375 | CASE_RETURN_STRING(QDF_STA_MODE); |
| 376 | CASE_RETURN_STRING(QDF_SAP_MODE); |
| 377 | CASE_RETURN_STRING(QDF_P2P_CLIENT_MODE); |
| 378 | CASE_RETURN_STRING(QDF_P2P_GO_MODE); |
| 379 | CASE_RETURN_STRING(QDF_FTM_MODE); |
| 380 | CASE_RETURN_STRING(QDF_IBSS_MODE); |
| 381 | CASE_RETURN_STRING(QDF_P2P_DEVICE_MODE); |
| 382 | CASE_RETURN_STRING(QDF_OCB_MODE); |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 383 | CASE_RETURN_STRING(QDF_NDI_MODE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 384 | default: |
| 385 | return "Unknown"; |
| 386 | } |
| 387 | } |
| 388 | |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 389 | /** |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 390 | * hdd_get_valid_chan() - return current chan list from regulatory. |
| 391 | * @hdd_ctx: HDD context |
| 392 | * @chan_list: buf hold returned chan list |
| 393 | * @chan_num: input buf size and output returned chan num |
| 394 | * |
| 395 | * This function helps get current available chan list from regulatory |
| 396 | * module. It excludes the "disabled" and "invalid" channels. |
| 397 | * |
| 398 | * Return: 0 for success. |
| 399 | */ |
| 400 | static int hdd_get_valid_chan(struct hdd_context *hdd_ctx, |
| 401 | uint8_t *chan_list, |
| 402 | uint32_t *chan_num) |
| 403 | { |
| 404 | int i = 0, j = 0; |
| 405 | struct regulatory_channel *cur_chan_list; |
| 406 | struct wlan_objmgr_pdev *pdev; |
| 407 | |
| 408 | if (!hdd_ctx || !hdd_ctx->hdd_pdev || !chan_list || !chan_num) |
| 409 | return -EINVAL; |
| 410 | |
| 411 | pdev = hdd_ctx->hdd_pdev; |
| 412 | cur_chan_list = qdf_mem_malloc(NUM_CHANNELS * |
| 413 | sizeof(struct regulatory_channel)); |
| 414 | if (!cur_chan_list) |
| 415 | return -ENOMEM; |
| 416 | |
| 417 | if (wlan_reg_get_current_chan_list(pdev, cur_chan_list) != |
| 418 | QDF_STATUS_SUCCESS) { |
| 419 | qdf_mem_free(cur_chan_list); |
| 420 | return -EINVAL; |
| 421 | } |
| 422 | |
| 423 | for (i = 0; i < NUM_CHANNELS; i++) { |
| 424 | uint32_t ch = cur_chan_list[i].chan_num; |
| 425 | enum channel_state state = wlan_reg_get_channel_state(pdev, |
| 426 | ch); |
| 427 | |
| 428 | if (state != CHANNEL_STATE_DISABLE && |
| 429 | state != CHANNEL_STATE_INVALID && |
| 430 | j < *chan_num) { |
| 431 | chan_list[j] = (uint8_t)ch; |
| 432 | j++; |
| 433 | } |
| 434 | } |
| 435 | *chan_num = j; |
| 436 | qdf_mem_free(cur_chan_list); |
| 437 | return 0; |
| 438 | } |
| 439 | |
| 440 | /** |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 441 | * hdd_validate_channel_and_bandwidth() - Validate the channel-bandwidth combo |
| 442 | * @adapter: HDD adapter |
| 443 | * @chan_number: Channel number |
| 444 | * @chan_bw: Bandwidth |
| 445 | * |
| 446 | * Checks if the given bandwidth is valid for the given channel number. |
| 447 | * |
| 448 | * Return: 0 for success, non-zero for failure |
| 449 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 450 | int hdd_validate_channel_and_bandwidth(struct hdd_adapter *adapter, |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 451 | uint32_t chan_number, |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 452 | enum phy_ch_width chan_bw) |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 453 | { |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 454 | uint8_t chan[NUM_CHANNELS]; |
| 455 | uint32_t len = NUM_CHANNELS, i; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 456 | bool found = false; |
| 457 | tHalHandle hal; |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 458 | int ret; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 459 | |
| 460 | hal = WLAN_HDD_GET_HAL_CTX(adapter); |
| 461 | if (!hal) { |
| 462 | hdd_err("Invalid HAL context"); |
| 463 | return -EINVAL; |
| 464 | } |
| 465 | |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 466 | ret = hdd_get_valid_chan(adapter->hdd_ctx, chan, |
| 467 | &len); |
| 468 | if (ret) { |
| 469 | hdd_err("error %d in getting valid channel list", ret); |
| 470 | return ret; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 471 | } |
| 472 | |
| 473 | for (i = 0; i < len; i++) { |
| 474 | if (chan[i] == chan_number) { |
| 475 | found = true; |
| 476 | break; |
| 477 | } |
| 478 | } |
| 479 | |
| 480 | if (found == false) { |
| 481 | hdd_err("Channel not in driver's valid channel list"); |
| 482 | return -EOPNOTSUPP; |
| 483 | } |
| 484 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 485 | if ((!WLAN_REG_IS_24GHZ_CH(chan_number)) && |
| 486 | (!WLAN_REG_IS_5GHZ_CH(chan_number))) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 487 | hdd_err("CH %d is not in 2.4GHz or 5GHz", chan_number); |
| 488 | return -EINVAL; |
| 489 | } |
| 490 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 491 | if (WLAN_REG_IS_24GHZ_CH(chan_number)) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 492 | if (chan_bw == CH_WIDTH_80MHZ) { |
| 493 | hdd_err("BW80 not possible in 2.4GHz band"); |
| 494 | return -EINVAL; |
| 495 | } |
| 496 | if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 14) && |
| 497 | (chan_bw != CH_WIDTH_MAX)) { |
| 498 | hdd_err("Only BW20 possible on channel 14"); |
| 499 | return -EINVAL; |
| 500 | } |
| 501 | } |
| 502 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 503 | if (WLAN_REG_IS_5GHZ_CH(chan_number)) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 504 | if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 165) && |
| 505 | (chan_bw != CH_WIDTH_MAX)) { |
| 506 | hdd_err("Only BW20 possible on channel 165"); |
| 507 | return -EINVAL; |
| 508 | } |
| 509 | } |
| 510 | |
| 511 | return 0; |
| 512 | } |
| 513 | |
Arunk Khandavalli | e1b3a38 | 2017-09-26 12:01:26 +0530 | [diff] [blame] | 514 | /** |
| 515 | * hdd_wait_for_recovery_completion() - Wait for cds recovery completion |
| 516 | * |
| 517 | * Block the unloading of the driver (or) interface up until the |
| 518 | * cds recovery is completed |
| 519 | * |
| 520 | * Return: true for recovery completion else false |
| 521 | */ |
| 522 | static bool hdd_wait_for_recovery_completion(void) |
| 523 | { |
| 524 | int retry = 0; |
| 525 | |
| 526 | /* Wait for recovery to complete */ |
| 527 | while (cds_is_driver_recovering()) { |
| 528 | if (retry == HDD_MOD_EXIT_SSR_MAX_RETRIES/2) |
| 529 | hdd_err("Recovery in progress; wait here!!!"); |
| 530 | msleep(1000); |
| 531 | if (retry++ == HDD_MOD_EXIT_SSR_MAX_RETRIES) { |
| 532 | hdd_err("SSR never completed, error"); |
| 533 | /* |
| 534 | * Trigger the bug_on in the internal builds, in the |
| 535 | * customer builds self-recovery will be enabled |
| 536 | * in those cases just return error. |
| 537 | */ |
| 538 | if (cds_is_self_recovery_enabled()) |
| 539 | return false; |
| 540 | QDF_BUG(0); |
| 541 | } |
| 542 | } |
| 543 | |
| 544 | hdd_info("Recovery completed successfully!"); |
| 545 | return true; |
| 546 | } |
| 547 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 548 | static int __hdd_netdev_notifier_call(struct notifier_block *nb, |
| 549 | unsigned long state, void *data) |
| 550 | { |
| 551 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 552 | struct netdev_notifier_info *dev_notif_info = data; |
| 553 | struct net_device *dev = dev_notif_info->dev; |
| 554 | #else |
| 555 | struct net_device *dev = data; |
| 556 | #endif |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 557 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 558 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 559 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 560 | hdd_enter_dev(dev); |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 561 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 562 | /* Make sure that this callback corresponds to our device. */ |
| 563 | if ((strncmp(dev->name, "wlan", 4)) && (strncmp(dev->name, "p2p", 3))) |
| 564 | return NOTIFY_DONE; |
| 565 | |
Samuel Ahn | c9c48ca | 2016-09-19 15:46:36 +0530 | [diff] [blame] | 566 | if ((adapter->magic != WLAN_HDD_ADAPTER_MAGIC) || |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 567 | (adapter->dev != dev)) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 568 | hdd_err("device adapter is not matching!!!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 569 | return NOTIFY_DONE; |
| 570 | } |
| 571 | |
| 572 | if (!dev->ieee80211_ptr) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 573 | hdd_err("ieee80211_ptr is NULL!!!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 574 | return NOTIFY_DONE; |
| 575 | } |
| 576 | |
| 577 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 578 | if (NULL == hdd_ctx) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 579 | hdd_err("HDD Context Null Pointer"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 580 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 581 | return NOTIFY_DONE; |
| 582 | } |
Jingxiang Ge | 9db9d23 | 2017-10-14 17:22:15 +0800 | [diff] [blame] | 583 | |
| 584 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) { |
| 585 | hdd_err("%s: Driver module is closed", __func__); |
| 586 | return NOTIFY_DONE; |
| 587 | } |
| 588 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 589 | if (cds_is_driver_recovering() || cds_is_driver_in_bad_state()) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 590 | return NOTIFY_DONE; |
| 591 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 592 | hdd_debug("%s New Net Device State = %lu", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 593 | dev->name, state); |
| 594 | |
| 595 | switch (state) { |
| 596 | case NETDEV_REGISTER: |
| 597 | break; |
| 598 | |
| 599 | case NETDEV_UNREGISTER: |
| 600 | break; |
| 601 | |
| 602 | case NETDEV_UP: |
| 603 | sme_ch_avoid_update_req(hdd_ctx->hHal); |
| 604 | break; |
| 605 | |
| 606 | case NETDEV_DOWN: |
| 607 | break; |
| 608 | |
| 609 | case NETDEV_CHANGE: |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 610 | if (adapter->is_link_up_service_needed) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 611 | complete(&adapter->linkup_event_var); |
| 612 | break; |
| 613 | |
| 614 | case NETDEV_GOING_DOWN: |
Sandeep Puligilla | 5f86d99 | 2017-10-29 14:58:53 -0700 | [diff] [blame] | 615 | if (ucfg_scan_get_vdev_status(adapter->hdd_vdev) != |
| 616 | SCAN_NOT_IN_PROGRESS) { |
Abhishek Singh | 69ccb51 | 2017-04-25 11:58:16 +0530 | [diff] [blame] | 617 | wlan_abort_scan(hdd_ctx->hdd_pdev, INVAL_PDEV_ID, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 618 | adapter->session_id, INVALID_SCAN_ID, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 619 | } else { |
hqu | eaa33ee | 2017-05-04 17:56:35 +0800 | [diff] [blame] | 620 | cds_flush_work(&adapter->scan_block_work); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 621 | hdd_debug("Scan is not Pending from user"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 622 | } |
Arunk Khandavalli | f0c0d76 | 2017-12-07 10:18:50 +0530 | [diff] [blame] | 623 | /* |
| 624 | * After NETDEV_GOING_DOWN, kernel calls hdd_stop.Irrespective |
| 625 | * of return status of hdd_stop call, kernel resets the IFF_UP |
| 626 | * flag after which driver does not send the cfg80211_scan_done. |
| 627 | * Ensure to cleanup the scan queue in NETDEV_GOING_DOWN |
| 628 | */ |
Sourav Mohapatra | 001cfaf | 2018-02-28 11:30:46 +0530 | [diff] [blame] | 629 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->hdd_pdev, dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 630 | break; |
| 631 | |
| 632 | default: |
| 633 | break; |
| 634 | } |
| 635 | |
| 636 | return NOTIFY_DONE; |
| 637 | } |
| 638 | |
| 639 | /** |
| 640 | * hdd_netdev_notifier_call() - netdev notifier callback function |
| 641 | * @nb: pointer to notifier block |
| 642 | * @state: state |
| 643 | * @ndev: ndev pointer |
| 644 | * |
| 645 | * Return: 0 on success, error number otherwise. |
| 646 | */ |
| 647 | static int hdd_netdev_notifier_call(struct notifier_block *nb, |
| 648 | unsigned long state, |
| 649 | void *ndev) |
| 650 | { |
| 651 | int ret; |
| 652 | |
| 653 | cds_ssr_protect(__func__); |
| 654 | ret = __hdd_netdev_notifier_call(nb, state, ndev); |
| 655 | cds_ssr_unprotect(__func__); |
| 656 | |
| 657 | return ret; |
| 658 | } |
| 659 | |
| 660 | struct notifier_block hdd_netdev_notifier = { |
| 661 | .notifier_call = hdd_netdev_notifier_call, |
| 662 | }; |
| 663 | |
| 664 | /* variable to hold the insmod parameters */ |
| 665 | static int con_mode; |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 666 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 667 | static int con_mode_ftm; |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 668 | int con_mode_monitor; |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 669 | |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 670 | /* Variable to hold connection mode including module parameter con_mode */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 671 | static int curr_con_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 672 | |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 673 | /** |
| 674 | * hdd_map_nl_chan_width() - Map NL channel width to internal representation |
| 675 | * @ch_width: NL channel width |
| 676 | * |
| 677 | * Converts the NL channel width to the driver's internal representation |
| 678 | * |
| 679 | * Return: Converted channel width. In case of non matching NL channel width, |
| 680 | * CH_WIDTH_MAX will be returned. |
| 681 | */ |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 682 | 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] | 683 | { |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 684 | uint8_t fw_ch_bw; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 685 | |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 686 | fw_ch_bw = wma_get_vht_ch_width(); |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 687 | switch (ch_width) { |
| 688 | case NL80211_CHAN_WIDTH_20_NOHT: |
| 689 | case NL80211_CHAN_WIDTH_20: |
| 690 | return CH_WIDTH_20MHZ; |
| 691 | case NL80211_CHAN_WIDTH_40: |
| 692 | return CH_WIDTH_40MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 693 | case NL80211_CHAN_WIDTH_80: |
| 694 | return CH_WIDTH_80MHZ; |
| 695 | case NL80211_CHAN_WIDTH_80P80: |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 696 | if (fw_ch_bw == WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ) |
| 697 | return CH_WIDTH_80P80MHZ; |
| 698 | else if (fw_ch_bw == WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ) |
| 699 | return CH_WIDTH_160MHZ; |
| 700 | else |
| 701 | return CH_WIDTH_80MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 702 | case NL80211_CHAN_WIDTH_160: |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 703 | if (fw_ch_bw >= WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ) |
| 704 | return CH_WIDTH_160MHZ; |
| 705 | else |
| 706 | return CH_WIDTH_80MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 707 | case NL80211_CHAN_WIDTH_5: |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 708 | return CH_WIDTH_5MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 709 | case NL80211_CHAN_WIDTH_10: |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 710 | return CH_WIDTH_10MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 711 | default: |
| 712 | hdd_err("Invalid channel width %d, setting to default", |
| 713 | ch_width); |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 714 | return CH_WIDTH_INVALID; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 715 | } |
| 716 | } |
| 717 | |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 718 | /* wlan_hdd_find_opclass() - Find operating class for a channel |
| 719 | * @hal: handler to HAL |
| 720 | * @channel: channel id |
| 721 | * @bw_offset: bandwidth offset |
| 722 | * |
| 723 | * Function invokes sme api to find the operating class |
| 724 | * |
| 725 | * Return: operating class |
| 726 | */ |
| 727 | uint8_t wlan_hdd_find_opclass(tHalHandle hal, uint8_t channel, |
| 728 | uint8_t bw_offset) |
| 729 | { |
| 730 | uint8_t opclass = 0; |
| 731 | |
| 732 | sme_get_opclass(hal, channel, bw_offset, &opclass); |
| 733 | return opclass; |
| 734 | } |
| 735 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 736 | /** |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 737 | * hdd_qdf_trace_enable() - configure initial QDF Trace enable |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 738 | * @module_id: Module whose trace level is being configured |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 739 | * @bitmask: Bitmask of log levels to be enabled |
| 740 | * |
| 741 | * Called immediately after the cfg.ini is read in order to configure |
| 742 | * the desired trace levels. |
| 743 | * |
| 744 | * Return: None |
| 745 | */ |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 746 | 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] | 747 | { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 748 | QDF_TRACE_LEVEL level; |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 749 | int qdf_print_idx = -1; |
| 750 | int status = -1; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 751 | /* |
| 752 | * if the bitmask is the default value, then a bitmask was not |
| 753 | * specified in cfg.ini, so leave the logging level alone (it |
| 754 | * will remain at the "compiled in" default value) |
| 755 | */ |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 756 | if (CFG_QDF_TRACE_ENABLE_DEFAULT == bitmask) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 757 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 758 | |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 759 | qdf_print_idx = qdf_get_pidx(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 760 | |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 761 | /* a mask was specified. start by disabling all logging */ |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 762 | status = qdf_print_set_category_verbose(qdf_print_idx, module_id, |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 763 | QDF_TRACE_LEVEL_NONE, 0); |
| 764 | |
| 765 | if (QDF_STATUS_SUCCESS != status) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 766 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 767 | /* now cycle through the bitmask until all "set" bits are serviced */ |
Ashish Kumar Dhanotiya | 83f286b | 2017-09-15 19:52:58 +0530 | [diff] [blame] | 768 | level = QDF_TRACE_LEVEL_NONE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 769 | while (0 != bitmask) { |
| 770 | if (bitmask & 1) { |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 771 | status = qdf_print_set_category_verbose(qdf_print_idx, |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 772 | module_id, level, 1); |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 773 | if (QDF_STATUS_SUCCESS != status) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 774 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 775 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 776 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 777 | level++; |
| 778 | bitmask >>= 1; |
| 779 | } |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 780 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 781 | } |
| 782 | |
| 783 | /** |
Chris Guo | 1751acf | 2017-07-03 14:09:01 +0800 | [diff] [blame] | 784 | * wlan_hdd_validate_context_in_loading() - check the HDD context in loading |
| 785 | * @hdd_ctx: HDD context pointer |
| 786 | * |
| 787 | * Return: 0 if the context is valid. Error code otherwise |
| 788 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 789 | int wlan_hdd_validate_context_in_loading(struct hdd_context *hdd_ctx) |
Chris Guo | 1751acf | 2017-07-03 14:09:01 +0800 | [diff] [blame] | 790 | { |
| 791 | if (NULL == hdd_ctx || NULL == hdd_ctx->config) { |
| 792 | hdd_info("%pS HDD context is Null", (void *)_RET_IP_); |
| 793 | return -ENODEV; |
| 794 | } |
| 795 | |
| 796 | if (cds_is_driver_recovering()) { |
| 797 | hdd_info("%pS Recovery in Progress. State: 0x%x Ignore!!!", |
| 798 | (void *)_RET_IP_, cds_get_driver_state()); |
| 799 | return -EAGAIN; |
| 800 | } |
| 801 | |
| 802 | if (hdd_ctx->start_modules_in_progress || |
| 803 | hdd_ctx->stop_modules_in_progress) { |
| 804 | hdd_info("%pS Start/Stop Modules in progress. Ignore!!!", |
| 805 | (void *)_RET_IP_); |
| 806 | return -EAGAIN; |
| 807 | } |
| 808 | |
| 809 | return 0; |
| 810 | } |
| 811 | |
| 812 | |
| 813 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 814 | * wlan_hdd_validate_context() - check the HDD context |
| 815 | * @hdd_ctx: HDD context pointer |
| 816 | * |
| 817 | * Return: 0 if the context is valid. Error code otherwise |
| 818 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 819 | int wlan_hdd_validate_context(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 820 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 821 | if (NULL == hdd_ctx || NULL == hdd_ctx->config) { |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 822 | hdd_err("%pS HDD context is Null", (void *)_RET_IP_); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 823 | return -ENODEV; |
| 824 | } |
| 825 | |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 826 | if (cds_is_driver_recovering()) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 827 | hdd_debug("%pS Recovery in Progress. State: 0x%x Ignore!!!", |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 828 | (void *)_RET_IP_, cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 829 | return -EAGAIN; |
| 830 | } |
| 831 | |
Yue Ma | 9f275d9 | 2017-09-14 16:58:41 -0700 | [diff] [blame] | 832 | if (cds_is_load_or_unload_in_progress()) { |
| 833 | hdd_debug("%pS Load or unload in progress, state: 0x%x, ignore!", |
| 834 | (void *)_RET_IP_, cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 835 | return -EAGAIN; |
Yue Ma | 9f275d9 | 2017-09-14 16:58:41 -0700 | [diff] [blame] | 836 | } |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 837 | |
| 838 | if (hdd_ctx->start_modules_in_progress || |
| 839 | hdd_ctx->stop_modules_in_progress) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 840 | hdd_debug("%pS Start/Stop Modules in progress. Ignore!!!", |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 841 | (void *)_RET_IP_); |
| 842 | return -EAGAIN; |
| 843 | } |
| 844 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 845 | if (cds_is_driver_in_bad_state()) { |
| 846 | hdd_debug("%pS driver in bad State: 0x%x Ignore!!!", |
| 847 | (void *)_RET_IP_, cds_get_driver_state()); |
Sourav Mohapatra | 21b3c98 | 2018-04-03 17:33:03 +0530 | [diff] [blame] | 848 | return -EAGAIN; |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 849 | } |
| 850 | |
Arunk Khandavalli | 2859fa1 | 2018-02-14 10:46:26 +0530 | [diff] [blame] | 851 | if (cds_is_fw_down()) { |
| 852 | hdd_debug("%pS FW is down: 0x%x Ignore!!!", |
| 853 | (void *)_RET_IP_, cds_get_driver_state()); |
Sourav Mohapatra | 21b3c98 | 2018-04-03 17:33:03 +0530 | [diff] [blame] | 854 | return -EAGAIN; |
Arunk Khandavalli | 2859fa1 | 2018-02-14 10:46:26 +0530 | [diff] [blame] | 855 | } |
| 856 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 857 | return 0; |
| 858 | } |
| 859 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 860 | int hdd_validate_adapter(struct hdd_adapter *adapter) |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 861 | { |
| 862 | if (!adapter) { |
| 863 | hdd_err("adapter is null"); |
| 864 | return -EINVAL; |
| 865 | } |
| 866 | |
| 867 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) { |
| 868 | hdd_err("bad adapter magic: 0x%x (should be 0x%x)", |
| 869 | adapter->magic, WLAN_HDD_ADAPTER_MAGIC); |
| 870 | return -EINVAL; |
| 871 | } |
| 872 | |
| 873 | if (!adapter->dev) { |
| 874 | hdd_err("adapter net_device is null"); |
| 875 | return -EINVAL; |
| 876 | } |
| 877 | |
| 878 | if (!(adapter->dev->flags & IFF_UP)) { |
| 879 | hdd_info("adapter net_device is not up"); |
| 880 | return -EAGAIN; |
| 881 | } |
| 882 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 883 | if (wlan_hdd_validate_session_id(adapter->session_id)) { |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 884 | hdd_info("adapter session is not open"); |
| 885 | return -EAGAIN; |
| 886 | } |
| 887 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 888 | if (adapter->session_id >= MAX_NUMBER_OF_ADAPTERS) { |
| 889 | hdd_err("bad adapter session Id: %u", adapter->session_id); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 890 | return -EINVAL; |
| 891 | } |
| 892 | |
| 893 | return 0; |
| 894 | } |
| 895 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 896 | /** |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 897 | * wlan_hdd_validate_modules_state() - Check modules status |
| 898 | * @hdd_ctx: HDD context pointer |
| 899 | * |
| 900 | * Check's the driver module's state and returns true if the |
| 901 | * modules are enabled returns false if modules are closed. |
| 902 | * |
| 903 | * Return: True if modules are enabled or false. |
| 904 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 905 | bool wlan_hdd_validate_modules_state(struct hdd_context *hdd_ctx) |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 906 | { |
| 907 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 908 | if (hdd_ctx->driver_status != DRIVER_MODULES_ENABLED) { |
| 909 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 910 | hdd_info("Modules not enabled, Present status: %d", |
| 911 | hdd_ctx->driver_status); |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 912 | return false; |
| 913 | } |
| 914 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 915 | return true; |
| 916 | } |
| 917 | |
| 918 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 919 | * 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] | 920 | * @struct hdd_adapter Hdd adapter. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 921 | * |
| 922 | * This function sets the IBSS power save config parameters to WMA |
| 923 | * which will send it to firmware if FW supports IBSS power save |
| 924 | * before vdev start. |
| 925 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 926 | * 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] | 927 | * on failure. |
| 928 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 929 | QDF_STATUS hdd_set_ibss_power_save_params(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 930 | { |
| 931 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 932 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 933 | |
| 934 | if (hdd_ctx == NULL) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 935 | hdd_err("HDD context is null"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 936 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 937 | } |
| 938 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 939 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 940 | WMA_VDEV_IBSS_SET_ATIM_WINDOW_SIZE, |
| 941 | hdd_ctx->config->ibssATIMWinSize, |
| 942 | VDEV_CMD); |
| 943 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 944 | hdd_err("WMA_VDEV_IBSS_SET_ATIM_WINDOW_SIZE failed %d", ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 945 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 946 | } |
| 947 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 948 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 949 | WMA_VDEV_IBSS_SET_POWER_SAVE_ALLOWED, |
| 950 | hdd_ctx->config->isIbssPowerSaveAllowed, |
| 951 | VDEV_CMD); |
| 952 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 953 | hdd_err("WMA_VDEV_IBSS_SET_POWER_SAVE_ALLOWED failed %d", |
| 954 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 955 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 956 | } |
| 957 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 958 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 959 | WMA_VDEV_IBSS_SET_POWER_COLLAPSE_ALLOWED, |
| 960 | hdd_ctx->config-> |
| 961 | isIbssPowerCollapseAllowed, VDEV_CMD); |
| 962 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 963 | hdd_err("WMA_VDEV_IBSS_SET_POWER_COLLAPSE_ALLOWED failed %d", |
| 964 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 965 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 966 | } |
| 967 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 968 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 969 | WMA_VDEV_IBSS_SET_AWAKE_ON_TX_RX, |
| 970 | hdd_ctx->config->isIbssAwakeOnTxRx, |
| 971 | VDEV_CMD); |
| 972 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 973 | 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] | 974 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 975 | } |
| 976 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 977 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 978 | WMA_VDEV_IBSS_SET_INACTIVITY_TIME, |
| 979 | hdd_ctx->config->ibssInactivityCount, |
| 980 | VDEV_CMD); |
| 981 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 982 | hdd_err("WMA_VDEV_IBSS_SET_INACTIVITY_TIME failed %d", ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 983 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 984 | } |
| 985 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 986 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 987 | WMA_VDEV_IBSS_SET_TXSP_END_INACTIVITY_TIME, |
| 988 | hdd_ctx->config->ibssTxSpEndInactivityTime, |
| 989 | VDEV_CMD); |
| 990 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 991 | hdd_err("WMA_VDEV_IBSS_SET_TXSP_END_INACTIVITY_TIME failed %d", |
| 992 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 993 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 994 | } |
| 995 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 996 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 997 | WMA_VDEV_IBSS_PS_SET_WARMUP_TIME_SECS, |
| 998 | hdd_ctx->config->ibssPsWarmupTime, |
| 999 | VDEV_CMD); |
| 1000 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1001 | hdd_err("WMA_VDEV_IBSS_PS_SET_WARMUP_TIME_SECS failed %d", |
| 1002 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1003 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1004 | } |
| 1005 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1006 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1007 | WMA_VDEV_IBSS_PS_SET_1RX_CHAIN_IN_ATIM_WINDOW, |
| 1008 | hdd_ctx->config->ibssPs1RxChainInAtimEnable, |
| 1009 | VDEV_CMD); |
| 1010 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1011 | hdd_err("WMA_VDEV_IBSS_PS_SET_1RX_CHAIN_IN_ATIM_WINDOW failed %d", |
| 1012 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1013 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1014 | } |
| 1015 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1016 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1017 | } |
| 1018 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1019 | #ifdef FEATURE_RUNTIME_PM |
| 1020 | /** |
| 1021 | * hdd_runtime_suspend_context_init() - API to initialize HDD Runtime Contexts |
| 1022 | * @hdd_ctx: HDD context |
| 1023 | * |
| 1024 | * Return: None |
| 1025 | */ |
| 1026 | static void hdd_runtime_suspend_context_init(struct hdd_context *hdd_ctx) |
| 1027 | { |
| 1028 | struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; |
| 1029 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1030 | qdf_runtime_lock_init(&ctx->dfs); |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 1031 | qdf_runtime_lock_init(&ctx->connect); |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1032 | |
| 1033 | wlan_scan_runtime_pm_init(hdd_ctx->hdd_pdev); |
| 1034 | } |
| 1035 | |
| 1036 | /** |
| 1037 | * hdd_runtime_suspend_context_deinit() - API to deinit HDD runtime context |
| 1038 | * @hdd_ctx: HDD Context |
| 1039 | * |
| 1040 | * Return: None |
| 1041 | */ |
| 1042 | static void hdd_runtime_suspend_context_deinit(struct hdd_context *hdd_ctx) |
| 1043 | { |
| 1044 | struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; |
| 1045 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1046 | qdf_runtime_lock_deinit(&ctx->dfs); |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 1047 | qdf_runtime_lock_deinit(&ctx->connect); |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1048 | |
| 1049 | wlan_scan_runtime_pm_deinit(hdd_ctx->hdd_pdev); |
| 1050 | } |
| 1051 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1052 | #else /* FEATURE_RUNTIME_PM */ |
| 1053 | static void hdd_runtime_suspend_context_init(struct hdd_context *hdd_ctx) {} |
| 1054 | static void hdd_runtime_suspend_context_deinit(struct hdd_context *hdd_ctx) {} |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1055 | #endif /* FEATURE_RUNTIME_PM */ |
| 1056 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1057 | #define INTF_MACADDR_MASK 0x7 |
| 1058 | |
| 1059 | /** |
| 1060 | * hdd_update_macaddr() - update mac address |
| 1061 | * @config: hdd configuration |
| 1062 | * @hw_macaddr: mac address |
| 1063 | * |
| 1064 | * Mac address for multiple virtual interface is found as following |
| 1065 | * i) The mac address of the first interface is just the actual hw mac address. |
| 1066 | * ii) MSM 3 or 4 bits of byte5 of the actual mac address are used to |
| 1067 | * define the mac address for the remaining interfaces and locally |
| 1068 | * admistered bit is set. INTF_MACADDR_MASK is based on the number of |
| 1069 | * supported virtual interfaces, right now this is 0x07 (meaning 8 |
| 1070 | * interface). |
| 1071 | * Byte[3] of second interface will be hw_macaddr[3](bit5..7) + 1, |
| 1072 | * for third interface it will be hw_macaddr[3](bit5..7) + 2, etc. |
| 1073 | * |
| 1074 | * Return: None |
| 1075 | */ |
| 1076 | void hdd_update_macaddr(struct hdd_config *config, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1077 | struct qdf_mac_addr hw_macaddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1078 | { |
| 1079 | int8_t i; |
| 1080 | uint8_t macaddr_b3, tmp_br3; |
| 1081 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1082 | qdf_mem_copy(config->intfMacAddr[0].bytes, hw_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1083 | QDF_MAC_ADDR_SIZE); |
| 1084 | for (i = 1; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1085 | qdf_mem_copy(config->intfMacAddr[i].bytes, hw_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1086 | QDF_MAC_ADDR_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1087 | macaddr_b3 = config->intfMacAddr[i].bytes[3]; |
| 1088 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + i) & |
| 1089 | INTF_MACADDR_MASK; |
| 1090 | macaddr_b3 += tmp_br3; |
| 1091 | |
| 1092 | /* XOR-ing bit-24 of the mac address. This will give enough |
| 1093 | * mac address range before collision |
| 1094 | */ |
| 1095 | macaddr_b3 ^= (1 << 7); |
| 1096 | |
| 1097 | /* Set locally administered bit */ |
| 1098 | config->intfMacAddr[i].bytes[0] |= 0x02; |
| 1099 | config->intfMacAddr[i].bytes[3] = macaddr_b3; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1100 | hdd_debug("config->intfMacAddr[%d]: " |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1101 | MAC_ADDRESS_STR, i, |
| 1102 | MAC_ADDR_ARRAY(config->intfMacAddr[i].bytes)); |
| 1103 | } |
| 1104 | } |
| 1105 | |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1106 | static int hdd_update_tdls_config(struct hdd_context *hdd_ctx) |
| 1107 | { |
| 1108 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 1109 | struct tdls_start_params tdls_cfg; |
| 1110 | struct tdls_user_config *config = &tdls_cfg.config; |
| 1111 | struct hdd_config *cfg = hdd_ctx->config; |
| 1112 | QDF_STATUS status; |
| 1113 | |
| 1114 | config->tdls_tx_states_period = cfg->fTDLSTxStatsPeriod; |
| 1115 | config->tdls_tx_pkt_threshold = cfg->fTDLSTxPacketThreshold; |
| 1116 | config->tdls_rx_pkt_threshold = cfg->fTDLSRxFrameThreshold; |
| 1117 | config->tdls_max_discovery_attempt = cfg->fTDLSMaxDiscoveryAttempt; |
| 1118 | config->tdls_idle_timeout = cfg->tdls_idle_timeout; |
| 1119 | config->tdls_idle_pkt_threshold = cfg->fTDLSIdlePacketThreshold; |
| 1120 | config->tdls_rssi_trigger_threshold = cfg->fTDLSRSSITriggerThreshold; |
| 1121 | config->tdls_rssi_teardown_threshold = cfg->fTDLSRSSITeardownThreshold; |
| 1122 | config->tdls_rssi_delta = cfg->fTDLSRSSIDelta; |
| 1123 | config->tdls_uapsd_mask = cfg->fTDLSUapsdMask; |
| 1124 | config->tdls_uapsd_inactivity_time = cfg->fTDLSPuapsdInactivityTimer; |
| 1125 | config->tdls_uapsd_pti_window = cfg->fTDLSPuapsdPTIWindow; |
| 1126 | config->tdls_uapsd_ptr_timeout = cfg->fTDLSPuapsdPTRTimeout; |
| 1127 | config->tdls_pre_off_chan_num = cfg->fTDLSPrefOffChanNum; |
| 1128 | config->tdls_pre_off_chan_bw = cfg->fTDLSPrefOffChanBandwidth; |
| 1129 | config->tdls_peer_kickout_threshold = cfg->tdls_peer_kickout_threshold; |
| 1130 | config->delayed_trig_framint = cfg->DelayedTriggerFrmInt; |
| 1131 | config->tdls_feature_flags = ((cfg->fEnableTDLSOffChannel ? |
| 1132 | 1 << TDLS_FEATURE_OFF_CHANNEL : 0) | |
| 1133 | (cfg->fEnableTDLSWmmMode ? 1 << TDLS_FEATURE_WMM : 0) | |
| 1134 | (cfg->fEnableTDLSBufferSta ? 1 << TDLS_FEATURE_BUFFER_STA : 0) | |
| 1135 | (cfg->fEnableTDLSSleepSta ? 1 << TDLS_FEATURE_SLEEP_STA : 0) | |
| 1136 | (cfg->enable_tdls_scan ? 1 << TDLS_FEATURE_SCAN : 0) | |
| 1137 | (cfg->fEnableTDLSSupport ? 1 << TDLS_FEATURE_ENABLE : 0) | |
| 1138 | (cfg->fEnableTDLSImplicitTrigger ? |
| 1139 | 1 << TDLS_FEAUTRE_IMPLICIT_TRIGGER : 0) | |
| 1140 | (cfg->fTDLSExternalControl ? |
| 1141 | 1 << TDLS_FEATURE_EXTERNAL_CONTROL : 0)); |
| 1142 | config->tdls_vdev_nss_2g = CFG_TDLS_NSS(cfg->vdev_type_nss_2g); |
| 1143 | config->tdls_vdev_nss_5g = CFG_TDLS_NSS(cfg->vdev_type_nss_5g); |
| 1144 | |
| 1145 | tdls_cfg.tdls_send_mgmt_req = eWNI_SME_TDLS_SEND_MGMT_REQ; |
| 1146 | tdls_cfg.tdls_add_sta_req = eWNI_SME_TDLS_ADD_STA_REQ; |
| 1147 | tdls_cfg.tdls_del_sta_req = eWNI_SME_TDLS_DEL_STA_REQ; |
| 1148 | tdls_cfg.tdls_update_peer_state = WMA_UPDATE_TDLS_PEER_STATE; |
| 1149 | tdls_cfg.tdls_del_all_peers = eWNI_SME_DEL_ALL_TDLS_PEERS; |
| 1150 | tdls_cfg.tdls_update_dp_vdev_flags = CDP_UPDATE_TDLS_FLAGS; |
| 1151 | tdls_cfg.tdls_event_cb = wlan_cfg80211_tdls_event_callback; |
| 1152 | tdls_cfg.tdls_evt_cb_data = psoc; |
Jeff Johnson | 1d40f5b | 2018-03-02 08:35:53 -0800 | [diff] [blame] | 1153 | tdls_cfg.tdls_peer_context = hdd_ctx; |
| 1154 | tdls_cfg.tdls_reg_peer = hdd_tdls_register_peer; |
| 1155 | tdls_cfg.tdls_dereg_peer = hdd_tdls_deregister_peer; |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1156 | tdls_cfg.tdls_wmm_cb = hdd_wmm_is_acm_allowed; |
| 1157 | tdls_cfg.tdls_wmm_cb_data = psoc; |
| 1158 | tdls_cfg.tdls_rx_cb = wlan_cfg80211_tdls_rx_callback; |
| 1159 | tdls_cfg.tdls_rx_cb_data = psoc; |
| 1160 | tdls_cfg.tdls_dp_vdev_update = hdd_update_dp_vdev_flags; |
| 1161 | |
| 1162 | status = ucfg_tdls_update_config(psoc, &tdls_cfg); |
| 1163 | if (status != QDF_STATUS_SUCCESS) { |
| 1164 | hdd_err("failed pmo psoc configuration"); |
| 1165 | return -EINVAL; |
| 1166 | } |
| 1167 | |
| 1168 | hdd_ctx->tdls_umac_comp_active = true; |
| 1169 | /* enable napier specific tdls data path */ |
| 1170 | hdd_ctx->tdls_nap_active = true; |
| 1171 | |
| 1172 | return 0; |
| 1173 | } |
| 1174 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1175 | static void hdd_update_tgt_services(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1176 | struct wma_tgt_services *cfg) |
| 1177 | { |
| 1178 | struct hdd_config *config = hdd_ctx->config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1179 | |
| 1180 | /* Set up UAPSD */ |
| 1181 | config->apUapsdEnabled &= cfg->uapsd; |
| 1182 | |
Krishna Kumaar Natarajan | 4f1d772 | 2017-03-03 21:12:51 -0800 | [diff] [blame] | 1183 | /* 11AX mode support */ |
| 1184 | if ((config->dot11Mode == eHDD_DOT11_MODE_11ax || |
| 1185 | config->dot11Mode == eHDD_DOT11_MODE_11ax_ONLY) && !cfg->en_11ax) |
| 1186 | config->dot11Mode = eHDD_DOT11_MODE_11ac; |
| 1187 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1188 | /* 11AC mode support */ |
| 1189 | if ((config->dot11Mode == eHDD_DOT11_MODE_11ac || |
| 1190 | config->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY) && !cfg->en_11ac) |
| 1191 | config->dot11Mode = eHDD_DOT11_MODE_AUTO; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1192 | |
| 1193 | /* ARP offload: override user setting if invalid */ |
| 1194 | config->fhostArpOffload &= cfg->arp_offload; |
| 1195 | |
| 1196 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 1197 | /* PNO offload */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1198 | hdd_debug("PNO Capability in f/w = %d", cfg->pno_offload); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1199 | if (cfg->pno_offload) |
| 1200 | config->PnoOffload = true; |
| 1201 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1202 | #ifdef FEATURE_WLAN_TDLS |
| 1203 | config->fEnableTDLSSupport &= cfg->en_tdls; |
Manjeet Singh | fdd2ac7 | 2016-09-02 18:11:43 +0530 | [diff] [blame] | 1204 | config->fEnableTDLSOffChannel = config->fEnableTDLSOffChannel && |
| 1205 | cfg->en_tdls_offchan; |
| 1206 | config->fEnableTDLSBufferSta = config->fEnableTDLSBufferSta && |
| 1207 | cfg->en_tdls_uapsd_buf_sta; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 1208 | if (config->fTDLSUapsdMask && cfg->en_tdls_uapsd_sleep_sta) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1209 | config->fEnableTDLSSleepSta = true; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 1210 | else |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1211 | config->fEnableTDLSSleepSta = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1212 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1213 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
| 1214 | config->isRoamOffloadEnabled &= cfg->en_roam_offload; |
| 1215 | #endif |
Will Huang | 496b36c | 2017-07-11 16:38:50 +0800 | [diff] [blame] | 1216 | config->sap_get_peer_info &= cfg->get_peer_info_enabled; |
Varun Reddy Yeturu | 62c3265 | 2017-10-26 15:32:35 -0700 | [diff] [blame] | 1217 | config->MAWCEnabled &= cfg->is_fw_mawc_capable; |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1218 | hdd_update_tdls_config(hdd_ctx); |
Krishna Kumaar Natarajan | 052c6e6 | 2015-09-28 15:32:55 -0700 | [diff] [blame] | 1219 | sme_update_tgt_services(hdd_ctx->hHal, cfg); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1220 | |
| 1221 | } |
| 1222 | |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1223 | /** |
| 1224 | * hdd_update_vdev_nss() - sets the vdev nss |
| 1225 | * @hdd_ctx: HDD context |
| 1226 | * |
| 1227 | * Sets the Nss per vdev type based on INI |
| 1228 | * |
| 1229 | * Return: None |
| 1230 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1231 | static void hdd_update_vdev_nss(struct hdd_context *hdd_ctx) |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1232 | { |
| 1233 | struct hdd_config *cfg_ini = hdd_ctx->config; |
| 1234 | uint8_t max_supp_nss = 1; |
| 1235 | |
Naveen Rawat | 10b1c15 | 2017-01-18 11:16:06 -0800 | [diff] [blame] | 1236 | if (cfg_ini->enable2x2 && !cds_is_sub_20_mhz_enabled()) |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1237 | max_supp_nss = 2; |
Liangwei Dong | 22810e8 | 2018-03-15 03:42:12 -0400 | [diff] [blame] | 1238 | hdd_debug("max nss %d vdev_type_nss_2g %x vdev_type_nss_5g %x", |
| 1239 | max_supp_nss, cfg_ini->vdev_type_nss_2g, |
| 1240 | cfg_ini->vdev_type_nss_5g); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1241 | |
| 1242 | sme_update_vdev_type_nss(hdd_ctx->hHal, max_supp_nss, |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1243 | cfg_ini->vdev_type_nss_2g, BAND_2G); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1244 | |
| 1245 | sme_update_vdev_type_nss(hdd_ctx->hHal, max_supp_nss, |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1246 | cfg_ini->vdev_type_nss_5g, BAND_5G); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1247 | } |
| 1248 | |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1249 | /** |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1250 | * hdd_update_wiphy_vhtcap() - Updates wiphy vhtcap fields |
| 1251 | * @hdd_ctx: HDD context |
| 1252 | * |
| 1253 | * Updates wiphy vhtcap fields |
| 1254 | * |
| 1255 | * Return: None |
| 1256 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1257 | static void hdd_update_wiphy_vhtcap(struct hdd_context *hdd_ctx) |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1258 | { |
| 1259 | struct ieee80211_supported_band *band_5g = |
| 1260 | hdd_ctx->wiphy->bands[NL80211_BAND_5GHZ]; |
| 1261 | uint32_t val; |
| 1262 | |
| 1263 | if (!band_5g) { |
| 1264 | hdd_debug("5GHz band disabled, skipping capability population"); |
| 1265 | return; |
| 1266 | } |
| 1267 | |
| 1268 | val = hdd_ctx->config->txBFCsnValue; |
| 1269 | band_5g->vht_cap.cap |= (val << IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT); |
| 1270 | |
| 1271 | val = NUM_OF_SOUNDING_DIMENSIONS; |
| 1272 | band_5g->vht_cap.cap |= |
| 1273 | (val << IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_SHIFT); |
| 1274 | |
| 1275 | hdd_info("Updated wiphy vhtcap:0x%x, CSNAntSupp:%d, NumSoundDim:%d", |
| 1276 | band_5g->vht_cap.cap, hdd_ctx->config->txBFCsnValue, val); |
| 1277 | } |
| 1278 | |
| 1279 | /** |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1280 | * hdd_update_hw_dbs_capable() - sets the dbs capability of the device |
| 1281 | * @hdd_ctx: HDD context |
| 1282 | * |
| 1283 | * Sets the DBS capability as per INI and firmware capability |
| 1284 | * |
| 1285 | * Return: None |
| 1286 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1287 | static void hdd_update_hw_dbs_capable(struct hdd_context *hdd_ctx) |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1288 | { |
| 1289 | struct hdd_config *cfg_ini = hdd_ctx->config; |
| 1290 | uint8_t hw_dbs_capable = 0; |
| 1291 | |
Tushnim Bhattacharyya | 49ed8ab | 2017-05-26 18:20:10 -0700 | [diff] [blame] | 1292 | if (policy_mgr_is_hw_dbs_capable(hdd_ctx->hdd_psoc) && |
| 1293 | ((cfg_ini->dual_mac_feature_disable == |
| 1294 | ENABLE_DBS_CXN_AND_SCAN) || |
| 1295 | (cfg_ini->dual_mac_feature_disable == |
| 1296 | ENABLE_DBS_CXN_AND_ENABLE_SCAN_WITH_ASYNC_SCAN_OFF))) |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1297 | hw_dbs_capable = 1; |
| 1298 | |
| 1299 | sme_update_hw_dbs_capable(hdd_ctx->hHal, hw_dbs_capable); |
| 1300 | } |
| 1301 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1302 | static void hdd_update_tgt_ht_cap(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1303 | struct wma_tgt_ht_cap *cfg) |
| 1304 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1305 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1306 | uint32_t value, val32; |
| 1307 | uint16_t val16; |
| 1308 | struct hdd_config *pconfig = hdd_ctx->config; |
| 1309 | tSirMacHTCapabilityInfo *phtCapInfo; |
| 1310 | uint8_t mcs_set[SIZE_OF_SUPPORTED_MCS_SET]; |
| 1311 | uint8_t enable_tx_stbc; |
| 1312 | |
| 1313 | /* check and update RX STBC */ |
| 1314 | if (pconfig->enableRxSTBC && !cfg->ht_rx_stbc) |
| 1315 | pconfig->enableRxSTBC = cfg->ht_rx_stbc; |
| 1316 | |
| 1317 | /* get the MPDU density */ |
| 1318 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_MPDU_DENSITY, &value); |
| 1319 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1320 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1321 | hdd_err("could not get MPDU DENSITY"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1322 | value = 0; |
| 1323 | } |
| 1324 | |
| 1325 | /* |
| 1326 | * MPDU density: |
| 1327 | * override user's setting if value is larger |
| 1328 | * than the one supported by target |
| 1329 | */ |
| 1330 | if (value > cfg->mpdu_density) { |
| 1331 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_MPDU_DENSITY, |
| 1332 | cfg->mpdu_density); |
| 1333 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1334 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1335 | hdd_err("could not set MPDU DENSITY to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1336 | } |
| 1337 | |
| 1338 | /* get the HT capability info */ |
| 1339 | 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] | 1340 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1341 | hdd_err("could not get HT capability info"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1342 | return; |
| 1343 | } |
| 1344 | val16 = (uint16_t) val32; |
| 1345 | phtCapInfo = (tSirMacHTCapabilityInfo *) &val16; |
| 1346 | |
| 1347 | /* Set the LDPC capability */ |
| 1348 | phtCapInfo->advCodingCap = cfg->ht_rx_ldpc; |
| 1349 | |
| 1350 | if (pconfig->ShortGI20MhzEnable && !cfg->ht_sgi_20) |
| 1351 | pconfig->ShortGI20MhzEnable = cfg->ht_sgi_20; |
| 1352 | |
| 1353 | if (pconfig->ShortGI40MhzEnable && !cfg->ht_sgi_40) |
| 1354 | pconfig->ShortGI40MhzEnable = cfg->ht_sgi_40; |
| 1355 | |
| 1356 | hdd_ctx->num_rf_chains = cfg->num_rf_chains; |
| 1357 | hdd_ctx->ht_tx_stbc_supported = cfg->ht_tx_stbc; |
| 1358 | |
| 1359 | enable_tx_stbc = pconfig->enableTxSTBC; |
| 1360 | |
| 1361 | if (pconfig->enable2x2 && (cfg->num_rf_chains == 2)) { |
| 1362 | pconfig->enable2x2 = 1; |
| 1363 | } else { |
| 1364 | pconfig->enable2x2 = 0; |
| 1365 | enable_tx_stbc = 0; |
| 1366 | |
| 1367 | /* 1x1 */ |
| 1368 | /* Update Rx Highest Long GI data Rate */ |
| 1369 | if (sme_cfg_set_int(hdd_ctx->hHal, |
| 1370 | WNI_CFG_VHT_RX_HIGHEST_SUPPORTED_DATA_RATE, |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1371 | VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1372 | == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1373 | 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] | 1374 | } |
| 1375 | |
| 1376 | /* Update Tx Highest Long GI data Rate */ |
| 1377 | if (sme_cfg_set_int |
| 1378 | (hdd_ctx->hHal, |
| 1379 | WNI_CFG_VHT_TX_HIGHEST_SUPPORTED_DATA_RATE, |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1380 | VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1) == |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1381 | QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1382 | hdd_err("VHT_TX_HIGHEST_SUPP_RATE_1_1 to CCM fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1383 | } |
| 1384 | } |
| 1385 | if (!(cfg->ht_tx_stbc && pconfig->enable2x2)) |
| 1386 | enable_tx_stbc = 0; |
| 1387 | phtCapInfo->txSTBC = enable_tx_stbc; |
| 1388 | |
| 1389 | val32 = val16; |
| 1390 | 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] | 1391 | if (status != QDF_STATUS_SUCCESS) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1392 | hdd_err("could not set HT capability to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1393 | #define WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES 0xff |
| 1394 | value = SIZE_OF_SUPPORTED_MCS_SET; |
| 1395 | 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] | 1396 | &value) == QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1397 | hdd_debug("Read MCS rate set"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1398 | |
| 1399 | if (pconfig->enable2x2) { |
| 1400 | for (value = 0; value < cfg->num_rf_chains; value++) |
| 1401 | mcs_set[value] = |
| 1402 | WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES; |
| 1403 | |
| 1404 | status = |
| 1405 | sme_cfg_set_str(hdd_ctx->hHal, |
| 1406 | WNI_CFG_SUPPORTED_MCS_SET, |
| 1407 | mcs_set, |
| 1408 | SIZE_OF_SUPPORTED_MCS_SET); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1409 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1410 | hdd_err("could not set MCS SET to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1411 | } |
| 1412 | } |
| 1413 | #undef WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES |
| 1414 | } |
| 1415 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1416 | static void hdd_update_tgt_vht_cap(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1417 | struct wma_tgt_vht_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 = 0; |
| 1421 | struct hdd_config *pconfig = hdd_ctx->config; |
| 1422 | struct wiphy *wiphy = hdd_ctx->wiphy; |
| 1423 | struct ieee80211_supported_band *band_5g = |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 1424 | wiphy->bands[HDD_NL80211_BAND_5GHZ]; |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1425 | uint32_t temp = 0; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1426 | uint32_t ch_width = eHT_CHANNEL_WIDTH_80MHZ; |
jiad | 4a7a33c | 2017-08-08 15:32:24 +0800 | [diff] [blame] | 1427 | uint32_t hw_rx_ldpc_enabled; |
Sandeep Puligilla | 305d509 | 2018-04-16 14:40:50 -0700 | [diff] [blame^] | 1428 | struct wma_caps_per_phy caps_per_phy; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1429 | |
Dustin Brown | 5e06bd3 | 2016-10-04 12:49:10 -0700 | [diff] [blame] | 1430 | if (!band_5g) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1431 | hdd_debug("5GHz band disabled, skipping capability population"); |
Dustin Brown | 5e06bd3 | 2016-10-04 12:49:10 -0700 | [diff] [blame] | 1432 | return; |
| 1433 | } |
| 1434 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1435 | /* Get the current MPDU length */ |
| 1436 | status = |
| 1437 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_MAX_MPDU_LENGTH, |
| 1438 | &value); |
| 1439 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1440 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1441 | hdd_err("could not get MPDU LENGTH"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1442 | value = 0; |
| 1443 | } |
| 1444 | |
| 1445 | /* |
| 1446 | * VHT max MPDU length: |
| 1447 | * override if user configured value is too high |
| 1448 | * that the target cannot support |
| 1449 | */ |
| 1450 | if (value > cfg->vht_max_mpdu) { |
| 1451 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1452 | WNI_CFG_VHT_MAX_MPDU_LENGTH, |
| 1453 | cfg->vht_max_mpdu); |
| 1454 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1455 | if (status == QDF_STATUS_E_FAILURE) |
| 1456 | hdd_err("could not set VHT MAX MPDU LENGTH"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1457 | } |
| 1458 | |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1459 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_BASIC_MCS_SET, &temp); |
| 1460 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtRxMCS; |
| 1461 | |
| 1462 | if (pconfig->enable2x2) |
| 1463 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtRxMCS2x2 << 2); |
| 1464 | |
| 1465 | if (sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_BASIC_MCS_SET, temp) == |
| 1466 | QDF_STATUS_E_FAILURE) { |
| 1467 | hdd_err("Could not pass VHT_BASIC_MCS_SET to CCM"); |
| 1468 | } |
| 1469 | |
| 1470 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_RX_MCS_MAP, &temp); |
| 1471 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtRxMCS; |
| 1472 | if (pconfig->enable2x2) |
| 1473 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtRxMCS2x2 << 2); |
| 1474 | |
| 1475 | if (sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_RX_MCS_MAP, temp) == |
| 1476 | QDF_STATUS_E_FAILURE) { |
| 1477 | hdd_err("Could not pass WNI_CFG_VHT_RX_MCS_MAP to CCM"); |
| 1478 | } |
| 1479 | |
| 1480 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_TX_MCS_MAP, &temp); |
| 1481 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtTxMCS; |
| 1482 | if (pconfig->enable2x2) |
| 1483 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtTxMCS2x2 << 2); |
| 1484 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1485 | hdd_debug("vhtRxMCS2x2 - %x temp - %u enable2x2 %d", |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1486 | pconfig->vhtRxMCS2x2, temp, pconfig->enable2x2); |
| 1487 | |
| 1488 | if (sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_TX_MCS_MAP, temp) == |
| 1489 | QDF_STATUS_E_FAILURE) { |
| 1490 | hdd_err("Could not pass WNI_CFG_VHT_TX_MCS_MAP to CCM"); |
| 1491 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1492 | /* Get the current RX LDPC setting */ |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1493 | 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] | 1494 | &value); |
| 1495 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1496 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1497 | hdd_err("could not get VHT LDPC CODING CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1498 | value = 0; |
| 1499 | } |
| 1500 | |
jiad | 4a7a33c | 2017-08-08 15:32:24 +0800 | [diff] [blame] | 1501 | /* Set HW RX LDPC capability */ |
| 1502 | hw_rx_ldpc_enabled = !!cfg->vht_rx_ldpc; |
| 1503 | if (hw_rx_ldpc_enabled != value) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1504 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1505 | WNI_CFG_VHT_LDPC_CODING_CAP, |
jiad | 4a7a33c | 2017-08-08 15:32:24 +0800 | [diff] [blame] | 1506 | hw_rx_ldpc_enabled); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1507 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1508 | if (status == QDF_STATUS_E_FAILURE) |
| 1509 | hdd_err("could not set VHT LDPC CODING CAP to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1510 | } |
| 1511 | |
| 1512 | /* Get current GI 80 value */ |
| 1513 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_SHORT_GI_80MHZ, |
| 1514 | &value); |
| 1515 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1516 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1517 | hdd_err("could not get SHORT GI 80MHZ"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1518 | value = 0; |
| 1519 | } |
| 1520 | |
| 1521 | /* set the Guard interval 80MHz */ |
| 1522 | if (value && !cfg->vht_short_gi_80) { |
| 1523 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1524 | WNI_CFG_VHT_SHORT_GI_80MHZ, |
| 1525 | cfg->vht_short_gi_80); |
| 1526 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1527 | if (status == QDF_STATUS_E_FAILURE) |
| 1528 | hdd_err("could not set SHORT GI 80MHZ to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1529 | } |
| 1530 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1531 | /* Get VHT TX STBC cap */ |
| 1532 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_TXSTBC, &value); |
| 1533 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1534 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1535 | hdd_err("could not get VHT TX STBC"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1536 | value = 0; |
| 1537 | } |
| 1538 | |
| 1539 | /* VHT TX STBC cap */ |
| 1540 | if (value && !cfg->vht_tx_stbc) { |
| 1541 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_TXSTBC, |
| 1542 | cfg->vht_tx_stbc); |
| 1543 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1544 | if (status == QDF_STATUS_E_FAILURE) |
| 1545 | hdd_err("could not set the VHT TX STBC to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1546 | } |
| 1547 | |
| 1548 | /* Get VHT RX STBC cap */ |
| 1549 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_RXSTBC, &value); |
| 1550 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1551 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1552 | hdd_err("could not get VHT RX STBC"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1553 | value = 0; |
| 1554 | } |
| 1555 | |
| 1556 | /* VHT RX STBC cap */ |
| 1557 | if (value && !cfg->vht_rx_stbc) { |
| 1558 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_RXSTBC, |
| 1559 | cfg->vht_rx_stbc); |
| 1560 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1561 | if (status == QDF_STATUS_E_FAILURE) |
| 1562 | hdd_err("could not set the VHT RX STBC to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1563 | } |
| 1564 | |
| 1565 | /* Get VHT SU Beamformer cap */ |
| 1566 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_SU_BEAMFORMER_CAP, |
| 1567 | &value); |
| 1568 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1569 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1570 | hdd_err("could not get VHT SU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1571 | value = 0; |
| 1572 | } |
| 1573 | |
| 1574 | /* set VHT SU Beamformer cap */ |
| 1575 | if (value && !cfg->vht_su_bformer) { |
| 1576 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1577 | WNI_CFG_VHT_SU_BEAMFORMER_CAP, |
| 1578 | cfg->vht_su_bformer); |
| 1579 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1580 | if (status == QDF_STATUS_E_FAILURE) |
| 1581 | hdd_err("could not set VHT SU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1582 | } |
| 1583 | |
| 1584 | /* check and update SU BEAMFORMEE capabality */ |
| 1585 | if (pconfig->enableTxBF && !cfg->vht_su_bformee) |
| 1586 | pconfig->enableTxBF = cfg->vht_su_bformee; |
| 1587 | |
| 1588 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1589 | WNI_CFG_VHT_SU_BEAMFORMEE_CAP, |
| 1590 | pconfig->enableTxBF); |
| 1591 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1592 | if (status == QDF_STATUS_E_FAILURE) |
| 1593 | hdd_err("could not set VHT SU BEAMFORMEE CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1594 | |
| 1595 | /* Get VHT MU Beamformer cap */ |
| 1596 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_MU_BEAMFORMER_CAP, |
| 1597 | &value); |
| 1598 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1599 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1600 | hdd_err("could not get VHT MU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1601 | value = 0; |
| 1602 | } |
| 1603 | |
| 1604 | /* set VHT MU Beamformer cap */ |
| 1605 | if (value && !cfg->vht_mu_bformer) { |
| 1606 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1607 | WNI_CFG_VHT_MU_BEAMFORMER_CAP, |
| 1608 | cfg->vht_mu_bformer); |
| 1609 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1610 | if (status == QDF_STATUS_E_FAILURE) |
| 1611 | hdd_err("could not set the VHT MU BEAMFORMER CAP to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1612 | } |
| 1613 | |
| 1614 | /* Get VHT MU Beamformee cap */ |
| 1615 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_MU_BEAMFORMEE_CAP, |
| 1616 | &value); |
| 1617 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1618 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1619 | hdd_err("could not get VHT MU BEAMFORMEE CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1620 | value = 0; |
| 1621 | } |
| 1622 | |
| 1623 | /* set VHT MU Beamformee cap */ |
| 1624 | if (value && !cfg->vht_mu_bformee) { |
| 1625 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1626 | WNI_CFG_VHT_MU_BEAMFORMEE_CAP, |
| 1627 | cfg->vht_mu_bformee); |
| 1628 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1629 | if (status == QDF_STATUS_E_FAILURE) |
| 1630 | hdd_err("could not set VHT MU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1631 | } |
| 1632 | |
| 1633 | /* Get VHT MAX AMPDU Len exp */ |
| 1634 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_AMPDU_LEN_EXPONENT, |
| 1635 | &value); |
| 1636 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1637 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1638 | hdd_err("could not get VHT AMPDU LEN"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1639 | value = 0; |
| 1640 | } |
| 1641 | |
| 1642 | /* |
| 1643 | * VHT max AMPDU len exp: |
| 1644 | * override if user configured value is too high |
| 1645 | * that the target cannot support. |
| 1646 | * Even though Rome publish ampdu_len=7, it can |
| 1647 | * only support 4 because of some h/w bug. |
| 1648 | */ |
| 1649 | |
| 1650 | if (value > cfg->vht_max_ampdu_len_exp) { |
| 1651 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1652 | WNI_CFG_VHT_AMPDU_LEN_EXPONENT, |
| 1653 | cfg->vht_max_ampdu_len_exp); |
| 1654 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1655 | if (status == QDF_STATUS_E_FAILURE) |
| 1656 | hdd_err("could not set the VHT AMPDU LEN EXP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1657 | } |
| 1658 | |
| 1659 | /* Get VHT TXOP PS CAP */ |
| 1660 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_TXOP_PS, &value); |
| 1661 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1662 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1663 | hdd_err("could not get VHT TXOP PS"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1664 | value = 0; |
| 1665 | } |
| 1666 | |
| 1667 | /* set VHT TXOP PS cap */ |
| 1668 | if (value && !cfg->vht_txop_ps) { |
| 1669 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_TXOP_PS, |
| 1670 | cfg->vht_txop_ps); |
| 1671 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1672 | if (status == QDF_STATUS_E_FAILURE) |
| 1673 | hdd_err("could not set the VHT TXOP PS"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1674 | } |
| 1675 | |
| 1676 | if (WMI_VHT_CAP_MAX_MPDU_LEN_11454 == cfg->vht_max_mpdu) |
| 1677 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454; |
| 1678 | else if (WMI_VHT_CAP_MAX_MPDU_LEN_7935 == cfg->vht_max_mpdu) |
| 1679 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991; |
| 1680 | else |
| 1681 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895; |
| 1682 | |
| 1683 | |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1684 | if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_80P80MHZ)) { |
| 1685 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1686 | WNI_CFG_VHT_SUPPORTED_CHAN_WIDTH_SET, |
| 1687 | VHT_CAP_160_AND_80P80_SUPP); |
| 1688 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1689 | hdd_err("could not set the VHT CAP 160"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1690 | band_5g->vht_cap.cap |= |
| 1691 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1692 | ch_width = eHT_CHANNEL_WIDTH_80P80MHZ; |
| 1693 | } else if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_160MHZ)) { |
| 1694 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1695 | WNI_CFG_VHT_SUPPORTED_CHAN_WIDTH_SET, |
| 1696 | VHT_CAP_160_SUPP); |
| 1697 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1698 | hdd_err("could not set the VHT CAP 160"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1699 | band_5g->vht_cap.cap |= |
| 1700 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1701 | ch_width = eHT_CHANNEL_WIDTH_160MHZ; |
| 1702 | } |
| 1703 | pconfig->vhtChannelWidth = QDF_MIN(pconfig->vhtChannelWidth, |
| 1704 | ch_width); |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1705 | /* Get the current GI 160 value */ |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1706 | status = sme_cfg_get_int(hdd_ctx->hHal, |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1707 | WNI_CFG_VHT_SHORT_GI_160_AND_80_PLUS_80MHZ, |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1708 | &value); |
| 1709 | if (status != QDF_STATUS_SUCCESS) { |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1710 | hdd_err("could not get GI 80 & 160"); |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1711 | value = 0; |
| 1712 | } |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1713 | /* set the Guard interval 160MHz */ |
| 1714 | if (value && !cfg->vht_short_gi_160) { |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1715 | status = sme_cfg_set_int(hdd_ctx->hHal, |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1716 | WNI_CFG_VHT_SHORT_GI_160_AND_80_PLUS_80MHZ, |
| 1717 | cfg->vht_short_gi_160); |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1718 | |
| 1719 | if (status == QDF_STATUS_E_FAILURE) |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1720 | hdd_err("failed to set SHORT GI 160MHZ"); |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1721 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1722 | |
Sandeep Puligilla | 305d509 | 2018-04-16 14:40:50 -0700 | [diff] [blame^] | 1723 | if (cfg->vht_rx_ldpc & WMI_VHT_CAP_RX_LDPC) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1724 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXLDPC; |
Sandeep Puligilla | 305d509 | 2018-04-16 14:40:50 -0700 | [diff] [blame^] | 1725 | hdd_debug("VHT RxLDPC capability is set"); |
| 1726 | } else { |
| 1727 | /* |
| 1728 | * Get the RX LDPC capability for the NON DBS |
| 1729 | * hardware mode for 5G band |
| 1730 | */ |
| 1731 | status = wma_get_caps_for_phyidx_hwmode(&caps_per_phy, |
| 1732 | HW_MODE_DBS_NONE, CDS_BAND_5GHZ); |
| 1733 | if ((QDF_IS_STATUS_SUCCESS(status)) && |
| 1734 | (caps_per_phy.vht_5g & WMI_VHT_CAP_RX_LDPC)) { |
| 1735 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXLDPC; |
| 1736 | hdd_debug("VHT RX LDPC capability is set"); |
| 1737 | } |
| 1738 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1739 | |
| 1740 | if (cfg->vht_short_gi_80 & WMI_VHT_CAP_SGI_80MHZ) |
| 1741 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_80; |
| 1742 | if (cfg->vht_short_gi_160 & WMI_VHT_CAP_SGI_160MHZ) |
| 1743 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_160; |
| 1744 | |
| 1745 | if (cfg->vht_tx_stbc & WMI_VHT_CAP_TX_STBC) |
| 1746 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_TXSTBC; |
| 1747 | |
| 1748 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_1SS) |
| 1749 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_1; |
| 1750 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_2SS) |
| 1751 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_2; |
| 1752 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_3SS) |
| 1753 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_3; |
| 1754 | |
| 1755 | band_5g->vht_cap.cap |= |
| 1756 | (cfg->vht_max_ampdu_len_exp << |
| 1757 | IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT); |
| 1758 | |
| 1759 | if (cfg->vht_su_bformer & WMI_VHT_CAP_SU_BFORMER) |
| 1760 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE; |
| 1761 | if (cfg->vht_su_bformee & WMI_VHT_CAP_SU_BFORMEE) |
| 1762 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE; |
| 1763 | if (cfg->vht_mu_bformer & WMI_VHT_CAP_MU_BFORMER) |
| 1764 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE; |
| 1765 | if (cfg->vht_mu_bformee & WMI_VHT_CAP_MU_BFORMEE) |
| 1766 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE; |
| 1767 | |
| 1768 | if (cfg->vht_txop_ps & WMI_VHT_CAP_TXOP_PS) |
| 1769 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_VHT_TXOP_PS; |
| 1770 | |
| 1771 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1772 | |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1773 | /** |
| 1774 | * hdd_generate_macaddr_auto() - Auto-generate mac address |
| 1775 | * @hdd_ctx: Pointer to the HDD context |
| 1776 | * |
| 1777 | * Auto-generate mac address using device serial number. |
| 1778 | * Keep the first 3 bytes of OUI as before and replace |
| 1779 | * the last 3 bytes with the lower 3 bytes of serial number. |
| 1780 | * |
| 1781 | * Return: 0 for success |
| 1782 | * Non zero failure code for errors |
| 1783 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1784 | static int hdd_generate_macaddr_auto(struct hdd_context *hdd_ctx) |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1785 | { |
| 1786 | unsigned int serialno = 0; |
| 1787 | struct qdf_mac_addr mac_addr = { |
| 1788 | {0x00, 0x0A, 0xF5, 0x00, 0x00, 0x00} |
| 1789 | }; |
| 1790 | |
Yuanyuan Liu | f97e822 | 2016-09-21 10:31:38 -0700 | [diff] [blame] | 1791 | serialno = pld_socinfo_get_serial_number(hdd_ctx->parent_dev); |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1792 | if (serialno == 0) |
| 1793 | return -EINVAL; |
| 1794 | |
| 1795 | serialno &= 0x00ffffff; |
| 1796 | |
| 1797 | mac_addr.bytes[3] = (serialno >> 16) & 0xff; |
| 1798 | mac_addr.bytes[4] = (serialno >> 8) & 0xff; |
| 1799 | mac_addr.bytes[5] = serialno & 0xff; |
| 1800 | |
| 1801 | hdd_update_macaddr(hdd_ctx->config, mac_addr); |
| 1802 | return 0; |
| 1803 | } |
| 1804 | |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1805 | /** |
| 1806 | * hdd_update_ra_rate_limit() - Update RA rate limit from target |
| 1807 | * configuration to cfg_ini in HDD |
| 1808 | * @hdd_ctx: Pointer to hdd_ctx |
| 1809 | * @cfg: target configuration |
| 1810 | * |
| 1811 | * Return: None |
| 1812 | */ |
| 1813 | #ifdef FEATURE_WLAN_RA_FILTERING |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1814 | static void hdd_update_ra_rate_limit(struct hdd_context *hdd_ctx, |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1815 | struct wma_tgt_cfg *cfg) |
| 1816 | { |
| 1817 | hdd_ctx->config->IsRArateLimitEnabled = cfg->is_ra_rate_limit_enabled; |
| 1818 | } |
| 1819 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1820 | static void hdd_update_ra_rate_limit(struct hdd_context *hdd_ctx, |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1821 | struct wma_tgt_cfg *cfg) |
| 1822 | { |
| 1823 | } |
| 1824 | #endif |
| 1825 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1826 | void hdd_update_tgt_cfg(void *context, void *param) |
| 1827 | { |
Rajeev Kumar | f49dfdb | 2017-01-13 15:40:35 -0800 | [diff] [blame] | 1828 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1829 | struct hdd_context *hdd_ctx = (struct hdd_context *) context; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1830 | struct wma_tgt_cfg *cfg = param; |
| 1831 | uint8_t temp_band_cap; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1832 | struct cds_config_info *cds_cfg = cds_get_ini_config(); |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 1833 | uint8_t antenna_mode; |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 1834 | QDF_STATUS status; |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1835 | |
Dustin Brown | bd68fe1 | 2017-11-21 15:28:52 -0800 | [diff] [blame] | 1836 | ret = hdd_objmgr_create_and_store_pdev(hdd_ctx); |
| 1837 | if (ret) { |
| 1838 | hdd_err("Failed to create pdev; errno:%d", ret); |
| 1839 | QDF_BUG(0); |
Sandeep Puligilla | 1cf6ebe | 2017-04-04 14:40:27 -0700 | [diff] [blame] | 1840 | } else { |
Dustin Brown | bd68fe1 | 2017-11-21 15:28:52 -0800 | [diff] [blame] | 1841 | hdd_debug("New pdev has been created with pdev_id = %u", |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 1842 | hdd_ctx->hdd_pdev->pdev_objmgr.wlan_pdev_id); |
Amar Singhal | 410675c | 2018-01-10 12:14:21 -0800 | [diff] [blame] | 1843 | if (dispatcher_pdev_open(hdd_ctx->hdd_pdev)) { |
| 1844 | hdd_err("dispatcher pdev open failed"); |
| 1845 | QDF_BUG(0); |
| 1846 | } |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1847 | } |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 1848 | |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 1849 | ret = hdd_green_ap_update_config(hdd_ctx); |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 1850 | |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 1851 | ucfg_ipa_set_dp_handle(hdd_ctx->hdd_psoc, |
| 1852 | cds_get_context(QDF_MODULE_ID_SOC)); |
| 1853 | ucfg_ipa_set_txrx_handle(hdd_ctx->hdd_psoc, |
| 1854 | cds_get_context(QDF_MODULE_ID_TXRX)); |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 1855 | ucfg_ipa_reg_sap_xmit_cb(hdd_ctx->hdd_pdev, |
| 1856 | hdd_softap_hard_start_xmit); |
| 1857 | ucfg_ipa_reg_send_to_nw_cb(hdd_ctx->hdd_pdev, |
| 1858 | hdd_ipa_send_skb_to_network); |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 1859 | |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1860 | if (cds_cfg) { |
| 1861 | if (hdd_ctx->config->enable_sub_20_channel_width != |
| 1862 | WLAN_SUB_20_CH_WIDTH_NONE && !cfg->sub_20_support) { |
| 1863 | hdd_err("User requested sub 20 MHz channel width but unsupported by FW."); |
| 1864 | cds_cfg->sub_20_channel_width = |
| 1865 | WLAN_SUB_20_CH_WIDTH_NONE; |
| 1866 | } else { |
| 1867 | cds_cfg->sub_20_channel_width = |
| 1868 | hdd_ctx->config->enable_sub_20_channel_width; |
| 1869 | } |
| 1870 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1871 | |
| 1872 | /* first store the INI band capability */ |
| 1873 | temp_band_cap = hdd_ctx->config->nBandCapability; |
| 1874 | |
| 1875 | hdd_ctx->config->nBandCapability = cfg->band_cap; |
Vignesh Viswanathan | 731186f | 2017-09-18 13:47:37 +0530 | [diff] [blame] | 1876 | hdd_ctx->is_fils_roaming_supported = |
| 1877 | cfg->services.is_fils_roaming_supported; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1878 | |
Vignesh Viswanathan | 694e28e | 2018-01-18 20:53:57 +0530 | [diff] [blame] | 1879 | hdd_ctx->config->is_11k_offload_supported = |
| 1880 | cfg->services.is_11k_offload_supported; |
| 1881 | |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 1882 | /* |
| 1883 | * now overwrite the target band capability with INI |
| 1884 | * setting if INI setting is a subset |
| 1885 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1886 | |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1887 | if ((hdd_ctx->config->nBandCapability == BAND_ALL) && |
| 1888 | (temp_band_cap != BAND_ALL)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1889 | hdd_ctx->config->nBandCapability = temp_band_cap; |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1890 | else if ((hdd_ctx->config->nBandCapability != BAND_ALL) && |
| 1891 | (temp_band_cap != BAND_ALL) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1892 | (hdd_ctx->config->nBandCapability != temp_band_cap)) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1893 | hdd_warn("ini BandCapability not supported by the target"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1894 | } |
| 1895 | |
Amar Singhal | 58b45ef | 2017-08-01 13:43:54 -0700 | [diff] [blame] | 1896 | hdd_ctx->curr_band = hdd_ctx->config->nBandCapability; |
| 1897 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 1898 | if (!cds_is_driver_recovering() || cds_is_driver_in_bad_state()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1899 | hdd_ctx->reg.reg_domain = cfg->reg_domain; |
| 1900 | hdd_ctx->reg.eeprom_rd_ext = cfg->eeprom_rd_ext; |
| 1901 | } |
| 1902 | |
| 1903 | /* This can be extended to other configurations like ht, vht cap... */ |
| 1904 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 1905 | if (!qdf_is_macaddr_zero(&cfg->hw_macaddr)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1906 | hdd_update_macaddr(hdd_ctx->config, cfg->hw_macaddr); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 1907 | hdd_ctx->update_mac_addr_to_fw = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1908 | } else { |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1909 | static struct qdf_mac_addr default_mac_addr = { |
| 1910 | {0x00, 0x0A, 0xF5, 0x89, 0x89, 0xFF} |
| 1911 | }; |
| 1912 | if (qdf_is_macaddr_equal(&hdd_ctx->config->intfMacAddr[0], |
| 1913 | &default_mac_addr)) { |
| 1914 | if (hdd_generate_macaddr_auto(hdd_ctx) != 0) |
| 1915 | hdd_err("Fail to auto-generate MAC, using MAC from ini file " |
| 1916 | MAC_ADDRESS_STR, |
| 1917 | MAC_ADDR_ARRAY(hdd_ctx->config-> |
| 1918 | intfMacAddr[0].bytes)); |
| 1919 | } else { |
| 1920 | hdd_err("Invalid MAC passed from target, using MAC from ini file " |
| 1921 | MAC_ADDRESS_STR, |
| 1922 | MAC_ADDR_ARRAY(hdd_ctx->config-> |
| 1923 | intfMacAddr[0].bytes)); |
| 1924 | } |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 1925 | hdd_ctx->update_mac_addr_to_fw = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1926 | } |
| 1927 | |
| 1928 | hdd_ctx->target_fw_version = cfg->target_fw_version; |
Sandeep Puligilla | 3d6a8e2 | 2016-10-11 18:57:14 -0700 | [diff] [blame] | 1929 | hdd_ctx->target_fw_vers_ext = cfg->target_fw_vers_ext; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1930 | |
| 1931 | hdd_ctx->max_intf_count = cfg->max_intf_count; |
| 1932 | |
Jeff Johnson | c875e24 | 2016-09-23 18:12:34 -0700 | [diff] [blame] | 1933 | hdd_lpass_target_config(hdd_ctx, cfg); |
Ryan Hsu | 3c8f79f | 2015-12-02 16:45:09 -0800 | [diff] [blame] | 1934 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1935 | hdd_ctx->ap_arpns_support = cfg->ap_arpns_support; |
| 1936 | hdd_update_tgt_services(hdd_ctx, &cfg->services); |
| 1937 | |
| 1938 | hdd_update_tgt_ht_cap(hdd_ctx, &cfg->ht_cap); |
| 1939 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1940 | hdd_update_tgt_vht_cap(hdd_ctx, &cfg->vht_cap); |
Krishna Kumaar Natarajan | ed1efd9 | 2016-09-24 18:05:47 -0700 | [diff] [blame] | 1941 | if (cfg->services.en_11ax) { |
| 1942 | hdd_info("11AX: 11ax is enabled - update HDD config"); |
| 1943 | hdd_update_tgt_he_cap(hdd_ctx, cfg); |
| 1944 | } |
Tushnim Bhattacharyya | f44a9d8 | 2016-07-05 10:52:06 -0700 | [diff] [blame] | 1945 | |
| 1946 | hdd_update_vdev_nss(hdd_ctx); |
| 1947 | |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1948 | hdd_update_hw_dbs_capable(hdd_ctx); |
| 1949 | |
Krishna Kumaar Natarajan | 1ae4911 | 2015-11-24 21:43:22 -0800 | [diff] [blame] | 1950 | hdd_ctx->config->fine_time_meas_cap &= cfg->fine_time_measurement_cap; |
Krunal Soni | e353194 | 2016-04-12 17:43:53 -0700 | [diff] [blame] | 1951 | hdd_ctx->fine_time_meas_cap_target = cfg->fine_time_measurement_cap; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1952 | hdd_debug("fine_time_meas_cap: 0x%x", |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 1953 | hdd_ctx->config->fine_time_meas_cap); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 1954 | |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 1955 | antenna_mode = (hdd_ctx->config->enable2x2 == 0x01) ? |
| 1956 | HDD_ANTENNA_MODE_2X2 : HDD_ANTENNA_MODE_1X1; |
| 1957 | hdd_update_smps_antenna_mode(hdd_ctx, antenna_mode); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1958 | hdd_debug("Init current antenna mode: %d", |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 1959 | hdd_ctx->current_antenna_mode); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 1960 | |
Rajeev Kumar | dd3bc60 | 2016-08-16 14:21:05 -0700 | [diff] [blame] | 1961 | hdd_ctx->bpf_enabled = (cfg->bpf_enabled && |
| 1962 | hdd_ctx->config->bpf_packet_filter_enable); |
Rajeev Kumar Sirasanagandla | 996e529 | 2016-11-22 21:20:33 +0530 | [diff] [blame] | 1963 | hdd_ctx->rcpi_enabled = cfg->rcpi_enabled; |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1964 | hdd_update_ra_rate_limit(hdd_ctx, cfg); |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 1965 | |
Nachiket Kukade | 8b4bfd8 | 2017-05-25 18:34:48 +0530 | [diff] [blame] | 1966 | if ((hdd_ctx->config->txBFCsnValue > |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 1967 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED_FW_DEF) && |
| 1968 | !cfg->tx_bfee_8ss_enabled) |
Nachiket Kukade | 8b4bfd8 | 2017-05-25 18:34:48 +0530 | [diff] [blame] | 1969 | hdd_ctx->config->txBFCsnValue = |
| 1970 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED_FW_DEF; |
| 1971 | |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 1972 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1973 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED, |
| 1974 | hdd_ctx->config->txBFCsnValue); |
| 1975 | if (QDF_IS_STATUS_ERROR(status)) |
Nachiket Kukade | 8b4bfd8 | 2017-05-25 18:34:48 +0530 | [diff] [blame] | 1976 | hdd_err("fw update WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED to CFG fails"); |
| 1977 | |
| 1978 | |
| 1979 | 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] | 1980 | cfg->bpf_enabled, hdd_ctx->config->bpf_packet_filter_enable, |
| 1981 | cfg->tx_bfee_8ss_enabled, hdd_ctx->config->txBFCsnValue); |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1982 | |
| 1983 | /* |
| 1984 | * Update txBFCsnValue and NumSoundingDim values to vhtcap in wiphy |
| 1985 | */ |
| 1986 | hdd_update_wiphy_vhtcap(hdd_ctx); |
Manjeet Singh | 70d3d93 | 2016-12-20 20:41:10 +0530 | [diff] [blame] | 1987 | |
Rajeev Kumar Sirasanagandla | 4787300 | 2016-09-09 13:46:09 +0530 | [diff] [blame] | 1988 | hdd_ctx->wmi_max_len = cfg->wmi_max_len; |
| 1989 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1990 | /* |
| 1991 | * This needs to be done after HDD pdev is created and stored since |
| 1992 | * it will access the HDD pdev object lock. |
| 1993 | */ |
| 1994 | hdd_runtime_suspend_context_init(hdd_ctx); |
| 1995 | |
Deepak Dhamdhere | 13230d3 | 2016-05-26 00:46:53 -0700 | [diff] [blame] | 1996 | /* Configure NAN datapath features */ |
| 1997 | hdd_nan_datapath_target_config(hdd_ctx, cfg); |
Arif Hussain | 759a023 | 2017-03-20 13:17:18 -0700 | [diff] [blame] | 1998 | hdd_ctx->dfs_cac_offload = cfg->dfs_cac_offload; |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 1999 | hdd_ctx->lte_coex_ant_share = cfg->services.lte_coex_ant_share; |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 2000 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_OBSS_DETECTION_OFFLOAD, |
| 2001 | cfg->obss_detection_offloaded); |
| 2002 | if (QDF_IS_STATUS_ERROR(status)) |
| 2003 | hdd_err("Couldn't pass WNI_CFG_OBSS_DETECTION_OFFLOAD to CFG"); |
Arif Hussain | 05fb487 | 2018-01-03 16:02:55 -0800 | [diff] [blame] | 2004 | |
| 2005 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 2006 | WNI_CFG_OBSS_COLOR_COLLISION_OFFLOAD, |
| 2007 | cfg->obss_color_collision_offloaded); |
| 2008 | if (QDF_IS_STATUS_ERROR(status)) |
| 2009 | hdd_err("Failed to set WNI_CFG_OBSS_COLOR_COLLISION_OFFLOAD"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2010 | } |
| 2011 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2012 | bool hdd_dfs_indicate_radar(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2013 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2014 | struct hdd_adapter *adapter; |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 2015 | struct hdd_ap_ctx *ap_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2016 | |
Jiachao Wu | f610d91 | 2018-01-23 17:47:32 +0800 | [diff] [blame] | 2017 | if (!hdd_ctx) { |
| 2018 | hdd_info("Couldn't get hdd_ctx"); |
| 2019 | return true; |
| 2020 | } |
| 2021 | |
| 2022 | if (hdd_ctx->config->disableDFSChSwitch) { |
Jeff Johnson | 36e74c4 | 2017-09-18 08:15:42 -0700 | [diff] [blame] | 2023 | hdd_info("skip tx block hdd_ctx=%pK, disableDFSChSwitch=%d", |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2024 | hdd_ctx, hdd_ctx->config->disableDFSChSwitch); |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 2025 | return true; |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2026 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2027 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 2028 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2029 | ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 2030 | |
| 2031 | if ((QDF_SAP_MODE == adapter->device_mode || |
| 2032 | QDF_P2P_GO_MODE == adapter->device_mode) && |
| 2033 | (wlan_reg_is_dfs_ch(hdd_ctx->hdd_pdev, |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 2034 | ap_ctx->operating_channel))) { |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2035 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->dfs_cac_block_tx = |
| 2036 | true; |
| 2037 | hdd_info("tx blocked for session: %d", |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 2038 | adapter->session_id); |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 2039 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2040 | } |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 2041 | |
| 2042 | return true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2043 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2044 | |
| 2045 | /** |
| 2046 | * hdd_is_valid_mac_address() - validate MAC address |
| 2047 | * @pMacAddr: Pointer to the input MAC address |
| 2048 | * |
| 2049 | * This function validates whether the given MAC address is valid or not |
| 2050 | * Expected MAC address is of the format XX:XX:XX:XX:XX:XX |
| 2051 | * where X is the hexa decimal digit character and separated by ':' |
| 2052 | * This algorithm works even if MAC address is not separated by ':' |
| 2053 | * |
| 2054 | * This code checks given input string mac contains exactly 12 hexadecimal |
| 2055 | * digits and a separator colon : appears in the input string only after |
| 2056 | * an even number of hex digits. |
| 2057 | * |
| 2058 | * Return: 1 for valid and 0 for invalid |
| 2059 | */ |
| 2060 | bool hdd_is_valid_mac_address(const uint8_t *pMacAddr) |
| 2061 | { |
| 2062 | int xdigit = 0; |
| 2063 | int separator = 0; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 2064 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2065 | while (*pMacAddr) { |
| 2066 | if (isxdigit(*pMacAddr)) { |
| 2067 | xdigit++; |
| 2068 | } else if (':' == *pMacAddr) { |
| 2069 | if (0 == xdigit || ((xdigit / 2) - 1) != separator) |
| 2070 | break; |
| 2071 | |
| 2072 | ++separator; |
| 2073 | } else { |
| 2074 | /* Invalid MAC found */ |
| 2075 | return 0; |
| 2076 | } |
| 2077 | ++pMacAddr; |
| 2078 | } |
| 2079 | return xdigit == 12 && (separator == 5 || separator == 0); |
| 2080 | } |
| 2081 | |
| 2082 | /** |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 2083 | * hdd_mon_mode_ether_setup() - Update monitor mode struct net_device. |
| 2084 | * @dev: Handle to struct net_device to be updated. |
| 2085 | * |
| 2086 | * Return: None |
| 2087 | */ |
| 2088 | static void hdd_mon_mode_ether_setup(struct net_device *dev) |
| 2089 | { |
| 2090 | dev->header_ops = NULL; |
| 2091 | dev->type = ARPHRD_IEEE80211_RADIOTAP; |
| 2092 | dev->hard_header_len = ETH_HLEN; |
| 2093 | dev->mtu = ETH_DATA_LEN; |
| 2094 | dev->addr_len = ETH_ALEN; |
| 2095 | dev->tx_queue_len = 1000; /* Ethernet wants good queues */ |
| 2096 | dev->flags = IFF_BROADCAST|IFF_MULTICAST; |
| 2097 | dev->priv_flags |= IFF_TX_SKB_SHARING; |
| 2098 | |
| 2099 | memset(dev->broadcast, 0xFF, ETH_ALEN); |
| 2100 | } |
| 2101 | |
| 2102 | /** |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2103 | * __hdd__mon_open() - HDD Open function |
| 2104 | * @dev: Pointer to net_device structure |
| 2105 | * |
| 2106 | * This is called in response to ifconfig up |
| 2107 | * |
| 2108 | * Return: 0 for success; non-zero for failure |
| 2109 | */ |
| 2110 | static int __hdd_mon_open(struct net_device *dev) |
| 2111 | { |
| 2112 | int ret; |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2113 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2114 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2115 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 2116 | hdd_enter_dev(dev); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2117 | |
| 2118 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 2119 | if (ret) |
| 2120 | return ret; |
| 2121 | |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 2122 | hdd_mon_mode_ether_setup(dev); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2123 | |
| 2124 | if (con_mode == QDF_GLOBAL_MONITOR_MODE) { |
| 2125 | ret = hdd_wlan_start_modules(hdd_ctx, adapter, false); |
| 2126 | if (ret) { |
| 2127 | hdd_err("Failed to start WLAN modules return"); |
| 2128 | return ret; |
| 2129 | } |
| 2130 | hdd_err("hdd_wlan_start_modules() successful !"); |
| 2131 | |
| 2132 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 2133 | ret = hdd_start_adapter(adapter); |
| 2134 | if (ret) { |
| 2135 | hdd_err("Failed to start adapter :%d", |
| 2136 | adapter->device_mode); |
| 2137 | return ret; |
| 2138 | } |
| 2139 | hdd_err("hdd_start_adapters() successful !"); |
| 2140 | } |
| 2141 | set_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 2142 | } |
| 2143 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2144 | ret = hdd_set_mon_rx_cb(dev); |
Ravi Joshi | 4f09595 | 2017-06-29 15:39:19 -0700 | [diff] [blame] | 2145 | |
| 2146 | if (!ret) |
| 2147 | ret = hdd_enable_monitor_mode(dev); |
| 2148 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2149 | return ret; |
| 2150 | } |
| 2151 | |
| 2152 | /** |
| 2153 | * hdd_mon_open() - Wrapper function for __hdd_mon_open to protect it from SSR |
| 2154 | * @dev: Pointer to net_device structure |
| 2155 | * |
| 2156 | * This is called in response to ifconfig up |
| 2157 | * |
| 2158 | * Return: 0 for success; non-zero for failure |
| 2159 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2160 | static int hdd_mon_open(struct net_device *dev) |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2161 | { |
| 2162 | int ret; |
| 2163 | |
| 2164 | cds_ssr_protect(__func__); |
| 2165 | ret = __hdd_mon_open(dev); |
| 2166 | cds_ssr_unprotect(__func__); |
| 2167 | |
| 2168 | return ret; |
| 2169 | } |
| 2170 | |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2171 | static QDF_STATUS |
| 2172 | wlan_hdd_update_dbs_scan_and_fw_mode_config(void) |
| 2173 | { |
| 2174 | struct policy_mgr_dual_mac_config cfg = {0}; |
| 2175 | QDF_STATUS status; |
| 2176 | uint32_t channel_select_logic_conc; |
| 2177 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 2178 | |
| 2179 | if (!hdd_ctx) { |
| 2180 | hdd_err("HDD context is NULL"); |
| 2181 | return QDF_STATUS_E_FAILURE; |
| 2182 | } |
| 2183 | |
| 2184 | |
| 2185 | if (!policy_mgr_is_hw_dbs_capable(hdd_ctx->hdd_psoc)) |
| 2186 | return QDF_STATUS_SUCCESS; |
| 2187 | |
| 2188 | cfg.scan_config = 0; |
| 2189 | cfg.fw_mode_config = 0; |
| 2190 | cfg.set_dual_mac_cb = policy_mgr_soc_set_dual_mac_cfg_cb; |
| 2191 | |
| 2192 | channel_select_logic_conc = hdd_ctx->config-> |
| 2193 | channel_select_logic_conc; |
| 2194 | |
| 2195 | if (hdd_ctx->config->dual_mac_feature_disable != |
| 2196 | DISABLE_DBS_CXN_AND_SCAN) { |
| 2197 | status = policy_mgr_get_updated_scan_and_fw_mode_config( |
| 2198 | hdd_ctx->hdd_psoc, &cfg.scan_config, |
| 2199 | &cfg.fw_mode_config, |
| 2200 | hdd_ctx->config->dual_mac_feature_disable, |
| 2201 | channel_select_logic_conc); |
| 2202 | |
| 2203 | if (status != QDF_STATUS_SUCCESS) { |
| 2204 | hdd_err("wma_get_updated_scan_and_fw_mode_config failed %d", |
| 2205 | status); |
| 2206 | return status; |
| 2207 | } |
| 2208 | } |
| 2209 | |
| 2210 | hdd_debug("send scan_cfg: 0x%x fw_mode_cfg: 0x%x to fw", |
| 2211 | cfg.scan_config, cfg.fw_mode_config); |
| 2212 | |
| 2213 | status = sme_soc_set_dual_mac_config(cfg); |
| 2214 | if (status != QDF_STATUS_SUCCESS) { |
| 2215 | hdd_err("sme_soc_set_dual_mac_config failed %d", status); |
| 2216 | return status; |
| 2217 | } |
| 2218 | |
| 2219 | return QDF_STATUS_SUCCESS; |
| 2220 | } |
| 2221 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2222 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2223 | * hdd_start_adapter() - Wrapper function for device specific adapter |
| 2224 | * @adapter: pointer to HDD adapter |
| 2225 | * |
| 2226 | * This function is called to start the device specific adapter for |
| 2227 | * the mode passed in the adapter's device_mode. |
| 2228 | * |
| 2229 | * Return: 0 for success; non-zero for failure |
| 2230 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2231 | int hdd_start_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2232 | { |
| 2233 | |
| 2234 | int ret; |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 2235 | enum QDF_OPMODE device_mode = adapter->device_mode; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2236 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 2237 | hdd_enter_dev(adapter->dev); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2238 | hdd_debug("Start_adapter for mode : %d", adapter->device_mode); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2239 | |
| 2240 | switch (device_mode) { |
| 2241 | case QDF_P2P_CLIENT_MODE: |
| 2242 | case QDF_P2P_DEVICE_MODE: |
| 2243 | case QDF_OCB_MODE: |
| 2244 | case QDF_STA_MODE: |
| 2245 | case QDF_MONITOR_MODE: |
| 2246 | ret = hdd_start_station_adapter(adapter); |
| 2247 | if (ret) |
| 2248 | goto err_start_adapter; |
| 2249 | break; |
| 2250 | case QDF_P2P_GO_MODE: |
| 2251 | case QDF_SAP_MODE: |
| 2252 | ret = hdd_start_ap_adapter(adapter); |
| 2253 | if (ret) |
| 2254 | goto err_start_adapter; |
| 2255 | break; |
Arun Khandavalli | b2f6c26 | 2016-08-18 19:07:19 +0530 | [diff] [blame] | 2256 | case QDF_IBSS_MODE: |
| 2257 | /* |
| 2258 | * For IBSS interface is initialized as part of |
| 2259 | * hdd_init_station_mode() |
| 2260 | */ |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2261 | goto exit_with_success; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2262 | case QDF_FTM_MODE: |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2263 | /* vdevs are dynamically managed by firmware in FTM */ |
| 2264 | goto exit_with_success; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2265 | default: |
| 2266 | hdd_err("Invalid session type %d", device_mode); |
| 2267 | QDF_ASSERT(0); |
| 2268 | goto err_start_adapter; |
| 2269 | } |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2270 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2271 | if (hdd_set_fw_params(adapter)) |
| 2272 | hdd_err("Failed to set the FW params for the adapter!"); |
| 2273 | |
| 2274 | /* |
| 2275 | * Action frame registered in one adapter which will |
| 2276 | * applicable to all interfaces |
| 2277 | */ |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 2278 | ret = wlan_hdd_cfg80211_register_frames(adapter); |
| 2279 | if (ret < 0) { |
| 2280 | hdd_err("Failed to register frames - ret %d", ret); |
| 2281 | goto err_start_adapter; |
| 2282 | } |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2283 | wlan_hdd_update_dbs_scan_and_fw_mode_config(); |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 2284 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2285 | exit_with_success: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2286 | hdd_exit(); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2287 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2288 | return 0; |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2289 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2290 | err_start_adapter: |
| 2291 | return -EINVAL; |
| 2292 | } |
| 2293 | |
| 2294 | /** |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 2295 | * hdd_enable_power_management() - API to Enable Power Management |
| 2296 | * |
| 2297 | * API invokes Bus Interface Layer power management functionality |
| 2298 | * |
| 2299 | * Return: None |
| 2300 | */ |
| 2301 | static void hdd_enable_power_management(void) |
| 2302 | { |
| 2303 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2304 | |
| 2305 | if (!hif_ctx) { |
| 2306 | hdd_err("Bus Interface Context is Invalid"); |
| 2307 | return; |
| 2308 | } |
| 2309 | |
| 2310 | hif_enable_power_management(hif_ctx, cds_is_packet_log_enabled()); |
| 2311 | } |
| 2312 | |
| 2313 | /** |
| 2314 | * hdd_disable_power_management() - API to disable Power Management |
| 2315 | * |
| 2316 | * API disable Bus Interface Layer Power management functionality |
| 2317 | * |
| 2318 | * Return: None |
| 2319 | */ |
| 2320 | static void hdd_disable_power_management(void) |
| 2321 | { |
| 2322 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2323 | |
| 2324 | if (!hif_ctx) { |
| 2325 | hdd_err("Bus Interface Context is Invalid"); |
| 2326 | return; |
| 2327 | } |
| 2328 | |
| 2329 | hif_disable_power_management(hif_ctx); |
| 2330 | } |
| 2331 | |
| 2332 | /** |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2333 | * hdd_update_hw_sw_info() - API to update the HW/SW information |
| 2334 | * |
| 2335 | * API to update the HW and SW information in the driver |
| 2336 | * |
| 2337 | * Return: None |
| 2338 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2339 | static void hdd_update_hw_sw_info(struct hdd_context *hdd_ctx) |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2340 | { |
| 2341 | void *hif_sc; |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2342 | size_t target_hw_name_len; |
| 2343 | const char *target_hw_name; |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2344 | |
| 2345 | hif_sc = cds_get_context(QDF_MODULE_ID_HIF); |
| 2346 | if (!hif_sc) { |
| 2347 | hdd_err("HIF context is NULL"); |
| 2348 | return; |
| 2349 | } |
| 2350 | |
| 2351 | /* |
| 2352 | * target hw version/revision would only be retrieved after firmware |
| 2353 | * download |
| 2354 | */ |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2355 | hif_get_hw_info(hif_sc, |
| 2356 | &hdd_ctx->target_hw_version, |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2357 | &hdd_ctx->target_hw_revision, |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2358 | &target_hw_name); |
| 2359 | |
| 2360 | if (hdd_ctx->target_hw_name) |
| 2361 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 2362 | |
| 2363 | target_hw_name_len = strlen(target_hw_name) + 1; |
| 2364 | hdd_ctx->target_hw_name = qdf_mem_malloc(target_hw_name_len); |
| 2365 | if (hdd_ctx->target_hw_name) |
| 2366 | qdf_mem_copy(hdd_ctx->target_hw_name, target_hw_name, |
| 2367 | target_hw_name_len); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2368 | |
| 2369 | /* Get the wlan hw/fw version */ |
| 2370 | hdd_wlan_get_version(hdd_ctx, NULL, NULL); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2371 | } |
| 2372 | |
| 2373 | /** |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2374 | * hdd_update_cds_ac_specs_params() - update cds ac_specs params |
| 2375 | * @hdd_ctx: Pointer to hdd context |
| 2376 | * |
| 2377 | * Return: none |
| 2378 | */ |
| 2379 | static void |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2380 | hdd_update_cds_ac_specs_params(struct hdd_context *hdd_ctx) |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2381 | { |
| 2382 | uint8_t num_entries = 0; |
| 2383 | uint8_t tx_sched_wrr_param[TX_SCHED_WRR_PARAMS_NUM]; |
| 2384 | uint8_t *tx_sched_wrr_ac; |
| 2385 | int i; |
| 2386 | cds_context_type *cds_ctx; |
| 2387 | |
| 2388 | if (NULL == hdd_ctx) |
| 2389 | return; |
| 2390 | |
| 2391 | if (NULL == hdd_ctx->config) { |
| 2392 | /* Do nothing if hdd_ctx is invalid */ |
| 2393 | hdd_err("%s: Warning: hdd_ctx->cfg_ini is NULL", __func__); |
| 2394 | return; |
| 2395 | } |
| 2396 | |
| 2397 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 2398 | |
| 2399 | if (!cds_ctx) { |
| 2400 | hdd_err("Invalid CDS Context"); |
| 2401 | return; |
| 2402 | } |
| 2403 | |
| 2404 | for (i = 0; i < OL_TX_NUM_WMM_AC; i++) { |
| 2405 | switch (i) { |
| 2406 | case OL_TX_WMM_AC_BE: |
| 2407 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_be; |
| 2408 | break; |
| 2409 | case OL_TX_WMM_AC_BK: |
| 2410 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_bk; |
| 2411 | break; |
| 2412 | case OL_TX_WMM_AC_VI: |
| 2413 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_vi; |
| 2414 | break; |
| 2415 | case OL_TX_WMM_AC_VO: |
| 2416 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_vo; |
| 2417 | break; |
| 2418 | default: |
| 2419 | tx_sched_wrr_ac = NULL; |
| 2420 | break; |
| 2421 | } |
| 2422 | |
| 2423 | hdd_string_to_u8_array(tx_sched_wrr_ac, |
| 2424 | tx_sched_wrr_param, |
| 2425 | &num_entries, |
| 2426 | sizeof(tx_sched_wrr_param)); |
| 2427 | |
| 2428 | if (num_entries == TX_SCHED_WRR_PARAMS_NUM) { |
| 2429 | cds_ctx->ac_specs[i].wrr_skip_weight = |
| 2430 | tx_sched_wrr_param[0]; |
| 2431 | cds_ctx->ac_specs[i].credit_threshold = |
| 2432 | tx_sched_wrr_param[1]; |
| 2433 | cds_ctx->ac_specs[i].send_limit = |
| 2434 | tx_sched_wrr_param[2]; |
| 2435 | cds_ctx->ac_specs[i].credit_reserve = |
| 2436 | tx_sched_wrr_param[3]; |
| 2437 | cds_ctx->ac_specs[i].discard_weight = |
| 2438 | tx_sched_wrr_param[4]; |
| 2439 | } |
| 2440 | |
| 2441 | num_entries = 0; |
| 2442 | } |
| 2443 | } |
| 2444 | |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 2445 | #ifdef IPA_OFFLOAD |
| 2446 | /** |
| 2447 | * hdd_update_ipa_component_config() - update ipa config |
| 2448 | * @hdd_ctx: Pointer to hdd context |
| 2449 | * |
| 2450 | * Return: none |
| 2451 | */ |
| 2452 | static void hdd_update_ipa_component_config(struct hdd_context *hdd_ctx) |
| 2453 | { |
| 2454 | struct hdd_config *cfg = hdd_ctx->config; |
| 2455 | struct wlan_ipa_config ipa_cfg; |
| 2456 | |
| 2457 | ipa_cfg.ipa_config = cfg->IpaConfig; |
| 2458 | ipa_cfg.desc_size = cfg->IpaDescSize; |
| 2459 | ipa_cfg.txbuf_count = cfg->IpaUcTxBufCount; |
| 2460 | ipa_cfg.bus_bw_high = cfg->busBandwidthHighThreshold; |
| 2461 | ipa_cfg.bus_bw_medium = cfg->busBandwidthMediumThreshold; |
| 2462 | ipa_cfg.bus_bw_low = cfg->busBandwidthLowThreshold; |
| 2463 | ipa_cfg.ipa_bw_high = cfg->IpaHighBandwidthMbps; |
| 2464 | ipa_cfg.ipa_bw_medium = cfg->IpaMediumBandwidthMbps; |
| 2465 | ipa_cfg.ipa_bw_low = cfg->IpaLowBandwidthMbps; |
| 2466 | |
| 2467 | ucfg_ipa_update_config(&ipa_cfg); |
| 2468 | } |
| 2469 | #else |
| 2470 | static void hdd_update_ipa_component_config(struct hdd_context *hdd_ctx) |
| 2471 | { |
| 2472 | } |
| 2473 | #endif |
| 2474 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2475 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2476 | static enum policy_mgr_con_mode wlan_hdd_get_mode_for_non_connected_vdev( |
| 2477 | struct wlan_objmgr_psoc *psoc, uint8_t vdev_id) |
| 2478 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2479 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2480 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2481 | |
| 2482 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 2483 | if (!adapter) { |
| 2484 | hdd_err("Adapter is NULL"); |
| 2485 | return PM_MAX_NUM_OF_MODE; |
| 2486 | } |
| 2487 | |
| 2488 | return policy_mgr_convert_device_mode_to_qdf_type( |
| 2489 | adapter->device_mode); |
| 2490 | } |
| 2491 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2492 | static void hdd_register_policy_manager_callback( |
| 2493 | struct wlan_objmgr_psoc *psoc) |
| 2494 | { |
| 2495 | struct policy_mgr_hdd_cbacks hdd_cbacks; |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 2496 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2497 | hdd_cbacks.sap_restart_chan_switch_cb = |
Jeff Johnson | 2381294 | 2017-10-06 11:33:55 -0700 | [diff] [blame] | 2498 | hdd_sap_restart_chan_switch_cb; |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2499 | hdd_cbacks.wlan_hdd_get_channel_for_sap_restart = |
| 2500 | wlan_hdd_get_channel_for_sap_restart; |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2501 | hdd_cbacks.get_mode_for_non_connected_vdev = |
| 2502 | wlan_hdd_get_mode_for_non_connected_vdev; |
Yeshwanth Sriram Guntuka | 469f957 | 2018-02-12 13:28:22 +0530 | [diff] [blame] | 2503 | hdd_cbacks.hdd_get_device_mode = hdd_get_device_mode; |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2504 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2505 | if (QDF_STATUS_SUCCESS != |
| 2506 | policy_mgr_register_hdd_cb(psoc, &hdd_cbacks)) { |
| 2507 | hdd_err("HDD callback registration with policy manager failed"); |
| 2508 | } |
| 2509 | } |
| 2510 | #else |
| 2511 | static void hdd_register_policy_manager_callback( |
| 2512 | struct wlan_objmgr_psoc *psoc) |
| 2513 | { |
| 2514 | } |
| 2515 | #endif |
| 2516 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2517 | static void hdd_nan_register_callbacks(struct hdd_context *hdd_ctx) |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2518 | { |
| 2519 | struct nan_callbacks cb_obj = {0}; |
| 2520 | |
| 2521 | cb_obj.ndi_open = hdd_ndi_open; |
| 2522 | cb_obj.ndi_close = hdd_ndi_close; |
| 2523 | cb_obj.ndi_start = hdd_ndi_start; |
| 2524 | cb_obj.ndi_delete = hdd_ndi_delete; |
| 2525 | cb_obj.drv_ndi_create_rsp_handler = hdd_ndi_drv_ndi_create_rsp_handler; |
| 2526 | cb_obj.drv_ndi_delete_rsp_handler = hdd_ndi_drv_ndi_delete_rsp_handler; |
| 2527 | |
Naveen Rawat | 37f62c8 | 2017-03-26 22:24:43 -0700 | [diff] [blame] | 2528 | cb_obj.new_peer_ind = hdd_ndp_new_peer_handler; |
| 2529 | cb_obj.get_peer_idx = hdd_ndp_get_peer_idx; |
Naveen Rawat | b3143ea | 2017-03-26 22:25:46 -0700 | [diff] [blame] | 2530 | cb_obj.peer_departed_ind = hdd_ndp_peer_departed_handler; |
Naveen Rawat | 37f62c8 | 2017-03-26 22:24:43 -0700 | [diff] [blame] | 2531 | |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2532 | os_if_nan_register_hdd_callbacks(hdd_ctx->hdd_psoc, &cb_obj); |
| 2533 | } |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2534 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2535 | #ifdef CONFIG_LEAK_DETECTION |
Dustin Brown | 4c5b990 | 2017-12-19 11:17:19 -0800 | [diff] [blame] | 2536 | /** |
| 2537 | * hdd_check_for_leaks() - Perform runtime memory leak checks |
| 2538 | * |
| 2539 | * This API triggers runtime memory leak detection. This feature enforces the |
| 2540 | * policy that any memory allocated at runtime must also be released at runtime. |
| 2541 | * |
| 2542 | * Allocating memory at runtime and releasing it at unload is effectively a |
| 2543 | * memory leak for configurations which never unload (e.g. LONU, statically |
| 2544 | * compiled driver). Such memory leaks are NOT false positives, and must be |
| 2545 | * fixed. |
| 2546 | * |
| 2547 | * Return: None |
| 2548 | */ |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2549 | static void hdd_check_for_leaks(void) |
| 2550 | { |
Dustin Brown | 4c5b990 | 2017-12-19 11:17:19 -0800 | [diff] [blame] | 2551 | /* DO NOT REMOVE these checks; for false positives, read above first */ |
| 2552 | |
Dustin Brown | 677e086 | 2017-10-10 16:30:09 -0700 | [diff] [blame] | 2553 | qdf_mc_timer_check_for_leaks(); |
Dustin Brown | 8e71150 | 2017-12-07 16:49:11 -0800 | [diff] [blame] | 2554 | qdf_nbuf_map_check_for_leaks(); |
Dustin Brown | e6b9d5a | 2017-12-14 15:18:49 -0800 | [diff] [blame] | 2555 | qdf_mem_check_for_leaks(); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2556 | } |
| 2557 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2558 | #define hdd_debug_domain_set(domain) qdf_debug_domain_set(domain) |
| 2559 | #else |
| 2560 | static inline void hdd_check_for_leaks(void) {} |
| 2561 | |
| 2562 | #define hdd_debug_domain_set(domain) |
| 2563 | #endif /* CONFIG_LEAK_DETECTION */ |
| 2564 | |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2565 | /** |
Paul Zhang | e03cf4c | 2018-01-19 18:33:22 +0800 | [diff] [blame] | 2566 | * hdd_update_country_code - Update country code |
| 2567 | * @hdd_ctx: HDD context |
| 2568 | * |
| 2569 | * Update country code based on module parameter country_code |
| 2570 | * |
| 2571 | * Return: 0 on success and errno on failure |
| 2572 | */ |
| 2573 | static int hdd_update_country_code(struct hdd_context *hdd_ctx) |
| 2574 | { |
| 2575 | if (!country_code) |
| 2576 | return 0; |
| 2577 | |
| 2578 | return hdd_reg_set_country(hdd_ctx, country_code); |
| 2579 | } |
| 2580 | |
| 2581 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2582 | * hdd_wlan_start_modules() - Single driver state machine for starting modules |
| 2583 | * @hdd_ctx: HDD context |
| 2584 | * @adapter: HDD adapter |
| 2585 | * @reinit: flag to indicate from SSR or normal path |
| 2586 | * |
| 2587 | * This function maintains the driver state machine it will be invoked from |
| 2588 | * startup, reinit and change interface. Depending on the driver state shall |
| 2589 | * perform the opening of the modules. |
| 2590 | * |
| 2591 | * Return: 0 for success; non-zero for failure |
| 2592 | */ |
Jeff Johnson | 60dc2b1 | 2017-09-28 14:56:02 -0700 | [diff] [blame] | 2593 | int hdd_wlan_start_modules(struct hdd_context *hdd_ctx, |
| 2594 | struct hdd_adapter *adapter, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2595 | bool reinit) |
| 2596 | { |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 2597 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2598 | qdf_device_t qdf_dev; |
| 2599 | QDF_STATUS status; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2600 | bool unint = false; |
| 2601 | void *hif_ctx; |
| 2602 | |
Jeff Johnson | 60dc2b1 | 2017-09-28 14:56:02 -0700 | [diff] [blame] | 2603 | hdd_debug("state:%d reinit:%d", hdd_ctx->driver_status, reinit); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2604 | |
| 2605 | qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 2606 | if (!qdf_dev) { |
| 2607 | hdd_err("QDF Device Context is Invalid return"); |
| 2608 | return -EINVAL; |
| 2609 | } |
| 2610 | |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 2611 | qdf_cancel_delayed_work(&hdd_ctx->iface_idle_work); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2612 | |
Dustin Brown | 1fe30a8 | 2017-10-03 16:13:36 -0700 | [diff] [blame] | 2613 | mutex_lock(&hdd_ctx->iface_change_lock); |
Arun Khandavalli | 5a62a82 | 2017-11-14 19:43:00 +0530 | [diff] [blame] | 2614 | if (hdd_ctx->driver_status == DRIVER_MODULES_ENABLED) { |
| 2615 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 2616 | hdd_info("Driver modules already Enabled"); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2617 | hdd_exit(); |
Arun Khandavalli | 5a62a82 | 2017-11-14 19:43:00 +0530 | [diff] [blame] | 2618 | return 0; |
| 2619 | } |
| 2620 | |
Dustin Brown | 1fe30a8 | 2017-10-03 16:13:36 -0700 | [diff] [blame] | 2621 | hdd_ctx->start_modules_in_progress = true; |
| 2622 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2623 | switch (hdd_ctx->driver_status) { |
| 2624 | case DRIVER_MODULES_UNINITIALIZED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2625 | hdd_info("Wlan transitioning (UNINITIALIZED -> CLOSED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2626 | unint = true; |
| 2627 | /* Fall through dont add break here */ |
| 2628 | case DRIVER_MODULES_CLOSED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2629 | hdd_info("Wlan transitioning (CLOSED -> OPENED)"); |
| 2630 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2631 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_ACTIVE); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2632 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2633 | if (!reinit && !unint) { |
| 2634 | ret = pld_power_on(qdf_dev->dev); |
| 2635 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2636 | hdd_err("Failed to Powerup the device; errno: %d", |
| 2637 | ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2638 | goto release_lock; |
| 2639 | } |
| 2640 | } |
Yuanyuan Liu | f8fe4bc | 2017-06-07 16:55:58 -0700 | [diff] [blame] | 2641 | |
| 2642 | pld_set_fw_log_mode(hdd_ctx->parent_dev, |
| 2643 | hdd_ctx->config->enable_fw_log); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2644 | ret = hdd_hif_open(qdf_dev->dev, qdf_dev->drv_hdl, qdf_dev->bid, |
| 2645 | qdf_dev->bus_type, |
| 2646 | (reinit == true) ? HIF_ENABLE_TYPE_REINIT : |
| 2647 | HIF_ENABLE_TYPE_PROBE); |
| 2648 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2649 | hdd_err("Failed to open hif; errno: %d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2650 | goto power_down; |
| 2651 | } |
| 2652 | |
| 2653 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
Arun Khandavalli | 1318b99 | 2016-08-09 11:04:57 +0530 | [diff] [blame] | 2654 | if (!hif_ctx) { |
| 2655 | hdd_err("hif context is null!!"); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2656 | ret = -EINVAL; |
Arun Khandavalli | 1318b99 | 2016-08-09 11:04:57 +0530 | [diff] [blame] | 2657 | goto power_down; |
| 2658 | } |
| 2659 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2660 | status = ol_cds_init(qdf_dev, hif_ctx); |
| 2661 | if (status != QDF_STATUS_SUCCESS) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2662 | hdd_err("No Memory to Create BMI Context; status: %d", |
| 2663 | status); |
| 2664 | ret = qdf_status_to_os_return(status); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2665 | goto hif_close; |
| 2666 | } |
| 2667 | |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 2668 | hdd_update_ipa_component_config(hdd_ctx); |
| 2669 | |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 2670 | ret = hdd_update_config(hdd_ctx); |
| 2671 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2672 | hdd_err("Failed to update configuration; errno: %d", |
| 2673 | ret); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2674 | goto cds_free; |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 2675 | } |
| 2676 | |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2677 | hdd_update_cds_ac_specs_params(hdd_ctx); |
| 2678 | |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 2679 | status = cds_open(hdd_ctx->hdd_psoc); |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2680 | if (QDF_IS_STATUS_ERROR(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2681 | hdd_err("Failed to Open CDS; status: %d", status); |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2682 | ret = qdf_status_to_os_return(status); |
| 2683 | goto deinit_config; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2684 | } |
| 2685 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2686 | /* initalize components configurations after psoc open */ |
| 2687 | ret = hdd_update_components_config(hdd_ctx); |
| 2688 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2689 | hdd_err("Failed to update component configs; errno: %d", |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2690 | ret); |
| 2691 | goto close; |
| 2692 | } |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2693 | status = cds_dp_open(hdd_ctx->hdd_psoc); |
| 2694 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2695 | hdd_err("Failed to Open cds post open; status: %d", |
| 2696 | status); |
| 2697 | ret = qdf_status_to_os_return(status); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2698 | goto close; |
| 2699 | } |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2700 | |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2701 | /* |
| 2702 | * NAN compoenet requires certian operations like, open adapter, |
| 2703 | * close adapter, etc. to be initiated by HDD, for those |
| 2704 | * register HDD callbacks with UMAC's NAN componenet. |
| 2705 | */ |
| 2706 | hdd_nan_register_callbacks(hdd_ctx); |
| 2707 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2708 | hdd_ctx->hHal = cds_get_context(QDF_MODULE_ID_SME); |
| 2709 | |
Jeff Johnson | 3a28012 | 2017-09-13 07:42:00 -0700 | [diff] [blame] | 2710 | status = cds_pre_enable(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2711 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2712 | hdd_err("Failed to pre-enable CDS; status: %d", status); |
| 2713 | ret = qdf_status_to_os_return(status); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2714 | goto cds_txrx_free; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2715 | } |
| 2716 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2717 | hdd_register_policy_manager_callback( |
| 2718 | hdd_ctx->hdd_psoc); |
| 2719 | |
Amar Singhal | 0928b19 | 2017-12-01 10:50:54 -0800 | [diff] [blame] | 2720 | hdd_sysfs_create_version_interface(hdd_ctx->hdd_psoc); |
| 2721 | |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2722 | hdd_update_hw_sw_info(hdd_ctx); |
Himanshu Agarwal | 0b9bbc3 | 2017-02-23 16:23:05 +0530 | [diff] [blame] | 2723 | hdd_ctx->driver_status = DRIVER_MODULES_OPENED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2724 | hdd_info("Wlan transitioned (now OPENED)"); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2725 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2726 | if (unint) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2727 | hdd_debug("In phase-1 initialization don't enable modules"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2728 | break; |
| 2729 | } |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 2730 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2731 | /* Fall through dont add break here */ |
| 2732 | case DRIVER_MODULES_OPENED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2733 | hdd_info("Wlan transitioning (OPENED -> ENABLED)"); |
| 2734 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2735 | if (!adapter) { |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2736 | hdd_alert("adapter is Null"); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2737 | ret = -EINVAL; |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2738 | goto post_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2739 | } |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 2740 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 2741 | hdd_err("in ftm mode, no need to configure cds modules"); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2742 | ret = -EINVAL; |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 2743 | break; |
| 2744 | } |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2745 | |
| 2746 | ret = hdd_configure_cds(hdd_ctx, adapter); |
| 2747 | if (ret) { |
| 2748 | hdd_err("Failed to Enable cds modules; errno: %d", ret); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2749 | goto post_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2750 | } |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2751 | |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 2752 | hdd_enable_power_management(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2753 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2754 | hdd_ctx->driver_status = DRIVER_MODULES_ENABLED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2755 | hdd_info("Wlan transitioned (now ENABLED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2756 | break; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2757 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2758 | default: |
| 2759 | hdd_err("WLAN start invoked in wrong state! :%d\n", |
| 2760 | hdd_ctx->driver_status); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2761 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2762 | goto release_lock; |
| 2763 | } |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2764 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 2765 | hdd_ctx->start_modules_in_progress = false; |
Paul Zhang | e03cf4c | 2018-01-19 18:33:22 +0800 | [diff] [blame] | 2766 | if (DRIVER_MODULES_ENABLED == hdd_ctx->driver_status) { |
| 2767 | ret = hdd_update_country_code(hdd_ctx); |
| 2768 | if (ret) |
| 2769 | hdd_err("Failed to update command line country code!"); |
| 2770 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2771 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2772 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2773 | hdd_exit(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2774 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2775 | return 0; |
| 2776 | |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2777 | post_disable: |
Rajeev Kumar | be02124 | 2017-02-16 16:12:23 -0800 | [diff] [blame] | 2778 | cds_post_disable(); |
Amar Singhal | 410675c | 2018-01-10 12:14:21 -0800 | [diff] [blame] | 2779 | dispatcher_pdev_close(hdd_ctx->hdd_pdev); |
Dustin Brown | bd68fe1 | 2017-11-21 15:28:52 -0800 | [diff] [blame] | 2780 | hdd_objmgr_release_and_destroy_pdev(hdd_ctx); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2781 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2782 | cds_txrx_free: |
| 2783 | cds_dp_close(hdd_ctx->hdd_psoc); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2784 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2785 | close: |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2786 | hdd_ctx->driver_status = DRIVER_MODULES_CLOSED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2787 | hdd_info("Wlan transition aborted (now CLOSED)"); |
| 2788 | |
Jeff Johnson | e4b1459 | 2017-09-13 14:23:33 -0700 | [diff] [blame] | 2789 | cds_close(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2790 | |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2791 | deinit_config: |
| 2792 | cds_deinit_ini_config(); |
| 2793 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2794 | cds_free: |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2795 | ol_cds_free(); |
| 2796 | |
| 2797 | hif_close: |
Jeff Johnson | 60dc2b1 | 2017-09-28 14:56:02 -0700 | [diff] [blame] | 2798 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2799 | hdd_hif_close(hdd_ctx, hif_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2800 | power_down: |
| 2801 | if (!reinit && !unint) |
| 2802 | pld_power_off(qdf_dev->dev); |
| 2803 | release_lock: |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 2804 | hdd_ctx->start_modules_in_progress = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2805 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2806 | |
| 2807 | /* many adapter resources are not freed by design in SSR case */ |
| 2808 | if (!reinit) |
| 2809 | hdd_check_for_leaks(); |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2810 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_INIT); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2811 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2812 | hdd_exit(); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2813 | |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 2814 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2815 | } |
| 2816 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2817 | #ifdef WIFI_POS_CONVERGED |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2818 | static int hdd_activate_wifi_pos(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2819 | { |
| 2820 | int ret = os_if_wifi_pos_register_nl(); |
| 2821 | |
| 2822 | if (ret) |
| 2823 | hdd_err("os_if_wifi_pos_register_nl failed"); |
| 2824 | |
| 2825 | return ret; |
| 2826 | } |
| 2827 | |
| 2828 | static int hdd_deactivate_wifi_pos(void) |
| 2829 | { |
| 2830 | int ret = os_if_wifi_pos_deregister_nl(); |
| 2831 | |
| 2832 | if (ret) |
| 2833 | hdd_err("os_if_wifi_pos_deregister_nl failed"); |
| 2834 | |
| 2835 | return ret; |
| 2836 | } |
| 2837 | |
| 2838 | /** |
| 2839 | * hdd_populate_wifi_pos_cfg - populates wifi_pos parameters |
| 2840 | * @hdd_ctx: hdd context |
| 2841 | * |
| 2842 | * Return: status of operation |
| 2843 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2844 | static void hdd_populate_wifi_pos_cfg(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2845 | { |
| 2846 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 2847 | struct hdd_config *cfg = hdd_ctx->config; |
| 2848 | |
| 2849 | wifi_pos_set_oem_target_type(psoc, hdd_ctx->target_type); |
| 2850 | wifi_pos_set_oem_fw_version(psoc, hdd_ctx->target_fw_version); |
| 2851 | wifi_pos_set_drv_ver_major(psoc, QWLAN_VERSION_MAJOR); |
| 2852 | wifi_pos_set_drv_ver_minor(psoc, QWLAN_VERSION_MINOR); |
| 2853 | wifi_pos_set_drv_ver_patch(psoc, QWLAN_VERSION_PATCH); |
| 2854 | wifi_pos_set_drv_ver_build(psoc, QWLAN_VERSION_BUILD); |
| 2855 | wifi_pos_set_dwell_time_min(psoc, cfg->nNeighborScanMinChanTime); |
| 2856 | wifi_pos_set_dwell_time_max(psoc, cfg->nNeighborScanMaxChanTime); |
| 2857 | } |
| 2858 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2859 | static int hdd_activate_wifi_pos(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2860 | { |
| 2861 | return oem_activate_service(hdd_ctx); |
| 2862 | } |
| 2863 | |
| 2864 | static int hdd_deactivate_wifi_pos(void) |
| 2865 | { |
| 2866 | return 0; |
| 2867 | } |
| 2868 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2869 | static void hdd_populate_wifi_pos_cfg(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2870 | { |
| 2871 | } |
| 2872 | #endif |
| 2873 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2874 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2875 | * __hdd_open() - HDD Open function |
| 2876 | * @dev: Pointer to net_device structure |
| 2877 | * |
| 2878 | * This is called in response to ifconfig up |
| 2879 | * |
| 2880 | * Return: 0 for success; non-zero for failure |
| 2881 | */ |
| 2882 | static int __hdd_open(struct net_device *dev) |
| 2883 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2884 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2885 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2886 | int ret; |
| 2887 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 2888 | hdd_enter_dev(dev); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 2889 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_OPEN_REQUEST, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 2890 | adapter->session_id, adapter->device_mode)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2891 | |
Ashish Kumar Dhanotiya | 15a7db5 | 2017-08-03 10:27:34 +0530 | [diff] [blame] | 2892 | /* Nothing to be done if device is unloading */ |
| 2893 | if (cds_is_driver_unloading()) { |
| 2894 | hdd_err("Driver is unloading can not open the hdd"); |
| 2895 | return -EBUSY; |
| 2896 | } |
| 2897 | |
Dustin Brown | 0184775 | 2017-10-25 13:56:27 -0700 | [diff] [blame] | 2898 | if (cds_is_driver_recovering()) { |
| 2899 | hdd_err("WLAN is currently recovering; Please try again."); |
| 2900 | return -EBUSY; |
| 2901 | } |
| 2902 | |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 2903 | if (qdf_atomic_read(&hdd_ctx->con_mode_flag)) { |
| 2904 | hdd_err("con_mode_handler is in progress; Please try again."); |
| 2905 | return -EBUSY; |
| 2906 | } |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2907 | |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 2908 | mutex_lock(&hdd_init_deinit_lock); |
Hanumanth Reddy Pothula | 006f383 | 2017-10-12 15:52:43 +0530 | [diff] [blame] | 2909 | hdd_start_driver_ops_timer(eHDD_DRV_OP_IFF_UP); |
| 2910 | |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2911 | /* |
| 2912 | * This scenario can be hit in cases where in the wlan driver after |
| 2913 | * registering the netdevices and there is a failure in driver |
| 2914 | * initialization. So return error gracefully because the netdevices |
| 2915 | * will be de-registered as part of the load failure. |
| 2916 | */ |
| 2917 | |
| 2918 | if (!cds_is_driver_loaded()) { |
| 2919 | hdd_err("Failed to start the wlan driver!!"); |
| 2920 | ret = -EIO; |
| 2921 | goto err_hdd_hdd_init_deinit_lock; |
| 2922 | } |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 2923 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2924 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2925 | ret = hdd_wlan_start_modules(hdd_ctx, adapter, false); |
| 2926 | if (ret) { |
| 2927 | hdd_err("Failed to start WLAN modules return"); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2928 | goto err_hdd_hdd_init_deinit_lock; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2929 | } |
| 2930 | |
| 2931 | |
| 2932 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 2933 | ret = hdd_start_adapter(adapter); |
| 2934 | if (ret) { |
| 2935 | hdd_err("Failed to start adapter :%d", |
| 2936 | adapter->device_mode); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2937 | goto err_hdd_hdd_init_deinit_lock; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2938 | } |
| 2939 | } |
| 2940 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2941 | set_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 2942 | 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] | 2943 | hdd_debug("Enabling Tx Queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2944 | /* Enable TX queues only when we are connected */ |
| 2945 | wlan_hdd_netif_queue_control(adapter, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2946 | WLAN_START_ALL_NETIF_QUEUE, |
| 2947 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2948 | } |
| 2949 | |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 2950 | /* Enable carrier and transmit queues for NDI */ |
| 2951 | if (WLAN_HDD_IS_NDI(adapter)) { |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 2952 | hdd_debug("Enabling Tx Queues"); |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 2953 | wlan_hdd_netif_queue_control(adapter, |
| 2954 | WLAN_START_ALL_NETIF_QUEUE_N_CARRIER, |
| 2955 | WLAN_CONTROL_PATH); |
| 2956 | } |
| 2957 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2958 | hdd_populate_wifi_pos_cfg(hdd_ctx); |
| 2959 | |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2960 | err_hdd_hdd_init_deinit_lock: |
Hanumanth Reddy Pothula | 006f383 | 2017-10-12 15:52:43 +0530 | [diff] [blame] | 2961 | hdd_stop_driver_ops_timer(); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2962 | mutex_unlock(&hdd_init_deinit_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2963 | return ret; |
| 2964 | } |
| 2965 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2966 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2967 | /** |
| 2968 | * hdd_open() - Wrapper function for __hdd_open to protect it from SSR |
| 2969 | * @dev: Pointer to net_device structure |
| 2970 | * |
| 2971 | * This is called in response to ifconfig up |
| 2972 | * |
| 2973 | * Return: 0 for success; non-zero for failure |
| 2974 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2975 | static int hdd_open(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2976 | { |
| 2977 | int ret; |
| 2978 | |
| 2979 | cds_ssr_protect(__func__); |
| 2980 | ret = __hdd_open(dev); |
| 2981 | cds_ssr_unprotect(__func__); |
| 2982 | |
| 2983 | return ret; |
| 2984 | } |
| 2985 | |
| 2986 | /** |
| 2987 | * __hdd_stop() - HDD stop function |
| 2988 | * @dev: Pointer to net_device structure |
| 2989 | * |
| 2990 | * This is called in response to ifconfig down |
| 2991 | * |
| 2992 | * Return: 0 for success; non-zero for failure |
| 2993 | */ |
| 2994 | static int __hdd_stop(struct net_device *dev) |
| 2995 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2996 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2997 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2998 | int ret; |
| 2999 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3000 | hdd_enter_dev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3001 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 3002 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_STOP_REQUEST, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3003 | adapter->session_id, adapter->device_mode)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3004 | |
| 3005 | ret = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 3006 | if (0 != ret) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3007 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3008 | |
| 3009 | /* Nothing to be done if the interface is not opened */ |
| 3010 | if (false == test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 3011 | hdd_err("NETDEV Interface is not OPENED"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3012 | return -ENODEV; |
| 3013 | } |
| 3014 | |
| 3015 | /* Make sure the interface is marked as closed */ |
| 3016 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 3017 | |
| 3018 | hdd_debug("Disabling Auto Power save timer"); |
| 3019 | sme_ps_disable_auto_ps_timer( |
| 3020 | WLAN_HDD_GET_HAL_CTX(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3021 | adapter->session_id); |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 3022 | |
| 3023 | /* |
| 3024 | * Disable TX on the interface, after this hard_start_xmit() will not |
| 3025 | * be called on that interface |
| 3026 | */ |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 3027 | hdd_info("Disabling queues, adapter device mode: %s(%d)", |
Kabilan Kannan | 8dac350 | 2017-10-30 12:40:27 -0700 | [diff] [blame] | 3028 | hdd_device_mode_to_string(adapter->device_mode), |
| 3029 | adapter->device_mode); |
| 3030 | |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 3031 | wlan_hdd_netif_queue_control(adapter, |
| 3032 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 3033 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3034 | |
| 3035 | /* |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 3036 | * NAN data interface is different in some sense. The traffic on NDI is |
| 3037 | * bursty in nature and depends on the need to transfer. The service |
| 3038 | * layer may down the interface after the usage and up again when |
| 3039 | * required. In some sense, the NDI is expected to be available |
| 3040 | * (like SAP) iface until NDI delete request is issued by the service |
| 3041 | * layer. Skip BSS termination and adapter deletion for NAN Data |
| 3042 | * interface (NDI). |
| 3043 | */ |
| 3044 | if (WLAN_HDD_IS_NDI(adapter)) |
| 3045 | return 0; |
| 3046 | |
| 3047 | /* |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3048 | * The interface is marked as down for outside world (aka kernel) |
| 3049 | * But the driver is pretty much alive inside. The driver needs to |
| 3050 | * tear down the existing connection on the netdev (session) |
| 3051 | * cleanup the data pipes and wait until the control plane is stabilized |
| 3052 | * for this interface. The call also needs to wait until the above |
| 3053 | * mentioned actions are completed before returning to the caller. |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3054 | * Notice that hdd_stop_adapter is requested not to close the session |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3055 | * That is intentional to be able to scan if it is a STA/P2P interface |
| 3056 | */ |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 3057 | hdd_stop_adapter(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3058 | |
| 3059 | /* DeInit the adapter. This ensures datapath cleanup as well */ |
| 3060 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
| 3061 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3062 | |
| 3063 | /* |
Hanumanth Reddy Pothula | 3862ca9 | 2018-01-12 16:44:10 +0530 | [diff] [blame] | 3064 | * Upon wifi turn off, DUT has to flush the scan results so if |
| 3065 | * this is the last cli iface, flush the scan database. |
| 3066 | */ |
| 3067 | if (!hdd_is_cli_iface_up(hdd_ctx)) |
| 3068 | sme_scan_flush_result(hdd_ctx->hHal); |
| 3069 | |
| 3070 | /* |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3071 | * Find if any iface is up. If any iface is up then can't put device to |
| 3072 | * sleep/power save mode |
| 3073 | */ |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 3074 | if (hdd_check_for_opened_interfaces(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3075 | hdd_debug("Closing all modules from the hdd_stop"); |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 3076 | qdf_sched_delayed_work(&hdd_ctx->iface_idle_work, |
| 3077 | hdd_ctx->config->iface_change_wait_time); |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 3078 | hdd_prevent_suspend_timeout( |
| 3079 | hdd_ctx->config->iface_change_wait_time, |
| 3080 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3081 | } |
| 3082 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3083 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3084 | return 0; |
| 3085 | } |
| 3086 | |
| 3087 | /** |
| 3088 | * hdd_stop() - Wrapper function for __hdd_stop to protect it from SSR |
| 3089 | * @dev: pointer to net_device structure |
| 3090 | * |
| 3091 | * This is called in response to ifconfig down |
| 3092 | * |
| 3093 | * Return: 0 for success and error number for failure |
| 3094 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3095 | static int hdd_stop(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3096 | { |
| 3097 | int ret; |
| 3098 | |
| 3099 | cds_ssr_protect(__func__); |
| 3100 | ret = __hdd_stop(dev); |
| 3101 | cds_ssr_unprotect(__func__); |
| 3102 | |
| 3103 | return ret; |
| 3104 | } |
| 3105 | |
| 3106 | /** |
| 3107 | * __hdd_uninit() - HDD uninit function |
| 3108 | * @dev: Pointer to net_device structure |
| 3109 | * |
| 3110 | * This is called during the netdev unregister to uninitialize all data |
| 3111 | * associated with the device |
| 3112 | * |
| 3113 | * Return: None |
| 3114 | */ |
| 3115 | static void __hdd_uninit(struct net_device *dev) |
| 3116 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3117 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 3118 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3119 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3120 | hdd_enter_dev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3121 | |
| 3122 | do { |
| 3123 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3124 | hdd_err("Invalid magic"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3125 | break; |
| 3126 | } |
| 3127 | |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 3128 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3129 | if (!hdd_ctx) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3130 | hdd_err("NULL hdd_ctx"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3131 | break; |
| 3132 | } |
| 3133 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3134 | if (dev != adapter->dev) |
| 3135 | hdd_err("Invalid device reference"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3136 | |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 3137 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3138 | |
| 3139 | /* after uninit our adapter structure will no longer be valid */ |
| 3140 | adapter->dev = NULL; |
| 3141 | adapter->magic = 0; |
| 3142 | } while (0); |
| 3143 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3144 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3145 | } |
| 3146 | |
| 3147 | /** |
| 3148 | * hdd_uninit() - Wrapper function to protect __hdd_uninit from SSR |
| 3149 | * @dev: pointer to net_device structure |
| 3150 | * |
| 3151 | * This is called during the netdev unregister to uninitialize all data |
| 3152 | * associated with the device |
| 3153 | * |
| 3154 | * Return: none |
| 3155 | */ |
| 3156 | static void hdd_uninit(struct net_device *dev) |
| 3157 | { |
| 3158 | cds_ssr_protect(__func__); |
| 3159 | __hdd_uninit(dev); |
| 3160 | cds_ssr_unprotect(__func__); |
| 3161 | } |
| 3162 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3163 | static int hdd_open_cesium_nl_sock(void) |
| 3164 | { |
| 3165 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 3166 | struct netlink_kernel_cfg cfg = { |
| 3167 | .groups = WLAN_NLINK_MCAST_GRP_ID, |
| 3168 | .input = NULL |
| 3169 | }; |
| 3170 | #endif |
| 3171 | int ret = 0; |
| 3172 | |
| 3173 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 3174 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 3175 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 7, 0)) |
| 3176 | THIS_MODULE, |
| 3177 | #endif |
| 3178 | &cfg); |
| 3179 | #else |
| 3180 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 3181 | WLAN_NLINK_MCAST_GRP_ID, |
| 3182 | NULL, NULL, THIS_MODULE); |
| 3183 | #endif |
| 3184 | |
| 3185 | if (cesium_nl_srv_sock == NULL) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 3186 | hdd_err("NLINK: cesium netlink_kernel_create failed"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3187 | ret = -ECONNREFUSED; |
| 3188 | } |
| 3189 | |
| 3190 | return ret; |
| 3191 | } |
| 3192 | |
| 3193 | static void hdd_close_cesium_nl_sock(void) |
| 3194 | { |
| 3195 | if (NULL != cesium_nl_srv_sock) { |
| 3196 | netlink_kernel_release(cesium_nl_srv_sock); |
| 3197 | cesium_nl_srv_sock = NULL; |
| 3198 | } |
| 3199 | } |
| 3200 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3201 | /** |
| 3202 | * __hdd_set_mac_address() - set the user specified mac address |
| 3203 | * @dev: Pointer to the net device. |
| 3204 | * @addr: Pointer to the sockaddr. |
| 3205 | * |
| 3206 | * This function sets the user specified mac address using |
| 3207 | * the command ifconfig wlanX hw ether <mac adress>. |
| 3208 | * |
| 3209 | * Return: 0 for success, non zero for failure |
| 3210 | */ |
| 3211 | static int __hdd_set_mac_address(struct net_device *dev, void *addr) |
| 3212 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3213 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3214 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3215 | struct sockaddr *psta_mac_addr = addr; |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3216 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3217 | int ret; |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3218 | struct qdf_mac_addr mac_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3219 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3220 | hdd_enter_dev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3221 | |
Hanumanth Reddy Pothula | 5c7a781 | 2018-03-09 12:55:32 +0530 | [diff] [blame] | 3222 | if (netif_running(dev)) { |
| 3223 | hdd_err("On iface up, set mac address change isn't supported"); |
| 3224 | return -EBUSY; |
| 3225 | } |
| 3226 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3227 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3228 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 3229 | if (0 != ret) |
| 3230 | return ret; |
| 3231 | |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3232 | qdf_mem_copy(&mac_addr, psta_mac_addr->sa_data, sizeof(mac_addr)); |
| 3233 | |
| 3234 | if (qdf_is_macaddr_zero(&mac_addr)) { |
| 3235 | hdd_err("MAC is all zero"); |
| 3236 | return -EINVAL; |
| 3237 | } |
| 3238 | |
| 3239 | if (qdf_is_macaddr_broadcast(&mac_addr)) { |
| 3240 | hdd_err("MAC is Broadcast"); |
| 3241 | return -EINVAL; |
| 3242 | } |
| 3243 | |
| 3244 | if (ETHER_IS_MULTICAST(psta_mac_addr->sa_data)) { |
| 3245 | hdd_err("MAC is Multicast"); |
| 3246 | return -EINVAL; |
| 3247 | } |
| 3248 | |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 3249 | memcpy(&adapter->mac_addr, psta_mac_addr->sa_data, ETH_ALEN); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3250 | memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN); |
| 3251 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3252 | hdd_exit(); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3253 | return qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3254 | } |
| 3255 | |
| 3256 | /** |
| 3257 | * hdd_set_mac_address() - Wrapper function to protect __hdd_set_mac_address() |
| 3258 | * function from SSR |
| 3259 | * @dev: pointer to net_device structure |
| 3260 | * @addr: Pointer to the sockaddr |
| 3261 | * |
| 3262 | * This function sets the user specified mac address using |
| 3263 | * the command ifconfig wlanX hw ether <mac adress>. |
| 3264 | * |
| 3265 | * Return: 0 for success. |
| 3266 | */ |
| 3267 | static int hdd_set_mac_address(struct net_device *dev, void *addr) |
| 3268 | { |
| 3269 | int ret; |
| 3270 | |
| 3271 | cds_ssr_protect(__func__); |
| 3272 | ret = __hdd_set_mac_address(dev, addr); |
| 3273 | cds_ssr_unprotect(__func__); |
| 3274 | |
| 3275 | return ret; |
| 3276 | } |
| 3277 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3278 | uint8_t *wlan_hdd_get_intf_addr(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3279 | { |
| 3280 | int i; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3281 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3282 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3283 | if (0 == ((hdd_ctx->config->intfAddrMask) & (1 << i))) |
| 3284 | break; |
| 3285 | } |
| 3286 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3287 | if (QDF_MAX_CONCURRENCY_PERSONA == i) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3288 | return NULL; |
| 3289 | |
| 3290 | hdd_ctx->config->intfAddrMask |= (1 << i); |
| 3291 | return &hdd_ctx->config->intfMacAddr[i].bytes[0]; |
| 3292 | } |
| 3293 | |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 3294 | void wlan_hdd_release_intf_addr(struct hdd_context *hdd_ctx, |
| 3295 | uint8_t *releaseAddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3296 | { |
| 3297 | int i; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3298 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3299 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3300 | if (!memcmp(releaseAddr, |
| 3301 | &hdd_ctx->config->intfMacAddr[i].bytes[0], |
| 3302 | 6)) { |
| 3303 | hdd_ctx->config->intfAddrMask &= ~(1 << i); |
| 3304 | break; |
| 3305 | } |
| 3306 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3307 | } |
| 3308 | |
| 3309 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 3310 | /** |
| 3311 | * __hdd_set_multicast_list() - set the multicast address list |
| 3312 | * @dev: Pointer to the WLAN device. |
| 3313 | * @skb: Pointer to OS packet (sk_buff). |
| 3314 | * |
| 3315 | * This funciton sets the multicast address list. |
| 3316 | * |
| 3317 | * Return: None |
| 3318 | */ |
| 3319 | static void __hdd_set_multicast_list(struct net_device *dev) |
| 3320 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3321 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3322 | int i = 0, status; |
| 3323 | struct netdev_hw_addr *ha; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3324 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3325 | struct pmo_mc_addr_list_params *mc_list_request = NULL; |
| 3326 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 3327 | int mc_count = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3328 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3329 | hdd_enter_dev(dev); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3330 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3331 | goto out; |
Mukul Sharma | 51c4494 | 2015-10-30 19:30:19 +0530 | [diff] [blame] | 3332 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3333 | status = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 3334 | if (0 != status) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3335 | goto out; |
| 3336 | |
Dustin Brown | c788acb | 2017-08-01 17:43:51 -0700 | [diff] [blame] | 3337 | status = hdd_validate_adapter(adapter); |
| 3338 | if (status) |
| 3339 | goto out; |
| 3340 | |
Arunk Khandavalli | 6a22788 | 2017-12-12 19:31:08 +0530 | [diff] [blame] | 3341 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) { |
| 3342 | hdd_err("%s: Driver module is closed", __func__); |
| 3343 | return; |
| 3344 | } |
| 3345 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3346 | mc_list_request = qdf_mem_malloc(sizeof(*mc_list_request)); |
| 3347 | if (!mc_list_request) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3348 | hdd_err("Cannot allocate mc_list_request"); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3349 | goto out; |
| 3350 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3351 | |
Hanumanth Reddy Pothula | ca84ec5 | 2017-02-21 12:09:45 +0530 | [diff] [blame] | 3352 | /* Delete already configured multicast address list */ |
| 3353 | if (adapter->mc_addr_list.mc_cnt > 0) { |
| 3354 | hdd_info("clear previously configured MC address list"); |
| 3355 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3356 | pmo_mc_list_change_notify); |
| 3357 | } |
| 3358 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3359 | if (dev->flags & IFF_ALLMULTI) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3360 | hdd_debug("allow all multicast frames"); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3361 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3362 | pmo_mc_list_change_notify); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3363 | } else { |
| 3364 | mc_count = netdev_mc_count(dev); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3365 | if (mc_count > pmo_ucfg_max_mc_addr_supported(psoc)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3366 | 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] | 3367 | pmo_ucfg_max_mc_addr_supported(psoc)); |
| 3368 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3369 | pmo_mc_list_change_notify); |
| 3370 | goto out; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3371 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3372 | netdev_for_each_mc_addr(ha, dev) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3373 | hdd_debug("ha_addr[%d] "MAC_ADDRESS_STR, |
Sachin Ahuja | a69c72a | 2016-09-03 15:59:33 +0530 | [diff] [blame] | 3374 | i, MAC_ADDR_ARRAY(ha->addr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3375 | if (i == mc_count) |
| 3376 | break; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3377 | memset(&(mc_list_request->mc_addr[i].bytes), |
| 3378 | 0, ETH_ALEN); |
| 3379 | memcpy(&(mc_list_request->mc_addr[i].bytes), |
| 3380 | ha->addr, ETH_ALEN); |
| 3381 | hdd_info("mlist[%d] = %pM", i, |
| 3382 | mc_list_request->mc_addr[i].bytes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3383 | i++; |
| 3384 | } |
| 3385 | } |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3386 | |
| 3387 | mc_list_request->psoc = psoc; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3388 | mc_list_request->vdev_id = adapter->session_id; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3389 | mc_list_request->count = mc_count; |
| 3390 | status = hdd_cache_mc_addr_list(mc_list_request); |
| 3391 | if (status == 0) { |
| 3392 | hdd_enable_mc_addr_filtering(adapter, |
| 3393 | pmo_mc_list_change_notify); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3394 | } else { |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3395 | hdd_err("error while caching mc list"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3396 | } |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3397 | out: |
| 3398 | if (mc_list_request) |
| 3399 | qdf_mem_free(mc_list_request); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3400 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3401 | } |
| 3402 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3403 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3404 | /** |
| 3405 | * hdd_set_multicast_list() - SSR wrapper function for __hdd_set_multicast_list |
| 3406 | * @dev: pointer to net_device |
| 3407 | * |
| 3408 | * Return: none |
| 3409 | */ |
| 3410 | static void hdd_set_multicast_list(struct net_device *dev) |
| 3411 | { |
| 3412 | cds_ssr_protect(__func__); |
| 3413 | __hdd_set_multicast_list(dev); |
| 3414 | cds_ssr_unprotect(__func__); |
| 3415 | } |
| 3416 | #endif |
| 3417 | |
| 3418 | /** |
| 3419 | * hdd_select_queue() - used by Linux OS to decide which queue to use first |
| 3420 | * @dev: Pointer to the WLAN device. |
| 3421 | * @skb: Pointer to OS packet (sk_buff). |
| 3422 | * |
| 3423 | * This function is registered with the Linux OS for network |
| 3424 | * core to decide which queue to use first. |
| 3425 | * |
| 3426 | * Return: ac, Queue Index/access category corresponding to UP in IP header |
| 3427 | */ |
| 3428 | static uint16_t hdd_select_queue(struct net_device *dev, struct sk_buff *skb |
| 3429 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0)) |
| 3430 | , void *accel_priv |
| 3431 | #endif |
| 3432 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) |
| 3433 | , select_queue_fallback_t fallback |
| 3434 | #endif |
| 3435 | ) |
| 3436 | { |
| 3437 | return hdd_wmm_select_queue(dev, skb); |
| 3438 | } |
| 3439 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3440 | static const struct net_device_ops wlan_drv_ops = { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3441 | .ndo_open = hdd_open, |
| 3442 | .ndo_stop = hdd_stop, |
| 3443 | .ndo_uninit = hdd_uninit, |
| 3444 | .ndo_start_xmit = hdd_hard_start_xmit, |
| 3445 | .ndo_tx_timeout = hdd_tx_timeout, |
| 3446 | .ndo_get_stats = hdd_get_stats, |
| 3447 | .ndo_do_ioctl = hdd_ioctl, |
| 3448 | .ndo_set_mac_address = hdd_set_mac_address, |
| 3449 | .ndo_select_queue = hdd_select_queue, |
| 3450 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3451 | .ndo_set_rx_mode = hdd_set_multicast_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3452 | #endif |
| 3453 | }; |
| 3454 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3455 | /* Monitor mode net_device_ops, doesnot Tx and most of operations. */ |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3456 | static const struct net_device_ops wlan_mon_drv_ops = { |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3457 | .ndo_open = hdd_mon_open, |
| 3458 | .ndo_stop = hdd_stop, |
| 3459 | .ndo_get_stats = hdd_get_stats, |
| 3460 | }; |
| 3461 | |
| 3462 | /** |
| 3463 | * hdd_set_station_ops() - update net_device ops for monitor mode |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3464 | * @dev: Handle to struct net_device to be updated. |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3465 | * Return: None |
| 3466 | */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3467 | void hdd_set_station_ops(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3468 | { |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3469 | if (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam()) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3470 | dev->netdev_ops = &wlan_mon_drv_ops; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3471 | else |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3472 | dev->netdev_ops = &wlan_drv_ops; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3473 | } |
| 3474 | |
| 3475 | /** |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3476 | * hdd_alloc_station_adapter() - allocate the station hdd adapter |
| 3477 | * @hdd_ctx: global hdd context |
| 3478 | * @macAddr: mac address to assign to the interface |
| 3479 | * @name: User-visible name of the interface |
| 3480 | * |
| 3481 | * hdd adapter pointer would point to the netdev->priv space, this function |
| 3482 | * would retrive the pointer, and setup the hdd adapter configuration. |
| 3483 | * |
| 3484 | * Return: the pointer to hdd adapter, otherwise NULL |
| 3485 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3486 | 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] | 3487 | tSirMacAddr macAddr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3488 | unsigned char name_assign_type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3489 | const char *name) |
| 3490 | { |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3491 | struct net_device *dev = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3492 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 3493 | struct hdd_station_ctx *sta_ctx; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3494 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3495 | /* |
| 3496 | * cfg80211 initialization and registration.... |
| 3497 | */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3498 | dev = alloc_netdev_mq(sizeof(struct hdd_adapter), name, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3499 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS) |
| 3500 | name_assign_type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3501 | #endif |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3502 | (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam() ? |
| 3503 | hdd_mon_mode_ether_setup : ether_setup), |
| 3504 | NUM_TX_QUEUES); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3505 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3506 | if (dev != NULL) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3507 | |
| 3508 | /* Save the pointer to the net_device in the HDD adapter */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3509 | adapter = (struct hdd_adapter *) netdev_priv(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3510 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3511 | qdf_mem_zero(adapter, sizeof(struct hdd_adapter)); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 3512 | sta_ctx = &adapter->session.station; |
Hanumanth Reddy Pothula | 18553ae | 2017-04-28 15:03:10 +0530 | [diff] [blame] | 3513 | qdf_mem_set(sta_ctx->conn_info.staId, |
| 3514 | sizeof(sta_ctx->conn_info.staId), |
| 3515 | HDD_WLAN_INVALID_STA_ID); |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3516 | adapter->dev = dev; |
Jeff Johnson | dba0db6 | 2017-08-30 11:12:39 -0700 | [diff] [blame] | 3517 | adapter->hdd_ctx = hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3518 | adapter->magic = WLAN_HDD_ADAPTER_MAGIC; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3519 | adapter->session_id = HDD_SESSION_ID_INVALID; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3520 | |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3521 | qdf_status = qdf_event_create( |
| 3522 | &adapter->qdf_session_open_event); |
| 3523 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 3524 | hdd_err("Session open QDF event init failed!"); |
| 3525 | free_netdev(adapter->dev); |
| 3526 | return NULL; |
| 3527 | } |
| 3528 | |
| 3529 | qdf_status = qdf_event_create( |
| 3530 | &adapter->qdf_session_close_event); |
| 3531 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 3532 | hdd_err("Session close QDF event init failed!"); |
| 3533 | free_netdev(adapter->dev); |
| 3534 | return NULL; |
| 3535 | } |
| 3536 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3537 | init_completion(&adapter->disconnect_comp_var); |
Abhishek Singh | 533c9da | 2017-05-04 10:23:34 +0530 | [diff] [blame] | 3538 | init_completion(&adapter->roaming_comp_var); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3539 | init_completion(&adapter->linkup_event_var); |
| 3540 | init_completion(&adapter->cancel_rem_on_chan_var); |
| 3541 | init_completion(&adapter->rem_on_chan_ready_event); |
| 3542 | init_completion(&adapter->sta_authorized_event); |
| 3543 | init_completion(&adapter->offchannel_tx_event); |
| 3544 | init_completion(&adapter->tx_action_cnf_event); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3545 | init_completion(&adapter->ibss_peer_info_comp); |
Sreelakshmi Konamki | 88a2a41 | 2017-04-14 15:11:55 +0530 | [diff] [blame] | 3546 | init_completion(&adapter->lfr_fw_status.disable_lfr_event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3547 | |
| 3548 | adapter->offloads_configured = false; |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 3549 | adapter->is_link_up_service_needed = false; |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 3550 | adapter->disconnection_in_progress = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3551 | /* Init the net_device structure */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3552 | strlcpy(dev->name, name, IFNAMSIZ); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3553 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3554 | qdf_mem_copy(dev->dev_addr, (void *)macAddr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3555 | sizeof(tSirMacAddr)); |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 3556 | qdf_mem_copy(adapter->mac_addr.bytes, macAddr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3557 | sizeof(tSirMacAddr)); |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3558 | dev->watchdog_timeo = HDD_TX_TIMEOUT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3559 | |
| 3560 | if (hdd_ctx->config->enable_ip_tcp_udp_checksum_offload) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3561 | dev->features |= |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3562 | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM; |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3563 | dev->features |= NETIF_F_RXCSUM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3564 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3565 | hdd_set_tso_flags(hdd_ctx, dev); |
Dhanashri Atre | 83d373d | 2015-07-28 16:45:59 -0700 | [diff] [blame] | 3566 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3567 | hdd_set_station_ops(adapter->dev); |
| 3568 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3569 | hdd_dev_setup_destructor(dev); |
| 3570 | dev->ieee80211_ptr = &adapter->wdev; |
| 3571 | dev->tx_queue_len = HDD_NETDEV_TX_QUEUE_LEN; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3572 | adapter->wdev.wiphy = hdd_ctx->wiphy; |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3573 | adapter->wdev.netdev = dev; |
| 3574 | /* set dev's parent to underlying device */ |
| 3575 | SET_NETDEV_DEV(dev, hdd_ctx->parent_dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3576 | hdd_wmm_init(adapter); |
| 3577 | spin_lock_init(&adapter->pause_map_lock); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 3578 | adapter->start_time = adapter->last_time = qdf_system_ticks(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3579 | } |
| 3580 | |
| 3581 | return adapter; |
| 3582 | } |
| 3583 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3584 | 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] | 3585 | { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3586 | struct net_device *dev = adapter->dev; |
| 3587 | int ret; |
| 3588 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 3589 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3590 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 3591 | if (rtnl_held) { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3592 | if (strnchr(dev->name, IFNAMSIZ - 1, '%')) { |
| 3593 | |
| 3594 | ret = dev_alloc_name(dev, dev->name); |
| 3595 | if (ret < 0) { |
| 3596 | hdd_err( |
| 3597 | "unable to get dev name: %s, err = 0x%x", |
| 3598 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3599 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3600 | } |
| 3601 | } |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3602 | |
| 3603 | ret = register_netdevice(dev); |
| 3604 | if (ret) { |
| 3605 | hdd_err("register_netdevice(%s) failed, err = 0x%x", |
| 3606 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3607 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3608 | } |
| 3609 | } else { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3610 | ret = register_netdev(dev); |
| 3611 | if (ret) { |
| 3612 | hdd_err("register_netdev(%s) failed, err = 0x%x", |
| 3613 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3614 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3615 | } |
| 3616 | } |
| 3617 | set_bit(NET_DEVICE_REGISTERED, &adapter->event_flags); |
| 3618 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3619 | hdd_exit(); |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3620 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3621 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3622 | } |
| 3623 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3624 | QDF_STATUS hdd_sme_open_session_callback(uint8_t session_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3625 | { |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3626 | struct hdd_adapter *adapter; |
| 3627 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3628 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3629 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 3630 | if (!hdd_ctx) { |
| 3631 | hdd_err("Invalid HDD_CTX"); |
| 3632 | return QDF_STATUS_E_FAILURE; |
| 3633 | } |
| 3634 | |
| 3635 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, session_id); |
| 3636 | if (NULL == adapter) { |
| 3637 | hdd_err("NULL adapter"); |
| 3638 | return QDF_STATUS_E_INVAL; |
| 3639 | } |
| 3640 | set_bit(SME_SESSION_OPENED, &adapter->event_flags); |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3641 | qdf_event_set(&adapter->qdf_session_open_event); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3642 | hdd_debug("session %d opened", adapter->session_id); |
| 3643 | |
| 3644 | return QDF_STATUS_SUCCESS; |
| 3645 | } |
| 3646 | |
| 3647 | QDF_STATUS hdd_sme_close_session_callback(uint8_t session_id) |
| 3648 | { |
| 3649 | struct hdd_adapter *adapter; |
| 3650 | struct hdd_context *hdd_ctx; |
| 3651 | |
| 3652 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 3653 | if (!hdd_ctx) { |
| 3654 | hdd_err("Invalid HDD_CTX"); |
| 3655 | return QDF_STATUS_E_FAILURE; |
| 3656 | } |
| 3657 | |
| 3658 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3659 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3660 | hdd_err("NULL adapter"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3661 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3662 | } |
| 3663 | |
| 3664 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3665 | hdd_err("Invalid magic"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3666 | return QDF_STATUS_NOT_INITIALIZED; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3667 | } |
| 3668 | |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3669 | /* |
| 3670 | * For NAN Data interface, the close session results in the final |
| 3671 | * indication to the userspace |
| 3672 | */ |
Rakesh Sunki | 3480f96 | 2016-08-29 17:29:53 -0700 | [diff] [blame] | 3673 | if (adapter->device_mode == QDF_NDI_MODE) |
| 3674 | hdd_ndp_session_end_handler(adapter); |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3675 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3676 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 3677 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3678 | /* |
| 3679 | * We can be blocked while waiting for scheduled work to be |
| 3680 | * flushed, and the adapter structure can potentially be freed, in |
| 3681 | * which case the magic will have been reset. So make sure the |
| 3682 | * magic is still good, and hence the adapter structure is still |
| 3683 | * valid, before signaling completion |
| 3684 | */ |
| 3685 | if (WLAN_HDD_ADAPTER_MAGIC == adapter->magic) |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3686 | qdf_event_set(&adapter->qdf_session_close_event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3687 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3688 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3689 | } |
| 3690 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3691 | int hdd_vdev_ready(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3692 | { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3693 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3694 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3695 | status = pmo_vdev_ready(adapter->hdd_vdev); |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 3696 | if (QDF_IS_STATUS_ERROR(status)) |
| 3697 | return qdf_status_to_os_return(status); |
| 3698 | |
Kiran Kumar Lokere | 3beeb95 | 2017-05-02 18:40:24 -0700 | [diff] [blame] | 3699 | status = ucfg_reg_11d_vdev_created_update(adapter->hdd_vdev); |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 3700 | if (QDF_IS_STATUS_ERROR(status)) |
| 3701 | return qdf_status_to_os_return(status); |
| 3702 | |
| 3703 | if (wma_capability_enhanced_mcast_filter()) |
| 3704 | status = pmo_ucfg_enhanced_mc_filter_enable(adapter->hdd_vdev); |
| 3705 | else |
| 3706 | status = pmo_ucfg_enhanced_mc_filter_disable(adapter->hdd_vdev); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3707 | |
| 3708 | return qdf_status_to_os_return(status); |
| 3709 | } |
| 3710 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3711 | int hdd_vdev_destroy(struct hdd_adapter *adapter) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3712 | { |
| 3713 | QDF_STATUS status; |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3714 | int errno = 0; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3715 | struct hdd_context *hdd_ctx; |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 3716 | uint8_t vdev_id; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3717 | |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 3718 | vdev_id = adapter->session_id; |
| 3719 | hdd_info("destroying vdev %d", vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3720 | |
| 3721 | /* vdev created sanity check */ |
| 3722 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3723 | hdd_err("vdev for Id %d does not exist", adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3724 | return -EINVAL; |
| 3725 | } |
Kiran Kumar Lokere | 3beeb95 | 2017-05-02 18:40:24 -0700 | [diff] [blame] | 3726 | status = ucfg_reg_11d_vdev_delete_update(adapter->hdd_vdev); |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 3727 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3728 | /* close sme session (destroy vdev in firmware via legacy API) */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3729 | qdf_event_reset(&adapter->qdf_session_close_event); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3730 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3731 | status = sme_close_session(hdd_ctx->hHal, adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3732 | if (QDF_IS_STATUS_ERROR(status)) { |
| 3733 | hdd_err("failed to close sme session: %d", status); |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3734 | errno = qdf_status_to_os_return(status); |
| 3735 | goto release_vdev; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3736 | } |
| 3737 | |
| 3738 | /* block on a completion variable until sme session is closed */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3739 | status = qdf_wait_for_event_completion( |
| 3740 | &adapter->qdf_session_close_event, |
| 3741 | WLAN_WAIT_TIME_SESSIONOPENCLOSE); |
| 3742 | if (QDF_STATUS_SUCCESS != status) { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3743 | if (adapter->device_mode == QDF_NDI_MODE) |
| 3744 | hdd_ndp_session_end_handler(adapter); |
| 3745 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3746 | adapter->session_id = HDD_SESSION_ID_INVALID; |
| 3747 | if (QDF_STATUS_E_TIMEOUT != status) { |
| 3748 | hdd_err("timed out waiting for close sme session: %u", status); |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3749 | errno = -ETIMEDOUT; |
| 3750 | goto release_vdev; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3751 | } else if (adapter->qdf_session_close_event.force_set) { |
| 3752 | hdd_err("Session close evt focefully set, SSR/PDR has occurred"); |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3753 | errno = -EINVAL; |
| 3754 | goto release_vdev; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3755 | } else { |
| 3756 | hdd_err("Failed to close sme session (%u)", status); |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3757 | errno = -EINVAL; |
| 3758 | goto release_vdev; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3759 | } |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3760 | } |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3761 | |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 3762 | release_vdev: |
Frank Liu | c66d4bf | 2018-01-26 16:18:18 +0800 | [diff] [blame] | 3763 | /* |
| 3764 | * In SSR or driver unloading case, directly exit may cause objects |
| 3765 | * leak, if sme_close_session failed. Free objects anyway. |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3766 | */ |
Kabilan Kannan | b867c31 | 2018-02-15 17:43:21 -0800 | [diff] [blame] | 3767 | if (errno && !cds_is_driver_recovering() && !cds_is_driver_unloading()) |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3768 | return errno; |
| 3769 | |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 3770 | /* do vdev logical destroy via objmgr */ |
Dustin Brown | b277dd6 | 2018-01-26 15:17:33 -0800 | [diff] [blame] | 3771 | errno = hdd_objmgr_release_and_destroy_vdev(adapter); |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 3772 | if (errno) { |
Dustin Brown | b277dd6 | 2018-01-26 15:17:33 -0800 | [diff] [blame] | 3773 | hdd_err("failed to destroy objmgr vdev; errno:%d", errno); |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 3774 | return errno; |
| 3775 | } |
| 3776 | |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 3777 | hdd_info("vdev %d destroyed successfully", vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3778 | |
| 3779 | return 0; |
| 3780 | } |
| 3781 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3782 | static int hdd_set_sme_session_param(struct hdd_adapter *adapter, |
| 3783 | struct sme_session_params *session_param, |
| 3784 | csr_roam_completeCallback callback, |
| 3785 | void *callback_ctx) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3786 | { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3787 | uint32_t type; |
| 3788 | uint32_t sub_type; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3789 | QDF_STATUS status; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3790 | |
| 3791 | /* determine vdev (sub)type */ |
| 3792 | status = cds_get_vdev_types(adapter->device_mode, &type, &sub_type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3793 | if (QDF_STATUS_SUCCESS != status) { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3794 | hdd_err("failed to get vdev type: %d", status); |
| 3795 | return qdf_status_to_os_return(status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3796 | } |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3797 | session_param->sme_session_id = adapter->session_id; |
| 3798 | session_param->self_mac_addr = (uint8_t *)&adapter->mac_addr; |
| 3799 | session_param->type_of_persona = type; |
| 3800 | session_param->subtype_of_persona = sub_type; |
| 3801 | session_param->session_open_cb = hdd_sme_open_session_callback; |
| 3802 | session_param->session_close_cb = hdd_sme_close_session_callback; |
| 3803 | session_param->callback = callback; |
| 3804 | session_param->callback_ctx = callback_ctx; |
| 3805 | |
| 3806 | return 0; |
| 3807 | } |
| 3808 | |
| 3809 | int hdd_vdev_create(struct hdd_adapter *adapter, |
| 3810 | csr_roam_completeCallback callback, void *ctx) |
| 3811 | { |
| 3812 | QDF_STATUS status; |
| 3813 | int errno; |
| 3814 | struct hdd_context *hdd_ctx; |
| 3815 | struct sme_session_params sme_session_params = {0}; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3816 | |
| 3817 | hdd_info("creating new vdev"); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3818 | |
| 3819 | /* do vdev create via objmgr */ |
| 3820 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Dustin Brown | 7d043f6 | 2017-03-27 12:07:36 -0700 | [diff] [blame] | 3821 | errno = hdd_objmgr_create_and_store_vdev(hdd_ctx->hdd_pdev, adapter); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3822 | if (errno) { |
| 3823 | hdd_err("failed to create objmgr vdev: %d", errno); |
| 3824 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3825 | } |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3826 | |
| 3827 | /* Open a SME session (prepare vdev in firmware via legacy API) */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3828 | status = qdf_event_reset(&adapter->qdf_session_open_event); |
| 3829 | if (QDF_STATUS_SUCCESS != status) { |
| 3830 | hdd_err("failed to reinit session open event"); |
| 3831 | return -EINVAL; |
| 3832 | } |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3833 | errno = hdd_set_sme_session_param(adapter, &sme_session_params, |
| 3834 | callback, ctx); |
| 3835 | if (errno) { |
| 3836 | hdd_err("failed to populating SME params"); |
| 3837 | goto objmgr_vdev_destroy_procedure; |
| 3838 | } |
| 3839 | |
| 3840 | status = sme_open_session(hdd_ctx->hHal, &sme_session_params); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3841 | if (QDF_IS_STATUS_ERROR(status)) { |
| 3842 | hdd_err("failed to open sme session: %d", status); |
| 3843 | errno = qdf_status_to_os_return(status); |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3844 | goto objmgr_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3845 | } |
| 3846 | |
| 3847 | /* block on a completion variable until sme session is opened */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3848 | status = qdf_wait_for_event_completion(&adapter->qdf_session_open_event, |
| 3849 | WLAN_WAIT_TIME_SESSIONOPENCLOSE); |
| 3850 | if (QDF_STATUS_SUCCESS != status) { |
| 3851 | if (adapter->qdf_session_open_event.force_set) { |
| 3852 | /* |
| 3853 | * SSR/PDR has caused shutdown, which has forcefully |
| 3854 | * set the event. Return without the closing session. |
| 3855 | */ |
| 3856 | adapter->session_id = HDD_SESSION_ID_INVALID; |
| 3857 | hdd_err("Session open event forcefully set"); |
| 3858 | return -EINVAL; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3859 | } |
Jeff Johnson | c66d310 | 2018-02-28 11:58:26 -0800 | [diff] [blame] | 3860 | |
| 3861 | if (QDF_STATUS_E_TIMEOUT == status) |
| 3862 | hdd_err("Session failed to open within timeout period"); |
| 3863 | else |
| 3864 | hdd_err("Failed to wait for session open event(status-%d)", |
| 3865 | status); |
| 3866 | errno = -ETIMEDOUT; |
| 3867 | set_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 3868 | goto hdd_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3869 | } |
| 3870 | |
| 3871 | /* firmware ready for component communication, raise vdev_ready event */ |
| 3872 | errno = hdd_vdev_ready(adapter); |
| 3873 | if (errno) { |
| 3874 | hdd_err("failed to dispatch vdev ready event: %d", errno); |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3875 | goto hdd_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3876 | } |
| 3877 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3878 | hdd_info("vdev %d created successfully", adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3879 | |
| 3880 | return 0; |
| 3881 | |
| 3882 | /* |
| 3883 | * Due to legacy constraints, we need to destroy in the same order as |
| 3884 | * create. So, split error handling into 2 cases to accommodate. |
| 3885 | */ |
| 3886 | |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3887 | objmgr_vdev_destroy_procedure: |
Dustin Brown | 7d043f6 | 2017-03-27 12:07:36 -0700 | [diff] [blame] | 3888 | QDF_BUG(!hdd_objmgr_release_and_destroy_vdev(adapter)); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3889 | |
| 3890 | return errno; |
| 3891 | |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3892 | hdd_vdev_destroy_procedure: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3893 | QDF_BUG(!hdd_vdev_destroy(adapter)); |
| 3894 | |
| 3895 | return errno; |
| 3896 | } |
| 3897 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3898 | QDF_STATUS hdd_init_station_mode(struct hdd_adapter *adapter) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3899 | { |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 3900 | struct hdd_station_ctx *sta_ctx = &adapter->session.station; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3901 | struct hdd_context *hdd_ctx; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3902 | QDF_STATUS status; |
| 3903 | int ret_val; |
| 3904 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3905 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3906 | sme_set_curr_device_mode(hdd_ctx->hHal, adapter->device_mode); |
| 3907 | 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] | 3908 | sme_set_vdev_ies_per_band(hdd_ctx->hHal, adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3909 | |
Jeff Johnson | 7f2c591 | 2018-03-23 11:42:28 -0700 | [diff] [blame] | 3910 | hdd_roam_profile_init(adapter); |
| 3911 | hdd_register_wext(adapter->dev); |
| 3912 | |
Varun Reddy Yeturu | 9e0032c | 2017-07-12 18:39:59 -0700 | [diff] [blame] | 3913 | hdd_conn_set_connection_state(adapter, eConnectionState_NotConnected); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3914 | |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 3915 | qdf_mem_set(sta_ctx->conn_info.staId, |
| 3916 | sizeof(sta_ctx->conn_info.staId), HDD_WLAN_INVALID_STA_ID); |
Hanumanth Reddy Pothula | b2d729c | 2017-05-30 11:49:53 +0530 | [diff] [blame] | 3917 | |
Deepak Dhamdhere | a278582 | 2016-11-17 01:17:45 -0800 | [diff] [blame] | 3918 | /* set fast roaming capability in sme session */ |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3919 | status = sme_config_fast_roaming(hdd_ctx->hHal, adapter->session_id, |
Abhishek Singh | 1f217ec | 2017-12-22 11:48:27 +0530 | [diff] [blame] | 3920 | true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3921 | /* Set the default operation channel */ |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 3922 | sta_ctx->conn_info.operationChannel = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3923 | hdd_ctx->config->OperatingChannel; |
| 3924 | |
| 3925 | /* Make the default Auth Type as OPEN */ |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 3926 | sta_ctx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3927 | |
| 3928 | status = hdd_init_tx_rx(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3929 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3930 | hdd_err("hdd_init_tx_rx() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3931 | status, status); |
| 3932 | goto error_init_txrx; |
| 3933 | } |
| 3934 | |
| 3935 | set_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 3936 | |
| 3937 | status = hdd_wmm_adapter_init(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3938 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3939 | hdd_err("hdd_wmm_adapter_init() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3940 | status, status); |
| 3941 | goto error_wmm_init; |
| 3942 | } |
| 3943 | |
| 3944 | set_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 3945 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3946 | ret_val = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3947 | WMI_PDEV_PARAM_BURST_ENABLE, |
| 3948 | hdd_ctx->config->enableSifsBurst, |
| 3949 | PDEV_CMD); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3950 | if (ret_val) |
| 3951 | hdd_err("WMI_PDEV_PARAM_BURST_ENABLE set failed %d", ret_val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3952 | |
Poddar, Siddarth | 4b3f731 | 2017-11-02 17:00:20 +0530 | [diff] [blame] | 3953 | /* |
| 3954 | * In case of USB tethering, LRO is disabled. If SSR happened |
| 3955 | * during that time, then as part of SSR init, do not enable |
| 3956 | * the LRO again. Keep the LRO state same as before SSR. |
| 3957 | */ |
| 3958 | if (!(qdf_atomic_read(&hdd_ctx->vendor_disable_lro_flag))) |
Dhanashri Atre | 1a6a4ce | 2017-05-03 19:40:33 -0700 | [diff] [blame] | 3959 | adapter->dev->features |= NETIF_F_LRO; |
Rajeev Kumar Sirasanagandla | 996e529 | 2016-11-22 21:20:33 +0530 | [diff] [blame] | 3960 | |
| 3961 | /* rcpi info initialization */ |
| 3962 | qdf_mem_zero(&adapter->rcpi, sizeof(adapter->rcpi)); |
| 3963 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3964 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3965 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3966 | error_wmm_init: |
| 3967 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 3968 | hdd_deinit_tx_rx(adapter); |
| 3969 | error_init_txrx: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3970 | hdd_unregister_wext(adapter->dev); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3971 | QDF_BUG(!hdd_vdev_destroy(adapter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3972 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3973 | return status; |
| 3974 | } |
| 3975 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3976 | /** |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3977 | * hdd_deinit_station_mode() - De-initialize the station adapter |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3978 | * @hdd_ctx: global hdd context |
| 3979 | * @adapter: HDD adapter |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3980 | * @rtnl_held: Used to indicate whether or not the caller is holding |
| 3981 | * the kernel rtnl_mutex |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3982 | * |
| 3983 | * This function De-initializes the STA/P2P/OCB adapter. |
| 3984 | * |
| 3985 | * Return: None. |
| 3986 | */ |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3987 | static void hdd_deinit_station_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3988 | struct hdd_adapter *adapter, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3989 | bool rtnl_held) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3990 | { |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3991 | hdd_enter_dev(adapter->dev); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3992 | |
Hanumanth Reddy Pothula | 7a65740 | 2016-09-07 20:59:18 +0530 | [diff] [blame] | 3993 | if (adapter->dev) { |
| 3994 | if (rtnl_held) |
| 3995 | adapter->dev->wireless_handlers = NULL; |
| 3996 | else { |
| 3997 | rtnl_lock(); |
| 3998 | adapter->dev->wireless_handlers = NULL; |
| 3999 | rtnl_unlock(); |
| 4000 | } |
| 4001 | } |
| 4002 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4003 | if (test_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags)) { |
| 4004 | hdd_deinit_tx_rx(adapter); |
| 4005 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 4006 | } |
| 4007 | |
| 4008 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 4009 | hdd_wmm_adapter_close(adapter); |
| 4010 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 4011 | } |
| 4012 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4013 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4014 | hdd_exit(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4015 | } |
| 4016 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4017 | void hdd_deinit_adapter(struct hdd_context *hdd_ctx, |
| 4018 | struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4019 | bool rtnl_held) |
| 4020 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 4021 | hdd_enter(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4022 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4023 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4024 | case QDF_STA_MODE: |
| 4025 | case QDF_P2P_CLIENT_MODE: |
| 4026 | case QDF_P2P_DEVICE_MODE: |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4027 | case QDF_IBSS_MODE: |
| 4028 | case QDF_NDI_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4029 | { |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4030 | hdd_deinit_station_mode(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4031 | break; |
| 4032 | } |
| 4033 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4034 | case QDF_SAP_MODE: |
| 4035 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4036 | { |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4037 | hdd_deinit_ap_mode(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4038 | break; |
| 4039 | } |
| 4040 | |
| 4041 | default: |
| 4042 | break; |
| 4043 | } |
| 4044 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4045 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4046 | } |
| 4047 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4048 | 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] | 4049 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4050 | { |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4051 | struct net_device *dev = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4052 | |
| 4053 | if (adapter) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4054 | dev = adapter->dev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4055 | else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4056 | hdd_err("adapter is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4057 | return; |
| 4058 | } |
| 4059 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 4060 | hdd_nud_deinit_tracking(adapter); |
| 4061 | qdf_mutex_destroy(&adapter->disconnection_status_lock); |
| 4062 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 4063 | hdd_debugfs_exit(adapter); |
Selvaraj, Sridhar | 4ea106e | 2016-08-05 20:34:46 +0530 | [diff] [blame] | 4064 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4065 | /* |
| 4066 | * The adapter is marked as closed. When hdd_wlan_exit() call returns, |
| 4067 | * the driver is almost closed and cannot handle either control |
| 4068 | * messages or data. However, unregister_netdevice() call above will |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4069 | * eventually invoke hdd_stop(ndo_close) driver callback, which attempts |
| 4070 | * to close the active connections(basically excites control path) which |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4071 | * is not right. Setting this flag helps hdd_stop() to recognize that |
| 4072 | * the interface is closed and restricts any operations on that |
| 4073 | */ |
| 4074 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 4075 | |
| 4076 | if (test_bit(NET_DEVICE_REGISTERED, &adapter->event_flags)) { |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4077 | if (rtnl_held) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4078 | unregister_netdevice(dev); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4079 | else |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4080 | unregister_netdev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4081 | /* |
| 4082 | * Note that the adapter is no longer valid at this point |
| 4083 | * since the memory has been reclaimed |
| 4084 | */ |
| 4085 | } |
| 4086 | } |
| 4087 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4088 | 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] | 4089 | tSirMacAddr macAddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4090 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4091 | struct hdd_adapter *adapter; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4092 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4093 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 4094 | if (!qdf_mem_cmp(adapter->mac_addr.bytes, |
| 4095 | macAddr, sizeof(tSirMacAddr))) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4096 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4097 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4098 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4099 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4100 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4101 | } |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4102 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4103 | #ifdef CONFIG_FW_LOGS_BASED_ON_INI |
| 4104 | /** |
| 4105 | * hdd_set_fw_log_params() - Set log parameters to FW |
| 4106 | * @hdd_ctx: HDD Context |
| 4107 | * @adapter: HDD Adapter |
| 4108 | * |
| 4109 | * This function set the FW Debug log level based on the INI. |
| 4110 | * |
| 4111 | * Return: None |
| 4112 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4113 | static void hdd_set_fw_log_params(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4114 | struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4115 | { |
| 4116 | uint8_t count = 0, numentries = 0, |
| 4117 | moduleloglevel[FW_MODULE_LOG_LEVEL_STRING_LENGTH]; |
| 4118 | uint32_t value = 0; |
| 4119 | int ret; |
| 4120 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4121 | if (QDF_GLOBAL_FTM_MODE == cds_get_conparam() || |
| 4122 | (!hdd_ctx->config->enable_fw_log)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4123 | 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] | 4124 | return; |
| 4125 | } |
| 4126 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4127 | /* Enable FW logs based on INI configuration */ |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4128 | hdd_ctx->fw_log_settings.dl_type = |
| 4129 | hdd_ctx->config->enableFwLogType; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4130 | ret = sme_cli_set_command(adapter->session_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4131 | WMI_DBGLOG_TYPE, |
| 4132 | hdd_ctx->config->enableFwLogType, |
| 4133 | DBG_CMD); |
| 4134 | if (ret != 0) |
| 4135 | hdd_err("Failed to enable FW log type ret %d", |
| 4136 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4137 | |
| 4138 | hdd_ctx->fw_log_settings.dl_loglevel = |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4139 | hdd_ctx->config->enableFwLogLevel; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4140 | ret = sme_cli_set_command(adapter->session_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4141 | WMI_DBGLOG_LOG_LEVEL, |
| 4142 | hdd_ctx->config->enableFwLogLevel, |
| 4143 | DBG_CMD); |
| 4144 | if (ret != 0) |
| 4145 | hdd_err("Failed to enable FW log level ret %d", |
| 4146 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4147 | |
| 4148 | hdd_string_to_u8_array( |
| 4149 | hdd_ctx->config->enableFwModuleLogLevel, |
| 4150 | moduleloglevel, |
| 4151 | &numentries, |
| 4152 | FW_MODULE_LOG_LEVEL_STRING_LENGTH); |
| 4153 | |
| 4154 | while (count < numentries) { |
| 4155 | /* |
| 4156 | * FW module log level input string looks like |
| 4157 | * below: |
| 4158 | * gFwDebugModuleLoglevel=<FW Module ID>, |
| 4159 | * <Log Level>,... |
| 4160 | * For example: |
| 4161 | * gFwDebugModuleLoglevel= |
| 4162 | * 1,0,2,1,3,2,4,3,5,4,6,5,7,6 |
| 4163 | * Above input string means : |
| 4164 | * For FW module ID 1 enable log level 0 |
| 4165 | * For FW module ID 2 enable log level 1 |
| 4166 | * For FW module ID 3 enable log level 2 |
| 4167 | * For FW module ID 4 enable log level 3 |
| 4168 | * For FW module ID 5 enable log level 4 |
| 4169 | * For FW module ID 6 enable log level 5 |
| 4170 | * For FW module ID 7 enable log level 6 |
| 4171 | */ |
| 4172 | |
Nishank Aggarwal | e239d96 | 2017-03-03 12:26:02 +0530 | [diff] [blame] | 4173 | if ((moduleloglevel[count] > WLAN_MODULE_ID_MAX) |
| 4174 | || (moduleloglevel[count + 1] > DBGLOG_LVL_MAX)) { |
| 4175 | hdd_err("Module id %d and dbglog level %d input length is more than max", |
| 4176 | moduleloglevel[count], |
| 4177 | moduleloglevel[count + 1]); |
| 4178 | return; |
| 4179 | } |
| 4180 | |
| 4181 | value = moduleloglevel[count] << 16; |
| 4182 | value |= moduleloglevel[count + 1]; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4183 | ret = sme_cli_set_command(adapter->session_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4184 | WMI_DBGLOG_MOD_LOG_LEVEL, |
| 4185 | value, DBG_CMD); |
| 4186 | if (ret != 0) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4187 | hdd_err("Failed to enable FW module log level %d ret %d", |
| 4188 | value, ret); |
| 4189 | |
| 4190 | count += 2; |
| 4191 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4192 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4193 | } |
| 4194 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4195 | static void hdd_set_fw_log_params(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4196 | struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4197 | { |
| 4198 | } |
| 4199 | |
| 4200 | #endif |
| 4201 | |
| 4202 | /** |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4203 | * hdd_configure_chain_mask() - programs chain mask to firmware |
| 4204 | * @adapter: HDD adapter |
| 4205 | * |
| 4206 | * Return: 0 on success or errno on failure |
| 4207 | */ |
| 4208 | static int hdd_configure_chain_mask(struct hdd_adapter *adapter) |
| 4209 | { |
| 4210 | int ret_val; |
| 4211 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 4212 | |
| 4213 | hdd_debug("enable2x2: %d, lte_coex: %d, ChainMask1x1: tx: %d rx: %d", |
| 4214 | hdd_ctx->config->enable2x2, hdd_ctx->lte_coex_ant_share, |
| 4215 | hdd_ctx->config->txchainmask1x1, |
| 4216 | hdd_ctx->config->rxchainmask1x1); |
| 4217 | hdd_debug("disable_DBS: %d, tx_chain_mask_2g: %d, rx_chain_mask_2g: %d", |
| 4218 | hdd_ctx->config->dual_mac_feature_disable, |
| 4219 | hdd_ctx->config->tx_chain_mask_2g, |
| 4220 | hdd_ctx->config->rx_chain_mask_2g); |
| 4221 | hdd_debug("tx_chain_mask_5g: %d, rx_chain_mask_5g: %d", |
| 4222 | hdd_ctx->config->tx_chain_mask_5g, |
| 4223 | hdd_ctx->config->rx_chain_mask_5g); |
Liangwei Dong | 22810e8 | 2018-03-15 03:42:12 -0400 | [diff] [blame] | 4224 | hdd_debug("enable_bt_chain_separation %d", |
| 4225 | hdd_ctx->config->enable_bt_chain_separation); |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4226 | |
Liangwei Dong | 22810e8 | 2018-03-15 03:42:12 -0400 | [diff] [blame] | 4227 | if (hdd_ctx->config->enable2x2 && |
| 4228 | !hdd_ctx->config->enable_bt_chain_separation) { |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4229 | hdd_info("2x2 enabled. skip chain mask programming"); |
| 4230 | return 0; |
| 4231 | } |
| 4232 | |
Naveen Rawat | b54c72b | 2018-02-05 10:39:06 -0800 | [diff] [blame] | 4233 | if (hdd_ctx->config->dual_mac_feature_disable != |
| 4234 | DISABLE_DBS_CXN_AND_SCAN) { |
| 4235 | hdd_info("DBS enabled(%d). skip chain mask programming", |
| 4236 | hdd_ctx->config->dual_mac_feature_disable); |
| 4237 | return 0; |
| 4238 | } |
| 4239 | |
Naveen Rawat | dacb503 | 2018-02-08 15:23:24 -0800 | [diff] [blame] | 4240 | if (hdd_ctx->lte_coex_ant_share) { |
| 4241 | hdd_info("lte ant sharing enabled. skip chainmask programming"); |
| 4242 | return 0; |
| 4243 | } |
| 4244 | |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4245 | if (hdd_ctx->config->txchainmask1x1) { |
| 4246 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4247 | WMI_PDEV_PARAM_TX_CHAIN_MASK, |
| 4248 | hdd_ctx->config->txchainmask1x1, |
| 4249 | PDEV_CMD); |
| 4250 | if (ret_val) |
| 4251 | goto error; |
| 4252 | } |
| 4253 | |
| 4254 | if (hdd_ctx->config->rxchainmask1x1) { |
| 4255 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4256 | WMI_PDEV_PARAM_RX_CHAIN_MASK, |
| 4257 | hdd_ctx->config->rxchainmask1x1, |
| 4258 | PDEV_CMD); |
| 4259 | if (ret_val) |
| 4260 | goto error; |
| 4261 | } |
| 4262 | |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4263 | if (hdd_ctx->config->txchainmask1x1 || |
| 4264 | hdd_ctx->config->rxchainmask1x1) { |
| 4265 | hdd_info("band agnostic tx/rx chain mask set. skip per band chain mask"); |
| 4266 | return 0; |
| 4267 | } |
| 4268 | |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4269 | if (hdd_ctx->config->tx_chain_mask_2g) { |
| 4270 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4271 | WMI_PDEV_PARAM_TX_CHAIN_MASK_2G, |
| 4272 | hdd_ctx->config->tx_chain_mask_2g, PDEV_CMD); |
| 4273 | if (0 != ret_val) |
| 4274 | goto error; |
| 4275 | } |
| 4276 | |
| 4277 | if (hdd_ctx->config->rx_chain_mask_2g) { |
| 4278 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4279 | WMI_PDEV_PARAM_RX_CHAIN_MASK_2G, |
| 4280 | hdd_ctx->config->rx_chain_mask_2g, PDEV_CMD); |
| 4281 | if (0 != ret_val) |
| 4282 | goto error; |
| 4283 | } |
| 4284 | |
| 4285 | if (hdd_ctx->config->tx_chain_mask_5g) { |
| 4286 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4287 | WMI_PDEV_PARAM_TX_CHAIN_MASK_5G, |
| 4288 | hdd_ctx->config->tx_chain_mask_5g, PDEV_CMD); |
| 4289 | if (0 != ret_val) |
| 4290 | goto error; |
| 4291 | } |
| 4292 | |
| 4293 | if (hdd_ctx->config->rx_chain_mask_5g) { |
| 4294 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4295 | WMI_PDEV_PARAM_RX_CHAIN_MASK_5G, |
| 4296 | hdd_ctx->config->rx_chain_mask_5g, PDEV_CMD); |
| 4297 | if (0 != ret_val) |
| 4298 | goto error; |
| 4299 | } |
| 4300 | |
| 4301 | return 0; |
| 4302 | |
| 4303 | error: |
| 4304 | hdd_err("WMI PDEV set param failed %d", ret_val); |
| 4305 | return -EINVAL; |
| 4306 | } |
| 4307 | |
| 4308 | /** |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4309 | * hdd_set_fw_params() - Set parameters to firmware |
| 4310 | * @adapter: HDD adapter |
| 4311 | * |
| 4312 | * This function Sets various parameters to fw once the |
| 4313 | * adapter is started. |
| 4314 | * |
| 4315 | * Return: 0 on success or errno on failure |
| 4316 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4317 | int hdd_set_fw_params(struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4318 | { |
| 4319 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4320 | struct hdd_context *hdd_ctx; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4321 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 4322 | hdd_enter_dev(adapter->dev); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4323 | |
| 4324 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 4325 | if (!hdd_ctx) |
| 4326 | return -EINVAL; |
| 4327 | |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4328 | if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE) { |
| 4329 | hdd_debug("FTM Mode is active; nothing to do"); |
| 4330 | return 0; |
| 4331 | } |
| 4332 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4333 | ret = sme_cli_set_command(adapter->session_id, |
Ashish Kumar Dhanotiya | b8630ab | 2017-07-21 14:18:14 +0530 | [diff] [blame] | 4334 | WMI_PDEV_PARAM_DTIM_SYNTH, |
| 4335 | hdd_ctx->config->enable_lprx, PDEV_CMD); |
| 4336 | if (ret) { |
| 4337 | hdd_err("Failed to set LPRx"); |
| 4338 | goto error; |
| 4339 | } |
| 4340 | |
Ashish Kumar Dhanotiya | 191d164 | 2018-02-08 17:43:09 +0530 | [diff] [blame] | 4341 | |
| 4342 | ret = sme_cli_set_command( |
| 4343 | adapter->session_id, |
| 4344 | WMI_PDEV_PARAM_1CH_DTIM_OPTIMIZED_CHAIN_SELECTION, |
| 4345 | hdd_ctx->config->enable_dtim_selection_diversity, |
| 4346 | PDEV_CMD); |
| 4347 | if (ret) { |
| 4348 | hdd_err("Failed to set DTIM_OPTIMIZED_CHAIN_SELECTION"); |
| 4349 | goto error; |
| 4350 | } |
| 4351 | |
Ashish Kumar Dhanotiya | 48dac7d | 2018-03-28 14:59:50 +0530 | [diff] [blame] | 4352 | ret = sme_cli_set_command( |
| 4353 | adapter->session_id, |
| 4354 | WMI_PDEV_PARAM_TX_SCH_DELAY, |
| 4355 | hdd_ctx->config->enable_tx_sch_delay, |
| 4356 | PDEV_CMD); |
| 4357 | if (ret) { |
| 4358 | hdd_err("Failed to set WMI_PDEV_PARAM_TX_SCH_DELAY"); |
| 4359 | goto error; |
| 4360 | } |
| 4361 | |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4362 | if (adapter->device_mode == QDF_STA_MODE) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4363 | sme_set_smps_cfg(adapter->session_id, |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4364 | HDD_STA_SMPS_PARAM_UPPER_BRSSI_THRESH, |
| 4365 | hdd_ctx->config->upper_brssi_thresh); |
| 4366 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4367 | sme_set_smps_cfg(adapter->session_id, |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4368 | HDD_STA_SMPS_PARAM_LOWER_BRSSI_THRESH, |
| 4369 | hdd_ctx->config->lower_brssi_thresh); |
| 4370 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4371 | sme_set_smps_cfg(adapter->session_id, |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4372 | HDD_STA_SMPS_PARAM_DTIM_1CHRX_ENABLE, |
| 4373 | hdd_ctx->config->enable_dtim_1chrx); |
| 4374 | } |
| 4375 | |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4376 | if (hdd_ctx->config->enable2x2) { |
| 4377 | hdd_debug("configuring 2x2 mode fw params"); |
| 4378 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4379 | ret = sme_cli_set_command(adapter->session_id, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4380 | WMI_PDEV_PARAM_ENABLE_CCK_TXFIR_OVERRIDE, |
| 4381 | hdd_ctx->config->enable_cck_tx_fir_override, |
| 4382 | PDEV_CMD); |
| 4383 | if (ret) { |
| 4384 | hdd_err("WMI_PDEV_PARAM_ENABLE_CCK_TXFIR_OVERRIDE set failed %d", |
| 4385 | ret); |
| 4386 | goto error; |
| 4387 | } |
Liangwei Dong | 22810e8 | 2018-03-15 03:42:12 -0400 | [diff] [blame] | 4388 | |
| 4389 | if (hdd_configure_chain_mask(adapter)) |
| 4390 | goto error; |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4391 | } else { |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4392 | #define HDD_DTIM_1CHAIN_RX_ID 0x5 |
| 4393 | #define HDD_SMPS_PARAM_VALUE_S 29 |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4394 | hdd_debug("configuring 1x1 mode fw params"); |
| 4395 | |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4396 | /* |
| 4397 | * Disable DTIM 1 chain Rx when in 1x1, |
| 4398 | * we are passing two value |
| 4399 | * as param_id << 29 | param_value. |
| 4400 | * Below param_value = 0(disable) |
| 4401 | */ |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4402 | ret = sme_cli_set_command(adapter->session_id, |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4403 | WMI_STA_SMPS_PARAM_CMDID, |
| 4404 | HDD_DTIM_1CHAIN_RX_ID << |
| 4405 | HDD_SMPS_PARAM_VALUE_S, |
| 4406 | VDEV_CMD); |
| 4407 | if (ret) { |
| 4408 | hdd_err("DTIM 1 chain set failed %d", ret); |
| 4409 | goto error; |
| 4410 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4411 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4412 | #undef HDD_DTIM_1CHAIN_RX_ID |
| 4413 | #undef HDD_SMPS_PARAM_VALUE_S |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4414 | |
| 4415 | if (hdd_configure_chain_mask(adapter)) |
| 4416 | goto error; |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4417 | } |
| 4418 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4419 | ret = sme_cli_set_command(adapter->session_id, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4420 | WMI_PDEV_PARAM_HYST_EN, |
| 4421 | hdd_ctx->config->enableMemDeepSleep, |
| 4422 | PDEV_CMD); |
| 4423 | if (ret) { |
| 4424 | hdd_err("WMI_PDEV_PARAM_HYST_EN set failed %d", ret); |
| 4425 | goto error; |
| 4426 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4427 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4428 | ret = sme_cli_set_command(adapter->session_id, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4429 | WMI_VDEV_PARAM_ENABLE_RTSCTS, |
| 4430 | hdd_ctx->config->rts_profile, |
| 4431 | VDEV_CMD); |
| 4432 | if (ret) { |
| 4433 | hdd_err("FAILED TO SET RTSCTS Profile ret:%d", ret); |
| 4434 | goto error; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4435 | } |
| 4436 | |
Deepak Dhamdhere | 612392c | 2016-08-28 02:56:51 -0700 | [diff] [blame] | 4437 | hdd_debug("SET AMSDU num %d", hdd_ctx->config->max_amsdu_num); |
| 4438 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4439 | ret = wma_cli_set_command(adapter->session_id, |
Deepak Dhamdhere | 612392c | 2016-08-28 02:56:51 -0700 | [diff] [blame] | 4440 | GEN_VDEV_PARAM_AMSDU, |
| 4441 | hdd_ctx->config->max_amsdu_num, |
| 4442 | GEN_CMD); |
| 4443 | if (ret != 0) { |
| 4444 | hdd_err("GEN_VDEV_PARAM_AMSDU set failed %d", ret); |
| 4445 | goto error; |
| 4446 | } |
| 4447 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4448 | hdd_set_fw_log_params(hdd_ctx, adapter); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4449 | hdd_exit(); |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4450 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4451 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4452 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4453 | error: |
| 4454 | return -EINVAL; |
| 4455 | } |
| 4456 | |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4457 | /** |
| 4458 | * hdd_open_adapter() - open and setup the hdd adatper |
| 4459 | * @hdd_ctx: global hdd context |
| 4460 | * @session_type: type of the interface to be created |
| 4461 | * @iface_name: User-visible name of the interface |
| 4462 | * @macAddr: MAC address to assign to the interface |
| 4463 | * @name_assign_type: the name of assign type of the netdev |
| 4464 | * @rtnl_held: the rtnl lock hold flag |
| 4465 | * |
| 4466 | * This function open and setup the hdd adpater according to the device |
| 4467 | * type request, assign the name, the mac address assigned, and then prepared |
| 4468 | * the hdd related parameters, queue, lock and ready to start. |
| 4469 | * |
| 4470 | * Return: the pointer of hdd adapter, otherwise NULL. |
| 4471 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4472 | 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] | 4473 | const char *iface_name, tSirMacAddr macAddr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4474 | unsigned char name_assign_type, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 4475 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4476 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4477 | struct hdd_adapter *adapter = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4478 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4479 | |
| 4480 | if (hdd_ctx->current_intf_count >= hdd_ctx->max_intf_count) { |
| 4481 | /* |
| 4482 | * Max limit reached on the number of vdevs configured by the |
| 4483 | * host. Return error |
| 4484 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4485 | hdd_err("Unable to add virtual intf: currentVdevCnt=%d,hostConfiguredVdevCnt=%d", |
| 4486 | hdd_ctx->current_intf_count, hdd_ctx->max_intf_count); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4487 | return NULL; |
| 4488 | } |
| 4489 | |
| 4490 | if (macAddr == NULL) { |
| 4491 | /* Not received valid macAddr */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4492 | 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] | 4493 | return NULL; |
| 4494 | } |
| 4495 | status = hdd_check_for_existing_macaddr(hdd_ctx, macAddr); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4496 | if (QDF_STATUS_E_FAILURE == status) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4497 | hdd_err("Duplicate MAC addr: " MAC_ADDRESS_STR |
| 4498 | " already exists", |
| 4499 | MAC_ADDR_ARRAY(macAddr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4500 | return NULL; |
| 4501 | } |
| 4502 | |
| 4503 | switch (session_type) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4504 | case QDF_STA_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4505 | /* Reset locally administered bit if the device mode is STA */ |
| 4506 | WLAN_HDD_RESET_LOCALLY_ADMINISTERED_BIT(macAddr); |
Arunk Khandavalli | 794fdfc | 2017-09-13 18:00:40 +0530 | [diff] [blame] | 4507 | hdd_info("locally administered bit reset in sta mode: " |
| 4508 | MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4509 | /* fall through */ |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4510 | case QDF_P2P_CLIENT_MODE: |
| 4511 | case QDF_P2P_DEVICE_MODE: |
| 4512 | case QDF_OCB_MODE: |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 4513 | case QDF_NDI_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4514 | case QDF_MONITOR_MODE: |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4515 | adapter = hdd_alloc_station_adapter(hdd_ctx, macAddr, |
| 4516 | name_assign_type, |
| 4517 | iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4518 | |
| 4519 | if (NULL == adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4520 | hdd_err("failed to allocate adapter for session %d", |
| 4521 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4522 | return NULL; |
| 4523 | } |
| 4524 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4525 | if (QDF_P2P_CLIENT_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4526 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_CLIENT; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4527 | else if (QDF_P2P_DEVICE_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4528 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_DEVICE; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4529 | else if (QDF_MONITOR_MODE == session_type) |
| 4530 | adapter->wdev.iftype = NL80211_IFTYPE_MONITOR; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4531 | else |
| 4532 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 4533 | |
| 4534 | adapter->device_mode = session_type; |
| 4535 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4536 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4537 | /* |
| 4538 | * Workqueue which gets scheduled in IPv4 notification |
| 4539 | * callback |
| 4540 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4541 | INIT_WORK(&adapter->ipv4_notifier_work, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4542 | hdd_ipv4_notifier_work_queue); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4543 | |
| 4544 | #ifdef WLAN_NS_OFFLOAD |
| 4545 | /* |
| 4546 | * Workqueue which gets scheduled in IPv6 |
| 4547 | * notification callback. |
| 4548 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4549 | INIT_WORK(&adapter->ipv6_notifier_work, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4550 | hdd_ipv6_notifier_work_queue); |
| 4551 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4552 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4553 | if (QDF_STATUS_SUCCESS != status) |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 4554 | goto err_free_netdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4555 | |
| 4556 | /* Stop the Interface TX queue. */ |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4557 | hdd_debug("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4558 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4559 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4560 | WLAN_CONTROL_PATH); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4561 | |
Ravi Joshi | 1a29256 | 2017-05-18 16:28:54 -0700 | [diff] [blame] | 4562 | /* Initialize NAN Data Interface */ |
| 4563 | if (QDF_NDI_MODE == session_type) { |
| 4564 | status = hdd_init_nan_data_mode(adapter); |
| 4565 | if (QDF_STATUS_SUCCESS != status) |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 4566 | goto err_free_netdev; |
Ravi Joshi | 1a29256 | 2017-05-18 16:28:54 -0700 | [diff] [blame] | 4567 | } |
| 4568 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 4569 | hdd_nud_init_tracking(adapter); |
| 4570 | |
| 4571 | qdf_mutex_create(&adapter->disconnection_status_lock); |
| 4572 | |
Ravi Joshi | 1a29256 | 2017-05-18 16:28:54 -0700 | [diff] [blame] | 4573 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4574 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4575 | case QDF_P2P_GO_MODE: |
| 4576 | case QDF_SAP_MODE: |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4577 | adapter = hdd_wlan_create_ap_dev(hdd_ctx, macAddr, |
| 4578 | name_assign_type, |
| 4579 | (uint8_t *) iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4580 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4581 | hdd_err("failed to allocate adapter for session %d", |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4582 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4583 | return NULL; |
| 4584 | } |
| 4585 | |
| 4586 | adapter->wdev.iftype = |
| 4587 | (session_type == |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4588 | QDF_SAP_MODE) ? NL80211_IFTYPE_AP : |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4589 | NL80211_IFTYPE_P2P_GO; |
| 4590 | adapter->device_mode = session_type; |
| 4591 | |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 4592 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4593 | if (QDF_STATUS_SUCCESS != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4594 | goto err_free_netdev; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4595 | |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4596 | hdd_debug("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4597 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4598 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4599 | WLAN_CONTROL_PATH); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4600 | |
| 4601 | /* |
| 4602 | * Workqueue which gets scheduled in IPv4 notification |
| 4603 | * callback |
| 4604 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4605 | INIT_WORK(&adapter->ipv4_notifier_work, |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4606 | hdd_ipv4_notifier_work_queue); |
| 4607 | |
| 4608 | #ifdef WLAN_NS_OFFLOAD |
| 4609 | /* |
| 4610 | * Workqueue which gets scheduled in IPv6 |
| 4611 | * notification callback. |
| 4612 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4613 | INIT_WORK(&adapter->ipv6_notifier_work, |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4614 | hdd_ipv6_notifier_work_queue); |
| 4615 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4616 | break; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4617 | case QDF_FTM_MODE: |
| 4618 | adapter = hdd_alloc_station_adapter(hdd_ctx, macAddr, |
| 4619 | name_assign_type, |
Lin Bai | 1c67848 | 2017-12-18 18:29:11 +0800 | [diff] [blame] | 4620 | iface_name); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4621 | if (NULL == adapter) { |
| 4622 | hdd_err("Failed to allocate adapter for FTM mode"); |
| 4623 | return NULL; |
| 4624 | } |
| 4625 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 4626 | adapter->device_mode = session_type; |
| 4627 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4628 | if (QDF_STATUS_SUCCESS != status) |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 4629 | goto err_free_netdev; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4630 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4631 | /* Stop the Interface TX queue. */ |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4632 | hdd_debug("Disabling queues"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4633 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4634 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4635 | WLAN_CONTROL_PATH); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4636 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4637 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4638 | hdd_err("Invalid session type %d", session_type); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4639 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4640 | return NULL; |
| 4641 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4642 | |
hqu | eaa33ee | 2017-05-04 17:56:35 +0800 | [diff] [blame] | 4643 | INIT_WORK(&adapter->scan_block_work, wlan_hdd_cfg80211_scan_block_cb); |
| 4644 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4645 | if (QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4646 | /* Add it to the hdd's session list. */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4647 | status = hdd_add_adapter_back(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4648 | } |
| 4649 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4650 | if (QDF_STATUS_SUCCESS != status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4651 | if (NULL != adapter) { |
| 4652 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 4653 | adapter = NULL; |
| 4654 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4655 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4656 | return NULL; |
| 4657 | } |
| 4658 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4659 | if (QDF_STATUS_SUCCESS == status) { |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 4660 | policy_mgr_set_concurrency_mode(hdd_ctx->hdd_psoc, |
| 4661 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4662 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4663 | /* Adapter successfully added. Increment the vdev count */ |
| 4664 | hdd_ctx->current_intf_count++; |
| 4665 | |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4666 | hdd_debug("current_intf_count=%d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4667 | hdd_ctx->current_intf_count); |
| 4668 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 4669 | hdd_check_and_restart_sap_with_non_dfs_acs(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4670 | } |
| 4671 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 4672 | if (QDF_STATUS_SUCCESS != hdd_debugfs_init(adapter)) |
Mahesh Kumar Kalikot Veetil | 80dda9a | 2017-07-17 11:38:03 -0700 | [diff] [blame] | 4673 | hdd_err("Interface %s wow debug_fs init failed", |
| 4674 | netdev_name(adapter->dev)); |
| 4675 | |
| 4676 | hdd_info("%s interface created. iftype: %d", netdev_name(adapter->dev), |
| 4677 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4678 | |
| 4679 | return adapter; |
| 4680 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4681 | err_free_netdev: |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 4682 | wlan_hdd_release_intf_addr(hdd_ctx, adapter->mac_addr.bytes); |
Hanumanth Reddy Pothula | 00a39e7 | 2016-11-09 21:32:16 +0530 | [diff] [blame] | 4683 | free_netdev(adapter->dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4684 | |
| 4685 | return NULL; |
| 4686 | } |
| 4687 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 4688 | #ifdef MSM_PLATFORM |
| 4689 | static inline |
| 4690 | void hdd_cancel_bus_bw_work(struct hdd_context *hdd_ctx) |
| 4691 | { |
| 4692 | cancel_work_sync(&hdd_ctx->bus_bw_work); |
| 4693 | } |
| 4694 | #else |
| 4695 | static inline |
| 4696 | void hdd_cancel_bus_bw_work(struct hdd_context *hdd_ctx) |
| 4697 | { |
| 4698 | } |
| 4699 | #endif |
| 4700 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4701 | 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] | 4702 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4703 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4704 | /* |
| 4705 | * Here we are stopping global bus_bw timer & work per adapter. |
| 4706 | * |
| 4707 | * The reason is to fix one race condition between |
| 4708 | * bus bandwidth work and cleaning up an adapter. |
| 4709 | * Under some conditions, it is possible for the bus bandwidth |
| 4710 | * work to access a particularly destroyed adapter, leading to |
| 4711 | * use-after-free. |
| 4712 | */ |
| 4713 | hdd_debug("wait for bus bw work to flush"); |
| 4714 | hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 4715 | hdd_bus_bw_cancel_work(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4716 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4717 | /* cleanup adapter */ |
| 4718 | policy_mgr_clear_concurrency_mode(hdd_ctx->hdd_psoc, |
| 4719 | adapter->device_mode); |
| 4720 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 4721 | hdd_remove_adapter(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4722 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4723 | /* conditionally restart the bw timer */ |
| 4724 | hdd_bus_bw_compute_timer_try_start(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4725 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4726 | /* Adapter removed. Decrement vdev count */ |
| 4727 | if (hdd_ctx->current_intf_count != 0) |
| 4728 | hdd_ctx->current_intf_count--; |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 4729 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4730 | /* Fw will take care incase of concurrency */ |
| 4731 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4732 | } |
| 4733 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 4734 | /** |
| 4735 | * hdd_close_all_adapters - Close all open adapters |
| 4736 | * @hdd_ctx: Hdd context |
| 4737 | * rtnl_held: True if RTNL lock held |
| 4738 | * |
| 4739 | * Close all open adapters. |
| 4740 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 4741 | * Return: QDF status code |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 4742 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4743 | 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] | 4744 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4745 | struct hdd_adapter *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4746 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4747 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 4748 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4749 | |
| 4750 | do { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4751 | status = hdd_remove_front_adapter(hdd_ctx, &adapter); |
| 4752 | if (QDF_IS_STATUS_SUCCESS(status)) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4753 | wlan_hdd_release_intf_addr(hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4754 | adapter->mac_addr.bytes); |
| 4755 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 4756 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4757 | /* Adapter removed. Decrement vdev count */ |
| 4758 | if (hdd_ctx->current_intf_count != 0) |
| 4759 | hdd_ctx->current_intf_count--; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4760 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4761 | } while (QDF_IS_STATUS_SUCCESS(status)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4762 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4763 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4764 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4765 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4766 | } |
| 4767 | |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4768 | void wlan_hdd_reset_prob_rspies(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4769 | { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4770 | struct qdf_mac_addr *bssid = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4771 | tSirUpdateIE updateIE; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4772 | |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4773 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4774 | case QDF_STA_MODE: |
| 4775 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4776 | { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4777 | struct hdd_station_ctx *sta_ctx = |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4778 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4779 | bssid = &sta_ctx->conn_info.bssId; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4780 | break; |
| 4781 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4782 | case QDF_SAP_MODE: |
| 4783 | case QDF_P2P_GO_MODE: |
| 4784 | case QDF_IBSS_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4785 | { |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 4786 | bssid = &adapter->mac_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4787 | break; |
| 4788 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4789 | case QDF_FTM_MODE: |
| 4790 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4791 | default: |
| 4792 | /* |
| 4793 | * wlan_hdd_reset_prob_rspies should not have been called |
| 4794 | * for these kind of devices |
| 4795 | */ |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4796 | hdd_err("Unexpected request for the current device type %d", |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4797 | adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4798 | return; |
| 4799 | } |
| 4800 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 4801 | qdf_copy_macaddr(&updateIE.bssid, bssid); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4802 | updateIE.smeSessionId = adapter->session_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4803 | updateIE.ieBufferlength = 0; |
| 4804 | updateIE.pAdditionIEBuffer = NULL; |
| 4805 | updateIE.append = true; |
| 4806 | updateIE.notify = false; |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4807 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(adapter), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4808 | &updateIE, |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4809 | eUPDATE_IE_PROBE_RESP) == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4810 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4811 | } |
| 4812 | } |
| 4813 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 4814 | QDF_STATUS hdd_stop_adapter(struct hdd_context *hdd_ctx, |
| 4815 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4816 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 4817 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 4818 | struct csr_roam_profile *roam_profile; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4819 | union iwreq_data wrqu; |
| 4820 | tSirUpdateIE updateIE; |
| 4821 | unsigned long rc; |
Arunk Khandavalli | 96c122f | 2017-10-17 11:49:36 +0530 | [diff] [blame] | 4822 | tsap_Config_t *sap_config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4823 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 4824 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4825 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 4826 | hdd_nud_ignore_tracking(adapter, true); |
| 4827 | hdd_nud_reset_tracking(adapter); |
| 4828 | |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4829 | hdd_debug("Disabling queues"); |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4830 | wlan_hdd_netif_queue_control(adapter, |
| 4831 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4832 | WLAN_CONTROL_PATH); |
Tushnim Bhattacharyya | 9bd058f | 2017-12-27 14:01:31 -0800 | [diff] [blame] | 4833 | /* |
| 4834 | * if this is the last active connection check & stop the |
| 4835 | * opportunistic timer first |
| 4836 | */ |
| 4837 | if (((policy_mgr_get_connection_count(hdd_ctx->hdd_psoc) == 1) && |
| 4838 | (policy_mgr_mode_specific_connection_count(hdd_ctx->hdd_psoc, |
| 4839 | policy_mgr_convert_device_mode_to_qdf_type( |
| 4840 | adapter->device_mode), NULL) == 1)) || |
| 4841 | !policy_mgr_get_connection_count(hdd_ctx->hdd_psoc)) |
| 4842 | policy_mgr_check_and_stop_opportunistic_timer( |
| 4843 | hdd_ctx->hdd_psoc, adapter->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4844 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4845 | case QDF_STA_MODE: |
| 4846 | case QDF_P2P_CLIENT_MODE: |
| 4847 | case QDF_IBSS_MODE: |
| 4848 | case QDF_P2P_DEVICE_MODE: |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4849 | case QDF_NDI_MODE: |
| 4850 | if ((QDF_NDI_MODE == adapter->device_mode) || |
| 4851 | hdd_conn_is_connected( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4852 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)) || |
| 4853 | hdd_is_connecting( |
| 4854 | WLAN_HDD_GET_STATION_CTX_PTR(adapter))) { |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4855 | INIT_COMPLETION(adapter->disconnect_comp_var); |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 4856 | roam_profile = hdd_roam_profile(adapter); |
| 4857 | /* For NDI do not use roam_profile */ |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4858 | if (QDF_NDI_MODE == adapter->device_mode) |
| 4859 | qdf_ret_status = sme_roam_disconnect( |
| 4860 | hdd_ctx->hHal, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4861 | adapter->session_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4862 | eCSR_DISCONNECT_REASON_NDI_DELETE); |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 4863 | else if (roam_profile->BSSType == |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4864 | eCSR_BSS_TYPE_START_IBSS) |
| 4865 | qdf_ret_status = sme_roam_disconnect( |
| 4866 | hdd_ctx->hHal, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4867 | adapter->session_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4868 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
Jingxiang Ge | cc7e1f4 | 2017-11-14 16:21:27 +0800 | [diff] [blame] | 4869 | else if (QDF_STA_MODE == adapter->device_mode) { |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 4870 | qdf_ret_status = |
| 4871 | wlan_hdd_try_disconnect(adapter); |
Jingxiang Ge | cc7e1f4 | 2017-11-14 16:21:27 +0800 | [diff] [blame] | 4872 | hdd_debug("Send disconnected event to userspace"); |
| 4873 | wlan_hdd_cfg80211_indicate_disconnect( |
| 4874 | adapter->dev, true, |
| 4875 | WLAN_REASON_UNSPECIFIED); |
Jeff Johnson | 109e79d | 2018-02-27 15:10:04 -0800 | [diff] [blame] | 4876 | } else |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4877 | qdf_ret_status = sme_roam_disconnect( |
| 4878 | hdd_ctx->hHal, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4879 | adapter->session_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4880 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4881 | /* success implies disconnect command got |
| 4882 | * queued up successfully |
| 4883 | */ |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 4884 | if (qdf_ret_status == QDF_STATUS_SUCCESS && |
| 4885 | QDF_STA_MODE != adapter->device_mode) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4886 | rc = wait_for_completion_timeout( |
| 4887 | &adapter->disconnect_comp_var, |
| 4888 | msecs_to_jiffies |
| 4889 | (WLAN_WAIT_TIME_DISCONNECT)); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4890 | if (!rc) |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 4891 | hdd_warn("disconn_comp_var wait fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4892 | } |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 4893 | if (qdf_ret_status != QDF_STATUS_SUCCESS) |
| 4894 | hdd_warn("failed to post disconnect"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4895 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 4896 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 4897 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 4898 | wireless_send_event(adapter->dev, SIOCGIWAP, &wrqu, |
| 4899 | NULL); |
Sachin Ahuja | 988fd10 | 2016-09-15 17:16:25 +0530 | [diff] [blame] | 4900 | } |
Wu Gao | aceec6c | 2017-08-30 16:08:21 +0800 | [diff] [blame] | 4901 | wlan_hdd_scan_abort(adapter); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4902 | |
Abhishek Singh | 1e94d7a | 2015-11-30 17:26:54 +0530 | [diff] [blame] | 4903 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 4904 | hdd_clear_fils_connection_info(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4905 | |
| 4906 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4907 | cancel_work_sync(&adapter->ipv4_notifier_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4908 | #endif |
| 4909 | |
| 4910 | hdd_deregister_tx_flow_control(adapter); |
| 4911 | |
| 4912 | #ifdef WLAN_NS_OFFLOAD |
| 4913 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4914 | cancel_work_sync(&adapter->ipv6_notifier_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4915 | #endif |
| 4916 | #endif |
| 4917 | |
Hanumanth Reddy Pothula | 0586014 | 2017-07-26 18:45:27 +0530 | [diff] [blame] | 4918 | if (adapter->device_mode == QDF_STA_MODE) |
| 4919 | wlan_cfg80211_sched_scan_stop(hdd_ctx->hdd_pdev, |
| 4920 | adapter->dev); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 4921 | |
| 4922 | if (wlan_hdd_try_disconnect(adapter)) { |
| 4923 | hdd_err("Error: Can't disconnect adapter"); |
| 4924 | return QDF_STATUS_E_FAILURE; |
Krunal Soni | 985b813 | 2017-02-10 18:49:08 -0800 | [diff] [blame] | 4925 | } |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 4926 | |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 4927 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4928 | break; |
| 4929 | |
Rajeev Kumar | 3b90620 | 2018-02-01 10:55:14 -0800 | [diff] [blame] | 4930 | case QDF_MONITOR_MODE: |
| 4931 | wlan_hdd_scan_abort(adapter); |
| 4932 | hdd_deregister_tx_flow_control(adapter); |
| 4933 | hdd_vdev_destroy(adapter); |
| 4934 | break; |
| 4935 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4936 | case QDF_SAP_MODE: |
wadesong | f9b15ed | 2017-12-14 14:12:32 +0800 | [diff] [blame] | 4937 | wlan_hdd_scan_abort(adapter); |
Govind Singh | 1dab23b | 2017-08-12 13:31:00 +0530 | [diff] [blame] | 4938 | /* Flush IPA exception path packets */ |
Arunk Khandavalli | 96c122f | 2017-10-17 11:49:36 +0530 | [diff] [blame] | 4939 | sap_config = &adapter->session.ap.sap_config; |
| 4940 | if (sap_config) |
| 4941 | wlansap_reset_sap_config_add_ie(sap_config, |
| 4942 | eUPDATE_IE_ALL); |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 4943 | ucfg_ipa_flush(hdd_ctx->hdd_pdev); |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 4944 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 4945 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4946 | case QDF_P2P_GO_MODE: |
Kiran Kumar Lokere | 85cb36b | 2017-09-14 15:19:14 -0700 | [diff] [blame] | 4947 | if (QDF_SAP_MODE == adapter->device_mode) { |
| 4948 | if (test_bit(ACS_PENDING, &adapter->event_flags)) { |
| 4949 | cds_flush_delayed_work( |
| 4950 | &adapter->acs_pending_work); |
| 4951 | clear_bit(ACS_PENDING, &adapter->event_flags); |
| 4952 | } |
| 4953 | } |
Krunal Soni | 2220839 | 2017-09-29 18:10:34 -0700 | [diff] [blame] | 4954 | cds_flush_work(&adapter->sap_stop_bss_work); |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 4955 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4956 | /* Any softap specific cleanup here... */ |
Abhinav Kumar | b638b5d | 2018-03-26 12:25:41 +0530 | [diff] [blame] | 4957 | qdf_atomic_set(&adapter->session.ap.acs_in_progress, 0); |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 4958 | wlan_hdd_undo_acs(adapter); |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4959 | if (adapter->device_mode == QDF_P2P_GO_MODE) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4960 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 4961 | |
| 4962 | hdd_deregister_tx_flow_control(adapter); |
| 4963 | |
Kapil Gupta | c1224bf | 2017-06-22 21:22:40 +0530 | [diff] [blame] | 4964 | hdd_destroy_acs_timer(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4965 | mutex_lock(&hdd_ctx->sap_lock); |
| 4966 | if (test_bit(SOFTAP_BSS_STARTED, &adapter->event_flags)) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4967 | QDF_STATUS status; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 4968 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4969 | |
| 4970 | /* Stop Bss. */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4971 | status = wlansap_stop_bss( |
| 4972 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4973 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4974 | if (QDF_IS_STATUS_SUCCESS(status)) { |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 4975 | struct hdd_hostapd_state *hostapd_state = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4976 | WLAN_HDD_GET_HOSTAP_STATE_PTR(adapter); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 4977 | qdf_event_reset(&hostapd_state-> |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 4978 | qdf_stop_bss_event); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 4979 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 4980 | qdf_wait_for_event_completion( |
| 4981 | &hostapd_state->qdf_stop_bss_event, |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 4982 | SME_CMD_TIMEOUT_VALUE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4983 | |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 4984 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4985 | hdd_err("failure waiting for wlansap_stop_bss %d", |
| 4986 | qdf_status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4987 | } |
| 4988 | } else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4989 | hdd_err("failure in wlansap_stop_bss"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4990 | } |
| 4991 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 4992 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
| 4993 | adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4994 | adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 4995 | hdd_green_ap_start_state_mc(hdd_ctx, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 4996 | adapter->device_mode, |
| 4997 | false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4998 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 4999 | qdf_copy_macaddr(&updateIE.bssid, |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 5000 | &adapter->mac_addr); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5001 | updateIE.smeSessionId = adapter->session_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5002 | updateIE.ieBufferlength = 0; |
| 5003 | updateIE.pAdditionIEBuffer = NULL; |
| 5004 | updateIE.append = false; |
| 5005 | updateIE.notify = false; |
| 5006 | /* Probe bcn reset */ |
| 5007 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(adapter), |
| 5008 | &updateIE, eUPDATE_IE_PROBE_BCN) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5009 | == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5010 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5011 | } |
| 5012 | /* Assoc resp reset */ |
| 5013 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(adapter), |
| 5014 | &updateIE, |
| 5015 | eUPDATE_IE_ASSOC_RESP) == |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5016 | QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5017 | hdd_err("Could not pass on ASSOC_RSP data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5018 | } |
| 5019 | /* Reset WNI_CFG_PROBE_RSP Flags */ |
| 5020 | wlan_hdd_reset_prob_rspies(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5021 | } |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 5022 | qdf_mem_free(adapter->session.ap.beacon); |
| 5023 | adapter->session.ap.beacon = NULL; |
Ajit Pal Singh | 747b680 | 2017-05-24 15:42:03 +0530 | [diff] [blame] | 5024 | /* |
| 5025 | * If Do_Not_Break_Stream was enabled clear avoid channel list. |
| 5026 | */ |
| 5027 | if (policy_mgr_is_dnsc_set(adapter->hdd_vdev)) |
| 5028 | wlan_hdd_send_avoid_freq_for_dnbs(hdd_ctx, 0); |
| 5029 | |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5030 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5031 | cancel_work_sync(&adapter->ipv4_notifier_work); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5032 | #endif |
| 5033 | |
| 5034 | #ifdef WLAN_NS_OFFLOAD |
| 5035 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5036 | cancel_work_sync(&adapter->ipv6_notifier_work); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5037 | #endif |
| 5038 | #endif |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5039 | |
| 5040 | hdd_vdev_destroy(adapter); |
| 5041 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5042 | mutex_unlock(&hdd_ctx->sap_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5043 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5044 | case QDF_OCB_MODE: |
Krishna Kumaar Natarajan | e58b409 | 2017-01-25 15:47:35 -0800 | [diff] [blame] | 5045 | cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC), |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 5046 | (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX), |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 5047 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)->conn_info.staId[0]); |
Zhang Qian | 79d0d13 | 2018-02-05 13:40:16 +0800 | [diff] [blame] | 5048 | hdd_deregister_tx_flow_control(adapter); |
| 5049 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5050 | break; |
| 5051 | default: |
| 5052 | break; |
| 5053 | } |
| 5054 | |
Dustin Brown | 0434837 | 2017-12-14 16:13:39 -0800 | [diff] [blame] | 5055 | if (adapter->scan_info.default_scan_ies) { |
| 5056 | qdf_mem_free(adapter->scan_info.default_scan_ies); |
| 5057 | adapter->scan_info.default_scan_ies = NULL; |
| 5058 | } |
| 5059 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5060 | hdd_exit(); |
Dustin Brown | 0434837 | 2017-12-14 16:13:39 -0800 | [diff] [blame] | 5061 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5062 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5063 | } |
| 5064 | |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5065 | /** |
| 5066 | * hdd_deinit_all_adapters - deinit all adapters |
| 5067 | * @hdd_ctx: HDD context |
| 5068 | * @rtnl_held: True if RTNL lock held |
| 5069 | * |
| 5070 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5071 | 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] | 5072 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5073 | struct hdd_adapter *adapter; |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5074 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5075 | hdd_enter(); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5076 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5077 | hdd_for_each_adapter(hdd_ctx, adapter) |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5078 | hdd_deinit_adapter(hdd_ctx, adapter, rtnl_held); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5079 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5080 | hdd_exit(); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5081 | } |
| 5082 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5083 | QDF_STATUS hdd_stop_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5084 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5085 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5086 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5087 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5088 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 5089 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 5090 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5091 | hdd_for_each_adapter(hdd_ctx, adapter) |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5092 | hdd_stop_adapter(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5093 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5094 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5095 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5096 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5097 | } |
| 5098 | |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5099 | static void hdd_reset_scan_operation(struct hdd_context *hdd_ctx, |
| 5100 | struct hdd_adapter *adapter) |
| 5101 | { |
| 5102 | switch (adapter->device_mode) { |
| 5103 | case QDF_STA_MODE: |
| 5104 | case QDF_P2P_CLIENT_MODE: |
| 5105 | case QDF_IBSS_MODE: |
| 5106 | case QDF_P2P_DEVICE_MODE: |
| 5107 | case QDF_NDI_MODE: |
| 5108 | wlan_hdd_scan_abort(adapter); |
| 5109 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 5110 | if (adapter->device_mode == QDF_STA_MODE) |
| 5111 | wlan_cfg80211_sched_scan_stop(hdd_ctx->hdd_pdev, |
| 5112 | adapter->dev); |
| 5113 | break; |
| 5114 | case QDF_P2P_GO_MODE: |
| 5115 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 5116 | break; |
| 5117 | case QDF_SAP_MODE: |
Abhinav Kumar | b638b5d | 2018-03-26 12:25:41 +0530 | [diff] [blame] | 5118 | qdf_atomic_set(&adapter->session.ap.acs_in_progress, 0); |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5119 | wlan_hdd_undo_acs(adapter); |
| 5120 | break; |
| 5121 | default: |
| 5122 | break; |
| 5123 | } |
| 5124 | } |
| 5125 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5126 | QDF_STATUS hdd_reset_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5127 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5128 | struct hdd_adapter *adapter; |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5129 | struct hdd_station_ctx *sta_ctx; |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5130 | struct qdf_mac_addr peerMacAddr; |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5131 | int sta_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5132 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5133 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5134 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 5135 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 5136 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5137 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 5138 | hdd_info("[SSR] reset adapter with device mode %s(%d)", |
| 5139 | hdd_device_mode_to_string(adapter->device_mode), |
| 5140 | adapter->device_mode); |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 5141 | |
| 5142 | if ((adapter->device_mode == QDF_STA_MODE) || |
Paul Zhang | 679025e | 2018-03-08 22:39:44 +0800 | [diff] [blame] | 5143 | (adapter->device_mode == QDF_P2P_CLIENT_MODE)) { |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 5144 | /* Stop tdls timers */ |
Kabilan Kannan | 00d2041 | 2017-06-04 14:20:32 -0700 | [diff] [blame] | 5145 | hdd_notify_tdls_reset_adapter(adapter->hdd_vdev); |
Paul Zhang | 679025e | 2018-03-08 22:39:44 +0800 | [diff] [blame] | 5146 | adapter->session.station.hdd_reassoc_scenario = false; |
| 5147 | } |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 5148 | |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5149 | if (hdd_ctx->config->sap_internal_restart && |
| 5150 | adapter->device_mode == QDF_SAP_MODE) { |
| 5151 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5152 | WLAN_STOP_ALL_NETIF_QUEUE, |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5153 | WLAN_CONTROL_PATH); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5154 | if (test_bit(SOFTAP_BSS_STARTED, |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5155 | &adapter->event_flags)) |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5156 | hdd_sap_indicate_disconnect_for_sta(adapter); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5157 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
| 5158 | } else { |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5159 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5160 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5161 | WLAN_CONTROL_PATH); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5162 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5163 | |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5164 | hdd_reset_scan_operation(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5165 | |
| 5166 | hdd_deinit_tx_rx(adapter); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 5167 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5168 | adapter->device_mode, adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 5169 | hdd_green_ap_start_state_mc(hdd_ctx, adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 5170 | false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5171 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 5172 | hdd_wmm_adapter_close(adapter); |
| 5173 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 5174 | } |
| 5175 | |
Vignesh Viswanathan | 2eb1874 | 2017-09-08 11:18:59 +0530 | [diff] [blame] | 5176 | if (adapter->device_mode == QDF_STA_MODE) |
| 5177 | hdd_clear_fils_connection_info(adapter); |
| 5178 | |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 5179 | if (adapter->device_mode == QDF_SAP_MODE) { |
| 5180 | /* |
| 5181 | * If adapter is SAP, set session ID to invalid |
| 5182 | * since SAP session will be cleanup during SSR. |
| 5183 | */ |
Wu Gao | 3671743 | 2016-11-21 15:09:48 +0800 | [diff] [blame] | 5184 | wlansap_set_invalid_session( |
| 5185 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
| 5186 | |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 5187 | wlansap_cleanup_cac_timer( |
| 5188 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
| 5189 | } |
| 5190 | |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5191 | /* Delete connection peers if any to avoid peer object leaks */ |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5192 | if (adapter->device_mode == QDF_STA_MODE || |
| 5193 | adapter->device_mode == QDF_P2P_CLIENT_MODE) { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5194 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5195 | qdf_copy_macaddr(&peerMacAddr, |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5196 | &sta_ctx->conn_info.bssId); |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5197 | |
| 5198 | hdd_objmgr_remove_peer_object(adapter->hdd_vdev, |
| 5199 | peerMacAddr.bytes); |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5200 | } else if (adapter->device_mode == QDF_P2P_GO_MODE) { |
| 5201 | for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; sta_id++) { |
| 5202 | if (adapter->sta_info[sta_id].in_use) { |
| 5203 | hdd_debug("[SSR] deregister STA with ID %d", |
| 5204 | sta_id); |
| 5205 | hdd_softap_deregister_sta(adapter, |
| 5206 | sta_id); |
| 5207 | adapter->sta_info[sta_id].in_use = 0; |
| 5208 | } |
| 5209 | } |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5210 | } |
| 5211 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5212 | hdd_nud_reset_tracking(adapter); |
| 5213 | hdd_nud_ignore_tracking(adapter, true); |
| 5214 | hdd_set_disconnect_status(adapter, false); |
| 5215 | |
Tiger Yu | 94a5a5c | 2018-03-09 21:22:26 +0800 | [diff] [blame] | 5216 | hdd_softap_deinit_tx_rx(adapter); |
| 5217 | |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 5218 | /* Destroy vdev which will be recreated during reinit. */ |
| 5219 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5220 | } |
| 5221 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5222 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5223 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5224 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5225 | } |
| 5226 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5227 | bool hdd_check_for_opened_interfaces(struct hdd_context *hdd_ctx) |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5228 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5229 | struct hdd_adapter *adapter; |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5230 | bool close_modules = true; |
| 5231 | |
Arun Khandavalli | ba479c4 | 2017-07-26 21:29:40 +0530 | [diff] [blame] | 5232 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 5233 | hdd_info("FTM mode, don't close the module"); |
| 5234 | return false; |
| 5235 | } |
| 5236 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5237 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 5238 | if (test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags) || |
| 5239 | test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5240 | hdd_debug("Still other ifaces are up cannot close modules"); |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5241 | close_modules = false; |
| 5242 | break; |
| 5243 | } |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5244 | } |
| 5245 | |
| 5246 | return close_modules; |
| 5247 | } |
| 5248 | |
yeshwanth sriram guntuka | ea63f63 | 2017-08-30 19:31:56 +0530 | [diff] [blame] | 5249 | bool hdd_is_interface_up(struct hdd_adapter *adapter) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5250 | { |
| 5251 | if (test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) |
| 5252 | return true; |
| 5253 | else |
| 5254 | return false; |
| 5255 | } |
| 5256 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5257 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)) \ |
bings | bdcd4a2 | 2017-06-20 09:27:00 +0800 | [diff] [blame] | 5258 | && !defined(WITH_BACKPORTS) && !defined(IEEE80211_PRIVACY) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5259 | struct cfg80211_bss *hdd_cfg80211_get_bss(struct wiphy *wiphy, |
| 5260 | struct ieee80211_channel *channel, |
| 5261 | const u8 *bssid, const u8 *ssid, |
| 5262 | size_t ssid_len) |
| 5263 | { |
| 5264 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 5265 | ssid, ssid_len, |
| 5266 | WLAN_CAPABILITY_ESS, |
| 5267 | WLAN_CAPABILITY_ESS); |
| 5268 | } |
| 5269 | #else |
| 5270 | struct cfg80211_bss *hdd_cfg80211_get_bss(struct wiphy *wiphy, |
| 5271 | struct ieee80211_channel *channel, |
| 5272 | const u8 *bssid, const u8 *ssid, |
| 5273 | size_t ssid_len) |
| 5274 | { |
| 5275 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 5276 | ssid, ssid_len, |
| 5277 | IEEE80211_BSS_TYPE_ESS, |
| 5278 | IEEE80211_PRIVACY_ANY); |
| 5279 | } |
| 5280 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5281 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5282 | #if defined CFG80211_CONNECT_BSS || \ |
| 5283 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5284 | #if defined CFG80211_CONNECT_TIMEOUT_REASON_CODE || \ |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5285 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5286 | /** |
| 5287 | * hdd_convert_timeout_reason() - Convert to kernel specific enum |
| 5288 | * @timeout_reason: reason for connect timeout |
| 5289 | * |
| 5290 | * This function is used to convert host timeout |
| 5291 | * reason enum to kernel specific enum. |
| 5292 | * |
| 5293 | * Return: nl timeout enum |
| 5294 | */ |
| 5295 | static enum nl80211_timeout_reason hdd_convert_timeout_reason( |
| 5296 | tSirResultCodes timeout_reason) |
| 5297 | { |
| 5298 | switch (timeout_reason) { |
| 5299 | case eSIR_SME_JOIN_TIMEOUT_RESULT_CODE: |
| 5300 | return NL80211_TIMEOUT_SCAN; |
| 5301 | case eSIR_SME_AUTH_TIMEOUT_RESULT_CODE: |
| 5302 | return NL80211_TIMEOUT_AUTH; |
| 5303 | case eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE: |
| 5304 | return NL80211_TIMEOUT_ASSOC; |
| 5305 | default: |
| 5306 | return NL80211_TIMEOUT_UNSPECIFIED; |
| 5307 | } |
| 5308 | } |
| 5309 | |
| 5310 | /** |
| 5311 | * hdd_cfg80211_connect_timeout() - API to send connection timeout reason |
| 5312 | * @dev: network device |
| 5313 | * @bssid: bssid to which we want to associate |
| 5314 | * @timeout_reason: reason for connect timeout |
| 5315 | * |
| 5316 | * This API is used to send connection timeout reason to supplicant |
| 5317 | * |
| 5318 | * Return: void |
| 5319 | */ |
| 5320 | static void hdd_cfg80211_connect_timeout(struct net_device *dev, |
| 5321 | const u8 *bssid, |
| 5322 | tSirResultCodes timeout_reason) |
| 5323 | { |
| 5324 | enum nl80211_timeout_reason nl_timeout_reason; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5325 | |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5326 | nl_timeout_reason = hdd_convert_timeout_reason(timeout_reason); |
| 5327 | |
| 5328 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL, |
| 5329 | nl_timeout_reason); |
| 5330 | } |
| 5331 | |
| 5332 | /** |
| 5333 | * __hdd_connect_bss() - API to send connection status to supplicant |
| 5334 | * @dev: network device |
| 5335 | * @bssid: bssid to which we want to associate |
| 5336 | * @req_ie: Request Information Element |
| 5337 | * @req_ie_len: len of the req IE |
| 5338 | * @resp_ie: Response IE |
| 5339 | * @resp_ie_len: len of ht response IE |
| 5340 | * @status: status |
| 5341 | * @gfp: Kernel Flag |
| 5342 | * @timeout_reason: reason for connect timeout |
| 5343 | * |
| 5344 | * Return: void |
| 5345 | */ |
| 5346 | static void __hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5347 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5348 | size_t req_ie_len, const u8 *resp_ie, |
| 5349 | size_t resp_ie_len, int status, gfp_t gfp, |
| 5350 | tSirResultCodes timeout_reason) |
| 5351 | { |
| 5352 | enum nl80211_timeout_reason nl_timeout_reason; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5353 | |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5354 | nl_timeout_reason = hdd_convert_timeout_reason(timeout_reason); |
| 5355 | |
| 5356 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 5357 | resp_ie, resp_ie_len, status, gfp, |
| 5358 | nl_timeout_reason); |
| 5359 | } |
| 5360 | #else |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5361 | #if defined CFG80211_CONNECT_TIMEOUT || \ |
| 5362 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5363 | static void hdd_cfg80211_connect_timeout(struct net_device *dev, |
| 5364 | const u8 *bssid, |
| 5365 | tSirResultCodes timeout_reason) |
| 5366 | { |
| 5367 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL); |
| 5368 | } |
| 5369 | #endif |
| 5370 | |
| 5371 | static void __hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5372 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5373 | size_t req_ie_len, const u8 *resp_ie, |
| 5374 | size_t resp_ie_len, int status, gfp_t gfp, |
| 5375 | tSirResultCodes timeout_reason) |
| 5376 | { |
| 5377 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 5378 | resp_ie, resp_ie_len, status, gfp); |
| 5379 | } |
| 5380 | #endif |
| 5381 | |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5382 | /** |
| 5383 | * hdd_connect_bss() - API to send connection status to supplicant |
| 5384 | * @dev: network device |
| 5385 | * @bssid: bssid to which we want to associate |
| 5386 | * @req_ie: Request Information Element |
| 5387 | * @req_ie_len: len of the req IE |
| 5388 | * @resp_ie: Response IE |
| 5389 | * @resp_ie_len: len of ht response IE |
| 5390 | * @status: status |
| 5391 | * @gfp: Kernel Flag |
| 5392 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5393 | * @timeout_reason: reason for connect timeout |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5394 | * |
| 5395 | * The API is a wrapper to send connection status to supplicant |
| 5396 | * |
| 5397 | * Return: Void |
| 5398 | */ |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5399 | #if defined CFG80211_CONNECT_TIMEOUT || \ |
| 5400 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5401 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5402 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5403 | size_t req_ie_len, const u8 *resp_ie, |
| 5404 | size_t resp_ie_len, int status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5405 | bool connect_timeout, |
| 5406 | tSirResultCodes timeout_reason) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5407 | { |
| 5408 | if (connect_timeout) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5409 | hdd_cfg80211_connect_timeout(dev, bssid, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5410 | else |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5411 | __hdd_connect_bss(dev, bssid, bss, req_ie, req_ie_len, resp_ie, |
| 5412 | resp_ie_len, status, gfp, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5413 | } |
| 5414 | #else |
| 5415 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5416 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5417 | size_t req_ie_len, const u8 *resp_ie, |
| 5418 | size_t resp_ie_len, int status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5419 | bool connect_timeout, |
| 5420 | tSirResultCodes timeout_reason) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5421 | { |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5422 | __hdd_connect_bss(dev, bssid, bss, req_ie, req_ie_len, resp_ie, |
| 5423 | resp_ie_len, status, gfp, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5424 | } |
| 5425 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5426 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5427 | #if defined(WLAN_FEATURE_FILS_SK) |
| 5428 | #if defined(CFG80211_CONNECT_DONE) || \ |
| 5429 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)) |
| 5430 | #if defined(CFG80211_FILS_SK_OFFLOAD_SUPPORT) || \ |
| 5431 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5432 | /** |
| 5433 | * hdd_populate_fils_params() - Populate FILS keys to connect response |
| 5434 | * @fils_params: connect response to supplicant |
| 5435 | * @fils_kek: FILS kek |
| 5436 | * @fils_kek_len: FILS kek length |
| 5437 | * @pmk: FILS PMK |
| 5438 | * @pmk_len: FILS PMK length |
| 5439 | * @pmkid: PMKID |
| 5440 | * @fils_seq_num: FILS Seq number |
| 5441 | * |
| 5442 | * Return: None |
| 5443 | */ |
| 5444 | static void hdd_populate_fils_params(struct cfg80211_connect_resp_params |
| 5445 | *fils_params, const uint8_t *fils_kek, |
| 5446 | size_t fils_kek_len, const uint8_t *pmk, |
| 5447 | size_t pmk_len, const uint8_t *pmkid, |
| 5448 | uint16_t fils_seq_num) |
| 5449 | { |
| 5450 | /* Increament seq number to be used for next FILS */ |
| 5451 | fils_params->fils_erp_next_seq_num = fils_seq_num + 1; |
| 5452 | fils_params->update_erp_next_seq_num = true; |
| 5453 | fils_params->fils_kek = fils_kek; |
| 5454 | fils_params->fils_kek_len = fils_kek_len; |
| 5455 | fils_params->pmk = pmk; |
| 5456 | fils_params->pmk_len = pmk_len; |
| 5457 | fils_params->pmkid = pmkid; |
| 5458 | } |
| 5459 | #else |
| 5460 | static inline void hdd_populate_fils_params(struct cfg80211_connect_resp_params |
| 5461 | *fils_params, const uint8_t |
| 5462 | *fils_kek, size_t fils_kek_len, |
| 5463 | const uint8_t *pmk, size_t pmk_len, |
| 5464 | const uint8_t *pmkid, |
| 5465 | uint16_t fils_seq_num) |
| 5466 | { } |
| 5467 | #endif |
| 5468 | |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5469 | void hdd_update_hlp_info(struct net_device *dev, |
| 5470 | struct csr_roam_info *roam_info) |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5471 | { |
| 5472 | struct sk_buff *skb; |
| 5473 | uint16_t skb_len; |
| 5474 | struct llc_snap_hdr_t *llc_hdr; |
| 5475 | QDF_STATUS status; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5476 | uint8_t *hlp_data; |
| 5477 | uint16_t hlp_data_len; |
| 5478 | struct fils_join_rsp_params *roam_fils_params |
| 5479 | = roam_info->fils_join_rsp; |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5480 | struct hdd_adapter *padapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5481 | |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5482 | if (!roam_fils_params) { |
| 5483 | hdd_err("FILS Roam Param NULL"); |
| 5484 | return; |
| 5485 | } |
| 5486 | |
Srinivas Girigowda | 3cc8e91 | 2017-11-28 18:11:57 -0800 | [diff] [blame] | 5487 | if (!roam_fils_params->hlp_data_len) { |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5488 | hdd_err("FILS HLP Data NULL, len %d", |
| 5489 | roam_fils_params->hlp_data_len); |
| 5490 | return; |
| 5491 | } |
| 5492 | |
| 5493 | hlp_data = roam_fils_params->hlp_data; |
| 5494 | hlp_data_len = roam_fils_params->hlp_data_len; |
| 5495 | |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5496 | /* Calculate skb length */ |
| 5497 | skb_len = (2 * ETH_ALEN) + hlp_data_len; |
| 5498 | skb = qdf_nbuf_alloc(NULL, skb_len, 0, 4, false); |
| 5499 | if (skb == NULL) { |
| 5500 | hdd_err("HLP packet nbuf alloc fails"); |
| 5501 | return; |
| 5502 | } |
| 5503 | |
| 5504 | qdf_mem_copy(skb_put(skb, ETH_ALEN), roam_fils_params->dst_mac.bytes, |
| 5505 | QDF_MAC_ADDR_SIZE); |
| 5506 | qdf_mem_copy(skb_put(skb, ETH_ALEN), roam_fils_params->src_mac.bytes, |
| 5507 | QDF_MAC_ADDR_SIZE); |
| 5508 | |
| 5509 | llc_hdr = (struct llc_snap_hdr_t *) hlp_data; |
| 5510 | if (IS_SNAP(llc_hdr)) { |
| 5511 | hlp_data += LLC_SNAP_HDR_OFFSET_ETHERTYPE; |
| 5512 | hlp_data_len += LLC_SNAP_HDR_OFFSET_ETHERTYPE; |
| 5513 | } |
| 5514 | |
| 5515 | qdf_mem_copy(skb_put(skb, hlp_data_len), hlp_data, hlp_data_len); |
| 5516 | |
| 5517 | /* |
| 5518 | * This HLP packet is formed from HLP info encapsulated |
| 5519 | * in assoc response frame which is AEAD encrypted. |
| 5520 | * Hence, this checksum validation can be set unnecessary. |
| 5521 | * i.e. network layer need not worry about checksum. |
| 5522 | */ |
| 5523 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
| 5524 | |
| 5525 | status = hdd_rx_packet_cbk(padapter, skb); |
| 5526 | if (QDF_IS_STATUS_ERROR(status)) { |
| 5527 | hdd_err("Sending HLP packet fails"); |
| 5528 | return; |
| 5529 | } |
| 5530 | hdd_debug("send HLP packet to netif successfully"); |
| 5531 | } |
| 5532 | |
| 5533 | /** |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5534 | * hdd_connect_done() - Wrapper API to call cfg80211_connect_done |
| 5535 | * @dev: network device |
| 5536 | * @bssid: bssid to which we want to associate |
| 5537 | * @bss: cfg80211 bss info |
| 5538 | * @roam_info: information about connected bss |
| 5539 | * @req_ie: Request Information Element |
| 5540 | * @req_ie_len: len of the req IE |
| 5541 | * @resp_ie: Response IE |
| 5542 | * @resp_ie_len: len of ht response IE |
| 5543 | * @status: status |
| 5544 | * @gfp: allocation flags |
| 5545 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
| 5546 | * @timeout_reason: reason for connect timeout |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5547 | * |
| 5548 | * This API is used as wrapper to send FILS key/sequence number |
| 5549 | * params etc. to supplicant in case of FILS connection |
| 5550 | * |
| 5551 | * Return: None |
| 5552 | */ |
| 5553 | static void hdd_connect_done(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5554 | struct cfg80211_bss *bss, |
| 5555 | struct csr_roam_info *roam_info, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5556 | const u8 *req_ie, size_t req_ie_len, |
| 5557 | const u8 *resp_ie, size_t resp_ie_len, u16 status, |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5558 | gfp_t gfp, bool connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5559 | tSirResultCodes timeout_reason) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5560 | { |
| 5561 | struct cfg80211_connect_resp_params fils_params; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5562 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5563 | struct fils_join_rsp_params *roam_fils_params = |
| 5564 | roam_info->fils_join_rsp; |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5565 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5566 | qdf_mem_zero(&fils_params, sizeof(fils_params)); |
| 5567 | |
| 5568 | if (!roam_fils_params) { |
| 5569 | fils_params.status = WLAN_STATUS_UNSPECIFIED_FAILURE; |
| 5570 | } else { |
| 5571 | fils_params.status = status; |
| 5572 | fils_params.bssid = bssid; |
Srinivas Girigowda | e975f53 | 2018-01-05 14:03:05 -0800 | [diff] [blame] | 5573 | fils_params.timeout_reason = |
| 5574 | hdd_convert_timeout_reason(timeout_reason); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5575 | fils_params.req_ie = req_ie; |
| 5576 | fils_params.req_ie_len = req_ie_len; |
| 5577 | fils_params.resp_ie = resp_ie; |
| 5578 | fils_params.resp_ie_len = resp_ie_len; |
| 5579 | fils_params.bss = bss; |
| 5580 | hdd_populate_fils_params(&fils_params, roam_fils_params->kek, |
| 5581 | roam_fils_params->kek_len, |
| 5582 | roam_fils_params->fils_pmk, |
| 5583 | roam_fils_params->fils_pmk_len, |
| 5584 | roam_fils_params->fils_pmkid, |
| 5585 | roam_info->fils_seq_num); |
Sridhar Selvaraj | e526044 | 2017-08-19 10:12:03 +0530 | [diff] [blame] | 5586 | hdd_save_gtk_params(adapter, roam_info, false); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5587 | } |
| 5588 | hdd_debug("FILS indicate connect status %d seq no %d", |
| 5589 | fils_params.status, |
| 5590 | fils_params.fils_erp_next_seq_num); |
| 5591 | |
| 5592 | cfg80211_connect_done(dev, &fils_params, gfp); |
| 5593 | |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5594 | if (roam_fils_params && roam_fils_params->hlp_data_len) |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5595 | hdd_update_hlp_info(dev, roam_info); |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5596 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5597 | /* Clear all the FILS key info */ |
| 5598 | if (roam_fils_params && roam_fils_params->fils_pmk) |
| 5599 | qdf_mem_free(roam_fils_params->fils_pmk); |
| 5600 | if (roam_fils_params) |
| 5601 | qdf_mem_free(roam_fils_params); |
| 5602 | roam_info->fils_join_rsp = NULL; |
| 5603 | } |
| 5604 | #else |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5605 | static inline void |
| 5606 | hdd_connect_done(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5607 | struct cfg80211_bss *bss, struct csr_roam_info *roam_info, |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5608 | const u8 *req_ie, size_t req_ie_len, |
| 5609 | const u8 *resp_ie, size_t resp_ie_len, u16 status, |
| 5610 | gfp_t gfp, bool connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5611 | tSirResultCodes timeout_reason) |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5612 | { } |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5613 | #endif |
| 5614 | #endif |
| 5615 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5616 | #if defined(WLAN_FEATURE_FILS_SK) && \ |
| 5617 | (defined(CFG80211_CONNECT_DONE) || \ |
| 5618 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0))) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5619 | /** |
| 5620 | * hdd_fils_update_connect_results() - API to send fils connection status to |
| 5621 | * supplicant. |
| 5622 | * @dev: network device |
| 5623 | * @bssid: bssid to which we want to associate |
| 5624 | * @bss: cfg80211 bss info |
| 5625 | * @roam_info: information about connected bss |
| 5626 | * @req_ie: Request Information Element |
| 5627 | * @req_ie_len: len of the req IE |
| 5628 | * @resp_ie: Response IE |
| 5629 | * @resp_ie_len: len of ht response IE |
| 5630 | * @status: status |
| 5631 | * @gfp: allocation flags |
| 5632 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
| 5633 | * @timeout_reason: reason for connect timeout |
| 5634 | * |
| 5635 | * The API is a wrapper to send connection status to supplicant |
| 5636 | * |
| 5637 | * Return: 0 if success else failure |
| 5638 | */ |
| 5639 | static int hdd_fils_update_connect_results(struct net_device *dev, |
| 5640 | const u8 *bssid, |
| 5641 | struct cfg80211_bss *bss, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5642 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5643 | size_t req_ie_len, const u8 *resp_ie, |
| 5644 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 5645 | bool connect_timeout, |
| 5646 | tSirResultCodes timeout_reason) |
| 5647 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5648 | hdd_enter(); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5649 | if (!roam_info || !roam_info->is_fils_connection) |
| 5650 | return -EINVAL; |
| 5651 | |
| 5652 | hdd_connect_done(dev, bssid, bss, roam_info, req_ie, req_ie_len, |
| 5653 | resp_ie, resp_ie_len, status, gfp, connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5654 | timeout_reason); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5655 | return 0; |
| 5656 | } |
| 5657 | #else |
| 5658 | static inline int hdd_fils_update_connect_results(struct net_device *dev, |
| 5659 | const u8 *bssid, |
| 5660 | struct cfg80211_bss *bss, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5661 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5662 | size_t req_ie_len, const u8 *resp_ie, |
| 5663 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 5664 | bool connect_timeout, |
| 5665 | tSirResultCodes timeout_reason) |
| 5666 | { |
| 5667 | return -EINVAL; |
| 5668 | } |
| 5669 | #endif |
| 5670 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5671 | /** |
| 5672 | * hdd_connect_result() - API to send connection status to supplicant |
| 5673 | * @dev: network device |
| 5674 | * @bssid: bssid to which we want to associate |
| 5675 | * @roam_info: information about connected bss |
| 5676 | * @req_ie: Request Information Element |
| 5677 | * @req_ie_len: len of the req IE |
| 5678 | * @resp_ie: Response IE |
| 5679 | * @resp_ie_len: len of ht response IE |
| 5680 | * @status: status |
| 5681 | * @gfp: Kernel Flag |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5682 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5683 | * @timeout_reason: reason for connect timeout |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5684 | * |
| 5685 | * The API is a wrapper to send connection status to supplicant |
| 5686 | * and allow runtime suspend |
| 5687 | * |
| 5688 | * Return: Void |
| 5689 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5690 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5691 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5692 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5693 | size_t resp_ie_len, u16 status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5694 | bool connect_timeout, |
| 5695 | tSirResultCodes timeout_reason) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5696 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5697 | struct hdd_adapter *padapter = (struct hdd_adapter *) netdev_priv(dev); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5698 | struct cfg80211_bss *bss = NULL; |
Jingxiang Ge | 929c793 | 2018-01-24 14:01:12 +0800 | [diff] [blame] | 5699 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(padapter); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5700 | |
| 5701 | if (WLAN_STATUS_SUCCESS == status) { |
| 5702 | struct ieee80211_channel *chan; |
| 5703 | int freq; |
| 5704 | int chan_no = roam_info->pBssDesc->channelId; |
| 5705 | |
| 5706 | if (chan_no <= 14) |
| 5707 | freq = ieee80211_channel_to_frequency(chan_no, |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 5708 | HDD_NL80211_BAND_2GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5709 | else |
| 5710 | freq = ieee80211_channel_to_frequency(chan_no, |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 5711 | HDD_NL80211_BAND_5GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5712 | |
| 5713 | chan = ieee80211_get_channel(padapter->wdev.wiphy, freq); |
| 5714 | bss = hdd_cfg80211_get_bss(padapter->wdev.wiphy, chan, bssid, |
| 5715 | roam_info->u.pConnectedProfile->SSID.ssId, |
| 5716 | roam_info->u.pConnectedProfile->SSID.length); |
| 5717 | } |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 5718 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5719 | if (hdd_fils_update_connect_results(dev, bssid, bss, |
| 5720 | roam_info, req_ie, req_ie_len, resp_ie, |
| 5721 | resp_ie_len, status, gfp, connect_timeout, |
| 5722 | timeout_reason) != 0) { |
| 5723 | hdd_connect_bss(dev, bssid, bss, req_ie, |
| 5724 | req_ie_len, resp_ie, resp_ie_len, |
| 5725 | status, gfp, connect_timeout, timeout_reason); |
| 5726 | } |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 5727 | |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 5728 | qdf_runtime_pm_allow_suspend(&hdd_ctx->runtime_context.connect); |
Dustin Brown | ceed67e | 2017-05-26 11:57:31 -0700 | [diff] [blame] | 5729 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5730 | } |
| 5731 | #else |
| 5732 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5733 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5734 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5735 | size_t resp_ie_len, u16 status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5736 | bool connect_timeout, |
| 5737 | tSirResultCodes timeout_reason) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5738 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5739 | struct hdd_adapter *padapter = (struct hdd_adapter *) netdev_priv(dev); |
Jingxiang Ge | 929c793 | 2018-01-24 14:01:12 +0800 | [diff] [blame] | 5740 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(padapter); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 5741 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5742 | cfg80211_connect_result(dev, bssid, req_ie, req_ie_len, |
| 5743 | resp_ie, resp_ie_len, status, gfp); |
Prashanth Bhatta | 87b6dc0 | 2017-01-19 15:17:58 -0800 | [diff] [blame] | 5744 | |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 5745 | qdf_runtime_pm_allow_suspend(&hdd_ctx->runtime_context.connect); |
Dustin Brown | ceed67e | 2017-05-26 11:57:31 -0700 | [diff] [blame] | 5746 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5747 | } |
| 5748 | #endif |
| 5749 | |
| 5750 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5751 | QDF_STATUS hdd_start_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5752 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5753 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5754 | #ifndef MSM_PLATFORM |
Dustin Brown | ce5b3d3 | 2018-01-17 15:07:38 -0800 | [diff] [blame] | 5755 | struct qdf_mac_addr bcastMac = QDF_MAC_ADDR_BCAST_INIT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5756 | #endif |
| 5757 | eConnectionState connState; |
| 5758 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5759 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5760 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5761 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5762 | if (!hdd_is_interface_up(adapter)) |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5763 | continue; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5764 | |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5765 | hdd_debug("[SSR] start adapter with device mode %s(%d)", |
| 5766 | hdd_device_mode_to_string(adapter->device_mode), |
| 5767 | adapter->device_mode); |
| 5768 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5769 | hdd_wmm_init(adapter); |
| 5770 | |
| 5771 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5772 | case QDF_STA_MODE: |
| 5773 | case QDF_P2P_CLIENT_MODE: |
| 5774 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5775 | |
| 5776 | connState = (WLAN_HDD_GET_STATION_CTX_PTR(adapter)) |
| 5777 | ->conn_info.connState; |
| 5778 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5779 | hdd_start_station_adapter(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5780 | /* Open the gates for HDD to receive Wext commands */ |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 5781 | adapter->is_link_up_service_needed = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5782 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5783 | /* Indicate disconnect event to supplicant |
| 5784 | * if associated previously |
| 5785 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5786 | if (eConnectionState_Associated == connState || |
Yue Ma | cd96144 | 2015-10-20 16:15:31 -0700 | [diff] [blame] | 5787 | eConnectionState_IbssConnected == connState || |
| 5788 | eConnectionState_NotConnected == connState || |
| 5789 | eConnectionState_IbssDisconnected == connState || |
| 5790 | eConnectionState_Disconnecting == connState) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5791 | union iwreq_data wrqu; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5792 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5793 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 5794 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 5795 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 5796 | wireless_send_event(adapter->dev, SIOCGIWAP, |
| 5797 | &wrqu, NULL); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 5798 | adapter->session.station. |
Jeff Johnson | 690fe95 | 2017-10-25 11:48:39 -0700 | [diff] [blame] | 5799 | hdd_reassoc_scenario = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5800 | |
| 5801 | /* indicate disconnected event to nl80211 */ |
Mahesh A Saptasagar | c35e8bf | 2016-06-17 20:03:46 +0530 | [diff] [blame] | 5802 | wlan_hdd_cfg80211_indicate_disconnect( |
| 5803 | adapter->dev, false, |
| 5804 | WLAN_REASON_UNSPECIFIED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5805 | } else if (eConnectionState_Connecting == connState) { |
| 5806 | /* |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5807 | * Indicate connect failure to supplicant if we |
| 5808 | * were in the process of connecting |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5809 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5810 | hdd_connect_result(adapter->dev, NULL, NULL, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5811 | NULL, 0, NULL, 0, |
| 5812 | WLAN_STATUS_ASSOC_DENIED_UNSPEC, |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5813 | GFP_KERNEL, false, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5814 | } |
| 5815 | |
| 5816 | hdd_register_tx_flow_control(adapter, |
| 5817 | hdd_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 5818 | hdd_tx_resume_cb, |
| 5819 | hdd_tx_flow_control_is_pause); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5820 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5821 | hdd_nud_ignore_tracking(adapter, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5822 | break; |
| 5823 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5824 | case QDF_SAP_MODE: |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5825 | if (hdd_ctx->config->sap_internal_restart) |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5826 | hdd_start_ap_adapter(adapter); |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5827 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5828 | break; |
| 5829 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5830 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5831 | #ifdef MSM_PLATFORM |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5832 | hdd_debug("[SSR] send stop ap to supplicant"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5833 | cfg80211_ap_stopped(adapter->dev, GFP_KERNEL); |
| 5834 | #else |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5835 | hdd_debug("[SSR] send restart supplicant"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5836 | /* event supplicant to restart */ |
| 5837 | cfg80211_del_sta(adapter->dev, |
| 5838 | (const u8 *)&bcastMac.bytes[0], |
| 5839 | GFP_KERNEL); |
| 5840 | #endif |
| 5841 | break; |
Arunk Khandavalli | 062fb03 | 2017-10-04 12:18:15 +0530 | [diff] [blame] | 5842 | case QDF_MONITOR_MODE: |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5843 | hdd_start_station_adapter(adapter); |
Arunk Khandavalli | 062fb03 | 2017-10-04 12:18:15 +0530 | [diff] [blame] | 5844 | hdd_set_mon_rx_cb(adapter->dev); |
| 5845 | wlan_hdd_set_mon_chan(adapter, adapter->mon_chan, |
| 5846 | adapter->mon_bandwidth); |
| 5847 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5848 | default: |
| 5849 | break; |
| 5850 | } |
Krunal Soni | 9c2ee03 | 2017-07-18 13:49:54 -0700 | [diff] [blame] | 5851 | /* |
| 5852 | * Action frame registered in one adapter which will |
| 5853 | * applicable to all interfaces |
| 5854 | */ |
| 5855 | wlan_hdd_cfg80211_register_frames(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5856 | } |
| 5857 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5858 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5859 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5860 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5861 | } |
| 5862 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5863 | QDF_STATUS hdd_get_front_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5864 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5865 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5866 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5867 | qdf_list_node_t *node; |
| 5868 | |
| 5869 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5870 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5871 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5872 | status = qdf_list_peek_front(&hdd_ctx->hdd_adapters, &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5873 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5874 | |
| 5875 | if (QDF_IS_STATUS_ERROR(status)) |
| 5876 | return status; |
| 5877 | |
| 5878 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 5879 | |
| 5880 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5881 | } |
| 5882 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5883 | QDF_STATUS hdd_get_next_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5884 | struct hdd_adapter *current_adapter, |
| 5885 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5886 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5887 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5888 | qdf_list_node_t *node; |
| 5889 | |
| 5890 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5891 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5892 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 5893 | status = qdf_list_peek_next(&hdd_ctx->hdd_adapters, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5894 | ¤t_adapter->node, |
| 5895 | &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5896 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5897 | |
| 5898 | if (QDF_IS_STATUS_ERROR(status)) |
| 5899 | return status; |
| 5900 | |
| 5901 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 5902 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5903 | return status; |
| 5904 | } |
| 5905 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5906 | QDF_STATUS hdd_remove_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5907 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5908 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5909 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5910 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5911 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5912 | status = qdf_list_remove_node(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5913 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5914 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5915 | return status; |
| 5916 | } |
| 5917 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5918 | QDF_STATUS hdd_remove_front_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5919 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5920 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5921 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5922 | qdf_list_node_t *node; |
| 5923 | |
| 5924 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5925 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5926 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5927 | status = qdf_list_remove_front(&hdd_ctx->hdd_adapters, &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5928 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5929 | |
| 5930 | if (QDF_IS_STATUS_ERROR(status)) |
| 5931 | return status; |
| 5932 | |
| 5933 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 5934 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5935 | return status; |
| 5936 | } |
| 5937 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5938 | QDF_STATUS hdd_add_adapter_back(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5939 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5940 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5941 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5942 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5943 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5944 | status = qdf_list_insert_back(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5945 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5946 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5947 | return status; |
| 5948 | } |
| 5949 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5950 | QDF_STATUS hdd_add_adapter_front(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5951 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5952 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5953 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5954 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5955 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5956 | status = qdf_list_insert_front(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5957 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5958 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5959 | return status; |
| 5960 | } |
| 5961 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5962 | 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] | 5963 | tSirMacAddr macAddr) |
| 5964 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5965 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5966 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5967 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 5968 | if (!qdf_mem_cmp(adapter->mac_addr.bytes, |
| 5969 | macAddr, sizeof(tSirMacAddr))) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5970 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5971 | } |
| 5972 | |
| 5973 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5974 | } |
| 5975 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5976 | 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] | 5977 | uint32_t vdev_id) |
| 5978 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5979 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5980 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5981 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5982 | if (adapter->session_id == vdev_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5983 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5984 | } |
| 5985 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5986 | return NULL; |
| 5987 | } |
| 5988 | |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 5989 | /** |
| 5990 | * hdd_get_adapter_by_sme_session_id() - Return adapter with |
| 5991 | * the sessionid |
| 5992 | * @hdd_ctx: hdd context. |
| 5993 | * @sme_session_id: sme session is for the adapter to get. |
| 5994 | * |
| 5995 | * This function is used to get the adapter with provided session id |
| 5996 | * |
| 5997 | * Return: adapter pointer if found |
| 5998 | * |
| 5999 | */ |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 6000 | struct hdd_adapter * |
| 6001 | hdd_get_adapter_by_sme_session_id(struct hdd_context *hdd_ctx, |
| 6002 | uint32_t sme_session_id) |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6003 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6004 | struct hdd_adapter *adapter; |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6005 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6006 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6007 | if (adapter->session_id == sme_session_id) |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6008 | return adapter; |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6009 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6010 | |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6011 | return NULL; |
| 6012 | } |
| 6013 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6014 | 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] | 6015 | const char *iface_name) |
| 6016 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6017 | struct hdd_adapter *adapter; |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6018 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6019 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6020 | if (!qdf_str_cmp(adapter->dev->name, iface_name)) |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6021 | return adapter; |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6022 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6023 | |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6024 | return NULL; |
| 6025 | } |
| 6026 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6027 | /** |
| 6028 | * hdd_get_adapter() - to get adapter matching the mode |
| 6029 | * @hdd_ctx: hdd context |
| 6030 | * @mode: adapter mode |
| 6031 | * |
| 6032 | * This routine will return the pointer to adapter matching |
| 6033 | * with the passed mode. |
| 6034 | * |
| 6035 | * Return: pointer to adapter or null |
| 6036 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6037 | struct hdd_adapter *hdd_get_adapter(struct hdd_context *hdd_ctx, |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 6038 | enum QDF_OPMODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6039 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6040 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6041 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6042 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6043 | if (adapter->device_mode == mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6044 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6045 | } |
| 6046 | |
| 6047 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6048 | } |
| 6049 | |
Yeshwanth Sriram Guntuka | 469f957 | 2018-02-12 13:28:22 +0530 | [diff] [blame] | 6050 | enum tQDF_ADAPTER_MODE hdd_get_device_mode(uint32_t session_id) |
| 6051 | { |
| 6052 | struct hdd_context *hdd_ctx; |
| 6053 | struct hdd_adapter *adapter; |
| 6054 | |
| 6055 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 6056 | if (!hdd_ctx) { |
| 6057 | hdd_err("Invalid HDD context"); |
| 6058 | return QDF_MAX_NO_OF_MODE; |
| 6059 | } |
| 6060 | |
| 6061 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, session_id); |
| 6062 | if (!adapter) { |
| 6063 | hdd_err("Invalid HDD adapter"); |
| 6064 | return QDF_MAX_NO_OF_MODE; |
| 6065 | } |
| 6066 | |
| 6067 | return adapter->device_mode; |
| 6068 | } |
| 6069 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6070 | /** |
| 6071 | * hdd_get_operating_channel() - return operating channel of the device mode |
| 6072 | * @hdd_ctx: Pointer to the HDD context. |
| 6073 | * @mode: Device mode for which operating channel is required. |
| 6074 | * Suported modes: |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6075 | * QDF_STA_MODE, |
| 6076 | * QDF_P2P_CLIENT_MODE, |
| 6077 | * QDF_SAP_MODE, |
| 6078 | * QDF_P2P_GO_MODE. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6079 | * |
| 6080 | * This API returns the operating channel of the requested device mode |
| 6081 | * |
| 6082 | * Return: channel number. "0" id the requested device is not found OR it is |
| 6083 | * not connected. |
| 6084 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6085 | uint8_t hdd_get_operating_channel(struct hdd_context *hdd_ctx, |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 6086 | enum QDF_OPMODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6087 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6088 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6089 | uint8_t operatingChannel = 0; |
| 6090 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6091 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6092 | if (mode == adapter->device_mode) { |
| 6093 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6094 | case QDF_STA_MODE: |
| 6095 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6096 | if (hdd_conn_is_connected |
| 6097 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 6098 | (adapter))) { |
| 6099 | operatingChannel = |
| 6100 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 6101 | (adapter))->conn_info. |
| 6102 | operationChannel; |
| 6103 | } |
| 6104 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6105 | case QDF_SAP_MODE: |
| 6106 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6107 | /* softap connection info */ |
| 6108 | if (test_bit |
| 6109 | (SOFTAP_BSS_STARTED, |
| 6110 | &adapter->event_flags)) |
| 6111 | operatingChannel = |
| 6112 | (WLAN_HDD_GET_AP_CTX_PTR |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 6113 | (adapter))->operating_channel; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6114 | break; |
| 6115 | default: |
| 6116 | break; |
| 6117 | } |
| 6118 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6119 | /* Found the device of interest. break the loop */ |
| 6120 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6121 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6122 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6123 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6124 | return operatingChannel; |
| 6125 | } |
| 6126 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6127 | static inline QDF_STATUS hdd_unregister_wext_all_adapters(struct hdd_context * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6128 | hdd_ctx) |
| 6129 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6130 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6131 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6132 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6133 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6134 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6135 | if (adapter->device_mode == QDF_STA_MODE || |
| 6136 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 6137 | adapter->device_mode == QDF_IBSS_MODE || |
| 6138 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 6139 | adapter->device_mode == QDF_SAP_MODE || |
| 6140 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6141 | wlan_hdd_cfg80211_deregister_frames(adapter); |
| 6142 | hdd_unregister_wext(adapter->dev); |
| 6143 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6144 | } |
| 6145 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6146 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6147 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6148 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6149 | } |
| 6150 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6151 | 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] | 6152 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6153 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6154 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6155 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6156 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6157 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6158 | if (adapter->device_mode == QDF_STA_MODE || |
| 6159 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 6160 | adapter->device_mode == QDF_IBSS_MODE || |
| 6161 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 6162 | adapter->device_mode == QDF_SAP_MODE || |
| 6163 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 6164 | wlan_abort_scan(hdd_ctx->hdd_pdev, INVAL_PDEV_ID, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 6165 | adapter->session_id, INVALID_SCAN_ID, |
Vignesh Viswanathan | 19611c8 | 2018-01-16 16:20:40 +0530 | [diff] [blame] | 6166 | true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6167 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6168 | } |
| 6169 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6170 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6171 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6172 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6173 | } |
| 6174 | |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6175 | /** |
| 6176 | * hdd_abort_sched_scan_all_adapters() - stops scheduled (PNO) scans for all |
| 6177 | * adapters |
| 6178 | * @hdd_ctx: The HDD context containing the adapters to operate on |
| 6179 | * |
| 6180 | * return: QDF_STATUS_SUCCESS |
| 6181 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6182 | 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] | 6183 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6184 | struct hdd_adapter *adapter; |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6185 | int err; |
| 6186 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6187 | hdd_enter(); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6188 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6189 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6190 | if (adapter->device_mode == QDF_STA_MODE || |
| 6191 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 6192 | adapter->device_mode == QDF_IBSS_MODE || |
| 6193 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 6194 | adapter->device_mode == QDF_SAP_MODE || |
| 6195 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6196 | err = wlan_hdd_sched_scan_stop(adapter->dev); |
| 6197 | if (err) |
| 6198 | hdd_err("Unable to stop scheduled scan"); |
| 6199 | } |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6200 | } |
| 6201 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6202 | hdd_exit(); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6203 | |
| 6204 | return QDF_STATUS_SUCCESS; |
| 6205 | } |
| 6206 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6207 | #ifdef WLAN_NS_OFFLOAD |
| 6208 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6209 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6210 | * @hdd_ctx: Pointer to hdd context |
| 6211 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6212 | * Unregister for IPv6 address change notifications. |
| 6213 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6214 | * Return: None |
| 6215 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6216 | static void hdd_wlan_unregister_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6217 | { |
| 6218 | unregister_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6219 | } |
| 6220 | |
| 6221 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6222 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6223 | * @hdd_ctx: Pointer to hdd context |
| 6224 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6225 | * Register for IPv6 address change notifications. |
| 6226 | * |
| 6227 | * Return: 0 on success and errno on failure. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6228 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6229 | static int hdd_wlan_register_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6230 | { |
| 6231 | int ret; |
| 6232 | |
| 6233 | hdd_ctx->ipv6_notifier.notifier_call = wlan_hdd_ipv6_changed; |
| 6234 | ret = register_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6235 | if (ret) { |
| 6236 | hdd_err("Failed to register IPv6 notifier: %d", ret); |
| 6237 | goto out; |
| 6238 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6239 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6240 | hdd_debug("Registered IPv6 notifier"); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6241 | out: |
| 6242 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6243 | } |
| 6244 | #else |
| 6245 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6246 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6247 | * @hdd_ctx: Pointer to hdd context |
| 6248 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6249 | * Unregister for IPv6 address change notifications. |
| 6250 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6251 | * Return: None |
| 6252 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6253 | static void hdd_wlan_unregister_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6254 | { |
| 6255 | } |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6256 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6257 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6258 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6259 | * @hdd_ctx: Pointer to hdd context |
| 6260 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6261 | * Register for IPv6 address change notifications. |
| 6262 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6263 | * Return: None |
| 6264 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6265 | static int hdd_wlan_register_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6266 | { |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6267 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6268 | } |
| 6269 | #endif |
| 6270 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 6271 | void hdd_set_disconnect_status(struct hdd_adapter *adapter, bool status) |
| 6272 | { |
| 6273 | qdf_mutex_acquire(&adapter->disconnection_status_lock); |
| 6274 | adapter->disconnection_in_progress = status; |
| 6275 | qdf_mutex_release(&adapter->disconnection_status_lock); |
| 6276 | hdd_debug("setting disconnection status: %d", status); |
| 6277 | } |
| 6278 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6279 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6280 | * hdd_register_notifiers - Register netdev notifiers. |
| 6281 | * @hdd_ctx: HDD context |
| 6282 | * |
| 6283 | * Register netdev notifiers like IPv4 and IPv6. |
| 6284 | * |
| 6285 | * Return: 0 on success and errno on failure |
| 6286 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6287 | static int hdd_register_notifiers(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6288 | { |
| 6289 | int ret; |
| 6290 | |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6291 | ret = hdd_wlan_register_ip6_notifier(hdd_ctx); |
| 6292 | if (ret) |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 6293 | goto out; |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6294 | |
| 6295 | hdd_ctx->ipv4_notifier.notifier_call = wlan_hdd_ipv4_changed; |
| 6296 | ret = register_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
| 6297 | if (ret) { |
| 6298 | hdd_err("Failed to register IPv4 notifier: %d", ret); |
| 6299 | goto unregister_ip6_notifier; |
| 6300 | } |
| 6301 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 6302 | ret = hdd_nud_register_netevent_notifier(hdd_ctx); |
| 6303 | if (ret) { |
| 6304 | hdd_err("Failed to register netevent notifier: %d", |
| 6305 | ret); |
| 6306 | goto unregister_inetaddr_notifier; |
| 6307 | } |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6308 | return 0; |
| 6309 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 6310 | unregister_inetaddr_notifier: |
| 6311 | unregister_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6312 | unregister_ip6_notifier: |
| 6313 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6314 | out: |
| 6315 | return ret; |
| 6316 | |
| 6317 | } |
| 6318 | |
| 6319 | /** |
| 6320 | * hdd_unregister_notifiers - Unregister netdev notifiers. |
| 6321 | * @hdd_ctx: HDD context |
| 6322 | * |
| 6323 | * Unregister netdev notifiers like IPv4 and IPv6. |
| 6324 | * |
| 6325 | * Return: None. |
| 6326 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6327 | void hdd_unregister_notifiers(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6328 | { |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 6329 | hdd_nud_unregister_netevent_notifier(hdd_ctx); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6330 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
| 6331 | |
| 6332 | unregister_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6333 | } |
| 6334 | |
| 6335 | /** |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6336 | * hdd_exit_netlink_services - Exit netlink services |
| 6337 | * @hdd_ctx: HDD context |
| 6338 | * |
| 6339 | * Exit netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 6340 | * nl service. |
| 6341 | * |
| 6342 | * Return: None. |
| 6343 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6344 | static void hdd_exit_netlink_services(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6345 | { |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6346 | hdd_close_cesium_nl_sock(); |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 6347 | hdd_deactivate_wifi_pos(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6348 | ptt_sock_deactivate_svc(); |
| 6349 | |
| 6350 | nl_srv_exit(); |
| 6351 | } |
| 6352 | |
| 6353 | /** |
| 6354 | * hdd_init_netlink_services- Init netlink services |
| 6355 | * @hdd_ctx: HDD context |
| 6356 | * |
| 6357 | * Init netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 6358 | * nl service. |
| 6359 | * |
| 6360 | * Return: 0 on success and errno on failure. |
| 6361 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6362 | static int hdd_init_netlink_services(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6363 | { |
| 6364 | int ret; |
| 6365 | |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 6366 | ret = wlan_hdd_nl_init(hdd_ctx); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6367 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6368 | hdd_err("nl_srv_init failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6369 | goto out; |
| 6370 | } |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 6371 | cds_set_radio_index(hdd_ctx->radio_index); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6372 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 6373 | ret = hdd_activate_wifi_pos(hdd_ctx); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6374 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6375 | hdd_err("hdd_activate_wifi_pos failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6376 | goto err_nl_srv; |
| 6377 | } |
| 6378 | |
| 6379 | ret = ptt_sock_activate_svc(); |
| 6380 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6381 | hdd_err("ptt_sock_activate_svc failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6382 | goto err_nl_srv; |
| 6383 | } |
| 6384 | |
| 6385 | ret = hdd_open_cesium_nl_sock(); |
Ryan Hsu | 5e2e205 | 2016-04-28 10:19:38 -0700 | [diff] [blame] | 6386 | if (ret) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6387 | hdd_err("hdd_open_cesium_nl_sock failed ret: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6388 | |
| 6389 | ret = cnss_diag_activate_service(); |
| 6390 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6391 | hdd_err("cnss_diag_activate_service failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6392 | goto err_close_cesium; |
| 6393 | } |
| 6394 | |
Sandeep Puligilla | 019a1bd | 2018-02-04 22:57:44 -0800 | [diff] [blame] | 6395 | ret = spectral_scan_activate_service(); |
| 6396 | if (ret) { |
| 6397 | hdd_alert("spectral_scan_activate_service failed: %d", ret); |
| 6398 | goto err_close_cesium; |
| 6399 | } |
| 6400 | |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6401 | return 0; |
| 6402 | |
| 6403 | err_close_cesium: |
| 6404 | hdd_close_cesium_nl_sock(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6405 | ptt_sock_deactivate_svc(); |
| 6406 | err_nl_srv: |
| 6407 | nl_srv_exit(); |
| 6408 | out: |
| 6409 | return ret; |
| 6410 | } |
| 6411 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6412 | /** |
| 6413 | * hdd_rx_wake_lock_destroy() - Destroy RX wakelock |
| 6414 | * @hdd_ctx: HDD context. |
| 6415 | * |
| 6416 | * Destroy RX wakelock. |
| 6417 | * |
| 6418 | * Return: None. |
| 6419 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6420 | static void hdd_rx_wake_lock_destroy(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6421 | { |
| 6422 | qdf_wake_lock_destroy(&hdd_ctx->rx_wake_lock); |
| 6423 | } |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6424 | |
| 6425 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6426 | * hdd_rx_wake_lock_create() - Create RX wakelock |
| 6427 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6428 | * |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6429 | * Create RX wakelock. |
| 6430 | * |
| 6431 | * Return: None. |
| 6432 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6433 | static void hdd_rx_wake_lock_create(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6434 | { |
| 6435 | qdf_wake_lock_create(&hdd_ctx->rx_wake_lock, "qcom_rx_wakelock"); |
| 6436 | } |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6437 | |
| 6438 | /** |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6439 | * hdd_context_deinit() - Deinitialize HDD context |
| 6440 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6441 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6442 | * Deinitialize HDD context along with all the feature specific contexts but |
| 6443 | * do not free hdd context itself. Caller of this API is supposed to free |
| 6444 | * HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6445 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6446 | * return: 0 on success and errno on failure. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6447 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6448 | static int hdd_context_deinit(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6449 | { |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 6450 | qdf_wake_lock_destroy(&hdd_ctx->monitor_mode_wakelock); |
| 6451 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6452 | wlan_hdd_cfg80211_deinit(hdd_ctx->wiphy); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6453 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6454 | hdd_sap_context_destroy(hdd_ctx); |
| 6455 | |
| 6456 | hdd_rx_wake_lock_destroy(hdd_ctx); |
| 6457 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6458 | hdd_scan_context_destroy(hdd_ctx); |
| 6459 | |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 6460 | qdf_list_destroy(&hdd_ctx->hdd_adapters); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6461 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6462 | return 0; |
| 6463 | } |
| 6464 | |
| 6465 | /** |
| 6466 | * hdd_context_destroy() - Destroy HDD context |
| 6467 | * @hdd_ctx: HDD context to be destroyed. |
| 6468 | * |
| 6469 | * Free config and HDD context as well as destroy all the resources. |
| 6470 | * |
| 6471 | * Return: None |
| 6472 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6473 | static void hdd_context_destroy(struct hdd_context *hdd_ctx) |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6474 | { |
Rajeev Kumar | 493a31b | 2017-09-29 14:01:24 -0700 | [diff] [blame] | 6475 | cds_set_context(QDF_MODULE_ID_HDD, NULL); |
Arunk Khandavalli | 3d267b4 | 2017-05-02 18:58:59 +0530 | [diff] [blame] | 6476 | |
Hanumantha Reddy Pothula | 00c74f6 | 2016-11-24 20:13:32 +0530 | [diff] [blame] | 6477 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 6478 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6479 | hdd_context_deinit(hdd_ctx); |
| 6480 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6481 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6482 | hdd_ctx->config = NULL; |
| 6483 | |
| 6484 | wiphy_free(hdd_ctx->wiphy); |
| 6485 | } |
| 6486 | |
| 6487 | /** |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 6488 | * wlan_destroy_bug_report_lock() - Destroy bug report lock |
| 6489 | * |
| 6490 | * This function is used to destroy bug report lock |
| 6491 | * |
| 6492 | * Return: None |
| 6493 | */ |
| 6494 | static void wlan_destroy_bug_report_lock(void) |
| 6495 | { |
| 6496 | p_cds_contextType p_cds_context; |
| 6497 | |
| 6498 | p_cds_context = cds_get_global_context(); |
| 6499 | if (!p_cds_context) { |
| 6500 | hdd_err("cds context is NULL"); |
| 6501 | return; |
| 6502 | } |
| 6503 | |
| 6504 | qdf_spinlock_destroy(&p_cds_context->bug_report_lock); |
| 6505 | } |
| 6506 | |
| 6507 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6508 | * hdd_wlan_exit() - HDD WLAN exit function |
| 6509 | * @hdd_ctx: Pointer to the HDD Context |
| 6510 | * |
| 6511 | * This is the driver exit point (invoked during rmmod) |
| 6512 | * |
| 6513 | * Return: None |
| 6514 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6515 | static void hdd_wlan_exit(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6516 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6517 | struct wiphy *wiphy = hdd_ctx->wiphy; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6518 | int driver_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6519 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6520 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6521 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6522 | hdd_unregister_notifiers(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6523 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6524 | hdd_bus_bandwidth_destroy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6525 | |
| 6526 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 6527 | if (QDF_TIMER_STATE_RUNNING == |
| 6528 | qdf_mc_timer_get_current_state(&hdd_ctx->skip_acs_scan_timer)) { |
| 6529 | qdf_mc_timer_stop(&hdd_ctx->skip_acs_scan_timer); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6530 | } |
| 6531 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6532 | if (!QDF_IS_STATUS_SUCCESS |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 6533 | (qdf_mc_timer_destroy(&hdd_ctx->skip_acs_scan_timer))) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 6534 | hdd_err("Cannot deallocate ACS Skip timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6535 | } |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 6536 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 6537 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 6538 | hdd_ctx->last_acs_channel_list = NULL; |
| 6539 | hdd_ctx->num_of_channels = 0; |
| 6540 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6541 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6542 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6543 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 6544 | driver_status = hdd_ctx->driver_status; |
| 6545 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 6546 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6547 | /* |
| 6548 | * Powersave Offload Case |
| 6549 | * Disable Idle Power Save Mode |
| 6550 | */ |
| 6551 | hdd_set_idle_ps_config(hdd_ctx, false); |
Sandeep Puligilla | 8fa28fd | 2017-11-02 12:19:33 -0700 | [diff] [blame] | 6552 | /* clear the scan queue in all the scenarios */ |
Sourav Mohapatra | 001cfaf | 2018-02-28 11:30:46 +0530 | [diff] [blame] | 6553 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->hdd_pdev, NULL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6554 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6555 | if (driver_status != DRIVER_MODULES_CLOSED) { |
| 6556 | hdd_unregister_wext_all_adapters(hdd_ctx); |
| 6557 | /* |
| 6558 | * Cancel any outstanding scan requests. We are about to close |
| 6559 | * all of our adapters, but an adapter structure is what SME |
| 6560 | * passes back to our callback function. Hence if there |
| 6561 | * are any outstanding scan requests then there is a |
| 6562 | * race condition between when the adapter is closed and |
| 6563 | * when the callback is invoked. We try to resolve that |
| 6564 | * race condition here by canceling any outstanding scans |
| 6565 | * before we close the adapters. |
| 6566 | * Note that the scans may be cancelled in an asynchronous |
| 6567 | * manner, so ideally there needs to be some kind of |
| 6568 | * synchronization. Rather than introduce a new |
| 6569 | * synchronization here, we will utilize the fact that we are |
| 6570 | * about to Request Full Power, and since that is synchronized, |
| 6571 | * the expectation is that by the time Request Full Power has |
| 6572 | * completed, all scans will be cancelled |
| 6573 | */ |
| 6574 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6575 | hdd_abort_sched_scan_all_adapters(hdd_ctx); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 6576 | hdd_stop_all_adapters(hdd_ctx); |
bings | 29c9986 | 2017-11-01 13:54:13 +0800 | [diff] [blame] | 6577 | hdd_deinit_all_adapters(hdd_ctx, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6578 | } |
| 6579 | |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 6580 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 6581 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 6582 | hdd_wlan_stop_modules(hdd_ctx, false); |
Hanumanth Reddy Pothula | 709a636 | 2016-10-18 18:19:44 +0530 | [diff] [blame] | 6583 | |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 6584 | hdd_driver_memdump_deinit(); |
| 6585 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 6586 | qdf_nbuf_deinit_replenish_timer(); |
| 6587 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 6588 | if (QDF_GLOBAL_MONITOR_MODE == hdd_get_conparam()) { |
| 6589 | hdd_info("Release wakelock for monitor mode!"); |
| 6590 | qdf_wake_lock_release(&hdd_ctx->monitor_mode_wakelock, |
| 6591 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 6592 | } |
| 6593 | |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 6594 | qdf_spinlock_destroy(&hdd_ctx->hdd_adapter_lock); |
| 6595 | qdf_spinlock_destroy(&hdd_ctx->sta_update_info_lock); |
| 6596 | qdf_spinlock_destroy(&hdd_ctx->connection_status_lock); |
| 6597 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6598 | /* |
| 6599 | * Close CDS |
| 6600 | * This frees pMac(HAL) context. There should not be any call |
| 6601 | * that requires pMac access after this. |
| 6602 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6603 | |
Jeff Johnson | ce0032c | 2017-01-20 07:18:27 -0800 | [diff] [blame] | 6604 | hdd_request_manager_deinit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6605 | |
Dustin Brown | d005ad8 | 2018-01-19 10:32:13 -0800 | [diff] [blame] | 6606 | hdd_close_all_adapters(hdd_ctx, false); |
| 6607 | |
Manishekar Chandrasekaran | f7a1dad | 2016-06-23 06:43:47 +0530 | [diff] [blame] | 6608 | wlansap_global_deinit(); |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 6609 | /* |
| 6610 | * If there is re_init failure wiphy would have already de-registered |
| 6611 | * check the wiphy status before un-registering again |
| 6612 | */ |
Ashish Kumar Dhanotiya | e16feb7 | 2017-03-31 19:39:37 +0530 | [diff] [blame] | 6613 | if (wiphy && wiphy->registered) { |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 6614 | wiphy_unregister(wiphy); |
| 6615 | wlan_hdd_cfg80211_deinit(wiphy); |
| 6616 | hdd_lpass_notify_stop(hdd_ctx); |
| 6617 | } |
Yuanyuan Liu | 3e918e5 | 2016-08-17 15:41:35 -0700 | [diff] [blame] | 6618 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6619 | hdd_exit_netlink_services(hdd_ctx); |
| 6620 | mutex_destroy(&hdd_ctx->iface_change_lock); |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 6621 | #ifdef FEATURE_WLAN_CH_AVOID |
| 6622 | mutex_destroy(&hdd_ctx->avoid_freq_lock); |
| 6623 | #endif |
Abhishek Singh | e9068f1 | 2017-03-31 14:14:52 +0530 | [diff] [blame] | 6624 | |
Abhishek Singh | e9068f1 | 2017-03-31 14:14:52 +0530 | [diff] [blame] | 6625 | driver_status = hdd_objmgr_release_and_destroy_psoc(hdd_ctx); |
| 6626 | if (driver_status) |
| 6627 | hdd_err("Psoc delete failed"); |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 6628 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6629 | hdd_context_destroy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6630 | } |
| 6631 | |
| 6632 | void __hdd_wlan_exit(void) |
| 6633 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6634 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6635 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6636 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6637 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 6638 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6639 | if (!hdd_ctx) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6640 | hdd_err("Invalid HDD Context"); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6641 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6642 | return; |
| 6643 | } |
| 6644 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6645 | /* Do all the cleanup before deregistering the driver */ |
| 6646 | hdd_wlan_exit(hdd_ctx); |
Mohit Khanna | ebf8a86 | 2016-04-28 17:53:59 -0700 | [diff] [blame] | 6647 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6648 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6649 | } |
| 6650 | |
| 6651 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 6652 | /** |
| 6653 | * hdd_skip_acs_scan_timer_handler() - skip ACS scan timer timeout handler |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6654 | * @data: pointer to struct hdd_context |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 6655 | * |
| 6656 | * This function will reset acs_scan_status to eSAP_DO_NEW_ACS_SCAN. |
| 6657 | * Then new ACS request will do a fresh scan without reusing the cached |
| 6658 | * scan information. |
| 6659 | * |
| 6660 | * Return: void |
| 6661 | */ |
Tang Yingying | 523322d | 2017-01-17 23:28:43 +0800 | [diff] [blame] | 6662 | static void hdd_skip_acs_scan_timer_handler(void *data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6663 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6664 | struct hdd_context *hdd_ctx = (struct hdd_context *) data; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6665 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6666 | hdd_debug("ACS Scan result expired. Reset ACS scan skip"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6667 | hdd_ctx->skip_acs_scan_status = eSAP_DO_NEW_ACS_SCAN; |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 6668 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 6669 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 6670 | hdd_ctx->last_acs_channel_list = NULL; |
| 6671 | hdd_ctx->num_of_channels = 0; |
| 6672 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6673 | |
| 6674 | if (!hdd_ctx->hHal) |
| 6675 | return; |
| 6676 | sme_scan_flush_result(hdd_ctx->hHal); |
| 6677 | } |
| 6678 | #endif |
| 6679 | |
| 6680 | #ifdef QCA_HT_2040_COEX |
Jeff Johnson | e7672e7 | 2017-10-21 15:10:04 -0700 | [diff] [blame] | 6681 | int hdd_wlan_set_ht2040_mode(struct hdd_adapter *adapter, uint16_t sta_id, |
| 6682 | struct qdf_mac_addr sta_mac, int channel_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6683 | { |
| 6684 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6685 | QDF_STATUS qdf_status; |
Jeff Johnson | e7672e7 | 2017-10-21 15:10:04 -0700 | [diff] [blame] | 6686 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6687 | |
| 6688 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 6689 | |
| 6690 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 6691 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6692 | return status; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 6693 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6694 | if (!hdd_ctx->hHal) |
| 6695 | return -EINVAL; |
| 6696 | |
Jeff Johnson | e7672e7 | 2017-10-21 15:10:04 -0700 | [diff] [blame] | 6697 | 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] | 6698 | adapter->session_id, channel_type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6699 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6700 | hdd_err("Fail to send notification with ht2040 mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6701 | return -EINVAL; |
| 6702 | } |
| 6703 | |
| 6704 | return 0; |
| 6705 | } |
| 6706 | #endif |
| 6707 | |
| 6708 | /** |
| 6709 | * hdd_wlan_notify_modem_power_state() - notify FW with modem power status |
| 6710 | * @state: state |
| 6711 | * |
| 6712 | * This function notifies FW with modem power status |
| 6713 | * |
| 6714 | * Return: 0 if successful, error number otherwise |
| 6715 | */ |
| 6716 | int hdd_wlan_notify_modem_power_state(int state) |
| 6717 | { |
| 6718 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6719 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6720 | struct hdd_context *hdd_ctx; |
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 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 6724 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6725 | return status; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 6726 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6727 | if (!hdd_ctx->hHal) |
| 6728 | return -EINVAL; |
| 6729 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6730 | qdf_status = sme_notify_modem_power_state(hdd_ctx->hHal, state); |
| 6731 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6732 | hdd_err("Fail to send notification with modem power state %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6733 | state); |
| 6734 | return -EINVAL; |
| 6735 | } |
| 6736 | return 0; |
| 6737 | } |
| 6738 | |
| 6739 | /** |
| 6740 | * |
| 6741 | * hdd_post_cds_enable_config() - HDD post cds start config helper |
| 6742 | * @adapter - Pointer to the HDD |
| 6743 | * |
| 6744 | * Return: None |
| 6745 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6746 | QDF_STATUS hdd_post_cds_enable_config(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6747 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 6748 | QDF_STATUS qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6749 | |
| 6750 | /* |
| 6751 | * Send ready indication to the HDD. This will kick off the MAC |
| 6752 | * into a 'running' state and should kick off an initial scan. |
| 6753 | */ |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 6754 | qdf_ret_status = sme_hdd_ready_ind(hdd_ctx->hHal); |
| 6755 | if (!QDF_IS_STATUS_SUCCESS(qdf_ret_status)) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6756 | hdd_err("sme_hdd_ready_ind() failed with status code %08d [x%08x]", |
| 6757 | qdf_ret_status, qdf_ret_status); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6758 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6759 | } |
| 6760 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6761 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6762 | } |
| 6763 | |
Sourav Mohapatra | 92ea8d6 | 2018-02-05 10:03:10 +0530 | [diff] [blame] | 6764 | struct hdd_adapter *hdd_get_first_valid_adapter(struct hdd_context *hdd_ctx) |
| 6765 | { |
| 6766 | struct hdd_adapter *adapter; |
| 6767 | |
| 6768 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6769 | if (adapter && adapter->magic == WLAN_HDD_ADAPTER_MAGIC) |
| 6770 | return adapter; |
| 6771 | } |
| 6772 | |
| 6773 | return NULL; |
| 6774 | } |
| 6775 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6776 | /* wake lock APIs for HDD */ |
| 6777 | void hdd_prevent_suspend(uint32_t reason) |
| 6778 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 6779 | qdf_wake_lock_acquire(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6780 | } |
| 6781 | |
| 6782 | void hdd_allow_suspend(uint32_t reason) |
| 6783 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 6784 | qdf_wake_lock_release(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6785 | } |
| 6786 | |
| 6787 | void hdd_prevent_suspend_timeout(uint32_t timeout, uint32_t reason) |
| 6788 | { |
Anurag Chouhan | 01cfa4e | 2016-09-04 15:10:49 +0530 | [diff] [blame] | 6789 | cds_host_diag_log_work(&wlan_wake_lock, timeout, reason); |
| 6790 | qdf_wake_lock_timeout_acquire(&wlan_wake_lock, timeout); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6791 | } |
| 6792 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6793 | /* Initialize channel list in sme based on the country code */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6794 | QDF_STATUS hdd_set_sme_chan_list(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6795 | { |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 6796 | |
Amar Singhal | 6f8592b | 2017-04-26 14:31:58 -0700 | [diff] [blame] | 6797 | return sme_init_chan_list(hdd_ctx->hHal, |
| 6798 | hdd_ctx->reg.alpha2, |
| 6799 | hdd_ctx->reg.cc_src); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6800 | } |
| 6801 | |
| 6802 | /** |
| 6803 | * hdd_is_5g_supported() - check if hardware supports 5GHz |
| 6804 | * @hdd_ctx: Pointer to the hdd context |
| 6805 | * |
| 6806 | * HDD function to know if hardware supports 5GHz |
| 6807 | * |
| 6808 | * Return: true if hardware supports 5GHz |
| 6809 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6810 | bool hdd_is_5g_supported(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6811 | { |
Amar Singhal | 58b45ef | 2017-08-01 13:43:54 -0700 | [diff] [blame] | 6812 | if (!hdd_ctx) |
zding | f54169a | 2016-10-12 17:08:45 +0800 | [diff] [blame] | 6813 | return true; |
| 6814 | |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 6815 | if (hdd_ctx->curr_band != BAND_2G) |
zding | f54169a | 2016-10-12 17:08:45 +0800 | [diff] [blame] | 6816 | return true; |
| 6817 | else |
| 6818 | return false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6819 | } |
| 6820 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6821 | static int hdd_wiphy_init(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6822 | { |
| 6823 | struct wiphy *wiphy; |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6824 | int ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6825 | |
| 6826 | wiphy = hdd_ctx->wiphy; |
| 6827 | |
| 6828 | /* |
| 6829 | * The channel information in |
| 6830 | * wiphy needs to be initialized before wiphy registration |
| 6831 | */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6832 | ret_val = hdd_regulatory_init(hdd_ctx, wiphy); |
| 6833 | if (ret_val) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6834 | hdd_err("regulatory init failed"); |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6835 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6836 | } |
| 6837 | |
| 6838 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 6839 | wiphy->wowlan = &wowlan_support_reg_init; |
| 6840 | #else |
| 6841 | wiphy->wowlan.flags = WIPHY_WOWLAN_ANY | |
| 6842 | WIPHY_WOWLAN_MAGIC_PKT | |
| 6843 | WIPHY_WOWLAN_DISCONNECT | |
| 6844 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 6845 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 6846 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 6847 | WIPHY_WOWLAN_4WAY_HANDSHAKE | |
| 6848 | WIPHY_WOWLAN_RFKILL_RELEASE; |
| 6849 | |
| 6850 | wiphy->wowlan.n_patterns = (WOW_MAX_FILTER_LISTS * |
| 6851 | WOW_MAX_FILTERS_PER_LIST); |
| 6852 | wiphy->wowlan.pattern_min_len = WOW_MIN_PATTERN_SIZE; |
| 6853 | wiphy->wowlan.pattern_max_len = WOW_MAX_PATTERN_SIZE; |
| 6854 | #endif |
| 6855 | |
| 6856 | /* registration of wiphy dev with cfg80211 */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6857 | ret_val = wlan_hdd_cfg80211_register(wiphy); |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 6858 | if (0 > ret_val) { |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6859 | hdd_err("wiphy registration failed"); |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 6860 | return ret_val; |
| 6861 | } |
| 6862 | |
Amar Singhal | 2d81201 | 2018-02-03 15:06:47 +0800 | [diff] [blame] | 6863 | pld_increment_driver_load_cnt(hdd_ctx->parent_dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6864 | |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6865 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6866 | } |
| 6867 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 6868 | #ifdef MSM_PLATFORM |
| 6869 | /** |
| 6870 | * hdd_display_periodic_stats() - Function to display periodic stats |
| 6871 | * @hdd_ctx - handle to hdd context |
| 6872 | * @bool data_in_interval - true, if data detected in bw time interval |
| 6873 | * |
| 6874 | * The periodicity is determined by hdd_ctx->config->periodic_stats_disp_time. |
| 6875 | * Stats show up in wlan driver logs. |
| 6876 | * |
| 6877 | * Returns: None |
| 6878 | */ |
| 6879 | static inline |
| 6880 | void hdd_display_periodic_stats(struct hdd_context *hdd_ctx, |
| 6881 | bool data_in_interval) |
| 6882 | { |
| 6883 | static u32 counter; |
| 6884 | static bool data_in_time_period; |
| 6885 | ol_txrx_pdev_handle pdev; |
| 6886 | |
| 6887 | if (hdd_ctx->config->periodic_stats_disp_time == 0) |
| 6888 | return; |
| 6889 | |
| 6890 | pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
| 6891 | if (!pdev) { |
| 6892 | hdd_err("pdev is NULL"); |
| 6893 | return; |
| 6894 | } |
| 6895 | |
| 6896 | counter++; |
| 6897 | if (data_in_interval) |
| 6898 | data_in_time_period = data_in_interval; |
| 6899 | |
| 6900 | if (counter * hdd_ctx->config->busBandwidthComputeInterval >= |
| 6901 | hdd_ctx->config->periodic_stats_disp_time * 1000) { |
| 6902 | if (data_in_time_period) { |
| 6903 | cdp_display_stats(cds_get_context(QDF_MODULE_ID_SOC), |
| 6904 | CDP_TXRX_PATH_STATS, |
| 6905 | QDF_STATS_VERBOSITY_LEVEL_LOW); |
| 6906 | wlan_hdd_display_netif_queue_history |
| 6907 | (hdd_ctx, QDF_STATS_VERBOSITY_LEVEL_LOW); |
| 6908 | qdf_dp_trace_dump_stats(); |
| 6909 | } |
| 6910 | counter = 0; |
| 6911 | data_in_time_period = false; |
| 6912 | } |
| 6913 | } |
| 6914 | |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 6915 | /** |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6916 | * hdd_pld_request_bus_bandwidth() - Function to control bus bandwidth |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 6917 | * @hdd_ctx - handle to hdd context |
| 6918 | * @tx_packets - transmit packet count |
| 6919 | * @rx_packets - receive packet count |
| 6920 | * |
| 6921 | * The function controls the bus bandwidth and dynamic control of |
| 6922 | * tcp delayed ack configuration |
| 6923 | * |
| 6924 | * Returns: None |
| 6925 | */ |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 6926 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6927 | static void hdd_pld_request_bus_bandwidth(struct hdd_context *hdd_ctx, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 6928 | const uint64_t tx_packets, |
| 6929 | const uint64_t rx_packets) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6930 | { |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 6931 | u64 total_pkts = tx_packets + rx_packets; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 6932 | uint64_t temp_rx = 0; |
| 6933 | uint64_t temp_tx = 0; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6934 | enum pld_bus_width_type next_vote_level = PLD_BUS_WIDTH_NONE; |
Mohit Khanna | c3da706 | 2017-02-08 21:08:56 -0800 | [diff] [blame] | 6935 | static enum wlan_tp_level next_rx_level = WLAN_SVC_TP_NONE; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 6936 | enum wlan_tp_level next_tx_level = WLAN_SVC_TP_NONE; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 6937 | uint32_t delack_timer_cnt = hdd_ctx->config->tcp_delack_timer_count; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 6938 | uint16_t index = 0; |
| 6939 | bool vote_level_change = false; |
| 6940 | bool rx_level_change = false; |
| 6941 | bool tx_level_change = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6942 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 6943 | if (total_pkts > hdd_ctx->config->busBandwidthHighThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6944 | next_vote_level = PLD_BUS_WIDTH_HIGH; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 6945 | else if (total_pkts > hdd_ctx->config->busBandwidthMediumThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6946 | next_vote_level = PLD_BUS_WIDTH_MEDIUM; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 6947 | else if (total_pkts > hdd_ctx->config->busBandwidthLowThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6948 | next_vote_level = PLD_BUS_WIDTH_LOW; |
Yue Ma | d6478e4 | 2015-10-20 18:49:24 -0700 | [diff] [blame] | 6949 | else |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6950 | next_vote_level = PLD_BUS_WIDTH_NONE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6951 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6952 | if (hdd_ctx->cur_vote_level != next_vote_level) { |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 6953 | hdd_debug("trigger level %d, tx_packets: %lld, rx_packets: %lld", |
| 6954 | next_vote_level, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6955 | hdd_ctx->cur_vote_level = next_vote_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 6956 | vote_level_change = true; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6957 | pld_request_bus_bandwidth(hdd_ctx->parent_dev, next_vote_level); |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 6958 | if (next_vote_level == PLD_BUS_WIDTH_LOW) { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 6959 | if (hdd_ctx->hbw_requested) { |
| 6960 | pld_remove_pm_qos(hdd_ctx->parent_dev); |
| 6961 | hdd_ctx->hbw_requested = false; |
| 6962 | } |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 6963 | if (cds_sched_handle_throughput_req(false)) |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6964 | hdd_warn("low bandwidth set rx affinity fail"); |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 6965 | } else { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 6966 | if (!hdd_ctx->hbw_requested) { |
| 6967 | pld_request_pm_qos(hdd_ctx->parent_dev, 1); |
| 6968 | hdd_ctx->hbw_requested = true; |
| 6969 | } |
| 6970 | |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 6971 | if (cds_sched_handle_throughput_req(true)) |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6972 | hdd_warn("high bandwidth set rx affinity fail"); |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 6973 | } |
Orhan K AKYILDIZ | 1481aff | 2016-05-16 12:40:13 -0700 | [diff] [blame] | 6974 | hdd_napi_apply_throughput_policy(hdd_ctx, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6975 | } |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 6976 | |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 6977 | qdf_dp_trace_throttle_live_mode( |
| 6978 | (next_vote_level > PLD_BUS_WIDTH_NONE) ? true : false); |
| 6979 | |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 6980 | /* fine-tuning parameters for RX Flows */ |
| 6981 | temp_rx = (rx_packets + hdd_ctx->prev_rx) / 2; |
| 6982 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6983 | hdd_ctx->prev_rx = rx_packets; |
Mohit Khanna | b1dd1e8 | 2017-02-04 15:14:38 -0800 | [diff] [blame] | 6984 | |
Poddar, Siddarth | 47c2340 | 2017-10-25 12:17:39 +0530 | [diff] [blame] | 6985 | if (temp_rx < hdd_ctx->config->busBandwidthLowThreshold) |
| 6986 | hdd_disable_lro_for_low_tput(hdd_ctx, true); |
| 6987 | else |
| 6988 | hdd_disable_lro_for_low_tput(hdd_ctx, false); |
| 6989 | |
Ravi Joshi | fed8357 | 2016-10-07 16:20:37 -0700 | [diff] [blame] | 6990 | if (temp_rx > hdd_ctx->config->tcpDelackThresholdHigh) { |
| 6991 | if ((hdd_ctx->cur_rx_level != WLAN_SVC_TP_HIGH) && |
| 6992 | (++hdd_ctx->rx_high_ind_cnt == delack_timer_cnt)) { |
| 6993 | next_rx_level = WLAN_SVC_TP_HIGH; |
| 6994 | } |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 6995 | } else { |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 6996 | hdd_ctx->rx_high_ind_cnt = 0; |
Mohit Khanna | c3da706 | 2017-02-08 21:08:56 -0800 | [diff] [blame] | 6997 | next_rx_level = WLAN_SVC_TP_LOW; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 6998 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6999 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7000 | if (hdd_ctx->cur_rx_level != next_rx_level) { |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 7001 | struct wlan_rx_tp_data rx_tp_data = {0}; |
| 7002 | |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7003 | hdd_debug("TCP DELACK trigger level %d, average_rx: %llu", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7004 | next_rx_level, temp_rx); |
| 7005 | hdd_ctx->cur_rx_level = next_rx_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7006 | rx_level_change = true; |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7007 | /* Send throughput indication only if it is enabled. |
| 7008 | * Disabling tcp_del_ack will revert the tcp stack behavior |
| 7009 | * to default delayed ack. Note that this will disable the |
| 7010 | * dynamic delayed ack mechanism across the system |
| 7011 | */ |
| 7012 | if (hdd_ctx->config->enable_tcp_delack) |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 7013 | rx_tp_data.rx_tp_flags |= TCP_DEL_ACK_IND; |
| 7014 | |
Mohit Khanna | 6272fb68 | 2017-04-13 09:34:36 -0700 | [diff] [blame] | 7015 | if (hdd_ctx->config->enable_tcp_adv_win_scale) |
| 7016 | rx_tp_data.rx_tp_flags |= TCP_ADV_WIN_SCL; |
| 7017 | |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 7018 | rx_tp_data.level = next_rx_level; |
| 7019 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 7020 | WLAN_SVC_WLAN_TP_IND, &rx_tp_data, |
| 7021 | sizeof(rx_tp_data)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7022 | } |
| 7023 | |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7024 | /* fine-tuning parameters for TX Flows */ |
| 7025 | temp_tx = (tx_packets + hdd_ctx->prev_tx) / 2; |
| 7026 | hdd_ctx->prev_tx = tx_packets; |
| 7027 | if (temp_tx > hdd_ctx->config->tcp_tx_high_tput_thres) |
| 7028 | next_tx_level = WLAN_SVC_TP_HIGH; |
| 7029 | else |
| 7030 | next_tx_level = WLAN_SVC_TP_LOW; |
| 7031 | |
Prakash Manjunathappa | e73e3b5 | 2018-02-27 18:56:22 -0800 | [diff] [blame] | 7032 | if ((hdd_ctx->config->enable_tcp_limit_output) && |
| 7033 | (hdd_ctx->cur_tx_level != next_tx_level)) { |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7034 | hdd_debug("change TCP TX trigger level %d, average_tx: %llu", |
| 7035 | next_tx_level, temp_tx); |
| 7036 | hdd_ctx->cur_tx_level = next_tx_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7037 | tx_level_change = true; |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 7038 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 7039 | WLAN_SVC_WLAN_TP_TX_IND, |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7040 | &next_tx_level, |
| 7041 | sizeof(next_tx_level)); |
| 7042 | } |
| 7043 | |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7044 | index = hdd_ctx->hdd_txrx_hist_idx; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7045 | if (vote_level_change || tx_level_change || rx_level_change) { |
| 7046 | hdd_ctx->hdd_txrx_hist[index].next_tx_level = next_tx_level; |
| 7047 | hdd_ctx->hdd_txrx_hist[index].next_rx_level = next_rx_level; |
| 7048 | hdd_ctx->hdd_txrx_hist[index].next_vote_level = next_vote_level; |
| 7049 | hdd_ctx->hdd_txrx_hist[index].interval_rx = rx_packets; |
| 7050 | hdd_ctx->hdd_txrx_hist[index].interval_tx = tx_packets; |
| 7051 | hdd_ctx->hdd_txrx_hist[index].qtime = qdf_get_log_timestamp(); |
| 7052 | hdd_ctx->hdd_txrx_hist_idx++; |
| 7053 | hdd_ctx->hdd_txrx_hist_idx &= NUM_TX_RX_HISTOGRAM_MASK; |
| 7054 | } |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7055 | |
| 7056 | hdd_display_periodic_stats(hdd_ctx, (total_pkts > 0) ? true : false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7057 | } |
| 7058 | |
| 7059 | #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] | 7060 | static void hdd_bus_bw_work_handler(struct work_struct *work) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7061 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7062 | struct hdd_context *hdd_ctx = container_of(work, struct hdd_context, |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7063 | bus_bw_work); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7064 | struct hdd_adapter *adapter = NULL; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7065 | uint64_t tx_packets = 0, rx_packets = 0; |
Himanshu Agarwal | a6cedee | 2016-06-08 14:50:00 +0530 | [diff] [blame] | 7066 | uint64_t fwd_tx_packets = 0, fwd_rx_packets = 0; |
| 7067 | uint64_t fwd_tx_packets_diff = 0, fwd_rx_packets_diff = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7068 | uint64_t total_tx = 0, total_rx = 0; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7069 | A_STATUS ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7070 | bool connected = false; |
| 7071 | uint32_t ipa_tx_packets = 0, ipa_rx_packets = 0; |
| 7072 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7073 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 7074 | return; |
| 7075 | |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 7076 | if (hdd_ctx->is_wiphy_suspended) |
Jingxiang Ge | c64e193 | 2017-08-22 14:38:59 +0800 | [diff] [blame] | 7077 | goto restart_timer; |
| 7078 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7079 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Manjeet Singh | 01327cc | 2016-09-03 12:14:25 +0530 | [diff] [blame] | 7080 | /* |
| 7081 | * Validate magic so we don't end up accessing |
| 7082 | * an invalid adapter. |
| 7083 | */ |
| 7084 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) |
| 7085 | continue; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7086 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 7087 | if ((adapter->device_mode == QDF_STA_MODE || |
| 7088 | adapter->device_mode == QDF_P2P_CLIENT_MODE) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7089 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)->conn_info.connState |
| 7090 | != eConnectionState_Associated) { |
| 7091 | |
| 7092 | continue; |
| 7093 | } |
| 7094 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 7095 | if ((adapter->device_mode == QDF_SAP_MODE || |
| 7096 | adapter->device_mode == QDF_P2P_GO_MODE) && |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 7097 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->ap_active == false) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7098 | |
| 7099 | continue; |
| 7100 | } |
| 7101 | |
| 7102 | tx_packets += HDD_BW_GET_DIFF(adapter->stats.tx_packets, |
| 7103 | adapter->prev_tx_packets); |
| 7104 | rx_packets += HDD_BW_GET_DIFF(adapter->stats.rx_packets, |
| 7105 | adapter->prev_rx_packets); |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7106 | |
| 7107 | if (adapter->device_mode == QDF_SAP_MODE || |
| 7108 | adapter->device_mode == QDF_P2P_GO_MODE || |
| 7109 | adapter->device_mode == QDF_IBSS_MODE) { |
| 7110 | |
Dhanashri Atre | a8f82f2 | 2017-01-23 12:58:24 -0800 | [diff] [blame] | 7111 | ret = cdp_get_intra_bss_fwd_pkts_count( |
| 7112 | cds_get_context(QDF_MODULE_ID_SOC), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 7113 | adapter->session_id, |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7114 | &fwd_tx_packets, &fwd_rx_packets); |
| 7115 | if (ret == A_OK) { |
| 7116 | fwd_tx_packets_diff += HDD_BW_GET_DIFF( |
| 7117 | fwd_tx_packets, |
| 7118 | adapter->prev_fwd_tx_packets); |
| 7119 | fwd_rx_packets_diff += HDD_BW_GET_DIFF( |
| 7120 | fwd_tx_packets, |
| 7121 | adapter->prev_fwd_rx_packets); |
| 7122 | } |
| 7123 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7124 | |
| 7125 | total_rx += adapter->stats.rx_packets; |
| 7126 | total_tx += adapter->stats.tx_packets; |
| 7127 | |
| 7128 | spin_lock_bh(&hdd_ctx->bus_bw_lock); |
| 7129 | adapter->prev_tx_packets = adapter->stats.tx_packets; |
| 7130 | adapter->prev_rx_packets = adapter->stats.rx_packets; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7131 | adapter->prev_fwd_tx_packets = fwd_tx_packets; |
| 7132 | adapter->prev_fwd_rx_packets = fwd_rx_packets; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7133 | spin_unlock_bh(&hdd_ctx->bus_bw_lock); |
| 7134 | connected = true; |
| 7135 | } |
| 7136 | |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7137 | /* add intra bss forwarded tx and rx packets */ |
| 7138 | tx_packets += fwd_tx_packets_diff; |
| 7139 | rx_packets += fwd_rx_packets_diff; |
| 7140 | |
Sravan Kumar Kairam | 271fab2 | 2018-03-07 18:57:41 +0530 | [diff] [blame] | 7141 | ucfg_ipa_uc_stat_query(hdd_ctx->hdd_pdev, &ipa_tx_packets, |
| 7142 | &ipa_rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7143 | tx_packets += (uint64_t)ipa_tx_packets; |
| 7144 | rx_packets += (uint64_t)ipa_rx_packets; |
| 7145 | |
| 7146 | if (!connected) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 7147 | hdd_err("bus bandwidth timer running in disconnected state"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7148 | return; |
| 7149 | } |
| 7150 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7151 | hdd_pld_request_bus_bandwidth(hdd_ctx, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7152 | |
Sravan Kumar Kairam | 9e99e9a | 2018-03-12 19:09:45 +0530 | [diff] [blame] | 7153 | ucfg_ipa_set_perf_level(hdd_ctx->hdd_pdev, tx_packets, rx_packets); |
Sravan Kumar Kairam | 271fab2 | 2018-03-07 18:57:41 +0530 | [diff] [blame] | 7154 | ucfg_ipa_uc_stat_request(hdd_ctx->hdd_pdev, 2); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7155 | |
Jingxiang Ge | c64e193 | 2017-08-22 14:38:59 +0800 | [diff] [blame] | 7156 | restart_timer: |
Dustin Brown | 2ed6036 | 2017-01-18 12:25:50 -0800 | [diff] [blame] | 7157 | /* ensure periodic timer should still be running before restarting it */ |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7158 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 2ed6036 | 2017-01-18 12:25:50 -0800 | [diff] [blame] | 7159 | if (hdd_ctx->bus_bw_timer_running) |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 7160 | qdf_timer_mod(&hdd_ctx->bus_bw_timer, |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7161 | hdd_ctx->config->busBandwidthComputeInterval); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7162 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7163 | } |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7164 | |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7165 | /** |
| 7166 | * __hdd_bus_bw_cbk() - Bus bandwidth data structure callback. |
| 7167 | * @arg: Argument of timer function |
| 7168 | * |
| 7169 | * Schedule a workqueue in this function where all the processing is done. |
| 7170 | * |
| 7171 | * Return: None. |
| 7172 | */ |
| 7173 | static void __hdd_bus_bw_cbk(void *arg) |
| 7174 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7175 | struct hdd_context *hdd_ctx = (struct hdd_context *) arg; |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7176 | |
| 7177 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 7178 | return; |
| 7179 | |
| 7180 | schedule_work(&hdd_ctx->bus_bw_work); |
| 7181 | } |
| 7182 | |
| 7183 | /** |
| 7184 | * hdd_bus_bw_cbk() - Wrapper for bus bw callback for SSR protection. |
| 7185 | * @arg: Argument of timer function |
| 7186 | * |
| 7187 | * Return: None. |
| 7188 | */ |
| 7189 | static void hdd_bus_bw_cbk(void *arg) |
| 7190 | { |
| 7191 | cds_ssr_protect(__func__); |
| 7192 | __hdd_bus_bw_cbk(arg); |
| 7193 | cds_ssr_unprotect(__func__); |
| 7194 | } |
| 7195 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7196 | int hdd_bus_bandwidth_init(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7197 | { |
| 7198 | spin_lock_init(&hdd_ctx->bus_bw_lock); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7199 | INIT_WORK(&hdd_ctx->bus_bw_work, |
| 7200 | hdd_bus_bw_work_handler); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7201 | hdd_ctx->bus_bw_timer_running = false; |
| 7202 | qdf_spinlock_create(&hdd_ctx->bus_bw_timer_lock); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7203 | qdf_timer_init(NULL, |
| 7204 | &hdd_ctx->bus_bw_timer, |
| 7205 | hdd_bus_bw_cbk, (void *)hdd_ctx, |
| 7206 | QDF_TIMER_TYPE_SW); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7207 | |
| 7208 | return 0; |
| 7209 | } |
| 7210 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7211 | void hdd_bus_bandwidth_destroy(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7212 | { |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7213 | if (hdd_ctx->bus_bw_timer_running) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7214 | hdd_reset_tcp_delack(hdd_ctx); |
| 7215 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7216 | hdd_debug("wait for bus bw work to flush"); |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 7217 | hdd_cancel_bus_bw_work(hdd_ctx); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7218 | qdf_timer_free(&hdd_ctx->bus_bw_timer); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7219 | hdd_ctx->bus_bw_timer_running = false; |
| 7220 | qdf_spinlock_destroy(&hdd_ctx->bus_bw_timer_lock); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7221 | } |
Lin Bai | c5c0688 | 2017-09-21 13:58:43 +0800 | [diff] [blame] | 7222 | |
| 7223 | void hdd_bus_bw_cancel_work(struct hdd_context *hdd_ctx) |
| 7224 | { |
| 7225 | if (hdd_ctx) |
| 7226 | cancel_work_sync(&hdd_ctx->bus_bw_work); |
| 7227 | } |
jiad | cdaf9bd | 2017-10-26 12:20:21 +0800 | [diff] [blame] | 7228 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7229 | #endif |
| 7230 | |
| 7231 | /** |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7232 | * wlan_hdd_init_tx_rx_histogram() - init tx/rx histogram stats |
| 7233 | * @hdd_ctx: hdd context |
| 7234 | * |
| 7235 | * Return: 0 for success or error code |
| 7236 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7237 | 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] | 7238 | { |
| 7239 | hdd_ctx->hdd_txrx_hist = qdf_mem_malloc( |
| 7240 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
| 7241 | if (hdd_ctx->hdd_txrx_hist == NULL) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 7242 | hdd_err("Failed malloc for hdd_txrx_hist"); |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7243 | return -ENOMEM; |
| 7244 | } |
| 7245 | return 0; |
| 7246 | } |
| 7247 | |
| 7248 | /** |
| 7249 | * wlan_hdd_deinit_tx_rx_histogram() - deinit tx/rx histogram stats |
| 7250 | * @hdd_ctx: hdd context |
| 7251 | * |
| 7252 | * Return: none |
| 7253 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7254 | void wlan_hdd_deinit_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7255 | { |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 7256 | if (!hdd_ctx || hdd_ctx->hdd_txrx_hist == NULL) |
| 7257 | return; |
| 7258 | |
| 7259 | qdf_mem_free(hdd_ctx->hdd_txrx_hist); |
| 7260 | hdd_ctx->hdd_txrx_hist = NULL; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7261 | } |
| 7262 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7263 | static uint8_t *convert_level_to_string(uint32_t level) |
| 7264 | { |
| 7265 | switch (level) { |
| 7266 | /* initialize the wlan sub system */ |
| 7267 | case WLAN_SVC_TP_NONE: |
| 7268 | return "NONE"; |
| 7269 | case WLAN_SVC_TP_LOW: |
| 7270 | return "LOW"; |
| 7271 | case WLAN_SVC_TP_MEDIUM: |
| 7272 | return "MED"; |
| 7273 | case WLAN_SVC_TP_HIGH: |
| 7274 | return "HIGH"; |
| 7275 | default: |
| 7276 | return "INVAL"; |
| 7277 | } |
| 7278 | } |
| 7279 | |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7280 | |
| 7281 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7282 | * wlan_hdd_display_tx_rx_histogram() - display tx rx histogram |
| 7283 | * @hdd_ctx: hdd context |
| 7284 | * |
| 7285 | * Return: none |
| 7286 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7287 | void wlan_hdd_display_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7288 | { |
| 7289 | int i; |
| 7290 | |
| 7291 | #ifdef MSM_PLATFORM |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7292 | hdd_debug("BW compute Interval: %dms", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7293 | hdd_ctx->config->busBandwidthComputeInterval); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7294 | 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] | 7295 | hdd_ctx->config->busBandwidthHighThreshold, |
| 7296 | hdd_ctx->config->busBandwidthMediumThreshold, |
| 7297 | hdd_ctx->config->busBandwidthLowThreshold); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7298 | hdd_debug("Enable TCP DEL ACK: %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7299 | hdd_ctx->config->enable_tcp_delack); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7300 | hdd_debug("TCP DEL High TH: %d TCP DEL Low TH: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7301 | hdd_ctx->config->tcpDelackThresholdHigh, |
| 7302 | hdd_ctx->config->tcpDelackThresholdLow); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7303 | 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] | 7304 | hdd_ctx->config->tcp_tx_high_tput_thres); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7305 | #endif |
| 7306 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7307 | hdd_debug("Total entries: %d Current index: %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7308 | NUM_TX_RX_HISTOGRAM, hdd_ctx->hdd_txrx_hist_idx); |
| 7309 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7310 | 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] | 7311 | |
| 7312 | for (i = 0; i < NUM_TX_RX_HISTOGRAM; i++) { |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7313 | /* using hdd_log to avoid printing function name */ |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7314 | if (hdd_ctx->hdd_txrx_hist[i].qtime > 0) |
Dustin Brown | 632af71 | 2018-03-14 15:03:55 -0700 | [diff] [blame] | 7315 | hdd_debug("[%3d][%15llu]: %6llu, %6llu, %s, %s, %s", |
| 7316 | i, hdd_ctx->hdd_txrx_hist[i].qtime, |
| 7317 | hdd_ctx->hdd_txrx_hist[i].interval_rx, |
| 7318 | hdd_ctx->hdd_txrx_hist[i].interval_tx, |
| 7319 | convert_level_to_string( |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7320 | hdd_ctx->hdd_txrx_hist[i]. |
| 7321 | next_vote_level), |
Dustin Brown | 632af71 | 2018-03-14 15:03:55 -0700 | [diff] [blame] | 7322 | convert_level_to_string( |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7323 | hdd_ctx->hdd_txrx_hist[i]. |
| 7324 | next_rx_level), |
Dustin Brown | 632af71 | 2018-03-14 15:03:55 -0700 | [diff] [blame] | 7325 | convert_level_to_string( |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7326 | hdd_ctx->hdd_txrx_hist[i]. |
| 7327 | next_tx_level)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7328 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7329 | } |
| 7330 | |
| 7331 | /** |
| 7332 | * wlan_hdd_clear_tx_rx_histogram() - clear tx rx histogram |
| 7333 | * @hdd_ctx: hdd context |
| 7334 | * |
| 7335 | * Return: none |
| 7336 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7337 | void wlan_hdd_clear_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7338 | { |
| 7339 | hdd_ctx->hdd_txrx_hist_idx = 0; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7340 | qdf_mem_zero(hdd_ctx->hdd_txrx_hist, |
| 7341 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7342 | } |
| 7343 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7344 | /* length of the netif queue log needed per adapter */ |
| 7345 | #define ADAP_NETIFQ_LOG_LEN ((20 * WLAN_REASON_TYPE_MAX) + 50) |
| 7346 | |
| 7347 | /** |
| 7348 | * |
| 7349 | * hdd_display_netif_queue_history_compact() - display compact netifq history |
| 7350 | * @hdd_ctx: hdd context |
| 7351 | * |
| 7352 | * Return: none |
| 7353 | */ |
| 7354 | static void |
| 7355 | hdd_display_netif_queue_history_compact(struct hdd_context *hdd_ctx) |
| 7356 | { |
| 7357 | int adapter_num = 0; |
| 7358 | int i; |
| 7359 | int bytes_written; |
| 7360 | u32 tbytes; |
| 7361 | qdf_time_t total, pause, unpause, curr_time, delta; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7362 | char temp_str[20 * WLAN_REASON_TYPE_MAX]; |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 7363 | char *comb_log_str; |
| 7364 | uint32_t comb_log_str_size; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7365 | struct hdd_adapter *adapter = NULL; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7366 | |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 7367 | comb_log_str_size = (ADAP_NETIFQ_LOG_LEN * MAX_NUMBER_OF_ADAPTERS) + 1; |
| 7368 | comb_log_str = qdf_mem_malloc(comb_log_str_size); |
| 7369 | if (!comb_log_str) { |
| 7370 | hdd_err("failed to alloc comb_log_str"); |
| 7371 | return; |
| 7372 | } |
| 7373 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7374 | bytes_written = 0; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7375 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7376 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7377 | curr_time = qdf_system_ticks(); |
| 7378 | total = curr_time - adapter->start_time; |
| 7379 | delta = curr_time - adapter->last_time; |
| 7380 | |
| 7381 | if (adapter->pause_map) { |
| 7382 | pause = adapter->total_pause_time + delta; |
| 7383 | unpause = adapter->total_unpause_time; |
| 7384 | } else { |
| 7385 | unpause = adapter->total_unpause_time + delta; |
| 7386 | pause = adapter->total_pause_time; |
| 7387 | } |
| 7388 | |
| 7389 | tbytes = 0; |
| 7390 | qdf_mem_set(temp_str, 0, sizeof(temp_str)); |
| 7391 | for (i = WLAN_CONTROL_PATH; i < WLAN_REASON_TYPE_MAX; i++) { |
| 7392 | if (adapter->queue_oper_stats[i].pause_count == 0) |
| 7393 | continue; |
| 7394 | tbytes += |
| 7395 | snprintf( |
| 7396 | &temp_str[tbytes], |
| 7397 | (tbytes >= sizeof(temp_str) ? |
| 7398 | 0 : sizeof(temp_str) - tbytes), |
| 7399 | "%d(%d,%d) ", |
| 7400 | i, |
| 7401 | adapter->queue_oper_stats[i]. |
| 7402 | pause_count, |
| 7403 | adapter->queue_oper_stats[i]. |
| 7404 | unpause_count); |
| 7405 | } |
| 7406 | if (tbytes >= sizeof(temp_str)) |
| 7407 | hdd_warn("log truncated"); |
| 7408 | |
| 7409 | bytes_written += snprintf(&comb_log_str[bytes_written], |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 7410 | bytes_written >= comb_log_str_size ? 0 : |
| 7411 | comb_log_str_size - bytes_written, |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7412 | "[%d %d] (%d) %u/%ums %s|", |
| 7413 | adapter->session_id, adapter->device_mode, |
| 7414 | adapter->pause_map, |
| 7415 | qdf_system_ticks_to_msecs(pause), |
| 7416 | qdf_system_ticks_to_msecs(total), |
| 7417 | temp_str); |
| 7418 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7419 | adapter_num++; |
| 7420 | } |
| 7421 | |
| 7422 | /* using QDF_TRACE to avoid printing function name */ |
| 7423 | QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_INFO_LOW, |
| 7424 | "STATS |%s", comb_log_str); |
| 7425 | |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 7426 | if (bytes_written >= comb_log_str_size) |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7427 | hdd_warn("log string truncated"); |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 7428 | |
| 7429 | qdf_mem_free(comb_log_str); |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7430 | } |
| 7431 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7432 | /** |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 7433 | * wlan_hdd_display_netif_queue_history() - display netif queue history |
Jeff Johnson | 58adbcf | 2017-09-03 08:53:31 -0700 | [diff] [blame] | 7434 | * @hdd_ctx: hdd context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7435 | * |
| 7436 | * Return: none |
| 7437 | */ |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7438 | void |
| 7439 | wlan_hdd_display_netif_queue_history(struct hdd_context *hdd_ctx, |
| 7440 | enum qdf_stats_verbosity_level verb_lvl) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7441 | { |
| 7442 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7443 | struct hdd_adapter *adapter = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7444 | int i; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7445 | qdf_time_t total, pause, unpause, curr_time, delta; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7446 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7447 | if (verb_lvl == QDF_STATS_VERBOSITY_LEVEL_LOW) { |
| 7448 | hdd_display_netif_queue_history_compact(hdd_ctx); |
| 7449 | return; |
| 7450 | } |
| 7451 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7452 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7453 | hdd_debug("Netif queue operation statistics:"); |
| 7454 | hdd_debug("Session_id %d device mode %d", |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 7455 | adapter->session_id, adapter->device_mode); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7456 | hdd_debug("Current pause_map value %x", adapter->pause_map); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7457 | curr_time = qdf_system_ticks(); |
| 7458 | total = curr_time - adapter->start_time; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7459 | delta = curr_time - adapter->last_time; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7460 | if (adapter->pause_map) { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7461 | pause = adapter->total_pause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7462 | unpause = adapter->total_unpause_time; |
| 7463 | } else { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7464 | unpause = adapter->total_unpause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7465 | pause = adapter->total_pause_time; |
| 7466 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7467 | hdd_debug("Total: %ums Pause: %ums Unpause: %ums", |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7468 | qdf_system_ticks_to_msecs(total), |
| 7469 | qdf_system_ticks_to_msecs(pause), |
| 7470 | qdf_system_ticks_to_msecs(unpause)); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7471 | hdd_debug("reason_type: pause_cnt: unpause_cnt: pause_time"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7472 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7473 | for (i = WLAN_CONTROL_PATH; i < WLAN_REASON_TYPE_MAX; i++) { |
| 7474 | qdf_time_t pause_delta = 0; |
| 7475 | |
| 7476 | if (adapter->pause_map & (1 << i)) |
| 7477 | pause_delta = delta; |
| 7478 | |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7479 | /* using hdd_log to avoid printing function name */ |
Dustin Brown | 632af71 | 2018-03-14 15:03:55 -0700 | [diff] [blame] | 7480 | hdd_debug("%s: %d: %d: %ums", |
| 7481 | hdd_reason_type_to_string(i), |
| 7482 | adapter->queue_oper_stats[i].pause_count, |
| 7483 | adapter->queue_oper_stats[i].unpause_count, |
| 7484 | qdf_system_ticks_to_msecs( |
| 7485 | adapter->queue_oper_stats[i].total_pause_time + |
| 7486 | pause_delta)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7487 | } |
| 7488 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7489 | hdd_debug("Netif queue operation history:"); |
| 7490 | hdd_debug("Total entries: %d current index %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7491 | WLAN_HDD_MAX_HISTORY_ENTRY, adapter->history_index); |
| 7492 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7493 | hdd_debug("index: time: action_type: reason_type: pause_map"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7494 | |
| 7495 | for (i = 0; i < WLAN_HDD_MAX_HISTORY_ENTRY; i++) { |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7496 | /* using hdd_log to avoid printing function name */ |
| 7497 | if (adapter->queue_oper_history[i].time == 0) |
| 7498 | continue; |
Dustin Brown | 632af71 | 2018-03-14 15:03:55 -0700 | [diff] [blame] | 7499 | hdd_debug("%d: %u: %s: %s: %x", |
| 7500 | i, qdf_system_ticks_to_msecs( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7501 | adapter->queue_oper_history[i].time), |
Dustin Brown | 632af71 | 2018-03-14 15:03:55 -0700 | [diff] [blame] | 7502 | hdd_action_type_to_string( |
| 7503 | adapter->queue_oper_history[i].netif_action), |
| 7504 | hdd_reason_type_to_string( |
| 7505 | adapter->queue_oper_history[i].netif_reason), |
| 7506 | adapter->queue_oper_history[i].pause_map); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7507 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7508 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7509 | } |
| 7510 | |
| 7511 | /** |
| 7512 | * wlan_hdd_clear_netif_queue_history() - clear netif queue operation history |
| 7513 | * @hdd_ctx: hdd context |
| 7514 | * |
| 7515 | * Return: none |
| 7516 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7517 | void wlan_hdd_clear_netif_queue_history(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7518 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7519 | struct hdd_adapter *adapter = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7520 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7521 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7522 | qdf_mem_zero(adapter->queue_oper_stats, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7523 | sizeof(adapter->queue_oper_stats)); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7524 | qdf_mem_zero(adapter->queue_oper_history, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7525 | sizeof(adapter->queue_oper_history)); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7526 | adapter->history_index = 0; |
| 7527 | adapter->start_time = adapter->last_time = qdf_system_ticks(); |
| 7528 | adapter->total_pause_time = 0; |
| 7529 | adapter->total_unpause_time = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7530 | } |
| 7531 | } |
| 7532 | |
| 7533 | /** |
| 7534 | * hdd_11d_scan_done() - callback for 11d scan completion of flushing results |
| 7535 | * @halHandle: Hal handle |
| 7536 | * @pContext: Pointer to the context |
| 7537 | * @sessionId: Session ID |
| 7538 | * @scanId: Scan ID |
| 7539 | * @status: Status |
| 7540 | * |
| 7541 | * This is the callback to be executed when 11d scan is completed to flush out |
| 7542 | * the scan results |
| 7543 | * |
| 7544 | * 11d scan is done during driver load and is a passive scan on all |
| 7545 | * channels supported by the device, 11d scans may find some APs on |
| 7546 | * frequencies which are forbidden to be used in the regulatory domain |
| 7547 | * the device is operating in. If these APs are notified to the supplicant |
| 7548 | * it may try to connect to these APs, thus flush out all the scan results |
| 7549 | * which are present in SME after 11d scan is done. |
| 7550 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7551 | * Return: QDF_STATUS_SUCCESS |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7552 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7553 | static QDF_STATUS hdd_11d_scan_done(tHalHandle halHandle, void *pContext, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7554 | uint8_t sessionId, uint32_t scanId, |
| 7555 | eCsrScanStatus status) |
| 7556 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 7557 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7558 | |
| 7559 | sme_scan_flush_result(halHandle); |
| 7560 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 7561 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7562 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7563 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7564 | } |
| 7565 | |
| 7566 | #ifdef WLAN_FEATURE_OFFLOAD_PACKETS |
| 7567 | /** |
| 7568 | * hdd_init_offloaded_packets_ctx() - Initialize offload packets context |
| 7569 | * @hdd_ctx: hdd global context |
| 7570 | * |
| 7571 | * Return: none |
| 7572 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7573 | static void hdd_init_offloaded_packets_ctx(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7574 | { |
| 7575 | uint8_t i; |
| 7576 | |
| 7577 | mutex_init(&hdd_ctx->op_ctx.op_lock); |
| 7578 | for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++) { |
| 7579 | hdd_ctx->op_ctx.op_table[i].request_id = MAX_REQUEST_ID; |
| 7580 | hdd_ctx->op_ctx.op_table[i].pattern_id = i; |
| 7581 | } |
| 7582 | } |
| 7583 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7584 | static void hdd_init_offloaded_packets_ctx(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7585 | { |
| 7586 | } |
| 7587 | #endif |
| 7588 | |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7589 | #ifdef WLAN_FEATURE_WOW_PULSE |
| 7590 | /** |
| 7591 | * 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] | 7592 | * @phddctx: struct hdd_context structure pointer |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7593 | * @enable: enable or disable this behaviour |
| 7594 | * |
| 7595 | * Return: int |
| 7596 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7597 | 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] | 7598 | { |
| 7599 | struct hdd_config *pcfg_ini = phddctx->config; |
| 7600 | struct wow_pulse_mode wow_pulse_set_info; |
| 7601 | QDF_STATUS status; |
| 7602 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7603 | hdd_debug("wow pulse enable flag is %d", enable); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7604 | |
| 7605 | if (false == phddctx->config->wow_pulse_support) |
| 7606 | return 0; |
| 7607 | |
| 7608 | /* prepare the request to send to SME */ |
| 7609 | if (enable == true) { |
| 7610 | wow_pulse_set_info.wow_pulse_enable = true; |
| 7611 | wow_pulse_set_info.wow_pulse_pin = |
| 7612 | pcfg_ini->wow_pulse_pin; |
| 7613 | wow_pulse_set_info.wow_pulse_interval_low = |
| 7614 | pcfg_ini->wow_pulse_interval_low; |
| 7615 | wow_pulse_set_info.wow_pulse_interval_high = |
| 7616 | pcfg_ini->wow_pulse_interval_high; |
| 7617 | } else { |
| 7618 | wow_pulse_set_info.wow_pulse_enable = false; |
| 7619 | wow_pulse_set_info.wow_pulse_pin = 0; |
| 7620 | wow_pulse_set_info.wow_pulse_interval_low = 0; |
| 7621 | wow_pulse_set_info.wow_pulse_interval_high = 0; |
| 7622 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7623 | hdd_debug("enable %d pin %d low %d high %d", |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7624 | wow_pulse_set_info.wow_pulse_enable, |
| 7625 | wow_pulse_set_info.wow_pulse_pin, |
| 7626 | wow_pulse_set_info.wow_pulse_interval_low, |
| 7627 | wow_pulse_set_info.wow_pulse_interval_high); |
| 7628 | |
| 7629 | status = sme_set_wow_pulse(&wow_pulse_set_info); |
| 7630 | if (QDF_STATUS_E_FAILURE == status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7631 | hdd_debug("sme_set_wow_pulse failure!"); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7632 | return -EIO; |
| 7633 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7634 | hdd_debug("sme_set_wow_pulse success!"); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7635 | return 0; |
| 7636 | } |
| 7637 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7638 | 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] | 7639 | { |
| 7640 | return 0; |
| 7641 | } |
| 7642 | #endif |
| 7643 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7644 | #ifdef WLAN_FEATURE_FASTPATH |
| 7645 | /** |
| 7646 | * hdd_enable_fastpath() - Enable fastpath if enabled in config INI |
| 7647 | * @hdd_cfg: hdd config |
| 7648 | * @context: lower layer context |
| 7649 | * |
| 7650 | * Return: none |
| 7651 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7652 | void hdd_enable_fastpath(struct hdd_config *hdd_cfg, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7653 | void *context) |
| 7654 | { |
| 7655 | if (hdd_cfg->fastpath_enable) |
| 7656 | hif_enable_fastpath(context); |
| 7657 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7658 | #endif |
| 7659 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7660 | #if defined(FEATURE_WLAN_CH_AVOID) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7661 | /** |
| 7662 | * hdd_set_thermal_level_cb() - set thermal level callback function |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7663 | * @context: hdd context pointer |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7664 | * @level: thermal level |
| 7665 | * |
| 7666 | * Change IPA data path to SW path when the thermal throttle level greater |
| 7667 | * than 0, and restore the original data path when throttle level is 0 |
| 7668 | * |
| 7669 | * Return: none |
| 7670 | */ |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7671 | 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] | 7672 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7673 | struct hdd_context *hdd_ctx = context; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7674 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7675 | /* Change IPA to SW path when throttle level greater than 0 */ |
| 7676 | if (level > THROTTLE_LEVEL_0) |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 7677 | ucfg_ipa_send_mcc_scc_msg(hdd_ctx->hdd_pdev, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7678 | else |
| 7679 | /* restore original concurrency mode */ |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 7680 | ucfg_ipa_send_mcc_scc_msg(hdd_ctx->hdd_pdev, hdd_ctx->mcc_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7681 | } |
| 7682 | |
| 7683 | /** |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7684 | * hdd_get_safe_channel_from_pcl_and_acs_range() - Get safe channel for SAP |
| 7685 | * restart |
Manishekar Chandrasekaran | db9b867 | 2016-06-10 23:31:19 +0530 | [diff] [blame] | 7686 | * @adapter: AP adapter, which should be checked for NULL |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7687 | * |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7688 | * Get a safe channel to restart SAP. PCL already takes into account the |
| 7689 | * unsafe channels. So, the PCL is validated with the ACS range to provide |
| 7690 | * a safe channel for the SAP to restart. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7691 | * |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7692 | * Return: Channel number to restart SAP in case of success. In case of any |
| 7693 | * failure, the channel number returned is zero. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7694 | */ |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7695 | static uint8_t hdd_get_safe_channel_from_pcl_and_acs_range( |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7696 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7697 | { |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7698 | struct sir_pcl_list pcl; |
| 7699 | QDF_STATUS status; |
| 7700 | uint32_t i, j; |
| 7701 | tHalHandle *hal_handle; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7702 | struct hdd_context *hdd_ctx; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7703 | bool found = false; |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 7704 | int ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7705 | |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7706 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 7707 | if (!hdd_ctx) { |
| 7708 | hdd_err("invalid HDD context"); |
| 7709 | return INVALID_CHANNEL_ID; |
| 7710 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7711 | |
Manishekar Chandrasekaran | 79746ac | 2016-06-24 04:45:33 +0530 | [diff] [blame] | 7712 | hal_handle = WLAN_HDD_GET_HAL_CTX(adapter); |
| 7713 | if (!hal_handle) { |
| 7714 | hdd_err("invalid HAL handle"); |
| 7715 | return INVALID_CHANNEL_ID; |
| 7716 | } |
| 7717 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7718 | status = policy_mgr_get_pcl_for_existing_conn(hdd_ctx->hdd_psoc, |
| 7719 | PM_SAP_MODE, pcl.pcl_list, &pcl.pcl_len, |
bings | 37bd58f | 2017-07-20 16:49:26 +0800 | [diff] [blame] | 7720 | pcl.weight_list, QDF_ARRAY_SIZE(pcl.weight_list), |
| 7721 | false); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7722 | if (QDF_IS_STATUS_ERROR(status)) { |
| 7723 | hdd_err("Get PCL failed"); |
| 7724 | return INVALID_CHANNEL_ID; |
| 7725 | } |
| 7726 | |
Frank Liu | dc2cefb | 2017-06-21 15:38:18 +0800 | [diff] [blame] | 7727 | /* |
| 7728 | * In some scenarios, like hw dbs disabled, sap+sap case, if operating |
| 7729 | * channel is unsafe channel, the pcl may be empty, instead of return, |
| 7730 | * try to choose a safe channel from acs range. |
| 7731 | */ |
| 7732 | if (!pcl.pcl_len) |
| 7733 | hdd_debug("pcl length is zero!"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7734 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7735 | hdd_debug("start:%d end:%d", |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7736 | adapter->session.ap.sap_config.acs_cfg.start_ch, |
| 7737 | adapter->session.ap.sap_config.acs_cfg.end_ch); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7738 | |
| 7739 | /* PCL already takes unsafe channel into account */ |
| 7740 | for (i = 0; i < pcl.pcl_len; i++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7741 | hdd_debug("chan[%d]:%d", i, pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7742 | if ((pcl.pcl_list[i] >= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7743 | adapter->session.ap.sap_config.acs_cfg.start_ch) && |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7744 | (pcl.pcl_list[i] <= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7745 | adapter->session.ap.sap_config.acs_cfg.end_ch)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7746 | hdd_debug("found PCL safe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7747 | return pcl.pcl_list[i]; |
| 7748 | } |
| 7749 | } |
| 7750 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7751 | hdd_debug("no safe channel from PCL found in ACS range"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7752 | |
| 7753 | /* Try for safe channel from all valid channel */ |
| 7754 | pcl.pcl_len = MAX_NUM_CHAN; |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 7755 | ret = hdd_get_valid_chan(hdd_ctx, pcl.pcl_list, |
| 7756 | &pcl.pcl_len); |
| 7757 | if (ret) { |
| 7758 | hdd_err("error %d in getting valid channel list", ret); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7759 | return INVALID_CHANNEL_ID; |
| 7760 | } |
| 7761 | |
| 7762 | for (i = 0; i < pcl.pcl_len; i++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7763 | hdd_debug("chan[%d]:%d", i, pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7764 | found = false; |
| 7765 | for (j = 0; j < hdd_ctx->unsafe_channel_count; j++) { |
Krunal Soni | 15f0db1 | 2016-10-11 18:53:37 -0700 | [diff] [blame] | 7766 | if (pcl.pcl_list[i] == |
| 7767 | hdd_ctx->unsafe_channel_list[j]) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7768 | hdd_debug("unsafe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7769 | found = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7770 | break; |
| 7771 | } |
| 7772 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7773 | |
| 7774 | if (found) |
| 7775 | continue; |
| 7776 | |
| 7777 | if ((pcl.pcl_list[i] >= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7778 | adapter->session.ap.sap_config.acs_cfg.start_ch) && |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7779 | (pcl.pcl_list[i] <= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7780 | adapter->session.ap.sap_config.acs_cfg.end_ch)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7781 | hdd_debug("found safe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7782 | return pcl.pcl_list[i]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7783 | } |
| 7784 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7785 | |
| 7786 | return INVALID_CHANNEL_ID; |
| 7787 | } |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 7788 | #endif |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7789 | |
| 7790 | /** |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 7791 | * hdd_switch_sap_channel() - Move SAP to the given channel |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7792 | * @adapter: AP adapter |
| 7793 | * @channel: Channel |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 7794 | * @forced: Force to switch channel, ignore SCC/MCC check |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7795 | * |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 7796 | * Moves the SAP interface by invoking the function which |
| 7797 | * executes the callback to perform channel switch using (E)CSA. |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7798 | * |
| 7799 | * Return: None |
| 7800 | */ |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 7801 | void hdd_switch_sap_channel(struct hdd_adapter *adapter, uint8_t channel, |
| 7802 | bool forced) |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7803 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 7804 | struct hdd_ap_ctx *hdd_ap_ctx; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7805 | tHalHandle *hal_handle; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7806 | struct hdd_context *hdd_ctx; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7807 | |
| 7808 | if (!adapter) { |
| 7809 | hdd_err("invalid adapter"); |
| 7810 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7811 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7812 | |
| 7813 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 7814 | |
| 7815 | hal_handle = WLAN_HDD_GET_HAL_CTX(adapter); |
| 7816 | if (!hal_handle) { |
| 7817 | hdd_err("invalid HAL handle"); |
| 7818 | return; |
| 7819 | } |
| 7820 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7821 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 7822 | |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 7823 | hdd_ap_ctx->sap_config.channel = channel; |
| 7824 | hdd_ap_ctx->sap_config.ch_params.ch_width = |
| 7825 | hdd_ap_ctx->sap_config.ch_width_orig; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7826 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7827 | hdd_debug("chan:%d width:%d", |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 7828 | channel, hdd_ap_ctx->sap_config.ch_width_orig); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7829 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 7830 | wlan_reg_set_channel_params(hdd_ctx->hdd_pdev, |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 7831 | hdd_ap_ctx->sap_config.channel, |
| 7832 | hdd_ap_ctx->sap_config.sec_ch, |
| 7833 | &hdd_ap_ctx->sap_config.ch_params); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7834 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7835 | policy_mgr_change_sap_channel_with_csa(hdd_ctx->hdd_psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 7836 | adapter->session_id, channel, |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 7837 | hdd_ap_ctx->sap_config.ch_width_orig, forced); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7838 | } |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7839 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7840 | 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] | 7841 | { |
| 7842 | struct hdd_external_acs_timer_context *timer_context; |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 7843 | int status; |
| 7844 | QDF_STATUS qdf_status; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7845 | |
| 7846 | set_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
| 7847 | |
| 7848 | if (QDF_TIMER_STATE_RUNNING == |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7849 | qdf_mc_timer_get_current_state(&adapter->session. |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7850 | ap.vendor_acs_timer)) { |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7851 | qdf_mc_timer_stop(&adapter->session.ap.vendor_acs_timer); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7852 | } |
| 7853 | timer_context = (struct hdd_external_acs_timer_context *) |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7854 | adapter->session.ap.vendor_acs_timer.user_data; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7855 | timer_context->reason = reason; |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 7856 | qdf_status = |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7857 | qdf_mc_timer_start(&adapter->session.ap.vendor_acs_timer, |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 7858 | WLAN_VENDOR_ACS_WAIT_TIME); |
| 7859 | if (qdf_status != QDF_STATUS_SUCCESS) { |
| 7860 | hdd_err("failed to start external acs timer"); |
| 7861 | return -ENOSPC; |
| 7862 | } |
| 7863 | /* Update config to application */ |
| 7864 | status = hdd_cfg80211_update_acs_config(adapter, reason); |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 7865 | hdd_info("Updated ACS config to nl with reason %d", reason); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7866 | |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 7867 | return status; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7868 | } |
| 7869 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 7870 | #if defined(FEATURE_WLAN_CH_AVOID) |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7871 | /** |
| 7872 | * hdd_unsafe_channel_restart_sap() - restart sap if sap is on unsafe channel |
| 7873 | * @hdd_ctx: hdd context pointer |
| 7874 | * |
| 7875 | * hdd_unsafe_channel_restart_sap check all unsafe channel list |
| 7876 | * and if ACS is enabled, driver will ask userspace to restart the |
| 7877 | * sap. User space on LTE coex indication restart driver. |
| 7878 | * |
| 7879 | * Return - none |
| 7880 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7881 | void hdd_unsafe_channel_restart_sap(struct hdd_context *hdd_ctxt) |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7882 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7883 | struct hdd_adapter *adapter; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7884 | uint32_t i; |
| 7885 | bool found = false; |
| 7886 | uint8_t restart_chan; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7887 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7888 | hdd_for_each_adapter(hdd_ctxt, adapter) { |
| 7889 | if (!(adapter->device_mode == QDF_SAP_MODE && |
| 7890 | adapter->session.ap.sap_config.acs_cfg.acs_mode)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7891 | hdd_debug("skip device mode:%d acs:%d", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7892 | adapter->device_mode, |
| 7893 | adapter->session.ap.sap_config. |
| 7894 | acs_cfg.acs_mode); |
| 7895 | continue; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7896 | } |
| 7897 | |
| 7898 | found = false; |
| 7899 | for (i = 0; i < hdd_ctxt->unsafe_channel_count; i++) { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7900 | if (adapter->session.ap.operating_channel == |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7901 | hdd_ctxt->unsafe_channel_list[i]) { |
| 7902 | found = true; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7903 | hdd_debug("operating ch:%d is unsafe", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7904 | adapter->session.ap.operating_channel); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7905 | break; |
| 7906 | } |
| 7907 | } |
| 7908 | |
| 7909 | if (!found) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7910 | hdd_debug("ch:%d is safe. no need to change channel", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7911 | adapter->session.ap.operating_channel); |
| 7912 | continue; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7913 | } |
| 7914 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7915 | if (hdd_ctxt->config->vendor_acs_support && |
| 7916 | hdd_ctxt->config->acs_support_for_dfs_ltecoex) { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7917 | hdd_update_acs_timer_reason(adapter, |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7918 | QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7919 | continue; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7920 | } else |
| 7921 | restart_chan = |
| 7922 | hdd_get_safe_channel_from_pcl_and_acs_range( |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7923 | adapter); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7924 | if (!restart_chan) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7925 | hdd_err("fail to restart SAP"); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7926 | } else { |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 7927 | /* |
| 7928 | * SAP restart due to unsafe channel. While |
| 7929 | * restarting the SAP, make sure to clear |
| 7930 | * acs_channel, channel to reset to |
| 7931 | * 0. Otherwise these settings will override |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 7932 | * the ACS while restart. |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 7933 | */ |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 7934 | hdd_ctxt->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7935 | adapter->session.ap.sap_config.channel = |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 7936 | AUTO_CHANNEL_SELECT; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7937 | hdd_debug("sending coex indication"); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7938 | wlan_hdd_send_svc_nlink_msg(hdd_ctxt->radio_index, |
| 7939 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
Liangwei Dong | 6663d16 | 2017-07-10 03:29:36 -0400 | [diff] [blame] | 7940 | hdd_debug("driver to start sap: %d", |
| 7941 | hdd_ctxt->config->sap_internal_restart); |
| 7942 | if (hdd_ctxt->config->sap_internal_restart) |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 7943 | hdd_switch_sap_channel(adapter, restart_chan, |
| 7944 | true); |
Liangwei Dong | 6663d16 | 2017-07-10 03:29:36 -0400 | [diff] [blame] | 7945 | else |
| 7946 | return; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7947 | } |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7948 | } |
| 7949 | } |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 7950 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7951 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7952 | * hdd_init_channel_avoidance() - Initialize channel avoidance |
| 7953 | * @hdd_ctx: HDD global context |
| 7954 | * |
| 7955 | * Initialize the channel avoidance logic by retrieving the unsafe |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7956 | * channel list from the platform driver and plumbing the data |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7957 | * down to the lower layers. Then subscribe to subsequent channel |
| 7958 | * avoidance events. |
| 7959 | * |
| 7960 | * Return: None |
| 7961 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7962 | static void hdd_init_channel_avoidance(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7963 | { |
| 7964 | uint16_t unsafe_channel_count; |
| 7965 | int index; |
| 7966 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7967 | pld_get_wlan_unsafe_channel(hdd_ctx->parent_dev, |
| 7968 | hdd_ctx->unsafe_channel_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7969 | &(hdd_ctx->unsafe_channel_count), |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 7970 | sizeof(uint16_t) * NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7971 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7972 | hdd_debug("num of unsafe channels is %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7973 | hdd_ctx->unsafe_channel_count); |
| 7974 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 7975 | unsafe_channel_count = QDF_MIN((uint16_t)hdd_ctx->unsafe_channel_count, |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 7976 | (uint16_t)NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7977 | |
| 7978 | for (index = 0; index < unsafe_channel_count; index++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7979 | hdd_debug("channel %d is not safe", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7980 | hdd_ctx->unsafe_channel_list[index]); |
| 7981 | |
| 7982 | } |
| 7983 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7984 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 7985 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7986 | static void hdd_lte_coex_restart_sap(struct hdd_adapter *adapter, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7987 | struct hdd_context *hdd_ctx) |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 7988 | { |
| 7989 | uint8_t restart_chan; |
| 7990 | |
| 7991 | restart_chan = hdd_get_safe_channel_from_pcl_and_acs_range(adapter); |
| 7992 | if (!restart_chan) { |
| 7993 | hdd_alert("fail to restart SAP"); |
| 7994 | return; |
| 7995 | } |
| 7996 | |
| 7997 | /* SAP restart due to unsafe channel. While restarting |
| 7998 | * the SAP, make sure to clear acs_channel, channel to |
| 7999 | * reset to 0. Otherwise these settings will override |
| 8000 | * the ACS while restart. |
| 8001 | */ |
| 8002 | hdd_ctx->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8003 | adapter->session.ap.sap_config.channel = AUTO_CHANNEL_SELECT; |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8004 | |
| 8005 | hdd_debug("sending coex indication"); |
| 8006 | |
| 8007 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 8008 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8009 | hdd_switch_sap_channel(adapter, restart_chan, true); |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8010 | } |
Liangwei Dong | 6e1a209 | 2017-08-30 16:29:06 +0800 | [diff] [blame] | 8011 | |
| 8012 | int hdd_clone_local_unsafe_chan(struct hdd_context *hdd_ctx, |
| 8013 | uint16_t **local_unsafe_list, uint16_t *local_unsafe_list_count) |
| 8014 | { |
| 8015 | uint32_t size; |
| 8016 | uint16_t *unsafe_list; |
| 8017 | uint16_t chan_count; |
| 8018 | |
| 8019 | if (!hdd_ctx || !local_unsafe_list_count || !local_unsafe_list_count) |
| 8020 | return -EINVAL; |
| 8021 | |
| 8022 | chan_count = QDF_MIN(hdd_ctx->unsafe_channel_count, |
| 8023 | NUM_CHANNELS); |
| 8024 | if (chan_count) { |
| 8025 | size = chan_count * sizeof(hdd_ctx->unsafe_channel_list[0]); |
| 8026 | unsafe_list = qdf_mem_malloc(size); |
| 8027 | if (!unsafe_list) { |
| 8028 | hdd_err("No memory for unsafe chan list size%d", |
| 8029 | size); |
| 8030 | return -ENOMEM; |
| 8031 | } |
| 8032 | qdf_mem_copy(unsafe_list, hdd_ctx->unsafe_channel_list, size); |
| 8033 | } else { |
| 8034 | unsafe_list = NULL; |
| 8035 | } |
| 8036 | |
| 8037 | *local_unsafe_list = unsafe_list; |
| 8038 | *local_unsafe_list_count = chan_count; |
| 8039 | |
| 8040 | return 0; |
| 8041 | } |
| 8042 | |
| 8043 | bool hdd_local_unsafe_channel_updated(struct hdd_context *hdd_ctx, |
| 8044 | uint16_t *local_unsafe_list, uint16_t local_unsafe_list_count) |
| 8045 | { |
| 8046 | int i, j; |
| 8047 | |
| 8048 | if (local_unsafe_list_count != hdd_ctx->unsafe_channel_count) |
| 8049 | return true; |
| 8050 | if (local_unsafe_list_count == 0) |
| 8051 | return false; |
| 8052 | for (i = 0; i < local_unsafe_list_count; i++) { |
| 8053 | for (j = 0; j < local_unsafe_list_count; j++) |
| 8054 | if (local_unsafe_list[i] == |
| 8055 | hdd_ctx->unsafe_channel_list[j]) |
| 8056 | break; |
| 8057 | if (j >= local_unsafe_list_count) |
| 8058 | break; |
| 8059 | } |
| 8060 | if (i >= local_unsafe_list_count) { |
| 8061 | hdd_info("unsafe chan list same"); |
| 8062 | return false; |
| 8063 | } |
| 8064 | |
| 8065 | return true; |
| 8066 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8067 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8068 | static void hdd_init_channel_avoidance(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8069 | { |
| 8070 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8071 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8072 | 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] | 8073 | { |
| 8074 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8075 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8076 | static inline void hdd_lte_coex_restart_sap(struct hdd_adapter *adapter, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8077 | struct hdd_context *hdd_ctx) |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8078 | { |
| 8079 | hdd_debug("Channel avoidance is not enabled; Abort SAP restart"); |
| 8080 | } |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8081 | #endif /* defined(FEATURE_WLAN_CH_AVOID) */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8082 | |
| 8083 | /** |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8084 | * hdd_indicate_mgmt_frame() - Wrapper to indicate management frame to |
| 8085 | * user space |
| 8086 | * @frame_ind: Management frame data to be informed. |
| 8087 | * |
| 8088 | * This function is used to indicate management frame to |
| 8089 | * user space |
| 8090 | * |
| 8091 | * Return: None |
| 8092 | * |
| 8093 | */ |
| 8094 | void hdd_indicate_mgmt_frame(tSirSmeMgmtFrameInd *frame_ind) |
| 8095 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8096 | struct hdd_context *hdd_ctx = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8097 | struct hdd_adapter *adapter = NULL; |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8098 | int i; |
| 8099 | |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8100 | /* Get the HDD context.*/ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8101 | hdd_ctx = (struct hdd_context *)cds_get_context(QDF_MODULE_ID_HDD); |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8102 | |
| 8103 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
| 8104 | return; |
| 8105 | |
| 8106 | if (SME_SESSION_ID_ANY == frame_ind->sessionId) { |
| 8107 | for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) { |
| 8108 | adapter = |
| 8109 | hdd_get_adapter_by_sme_session_id(hdd_ctx, i); |
| 8110 | if (adapter) |
| 8111 | break; |
| 8112 | } |
Wu Gao | a0230a6 | 2018-01-04 20:56:57 +0800 | [diff] [blame] | 8113 | } else if (SME_SESSION_ID_BROADCAST == frame_ind->sessionId) { |
| 8114 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 8115 | if ((NULL != adapter) && |
| 8116 | (WLAN_HDD_ADAPTER_MAGIC == adapter->magic)) { |
| 8117 | __hdd_indicate_mgmt_frame(adapter, |
| 8118 | frame_ind->frame_len, |
| 8119 | frame_ind->frameBuf, |
| 8120 | frame_ind->frameType, |
| 8121 | frame_ind->rxChan, |
| 8122 | frame_ind->rxRssi); |
| 8123 | } |
| 8124 | } |
| 8125 | adapter = NULL; |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8126 | } else { |
| 8127 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, |
| 8128 | frame_ind->sessionId); |
| 8129 | } |
| 8130 | |
| 8131 | if ((NULL != adapter) && |
| 8132 | (WLAN_HDD_ADAPTER_MAGIC == adapter->magic)) |
| 8133 | __hdd_indicate_mgmt_frame(adapter, |
| 8134 | frame_ind->frame_len, |
| 8135 | frame_ind->frameBuf, |
| 8136 | frame_ind->frameType, |
| 8137 | frame_ind->rxChan, |
| 8138 | frame_ind->rxRssi); |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8139 | } |
| 8140 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8141 | void hdd_acs_response_timeout_handler(void *context) |
| 8142 | { |
| 8143 | struct hdd_external_acs_timer_context *timer_context = |
| 8144 | (struct hdd_external_acs_timer_context *)context; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8145 | struct hdd_adapter *adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8146 | struct hdd_context *hdd_ctx; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8147 | uint8_t reason; |
| 8148 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 8149 | hdd_enter(); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8150 | if (!timer_context) { |
| 8151 | hdd_err("invlaid timer context"); |
| 8152 | return; |
| 8153 | } |
| 8154 | adapter = timer_context->adapter; |
| 8155 | reason = timer_context->reason; |
| 8156 | |
| 8157 | |
| 8158 | if ((!adapter) || |
| 8159 | (adapter->magic != WLAN_HDD_ADAPTER_MAGIC)) { |
| 8160 | hdd_err("invalid adapter or adapter has invalid magic"); |
| 8161 | return; |
| 8162 | } |
| 8163 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 8164 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 8165 | return; |
| 8166 | |
| 8167 | if (test_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags)) |
| 8168 | clear_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
| 8169 | else |
| 8170 | return; |
| 8171 | |
| 8172 | hdd_err("ACS timeout happened for %s reason %d", |
| 8173 | adapter->dev->name, reason); |
| 8174 | switch (reason) { |
| 8175 | /* SAP init case */ |
| 8176 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_INIT: |
| 8177 | wlan_sap_set_vendor_acs(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 8178 | false); |
| 8179 | wlan_hdd_cfg80211_start_acs(adapter); |
| 8180 | break; |
| 8181 | /* DFS detected on current channel */ |
| 8182 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_DFS: |
| 8183 | wlan_sap_update_next_channel( |
| 8184 | WLAN_HDD_GET_SAP_CTX_PTR(adapter), 0, 0); |
| 8185 | sme_update_new_channel_event(WLAN_HDD_GET_HAL_CTX(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 8186 | adapter->session_id); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8187 | break; |
| 8188 | /* LTE coex event on current channel */ |
| 8189 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX: |
| 8190 | hdd_lte_coex_restart_sap(adapter, hdd_ctx); |
| 8191 | break; |
| 8192 | default: |
| 8193 | hdd_info("invalid reason for timer invoke"); |
| 8194 | |
| 8195 | } |
| 8196 | } |
| 8197 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8198 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8199 | * hdd_override_ini_config - Override INI config |
| 8200 | * @hdd_ctx: HDD context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8201 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8202 | * Override INI config based on module parameter. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8203 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8204 | * Return: None |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8205 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8206 | static void hdd_override_ini_config(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8207 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8208 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8209 | if (0 == enable_dfs_chan_scan || 1 == enable_dfs_chan_scan) { |
| 8210 | hdd_ctx->config->enableDFSChnlScan = enable_dfs_chan_scan; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8211 | hdd_debug("Module enable_dfs_chan_scan set to %d", |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8212 | enable_dfs_chan_scan); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8213 | } |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8214 | if (0 == enable_11d || 1 == enable_11d) { |
| 8215 | hdd_ctx->config->Is11dSupportEnabled = enable_11d; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8216 | hdd_debug("Module enable_11d set to %d", enable_11d); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8217 | } |
Leo Chang | 11545d6 | 2016-10-17 14:53:50 -0700 | [diff] [blame] | 8218 | |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 8219 | if (!ucfg_ipa_is_present()) { |
Leo Chang | 11545d6 | 2016-10-17 14:53:50 -0700 | [diff] [blame] | 8220 | hdd_ctx->config->IpaConfig = 0; |
Jingxiang Ge | 7a040dc | 2018-02-02 11:07:59 +0800 | [diff] [blame] | 8221 | hdd_debug("IpaConfig override to %d", |
| 8222 | hdd_ctx->config->IpaConfig); |
| 8223 | } |
Yeshwanth Sriram Guntuka | 2ba6fe9 | 2017-10-04 14:40:45 +0530 | [diff] [blame] | 8224 | |
| 8225 | if (!hdd_ctx->config->rssi_assoc_reject_enabled || |
| 8226 | !hdd_ctx->config->enable_bcast_probe_rsp) { |
| 8227 | hdd_debug("OCE disabled, rssi_assoc_reject_enabled: %d enable_bcast_probe_rsp: %d", |
| 8228 | hdd_ctx->config->rssi_assoc_reject_enabled, |
| 8229 | hdd_ctx->config->enable_bcast_probe_rsp); |
| 8230 | hdd_ctx->config->oce_sta_enabled = 0; |
| 8231 | } |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8232 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8233 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8234 | /** |
| 8235 | * hdd_set_trace_level_for_each - Set trace level for each INI config |
| 8236 | * @hdd_ctx - HDD context |
| 8237 | * |
| 8238 | * Set trace level for each module based on INI config. |
| 8239 | * |
| 8240 | * Return: None |
| 8241 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8242 | 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] | 8243 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 8244 | hdd_qdf_trace_enable(QDF_MODULE_ID_WMI, |
| 8245 | hdd_ctx->config->qdf_trace_enable_wdi); |
| 8246 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD, |
| 8247 | hdd_ctx->config->qdf_trace_enable_hdd); |
| 8248 | hdd_qdf_trace_enable(QDF_MODULE_ID_SME, |
| 8249 | hdd_ctx->config->qdf_trace_enable_sme); |
| 8250 | hdd_qdf_trace_enable(QDF_MODULE_ID_PE, |
| 8251 | hdd_ctx->config->qdf_trace_enable_pe); |
| 8252 | hdd_qdf_trace_enable(QDF_MODULE_ID_WMA, |
| 8253 | hdd_ctx->config->qdf_trace_enable_wma); |
| 8254 | hdd_qdf_trace_enable(QDF_MODULE_ID_SYS, |
| 8255 | hdd_ctx->config->qdf_trace_enable_sys); |
| 8256 | hdd_qdf_trace_enable(QDF_MODULE_ID_QDF, |
| 8257 | hdd_ctx->config->qdf_trace_enable_qdf); |
| 8258 | hdd_qdf_trace_enable(QDF_MODULE_ID_SAP, |
| 8259 | hdd_ctx->config->qdf_trace_enable_sap); |
| 8260 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_SOFTAP, |
| 8261 | hdd_ctx->config->qdf_trace_enable_hdd_sap); |
| 8262 | hdd_qdf_trace_enable(QDF_MODULE_ID_BMI, |
| 8263 | hdd_ctx->config->qdf_trace_enable_bmi); |
| 8264 | hdd_qdf_trace_enable(QDF_MODULE_ID_CFG, |
| 8265 | hdd_ctx->config->qdf_trace_enable_cfg); |
| 8266 | hdd_qdf_trace_enable(QDF_MODULE_ID_EPPING, |
| 8267 | hdd_ctx->config->qdf_trace_enable_epping); |
| 8268 | hdd_qdf_trace_enable(QDF_MODULE_ID_QDF_DEVICE, |
| 8269 | hdd_ctx->config->qdf_trace_enable_qdf_devices); |
| 8270 | hdd_qdf_trace_enable(QDF_MODULE_ID_TXRX, |
Houston Hoffman | fbf0510 | 2017-08-28 11:37:01 -0700 | [diff] [blame] | 8271 | hdd_ctx->config->qdf_trace_enable_txrx); |
| 8272 | hdd_qdf_trace_enable(QDF_MODULE_ID_DP, |
| 8273 | hdd_ctx->config->qdf_trace_enable_dp); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 8274 | hdd_qdf_trace_enable(QDF_MODULE_ID_HTC, |
| 8275 | hdd_ctx->config->qdf_trace_enable_htc); |
| 8276 | hdd_qdf_trace_enable(QDF_MODULE_ID_HIF, |
| 8277 | hdd_ctx->config->qdf_trace_enable_hif); |
| 8278 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_SAP_DATA, |
| 8279 | hdd_ctx->config->qdf_trace_enable_hdd_sap_data); |
| 8280 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_DATA, |
| 8281 | hdd_ctx->config->qdf_trace_enable_hdd_data); |
Naveen Rawat | 7df3186 | 2017-03-01 17:09:30 -0800 | [diff] [blame] | 8282 | hdd_qdf_trace_enable(QDF_MODULE_ID_WIFIPOS, |
| 8283 | hdd_ctx->config->qdf_trace_enable_wifi_pos); |
Naveen Rawat | f2b0dbd | 2017-03-27 10:00:15 -0700 | [diff] [blame] | 8284 | hdd_qdf_trace_enable(QDF_MODULE_ID_NAN, |
| 8285 | hdd_ctx->config->qdf_trace_enable_nan); |
Kiran Kumar Lokere | 798de7e | 2017-03-30 14:01:12 -0700 | [diff] [blame] | 8286 | hdd_qdf_trace_enable(QDF_MODULE_ID_REGULATORY, |
| 8287 | hdd_ctx->config->qdf_trace_enable_regulatory); |
Naveen Rawat | 3cb779e | 2018-02-16 16:36:10 -0800 | [diff] [blame] | 8288 | hdd_qdf_trace_enable(QDF_MODULE_ID_CP_STATS, |
| 8289 | hdd_ctx->config->qdf_trace_enable_cp_stats); |
Kiran Kumar Lokere | 798de7e | 2017-03-30 14:01:12 -0700 | [diff] [blame] | 8290 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8291 | hdd_cfg_print(hdd_ctx); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8292 | } |
| 8293 | |
| 8294 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8295 | * hdd_context_init() - Initialize HDD context |
| 8296 | * @hdd_ctx: HDD context. |
| 8297 | * |
| 8298 | * Initialize HDD context along with all the feature specific contexts. |
| 8299 | * |
| 8300 | * return: 0 on success and errno on failure. |
| 8301 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8302 | static int hdd_context_init(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8303 | { |
| 8304 | int ret; |
| 8305 | |
| 8306 | hdd_ctx->ioctl_scan_mode = eSIR_ACTIVE_SCAN; |
| 8307 | hdd_ctx->max_intf_count = CSR_ROAM_SESSION_MAX; |
| 8308 | |
| 8309 | hdd_init_ll_stats_ctx(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 8310 | hdd_init_nud_stats_ctx(hdd_ctx); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8311 | |
| 8312 | init_completion(&hdd_ctx->mc_sus_event_var); |
| 8313 | init_completion(&hdd_ctx->ready_to_suspend); |
| 8314 | |
| 8315 | qdf_spinlock_create(&hdd_ctx->connection_status_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 8316 | qdf_spinlock_create(&hdd_ctx->sta_update_info_lock); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8317 | qdf_spinlock_create(&hdd_ctx->hdd_adapter_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 8318 | |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 8319 | qdf_list_create(&hdd_ctx->hdd_adapters, MAX_NUMBER_OF_ADAPTERS); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8320 | |
| 8321 | init_completion(&hdd_ctx->set_antenna_mode_cmpl); |
| 8322 | |
| 8323 | ret = hdd_scan_context_init(hdd_ctx); |
| 8324 | if (ret) |
| 8325 | goto list_destroy; |
| 8326 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8327 | hdd_rx_wake_lock_create(hdd_ctx); |
| 8328 | |
| 8329 | ret = hdd_sap_context_init(hdd_ctx); |
| 8330 | if (ret) |
| 8331 | goto scan_destroy; |
| 8332 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8333 | wlan_hdd_cfg80211_extscan_init(hdd_ctx); |
| 8334 | |
| 8335 | hdd_init_offloaded_packets_ctx(hdd_ctx); |
| 8336 | |
| 8337 | ret = wlan_hdd_cfg80211_init(hdd_ctx->parent_dev, hdd_ctx->wiphy, |
| 8338 | hdd_ctx->config); |
| 8339 | if (ret) |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 8340 | goto sap_destroy; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8341 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 8342 | qdf_wake_lock_create(&hdd_ctx->monitor_mode_wakelock, |
| 8343 | "monitor_mode_wakelock"); |
| 8344 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8345 | return 0; |
| 8346 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8347 | sap_destroy: |
| 8348 | hdd_sap_context_destroy(hdd_ctx); |
| 8349 | |
| 8350 | scan_destroy: |
| 8351 | hdd_scan_context_destroy(hdd_ctx); |
| 8352 | hdd_rx_wake_lock_destroy(hdd_ctx); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8353 | list_destroy: |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 8354 | qdf_list_destroy(&hdd_ctx->hdd_adapters); |
Sandeep Puligilla | d000421 | 2017-02-26 18:34:56 -0800 | [diff] [blame] | 8355 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8356 | return ret; |
| 8357 | } |
| 8358 | |
| 8359 | /** |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 8360 | * ie_whitelist_attrs_init() - initialize ie whitelisting attributes |
| 8361 | * @hdd_ctx: pointer to hdd context |
| 8362 | * |
| 8363 | * Return: status of initialization |
| 8364 | * 0 - success |
| 8365 | * negative value - failure |
| 8366 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8367 | static int ie_whitelist_attrs_init(struct hdd_context *hdd_ctx) |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 8368 | { |
| 8369 | int ret; |
| 8370 | |
| 8371 | if (!hdd_ctx->config->probe_req_ie_whitelist) |
| 8372 | return 0; |
| 8373 | |
| 8374 | if (!hdd_validate_prb_req_ie_bitmap(hdd_ctx)) { |
| 8375 | hdd_err("invalid ie bitmap and ouis: disable ie whitelisting"); |
| 8376 | hdd_ctx->config->probe_req_ie_whitelist = false; |
| 8377 | return -EINVAL; |
| 8378 | } |
| 8379 | |
| 8380 | /* parse ini string probe req oui */ |
| 8381 | ret = hdd_parse_probe_req_ouis(hdd_ctx); |
| 8382 | if (ret) { |
| 8383 | hdd_err("parsing error: disable ie whitelisting"); |
| 8384 | hdd_ctx->config->probe_req_ie_whitelist = false; |
| 8385 | } |
| 8386 | |
| 8387 | return ret; |
| 8388 | } |
| 8389 | |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8390 | /** |
| 8391 | * hdd_iface_change_callback() - Function invoked when stop modules expires |
| 8392 | * @priv: pointer to hdd context |
| 8393 | * |
| 8394 | * This function is invoked when the timer waiting for the interface change |
| 8395 | * expires, it shall cut-down the power to wlan and stop all the modules. |
| 8396 | * |
| 8397 | * Return: void |
| 8398 | */ |
| 8399 | static void hdd_iface_change_callback(void *priv) |
| 8400 | { |
| 8401 | struct hdd_context *hdd_ctx = (struct hdd_context *) priv; |
| 8402 | int ret; |
| 8403 | int status = wlan_hdd_validate_context(hdd_ctx); |
| 8404 | |
| 8405 | if (status) |
| 8406 | return; |
| 8407 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 8408 | hdd_enter(); |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8409 | hdd_debug("Interface change timer expired close the modules!"); |
| 8410 | ret = hdd_wlan_stop_modules(hdd_ctx, false); |
| 8411 | if (ret) |
| 8412 | hdd_err("Failed to stop modules"); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 8413 | hdd_exit(); |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8414 | } |
| 8415 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 8416 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 8417 | static void hdd_set_wlan_logging(struct hdd_context *hdd_ctx) |
| 8418 | { |
| 8419 | wlan_logging_set_log_to_console(hdd_ctx->config-> |
| 8420 | wlan_logging_to_console); |
| 8421 | wlan_logging_set_active(hdd_ctx->config->wlan_logging_enable); |
| 8422 | } |
| 8423 | #else |
| 8424 | static void hdd_set_wlan_logging(struct hdd_context *hdd_ctx) |
| 8425 | { } |
| 8426 | #endif |
| 8427 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 8428 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8429 | * hdd_context_create() - Allocate and inialize HDD context. |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8430 | * @dev: Device Pointer to the underlying device |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8431 | * |
| 8432 | * Allocate and initialize HDD context. HDD context is allocated as part of |
| 8433 | * wiphy allocation and then context is initialized. |
| 8434 | * |
| 8435 | * Return: HDD context on success and ERR_PTR on failure |
| 8436 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8437 | static struct hdd_context *hdd_context_create(struct device *dev) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8438 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8439 | QDF_STATUS status; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8440 | int ret = 0; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8441 | struct hdd_context *hdd_ctx; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8442 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 8443 | hdd_enter(); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8444 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8445 | hdd_ctx = hdd_cfg80211_wiphy_alloc(sizeof(struct hdd_context)); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8446 | if (hdd_ctx == NULL) { |
| 8447 | ret = -ENOMEM; |
| 8448 | goto err_out; |
| 8449 | } |
| 8450 | |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 8451 | qdf_create_delayed_work(&hdd_ctx->iface_idle_work, |
| 8452 | hdd_iface_change_callback, |
| 8453 | (void *)hdd_ctx); |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8454 | |
| 8455 | mutex_init(&hdd_ctx->iface_change_lock); |
| 8456 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8457 | hdd_ctx->parent_dev = dev; |
Sreelakshmi Konamki | b53c629 | 2017-03-01 13:13:23 +0530 | [diff] [blame] | 8458 | hdd_ctx->last_scan_reject_session_id = 0xFF; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8459 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 8460 | hdd_ctx->config = qdf_mem_malloc(sizeof(struct hdd_config)); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8461 | if (hdd_ctx->config == NULL) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8462 | hdd_err("Failed to alloc memory for HDD config!"); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8463 | ret = -ENOMEM; |
| 8464 | goto err_free_hdd_context; |
| 8465 | } |
| 8466 | |
| 8467 | /* Read and parse the qcom_cfg.ini file */ |
| 8468 | status = hdd_parse_config_ini(hdd_ctx); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8469 | if (QDF_STATUS_SUCCESS != status) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8470 | hdd_err("Error (status: %d) parsing INI file: %s", status, |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8471 | WLAN_INI_FILE); |
| 8472 | ret = -EINVAL; |
| 8473 | goto err_free_config; |
| 8474 | } |
| 8475 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 8476 | ie_whitelist_attrs_init(hdd_ctx); |
| 8477 | |
Dustin Brown | 7f93993 | 2017-05-18 15:02:17 -0700 | [diff] [blame] | 8478 | hdd_debug("setting timer multiplier: %u", |
| 8479 | hdd_ctx->config->timer_multiplier); |
| 8480 | qdf_timer_set_multiplier(hdd_ctx->config->timer_multiplier); |
| 8481 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8482 | |
Sravan Kumar Kairam | fece87f | 2016-07-26 14:58:28 +0530 | [diff] [blame] | 8483 | if (hdd_ctx->config->fhostNSOffload) |
| 8484 | hdd_ctx->ns_offload_enable = true; |
| 8485 | |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 8486 | cds_set_fatal_event(hdd_ctx->config->enable_fatal_event); |
| 8487 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8488 | hdd_override_ini_config(hdd_ctx); |
| 8489 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8490 | ret = hdd_context_init(hdd_ctx); |
| 8491 | |
| 8492 | if (ret) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8493 | goto err_free_config; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8494 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8495 | /* Uses to enabled logging after SSR */ |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 8496 | hdd_ctx->fw_log_settings.enable = hdd_ctx->config->enable_fw_log; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8497 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8498 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8499 | goto skip_multicast_logging; |
| 8500 | |
| 8501 | cds_set_multicast_logging(hdd_ctx->config->multicast_host_fw_msgs); |
| 8502 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 8503 | ret = wlan_hdd_init_tx_rx_histogram(hdd_ctx); |
| 8504 | if (ret) |
| 8505 | goto err_deinit_hdd_context; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8506 | |
Houston Hoffman | b18dc6e | 2017-08-11 17:43:07 -0700 | [diff] [blame] | 8507 | ret = hdd_init_netlink_services(hdd_ctx); |
| 8508 | if (ret) |
| 8509 | goto err_deinit_txrx_histogram; |
| 8510 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 8511 | hdd_set_wlan_logging(hdd_ctx); |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8512 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8513 | skip_multicast_logging: |
| 8514 | hdd_set_trace_level_for_each(hdd_ctx); |
| 8515 | |
Rajeev Kumar | 493a31b | 2017-09-29 14:01:24 -0700 | [diff] [blame] | 8516 | cds_set_context(QDF_MODULE_ID_HDD, hdd_ctx); |
| 8517 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 8518 | hdd_exit(); |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 8519 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8520 | return hdd_ctx; |
| 8521 | |
Houston Hoffman | b18dc6e | 2017-08-11 17:43:07 -0700 | [diff] [blame] | 8522 | err_deinit_txrx_histogram: |
| 8523 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 8524 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 8525 | err_deinit_hdd_context: |
| 8526 | hdd_context_deinit(hdd_ctx); |
| 8527 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8528 | err_free_config: |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 8529 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8530 | |
| 8531 | err_free_hdd_context: |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8532 | mutex_destroy(&hdd_ctx->iface_change_lock); |
Rajeev Kumar | fa55a69 | 2018-01-09 14:12:41 -0800 | [diff] [blame] | 8533 | wiphy_free(hdd_ctx->wiphy); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8534 | |
| 8535 | err_out: |
| 8536 | return ERR_PTR(ret); |
| 8537 | } |
| 8538 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8539 | #ifdef WLAN_OPEN_P2P_INTERFACE |
| 8540 | /** |
| 8541 | * hdd_open_p2p_interface - Open P2P interface |
| 8542 | * @hdd_ctx: HDD context |
| 8543 | * @rtnl_held: True if RTNL lock held |
| 8544 | * |
| 8545 | * Open P2P interface during probe. This function called to open the P2P |
| 8546 | * interface at probe along with STA interface. |
| 8547 | * |
| 8548 | * Return: 0 on success and errno on failure |
| 8549 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8550 | 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] | 8551 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8552 | struct hdd_adapter *adapter; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8553 | uint8_t *p2p_dev_addr; |
| 8554 | |
| 8555 | if (hdd_ctx->config->isP2pDeviceAddrAdministrated && |
| 8556 | !(hdd_ctx->config->intfMacAddr[0].bytes[0] & 0x02)) { |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 8557 | qdf_mem_copy(hdd_ctx->p2p_device_address.bytes, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8558 | hdd_ctx->config->intfMacAddr[0].bytes, |
| 8559 | sizeof(tSirMacAddr)); |
| 8560 | |
| 8561 | /* |
| 8562 | * Generate the P2P Device Address. This consists of |
| 8563 | * the device's primary MAC address with the locally |
| 8564 | * administered bit set. |
| 8565 | */ |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 8566 | hdd_ctx->p2p_device_address.bytes[0] |= 0x02; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8567 | } else { |
| 8568 | p2p_dev_addr = wlan_hdd_get_intf_addr(hdd_ctx); |
| 8569 | if (p2p_dev_addr == NULL) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8570 | hdd_err("Failed to allocate mac_address for p2p_device"); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8571 | return -ENOSPC; |
| 8572 | } |
| 8573 | |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 8574 | qdf_mem_copy(&hdd_ctx->p2p_device_address.bytes[0], |
| 8575 | p2p_dev_addr, QDF_MAC_ADDR_SIZE); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8576 | } |
| 8577 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 8578 | adapter = hdd_open_adapter(hdd_ctx, QDF_P2P_DEVICE_MODE, "p2p%d", |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 8579 | &hdd_ctx->p2p_device_address.bytes[0], |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 8580 | NET_NAME_UNKNOWN, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8581 | |
| 8582 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8583 | hdd_err("Failed to do hdd_open_adapter for P2P Device Interface"); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8584 | return -ENOSPC; |
| 8585 | } |
| 8586 | |
| 8587 | return 0; |
| 8588 | } |
| 8589 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8590 | static inline int hdd_open_p2p_interface(struct hdd_context *hdd_ctx, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8591 | bool rtnl_held) |
| 8592 | { |
| 8593 | return 0; |
| 8594 | } |
| 8595 | #endif |
| 8596 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8597 | 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] | 8598 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8599 | struct hdd_adapter *adapter; |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8600 | int ret = 0; |
| 8601 | |
| 8602 | adapter = hdd_open_adapter(hdd_ctx, QDF_OCB_MODE, "wlanocb%d", |
| 8603 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 8604 | NET_NAME_UNKNOWN, rtnl_held); |
| 8605 | if (adapter == NULL) { |
| 8606 | hdd_err("Failed to open 802.11p interface"); |
| 8607 | ret = -ENOSPC; |
| 8608 | } |
| 8609 | |
| 8610 | return ret; |
| 8611 | } |
| 8612 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8613 | /** |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8614 | * hdd_start_station_adapter()- Start the Station Adapter |
| 8615 | * @adapter: HDD adapter |
| 8616 | * |
| 8617 | * This function initializes the adapter for the station mode. |
| 8618 | * |
| 8619 | * Return: 0 on success or errno on failure. |
| 8620 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8621 | int hdd_start_station_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8622 | { |
| 8623 | QDF_STATUS status; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8624 | int ret; |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8625 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 8626 | hdd_enter_dev(adapter->dev); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8627 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 8628 | hdd_err("session is already opened, %d", |
| 8629 | adapter->session_id); |
| 8630 | return qdf_status_to_os_return(QDF_STATUS_SUCCESS); |
| 8631 | } |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8632 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8633 | ret = hdd_vdev_create(adapter, hdd_sme_roam_callback, adapter); |
| 8634 | if (ret) { |
| 8635 | hdd_err("failed to create vdev: %d", ret); |
| 8636 | return ret; |
| 8637 | } |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8638 | status = hdd_init_station_mode(adapter); |
| 8639 | |
| 8640 | if (QDF_STATUS_SUCCESS != status) { |
| 8641 | hdd_err("Error Initializing station mode: %d", status); |
| 8642 | return qdf_status_to_os_return(status); |
| 8643 | } |
| 8644 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8645 | hdd_register_tx_flow_control(adapter, |
| 8646 | hdd_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 8647 | hdd_tx_resume_cb, |
| 8648 | hdd_tx_flow_control_is_pause); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8649 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 8650 | hdd_exit(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8651 | return 0; |
| 8652 | } |
| 8653 | |
| 8654 | /** |
| 8655 | * hdd_start_ap_adapter()- Start AP Adapter |
| 8656 | * @adapter: HDD adapter |
| 8657 | * |
| 8658 | * This function initializes the adapter for the AP mode. |
| 8659 | * |
| 8660 | * Return: 0 on success errno on failure. |
| 8661 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8662 | int hdd_start_ap_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8663 | { |
| 8664 | QDF_STATUS status; |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 8665 | bool is_ssr = false; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8666 | int ret; |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 8667 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8668 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 8669 | hdd_enter(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8670 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8671 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 8672 | hdd_err("session is already opened, %d", |
| 8673 | adapter->session_id); |
| 8674 | return qdf_status_to_os_return(QDF_STATUS_SUCCESS); |
| 8675 | } |
| 8676 | /* |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 8677 | * In SSR case no need to create new sap context. |
| 8678 | * Otherwise create sap context first and then create |
| 8679 | * vdev as while creating the vdev, driver needs to |
| 8680 | * register SAP callback and that callback uses sap context |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8681 | */ |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 8682 | if (adapter->session.ap.sap_context) { |
| 8683 | is_ssr = true; |
| 8684 | } else if (!hdd_sap_create_ctx(adapter)) { |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8685 | hdd_err("sap creation failed"); |
| 8686 | return qdf_status_to_os_return(QDF_STATUS_E_FAILURE); |
| 8687 | } |
| 8688 | |
| 8689 | ret = hdd_vdev_create(adapter, wlansap_roam_callback, |
| 8690 | adapter->session.ap.sap_context); |
| 8691 | if (ret) { |
| 8692 | hdd_err("failed to create vdev, status:%d", ret); |
| 8693 | hdd_sap_destroy_ctx(adapter); |
| 8694 | return ret; |
| 8695 | } |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 8696 | |
| 8697 | if (adapter->device_mode == QDF_SAP_MODE) |
| 8698 | sme_cli_set_command(adapter->session_id, |
| 8699 | WMI_VDEV_PARAM_ENABLE_DISABLE_RTT_RESPONDER_ROLE, |
| 8700 | (bool)(hdd_ctx->config->fine_time_meas_cap & |
| 8701 | WMI_FW_AP_RTT_RESPR), |
| 8702 | VDEV_CMD); |
| 8703 | |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 8704 | status = hdd_init_ap_mode(adapter, is_ssr); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8705 | |
| 8706 | if (QDF_STATUS_SUCCESS != status) { |
| 8707 | hdd_err("Error Initializing the AP mode: %d", status); |
| 8708 | return qdf_status_to_os_return(status); |
| 8709 | } |
| 8710 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8711 | hdd_register_tx_flow_control(adapter, |
| 8712 | hdd_softap_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 8713 | hdd_softap_tx_resume_cb, |
| 8714 | hdd_tx_flow_control_is_pause); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8715 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 8716 | hdd_exit(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8717 | return 0; |
| 8718 | } |
| 8719 | |
Sourav Mohapatra | 57006c7 | 2017-11-19 16:15:55 +0530 | [diff] [blame] | 8720 | static int hdd_open_concurrent_interface(struct hdd_context *hdd_ctx, |
| 8721 | bool rtnl_held) |
| 8722 | { |
| 8723 | struct hdd_adapter *adapter; |
| 8724 | |
| 8725 | adapter = hdd_open_adapter(hdd_ctx, QDF_STA_MODE, |
| 8726 | hdd_ctx->config->enableConcurrentSTA, |
| 8727 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 8728 | NET_NAME_UNKNOWN, rtnl_held); |
| 8729 | |
| 8730 | if (!adapter) |
| 8731 | return -ENOSPC; |
| 8732 | |
| 8733 | return 0; |
| 8734 | } |
| 8735 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8736 | /** |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8737 | * hdd_open_interfaces - Open all required interfaces |
| 8738 | * hdd_ctx: HDD context |
| 8739 | * rtnl_held: True if RTNL lock is held |
| 8740 | * |
| 8741 | * Open all the interfaces like STA, P2P and OCB based on the configuration. |
| 8742 | * |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8743 | * Return: 0 if all interfaces were created, otherwise negative errno |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8744 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8745 | 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] | 8746 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8747 | struct hdd_adapter *adapter; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8748 | int ret; |
| 8749 | |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 8750 | /* open monitor mode adapter if con_mode is monitor mode */ |
Lin Bai | 1c67848 | 2017-12-18 18:29:11 +0800 | [diff] [blame] | 8751 | if (con_mode == QDF_GLOBAL_MONITOR_MODE || |
| 8752 | con_mode == QDF_GLOBAL_FTM_MODE) { |
| 8753 | uint8_t session_type = (con_mode == QDF_GLOBAL_MONITOR_MODE) ? |
| 8754 | QDF_MONITOR_MODE : QDF_FTM_MODE; |
| 8755 | |
| 8756 | adapter = hdd_open_adapter(hdd_ctx, session_type, "wlan%d", |
| 8757 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 8758 | NET_NAME_UNKNOWN, rtnl_held); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 8759 | if (!adapter) { |
| 8760 | hdd_err("open adapter failed"); |
| 8761 | return -ENOSPC; |
| 8762 | } |
Lin Bai | 1c67848 | 2017-12-18 18:29:11 +0800 | [diff] [blame] | 8763 | |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 8764 | return 0; |
| 8765 | } |
| 8766 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8767 | if (hdd_ctx->config->dot11p_mode == WLAN_HDD_11P_STANDALONE) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8768 | /* Create only 802.11p interface */ |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8769 | return hdd_open_ocb_interface(hdd_ctx, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8770 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 8771 | adapter = hdd_open_adapter(hdd_ctx, QDF_STA_MODE, "wlan%d", |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8772 | wlan_hdd_get_intf_addr(hdd_ctx), |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 8773 | NET_NAME_UNKNOWN, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8774 | |
| 8775 | if (adapter == NULL) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8776 | return -ENOSPC; |
| 8777 | |
Sourav Mohapatra | 57006c7 | 2017-11-19 16:15:55 +0530 | [diff] [blame] | 8778 | if (strlen(hdd_ctx->config->enableConcurrentSTA) != 0) { |
| 8779 | ret = hdd_open_concurrent_interface(hdd_ctx, rtnl_held); |
| 8780 | if (ret) |
| 8781 | hdd_err("Cannot create concurrent STA interface"); |
| 8782 | } |
| 8783 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8784 | ret = hdd_open_p2p_interface(hdd_ctx, rtnl_held); |
| 8785 | if (ret) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8786 | goto err_close_adapters; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8787 | |
| 8788 | /* Open 802.11p Interface */ |
| 8789 | if (hdd_ctx->config->dot11p_mode == WLAN_HDD_11P_CONCURRENT) { |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8790 | ret = hdd_open_ocb_interface(hdd_ctx, rtnl_held); |
| 8791 | if (ret) |
| 8792 | goto err_close_adapters; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8793 | } |
| 8794 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8795 | return 0; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8796 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8797 | err_close_adapters: |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8798 | hdd_close_all_adapters(hdd_ctx, rtnl_held); |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8799 | return ret; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8800 | } |
| 8801 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8802 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8803 | #ifdef QCA_LL_TX_FLOW_CONTROL_V2 |
| 8804 | /** |
| 8805 | * hdd_txrx_populate_cds_config() - Populate txrx cds configuration |
| 8806 | * @cds_cfg: CDS Configuration |
| 8807 | * @hdd_ctx: Pointer to hdd context |
| 8808 | * |
| 8809 | * Return: none |
| 8810 | */ |
| 8811 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 8812 | *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8813 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8814 | { |
| 8815 | cds_cfg->tx_flow_stop_queue_th = |
| 8816 | hdd_ctx->config->TxFlowStopQueueThreshold; |
| 8817 | cds_cfg->tx_flow_start_queue_offset = |
| 8818 | hdd_ctx->config->TxFlowStartQueueOffset; |
| 8819 | } |
| 8820 | #else |
| 8821 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 8822 | *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8823 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8824 | { |
| 8825 | } |
| 8826 | #endif |
| 8827 | |
| 8828 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 8829 | /** |
| 8830 | * hdd_ra_populate_cds_config() - Populate RA filtering cds configuration |
| 8831 | * @cds_cfg: CDS Configuration |
| 8832 | * @hdd_ctx: Pointer to hdd context |
| 8833 | * |
| 8834 | * Return: none |
| 8835 | */ |
Anand Kumar | 3b92a91 | 2016-12-05 12:01:26 +0530 | [diff] [blame] | 8836 | 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] | 8837 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8838 | { |
| 8839 | cds_cfg->ra_ratelimit_interval = |
| 8840 | hdd_ctx->config->RArateLimitInterval; |
| 8841 | cds_cfg->is_ra_ratelimit_enabled = |
| 8842 | hdd_ctx->config->IsRArateLimitEnabled; |
| 8843 | } |
| 8844 | #else |
Anand Kumar | 3b92a91 | 2016-12-05 12:01:26 +0530 | [diff] [blame] | 8845 | 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] | 8846 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8847 | { |
| 8848 | } |
| 8849 | #endif |
| 8850 | |
| 8851 | /** |
| 8852 | * hdd_update_cds_config() - API to update cds configuration parameters |
| 8853 | * @hdd_ctx: HDD Context |
| 8854 | * |
| 8855 | * Return: 0 for Success, errno on failure |
| 8856 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8857 | static int hdd_update_cds_config(struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8858 | { |
| 8859 | struct cds_config_info *cds_cfg; |
| 8860 | |
| 8861 | cds_cfg = (struct cds_config_info *)qdf_mem_malloc(sizeof(*cds_cfg)); |
| 8862 | if (!cds_cfg) { |
| 8863 | hdd_err("failed to allocate cds config"); |
| 8864 | return -ENOMEM; |
| 8865 | } |
| 8866 | |
Srinivas Girigowda | 35b0031 | 2017-06-27 21:52:03 -0700 | [diff] [blame] | 8867 | cds_cfg->driver_type = QDF_DRIVER_TYPE_PRODUCTION; |
Kiran Kumar Lokere | 7006e0a | 2017-03-07 19:28:36 -0800 | [diff] [blame] | 8868 | if (!hdd_ctx->config->nMaxPsPoll || |
| 8869 | !hdd_ctx->config->enablePowersaveOffload) { |
| 8870 | cds_cfg->powersave_offload_enabled = |
| 8871 | hdd_ctx->config->enablePowersaveOffload; |
| 8872 | } else { |
| 8873 | if ((hdd_ctx->config->enablePowersaveOffload == |
| 8874 | PS_QPOWER_NODEEPSLEEP) || |
| 8875 | (hdd_ctx->config->enablePowersaveOffload == |
| 8876 | PS_LEGACY_NODEEPSLEEP)) |
| 8877 | cds_cfg->powersave_offload_enabled = |
| 8878 | PS_LEGACY_NODEEPSLEEP; |
| 8879 | else |
| 8880 | cds_cfg->powersave_offload_enabled = |
| 8881 | PS_LEGACY_DEEPSLEEP; |
| 8882 | hdd_info("Qpower disabled in cds config, %d", |
| 8883 | cds_cfg->powersave_offload_enabled); |
| 8884 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8885 | cds_cfg->sta_dynamic_dtim = hdd_ctx->config->enableDynamicDTIM; |
| 8886 | cds_cfg->sta_mod_dtim = hdd_ctx->config->enableModulatedDTIM; |
| 8887 | cds_cfg->sta_maxlimod_dtim = hdd_ctx->config->fMaxLIModulatedDTIM; |
| 8888 | cds_cfg->wow_enable = hdd_ctx->config->wowEnable; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8889 | |
| 8890 | /* |
| 8891 | * Copy the DFS Phyerr Filtering Offload status. |
| 8892 | * This parameter reflects the value of the |
| 8893 | * dfs_phyerr_filter_offload flag as set in the ini. |
| 8894 | */ |
| 8895 | cds_cfg->dfs_phyerr_filter_offload = |
| 8896 | hdd_ctx->config->fDfsPhyerrFilterOffload; |
| 8897 | if (hdd_ctx->config->ssdp) |
| 8898 | cds_cfg->ssdp = hdd_ctx->config->ssdp; |
| 8899 | |
SaidiReddy Yenuga | cc733af | 2016-11-09 17:45:42 +0530 | [diff] [blame] | 8900 | cds_cfg->force_target_assert_enabled = |
| 8901 | hdd_ctx->config->crash_inject_enabled; |
| 8902 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8903 | cds_cfg->enable_mc_list = hdd_ctx->config->fEnableMCAddrList; |
| 8904 | cds_cfg->ap_maxoffload_peers = hdd_ctx->config->apMaxOffloadPeers; |
| 8905 | |
| 8906 | cds_cfg->ap_maxoffload_reorderbuffs = |
| 8907 | hdd_ctx->config->apMaxOffloadReorderBuffs; |
| 8908 | |
| 8909 | cds_cfg->ap_disable_intrabss_fwd = |
| 8910 | hdd_ctx->config->apDisableIntraBssFwd; |
| 8911 | |
| 8912 | cds_cfg->dfs_pri_multiplier = |
| 8913 | hdd_ctx->config->dfsRadarPriMultiplier; |
| 8914 | cds_cfg->reorder_offload = |
| 8915 | hdd_ctx->config->reorderOffloadSupport; |
| 8916 | |
| 8917 | /* IPA micro controller data path offload resource config item */ |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 8918 | cds_cfg->uc_offload_enabled = ucfg_ipa_uc_is_enabled(); |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8919 | if (!is_power_of_2(hdd_ctx->config->IpaUcTxBufCount)) { |
| 8920 | /* IpaUcTxBufCount should be power of 2 */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8921 | hdd_debug("Round down IpaUcTxBufCount %d to nearest power of 2", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8922 | hdd_ctx->config->IpaUcTxBufCount); |
| 8923 | hdd_ctx->config->IpaUcTxBufCount = |
| 8924 | rounddown_pow_of_two( |
| 8925 | hdd_ctx->config->IpaUcTxBufCount); |
| 8926 | if (!hdd_ctx->config->IpaUcTxBufCount) { |
| 8927 | hdd_err("Failed to round down IpaUcTxBufCount"); |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 8928 | goto exit; |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8929 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8930 | hdd_debug("IpaUcTxBufCount rounded down to %d", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8931 | hdd_ctx->config->IpaUcTxBufCount); |
| 8932 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8933 | cds_cfg->uc_txbuf_count = hdd_ctx->config->IpaUcTxBufCount; |
| 8934 | cds_cfg->uc_txbuf_size = hdd_ctx->config->IpaUcTxBufSize; |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8935 | if (!is_power_of_2(hdd_ctx->config->IpaUcRxIndRingCount)) { |
| 8936 | /* IpaUcRxIndRingCount should be power of 2 */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8937 | hdd_debug("Round down IpaUcRxIndRingCount %d to nearest power of 2", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8938 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 8939 | hdd_ctx->config->IpaUcRxIndRingCount = |
| 8940 | rounddown_pow_of_two( |
| 8941 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 8942 | if (!hdd_ctx->config->IpaUcRxIndRingCount) { |
| 8943 | hdd_err("Failed to round down IpaUcRxIndRingCount"); |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 8944 | goto exit; |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8945 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8946 | hdd_debug("IpaUcRxIndRingCount rounded down to %d", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8947 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 8948 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8949 | cds_cfg->uc_rxind_ringcount = |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8950 | hdd_ctx->config->IpaUcRxIndRingCount; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8951 | cds_cfg->uc_tx_partition_base = |
| 8952 | hdd_ctx->config->IpaUcTxPartitionBase; |
| 8953 | cds_cfg->max_scan = hdd_ctx->config->max_scan_count; |
| 8954 | |
| 8955 | cds_cfg->ip_tcp_udp_checksum_offload = |
| 8956 | hdd_ctx->config->enable_ip_tcp_udp_checksum_offload; |
Jeff Johnson | e2ba3cd | 2017-10-30 20:02:09 -0700 | [diff] [blame] | 8957 | cds_cfg->enable_rxthread = hdd_ctx->enable_rxthread; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8958 | cds_cfg->ce_classify_enabled = |
| 8959 | hdd_ctx->config->ce_classify_enabled; |
Dustin Brown | d3fc9ee | 2016-09-14 13:57:27 -0700 | [diff] [blame] | 8960 | cds_cfg->bpf_packet_filter_enable = |
| 8961 | hdd_ctx->config->bpf_packet_filter_enable; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8962 | cds_cfg->tx_chain_mask_cck = hdd_ctx->config->tx_chain_mask_cck; |
| 8963 | cds_cfg->self_gen_frm_pwr = hdd_ctx->config->self_gen_frm_pwr; |
| 8964 | cds_cfg->max_station = hdd_ctx->config->maxNumberOfPeers; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 8965 | cds_cfg->sub_20_channel_width = WLAN_SUB_20_CH_WIDTH_NONE; |
Manjunathappa Prakash | fff753c | 2016-09-01 19:34:56 -0700 | [diff] [blame] | 8966 | cds_cfg->flow_steering_enabled = hdd_ctx->config->flow_steering_enable; |
Orhan K AKYILDIZ | 30e8cbc | 2017-08-11 18:00:28 -0700 | [diff] [blame] | 8967 | cds_cfg->max_msdus_per_rxinorderind = |
| 8968 | hdd_ctx->config->max_msdus_per_rxinorderind; |
Naveen Rawat | 91df30a | 2016-10-12 21:26:18 -0700 | [diff] [blame] | 8969 | cds_cfg->self_recovery_enabled = hdd_ctx->config->enableSelfRecovery; |
Sandeep Puligilla | afa5289 | 2016-10-26 19:03:16 -0700 | [diff] [blame] | 8970 | cds_cfg->fw_timeout_crash = hdd_ctx->config->fw_timeout_crash; |
Hanumanth Reddy Pothula | e87621b | 2017-04-12 20:53:35 +0530 | [diff] [blame] | 8971 | cds_cfg->active_uc_bpf_mode = hdd_ctx->config->active_uc_bpf_mode; |
| 8972 | 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] | 8973 | cds_cfg->auto_power_save_fail_mode = |
| 8974 | hdd_ctx->config->auto_pwr_save_fail_mode; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8975 | |
Ashish Kumar Dhanotiya | 9335d81 | 2017-06-30 16:57:20 +0530 | [diff] [blame] | 8976 | cds_cfg->ito_repeat_count = hdd_ctx->config->ito_repeat_count; |
Sandeep Puligilla | 819d94f | 2017-10-10 18:33:56 -0700 | [diff] [blame] | 8977 | cds_cfg->bandcapability = hdd_ctx->config->nBandCapability; |
Zhu Jianmin | a2f8e8d | 2018-02-11 16:37:10 +0800 | [diff] [blame] | 8978 | cds_cfg->delay_before_vdev_stop = |
| 8979 | hdd_ctx->config->delay_before_vdev_stop; |
Ashish Kumar Dhanotiya | 9335d81 | 2017-06-30 16:57:20 +0530 | [diff] [blame] | 8980 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8981 | hdd_ra_populate_cds_config(cds_cfg, hdd_ctx); |
| 8982 | hdd_txrx_populate_cds_config(cds_cfg, hdd_ctx); |
| 8983 | hdd_nan_populate_cds_config(cds_cfg, hdd_ctx); |
Jeff Johnson | 9078bdc | 2016-09-23 17:18:11 -0700 | [diff] [blame] | 8984 | hdd_lpass_populate_cds_config(cds_cfg, hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8985 | cds_init_ini_config(cds_cfg); |
| 8986 | return 0; |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 8987 | |
| 8988 | exit: |
| 8989 | qdf_mem_free(cds_cfg); |
| 8990 | return -EINVAL; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8991 | } |
| 8992 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8993 | /** |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 8994 | * hdd_update_user_config() - API to update user configuration |
| 8995 | * parameters to obj mgr which are used by multiple components |
| 8996 | * @hdd_ctx: HDD Context |
| 8997 | * |
| 8998 | * Return: 0 for Success, errno on failure |
| 8999 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9000 | static int hdd_update_user_config(struct hdd_context *hdd_ctx) |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9001 | { |
| 9002 | struct wlan_objmgr_psoc_user_config *user_config; |
| 9003 | |
| 9004 | user_config = qdf_mem_malloc(sizeof(*user_config)); |
| 9005 | if (user_config == NULL) { |
| 9006 | hdd_alert("Failed to alloc memory for user_config!"); |
| 9007 | return -ENOMEM; |
| 9008 | } |
| 9009 | |
| 9010 | user_config->dot11_mode = hdd_ctx->config->dot11Mode; |
| 9011 | user_config->dual_mac_feature_disable = |
| 9012 | hdd_ctx->config->dual_mac_feature_disable; |
| 9013 | user_config->indoor_channel_support = |
| 9014 | hdd_ctx->config->indoor_channel_support; |
| 9015 | user_config->is_11d_support_enabled = |
| 9016 | hdd_ctx->config->Is11dSupportEnabled; |
| 9017 | user_config->is_11h_support_enabled = |
| 9018 | hdd_ctx->config->Is11hSupportEnabled; |
| 9019 | user_config->optimize_chan_avoid_event = |
| 9020 | hdd_ctx->config->goptimize_chan_avoid_event; |
| 9021 | user_config->skip_dfs_chnl_in_p2p_search = |
| 9022 | hdd_ctx->config->skipDfsChnlInP2pSearch; |
Naveen Rawat | 222b2e9 | 2017-03-16 09:52:21 -0700 | [diff] [blame] | 9023 | user_config->band_capability = hdd_ctx->config->nBandCapability; |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9024 | wlan_objmgr_psoc_set_user_config(hdd_ctx->hdd_psoc, user_config); |
| 9025 | |
| 9026 | qdf_mem_free(user_config); |
| 9027 | return 0; |
| 9028 | } |
| 9029 | |
| 9030 | /** |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9031 | * hdd_init_thermal_info - Initialize thermal level |
| 9032 | * @hdd_ctx: HDD context |
| 9033 | * |
| 9034 | * Initialize thermal level at SME layer and set the thermal level callback |
| 9035 | * which would be called when a configured thermal threshold is hit. |
| 9036 | * |
| 9037 | * Return: 0 on success and errno on failure |
| 9038 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9039 | static int hdd_init_thermal_info(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9040 | { |
| 9041 | tSmeThermalParams thermal_param; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9042 | QDF_STATUS status; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9043 | |
| 9044 | thermal_param.smeThermalMgmtEnabled = |
| 9045 | hdd_ctx->config->thermalMitigationEnable; |
| 9046 | thermal_param.smeThrottlePeriod = hdd_ctx->config->throttlePeriod; |
| 9047 | |
Poddar, Siddarth | 8390502 | 2016-04-16 17:56:08 -0700 | [diff] [blame] | 9048 | thermal_param.sme_throttle_duty_cycle_tbl[0] = |
| 9049 | hdd_ctx->config->throttle_dutycycle_level0; |
| 9050 | thermal_param.sme_throttle_duty_cycle_tbl[1] = |
| 9051 | hdd_ctx->config->throttle_dutycycle_level1; |
| 9052 | thermal_param.sme_throttle_duty_cycle_tbl[2] = |
| 9053 | hdd_ctx->config->throttle_dutycycle_level2; |
| 9054 | thermal_param.sme_throttle_duty_cycle_tbl[3] = |
| 9055 | hdd_ctx->config->throttle_dutycycle_level3; |
| 9056 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9057 | thermal_param.smeThermalLevels[0].smeMinTempThreshold = |
| 9058 | hdd_ctx->config->thermalTempMinLevel0; |
| 9059 | thermal_param.smeThermalLevels[0].smeMaxTempThreshold = |
| 9060 | hdd_ctx->config->thermalTempMaxLevel0; |
| 9061 | thermal_param.smeThermalLevels[1].smeMinTempThreshold = |
| 9062 | hdd_ctx->config->thermalTempMinLevel1; |
| 9063 | thermal_param.smeThermalLevels[1].smeMaxTempThreshold = |
| 9064 | hdd_ctx->config->thermalTempMaxLevel1; |
| 9065 | thermal_param.smeThermalLevels[2].smeMinTempThreshold = |
| 9066 | hdd_ctx->config->thermalTempMinLevel2; |
| 9067 | thermal_param.smeThermalLevels[2].smeMaxTempThreshold = |
| 9068 | hdd_ctx->config->thermalTempMaxLevel2; |
| 9069 | thermal_param.smeThermalLevels[3].smeMinTempThreshold = |
| 9070 | hdd_ctx->config->thermalTempMinLevel3; |
| 9071 | thermal_param.smeThermalLevels[3].smeMaxTempThreshold = |
| 9072 | hdd_ctx->config->thermalTempMaxLevel3; |
| 9073 | |
| 9074 | status = sme_init_thermal_info(hdd_ctx->hHal, thermal_param); |
| 9075 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9076 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 9077 | return qdf_status_to_os_return(status); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9078 | |
| 9079 | sme_add_set_thermal_level_callback(hdd_ctx->hHal, |
| 9080 | hdd_set_thermal_level_cb); |
| 9081 | |
| 9082 | return 0; |
| 9083 | |
| 9084 | } |
| 9085 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9086 | #if defined(CONFIG_HDD_INIT_WITH_RTNL_LOCK) |
| 9087 | /** |
| 9088 | * hdd_hold_rtnl_lock - Hold RTNL lock |
| 9089 | * |
| 9090 | * Hold RTNL lock |
| 9091 | * |
| 9092 | * Return: True if held and false otherwise |
| 9093 | */ |
| 9094 | static inline bool hdd_hold_rtnl_lock(void) |
| 9095 | { |
| 9096 | rtnl_lock(); |
| 9097 | return true; |
| 9098 | } |
| 9099 | |
| 9100 | /** |
| 9101 | * hdd_release_rtnl_lock - Release RTNL lock |
| 9102 | * |
| 9103 | * Release RTNL lock |
| 9104 | * |
| 9105 | * Return: None |
| 9106 | */ |
| 9107 | static inline void hdd_release_rtnl_lock(void) |
| 9108 | { |
| 9109 | rtnl_unlock(); |
| 9110 | } |
| 9111 | #else |
| 9112 | static inline bool hdd_hold_rtnl_lock(void) { return false; } |
| 9113 | static inline void hdd_release_rtnl_lock(void) { } |
| 9114 | #endif |
| 9115 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9116 | #if !defined(REMOVE_PKT_LOG) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9117 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9118 | /* MAX iwpriv command support */ |
| 9119 | #define PKTLOG_SET_BUFF_SIZE 3 |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9120 | #define PKTLOG_CLEAR_BUFF 4 |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9121 | #define MAX_PKTLOG_SIZE 16 |
| 9122 | |
| 9123 | /** |
| 9124 | * hdd_pktlog_set_buff_size() - set pktlog buffer size |
| 9125 | * @hdd_ctx: hdd context |
| 9126 | * @set_value2: pktlog buffer size value |
| 9127 | * |
| 9128 | * |
| 9129 | * Return: 0 for success or error. |
| 9130 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9131 | 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] | 9132 | { |
| 9133 | struct sir_wifi_start_log start_log = { 0 }; |
| 9134 | QDF_STATUS status; |
| 9135 | |
| 9136 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 9137 | start_log.verbose_level = WLAN_LOG_LEVEL_OFF; |
| 9138 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 9139 | start_log.user_triggered = 1; |
| 9140 | start_log.size = set_value2; |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9141 | start_log.is_pktlog_buff_clear = false; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9142 | |
| 9143 | status = sme_wifi_start_logger(hdd_ctx->hHal, start_log); |
| 9144 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9145 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9146 | hdd_exit(); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9147 | return -EINVAL; |
| 9148 | } |
| 9149 | |
| 9150 | return 0; |
| 9151 | } |
| 9152 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9153 | /** |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9154 | * hdd_pktlog_clear_buff() - clear pktlog buffer |
| 9155 | * @hdd_ctx: hdd context |
| 9156 | * |
| 9157 | * Return: 0 for success or error. |
| 9158 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9159 | static int hdd_pktlog_clear_buff(struct hdd_context *hdd_ctx) |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9160 | { |
| 9161 | struct sir_wifi_start_log start_log; |
| 9162 | QDF_STATUS status; |
| 9163 | |
| 9164 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 9165 | start_log.verbose_level = WLAN_LOG_LEVEL_OFF; |
| 9166 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 9167 | start_log.user_triggered = 1; |
| 9168 | start_log.size = 0; |
| 9169 | start_log.is_pktlog_buff_clear = true; |
| 9170 | |
| 9171 | status = sme_wifi_start_logger(hdd_ctx->hHal, start_log); |
| 9172 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9173 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9174 | hdd_exit(); |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9175 | return -EINVAL; |
| 9176 | } |
| 9177 | |
| 9178 | return 0; |
| 9179 | } |
| 9180 | |
| 9181 | |
| 9182 | /** |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9183 | * hdd_process_pktlog_command() - process pktlog command |
| 9184 | * @hdd_ctx: hdd context |
| 9185 | * @set_value: value set by user |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9186 | * @set_value2: pktlog buffer size value |
| 9187 | * |
| 9188 | * This function process pktlog command. |
| 9189 | * set_value2 only matters when set_value is 3 (set buff size) |
| 9190 | * otherwise we ignore it. |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9191 | * |
| 9192 | * Return: 0 for success or error. |
| 9193 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9194 | 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] | 9195 | int set_value2) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9196 | { |
| 9197 | int ret; |
| 9198 | bool enable; |
| 9199 | uint8_t user_triggered = 0; |
| 9200 | |
| 9201 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 9202 | if (0 != ret) |
| 9203 | return ret; |
| 9204 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9205 | hdd_debug("set pktlog %d, set size %d", set_value, set_value2); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9206 | |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9207 | if (set_value > PKTLOG_CLEAR_BUFF) { |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9208 | hdd_err("invalid pktlog value %d", set_value); |
| 9209 | return -EINVAL; |
| 9210 | } |
| 9211 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9212 | if (set_value == PKTLOG_SET_BUFF_SIZE) { |
| 9213 | if (set_value2 <= 0) { |
| 9214 | hdd_err("invalid pktlog size %d", set_value2); |
| 9215 | return -EINVAL; |
| 9216 | } else if (set_value2 > MAX_PKTLOG_SIZE) { |
| 9217 | hdd_err("Pktlog buff size is too large. max value is 16MB.\n"); |
| 9218 | return -EINVAL; |
| 9219 | } |
| 9220 | return hdd_pktlog_set_buff_size(hdd_ctx, set_value2); |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9221 | } else if (set_value == PKTLOG_CLEAR_BUFF) { |
| 9222 | return hdd_pktlog_clear_buff(hdd_ctx); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9223 | } |
| 9224 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9225 | /* |
| 9226 | * set_value = 0 then disable packetlog |
| 9227 | * set_value = 1 enable packetlog forcefully |
| 9228 | * set_vlaue = 2 then disable packetlog if disabled through ini or |
| 9229 | * enable packetlog with AUTO type. |
| 9230 | */ |
| 9231 | enable = ((set_value > 0) && cds_is_packet_log_enabled()) ? |
| 9232 | true : false; |
| 9233 | |
| 9234 | if (1 == set_value) { |
| 9235 | enable = true; |
| 9236 | user_triggered = 1; |
| 9237 | } |
| 9238 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9239 | return hdd_pktlog_enable_disable(hdd_ctx, enable, user_triggered, 0); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9240 | } |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 9241 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9242 | /** |
| 9243 | * hdd_pktlog_enable_disable() - Enable/Disable packet logging |
| 9244 | * @hdd_ctx: HDD context |
| 9245 | * @enable: Flag to enable/disable |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9246 | * @user_triggered: triggered through iwpriv |
| 9247 | * @size: buffer size to be used for packetlog |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9248 | * |
| 9249 | * Return: 0 on success; error number otherwise |
| 9250 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9251 | int hdd_pktlog_enable_disable(struct hdd_context *hdd_ctx, bool enable, |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9252 | uint8_t user_triggered, int size) |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9253 | { |
| 9254 | struct sir_wifi_start_log start_log; |
| 9255 | QDF_STATUS status; |
| 9256 | |
| 9257 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 9258 | start_log.verbose_level = |
| 9259 | enable ? WLAN_LOG_LEVEL_ACTIVE : WLAN_LOG_LEVEL_OFF; |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9260 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 9261 | start_log.user_triggered = user_triggered; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9262 | start_log.size = size; |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9263 | start_log.is_pktlog_buff_clear = false; |
Poddar, Siddarth | eefe348 | 2016-09-21 18:12:59 +0530 | [diff] [blame] | 9264 | /* |
| 9265 | * Use "is_iwpriv_command" flag to distinguish iwpriv command from other |
| 9266 | * commands. Host uses this flag to decide whether to send pktlog |
| 9267 | * disable command to fw without sending pktlog enable command |
| 9268 | * previously. For eg, If vendor sends pktlog disable command without |
| 9269 | * sending pktlog enable command, then host discards the packet |
| 9270 | * but for iwpriv command, host will send it to fw. |
| 9271 | */ |
| 9272 | start_log.is_iwpriv_command = 1; |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9273 | status = sme_wifi_start_logger(hdd_ctx->hHal, start_log); |
| 9274 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9275 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9276 | hdd_exit(); |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9277 | return -EINVAL; |
| 9278 | } |
| 9279 | |
Poddar, Siddarth | 61fbc93 | 2017-12-19 14:27:55 +0530 | [diff] [blame] | 9280 | if (enable == true) |
| 9281 | hdd_ctx->is_pktlog_enabled = 1; |
| 9282 | else |
| 9283 | hdd_ctx->is_pktlog_enabled = 0; |
| 9284 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9285 | return 0; |
| 9286 | } |
| 9287 | #endif /* REMOVE_PKT_LOG */ |
| 9288 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9289 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9290 | * hdd_get_platform_wlan_mac_buff() - API to query platform driver |
| 9291 | * for MAC address |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9292 | * @dev: Device Pointer |
| 9293 | * @num: Number of Valid Mac address |
| 9294 | * |
| 9295 | * Return: Pointer to MAC address buffer |
| 9296 | */ |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9297 | static uint8_t *hdd_get_platform_wlan_mac_buff(struct device *dev, |
| 9298 | uint32_t *num) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9299 | { |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9300 | return pld_get_wlan_mac_address(dev, num); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9301 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9302 | |
| 9303 | /** |
| 9304 | * hdd_populate_random_mac_addr() - API to populate random mac addresses |
| 9305 | * @hdd_ctx: HDD Context |
| 9306 | * @num: Number of random mac addresses needed |
| 9307 | * |
| 9308 | * Generate random addresses using bit manipulation on the base mac address |
| 9309 | * |
| 9310 | * Return: None |
| 9311 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9312 | 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] | 9313 | { |
| 9314 | uint32_t start_idx = QDF_MAX_CONCURRENCY_PERSONA - num; |
| 9315 | uint32_t iter; |
| 9316 | struct hdd_config *ini = hdd_ctx->config; |
| 9317 | uint8_t *buf = NULL; |
| 9318 | uint8_t macaddr_b3, tmp_br3; |
| 9319 | uint8_t *src = ini->intfMacAddr[0].bytes; |
| 9320 | |
| 9321 | for (iter = start_idx; iter < QDF_MAX_CONCURRENCY_PERSONA; ++iter) { |
| 9322 | buf = ini->intfMacAddr[iter].bytes; |
| 9323 | qdf_mem_copy(buf, src, QDF_MAC_ADDR_SIZE); |
| 9324 | macaddr_b3 = buf[3]; |
| 9325 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + iter) & |
| 9326 | INTF_MACADDR_MASK; |
| 9327 | macaddr_b3 += tmp_br3; |
| 9328 | macaddr_b3 ^= (1 << INTF_MACADDR_MASK); |
| 9329 | buf[0] |= 0x02; |
| 9330 | buf[3] = macaddr_b3; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9331 | hdd_debug(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(buf)); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9332 | } |
| 9333 | } |
| 9334 | |
| 9335 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9336 | * hdd_platform_wlan_mac() - API to get mac addresses from platform driver |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9337 | * @hdd_ctx: HDD Context |
| 9338 | * |
| 9339 | * API to get mac addresses from platform driver and update the driver |
| 9340 | * structures and configure FW with the base mac address. |
| 9341 | * Return: int |
| 9342 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9343 | static int hdd_platform_wlan_mac(struct hdd_context *hdd_ctx) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9344 | { |
| 9345 | uint32_t no_of_mac_addr, iter; |
| 9346 | uint32_t max_mac_addr = QDF_MAX_CONCURRENCY_PERSONA; |
| 9347 | uint32_t mac_addr_size = QDF_MAC_ADDR_SIZE; |
| 9348 | uint8_t *addr, *buf; |
| 9349 | struct device *dev = hdd_ctx->parent_dev; |
| 9350 | struct hdd_config *ini = hdd_ctx->config; |
| 9351 | tSirMacAddr mac_addr; |
| 9352 | QDF_STATUS status; |
| 9353 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9354 | addr = hdd_get_platform_wlan_mac_buff(dev, &no_of_mac_addr); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9355 | |
| 9356 | if (no_of_mac_addr == 0 || !addr) { |
| 9357 | hdd_warn("Platform Driver Doesn't have wlan mac addresses"); |
| 9358 | return -EINVAL; |
| 9359 | } |
| 9360 | |
| 9361 | if (no_of_mac_addr > max_mac_addr) |
| 9362 | no_of_mac_addr = max_mac_addr; |
| 9363 | |
| 9364 | qdf_mem_copy(&mac_addr, addr, mac_addr_size); |
| 9365 | |
| 9366 | for (iter = 0; iter < no_of_mac_addr; ++iter, addr += mac_addr_size) { |
| 9367 | buf = ini->intfMacAddr[iter].bytes; |
| 9368 | qdf_mem_copy(buf, addr, QDF_MAC_ADDR_SIZE); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9369 | hdd_debug(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(buf)); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9370 | } |
| 9371 | |
| 9372 | status = sme_set_custom_mac_addr(mac_addr); |
| 9373 | |
| 9374 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9375 | return -EAGAIN; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 9376 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9377 | if (no_of_mac_addr < max_mac_addr) |
| 9378 | hdd_populate_random_mac_addr(hdd_ctx, max_mac_addr - |
| 9379 | no_of_mac_addr); |
| 9380 | return 0; |
| 9381 | } |
| 9382 | |
| 9383 | /** |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9384 | * hdd_update_mac_addr_to_fw() - API to update wlan mac addresses to FW |
| 9385 | * @hdd_ctx: HDD Context |
| 9386 | * |
| 9387 | * Update MAC address to FW. If MAC address passed by FW is invalid, host |
| 9388 | * will generate its own MAC and update it to FW. |
| 9389 | * |
| 9390 | * Return: 0 for success |
| 9391 | * Non-zero error code for failure |
| 9392 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9393 | 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] | 9394 | { |
| 9395 | tSirMacAddr customMacAddr; |
| 9396 | QDF_STATUS status; |
| 9397 | |
| 9398 | qdf_mem_copy(&customMacAddr, |
| 9399 | &hdd_ctx->config->intfMacAddr[0].bytes[0], |
| 9400 | sizeof(tSirMacAddr)); |
| 9401 | status = sme_set_custom_mac_addr(customMacAddr); |
| 9402 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9403 | return -EAGAIN; |
| 9404 | return 0; |
| 9405 | } |
| 9406 | |
| 9407 | /** |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9408 | * hdd_initialize_mac_address() - API to get wlan mac addresses |
| 9409 | * @hdd_ctx: HDD Context |
| 9410 | * |
| 9411 | * Get MAC addresses from platform driver or wlan_mac.bin. If platform driver |
| 9412 | * is provisioned with mac addresses, driver uses it, else it will use |
| 9413 | * wlan_mac.bin to update HW MAC addresses. |
| 9414 | * |
| 9415 | * Return: None |
| 9416 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9417 | static void hdd_initialize_mac_address(struct hdd_context *hdd_ctx) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9418 | { |
| 9419 | QDF_STATUS status; |
| 9420 | int ret; |
| 9421 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9422 | ret = hdd_platform_wlan_mac(hdd_ctx); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9423 | if (ret == 0) |
| 9424 | return; |
| 9425 | |
Yuanyuan Liu | 3d62f6a | 2017-06-08 11:08:46 -0700 | [diff] [blame] | 9426 | hdd_info("MAC is not programmed in platform driver ret: %d, use wlan_mac.bin", |
| 9427 | ret); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9428 | |
| 9429 | status = hdd_update_mac_config(hdd_ctx); |
| 9430 | |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9431 | if (QDF_IS_STATUS_SUCCESS(status)) |
| 9432 | return; |
| 9433 | |
Yuanyuan Liu | 3d62f6a | 2017-06-08 11:08:46 -0700 | [diff] [blame] | 9434 | hdd_info("MAC is not programmed in wlan_mac.bin ret %d, use default MAC", |
| 9435 | status); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9436 | |
Yuanyuan Liu | 1c2caa3 | 2016-11-07 17:13:48 -0800 | [diff] [blame] | 9437 | if (hdd_ctx->update_mac_addr_to_fw) { |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9438 | ret = hdd_update_mac_addr_to_fw(hdd_ctx); |
Yuanyuan Liu | 1c2caa3 | 2016-11-07 17:13:48 -0800 | [diff] [blame] | 9439 | if (ret != 0) { |
| 9440 | hdd_err("MAC address out-of-sync, ret:%d", ret); |
| 9441 | QDF_ASSERT(ret); |
| 9442 | } |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9443 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9444 | } |
| 9445 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9446 | static int hdd_set_smart_chainmask_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9447 | { |
| 9448 | int vdev_id = 0; |
| 9449 | int param_id = WMI_PDEV_PARAM_SMART_CHAINMASK_SCHEME; |
| 9450 | int value = hdd_ctx->config->smart_chainmask_enabled; |
| 9451 | int vpdev = PDEV_CMD; |
| 9452 | int ret; |
| 9453 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9454 | ret = sme_cli_set_command(vdev_id, param_id, value, vpdev); |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9455 | if (ret) |
| 9456 | hdd_err("WMI_PDEV_PARAM_SMART_CHAINMASK_SCHEME failed %d", ret); |
| 9457 | |
| 9458 | return ret; |
| 9459 | } |
| 9460 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9461 | static int hdd_set_alternative_chainmask_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9462 | { |
| 9463 | int vdev_id = 0; |
| 9464 | int param_id = WMI_PDEV_PARAM_ALTERNATIVE_CHAINMASK_SCHEME; |
| 9465 | int value = hdd_ctx->config->alternative_chainmask_enabled; |
| 9466 | int vpdev = PDEV_CMD; |
| 9467 | int ret; |
| 9468 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9469 | ret = sme_cli_set_command(vdev_id, param_id, value, vpdev); |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9470 | if (ret) |
| 9471 | hdd_err("WMI_PDEV_PARAM_ALTERNATIVE_CHAINMASK_SCHEME failed %d", |
| 9472 | ret); |
| 9473 | |
| 9474 | return ret; |
| 9475 | } |
| 9476 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9477 | static int hdd_set_ani_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 9478 | { |
| 9479 | int vdev_id = 0; |
| 9480 | int param_id = WMI_PDEV_PARAM_ANI_ENABLE; |
| 9481 | int value = hdd_ctx->config->ani_enabled; |
| 9482 | int vpdev = PDEV_CMD; |
| 9483 | int ret; |
| 9484 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9485 | ret = sme_cli_set_command(vdev_id, param_id, value, vpdev); |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 9486 | if (ret) |
| 9487 | hdd_err("WMI_PDEV_PARAM_ANI_ENABLE failed %d", ret); |
| 9488 | |
| 9489 | return ret; |
| 9490 | } |
| 9491 | |
Jeff Johnson | 89c66ff | 2016-04-22 15:21:37 -0700 | [diff] [blame] | 9492 | /** |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9493 | * hdd_pre_enable_configure() - Configurations prior to cds_enable |
| 9494 | * @hdd_ctx: HDD context |
| 9495 | * |
| 9496 | * Pre configurations to be done at lower layer before calling cds enable. |
| 9497 | * |
| 9498 | * Return: 0 on success and errno on failure. |
| 9499 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9500 | static int hdd_pre_enable_configure(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9501 | { |
| 9502 | int ret; |
| 9503 | QDF_STATUS status; |
| 9504 | tSirRetStatus hal_status; |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 9505 | void *soc = cds_get_context(QDF_MODULE_ID_SOC); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9506 | |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 9507 | cdp_register_pause_cb(soc, wlan_hdd_txrx_pause_cb); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9508 | /* |
| 9509 | * Set 802.11p config |
| 9510 | * TODO-OCB: This has been temporarily added here to ensure this |
| 9511 | * parameter is set in CSR when we init the channel list. This should |
| 9512 | * be removed once the 5.9 GHz channels are added to the regulatory |
| 9513 | * domain. |
| 9514 | */ |
| 9515 | hdd_set_dot11p_config(hdd_ctx); |
| 9516 | |
| 9517 | /* |
| 9518 | * Note that the cds_pre_enable() sequence triggers the cfg download. |
| 9519 | * The cfg download must occur before we update the SME config |
| 9520 | * since the SME config operation must access the cfg database |
| 9521 | */ |
| 9522 | status = hdd_set_sme_config(hdd_ctx); |
| 9523 | |
| 9524 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9525 | hdd_err("Failed hdd_set_sme_config: %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9526 | ret = qdf_status_to_os_return(status); |
| 9527 | goto out; |
| 9528 | } |
| 9529 | |
Tushnim Bhattacharyya | ba8ee93 | 2017-03-23 09:27:40 -0700 | [diff] [blame] | 9530 | status = hdd_set_policy_mgr_user_cfg(hdd_ctx); |
| 9531 | if (QDF_STATUS_SUCCESS != status) { |
| 9532 | hdd_alert("Failed hdd_set_policy_mgr_user_cfg: %d", status); |
| 9533 | ret = qdf_status_to_os_return(status); |
| 9534 | goto out; |
| 9535 | } |
| 9536 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9537 | 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] | 9538 | hdd_ctx->config->tx_chain_mask_1ss, |
| 9539 | PDEV_CMD); |
| 9540 | if (0 != ret) { |
| 9541 | hdd_err("WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS failed %d", ret); |
| 9542 | goto out; |
| 9543 | } |
| 9544 | |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9545 | ret = hdd_set_smart_chainmask_enabled(hdd_ctx); |
| 9546 | if (ret) |
| 9547 | goto out; |
| 9548 | |
| 9549 | ret = hdd_set_alternative_chainmask_enabled(hdd_ctx); |
| 9550 | if (ret) |
| 9551 | goto out; |
| 9552 | |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 9553 | ret = hdd_set_ani_enabled(hdd_ctx); |
| 9554 | if (ret) |
| 9555 | goto out; |
| 9556 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9557 | ret = sme_cli_set_command(0, WMI_PDEV_PARAM_ARP_AC_OVERRIDE, |
Srinivas Girigowda | 70e169a | 2017-03-07 23:55:57 -0800 | [diff] [blame] | 9558 | hdd_ctx->config->arp_ac_category, |
| 9559 | PDEV_CMD); |
| 9560 | if (0 != ret) { |
| 9561 | hdd_err("WMI_PDEV_PARAM_ARP_AC_OVERRIDE ac: %d ret: %d", |
| 9562 | hdd_ctx->config->arp_ac_category, ret); |
| 9563 | goto out; |
| 9564 | } |
| 9565 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9566 | status = hdd_set_sme_chan_list(hdd_ctx); |
| 9567 | if (status != QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9568 | hdd_err("Failed to init channel list: %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9569 | ret = qdf_status_to_os_return(status); |
| 9570 | goto out; |
| 9571 | } |
| 9572 | |
| 9573 | /* Apply the cfg.ini to cfg.dat */ |
Krunal Soni | df0f874 | 2016-09-26 14:56:31 -0700 | [diff] [blame] | 9574 | if (!hdd_update_config_cfg(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9575 | hdd_err("config update failed"); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9576 | ret = -EINVAL; |
| 9577 | goto out; |
| 9578 | } |
| 9579 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9580 | /* |
| 9581 | * Set the MAC Address Currently this is used by HAL to add self sta. |
| 9582 | * Remove this once self sta is added as part of session open. |
| 9583 | */ |
| 9584 | hal_status = cfg_set_str(hdd_ctx->hHal, WNI_CFG_STA_ID, |
| 9585 | hdd_ctx->config->intfMacAddr[0].bytes, |
| 9586 | sizeof(hdd_ctx->config->intfMacAddr[0])); |
| 9587 | |
| 9588 | if (!IS_SIR_STATUS_SUCCESS(hal_status)) { |
| 9589 | hdd_err("Failed to set MAC Address. HALStatus is %08d [x%08x]", |
| 9590 | hal_status, hal_status); |
| 9591 | ret = -EINVAL; |
| 9592 | goto out; |
| 9593 | } |
| 9594 | |
| 9595 | hdd_init_channel_avoidance(hdd_ctx); |
| 9596 | |
Ganesh Kondabattini | 408fb8d | 2017-08-08 22:00:20 +0530 | [diff] [blame] | 9597 | /* update enable sap mandatory chan list */ |
| 9598 | policy_mgr_enable_disable_sap_mandatory_chan_list(hdd_ctx->hdd_psoc, |
| 9599 | hdd_ctx->config->enable_sap_mandatory_chan_list); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9600 | out: |
| 9601 | return ret; |
| 9602 | } |
| 9603 | |
| 9604 | /** |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9605 | * wlan_hdd_p2p_lo_event_callback - P2P listen offload stop event handler |
| 9606 | * @context_ptr - hdd context pointer |
| 9607 | * @event_ptr - event structure pointer |
| 9608 | * |
| 9609 | * This is the p2p listen offload stop event handler, it sends vendor |
| 9610 | * event back to supplicant to notify the stop reason. |
| 9611 | * |
| 9612 | * Return: None |
| 9613 | */ |
| 9614 | static void wlan_hdd_p2p_lo_event_callback(void *context_ptr, |
| 9615 | void *event_ptr) |
| 9616 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9617 | struct hdd_context *hdd_ctx = (struct hdd_context *)context_ptr; |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9618 | struct sir_p2p_lo_event *evt = event_ptr; |
| 9619 | struct sk_buff *vendor_event; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9620 | struct hdd_adapter *adapter; |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9621 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 9622 | hdd_enter(); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9623 | |
| 9624 | if (hdd_ctx == NULL) { |
| 9625 | hdd_err("Invalid HDD context pointer"); |
| 9626 | return; |
| 9627 | } |
| 9628 | |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 9629 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, evt->vdev_id); |
| 9630 | if (!adapter) { |
| 9631 | hdd_err("Cannot find adapter by vdev_id = %d", |
| 9632 | evt->vdev_id); |
| 9633 | return; |
| 9634 | } |
| 9635 | |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9636 | vendor_event = |
| 9637 | cfg80211_vendor_event_alloc(hdd_ctx->wiphy, |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 9638 | &(adapter->wdev), sizeof(uint32_t) + NLMSG_HDRLEN, |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9639 | QCA_NL80211_VENDOR_SUBCMD_P2P_LO_EVENT_INDEX, |
| 9640 | GFP_KERNEL); |
| 9641 | |
| 9642 | if (!vendor_event) { |
| 9643 | hdd_err("cfg80211_vendor_event_alloc failed"); |
| 9644 | return; |
| 9645 | } |
| 9646 | |
| 9647 | if (nla_put_u32(vendor_event, |
| 9648 | QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_STOP_REASON, |
| 9649 | evt->reason_code)) { |
| 9650 | hdd_err("nla put failed"); |
| 9651 | kfree_skb(vendor_event); |
| 9652 | return; |
| 9653 | } |
| 9654 | |
| 9655 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 9656 | hdd_debug("Sent P2P_LISTEN_OFFLOAD_STOP event for vdev_id = %d", |
| 9657 | evt->vdev_id); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9658 | } |
| 9659 | |
| 9660 | /** |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 9661 | * hdd_adaptive_dwelltime_init() - initialization for adaptive dwell time config |
| 9662 | * @hdd_ctx: HDD context |
| 9663 | * |
| 9664 | * This function sends the adaptive dwell time config configuration to the |
| 9665 | * firmware via WMA |
| 9666 | * |
| 9667 | * Return: 0 - success, < 0 - failure |
| 9668 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9669 | static int hdd_adaptive_dwelltime_init(struct hdd_context *hdd_ctx) |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 9670 | { |
| 9671 | QDF_STATUS status; |
| 9672 | struct adaptive_dwelltime_params dwelltime_params; |
| 9673 | |
| 9674 | dwelltime_params.is_enabled = |
| 9675 | hdd_ctx->config->adaptive_dwell_mode_enabled; |
| 9676 | dwelltime_params.dwelltime_mode = |
| 9677 | hdd_ctx->config->global_adapt_dwelltime_mode; |
| 9678 | dwelltime_params.lpf_weight = |
| 9679 | hdd_ctx->config->adapt_dwell_lpf_weight; |
| 9680 | dwelltime_params.passive_mon_intval = |
| 9681 | hdd_ctx->config->adapt_dwell_passive_mon_intval; |
| 9682 | dwelltime_params.wifi_act_threshold = |
| 9683 | hdd_ctx->config->adapt_dwell_wifi_act_threshold; |
| 9684 | |
| 9685 | status = sme_set_adaptive_dwelltime_config(hdd_ctx->hHal, |
| 9686 | &dwelltime_params); |
| 9687 | |
| 9688 | hdd_debug("Sending Adaptive Dwelltime Configuration to fw"); |
| 9689 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9690 | hdd_err("Failed to send Adaptive Dwelltime configuration!"); |
| 9691 | return -EAGAIN; |
| 9692 | } |
| 9693 | return 0; |
| 9694 | } |
| 9695 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9696 | int hdd_dbs_scan_selection_init(struct hdd_context *hdd_ctx) |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 9697 | { |
| 9698 | QDF_STATUS status; |
| 9699 | struct wmi_dbs_scan_sel_params dbs_scan_params; |
| 9700 | uint32_t i = 0; |
| 9701 | uint8_t count = 0, numentries = 0; |
| 9702 | uint8_t dbs_scan_config[CDS_DBS_SCAN_PARAM_PER_CLIENT |
| 9703 | * CDS_DBS_SCAN_CLIENTS_MAX]; |
| 9704 | |
| 9705 | /* check if DBS is enabled or supported */ |
Bala Venkatesh | c8236ca | 2018-03-09 12:38:29 +0530 | [diff] [blame] | 9706 | if ((hdd_ctx->config->dual_mac_feature_disable == |
| 9707 | DISABLE_DBS_CXN_AND_SCAN) || |
| 9708 | (hdd_ctx->config->dual_mac_feature_disable == |
| 9709 | ENABLE_DBS_CXN_AND_DISABLE_DBS_SCAN)) |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 9710 | return -EINVAL; |
| 9711 | |
| 9712 | hdd_string_to_u8_array(hdd_ctx->config->dbs_scan_selection, |
| 9713 | dbs_scan_config, &numentries, |
| 9714 | (CDS_DBS_SCAN_PARAM_PER_CLIENT |
| 9715 | * CDS_DBS_SCAN_CLIENTS_MAX)); |
| 9716 | |
| 9717 | hdd_info("numentries %hu", numentries); |
| 9718 | if (!numentries) { |
| 9719 | hdd_info("Donot send scan_selection_config"); |
| 9720 | return 0; |
| 9721 | } |
| 9722 | |
| 9723 | /* hdd_set_fw_log_params */ |
| 9724 | dbs_scan_params.num_clients = 0; |
| 9725 | while (count < (numentries - 2)) { |
| 9726 | dbs_scan_params.module_id[i] = dbs_scan_config[count]; |
| 9727 | dbs_scan_params.num_dbs_scans[i] = dbs_scan_config[count + 1]; |
| 9728 | dbs_scan_params.num_non_dbs_scans[i] = |
| 9729 | dbs_scan_config[count + 2]; |
| 9730 | dbs_scan_params.num_clients++; |
| 9731 | hdd_debug("module:%d NDS:%d NNDS:%d", |
| 9732 | dbs_scan_params.module_id[i], |
| 9733 | dbs_scan_params.num_dbs_scans[i], |
| 9734 | dbs_scan_params.num_non_dbs_scans[i]); |
| 9735 | count += CDS_DBS_SCAN_PARAM_PER_CLIENT; |
| 9736 | i++; |
| 9737 | } |
| 9738 | |
| 9739 | dbs_scan_params.pdev_id = 0; |
| 9740 | |
| 9741 | hdd_debug("clients:%d pdev:%d", |
| 9742 | dbs_scan_params.num_clients, dbs_scan_params.pdev_id); |
| 9743 | |
| 9744 | status = sme_set_dbs_scan_selection_config(hdd_ctx->hHal, |
| 9745 | &dbs_scan_params); |
| 9746 | hdd_debug("Sending DBS Scan Selection Configuration to fw"); |
| 9747 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9748 | hdd_err("Failed to send DBS Scan selection configuration!"); |
| 9749 | return -EAGAIN; |
| 9750 | } |
| 9751 | return 0; |
| 9752 | } |
| 9753 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9754 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 9755 | /** |
| 9756 | * hdd_set_auto_shutdown_cb() - Set auto shutdown callback |
| 9757 | * @hdd_ctx: HDD context |
| 9758 | * |
| 9759 | * Set auto shutdown callback to get indications from firmware to indicate |
| 9760 | * userspace to shutdown WLAN after a configured amount of inactivity. |
| 9761 | * |
| 9762 | * Return: 0 on success and errno on failure. |
| 9763 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9764 | static int hdd_set_auto_shutdown_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9765 | { |
| 9766 | QDF_STATUS status; |
| 9767 | |
| 9768 | if (!hdd_ctx->config->WlanAutoShutdown) |
| 9769 | return 0; |
| 9770 | |
| 9771 | status = sme_set_auto_shutdown_cb(hdd_ctx->hHal, |
| 9772 | wlan_hdd_auto_shutdown_cb); |
| 9773 | if (status != QDF_STATUS_SUCCESS) |
| 9774 | hdd_err("Auto shutdown feature could not be enabled: %d", |
| 9775 | status); |
| 9776 | |
| 9777 | return qdf_status_to_os_return(status); |
| 9778 | } |
| 9779 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9780 | static int hdd_set_auto_shutdown_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9781 | { |
| 9782 | return 0; |
| 9783 | } |
| 9784 | #endif |
| 9785 | |
| 9786 | /** |
| 9787 | * hdd_features_init() - Init features |
| 9788 | * @hdd_ctx: HDD context |
| 9789 | * @adapter: Primary adapter context |
| 9790 | * |
| 9791 | * Initialize features and their feature context after WLAN firmware is up. |
| 9792 | * |
| 9793 | * Return: 0 on success and errno on failure. |
| 9794 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9795 | 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] | 9796 | { |
| 9797 | tSirTxPowerLimit hddtxlimit; |
| 9798 | QDF_STATUS status; |
Manjeet Singh | a9cae43 | 2017-02-28 11:58:22 +0530 | [diff] [blame] | 9799 | struct sme_5g_band_pref_params band_pref_params; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9800 | int ret; |
| 9801 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 9802 | hdd_enter(); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9803 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9804 | /* FW capabilities received, Set the Dot11 mode */ |
| 9805 | sme_setdef_dot11mode(hdd_ctx->hHal); |
Kiran Kumar Lokere | 1aa9c9a | 2016-10-05 18:50:59 -0700 | [diff] [blame] | 9806 | sme_set_prefer_80MHz_over_160MHz(hdd_ctx->hHal, |
| 9807 | hdd_ctx->config->sta_prefer_80MHz_over_160MHz); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9808 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9809 | |
| 9810 | if (hdd_ctx->config->fIsImpsEnabled) |
| 9811 | hdd_set_idle_ps_config(hdd_ctx, true); |
| 9812 | else |
| 9813 | hdd_set_idle_ps_config(hdd_ctx, false); |
| 9814 | |
Poddar, Siddarth | 3703303 | 2017-10-11 15:47:40 +0530 | [diff] [blame] | 9815 | /* Send Enable/Disable data stall detection cmd to FW */ |
| 9816 | sme_cli_set_command(0, WMI_PDEV_PARAM_DATA_STALL_DETECT_ENABLE, |
| 9817 | hdd_ctx->config->enable_data_stall_det, PDEV_CMD); |
| 9818 | |
Agrawal Ashish | 642ec9b | 2017-02-22 14:45:30 +0530 | [diff] [blame] | 9819 | if (hdd_ctx->config->enable_go_cts2self_for_sta) |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 9820 | sme_set_cts2self_for_p2p_go(hdd_ctx->hHal); |
Agrawal Ashish | 642ec9b | 2017-02-22 14:45:30 +0530 | [diff] [blame] | 9821 | |
Nachiket Kukade | 8983cf6 | 2017-10-12 18:14:48 +0530 | [diff] [blame] | 9822 | if (sme_set_vc_mode_config(hdd_ctx->config->vc_mode_cfg_bitmap)) |
| 9823 | hdd_warn("Error in setting Voltage Corner mode config to FW"); |
| 9824 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9825 | if (hdd_lro_init(hdd_ctx)) |
| 9826 | hdd_err("Unable to initialize LRO in fw"); |
| 9827 | |
| 9828 | if (hdd_adaptive_dwelltime_init(hdd_ctx)) |
| 9829 | hdd_err("Unable to send adaptive dwelltime setting to FW"); |
| 9830 | |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 9831 | if (hdd_dbs_scan_selection_init(hdd_ctx)) |
| 9832 | hdd_err("Unable to send DBS scan selection setting to FW"); |
| 9833 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9834 | ret = hdd_init_thermal_info(hdd_ctx); |
| 9835 | if (ret) { |
| 9836 | hdd_err("Error while initializing thermal information"); |
| 9837 | goto deregister_frames; |
| 9838 | } |
| 9839 | |
Poddar, Siddarth | 61fbc93 | 2017-12-19 14:27:55 +0530 | [diff] [blame] | 9840 | /** |
| 9841 | * In case of SSR/PDR, if pktlog was enabled manually before |
| 9842 | * SSR/PDR, Then enabled it again automatically after Wlan |
| 9843 | * device up. |
| 9844 | */ |
| 9845 | if (cds_is_driver_recovering()) { |
| 9846 | if (hdd_ctx->is_pktlog_enabled) |
| 9847 | hdd_pktlog_enable_disable(hdd_ctx, true, 0, 0); |
Tiger Yu | f3d5d7f | 2018-03-15 14:48:11 +0800 | [diff] [blame] | 9848 | } |
Poddar, Siddarth | 66a4659 | 2017-02-22 11:44:44 +0530 | [diff] [blame] | 9849 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9850 | hddtxlimit.txPower2g = hdd_ctx->config->TxPower2g; |
| 9851 | hddtxlimit.txPower5g = hdd_ctx->config->TxPower5g; |
| 9852 | status = sme_txpower_limit(hdd_ctx->hHal, &hddtxlimit); |
| 9853 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9854 | hdd_err("Error setting txlimit in sme: %d", status); |
| 9855 | |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 9856 | wlan_hdd_tsf_init(hdd_ctx); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9857 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9858 | ret = hdd_register_cb(hdd_ctx); |
| 9859 | if (ret) { |
| 9860 | hdd_err("Failed to register HDD callbacks!"); |
| 9861 | goto deregister_frames; |
| 9862 | } |
| 9863 | |
Selvaraj, Sridhar | 371f55e | 2017-02-21 10:36:15 +0530 | [diff] [blame] | 9864 | if (hdd_ctx->config->goptimize_chan_avoid_event) { |
| 9865 | status = sme_enable_disable_chanavoidind_event( |
| 9866 | hdd_ctx->hHal, 0); |
| 9867 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9868 | hdd_err("Failed to disable Chan Avoidance Indication"); |
| 9869 | goto deregister_cb; |
| 9870 | } |
| 9871 | } |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9872 | |
Manjeet Singh | a9cae43 | 2017-02-28 11:58:22 +0530 | [diff] [blame] | 9873 | if (hdd_ctx->config->enable_5g_band_pref) { |
| 9874 | band_pref_params.rssi_boost_threshold_5g = |
| 9875 | hdd_ctx->config->rssi_boost_threshold_5g; |
| 9876 | band_pref_params.rssi_boost_factor_5g = |
| 9877 | hdd_ctx->config->rssi_boost_factor_5g; |
| 9878 | band_pref_params.max_rssi_boost_5g = |
| 9879 | hdd_ctx->config->max_rssi_boost_5g; |
| 9880 | band_pref_params.rssi_penalize_threshold_5g = |
| 9881 | hdd_ctx->config->rssi_penalize_threshold_5g; |
| 9882 | band_pref_params.rssi_penalize_factor_5g = |
| 9883 | hdd_ctx->config->rssi_penalize_factor_5g; |
| 9884 | band_pref_params.max_rssi_penalize_5g = |
| 9885 | hdd_ctx->config->max_rssi_penalize_5g; |
| 9886 | sme_set_5g_band_pref(hdd_ctx->hHal, &band_pref_params); |
| 9887 | } |
| 9888 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9889 | /* register P2P Listen Offload event callback */ |
| 9890 | if (wma_is_p2p_lo_capable()) |
| 9891 | sme_register_p2p_lo_event(hdd_ctx->hHal, hdd_ctx, |
| 9892 | wlan_hdd_p2p_lo_event_callback); |
| 9893 | |
| 9894 | ret = hdd_set_auto_shutdown_cb(hdd_ctx); |
| 9895 | |
| 9896 | if (ret) |
| 9897 | goto deregister_cb; |
| 9898 | |
Dustin Brown | 11638b7 | 2018-01-25 17:37:25 +0530 | [diff] [blame] | 9899 | wlan_hdd_init_chan_info(hdd_ctx); |
| 9900 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9901 | hdd_exit(); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9902 | return 0; |
| 9903 | |
| 9904 | deregister_cb: |
| 9905 | hdd_deregister_cb(hdd_ctx); |
| 9906 | deregister_frames: |
| 9907 | wlan_hdd_cfg80211_deregister_frames(adapter); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9908 | return -EINVAL; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9909 | } |
| 9910 | |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 9911 | /** |
| 9912 | * hdd_features_deinit() - Deinit features |
| 9913 | * @hdd_ctx: HDD context |
| 9914 | * |
| 9915 | * De-Initialize features and their feature context. |
| 9916 | * |
| 9917 | * Return: none. |
| 9918 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9919 | static void hdd_features_deinit(struct hdd_context *hdd_ctx) |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 9920 | { |
Dustin Brown | 11638b7 | 2018-01-25 17:37:25 +0530 | [diff] [blame] | 9921 | wlan_hdd_deinit_chan_info(hdd_ctx); |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 9922 | wlan_hdd_tsf_deinit(hdd_ctx); |
| 9923 | } |
| 9924 | |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 9925 | /** |
Sandeep Puligilla | 0a11f8d | 2017-06-23 15:53:29 -0700 | [diff] [blame] | 9926 | * hdd_register_bcn_cb() - register scan beacon callback |
| 9927 | * @hdd_ctx - Pointer to the HDD context |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 9928 | * |
Sandeep Puligilla | 0a11f8d | 2017-06-23 15:53:29 -0700 | [diff] [blame] | 9929 | * Return: QDF_STATUS |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 9930 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9931 | 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] | 9932 | { |
| 9933 | QDF_STATUS status; |
| 9934 | |
| 9935 | status = ucfg_scan_register_bcn_cb(hdd_ctx->hdd_psoc, |
| 9936 | wlan_cfg80211_inform_bss_frame, |
| 9937 | SCAN_CB_TYPE_INFORM_BCN); |
| 9938 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9939 | hdd_err("failed with status code %08d [x%08x]", |
| 9940 | status, status); |
| 9941 | return status; |
| 9942 | } |
| 9943 | |
| 9944 | return QDF_STATUS_SUCCESS; |
| 9945 | } |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9946 | |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 9947 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9948 | * hdd_configure_cds() - Configure cds modules |
| 9949 | * @hdd_ctx: HDD context |
| 9950 | * @adapter: Primary adapter context |
| 9951 | * |
| 9952 | * Enable Cds modules after WLAN firmware is up. |
| 9953 | * |
| 9954 | * Return: 0 on success and errno on failure. |
| 9955 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9956 | 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] | 9957 | { |
| 9958 | int ret; |
| 9959 | QDF_STATUS status; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 9960 | int set_value; |
| 9961 | uint32_t num_abg_tx_chains = 0; |
| 9962 | uint32_t num_11b_tx_chains = 0; |
| 9963 | uint32_t num_11ag_tx_chains = 0; |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 9964 | struct policy_mgr_dp_cbacks dp_cbs; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 9965 | |
| 9966 | if (hdd_ctx->config->sifs_burst_duration) { |
| 9967 | set_value = (SIFS_BURST_DUR_MULTIPLIER) * |
| 9968 | hdd_ctx->config->sifs_burst_duration; |
| 9969 | |
| 9970 | if ((set_value > 0) && (set_value <= SIFS_BURST_DUR_MAX)) |
| 9971 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_BURST_DUR, |
| 9972 | set_value, PDEV_CMD); |
| 9973 | } |
| 9974 | |
| 9975 | if (hdd_ctx->config->is_force_1x1) |
| 9976 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_SET_IOT_PATTERN, |
| 9977 | 1, PDEV_CMD); |
| 9978 | /* set chip power save failure detected callback */ |
| 9979 | sme_set_chip_pwr_save_fail_cb(hdd_ctx->hHal, |
| 9980 | hdd_chip_pwr_save_fail_detected_cb); |
| 9981 | |
| 9982 | if (hdd_ctx->config->max_mpdus_inampdu) { |
| 9983 | set_value = hdd_ctx->config->max_mpdus_inampdu; |
| 9984 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_MAX_MPDUS_IN_AMPDU, |
| 9985 | set_value, PDEV_CMD); |
| 9986 | } |
| 9987 | |
| 9988 | if (hdd_ctx->config->enable_rts_sifsbursting) { |
| 9989 | set_value = hdd_ctx->config->enable_rts_sifsbursting; |
| 9990 | sme_cli_set_command(0, |
| 9991 | (int)WMI_PDEV_PARAM_ENABLE_RTS_SIFS_BURSTING, |
| 9992 | set_value, PDEV_CMD); |
| 9993 | } |
| 9994 | |
| 9995 | if (hdd_ctx->config->sap_get_peer_info) { |
| 9996 | set_value = hdd_ctx->config->sap_get_peer_info; |
| 9997 | sme_cli_set_command(0, |
| 9998 | (int)WMI_PDEV_PARAM_PEER_STATS_INFO_ENABLE, |
| 9999 | set_value, PDEV_CMD); |
| 10000 | } |
| 10001 | |
| 10002 | num_11b_tx_chains = hdd_ctx->config->num_11b_tx_chains; |
| 10003 | num_11ag_tx_chains = hdd_ctx->config->num_11ag_tx_chains; |
| 10004 | if (!hdd_ctx->config->enable2x2) { |
| 10005 | if (num_11b_tx_chains > 1) |
| 10006 | num_11b_tx_chains = 1; |
| 10007 | if (num_11ag_tx_chains > 1) |
| 10008 | num_11ag_tx_chains = 1; |
| 10009 | } |
| 10010 | WMI_PDEV_PARAM_SET_11B_TX_CHAIN_NUM(num_abg_tx_chains, |
| 10011 | num_11b_tx_chains); |
| 10012 | WMI_PDEV_PARAM_SET_11AG_TX_CHAIN_NUM(num_abg_tx_chains, |
| 10013 | num_11ag_tx_chains); |
| 10014 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_ABG_MODE_TX_CHAIN_NUM, |
| 10015 | num_abg_tx_chains, PDEV_CMD); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10016 | |
| 10017 | ret = hdd_pre_enable_configure(hdd_ctx); |
| 10018 | if (ret) { |
| 10019 | hdd_err("Failed to pre-configure cds"); |
| 10020 | goto out; |
| 10021 | } |
| 10022 | |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 10023 | /* Always get latest IPA resources allocated from cds_open and configure |
| 10024 | * IPA module before configuring them to FW. Sequence required as crash |
| 10025 | * observed otherwise. |
| 10026 | */ |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 10027 | if (ucfg_ipa_uc_ol_init(hdd_ctx->hdd_pdev, |
| 10028 | cds_get_context(QDF_MODULE_ID_QDF_DEVICE))) { |
Manikandan Mohan | 2e803a0 | 2017-02-14 14:57:53 -0800 | [diff] [blame] | 10029 | hdd_err("Failed to setup pipes"); |
| 10030 | goto out; |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 10031 | } |
| 10032 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10033 | /* |
| 10034 | * Start CDS which starts up the SME/MAC/HAL modules and everything |
| 10035 | * else |
| 10036 | */ |
Jeff Johnson | 8f9dd5f | 2017-09-13 14:16:08 -0700 | [diff] [blame] | 10037 | status = cds_enable(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10038 | |
| 10039 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10040 | hdd_err("cds_enable failed"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10041 | goto out; |
| 10042 | } |
| 10043 | |
| 10044 | status = hdd_post_cds_enable_config(hdd_ctx); |
| 10045 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10046 | hdd_err("hdd_post_cds_enable_config failed"); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 10047 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10048 | } |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10049 | status = hdd_register_bcn_cb(hdd_ctx); |
| 10050 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Paul Zhang | e03cf4c | 2018-01-19 18:33:22 +0800 | [diff] [blame] | 10051 | hdd_err("hdd_register_bcn_cb failed"); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10052 | goto cds_disable; |
| 10053 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10054 | |
| 10055 | ret = hdd_features_init(hdd_ctx, adapter); |
| 10056 | if (ret) |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 10057 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10058 | |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 10059 | dp_cbs.hdd_disable_lro_in_concurrency = hdd_disable_lro_in_concurrency; |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 10060 | dp_cbs.hdd_set_rx_mode_rps_cb = hdd_set_rx_mode_rps; |
jiad | bb47e13 | 2018-03-30 16:28:30 +0800 | [diff] [blame] | 10061 | dp_cbs.hdd_ipa_set_mcc_mode_cb = hdd_ipa_set_mcc_mode; |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 10062 | status = policy_mgr_register_dp_cb(hdd_ctx->hdd_psoc, &dp_cbs); |
| 10063 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 10064 | hdd_debug("Failed to register DP cb with Policy Manager"); |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 10065 | goto cds_disable; |
| 10066 | } |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 10067 | status = policy_mgr_register_mode_change_cb(hdd_ctx->hdd_psoc, |
| 10068 | wlan_hdd_send_mode_change_event); |
| 10069 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10070 | hdd_debug("Failed to register mode change cb with Policy Manager"); |
| 10071 | goto cds_disable; |
| 10072 | } |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 10073 | |
Jeff Johnson | 8bb6111 | 2018-03-31 13:33:54 -0700 | [diff] [blame] | 10074 | if (hdd_green_ap_enable_egap(hdd_ctx)) |
Nachiket Kukade | fbd1afc | 2017-07-12 17:41:54 +0530 | [diff] [blame] | 10075 | hdd_debug("enhance green ap is not enabled"); |
| 10076 | |
Nachiket Kukade | dd30266 | 2017-07-13 17:31:44 +0530 | [diff] [blame] | 10077 | if (0 != wlan_hdd_set_wow_pulse(hdd_ctx, true)) |
| 10078 | hdd_debug("Failed to set wow pulse"); |
| 10079 | |
Ashish Kumar Dhanotiya | cb14b11 | 2018-01-19 19:26:44 +0530 | [diff] [blame] | 10080 | sme_cli_set_command(0, WMI_PDEV_PARAM_GCMP_SUPPORT_ENABLE, |
| 10081 | hdd_ctx->config->gcmp_enabled, PDEV_CMD); |
Hanumanth Reddy Pothula | ab39595 | 2017-09-05 19:12:26 +0530 | [diff] [blame] | 10082 | sme_cli_set_command(0, WMI_PDEV_AUTO_DETECT_POWER_FAILURE, |
| 10083 | hdd_ctx->config->auto_pwr_save_fail_mode, PDEV_CMD); |
| 10084 | |
Ravi Kumar Bokka | 990edcc | 2017-01-09 20:02:58 +0530 | [diff] [blame] | 10085 | |
| 10086 | if (hdd_ctx->config->enable_phy_reg_retention) |
| 10087 | wma_cli_set_command(0, WMI_PDEV_PARAM_FAST_PWR_TRANSITION, |
| 10088 | hdd_ctx->config->enable_phy_reg_retention, PDEV_CMD); |
| 10089 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10090 | return 0; |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 10091 | |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 10092 | cds_disable: |
Jeff Johnson | ea5c2aa1 | 2017-09-13 14:18:59 -0700 | [diff] [blame] | 10093 | cds_disable(hdd_ctx->hdd_psoc); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 10094 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10095 | out: |
| 10096 | return -EINVAL; |
| 10097 | } |
| 10098 | |
| 10099 | /** |
| 10100 | * hdd_deconfigure_cds() -De-Configure cds |
| 10101 | * @hdd_ctx: HDD context |
| 10102 | * |
| 10103 | * Deconfigure Cds modules before WLAN firmware is down. |
| 10104 | * |
| 10105 | * Return: 0 on success and errno on failure. |
| 10106 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10107 | static int hdd_deconfigure_cds(struct hdd_context *hdd_ctx) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10108 | { |
| 10109 | QDF_STATUS qdf_status; |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 10110 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10111 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10112 | hdd_enter(); |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10113 | |
| 10114 | /* De-init features */ |
| 10115 | hdd_features_deinit(hdd_ctx); |
| 10116 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10117 | /* De-register the SME callbacks */ |
| 10118 | hdd_deregister_cb(hdd_ctx); |
| 10119 | |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 10120 | qdf_status = policy_mgr_deregister_mode_change_cb(hdd_ctx->hdd_psoc); |
| 10121 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 10122 | hdd_debug("Failed to deregister mode change cb with Policy Manager"); |
| 10123 | } |
| 10124 | |
Jeff Johnson | ea5c2aa1 | 2017-09-13 14:18:59 -0700 | [diff] [blame] | 10125 | qdf_status = cds_disable(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10126 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 10127 | hdd_err("Failed to Disable the CDS Modules! :%d", |
| 10128 | qdf_status); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 10129 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10130 | } |
| 10131 | |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 10132 | if (ucfg_ipa_uc_ol_deinit(hdd_ctx->hdd_pdev) != QDF_STATUS_SUCCESS) { |
Sravan Kumar Kairam | 7112171 | 2017-04-15 00:34:42 +0530 | [diff] [blame] | 10133 | hdd_err("Failed to disconnect pipes"); |
| 10134 | ret = -EINVAL; |
| 10135 | } |
| 10136 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10137 | hdd_exit(); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 10138 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10139 | } |
| 10140 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 10141 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
| 10142 | static void hdd_deregister_policy_manager_callback( |
| 10143 | struct wlan_objmgr_psoc *psoc) |
| 10144 | { |
| 10145 | if (QDF_STATUS_SUCCESS != |
| 10146 | policy_mgr_deregister_hdd_cb(psoc)) { |
| 10147 | hdd_err("HDD callback deregister with policy manager failed"); |
| 10148 | } |
| 10149 | } |
| 10150 | #else |
| 10151 | static void hdd_deregister_policy_manager_callback( |
| 10152 | struct wlan_objmgr_psoc *psoc) |
| 10153 | { |
| 10154 | } |
| 10155 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10156 | |
| 10157 | /** |
| 10158 | * hdd_wlan_stop_modules - Single driver state machine for stoping modules |
| 10159 | * @hdd_ctx: HDD context |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 10160 | * @ftm_mode: ftm mode |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10161 | * |
| 10162 | * This function maintains the driver state machine it will be invoked from |
| 10163 | * exit, shutdown and con_mode change handler. Depending on the driver state |
| 10164 | * shall perform the stopping/closing of the modules. |
| 10165 | * |
| 10166 | * Return: 0 for success; non-zero for failure |
| 10167 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10168 | 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] | 10169 | { |
| 10170 | void *hif_ctx; |
| 10171 | qdf_device_t qdf_ctx; |
| 10172 | QDF_STATUS qdf_status; |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10173 | int ret = 0; |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 10174 | bool is_recovery_stop = cds_is_driver_recovering(); |
Liangwei Dong | a78cc1d | 2018-02-01 02:19:30 -0500 | [diff] [blame] | 10175 | bool is_idle_stop = !cds_is_driver_unloading() && !is_recovery_stop && |
| 10176 | !cds_is_driver_loading(); |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10177 | int active_threads; |
Arunk Khandavalli | a6305a3 | 2018-01-25 11:19:18 +0530 | [diff] [blame] | 10178 | struct target_psoc_info *tgt_hdl; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10179 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10180 | hdd_enter(); |
Yun Park | fec73dc | 2017-09-06 10:40:07 -0700 | [diff] [blame] | 10181 | hdd_alert("stop WLAN module: entering driver status=%d", |
| 10182 | hdd_ctx->driver_status); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10183 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 10184 | hdd_deregister_policy_manager_callback(hdd_ctx->hdd_psoc); |
| 10185 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10186 | qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 10187 | if (!qdf_ctx) { |
| 10188 | hdd_err("QDF device context NULL"); |
| 10189 | return -EINVAL; |
| 10190 | } |
| 10191 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10192 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 10193 | hdd_ctx->stop_modules_in_progress = true; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 10194 | cds_set_module_stop_in_progress(true); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10195 | |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10196 | active_threads = cds_return_external_threads_count(); |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 10197 | if (active_threads > 0 || hdd_ctx->is_wiphy_suspended) { |
Rajeev Kumar | 86177c2 | 2017-03-16 19:44:39 -0700 | [diff] [blame] | 10198 | hdd_warn("External threads %d wiphy suspend %d", |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 10199 | active_threads, hdd_ctx->is_wiphy_suspended); |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10200 | |
| 10201 | cds_print_external_threads(); |
| 10202 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 10203 | if (is_idle_stop && !ftm_mode) { |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10204 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 10205 | qdf_sched_delayed_work(&hdd_ctx->iface_idle_work, |
| 10206 | hdd_ctx->config->iface_change_wait_time); |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 10207 | hdd_prevent_suspend_timeout( |
| 10208 | hdd_ctx->config->iface_change_wait_time, |
| 10209 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER); |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 10210 | hdd_ctx->stop_modules_in_progress = false; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 10211 | cds_set_module_stop_in_progress(false); |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10212 | return 0; |
| 10213 | } |
Rajeev Kumar | 86177c2 | 2017-03-16 19:44:39 -0700 | [diff] [blame] | 10214 | } |
| 10215 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10216 | hdd_info("Present Driver Status: %d", hdd_ctx->driver_status); |
| 10217 | |
Kabilan Kannan | 6edafeb | 2017-11-16 16:34:34 -0800 | [diff] [blame] | 10218 | /* free user wowl patterns */ |
| 10219 | hdd_free_user_wowl_ptrns(); |
| 10220 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10221 | switch (hdd_ctx->driver_status) { |
| 10222 | case DRIVER_MODULES_UNINITIALIZED: |
| 10223 | hdd_info("Modules not initialized just return"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10224 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10225 | case DRIVER_MODULES_CLOSED: |
| 10226 | hdd_info("Modules already closed"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10227 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10228 | case DRIVER_MODULES_ENABLED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10229 | hdd_info("Wlan transitioning (OPENED <- ENABLED)"); |
| 10230 | |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 10231 | hdd_disable_power_management(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10232 | if (hdd_deconfigure_cds(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10233 | hdd_err("Failed to de-configure CDS"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10234 | QDF_ASSERT(0); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10235 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10236 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10237 | hdd_debug("successfully Disabled the CDS modules!"); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10238 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10239 | hdd_ctx->driver_status = DRIVER_MODULES_OPENED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10240 | hdd_info("Wlan transitioned (now OPENED)"); |
| 10241 | |
| 10242 | /* fall through */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10243 | case DRIVER_MODULES_OPENED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10244 | hdd_info("Wlan transitioning (CLOSED <- OPENED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10245 | break; |
| 10246 | default: |
| 10247 | hdd_err("Trying to stop wlan in a wrong state: %d", |
| 10248 | hdd_ctx->driver_status); |
| 10249 | QDF_ASSERT(0); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10250 | ret = -EINVAL; |
| 10251 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10252 | } |
| 10253 | |
Amar Singhal | 1808164 | 2018-01-26 16:04:13 -0800 | [diff] [blame] | 10254 | hdd_sysfs_destroy_version_interface(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10255 | hdd_debug("Closing CDS modules!"); |
Amar Singhal | 1808164 | 2018-01-26 16:04:13 -0800 | [diff] [blame] | 10256 | |
Rajeev Kumar | be02124 | 2017-02-16 16:12:23 -0800 | [diff] [blame] | 10257 | qdf_status = cds_post_disable(); |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 10258 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 10259 | hdd_err("Failed to process post CDS disable Modules! :%d", |
| 10260 | qdf_status); |
| 10261 | ret = -EINVAL; |
| 10262 | QDF_ASSERT(0); |
| 10263 | } |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 10264 | |
psimha | deea0a1 | 2017-12-18 14:50:02 -0800 | [diff] [blame] | 10265 | hdd_runtime_suspend_context_deinit(hdd_ctx); |
| 10266 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 10267 | qdf_status = cds_dp_close(hdd_ctx->hdd_psoc); |
| 10268 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 10269 | hdd_warn("Failed to stop CDS DP: %d", qdf_status); |
| 10270 | ret = -EINVAL; |
| 10271 | QDF_ASSERT(0); |
| 10272 | } |
| 10273 | |
Jeff Johnson | e4b1459 | 2017-09-13 14:23:33 -0700 | [diff] [blame] | 10274 | qdf_status = cds_close(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10275 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10276 | hdd_warn("Failed to stop CDS: %d", qdf_status); |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 10277 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10278 | QDF_ASSERT(0); |
| 10279 | } |
Krunal Soni | d32c6bc | 2016-10-18 18:00:21 -0700 | [diff] [blame] | 10280 | |
Amar Singhal | 410675c | 2018-01-10 12:14:21 -0800 | [diff] [blame] | 10281 | dispatcher_pdev_close(hdd_ctx->hdd_pdev); |
Liangwei Dong | 50a64a7 | 2018-01-11 01:17:00 -0500 | [diff] [blame] | 10282 | ret = hdd_objmgr_release_and_destroy_pdev(hdd_ctx); |
| 10283 | if (ret) { |
| 10284 | hdd_err("Failed to destroy pdev; errno:%d", ret); |
| 10285 | QDF_ASSERT(0); |
| 10286 | } |
| 10287 | |
| 10288 | /* |
| 10289 | * Reset total mac phy during module stop such that during |
| 10290 | * next module start same psoc is used to populate new service |
| 10291 | * ready data |
| 10292 | */ |
Arunk Khandavalli | a6305a3 | 2018-01-25 11:19:18 +0530 | [diff] [blame] | 10293 | tgt_hdl = wlan_psoc_get_tgt_if_handle(hdd_ctx->hdd_psoc); |
| 10294 | if (tgt_hdl) |
| 10295 | target_psoc_set_total_mac_phy_cnt(tgt_hdl, 0); |
| 10296 | |
Liangwei Dong | 50a64a7 | 2018-01-11 01:17:00 -0500 | [diff] [blame] | 10297 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10298 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 10299 | if (!hif_ctx) { |
| 10300 | hdd_err("Hif context is Null"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10301 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10302 | } |
| 10303 | |
Arunk Khandavalli | 4b40433 | 2017-09-26 12:46:00 +0530 | [diff] [blame] | 10304 | if (hdd_ctx->target_hw_name) { |
| 10305 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 10306 | hdd_ctx->target_hw_name = NULL; |
| 10307 | } |
| 10308 | |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 10309 | hdd_hif_close(hdd_ctx, hif_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10310 | |
| 10311 | ol_cds_free(); |
| 10312 | |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10313 | if (is_idle_stop) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10314 | ret = pld_power_off(qdf_ctx->dev); |
| 10315 | if (ret) |
| 10316 | hdd_err("CNSS power down failed put device into Low power mode:%d", |
| 10317 | ret); |
| 10318 | } |
Arunk Khandavalli | 847969d | 2017-09-25 15:15:36 +0530 | [diff] [blame] | 10319 | |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 10320 | /* many adapter resources are not freed by design in SSR case */ |
| 10321 | if (!is_recovery_stop) |
| 10322 | hdd_check_for_leaks(); |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 10323 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_INIT); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 10324 | |
Arunk Khandavalli | 847969d | 2017-09-25 15:15:36 +0530 | [diff] [blame] | 10325 | /* Once the firmware sequence is completed reset this flag */ |
| 10326 | hdd_ctx->imps_enabled = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10327 | hdd_ctx->driver_status = DRIVER_MODULES_CLOSED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10328 | hdd_info("Wlan transitioned (now CLOSED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10329 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10330 | done: |
| 10331 | hdd_ctx->stop_modules_in_progress = false; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 10332 | cds_set_module_stop_in_progress(false); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10333 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Yun Park | fec73dc | 2017-09-06 10:40:07 -0700 | [diff] [blame] | 10334 | hdd_alert("stop WLAN module: exit driver status=%d", |
| 10335 | hdd_ctx->driver_status); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 10336 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10337 | hdd_exit(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10338 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10339 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10340 | } |
| 10341 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10342 | |
| 10343 | /** |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10344 | * hdd_state_info_dump() - prints state information of hdd layer |
| 10345 | * @buf: buffer pointer |
| 10346 | * @size: size of buffer to be filled |
| 10347 | * |
| 10348 | * This function is used to dump state information of hdd layer |
| 10349 | * |
| 10350 | * Return: None |
| 10351 | */ |
| 10352 | static void hdd_state_info_dump(char **buf_ptr, uint16_t *size) |
| 10353 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10354 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 10355 | struct hdd_station_ctx *hdd_sta_ctx; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10356 | struct hdd_adapter *adapter; |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10357 | uint16_t len = 0; |
| 10358 | char *buf = *buf_ptr; |
| 10359 | |
| 10360 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 10361 | if (!hdd_ctx) { |
| 10362 | hdd_err("Failed to get hdd context "); |
| 10363 | return; |
| 10364 | } |
| 10365 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10366 | hdd_debug("size of buffer: %d", *size); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10367 | |
| 10368 | len += scnprintf(buf + len, *size - len, |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 10369 | "\n is_wiphy_suspended %d", hdd_ctx->is_wiphy_suspended); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10370 | len += scnprintf(buf + len, *size - len, |
Rajeev Kumar | eada0d0 | 2016-12-08 17:44:17 -0800 | [diff] [blame] | 10371 | "\n is_scheduler_suspended %d", |
| 10372 | hdd_ctx->is_scheduler_suspended); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10373 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 10374 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10375 | if (adapter->dev) |
| 10376 | len += scnprintf(buf + len, *size - len, |
| 10377 | "\n device name: %s", adapter->dev->name); |
wadesong | 42968e9 | 2017-06-08 14:11:21 +0800 | [diff] [blame] | 10378 | len += scnprintf(buf + len, *size - len, |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10379 | "\n device_mode: %d", adapter->device_mode); |
| 10380 | switch (adapter->device_mode) { |
| 10381 | case QDF_STA_MODE: |
| 10382 | case QDF_P2P_CLIENT_MODE: |
| 10383 | hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 10384 | len += scnprintf(buf + len, *size - len, |
| 10385 | "\n connState: %d", |
| 10386 | hdd_sta_ctx->conn_info.connState); |
| 10387 | break; |
| 10388 | |
| 10389 | default: |
| 10390 | break; |
| 10391 | } |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10392 | } |
| 10393 | |
| 10394 | *size -= len; |
| 10395 | *buf_ptr += len; |
| 10396 | } |
| 10397 | |
| 10398 | /** |
| 10399 | * hdd_register_debug_callback() - registration function for hdd layer |
| 10400 | * to print hdd state information |
| 10401 | * |
| 10402 | * Return: None |
| 10403 | */ |
| 10404 | static void hdd_register_debug_callback(void) |
| 10405 | { |
| 10406 | qdf_register_debug_callback(QDF_MODULE_ID_HDD, &hdd_state_info_dump); |
| 10407 | } |
| 10408 | |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 10409 | /* |
| 10410 | * wlan_init_bug_report_lock() - Initialize bug report lock |
| 10411 | * |
| 10412 | * This function is used to create bug report lock |
| 10413 | * |
| 10414 | * Return: None |
| 10415 | */ |
| 10416 | static void wlan_init_bug_report_lock(void) |
| 10417 | { |
| 10418 | p_cds_contextType p_cds_context; |
| 10419 | |
| 10420 | p_cds_context = cds_get_global_context(); |
| 10421 | if (!p_cds_context) { |
| 10422 | hdd_err("cds context is NULL"); |
| 10423 | return; |
| 10424 | } |
| 10425 | |
| 10426 | qdf_spinlock_create(&p_cds_context->bug_report_lock); |
| 10427 | } |
| 10428 | |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10429 | void hdd_dp_trace_init(struct hdd_config *config) |
| 10430 | { |
| 10431 | |
| 10432 | bool live_mode = DP_TRACE_CONFIG_DEFAULT_LIVE_MODE; |
| 10433 | uint8_t thresh = DP_TRACE_CONFIG_DEFAULT_THRESH; |
| 10434 | uint16_t thresh_time_limit = DP_TRACE_CONFIG_DEFAULT_THRESH_TIME_LIMIT; |
| 10435 | uint8_t verbosity = DP_TRACE_CONFIG_DEFAULT_VERBOSTY; |
| 10436 | uint8_t proto_bitmap = DP_TRACE_CONFIG_DEFAULT_BITMAP; |
| 10437 | uint8_t config_params[DP_TRACE_CONFIG_NUM_PARAMS]; |
| 10438 | uint8_t num_entries = 0; |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 10439 | uint32_t bw_compute_interval; |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10440 | |
| 10441 | hdd_string_to_u8_array(config->dp_trace_config, config_params, |
| 10442 | &num_entries, sizeof(config_params)); |
| 10443 | |
| 10444 | /* calculating, num bw timer intervals in a second (1000ms) */ |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 10445 | bw_compute_interval = GET_BW_COMPUTE_INTV(config); |
Jiachao Wu | 1b00ecb | 2017-07-05 19:13:41 +0800 | [diff] [blame] | 10446 | if (bw_compute_interval <= 1000 && bw_compute_interval > 0) |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 10447 | thresh_time_limit = 1000 / bw_compute_interval; |
Jiachao Wu | 1b00ecb | 2017-07-05 19:13:41 +0800 | [diff] [blame] | 10448 | else if (bw_compute_interval > 1000) { |
| 10449 | hdd_err("busBandwidthComputeInterval > 1000, using 1000"); |
| 10450 | thresh_time_limit = 1; |
| 10451 | } else |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10452 | hdd_err("busBandwidthComputeInterval is 0, using defaults"); |
| 10453 | |
| 10454 | switch (num_entries) { |
| 10455 | case 4: |
| 10456 | proto_bitmap = config_params[3]; |
| 10457 | case 3: |
| 10458 | verbosity = config_params[2]; |
| 10459 | case 2: |
| 10460 | thresh = config_params[1]; |
| 10461 | case 1: |
| 10462 | live_mode = config_params[0]; |
| 10463 | default: |
Rajeev Kumar | 3887f9b | 2018-01-10 11:24:01 -0800 | [diff] [blame] | 10464 | 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] | 10465 | live_mode, thresh, thresh_time_limit, |
| 10466 | verbosity, proto_bitmap); |
| 10467 | }; |
| 10468 | |
| 10469 | qdf_dp_trace_init(live_mode, thresh, thresh_time_limit, |
| 10470 | verbosity, proto_bitmap); |
| 10471 | |
| 10472 | } |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10473 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10474 | * hdd_wlan_startup() - HDD init function |
| 10475 | * @dev: Pointer to the underlying device |
| 10476 | * |
| 10477 | * This is the driver startup code executed once a WLAN device has been detected |
| 10478 | * |
| 10479 | * Return: 0 for success, < 0 for failure |
| 10480 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10481 | int hdd_wlan_startup(struct device *dev) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10482 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10483 | QDF_STATUS status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10484 | struct hdd_context *hdd_ctx; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10485 | int ret; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 10486 | bool rtnl_held; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10487 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10488 | hdd_enter(); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10489 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10490 | hdd_ctx = hdd_context_create(dev); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10491 | |
| 10492 | if (IS_ERR(hdd_ctx)) |
| 10493 | return PTR_ERR(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10494 | |
Abhishek Singh | e9068f1 | 2017-03-31 14:14:52 +0530 | [diff] [blame] | 10495 | ret = hdd_objmgr_create_and_store_psoc(hdd_ctx, |
| 10496 | DEFAULT_PSOC_ID); |
| 10497 | if (ret) { |
| 10498 | hdd_err("Psoc creation fails!"); |
| 10499 | QDF_BUG(0); |
| 10500 | goto err_hdd_free_context; |
| 10501 | } |
| 10502 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 10503 | qdf_nbuf_init_replenish_timer(); |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 10504 | #ifdef FEATURE_WLAN_CH_AVOID |
| 10505 | mutex_init(&hdd_ctx->avoid_freq_lock); |
| 10506 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10507 | |
Jeff Johnson | ce0032c | 2017-01-20 07:18:27 -0800 | [diff] [blame] | 10508 | hdd_request_manager_init(); |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 10509 | qdf_atomic_init(&hdd_ctx->con_mode_flag); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10510 | |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 10511 | hdd_driver_memdump_init(); |
| 10512 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 10513 | ret = hdd_wlan_start_modules(hdd_ctx, NULL, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10514 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10515 | hdd_err("Failed to start modules: %d", ret); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 10516 | goto err_memdump_deinit; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10517 | } |
| 10518 | |
Yingying Tang | 80e15f3 | 2016-09-27 18:23:01 +0800 | [diff] [blame] | 10519 | wlan_hdd_update_wiphy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10520 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 10521 | hdd_ctx->hHal = cds_get_context(QDF_MODULE_ID_SME); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10522 | |
| 10523 | if (NULL == hdd_ctx->hHal) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10524 | hdd_err("HAL context is null"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10525 | goto err_stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10526 | } |
| 10527 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10528 | ret = hdd_wiphy_init(hdd_ctx); |
| 10529 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10530 | hdd_err("Failed to initialize wiphy: %d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10531 | goto err_stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10532 | } |
| 10533 | |
Nirav Shah | cc1f1ae | 2016-04-26 11:41:29 +0530 | [diff] [blame] | 10534 | if (hdd_ctx->config->enable_dp_trace) |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10535 | hdd_dp_trace_init(hdd_ctx->config); |
Nirav Shah | cc1f1ae | 2016-04-26 11:41:29 +0530 | [diff] [blame] | 10536 | |
Yuanyuan Liu | c98370e | 2016-10-13 11:22:13 -0700 | [diff] [blame] | 10537 | hdd_initialize_mac_address(hdd_ctx); |
Prashanth Bhatta | 75fa9a1 | 2016-01-11 18:30:08 -0800 | [diff] [blame] | 10538 | |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 10539 | ret = register_netdevice_notifier(&hdd_netdev_notifier); |
| 10540 | if (ret) { |
| 10541 | hdd_err("register_netdevice_notifier failed: %d", ret); |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 10542 | goto err_wiphy_unregister; |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 10543 | } |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 10544 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 10545 | rtnl_held = hdd_hold_rtnl_lock(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10546 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 10547 | ret = hdd_open_interfaces(hdd_ctx, rtnl_held); |
| 10548 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10549 | hdd_err("Failed to open interfaces: %d", ret); |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 10550 | goto err_release_rtnl_lock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10551 | } |
| 10552 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 10553 | hdd_release_rtnl_lock(); |
| 10554 | rtnl_held = false; |
| 10555 | |
Yingying Tang | 3ba3dbc | 2016-09-27 16:36:58 +0800 | [diff] [blame] | 10556 | wlan_hdd_update_11n_mode(hdd_ctx->config); |
| 10557 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10558 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 10559 | status = qdf_mc_timer_init(&hdd_ctx->skip_acs_scan_timer, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 10560 | QDF_TIMER_TYPE_SW, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10561 | hdd_skip_acs_scan_timer_handler, |
| 10562 | (void *)hdd_ctx); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10563 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 10564 | hdd_err("Failed to init ACS Skip timer"); |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 10565 | qdf_spinlock_create(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10566 | #endif |
| 10567 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 10568 | hdd_bus_bandwidth_init(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10569 | |
Jeff Johnson | 9afc501 | 2016-09-23 13:56:27 -0700 | [diff] [blame] | 10570 | hdd_lpass_notify_start(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10571 | |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 10572 | if (hdd_ctx->rps) |
| 10573 | hdd_set_rps_cpu_mask(hdd_ctx); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10574 | |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 10575 | ret = hdd_register_notifiers(hdd_ctx); |
| 10576 | if (ret) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 10577 | goto err_close_adapters; |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 10578 | |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 10579 | status = wlansap_global_init(); |
| 10580 | if (QDF_IS_STATUS_ERROR(status)) { |
| 10581 | hdd_unregister_notifiers(hdd_ctx); |
| 10582 | goto err_close_adapters; |
| 10583 | } |
| 10584 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10585 | if (hdd_ctx->config->fIsImpsEnabled) |
| 10586 | hdd_set_idle_ps_config(hdd_ctx, true); |
Kiran Kumar Lokere | b0f19c3 | 2017-10-13 12:23:26 -0700 | [diff] [blame] | 10587 | else |
| 10588 | hdd_set_idle_ps_config(hdd_ctx, false); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10589 | |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 10590 | if (QDF_GLOBAL_FTM_MODE != hdd_get_conparam()) { |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 10591 | qdf_sched_delayed_work(&hdd_ctx->iface_idle_work, |
| 10592 | hdd_ctx->config->iface_change_wait_time); |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 10593 | hdd_prevent_suspend_timeout( |
| 10594 | hdd_ctx->config->iface_change_wait_time, |
| 10595 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER); |
| 10596 | } |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 10597 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10598 | goto success; |
| 10599 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 10600 | err_close_adapters: |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 10601 | hdd_close_all_adapters(hdd_ctx, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10602 | |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 10603 | err_release_rtnl_lock: |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10604 | if (rtnl_held) |
| 10605 | hdd_release_rtnl_lock(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10606 | |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 10607 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 10608 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10609 | err_wiphy_unregister: |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10610 | wiphy_unregister(hdd_ctx->wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10611 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10612 | err_stop_modules: |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 10613 | hdd_wlan_stop_modules(hdd_ctx, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10614 | |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 10615 | err_memdump_deinit: |
| 10616 | hdd_driver_memdump_deinit(); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 10617 | |
Jeff Johnson | ce0032c | 2017-01-20 07:18:27 -0800 | [diff] [blame] | 10618 | hdd_request_manager_deinit(); |
Ryan Hsu | cfef0ae | 2016-04-28 10:20:46 -0700 | [diff] [blame] | 10619 | hdd_exit_netlink_services(hdd_ctx); |
| 10620 | |
Dustin Brown | 2091246 | 2017-06-07 13:48:25 -0700 | [diff] [blame] | 10621 | hdd_objmgr_release_and_destroy_psoc(hdd_ctx); |
| 10622 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10623 | err_hdd_free_context: |
Nachiket Kukade | 8003d25 | 2017-03-30 15:55:58 +0530 | [diff] [blame] | 10624 | if (cds_is_fw_down()) |
| 10625 | hdd_err("Not setting the complete event as fw is down"); |
| 10626 | else |
| 10627 | hdd_start_complete(ret); |
| 10628 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 10629 | qdf_nbuf_deinit_replenish_timer(); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 10630 | hdd_context_destroy(hdd_ctx); |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 10631 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10632 | |
| 10633 | success: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10634 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10635 | return 0; |
| 10636 | } |
| 10637 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10638 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10639 | * hdd_wlan_update_target_info() - update target type info |
| 10640 | * @hdd_ctx: HDD context |
| 10641 | * @context: hif context |
| 10642 | * |
| 10643 | * Update target info received from firmware in hdd context |
| 10644 | * Return:None |
| 10645 | */ |
| 10646 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10647 | 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] | 10648 | { |
| 10649 | struct hif_target_info *tgt_info = hif_get_target_info_handle(context); |
| 10650 | |
| 10651 | if (!tgt_info) { |
| 10652 | hdd_err("Target info is Null"); |
| 10653 | return; |
| 10654 | } |
| 10655 | |
| 10656 | hdd_ctx->target_type = tgt_info->target_type; |
| 10657 | } |
| 10658 | |
| 10659 | /** |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10660 | * hdd_get_nud_stats_cb() - callback api to update the stats |
| 10661 | * received from the firmware |
| 10662 | * @data: pointer to adapter. |
| 10663 | * @rsp: pointer to data received from FW. |
| 10664 | * |
| 10665 | * This is called when wlan driver received response event for |
| 10666 | * get arp stats to firmware. |
| 10667 | * |
| 10668 | * Return: None |
| 10669 | */ |
| 10670 | static void hdd_get_nud_stats_cb(void *data, struct rsp_stats *rsp) |
| 10671 | { |
| 10672 | struct hdd_context *hdd_ctx = (struct hdd_context *)data; |
| 10673 | struct hdd_nud_stats_context *context; |
| 10674 | int status; |
| 10675 | struct hdd_adapter *adapter = NULL; |
| 10676 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10677 | hdd_enter(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10678 | |
| 10679 | if (!rsp) { |
| 10680 | hdd_err("data is null"); |
| 10681 | return; |
| 10682 | } |
| 10683 | |
| 10684 | status = wlan_hdd_validate_context(hdd_ctx); |
| 10685 | if (0 != status) |
| 10686 | return; |
| 10687 | |
| 10688 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, rsp->vdev_id); |
| 10689 | if ((NULL == adapter) || (WLAN_HDD_ADAPTER_MAGIC != adapter->magic)) { |
| 10690 | hdd_err("Invalid adapter or adapter has invalid magic"); |
| 10691 | return; |
| 10692 | } |
| 10693 | |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 10694 | hdd_info("rsp->arp_req_enqueue :%x", rsp->arp_req_enqueue); |
| 10695 | hdd_info("rsp->arp_req_tx_success :%x", rsp->arp_req_tx_success); |
| 10696 | hdd_info("rsp->arp_req_tx_failure :%x", rsp->arp_req_tx_failure); |
| 10697 | hdd_info("rsp->arp_rsp_recvd :%x", rsp->arp_rsp_recvd); |
| 10698 | hdd_info("rsp->out_of_order_arp_rsp_drop_cnt :%x", |
| 10699 | rsp->out_of_order_arp_rsp_drop_cnt); |
| 10700 | hdd_info("rsp->dad_detected :%x", rsp->dad_detected); |
| 10701 | hdd_info("rsp->connect_status :%x", rsp->connect_status); |
| 10702 | hdd_info("rsp->ba_session_establishment_status :%x", |
| 10703 | rsp->ba_session_establishment_status); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10704 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10705 | 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] | 10706 | adapter->dad |= rsp->dad_detected; |
| 10707 | adapter->con_status = rsp->connect_status; |
| 10708 | |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 10709 | /* Flag true indicates connectivity check stats present. */ |
| 10710 | if (rsp->connect_stats_present) { |
| 10711 | hdd_info("rsp->tcp_ack_recvd :%x", rsp->tcp_ack_recvd); |
| 10712 | hdd_info("rsp->icmpv4_rsp_recvd :%x", rsp->icmpv4_rsp_recvd); |
| 10713 | adapter->hdd_stats.hdd_tcp_stats.rx_fw_cnt = rsp->tcp_ack_recvd; |
| 10714 | adapter->hdd_stats.hdd_icmpv4_stats.rx_fw_cnt = |
| 10715 | rsp->icmpv4_rsp_recvd; |
| 10716 | } |
| 10717 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10718 | spin_lock(&hdd_context_lock); |
| 10719 | context = &hdd_ctx->nud_stats_context; |
| 10720 | complete(&context->response_event); |
| 10721 | spin_unlock(&hdd_context_lock); |
| 10722 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10723 | hdd_exit(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10724 | } |
| 10725 | |
| 10726 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10727 | * hdd_register_cb - Register HDD callbacks. |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10728 | * @hdd_ctx: HDD context |
| 10729 | * |
| 10730 | * Register the HDD callbacks to CDS/SME. |
| 10731 | * |
| 10732 | * Return: 0 for success or Error code for failure |
| 10733 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10734 | int hdd_register_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10735 | { |
| 10736 | QDF_STATUS status; |
| 10737 | int ret = 0; |
| 10738 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10739 | hdd_enter(); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10740 | |
| 10741 | sme_register11d_scan_done_callback(hdd_ctx->hHal, hdd_11d_scan_done); |
| 10742 | |
| 10743 | sme_register_oem_data_rsp_callback(hdd_ctx->hHal, |
| 10744 | hdd_send_oem_data_rsp_msg); |
| 10745 | |
Deepthi Gowri | d5a58fe | 2016-09-03 16:01:28 +0530 | [diff] [blame] | 10746 | sme_register_mgmt_frame_ind_callback(hdd_ctx->hHal, |
| 10747 | hdd_indicate_mgmt_frame); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10748 | sme_set_tsfcb(hdd_ctx->hHal, hdd_get_tsf_cb, hdd_ctx); |
| 10749 | sme_nan_register_callback(hdd_ctx->hHal, |
| 10750 | wlan_hdd_cfg80211_nan_callback); |
| 10751 | sme_stats_ext_register_callback(hdd_ctx->hHal, |
| 10752 | wlan_hdd_cfg80211_stats_ext_callback); |
| 10753 | |
| 10754 | sme_ext_scan_register_callback(hdd_ctx->hHal, |
| 10755 | wlan_hdd_cfg80211_extscan_callback); |
lifeng | 6683166 | 2017-05-19 16:01:35 +0800 | [diff] [blame] | 10756 | sme_stats_ext2_register_callback(hdd_ctx->hHal, |
| 10757 | wlan_hdd_cfg80211_stats_ext2_callback); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10758 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10759 | sme_set_rssi_threshold_breached_cb(hdd_ctx->hHal, |
| 10760 | hdd_rssi_threshold_breached); |
| 10761 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10762 | sme_set_nud_debug_stats_cb(hdd_ctx->hHal, hdd_get_nud_stats_cb); |
| 10763 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10764 | sme_set_link_layer_stats_ind_cb(hdd_ctx->hHal, |
| 10765 | wlan_hdd_cfg80211_link_layer_stats_callback); |
| 10766 | |
Sreelakshmi Konamki | 88a2a41 | 2017-04-14 15:11:55 +0530 | [diff] [blame] | 10767 | sme_rso_cmd_status_cb(hdd_ctx->hHal, wlan_hdd_rso_cmd_status_cb); |
| 10768 | |
Zhang Qian | ca38fb1 | 2016-12-23 11:10:48 +0800 | [diff] [blame] | 10769 | sme_set_link_layer_ext_cb(hdd_ctx->hHal, |
| 10770 | wlan_hdd_cfg80211_link_layer_stats_ext_callback); |
| 10771 | |
Sreelakshmi Konamki | 58c7243 | 2016-11-09 17:06:44 +0530 | [diff] [blame] | 10772 | status = sme_set_lost_link_info_cb(hdd_ctx->hHal, |
| 10773 | hdd_lost_link_info_cb); |
| 10774 | /* print error and not block the startup process */ |
| 10775 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10776 | hdd_err("set lost link info callback failed"); |
| 10777 | |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 10778 | ret = hdd_register_data_stall_detect_cb(); |
| 10779 | if (ret) { |
| 10780 | hdd_err("Register data stall detect detect callback failed."); |
| 10781 | return ret; |
| 10782 | } |
| 10783 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10784 | wlan_hdd_dcc_register_for_dcc_stats_event(hdd_ctx); |
| 10785 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 10786 | sme_register_set_connection_info_cb(hdd_ctx->hHal, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 10787 | hdd_set_connection_in_progress, |
| 10788 | hdd_is_connection_in_progress); |
Padma, Santhosh Kumar | 16dacfb | 2017-03-21 19:05:40 +0530 | [diff] [blame] | 10789 | |
| 10790 | status = sme_congestion_register_callback(hdd_ctx->hHal, |
| 10791 | hdd_update_cca_info_cb); |
| 10792 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10793 | hdd_err("set congestion callback failed"); |
| 10794 | |
Vidyullatha Kanchanapally | be0ebb3 | 2017-03-23 14:36:21 +0530 | [diff] [blame] | 10795 | status = sme_set_bt_activity_info_cb(hdd_ctx->hHal, |
| 10796 | hdd_bt_activity_cb); |
| 10797 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10798 | hdd_err("set bt activity info callback failed"); |
| 10799 | |
Varun Reddy Yeturu | 076eaa8 | 2018-01-16 12:16:14 -0800 | [diff] [blame] | 10800 | status = sme_register_tx_queue_cb(hdd_ctx->hHal, |
| 10801 | hdd_tx_queue_cb); |
| 10802 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10803 | hdd_err("Register tx queue callback failed"); |
| 10804 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10805 | hdd_exit(); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10806 | |
| 10807 | return ret; |
| 10808 | } |
| 10809 | |
| 10810 | /** |
| 10811 | * hdd_deregister_cb() - De-Register HDD callbacks. |
| 10812 | * @hdd_ctx: HDD context |
| 10813 | * |
| 10814 | * De-Register the HDD callbacks to CDS/SME. |
| 10815 | * |
| 10816 | * Return: void |
| 10817 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10818 | void hdd_deregister_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10819 | { |
| 10820 | QDF_STATUS status; |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 10821 | int ret; |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10822 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10823 | hdd_enter(); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10824 | |
Varun Reddy Yeturu | 076eaa8 | 2018-01-16 12:16:14 -0800 | [diff] [blame] | 10825 | sme_deregister_tx_queue_cb(hdd_ctx->hHal); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10826 | status = sme_deregister_for_dcc_stats_event(hdd_ctx->hHal); |
| 10827 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10828 | hdd_err("De-register of dcc stats callback failed: %d", |
| 10829 | status); |
| 10830 | |
| 10831 | sme_reset_link_layer_stats_ind_cb(hdd_ctx->hHal); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10832 | sme_reset_rssi_threshold_breached_cb(hdd_ctx->hHal); |
| 10833 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10834 | sme_stats_ext_register_callback(hdd_ctx->hHal, |
| 10835 | wlan_hdd_cfg80211_stats_ext_callback); |
| 10836 | |
| 10837 | sme_nan_deregister_callback(hdd_ctx->hHal); |
| 10838 | status = sme_reset_tsfcb(hdd_ctx->hHal); |
| 10839 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10840 | hdd_err("Failed to de-register tsfcb the callback:%d", |
| 10841 | status); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10842 | |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 10843 | ret = hdd_deregister_data_stall_detect_cb(); |
| 10844 | if (ret) |
| 10845 | hdd_err("Failed to de-register data stall detect event callback"); |
| 10846 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10847 | sme_deregister_oem_data_rsp_callback(hdd_ctx->hHal); |
| 10848 | sme_deregister11d_scan_done_callback(hdd_ctx->hHal); |
| 10849 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10850 | hdd_exit(); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10851 | } |
| 10852 | |
| 10853 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10854 | * hdd_softap_sta_deauth() - handle deauth req from HDD |
| 10855 | * @adapter: Pointer to the HDD |
| 10856 | * @enable: bool value |
| 10857 | * |
| 10858 | * This to take counter measure to handle deauth req from HDD |
| 10859 | * |
| 10860 | * Return: None |
| 10861 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10862 | QDF_STATUS hdd_softap_sta_deauth(struct hdd_adapter *adapter, |
Jeff Johnson | e6bf719 | 2017-11-07 15:16:09 -0800 | [diff] [blame] | 10863 | struct csr_del_sta_params *pDelStaParams) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10864 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10865 | QDF_STATUS qdf_status = QDF_STATUS_E_FAULT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10866 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10867 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10868 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10869 | /* Ignore request to deauth bcmc station */ |
| 10870 | if (pDelStaParams->peerMacAddr.bytes[0] & 0x1) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10871 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10872 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10873 | qdf_status = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10874 | wlansap_deauth_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 10875 | pDelStaParams); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10876 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10877 | hdd_exit(); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10878 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10879 | } |
| 10880 | |
| 10881 | /** |
| 10882 | * hdd_softap_sta_disassoc() - take counter measure to handle deauth req from HDD |
| 10883 | * @adapter: Pointer to the HDD |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 10884 | * @p_del_sta_params: pointer to station deletion parameters |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10885 | * |
| 10886 | * This to take counter measure to handle deauth req from HDD |
| 10887 | * |
| 10888 | * Return: None |
| 10889 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10890 | void hdd_softap_sta_disassoc(struct hdd_adapter *adapter, |
Jeff Johnson | e6bf719 | 2017-11-07 15:16:09 -0800 | [diff] [blame] | 10891 | struct csr_del_sta_params *pDelStaParams) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10892 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10893 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10894 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10895 | /* Ignore request to disassoc bcmc station */ |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 10896 | if (pDelStaParams->peerMacAddr.bytes[0] & 0x1) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10897 | return; |
| 10898 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10899 | wlansap_disassoc_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 10900 | pDelStaParams); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10901 | } |
| 10902 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10903 | /** |
| 10904 | * hdd_issta_p2p_clientconnected() - check if sta or p2p client is connected |
| 10905 | * @hdd_ctx: HDD Context |
| 10906 | * |
| 10907 | * API to find if there is any STA or P2P-Client is connected |
| 10908 | * |
| 10909 | * Return: true if connected; false otherwise |
| 10910 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10911 | QDF_STATUS hdd_issta_p2p_clientconnected(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10912 | { |
| 10913 | return sme_is_sta_p2p_client_connected(hdd_ctx->hHal); |
| 10914 | } |
| 10915 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10916 | /** |
| 10917 | * wlan_hdd_disable_roaming() - disable roaming on all STAs except the input one |
| 10918 | * @adapter: HDD adapter pointer |
| 10919 | * |
| 10920 | * This function loop through each adapter and disable roaming on each STA |
| 10921 | * device mode except the input adapter. |
| 10922 | * |
| 10923 | * Note: On the input adapter roaming is not enabled yet hence no need to |
| 10924 | * disable. |
| 10925 | * |
| 10926 | * Return: None |
| 10927 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10928 | void wlan_hdd_disable_roaming(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10929 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10930 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10931 | struct hdd_adapter *adapterIdx = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10932 | |
| 10933 | if (hdd_ctx->config->isFastRoamIniFeatureEnabled && |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 10934 | hdd_ctx->config->isRoamOffloadScanEnabled && |
| 10935 | QDF_STA_MODE == adapter->device_mode && |
| 10936 | policy_mgr_is_sta_active_connection_exists( |
| 10937 | hdd_ctx->hdd_psoc)) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 10938 | hdd_debug("Connect received on STA session Id(%d)", |
| 10939 | adapter->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10940 | /* |
| 10941 | * Loop through adapter and disable roaming for each STA device |
| 10942 | * mode except the input adapter. |
| 10943 | */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 10944 | hdd_for_each_adapter(hdd_ctx, adapterIdx) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 10945 | if (QDF_STA_MODE == adapterIdx->device_mode && |
| 10946 | adapter->session_id != adapterIdx->session_id) { |
| 10947 | hdd_debug("Disable Roaming on session Id(%d)", |
| 10948 | adapterIdx->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10949 | sme_stop_roaming(WLAN_HDD_GET_HAL_CTX |
| 10950 | (adapterIdx), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 10951 | adapterIdx->session_id, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10952 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10953 | } |
| 10954 | } |
| 10955 | } |
| 10956 | |
| 10957 | /** |
| 10958 | * wlan_hdd_enable_roaming() - enable roaming on all STAs except the input one |
| 10959 | * @adapter: HDD adapter pointer |
| 10960 | * |
| 10961 | * This function loop through each adapter and enable roaming on each STA |
| 10962 | * device mode except the input adapter. |
| 10963 | * Note: On the input adapter no need to enable roaming because link got |
| 10964 | * disconnected on this. |
| 10965 | * |
| 10966 | * Return: None |
| 10967 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10968 | void wlan_hdd_enable_roaming(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10969 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10970 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10971 | struct hdd_adapter *adapterIdx = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10972 | |
| 10973 | if (hdd_ctx->config->isFastRoamIniFeatureEnabled && |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 10974 | hdd_ctx->config->isRoamOffloadScanEnabled && |
| 10975 | QDF_STA_MODE == adapter->device_mode && |
| 10976 | policy_mgr_is_sta_active_connection_exists( |
| 10977 | hdd_ctx->hdd_psoc)) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 10978 | hdd_debug("Disconnect received on STA session Id(%d)", |
| 10979 | adapter->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10980 | /* |
| 10981 | * Loop through adapter and enable roaming for each STA device |
| 10982 | * mode except the input adapter. |
| 10983 | */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 10984 | hdd_for_each_adapter(hdd_ctx, adapterIdx) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 10985 | if (QDF_STA_MODE == adapterIdx->device_mode && |
| 10986 | adapter->session_id != adapterIdx->session_id) { |
| 10987 | hdd_debug("Enabling Roaming on session Id(%d)", |
| 10988 | adapterIdx->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10989 | sme_start_roaming(WLAN_HDD_GET_HAL_CTX |
| 10990 | (adapterIdx), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 10991 | adapterIdx->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10992 | REASON_CONNECT); |
| 10993 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10994 | } |
| 10995 | } |
| 10996 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10997 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 10998 | /** |
| 10999 | * nl_srv_bcast_svc() - Wrapper function to send bcast msgs to SVC mcast group |
| 11000 | * @skb: sk buffer pointer |
| 11001 | * |
| 11002 | * Sends the bcast message to SVC multicast group with generic nl socket |
| 11003 | * if CNSS_GENL is enabled. Else, use the legacy netlink socket to send. |
| 11004 | * |
| 11005 | * Return: None |
| 11006 | */ |
| 11007 | static void nl_srv_bcast_svc(struct sk_buff *skb) |
| 11008 | { |
| 11009 | #ifdef CNSS_GENL |
| 11010 | nl_srv_bcast(skb, CLD80211_MCGRP_SVC_MSGS, WLAN_NL_MSG_SVC); |
| 11011 | #else |
| 11012 | nl_srv_bcast(skb); |
| 11013 | #endif |
| 11014 | } |
| 11015 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11016 | 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] | 11017 | { |
| 11018 | struct sk_buff *skb; |
| 11019 | struct nlmsghdr *nlh; |
| 11020 | tAniMsgHdr *ani_hdr; |
| 11021 | void *nl_data = NULL; |
| 11022 | int flags = GFP_KERNEL; |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11023 | struct radio_index_tlv *radio_info; |
| 11024 | int tlv_len; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11025 | |
| 11026 | if (in_interrupt() || irqs_disabled() || in_atomic()) |
| 11027 | flags = GFP_ATOMIC; |
| 11028 | |
| 11029 | skb = alloc_skb(NLMSG_SPACE(WLAN_NL_MAX_PAYLOAD), flags); |
| 11030 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 11031 | if (skb == NULL) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11032 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11033 | |
| 11034 | nlh = (struct nlmsghdr *)skb->data; |
| 11035 | nlh->nlmsg_pid = 0; /* from kernel */ |
| 11036 | nlh->nlmsg_flags = 0; |
| 11037 | nlh->nlmsg_seq = 0; |
| 11038 | nlh->nlmsg_type = WLAN_NL_MSG_SVC; |
| 11039 | |
| 11040 | ani_hdr = NLMSG_DATA(nlh); |
| 11041 | ani_hdr->type = type; |
| 11042 | |
| 11043 | switch (type) { |
| 11044 | case WLAN_SVC_FW_CRASHED_IND: |
Komal Seelam | 78ff65a | 2016-08-18 15:25:24 +0530 | [diff] [blame] | 11045 | case WLAN_SVC_FW_SHUTDOWN_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11046 | case WLAN_SVC_LTE_COEX_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11047 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND: |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 11048 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11049 | ani_hdr->length = 0; |
| 11050 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr))); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11051 | break; |
| 11052 | case WLAN_SVC_WLAN_STATUS_IND: |
| 11053 | case WLAN_SVC_WLAN_VERSION_IND: |
| 11054 | case WLAN_SVC_DFS_CAC_START_IND: |
| 11055 | case WLAN_SVC_DFS_CAC_END_IND: |
| 11056 | case WLAN_SVC_DFS_RADAR_DETECT_IND: |
| 11057 | case WLAN_SVC_DFS_ALL_CHANNEL_UNAVAIL_IND: |
| 11058 | case WLAN_SVC_WLAN_TP_IND: |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 11059 | case WLAN_SVC_WLAN_TP_TX_IND: |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 11060 | case WLAN_SVC_RPS_ENABLE_IND: |
Orhan K AKYILDIZ | e7445a2 | 2017-01-19 21:21:47 -0800 | [diff] [blame] | 11061 | case WLAN_SVC_CORE_MINFREQ: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11062 | ani_hdr->length = len; |
| 11063 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr) + len)); |
| 11064 | nl_data = (char *)ani_hdr + sizeof(tAniMsgHdr); |
| 11065 | memcpy(nl_data, data, len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11066 | break; |
| 11067 | |
| 11068 | default: |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 11069 | hdd_err("WLAN SVC: Attempt to send unknown nlink message %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11070 | type); |
| 11071 | kfree_skb(skb); |
| 11072 | return; |
| 11073 | } |
| 11074 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11075 | /* |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 11076 | * Add radio index at the end of the svc event in TLV format |
| 11077 | * to maintain the backward compatibility with userspace |
| 11078 | * applications. |
| 11079 | */ |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11080 | |
| 11081 | tlv_len = 0; |
| 11082 | |
| 11083 | if ((sizeof(*ani_hdr) + len + sizeof(struct radio_index_tlv)) |
| 11084 | < WLAN_NL_MAX_PAYLOAD) { |
| 11085 | radio_info = (struct radio_index_tlv *)((char *) ani_hdr + |
| 11086 | sizeof(*ani_hdr) + len); |
| 11087 | radio_info->type = (unsigned short) WLAN_SVC_WLAN_RADIO_INDEX; |
| 11088 | radio_info->length = (unsigned short) sizeof(radio_info->radio); |
| 11089 | radio_info->radio = radio; |
| 11090 | tlv_len = sizeof(*radio_info); |
Dustin Brown | a286862 | 2018-03-20 11:38:14 -0700 | [diff] [blame] | 11091 | hdd_debug("Added radio index tlv - radio index %d", |
| 11092 | radio_info->radio); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11093 | } |
| 11094 | |
| 11095 | nlh->nlmsg_len += tlv_len; |
| 11096 | skb_put(skb, NLMSG_SPACE(sizeof(tAniMsgHdr) + len + tlv_len)); |
| 11097 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 11098 | nl_srv_bcast_svc(skb); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11099 | } |
| 11100 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11101 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 11102 | void wlan_hdd_auto_shutdown_cb(void) |
| 11103 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11104 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11105 | |
| 11106 | if (!hdd_ctx) |
| 11107 | return; |
| 11108 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11109 | hdd_debug("Wlan Idle. Sending Shutdown event.."); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11110 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 11111 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11112 | } |
| 11113 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11114 | 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] | 11115 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11116 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11117 | bool ap_connected = false, sta_connected = false; |
| 11118 | tHalHandle hal_handle; |
| 11119 | |
| 11120 | hal_handle = hdd_ctx->hHal; |
| 11121 | if (hal_handle == NULL) |
| 11122 | return; |
| 11123 | |
| 11124 | if (hdd_ctx->config->WlanAutoShutdown == 0) |
| 11125 | return; |
| 11126 | |
| 11127 | if (enable == false) { |
| 11128 | if (sme_set_auto_shutdown_timer(hal_handle, 0) != |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11129 | QDF_STATUS_SUCCESS) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11130 | hdd_err("Failed to stop wlan auto shutdown timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11131 | } |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11132 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 11133 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11134 | return; |
| 11135 | } |
| 11136 | |
| 11137 | /* To enable shutdown timer check conncurrency */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11138 | if (policy_mgr_concurrent_open_sessions_running(hdd_ctx->hdd_psoc)) { |
| 11139 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 11140 | if (adapter->device_mode == QDF_STA_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11141 | if (WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
| 11142 | conn_info.connState == |
| 11143 | eConnectionState_Associated) { |
| 11144 | sta_connected = true; |
| 11145 | break; |
| 11146 | } |
| 11147 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11148 | |
| 11149 | if (adapter->device_mode == QDF_SAP_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11150 | if (WLAN_HDD_GET_AP_CTX_PTR(adapter)-> |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 11151 | ap_active == true) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11152 | ap_connected = true; |
| 11153 | break; |
| 11154 | } |
| 11155 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11156 | } |
| 11157 | } |
| 11158 | |
| 11159 | if (ap_connected == true || sta_connected == true) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11160 | hdd_debug("CC Session active. Shutdown timer not enabled"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11161 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11162 | } |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 11163 | |
| 11164 | if (sme_set_auto_shutdown_timer(hal_handle, |
| 11165 | hdd_ctx->config->WlanAutoShutdown) |
| 11166 | != QDF_STATUS_SUCCESS) |
| 11167 | hdd_err("Failed to start wlan auto shutdown timer"); |
| 11168 | else |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 11169 | hdd_info("Auto Shutdown timer for %d seconds enabled", |
| 11170 | hdd_ctx->config->WlanAutoShutdown); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11171 | } |
| 11172 | #endif |
| 11173 | |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 11174 | struct hdd_adapter * |
| 11175 | hdd_get_con_sap_adapter(struct hdd_adapter *this_sap_adapter, |
| 11176 | bool check_start_bss) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11177 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11178 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(this_sap_adapter); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11179 | struct hdd_adapter *adapter, *con_sap_adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11180 | |
| 11181 | con_sap_adapter = NULL; |
| 11182 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11183 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 11184 | if (adapter && ((adapter->device_mode == QDF_SAP_MODE) || |
| 11185 | (adapter->device_mode == QDF_P2P_GO_MODE)) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11186 | adapter != this_sap_adapter) { |
| 11187 | if (check_start_bss) { |
| 11188 | if (test_bit(SOFTAP_BSS_STARTED, |
| 11189 | &adapter->event_flags)) { |
| 11190 | con_sap_adapter = adapter; |
| 11191 | break; |
| 11192 | } |
| 11193 | } else { |
| 11194 | con_sap_adapter = adapter; |
| 11195 | break; |
| 11196 | } |
| 11197 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11198 | } |
| 11199 | |
| 11200 | return con_sap_adapter; |
| 11201 | } |
| 11202 | |
| 11203 | #ifdef MSM_PLATFORM |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11204 | static inline bool hdd_adapter_is_sta(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11205 | { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11206 | return adapter->device_mode == QDF_STA_MODE || |
| 11207 | adapter->device_mode == QDF_P2P_CLIENT_MODE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11208 | } |
| 11209 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11210 | static inline bool hdd_adapter_is_ap(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11211 | { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11212 | return adapter->device_mode == QDF_SAP_MODE || |
| 11213 | adapter->device_mode == QDF_P2P_GO_MODE; |
| 11214 | } |
| 11215 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11216 | static bool hdd_any_adapter_is_assoc(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11217 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11218 | struct hdd_adapter *adapter; |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11219 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11220 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 11221 | if (hdd_adapter_is_sta(adapter) && |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11222 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
| 11223 | conn_info.connState == eConnectionState_Associated) { |
| 11224 | return true; |
| 11225 | } |
| 11226 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11227 | if (hdd_adapter_is_ap(adapter) && |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 11228 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->ap_active) { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11229 | return true; |
| 11230 | } |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11231 | } |
| 11232 | |
| 11233 | return false; |
| 11234 | } |
| 11235 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11236 | 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] | 11237 | { |
| 11238 | bool is_running; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11239 | |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 11240 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11241 | is_running = hdd_ctx->bus_bw_timer_running; |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 11242 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11243 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11244 | return is_running; |
| 11245 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11246 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11247 | 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] | 11248 | { |
| 11249 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
| 11250 | hdd_ctx->bus_bw_timer_running = true; |
| 11251 | qdf_timer_start(&hdd_ctx->bus_bw_timer, |
| 11252 | hdd_ctx->config->busBandwidthComputeInterval); |
| 11253 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
| 11254 | } |
| 11255 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11256 | void hdd_bus_bw_compute_timer_start(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11257 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11258 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11259 | |
| 11260 | if (hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 11261 | hdd_debug("Bandwidth compute timer already started"); |
| 11262 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11263 | } |
| 11264 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11265 | __hdd_bus_bw_compute_timer_start(hdd_ctx); |
| 11266 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11267 | hdd_exit(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11268 | } |
| 11269 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11270 | 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] | 11271 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11272 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11273 | |
| 11274 | if (hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 11275 | hdd_debug("Bandwidth compute timer already started"); |
| 11276 | return; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 11277 | } |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11278 | |
| 11279 | if (hdd_any_adapter_is_assoc(hdd_ctx)) |
| 11280 | __hdd_bus_bw_compute_timer_start(hdd_ctx); |
| 11281 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11282 | hdd_exit(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11283 | } |
| 11284 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11285 | 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] | 11286 | { |
Sravan Kumar Kairam | 9e99e9a | 2018-03-12 19:09:45 +0530 | [diff] [blame] | 11287 | ucfg_ipa_set_perf_level(hdd_ctx->hdd_pdev, 0, 0); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11288 | |
| 11289 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
| 11290 | qdf_timer_stop(&hdd_ctx->bus_bw_timer); |
| 11291 | hdd_ctx->bus_bw_timer_running = false; |
| 11292 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
| 11293 | |
| 11294 | hdd_reset_tcp_delack(hdd_ctx); |
| 11295 | } |
| 11296 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11297 | void hdd_bus_bw_compute_timer_stop(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11298 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11299 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11300 | |
| 11301 | if (!hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 11302 | hdd_debug("Bandwidth compute timer already stopped"); |
| 11303 | return; |
| 11304 | } |
| 11305 | |
| 11306 | __hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 11307 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11308 | hdd_exit(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11309 | } |
| 11310 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11311 | 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] | 11312 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11313 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11314 | |
| 11315 | if (!hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 11316 | hdd_debug("Bandwidth compute timer already stopped"); |
| 11317 | return; |
| 11318 | } |
| 11319 | |
| 11320 | if (!hdd_any_adapter_is_assoc(hdd_ctx)) |
| 11321 | __hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 11322 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11323 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11324 | } |
| 11325 | #endif |
| 11326 | |
| 11327 | /** |
| 11328 | * wlan_hdd_check_custom_con_channel_rules() - This function checks the sap's |
| 11329 | * and sta's operating channel. |
| 11330 | * @sta_adapter: Describe the first argument to foobar. |
| 11331 | * @ap_adapter: Describe the second argument to foobar. |
| 11332 | * @roam_profile: Roam profile of AP to which STA wants to connect. |
| 11333 | * @concurrent_chnl_same: If both SAP and STA channels are same then |
| 11334 | * set this flag to true else false. |
| 11335 | * |
| 11336 | * This function checks the sap's operating channel and sta's operating channel. |
| 11337 | * if both are same then it will return false else it will restart the sap in |
| 11338 | * sta's channel and return true. |
| 11339 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11340 | * Return: QDF_STATUS_SUCCESS or QDF_STATUS_E_FAILURE. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11341 | */ |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 11342 | QDF_STATUS |
| 11343 | wlan_hdd_check_custom_con_channel_rules(struct hdd_adapter *sta_adapter, |
| 11344 | struct hdd_adapter *ap_adapter, |
Jeff Johnson | 61b5e98 | 2018-03-15 11:33:31 -0700 | [diff] [blame] | 11345 | struct csr_roam_profile *roam_profile, |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 11346 | tScanResultHandle *scan_cache, |
| 11347 | bool *concurrent_chnl_same) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11348 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 11349 | struct hdd_ap_ctx *hdd_ap_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11350 | uint8_t channel_id; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11351 | QDF_STATUS status; |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 11352 | enum QDF_OPMODE device_mode = ap_adapter->device_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11353 | *concurrent_chnl_same = true; |
| 11354 | |
| 11355 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 11356 | status = |
Archana Ramachandran | 2eb7a61 | 2017-03-23 22:58:42 -0700 | [diff] [blame] | 11357 | sme_get_ap_channel_from_scan_cache(roam_profile, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11358 | scan_cache, |
| 11359 | &channel_id); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 11360 | if (QDF_STATUS_SUCCESS == status) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 11361 | if ((QDF_SAP_MODE == device_mode) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11362 | (channel_id < SIR_11A_CHANNEL_BEGIN)) { |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 11363 | if (hdd_ap_ctx->operating_channel != channel_id) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11364 | *concurrent_chnl_same = false; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11365 | hdd_debug("channels are different"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11366 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 11367 | } else if ((QDF_P2P_GO_MODE == device_mode) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11368 | (channel_id >= SIR_11A_CHANNEL_BEGIN)) { |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 11369 | if (hdd_ap_ctx->operating_channel != channel_id) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11370 | *concurrent_chnl_same = false; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11371 | hdd_debug("channels are different"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11372 | } |
| 11373 | } |
| 11374 | } else { |
| 11375 | /* |
| 11376 | * Lets handle worst case scenario here, Scan cache lookup is |
| 11377 | * failed so we have to stop the SAP to avoid any channel |
| 11378 | * discrepancy between SAP's channel and STA's channel. |
| 11379 | * Return the status as failure so caller function could know |
| 11380 | * that scan look up is failed. |
| 11381 | */ |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11382 | hdd_err("Finding AP from scan cache failed"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11383 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11384 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11385 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11386 | } |
| 11387 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11388 | /** |
| 11389 | * wlan_hdd_stop_sap() - This function stops bss of SAP. |
| 11390 | * @ap_adapter: SAP adapter |
| 11391 | * |
| 11392 | * This function will process the stopping of sap adapter. |
| 11393 | * |
| 11394 | * Return: None |
| 11395 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11396 | void wlan_hdd_stop_sap(struct hdd_adapter *ap_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11397 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 11398 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 11399 | struct hdd_hostapd_state *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 11400 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11401 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11402 | |
| 11403 | if (NULL == ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11404 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11405 | return; |
| 11406 | } |
| 11407 | |
| 11408 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 11409 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 11410 | if (wlan_hdd_validate_context(hdd_ctx)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11411 | return; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 11412 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11413 | mutex_lock(&hdd_ctx->sap_lock); |
| 11414 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
Ryan Hsu | 8ecb0fa | 2016-01-18 15:40:55 -0800 | [diff] [blame] | 11415 | wlan_hdd_del_station(ap_adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11416 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11417 | hdd_debug("Now doing SAP STOPBSS"); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 11418 | qdf_event_reset(&hostapd_state->qdf_stop_bss_event); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11419 | if (QDF_STATUS_SUCCESS == wlansap_stop_bss(hdd_ap_ctx-> |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 11420 | sap_context)) { |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 11421 | qdf_status = qdf_wait_for_event_completion(&hostapd_state-> |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 11422 | qdf_stop_bss_event, |
| 11423 | SME_CMD_TIMEOUT_VALUE); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 11424 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11425 | mutex_unlock(&hdd_ctx->sap_lock); |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11426 | hdd_err("SAP Stop Failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11427 | return; |
| 11428 | } |
| 11429 | } |
| 11430 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 11431 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
| 11432 | ap_adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11433 | ap_adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 11434 | hdd_green_ap_start_state_mc(hdd_ctx, ap_adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 11435 | false); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11436 | hdd_debug("SAP Stop Success"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11437 | } else { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11438 | hdd_err("Can't stop ap because its not started"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11439 | } |
| 11440 | mutex_unlock(&hdd_ctx->sap_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11441 | } |
| 11442 | |
| 11443 | /** |
| 11444 | * wlan_hdd_start_sap() - this function starts bss of SAP. |
| 11445 | * @ap_adapter: SAP adapter |
| 11446 | * |
| 11447 | * This function will process the starting of sap adapter. |
| 11448 | * |
| 11449 | * Return: None |
| 11450 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11451 | void wlan_hdd_start_sap(struct hdd_adapter *ap_adapter, bool reinit) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11452 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 11453 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 11454 | struct hdd_hostapd_state *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 11455 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11456 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11457 | tsap_Config_t *sap_config; |
| 11458 | |
| 11459 | if (NULL == ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11460 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11461 | return; |
| 11462 | } |
| 11463 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 11464 | if (QDF_SAP_MODE != ap_adapter->device_mode) { |
Peng Xu | f5d60c8 | 2015-10-02 17:17:03 -0700 | [diff] [blame] | 11465 | hdd_err("SoftAp role has not been enabled"); |
| 11466 | return; |
| 11467 | } |
| 11468 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11469 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
| 11470 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 11471 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 11472 | sap_config = &ap_adapter->session.ap.sap_config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11473 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11474 | mutex_lock(&hdd_ctx->sap_lock); |
| 11475 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) |
| 11476 | goto end; |
| 11477 | |
| 11478 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11479 | hdd_err("SAP Not able to set AP IEs"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11480 | goto end; |
| 11481 | } |
| 11482 | |
Wei Song | 2f76f64 | 2016-11-18 16:32:53 +0800 | [diff] [blame] | 11483 | qdf_event_reset(&hostapd_state->qdf_event); |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 11484 | 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] | 11485 | &hdd_ap_ctx->sap_config, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11486 | ap_adapter->dev) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11487 | != QDF_STATUS_SUCCESS) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11488 | goto end; |
| 11489 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11490 | hdd_debug("Waiting for SAP to start"); |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 11491 | qdf_status = qdf_wait_for_event_completion(&hostapd_state->qdf_event, |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 11492 | SME_CMD_TIMEOUT_VALUE); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 11493 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11494 | hdd_err("SAP Start failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11495 | goto end; |
| 11496 | } |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11497 | hdd_info("SAP Start Success"); |
Vignesh Viswanathan | 85b455e | 2018-01-17 19:54:33 +0530 | [diff] [blame] | 11498 | wlansap_reset_sap_config_add_ie(sap_config, eUPDATE_IE_ALL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11499 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 11500 | if (hostapd_state->bss_state == BSS_START) { |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 11501 | policy_mgr_incr_active_session(hdd_ctx->hdd_psoc, |
| 11502 | ap_adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11503 | ap_adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 11504 | hdd_green_ap_start_state_mc(hdd_ctx, ap_adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 11505 | true); |
| 11506 | } |
Sourav Mohapatra | 9bc6711 | 2017-11-08 09:36:11 +0530 | [diff] [blame] | 11507 | mutex_unlock(&hdd_ctx->sap_lock); |
| 11508 | |
| 11509 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11510 | end: |
Vignesh Viswanathan | 85b455e | 2018-01-17 19:54:33 +0530 | [diff] [blame] | 11511 | wlansap_reset_sap_config_add_ie(sap_config, eUPDATE_IE_ALL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11512 | mutex_unlock(&hdd_ctx->sap_lock); |
Manikandan Mohan | 3dad1a4 | 2017-06-14 10:50:18 -0700 | [diff] [blame] | 11513 | /* SAP context and beacon cleanup will happen during driver unload |
| 11514 | * in hdd_stop_adapter |
| 11515 | */ |
| 11516 | hdd_err("SAP restart after SSR failed! Reload WLAN and try SAP again"); |
| 11517 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11518 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11519 | |
| 11520 | /** |
Archana Ramachandran | a20ef81 | 2015-11-13 16:12:13 -0800 | [diff] [blame] | 11521 | * wlan_hdd_soc_set_antenna_mode_cb() - Callback for set dual |
| 11522 | * mac scan config |
| 11523 | * @status: Status of set antenna mode |
| 11524 | * |
| 11525 | * Callback on setting the dual mac configuration |
| 11526 | * |
| 11527 | * Return: None |
| 11528 | */ |
| 11529 | void wlan_hdd_soc_set_antenna_mode_cb( |
| 11530 | enum set_antenna_mode_status status) |
| 11531 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11532 | struct hdd_context *hdd_ctx; |
Archana Ramachandran | a20ef81 | 2015-11-13 16:12:13 -0800 | [diff] [blame] | 11533 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11534 | hdd_debug("Status: %d", status); |
Archana Ramachandran | a20ef81 | 2015-11-13 16:12:13 -0800 | [diff] [blame] | 11535 | |
| 11536 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 11537 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
| 11538 | return; |
| 11539 | |
| 11540 | /* Signal the completion of set dual mac config */ |
| 11541 | complete(&hdd_ctx->set_antenna_mode_cmpl); |
| 11542 | } |
| 11543 | |
| 11544 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11545 | * hdd_get_fw_version() - Get FW version |
| 11546 | * @hdd_ctx: pointer to HDD context. |
| 11547 | * @major_spid: FW version - major spid. |
| 11548 | * @minor_spid: FW version - minor spid |
| 11549 | * @ssid: FW version - ssid |
| 11550 | * @crmid: FW version - crmid |
| 11551 | * |
| 11552 | * This function is called to get the firmware build version stored |
| 11553 | * as part of the HDD context |
| 11554 | * |
| 11555 | * Return: None |
| 11556 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11557 | void hdd_get_fw_version(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11558 | uint32_t *major_spid, uint32_t *minor_spid, |
| 11559 | uint32_t *siid, uint32_t *crmid) |
| 11560 | { |
| 11561 | *major_spid = (hdd_ctx->target_fw_version & 0xf0000000) >> 28; |
| 11562 | *minor_spid = (hdd_ctx->target_fw_version & 0xf000000) >> 24; |
| 11563 | *siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20; |
| 11564 | *crmid = hdd_ctx->target_fw_version & 0x7fff; |
| 11565 | } |
| 11566 | |
| 11567 | #ifdef QCA_CONFIG_SMP |
| 11568 | /** |
| 11569 | * wlan_hdd_get_cpu() - get cpu_index |
| 11570 | * |
| 11571 | * Return: cpu_index |
| 11572 | */ |
| 11573 | int wlan_hdd_get_cpu(void) |
| 11574 | { |
| 11575 | int cpu_index = get_cpu(); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 11576 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11577 | put_cpu(); |
| 11578 | return cpu_index; |
| 11579 | } |
| 11580 | #endif |
| 11581 | |
| 11582 | /** |
| 11583 | * hdd_get_fwpath() - get framework path |
| 11584 | * |
| 11585 | * This function is used to get the string written by |
| 11586 | * userspace to start the wlan driver |
| 11587 | * |
| 11588 | * Return: string |
| 11589 | */ |
| 11590 | const char *hdd_get_fwpath(void) |
| 11591 | { |
| 11592 | return fwpath.string; |
| 11593 | } |
| 11594 | |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 11595 | static int hdd_qdf_print_init(void) |
| 11596 | { |
| 11597 | int qdf_print_idx; |
| 11598 | QDF_STATUS status; |
| 11599 | |
| 11600 | status = qdf_print_setup(); |
| 11601 | if (status != QDF_STATUS_SUCCESS) { |
| 11602 | pr_err("qdf_print_setup failed\n"); |
| 11603 | return -EINVAL; |
| 11604 | } |
| 11605 | |
| 11606 | qdf_print_idx = qdf_print_ctrl_register(cinfo, NULL, NULL, "MCL_WLAN"); |
| 11607 | |
| 11608 | if (qdf_print_idx < 0) { |
| 11609 | pr_err("qdf_print_ctrl_register failed, ret = %d\n", |
| 11610 | qdf_print_idx); |
| 11611 | return -EINVAL; |
| 11612 | } |
| 11613 | |
| 11614 | qdf_set_pidx(qdf_print_idx); |
| 11615 | |
| 11616 | return 0; |
| 11617 | } |
| 11618 | |
| 11619 | static void hdd_qdf_print_deinit(void) |
| 11620 | { |
| 11621 | int qdf_print_idx; |
| 11622 | |
| 11623 | qdf_print_idx = qdf_get_pidx(); |
| 11624 | qdf_print_ctrl_cleanup(qdf_print_idx); |
| 11625 | } |
| 11626 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11627 | /** |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11628 | * hdd_init() - Initialize Driver |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11629 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11630 | * This function initilizes CDS global context with the help of cds_init. This |
| 11631 | * has to be the first function called after probe to get a valid global |
| 11632 | * context. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11633 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11634 | * Return: 0 for success, errno on failure |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11635 | */ |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11636 | int hdd_init(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11637 | { |
Jeff Johnson | 7aaeeea | 2017-09-26 13:16:24 -0700 | [diff] [blame] | 11638 | QDF_STATUS status; |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11639 | int ret = 0; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11640 | |
Jeff Johnson | 7aaeeea | 2017-09-26 13:16:24 -0700 | [diff] [blame] | 11641 | status = cds_init(); |
wadesong | ae4ffd1 | 2017-10-24 16:45:54 +0800 | [diff] [blame] | 11642 | if (QDF_IS_STATUS_ERROR(status)) { |
| 11643 | hdd_err("Failed to allocate CDS context"); |
| 11644 | ret = -ENOMEM; |
| 11645 | goto err_out; |
| 11646 | } |
Hanumanth Reddy Pothula | 788a37e | 2017-08-17 18:40:11 +0530 | [diff] [blame] | 11647 | |
| 11648 | wlan_init_bug_report_lock(); |
| 11649 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11650 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 11651 | wlan_logging_sock_init_svc(); |
| 11652 | #endif |
| 11653 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 11654 | qdf_timer_init(NULL, &hdd_drv_ops_inactivity_timer, |
| 11655 | (void *)hdd_drv_ops_inactivity_handler, NULL, |
| 11656 | QDF_TIMER_TYPE_SW); |
| 11657 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11658 | hdd_trace_init(); |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 11659 | hdd_qdf_print_init(); |
| 11660 | |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11661 | hdd_register_debug_callback(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11662 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11663 | err_out: |
| 11664 | return ret; |
| 11665 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11666 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11667 | /** |
| 11668 | * hdd_deinit() - Deinitialize Driver |
| 11669 | * |
| 11670 | * This function frees CDS global context with the help of cds_deinit. This |
| 11671 | * has to be the last function call in remove callback to free the global |
| 11672 | * context. |
| 11673 | */ |
| 11674 | void hdd_deinit(void) |
| 11675 | { |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 11676 | qdf_timer_free(&hdd_drv_ops_inactivity_timer); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11677 | |
Rajeev Kumar | 2d0f219 | 2017-10-18 19:48:21 -0700 | [diff] [blame] | 11678 | wlan_destroy_bug_report_lock(); |
| 11679 | cds_deinit(); |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 11680 | |
Rajeev Kumar | 2d0f219 | 2017-10-18 19:48:21 -0700 | [diff] [blame] | 11681 | hdd_qdf_print_deinit(); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11682 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 11683 | wlan_logging_sock_deinit_svc(); |
| 11684 | #endif |
| 11685 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11686 | |
Yue Ma | 6e7b1a0 | 2017-04-03 14:17:46 -0700 | [diff] [blame] | 11687 | #ifdef QCA_WIFI_NAPIER_EMULATION |
| 11688 | #define HDD_WLAN_START_WAIT_TIME ((CDS_WMA_TIMEOUT + 5000) * 100) |
| 11689 | #else |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11690 | #define HDD_WLAN_START_WAIT_TIME (CDS_WMA_TIMEOUT + 5000) |
Yue Ma | 6e7b1a0 | 2017-04-03 14:17:46 -0700 | [diff] [blame] | 11691 | #endif |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11692 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11693 | static int wlan_hdd_state_ctrl_param_open(struct inode *inode, |
| 11694 | struct file *file) |
| 11695 | { |
| 11696 | return 0; |
| 11697 | } |
| 11698 | |
| 11699 | static ssize_t wlan_hdd_state_ctrl_param_write(struct file *filp, |
| 11700 | const char __user *user_buf, |
| 11701 | size_t count, |
| 11702 | loff_t *f_pos) |
| 11703 | { |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 11704 | char buf[3]; |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11705 | static const char wlan_off_str[] = "OFF"; |
| 11706 | static const char wlan_on_str[] = "ON"; |
| 11707 | int ret; |
| 11708 | unsigned long rc; |
| 11709 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 11710 | if (copy_from_user(buf, user_buf, 3)) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11711 | pr_err("Failed to read buffer\n"); |
| 11712 | return -EINVAL; |
| 11713 | } |
| 11714 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 11715 | if (strncmp(buf, wlan_off_str, strlen(wlan_off_str)) == 0) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11716 | pr_debug("Wifi turning off from UI\n"); |
| 11717 | goto exit; |
| 11718 | } |
| 11719 | |
Sachin Ahuja | 16904db | 2017-12-13 19:56:57 +0530 | [diff] [blame] | 11720 | if (strncmp(buf, wlan_on_str, strlen(wlan_on_str)) == 0) { |
| 11721 | pr_info("Wifi Turning On from UI\n"); |
| 11722 | } |
| 11723 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 11724 | if (strncmp(buf, wlan_on_str, strlen(wlan_on_str)) != 0) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11725 | pr_err("Invalid value received from framework"); |
| 11726 | goto exit; |
| 11727 | } |
| 11728 | |
| 11729 | if (!cds_is_driver_loaded()) { |
Sachin Ahuja | ee62b54 | 2017-04-21 14:14:16 +0530 | [diff] [blame] | 11730 | init_completion(&wlan_start_comp); |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11731 | rc = wait_for_completion_timeout(&wlan_start_comp, |
| 11732 | msecs_to_jiffies(HDD_WLAN_START_WAIT_TIME)); |
| 11733 | if (!rc) { |
| 11734 | hdd_alert("Timed-out waiting in wlan_hdd_state_ctrl_param_write"); |
| 11735 | ret = -EINVAL; |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11736 | return ret; |
| 11737 | } |
| 11738 | |
| 11739 | hdd_start_complete(0); |
| 11740 | } |
| 11741 | |
| 11742 | exit: |
| 11743 | return count; |
| 11744 | } |
| 11745 | |
| 11746 | |
| 11747 | const struct file_operations wlan_hdd_state_fops = { |
| 11748 | .owner = THIS_MODULE, |
| 11749 | .open = wlan_hdd_state_ctrl_param_open, |
| 11750 | .write = wlan_hdd_state_ctrl_param_write, |
| 11751 | }; |
| 11752 | |
| 11753 | static int wlan_hdd_state_ctrl_param_create(void) |
| 11754 | { |
| 11755 | unsigned int wlan_hdd_state_major = 0; |
| 11756 | int ret; |
| 11757 | struct device *dev; |
| 11758 | |
| 11759 | device = MKDEV(wlan_hdd_state_major, 0); |
| 11760 | |
| 11761 | ret = alloc_chrdev_region(&device, 0, dev_num, "qcwlanstate"); |
| 11762 | if (ret) { |
| 11763 | pr_err("Failed to register qcwlanstate"); |
| 11764 | goto dev_alloc_err; |
| 11765 | } |
| 11766 | wlan_hdd_state_major = MAJOR(device); |
| 11767 | |
| 11768 | class = class_create(THIS_MODULE, WLAN_MODULE_NAME); |
| 11769 | if (IS_ERR(class)) { |
| 11770 | pr_err("wlan_hdd_state class_create error"); |
| 11771 | goto class_err; |
| 11772 | } |
| 11773 | |
| 11774 | dev = device_create(class, NULL, device, NULL, WLAN_MODULE_NAME); |
| 11775 | if (IS_ERR(dev)) { |
| 11776 | pr_err("wlan_hdd_statedevice_create error"); |
| 11777 | goto err_class_destroy; |
| 11778 | } |
| 11779 | |
| 11780 | cdev_init(&wlan_hdd_state_cdev, &wlan_hdd_state_fops); |
| 11781 | ret = cdev_add(&wlan_hdd_state_cdev, device, dev_num); |
| 11782 | if (ret) { |
| 11783 | pr_err("Failed to add cdev error"); |
| 11784 | goto cdev_add_err; |
| 11785 | } |
| 11786 | |
| 11787 | pr_info("wlan_hdd_state %s major(%d) initialized", |
| 11788 | WLAN_MODULE_NAME, wlan_hdd_state_major); |
| 11789 | |
| 11790 | return 0; |
| 11791 | |
| 11792 | cdev_add_err: |
| 11793 | device_destroy(class, device); |
| 11794 | err_class_destroy: |
| 11795 | class_destroy(class); |
| 11796 | class_err: |
| 11797 | unregister_chrdev_region(device, dev_num); |
| 11798 | dev_alloc_err: |
| 11799 | return -ENODEV; |
| 11800 | } |
| 11801 | |
| 11802 | static void wlan_hdd_state_ctrl_param_destroy(void) |
| 11803 | { |
| 11804 | cdev_del(&wlan_hdd_state_cdev); |
| 11805 | device_destroy(class, device); |
| 11806 | class_destroy(class); |
| 11807 | unregister_chrdev_region(device, dev_num); |
| 11808 | |
| 11809 | pr_info("Device node unregistered"); |
| 11810 | } |
| 11811 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11812 | /** |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 11813 | * component_init - API to init cld component's |
| 11814 | * |
| 11815 | * Return: None |
| 11816 | */ |
| 11817 | static void component_init(void) |
| 11818 | { |
| 11819 | pmo_init(); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 11820 | disa_init(); |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 11821 | ucfg_ocb_init(); |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 11822 | ipa_init(); |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 11823 | } |
| 11824 | |
| 11825 | /** |
| 11826 | * component_deinit - API to deinit cld component's |
| 11827 | * |
| 11828 | * Return: None |
| 11829 | */ |
| 11830 | static void component_deinit(void) |
| 11831 | { |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 11832 | ipa_deinit(); |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 11833 | ucfg_ocb_deinit(); |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 11834 | pmo_deinit(); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 11835 | disa_deinit(); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 11836 | } |
| 11837 | |
| 11838 | void hdd_component_psoc_enable(struct wlan_objmgr_psoc *psoc) |
| 11839 | { |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 11840 | ocb_psoc_enable(psoc); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 11841 | disa_psoc_enable(psoc); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 11842 | } |
| 11843 | |
| 11844 | void hdd_component_psoc_disable(struct wlan_objmgr_psoc *psoc) |
| 11845 | { |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 11846 | disa_psoc_disable(psoc); |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 11847 | ocb_psoc_disable(psoc); |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 11848 | } |
| 11849 | |
| 11850 | /** |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11851 | * __hdd_module_init - Module init helper |
| 11852 | * |
| 11853 | * Module init helper function used by both module and static driver. |
| 11854 | * |
| 11855 | * Return: 0 for success, errno on failure |
| 11856 | */ |
| 11857 | static int __hdd_module_init(void) |
| 11858 | { |
| 11859 | int ret = 0; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11860 | |
Dustin Brown | 96cd963 | 2017-11-13 12:45:04 -0800 | [diff] [blame] | 11861 | pr_err("%s: Loading driver v%s (%s)\n", |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 11862 | WLAN_MODULE_NAME, |
Dustin Brown | 96cd963 | 2017-11-13 12:45:04 -0800 | [diff] [blame] | 11863 | g_wlan_driver_version, |
Dustin Brown | c1034df | 2018-02-07 14:51:32 -0800 | [diff] [blame] | 11864 | TIMER_MANAGER_STR MEMORY_DEBUG_STR PANIC_ON_BUG_STR); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11865 | |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 11866 | pld_init(); |
| 11867 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 11868 | ret = hdd_init(); |
| 11869 | if (ret) { |
| 11870 | pr_err("hdd_init failed %x\n", ret); |
| 11871 | goto err_hdd_init; |
| 11872 | } |
| 11873 | |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 11874 | dispatcher_init(); |
| 11875 | |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 11876 | /* Ensure to call post objmgr init */ |
| 11877 | component_init(); |
| 11878 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 11879 | qdf_wake_lock_create(&wlan_wake_lock, "wlan"); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11880 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11881 | hdd_set_conparam((uint32_t) con_mode); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11882 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11883 | ret = wlan_hdd_register_driver(); |
| 11884 | if (ret) { |
Mohit Khanna | fa99aea | 2016-05-12 21:43:13 -0700 | [diff] [blame] | 11885 | pr_err("%s: driver load failure, err %d\n", WLAN_MODULE_NAME, |
| 11886 | ret); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11887 | goto out; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11888 | } |
| 11889 | |
Sachin Ahuja | 16904db | 2017-12-13 19:56:57 +0530 | [diff] [blame] | 11890 | ret = wlan_hdd_state_ctrl_param_create(); |
| 11891 | if (ret) { |
| 11892 | pr_err("wlan_hdd_state_create:%x\n", ret); |
| 11893 | goto out; |
| 11894 | } |
| 11895 | |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 11896 | pr_info("%s: driver loaded\n", WLAN_MODULE_NAME); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11897 | |
| 11898 | return 0; |
| 11899 | out: |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 11900 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Liangwei Dong | 9fcc721 | 2017-10-24 13:43:52 +0800 | [diff] [blame] | 11901 | component_deinit(); |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 11902 | dispatcher_deinit(); |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 11903 | hdd_deinit(); |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 11904 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 11905 | err_hdd_init: |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 11906 | pld_deinit(); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11907 | return ret; |
| 11908 | } |
| 11909 | |
| 11910 | /** |
| 11911 | * __hdd_module_exit - Module exit helper |
| 11912 | * |
| 11913 | * Module exit helper function used by both module and static driver. |
| 11914 | */ |
| 11915 | static void __hdd_module_exit(void) |
| 11916 | { |
Will Huang | 3604972 | 2018-04-13 11:48:51 +0800 | [diff] [blame] | 11917 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 11918 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11919 | pr_info("%s: Unloading driver v%s\n", WLAN_MODULE_NAME, |
| 11920 | QWLAN_VERSIONSTR); |
| 11921 | |
Will Huang | 3604972 | 2018-04-13 11:48:51 +0800 | [diff] [blame] | 11922 | if (!hdd_ctx) { |
| 11923 | hdd_err("hdd context is NULL return!!"); |
| 11924 | return; |
| 11925 | } |
| 11926 | |
Arunk Khandavalli | 07ec8f6 | 2016-09-27 21:51:01 +0530 | [diff] [blame] | 11927 | hdd_wait_for_recovery_completion(); |
| 11928 | |
Will Huang | 3604972 | 2018-04-13 11:48:51 +0800 | [diff] [blame] | 11929 | qdf_cancel_delayed_work(&hdd_ctx->iface_idle_work); |
| 11930 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11931 | wlan_hdd_unregister_driver(); |
| 11932 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 11933 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11934 | |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 11935 | /* Ensure to call prior to objmgr deinit */ |
| 11936 | component_deinit(); |
| 11937 | |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 11938 | dispatcher_deinit(); |
Amar Singhal | 0928b19 | 2017-12-01 10:50:54 -0800 | [diff] [blame] | 11939 | |
| 11940 | hdd_sysfs_destroy_version_interface(); |
| 11941 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 11942 | hdd_deinit(); |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 11943 | pld_deinit(); |
| 11944 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11945 | wlan_hdd_state_ctrl_param_destroy(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11946 | } |
| 11947 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11948 | #ifndef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11949 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11950 | * wlan_boot_cb() - Wlan boot callback |
| 11951 | * @kobj: object whose directory we're creating the link in. |
| 11952 | * @attr: attribute the user is interacting with |
| 11953 | * @buff: the buffer containing the user data |
| 11954 | * @count: number of bytes in the buffer |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11955 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11956 | * This callback is invoked when the fs is ready to start the |
| 11957 | * wlan driver initialization. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11958 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11959 | * 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] | 11960 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11961 | static ssize_t wlan_boot_cb(struct kobject *kobj, |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11962 | struct kobj_attribute *attr, |
| 11963 | const char *buf, |
| 11964 | size_t count) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11965 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11966 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11967 | if (wlan_loader->loaded_state) { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11968 | pr_err("%s: wlan driver already initialized\n", __func__); |
| 11969 | return -EALREADY; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11970 | } |
| 11971 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11972 | if (__hdd_module_init()) { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11973 | pr_err("%s: wlan driver initialization failed\n", __func__); |
| 11974 | return -EIO; |
| 11975 | } |
| 11976 | |
| 11977 | wlan_loader->loaded_state = MODULE_INITIALIZED; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11978 | |
| 11979 | return count; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11980 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11981 | |
| 11982 | /** |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11983 | * hdd_sysfs_cleanup() - cleanup sysfs |
| 11984 | * |
| 11985 | * Return: None |
| 11986 | * |
| 11987 | */ |
| 11988 | static void hdd_sysfs_cleanup(void) |
| 11989 | { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11990 | /* remove from group */ |
| 11991 | if (wlan_loader->boot_wlan_obj && wlan_loader->attr_group) |
| 11992 | sysfs_remove_group(wlan_loader->boot_wlan_obj, |
| 11993 | wlan_loader->attr_group); |
| 11994 | |
| 11995 | /* unlink the object from parent */ |
| 11996 | kobject_del(wlan_loader->boot_wlan_obj); |
| 11997 | |
| 11998 | /* free the object */ |
| 11999 | kobject_put(wlan_loader->boot_wlan_obj); |
| 12000 | |
| 12001 | kfree(wlan_loader->attr_group); |
| 12002 | kfree(wlan_loader); |
| 12003 | |
| 12004 | wlan_loader = NULL; |
| 12005 | } |
| 12006 | |
| 12007 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12008 | * wlan_init_sysfs() - Creates the sysfs to be invoked when the fs is |
| 12009 | * ready |
| 12010 | * |
| 12011 | * This is creates the syfs entry boot_wlan. Which shall be invoked |
| 12012 | * when the filesystem is ready. |
| 12013 | * |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12014 | * QDF API cannot be used here since this function is called even before |
| 12015 | * initializing WLAN driver. |
| 12016 | * |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 12017 | * Return: 0 for success, errno on failure |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12018 | */ |
| 12019 | static int wlan_init_sysfs(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12020 | { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12021 | int ret = -ENOMEM; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12022 | |
| 12023 | wlan_loader = kzalloc(sizeof(*wlan_loader), GFP_KERNEL); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 12024 | if (!wlan_loader) |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12025 | return -ENOMEM; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12026 | |
| 12027 | wlan_loader->boot_wlan_obj = NULL; |
| 12028 | wlan_loader->attr_group = kzalloc(sizeof(*(wlan_loader->attr_group)), |
| 12029 | GFP_KERNEL); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 12030 | if (!wlan_loader->attr_group) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12031 | goto error_return; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12032 | |
| 12033 | wlan_loader->loaded_state = 0; |
| 12034 | wlan_loader->attr_group->attrs = attrs; |
| 12035 | |
| 12036 | wlan_loader->boot_wlan_obj = kobject_create_and_add("boot_wlan", |
| 12037 | kernel_kobj); |
| 12038 | if (!wlan_loader->boot_wlan_obj) { |
| 12039 | pr_err("%s: sysfs create and add failed\n", __func__); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12040 | goto error_return; |
| 12041 | } |
| 12042 | |
| 12043 | ret = sysfs_create_group(wlan_loader->boot_wlan_obj, |
| 12044 | wlan_loader->attr_group); |
| 12045 | if (ret) { |
| 12046 | pr_err("%s: sysfs create group failed %d\n", __func__, ret); |
| 12047 | goto error_return; |
| 12048 | } |
| 12049 | |
| 12050 | return 0; |
| 12051 | |
| 12052 | error_return: |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12053 | hdd_sysfs_cleanup(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12054 | |
| 12055 | return ret; |
| 12056 | } |
| 12057 | |
| 12058 | /** |
| 12059 | * wlan_deinit_sysfs() - Removes the sysfs created to initialize the wlan |
| 12060 | * |
| 12061 | * Return: 0 on success or errno on failure |
| 12062 | */ |
| 12063 | static int wlan_deinit_sysfs(void) |
| 12064 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12065 | if (!wlan_loader) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12066 | hdd_err("wlan loader context is Null!"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12067 | return -EINVAL; |
| 12068 | } |
| 12069 | |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12070 | hdd_sysfs_cleanup(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12071 | return 0; |
| 12072 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12073 | |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12074 | #endif /* MODULE */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12075 | |
| 12076 | #ifdef MODULE |
| 12077 | /** |
| 12078 | * __hdd_module_init - Module init helper |
| 12079 | * |
| 12080 | * Module init helper function used by both module and static driver. |
| 12081 | * |
| 12082 | * Return: 0 for success, errno on failure |
| 12083 | */ |
| 12084 | static int hdd_module_init(void) |
| 12085 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12086 | if (__hdd_module_init()) { |
| 12087 | pr_err("%s: Failed to register handler\n", __func__); |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 12088 | return -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12089 | } |
| 12090 | |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 12091 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12092 | } |
| 12093 | #else |
| 12094 | static int __init hdd_module_init(void) |
| 12095 | { |
| 12096 | int ret = -EINVAL; |
| 12097 | |
| 12098 | ret = wlan_init_sysfs(); |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 12099 | if (ret) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12100 | pr_err("Failed to create sysfs entry for loading wlan"); |
| 12101 | |
| 12102 | return ret; |
| 12103 | } |
| 12104 | #endif |
| 12105 | |
| 12106 | |
| 12107 | #ifdef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12108 | /** |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12109 | * hdd_module_exit() - Exit function |
| 12110 | * |
| 12111 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 12112 | * |
| 12113 | * Return: None |
| 12114 | */ |
| 12115 | static void __exit hdd_module_exit(void) |
| 12116 | { |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12117 | __hdd_module_exit(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12118 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12119 | #else |
| 12120 | static void __exit hdd_module_exit(void) |
| 12121 | { |
| 12122 | __hdd_module_exit(); |
| 12123 | wlan_deinit_sysfs(); |
| 12124 | } |
| 12125 | #endif |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12126 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 12127 | static int fwpath_changed_handler(const char *kmessage, |
| 12128 | const struct kernel_param *kp) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12129 | { |
| 12130 | return param_set_copystring(kmessage, kp); |
| 12131 | } |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12132 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12133 | /** |
| 12134 | * is_con_mode_valid() check con mode is valid or not |
| 12135 | * @mode: global con mode |
| 12136 | * |
| 12137 | * Return: TRUE on success FALSE on failure |
| 12138 | */ |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12139 | static bool is_con_mode_valid(enum QDF_GLOBAL_MODE mode) |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12140 | { |
| 12141 | switch (mode) { |
| 12142 | case QDF_GLOBAL_MONITOR_MODE: |
| 12143 | case QDF_GLOBAL_FTM_MODE: |
| 12144 | case QDF_GLOBAL_EPPING_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12145 | case QDF_GLOBAL_MISSION_MODE: |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12146 | return true; |
| 12147 | default: |
| 12148 | return false; |
| 12149 | } |
| 12150 | } |
| 12151 | |
| 12152 | /** |
| 12153 | * hdd_get_adpter_mode() - returns adapter mode based on global con mode |
| 12154 | * @mode: global con mode |
| 12155 | * |
| 12156 | * Return: adapter mode |
| 12157 | */ |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 12158 | static enum QDF_OPMODE hdd_get_adpter_mode( |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12159 | enum QDF_GLOBAL_MODE mode) |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12160 | { |
| 12161 | |
| 12162 | switch (mode) { |
| 12163 | case QDF_GLOBAL_MISSION_MODE: |
| 12164 | return QDF_STA_MODE; |
| 12165 | case QDF_GLOBAL_MONITOR_MODE: |
| 12166 | return QDF_MONITOR_MODE; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12167 | case QDF_GLOBAL_EPPING_MODE: |
| 12168 | return QDF_EPPING_MODE; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12169 | case QDF_GLOBAL_FTM_MODE: |
| 12170 | return QDF_FTM_MODE; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12171 | case QDF_GLOBAL_QVIT_MODE: |
| 12172 | return QDF_QVIT_MODE; |
| 12173 | default: |
| 12174 | return QDF_MAX_NO_OF_MODE; |
| 12175 | } |
| 12176 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12177 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12178 | static void hdd_stop_present_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12179 | enum QDF_GLOBAL_MODE curr_mode) |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12180 | { |
| 12181 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) |
| 12182 | return; |
| 12183 | |
| 12184 | switch (curr_mode) { |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12185 | case QDF_GLOBAL_MONITOR_MODE: |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 12186 | hdd_info("Release wakelock for monitor mode!"); |
| 12187 | qdf_wake_lock_release(&hdd_ctx->monitor_mode_wakelock, |
| 12188 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 12189 | case QDF_GLOBAL_MISSION_MODE: |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12190 | case QDF_GLOBAL_FTM_MODE: |
| 12191 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
Sourav Mohapatra | 001cfaf | 2018-02-28 11:30:46 +0530 | [diff] [blame] | 12192 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->hdd_pdev, NULL); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 12193 | hdd_stop_all_adapters(hdd_ctx); |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12194 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12195 | break; |
| 12196 | default: |
| 12197 | break; |
| 12198 | } |
| 12199 | } |
| 12200 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12201 | static void hdd_cleanup_present_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12202 | enum QDF_GLOBAL_MODE curr_mode) |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12203 | { |
Ashish Kumar Dhanotiya | 0024313 | 2017-01-24 16:37:34 +0530 | [diff] [blame] | 12204 | int driver_status; |
| 12205 | |
| 12206 | driver_status = hdd_ctx->driver_status; |
| 12207 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12208 | switch (curr_mode) { |
| 12209 | case QDF_GLOBAL_MISSION_MODE: |
| 12210 | case QDF_GLOBAL_MONITOR_MODE: |
| 12211 | case QDF_GLOBAL_FTM_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12212 | hdd_deinit_all_adapters(hdd_ctx, false); |
| 12213 | hdd_close_all_adapters(hdd_ctx, false); |
| 12214 | break; |
| 12215 | case QDF_GLOBAL_EPPING_MODE: |
| 12216 | epping_disable(); |
| 12217 | epping_close(); |
| 12218 | break; |
| 12219 | default: |
| 12220 | return; |
| 12221 | } |
| 12222 | } |
| 12223 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12224 | static int hdd_register_req_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12225 | enum QDF_GLOBAL_MODE mode) |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12226 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12227 | struct hdd_adapter *adapter; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12228 | int ret = 0; |
| 12229 | bool rtnl_held; |
| 12230 | qdf_device_t qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 12231 | QDF_STATUS status; |
| 12232 | |
| 12233 | if (!qdf_dev) { |
| 12234 | hdd_err("qdf device context is Null return!"); |
| 12235 | return -EINVAL; |
| 12236 | } |
| 12237 | |
| 12238 | rtnl_held = hdd_hold_rtnl_lock(); |
| 12239 | switch (mode) { |
| 12240 | case QDF_GLOBAL_MISSION_MODE: |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 12241 | ret = hdd_open_interfaces(hdd_ctx, rtnl_held); |
| 12242 | if (ret) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12243 | hdd_err("Failed to open interfaces: %d", ret); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12244 | break; |
| 12245 | case QDF_GLOBAL_FTM_MODE: |
| 12246 | adapter = hdd_open_adapter(hdd_ctx, QDF_FTM_MODE, "wlan%d", |
| 12247 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 12248 | NET_NAME_UNKNOWN, rtnl_held); |
| 12249 | if (adapter == NULL) |
| 12250 | ret = -EINVAL; |
| 12251 | break; |
| 12252 | case QDF_GLOBAL_MONITOR_MODE: |
| 12253 | adapter = hdd_open_adapter(hdd_ctx, QDF_MONITOR_MODE, "wlan%d", |
| 12254 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 12255 | NET_NAME_UNKNOWN, rtnl_held); |
| 12256 | if (adapter == NULL) |
| 12257 | ret = -EINVAL; |
| 12258 | break; |
| 12259 | case QDF_GLOBAL_EPPING_MODE: |
| 12260 | status = epping_open(); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 12261 | if (status != QDF_STATUS_SUCCESS) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12262 | hdd_err("Failed to open in eeping mode: %d", status); |
| 12263 | ret = -EINVAL; |
| 12264 | break; |
| 12265 | } |
| 12266 | ret = epping_enable(qdf_dev->dev); |
| 12267 | if (ret) { |
| 12268 | hdd_err("Failed to enable in epping mode : %d", ret); |
| 12269 | epping_close(); |
| 12270 | } |
| 12271 | break; |
| 12272 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12273 | hdd_err("Mode not supported"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12274 | ret = -ENOTSUPP; |
| 12275 | break; |
| 12276 | } |
| 12277 | hdd_release_rtnl_lock(); |
| 12278 | rtnl_held = false; |
| 12279 | return ret; |
| 12280 | } |
| 12281 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12282 | /** |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12283 | * __con_mode_handler() - Handles module param con_mode change |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12284 | * @kmessage: con mode name on which driver to be bring up |
| 12285 | * @kp: The associated kernel parameter |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12286 | * @hdd_ctx: Pointer to the global HDD context |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12287 | * |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12288 | * This function is invoked when user updates con mode using sys entry, |
| 12289 | * to initialize and bring-up driver in that specific mode. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12290 | * |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12291 | * Return - 0 on success and failure code on failure |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12292 | */ |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 12293 | static int __con_mode_handler(const char *kmessage, |
| 12294 | const struct kernel_param *kp, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12295 | struct hdd_context *hdd_ctx) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12296 | { |
| 12297 | int ret; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12298 | struct hdd_adapter *adapter; |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12299 | enum QDF_GLOBAL_MODE curr_mode; |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 12300 | enum QDF_OPMODE adapter_mode; |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12301 | int new_con_mode; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12302 | |
Dustin Brown | ab6029b | 2017-05-24 13:04:19 -0700 | [diff] [blame] | 12303 | hdd_info("con_mode handler: %s", kmessage); |
| 12304 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12305 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 12306 | if (ret) |
| 12307 | return ret; |
| 12308 | |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 12309 | qdf_atomic_set(&hdd_ctx->con_mode_flag, 1); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12310 | cds_set_load_in_progress(true); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12311 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12312 | ret = kstrtoint(kmessage, 0, &new_con_mode); |
| 12313 | if (ret) { |
| 12314 | hdd_err("Failed to parse con_mode '%s'", kmessage); |
| 12315 | goto reset_flags; |
| 12316 | } |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 12317 | mutex_lock(&hdd_init_deinit_lock); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12318 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12319 | if (!is_con_mode_valid(new_con_mode)) { |
| 12320 | hdd_err("invalid con_mode %d", new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12321 | ret = -EINVAL; |
| 12322 | goto reset_flags; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12323 | } |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12324 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12325 | curr_mode = hdd_get_conparam(); |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12326 | if (curr_mode == new_con_mode) { |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12327 | hdd_err("curr mode: %d is same as user triggered mode %d", |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12328 | curr_mode, new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12329 | ret = 0; |
| 12330 | goto reset_flags; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12331 | } |
| 12332 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12333 | /* ensure adapters are stopped */ |
| 12334 | hdd_stop_present_mode(hdd_ctx, curr_mode); |
| 12335 | |
Frank Liu | 6666f83 | 2018-01-04 10:06:05 +0800 | [diff] [blame] | 12336 | /* Cleanup present mode before switching to new mode */ |
| 12337 | hdd_cleanup_present_mode(hdd_ctx, curr_mode); |
| 12338 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 12339 | ret = hdd_wlan_stop_modules(hdd_ctx, true); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12340 | if (ret) { |
| 12341 | hdd_err("Stop wlan modules failed"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12342 | goto reset_flags; |
| 12343 | } |
| 12344 | |
Ashish Kumar Dhanotiya | cda5766 | 2017-08-14 14:45:25 +0530 | [diff] [blame] | 12345 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12346 | hdd_set_conparam(new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12347 | |
Frank Liu | 6666f83 | 2018-01-04 10:06:05 +0800 | [diff] [blame] | 12348 | /* |
| 12349 | * Set ACTIVE domain before adapters created, otherwise check domain |
| 12350 | * match will fail when cleanup adapters. |
| 12351 | */ |
| 12352 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_ACTIVE); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12353 | /* Register for new con_mode & then kick_start modules again */ |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12354 | ret = hdd_register_req_mode(hdd_ctx, new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12355 | if (ret) { |
| 12356 | hdd_err("Failed to register for new mode"); |
| 12357 | goto reset_flags; |
| 12358 | } |
| 12359 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12360 | adapter_mode = hdd_get_adpter_mode(new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12361 | if (adapter_mode == QDF_MAX_NO_OF_MODE) { |
| 12362 | hdd_err("invalid adapter"); |
| 12363 | ret = -EINVAL; |
| 12364 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12365 | } |
| 12366 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12367 | adapter = hdd_get_adapter(hdd_ctx, adapter_mode); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12368 | if (!adapter) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12369 | hdd_err("Failed to get adapter:%d", adapter_mode); |
| 12370 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12371 | } |
| 12372 | |
| 12373 | ret = hdd_wlan_start_modules(hdd_ctx, adapter, false); |
| 12374 | if (ret) { |
| 12375 | hdd_err("Start wlan modules failed: %d", ret); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12376 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12377 | } |
| 12378 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12379 | if (new_con_mode == QDF_GLOBAL_MONITOR_MODE) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12380 | if (hdd_start_adapter(adapter)) { |
| 12381 | hdd_err("Failed to start %s adapter", kmessage); |
| 12382 | ret = -EINVAL; |
| 12383 | goto reset_flags; |
| 12384 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12385 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 12386 | hdd_info("Acquire wakelock for monitor mode!"); |
| 12387 | qdf_wake_lock_acquire(&hdd_ctx->monitor_mode_wakelock, |
| 12388 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 12389 | } |
| 12390 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12391 | /* con_mode is a global module parameter */ |
| 12392 | con_mode = new_con_mode; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12393 | hdd_info("Mode successfully changed to %s", kmessage); |
| 12394 | ret = 0; |
| 12395 | |
| 12396 | reset_flags: |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 12397 | mutex_unlock(&hdd_init_deinit_lock); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12398 | cds_set_load_in_progress(false); |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 12399 | qdf_atomic_set(&hdd_ctx->con_mode_flag, 0); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12400 | return ret; |
| 12401 | } |
| 12402 | |
| 12403 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 12404 | static int con_mode_handler(const char *kmessage, const struct kernel_param *kp) |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12405 | { |
| 12406 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12407 | struct hdd_context *hdd_ctx; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12408 | |
| 12409 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 12410 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 12411 | if (ret) |
| 12412 | return ret; |
| 12413 | |
| 12414 | cds_ssr_protect(__func__); |
| 12415 | ret = __con_mode_handler(kmessage, kp, hdd_ctx); |
| 12416 | cds_ssr_unprotect(__func__); |
| 12417 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12418 | return ret; |
| 12419 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12420 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 12421 | static int con_mode_handler_ftm(const char *kmessage, |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 12422 | const struct kernel_param *kp) |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 12423 | { |
| 12424 | int ret; |
| 12425 | |
| 12426 | ret = param_set_int(kmessage, kp); |
| 12427 | |
| 12428 | if (con_mode_ftm != QDF_GLOBAL_FTM_MODE) { |
| 12429 | pr_err("Only FTM mode supported!"); |
| 12430 | return -ENOTSUPP; |
| 12431 | } |
| 12432 | |
| 12433 | hdd_set_conparam(con_mode_ftm); |
| 12434 | con_mode = con_mode_ftm; |
| 12435 | |
| 12436 | return ret; |
| 12437 | } |
| 12438 | |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 12439 | static int con_mode_handler_monitor(const char *kmessage, |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 12440 | const struct kernel_param *kp) |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 12441 | { |
| 12442 | int ret; |
| 12443 | |
| 12444 | ret = param_set_int(kmessage, kp); |
| 12445 | |
| 12446 | if (con_mode_monitor != QDF_GLOBAL_MONITOR_MODE) { |
| 12447 | pr_err("Only Monitor mode supported!"); |
| 12448 | return -ENOTSUPP; |
| 12449 | } |
| 12450 | |
| 12451 | hdd_set_conparam(con_mode_monitor); |
| 12452 | con_mode = con_mode_monitor; |
| 12453 | |
| 12454 | return ret; |
| 12455 | } |
| 12456 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12457 | /** |
| 12458 | * hdd_get_conparam() - driver exit point |
| 12459 | * |
| 12460 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 12461 | * |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12462 | * Return: enum QDF_GLOBAL_MODE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12463 | */ |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12464 | enum QDF_GLOBAL_MODE hdd_get_conparam(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12465 | { |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12466 | return (enum QDF_GLOBAL_MODE) curr_con_mode; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12467 | } |
| 12468 | |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 12469 | void hdd_set_conparam(uint32_t con_param) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12470 | { |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 12471 | curr_con_mode = con_param; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12472 | } |
| 12473 | |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12474 | /** |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 12475 | * hdd_clean_up_pre_cac_interface() - Clean up the pre cac interface |
| 12476 | * @hdd_ctx: HDD context |
| 12477 | * |
| 12478 | * Cleans up the pre cac interface, if it exists |
| 12479 | * |
| 12480 | * Return: None |
| 12481 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12482 | void hdd_clean_up_pre_cac_interface(struct hdd_context *hdd_ctx) |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 12483 | { |
| 12484 | uint8_t session_id; |
| 12485 | QDF_STATUS status; |
Jeff Johnson | 85b5c11 | 2017-08-11 15:15:23 -0700 | [diff] [blame] | 12486 | struct hdd_adapter *precac_adapter; |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 12487 | |
| 12488 | status = wlan_sap_get_pre_cac_vdev_id(hdd_ctx->hHal, &session_id); |
| 12489 | if (QDF_IS_STATUS_ERROR(status)) { |
| 12490 | hdd_err("failed to get pre cac vdev id"); |
| 12491 | return; |
| 12492 | } |
| 12493 | |
| 12494 | precac_adapter = hdd_get_adapter_by_vdev(hdd_ctx, session_id); |
| 12495 | if (!precac_adapter) { |
| 12496 | hdd_err("invalid pre cac adapater"); |
| 12497 | return; |
| 12498 | } |
| 12499 | |
| 12500 | qdf_create_work(0, &hdd_ctx->sap_pre_cac_work, |
| 12501 | wlan_hdd_sap_pre_cac_failure, |
| 12502 | (void *)precac_adapter); |
| 12503 | qdf_sched_work(0, &hdd_ctx->sap_pre_cac_work); |
| 12504 | |
| 12505 | } |
| 12506 | |
| 12507 | /** |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12508 | * hdd_update_ol_config - API to update ol configuration parameters |
| 12509 | * @hdd_ctx: HDD context |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12510 | * |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12511 | * Return: void |
| 12512 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12513 | static void hdd_update_ol_config(struct hdd_context *hdd_ctx) |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12514 | { |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12515 | struct ol_config_info cfg; |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 12516 | struct ol_context *ol_ctx = cds_get_context(QDF_MODULE_ID_BMI); |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12517 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12518 | if (!ol_ctx) |
| 12519 | return; |
| 12520 | |
| 12521 | cfg.enable_self_recovery = hdd_ctx->config->enableSelfRecovery; |
| 12522 | cfg.enable_uart_print = hdd_ctx->config->enablefwprint; |
| 12523 | cfg.enable_fw_log = hdd_ctx->config->enable_fw_log; |
| 12524 | cfg.enable_ramdump_collection = hdd_ctx->config->is_ramdump_enabled; |
Jeff Johnson | b8bf907 | 2016-09-23 17:39:27 -0700 | [diff] [blame] | 12525 | cfg.enable_lpass_support = hdd_lpass_is_supported(hdd_ctx); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12526 | |
| 12527 | ol_init_ini_config(ol_ctx, &cfg); |
| 12528 | } |
| 12529 | |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 12530 | #ifdef FEATURE_RUNTIME_PM |
| 12531 | /** |
| 12532 | * hdd_populate_runtime_cfg() - populate runtime configuration |
| 12533 | * @hdd_ctx: hdd context |
| 12534 | * @cfg: pointer to the configuration memory being populated |
| 12535 | * |
| 12536 | * Return: void |
| 12537 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12538 | static void hdd_populate_runtime_cfg(struct hdd_context *hdd_ctx, |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 12539 | struct hif_config_info *cfg) |
| 12540 | { |
| 12541 | cfg->enable_runtime_pm = hdd_ctx->config->runtime_pm; |
| 12542 | cfg->runtime_pm_delay = hdd_ctx->config->runtime_pm_delay; |
| 12543 | } |
| 12544 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12545 | static void hdd_populate_runtime_cfg(struct hdd_context *hdd_ctx, |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 12546 | struct hif_config_info *cfg) |
| 12547 | { |
| 12548 | } |
| 12549 | #endif |
| 12550 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12551 | /** |
| 12552 | * hdd_update_hif_config - API to update HIF configuration parameters |
| 12553 | * @hdd_ctx: HDD Context |
| 12554 | * |
| 12555 | * Return: void |
| 12556 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12557 | static void hdd_update_hif_config(struct hdd_context *hdd_ctx) |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12558 | { |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 12559 | struct hif_opaque_softc *scn = cds_get_context(QDF_MODULE_ID_HIF); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12560 | struct hif_config_info cfg; |
| 12561 | |
| 12562 | if (!scn) |
| 12563 | return; |
| 12564 | |
| 12565 | cfg.enable_self_recovery = hdd_ctx->config->enableSelfRecovery; |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 12566 | hdd_populate_runtime_cfg(hdd_ctx, &cfg); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12567 | hif_init_ini_config(scn, &cfg); |
Dustin Brown | ee3e059 | 2017-09-07 13:50:11 -0700 | [diff] [blame] | 12568 | |
| 12569 | if (hdd_ctx->config->prevent_link_down) |
| 12570 | hif_vote_link_up(scn); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12571 | } |
| 12572 | |
| 12573 | /** |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 12574 | * hdd_update_dp_config() - Propagate config parameters to Lithium |
| 12575 | * datapath |
| 12576 | * @hdd_ctx: HDD Context |
| 12577 | * |
| 12578 | * Return: 0 for success/errno for failure |
| 12579 | */ |
| 12580 | static int hdd_update_dp_config(struct hdd_context *hdd_ctx) |
| 12581 | { |
| 12582 | struct cdp_config_params params; |
| 12583 | QDF_STATUS status; |
| 12584 | |
| 12585 | params.tso_enable = hdd_ctx->config->tso_enable; |
| 12586 | params.lro_enable = hdd_ctx->config->lro_enable; |
| 12587 | #ifdef QCA_LL_TX_FLOW_CONTROL_V2 |
| 12588 | params.tx_flow_stop_queue_threshold = |
| 12589 | hdd_ctx->config->TxFlowStopQueueThreshold; |
| 12590 | params.tx_flow_start_queue_offset = |
| 12591 | hdd_ctx->config->TxFlowStartQueueOffset; |
| 12592 | #endif |
| 12593 | params.flow_steering_enable = hdd_ctx->config->flow_steering_enable; |
| 12594 | params.napi_enable = hdd_ctx->napi_enable; |
| 12595 | params.tcp_udp_checksumoffload = |
| 12596 | hdd_ctx->config->enable_ip_tcp_udp_checksum_offload; |
| 12597 | |
| 12598 | status = cdp_update_config_parameters( |
| 12599 | cds_get_context(QDF_MODULE_ID_SOC), |
| 12600 | ¶ms); |
| 12601 | if (status) { |
Dustin Brown | a286862 | 2018-03-20 11:38:14 -0700 | [diff] [blame] | 12602 | hdd_err("Failed to attach config parameters"); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 12603 | return status; |
| 12604 | } |
| 12605 | |
| 12606 | return 0; |
| 12607 | } |
| 12608 | |
| 12609 | /** |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12610 | * hdd_update_config() - Initialize driver per module ini parameters |
| 12611 | * @hdd_ctx: HDD Context |
| 12612 | * |
| 12613 | * API is used to initialize all driver per module configuration parameters |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 12614 | * Return: 0 for success, errno for failure |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12615 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12616 | int hdd_update_config(struct hdd_context *hdd_ctx) |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12617 | { |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 12618 | int ret; |
| 12619 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12620 | hdd_update_ol_config(hdd_ctx); |
| 12621 | hdd_update_hif_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 12622 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
| 12623 | ret = hdd_update_cds_config_ftm(hdd_ctx); |
| 12624 | else |
| 12625 | ret = hdd_update_cds_config(hdd_ctx); |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 12626 | ret = hdd_update_user_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 12627 | |
| 12628 | return ret; |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12629 | } |
| 12630 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12631 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 12632 | /** |
| 12633 | * hdd_ra_populate_cds_config() - Populate RA filtering cds configuration |
| 12634 | * @psoc_cfg: pmo psoc Configuration |
| 12635 | * @hdd_ctx: Pointer to hdd context |
| 12636 | * |
| 12637 | * Return: none |
| 12638 | */ |
| 12639 | static inline void hdd_ra_populate_pmo_config( |
| 12640 | struct pmo_psoc_cfg *psoc_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12641 | struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12642 | { |
| 12643 | psoc_cfg->ra_ratelimit_interval = |
| 12644 | hdd_ctx->config->RArateLimitInterval; |
| 12645 | psoc_cfg->ra_ratelimit_enable = |
| 12646 | hdd_ctx->config->IsRArateLimitEnabled; |
| 12647 | } |
| 12648 | #else |
| 12649 | static inline void hdd_ra_populate_pmo_config( |
| 12650 | struct cds_config_info *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12651 | struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12652 | { |
| 12653 | } |
| 12654 | #endif |
Will Huang | 3cd2b7c | 2017-11-17 13:16:56 +0800 | [diff] [blame] | 12655 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12656 | /** |
| 12657 | * hdd_update_pmo_config - API to update pmo configuration parameters |
| 12658 | * @hdd_ctx: HDD context |
| 12659 | * |
| 12660 | * Return: void |
| 12661 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12662 | static int hdd_update_pmo_config(struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12663 | { |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12664 | struct pmo_psoc_cfg psoc_cfg; |
| 12665 | QDF_STATUS status; |
| 12666 | |
| 12667 | /* |
| 12668 | * Value of hdd_ctx->wowEnable can be, |
| 12669 | * 0 - Disable both magic pattern match and pattern byte match. |
| 12670 | * 1 - Enable magic pattern match on all interfaces. |
| 12671 | * 2 - Enable pattern byte match on all interfaces. |
| 12672 | * 3 - Enable both magic patter and pattern byte match on |
| 12673 | * all interfaces. |
| 12674 | */ |
| 12675 | psoc_cfg.magic_ptrn_enable = |
| 12676 | (hdd_ctx->config->wowEnable & 0x01) ? true : false; |
| 12677 | psoc_cfg.ptrn_match_enable_all_vdev = |
| 12678 | (hdd_ctx->config->wowEnable & 0x02) ? true : false; |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 12679 | psoc_cfg.ptrn_id_per_vdev = |
| 12680 | wma_is_service_enabled(wmi_service_unified_wow_capability); |
| 12681 | psoc_cfg.apf_enable = hdd_ctx->config->bpf_packet_filter_enable; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12682 | psoc_cfg.arp_offload_enable = hdd_ctx->config->fhostArpOffload; |
Dustin Brown | 1224e21 | 2017-05-12 14:02:12 -0700 | [diff] [blame] | 12683 | psoc_cfg.hw_filter_mode = hdd_ctx->config->hw_filter_mode; |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 12684 | psoc_cfg.ns_offload_enable_dynamic = hdd_ctx->config->fhostNSOffload; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12685 | psoc_cfg.ns_offload_enable_static = hdd_ctx->config->fhostNSOffload; |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 12686 | psoc_cfg.packet_filter_enabled = !hdd_ctx->config->disablePacketFilter; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12687 | psoc_cfg.ssdp = hdd_ctx->config->ssdp; |
| 12688 | psoc_cfg.enable_mc_list = hdd_ctx->config->fEnableMCAddrList; |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 12689 | psoc_cfg.active_mode_offload = hdd_ctx->config->active_mode_offload; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12690 | psoc_cfg.ap_arpns_support = hdd_ctx->ap_arpns_support; |
Will Huang | 3cd2b7c | 2017-11-17 13:16:56 +0800 | [diff] [blame] | 12691 | psoc_cfg.d0_wow_supported = wma_d0_wow_is_supported(); |
Mukul Sharma | 9223f23 | 2017-03-08 18:42:27 +0530 | [diff] [blame] | 12692 | psoc_cfg.sta_dynamic_dtim = hdd_ctx->config->enableDynamicDTIM; |
| 12693 | psoc_cfg.sta_mod_dtim = hdd_ctx->config->enableModulatedDTIM; |
| 12694 | psoc_cfg.sta_max_li_mod_dtim = hdd_ctx->config->fMaxLIModulatedDTIM; |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 12695 | psoc_cfg.power_save_mode = hdd_ctx->config->enablePowersaveOffload; |
Ravi Kumar Bokka | 05c14e5 | 2017-03-27 14:48:23 +0530 | [diff] [blame] | 12696 | psoc_cfg.auto_power_save_fail_mode = |
| 12697 | hdd_ctx->config->auto_pwr_save_fail_mode; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12698 | |
| 12699 | hdd_ra_populate_pmo_config(&psoc_cfg, hdd_ctx); |
Mukul Sharma | 9223f23 | 2017-03-08 18:42:27 +0530 | [diff] [blame] | 12700 | hdd_nan_populate_pmo_config(&psoc_cfg, hdd_ctx); |
| 12701 | hdd_lpass_populate_pmo_config(&psoc_cfg, hdd_ctx); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12702 | |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 12703 | status = ucfg_pmo_update_psoc_config(hdd_ctx->hdd_psoc, &psoc_cfg); |
| 12704 | if (QDF_IS_STATUS_ERROR(status)) |
| 12705 | hdd_err("failed pmo psoc configuration; status:%d", status); |
| 12706 | |
| 12707 | return qdf_status_to_os_return(status); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12708 | } |
| 12709 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12710 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 12711 | static inline void hdd_update_pno_config(struct pno_user_cfg *pno_cfg, |
| 12712 | struct hdd_config *cfg) |
| 12713 | { |
Varun Reddy Yeturu | bba32e9 | 2017-09-06 13:31:40 -0700 | [diff] [blame] | 12714 | struct nlo_mawc_params *mawc_cfg = &pno_cfg->mawc_params; |
| 12715 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12716 | pno_cfg->channel_prediction = cfg->pno_channel_prediction; |
| 12717 | pno_cfg->top_k_num_of_channels = cfg->top_k_num_of_channels; |
| 12718 | pno_cfg->stationary_thresh = cfg->stationary_thresh; |
| 12719 | pno_cfg->adaptive_dwell_mode = cfg->adaptive_dwell_mode_enabled; |
| 12720 | pno_cfg->channel_prediction_full_scan = |
| 12721 | cfg->channel_prediction_full_scan; |
Varun Reddy Yeturu | bba32e9 | 2017-09-06 13:31:40 -0700 | [diff] [blame] | 12722 | mawc_cfg->enable = cfg->MAWCEnabled && cfg->mawc_nlo_enabled; |
| 12723 | mawc_cfg->exp_backoff_ratio = cfg->mawc_nlo_exp_backoff_ratio; |
| 12724 | mawc_cfg->init_scan_interval = cfg->mawc_nlo_init_scan_interval; |
| 12725 | mawc_cfg->max_scan_interval = cfg->mawc_nlo_max_scan_interval; |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12726 | } |
| 12727 | #else |
| 12728 | static inline void |
| 12729 | hdd_update_pno_config(struct pno_user_cfg *pno_cfg, |
Jeff Johnson | 33a0792 | 2017-10-05 09:08:46 -0700 | [diff] [blame] | 12730 | struct hdd_config *cfg) |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12731 | { |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12732 | } |
| 12733 | #endif |
| 12734 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 12735 | void hdd_update_ie_whitelist_attr(struct probe_req_whitelist_attr *ie_whitelist, |
| 12736 | struct hdd_config *cfg) |
| 12737 | { |
| 12738 | uint8_t i = 0; |
| 12739 | |
| 12740 | ie_whitelist->white_list = cfg->probe_req_ie_whitelist; |
| 12741 | if (!ie_whitelist->white_list) |
| 12742 | return; |
| 12743 | |
| 12744 | ie_whitelist->ie_bitmap[0] = cfg->probe_req_ie_bitmap_0; |
| 12745 | ie_whitelist->ie_bitmap[1] = cfg->probe_req_ie_bitmap_1; |
| 12746 | ie_whitelist->ie_bitmap[2] = cfg->probe_req_ie_bitmap_2; |
| 12747 | ie_whitelist->ie_bitmap[3] = cfg->probe_req_ie_bitmap_3; |
| 12748 | ie_whitelist->ie_bitmap[4] = cfg->probe_req_ie_bitmap_4; |
| 12749 | ie_whitelist->ie_bitmap[5] = cfg->probe_req_ie_bitmap_5; |
| 12750 | ie_whitelist->ie_bitmap[6] = cfg->probe_req_ie_bitmap_6; |
| 12751 | ie_whitelist->ie_bitmap[7] = cfg->probe_req_ie_bitmap_7; |
| 12752 | |
| 12753 | ie_whitelist->num_vendor_oui = cfg->no_of_probe_req_ouis; |
| 12754 | for (i = 0; i < ie_whitelist->num_vendor_oui; i++) |
| 12755 | ie_whitelist->voui[i] = cfg->probe_req_voui[i]; |
| 12756 | } |
| 12757 | |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 12758 | uint32_t hdd_limit_max_per_index_score(uint32_t per_index_score) |
| 12759 | { |
| 12760 | uint8_t i, score; |
| 12761 | |
| 12762 | for (i = 0; i < MAX_INDEX_PER_INI; i++) { |
| 12763 | score = WLAN_GET_SCORE_PERCENTAGE(per_index_score, i); |
| 12764 | if (score > MAX_INDEX_SCORE) |
| 12765 | WLAN_SET_SCORE_PERCENTAGE(per_index_score, |
| 12766 | MAX_INDEX_SCORE, i); |
| 12767 | } |
| 12768 | |
| 12769 | return per_index_score; |
| 12770 | } |
| 12771 | |
| 12772 | /** |
| 12773 | * hdd_update_score_config - API to update candidate scoring related params |
| 12774 | * configuration parameters |
| 12775 | * @score_config: score config to update |
| 12776 | * @cfg: config params |
| 12777 | * |
| 12778 | * Return: 0 if success else err |
| 12779 | */ |
| 12780 | static void hdd_update_score_config( |
| 12781 | struct scoring_config *score_config, struct hdd_config *cfg) |
| 12782 | { |
| 12783 | int total_weight; |
| 12784 | |
| 12785 | score_config->weight_cfg.rssi_weightage = cfg->rssi_weightage; |
| 12786 | score_config->weight_cfg.ht_caps_weightage = cfg->ht_caps_weightage; |
| 12787 | score_config->weight_cfg.vht_caps_weightage = |
| 12788 | cfg->vht_caps_weightage; |
| 12789 | score_config->weight_cfg.he_caps_weightage = |
| 12790 | cfg->he_caps_weightage; |
| 12791 | score_config->weight_cfg.chan_width_weightage = |
| 12792 | cfg->chan_width_weightage; |
| 12793 | score_config->weight_cfg.chan_band_weightage = |
| 12794 | cfg->chan_band_weightage; |
| 12795 | score_config->weight_cfg.nss_weightage = cfg->nss_weightage; |
| 12796 | score_config->weight_cfg.beamforming_cap_weightage = |
| 12797 | cfg->beamforming_cap_weightage; |
| 12798 | score_config->weight_cfg.pcl_weightage = cfg->pcl_weightage; |
| 12799 | score_config->weight_cfg.channel_congestion_weightage = |
| 12800 | cfg->channel_congestion_weightage; |
| 12801 | score_config->weight_cfg.oce_wan_weightage = cfg->oce_wan_weightage; |
| 12802 | |
| 12803 | total_weight = score_config->weight_cfg.rssi_weightage + |
| 12804 | score_config->weight_cfg.ht_caps_weightage + |
| 12805 | score_config->weight_cfg.vht_caps_weightage + |
| 12806 | score_config->weight_cfg.he_caps_weightage + |
| 12807 | score_config->weight_cfg.chan_width_weightage + |
| 12808 | score_config->weight_cfg.chan_band_weightage + |
| 12809 | score_config->weight_cfg.nss_weightage + |
| 12810 | score_config->weight_cfg.beamforming_cap_weightage + |
| 12811 | score_config->weight_cfg.pcl_weightage + |
| 12812 | score_config->weight_cfg.channel_congestion_weightage + |
| 12813 | score_config->weight_cfg.oce_wan_weightage; |
| 12814 | |
| 12815 | if (total_weight > BEST_CANDIDATE_MAX_WEIGHT) { |
| 12816 | hdd_err("total weight is greater than %d fallback to default values", |
| 12817 | BEST_CANDIDATE_MAX_WEIGHT); |
| 12818 | |
| 12819 | score_config->weight_cfg.rssi_weightage = RSSI_WEIGHTAGE; |
| 12820 | score_config->weight_cfg.ht_caps_weightage = |
| 12821 | HT_CAPABILITY_WEIGHTAGE; |
| 12822 | score_config->weight_cfg.vht_caps_weightage = VHT_CAP_WEIGHTAGE; |
| 12823 | score_config->weight_cfg.he_caps_weightage = HE_CAP_WEIGHTAGE; |
| 12824 | score_config->weight_cfg.chan_width_weightage = |
| 12825 | CHAN_WIDTH_WEIGHTAGE; |
| 12826 | score_config->weight_cfg.chan_band_weightage = |
| 12827 | CHAN_BAND_WEIGHTAGE; |
| 12828 | score_config->weight_cfg.nss_weightage = NSS_WEIGHTAGE; |
| 12829 | score_config->weight_cfg.beamforming_cap_weightage = |
| 12830 | BEAMFORMING_CAP_WEIGHTAGE; |
| 12831 | score_config->weight_cfg.pcl_weightage = PCL_WEIGHT; |
| 12832 | score_config->weight_cfg.channel_congestion_weightage = |
| 12833 | CHANNEL_CONGESTION_WEIGHTAGE; |
| 12834 | score_config->weight_cfg.oce_wan_weightage = OCE_WAN_WEIGHTAGE; |
| 12835 | } |
| 12836 | |
| 12837 | score_config->bandwidth_weight_per_index = |
| 12838 | hdd_limit_max_per_index_score( |
| 12839 | cfg->bandwidth_weight_per_index); |
| 12840 | score_config->nss_weight_per_index = |
| 12841 | hdd_limit_max_per_index_score(cfg->nss_weight_per_index); |
| 12842 | score_config->band_weight_per_index = |
| 12843 | hdd_limit_max_per_index_score(cfg->band_weight_per_index); |
| 12844 | |
| 12845 | score_config->rssi_score.best_rssi_threshold = |
| 12846 | cfg->best_rssi_threshold; |
| 12847 | score_config->rssi_score.good_rssi_threshold = |
| 12848 | cfg->good_rssi_threshold; |
| 12849 | score_config->rssi_score.bad_rssi_threshold = |
| 12850 | cfg->bad_rssi_threshold; |
| 12851 | score_config->rssi_score.good_rssi_pcnt = cfg->good_rssi_pcnt; |
| 12852 | score_config->rssi_score.bad_rssi_pcnt = cfg->bad_rssi_pcnt; |
| 12853 | score_config->rssi_score.good_rssi_bucket_size = |
| 12854 | cfg->good_rssi_bucket_size; |
| 12855 | score_config->rssi_score.bad_rssi_bucket_size = |
| 12856 | cfg->bad_rssi_bucket_size; |
| 12857 | score_config->rssi_score.rssi_pref_5g_rssi_thresh = |
| 12858 | cfg->rssi_pref_5g_rssi_thresh; |
| 12859 | |
| 12860 | score_config->esp_qbss_scoring.num_slot = cfg->num_esp_qbss_slots; |
| 12861 | score_config->esp_qbss_scoring.score_pcnt3_to_0 = |
| 12862 | hdd_limit_max_per_index_score( |
| 12863 | cfg->esp_qbss_score_slots3_to_0); |
| 12864 | score_config->esp_qbss_scoring.score_pcnt7_to_4 = |
| 12865 | hdd_limit_max_per_index_score( |
| 12866 | cfg->esp_qbss_score_slots7_to_4); |
| 12867 | score_config->esp_qbss_scoring.score_pcnt11_to_8 = |
| 12868 | hdd_limit_max_per_index_score( |
| 12869 | cfg->esp_qbss_score_slots11_to_8); |
| 12870 | score_config->esp_qbss_scoring.score_pcnt15_to_12 = |
| 12871 | hdd_limit_max_per_index_score( |
| 12872 | cfg->esp_qbss_score_slots15_to_12); |
| 12873 | |
| 12874 | score_config->oce_wan_scoring.num_slot = cfg->num_oce_wan_slots; |
| 12875 | score_config->oce_wan_scoring.score_pcnt3_to_0 = |
| 12876 | hdd_limit_max_per_index_score( |
| 12877 | cfg->oce_wan_score_slots3_to_0); |
| 12878 | score_config->oce_wan_scoring.score_pcnt7_to_4 = |
| 12879 | hdd_limit_max_per_index_score( |
| 12880 | cfg->oce_wan_score_slots7_to_4); |
| 12881 | score_config->oce_wan_scoring.score_pcnt11_to_8 = |
| 12882 | hdd_limit_max_per_index_score( |
| 12883 | cfg->oce_wan_score_slots11_to_8); |
| 12884 | score_config->oce_wan_scoring.score_pcnt15_to_12 = |
| 12885 | hdd_limit_max_per_index_score( |
| 12886 | cfg->oce_wan_score_slots15_to_12); |
| 12887 | |
| 12888 | |
| 12889 | score_config->cb_mode_24G = cfg->nChannelBondingMode24GHz; |
| 12890 | score_config->cb_mode_5G = cfg->nChannelBondingMode5GHz; |
| 12891 | score_config->nss = cfg->enable2x2 ? 2 : 1; |
| 12892 | |
| 12893 | if (cfg->dot11Mode == eHDD_DOT11_MODE_AUTO || |
| 12894 | cfg->dot11Mode == eHDD_DOT11_MODE_11ax || |
| 12895 | cfg->dot11Mode == eHDD_DOT11_MODE_11ax_ONLY) |
| 12896 | score_config->he_cap = 1; |
| 12897 | |
| 12898 | if (score_config->he_cap || |
| 12899 | cfg->dot11Mode == eHDD_DOT11_MODE_11ac || |
| 12900 | cfg->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY) |
| 12901 | score_config->vht_cap = 1; |
| 12902 | |
| 12903 | if (score_config->vht_cap || cfg->dot11Mode == eHDD_DOT11_MODE_11n || |
| 12904 | cfg->dot11Mode == eHDD_DOT11_MODE_11n_ONLY) |
| 12905 | score_config->ht_cap = 1; |
| 12906 | |
| 12907 | if (score_config->vht_cap && cfg->enableVhtFor24GHzBand) |
| 12908 | score_config->vht_24G_cap = 1; |
| 12909 | |
| 12910 | if (cfg->enableTxBF) |
| 12911 | score_config->beamformee_cap = 1; |
| 12912 | |
| 12913 | } |
| 12914 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12915 | /** |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 12916 | * hdd_update_dfs_config() - API to update dfs configuration parameters. |
| 12917 | * @hdd_ctx: HDD context |
| 12918 | * |
| 12919 | * Return: 0 if success else err |
| 12920 | */ |
| 12921 | static int hdd_update_dfs_config(struct hdd_context *hdd_ctx) |
| 12922 | { |
| 12923 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 12924 | struct hdd_config *cfg = hdd_ctx->config; |
| 12925 | struct dfs_user_config dfs_cfg; |
| 12926 | QDF_STATUS status; |
| 12927 | |
| 12928 | dfs_cfg.dfs_is_phyerr_filter_offload = !!cfg->fDfsPhyerrFilterOffload; |
| 12929 | status = ucfg_dfs_update_config(psoc, &dfs_cfg); |
| 12930 | if (QDF_IS_STATUS_ERROR(status)) { |
| 12931 | hdd_err("failed dfs psoc configuration"); |
| 12932 | return -EINVAL; |
| 12933 | } |
| 12934 | |
| 12935 | return 0; |
| 12936 | } |
| 12937 | |
| 12938 | /** |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12939 | * hdd_update_scan_config - API to update scan configuration parameters |
| 12940 | * @hdd_ctx: HDD context |
| 12941 | * |
| 12942 | * Return: 0 if success else err |
| 12943 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12944 | static int hdd_update_scan_config(struct hdd_context *hdd_ctx) |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12945 | { |
| 12946 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 12947 | struct scan_user_cfg scan_cfg; |
| 12948 | struct hdd_config *cfg = hdd_ctx->config; |
| 12949 | QDF_STATUS status; |
| 12950 | |
| 12951 | scan_cfg.active_dwell = cfg->nActiveMaxChnTime; |
| 12952 | scan_cfg.passive_dwell = cfg->nPassiveMaxChnTime; |
| 12953 | scan_cfg.conc_active_dwell = cfg->nActiveMaxChnTimeConc; |
| 12954 | scan_cfg.conc_passive_dwell = cfg->nPassiveMaxChnTimeConc; |
| 12955 | scan_cfg.conc_max_rest_time = cfg->nRestTimeConc; |
| 12956 | scan_cfg.conc_min_rest_time = cfg->min_rest_time_conc; |
| 12957 | scan_cfg.conc_idle_time = cfg->idle_time_conc; |
Abhishek Singh | 158fe25 | 2017-03-23 11:09:34 +0530 | [diff] [blame] | 12958 | /* convert to ms */ |
| 12959 | scan_cfg.scan_cache_aging_time = |
| 12960 | cfg->scanAgingTimeout * 1000; |
| 12961 | scan_cfg.prefer_5ghz = cfg->nRoamPrefer5GHz; |
| 12962 | scan_cfg.select_5ghz_margin = cfg->nSelect5GHzMargin; |
| 12963 | scan_cfg.scan_bucket_threshold = cfg->first_scan_bucket_threshold; |
| 12964 | scan_cfg.rssi_cat_gap = cfg->nRssiCatGap; |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12965 | scan_cfg.scan_dwell_time_mode = cfg->scan_adaptive_dwell_mode; |
Kapil Gupta | fa9a8c6 | 2017-04-10 15:25:40 +0530 | [diff] [blame] | 12966 | scan_cfg.is_snr_monitoring_enabled = cfg->fEnableSNRMonitoring; |
Jeff Johnson | 81c00d0 | 2017-11-07 12:34:36 -0800 | [diff] [blame] | 12967 | scan_cfg.usr_cfg_probe_rpt_time = cfg->scan_probe_repeat_time; |
| 12968 | scan_cfg.usr_cfg_num_probes = cfg->scan_num_probes; |
Abhishek Singh | b58164a | 2017-07-19 18:47:23 +0530 | [diff] [blame] | 12969 | scan_cfg.is_bssid_hint_priority = cfg->is_bssid_hint_priority; |
Kiran Kumar Lokere | d547fdd | 2017-09-13 17:20:55 -0700 | [diff] [blame] | 12970 | scan_cfg.enable_mac_spoofing = cfg->enable_mac_spoofing; |
Abhishek Singh | c87bb04 | 2018-01-30 17:10:42 +0530 | [diff] [blame] | 12971 | scan_cfg.sta_miracast_mcc_rest_time = |
| 12972 | cfg->sta_miracast_mcc_rest_time_val; |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12973 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12974 | hdd_update_pno_config(&scan_cfg.pno_cfg, cfg); |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 12975 | hdd_update_ie_whitelist_attr(&scan_cfg.ie_whitelist, cfg); |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 12976 | hdd_update_score_config(&scan_cfg.score_config, cfg); |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12977 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12978 | status = ucfg_scan_update_user_config(psoc, &scan_cfg); |
| 12979 | if (status != QDF_STATUS_SUCCESS) { |
| 12980 | hdd_err("failed pmo psoc configuration"); |
| 12981 | return -EINVAL; |
| 12982 | } |
| 12983 | |
| 12984 | return 0; |
| 12985 | } |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12986 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12987 | int hdd_update_components_config(struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12988 | { |
| 12989 | int ret; |
| 12990 | |
| 12991 | ret = hdd_update_pmo_config(hdd_ctx); |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12992 | if (ret) |
| 12993 | return ret; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 12994 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12995 | ret = hdd_update_scan_config(hdd_ctx); |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 12996 | if (ret) |
| 12997 | return ret; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 12998 | |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 12999 | ret = hdd_update_tdls_config(hdd_ctx); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 13000 | if (ret) |
| 13001 | return ret; |
| 13002 | |
| 13003 | ret = hdd_update_dp_config(hdd_ctx); |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 13004 | if (ret) |
| 13005 | return ret; |
| 13006 | |
| 13007 | ret = hdd_update_dfs_config(hdd_ctx); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13008 | |
| 13009 | return ret; |
| 13010 | } |
| 13011 | |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 13012 | /** |
| 13013 | * wlan_hdd_get_dfs_mode() - get ACS DFS mode |
| 13014 | * @mode : cfg80211 DFS mode |
| 13015 | * |
| 13016 | * Return: return SAP ACS DFS mode else return ACS_DFS_MODE_NONE |
| 13017 | */ |
| 13018 | enum sap_acs_dfs_mode wlan_hdd_get_dfs_mode(enum dfs_mode mode) |
| 13019 | { |
| 13020 | switch (mode) { |
| 13021 | case DFS_MODE_ENABLE: |
| 13022 | return ACS_DFS_MODE_ENABLE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 13023 | case DFS_MODE_DISABLE: |
| 13024 | return ACS_DFS_MODE_DISABLE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 13025 | case DFS_MODE_DEPRIORITIZE: |
| 13026 | return ACS_DFS_MODE_DEPRIORITIZE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 13027 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 13028 | hdd_debug("ACS dfs mode is NONE"); |
| 13029 | return ACS_DFS_MODE_NONE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 13030 | } |
| 13031 | } |
| 13032 | |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 13033 | /** |
| 13034 | * hdd_enable_disable_ca_event() - enable/disable channel avoidance event |
| 13035 | * @hddctx: pointer to hdd context |
| 13036 | * @set_value: enable/disable |
| 13037 | * |
| 13038 | * When Host sends vendor command enable, FW will send *ONE* CA ind to |
| 13039 | * Host(even though it is duplicate). When Host send vendor command |
| 13040 | * disable,FW doesn't perform any action. Whenever any change in |
| 13041 | * CA *and* WLAN is in SAP/P2P-GO mode, FW sends CA ind to host. |
| 13042 | * |
| 13043 | * return - 0 on success, appropriate error values on failure. |
| 13044 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13045 | 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] | 13046 | { |
| 13047 | QDF_STATUS status; |
| 13048 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 13049 | if (0 != wlan_hdd_validate_context(hddctx)) |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 13050 | return -EAGAIN; |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 13051 | |
| 13052 | if (!hddctx->config->goptimize_chan_avoid_event) { |
| 13053 | hdd_warn("goptimize_chan_avoid_event ini param disabled"); |
| 13054 | return -EINVAL; |
| 13055 | } |
| 13056 | |
| 13057 | status = sme_enable_disable_chanavoidind_event(hddctx->hHal, set_value); |
| 13058 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 13059 | hdd_err("Failed to send chan avoid command to SME"); |
| 13060 | return -EINVAL; |
| 13061 | } |
| 13062 | return 0; |
| 13063 | } |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 13064 | |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13065 | /** |
| 13066 | * hdd_set_roaming_in_progress() - to set the roaming in progress flag |
| 13067 | * @value: value to set |
| 13068 | * |
| 13069 | * This function will set the passed value to roaming in progress flag. |
| 13070 | * |
| 13071 | * Return: None |
| 13072 | */ |
| 13073 | void hdd_set_roaming_in_progress(bool value) |
| 13074 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13075 | struct hdd_context *hdd_ctx; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13076 | |
| 13077 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13078 | if (!hdd_ctx) { |
| 13079 | hdd_err("HDD context is NULL"); |
| 13080 | return; |
| 13081 | } |
| 13082 | |
| 13083 | hdd_ctx->roaming_in_progress = value; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 13084 | hdd_debug("Roaming in Progress set to %d", value); |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13085 | } |
| 13086 | |
| 13087 | /** |
| 13088 | * hdd_is_roaming_in_progress() - check if roaming is in progress |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 13089 | * @adapter - HDD adapter |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13090 | * |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 13091 | * 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] | 13092 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13093 | bool hdd_is_roaming_in_progress(struct hdd_adapter *adapter) |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13094 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13095 | struct hdd_context *hdd_ctx; |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 13096 | bool ret_status = false; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13097 | |
| 13098 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13099 | if (!hdd_ctx) { |
| 13100 | hdd_err("HDD context is NULL"); |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 13101 | return ret_status; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13102 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 13103 | hdd_debug("dev mode = %d, roaming_in_progress = %d", |
| 13104 | adapter->device_mode, hdd_ctx->roaming_in_progress); |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 13105 | ret_status = ((adapter->device_mode == QDF_STA_MODE) && |
| 13106 | hdd_ctx->roaming_in_progress); |
| 13107 | |
| 13108 | return ret_status; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13109 | } |
| 13110 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13111 | /** |
| 13112 | * hdd_is_connection_in_progress() - check if connection is in |
| 13113 | * progress |
| 13114 | * @session_id: session id |
| 13115 | * @reason: scan reject reason |
| 13116 | * |
| 13117 | * Go through each adapter and check if Connection is in progress |
| 13118 | * |
| 13119 | * Return: true if connection is in progress else false |
| 13120 | */ |
| 13121 | bool hdd_is_connection_in_progress(uint8_t *session_id, |
| 13122 | enum scan_reject_states *reason) |
| 13123 | { |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 13124 | struct hdd_station_ctx *hdd_sta_ctx = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13125 | struct hdd_adapter *adapter = NULL; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13126 | uint8_t sta_id = 0; |
| 13127 | uint8_t *sta_mac = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13128 | struct hdd_context *hdd_ctx; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13129 | |
| 13130 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13131 | if (!hdd_ctx) { |
| 13132 | hdd_err("HDD context is NULL"); |
| 13133 | return false; |
| 13134 | } |
| 13135 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 13136 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13137 | hdd_info("Adapter with device mode %s(%d) exists", |
| 13138 | hdd_device_mode_to_string(adapter->device_mode), |
| 13139 | adapter->device_mode); |
| 13140 | if (((QDF_STA_MODE == adapter->device_mode) |
| 13141 | || (QDF_P2P_CLIENT_MODE == adapter->device_mode) |
| 13142 | || (QDF_P2P_DEVICE_MODE == adapter->device_mode)) |
| 13143 | && (eConnectionState_Connecting == |
| 13144 | (WLAN_HDD_GET_STATION_CTX_PTR(adapter))-> |
| 13145 | conn_info.connState)) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 13146 | hdd_debug("%pK(%d) Connection is in progress", |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13147 | WLAN_HDD_GET_STATION_CTX_PTR(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13148 | adapter->session_id); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13149 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13150 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13151 | *reason = CONNECTION_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13152 | } |
| 13153 | return true; |
| 13154 | } |
Archana Ramachandran | 62886ce | 2017-03-24 14:46:32 -0700 | [diff] [blame] | 13155 | /* |
| 13156 | * sme_neighbor_middle_of_roaming is for LFR2 |
| 13157 | * hdd_is_roaming_in_progress is for LFR3 |
| 13158 | */ |
| 13159 | if (((QDF_STA_MODE == adapter->device_mode) && |
| 13160 | sme_neighbor_middle_of_roaming( |
| 13161 | WLAN_HDD_GET_HAL_CTX(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13162 | adapter->session_id)) || |
Archana Ramachandran | 62886ce | 2017-03-24 14:46:32 -0700 | [diff] [blame] | 13163 | hdd_is_roaming_in_progress(adapter)) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 13164 | hdd_debug("%pK(%d) Reassociation in progress", |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13165 | WLAN_HDD_GET_STATION_CTX_PTR(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13166 | adapter->session_id); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13167 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13168 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13169 | *reason = REASSOC_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13170 | } |
| 13171 | return true; |
| 13172 | } |
| 13173 | if ((QDF_STA_MODE == adapter->device_mode) || |
| 13174 | (QDF_P2P_CLIENT_MODE == adapter->device_mode) || |
| 13175 | (QDF_P2P_DEVICE_MODE == adapter->device_mode)) { |
| 13176 | hdd_sta_ctx = |
| 13177 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 13178 | if ((eConnectionState_Associated == |
Vignesh Viswanathan | 0a56929 | 2018-02-14 15:34:47 +0530 | [diff] [blame] | 13179 | hdd_sta_ctx->conn_info.connState) |
| 13180 | && sme_is_sta_key_exchange_in_progress( |
| 13181 | hdd_ctx->hHal, adapter->session_id)) { |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13182 | sta_mac = (uint8_t *) |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 13183 | &(adapter->mac_addr.bytes[0]); |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 13184 | hdd_debug("client " MAC_ADDRESS_STR |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13185 | " is in middle of WPS/EAPOL exchange.", |
| 13186 | MAC_ADDR_ARRAY(sta_mac)); |
| 13187 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13188 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13189 | *reason = EAPOL_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13190 | } |
| 13191 | return true; |
| 13192 | } |
| 13193 | } else if ((QDF_SAP_MODE == adapter->device_mode) || |
| 13194 | (QDF_P2P_GO_MODE == adapter->device_mode)) { |
| 13195 | for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; |
| 13196 | sta_id++) { |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 13197 | if (!((adapter->sta_info[sta_id].in_use) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13198 | && (OL_TXRX_PEER_STATE_CONN == |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 13199 | adapter->sta_info[sta_id].peer_state))) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13200 | continue; |
| 13201 | |
| 13202 | sta_mac = (uint8_t *) |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 13203 | &(adapter->sta_info[sta_id]. |
Jeff Johnson | f235651 | 2017-10-21 16:04:12 -0700 | [diff] [blame] | 13204 | sta_mac.bytes[0]); |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 13205 | hdd_debug("client " MAC_ADDRESS_STR |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13206 | " of SAP/GO is in middle of WPS/EAPOL exchange", |
| 13207 | MAC_ADDR_ARRAY(sta_mac)); |
| 13208 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13209 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13210 | *reason = SAP_EAPOL_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13211 | } |
| 13212 | return true; |
| 13213 | } |
| 13214 | if (hdd_ctx->connection_in_progress) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 13215 | hdd_debug("AP/GO: connection is in progress"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13216 | return true; |
| 13217 | } |
| 13218 | } |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13219 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 13220 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13221 | return false; |
| 13222 | } |
| 13223 | |
| 13224 | /** |
| 13225 | * hdd_restart_sap() - to restart SAP in driver internally |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13226 | * @ap_adapter: Pointer to SAP struct hdd_adapter structure |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13227 | * |
| 13228 | * Return: None |
| 13229 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13230 | void hdd_restart_sap(struct hdd_adapter *ap_adapter) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13231 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 13232 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 13233 | struct hdd_hostapd_state *hostapd_state; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13234 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13235 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13236 | tsap_Config_t *sap_config; |
| 13237 | void *sap_ctx; |
| 13238 | |
| 13239 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 13240 | sap_config = &hdd_ap_ctx->sap_config; |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 13241 | sap_ctx = hdd_ap_ctx->sap_context; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13242 | |
| 13243 | mutex_lock(&hdd_ctx->sap_lock); |
| 13244 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
| 13245 | wlan_hdd_del_station(ap_adapter); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13246 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
| 13247 | qdf_event_reset(&hostapd_state->qdf_stop_bss_event); |
| 13248 | if (QDF_STATUS_SUCCESS == wlansap_stop_bss(sap_ctx)) { |
| 13249 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 13250 | qdf_wait_for_event_completion(&hostapd_state-> |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13251 | qdf_stop_bss_event, |
| 13252 | SME_CMD_TIMEOUT_VALUE); |
| 13253 | |
| 13254 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13255 | hdd_err("SAP Stop Failed"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13256 | goto end; |
| 13257 | } |
| 13258 | } |
| 13259 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13260 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13261 | ap_adapter->device_mode, ap_adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 13262 | hdd_green_ap_start_state_mc(hdd_ctx, ap_adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 13263 | false); |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13264 | hdd_err("SAP Stop Success"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13265 | |
| 13266 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13267 | hdd_err("SAP Not able to set AP IEs"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13268 | wlansap_reset_sap_config_add_ie(sap_config, |
| 13269 | eUPDATE_IE_ALL); |
| 13270 | goto end; |
| 13271 | } |
| 13272 | |
| 13273 | qdf_event_reset(&hostapd_state->qdf_event); |
| 13274 | if (wlansap_start_bss(sap_ctx, hdd_hostapd_sap_event_cb, |
| 13275 | sap_config, |
| 13276 | ap_adapter->dev) != QDF_STATUS_SUCCESS) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13277 | hdd_err("SAP Start Bss fail"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13278 | wlansap_reset_sap_config_add_ie(sap_config, |
| 13279 | eUPDATE_IE_ALL); |
| 13280 | goto end; |
| 13281 | } |
| 13282 | |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13283 | hdd_info("Waiting for SAP to start"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13284 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 13285 | qdf_wait_for_event_completion(&hostapd_state->qdf_event, |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13286 | SME_CMD_TIMEOUT_VALUE); |
| 13287 | wlansap_reset_sap_config_add_ie(sap_config, |
| 13288 | eUPDATE_IE_ALL); |
| 13289 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13290 | hdd_err("SAP Start failed"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13291 | goto end; |
| 13292 | } |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13293 | hdd_err("SAP Start Success"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13294 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 13295 | if (hostapd_state->bss_state == BSS_START) { |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13296 | policy_mgr_incr_active_session(hdd_ctx->hdd_psoc, |
| 13297 | ap_adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13298 | ap_adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 13299 | hdd_green_ap_start_state_mc(hdd_ctx, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 13300 | ap_adapter->device_mode, |
| 13301 | true); |
| 13302 | } |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13303 | } |
| 13304 | end: |
| 13305 | mutex_unlock(&hdd_ctx->sap_lock); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13306 | } |
| 13307 | |
| 13308 | /** |
| 13309 | * hdd_check_and_restart_sap_with_non_dfs_acs() - Restart SAP |
| 13310 | * with non dfs acs |
| 13311 | * |
| 13312 | * Restarts SAP in non-DFS ACS mode when STA-AP mode DFS is not supported |
| 13313 | * |
| 13314 | * Return: None |
| 13315 | */ |
| 13316 | void hdd_check_and_restart_sap_with_non_dfs_acs(void) |
| 13317 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13318 | struct hdd_adapter *ap_adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13319 | struct hdd_context *hdd_ctx; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13320 | cds_context_type *cds_ctx; |
| 13321 | |
| 13322 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13323 | if (!hdd_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13324 | hdd_err("HDD context is NULL"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13325 | return; |
| 13326 | } |
| 13327 | |
| 13328 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 13329 | if (!cds_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13330 | hdd_err("Invalid CDS Context"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13331 | return; |
| 13332 | } |
| 13333 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13334 | if (policy_mgr_get_concurrency_mode(hdd_ctx->hdd_psoc) |
| 13335 | != (QDF_STA_MASK | QDF_SAP_MASK)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13336 | hdd_info("Concurrency mode is not SAP"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13337 | return; |
| 13338 | } |
| 13339 | |
| 13340 | ap_adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE); |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 13341 | if (ap_adapter != NULL && test_bit(SOFTAP_BSS_STARTED, |
| 13342 | &ap_adapter->event_flags) && |
| 13343 | wlan_reg_is_dfs_ch(hdd_ctx->hdd_pdev, |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 13344 | ap_adapter->session.ap.operating_channel)) { |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13345 | |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13346 | 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] | 13347 | ap_adapter->session.ap.sap_config.channel = |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13348 | AUTO_CHANNEL_SELECT; |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 13349 | ap_adapter->session.ap.sap_config. |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13350 | acs_cfg.acs_mode = true; |
| 13351 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13352 | hdd_restart_sap(ap_adapter); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13353 | } |
| 13354 | } |
| 13355 | |
| 13356 | /** |
| 13357 | * hdd_set_connection_in_progress() - to set the connection in |
| 13358 | * progress flag |
| 13359 | * @value: value to set |
| 13360 | * |
| 13361 | * This function will set the passed value to connection in progress flag. |
| 13362 | * If value is previously being set to true then no need to set it again. |
| 13363 | * |
| 13364 | * Return: true if value is being set correctly and false otherwise. |
| 13365 | */ |
| 13366 | bool hdd_set_connection_in_progress(bool value) |
| 13367 | { |
| 13368 | bool status = true; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13369 | struct hdd_context *hdd_ctx; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13370 | |
| 13371 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13372 | if (!hdd_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13373 | hdd_err("HDD context is NULL"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13374 | return false; |
| 13375 | } |
| 13376 | |
| 13377 | qdf_spin_lock(&hdd_ctx->connection_status_lock); |
| 13378 | /* |
| 13379 | * if the value is set to true previously and if someone is |
| 13380 | * trying to make it true again then it could be some race |
| 13381 | * condition being triggered. Avoid this situation by returning |
| 13382 | * false |
| 13383 | */ |
| 13384 | if (hdd_ctx->connection_in_progress && value) |
| 13385 | status = false; |
| 13386 | else |
| 13387 | hdd_ctx->connection_in_progress = value; |
| 13388 | qdf_spin_unlock(&hdd_ctx->connection_status_lock); |
| 13389 | return status; |
| 13390 | } |
| 13391 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13392 | 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] | 13393 | { |
| 13394 | if (!adapter) { |
| 13395 | hdd_err("Invalid adapter"); |
| 13396 | return -EINVAL; |
| 13397 | } |
| 13398 | hdd_info("Send MCC P2P QUOTA to WMA: %d", set_value); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13399 | sme_cli_set_command(adapter->session_id, |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 13400 | WMA_VDEV_MCC_SET_TIME_QUOTA, |
| 13401 | set_value, VDEV_CMD); |
| 13402 | return 0; |
| 13403 | |
| 13404 | } |
| 13405 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13406 | 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] | 13407 | { |
| 13408 | if (!adapter) { |
| 13409 | hdd_err("Invalid adapter"); |
| 13410 | return -EINVAL; |
| 13411 | } |
| 13412 | |
| 13413 | hdd_info("Send MCC latency WMA: %d", set_value); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13414 | sme_cli_set_command(adapter->session_id, |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 13415 | WMA_VDEV_MCC_SET_TIME_LATENCY, |
| 13416 | set_value, VDEV_CMD); |
| 13417 | return 0; |
| 13418 | } |
| 13419 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13420 | 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] | 13421 | *psoc, uint8_t vdev_id) |
| 13422 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13423 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13424 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 13425 | |
| 13426 | /* |
| 13427 | * Currently PSOC is not being used. But this logic will |
| 13428 | * change once we have the converged implementation of |
| 13429 | * HDD context per PSOC in place. This would break if |
| 13430 | * multiple vdev objects reuse the vdev id. |
| 13431 | */ |
| 13432 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 13433 | if (!adapter) |
| 13434 | hdd_err("Get adapter by vdev id failed"); |
| 13435 | |
| 13436 | return adapter; |
| 13437 | } |
| 13438 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13439 | 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] | 13440 | int8_t *rssi, int8_t *snr) |
| 13441 | { |
| 13442 | QDF_STATUS status; |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 13443 | struct csr_roam_profile *roam_profile; |
Hanumanth Reddy Pothula | 9005178 | 2017-05-04 22:14:43 +0530 | [diff] [blame] | 13444 | |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 13445 | roam_profile = hdd_roam_profile(adapter); |
Hanumanth Reddy Pothula | 9005178 | 2017-05-04 22:14:43 +0530 | [diff] [blame] | 13446 | 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] | 13447 | roam_profile, bssid, rssi, snr); |
Hanumanth Reddy Pothula | 9005178 | 2017-05-04 22:14:43 +0530 | [diff] [blame] | 13448 | if (QDF_STATUS_SUCCESS != status) { |
| 13449 | hdd_warn("sme_get_rssi_snr_by_bssid failed"); |
| 13450 | return -EINVAL; |
| 13451 | } |
| 13452 | |
| 13453 | return 0; |
| 13454 | } |
| 13455 | |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13456 | /** |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13457 | * hdd_set_limit_off_chan_for_tos() - set limit off-channel command parameters |
| 13458 | * @adapter - HDD adapter |
| 13459 | * @tos - type of service |
| 13460 | * @status - status of the traffic |
| 13461 | * |
| 13462 | * Return: 0 on success and non zero value on failure |
| 13463 | */ |
| 13464 | |
| 13465 | int hdd_set_limit_off_chan_for_tos(struct hdd_adapter *adapter, enum tos tos, |
| 13466 | bool is_tos_active) |
| 13467 | { |
| 13468 | int ac_bit; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13469 | struct hdd_context *hdd_ctx; |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13470 | uint32_t max_off_chan_time = 0; |
| 13471 | QDF_STATUS status; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13472 | int ret; |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13473 | tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter); |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13474 | |
| 13475 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 13476 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 13477 | |
| 13478 | if (ret < 0) { |
| 13479 | hdd_err("failed to set limit off chan params"); |
| 13480 | return ret; |
| 13481 | } |
| 13482 | |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13483 | ac_bit = limit_off_chan_tbl[tos][HDD_AC_BIT_INDX]; |
| 13484 | |
| 13485 | if (is_tos_active) |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 13486 | adapter->active_ac |= ac_bit; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13487 | else |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 13488 | adapter->active_ac &= ~ac_bit; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13489 | |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 13490 | if (adapter->active_ac) { |
| 13491 | if (adapter->active_ac & HDD_AC_VO_BIT) { |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13492 | max_off_chan_time = |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13493 | limit_off_chan_tbl[TOS_VO][HDD_DWELL_TIME_INDX]; |
| 13494 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13495 | PM_LATENCY); |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 13496 | } else if (adapter->active_ac & HDD_AC_VI_BIT) { |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13497 | max_off_chan_time = |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13498 | limit_off_chan_tbl[TOS_VI][HDD_DWELL_TIME_INDX]; |
| 13499 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13500 | PM_LATENCY); |
| 13501 | } else { |
| 13502 | /*ignore this command if only BE/BK is active */ |
| 13503 | is_tos_active = false; |
| 13504 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13505 | hdd_ctx->config->conc_system_pref); |
| 13506 | } |
| 13507 | } else { |
| 13508 | /* No active tos */ |
| 13509 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13510 | hdd_ctx->config->conc_system_pref); |
| 13511 | } |
| 13512 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13513 | status = sme_send_limit_off_channel_params(hal, adapter->session_id, |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13514 | is_tos_active, max_off_chan_time, |
| 13515 | hdd_ctx->config->nRestTimeConc, true); |
| 13516 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 13517 | hdd_err("failed to set limit off chan params"); |
| 13518 | ret = -EINVAL; |
| 13519 | } |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13520 | |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13521 | return ret; |
| 13522 | } |
| 13523 | |
| 13524 | /** |
| 13525 | * hdd_reset_limit_off_chan() - reset limit off-channel command parameters |
| 13526 | * @adapter - HDD adapter |
| 13527 | * |
| 13528 | * Return: 0 on success and non zero value on failure |
| 13529 | */ |
| 13530 | int hdd_reset_limit_off_chan(struct hdd_adapter *adapter) |
| 13531 | { |
| 13532 | struct hdd_context *hdd_ctx; |
| 13533 | int ret; |
| 13534 | QDF_STATUS status; |
| 13535 | tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter); |
| 13536 | |
| 13537 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 13538 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 13539 | if (ret < 0) |
| 13540 | return ret; |
| 13541 | |
| 13542 | /* set the system preferece to default */ |
| 13543 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13544 | hdd_ctx->config->conc_system_pref); |
| 13545 | |
| 13546 | /* clear the bitmap */ |
| 13547 | adapter->active_ac = 0; |
| 13548 | |
| 13549 | hdd_debug("reset ac_bitmap for session %hu active_ac %0x", |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13550 | adapter->session_id, adapter->active_ac); |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13551 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13552 | status = sme_send_limit_off_channel_params(hal, adapter->session_id, |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13553 | false, 0, 0, false); |
| 13554 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 13555 | hdd_err("failed to reset limit off chan params"); |
| 13556 | ret = -EINVAL; |
| 13557 | } |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13558 | |
| 13559 | return ret; |
| 13560 | } |
| 13561 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13562 | /** |
| 13563 | * hdd_start_driver_ops_timer() - Starts driver ops inactivity timer |
| 13564 | * @drv_op: Enum indicating driver op |
| 13565 | * |
| 13566 | * Return: none |
| 13567 | */ |
| 13568 | void hdd_start_driver_ops_timer(int drv_op) |
| 13569 | { |
| 13570 | memset(drv_ops_string, 0, MAX_OPS_NAME_STRING_SIZE); |
| 13571 | switch (drv_op) { |
| 13572 | case eHDD_DRV_OP_PROBE: |
| 13573 | memcpy(drv_ops_string, "probe", sizeof("probe")); |
| 13574 | break; |
| 13575 | case eHDD_DRV_OP_REMOVE: |
| 13576 | memcpy(drv_ops_string, "remove", sizeof("remove")); |
| 13577 | break; |
| 13578 | case eHDD_DRV_OP_SHUTDOWN: |
| 13579 | memcpy(drv_ops_string, "shutdown", sizeof("shutdown")); |
| 13580 | break; |
| 13581 | case eHDD_DRV_OP_REINIT: |
| 13582 | memcpy(drv_ops_string, "reinit", sizeof("reinit")); |
| 13583 | break; |
Arunk Khandavalli | e9ef42a | 2017-10-04 14:49:51 +0530 | [diff] [blame] | 13584 | case eHDD_DRV_OP_IFF_UP: |
| 13585 | memcpy(drv_ops_string, "iff_up", sizeof("iff_up")); |
| 13586 | break; |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13587 | } |
| 13588 | |
Dustin Brown | 45ed4bb | 2017-12-18 12:00:13 -0800 | [diff] [blame] | 13589 | hdd_drv_ops_task = current; |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13590 | qdf_timer_start(&hdd_drv_ops_inactivity_timer, |
| 13591 | HDD_OPS_INACTIVITY_TIMEOUT); |
| 13592 | } |
| 13593 | |
| 13594 | /** |
| 13595 | * hdd_stop_driver_ops_timer() - Stops driver ops inactivity timer |
| 13596 | * |
| 13597 | * Return: none |
| 13598 | */ |
| 13599 | void hdd_stop_driver_ops_timer(void) |
| 13600 | { |
| 13601 | qdf_timer_sync_cancel(&hdd_drv_ops_inactivity_timer); |
| 13602 | } |
| 13603 | |
| 13604 | /** |
| 13605 | * hdd_drv_ops_inactivity_handler() - Timeout handler for driver ops |
| 13606 | * inactivity timer |
| 13607 | * |
| 13608 | * Return: None |
| 13609 | */ |
| 13610 | void hdd_drv_ops_inactivity_handler(void) |
| 13611 | { |
| 13612 | hdd_err("%s: %d Sec timer expired while in .%s", |
| 13613 | __func__, HDD_OPS_INACTIVITY_TIMEOUT/1000, drv_ops_string); |
| 13614 | |
Dustin Brown | 45ed4bb | 2017-12-18 12:00:13 -0800 | [diff] [blame] | 13615 | if (hdd_drv_ops_task) { |
| 13616 | printk("Call stack for \"%s\"\n", hdd_drv_ops_task->comm); |
| 13617 | qdf_print_thread_trace(hdd_drv_ops_task); |
| 13618 | } else { |
| 13619 | hdd_err("hdd_drv_ops_task is null"); |
| 13620 | } |
| 13621 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13622 | /* Driver shutdown is stuck, no recovery possible at this point */ |
| 13623 | if (0 == qdf_mem_cmp(&drv_ops_string[0], "shutdown", |
| 13624 | sizeof("shutdown"))) |
| 13625 | QDF_BUG(0); |
| 13626 | |
Rajeev Kumar | 1e57b9c | 2018-01-04 16:17:10 -0800 | [diff] [blame] | 13627 | if (cds_is_fw_down()) { |
| 13628 | hdd_err("FW is down"); |
| 13629 | return; |
| 13630 | } |
| 13631 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13632 | if (cds_is_self_recovery_enabled()) |
Anurag Chouhan | 4085ff7 | 2017-10-05 18:09:56 +0530 | [diff] [blame] | 13633 | cds_trigger_recovery(QDF_REASON_UNSPECIFIED); |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13634 | else |
| 13635 | QDF_BUG(0); |
| 13636 | } |
| 13637 | |
Sravan Kumar Kairam | d80c766 | 2017-10-03 16:11:05 +0530 | [diff] [blame] | 13638 | void hdd_pld_ipa_uc_shutdown_pipes(void) |
| 13639 | { |
| 13640 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13641 | |
| 13642 | if (!hdd_ctx) |
| 13643 | return; |
| 13644 | |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 13645 | ucfg_ipa_uc_force_pipe_shutdown(hdd_ctx->hdd_pdev); |
Sravan Kumar Kairam | d80c766 | 2017-10-03 16:11:05 +0530 | [diff] [blame] | 13646 | } |
| 13647 | |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 13648 | /** |
| 13649 | * hdd_set_rx_mode_rps() - Enable/disable RPS in SAP mode |
| 13650 | * @struct hdd_context *hdd_ctx |
| 13651 | * @struct hdd_adapter *padapter |
| 13652 | * @bool enble |
| 13653 | * |
| 13654 | * Return: none |
| 13655 | */ |
| 13656 | void hdd_set_rx_mode_rps(bool enable) |
| 13657 | { |
| 13658 | struct cds_config_info *cds_cfg = cds_get_ini_config(); |
| 13659 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13660 | struct hdd_adapter *adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE); |
| 13661 | |
| 13662 | if (adapter && hdd_ctx && |
| 13663 | !hdd_ctx->rps && cds_cfg->uc_offload_enabled) { |
| 13664 | if (enable && !cds_cfg->rps_enabled) |
| 13665 | hdd_send_rps_ind(adapter); |
| 13666 | else if (!enable && cds_cfg->rps_enabled) |
| 13667 | hdd_send_rps_disable_ind(adapter); |
| 13668 | } |
| 13669 | } |
| 13670 | |
Hanumanth Reddy Pothula | 3862ca9 | 2018-01-12 16:44:10 +0530 | [diff] [blame] | 13671 | bool hdd_is_cli_iface_up(struct hdd_context *hdd_ctx) |
| 13672 | { |
| 13673 | struct hdd_adapter *adapter = NULL; |
| 13674 | |
| 13675 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 13676 | if ((adapter->device_mode == QDF_STA_MODE || |
| 13677 | adapter->device_mode == QDF_P2P_CLIENT_MODE) && |
| 13678 | qdf_atomic_test_bit(DEVICE_IFACE_OPENED, |
| 13679 | &adapter->event_flags)){ |
| 13680 | return true; |
| 13681 | } |
| 13682 | } |
| 13683 | |
| 13684 | return false; |
| 13685 | } |
| 13686 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13687 | /* Register the module init/exit functions */ |
| 13688 | module_init(hdd_module_init); |
| 13689 | module_exit(hdd_module_exit); |
| 13690 | |
| 13691 | MODULE_LICENSE("Dual BSD/GPL"); |
| 13692 | MODULE_AUTHOR("Qualcomm Atheros, Inc."); |
| 13693 | MODULE_DESCRIPTION("WLAN HOST DEVICE DRIVER"); |
| 13694 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 13695 | static const struct kernel_param_ops con_mode_ops = { |
| 13696 | .set = con_mode_handler, |
| 13697 | .get = param_get_int, |
| 13698 | }; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13699 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 13700 | static const struct kernel_param_ops con_mode_ftm_ops = { |
| 13701 | .set = con_mode_handler_ftm, |
| 13702 | .get = param_get_int, |
| 13703 | }; |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 13704 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 13705 | static const struct kernel_param_ops con_mode_monitor_ops = { |
| 13706 | .set = con_mode_handler_monitor, |
| 13707 | .get = param_get_int, |
| 13708 | }; |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 13709 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 13710 | static const struct kernel_param_ops fwpath_ops = { |
| 13711 | .set = fwpath_changed_handler, |
| 13712 | .get = param_get_string, |
| 13713 | }; |
| 13714 | |
| 13715 | module_param_cb(con_mode, &con_mode_ops, &con_mode, |
| 13716 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 13717 | |
| 13718 | module_param_cb(con_mode_ftm, &con_mode_ftm_ops, &con_mode_ftm, |
| 13719 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 13720 | |
| 13721 | module_param_cb(con_mode_monitor, &con_mode_monitor_ops, &con_mode_monitor, |
| 13722 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 13723 | |
| 13724 | module_param_cb(fwpath, &fwpath_ops, &fwpath, |
| 13725 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13726 | |
| 13727 | module_param(enable_dfs_chan_scan, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 13728 | |
| 13729 | module_param(enable_11d, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 13730 | |
| 13731 | module_param(country_code, charp, S_IRUSR | S_IRGRP | S_IROTH); |