Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1 | /* |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2 | * Copyright (c) 2012-2018 The Linux Foundation. All rights reserved. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3 | * |
| 4 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 5 | * |
| 6 | * |
| 7 | * Permission to use, copy, modify, and/or distribute this software for |
| 8 | * any purpose with or without fee is hereby granted, provided that the |
| 9 | * above copyright notice and this permission notice appear in all |
| 10 | * copies. |
| 11 | * |
| 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 13 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 14 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 15 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 16 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 17 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 18 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 19 | * PERFORMANCE OF THIS SOFTWARE. |
| 20 | */ |
| 21 | |
| 22 | /* |
| 23 | * This file was originally distributed by Qualcomm Atheros, Inc. |
| 24 | * under proprietary terms before Copyright ownership was assigned |
| 25 | * to the Linux Foundation. |
| 26 | */ |
| 27 | |
| 28 | /** |
| 29 | * DOC: wlan_hdd_main.c |
| 30 | * |
| 31 | * WLAN Host Device Driver implementation |
| 32 | * |
| 33 | */ |
| 34 | |
| 35 | /* Include Files */ |
| 36 | #include <wlan_hdd_includes.h> |
| 37 | #include <cds_api.h> |
| 38 | #include <cds_sched.h> |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 39 | #include <linux/cpu.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 40 | #include <linux/etherdevice.h> |
| 41 | #include <linux/firmware.h> |
| 42 | #include <wlan_hdd_tx_rx.h> |
| 43 | #include <wni_api.h> |
| 44 | #include <wlan_hdd_cfg.h> |
| 45 | #include <wlan_ptt_sock_svc.h> |
| 46 | #include <dbglog_host.h> |
| 47 | #include <wlan_logging_sock_svc.h> |
| 48 | #include <wlan_hdd_wowl.h> |
| 49 | #include <wlan_hdd_misc.h> |
| 50 | #include <wlan_hdd_wext.h> |
| 51 | #include "wlan_hdd_trace.h" |
| 52 | #include "wlan_hdd_ioctl.h" |
| 53 | #include "wlan_hdd_ftm.h" |
| 54 | #include "wlan_hdd_power.h" |
| 55 | #include "wlan_hdd_stats.h" |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 56 | #include "wlan_hdd_scan.h" |
Jeff Johnson | ce0032c | 2017-01-20 07:18:27 -0800 | [diff] [blame] | 57 | #include "wlan_hdd_request_manager.h" |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 58 | #ifdef CONFIG_LEAK_DETECTION |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 59 | #include "qdf_debug_domain.h" |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 60 | #endif |
Dustin Brown | d424194 | 2018-02-26 12:51:37 -0800 | [diff] [blame] | 61 | #include "qdf_str.h" |
| 62 | #include "qdf_trace.h" |
| 63 | #include "qdf_types.h" |
Manjunathappa Prakash | 3454fd6 | 2016-04-01 08:52:06 -0700 | [diff] [blame] | 64 | #include <cdp_txrx_peer_ops.h> |
Dhanashri Atre | a8f82f2 | 2017-01-23 12:58:24 -0800 | [diff] [blame] | 65 | #include <cdp_txrx_misc.h> |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 66 | #include <cdp_txrx_stats.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 67 | |
| 68 | #include <net/addrconf.h> |
| 69 | #include <linux/wireless.h> |
| 70 | #include <net/cfg80211.h> |
| 71 | #include <linux/inetdevice.h> |
| 72 | #include <net/addrconf.h> |
| 73 | #include "wlan_hdd_cfg80211.h" |
| 74 | #include "wlan_hdd_ext_scan.h" |
| 75 | #include "wlan_hdd_p2p.h" |
| 76 | #include <linux/rtnetlink.h> |
| 77 | #include "sap_api.h" |
| 78 | #include <linux/semaphore.h> |
| 79 | #include <linux/ctype.h> |
| 80 | #include <linux/compat.h> |
| 81 | #ifdef MSM_PLATFORM |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 82 | #include <soc/qcom/subsystem_restart.h> |
| 83 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 84 | #include <wlan_hdd_hostapd.h> |
| 85 | #include <wlan_hdd_softap_tx_rx.h> |
| 86 | #include "cfg_api.h" |
| 87 | #include "qwlan_version.h" |
| 88 | #include "wma_types.h" |
| 89 | #include "wlan_hdd_tdls.h" |
| 90 | #ifdef FEATURE_WLAN_CH_AVOID |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 91 | #include "cds_regdomain.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 92 | #endif /* FEATURE_WLAN_CH_AVOID */ |
Dustin Brown | ce46d1d | 2017-08-15 13:34:24 -0700 | [diff] [blame] | 93 | #include "cdp_txrx_flow_ctrl_v2.h" |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 94 | #include "pld_common.h" |
Tushnim Bhattacharyya | 15596cf | 2016-02-12 11:57:02 -0800 | [diff] [blame] | 95 | #include "wlan_hdd_ocb.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 96 | #include "wlan_hdd_nan.h" |
| 97 | #include "wlan_hdd_debugfs.h" |
| 98 | #include "wlan_hdd_driver_ops.h" |
| 99 | #include "epping_main.h" |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 100 | #include "wlan_hdd_data_stall_detection.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 101 | |
| 102 | #include <wlan_hdd_ipa.h> |
| 103 | #include "hif.h" |
| 104 | #include "wma.h" |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 105 | #include "wlan_policy_mgr_api.h" |
Manikandan Mohan | dcc21ba | 2016-03-15 14:31:56 -0700 | [diff] [blame] | 106 | #include "wlan_hdd_tsf.h" |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 107 | #include "bmi.h" |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 108 | #include <wlan_hdd_regulatory.h> |
Jeff Johnson | 2b0a7b8 | 2016-05-18 15:08:02 -0700 | [diff] [blame] | 109 | #include "wlan_hdd_lpass.h" |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 110 | #include "nan_api.h" |
Orhan K AKYILDIZ | 1481aff | 2016-05-16 12:40:13 -0700 | [diff] [blame] | 111 | #include <wlan_hdd_napi.h> |
Padma, Santhosh Kumar | d7cc079 | 2016-06-28 18:54:12 +0530 | [diff] [blame] | 112 | #include "wlan_hdd_disa.h" |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 113 | #include <dispatcher_init_deinit.h> |
Rajeev Kumar | 699debf | 2017-01-06 14:17:00 -0800 | [diff] [blame] | 114 | #include "wlan_hdd_object_manager.h" |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 115 | #include "cds_utils.h" |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 116 | #include <cdp_txrx_handle.h> |
Sandeep Puligilla | fdd201e | 2017-02-02 18:43:46 -0800 | [diff] [blame] | 117 | #include <qca_vendor.h> |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 118 | #include "wlan_pmo_ucfg_api.h" |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 119 | #include "sir_api.h" |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 120 | #include "os_if_wifi_pos.h" |
| 121 | #include "wifi_pos_api.h" |
| 122 | #include "wlan_hdd_oemdata.h" |
Krishna Kumaar Natarajan | 4f1d772 | 2017-03-03 21:12:51 -0800 | [diff] [blame] | 123 | #include "wlan_hdd_he.h" |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 124 | #include "os_if_nan.h" |
| 125 | #include "nan_public_structs.h" |
Kiran Kumar Lokere | 3beeb95 | 2017-05-02 18:40:24 -0700 | [diff] [blame] | 126 | #include "wlan_reg_ucfg_api.h" |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 127 | #include "wlan_dfs_ucfg_api.h" |
Ravi Joshi | 4f09595 | 2017-06-29 15:39:19 -0700 | [diff] [blame] | 128 | #include "wlan_hdd_rx_monitor.h" |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 129 | #include "sme_power_save_api.h" |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 130 | #include "enet.h" |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 131 | #include <cdp_txrx_cmn_struct.h> |
Amar Singhal | 0928b19 | 2017-12-01 10:50:54 -0800 | [diff] [blame] | 132 | #include "wlan_hdd_sysfs.h" |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 133 | #include "wlan_disa_ucfg_api.h" |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 134 | #include "wlan_ipa_ucfg_api.h" |
Arunk Khandavalli | a6305a3 | 2018-01-25 11:19:18 +0530 | [diff] [blame] | 135 | #include <target_if.h> |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 136 | #include "wlan_hdd_nud_tracking.h" |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 137 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 138 | #ifdef CNSS_GENL |
| 139 | #include <net/cnss_nl.h> |
| 140 | #endif |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 141 | #include "wlan_reg_ucfg_api.h" |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 142 | #include "wlan_ocb_ucfg_api.h" |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 143 | |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 144 | #include <wlan_green_ap_ucfg_api.h> |
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 | /** |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 316 | * hdd_green_ap_check_enable() - to check whether to enable green ap or not |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 317 | * @hdd_ctx: hdd context |
| 318 | * @enable_green_ap: 1 - enable green ap enabled, 0 - disbale green ap |
| 319 | * |
| 320 | * Return: 0 - success, < 0 - failure |
| 321 | */ |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 322 | static int hdd_green_ap_check_enable(struct hdd_context *hdd_ctx, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 323 | bool *enable_green_ap) |
| 324 | { |
| 325 | uint8_t num_sessions, mode; |
| 326 | QDF_STATUS status; |
| 327 | |
| 328 | for (mode = 0; |
| 329 | mode < QDF_MAX_NO_OF_MODE; |
| 330 | mode++) { |
| 331 | if (mode == QDF_SAP_MODE || mode == QDF_P2P_GO_MODE) |
| 332 | continue; |
| 333 | |
| 334 | status = policy_mgr_mode_specific_num_active_sessions( |
| 335 | hdd_ctx->hdd_psoc, mode, &num_sessions); |
| 336 | hdd_debug("No. of active sessions for mode: %d is %d", |
| 337 | mode, num_sessions); |
| 338 | if (status != QDF_STATUS_SUCCESS) { |
| 339 | hdd_err("Failed to get num sessions for mode: %d", |
| 340 | mode); |
| 341 | return -EINVAL; |
| 342 | } else if (num_sessions) { |
| 343 | *enable_green_ap = false; |
| 344 | return 0; |
| 345 | } |
| 346 | } |
| 347 | *enable_green_ap = true; |
| 348 | return 0; |
| 349 | } |
| 350 | |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 351 | int hdd_green_ap_start_state_mc(struct hdd_context *hdd_ctx, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 352 | enum QDF_OPMODE mode, bool is_session_start) |
| 353 | { |
| 354 | struct hdd_config *cfg; |
| 355 | bool enable_green_ap = false; |
| 356 | uint8_t num_sap_sessions = 0, num_p2p_go_sessions = 0, ret = 0; |
| 357 | |
| 358 | cfg = hdd_ctx->config; |
| 359 | if (!cfg) { |
| 360 | hdd_err("NULL hdd config"); |
| 361 | return -EINVAL; |
| 362 | } |
| 363 | |
| 364 | if (!cfg->enable2x2 || !cfg->enableGreenAP) { |
| 365 | hdd_info("Green AP support not present: enable2x2: %d, enableGreenAp: %d", |
| 366 | cfg->enable2x2, cfg->enableGreenAP); |
| 367 | return 0; |
| 368 | } |
| 369 | |
| 370 | policy_mgr_mode_specific_num_active_sessions(hdd_ctx->hdd_psoc, |
| 371 | QDF_SAP_MODE, |
| 372 | &num_sap_sessions); |
| 373 | policy_mgr_mode_specific_num_active_sessions(hdd_ctx->hdd_psoc, |
| 374 | QDF_P2P_GO_MODE, |
| 375 | &num_p2p_go_sessions); |
| 376 | |
| 377 | switch (mode) { |
| 378 | case QDF_STA_MODE: |
| 379 | case QDF_P2P_CLIENT_MODE: |
| 380 | case QDF_IBSS_MODE: |
| 381 | if (!num_sap_sessions && !num_p2p_go_sessions) |
| 382 | return 0; |
| 383 | |
| 384 | if (is_session_start) { |
| 385 | hdd_debug("Disabling Green AP"); |
| 386 | ucfg_green_ap_set_ps_config(hdd_ctx->hdd_pdev, |
| 387 | false); |
| 388 | wlan_green_ap_stop(hdd_ctx->hdd_pdev); |
| 389 | } else { |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 390 | ret = hdd_green_ap_check_enable(hdd_ctx, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 391 | &enable_green_ap); |
| 392 | if (!ret) { |
| 393 | if (enable_green_ap) { |
| 394 | hdd_debug("Enabling Green AP"); |
| 395 | ucfg_green_ap_set_ps_config( |
| 396 | hdd_ctx->hdd_pdev, true); |
| 397 | wlan_green_ap_start(hdd_ctx->hdd_pdev); |
| 398 | } |
| 399 | } else { |
| 400 | hdd_err("Failed to check Green AP enable status"); |
| 401 | } |
| 402 | } |
| 403 | break; |
| 404 | case QDF_SAP_MODE: |
| 405 | case QDF_P2P_GO_MODE: |
| 406 | if (is_session_start) { |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 407 | ret = hdd_green_ap_check_enable(hdd_ctx, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 408 | &enable_green_ap); |
| 409 | if (!ret) { |
| 410 | if (enable_green_ap) { |
| 411 | hdd_debug("Enabling Green AP"); |
| 412 | ucfg_green_ap_set_ps_config( |
| 413 | hdd_ctx->hdd_pdev, true); |
| 414 | wlan_green_ap_start(hdd_ctx->hdd_pdev); |
| 415 | } |
| 416 | } else { |
| 417 | hdd_err("Failed to check Green AP enable status"); |
| 418 | } |
| 419 | } else { |
| 420 | if (!num_sap_sessions && !num_p2p_go_sessions) { |
| 421 | hdd_debug("Disabling Green AP"); |
| 422 | ucfg_green_ap_set_ps_config(hdd_ctx->hdd_pdev, |
| 423 | false); |
| 424 | wlan_green_ap_stop(hdd_ctx->hdd_pdev); |
| 425 | } |
| 426 | } |
| 427 | break; |
| 428 | default: |
| 429 | break; |
| 430 | } |
| 431 | return ret; |
| 432 | } |
| 433 | |
| 434 | /** |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 435 | * hdd_set_rps_cpu_mask - set RPS CPU mask for interfaces |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 436 | * @hdd_ctx: pointer to struct hdd_context |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 437 | * |
| 438 | * Return: none |
| 439 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 440 | static void hdd_set_rps_cpu_mask(struct hdd_context *hdd_ctx) |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 441 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 442 | struct hdd_adapter *adapter; |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 443 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 444 | hdd_for_each_adapter(hdd_ctx, adapter) |
| 445 | hdd_send_rps_ind(adapter); |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 446 | } |
| 447 | |
| 448 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 449 | * wlan_hdd_txrx_pause_cb() - pause callback from txrx layer |
| 450 | * @vdev_id: vdev_id |
| 451 | * @action: action type |
| 452 | * @reason: reason type |
| 453 | * |
| 454 | * Return: none |
| 455 | */ |
| 456 | void wlan_hdd_txrx_pause_cb(uint8_t vdev_id, |
| 457 | enum netif_action_type action, enum netif_reason_type reason) |
| 458 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 459 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 460 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 461 | |
| 462 | if (!hdd_ctx) { |
| 463 | hdd_err("hdd ctx is NULL"); |
| 464 | return; |
| 465 | } |
| 466 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 467 | |
| 468 | wlan_hdd_netif_queue_control(adapter, action, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 469 | } |
| 470 | |
| 471 | /* |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 472 | * Store WLAN driver version and timestamp info in global variables such that |
| 473 | * crash debugger can extract them from driver debug symbol and crashdump for |
| 474 | * post processing |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 475 | */ |
Dustin Brown | 96cd963 | 2017-11-13 12:45:04 -0800 | [diff] [blame] | 476 | #ifdef BUILD_TAG |
| 477 | uint8_t g_wlan_driver_version[] = QWLAN_VERSIONSTR "; " BUILD_TAG; |
| 478 | #else |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 479 | uint8_t g_wlan_driver_version[] = QWLAN_VERSIONSTR; |
Naveen Rawat | 9383625 | 2017-06-20 16:30:59 -0700 | [diff] [blame] | 480 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 481 | |
| 482 | /** |
| 483 | * hdd_device_mode_to_string() - return string conversion of device mode |
| 484 | * @device_mode: device mode |
| 485 | * |
| 486 | * This utility function helps log string conversion of device mode. |
| 487 | * |
| 488 | * Return: string conversion of device mode, if match found; |
| 489 | * "Unknown" otherwise. |
| 490 | */ |
| 491 | const char *hdd_device_mode_to_string(uint8_t device_mode) |
| 492 | { |
| 493 | switch (device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 494 | CASE_RETURN_STRING(QDF_STA_MODE); |
| 495 | CASE_RETURN_STRING(QDF_SAP_MODE); |
| 496 | CASE_RETURN_STRING(QDF_P2P_CLIENT_MODE); |
| 497 | CASE_RETURN_STRING(QDF_P2P_GO_MODE); |
| 498 | CASE_RETURN_STRING(QDF_FTM_MODE); |
| 499 | CASE_RETURN_STRING(QDF_IBSS_MODE); |
| 500 | CASE_RETURN_STRING(QDF_P2P_DEVICE_MODE); |
| 501 | CASE_RETURN_STRING(QDF_OCB_MODE); |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 502 | CASE_RETURN_STRING(QDF_NDI_MODE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 503 | default: |
| 504 | return "Unknown"; |
| 505 | } |
| 506 | } |
| 507 | |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 508 | /** |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 509 | * hdd_get_valid_chan() - return current chan list from regulatory. |
| 510 | * @hdd_ctx: HDD context |
| 511 | * @chan_list: buf hold returned chan list |
| 512 | * @chan_num: input buf size and output returned chan num |
| 513 | * |
| 514 | * This function helps get current available chan list from regulatory |
| 515 | * module. It excludes the "disabled" and "invalid" channels. |
| 516 | * |
| 517 | * Return: 0 for success. |
| 518 | */ |
| 519 | static int hdd_get_valid_chan(struct hdd_context *hdd_ctx, |
| 520 | uint8_t *chan_list, |
| 521 | uint32_t *chan_num) |
| 522 | { |
| 523 | int i = 0, j = 0; |
| 524 | struct regulatory_channel *cur_chan_list; |
| 525 | struct wlan_objmgr_pdev *pdev; |
| 526 | |
| 527 | if (!hdd_ctx || !hdd_ctx->hdd_pdev || !chan_list || !chan_num) |
| 528 | return -EINVAL; |
| 529 | |
| 530 | pdev = hdd_ctx->hdd_pdev; |
| 531 | cur_chan_list = qdf_mem_malloc(NUM_CHANNELS * |
| 532 | sizeof(struct regulatory_channel)); |
| 533 | if (!cur_chan_list) |
| 534 | return -ENOMEM; |
| 535 | |
| 536 | if (wlan_reg_get_current_chan_list(pdev, cur_chan_list) != |
| 537 | QDF_STATUS_SUCCESS) { |
| 538 | qdf_mem_free(cur_chan_list); |
| 539 | return -EINVAL; |
| 540 | } |
| 541 | |
| 542 | for (i = 0; i < NUM_CHANNELS; i++) { |
| 543 | uint32_t ch = cur_chan_list[i].chan_num; |
| 544 | enum channel_state state = wlan_reg_get_channel_state(pdev, |
| 545 | ch); |
| 546 | |
| 547 | if (state != CHANNEL_STATE_DISABLE && |
| 548 | state != CHANNEL_STATE_INVALID && |
| 549 | j < *chan_num) { |
| 550 | chan_list[j] = (uint8_t)ch; |
| 551 | j++; |
| 552 | } |
| 553 | } |
| 554 | *chan_num = j; |
| 555 | qdf_mem_free(cur_chan_list); |
| 556 | return 0; |
| 557 | } |
| 558 | |
| 559 | /** |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 560 | * hdd_validate_channel_and_bandwidth() - Validate the channel-bandwidth combo |
| 561 | * @adapter: HDD adapter |
| 562 | * @chan_number: Channel number |
| 563 | * @chan_bw: Bandwidth |
| 564 | * |
| 565 | * Checks if the given bandwidth is valid for the given channel number. |
| 566 | * |
| 567 | * Return: 0 for success, non-zero for failure |
| 568 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 569 | int hdd_validate_channel_and_bandwidth(struct hdd_adapter *adapter, |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 570 | uint32_t chan_number, |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 571 | enum phy_ch_width chan_bw) |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 572 | { |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 573 | uint8_t chan[NUM_CHANNELS]; |
| 574 | uint32_t len = NUM_CHANNELS, i; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 575 | bool found = false; |
| 576 | tHalHandle hal; |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 577 | int ret; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 578 | |
| 579 | hal = WLAN_HDD_GET_HAL_CTX(adapter); |
| 580 | if (!hal) { |
| 581 | hdd_err("Invalid HAL context"); |
| 582 | return -EINVAL; |
| 583 | } |
| 584 | |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 585 | ret = hdd_get_valid_chan(adapter->hdd_ctx, chan, |
| 586 | &len); |
| 587 | if (ret) { |
| 588 | hdd_err("error %d in getting valid channel list", ret); |
| 589 | return ret; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 590 | } |
| 591 | |
| 592 | for (i = 0; i < len; i++) { |
| 593 | if (chan[i] == chan_number) { |
| 594 | found = true; |
| 595 | break; |
| 596 | } |
| 597 | } |
| 598 | |
| 599 | if (found == false) { |
| 600 | hdd_err("Channel not in driver's valid channel list"); |
| 601 | return -EOPNOTSUPP; |
| 602 | } |
| 603 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 604 | if ((!WLAN_REG_IS_24GHZ_CH(chan_number)) && |
| 605 | (!WLAN_REG_IS_5GHZ_CH(chan_number))) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 606 | hdd_err("CH %d is not in 2.4GHz or 5GHz", chan_number); |
| 607 | return -EINVAL; |
| 608 | } |
| 609 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 610 | if (WLAN_REG_IS_24GHZ_CH(chan_number)) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 611 | if (chan_bw == CH_WIDTH_80MHZ) { |
| 612 | hdd_err("BW80 not possible in 2.4GHz band"); |
| 613 | return -EINVAL; |
| 614 | } |
| 615 | if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 14) && |
| 616 | (chan_bw != CH_WIDTH_MAX)) { |
| 617 | hdd_err("Only BW20 possible on channel 14"); |
| 618 | return -EINVAL; |
| 619 | } |
| 620 | } |
| 621 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 622 | if (WLAN_REG_IS_5GHZ_CH(chan_number)) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 623 | if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 165) && |
| 624 | (chan_bw != CH_WIDTH_MAX)) { |
| 625 | hdd_err("Only BW20 possible on channel 165"); |
| 626 | return -EINVAL; |
| 627 | } |
| 628 | } |
| 629 | |
| 630 | return 0; |
| 631 | } |
| 632 | |
Arunk Khandavalli | e1b3a38 | 2017-09-26 12:01:26 +0530 | [diff] [blame] | 633 | /** |
| 634 | * hdd_wait_for_recovery_completion() - Wait for cds recovery completion |
| 635 | * |
| 636 | * Block the unloading of the driver (or) interface up until the |
| 637 | * cds recovery is completed |
| 638 | * |
| 639 | * Return: true for recovery completion else false |
| 640 | */ |
| 641 | static bool hdd_wait_for_recovery_completion(void) |
| 642 | { |
| 643 | int retry = 0; |
| 644 | |
| 645 | /* Wait for recovery to complete */ |
| 646 | while (cds_is_driver_recovering()) { |
| 647 | if (retry == HDD_MOD_EXIT_SSR_MAX_RETRIES/2) |
| 648 | hdd_err("Recovery in progress; wait here!!!"); |
| 649 | msleep(1000); |
| 650 | if (retry++ == HDD_MOD_EXIT_SSR_MAX_RETRIES) { |
| 651 | hdd_err("SSR never completed, error"); |
| 652 | /* |
| 653 | * Trigger the bug_on in the internal builds, in the |
| 654 | * customer builds self-recovery will be enabled |
| 655 | * in those cases just return error. |
| 656 | */ |
| 657 | if (cds_is_self_recovery_enabled()) |
| 658 | return false; |
| 659 | QDF_BUG(0); |
| 660 | } |
| 661 | } |
| 662 | |
| 663 | hdd_info("Recovery completed successfully!"); |
| 664 | return true; |
| 665 | } |
| 666 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 667 | static int __hdd_netdev_notifier_call(struct notifier_block *nb, |
| 668 | unsigned long state, void *data) |
| 669 | { |
| 670 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 671 | struct netdev_notifier_info *dev_notif_info = data; |
| 672 | struct net_device *dev = dev_notif_info->dev; |
| 673 | #else |
| 674 | struct net_device *dev = data; |
| 675 | #endif |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 676 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 677 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 678 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 679 | hdd_enter_dev(dev); |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 680 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 681 | /* Make sure that this callback corresponds to our device. */ |
| 682 | if ((strncmp(dev->name, "wlan", 4)) && (strncmp(dev->name, "p2p", 3))) |
| 683 | return NOTIFY_DONE; |
| 684 | |
Samuel Ahn | c9c48ca | 2016-09-19 15:46:36 +0530 | [diff] [blame] | 685 | if ((adapter->magic != WLAN_HDD_ADAPTER_MAGIC) || |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 686 | (adapter->dev != dev)) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 687 | hdd_err("device adapter is not matching!!!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 688 | return NOTIFY_DONE; |
| 689 | } |
| 690 | |
| 691 | if (!dev->ieee80211_ptr) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 692 | hdd_err("ieee80211_ptr is NULL!!!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 693 | return NOTIFY_DONE; |
| 694 | } |
| 695 | |
| 696 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 697 | if (NULL == hdd_ctx) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 698 | hdd_err("HDD Context Null Pointer"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 699 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 700 | return NOTIFY_DONE; |
| 701 | } |
Jingxiang Ge | 9db9d23 | 2017-10-14 17:22:15 +0800 | [diff] [blame] | 702 | |
| 703 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) { |
| 704 | hdd_err("%s: Driver module is closed", __func__); |
| 705 | return NOTIFY_DONE; |
| 706 | } |
| 707 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 708 | if (cds_is_driver_recovering() || cds_is_driver_in_bad_state()) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 709 | return NOTIFY_DONE; |
| 710 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 711 | hdd_debug("%s New Net Device State = %lu", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 712 | dev->name, state); |
| 713 | |
| 714 | switch (state) { |
| 715 | case NETDEV_REGISTER: |
| 716 | break; |
| 717 | |
| 718 | case NETDEV_UNREGISTER: |
| 719 | break; |
| 720 | |
| 721 | case NETDEV_UP: |
| 722 | sme_ch_avoid_update_req(hdd_ctx->hHal); |
| 723 | break; |
| 724 | |
| 725 | case NETDEV_DOWN: |
| 726 | break; |
| 727 | |
| 728 | case NETDEV_CHANGE: |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 729 | if (adapter->is_link_up_service_needed) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 730 | complete(&adapter->linkup_event_var); |
| 731 | break; |
| 732 | |
| 733 | case NETDEV_GOING_DOWN: |
Sandeep Puligilla | 5f86d99 | 2017-10-29 14:58:53 -0700 | [diff] [blame] | 734 | if (ucfg_scan_get_vdev_status(adapter->hdd_vdev) != |
| 735 | SCAN_NOT_IN_PROGRESS) { |
Abhishek Singh | 69ccb51 | 2017-04-25 11:58:16 +0530 | [diff] [blame] | 736 | wlan_abort_scan(hdd_ctx->hdd_pdev, INVAL_PDEV_ID, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 737 | adapter->session_id, INVALID_SCAN_ID, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 738 | } else { |
hqu | eaa33ee | 2017-05-04 17:56:35 +0800 | [diff] [blame] | 739 | cds_flush_work(&adapter->scan_block_work); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 740 | hdd_debug("Scan is not Pending from user"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 741 | } |
Arunk Khandavalli | f0c0d76 | 2017-12-07 10:18:50 +0530 | [diff] [blame] | 742 | /* |
| 743 | * After NETDEV_GOING_DOWN, kernel calls hdd_stop.Irrespective |
| 744 | * of return status of hdd_stop call, kernel resets the IFF_UP |
| 745 | * flag after which driver does not send the cfg80211_scan_done. |
| 746 | * Ensure to cleanup the scan queue in NETDEV_GOING_DOWN |
| 747 | */ |
Sourav Mohapatra | 001cfaf | 2018-02-28 11:30:46 +0530 | [diff] [blame] | 748 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->hdd_pdev, dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 749 | break; |
| 750 | |
| 751 | default: |
| 752 | break; |
| 753 | } |
| 754 | |
| 755 | return NOTIFY_DONE; |
| 756 | } |
| 757 | |
| 758 | /** |
| 759 | * hdd_netdev_notifier_call() - netdev notifier callback function |
| 760 | * @nb: pointer to notifier block |
| 761 | * @state: state |
| 762 | * @ndev: ndev pointer |
| 763 | * |
| 764 | * Return: 0 on success, error number otherwise. |
| 765 | */ |
| 766 | static int hdd_netdev_notifier_call(struct notifier_block *nb, |
| 767 | unsigned long state, |
| 768 | void *ndev) |
| 769 | { |
| 770 | int ret; |
| 771 | |
| 772 | cds_ssr_protect(__func__); |
| 773 | ret = __hdd_netdev_notifier_call(nb, state, ndev); |
| 774 | cds_ssr_unprotect(__func__); |
| 775 | |
| 776 | return ret; |
| 777 | } |
| 778 | |
| 779 | struct notifier_block hdd_netdev_notifier = { |
| 780 | .notifier_call = hdd_netdev_notifier_call, |
| 781 | }; |
| 782 | |
| 783 | /* variable to hold the insmod parameters */ |
| 784 | static int con_mode; |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 785 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 786 | static int con_mode_ftm; |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 787 | int con_mode_monitor; |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 788 | |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 789 | /* Variable to hold connection mode including module parameter con_mode */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 790 | static int curr_con_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 791 | |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 792 | /** |
| 793 | * hdd_map_nl_chan_width() - Map NL channel width to internal representation |
| 794 | * @ch_width: NL channel width |
| 795 | * |
| 796 | * Converts the NL channel width to the driver's internal representation |
| 797 | * |
| 798 | * Return: Converted channel width. In case of non matching NL channel width, |
| 799 | * CH_WIDTH_MAX will be returned. |
| 800 | */ |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 801 | 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] | 802 | { |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 803 | uint8_t fw_ch_bw; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 804 | |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 805 | fw_ch_bw = wma_get_vht_ch_width(); |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 806 | switch (ch_width) { |
| 807 | case NL80211_CHAN_WIDTH_20_NOHT: |
| 808 | case NL80211_CHAN_WIDTH_20: |
| 809 | return CH_WIDTH_20MHZ; |
| 810 | case NL80211_CHAN_WIDTH_40: |
| 811 | return CH_WIDTH_40MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 812 | case NL80211_CHAN_WIDTH_80: |
| 813 | return CH_WIDTH_80MHZ; |
| 814 | case NL80211_CHAN_WIDTH_80P80: |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 815 | if (fw_ch_bw == WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ) |
| 816 | return CH_WIDTH_80P80MHZ; |
| 817 | else if (fw_ch_bw == WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ) |
| 818 | return CH_WIDTH_160MHZ; |
| 819 | else |
| 820 | return CH_WIDTH_80MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 821 | case NL80211_CHAN_WIDTH_160: |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 822 | if (fw_ch_bw >= WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ) |
| 823 | return CH_WIDTH_160MHZ; |
| 824 | else |
| 825 | return CH_WIDTH_80MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 826 | case NL80211_CHAN_WIDTH_5: |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 827 | return CH_WIDTH_5MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 828 | case NL80211_CHAN_WIDTH_10: |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 829 | return CH_WIDTH_10MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 830 | default: |
| 831 | hdd_err("Invalid channel width %d, setting to default", |
| 832 | ch_width); |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 833 | return CH_WIDTH_INVALID; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 834 | } |
| 835 | } |
| 836 | |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 837 | /* wlan_hdd_find_opclass() - Find operating class for a channel |
| 838 | * @hal: handler to HAL |
| 839 | * @channel: channel id |
| 840 | * @bw_offset: bandwidth offset |
| 841 | * |
| 842 | * Function invokes sme api to find the operating class |
| 843 | * |
| 844 | * Return: operating class |
| 845 | */ |
| 846 | uint8_t wlan_hdd_find_opclass(tHalHandle hal, uint8_t channel, |
| 847 | uint8_t bw_offset) |
| 848 | { |
| 849 | uint8_t opclass = 0; |
| 850 | |
| 851 | sme_get_opclass(hal, channel, bw_offset, &opclass); |
| 852 | return opclass; |
| 853 | } |
| 854 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 855 | /** |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 856 | * hdd_qdf_trace_enable() - configure initial QDF Trace enable |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 857 | * @module_id: Module whose trace level is being configured |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 858 | * @bitmask: Bitmask of log levels to be enabled |
| 859 | * |
| 860 | * Called immediately after the cfg.ini is read in order to configure |
| 861 | * the desired trace levels. |
| 862 | * |
| 863 | * Return: None |
| 864 | */ |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 865 | 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] | 866 | { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 867 | QDF_TRACE_LEVEL level; |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 868 | int qdf_print_idx = -1; |
| 869 | int status = -1; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 870 | /* |
| 871 | * if the bitmask is the default value, then a bitmask was not |
| 872 | * specified in cfg.ini, so leave the logging level alone (it |
| 873 | * will remain at the "compiled in" default value) |
| 874 | */ |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 875 | if (CFG_QDF_TRACE_ENABLE_DEFAULT == bitmask) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 876 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 877 | |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 878 | qdf_print_idx = qdf_get_pidx(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 879 | |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 880 | /* a mask was specified. start by disabling all logging */ |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 881 | status = qdf_print_set_category_verbose(qdf_print_idx, module_id, |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 882 | QDF_TRACE_LEVEL_NONE, 0); |
| 883 | |
| 884 | if (QDF_STATUS_SUCCESS != status) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 885 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 886 | /* now cycle through the bitmask until all "set" bits are serviced */ |
Ashish Kumar Dhanotiya | 83f286b | 2017-09-15 19:52:58 +0530 | [diff] [blame] | 887 | level = QDF_TRACE_LEVEL_NONE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 888 | while (0 != bitmask) { |
| 889 | if (bitmask & 1) { |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 890 | status = qdf_print_set_category_verbose(qdf_print_idx, |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 891 | module_id, level, 1); |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 892 | if (QDF_STATUS_SUCCESS != status) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 893 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 894 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 895 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 896 | level++; |
| 897 | bitmask >>= 1; |
| 898 | } |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 899 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 900 | } |
| 901 | |
| 902 | /** |
Chris Guo | 1751acf | 2017-07-03 14:09:01 +0800 | [diff] [blame] | 903 | * wlan_hdd_validate_context_in_loading() - check the HDD context in loading |
| 904 | * @hdd_ctx: HDD context pointer |
| 905 | * |
| 906 | * Return: 0 if the context is valid. Error code otherwise |
| 907 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 908 | int wlan_hdd_validate_context_in_loading(struct hdd_context *hdd_ctx) |
Chris Guo | 1751acf | 2017-07-03 14:09:01 +0800 | [diff] [blame] | 909 | { |
| 910 | if (NULL == hdd_ctx || NULL == hdd_ctx->config) { |
| 911 | hdd_info("%pS HDD context is Null", (void *)_RET_IP_); |
| 912 | return -ENODEV; |
| 913 | } |
| 914 | |
| 915 | if (cds_is_driver_recovering()) { |
| 916 | hdd_info("%pS Recovery in Progress. State: 0x%x Ignore!!!", |
| 917 | (void *)_RET_IP_, cds_get_driver_state()); |
| 918 | return -EAGAIN; |
| 919 | } |
| 920 | |
| 921 | if (hdd_ctx->start_modules_in_progress || |
| 922 | hdd_ctx->stop_modules_in_progress) { |
| 923 | hdd_info("%pS Start/Stop Modules in progress. Ignore!!!", |
| 924 | (void *)_RET_IP_); |
| 925 | return -EAGAIN; |
| 926 | } |
| 927 | |
| 928 | return 0; |
| 929 | } |
| 930 | |
| 931 | |
| 932 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 933 | * wlan_hdd_validate_context() - check the HDD context |
| 934 | * @hdd_ctx: HDD context pointer |
| 935 | * |
| 936 | * Return: 0 if the context is valid. Error code otherwise |
| 937 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 938 | int wlan_hdd_validate_context(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 939 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 940 | if (NULL == hdd_ctx || NULL == hdd_ctx->config) { |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 941 | hdd_err("%pS HDD context is Null", (void *)_RET_IP_); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 942 | return -ENODEV; |
| 943 | } |
| 944 | |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 945 | if (cds_is_driver_recovering()) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 946 | hdd_debug("%pS Recovery in Progress. State: 0x%x Ignore!!!", |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 947 | (void *)_RET_IP_, cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 948 | return -EAGAIN; |
| 949 | } |
| 950 | |
Yue Ma | 9f275d9 | 2017-09-14 16:58:41 -0700 | [diff] [blame] | 951 | if (cds_is_load_or_unload_in_progress()) { |
| 952 | hdd_debug("%pS Load or unload in progress, state: 0x%x, ignore!", |
| 953 | (void *)_RET_IP_, cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 954 | return -EAGAIN; |
Yue Ma | 9f275d9 | 2017-09-14 16:58:41 -0700 | [diff] [blame] | 955 | } |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 956 | |
| 957 | if (hdd_ctx->start_modules_in_progress || |
| 958 | hdd_ctx->stop_modules_in_progress) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 959 | hdd_debug("%pS Start/Stop Modules in progress. Ignore!!!", |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 960 | (void *)_RET_IP_); |
| 961 | return -EAGAIN; |
| 962 | } |
| 963 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 964 | if (cds_is_driver_in_bad_state()) { |
| 965 | hdd_debug("%pS driver in bad State: 0x%x Ignore!!!", |
| 966 | (void *)_RET_IP_, cds_get_driver_state()); |
| 967 | return -ENODEV; |
| 968 | } |
| 969 | |
Arunk Khandavalli | 2859fa1 | 2018-02-14 10:46:26 +0530 | [diff] [blame] | 970 | if (cds_is_fw_down()) { |
| 971 | hdd_debug("%pS FW is down: 0x%x Ignore!!!", |
| 972 | (void *)_RET_IP_, cds_get_driver_state()); |
| 973 | return -ENODEV; |
| 974 | } |
| 975 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 976 | return 0; |
| 977 | } |
| 978 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 979 | int hdd_validate_adapter(struct hdd_adapter *adapter) |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 980 | { |
| 981 | if (!adapter) { |
| 982 | hdd_err("adapter is null"); |
| 983 | return -EINVAL; |
| 984 | } |
| 985 | |
| 986 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) { |
| 987 | hdd_err("bad adapter magic: 0x%x (should be 0x%x)", |
| 988 | adapter->magic, WLAN_HDD_ADAPTER_MAGIC); |
| 989 | return -EINVAL; |
| 990 | } |
| 991 | |
| 992 | if (!adapter->dev) { |
| 993 | hdd_err("adapter net_device is null"); |
| 994 | return -EINVAL; |
| 995 | } |
| 996 | |
| 997 | if (!(adapter->dev->flags & IFF_UP)) { |
| 998 | hdd_info("adapter net_device is not up"); |
| 999 | return -EAGAIN; |
| 1000 | } |
| 1001 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1002 | if (wlan_hdd_validate_session_id(adapter->session_id)) { |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 1003 | hdd_info("adapter session is not open"); |
| 1004 | return -EAGAIN; |
| 1005 | } |
| 1006 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1007 | if (adapter->session_id >= MAX_NUMBER_OF_ADAPTERS) { |
| 1008 | hdd_err("bad adapter session Id: %u", adapter->session_id); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 1009 | return -EINVAL; |
| 1010 | } |
| 1011 | |
| 1012 | return 0; |
| 1013 | } |
| 1014 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1015 | /** |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 1016 | * wlan_hdd_validate_modules_state() - Check modules status |
| 1017 | * @hdd_ctx: HDD context pointer |
| 1018 | * |
| 1019 | * Check's the driver module's state and returns true if the |
| 1020 | * modules are enabled returns false if modules are closed. |
| 1021 | * |
| 1022 | * Return: True if modules are enabled or false. |
| 1023 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1024 | bool wlan_hdd_validate_modules_state(struct hdd_context *hdd_ctx) |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 1025 | { |
| 1026 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 1027 | if (hdd_ctx->driver_status != DRIVER_MODULES_ENABLED) { |
| 1028 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 1029 | hdd_info("Modules not enabled, Present status: %d", |
| 1030 | hdd_ctx->driver_status); |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 1031 | return false; |
| 1032 | } |
| 1033 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 1034 | return true; |
| 1035 | } |
| 1036 | |
| 1037 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1038 | * 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] | 1039 | * @struct hdd_adapter Hdd adapter. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1040 | * |
| 1041 | * This function sets the IBSS power save config parameters to WMA |
| 1042 | * which will send it to firmware if FW supports IBSS power save |
| 1043 | * before vdev start. |
| 1044 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1045 | * 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] | 1046 | * on failure. |
| 1047 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 1048 | QDF_STATUS hdd_set_ibss_power_save_params(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1049 | { |
| 1050 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1051 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1052 | |
| 1053 | if (hdd_ctx == NULL) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1054 | hdd_err("HDD context is null"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1055 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1056 | } |
| 1057 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1058 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1059 | WMA_VDEV_IBSS_SET_ATIM_WINDOW_SIZE, |
| 1060 | hdd_ctx->config->ibssATIMWinSize, |
| 1061 | VDEV_CMD); |
| 1062 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1063 | hdd_err("WMA_VDEV_IBSS_SET_ATIM_WINDOW_SIZE failed %d", ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1064 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1065 | } |
| 1066 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1067 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1068 | WMA_VDEV_IBSS_SET_POWER_SAVE_ALLOWED, |
| 1069 | hdd_ctx->config->isIbssPowerSaveAllowed, |
| 1070 | VDEV_CMD); |
| 1071 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1072 | hdd_err("WMA_VDEV_IBSS_SET_POWER_SAVE_ALLOWED failed %d", |
| 1073 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1074 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1075 | } |
| 1076 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1077 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1078 | WMA_VDEV_IBSS_SET_POWER_COLLAPSE_ALLOWED, |
| 1079 | hdd_ctx->config-> |
| 1080 | isIbssPowerCollapseAllowed, VDEV_CMD); |
| 1081 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1082 | hdd_err("WMA_VDEV_IBSS_SET_POWER_COLLAPSE_ALLOWED failed %d", |
| 1083 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1084 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1085 | } |
| 1086 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1087 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1088 | WMA_VDEV_IBSS_SET_AWAKE_ON_TX_RX, |
| 1089 | hdd_ctx->config->isIbssAwakeOnTxRx, |
| 1090 | VDEV_CMD); |
| 1091 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1092 | 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] | 1093 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1094 | } |
| 1095 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1096 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1097 | WMA_VDEV_IBSS_SET_INACTIVITY_TIME, |
| 1098 | hdd_ctx->config->ibssInactivityCount, |
| 1099 | VDEV_CMD); |
| 1100 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1101 | hdd_err("WMA_VDEV_IBSS_SET_INACTIVITY_TIME failed %d", ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1102 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1103 | } |
| 1104 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1105 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1106 | WMA_VDEV_IBSS_SET_TXSP_END_INACTIVITY_TIME, |
| 1107 | hdd_ctx->config->ibssTxSpEndInactivityTime, |
| 1108 | VDEV_CMD); |
| 1109 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1110 | hdd_err("WMA_VDEV_IBSS_SET_TXSP_END_INACTIVITY_TIME failed %d", |
| 1111 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1112 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1113 | } |
| 1114 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1115 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1116 | WMA_VDEV_IBSS_PS_SET_WARMUP_TIME_SECS, |
| 1117 | hdd_ctx->config->ibssPsWarmupTime, |
| 1118 | VDEV_CMD); |
| 1119 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1120 | hdd_err("WMA_VDEV_IBSS_PS_SET_WARMUP_TIME_SECS failed %d", |
| 1121 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1122 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1123 | } |
| 1124 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1125 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1126 | WMA_VDEV_IBSS_PS_SET_1RX_CHAIN_IN_ATIM_WINDOW, |
| 1127 | hdd_ctx->config->ibssPs1RxChainInAtimEnable, |
| 1128 | VDEV_CMD); |
| 1129 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1130 | hdd_err("WMA_VDEV_IBSS_PS_SET_1RX_CHAIN_IN_ATIM_WINDOW failed %d", |
| 1131 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1132 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1133 | } |
| 1134 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1135 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1136 | } |
| 1137 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1138 | #ifdef FEATURE_RUNTIME_PM |
| 1139 | /** |
| 1140 | * hdd_runtime_suspend_context_init() - API to initialize HDD Runtime Contexts |
| 1141 | * @hdd_ctx: HDD context |
| 1142 | * |
| 1143 | * Return: None |
| 1144 | */ |
| 1145 | static void hdd_runtime_suspend_context_init(struct hdd_context *hdd_ctx) |
| 1146 | { |
| 1147 | struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; |
| 1148 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1149 | qdf_runtime_lock_init(&ctx->dfs); |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 1150 | qdf_runtime_lock_init(&ctx->connect); |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1151 | |
| 1152 | wlan_scan_runtime_pm_init(hdd_ctx->hdd_pdev); |
| 1153 | } |
| 1154 | |
| 1155 | /** |
| 1156 | * hdd_runtime_suspend_context_deinit() - API to deinit HDD runtime context |
| 1157 | * @hdd_ctx: HDD Context |
| 1158 | * |
| 1159 | * Return: None |
| 1160 | */ |
| 1161 | static void hdd_runtime_suspend_context_deinit(struct hdd_context *hdd_ctx) |
| 1162 | { |
| 1163 | struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; |
| 1164 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1165 | qdf_runtime_lock_deinit(&ctx->dfs); |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 1166 | qdf_runtime_lock_deinit(&ctx->connect); |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1167 | |
| 1168 | wlan_scan_runtime_pm_deinit(hdd_ctx->hdd_pdev); |
| 1169 | } |
| 1170 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1171 | #else /* FEATURE_RUNTIME_PM */ |
| 1172 | static void hdd_runtime_suspend_context_init(struct hdd_context *hdd_ctx) {} |
| 1173 | static void hdd_runtime_suspend_context_deinit(struct hdd_context *hdd_ctx) {} |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1174 | #endif /* FEATURE_RUNTIME_PM */ |
| 1175 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1176 | #define INTF_MACADDR_MASK 0x7 |
| 1177 | |
| 1178 | /** |
| 1179 | * hdd_update_macaddr() - update mac address |
| 1180 | * @config: hdd configuration |
| 1181 | * @hw_macaddr: mac address |
| 1182 | * |
| 1183 | * Mac address for multiple virtual interface is found as following |
| 1184 | * i) The mac address of the first interface is just the actual hw mac address. |
| 1185 | * ii) MSM 3 or 4 bits of byte5 of the actual mac address are used to |
| 1186 | * define the mac address for the remaining interfaces and locally |
| 1187 | * admistered bit is set. INTF_MACADDR_MASK is based on the number of |
| 1188 | * supported virtual interfaces, right now this is 0x07 (meaning 8 |
| 1189 | * interface). |
| 1190 | * Byte[3] of second interface will be hw_macaddr[3](bit5..7) + 1, |
| 1191 | * for third interface it will be hw_macaddr[3](bit5..7) + 2, etc. |
| 1192 | * |
| 1193 | * Return: None |
| 1194 | */ |
| 1195 | void hdd_update_macaddr(struct hdd_config *config, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1196 | struct qdf_mac_addr hw_macaddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1197 | { |
| 1198 | int8_t i; |
| 1199 | uint8_t macaddr_b3, tmp_br3; |
| 1200 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1201 | qdf_mem_copy(config->intfMacAddr[0].bytes, hw_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1202 | QDF_MAC_ADDR_SIZE); |
| 1203 | for (i = 1; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1204 | qdf_mem_copy(config->intfMacAddr[i].bytes, hw_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1205 | QDF_MAC_ADDR_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1206 | macaddr_b3 = config->intfMacAddr[i].bytes[3]; |
| 1207 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + i) & |
| 1208 | INTF_MACADDR_MASK; |
| 1209 | macaddr_b3 += tmp_br3; |
| 1210 | |
| 1211 | /* XOR-ing bit-24 of the mac address. This will give enough |
| 1212 | * mac address range before collision |
| 1213 | */ |
| 1214 | macaddr_b3 ^= (1 << 7); |
| 1215 | |
| 1216 | /* Set locally administered bit */ |
| 1217 | config->intfMacAddr[i].bytes[0] |= 0x02; |
| 1218 | config->intfMacAddr[i].bytes[3] = macaddr_b3; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1219 | hdd_debug("config->intfMacAddr[%d]: " |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1220 | MAC_ADDRESS_STR, i, |
| 1221 | MAC_ADDR_ARRAY(config->intfMacAddr[i].bytes)); |
| 1222 | } |
| 1223 | } |
| 1224 | |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1225 | static int hdd_update_tdls_config(struct hdd_context *hdd_ctx) |
| 1226 | { |
| 1227 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 1228 | struct tdls_start_params tdls_cfg; |
| 1229 | struct tdls_user_config *config = &tdls_cfg.config; |
| 1230 | struct hdd_config *cfg = hdd_ctx->config; |
| 1231 | QDF_STATUS status; |
| 1232 | |
| 1233 | config->tdls_tx_states_period = cfg->fTDLSTxStatsPeriod; |
| 1234 | config->tdls_tx_pkt_threshold = cfg->fTDLSTxPacketThreshold; |
| 1235 | config->tdls_rx_pkt_threshold = cfg->fTDLSRxFrameThreshold; |
| 1236 | config->tdls_max_discovery_attempt = cfg->fTDLSMaxDiscoveryAttempt; |
| 1237 | config->tdls_idle_timeout = cfg->tdls_idle_timeout; |
| 1238 | config->tdls_idle_pkt_threshold = cfg->fTDLSIdlePacketThreshold; |
| 1239 | config->tdls_rssi_trigger_threshold = cfg->fTDLSRSSITriggerThreshold; |
| 1240 | config->tdls_rssi_teardown_threshold = cfg->fTDLSRSSITeardownThreshold; |
| 1241 | config->tdls_rssi_delta = cfg->fTDLSRSSIDelta; |
| 1242 | config->tdls_uapsd_mask = cfg->fTDLSUapsdMask; |
| 1243 | config->tdls_uapsd_inactivity_time = cfg->fTDLSPuapsdInactivityTimer; |
| 1244 | config->tdls_uapsd_pti_window = cfg->fTDLSPuapsdPTIWindow; |
| 1245 | config->tdls_uapsd_ptr_timeout = cfg->fTDLSPuapsdPTRTimeout; |
| 1246 | config->tdls_pre_off_chan_num = cfg->fTDLSPrefOffChanNum; |
| 1247 | config->tdls_pre_off_chan_bw = cfg->fTDLSPrefOffChanBandwidth; |
| 1248 | config->tdls_peer_kickout_threshold = cfg->tdls_peer_kickout_threshold; |
| 1249 | config->delayed_trig_framint = cfg->DelayedTriggerFrmInt; |
| 1250 | config->tdls_feature_flags = ((cfg->fEnableTDLSOffChannel ? |
| 1251 | 1 << TDLS_FEATURE_OFF_CHANNEL : 0) | |
| 1252 | (cfg->fEnableTDLSWmmMode ? 1 << TDLS_FEATURE_WMM : 0) | |
| 1253 | (cfg->fEnableTDLSBufferSta ? 1 << TDLS_FEATURE_BUFFER_STA : 0) | |
| 1254 | (cfg->fEnableTDLSSleepSta ? 1 << TDLS_FEATURE_SLEEP_STA : 0) | |
| 1255 | (cfg->enable_tdls_scan ? 1 << TDLS_FEATURE_SCAN : 0) | |
| 1256 | (cfg->fEnableTDLSSupport ? 1 << TDLS_FEATURE_ENABLE : 0) | |
| 1257 | (cfg->fEnableTDLSImplicitTrigger ? |
| 1258 | 1 << TDLS_FEAUTRE_IMPLICIT_TRIGGER : 0) | |
| 1259 | (cfg->fTDLSExternalControl ? |
| 1260 | 1 << TDLS_FEATURE_EXTERNAL_CONTROL : 0)); |
| 1261 | config->tdls_vdev_nss_2g = CFG_TDLS_NSS(cfg->vdev_type_nss_2g); |
| 1262 | config->tdls_vdev_nss_5g = CFG_TDLS_NSS(cfg->vdev_type_nss_5g); |
| 1263 | |
| 1264 | tdls_cfg.tdls_send_mgmt_req = eWNI_SME_TDLS_SEND_MGMT_REQ; |
| 1265 | tdls_cfg.tdls_add_sta_req = eWNI_SME_TDLS_ADD_STA_REQ; |
| 1266 | tdls_cfg.tdls_del_sta_req = eWNI_SME_TDLS_DEL_STA_REQ; |
| 1267 | tdls_cfg.tdls_update_peer_state = WMA_UPDATE_TDLS_PEER_STATE; |
| 1268 | tdls_cfg.tdls_del_all_peers = eWNI_SME_DEL_ALL_TDLS_PEERS; |
| 1269 | tdls_cfg.tdls_update_dp_vdev_flags = CDP_UPDATE_TDLS_FLAGS; |
| 1270 | tdls_cfg.tdls_event_cb = wlan_cfg80211_tdls_event_callback; |
| 1271 | tdls_cfg.tdls_evt_cb_data = psoc; |
Jeff Johnson | 1d40f5b | 2018-03-02 08:35:53 -0800 | [diff] [blame] | 1272 | tdls_cfg.tdls_peer_context = hdd_ctx; |
| 1273 | tdls_cfg.tdls_reg_peer = hdd_tdls_register_peer; |
| 1274 | tdls_cfg.tdls_dereg_peer = hdd_tdls_deregister_peer; |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1275 | tdls_cfg.tdls_wmm_cb = hdd_wmm_is_acm_allowed; |
| 1276 | tdls_cfg.tdls_wmm_cb_data = psoc; |
| 1277 | tdls_cfg.tdls_rx_cb = wlan_cfg80211_tdls_rx_callback; |
| 1278 | tdls_cfg.tdls_rx_cb_data = psoc; |
| 1279 | tdls_cfg.tdls_dp_vdev_update = hdd_update_dp_vdev_flags; |
| 1280 | |
| 1281 | status = ucfg_tdls_update_config(psoc, &tdls_cfg); |
| 1282 | if (status != QDF_STATUS_SUCCESS) { |
| 1283 | hdd_err("failed pmo psoc configuration"); |
| 1284 | return -EINVAL; |
| 1285 | } |
| 1286 | |
| 1287 | hdd_ctx->tdls_umac_comp_active = true; |
| 1288 | /* enable napier specific tdls data path */ |
| 1289 | hdd_ctx->tdls_nap_active = true; |
| 1290 | |
| 1291 | return 0; |
| 1292 | } |
| 1293 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1294 | static void hdd_update_tgt_services(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1295 | struct wma_tgt_services *cfg) |
| 1296 | { |
| 1297 | struct hdd_config *config = hdd_ctx->config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1298 | |
| 1299 | /* Set up UAPSD */ |
| 1300 | config->apUapsdEnabled &= cfg->uapsd; |
| 1301 | |
Krishna Kumaar Natarajan | 4f1d772 | 2017-03-03 21:12:51 -0800 | [diff] [blame] | 1302 | /* 11AX mode support */ |
| 1303 | if ((config->dot11Mode == eHDD_DOT11_MODE_11ax || |
| 1304 | config->dot11Mode == eHDD_DOT11_MODE_11ax_ONLY) && !cfg->en_11ax) |
| 1305 | config->dot11Mode = eHDD_DOT11_MODE_11ac; |
| 1306 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1307 | /* 11AC mode support */ |
| 1308 | if ((config->dot11Mode == eHDD_DOT11_MODE_11ac || |
| 1309 | config->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY) && !cfg->en_11ac) |
| 1310 | config->dot11Mode = eHDD_DOT11_MODE_AUTO; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1311 | |
| 1312 | /* ARP offload: override user setting if invalid */ |
| 1313 | config->fhostArpOffload &= cfg->arp_offload; |
| 1314 | |
| 1315 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 1316 | /* PNO offload */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1317 | hdd_debug("PNO Capability in f/w = %d", cfg->pno_offload); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1318 | if (cfg->pno_offload) |
| 1319 | config->PnoOffload = true; |
| 1320 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1321 | #ifdef FEATURE_WLAN_TDLS |
| 1322 | config->fEnableTDLSSupport &= cfg->en_tdls; |
Manjeet Singh | fdd2ac7 | 2016-09-02 18:11:43 +0530 | [diff] [blame] | 1323 | config->fEnableTDLSOffChannel = config->fEnableTDLSOffChannel && |
| 1324 | cfg->en_tdls_offchan; |
| 1325 | config->fEnableTDLSBufferSta = config->fEnableTDLSBufferSta && |
| 1326 | cfg->en_tdls_uapsd_buf_sta; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 1327 | if (config->fTDLSUapsdMask && cfg->en_tdls_uapsd_sleep_sta) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1328 | config->fEnableTDLSSleepSta = true; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 1329 | else |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1330 | config->fEnableTDLSSleepSta = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1331 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1332 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
| 1333 | config->isRoamOffloadEnabled &= cfg->en_roam_offload; |
| 1334 | #endif |
Will Huang | 496b36c | 2017-07-11 16:38:50 +0800 | [diff] [blame] | 1335 | config->sap_get_peer_info &= cfg->get_peer_info_enabled; |
Varun Reddy Yeturu | 62c3265 | 2017-10-26 15:32:35 -0700 | [diff] [blame] | 1336 | config->MAWCEnabled &= cfg->is_fw_mawc_capable; |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1337 | hdd_update_tdls_config(hdd_ctx); |
Krishna Kumaar Natarajan | 052c6e6 | 2015-09-28 15:32:55 -0700 | [diff] [blame] | 1338 | sme_update_tgt_services(hdd_ctx->hHal, cfg); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1339 | |
| 1340 | } |
| 1341 | |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1342 | /** |
| 1343 | * hdd_update_vdev_nss() - sets the vdev nss |
| 1344 | * @hdd_ctx: HDD context |
| 1345 | * |
| 1346 | * Sets the Nss per vdev type based on INI |
| 1347 | * |
| 1348 | * Return: None |
| 1349 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1350 | static void hdd_update_vdev_nss(struct hdd_context *hdd_ctx) |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1351 | { |
| 1352 | struct hdd_config *cfg_ini = hdd_ctx->config; |
| 1353 | uint8_t max_supp_nss = 1; |
| 1354 | |
Naveen Rawat | 10b1c15 | 2017-01-18 11:16:06 -0800 | [diff] [blame] | 1355 | if (cfg_ini->enable2x2 && !cds_is_sub_20_mhz_enabled()) |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1356 | max_supp_nss = 2; |
Liangwei Dong | 22810e8 | 2018-03-15 03:42:12 -0400 | [diff] [blame] | 1357 | hdd_debug("max nss %d vdev_type_nss_2g %x vdev_type_nss_5g %x", |
| 1358 | max_supp_nss, cfg_ini->vdev_type_nss_2g, |
| 1359 | cfg_ini->vdev_type_nss_5g); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1360 | |
| 1361 | sme_update_vdev_type_nss(hdd_ctx->hHal, max_supp_nss, |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1362 | cfg_ini->vdev_type_nss_2g, BAND_2G); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1363 | |
| 1364 | sme_update_vdev_type_nss(hdd_ctx->hHal, max_supp_nss, |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1365 | cfg_ini->vdev_type_nss_5g, BAND_5G); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1366 | } |
| 1367 | |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1368 | /** |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1369 | * hdd_update_wiphy_vhtcap() - Updates wiphy vhtcap fields |
| 1370 | * @hdd_ctx: HDD context |
| 1371 | * |
| 1372 | * Updates wiphy vhtcap fields |
| 1373 | * |
| 1374 | * Return: None |
| 1375 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1376 | static void hdd_update_wiphy_vhtcap(struct hdd_context *hdd_ctx) |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1377 | { |
| 1378 | struct ieee80211_supported_band *band_5g = |
| 1379 | hdd_ctx->wiphy->bands[NL80211_BAND_5GHZ]; |
| 1380 | uint32_t val; |
| 1381 | |
| 1382 | if (!band_5g) { |
| 1383 | hdd_debug("5GHz band disabled, skipping capability population"); |
| 1384 | return; |
| 1385 | } |
| 1386 | |
| 1387 | val = hdd_ctx->config->txBFCsnValue; |
| 1388 | band_5g->vht_cap.cap |= (val << IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT); |
| 1389 | |
| 1390 | val = NUM_OF_SOUNDING_DIMENSIONS; |
| 1391 | band_5g->vht_cap.cap |= |
| 1392 | (val << IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_SHIFT); |
| 1393 | |
| 1394 | hdd_info("Updated wiphy vhtcap:0x%x, CSNAntSupp:%d, NumSoundDim:%d", |
| 1395 | band_5g->vht_cap.cap, hdd_ctx->config->txBFCsnValue, val); |
| 1396 | } |
| 1397 | |
| 1398 | /** |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1399 | * hdd_update_hw_dbs_capable() - sets the dbs capability of the device |
| 1400 | * @hdd_ctx: HDD context |
| 1401 | * |
| 1402 | * Sets the DBS capability as per INI and firmware capability |
| 1403 | * |
| 1404 | * Return: None |
| 1405 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1406 | static void hdd_update_hw_dbs_capable(struct hdd_context *hdd_ctx) |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1407 | { |
| 1408 | struct hdd_config *cfg_ini = hdd_ctx->config; |
| 1409 | uint8_t hw_dbs_capable = 0; |
| 1410 | |
Tushnim Bhattacharyya | 49ed8ab | 2017-05-26 18:20:10 -0700 | [diff] [blame] | 1411 | if (policy_mgr_is_hw_dbs_capable(hdd_ctx->hdd_psoc) && |
| 1412 | ((cfg_ini->dual_mac_feature_disable == |
| 1413 | ENABLE_DBS_CXN_AND_SCAN) || |
| 1414 | (cfg_ini->dual_mac_feature_disable == |
| 1415 | ENABLE_DBS_CXN_AND_ENABLE_SCAN_WITH_ASYNC_SCAN_OFF))) |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1416 | hw_dbs_capable = 1; |
| 1417 | |
| 1418 | sme_update_hw_dbs_capable(hdd_ctx->hHal, hw_dbs_capable); |
| 1419 | } |
| 1420 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1421 | static void hdd_update_tgt_ht_cap(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1422 | struct wma_tgt_ht_cap *cfg) |
| 1423 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1424 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1425 | uint32_t value, val32; |
| 1426 | uint16_t val16; |
| 1427 | struct hdd_config *pconfig = hdd_ctx->config; |
| 1428 | tSirMacHTCapabilityInfo *phtCapInfo; |
| 1429 | uint8_t mcs_set[SIZE_OF_SUPPORTED_MCS_SET]; |
| 1430 | uint8_t enable_tx_stbc; |
| 1431 | |
| 1432 | /* check and update RX STBC */ |
| 1433 | if (pconfig->enableRxSTBC && !cfg->ht_rx_stbc) |
| 1434 | pconfig->enableRxSTBC = cfg->ht_rx_stbc; |
| 1435 | |
| 1436 | /* get the MPDU density */ |
| 1437 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_MPDU_DENSITY, &value); |
| 1438 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1439 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1440 | hdd_err("could not get MPDU DENSITY"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1441 | value = 0; |
| 1442 | } |
| 1443 | |
| 1444 | /* |
| 1445 | * MPDU density: |
| 1446 | * override user's setting if value is larger |
| 1447 | * than the one supported by target |
| 1448 | */ |
| 1449 | if (value > cfg->mpdu_density) { |
| 1450 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_MPDU_DENSITY, |
| 1451 | cfg->mpdu_density); |
| 1452 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1453 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1454 | hdd_err("could not set MPDU DENSITY to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1455 | } |
| 1456 | |
| 1457 | /* get the HT capability info */ |
| 1458 | 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] | 1459 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1460 | hdd_err("could not get HT capability info"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1461 | return; |
| 1462 | } |
| 1463 | val16 = (uint16_t) val32; |
| 1464 | phtCapInfo = (tSirMacHTCapabilityInfo *) &val16; |
| 1465 | |
| 1466 | /* Set the LDPC capability */ |
| 1467 | phtCapInfo->advCodingCap = cfg->ht_rx_ldpc; |
| 1468 | |
| 1469 | if (pconfig->ShortGI20MhzEnable && !cfg->ht_sgi_20) |
| 1470 | pconfig->ShortGI20MhzEnable = cfg->ht_sgi_20; |
| 1471 | |
| 1472 | if (pconfig->ShortGI40MhzEnable && !cfg->ht_sgi_40) |
| 1473 | pconfig->ShortGI40MhzEnable = cfg->ht_sgi_40; |
| 1474 | |
| 1475 | hdd_ctx->num_rf_chains = cfg->num_rf_chains; |
| 1476 | hdd_ctx->ht_tx_stbc_supported = cfg->ht_tx_stbc; |
| 1477 | |
| 1478 | enable_tx_stbc = pconfig->enableTxSTBC; |
| 1479 | |
| 1480 | if (pconfig->enable2x2 && (cfg->num_rf_chains == 2)) { |
| 1481 | pconfig->enable2x2 = 1; |
| 1482 | } else { |
| 1483 | pconfig->enable2x2 = 0; |
| 1484 | enable_tx_stbc = 0; |
| 1485 | |
| 1486 | /* 1x1 */ |
| 1487 | /* Update Rx Highest Long GI data Rate */ |
| 1488 | if (sme_cfg_set_int(hdd_ctx->hHal, |
| 1489 | WNI_CFG_VHT_RX_HIGHEST_SUPPORTED_DATA_RATE, |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1490 | VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1491 | == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1492 | 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] | 1493 | } |
| 1494 | |
| 1495 | /* Update Tx Highest Long GI data Rate */ |
| 1496 | if (sme_cfg_set_int |
| 1497 | (hdd_ctx->hHal, |
| 1498 | WNI_CFG_VHT_TX_HIGHEST_SUPPORTED_DATA_RATE, |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1499 | VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1) == |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1500 | QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1501 | hdd_err("VHT_TX_HIGHEST_SUPP_RATE_1_1 to CCM fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1502 | } |
| 1503 | } |
| 1504 | if (!(cfg->ht_tx_stbc && pconfig->enable2x2)) |
| 1505 | enable_tx_stbc = 0; |
| 1506 | phtCapInfo->txSTBC = enable_tx_stbc; |
| 1507 | |
| 1508 | val32 = val16; |
| 1509 | 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] | 1510 | if (status != QDF_STATUS_SUCCESS) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1511 | hdd_err("could not set HT capability to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1512 | #define WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES 0xff |
| 1513 | value = SIZE_OF_SUPPORTED_MCS_SET; |
| 1514 | 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] | 1515 | &value) == QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1516 | hdd_debug("Read MCS rate set"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1517 | |
| 1518 | if (pconfig->enable2x2) { |
| 1519 | for (value = 0; value < cfg->num_rf_chains; value++) |
| 1520 | mcs_set[value] = |
| 1521 | WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES; |
| 1522 | |
| 1523 | status = |
| 1524 | sme_cfg_set_str(hdd_ctx->hHal, |
| 1525 | WNI_CFG_SUPPORTED_MCS_SET, |
| 1526 | mcs_set, |
| 1527 | SIZE_OF_SUPPORTED_MCS_SET); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1528 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1529 | hdd_err("could not set MCS SET to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1530 | } |
| 1531 | } |
| 1532 | #undef WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES |
| 1533 | } |
| 1534 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1535 | static void hdd_update_tgt_vht_cap(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1536 | struct wma_tgt_vht_cap *cfg) |
| 1537 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1538 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1539 | uint32_t value = 0; |
| 1540 | struct hdd_config *pconfig = hdd_ctx->config; |
| 1541 | struct wiphy *wiphy = hdd_ctx->wiphy; |
| 1542 | struct ieee80211_supported_band *band_5g = |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 1543 | wiphy->bands[HDD_NL80211_BAND_5GHZ]; |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1544 | uint32_t temp = 0; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1545 | uint32_t ch_width = eHT_CHANNEL_WIDTH_80MHZ; |
jiad | 4a7a33c | 2017-08-08 15:32:24 +0800 | [diff] [blame] | 1546 | uint32_t hw_rx_ldpc_enabled; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1547 | |
Dustin Brown | 5e06bd3 | 2016-10-04 12:49:10 -0700 | [diff] [blame] | 1548 | if (!band_5g) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1549 | hdd_debug("5GHz band disabled, skipping capability population"); |
Dustin Brown | 5e06bd3 | 2016-10-04 12:49:10 -0700 | [diff] [blame] | 1550 | return; |
| 1551 | } |
| 1552 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1553 | /* Get the current MPDU length */ |
| 1554 | status = |
| 1555 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_MAX_MPDU_LENGTH, |
| 1556 | &value); |
| 1557 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1558 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1559 | hdd_err("could not get MPDU LENGTH"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1560 | value = 0; |
| 1561 | } |
| 1562 | |
| 1563 | /* |
| 1564 | * VHT max MPDU length: |
| 1565 | * override if user configured value is too high |
| 1566 | * that the target cannot support |
| 1567 | */ |
| 1568 | if (value > cfg->vht_max_mpdu) { |
| 1569 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1570 | WNI_CFG_VHT_MAX_MPDU_LENGTH, |
| 1571 | cfg->vht_max_mpdu); |
| 1572 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1573 | if (status == QDF_STATUS_E_FAILURE) |
| 1574 | hdd_err("could not set VHT MAX MPDU LENGTH"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1575 | } |
| 1576 | |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1577 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_BASIC_MCS_SET, &temp); |
| 1578 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtRxMCS; |
| 1579 | |
| 1580 | if (pconfig->enable2x2) |
| 1581 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtRxMCS2x2 << 2); |
| 1582 | |
| 1583 | if (sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_BASIC_MCS_SET, temp) == |
| 1584 | QDF_STATUS_E_FAILURE) { |
| 1585 | hdd_err("Could not pass VHT_BASIC_MCS_SET to CCM"); |
| 1586 | } |
| 1587 | |
| 1588 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_RX_MCS_MAP, &temp); |
| 1589 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtRxMCS; |
| 1590 | if (pconfig->enable2x2) |
| 1591 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtRxMCS2x2 << 2); |
| 1592 | |
| 1593 | if (sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_RX_MCS_MAP, temp) == |
| 1594 | QDF_STATUS_E_FAILURE) { |
| 1595 | hdd_err("Could not pass WNI_CFG_VHT_RX_MCS_MAP to CCM"); |
| 1596 | } |
| 1597 | |
| 1598 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_TX_MCS_MAP, &temp); |
| 1599 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtTxMCS; |
| 1600 | if (pconfig->enable2x2) |
| 1601 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtTxMCS2x2 << 2); |
| 1602 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1603 | hdd_debug("vhtRxMCS2x2 - %x temp - %u enable2x2 %d", |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1604 | pconfig->vhtRxMCS2x2, temp, pconfig->enable2x2); |
| 1605 | |
| 1606 | if (sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_TX_MCS_MAP, temp) == |
| 1607 | QDF_STATUS_E_FAILURE) { |
| 1608 | hdd_err("Could not pass WNI_CFG_VHT_TX_MCS_MAP to CCM"); |
| 1609 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1610 | /* Get the current RX LDPC setting */ |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1611 | 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] | 1612 | &value); |
| 1613 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1614 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1615 | hdd_err("could not get VHT LDPC CODING CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1616 | value = 0; |
| 1617 | } |
| 1618 | |
jiad | 4a7a33c | 2017-08-08 15:32:24 +0800 | [diff] [blame] | 1619 | /* Set HW RX LDPC capability */ |
| 1620 | hw_rx_ldpc_enabled = !!cfg->vht_rx_ldpc; |
| 1621 | if (hw_rx_ldpc_enabled != value) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1622 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1623 | WNI_CFG_VHT_LDPC_CODING_CAP, |
jiad | 4a7a33c | 2017-08-08 15:32:24 +0800 | [diff] [blame] | 1624 | hw_rx_ldpc_enabled); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1625 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1626 | if (status == QDF_STATUS_E_FAILURE) |
| 1627 | hdd_err("could not set VHT LDPC CODING CAP to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1628 | } |
| 1629 | |
| 1630 | /* Get current GI 80 value */ |
| 1631 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_SHORT_GI_80MHZ, |
| 1632 | &value); |
| 1633 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1634 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1635 | hdd_err("could not get SHORT GI 80MHZ"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1636 | value = 0; |
| 1637 | } |
| 1638 | |
| 1639 | /* set the Guard interval 80MHz */ |
| 1640 | if (value && !cfg->vht_short_gi_80) { |
| 1641 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1642 | WNI_CFG_VHT_SHORT_GI_80MHZ, |
| 1643 | cfg->vht_short_gi_80); |
| 1644 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1645 | if (status == QDF_STATUS_E_FAILURE) |
| 1646 | hdd_err("could not set SHORT GI 80MHZ to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1647 | } |
| 1648 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1649 | /* Get VHT TX STBC cap */ |
| 1650 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_TXSTBC, &value); |
| 1651 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1652 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1653 | hdd_err("could not get VHT TX STBC"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1654 | value = 0; |
| 1655 | } |
| 1656 | |
| 1657 | /* VHT TX STBC cap */ |
| 1658 | if (value && !cfg->vht_tx_stbc) { |
| 1659 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_TXSTBC, |
| 1660 | cfg->vht_tx_stbc); |
| 1661 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1662 | if (status == QDF_STATUS_E_FAILURE) |
| 1663 | hdd_err("could not set the VHT TX STBC to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1664 | } |
| 1665 | |
| 1666 | /* Get VHT RX STBC cap */ |
| 1667 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_RXSTBC, &value); |
| 1668 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1669 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1670 | hdd_err("could not get VHT RX STBC"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1671 | value = 0; |
| 1672 | } |
| 1673 | |
| 1674 | /* VHT RX STBC cap */ |
| 1675 | if (value && !cfg->vht_rx_stbc) { |
| 1676 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_RXSTBC, |
| 1677 | cfg->vht_rx_stbc); |
| 1678 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1679 | if (status == QDF_STATUS_E_FAILURE) |
| 1680 | hdd_err("could not set the VHT RX STBC to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1681 | } |
| 1682 | |
| 1683 | /* Get VHT SU Beamformer cap */ |
| 1684 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_SU_BEAMFORMER_CAP, |
| 1685 | &value); |
| 1686 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1687 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1688 | hdd_err("could not get VHT SU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1689 | value = 0; |
| 1690 | } |
| 1691 | |
| 1692 | /* set VHT SU Beamformer cap */ |
| 1693 | if (value && !cfg->vht_su_bformer) { |
| 1694 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1695 | WNI_CFG_VHT_SU_BEAMFORMER_CAP, |
| 1696 | cfg->vht_su_bformer); |
| 1697 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1698 | if (status == QDF_STATUS_E_FAILURE) |
| 1699 | hdd_err("could not set VHT SU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1700 | } |
| 1701 | |
| 1702 | /* check and update SU BEAMFORMEE capabality */ |
| 1703 | if (pconfig->enableTxBF && !cfg->vht_su_bformee) |
| 1704 | pconfig->enableTxBF = cfg->vht_su_bformee; |
| 1705 | |
| 1706 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1707 | WNI_CFG_VHT_SU_BEAMFORMEE_CAP, |
| 1708 | pconfig->enableTxBF); |
| 1709 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1710 | if (status == QDF_STATUS_E_FAILURE) |
| 1711 | hdd_err("could not set VHT SU BEAMFORMEE CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1712 | |
| 1713 | /* Get VHT MU Beamformer cap */ |
| 1714 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_MU_BEAMFORMER_CAP, |
| 1715 | &value); |
| 1716 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1717 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1718 | hdd_err("could not get VHT MU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1719 | value = 0; |
| 1720 | } |
| 1721 | |
| 1722 | /* set VHT MU Beamformer cap */ |
| 1723 | if (value && !cfg->vht_mu_bformer) { |
| 1724 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1725 | WNI_CFG_VHT_MU_BEAMFORMER_CAP, |
| 1726 | cfg->vht_mu_bformer); |
| 1727 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1728 | if (status == QDF_STATUS_E_FAILURE) |
| 1729 | hdd_err("could not set the VHT MU BEAMFORMER CAP to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1730 | } |
| 1731 | |
| 1732 | /* Get VHT MU Beamformee cap */ |
| 1733 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_MU_BEAMFORMEE_CAP, |
| 1734 | &value); |
| 1735 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1736 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1737 | hdd_err("could not get VHT MU BEAMFORMEE CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1738 | value = 0; |
| 1739 | } |
| 1740 | |
| 1741 | /* set VHT MU Beamformee cap */ |
| 1742 | if (value && !cfg->vht_mu_bformee) { |
| 1743 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1744 | WNI_CFG_VHT_MU_BEAMFORMEE_CAP, |
| 1745 | cfg->vht_mu_bformee); |
| 1746 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1747 | if (status == QDF_STATUS_E_FAILURE) |
| 1748 | hdd_err("could not set VHT MU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1749 | } |
| 1750 | |
| 1751 | /* Get VHT MAX AMPDU Len exp */ |
| 1752 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_AMPDU_LEN_EXPONENT, |
| 1753 | &value); |
| 1754 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1755 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1756 | hdd_err("could not get VHT AMPDU LEN"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1757 | value = 0; |
| 1758 | } |
| 1759 | |
| 1760 | /* |
| 1761 | * VHT max AMPDU len exp: |
| 1762 | * override if user configured value is too high |
| 1763 | * that the target cannot support. |
| 1764 | * Even though Rome publish ampdu_len=7, it can |
| 1765 | * only support 4 because of some h/w bug. |
| 1766 | */ |
| 1767 | |
| 1768 | if (value > cfg->vht_max_ampdu_len_exp) { |
| 1769 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1770 | WNI_CFG_VHT_AMPDU_LEN_EXPONENT, |
| 1771 | cfg->vht_max_ampdu_len_exp); |
| 1772 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1773 | if (status == QDF_STATUS_E_FAILURE) |
| 1774 | hdd_err("could not set the VHT AMPDU LEN EXP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1775 | } |
| 1776 | |
| 1777 | /* Get VHT TXOP PS CAP */ |
| 1778 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_TXOP_PS, &value); |
| 1779 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1780 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1781 | hdd_err("could not get VHT TXOP PS"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1782 | value = 0; |
| 1783 | } |
| 1784 | |
| 1785 | /* set VHT TXOP PS cap */ |
| 1786 | if (value && !cfg->vht_txop_ps) { |
| 1787 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_TXOP_PS, |
| 1788 | cfg->vht_txop_ps); |
| 1789 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1790 | if (status == QDF_STATUS_E_FAILURE) |
| 1791 | hdd_err("could not set the VHT TXOP PS"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1792 | } |
| 1793 | |
| 1794 | if (WMI_VHT_CAP_MAX_MPDU_LEN_11454 == cfg->vht_max_mpdu) |
| 1795 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454; |
| 1796 | else if (WMI_VHT_CAP_MAX_MPDU_LEN_7935 == cfg->vht_max_mpdu) |
| 1797 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991; |
| 1798 | else |
| 1799 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895; |
| 1800 | |
| 1801 | |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1802 | if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_80P80MHZ)) { |
| 1803 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1804 | WNI_CFG_VHT_SUPPORTED_CHAN_WIDTH_SET, |
| 1805 | VHT_CAP_160_AND_80P80_SUPP); |
| 1806 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1807 | hdd_err("could not set the VHT CAP 160"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1808 | band_5g->vht_cap.cap |= |
| 1809 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1810 | ch_width = eHT_CHANNEL_WIDTH_80P80MHZ; |
| 1811 | } else if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_160MHZ)) { |
| 1812 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1813 | WNI_CFG_VHT_SUPPORTED_CHAN_WIDTH_SET, |
| 1814 | VHT_CAP_160_SUPP); |
| 1815 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1816 | hdd_err("could not set the VHT CAP 160"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1817 | band_5g->vht_cap.cap |= |
| 1818 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1819 | ch_width = eHT_CHANNEL_WIDTH_160MHZ; |
| 1820 | } |
| 1821 | pconfig->vhtChannelWidth = QDF_MIN(pconfig->vhtChannelWidth, |
| 1822 | ch_width); |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1823 | /* Get the current GI 160 value */ |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1824 | status = sme_cfg_get_int(hdd_ctx->hHal, |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1825 | WNI_CFG_VHT_SHORT_GI_160_AND_80_PLUS_80MHZ, |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1826 | &value); |
| 1827 | if (status != QDF_STATUS_SUCCESS) { |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1828 | hdd_err("could not get GI 80 & 160"); |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1829 | value = 0; |
| 1830 | } |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1831 | /* set the Guard interval 160MHz */ |
| 1832 | if (value && !cfg->vht_short_gi_160) { |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1833 | status = sme_cfg_set_int(hdd_ctx->hHal, |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1834 | WNI_CFG_VHT_SHORT_GI_160_AND_80_PLUS_80MHZ, |
| 1835 | cfg->vht_short_gi_160); |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1836 | |
| 1837 | if (status == QDF_STATUS_E_FAILURE) |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1838 | hdd_err("failed to set SHORT GI 160MHZ"); |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1839 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1840 | |
| 1841 | if (cfg->vht_rx_ldpc & WMI_VHT_CAP_RX_LDPC) |
| 1842 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXLDPC; |
| 1843 | |
| 1844 | if (cfg->vht_short_gi_80 & WMI_VHT_CAP_SGI_80MHZ) |
| 1845 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_80; |
| 1846 | if (cfg->vht_short_gi_160 & WMI_VHT_CAP_SGI_160MHZ) |
| 1847 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_160; |
| 1848 | |
| 1849 | if (cfg->vht_tx_stbc & WMI_VHT_CAP_TX_STBC) |
| 1850 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_TXSTBC; |
| 1851 | |
| 1852 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_1SS) |
| 1853 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_1; |
| 1854 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_2SS) |
| 1855 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_2; |
| 1856 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_3SS) |
| 1857 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_3; |
| 1858 | |
| 1859 | band_5g->vht_cap.cap |= |
| 1860 | (cfg->vht_max_ampdu_len_exp << |
| 1861 | IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT); |
| 1862 | |
| 1863 | if (cfg->vht_su_bformer & WMI_VHT_CAP_SU_BFORMER) |
| 1864 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE; |
| 1865 | if (cfg->vht_su_bformee & WMI_VHT_CAP_SU_BFORMEE) |
| 1866 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE; |
| 1867 | if (cfg->vht_mu_bformer & WMI_VHT_CAP_MU_BFORMER) |
| 1868 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE; |
| 1869 | if (cfg->vht_mu_bformee & WMI_VHT_CAP_MU_BFORMEE) |
| 1870 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE; |
| 1871 | |
| 1872 | if (cfg->vht_txop_ps & WMI_VHT_CAP_TXOP_PS) |
| 1873 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_VHT_TXOP_PS; |
| 1874 | |
| 1875 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1876 | |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1877 | /** |
| 1878 | * hdd_generate_macaddr_auto() - Auto-generate mac address |
| 1879 | * @hdd_ctx: Pointer to the HDD context |
| 1880 | * |
| 1881 | * Auto-generate mac address using device serial number. |
| 1882 | * Keep the first 3 bytes of OUI as before and replace |
| 1883 | * the last 3 bytes with the lower 3 bytes of serial number. |
| 1884 | * |
| 1885 | * Return: 0 for success |
| 1886 | * Non zero failure code for errors |
| 1887 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1888 | static int hdd_generate_macaddr_auto(struct hdd_context *hdd_ctx) |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1889 | { |
| 1890 | unsigned int serialno = 0; |
| 1891 | struct qdf_mac_addr mac_addr = { |
| 1892 | {0x00, 0x0A, 0xF5, 0x00, 0x00, 0x00} |
| 1893 | }; |
| 1894 | |
Yuanyuan Liu | f97e822 | 2016-09-21 10:31:38 -0700 | [diff] [blame] | 1895 | serialno = pld_socinfo_get_serial_number(hdd_ctx->parent_dev); |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1896 | if (serialno == 0) |
| 1897 | return -EINVAL; |
| 1898 | |
| 1899 | serialno &= 0x00ffffff; |
| 1900 | |
| 1901 | mac_addr.bytes[3] = (serialno >> 16) & 0xff; |
| 1902 | mac_addr.bytes[4] = (serialno >> 8) & 0xff; |
| 1903 | mac_addr.bytes[5] = serialno & 0xff; |
| 1904 | |
| 1905 | hdd_update_macaddr(hdd_ctx->config, mac_addr); |
| 1906 | return 0; |
| 1907 | } |
| 1908 | |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1909 | /** |
| 1910 | * hdd_update_ra_rate_limit() - Update RA rate limit from target |
| 1911 | * configuration to cfg_ini in HDD |
| 1912 | * @hdd_ctx: Pointer to hdd_ctx |
| 1913 | * @cfg: target configuration |
| 1914 | * |
| 1915 | * Return: None |
| 1916 | */ |
| 1917 | #ifdef FEATURE_WLAN_RA_FILTERING |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1918 | static void hdd_update_ra_rate_limit(struct hdd_context *hdd_ctx, |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1919 | struct wma_tgt_cfg *cfg) |
| 1920 | { |
| 1921 | hdd_ctx->config->IsRArateLimitEnabled = cfg->is_ra_rate_limit_enabled; |
| 1922 | } |
| 1923 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1924 | static void hdd_update_ra_rate_limit(struct hdd_context *hdd_ctx, |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1925 | struct wma_tgt_cfg *cfg) |
| 1926 | { |
| 1927 | } |
| 1928 | #endif |
| 1929 | |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 1930 | static int hdd_green_ap_update_config(struct hdd_context *hdd_ctx) |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 1931 | { |
| 1932 | struct green_ap_user_cfg green_ap_cfg; |
| 1933 | struct hdd_config *cfg = hdd_ctx->config; |
| 1934 | QDF_STATUS status; |
| 1935 | |
| 1936 | green_ap_cfg.host_enable_egap = cfg->enable_egap; |
| 1937 | green_ap_cfg.egap_inactivity_time = cfg->egap_inact_time; |
| 1938 | green_ap_cfg.egap_wait_time = cfg->egap_wait_time; |
| 1939 | green_ap_cfg.egap_feature_flags = cfg->egap_feature_flag; |
| 1940 | |
| 1941 | status = ucfg_green_ap_update_user_config(hdd_ctx->hdd_pdev, |
| 1942 | &green_ap_cfg); |
| 1943 | if (status != QDF_STATUS_SUCCESS) { |
| 1944 | hdd_err("failed to update green ap user configuration"); |
| 1945 | return -EINVAL; |
| 1946 | } |
| 1947 | |
| 1948 | return 0; |
| 1949 | } |
| 1950 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1951 | void hdd_update_tgt_cfg(void *context, void *param) |
| 1952 | { |
Rajeev Kumar | f49dfdb | 2017-01-13 15:40:35 -0800 | [diff] [blame] | 1953 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1954 | struct hdd_context *hdd_ctx = (struct hdd_context *) context; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1955 | struct wma_tgt_cfg *cfg = param; |
| 1956 | uint8_t temp_band_cap; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1957 | struct cds_config_info *cds_cfg = cds_get_ini_config(); |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 1958 | uint8_t antenna_mode; |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 1959 | QDF_STATUS status; |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1960 | |
Dustin Brown | bd68fe1 | 2017-11-21 15:28:52 -0800 | [diff] [blame] | 1961 | ret = hdd_objmgr_create_and_store_pdev(hdd_ctx); |
| 1962 | if (ret) { |
| 1963 | hdd_err("Failed to create pdev; errno:%d", ret); |
| 1964 | QDF_BUG(0); |
Sandeep Puligilla | 1cf6ebe | 2017-04-04 14:40:27 -0700 | [diff] [blame] | 1965 | } else { |
Dustin Brown | bd68fe1 | 2017-11-21 15:28:52 -0800 | [diff] [blame] | 1966 | hdd_debug("New pdev has been created with pdev_id = %u", |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 1967 | hdd_ctx->hdd_pdev->pdev_objmgr.wlan_pdev_id); |
Amar Singhal | 410675c | 2018-01-10 12:14:21 -0800 | [diff] [blame] | 1968 | if (dispatcher_pdev_open(hdd_ctx->hdd_pdev)) { |
| 1969 | hdd_err("dispatcher pdev open failed"); |
| 1970 | QDF_BUG(0); |
| 1971 | } |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1972 | } |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 1973 | |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 1974 | ret = hdd_green_ap_update_config(hdd_ctx); |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 1975 | |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 1976 | ucfg_ipa_set_dp_handle(hdd_ctx->hdd_psoc, |
| 1977 | cds_get_context(QDF_MODULE_ID_SOC)); |
| 1978 | ucfg_ipa_set_txrx_handle(hdd_ctx->hdd_psoc, |
| 1979 | cds_get_context(QDF_MODULE_ID_TXRX)); |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 1980 | ucfg_ipa_reg_sap_xmit_cb(hdd_ctx->hdd_pdev, |
| 1981 | hdd_softap_hard_start_xmit); |
| 1982 | ucfg_ipa_reg_send_to_nw_cb(hdd_ctx->hdd_pdev, |
| 1983 | hdd_ipa_send_skb_to_network); |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 1984 | |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1985 | if (cds_cfg) { |
| 1986 | if (hdd_ctx->config->enable_sub_20_channel_width != |
| 1987 | WLAN_SUB_20_CH_WIDTH_NONE && !cfg->sub_20_support) { |
| 1988 | hdd_err("User requested sub 20 MHz channel width but unsupported by FW."); |
| 1989 | cds_cfg->sub_20_channel_width = |
| 1990 | WLAN_SUB_20_CH_WIDTH_NONE; |
| 1991 | } else { |
| 1992 | cds_cfg->sub_20_channel_width = |
| 1993 | hdd_ctx->config->enable_sub_20_channel_width; |
| 1994 | } |
| 1995 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1996 | |
| 1997 | /* first store the INI band capability */ |
| 1998 | temp_band_cap = hdd_ctx->config->nBandCapability; |
| 1999 | |
| 2000 | hdd_ctx->config->nBandCapability = cfg->band_cap; |
Vignesh Viswanathan | 731186f | 2017-09-18 13:47:37 +0530 | [diff] [blame] | 2001 | hdd_ctx->is_fils_roaming_supported = |
| 2002 | cfg->services.is_fils_roaming_supported; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2003 | |
Vignesh Viswanathan | 694e28e | 2018-01-18 20:53:57 +0530 | [diff] [blame] | 2004 | hdd_ctx->config->is_11k_offload_supported = |
| 2005 | cfg->services.is_11k_offload_supported; |
| 2006 | |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 2007 | /* |
| 2008 | * now overwrite the target band capability with INI |
| 2009 | * setting if INI setting is a subset |
| 2010 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2011 | |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 2012 | if ((hdd_ctx->config->nBandCapability == BAND_ALL) && |
| 2013 | (temp_band_cap != BAND_ALL)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2014 | hdd_ctx->config->nBandCapability = temp_band_cap; |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 2015 | else if ((hdd_ctx->config->nBandCapability != BAND_ALL) && |
| 2016 | (temp_band_cap != BAND_ALL) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2017 | (hdd_ctx->config->nBandCapability != temp_band_cap)) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 2018 | hdd_warn("ini BandCapability not supported by the target"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2019 | } |
| 2020 | |
Amar Singhal | 58b45ef | 2017-08-01 13:43:54 -0700 | [diff] [blame] | 2021 | hdd_ctx->curr_band = hdd_ctx->config->nBandCapability; |
| 2022 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 2023 | if (!cds_is_driver_recovering() || cds_is_driver_in_bad_state()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2024 | hdd_ctx->reg.reg_domain = cfg->reg_domain; |
| 2025 | hdd_ctx->reg.eeprom_rd_ext = cfg->eeprom_rd_ext; |
| 2026 | } |
| 2027 | |
| 2028 | /* This can be extended to other configurations like ht, vht cap... */ |
| 2029 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 2030 | if (!qdf_is_macaddr_zero(&cfg->hw_macaddr)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2031 | hdd_update_macaddr(hdd_ctx->config, cfg->hw_macaddr); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 2032 | hdd_ctx->update_mac_addr_to_fw = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2033 | } else { |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 2034 | static struct qdf_mac_addr default_mac_addr = { |
| 2035 | {0x00, 0x0A, 0xF5, 0x89, 0x89, 0xFF} |
| 2036 | }; |
| 2037 | if (qdf_is_macaddr_equal(&hdd_ctx->config->intfMacAddr[0], |
| 2038 | &default_mac_addr)) { |
| 2039 | if (hdd_generate_macaddr_auto(hdd_ctx) != 0) |
| 2040 | hdd_err("Fail to auto-generate MAC, using MAC from ini file " |
| 2041 | MAC_ADDRESS_STR, |
| 2042 | MAC_ADDR_ARRAY(hdd_ctx->config-> |
| 2043 | intfMacAddr[0].bytes)); |
| 2044 | } else { |
| 2045 | hdd_err("Invalid MAC passed from target, using MAC from ini file " |
| 2046 | MAC_ADDRESS_STR, |
| 2047 | MAC_ADDR_ARRAY(hdd_ctx->config-> |
| 2048 | intfMacAddr[0].bytes)); |
| 2049 | } |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 2050 | hdd_ctx->update_mac_addr_to_fw = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2051 | } |
| 2052 | |
| 2053 | hdd_ctx->target_fw_version = cfg->target_fw_version; |
Sandeep Puligilla | 3d6a8e2 | 2016-10-11 18:57:14 -0700 | [diff] [blame] | 2054 | hdd_ctx->target_fw_vers_ext = cfg->target_fw_vers_ext; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2055 | |
| 2056 | hdd_ctx->max_intf_count = cfg->max_intf_count; |
| 2057 | |
Jeff Johnson | c875e24 | 2016-09-23 18:12:34 -0700 | [diff] [blame] | 2058 | hdd_lpass_target_config(hdd_ctx, cfg); |
Ryan Hsu | 3c8f79f | 2015-12-02 16:45:09 -0800 | [diff] [blame] | 2059 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2060 | hdd_ctx->ap_arpns_support = cfg->ap_arpns_support; |
| 2061 | hdd_update_tgt_services(hdd_ctx, &cfg->services); |
| 2062 | |
| 2063 | hdd_update_tgt_ht_cap(hdd_ctx, &cfg->ht_cap); |
| 2064 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2065 | hdd_update_tgt_vht_cap(hdd_ctx, &cfg->vht_cap); |
Krishna Kumaar Natarajan | ed1efd9 | 2016-09-24 18:05:47 -0700 | [diff] [blame] | 2066 | if (cfg->services.en_11ax) { |
| 2067 | hdd_info("11AX: 11ax is enabled - update HDD config"); |
| 2068 | hdd_update_tgt_he_cap(hdd_ctx, cfg); |
| 2069 | } |
Tushnim Bhattacharyya | f44a9d8 | 2016-07-05 10:52:06 -0700 | [diff] [blame] | 2070 | |
| 2071 | hdd_update_vdev_nss(hdd_ctx); |
| 2072 | |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 2073 | hdd_update_hw_dbs_capable(hdd_ctx); |
| 2074 | |
Krishna Kumaar Natarajan | 1ae4911 | 2015-11-24 21:43:22 -0800 | [diff] [blame] | 2075 | hdd_ctx->config->fine_time_meas_cap &= cfg->fine_time_measurement_cap; |
Krunal Soni | e353194 | 2016-04-12 17:43:53 -0700 | [diff] [blame] | 2076 | hdd_ctx->fine_time_meas_cap_target = cfg->fine_time_measurement_cap; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2077 | hdd_debug("fine_time_meas_cap: 0x%x", |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 2078 | hdd_ctx->config->fine_time_meas_cap); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 2079 | |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 2080 | antenna_mode = (hdd_ctx->config->enable2x2 == 0x01) ? |
| 2081 | HDD_ANTENNA_MODE_2X2 : HDD_ANTENNA_MODE_1X1; |
| 2082 | hdd_update_smps_antenna_mode(hdd_ctx, antenna_mode); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2083 | hdd_debug("Init current antenna mode: %d", |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 2084 | hdd_ctx->current_antenna_mode); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 2085 | |
Rajeev Kumar | dd3bc60 | 2016-08-16 14:21:05 -0700 | [diff] [blame] | 2086 | hdd_ctx->bpf_enabled = (cfg->bpf_enabled && |
| 2087 | hdd_ctx->config->bpf_packet_filter_enable); |
Rajeev Kumar Sirasanagandla | 996e529 | 2016-11-22 21:20:33 +0530 | [diff] [blame] | 2088 | hdd_ctx->rcpi_enabled = cfg->rcpi_enabled; |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 2089 | hdd_update_ra_rate_limit(hdd_ctx, cfg); |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 2090 | |
Nachiket Kukade | 8b4bfd8 | 2017-05-25 18:34:48 +0530 | [diff] [blame] | 2091 | if ((hdd_ctx->config->txBFCsnValue > |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 2092 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED_FW_DEF) && |
| 2093 | !cfg->tx_bfee_8ss_enabled) |
Nachiket Kukade | 8b4bfd8 | 2017-05-25 18:34:48 +0530 | [diff] [blame] | 2094 | hdd_ctx->config->txBFCsnValue = |
| 2095 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED_FW_DEF; |
| 2096 | |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 2097 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 2098 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED, |
| 2099 | hdd_ctx->config->txBFCsnValue); |
| 2100 | if (QDF_IS_STATUS_ERROR(status)) |
Nachiket Kukade | 8b4bfd8 | 2017-05-25 18:34:48 +0530 | [diff] [blame] | 2101 | hdd_err("fw update WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED to CFG fails"); |
| 2102 | |
| 2103 | |
| 2104 | 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] | 2105 | cfg->bpf_enabled, hdd_ctx->config->bpf_packet_filter_enable, |
| 2106 | cfg->tx_bfee_8ss_enabled, hdd_ctx->config->txBFCsnValue); |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 2107 | |
| 2108 | /* |
| 2109 | * Update txBFCsnValue and NumSoundingDim values to vhtcap in wiphy |
| 2110 | */ |
| 2111 | hdd_update_wiphy_vhtcap(hdd_ctx); |
Manjeet Singh | 70d3d93 | 2016-12-20 20:41:10 +0530 | [diff] [blame] | 2112 | |
Rajeev Kumar Sirasanagandla | 4787300 | 2016-09-09 13:46:09 +0530 | [diff] [blame] | 2113 | hdd_ctx->wmi_max_len = cfg->wmi_max_len; |
| 2114 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 2115 | /* |
| 2116 | * This needs to be done after HDD pdev is created and stored since |
| 2117 | * it will access the HDD pdev object lock. |
| 2118 | */ |
| 2119 | hdd_runtime_suspend_context_init(hdd_ctx); |
| 2120 | |
Deepak Dhamdhere | 13230d3 | 2016-05-26 00:46:53 -0700 | [diff] [blame] | 2121 | /* Configure NAN datapath features */ |
| 2122 | hdd_nan_datapath_target_config(hdd_ctx, cfg); |
Arif Hussain | 759a023 | 2017-03-20 13:17:18 -0700 | [diff] [blame] | 2123 | hdd_ctx->dfs_cac_offload = cfg->dfs_cac_offload; |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 2124 | hdd_ctx->lte_coex_ant_share = cfg->services.lte_coex_ant_share; |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 2125 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_OBSS_DETECTION_OFFLOAD, |
| 2126 | cfg->obss_detection_offloaded); |
| 2127 | if (QDF_IS_STATUS_ERROR(status)) |
| 2128 | hdd_err("Couldn't pass WNI_CFG_OBSS_DETECTION_OFFLOAD to CFG"); |
Arif Hussain | 05fb487 | 2018-01-03 16:02:55 -0800 | [diff] [blame] | 2129 | |
| 2130 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 2131 | WNI_CFG_OBSS_COLOR_COLLISION_OFFLOAD, |
| 2132 | cfg->obss_color_collision_offloaded); |
| 2133 | if (QDF_IS_STATUS_ERROR(status)) |
| 2134 | hdd_err("Failed to set WNI_CFG_OBSS_COLOR_COLLISION_OFFLOAD"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2135 | } |
| 2136 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2137 | bool hdd_dfs_indicate_radar(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2138 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2139 | struct hdd_adapter *adapter; |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 2140 | struct hdd_ap_ctx *ap_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2141 | |
Jiachao Wu | f610d91 | 2018-01-23 17:47:32 +0800 | [diff] [blame] | 2142 | if (!hdd_ctx) { |
| 2143 | hdd_info("Couldn't get hdd_ctx"); |
| 2144 | return true; |
| 2145 | } |
| 2146 | |
| 2147 | if (hdd_ctx->config->disableDFSChSwitch) { |
Jeff Johnson | 36e74c4 | 2017-09-18 08:15:42 -0700 | [diff] [blame] | 2148 | hdd_info("skip tx block hdd_ctx=%pK, disableDFSChSwitch=%d", |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2149 | hdd_ctx, hdd_ctx->config->disableDFSChSwitch); |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 2150 | return true; |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2151 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2152 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 2153 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2154 | ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 2155 | |
| 2156 | if ((QDF_SAP_MODE == adapter->device_mode || |
| 2157 | QDF_P2P_GO_MODE == adapter->device_mode) && |
| 2158 | (wlan_reg_is_dfs_ch(hdd_ctx->hdd_pdev, |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 2159 | ap_ctx->operating_channel))) { |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2160 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->dfs_cac_block_tx = |
| 2161 | true; |
| 2162 | hdd_info("tx blocked for session: %d", |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 2163 | adapter->session_id); |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 2164 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2165 | } |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 2166 | |
| 2167 | return true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2168 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2169 | |
| 2170 | /** |
| 2171 | * hdd_is_valid_mac_address() - validate MAC address |
| 2172 | * @pMacAddr: Pointer to the input MAC address |
| 2173 | * |
| 2174 | * This function validates whether the given MAC address is valid or not |
| 2175 | * Expected MAC address is of the format XX:XX:XX:XX:XX:XX |
| 2176 | * where X is the hexa decimal digit character and separated by ':' |
| 2177 | * This algorithm works even if MAC address is not separated by ':' |
| 2178 | * |
| 2179 | * This code checks given input string mac contains exactly 12 hexadecimal |
| 2180 | * digits and a separator colon : appears in the input string only after |
| 2181 | * an even number of hex digits. |
| 2182 | * |
| 2183 | * Return: 1 for valid and 0 for invalid |
| 2184 | */ |
| 2185 | bool hdd_is_valid_mac_address(const uint8_t *pMacAddr) |
| 2186 | { |
| 2187 | int xdigit = 0; |
| 2188 | int separator = 0; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 2189 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2190 | while (*pMacAddr) { |
| 2191 | if (isxdigit(*pMacAddr)) { |
| 2192 | xdigit++; |
| 2193 | } else if (':' == *pMacAddr) { |
| 2194 | if (0 == xdigit || ((xdigit / 2) - 1) != separator) |
| 2195 | break; |
| 2196 | |
| 2197 | ++separator; |
| 2198 | } else { |
| 2199 | /* Invalid MAC found */ |
| 2200 | return 0; |
| 2201 | } |
| 2202 | ++pMacAddr; |
| 2203 | } |
| 2204 | return xdigit == 12 && (separator == 5 || separator == 0); |
| 2205 | } |
| 2206 | |
| 2207 | /** |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 2208 | * hdd_mon_mode_ether_setup() - Update monitor mode struct net_device. |
| 2209 | * @dev: Handle to struct net_device to be updated. |
| 2210 | * |
| 2211 | * Return: None |
| 2212 | */ |
| 2213 | static void hdd_mon_mode_ether_setup(struct net_device *dev) |
| 2214 | { |
| 2215 | dev->header_ops = NULL; |
| 2216 | dev->type = ARPHRD_IEEE80211_RADIOTAP; |
| 2217 | dev->hard_header_len = ETH_HLEN; |
| 2218 | dev->mtu = ETH_DATA_LEN; |
| 2219 | dev->addr_len = ETH_ALEN; |
| 2220 | dev->tx_queue_len = 1000; /* Ethernet wants good queues */ |
| 2221 | dev->flags = IFF_BROADCAST|IFF_MULTICAST; |
| 2222 | dev->priv_flags |= IFF_TX_SKB_SHARING; |
| 2223 | |
| 2224 | memset(dev->broadcast, 0xFF, ETH_ALEN); |
| 2225 | } |
| 2226 | |
| 2227 | /** |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2228 | * __hdd__mon_open() - HDD Open function |
| 2229 | * @dev: Pointer to net_device structure |
| 2230 | * |
| 2231 | * This is called in response to ifconfig up |
| 2232 | * |
| 2233 | * Return: 0 for success; non-zero for failure |
| 2234 | */ |
| 2235 | static int __hdd_mon_open(struct net_device *dev) |
| 2236 | { |
| 2237 | int ret; |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2238 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2239 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2240 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 2241 | hdd_enter_dev(dev); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2242 | |
| 2243 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 2244 | if (ret) |
| 2245 | return ret; |
| 2246 | |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 2247 | hdd_mon_mode_ether_setup(dev); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2248 | |
| 2249 | if (con_mode == QDF_GLOBAL_MONITOR_MODE) { |
| 2250 | ret = hdd_wlan_start_modules(hdd_ctx, adapter, false); |
| 2251 | if (ret) { |
| 2252 | hdd_err("Failed to start WLAN modules return"); |
| 2253 | return ret; |
| 2254 | } |
| 2255 | hdd_err("hdd_wlan_start_modules() successful !"); |
| 2256 | |
| 2257 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 2258 | ret = hdd_start_adapter(adapter); |
| 2259 | if (ret) { |
| 2260 | hdd_err("Failed to start adapter :%d", |
| 2261 | adapter->device_mode); |
| 2262 | return ret; |
| 2263 | } |
| 2264 | hdd_err("hdd_start_adapters() successful !"); |
| 2265 | } |
| 2266 | set_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 2267 | } |
| 2268 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2269 | ret = hdd_set_mon_rx_cb(dev); |
Ravi Joshi | 4f09595 | 2017-06-29 15:39:19 -0700 | [diff] [blame] | 2270 | |
| 2271 | if (!ret) |
| 2272 | ret = hdd_enable_monitor_mode(dev); |
| 2273 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2274 | return ret; |
| 2275 | } |
| 2276 | |
| 2277 | /** |
| 2278 | * hdd_mon_open() - Wrapper function for __hdd_mon_open to protect it from SSR |
| 2279 | * @dev: Pointer to net_device structure |
| 2280 | * |
| 2281 | * This is called in response to ifconfig up |
| 2282 | * |
| 2283 | * Return: 0 for success; non-zero for failure |
| 2284 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2285 | static int hdd_mon_open(struct net_device *dev) |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2286 | { |
| 2287 | int ret; |
| 2288 | |
| 2289 | cds_ssr_protect(__func__); |
| 2290 | ret = __hdd_mon_open(dev); |
| 2291 | cds_ssr_unprotect(__func__); |
| 2292 | |
| 2293 | return ret; |
| 2294 | } |
| 2295 | |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2296 | static QDF_STATUS |
| 2297 | wlan_hdd_update_dbs_scan_and_fw_mode_config(void) |
| 2298 | { |
| 2299 | struct policy_mgr_dual_mac_config cfg = {0}; |
| 2300 | QDF_STATUS status; |
| 2301 | uint32_t channel_select_logic_conc; |
| 2302 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 2303 | |
| 2304 | if (!hdd_ctx) { |
| 2305 | hdd_err("HDD context is NULL"); |
| 2306 | return QDF_STATUS_E_FAILURE; |
| 2307 | } |
| 2308 | |
| 2309 | |
| 2310 | if (!policy_mgr_is_hw_dbs_capable(hdd_ctx->hdd_psoc)) |
| 2311 | return QDF_STATUS_SUCCESS; |
| 2312 | |
| 2313 | cfg.scan_config = 0; |
| 2314 | cfg.fw_mode_config = 0; |
| 2315 | cfg.set_dual_mac_cb = policy_mgr_soc_set_dual_mac_cfg_cb; |
| 2316 | |
| 2317 | channel_select_logic_conc = hdd_ctx->config-> |
| 2318 | channel_select_logic_conc; |
| 2319 | |
| 2320 | if (hdd_ctx->config->dual_mac_feature_disable != |
| 2321 | DISABLE_DBS_CXN_AND_SCAN) { |
| 2322 | status = policy_mgr_get_updated_scan_and_fw_mode_config( |
| 2323 | hdd_ctx->hdd_psoc, &cfg.scan_config, |
| 2324 | &cfg.fw_mode_config, |
| 2325 | hdd_ctx->config->dual_mac_feature_disable, |
| 2326 | channel_select_logic_conc); |
| 2327 | |
| 2328 | if (status != QDF_STATUS_SUCCESS) { |
| 2329 | hdd_err("wma_get_updated_scan_and_fw_mode_config failed %d", |
| 2330 | status); |
| 2331 | return status; |
| 2332 | } |
| 2333 | } |
| 2334 | |
| 2335 | hdd_debug("send scan_cfg: 0x%x fw_mode_cfg: 0x%x to fw", |
| 2336 | cfg.scan_config, cfg.fw_mode_config); |
| 2337 | |
| 2338 | status = sme_soc_set_dual_mac_config(cfg); |
| 2339 | if (status != QDF_STATUS_SUCCESS) { |
| 2340 | hdd_err("sme_soc_set_dual_mac_config failed %d", status); |
| 2341 | return status; |
| 2342 | } |
| 2343 | |
| 2344 | return QDF_STATUS_SUCCESS; |
| 2345 | } |
| 2346 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2347 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2348 | * hdd_start_adapter() - Wrapper function for device specific adapter |
| 2349 | * @adapter: pointer to HDD adapter |
| 2350 | * |
| 2351 | * This function is called to start the device specific adapter for |
| 2352 | * the mode passed in the adapter's device_mode. |
| 2353 | * |
| 2354 | * Return: 0 for success; non-zero for failure |
| 2355 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2356 | int hdd_start_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2357 | { |
| 2358 | |
| 2359 | int ret; |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 2360 | enum QDF_OPMODE device_mode = adapter->device_mode; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2361 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 2362 | hdd_enter_dev(adapter->dev); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2363 | hdd_debug("Start_adapter for mode : %d", adapter->device_mode); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2364 | |
| 2365 | switch (device_mode) { |
| 2366 | case QDF_P2P_CLIENT_MODE: |
| 2367 | case QDF_P2P_DEVICE_MODE: |
| 2368 | case QDF_OCB_MODE: |
| 2369 | case QDF_STA_MODE: |
| 2370 | case QDF_MONITOR_MODE: |
| 2371 | ret = hdd_start_station_adapter(adapter); |
| 2372 | if (ret) |
| 2373 | goto err_start_adapter; |
| 2374 | break; |
| 2375 | case QDF_P2P_GO_MODE: |
| 2376 | case QDF_SAP_MODE: |
| 2377 | ret = hdd_start_ap_adapter(adapter); |
| 2378 | if (ret) |
| 2379 | goto err_start_adapter; |
| 2380 | break; |
Arun Khandavalli | b2f6c26 | 2016-08-18 19:07:19 +0530 | [diff] [blame] | 2381 | case QDF_IBSS_MODE: |
| 2382 | /* |
| 2383 | * For IBSS interface is initialized as part of |
| 2384 | * hdd_init_station_mode() |
| 2385 | */ |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2386 | goto exit_with_success; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2387 | case QDF_FTM_MODE: |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2388 | /* vdevs are dynamically managed by firmware in FTM */ |
| 2389 | goto exit_with_success; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2390 | default: |
| 2391 | hdd_err("Invalid session type %d", device_mode); |
| 2392 | QDF_ASSERT(0); |
| 2393 | goto err_start_adapter; |
| 2394 | } |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2395 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2396 | if (hdd_set_fw_params(adapter)) |
| 2397 | hdd_err("Failed to set the FW params for the adapter!"); |
| 2398 | |
| 2399 | /* |
| 2400 | * Action frame registered in one adapter which will |
| 2401 | * applicable to all interfaces |
| 2402 | */ |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 2403 | ret = wlan_hdd_cfg80211_register_frames(adapter); |
| 2404 | if (ret < 0) { |
| 2405 | hdd_err("Failed to register frames - ret %d", ret); |
| 2406 | goto err_start_adapter; |
| 2407 | } |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2408 | wlan_hdd_update_dbs_scan_and_fw_mode_config(); |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 2409 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2410 | exit_with_success: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2411 | hdd_exit(); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2412 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2413 | return 0; |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2414 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2415 | err_start_adapter: |
| 2416 | return -EINVAL; |
| 2417 | } |
| 2418 | |
| 2419 | /** |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 2420 | * hdd_enable_power_management() - API to Enable Power Management |
| 2421 | * |
| 2422 | * API invokes Bus Interface Layer power management functionality |
| 2423 | * |
| 2424 | * Return: None |
| 2425 | */ |
| 2426 | static void hdd_enable_power_management(void) |
| 2427 | { |
| 2428 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2429 | |
| 2430 | if (!hif_ctx) { |
| 2431 | hdd_err("Bus Interface Context is Invalid"); |
| 2432 | return; |
| 2433 | } |
| 2434 | |
| 2435 | hif_enable_power_management(hif_ctx, cds_is_packet_log_enabled()); |
| 2436 | } |
| 2437 | |
| 2438 | /** |
| 2439 | * hdd_disable_power_management() - API to disable Power Management |
| 2440 | * |
| 2441 | * API disable Bus Interface Layer Power management functionality |
| 2442 | * |
| 2443 | * Return: None |
| 2444 | */ |
| 2445 | static void hdd_disable_power_management(void) |
| 2446 | { |
| 2447 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2448 | |
| 2449 | if (!hif_ctx) { |
| 2450 | hdd_err("Bus Interface Context is Invalid"); |
| 2451 | return; |
| 2452 | } |
| 2453 | |
| 2454 | hif_disable_power_management(hif_ctx); |
| 2455 | } |
| 2456 | |
| 2457 | /** |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2458 | * hdd_update_hw_sw_info() - API to update the HW/SW information |
| 2459 | * |
| 2460 | * API to update the HW and SW information in the driver |
| 2461 | * |
| 2462 | * Return: None |
| 2463 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2464 | static void hdd_update_hw_sw_info(struct hdd_context *hdd_ctx) |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2465 | { |
| 2466 | void *hif_sc; |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2467 | size_t target_hw_name_len; |
| 2468 | const char *target_hw_name; |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2469 | |
| 2470 | hif_sc = cds_get_context(QDF_MODULE_ID_HIF); |
| 2471 | if (!hif_sc) { |
| 2472 | hdd_err("HIF context is NULL"); |
| 2473 | return; |
| 2474 | } |
| 2475 | |
| 2476 | /* |
| 2477 | * target hw version/revision would only be retrieved after firmware |
| 2478 | * download |
| 2479 | */ |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2480 | hif_get_hw_info(hif_sc, |
| 2481 | &hdd_ctx->target_hw_version, |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2482 | &hdd_ctx->target_hw_revision, |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2483 | &target_hw_name); |
| 2484 | |
| 2485 | if (hdd_ctx->target_hw_name) |
| 2486 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 2487 | |
| 2488 | target_hw_name_len = strlen(target_hw_name) + 1; |
| 2489 | hdd_ctx->target_hw_name = qdf_mem_malloc(target_hw_name_len); |
| 2490 | if (hdd_ctx->target_hw_name) |
| 2491 | qdf_mem_copy(hdd_ctx->target_hw_name, target_hw_name, |
| 2492 | target_hw_name_len); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2493 | |
| 2494 | /* Get the wlan hw/fw version */ |
| 2495 | hdd_wlan_get_version(hdd_ctx, NULL, NULL); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2496 | } |
| 2497 | |
| 2498 | /** |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2499 | * hdd_update_cds_ac_specs_params() - update cds ac_specs params |
| 2500 | * @hdd_ctx: Pointer to hdd context |
| 2501 | * |
| 2502 | * Return: none |
| 2503 | */ |
| 2504 | static void |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2505 | hdd_update_cds_ac_specs_params(struct hdd_context *hdd_ctx) |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2506 | { |
| 2507 | uint8_t num_entries = 0; |
| 2508 | uint8_t tx_sched_wrr_param[TX_SCHED_WRR_PARAMS_NUM]; |
| 2509 | uint8_t *tx_sched_wrr_ac; |
| 2510 | int i; |
| 2511 | cds_context_type *cds_ctx; |
| 2512 | |
| 2513 | if (NULL == hdd_ctx) |
| 2514 | return; |
| 2515 | |
| 2516 | if (NULL == hdd_ctx->config) { |
| 2517 | /* Do nothing if hdd_ctx is invalid */ |
| 2518 | hdd_err("%s: Warning: hdd_ctx->cfg_ini is NULL", __func__); |
| 2519 | return; |
| 2520 | } |
| 2521 | |
| 2522 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 2523 | |
| 2524 | if (!cds_ctx) { |
| 2525 | hdd_err("Invalid CDS Context"); |
| 2526 | return; |
| 2527 | } |
| 2528 | |
| 2529 | for (i = 0; i < OL_TX_NUM_WMM_AC; i++) { |
| 2530 | switch (i) { |
| 2531 | case OL_TX_WMM_AC_BE: |
| 2532 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_be; |
| 2533 | break; |
| 2534 | case OL_TX_WMM_AC_BK: |
| 2535 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_bk; |
| 2536 | break; |
| 2537 | case OL_TX_WMM_AC_VI: |
| 2538 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_vi; |
| 2539 | break; |
| 2540 | case OL_TX_WMM_AC_VO: |
| 2541 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_vo; |
| 2542 | break; |
| 2543 | default: |
| 2544 | tx_sched_wrr_ac = NULL; |
| 2545 | break; |
| 2546 | } |
| 2547 | |
| 2548 | hdd_string_to_u8_array(tx_sched_wrr_ac, |
| 2549 | tx_sched_wrr_param, |
| 2550 | &num_entries, |
| 2551 | sizeof(tx_sched_wrr_param)); |
| 2552 | |
| 2553 | if (num_entries == TX_SCHED_WRR_PARAMS_NUM) { |
| 2554 | cds_ctx->ac_specs[i].wrr_skip_weight = |
| 2555 | tx_sched_wrr_param[0]; |
| 2556 | cds_ctx->ac_specs[i].credit_threshold = |
| 2557 | tx_sched_wrr_param[1]; |
| 2558 | cds_ctx->ac_specs[i].send_limit = |
| 2559 | tx_sched_wrr_param[2]; |
| 2560 | cds_ctx->ac_specs[i].credit_reserve = |
| 2561 | tx_sched_wrr_param[3]; |
| 2562 | cds_ctx->ac_specs[i].discard_weight = |
| 2563 | tx_sched_wrr_param[4]; |
| 2564 | } |
| 2565 | |
| 2566 | num_entries = 0; |
| 2567 | } |
| 2568 | } |
| 2569 | |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 2570 | #ifdef IPA_OFFLOAD |
| 2571 | /** |
| 2572 | * hdd_update_ipa_component_config() - update ipa config |
| 2573 | * @hdd_ctx: Pointer to hdd context |
| 2574 | * |
| 2575 | * Return: none |
| 2576 | */ |
| 2577 | static void hdd_update_ipa_component_config(struct hdd_context *hdd_ctx) |
| 2578 | { |
| 2579 | struct hdd_config *cfg = hdd_ctx->config; |
| 2580 | struct wlan_ipa_config ipa_cfg; |
| 2581 | |
| 2582 | ipa_cfg.ipa_config = cfg->IpaConfig; |
| 2583 | ipa_cfg.desc_size = cfg->IpaDescSize; |
| 2584 | ipa_cfg.txbuf_count = cfg->IpaUcTxBufCount; |
| 2585 | ipa_cfg.bus_bw_high = cfg->busBandwidthHighThreshold; |
| 2586 | ipa_cfg.bus_bw_medium = cfg->busBandwidthMediumThreshold; |
| 2587 | ipa_cfg.bus_bw_low = cfg->busBandwidthLowThreshold; |
| 2588 | ipa_cfg.ipa_bw_high = cfg->IpaHighBandwidthMbps; |
| 2589 | ipa_cfg.ipa_bw_medium = cfg->IpaMediumBandwidthMbps; |
| 2590 | ipa_cfg.ipa_bw_low = cfg->IpaLowBandwidthMbps; |
| 2591 | |
| 2592 | ucfg_ipa_update_config(&ipa_cfg); |
| 2593 | } |
| 2594 | #else |
| 2595 | static void hdd_update_ipa_component_config(struct hdd_context *hdd_ctx) |
| 2596 | { |
| 2597 | } |
| 2598 | #endif |
| 2599 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2600 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2601 | static enum policy_mgr_con_mode wlan_hdd_get_mode_for_non_connected_vdev( |
| 2602 | struct wlan_objmgr_psoc *psoc, uint8_t vdev_id) |
| 2603 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2604 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2605 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2606 | |
| 2607 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 2608 | if (!adapter) { |
| 2609 | hdd_err("Adapter is NULL"); |
| 2610 | return PM_MAX_NUM_OF_MODE; |
| 2611 | } |
| 2612 | |
| 2613 | return policy_mgr_convert_device_mode_to_qdf_type( |
| 2614 | adapter->device_mode); |
| 2615 | } |
| 2616 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2617 | static void hdd_register_policy_manager_callback( |
| 2618 | struct wlan_objmgr_psoc *psoc) |
| 2619 | { |
| 2620 | struct policy_mgr_hdd_cbacks hdd_cbacks; |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 2621 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2622 | hdd_cbacks.sap_restart_chan_switch_cb = |
Jeff Johnson | 2381294 | 2017-10-06 11:33:55 -0700 | [diff] [blame] | 2623 | hdd_sap_restart_chan_switch_cb; |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2624 | hdd_cbacks.wlan_hdd_get_channel_for_sap_restart = |
| 2625 | wlan_hdd_get_channel_for_sap_restart; |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2626 | hdd_cbacks.get_mode_for_non_connected_vdev = |
| 2627 | wlan_hdd_get_mode_for_non_connected_vdev; |
Yeshwanth Sriram Guntuka | 469f957 | 2018-02-12 13:28:22 +0530 | [diff] [blame] | 2628 | hdd_cbacks.hdd_get_device_mode = hdd_get_device_mode; |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2629 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2630 | if (QDF_STATUS_SUCCESS != |
| 2631 | policy_mgr_register_hdd_cb(psoc, &hdd_cbacks)) { |
| 2632 | hdd_err("HDD callback registration with policy manager failed"); |
| 2633 | } |
| 2634 | } |
| 2635 | #else |
| 2636 | static void hdd_register_policy_manager_callback( |
| 2637 | struct wlan_objmgr_psoc *psoc) |
| 2638 | { |
| 2639 | } |
| 2640 | #endif |
| 2641 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2642 | static void hdd_nan_register_callbacks(struct hdd_context *hdd_ctx) |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2643 | { |
| 2644 | struct nan_callbacks cb_obj = {0}; |
| 2645 | |
| 2646 | cb_obj.ndi_open = hdd_ndi_open; |
| 2647 | cb_obj.ndi_close = hdd_ndi_close; |
| 2648 | cb_obj.ndi_start = hdd_ndi_start; |
| 2649 | cb_obj.ndi_delete = hdd_ndi_delete; |
| 2650 | cb_obj.drv_ndi_create_rsp_handler = hdd_ndi_drv_ndi_create_rsp_handler; |
| 2651 | cb_obj.drv_ndi_delete_rsp_handler = hdd_ndi_drv_ndi_delete_rsp_handler; |
| 2652 | |
Naveen Rawat | 37f62c8 | 2017-03-26 22:24:43 -0700 | [diff] [blame] | 2653 | cb_obj.new_peer_ind = hdd_ndp_new_peer_handler; |
| 2654 | cb_obj.get_peer_idx = hdd_ndp_get_peer_idx; |
Naveen Rawat | b3143ea | 2017-03-26 22:25:46 -0700 | [diff] [blame] | 2655 | cb_obj.peer_departed_ind = hdd_ndp_peer_departed_handler; |
Naveen Rawat | 37f62c8 | 2017-03-26 22:24:43 -0700 | [diff] [blame] | 2656 | |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2657 | os_if_nan_register_hdd_callbacks(hdd_ctx->hdd_psoc, &cb_obj); |
| 2658 | } |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2659 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2660 | #ifdef CONFIG_LEAK_DETECTION |
Dustin Brown | 4c5b990 | 2017-12-19 11:17:19 -0800 | [diff] [blame] | 2661 | /** |
| 2662 | * hdd_check_for_leaks() - Perform runtime memory leak checks |
| 2663 | * |
| 2664 | * This API triggers runtime memory leak detection. This feature enforces the |
| 2665 | * policy that any memory allocated at runtime must also be released at runtime. |
| 2666 | * |
| 2667 | * Allocating memory at runtime and releasing it at unload is effectively a |
| 2668 | * memory leak for configurations which never unload (e.g. LONU, statically |
| 2669 | * compiled driver). Such memory leaks are NOT false positives, and must be |
| 2670 | * fixed. |
| 2671 | * |
| 2672 | * Return: None |
| 2673 | */ |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2674 | static void hdd_check_for_leaks(void) |
| 2675 | { |
Dustin Brown | 4c5b990 | 2017-12-19 11:17:19 -0800 | [diff] [blame] | 2676 | /* DO NOT REMOVE these checks; for false positives, read above first */ |
| 2677 | |
Dustin Brown | 677e086 | 2017-10-10 16:30:09 -0700 | [diff] [blame] | 2678 | qdf_mc_timer_check_for_leaks(); |
Dustin Brown | 8e71150 | 2017-12-07 16:49:11 -0800 | [diff] [blame] | 2679 | qdf_nbuf_map_check_for_leaks(); |
Dustin Brown | e6b9d5a | 2017-12-14 15:18:49 -0800 | [diff] [blame] | 2680 | qdf_mem_check_for_leaks(); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2681 | } |
| 2682 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2683 | #define hdd_debug_domain_set(domain) qdf_debug_domain_set(domain) |
| 2684 | #else |
| 2685 | static inline void hdd_check_for_leaks(void) {} |
| 2686 | |
| 2687 | #define hdd_debug_domain_set(domain) |
| 2688 | #endif /* CONFIG_LEAK_DETECTION */ |
| 2689 | |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2690 | /** |
Paul Zhang | e03cf4c | 2018-01-19 18:33:22 +0800 | [diff] [blame] | 2691 | * hdd_update_country_code - Update country code |
| 2692 | * @hdd_ctx: HDD context |
| 2693 | * |
| 2694 | * Update country code based on module parameter country_code |
| 2695 | * |
| 2696 | * Return: 0 on success and errno on failure |
| 2697 | */ |
| 2698 | static int hdd_update_country_code(struct hdd_context *hdd_ctx) |
| 2699 | { |
| 2700 | if (!country_code) |
| 2701 | return 0; |
| 2702 | |
| 2703 | return hdd_reg_set_country(hdd_ctx, country_code); |
| 2704 | } |
| 2705 | |
| 2706 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2707 | * hdd_wlan_start_modules() - Single driver state machine for starting modules |
| 2708 | * @hdd_ctx: HDD context |
| 2709 | * @adapter: HDD adapter |
| 2710 | * @reinit: flag to indicate from SSR or normal path |
| 2711 | * |
| 2712 | * This function maintains the driver state machine it will be invoked from |
| 2713 | * startup, reinit and change interface. Depending on the driver state shall |
| 2714 | * perform the opening of the modules. |
| 2715 | * |
| 2716 | * Return: 0 for success; non-zero for failure |
| 2717 | */ |
Jeff Johnson | 60dc2b1 | 2017-09-28 14:56:02 -0700 | [diff] [blame] | 2718 | int hdd_wlan_start_modules(struct hdd_context *hdd_ctx, |
| 2719 | struct hdd_adapter *adapter, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2720 | bool reinit) |
| 2721 | { |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 2722 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2723 | qdf_device_t qdf_dev; |
| 2724 | QDF_STATUS status; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2725 | bool unint = false; |
| 2726 | void *hif_ctx; |
| 2727 | |
Jeff Johnson | 60dc2b1 | 2017-09-28 14:56:02 -0700 | [diff] [blame] | 2728 | hdd_debug("state:%d reinit:%d", hdd_ctx->driver_status, reinit); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2729 | |
| 2730 | qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 2731 | if (!qdf_dev) { |
| 2732 | hdd_err("QDF Device Context is Invalid return"); |
| 2733 | return -EINVAL; |
| 2734 | } |
| 2735 | |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 2736 | qdf_cancel_delayed_work(&hdd_ctx->iface_idle_work); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2737 | |
Dustin Brown | 1fe30a8 | 2017-10-03 16:13:36 -0700 | [diff] [blame] | 2738 | mutex_lock(&hdd_ctx->iface_change_lock); |
Arun Khandavalli | 5a62a82 | 2017-11-14 19:43:00 +0530 | [diff] [blame] | 2739 | if (hdd_ctx->driver_status == DRIVER_MODULES_ENABLED) { |
| 2740 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 2741 | hdd_info("Driver modules already Enabled"); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2742 | hdd_exit(); |
Arun Khandavalli | 5a62a82 | 2017-11-14 19:43:00 +0530 | [diff] [blame] | 2743 | return 0; |
| 2744 | } |
| 2745 | |
Dustin Brown | 1fe30a8 | 2017-10-03 16:13:36 -0700 | [diff] [blame] | 2746 | hdd_ctx->start_modules_in_progress = true; |
| 2747 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2748 | switch (hdd_ctx->driver_status) { |
| 2749 | case DRIVER_MODULES_UNINITIALIZED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2750 | hdd_info("Wlan transitioning (UNINITIALIZED -> CLOSED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2751 | unint = true; |
| 2752 | /* Fall through dont add break here */ |
| 2753 | case DRIVER_MODULES_CLOSED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2754 | hdd_info("Wlan transitioning (CLOSED -> OPENED)"); |
| 2755 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2756 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_ACTIVE); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2757 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2758 | if (!reinit && !unint) { |
| 2759 | ret = pld_power_on(qdf_dev->dev); |
| 2760 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2761 | hdd_err("Failed to Powerup the device; errno: %d", |
| 2762 | ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2763 | goto release_lock; |
| 2764 | } |
| 2765 | } |
Yuanyuan Liu | f8fe4bc | 2017-06-07 16:55:58 -0700 | [diff] [blame] | 2766 | |
| 2767 | pld_set_fw_log_mode(hdd_ctx->parent_dev, |
| 2768 | hdd_ctx->config->enable_fw_log); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2769 | ret = hdd_hif_open(qdf_dev->dev, qdf_dev->drv_hdl, qdf_dev->bid, |
| 2770 | qdf_dev->bus_type, |
| 2771 | (reinit == true) ? HIF_ENABLE_TYPE_REINIT : |
| 2772 | HIF_ENABLE_TYPE_PROBE); |
| 2773 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2774 | hdd_err("Failed to open hif; errno: %d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2775 | goto power_down; |
| 2776 | } |
| 2777 | |
| 2778 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
Arun Khandavalli | 1318b99 | 2016-08-09 11:04:57 +0530 | [diff] [blame] | 2779 | if (!hif_ctx) { |
| 2780 | hdd_err("hif context is null!!"); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2781 | ret = -EINVAL; |
Arun Khandavalli | 1318b99 | 2016-08-09 11:04:57 +0530 | [diff] [blame] | 2782 | goto power_down; |
| 2783 | } |
| 2784 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2785 | status = ol_cds_init(qdf_dev, hif_ctx); |
| 2786 | if (status != QDF_STATUS_SUCCESS) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2787 | hdd_err("No Memory to Create BMI Context; status: %d", |
| 2788 | status); |
| 2789 | ret = qdf_status_to_os_return(status); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2790 | goto hif_close; |
| 2791 | } |
| 2792 | |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 2793 | hdd_update_ipa_component_config(hdd_ctx); |
| 2794 | |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 2795 | ret = hdd_update_config(hdd_ctx); |
| 2796 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2797 | hdd_err("Failed to update configuration; errno: %d", |
| 2798 | ret); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2799 | goto cds_free; |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 2800 | } |
| 2801 | |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2802 | hdd_update_cds_ac_specs_params(hdd_ctx); |
| 2803 | |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 2804 | status = cds_open(hdd_ctx->hdd_psoc); |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2805 | if (QDF_IS_STATUS_ERROR(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2806 | hdd_err("Failed to Open CDS; status: %d", status); |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2807 | ret = qdf_status_to_os_return(status); |
| 2808 | goto deinit_config; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2809 | } |
| 2810 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2811 | /* initalize components configurations after psoc open */ |
| 2812 | ret = hdd_update_components_config(hdd_ctx); |
| 2813 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2814 | hdd_err("Failed to update component configs; errno: %d", |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2815 | ret); |
| 2816 | goto close; |
| 2817 | } |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2818 | status = cds_dp_open(hdd_ctx->hdd_psoc); |
| 2819 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2820 | hdd_err("Failed to Open cds post open; status: %d", |
| 2821 | status); |
| 2822 | ret = qdf_status_to_os_return(status); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2823 | goto close; |
| 2824 | } |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2825 | |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2826 | /* |
| 2827 | * NAN compoenet requires certian operations like, open adapter, |
| 2828 | * close adapter, etc. to be initiated by HDD, for those |
| 2829 | * register HDD callbacks with UMAC's NAN componenet. |
| 2830 | */ |
| 2831 | hdd_nan_register_callbacks(hdd_ctx); |
| 2832 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2833 | hdd_ctx->hHal = cds_get_context(QDF_MODULE_ID_SME); |
| 2834 | |
Jeff Johnson | 3a28012 | 2017-09-13 07:42:00 -0700 | [diff] [blame] | 2835 | status = cds_pre_enable(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2836 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2837 | hdd_err("Failed to pre-enable CDS; status: %d", status); |
| 2838 | ret = qdf_status_to_os_return(status); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2839 | goto cds_txrx_free; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2840 | } |
| 2841 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2842 | hdd_register_policy_manager_callback( |
| 2843 | hdd_ctx->hdd_psoc); |
| 2844 | |
Amar Singhal | 0928b19 | 2017-12-01 10:50:54 -0800 | [diff] [blame] | 2845 | hdd_sysfs_create_version_interface(hdd_ctx->hdd_psoc); |
| 2846 | |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2847 | hdd_update_hw_sw_info(hdd_ctx); |
Himanshu Agarwal | 0b9bbc3 | 2017-02-23 16:23:05 +0530 | [diff] [blame] | 2848 | hdd_ctx->driver_status = DRIVER_MODULES_OPENED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2849 | hdd_info("Wlan transitioned (now OPENED)"); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2850 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2851 | if (unint) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2852 | hdd_debug("In phase-1 initialization don't enable modules"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2853 | break; |
| 2854 | } |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 2855 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2856 | /* Fall through dont add break here */ |
| 2857 | case DRIVER_MODULES_OPENED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2858 | hdd_info("Wlan transitioning (OPENED -> ENABLED)"); |
| 2859 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2860 | if (!adapter) { |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2861 | hdd_alert("adapter is Null"); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2862 | ret = -EINVAL; |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2863 | goto post_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2864 | } |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 2865 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 2866 | hdd_err("in ftm mode, no need to configure cds modules"); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2867 | ret = -EINVAL; |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 2868 | break; |
| 2869 | } |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2870 | |
| 2871 | ret = hdd_configure_cds(hdd_ctx, adapter); |
| 2872 | if (ret) { |
| 2873 | hdd_err("Failed to Enable cds modules; errno: %d", ret); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2874 | goto post_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2875 | } |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2876 | |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 2877 | hdd_enable_power_management(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2878 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2879 | hdd_ctx->driver_status = DRIVER_MODULES_ENABLED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2880 | hdd_info("Wlan transitioned (now ENABLED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2881 | break; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2882 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2883 | default: |
| 2884 | hdd_err("WLAN start invoked in wrong state! :%d\n", |
| 2885 | hdd_ctx->driver_status); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2886 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2887 | goto release_lock; |
| 2888 | } |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2889 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 2890 | hdd_ctx->start_modules_in_progress = false; |
Paul Zhang | e03cf4c | 2018-01-19 18:33:22 +0800 | [diff] [blame] | 2891 | if (DRIVER_MODULES_ENABLED == hdd_ctx->driver_status) { |
| 2892 | ret = hdd_update_country_code(hdd_ctx); |
| 2893 | if (ret) |
| 2894 | hdd_err("Failed to update command line country code!"); |
| 2895 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2896 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2897 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2898 | hdd_exit(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2899 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2900 | return 0; |
| 2901 | |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2902 | post_disable: |
Rajeev Kumar | be02124 | 2017-02-16 16:12:23 -0800 | [diff] [blame] | 2903 | cds_post_disable(); |
Amar Singhal | 410675c | 2018-01-10 12:14:21 -0800 | [diff] [blame] | 2904 | dispatcher_pdev_close(hdd_ctx->hdd_pdev); |
Dustin Brown | bd68fe1 | 2017-11-21 15:28:52 -0800 | [diff] [blame] | 2905 | hdd_objmgr_release_and_destroy_pdev(hdd_ctx); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2906 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2907 | cds_txrx_free: |
| 2908 | cds_dp_close(hdd_ctx->hdd_psoc); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2909 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2910 | close: |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2911 | hdd_ctx->driver_status = DRIVER_MODULES_CLOSED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2912 | hdd_info("Wlan transition aborted (now CLOSED)"); |
| 2913 | |
Jeff Johnson | e4b1459 | 2017-09-13 14:23:33 -0700 | [diff] [blame] | 2914 | cds_close(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2915 | |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2916 | deinit_config: |
| 2917 | cds_deinit_ini_config(); |
| 2918 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2919 | cds_free: |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2920 | ol_cds_free(); |
| 2921 | |
| 2922 | hif_close: |
Jeff Johnson | 60dc2b1 | 2017-09-28 14:56:02 -0700 | [diff] [blame] | 2923 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2924 | hdd_hif_close(hdd_ctx, hif_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2925 | power_down: |
| 2926 | if (!reinit && !unint) |
| 2927 | pld_power_off(qdf_dev->dev); |
| 2928 | release_lock: |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 2929 | hdd_ctx->start_modules_in_progress = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2930 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2931 | |
| 2932 | /* many adapter resources are not freed by design in SSR case */ |
| 2933 | if (!reinit) |
| 2934 | hdd_check_for_leaks(); |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2935 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_INIT); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2936 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2937 | hdd_exit(); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2938 | |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 2939 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2940 | } |
| 2941 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2942 | #ifdef WIFI_POS_CONVERGED |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2943 | static int hdd_activate_wifi_pos(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2944 | { |
| 2945 | int ret = os_if_wifi_pos_register_nl(); |
| 2946 | |
| 2947 | if (ret) |
| 2948 | hdd_err("os_if_wifi_pos_register_nl failed"); |
| 2949 | |
| 2950 | return ret; |
| 2951 | } |
| 2952 | |
| 2953 | static int hdd_deactivate_wifi_pos(void) |
| 2954 | { |
| 2955 | int ret = os_if_wifi_pos_deregister_nl(); |
| 2956 | |
| 2957 | if (ret) |
| 2958 | hdd_err("os_if_wifi_pos_deregister_nl failed"); |
| 2959 | |
| 2960 | return ret; |
| 2961 | } |
| 2962 | |
| 2963 | /** |
| 2964 | * hdd_populate_wifi_pos_cfg - populates wifi_pos parameters |
| 2965 | * @hdd_ctx: hdd context |
| 2966 | * |
| 2967 | * Return: status of operation |
| 2968 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2969 | static void hdd_populate_wifi_pos_cfg(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2970 | { |
| 2971 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 2972 | struct hdd_config *cfg = hdd_ctx->config; |
| 2973 | |
| 2974 | wifi_pos_set_oem_target_type(psoc, hdd_ctx->target_type); |
| 2975 | wifi_pos_set_oem_fw_version(psoc, hdd_ctx->target_fw_version); |
| 2976 | wifi_pos_set_drv_ver_major(psoc, QWLAN_VERSION_MAJOR); |
| 2977 | wifi_pos_set_drv_ver_minor(psoc, QWLAN_VERSION_MINOR); |
| 2978 | wifi_pos_set_drv_ver_patch(psoc, QWLAN_VERSION_PATCH); |
| 2979 | wifi_pos_set_drv_ver_build(psoc, QWLAN_VERSION_BUILD); |
| 2980 | wifi_pos_set_dwell_time_min(psoc, cfg->nNeighborScanMinChanTime); |
| 2981 | wifi_pos_set_dwell_time_max(psoc, cfg->nNeighborScanMaxChanTime); |
| 2982 | } |
| 2983 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2984 | static int hdd_activate_wifi_pos(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2985 | { |
| 2986 | return oem_activate_service(hdd_ctx); |
| 2987 | } |
| 2988 | |
| 2989 | static int hdd_deactivate_wifi_pos(void) |
| 2990 | { |
| 2991 | return 0; |
| 2992 | } |
| 2993 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2994 | static void hdd_populate_wifi_pos_cfg(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2995 | { |
| 2996 | } |
| 2997 | #endif |
| 2998 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2999 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3000 | * __hdd_open() - HDD Open function |
| 3001 | * @dev: Pointer to net_device structure |
| 3002 | * |
| 3003 | * This is called in response to ifconfig up |
| 3004 | * |
| 3005 | * Return: 0 for success; non-zero for failure |
| 3006 | */ |
| 3007 | static int __hdd_open(struct net_device *dev) |
| 3008 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3009 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3010 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3011 | int ret; |
| 3012 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3013 | hdd_enter_dev(dev); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 3014 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_OPEN_REQUEST, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3015 | adapter->session_id, adapter->device_mode)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3016 | |
Ashish Kumar Dhanotiya | 15a7db5 | 2017-08-03 10:27:34 +0530 | [diff] [blame] | 3017 | /* Nothing to be done if device is unloading */ |
| 3018 | if (cds_is_driver_unloading()) { |
| 3019 | hdd_err("Driver is unloading can not open the hdd"); |
| 3020 | return -EBUSY; |
| 3021 | } |
| 3022 | |
Dustin Brown | 0184775 | 2017-10-25 13:56:27 -0700 | [diff] [blame] | 3023 | if (cds_is_driver_recovering()) { |
| 3024 | hdd_err("WLAN is currently recovering; Please try again."); |
| 3025 | return -EBUSY; |
| 3026 | } |
| 3027 | |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 3028 | if (qdf_atomic_read(&hdd_ctx->con_mode_flag)) { |
| 3029 | hdd_err("con_mode_handler is in progress; Please try again."); |
| 3030 | return -EBUSY; |
| 3031 | } |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3032 | |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 3033 | mutex_lock(&hdd_init_deinit_lock); |
Hanumanth Reddy Pothula | 006f383 | 2017-10-12 15:52:43 +0530 | [diff] [blame] | 3034 | hdd_start_driver_ops_timer(eHDD_DRV_OP_IFF_UP); |
| 3035 | |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3036 | /* |
| 3037 | * This scenario can be hit in cases where in the wlan driver after |
| 3038 | * registering the netdevices and there is a failure in driver |
| 3039 | * initialization. So return error gracefully because the netdevices |
| 3040 | * will be de-registered as part of the load failure. |
| 3041 | */ |
| 3042 | |
| 3043 | if (!cds_is_driver_loaded()) { |
| 3044 | hdd_err("Failed to start the wlan driver!!"); |
| 3045 | ret = -EIO; |
| 3046 | goto err_hdd_hdd_init_deinit_lock; |
| 3047 | } |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 3048 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3049 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3050 | ret = hdd_wlan_start_modules(hdd_ctx, adapter, false); |
| 3051 | if (ret) { |
| 3052 | hdd_err("Failed to start WLAN modules return"); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3053 | goto err_hdd_hdd_init_deinit_lock; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3054 | } |
| 3055 | |
| 3056 | |
| 3057 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 3058 | ret = hdd_start_adapter(adapter); |
| 3059 | if (ret) { |
| 3060 | hdd_err("Failed to start adapter :%d", |
| 3061 | adapter->device_mode); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3062 | goto err_hdd_hdd_init_deinit_lock; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3063 | } |
| 3064 | } |
| 3065 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3066 | set_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 3067 | 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] | 3068 | hdd_debug("Enabling Tx Queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3069 | /* Enable TX queues only when we are connected */ |
| 3070 | wlan_hdd_netif_queue_control(adapter, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3071 | WLAN_START_ALL_NETIF_QUEUE, |
| 3072 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3073 | } |
| 3074 | |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 3075 | /* Enable carrier and transmit queues for NDI */ |
| 3076 | if (WLAN_HDD_IS_NDI(adapter)) { |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 3077 | hdd_debug("Enabling Tx Queues"); |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 3078 | wlan_hdd_netif_queue_control(adapter, |
| 3079 | WLAN_START_ALL_NETIF_QUEUE_N_CARRIER, |
| 3080 | WLAN_CONTROL_PATH); |
| 3081 | } |
| 3082 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3083 | hdd_populate_wifi_pos_cfg(hdd_ctx); |
| 3084 | |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3085 | err_hdd_hdd_init_deinit_lock: |
Hanumanth Reddy Pothula | 006f383 | 2017-10-12 15:52:43 +0530 | [diff] [blame] | 3086 | hdd_stop_driver_ops_timer(); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3087 | mutex_unlock(&hdd_init_deinit_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3088 | return ret; |
| 3089 | } |
| 3090 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3091 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3092 | /** |
| 3093 | * hdd_open() - Wrapper function for __hdd_open to protect it from SSR |
| 3094 | * @dev: Pointer to net_device structure |
| 3095 | * |
| 3096 | * This is called in response to ifconfig up |
| 3097 | * |
| 3098 | * Return: 0 for success; non-zero for failure |
| 3099 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3100 | static int hdd_open(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3101 | { |
| 3102 | int ret; |
| 3103 | |
| 3104 | cds_ssr_protect(__func__); |
| 3105 | ret = __hdd_open(dev); |
| 3106 | cds_ssr_unprotect(__func__); |
| 3107 | |
| 3108 | return ret; |
| 3109 | } |
| 3110 | |
| 3111 | /** |
| 3112 | * __hdd_stop() - HDD stop function |
| 3113 | * @dev: Pointer to net_device structure |
| 3114 | * |
| 3115 | * This is called in response to ifconfig down |
| 3116 | * |
| 3117 | * Return: 0 for success; non-zero for failure |
| 3118 | */ |
| 3119 | static int __hdd_stop(struct net_device *dev) |
| 3120 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3121 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3122 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3123 | int ret; |
| 3124 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3125 | hdd_enter_dev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3126 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 3127 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_STOP_REQUEST, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3128 | adapter->session_id, adapter->device_mode)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3129 | |
| 3130 | ret = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 3131 | if (0 != ret) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3132 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3133 | |
| 3134 | /* Nothing to be done if the interface is not opened */ |
| 3135 | if (false == test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 3136 | hdd_err("NETDEV Interface is not OPENED"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3137 | return -ENODEV; |
| 3138 | } |
| 3139 | |
| 3140 | /* Make sure the interface is marked as closed */ |
| 3141 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 3142 | |
| 3143 | hdd_debug("Disabling Auto Power save timer"); |
| 3144 | sme_ps_disable_auto_ps_timer( |
| 3145 | WLAN_HDD_GET_HAL_CTX(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3146 | adapter->session_id); |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 3147 | |
| 3148 | /* |
| 3149 | * Disable TX on the interface, after this hard_start_xmit() will not |
| 3150 | * be called on that interface |
| 3151 | */ |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 3152 | hdd_info("Disabling queues, adapter device mode: %s(%d)", |
Kabilan Kannan | 8dac350 | 2017-10-30 12:40:27 -0700 | [diff] [blame] | 3153 | hdd_device_mode_to_string(adapter->device_mode), |
| 3154 | adapter->device_mode); |
| 3155 | |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 3156 | wlan_hdd_netif_queue_control(adapter, |
| 3157 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 3158 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3159 | |
| 3160 | /* |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 3161 | * NAN data interface is different in some sense. The traffic on NDI is |
| 3162 | * bursty in nature and depends on the need to transfer. The service |
| 3163 | * layer may down the interface after the usage and up again when |
| 3164 | * required. In some sense, the NDI is expected to be available |
| 3165 | * (like SAP) iface until NDI delete request is issued by the service |
| 3166 | * layer. Skip BSS termination and adapter deletion for NAN Data |
| 3167 | * interface (NDI). |
| 3168 | */ |
| 3169 | if (WLAN_HDD_IS_NDI(adapter)) |
| 3170 | return 0; |
| 3171 | |
| 3172 | /* |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3173 | * The interface is marked as down for outside world (aka kernel) |
| 3174 | * But the driver is pretty much alive inside. The driver needs to |
| 3175 | * tear down the existing connection on the netdev (session) |
| 3176 | * cleanup the data pipes and wait until the control plane is stabilized |
| 3177 | * for this interface. The call also needs to wait until the above |
| 3178 | * mentioned actions are completed before returning to the caller. |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3179 | * Notice that hdd_stop_adapter is requested not to close the session |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3180 | * That is intentional to be able to scan if it is a STA/P2P interface |
| 3181 | */ |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 3182 | hdd_stop_adapter(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3183 | |
| 3184 | /* DeInit the adapter. This ensures datapath cleanup as well */ |
| 3185 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
| 3186 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3187 | |
| 3188 | /* |
Hanumanth Reddy Pothula | 3862ca9 | 2018-01-12 16:44:10 +0530 | [diff] [blame] | 3189 | * Upon wifi turn off, DUT has to flush the scan results so if |
| 3190 | * this is the last cli iface, flush the scan database. |
| 3191 | */ |
| 3192 | if (!hdd_is_cli_iface_up(hdd_ctx)) |
| 3193 | sme_scan_flush_result(hdd_ctx->hHal); |
| 3194 | |
| 3195 | /* |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3196 | * Find if any iface is up. If any iface is up then can't put device to |
| 3197 | * sleep/power save mode |
| 3198 | */ |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 3199 | if (hdd_check_for_opened_interfaces(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3200 | hdd_debug("Closing all modules from the hdd_stop"); |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 3201 | qdf_sched_delayed_work(&hdd_ctx->iface_idle_work, |
| 3202 | hdd_ctx->config->iface_change_wait_time); |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 3203 | hdd_prevent_suspend_timeout( |
| 3204 | hdd_ctx->config->iface_change_wait_time, |
| 3205 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3206 | } |
| 3207 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3208 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3209 | return 0; |
| 3210 | } |
| 3211 | |
| 3212 | /** |
| 3213 | * hdd_stop() - Wrapper function for __hdd_stop to protect it from SSR |
| 3214 | * @dev: pointer to net_device structure |
| 3215 | * |
| 3216 | * This is called in response to ifconfig down |
| 3217 | * |
| 3218 | * Return: 0 for success and error number for failure |
| 3219 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3220 | static int hdd_stop(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3221 | { |
| 3222 | int ret; |
| 3223 | |
| 3224 | cds_ssr_protect(__func__); |
| 3225 | ret = __hdd_stop(dev); |
| 3226 | cds_ssr_unprotect(__func__); |
| 3227 | |
| 3228 | return ret; |
| 3229 | } |
| 3230 | |
| 3231 | /** |
| 3232 | * __hdd_uninit() - HDD uninit function |
| 3233 | * @dev: Pointer to net_device structure |
| 3234 | * |
| 3235 | * This is called during the netdev unregister to uninitialize all data |
| 3236 | * associated with the device |
| 3237 | * |
| 3238 | * Return: None |
| 3239 | */ |
| 3240 | static void __hdd_uninit(struct net_device *dev) |
| 3241 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3242 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 3243 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3244 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3245 | hdd_enter_dev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3246 | |
| 3247 | do { |
| 3248 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3249 | hdd_err("Invalid magic"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3250 | break; |
| 3251 | } |
| 3252 | |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 3253 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3254 | if (!hdd_ctx) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3255 | hdd_err("NULL hdd_ctx"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3256 | break; |
| 3257 | } |
| 3258 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3259 | if (dev != adapter->dev) |
| 3260 | hdd_err("Invalid device reference"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3261 | |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 3262 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3263 | |
| 3264 | /* after uninit our adapter structure will no longer be valid */ |
| 3265 | adapter->dev = NULL; |
| 3266 | adapter->magic = 0; |
| 3267 | } while (0); |
| 3268 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3269 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3270 | } |
| 3271 | |
| 3272 | /** |
| 3273 | * hdd_uninit() - Wrapper function to protect __hdd_uninit from SSR |
| 3274 | * @dev: pointer to net_device structure |
| 3275 | * |
| 3276 | * This is called during the netdev unregister to uninitialize all data |
| 3277 | * associated with the device |
| 3278 | * |
| 3279 | * Return: none |
| 3280 | */ |
| 3281 | static void hdd_uninit(struct net_device *dev) |
| 3282 | { |
| 3283 | cds_ssr_protect(__func__); |
| 3284 | __hdd_uninit(dev); |
| 3285 | cds_ssr_unprotect(__func__); |
| 3286 | } |
| 3287 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3288 | static int hdd_open_cesium_nl_sock(void) |
| 3289 | { |
| 3290 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 3291 | struct netlink_kernel_cfg cfg = { |
| 3292 | .groups = WLAN_NLINK_MCAST_GRP_ID, |
| 3293 | .input = NULL |
| 3294 | }; |
| 3295 | #endif |
| 3296 | int ret = 0; |
| 3297 | |
| 3298 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 3299 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 3300 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 7, 0)) |
| 3301 | THIS_MODULE, |
| 3302 | #endif |
| 3303 | &cfg); |
| 3304 | #else |
| 3305 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 3306 | WLAN_NLINK_MCAST_GRP_ID, |
| 3307 | NULL, NULL, THIS_MODULE); |
| 3308 | #endif |
| 3309 | |
| 3310 | if (cesium_nl_srv_sock == NULL) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 3311 | hdd_err("NLINK: cesium netlink_kernel_create failed"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3312 | ret = -ECONNREFUSED; |
| 3313 | } |
| 3314 | |
| 3315 | return ret; |
| 3316 | } |
| 3317 | |
| 3318 | static void hdd_close_cesium_nl_sock(void) |
| 3319 | { |
| 3320 | if (NULL != cesium_nl_srv_sock) { |
| 3321 | netlink_kernel_release(cesium_nl_srv_sock); |
| 3322 | cesium_nl_srv_sock = NULL; |
| 3323 | } |
| 3324 | } |
| 3325 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3326 | /** |
| 3327 | * __hdd_set_mac_address() - set the user specified mac address |
| 3328 | * @dev: Pointer to the net device. |
| 3329 | * @addr: Pointer to the sockaddr. |
| 3330 | * |
| 3331 | * This function sets the user specified mac address using |
| 3332 | * the command ifconfig wlanX hw ether <mac adress>. |
| 3333 | * |
| 3334 | * Return: 0 for success, non zero for failure |
| 3335 | */ |
| 3336 | static int __hdd_set_mac_address(struct net_device *dev, void *addr) |
| 3337 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3338 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3339 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3340 | struct sockaddr *psta_mac_addr = addr; |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3341 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3342 | int ret; |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3343 | struct qdf_mac_addr mac_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3344 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3345 | hdd_enter_dev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3346 | |
Hanumanth Reddy Pothula | 5c7a781 | 2018-03-09 12:55:32 +0530 | [diff] [blame] | 3347 | if (netif_running(dev)) { |
| 3348 | hdd_err("On iface up, set mac address change isn't supported"); |
| 3349 | return -EBUSY; |
| 3350 | } |
| 3351 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3352 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3353 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 3354 | if (0 != ret) |
| 3355 | return ret; |
| 3356 | |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3357 | qdf_mem_copy(&mac_addr, psta_mac_addr->sa_data, sizeof(mac_addr)); |
| 3358 | |
| 3359 | if (qdf_is_macaddr_zero(&mac_addr)) { |
| 3360 | hdd_err("MAC is all zero"); |
| 3361 | return -EINVAL; |
| 3362 | } |
| 3363 | |
| 3364 | if (qdf_is_macaddr_broadcast(&mac_addr)) { |
| 3365 | hdd_err("MAC is Broadcast"); |
| 3366 | return -EINVAL; |
| 3367 | } |
| 3368 | |
| 3369 | if (ETHER_IS_MULTICAST(psta_mac_addr->sa_data)) { |
| 3370 | hdd_err("MAC is Multicast"); |
| 3371 | return -EINVAL; |
| 3372 | } |
| 3373 | |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 3374 | memcpy(&adapter->mac_addr, psta_mac_addr->sa_data, ETH_ALEN); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3375 | memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN); |
| 3376 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3377 | hdd_exit(); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3378 | return qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3379 | } |
| 3380 | |
| 3381 | /** |
| 3382 | * hdd_set_mac_address() - Wrapper function to protect __hdd_set_mac_address() |
| 3383 | * function from SSR |
| 3384 | * @dev: pointer to net_device structure |
| 3385 | * @addr: Pointer to the sockaddr |
| 3386 | * |
| 3387 | * This function sets the user specified mac address using |
| 3388 | * the command ifconfig wlanX hw ether <mac adress>. |
| 3389 | * |
| 3390 | * Return: 0 for success. |
| 3391 | */ |
| 3392 | static int hdd_set_mac_address(struct net_device *dev, void *addr) |
| 3393 | { |
| 3394 | int ret; |
| 3395 | |
| 3396 | cds_ssr_protect(__func__); |
| 3397 | ret = __hdd_set_mac_address(dev, addr); |
| 3398 | cds_ssr_unprotect(__func__); |
| 3399 | |
| 3400 | return ret; |
| 3401 | } |
| 3402 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3403 | uint8_t *wlan_hdd_get_intf_addr(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3404 | { |
| 3405 | int i; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3406 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3407 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3408 | if (0 == ((hdd_ctx->config->intfAddrMask) & (1 << i))) |
| 3409 | break; |
| 3410 | } |
| 3411 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3412 | if (QDF_MAX_CONCURRENCY_PERSONA == i) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3413 | return NULL; |
| 3414 | |
| 3415 | hdd_ctx->config->intfAddrMask |= (1 << i); |
| 3416 | return &hdd_ctx->config->intfMacAddr[i].bytes[0]; |
| 3417 | } |
| 3418 | |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 3419 | void wlan_hdd_release_intf_addr(struct hdd_context *hdd_ctx, |
| 3420 | uint8_t *releaseAddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3421 | { |
| 3422 | int i; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3423 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3424 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3425 | if (!memcmp(releaseAddr, |
| 3426 | &hdd_ctx->config->intfMacAddr[i].bytes[0], |
| 3427 | 6)) { |
| 3428 | hdd_ctx->config->intfAddrMask &= ~(1 << i); |
| 3429 | break; |
| 3430 | } |
| 3431 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3432 | } |
| 3433 | |
| 3434 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 3435 | /** |
| 3436 | * __hdd_set_multicast_list() - set the multicast address list |
| 3437 | * @dev: Pointer to the WLAN device. |
| 3438 | * @skb: Pointer to OS packet (sk_buff). |
| 3439 | * |
| 3440 | * This funciton sets the multicast address list. |
| 3441 | * |
| 3442 | * Return: None |
| 3443 | */ |
| 3444 | static void __hdd_set_multicast_list(struct net_device *dev) |
| 3445 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3446 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3447 | int i = 0, status; |
| 3448 | struct netdev_hw_addr *ha; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3449 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3450 | struct pmo_mc_addr_list_params *mc_list_request = NULL; |
| 3451 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 3452 | int mc_count = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3453 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3454 | hdd_enter_dev(dev); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3455 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3456 | goto out; |
Mukul Sharma | 51c4494 | 2015-10-30 19:30:19 +0530 | [diff] [blame] | 3457 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3458 | status = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 3459 | if (0 != status) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3460 | goto out; |
| 3461 | |
Dustin Brown | c788acb | 2017-08-01 17:43:51 -0700 | [diff] [blame] | 3462 | status = hdd_validate_adapter(adapter); |
| 3463 | if (status) |
| 3464 | goto out; |
| 3465 | |
Arunk Khandavalli | 6a22788 | 2017-12-12 19:31:08 +0530 | [diff] [blame] | 3466 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) { |
| 3467 | hdd_err("%s: Driver module is closed", __func__); |
| 3468 | return; |
| 3469 | } |
| 3470 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3471 | mc_list_request = qdf_mem_malloc(sizeof(*mc_list_request)); |
| 3472 | if (!mc_list_request) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3473 | hdd_err("Cannot allocate mc_list_request"); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3474 | goto out; |
| 3475 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3476 | |
Hanumanth Reddy Pothula | ca84ec5 | 2017-02-21 12:09:45 +0530 | [diff] [blame] | 3477 | /* Delete already configured multicast address list */ |
| 3478 | if (adapter->mc_addr_list.mc_cnt > 0) { |
| 3479 | hdd_info("clear previously configured MC address list"); |
| 3480 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3481 | pmo_mc_list_change_notify); |
| 3482 | } |
| 3483 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3484 | if (dev->flags & IFF_ALLMULTI) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3485 | hdd_debug("allow all multicast frames"); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3486 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3487 | pmo_mc_list_change_notify); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3488 | } else { |
| 3489 | mc_count = netdev_mc_count(dev); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3490 | if (mc_count > pmo_ucfg_max_mc_addr_supported(psoc)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3491 | 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] | 3492 | pmo_ucfg_max_mc_addr_supported(psoc)); |
| 3493 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3494 | pmo_mc_list_change_notify); |
| 3495 | goto out; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3496 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3497 | netdev_for_each_mc_addr(ha, dev) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3498 | hdd_debug("ha_addr[%d] "MAC_ADDRESS_STR, |
Sachin Ahuja | a69c72a | 2016-09-03 15:59:33 +0530 | [diff] [blame] | 3499 | i, MAC_ADDR_ARRAY(ha->addr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3500 | if (i == mc_count) |
| 3501 | break; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3502 | memset(&(mc_list_request->mc_addr[i].bytes), |
| 3503 | 0, ETH_ALEN); |
| 3504 | memcpy(&(mc_list_request->mc_addr[i].bytes), |
| 3505 | ha->addr, ETH_ALEN); |
| 3506 | hdd_info("mlist[%d] = %pM", i, |
| 3507 | mc_list_request->mc_addr[i].bytes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3508 | i++; |
| 3509 | } |
| 3510 | } |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3511 | |
| 3512 | mc_list_request->psoc = psoc; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3513 | mc_list_request->vdev_id = adapter->session_id; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3514 | mc_list_request->count = mc_count; |
| 3515 | status = hdd_cache_mc_addr_list(mc_list_request); |
| 3516 | if (status == 0) { |
| 3517 | hdd_enable_mc_addr_filtering(adapter, |
| 3518 | pmo_mc_list_change_notify); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3519 | } else { |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3520 | hdd_err("error while caching mc list"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3521 | } |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3522 | out: |
| 3523 | if (mc_list_request) |
| 3524 | qdf_mem_free(mc_list_request); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3525 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3526 | } |
| 3527 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3528 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3529 | /** |
| 3530 | * hdd_set_multicast_list() - SSR wrapper function for __hdd_set_multicast_list |
| 3531 | * @dev: pointer to net_device |
| 3532 | * |
| 3533 | * Return: none |
| 3534 | */ |
| 3535 | static void hdd_set_multicast_list(struct net_device *dev) |
| 3536 | { |
| 3537 | cds_ssr_protect(__func__); |
| 3538 | __hdd_set_multicast_list(dev); |
| 3539 | cds_ssr_unprotect(__func__); |
| 3540 | } |
| 3541 | #endif |
| 3542 | |
| 3543 | /** |
| 3544 | * hdd_select_queue() - used by Linux OS to decide which queue to use first |
| 3545 | * @dev: Pointer to the WLAN device. |
| 3546 | * @skb: Pointer to OS packet (sk_buff). |
| 3547 | * |
| 3548 | * This function is registered with the Linux OS for network |
| 3549 | * core to decide which queue to use first. |
| 3550 | * |
| 3551 | * Return: ac, Queue Index/access category corresponding to UP in IP header |
| 3552 | */ |
| 3553 | static uint16_t hdd_select_queue(struct net_device *dev, struct sk_buff *skb |
| 3554 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0)) |
| 3555 | , void *accel_priv |
| 3556 | #endif |
| 3557 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) |
| 3558 | , select_queue_fallback_t fallback |
| 3559 | #endif |
| 3560 | ) |
| 3561 | { |
| 3562 | return hdd_wmm_select_queue(dev, skb); |
| 3563 | } |
| 3564 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3565 | static const struct net_device_ops wlan_drv_ops = { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3566 | .ndo_open = hdd_open, |
| 3567 | .ndo_stop = hdd_stop, |
| 3568 | .ndo_uninit = hdd_uninit, |
| 3569 | .ndo_start_xmit = hdd_hard_start_xmit, |
| 3570 | .ndo_tx_timeout = hdd_tx_timeout, |
| 3571 | .ndo_get_stats = hdd_get_stats, |
| 3572 | .ndo_do_ioctl = hdd_ioctl, |
| 3573 | .ndo_set_mac_address = hdd_set_mac_address, |
| 3574 | .ndo_select_queue = hdd_select_queue, |
| 3575 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3576 | .ndo_set_rx_mode = hdd_set_multicast_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3577 | #endif |
| 3578 | }; |
| 3579 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3580 | /* Monitor mode net_device_ops, doesnot Tx and most of operations. */ |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3581 | static const struct net_device_ops wlan_mon_drv_ops = { |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3582 | .ndo_open = hdd_mon_open, |
| 3583 | .ndo_stop = hdd_stop, |
| 3584 | .ndo_get_stats = hdd_get_stats, |
| 3585 | }; |
| 3586 | |
| 3587 | /** |
| 3588 | * hdd_set_station_ops() - update net_device ops for monitor mode |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3589 | * @dev: Handle to struct net_device to be updated. |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3590 | * Return: None |
| 3591 | */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3592 | void hdd_set_station_ops(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3593 | { |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3594 | if (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam()) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3595 | dev->netdev_ops = &wlan_mon_drv_ops; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3596 | else |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3597 | dev->netdev_ops = &wlan_drv_ops; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3598 | } |
| 3599 | |
| 3600 | /** |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3601 | * hdd_alloc_station_adapter() - allocate the station hdd adapter |
| 3602 | * @hdd_ctx: global hdd context |
| 3603 | * @macAddr: mac address to assign to the interface |
| 3604 | * @name: User-visible name of the interface |
| 3605 | * |
| 3606 | * hdd adapter pointer would point to the netdev->priv space, this function |
| 3607 | * would retrive the pointer, and setup the hdd adapter configuration. |
| 3608 | * |
| 3609 | * Return: the pointer to hdd adapter, otherwise NULL |
| 3610 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3611 | 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] | 3612 | tSirMacAddr macAddr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3613 | unsigned char name_assign_type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3614 | const char *name) |
| 3615 | { |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3616 | struct net_device *dev = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3617 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 3618 | struct hdd_station_ctx *sta_ctx; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3619 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3620 | /* |
| 3621 | * cfg80211 initialization and registration.... |
| 3622 | */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3623 | dev = alloc_netdev_mq(sizeof(struct hdd_adapter), name, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3624 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS) |
| 3625 | name_assign_type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3626 | #endif |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3627 | (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam() ? |
| 3628 | hdd_mon_mode_ether_setup : ether_setup), |
| 3629 | NUM_TX_QUEUES); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3630 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3631 | if (dev != NULL) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3632 | |
| 3633 | /* Save the pointer to the net_device in the HDD adapter */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3634 | adapter = (struct hdd_adapter *) netdev_priv(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3635 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3636 | qdf_mem_zero(adapter, sizeof(struct hdd_adapter)); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 3637 | sta_ctx = &adapter->session.station; |
Hanumanth Reddy Pothula | 18553ae | 2017-04-28 15:03:10 +0530 | [diff] [blame] | 3638 | qdf_mem_set(sta_ctx->conn_info.staId, |
| 3639 | sizeof(sta_ctx->conn_info.staId), |
| 3640 | HDD_WLAN_INVALID_STA_ID); |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3641 | adapter->dev = dev; |
Jeff Johnson | dba0db6 | 2017-08-30 11:12:39 -0700 | [diff] [blame] | 3642 | adapter->hdd_ctx = hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3643 | adapter->magic = WLAN_HDD_ADAPTER_MAGIC; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3644 | adapter->session_id = HDD_SESSION_ID_INVALID; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3645 | |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3646 | qdf_status = qdf_event_create( |
| 3647 | &adapter->qdf_session_open_event); |
| 3648 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 3649 | hdd_err("Session open QDF event init failed!"); |
| 3650 | free_netdev(adapter->dev); |
| 3651 | return NULL; |
| 3652 | } |
| 3653 | |
| 3654 | qdf_status = qdf_event_create( |
| 3655 | &adapter->qdf_session_close_event); |
| 3656 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 3657 | hdd_err("Session close QDF event init failed!"); |
| 3658 | free_netdev(adapter->dev); |
| 3659 | return NULL; |
| 3660 | } |
| 3661 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3662 | init_completion(&adapter->disconnect_comp_var); |
Abhishek Singh | 533c9da | 2017-05-04 10:23:34 +0530 | [diff] [blame] | 3663 | init_completion(&adapter->roaming_comp_var); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3664 | init_completion(&adapter->linkup_event_var); |
| 3665 | init_completion(&adapter->cancel_rem_on_chan_var); |
| 3666 | init_completion(&adapter->rem_on_chan_ready_event); |
| 3667 | init_completion(&adapter->sta_authorized_event); |
| 3668 | init_completion(&adapter->offchannel_tx_event); |
| 3669 | init_completion(&adapter->tx_action_cnf_event); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3670 | init_completion(&adapter->ibss_peer_info_comp); |
Sreelakshmi Konamki | 88a2a41 | 2017-04-14 15:11:55 +0530 | [diff] [blame] | 3671 | init_completion(&adapter->lfr_fw_status.disable_lfr_event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3672 | |
| 3673 | adapter->offloads_configured = false; |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 3674 | adapter->is_link_up_service_needed = false; |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 3675 | adapter->disconnection_in_progress = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3676 | /* Init the net_device structure */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3677 | strlcpy(dev->name, name, IFNAMSIZ); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3678 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3679 | qdf_mem_copy(dev->dev_addr, (void *)macAddr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3680 | sizeof(tSirMacAddr)); |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 3681 | qdf_mem_copy(adapter->mac_addr.bytes, macAddr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3682 | sizeof(tSirMacAddr)); |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3683 | dev->watchdog_timeo = HDD_TX_TIMEOUT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3684 | |
| 3685 | if (hdd_ctx->config->enable_ip_tcp_udp_checksum_offload) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3686 | dev->features |= |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3687 | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM; |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3688 | dev->features |= NETIF_F_RXCSUM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3689 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3690 | hdd_set_tso_flags(hdd_ctx, dev); |
Dhanashri Atre | 83d373d | 2015-07-28 16:45:59 -0700 | [diff] [blame] | 3691 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3692 | hdd_set_station_ops(adapter->dev); |
| 3693 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3694 | hdd_dev_setup_destructor(dev); |
| 3695 | dev->ieee80211_ptr = &adapter->wdev; |
| 3696 | dev->tx_queue_len = HDD_NETDEV_TX_QUEUE_LEN; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3697 | adapter->wdev.wiphy = hdd_ctx->wiphy; |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3698 | adapter->wdev.netdev = dev; |
| 3699 | /* set dev's parent to underlying device */ |
| 3700 | SET_NETDEV_DEV(dev, hdd_ctx->parent_dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3701 | hdd_wmm_init(adapter); |
| 3702 | spin_lock_init(&adapter->pause_map_lock); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 3703 | adapter->start_time = adapter->last_time = qdf_system_ticks(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3704 | } |
| 3705 | |
| 3706 | return adapter; |
| 3707 | } |
| 3708 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3709 | 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] | 3710 | { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3711 | struct net_device *dev = adapter->dev; |
| 3712 | int ret; |
| 3713 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 3714 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3715 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 3716 | if (rtnl_held) { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3717 | if (strnchr(dev->name, IFNAMSIZ - 1, '%')) { |
| 3718 | |
| 3719 | ret = dev_alloc_name(dev, dev->name); |
| 3720 | if (ret < 0) { |
| 3721 | hdd_err( |
| 3722 | "unable to get dev name: %s, err = 0x%x", |
| 3723 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3724 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3725 | } |
| 3726 | } |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3727 | |
| 3728 | ret = register_netdevice(dev); |
| 3729 | if (ret) { |
| 3730 | hdd_err("register_netdevice(%s) failed, err = 0x%x", |
| 3731 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3732 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3733 | } |
| 3734 | } else { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3735 | ret = register_netdev(dev); |
| 3736 | if (ret) { |
| 3737 | hdd_err("register_netdev(%s) failed, err = 0x%x", |
| 3738 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3739 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3740 | } |
| 3741 | } |
| 3742 | set_bit(NET_DEVICE_REGISTERED, &adapter->event_flags); |
| 3743 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3744 | hdd_exit(); |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3745 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3746 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3747 | } |
| 3748 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3749 | QDF_STATUS hdd_sme_open_session_callback(uint8_t session_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3750 | { |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3751 | struct hdd_adapter *adapter; |
| 3752 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3753 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3754 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 3755 | if (!hdd_ctx) { |
| 3756 | hdd_err("Invalid HDD_CTX"); |
| 3757 | return QDF_STATUS_E_FAILURE; |
| 3758 | } |
| 3759 | |
| 3760 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, session_id); |
| 3761 | if (NULL == adapter) { |
| 3762 | hdd_err("NULL adapter"); |
| 3763 | return QDF_STATUS_E_INVAL; |
| 3764 | } |
| 3765 | set_bit(SME_SESSION_OPENED, &adapter->event_flags); |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3766 | qdf_event_set(&adapter->qdf_session_open_event); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3767 | hdd_debug("session %d opened", adapter->session_id); |
| 3768 | |
| 3769 | return QDF_STATUS_SUCCESS; |
| 3770 | } |
| 3771 | |
| 3772 | QDF_STATUS hdd_sme_close_session_callback(uint8_t session_id) |
| 3773 | { |
| 3774 | struct hdd_adapter *adapter; |
| 3775 | struct hdd_context *hdd_ctx; |
| 3776 | |
| 3777 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 3778 | if (!hdd_ctx) { |
| 3779 | hdd_err("Invalid HDD_CTX"); |
| 3780 | return QDF_STATUS_E_FAILURE; |
| 3781 | } |
| 3782 | |
| 3783 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3784 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3785 | hdd_err("NULL adapter"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3786 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3787 | } |
| 3788 | |
| 3789 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3790 | hdd_err("Invalid magic"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3791 | return QDF_STATUS_NOT_INITIALIZED; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3792 | } |
| 3793 | |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3794 | /* |
| 3795 | * For NAN Data interface, the close session results in the final |
| 3796 | * indication to the userspace |
| 3797 | */ |
Rakesh Sunki | 3480f96 | 2016-08-29 17:29:53 -0700 | [diff] [blame] | 3798 | if (adapter->device_mode == QDF_NDI_MODE) |
| 3799 | hdd_ndp_session_end_handler(adapter); |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3800 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3801 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 3802 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3803 | /* |
| 3804 | * We can be blocked while waiting for scheduled work to be |
| 3805 | * flushed, and the adapter structure can potentially be freed, in |
| 3806 | * which case the magic will have been reset. So make sure the |
| 3807 | * magic is still good, and hence the adapter structure is still |
| 3808 | * valid, before signaling completion |
| 3809 | */ |
| 3810 | if (WLAN_HDD_ADAPTER_MAGIC == adapter->magic) |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3811 | qdf_event_set(&adapter->qdf_session_close_event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3812 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3813 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3814 | } |
| 3815 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3816 | int hdd_vdev_ready(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3817 | { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3818 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3819 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3820 | status = pmo_vdev_ready(adapter->hdd_vdev); |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 3821 | if (QDF_IS_STATUS_ERROR(status)) |
| 3822 | return qdf_status_to_os_return(status); |
| 3823 | |
Kiran Kumar Lokere | 3beeb95 | 2017-05-02 18:40:24 -0700 | [diff] [blame] | 3824 | status = ucfg_reg_11d_vdev_created_update(adapter->hdd_vdev); |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 3825 | if (QDF_IS_STATUS_ERROR(status)) |
| 3826 | return qdf_status_to_os_return(status); |
| 3827 | |
| 3828 | if (wma_capability_enhanced_mcast_filter()) |
| 3829 | status = pmo_ucfg_enhanced_mc_filter_enable(adapter->hdd_vdev); |
| 3830 | else |
| 3831 | status = pmo_ucfg_enhanced_mc_filter_disable(adapter->hdd_vdev); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3832 | |
| 3833 | return qdf_status_to_os_return(status); |
| 3834 | } |
| 3835 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3836 | int hdd_vdev_destroy(struct hdd_adapter *adapter) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3837 | { |
| 3838 | QDF_STATUS status; |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3839 | int errno = 0; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3840 | struct hdd_context *hdd_ctx; |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 3841 | uint8_t vdev_id; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3842 | |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 3843 | vdev_id = adapter->session_id; |
| 3844 | hdd_info("destroying vdev %d", vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3845 | |
| 3846 | /* vdev created sanity check */ |
| 3847 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3848 | hdd_err("vdev for Id %d does not exist", adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3849 | return -EINVAL; |
| 3850 | } |
Kiran Kumar Lokere | 3beeb95 | 2017-05-02 18:40:24 -0700 | [diff] [blame] | 3851 | status = ucfg_reg_11d_vdev_delete_update(adapter->hdd_vdev); |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 3852 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3853 | /* close sme session (destroy vdev in firmware via legacy API) */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3854 | qdf_event_reset(&adapter->qdf_session_close_event); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3855 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3856 | status = sme_close_session(hdd_ctx->hHal, adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3857 | if (QDF_IS_STATUS_ERROR(status)) { |
| 3858 | hdd_err("failed to close sme session: %d", status); |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3859 | errno = qdf_status_to_os_return(status); |
| 3860 | goto release_vdev; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3861 | } |
| 3862 | |
| 3863 | /* block on a completion variable until sme session is closed */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3864 | status = qdf_wait_for_event_completion( |
| 3865 | &adapter->qdf_session_close_event, |
| 3866 | WLAN_WAIT_TIME_SESSIONOPENCLOSE); |
| 3867 | if (QDF_STATUS_SUCCESS != status) { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3868 | if (adapter->device_mode == QDF_NDI_MODE) |
| 3869 | hdd_ndp_session_end_handler(adapter); |
| 3870 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3871 | adapter->session_id = HDD_SESSION_ID_INVALID; |
| 3872 | if (QDF_STATUS_E_TIMEOUT != status) { |
| 3873 | hdd_err("timed out waiting for close sme session: %u", status); |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3874 | errno = -ETIMEDOUT; |
| 3875 | goto release_vdev; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3876 | } else if (adapter->qdf_session_close_event.force_set) { |
| 3877 | hdd_err("Session close evt focefully set, SSR/PDR has occurred"); |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3878 | errno = -EINVAL; |
| 3879 | goto release_vdev; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3880 | } else { |
| 3881 | hdd_err("Failed to close sme session (%u)", status); |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3882 | errno = -EINVAL; |
| 3883 | goto release_vdev; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3884 | } |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3885 | } |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3886 | |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 3887 | release_vdev: |
Frank Liu | c66d4bf | 2018-01-26 16:18:18 +0800 | [diff] [blame] | 3888 | /* |
| 3889 | * In SSR or driver unloading case, directly exit may cause objects |
| 3890 | * leak, if sme_close_session failed. Free objects anyway. |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3891 | */ |
Kabilan Kannan | b867c31 | 2018-02-15 17:43:21 -0800 | [diff] [blame] | 3892 | if (errno && !cds_is_driver_recovering() && !cds_is_driver_unloading()) |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3893 | return errno; |
| 3894 | |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 3895 | /* do vdev logical destroy via objmgr */ |
Dustin Brown | b277dd6 | 2018-01-26 15:17:33 -0800 | [diff] [blame] | 3896 | errno = hdd_objmgr_release_and_destroy_vdev(adapter); |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 3897 | if (errno) { |
Dustin Brown | b277dd6 | 2018-01-26 15:17:33 -0800 | [diff] [blame] | 3898 | hdd_err("failed to destroy objmgr vdev; errno:%d", errno); |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 3899 | return errno; |
| 3900 | } |
| 3901 | |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 3902 | hdd_info("vdev %d destroyed successfully", vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3903 | |
| 3904 | return 0; |
| 3905 | } |
| 3906 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3907 | static int hdd_set_sme_session_param(struct hdd_adapter *adapter, |
| 3908 | struct sme_session_params *session_param, |
| 3909 | csr_roam_completeCallback callback, |
| 3910 | void *callback_ctx) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3911 | { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3912 | uint32_t type; |
| 3913 | uint32_t sub_type; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3914 | QDF_STATUS status; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3915 | |
| 3916 | /* determine vdev (sub)type */ |
| 3917 | status = cds_get_vdev_types(adapter->device_mode, &type, &sub_type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3918 | if (QDF_STATUS_SUCCESS != status) { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3919 | hdd_err("failed to get vdev type: %d", status); |
| 3920 | return qdf_status_to_os_return(status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3921 | } |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3922 | session_param->sme_session_id = adapter->session_id; |
| 3923 | session_param->self_mac_addr = (uint8_t *)&adapter->mac_addr; |
| 3924 | session_param->type_of_persona = type; |
| 3925 | session_param->subtype_of_persona = sub_type; |
| 3926 | session_param->session_open_cb = hdd_sme_open_session_callback; |
| 3927 | session_param->session_close_cb = hdd_sme_close_session_callback; |
| 3928 | session_param->callback = callback; |
| 3929 | session_param->callback_ctx = callback_ctx; |
| 3930 | |
| 3931 | return 0; |
| 3932 | } |
| 3933 | |
| 3934 | int hdd_vdev_create(struct hdd_adapter *adapter, |
| 3935 | csr_roam_completeCallback callback, void *ctx) |
| 3936 | { |
| 3937 | QDF_STATUS status; |
| 3938 | int errno; |
| 3939 | struct hdd_context *hdd_ctx; |
| 3940 | struct sme_session_params sme_session_params = {0}; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3941 | |
| 3942 | hdd_info("creating new vdev"); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3943 | |
| 3944 | /* do vdev create via objmgr */ |
| 3945 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Dustin Brown | 7d043f6 | 2017-03-27 12:07:36 -0700 | [diff] [blame] | 3946 | errno = hdd_objmgr_create_and_store_vdev(hdd_ctx->hdd_pdev, adapter); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3947 | if (errno) { |
| 3948 | hdd_err("failed to create objmgr vdev: %d", errno); |
| 3949 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3950 | } |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3951 | |
| 3952 | /* Open a SME session (prepare vdev in firmware via legacy API) */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3953 | status = qdf_event_reset(&adapter->qdf_session_open_event); |
| 3954 | if (QDF_STATUS_SUCCESS != status) { |
| 3955 | hdd_err("failed to reinit session open event"); |
| 3956 | return -EINVAL; |
| 3957 | } |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3958 | errno = hdd_set_sme_session_param(adapter, &sme_session_params, |
| 3959 | callback, ctx); |
| 3960 | if (errno) { |
| 3961 | hdd_err("failed to populating SME params"); |
| 3962 | goto objmgr_vdev_destroy_procedure; |
| 3963 | } |
| 3964 | |
| 3965 | status = sme_open_session(hdd_ctx->hHal, &sme_session_params); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3966 | if (QDF_IS_STATUS_ERROR(status)) { |
| 3967 | hdd_err("failed to open sme session: %d", status); |
| 3968 | errno = qdf_status_to_os_return(status); |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3969 | goto objmgr_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3970 | } |
| 3971 | |
| 3972 | /* block on a completion variable until sme session is opened */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3973 | status = qdf_wait_for_event_completion(&adapter->qdf_session_open_event, |
| 3974 | WLAN_WAIT_TIME_SESSIONOPENCLOSE); |
| 3975 | if (QDF_STATUS_SUCCESS != status) { |
| 3976 | if (adapter->qdf_session_open_event.force_set) { |
| 3977 | /* |
| 3978 | * SSR/PDR has caused shutdown, which has forcefully |
| 3979 | * set the event. Return without the closing session. |
| 3980 | */ |
| 3981 | adapter->session_id = HDD_SESSION_ID_INVALID; |
| 3982 | hdd_err("Session open event forcefully set"); |
| 3983 | return -EINVAL; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3984 | } |
Jeff Johnson | c66d310 | 2018-02-28 11:58:26 -0800 | [diff] [blame] | 3985 | |
| 3986 | if (QDF_STATUS_E_TIMEOUT == status) |
| 3987 | hdd_err("Session failed to open within timeout period"); |
| 3988 | else |
| 3989 | hdd_err("Failed to wait for session open event(status-%d)", |
| 3990 | status); |
| 3991 | errno = -ETIMEDOUT; |
| 3992 | set_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 3993 | goto hdd_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3994 | } |
| 3995 | |
| 3996 | /* firmware ready for component communication, raise vdev_ready event */ |
| 3997 | errno = hdd_vdev_ready(adapter); |
| 3998 | if (errno) { |
| 3999 | hdd_err("failed to dispatch vdev ready event: %d", errno); |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4000 | goto hdd_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4001 | } |
| 4002 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4003 | hdd_info("vdev %d created successfully", adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4004 | |
| 4005 | return 0; |
| 4006 | |
| 4007 | /* |
| 4008 | * Due to legacy constraints, we need to destroy in the same order as |
| 4009 | * create. So, split error handling into 2 cases to accommodate. |
| 4010 | */ |
| 4011 | |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4012 | objmgr_vdev_destroy_procedure: |
Dustin Brown | 7d043f6 | 2017-03-27 12:07:36 -0700 | [diff] [blame] | 4013 | QDF_BUG(!hdd_objmgr_release_and_destroy_vdev(adapter)); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4014 | |
| 4015 | return errno; |
| 4016 | |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4017 | hdd_vdev_destroy_procedure: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4018 | QDF_BUG(!hdd_vdev_destroy(adapter)); |
| 4019 | |
| 4020 | return errno; |
| 4021 | } |
| 4022 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4023 | QDF_STATUS hdd_init_station_mode(struct hdd_adapter *adapter) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4024 | { |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 4025 | struct hdd_station_ctx *sta_ctx = &adapter->session.station; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4026 | struct hdd_context *hdd_ctx; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4027 | QDF_STATUS status; |
| 4028 | int ret_val; |
| 4029 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4030 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 4031 | sme_set_curr_device_mode(hdd_ctx->hHal, adapter->device_mode); |
| 4032 | 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] | 4033 | sme_set_vdev_ies_per_band(hdd_ctx->hHal, adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4034 | |
Jeff Johnson | 7f2c591 | 2018-03-23 11:42:28 -0700 | [diff] [blame] | 4035 | hdd_roam_profile_init(adapter); |
| 4036 | hdd_register_wext(adapter->dev); |
| 4037 | |
Varun Reddy Yeturu | 9e0032c | 2017-07-12 18:39:59 -0700 | [diff] [blame] | 4038 | hdd_conn_set_connection_state(adapter, eConnectionState_NotConnected); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4039 | |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4040 | qdf_mem_set(sta_ctx->conn_info.staId, |
| 4041 | sizeof(sta_ctx->conn_info.staId), HDD_WLAN_INVALID_STA_ID); |
Hanumanth Reddy Pothula | b2d729c | 2017-05-30 11:49:53 +0530 | [diff] [blame] | 4042 | |
Deepak Dhamdhere | a278582 | 2016-11-17 01:17:45 -0800 | [diff] [blame] | 4043 | /* set fast roaming capability in sme session */ |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4044 | status = sme_config_fast_roaming(hdd_ctx->hHal, adapter->session_id, |
Abhishek Singh | 1f217ec | 2017-12-22 11:48:27 +0530 | [diff] [blame] | 4045 | true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4046 | /* Set the default operation channel */ |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4047 | sta_ctx->conn_info.operationChannel = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4048 | hdd_ctx->config->OperatingChannel; |
| 4049 | |
| 4050 | /* Make the default Auth Type as OPEN */ |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4051 | sta_ctx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4052 | |
| 4053 | status = hdd_init_tx_rx(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4054 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4055 | hdd_err("hdd_init_tx_rx() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4056 | status, status); |
| 4057 | goto error_init_txrx; |
| 4058 | } |
| 4059 | |
| 4060 | set_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 4061 | |
| 4062 | status = hdd_wmm_adapter_init(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4063 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4064 | hdd_err("hdd_wmm_adapter_init() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4065 | status, status); |
| 4066 | goto error_wmm_init; |
| 4067 | } |
| 4068 | |
| 4069 | set_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 4070 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4071 | ret_val = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4072 | WMI_PDEV_PARAM_BURST_ENABLE, |
| 4073 | hdd_ctx->config->enableSifsBurst, |
| 4074 | PDEV_CMD); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4075 | if (ret_val) |
| 4076 | hdd_err("WMI_PDEV_PARAM_BURST_ENABLE set failed %d", ret_val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4077 | |
Poddar, Siddarth | 4b3f731 | 2017-11-02 17:00:20 +0530 | [diff] [blame] | 4078 | /* |
| 4079 | * In case of USB tethering, LRO is disabled. If SSR happened |
| 4080 | * during that time, then as part of SSR init, do not enable |
| 4081 | * the LRO again. Keep the LRO state same as before SSR. |
| 4082 | */ |
| 4083 | if (!(qdf_atomic_read(&hdd_ctx->vendor_disable_lro_flag))) |
Dhanashri Atre | 1a6a4ce | 2017-05-03 19:40:33 -0700 | [diff] [blame] | 4084 | adapter->dev->features |= NETIF_F_LRO; |
Rajeev Kumar Sirasanagandla | 996e529 | 2016-11-22 21:20:33 +0530 | [diff] [blame] | 4085 | |
| 4086 | /* rcpi info initialization */ |
| 4087 | qdf_mem_zero(&adapter->rcpi, sizeof(adapter->rcpi)); |
| 4088 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4089 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4090 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4091 | error_wmm_init: |
| 4092 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 4093 | hdd_deinit_tx_rx(adapter); |
| 4094 | error_init_txrx: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4095 | hdd_unregister_wext(adapter->dev); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4096 | QDF_BUG(!hdd_vdev_destroy(adapter)); |
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 | return status; |
| 4099 | } |
| 4100 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4101 | /** |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4102 | * hdd_deinit_station_mode() - De-initialize the station adapter |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4103 | * @hdd_ctx: global hdd context |
| 4104 | * @adapter: HDD adapter |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 4105 | * @rtnl_held: Used to indicate whether or not the caller is holding |
| 4106 | * the kernel rtnl_mutex |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4107 | * |
| 4108 | * This function De-initializes the STA/P2P/OCB adapter. |
| 4109 | * |
| 4110 | * Return: None. |
| 4111 | */ |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4112 | static void hdd_deinit_station_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4113 | struct hdd_adapter *adapter, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 4114 | bool rtnl_held) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4115 | { |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 4116 | hdd_enter_dev(adapter->dev); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4117 | |
Hanumanth Reddy Pothula | 7a65740 | 2016-09-07 20:59:18 +0530 | [diff] [blame] | 4118 | if (adapter->dev) { |
| 4119 | if (rtnl_held) |
| 4120 | adapter->dev->wireless_handlers = NULL; |
| 4121 | else { |
| 4122 | rtnl_lock(); |
| 4123 | adapter->dev->wireless_handlers = NULL; |
| 4124 | rtnl_unlock(); |
| 4125 | } |
| 4126 | } |
| 4127 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4128 | if (test_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags)) { |
| 4129 | hdd_deinit_tx_rx(adapter); |
| 4130 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 4131 | } |
| 4132 | |
| 4133 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 4134 | hdd_wmm_adapter_close(adapter); |
| 4135 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 4136 | } |
| 4137 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4138 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4139 | hdd_exit(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4140 | } |
| 4141 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4142 | void hdd_deinit_adapter(struct hdd_context *hdd_ctx, |
| 4143 | struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4144 | bool rtnl_held) |
| 4145 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 4146 | hdd_enter(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4147 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4148 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4149 | case QDF_STA_MODE: |
| 4150 | case QDF_P2P_CLIENT_MODE: |
| 4151 | case QDF_P2P_DEVICE_MODE: |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4152 | case QDF_IBSS_MODE: |
| 4153 | case QDF_NDI_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4154 | { |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4155 | hdd_deinit_station_mode(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4156 | break; |
| 4157 | } |
| 4158 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4159 | case QDF_SAP_MODE: |
| 4160 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4161 | { |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4162 | hdd_deinit_ap_mode(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4163 | break; |
| 4164 | } |
| 4165 | |
| 4166 | default: |
| 4167 | break; |
| 4168 | } |
| 4169 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4170 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4171 | } |
| 4172 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4173 | 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] | 4174 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4175 | { |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4176 | struct net_device *dev = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4177 | |
| 4178 | if (adapter) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4179 | dev = adapter->dev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4180 | else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4181 | hdd_err("adapter is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4182 | return; |
| 4183 | } |
| 4184 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 4185 | hdd_nud_deinit_tracking(adapter); |
| 4186 | qdf_mutex_destroy(&adapter->disconnection_status_lock); |
| 4187 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 4188 | hdd_debugfs_exit(adapter); |
Selvaraj, Sridhar | 4ea106e | 2016-08-05 20:34:46 +0530 | [diff] [blame] | 4189 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4190 | /* |
| 4191 | * The adapter is marked as closed. When hdd_wlan_exit() call returns, |
| 4192 | * the driver is almost closed and cannot handle either control |
| 4193 | * messages or data. However, unregister_netdevice() call above will |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4194 | * eventually invoke hdd_stop(ndo_close) driver callback, which attempts |
| 4195 | * to close the active connections(basically excites control path) which |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4196 | * is not right. Setting this flag helps hdd_stop() to recognize that |
| 4197 | * the interface is closed and restricts any operations on that |
| 4198 | */ |
| 4199 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 4200 | |
| 4201 | if (test_bit(NET_DEVICE_REGISTERED, &adapter->event_flags)) { |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4202 | if (rtnl_held) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4203 | unregister_netdevice(dev); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4204 | else |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4205 | unregister_netdev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4206 | /* |
| 4207 | * Note that the adapter is no longer valid at this point |
| 4208 | * since the memory has been reclaimed |
| 4209 | */ |
| 4210 | } |
| 4211 | } |
| 4212 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4213 | 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] | 4214 | tSirMacAddr macAddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4215 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4216 | struct hdd_adapter *adapter; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4217 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4218 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 4219 | if (!qdf_mem_cmp(adapter->mac_addr.bytes, |
| 4220 | macAddr, sizeof(tSirMacAddr))) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4221 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4222 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4223 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4224 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4225 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4226 | } |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4227 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4228 | #ifdef CONFIG_FW_LOGS_BASED_ON_INI |
| 4229 | /** |
| 4230 | * hdd_set_fw_log_params() - Set log parameters to FW |
| 4231 | * @hdd_ctx: HDD Context |
| 4232 | * @adapter: HDD Adapter |
| 4233 | * |
| 4234 | * This function set the FW Debug log level based on the INI. |
| 4235 | * |
| 4236 | * Return: None |
| 4237 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4238 | static void hdd_set_fw_log_params(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4239 | struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4240 | { |
| 4241 | uint8_t count = 0, numentries = 0, |
| 4242 | moduleloglevel[FW_MODULE_LOG_LEVEL_STRING_LENGTH]; |
| 4243 | uint32_t value = 0; |
| 4244 | int ret; |
| 4245 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4246 | if (QDF_GLOBAL_FTM_MODE == cds_get_conparam() || |
| 4247 | (!hdd_ctx->config->enable_fw_log)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4248 | 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] | 4249 | return; |
| 4250 | } |
| 4251 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4252 | /* Enable FW logs based on INI configuration */ |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4253 | hdd_ctx->fw_log_settings.dl_type = |
| 4254 | hdd_ctx->config->enableFwLogType; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4255 | ret = sme_cli_set_command(adapter->session_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4256 | WMI_DBGLOG_TYPE, |
| 4257 | hdd_ctx->config->enableFwLogType, |
| 4258 | DBG_CMD); |
| 4259 | if (ret != 0) |
| 4260 | hdd_err("Failed to enable FW log type ret %d", |
| 4261 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4262 | |
| 4263 | hdd_ctx->fw_log_settings.dl_loglevel = |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4264 | hdd_ctx->config->enableFwLogLevel; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4265 | ret = sme_cli_set_command(adapter->session_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4266 | WMI_DBGLOG_LOG_LEVEL, |
| 4267 | hdd_ctx->config->enableFwLogLevel, |
| 4268 | DBG_CMD); |
| 4269 | if (ret != 0) |
| 4270 | hdd_err("Failed to enable FW log level ret %d", |
| 4271 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4272 | |
| 4273 | hdd_string_to_u8_array( |
| 4274 | hdd_ctx->config->enableFwModuleLogLevel, |
| 4275 | moduleloglevel, |
| 4276 | &numentries, |
| 4277 | FW_MODULE_LOG_LEVEL_STRING_LENGTH); |
| 4278 | |
| 4279 | while (count < numentries) { |
| 4280 | /* |
| 4281 | * FW module log level input string looks like |
| 4282 | * below: |
| 4283 | * gFwDebugModuleLoglevel=<FW Module ID>, |
| 4284 | * <Log Level>,... |
| 4285 | * For example: |
| 4286 | * gFwDebugModuleLoglevel= |
| 4287 | * 1,0,2,1,3,2,4,3,5,4,6,5,7,6 |
| 4288 | * Above input string means : |
| 4289 | * For FW module ID 1 enable log level 0 |
| 4290 | * For FW module ID 2 enable log level 1 |
| 4291 | * For FW module ID 3 enable log level 2 |
| 4292 | * For FW module ID 4 enable log level 3 |
| 4293 | * For FW module ID 5 enable log level 4 |
| 4294 | * For FW module ID 6 enable log level 5 |
| 4295 | * For FW module ID 7 enable log level 6 |
| 4296 | */ |
| 4297 | |
Nishank Aggarwal | e239d96 | 2017-03-03 12:26:02 +0530 | [diff] [blame] | 4298 | if ((moduleloglevel[count] > WLAN_MODULE_ID_MAX) |
| 4299 | || (moduleloglevel[count + 1] > DBGLOG_LVL_MAX)) { |
| 4300 | hdd_err("Module id %d and dbglog level %d input length is more than max", |
| 4301 | moduleloglevel[count], |
| 4302 | moduleloglevel[count + 1]); |
| 4303 | return; |
| 4304 | } |
| 4305 | |
| 4306 | value = moduleloglevel[count] << 16; |
| 4307 | value |= moduleloglevel[count + 1]; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4308 | ret = sme_cli_set_command(adapter->session_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4309 | WMI_DBGLOG_MOD_LOG_LEVEL, |
| 4310 | value, DBG_CMD); |
| 4311 | if (ret != 0) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4312 | hdd_err("Failed to enable FW module log level %d ret %d", |
| 4313 | value, ret); |
| 4314 | |
| 4315 | count += 2; |
| 4316 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4317 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4318 | } |
| 4319 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4320 | static void hdd_set_fw_log_params(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4321 | struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4322 | { |
| 4323 | } |
| 4324 | |
| 4325 | #endif |
| 4326 | |
| 4327 | /** |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4328 | * hdd_configure_chain_mask() - programs chain mask to firmware |
| 4329 | * @adapter: HDD adapter |
| 4330 | * |
| 4331 | * Return: 0 on success or errno on failure |
| 4332 | */ |
| 4333 | static int hdd_configure_chain_mask(struct hdd_adapter *adapter) |
| 4334 | { |
| 4335 | int ret_val; |
| 4336 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 4337 | |
| 4338 | hdd_debug("enable2x2: %d, lte_coex: %d, ChainMask1x1: tx: %d rx: %d", |
| 4339 | hdd_ctx->config->enable2x2, hdd_ctx->lte_coex_ant_share, |
| 4340 | hdd_ctx->config->txchainmask1x1, |
| 4341 | hdd_ctx->config->rxchainmask1x1); |
| 4342 | hdd_debug("disable_DBS: %d, tx_chain_mask_2g: %d, rx_chain_mask_2g: %d", |
| 4343 | hdd_ctx->config->dual_mac_feature_disable, |
| 4344 | hdd_ctx->config->tx_chain_mask_2g, |
| 4345 | hdd_ctx->config->rx_chain_mask_2g); |
| 4346 | hdd_debug("tx_chain_mask_5g: %d, rx_chain_mask_5g: %d", |
| 4347 | hdd_ctx->config->tx_chain_mask_5g, |
| 4348 | hdd_ctx->config->rx_chain_mask_5g); |
Liangwei Dong | 22810e8 | 2018-03-15 03:42:12 -0400 | [diff] [blame] | 4349 | hdd_debug("enable_bt_chain_separation %d", |
| 4350 | hdd_ctx->config->enable_bt_chain_separation); |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4351 | |
Liangwei Dong | 22810e8 | 2018-03-15 03:42:12 -0400 | [diff] [blame] | 4352 | if (hdd_ctx->config->enable2x2 && |
| 4353 | !hdd_ctx->config->enable_bt_chain_separation) { |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4354 | hdd_info("2x2 enabled. skip chain mask programming"); |
| 4355 | return 0; |
| 4356 | } |
| 4357 | |
Naveen Rawat | b54c72b | 2018-02-05 10:39:06 -0800 | [diff] [blame] | 4358 | if (hdd_ctx->config->dual_mac_feature_disable != |
| 4359 | DISABLE_DBS_CXN_AND_SCAN) { |
| 4360 | hdd_info("DBS enabled(%d). skip chain mask programming", |
| 4361 | hdd_ctx->config->dual_mac_feature_disable); |
| 4362 | return 0; |
| 4363 | } |
| 4364 | |
Naveen Rawat | dacb503 | 2018-02-08 15:23:24 -0800 | [diff] [blame] | 4365 | if (hdd_ctx->lte_coex_ant_share) { |
| 4366 | hdd_info("lte ant sharing enabled. skip chainmask programming"); |
| 4367 | return 0; |
| 4368 | } |
| 4369 | |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4370 | if (hdd_ctx->config->txchainmask1x1) { |
| 4371 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4372 | WMI_PDEV_PARAM_TX_CHAIN_MASK, |
| 4373 | hdd_ctx->config->txchainmask1x1, |
| 4374 | PDEV_CMD); |
| 4375 | if (ret_val) |
| 4376 | goto error; |
| 4377 | } |
| 4378 | |
| 4379 | if (hdd_ctx->config->rxchainmask1x1) { |
| 4380 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4381 | WMI_PDEV_PARAM_RX_CHAIN_MASK, |
| 4382 | hdd_ctx->config->rxchainmask1x1, |
| 4383 | PDEV_CMD); |
| 4384 | if (ret_val) |
| 4385 | goto error; |
| 4386 | } |
| 4387 | |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4388 | if (hdd_ctx->config->txchainmask1x1 || |
| 4389 | hdd_ctx->config->rxchainmask1x1) { |
| 4390 | hdd_info("band agnostic tx/rx chain mask set. skip per band chain mask"); |
| 4391 | return 0; |
| 4392 | } |
| 4393 | |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4394 | if (hdd_ctx->config->tx_chain_mask_2g) { |
| 4395 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4396 | WMI_PDEV_PARAM_TX_CHAIN_MASK_2G, |
| 4397 | hdd_ctx->config->tx_chain_mask_2g, PDEV_CMD); |
| 4398 | if (0 != ret_val) |
| 4399 | goto error; |
| 4400 | } |
| 4401 | |
| 4402 | if (hdd_ctx->config->rx_chain_mask_2g) { |
| 4403 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4404 | WMI_PDEV_PARAM_RX_CHAIN_MASK_2G, |
| 4405 | hdd_ctx->config->rx_chain_mask_2g, PDEV_CMD); |
| 4406 | if (0 != ret_val) |
| 4407 | goto error; |
| 4408 | } |
| 4409 | |
| 4410 | if (hdd_ctx->config->tx_chain_mask_5g) { |
| 4411 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4412 | WMI_PDEV_PARAM_TX_CHAIN_MASK_5G, |
| 4413 | hdd_ctx->config->tx_chain_mask_5g, PDEV_CMD); |
| 4414 | if (0 != ret_val) |
| 4415 | goto error; |
| 4416 | } |
| 4417 | |
| 4418 | if (hdd_ctx->config->rx_chain_mask_5g) { |
| 4419 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4420 | WMI_PDEV_PARAM_RX_CHAIN_MASK_5G, |
| 4421 | hdd_ctx->config->rx_chain_mask_5g, PDEV_CMD); |
| 4422 | if (0 != ret_val) |
| 4423 | goto error; |
| 4424 | } |
| 4425 | |
| 4426 | return 0; |
| 4427 | |
| 4428 | error: |
| 4429 | hdd_err("WMI PDEV set param failed %d", ret_val); |
| 4430 | return -EINVAL; |
| 4431 | } |
| 4432 | |
| 4433 | /** |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4434 | * hdd_set_fw_params() - Set parameters to firmware |
| 4435 | * @adapter: HDD adapter |
| 4436 | * |
| 4437 | * This function Sets various parameters to fw once the |
| 4438 | * adapter is started. |
| 4439 | * |
| 4440 | * Return: 0 on success or errno on failure |
| 4441 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4442 | int hdd_set_fw_params(struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4443 | { |
| 4444 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4445 | struct hdd_context *hdd_ctx; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4446 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 4447 | hdd_enter_dev(adapter->dev); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4448 | |
| 4449 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 4450 | if (!hdd_ctx) |
| 4451 | return -EINVAL; |
| 4452 | |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4453 | if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE) { |
| 4454 | hdd_debug("FTM Mode is active; nothing to do"); |
| 4455 | return 0; |
| 4456 | } |
| 4457 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4458 | ret = sme_cli_set_command(adapter->session_id, |
Ashish Kumar Dhanotiya | b8630ab | 2017-07-21 14:18:14 +0530 | [diff] [blame] | 4459 | WMI_PDEV_PARAM_DTIM_SYNTH, |
| 4460 | hdd_ctx->config->enable_lprx, PDEV_CMD); |
| 4461 | if (ret) { |
| 4462 | hdd_err("Failed to set LPRx"); |
| 4463 | goto error; |
| 4464 | } |
| 4465 | |
Ashish Kumar Dhanotiya | 191d164 | 2018-02-08 17:43:09 +0530 | [diff] [blame] | 4466 | |
| 4467 | ret = sme_cli_set_command( |
| 4468 | adapter->session_id, |
| 4469 | WMI_PDEV_PARAM_1CH_DTIM_OPTIMIZED_CHAIN_SELECTION, |
| 4470 | hdd_ctx->config->enable_dtim_selection_diversity, |
| 4471 | PDEV_CMD); |
| 4472 | if (ret) { |
| 4473 | hdd_err("Failed to set DTIM_OPTIMIZED_CHAIN_SELECTION"); |
| 4474 | goto error; |
| 4475 | } |
| 4476 | |
Ashish Kumar Dhanotiya | 48dac7d | 2018-03-28 14:59:50 +0530 | [diff] [blame^] | 4477 | ret = sme_cli_set_command( |
| 4478 | adapter->session_id, |
| 4479 | WMI_PDEV_PARAM_TX_SCH_DELAY, |
| 4480 | hdd_ctx->config->enable_tx_sch_delay, |
| 4481 | PDEV_CMD); |
| 4482 | if (ret) { |
| 4483 | hdd_err("Failed to set WMI_PDEV_PARAM_TX_SCH_DELAY"); |
| 4484 | goto error; |
| 4485 | } |
| 4486 | |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4487 | if (adapter->device_mode == QDF_STA_MODE) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4488 | sme_set_smps_cfg(adapter->session_id, |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4489 | HDD_STA_SMPS_PARAM_UPPER_BRSSI_THRESH, |
| 4490 | hdd_ctx->config->upper_brssi_thresh); |
| 4491 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4492 | sme_set_smps_cfg(adapter->session_id, |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4493 | HDD_STA_SMPS_PARAM_LOWER_BRSSI_THRESH, |
| 4494 | hdd_ctx->config->lower_brssi_thresh); |
| 4495 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4496 | sme_set_smps_cfg(adapter->session_id, |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4497 | HDD_STA_SMPS_PARAM_DTIM_1CHRX_ENABLE, |
| 4498 | hdd_ctx->config->enable_dtim_1chrx); |
| 4499 | } |
| 4500 | |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4501 | if (hdd_ctx->config->enable2x2) { |
| 4502 | hdd_debug("configuring 2x2 mode fw params"); |
| 4503 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4504 | ret = sme_cli_set_command(adapter->session_id, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4505 | WMI_PDEV_PARAM_ENABLE_CCK_TXFIR_OVERRIDE, |
| 4506 | hdd_ctx->config->enable_cck_tx_fir_override, |
| 4507 | PDEV_CMD); |
| 4508 | if (ret) { |
| 4509 | hdd_err("WMI_PDEV_PARAM_ENABLE_CCK_TXFIR_OVERRIDE set failed %d", |
| 4510 | ret); |
| 4511 | goto error; |
| 4512 | } |
Liangwei Dong | 22810e8 | 2018-03-15 03:42:12 -0400 | [diff] [blame] | 4513 | |
| 4514 | if (hdd_configure_chain_mask(adapter)) |
| 4515 | goto error; |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4516 | } else { |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4517 | #define HDD_DTIM_1CHAIN_RX_ID 0x5 |
| 4518 | #define HDD_SMPS_PARAM_VALUE_S 29 |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4519 | hdd_debug("configuring 1x1 mode fw params"); |
| 4520 | |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4521 | /* |
| 4522 | * Disable DTIM 1 chain Rx when in 1x1, |
| 4523 | * we are passing two value |
| 4524 | * as param_id << 29 | param_value. |
| 4525 | * Below param_value = 0(disable) |
| 4526 | */ |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4527 | ret = sme_cli_set_command(adapter->session_id, |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4528 | WMI_STA_SMPS_PARAM_CMDID, |
| 4529 | HDD_DTIM_1CHAIN_RX_ID << |
| 4530 | HDD_SMPS_PARAM_VALUE_S, |
| 4531 | VDEV_CMD); |
| 4532 | if (ret) { |
| 4533 | hdd_err("DTIM 1 chain set failed %d", ret); |
| 4534 | goto error; |
| 4535 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4536 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4537 | #undef HDD_DTIM_1CHAIN_RX_ID |
| 4538 | #undef HDD_SMPS_PARAM_VALUE_S |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4539 | |
| 4540 | if (hdd_configure_chain_mask(adapter)) |
| 4541 | goto error; |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4542 | } |
| 4543 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4544 | ret = sme_cli_set_command(adapter->session_id, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4545 | WMI_PDEV_PARAM_HYST_EN, |
| 4546 | hdd_ctx->config->enableMemDeepSleep, |
| 4547 | PDEV_CMD); |
| 4548 | if (ret) { |
| 4549 | hdd_err("WMI_PDEV_PARAM_HYST_EN set failed %d", ret); |
| 4550 | goto error; |
| 4551 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4552 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4553 | ret = sme_cli_set_command(adapter->session_id, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4554 | WMI_VDEV_PARAM_ENABLE_RTSCTS, |
| 4555 | hdd_ctx->config->rts_profile, |
| 4556 | VDEV_CMD); |
| 4557 | if (ret) { |
| 4558 | hdd_err("FAILED TO SET RTSCTS Profile ret:%d", ret); |
| 4559 | goto error; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4560 | } |
| 4561 | |
Deepak Dhamdhere | 612392c | 2016-08-28 02:56:51 -0700 | [diff] [blame] | 4562 | hdd_debug("SET AMSDU num %d", hdd_ctx->config->max_amsdu_num); |
| 4563 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4564 | ret = wma_cli_set_command(adapter->session_id, |
Deepak Dhamdhere | 612392c | 2016-08-28 02:56:51 -0700 | [diff] [blame] | 4565 | GEN_VDEV_PARAM_AMSDU, |
| 4566 | hdd_ctx->config->max_amsdu_num, |
| 4567 | GEN_CMD); |
| 4568 | if (ret != 0) { |
| 4569 | hdd_err("GEN_VDEV_PARAM_AMSDU set failed %d", ret); |
| 4570 | goto error; |
| 4571 | } |
| 4572 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4573 | hdd_set_fw_log_params(hdd_ctx, adapter); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4574 | hdd_exit(); |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4575 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4576 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4577 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4578 | error: |
| 4579 | return -EINVAL; |
| 4580 | } |
| 4581 | |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4582 | /** |
| 4583 | * hdd_open_adapter() - open and setup the hdd adatper |
| 4584 | * @hdd_ctx: global hdd context |
| 4585 | * @session_type: type of the interface to be created |
| 4586 | * @iface_name: User-visible name of the interface |
| 4587 | * @macAddr: MAC address to assign to the interface |
| 4588 | * @name_assign_type: the name of assign type of the netdev |
| 4589 | * @rtnl_held: the rtnl lock hold flag |
| 4590 | * |
| 4591 | * This function open and setup the hdd adpater according to the device |
| 4592 | * type request, assign the name, the mac address assigned, and then prepared |
| 4593 | * the hdd related parameters, queue, lock and ready to start. |
| 4594 | * |
| 4595 | * Return: the pointer of hdd adapter, otherwise NULL. |
| 4596 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4597 | 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] | 4598 | const char *iface_name, tSirMacAddr macAddr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4599 | unsigned char name_assign_type, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 4600 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4601 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4602 | struct hdd_adapter *adapter = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4603 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4604 | |
| 4605 | if (hdd_ctx->current_intf_count >= hdd_ctx->max_intf_count) { |
| 4606 | /* |
| 4607 | * Max limit reached on the number of vdevs configured by the |
| 4608 | * host. Return error |
| 4609 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4610 | hdd_err("Unable to add virtual intf: currentVdevCnt=%d,hostConfiguredVdevCnt=%d", |
| 4611 | hdd_ctx->current_intf_count, hdd_ctx->max_intf_count); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4612 | return NULL; |
| 4613 | } |
| 4614 | |
| 4615 | if (macAddr == NULL) { |
| 4616 | /* Not received valid macAddr */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4617 | 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] | 4618 | return NULL; |
| 4619 | } |
| 4620 | status = hdd_check_for_existing_macaddr(hdd_ctx, macAddr); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4621 | if (QDF_STATUS_E_FAILURE == status) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4622 | hdd_err("Duplicate MAC addr: " MAC_ADDRESS_STR |
| 4623 | " already exists", |
| 4624 | MAC_ADDR_ARRAY(macAddr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4625 | return NULL; |
| 4626 | } |
| 4627 | |
| 4628 | switch (session_type) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4629 | case QDF_STA_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4630 | /* Reset locally administered bit if the device mode is STA */ |
| 4631 | WLAN_HDD_RESET_LOCALLY_ADMINISTERED_BIT(macAddr); |
Arunk Khandavalli | 794fdfc | 2017-09-13 18:00:40 +0530 | [diff] [blame] | 4632 | hdd_info("locally administered bit reset in sta mode: " |
| 4633 | MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4634 | /* fall through */ |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4635 | case QDF_P2P_CLIENT_MODE: |
| 4636 | case QDF_P2P_DEVICE_MODE: |
| 4637 | case QDF_OCB_MODE: |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 4638 | case QDF_NDI_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4639 | case QDF_MONITOR_MODE: |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4640 | adapter = hdd_alloc_station_adapter(hdd_ctx, macAddr, |
| 4641 | name_assign_type, |
| 4642 | iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4643 | |
| 4644 | if (NULL == adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4645 | hdd_err("failed to allocate adapter for session %d", |
| 4646 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4647 | return NULL; |
| 4648 | } |
| 4649 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4650 | if (QDF_P2P_CLIENT_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4651 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_CLIENT; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4652 | else if (QDF_P2P_DEVICE_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4653 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_DEVICE; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4654 | else if (QDF_MONITOR_MODE == session_type) |
| 4655 | adapter->wdev.iftype = NL80211_IFTYPE_MONITOR; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4656 | else |
| 4657 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 4658 | |
| 4659 | adapter->device_mode = session_type; |
| 4660 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4661 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4662 | /* |
| 4663 | * Workqueue which gets scheduled in IPv4 notification |
| 4664 | * callback |
| 4665 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4666 | INIT_WORK(&adapter->ipv4_notifier_work, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4667 | hdd_ipv4_notifier_work_queue); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4668 | |
| 4669 | #ifdef WLAN_NS_OFFLOAD |
| 4670 | /* |
| 4671 | * Workqueue which gets scheduled in IPv6 |
| 4672 | * notification callback. |
| 4673 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4674 | INIT_WORK(&adapter->ipv6_notifier_work, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4675 | hdd_ipv6_notifier_work_queue); |
| 4676 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4677 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4678 | if (QDF_STATUS_SUCCESS != status) |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 4679 | goto err_free_netdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4680 | |
| 4681 | /* Stop the Interface TX queue. */ |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4682 | hdd_debug("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4683 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4684 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4685 | WLAN_CONTROL_PATH); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4686 | |
Ravi Joshi | 1a29256 | 2017-05-18 16:28:54 -0700 | [diff] [blame] | 4687 | /* Initialize NAN Data Interface */ |
| 4688 | if (QDF_NDI_MODE == session_type) { |
| 4689 | status = hdd_init_nan_data_mode(adapter); |
| 4690 | if (QDF_STATUS_SUCCESS != status) |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 4691 | goto err_free_netdev; |
Ravi Joshi | 1a29256 | 2017-05-18 16:28:54 -0700 | [diff] [blame] | 4692 | } |
| 4693 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 4694 | hdd_nud_init_tracking(adapter); |
| 4695 | |
| 4696 | qdf_mutex_create(&adapter->disconnection_status_lock); |
| 4697 | |
Ravi Joshi | 1a29256 | 2017-05-18 16:28:54 -0700 | [diff] [blame] | 4698 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4699 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4700 | case QDF_P2P_GO_MODE: |
| 4701 | case QDF_SAP_MODE: |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4702 | adapter = hdd_wlan_create_ap_dev(hdd_ctx, macAddr, |
| 4703 | name_assign_type, |
| 4704 | (uint8_t *) iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4705 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4706 | hdd_err("failed to allocate adapter for session %d", |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4707 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4708 | return NULL; |
| 4709 | } |
| 4710 | |
| 4711 | adapter->wdev.iftype = |
| 4712 | (session_type == |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4713 | QDF_SAP_MODE) ? NL80211_IFTYPE_AP : |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4714 | NL80211_IFTYPE_P2P_GO; |
| 4715 | adapter->device_mode = session_type; |
| 4716 | |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 4717 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4718 | if (QDF_STATUS_SUCCESS != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4719 | goto err_free_netdev; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4720 | |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4721 | hdd_debug("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4722 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4723 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4724 | WLAN_CONTROL_PATH); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4725 | |
| 4726 | /* |
| 4727 | * Workqueue which gets scheduled in IPv4 notification |
| 4728 | * callback |
| 4729 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4730 | INIT_WORK(&adapter->ipv4_notifier_work, |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4731 | hdd_ipv4_notifier_work_queue); |
| 4732 | |
| 4733 | #ifdef WLAN_NS_OFFLOAD |
| 4734 | /* |
| 4735 | * Workqueue which gets scheduled in IPv6 |
| 4736 | * notification callback. |
| 4737 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4738 | INIT_WORK(&adapter->ipv6_notifier_work, |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4739 | hdd_ipv6_notifier_work_queue); |
| 4740 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4741 | break; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4742 | case QDF_FTM_MODE: |
| 4743 | adapter = hdd_alloc_station_adapter(hdd_ctx, macAddr, |
| 4744 | name_assign_type, |
Lin Bai | 1c67848 | 2017-12-18 18:29:11 +0800 | [diff] [blame] | 4745 | iface_name); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4746 | if (NULL == adapter) { |
| 4747 | hdd_err("Failed to allocate adapter for FTM mode"); |
| 4748 | return NULL; |
| 4749 | } |
| 4750 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 4751 | adapter->device_mode = session_type; |
| 4752 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4753 | if (QDF_STATUS_SUCCESS != status) |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 4754 | goto err_free_netdev; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4755 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4756 | /* Stop the Interface TX queue. */ |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4757 | hdd_debug("Disabling queues"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4758 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4759 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4760 | WLAN_CONTROL_PATH); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4761 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4762 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4763 | hdd_err("Invalid session type %d", session_type); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4764 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4765 | return NULL; |
| 4766 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4767 | |
hqu | eaa33ee | 2017-05-04 17:56:35 +0800 | [diff] [blame] | 4768 | INIT_WORK(&adapter->scan_block_work, wlan_hdd_cfg80211_scan_block_cb); |
| 4769 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4770 | if (QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4771 | /* Add it to the hdd's session list. */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4772 | status = hdd_add_adapter_back(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4773 | } |
| 4774 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4775 | if (QDF_STATUS_SUCCESS != status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4776 | if (NULL != adapter) { |
| 4777 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 4778 | adapter = NULL; |
| 4779 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4780 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4781 | return NULL; |
| 4782 | } |
| 4783 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4784 | if (QDF_STATUS_SUCCESS == status) { |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 4785 | policy_mgr_set_concurrency_mode(hdd_ctx->hdd_psoc, |
| 4786 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4787 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4788 | /* Adapter successfully added. Increment the vdev count */ |
| 4789 | hdd_ctx->current_intf_count++; |
| 4790 | |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4791 | hdd_debug("current_intf_count=%d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4792 | hdd_ctx->current_intf_count); |
| 4793 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 4794 | hdd_check_and_restart_sap_with_non_dfs_acs(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4795 | } |
| 4796 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 4797 | if (QDF_STATUS_SUCCESS != hdd_debugfs_init(adapter)) |
Mahesh Kumar Kalikot Veetil | 80dda9a | 2017-07-17 11:38:03 -0700 | [diff] [blame] | 4798 | hdd_err("Interface %s wow debug_fs init failed", |
| 4799 | netdev_name(adapter->dev)); |
| 4800 | |
| 4801 | hdd_info("%s interface created. iftype: %d", netdev_name(adapter->dev), |
| 4802 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4803 | |
| 4804 | return adapter; |
| 4805 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4806 | err_free_netdev: |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 4807 | wlan_hdd_release_intf_addr(hdd_ctx, adapter->mac_addr.bytes); |
Hanumanth Reddy Pothula | 00a39e7 | 2016-11-09 21:32:16 +0530 | [diff] [blame] | 4808 | free_netdev(adapter->dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4809 | |
| 4810 | return NULL; |
| 4811 | } |
| 4812 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 4813 | #ifdef MSM_PLATFORM |
| 4814 | static inline |
| 4815 | void hdd_cancel_bus_bw_work(struct hdd_context *hdd_ctx) |
| 4816 | { |
| 4817 | cancel_work_sync(&hdd_ctx->bus_bw_work); |
| 4818 | } |
| 4819 | #else |
| 4820 | static inline |
| 4821 | void hdd_cancel_bus_bw_work(struct hdd_context *hdd_ctx) |
| 4822 | { |
| 4823 | } |
| 4824 | #endif |
| 4825 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4826 | 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] | 4827 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4828 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4829 | /* |
| 4830 | * Here we are stopping global bus_bw timer & work per adapter. |
| 4831 | * |
| 4832 | * The reason is to fix one race condition between |
| 4833 | * bus bandwidth work and cleaning up an adapter. |
| 4834 | * Under some conditions, it is possible for the bus bandwidth |
| 4835 | * work to access a particularly destroyed adapter, leading to |
| 4836 | * use-after-free. |
| 4837 | */ |
| 4838 | hdd_debug("wait for bus bw work to flush"); |
| 4839 | hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 4840 | hdd_bus_bw_cancel_work(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4841 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4842 | /* cleanup adapter */ |
| 4843 | policy_mgr_clear_concurrency_mode(hdd_ctx->hdd_psoc, |
| 4844 | adapter->device_mode); |
| 4845 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 4846 | hdd_remove_adapter(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4847 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4848 | /* conditionally restart the bw timer */ |
| 4849 | hdd_bus_bw_compute_timer_try_start(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4850 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4851 | /* Adapter removed. Decrement vdev count */ |
| 4852 | if (hdd_ctx->current_intf_count != 0) |
| 4853 | hdd_ctx->current_intf_count--; |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 4854 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4855 | /* Fw will take care incase of concurrency */ |
| 4856 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4857 | } |
| 4858 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 4859 | /** |
| 4860 | * hdd_close_all_adapters - Close all open adapters |
| 4861 | * @hdd_ctx: Hdd context |
| 4862 | * rtnl_held: True if RTNL lock held |
| 4863 | * |
| 4864 | * Close all open adapters. |
| 4865 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 4866 | * Return: QDF status code |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 4867 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4868 | 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] | 4869 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4870 | struct hdd_adapter *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4871 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4872 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 4873 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4874 | |
| 4875 | do { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4876 | status = hdd_remove_front_adapter(hdd_ctx, &adapter); |
| 4877 | if (QDF_IS_STATUS_SUCCESS(status)) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4878 | wlan_hdd_release_intf_addr(hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4879 | adapter->mac_addr.bytes); |
| 4880 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 4881 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4882 | /* Adapter removed. Decrement vdev count */ |
| 4883 | if (hdd_ctx->current_intf_count != 0) |
| 4884 | hdd_ctx->current_intf_count--; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4885 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4886 | } while (QDF_IS_STATUS_SUCCESS(status)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4887 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4888 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4889 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4890 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4891 | } |
| 4892 | |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4893 | void wlan_hdd_reset_prob_rspies(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4894 | { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4895 | struct qdf_mac_addr *bssid = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4896 | tSirUpdateIE updateIE; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4897 | |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4898 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4899 | case QDF_STA_MODE: |
| 4900 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4901 | { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4902 | struct hdd_station_ctx *sta_ctx = |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4903 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4904 | bssid = &sta_ctx->conn_info.bssId; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4905 | break; |
| 4906 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4907 | case QDF_SAP_MODE: |
| 4908 | case QDF_P2P_GO_MODE: |
| 4909 | case QDF_IBSS_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4910 | { |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 4911 | bssid = &adapter->mac_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4912 | break; |
| 4913 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4914 | case QDF_FTM_MODE: |
| 4915 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4916 | default: |
| 4917 | /* |
| 4918 | * wlan_hdd_reset_prob_rspies should not have been called |
| 4919 | * for these kind of devices |
| 4920 | */ |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4921 | hdd_err("Unexpected request for the current device type %d", |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4922 | adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4923 | return; |
| 4924 | } |
| 4925 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 4926 | qdf_copy_macaddr(&updateIE.bssid, bssid); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4927 | updateIE.smeSessionId = adapter->session_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4928 | updateIE.ieBufferlength = 0; |
| 4929 | updateIE.pAdditionIEBuffer = NULL; |
| 4930 | updateIE.append = true; |
| 4931 | updateIE.notify = false; |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4932 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(adapter), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4933 | &updateIE, |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4934 | eUPDATE_IE_PROBE_RESP) == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4935 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4936 | } |
| 4937 | } |
| 4938 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 4939 | QDF_STATUS hdd_stop_adapter(struct hdd_context *hdd_ctx, |
| 4940 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4941 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 4942 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 4943 | struct csr_roam_profile *roam_profile; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4944 | union iwreq_data wrqu; |
| 4945 | tSirUpdateIE updateIE; |
| 4946 | unsigned long rc; |
Arunk Khandavalli | 96c122f | 2017-10-17 11:49:36 +0530 | [diff] [blame] | 4947 | tsap_Config_t *sap_config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4948 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 4949 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4950 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 4951 | hdd_nud_ignore_tracking(adapter, true); |
| 4952 | hdd_nud_reset_tracking(adapter); |
| 4953 | |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4954 | hdd_debug("Disabling queues"); |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4955 | wlan_hdd_netif_queue_control(adapter, |
| 4956 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4957 | WLAN_CONTROL_PATH); |
Tushnim Bhattacharyya | 9bd058f | 2017-12-27 14:01:31 -0800 | [diff] [blame] | 4958 | /* |
| 4959 | * if this is the last active connection check & stop the |
| 4960 | * opportunistic timer first |
| 4961 | */ |
| 4962 | if (((policy_mgr_get_connection_count(hdd_ctx->hdd_psoc) == 1) && |
| 4963 | (policy_mgr_mode_specific_connection_count(hdd_ctx->hdd_psoc, |
| 4964 | policy_mgr_convert_device_mode_to_qdf_type( |
| 4965 | adapter->device_mode), NULL) == 1)) || |
| 4966 | !policy_mgr_get_connection_count(hdd_ctx->hdd_psoc)) |
| 4967 | policy_mgr_check_and_stop_opportunistic_timer( |
| 4968 | hdd_ctx->hdd_psoc, adapter->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4969 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4970 | case QDF_STA_MODE: |
| 4971 | case QDF_P2P_CLIENT_MODE: |
| 4972 | case QDF_IBSS_MODE: |
| 4973 | case QDF_P2P_DEVICE_MODE: |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4974 | case QDF_NDI_MODE: |
| 4975 | if ((QDF_NDI_MODE == adapter->device_mode) || |
| 4976 | hdd_conn_is_connected( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4977 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)) || |
| 4978 | hdd_is_connecting( |
| 4979 | WLAN_HDD_GET_STATION_CTX_PTR(adapter))) { |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4980 | INIT_COMPLETION(adapter->disconnect_comp_var); |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 4981 | roam_profile = hdd_roam_profile(adapter); |
| 4982 | /* For NDI do not use roam_profile */ |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4983 | if (QDF_NDI_MODE == adapter->device_mode) |
| 4984 | qdf_ret_status = sme_roam_disconnect( |
| 4985 | hdd_ctx->hHal, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4986 | adapter->session_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4987 | eCSR_DISCONNECT_REASON_NDI_DELETE); |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 4988 | else if (roam_profile->BSSType == |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4989 | eCSR_BSS_TYPE_START_IBSS) |
| 4990 | qdf_ret_status = sme_roam_disconnect( |
| 4991 | hdd_ctx->hHal, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4992 | adapter->session_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4993 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
Jingxiang Ge | cc7e1f4 | 2017-11-14 16:21:27 +0800 | [diff] [blame] | 4994 | else if (QDF_STA_MODE == adapter->device_mode) { |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 4995 | qdf_ret_status = |
| 4996 | wlan_hdd_try_disconnect(adapter); |
Jingxiang Ge | cc7e1f4 | 2017-11-14 16:21:27 +0800 | [diff] [blame] | 4997 | hdd_debug("Send disconnected event to userspace"); |
| 4998 | wlan_hdd_cfg80211_indicate_disconnect( |
| 4999 | adapter->dev, true, |
| 5000 | WLAN_REASON_UNSPECIFIED); |
Jeff Johnson | 109e79d | 2018-02-27 15:10:04 -0800 | [diff] [blame] | 5001 | } else |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5002 | qdf_ret_status = sme_roam_disconnect( |
| 5003 | hdd_ctx->hHal, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5004 | adapter->session_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5005 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5006 | /* success implies disconnect command got |
| 5007 | * queued up successfully |
| 5008 | */ |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 5009 | if (qdf_ret_status == QDF_STATUS_SUCCESS && |
| 5010 | QDF_STA_MODE != adapter->device_mode) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5011 | rc = wait_for_completion_timeout( |
| 5012 | &adapter->disconnect_comp_var, |
| 5013 | msecs_to_jiffies |
| 5014 | (WLAN_WAIT_TIME_DISCONNECT)); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5015 | if (!rc) |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 5016 | hdd_warn("disconn_comp_var wait fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5017 | } |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 5018 | if (qdf_ret_status != QDF_STATUS_SUCCESS) |
| 5019 | hdd_warn("failed to post disconnect"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5020 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 5021 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 5022 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 5023 | wireless_send_event(adapter->dev, SIOCGIWAP, &wrqu, |
| 5024 | NULL); |
Sachin Ahuja | 988fd10 | 2016-09-15 17:16:25 +0530 | [diff] [blame] | 5025 | } |
Wu Gao | aceec6c | 2017-08-30 16:08:21 +0800 | [diff] [blame] | 5026 | wlan_hdd_scan_abort(adapter); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5027 | |
Abhishek Singh | 1e94d7a | 2015-11-30 17:26:54 +0530 | [diff] [blame] | 5028 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 5029 | hdd_clear_fils_connection_info(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5030 | |
| 5031 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5032 | cancel_work_sync(&adapter->ipv4_notifier_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5033 | #endif |
| 5034 | |
| 5035 | hdd_deregister_tx_flow_control(adapter); |
| 5036 | |
| 5037 | #ifdef WLAN_NS_OFFLOAD |
| 5038 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5039 | cancel_work_sync(&adapter->ipv6_notifier_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5040 | #endif |
| 5041 | #endif |
| 5042 | |
Hanumanth Reddy Pothula | 0586014 | 2017-07-26 18:45:27 +0530 | [diff] [blame] | 5043 | if (adapter->device_mode == QDF_STA_MODE) |
| 5044 | wlan_cfg80211_sched_scan_stop(hdd_ctx->hdd_pdev, |
| 5045 | adapter->dev); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5046 | |
| 5047 | if (wlan_hdd_try_disconnect(adapter)) { |
| 5048 | hdd_err("Error: Can't disconnect adapter"); |
| 5049 | return QDF_STATUS_E_FAILURE; |
Krunal Soni | 985b813 | 2017-02-10 18:49:08 -0800 | [diff] [blame] | 5050 | } |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5051 | |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 5052 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5053 | break; |
| 5054 | |
Rajeev Kumar | 3b90620 | 2018-02-01 10:55:14 -0800 | [diff] [blame] | 5055 | case QDF_MONITOR_MODE: |
| 5056 | wlan_hdd_scan_abort(adapter); |
| 5057 | hdd_deregister_tx_flow_control(adapter); |
| 5058 | hdd_vdev_destroy(adapter); |
| 5059 | break; |
| 5060 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5061 | case QDF_SAP_MODE: |
wadesong | f9b15ed | 2017-12-14 14:12:32 +0800 | [diff] [blame] | 5062 | wlan_hdd_scan_abort(adapter); |
Govind Singh | 1dab23b | 2017-08-12 13:31:00 +0530 | [diff] [blame] | 5063 | /* Flush IPA exception path packets */ |
Arunk Khandavalli | 96c122f | 2017-10-17 11:49:36 +0530 | [diff] [blame] | 5064 | sap_config = &adapter->session.ap.sap_config; |
| 5065 | if (sap_config) |
| 5066 | wlansap_reset_sap_config_add_ie(sap_config, |
| 5067 | eUPDATE_IE_ALL); |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 5068 | ucfg_ipa_flush(hdd_ctx->hdd_pdev); |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 5069 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 5070 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5071 | case QDF_P2P_GO_MODE: |
Kiran Kumar Lokere | 85cb36b | 2017-09-14 15:19:14 -0700 | [diff] [blame] | 5072 | if (QDF_SAP_MODE == adapter->device_mode) { |
| 5073 | if (test_bit(ACS_PENDING, &adapter->event_flags)) { |
| 5074 | cds_flush_delayed_work( |
| 5075 | &adapter->acs_pending_work); |
| 5076 | clear_bit(ACS_PENDING, &adapter->event_flags); |
| 5077 | } |
| 5078 | } |
Krunal Soni | 2220839 | 2017-09-29 18:10:34 -0700 | [diff] [blame] | 5079 | cds_flush_work(&adapter->sap_stop_bss_work); |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 5080 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5081 | /* Any softap specific cleanup here... */ |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 5082 | wlan_hdd_undo_acs(adapter); |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5083 | if (adapter->device_mode == QDF_P2P_GO_MODE) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5084 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 5085 | |
| 5086 | hdd_deregister_tx_flow_control(adapter); |
| 5087 | |
Kapil Gupta | c1224bf | 2017-06-22 21:22:40 +0530 | [diff] [blame] | 5088 | hdd_destroy_acs_timer(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5089 | mutex_lock(&hdd_ctx->sap_lock); |
| 5090 | if (test_bit(SOFTAP_BSS_STARTED, &adapter->event_flags)) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5091 | QDF_STATUS status; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 5092 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5093 | |
| 5094 | /* Stop Bss. */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5095 | status = wlansap_stop_bss( |
| 5096 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5097 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5098 | if (QDF_IS_STATUS_SUCCESS(status)) { |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 5099 | struct hdd_hostapd_state *hostapd_state = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5100 | WLAN_HDD_GET_HOSTAP_STATE_PTR(adapter); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 5101 | qdf_event_reset(&hostapd_state-> |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 5102 | qdf_stop_bss_event); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 5103 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 5104 | qdf_wait_for_event_completion( |
| 5105 | &hostapd_state->qdf_stop_bss_event, |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 5106 | SME_CMD_TIMEOUT_VALUE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5107 | |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 5108 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5109 | hdd_err("failure waiting for wlansap_stop_bss %d", |
| 5110 | qdf_status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5111 | } |
| 5112 | } else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5113 | hdd_err("failure in wlansap_stop_bss"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5114 | } |
| 5115 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 5116 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
| 5117 | adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5118 | adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 5119 | hdd_green_ap_start_state_mc(hdd_ctx, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 5120 | adapter->device_mode, |
| 5121 | false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5122 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 5123 | qdf_copy_macaddr(&updateIE.bssid, |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 5124 | &adapter->mac_addr); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5125 | updateIE.smeSessionId = adapter->session_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5126 | updateIE.ieBufferlength = 0; |
| 5127 | updateIE.pAdditionIEBuffer = NULL; |
| 5128 | updateIE.append = false; |
| 5129 | updateIE.notify = false; |
| 5130 | /* Probe bcn reset */ |
| 5131 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(adapter), |
| 5132 | &updateIE, eUPDATE_IE_PROBE_BCN) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5133 | == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5134 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5135 | } |
| 5136 | /* Assoc resp reset */ |
| 5137 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(adapter), |
| 5138 | &updateIE, |
| 5139 | eUPDATE_IE_ASSOC_RESP) == |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5140 | QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5141 | hdd_err("Could not pass on ASSOC_RSP data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5142 | } |
| 5143 | /* Reset WNI_CFG_PROBE_RSP Flags */ |
| 5144 | wlan_hdd_reset_prob_rspies(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5145 | } |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 5146 | qdf_mem_free(adapter->session.ap.beacon); |
| 5147 | adapter->session.ap.beacon = NULL; |
Ajit Pal Singh | 747b680 | 2017-05-24 15:42:03 +0530 | [diff] [blame] | 5148 | /* |
| 5149 | * If Do_Not_Break_Stream was enabled clear avoid channel list. |
| 5150 | */ |
| 5151 | if (policy_mgr_is_dnsc_set(adapter->hdd_vdev)) |
| 5152 | wlan_hdd_send_avoid_freq_for_dnbs(hdd_ctx, 0); |
| 5153 | |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5154 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5155 | cancel_work_sync(&adapter->ipv4_notifier_work); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5156 | #endif |
| 5157 | |
| 5158 | #ifdef WLAN_NS_OFFLOAD |
| 5159 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5160 | cancel_work_sync(&adapter->ipv6_notifier_work); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5161 | #endif |
| 5162 | #endif |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5163 | |
| 5164 | hdd_vdev_destroy(adapter); |
| 5165 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5166 | mutex_unlock(&hdd_ctx->sap_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5167 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5168 | case QDF_OCB_MODE: |
Krishna Kumaar Natarajan | e58b409 | 2017-01-25 15:47:35 -0800 | [diff] [blame] | 5169 | cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC), |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 5170 | (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX), |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 5171 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)->conn_info.staId[0]); |
Zhang Qian | 79d0d13 | 2018-02-05 13:40:16 +0800 | [diff] [blame] | 5172 | hdd_deregister_tx_flow_control(adapter); |
| 5173 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5174 | break; |
| 5175 | default: |
| 5176 | break; |
| 5177 | } |
| 5178 | |
Dustin Brown | 0434837 | 2017-12-14 16:13:39 -0800 | [diff] [blame] | 5179 | if (adapter->scan_info.default_scan_ies) { |
| 5180 | qdf_mem_free(adapter->scan_info.default_scan_ies); |
| 5181 | adapter->scan_info.default_scan_ies = NULL; |
| 5182 | } |
| 5183 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5184 | hdd_exit(); |
Dustin Brown | 0434837 | 2017-12-14 16:13:39 -0800 | [diff] [blame] | 5185 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5186 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5187 | } |
| 5188 | |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5189 | /** |
| 5190 | * hdd_deinit_all_adapters - deinit all adapters |
| 5191 | * @hdd_ctx: HDD context |
| 5192 | * @rtnl_held: True if RTNL lock held |
| 5193 | * |
| 5194 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5195 | 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] | 5196 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5197 | struct hdd_adapter *adapter; |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5198 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5199 | hdd_enter(); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5200 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5201 | hdd_for_each_adapter(hdd_ctx, adapter) |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5202 | hdd_deinit_adapter(hdd_ctx, adapter, rtnl_held); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5203 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5204 | hdd_exit(); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5205 | } |
| 5206 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5207 | QDF_STATUS hdd_stop_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5208 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5209 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5210 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5211 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5212 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 5213 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 5214 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5215 | hdd_for_each_adapter(hdd_ctx, adapter) |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5216 | hdd_stop_adapter(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5217 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5218 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5219 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5220 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5221 | } |
| 5222 | |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5223 | static void hdd_reset_scan_operation(struct hdd_context *hdd_ctx, |
| 5224 | struct hdd_adapter *adapter) |
| 5225 | { |
| 5226 | switch (adapter->device_mode) { |
| 5227 | case QDF_STA_MODE: |
| 5228 | case QDF_P2P_CLIENT_MODE: |
| 5229 | case QDF_IBSS_MODE: |
| 5230 | case QDF_P2P_DEVICE_MODE: |
| 5231 | case QDF_NDI_MODE: |
| 5232 | wlan_hdd_scan_abort(adapter); |
| 5233 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 5234 | if (adapter->device_mode == QDF_STA_MODE) |
| 5235 | wlan_cfg80211_sched_scan_stop(hdd_ctx->hdd_pdev, |
| 5236 | adapter->dev); |
| 5237 | break; |
| 5238 | case QDF_P2P_GO_MODE: |
| 5239 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 5240 | break; |
| 5241 | case QDF_SAP_MODE: |
| 5242 | wlan_hdd_undo_acs(adapter); |
| 5243 | break; |
| 5244 | default: |
| 5245 | break; |
| 5246 | } |
| 5247 | } |
| 5248 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5249 | QDF_STATUS hdd_reset_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5250 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5251 | struct hdd_adapter *adapter; |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5252 | struct hdd_station_ctx *sta_ctx; |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5253 | struct qdf_mac_addr peerMacAddr; |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5254 | int sta_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5255 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5256 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5257 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 5258 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 5259 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5260 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 5261 | hdd_info("[SSR] reset adapter with device mode %s(%d)", |
| 5262 | hdd_device_mode_to_string(adapter->device_mode), |
| 5263 | adapter->device_mode); |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 5264 | |
| 5265 | if ((adapter->device_mode == QDF_STA_MODE) || |
Paul Zhang | 679025e | 2018-03-08 22:39:44 +0800 | [diff] [blame] | 5266 | (adapter->device_mode == QDF_P2P_CLIENT_MODE)) { |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 5267 | /* Stop tdls timers */ |
Kabilan Kannan | 00d2041 | 2017-06-04 14:20:32 -0700 | [diff] [blame] | 5268 | hdd_notify_tdls_reset_adapter(adapter->hdd_vdev); |
Paul Zhang | 679025e | 2018-03-08 22:39:44 +0800 | [diff] [blame] | 5269 | adapter->session.station.hdd_reassoc_scenario = false; |
| 5270 | } |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 5271 | |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5272 | if (hdd_ctx->config->sap_internal_restart && |
| 5273 | adapter->device_mode == QDF_SAP_MODE) { |
| 5274 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5275 | WLAN_STOP_ALL_NETIF_QUEUE, |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5276 | WLAN_CONTROL_PATH); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5277 | if (test_bit(SOFTAP_BSS_STARTED, |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5278 | &adapter->event_flags)) |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5279 | hdd_sap_indicate_disconnect_for_sta(adapter); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5280 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
| 5281 | } else { |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5282 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5283 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5284 | WLAN_CONTROL_PATH); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5285 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5286 | |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5287 | hdd_reset_scan_operation(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5288 | |
| 5289 | hdd_deinit_tx_rx(adapter); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 5290 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5291 | adapter->device_mode, adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 5292 | hdd_green_ap_start_state_mc(hdd_ctx, adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 5293 | false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5294 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 5295 | hdd_wmm_adapter_close(adapter); |
| 5296 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 5297 | } |
| 5298 | |
Vignesh Viswanathan | 2eb1874 | 2017-09-08 11:18:59 +0530 | [diff] [blame] | 5299 | if (adapter->device_mode == QDF_STA_MODE) |
| 5300 | hdd_clear_fils_connection_info(adapter); |
| 5301 | |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 5302 | if (adapter->device_mode == QDF_SAP_MODE) { |
| 5303 | /* |
| 5304 | * If adapter is SAP, set session ID to invalid |
| 5305 | * since SAP session will be cleanup during SSR. |
| 5306 | */ |
Wu Gao | 3671743 | 2016-11-21 15:09:48 +0800 | [diff] [blame] | 5307 | wlansap_set_invalid_session( |
| 5308 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
| 5309 | |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 5310 | wlansap_cleanup_cac_timer( |
| 5311 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
| 5312 | } |
| 5313 | |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5314 | /* Delete connection peers if any to avoid peer object leaks */ |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5315 | if (adapter->device_mode == QDF_STA_MODE || |
| 5316 | adapter->device_mode == QDF_P2P_CLIENT_MODE) { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5317 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5318 | qdf_copy_macaddr(&peerMacAddr, |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5319 | &sta_ctx->conn_info.bssId); |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5320 | |
| 5321 | hdd_objmgr_remove_peer_object(adapter->hdd_vdev, |
| 5322 | peerMacAddr.bytes); |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5323 | } else if (adapter->device_mode == QDF_P2P_GO_MODE) { |
| 5324 | for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; sta_id++) { |
| 5325 | if (adapter->sta_info[sta_id].in_use) { |
| 5326 | hdd_debug("[SSR] deregister STA with ID %d", |
| 5327 | sta_id); |
| 5328 | hdd_softap_deregister_sta(adapter, |
| 5329 | sta_id); |
| 5330 | adapter->sta_info[sta_id].in_use = 0; |
| 5331 | } |
| 5332 | } |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5333 | } |
| 5334 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5335 | hdd_nud_reset_tracking(adapter); |
| 5336 | hdd_nud_ignore_tracking(adapter, true); |
| 5337 | hdd_set_disconnect_status(adapter, false); |
| 5338 | |
Tiger Yu | 94a5a5c | 2018-03-09 21:22:26 +0800 | [diff] [blame] | 5339 | hdd_softap_deinit_tx_rx(adapter); |
| 5340 | |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 5341 | /* Destroy vdev which will be recreated during reinit. */ |
| 5342 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5343 | } |
| 5344 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5345 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5346 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5347 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5348 | } |
| 5349 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5350 | bool hdd_check_for_opened_interfaces(struct hdd_context *hdd_ctx) |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5351 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5352 | struct hdd_adapter *adapter; |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5353 | bool close_modules = true; |
| 5354 | |
Arun Khandavalli | ba479c4 | 2017-07-26 21:29:40 +0530 | [diff] [blame] | 5355 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 5356 | hdd_info("FTM mode, don't close the module"); |
| 5357 | return false; |
| 5358 | } |
| 5359 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5360 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 5361 | if (test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags) || |
| 5362 | test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5363 | hdd_debug("Still other ifaces are up cannot close modules"); |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5364 | close_modules = false; |
| 5365 | break; |
| 5366 | } |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5367 | } |
| 5368 | |
| 5369 | return close_modules; |
| 5370 | } |
| 5371 | |
yeshwanth sriram guntuka | ea63f63 | 2017-08-30 19:31:56 +0530 | [diff] [blame] | 5372 | bool hdd_is_interface_up(struct hdd_adapter *adapter) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5373 | { |
| 5374 | if (test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) |
| 5375 | return true; |
| 5376 | else |
| 5377 | return false; |
| 5378 | } |
| 5379 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5380 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)) \ |
bings | bdcd4a2 | 2017-06-20 09:27:00 +0800 | [diff] [blame] | 5381 | && !defined(WITH_BACKPORTS) && !defined(IEEE80211_PRIVACY) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5382 | struct cfg80211_bss *hdd_cfg80211_get_bss(struct wiphy *wiphy, |
| 5383 | struct ieee80211_channel *channel, |
| 5384 | const u8 *bssid, const u8 *ssid, |
| 5385 | size_t ssid_len) |
| 5386 | { |
| 5387 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 5388 | ssid, ssid_len, |
| 5389 | WLAN_CAPABILITY_ESS, |
| 5390 | WLAN_CAPABILITY_ESS); |
| 5391 | } |
| 5392 | #else |
| 5393 | struct cfg80211_bss *hdd_cfg80211_get_bss(struct wiphy *wiphy, |
| 5394 | struct ieee80211_channel *channel, |
| 5395 | const u8 *bssid, const u8 *ssid, |
| 5396 | size_t ssid_len) |
| 5397 | { |
| 5398 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 5399 | ssid, ssid_len, |
| 5400 | IEEE80211_BSS_TYPE_ESS, |
| 5401 | IEEE80211_PRIVACY_ANY); |
| 5402 | } |
| 5403 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5404 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5405 | #if defined CFG80211_CONNECT_BSS || \ |
| 5406 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5407 | #if defined CFG80211_CONNECT_TIMEOUT_REASON_CODE || \ |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5408 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5409 | /** |
| 5410 | * hdd_convert_timeout_reason() - Convert to kernel specific enum |
| 5411 | * @timeout_reason: reason for connect timeout |
| 5412 | * |
| 5413 | * This function is used to convert host timeout |
| 5414 | * reason enum to kernel specific enum. |
| 5415 | * |
| 5416 | * Return: nl timeout enum |
| 5417 | */ |
| 5418 | static enum nl80211_timeout_reason hdd_convert_timeout_reason( |
| 5419 | tSirResultCodes timeout_reason) |
| 5420 | { |
| 5421 | switch (timeout_reason) { |
| 5422 | case eSIR_SME_JOIN_TIMEOUT_RESULT_CODE: |
| 5423 | return NL80211_TIMEOUT_SCAN; |
| 5424 | case eSIR_SME_AUTH_TIMEOUT_RESULT_CODE: |
| 5425 | return NL80211_TIMEOUT_AUTH; |
| 5426 | case eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE: |
| 5427 | return NL80211_TIMEOUT_ASSOC; |
| 5428 | default: |
| 5429 | return NL80211_TIMEOUT_UNSPECIFIED; |
| 5430 | } |
| 5431 | } |
| 5432 | |
| 5433 | /** |
| 5434 | * hdd_cfg80211_connect_timeout() - API to send connection timeout reason |
| 5435 | * @dev: network device |
| 5436 | * @bssid: bssid to which we want to associate |
| 5437 | * @timeout_reason: reason for connect timeout |
| 5438 | * |
| 5439 | * This API is used to send connection timeout reason to supplicant |
| 5440 | * |
| 5441 | * Return: void |
| 5442 | */ |
| 5443 | static void hdd_cfg80211_connect_timeout(struct net_device *dev, |
| 5444 | const u8 *bssid, |
| 5445 | tSirResultCodes timeout_reason) |
| 5446 | { |
| 5447 | enum nl80211_timeout_reason nl_timeout_reason; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5448 | |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5449 | nl_timeout_reason = hdd_convert_timeout_reason(timeout_reason); |
| 5450 | |
| 5451 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL, |
| 5452 | nl_timeout_reason); |
| 5453 | } |
| 5454 | |
| 5455 | /** |
| 5456 | * __hdd_connect_bss() - API to send connection status to supplicant |
| 5457 | * @dev: network device |
| 5458 | * @bssid: bssid to which we want to associate |
| 5459 | * @req_ie: Request Information Element |
| 5460 | * @req_ie_len: len of the req IE |
| 5461 | * @resp_ie: Response IE |
| 5462 | * @resp_ie_len: len of ht response IE |
| 5463 | * @status: status |
| 5464 | * @gfp: Kernel Flag |
| 5465 | * @timeout_reason: reason for connect timeout |
| 5466 | * |
| 5467 | * Return: void |
| 5468 | */ |
| 5469 | static void __hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5470 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5471 | size_t req_ie_len, const u8 *resp_ie, |
| 5472 | size_t resp_ie_len, int status, gfp_t gfp, |
| 5473 | tSirResultCodes timeout_reason) |
| 5474 | { |
| 5475 | enum nl80211_timeout_reason nl_timeout_reason; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5476 | |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5477 | nl_timeout_reason = hdd_convert_timeout_reason(timeout_reason); |
| 5478 | |
| 5479 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 5480 | resp_ie, resp_ie_len, status, gfp, |
| 5481 | nl_timeout_reason); |
| 5482 | } |
| 5483 | #else |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5484 | #if defined CFG80211_CONNECT_TIMEOUT || \ |
| 5485 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5486 | static void hdd_cfg80211_connect_timeout(struct net_device *dev, |
| 5487 | const u8 *bssid, |
| 5488 | tSirResultCodes timeout_reason) |
| 5489 | { |
| 5490 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL); |
| 5491 | } |
| 5492 | #endif |
| 5493 | |
| 5494 | static void __hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5495 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5496 | size_t req_ie_len, const u8 *resp_ie, |
| 5497 | size_t resp_ie_len, int status, gfp_t gfp, |
| 5498 | tSirResultCodes timeout_reason) |
| 5499 | { |
| 5500 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 5501 | resp_ie, resp_ie_len, status, gfp); |
| 5502 | } |
| 5503 | #endif |
| 5504 | |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5505 | /** |
| 5506 | * hdd_connect_bss() - API to send connection status to supplicant |
| 5507 | * @dev: network device |
| 5508 | * @bssid: bssid to which we want to associate |
| 5509 | * @req_ie: Request Information Element |
| 5510 | * @req_ie_len: len of the req IE |
| 5511 | * @resp_ie: Response IE |
| 5512 | * @resp_ie_len: len of ht response IE |
| 5513 | * @status: status |
| 5514 | * @gfp: Kernel Flag |
| 5515 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5516 | * @timeout_reason: reason for connect timeout |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5517 | * |
| 5518 | * The API is a wrapper to send connection status to supplicant |
| 5519 | * |
| 5520 | * Return: Void |
| 5521 | */ |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5522 | #if defined CFG80211_CONNECT_TIMEOUT || \ |
| 5523 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5524 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5525 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5526 | size_t req_ie_len, const u8 *resp_ie, |
| 5527 | size_t resp_ie_len, int status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5528 | bool connect_timeout, |
| 5529 | tSirResultCodes timeout_reason) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5530 | { |
| 5531 | if (connect_timeout) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5532 | hdd_cfg80211_connect_timeout(dev, bssid, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5533 | else |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5534 | __hdd_connect_bss(dev, bssid, bss, req_ie, req_ie_len, resp_ie, |
| 5535 | resp_ie_len, status, gfp, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5536 | } |
| 5537 | #else |
| 5538 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5539 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5540 | size_t req_ie_len, const u8 *resp_ie, |
| 5541 | size_t resp_ie_len, int status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5542 | bool connect_timeout, |
| 5543 | tSirResultCodes timeout_reason) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5544 | { |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5545 | __hdd_connect_bss(dev, bssid, bss, req_ie, req_ie_len, resp_ie, |
| 5546 | resp_ie_len, status, gfp, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5547 | } |
| 5548 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5549 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5550 | #if defined(WLAN_FEATURE_FILS_SK) |
| 5551 | #if defined(CFG80211_CONNECT_DONE) || \ |
| 5552 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)) |
| 5553 | #if defined(CFG80211_FILS_SK_OFFLOAD_SUPPORT) || \ |
| 5554 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5555 | /** |
| 5556 | * hdd_populate_fils_params() - Populate FILS keys to connect response |
| 5557 | * @fils_params: connect response to supplicant |
| 5558 | * @fils_kek: FILS kek |
| 5559 | * @fils_kek_len: FILS kek length |
| 5560 | * @pmk: FILS PMK |
| 5561 | * @pmk_len: FILS PMK length |
| 5562 | * @pmkid: PMKID |
| 5563 | * @fils_seq_num: FILS Seq number |
| 5564 | * |
| 5565 | * Return: None |
| 5566 | */ |
| 5567 | static void hdd_populate_fils_params(struct cfg80211_connect_resp_params |
| 5568 | *fils_params, const uint8_t *fils_kek, |
| 5569 | size_t fils_kek_len, const uint8_t *pmk, |
| 5570 | size_t pmk_len, const uint8_t *pmkid, |
| 5571 | uint16_t fils_seq_num) |
| 5572 | { |
| 5573 | /* Increament seq number to be used for next FILS */ |
| 5574 | fils_params->fils_erp_next_seq_num = fils_seq_num + 1; |
| 5575 | fils_params->update_erp_next_seq_num = true; |
| 5576 | fils_params->fils_kek = fils_kek; |
| 5577 | fils_params->fils_kek_len = fils_kek_len; |
| 5578 | fils_params->pmk = pmk; |
| 5579 | fils_params->pmk_len = pmk_len; |
| 5580 | fils_params->pmkid = pmkid; |
| 5581 | } |
| 5582 | #else |
| 5583 | static inline void hdd_populate_fils_params(struct cfg80211_connect_resp_params |
| 5584 | *fils_params, const uint8_t |
| 5585 | *fils_kek, size_t fils_kek_len, |
| 5586 | const uint8_t *pmk, size_t pmk_len, |
| 5587 | const uint8_t *pmkid, |
| 5588 | uint16_t fils_seq_num) |
| 5589 | { } |
| 5590 | #endif |
| 5591 | |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5592 | void hdd_update_hlp_info(struct net_device *dev, |
| 5593 | struct csr_roam_info *roam_info) |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5594 | { |
| 5595 | struct sk_buff *skb; |
| 5596 | uint16_t skb_len; |
| 5597 | struct llc_snap_hdr_t *llc_hdr; |
| 5598 | QDF_STATUS status; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5599 | uint8_t *hlp_data; |
| 5600 | uint16_t hlp_data_len; |
| 5601 | struct fils_join_rsp_params *roam_fils_params |
| 5602 | = roam_info->fils_join_rsp; |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5603 | struct hdd_adapter *padapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5604 | |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5605 | if (!roam_fils_params) { |
| 5606 | hdd_err("FILS Roam Param NULL"); |
| 5607 | return; |
| 5608 | } |
| 5609 | |
Srinivas Girigowda | 3cc8e91 | 2017-11-28 18:11:57 -0800 | [diff] [blame] | 5610 | if (!roam_fils_params->hlp_data_len) { |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5611 | hdd_err("FILS HLP Data NULL, len %d", |
| 5612 | roam_fils_params->hlp_data_len); |
| 5613 | return; |
| 5614 | } |
| 5615 | |
| 5616 | hlp_data = roam_fils_params->hlp_data; |
| 5617 | hlp_data_len = roam_fils_params->hlp_data_len; |
| 5618 | |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5619 | /* Calculate skb length */ |
| 5620 | skb_len = (2 * ETH_ALEN) + hlp_data_len; |
| 5621 | skb = qdf_nbuf_alloc(NULL, skb_len, 0, 4, false); |
| 5622 | if (skb == NULL) { |
| 5623 | hdd_err("HLP packet nbuf alloc fails"); |
| 5624 | return; |
| 5625 | } |
| 5626 | |
| 5627 | qdf_mem_copy(skb_put(skb, ETH_ALEN), roam_fils_params->dst_mac.bytes, |
| 5628 | QDF_MAC_ADDR_SIZE); |
| 5629 | qdf_mem_copy(skb_put(skb, ETH_ALEN), roam_fils_params->src_mac.bytes, |
| 5630 | QDF_MAC_ADDR_SIZE); |
| 5631 | |
| 5632 | llc_hdr = (struct llc_snap_hdr_t *) hlp_data; |
| 5633 | if (IS_SNAP(llc_hdr)) { |
| 5634 | hlp_data += LLC_SNAP_HDR_OFFSET_ETHERTYPE; |
| 5635 | hlp_data_len += LLC_SNAP_HDR_OFFSET_ETHERTYPE; |
| 5636 | } |
| 5637 | |
| 5638 | qdf_mem_copy(skb_put(skb, hlp_data_len), hlp_data, hlp_data_len); |
| 5639 | |
| 5640 | /* |
| 5641 | * This HLP packet is formed from HLP info encapsulated |
| 5642 | * in assoc response frame which is AEAD encrypted. |
| 5643 | * Hence, this checksum validation can be set unnecessary. |
| 5644 | * i.e. network layer need not worry about checksum. |
| 5645 | */ |
| 5646 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
| 5647 | |
| 5648 | status = hdd_rx_packet_cbk(padapter, skb); |
| 5649 | if (QDF_IS_STATUS_ERROR(status)) { |
| 5650 | hdd_err("Sending HLP packet fails"); |
| 5651 | return; |
| 5652 | } |
| 5653 | hdd_debug("send HLP packet to netif successfully"); |
| 5654 | } |
| 5655 | |
| 5656 | /** |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5657 | * hdd_connect_done() - Wrapper API to call cfg80211_connect_done |
| 5658 | * @dev: network device |
| 5659 | * @bssid: bssid to which we want to associate |
| 5660 | * @bss: cfg80211 bss info |
| 5661 | * @roam_info: information about connected bss |
| 5662 | * @req_ie: Request Information Element |
| 5663 | * @req_ie_len: len of the req IE |
| 5664 | * @resp_ie: Response IE |
| 5665 | * @resp_ie_len: len of ht response IE |
| 5666 | * @status: status |
| 5667 | * @gfp: allocation flags |
| 5668 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
| 5669 | * @timeout_reason: reason for connect timeout |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5670 | * |
| 5671 | * This API is used as wrapper to send FILS key/sequence number |
| 5672 | * params etc. to supplicant in case of FILS connection |
| 5673 | * |
| 5674 | * Return: None |
| 5675 | */ |
| 5676 | static void hdd_connect_done(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5677 | struct cfg80211_bss *bss, |
| 5678 | struct csr_roam_info *roam_info, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5679 | const u8 *req_ie, size_t req_ie_len, |
| 5680 | const u8 *resp_ie, size_t resp_ie_len, u16 status, |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5681 | gfp_t gfp, bool connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5682 | tSirResultCodes timeout_reason) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5683 | { |
| 5684 | struct cfg80211_connect_resp_params fils_params; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5685 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5686 | struct fils_join_rsp_params *roam_fils_params = |
| 5687 | roam_info->fils_join_rsp; |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5688 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5689 | qdf_mem_zero(&fils_params, sizeof(fils_params)); |
| 5690 | |
| 5691 | if (!roam_fils_params) { |
| 5692 | fils_params.status = WLAN_STATUS_UNSPECIFIED_FAILURE; |
| 5693 | } else { |
| 5694 | fils_params.status = status; |
| 5695 | fils_params.bssid = bssid; |
Srinivas Girigowda | e975f53 | 2018-01-05 14:03:05 -0800 | [diff] [blame] | 5696 | fils_params.timeout_reason = |
| 5697 | hdd_convert_timeout_reason(timeout_reason); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5698 | fils_params.req_ie = req_ie; |
| 5699 | fils_params.req_ie_len = req_ie_len; |
| 5700 | fils_params.resp_ie = resp_ie; |
| 5701 | fils_params.resp_ie_len = resp_ie_len; |
| 5702 | fils_params.bss = bss; |
| 5703 | hdd_populate_fils_params(&fils_params, roam_fils_params->kek, |
| 5704 | roam_fils_params->kek_len, |
| 5705 | roam_fils_params->fils_pmk, |
| 5706 | roam_fils_params->fils_pmk_len, |
| 5707 | roam_fils_params->fils_pmkid, |
| 5708 | roam_info->fils_seq_num); |
Sridhar Selvaraj | e526044 | 2017-08-19 10:12:03 +0530 | [diff] [blame] | 5709 | hdd_save_gtk_params(adapter, roam_info, false); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5710 | } |
| 5711 | hdd_debug("FILS indicate connect status %d seq no %d", |
| 5712 | fils_params.status, |
| 5713 | fils_params.fils_erp_next_seq_num); |
| 5714 | |
| 5715 | cfg80211_connect_done(dev, &fils_params, gfp); |
| 5716 | |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5717 | if (roam_fils_params && roam_fils_params->hlp_data_len) |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5718 | hdd_update_hlp_info(dev, roam_info); |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5719 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5720 | /* Clear all the FILS key info */ |
| 5721 | if (roam_fils_params && roam_fils_params->fils_pmk) |
| 5722 | qdf_mem_free(roam_fils_params->fils_pmk); |
| 5723 | if (roam_fils_params) |
| 5724 | qdf_mem_free(roam_fils_params); |
| 5725 | roam_info->fils_join_rsp = NULL; |
| 5726 | } |
| 5727 | #else |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5728 | static inline void |
| 5729 | hdd_connect_done(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5730 | struct cfg80211_bss *bss, struct csr_roam_info *roam_info, |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5731 | const u8 *req_ie, size_t req_ie_len, |
| 5732 | const u8 *resp_ie, size_t resp_ie_len, u16 status, |
| 5733 | gfp_t gfp, bool connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5734 | tSirResultCodes timeout_reason) |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5735 | { } |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5736 | #endif |
| 5737 | #endif |
| 5738 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5739 | #if defined(WLAN_FEATURE_FILS_SK) && \ |
| 5740 | (defined(CFG80211_CONNECT_DONE) || \ |
| 5741 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0))) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5742 | /** |
| 5743 | * hdd_fils_update_connect_results() - API to send fils connection status to |
| 5744 | * supplicant. |
| 5745 | * @dev: network device |
| 5746 | * @bssid: bssid to which we want to associate |
| 5747 | * @bss: cfg80211 bss info |
| 5748 | * @roam_info: information about connected bss |
| 5749 | * @req_ie: Request Information Element |
| 5750 | * @req_ie_len: len of the req IE |
| 5751 | * @resp_ie: Response IE |
| 5752 | * @resp_ie_len: len of ht response IE |
| 5753 | * @status: status |
| 5754 | * @gfp: allocation flags |
| 5755 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
| 5756 | * @timeout_reason: reason for connect timeout |
| 5757 | * |
| 5758 | * The API is a wrapper to send connection status to supplicant |
| 5759 | * |
| 5760 | * Return: 0 if success else failure |
| 5761 | */ |
| 5762 | static int hdd_fils_update_connect_results(struct net_device *dev, |
| 5763 | const u8 *bssid, |
| 5764 | struct cfg80211_bss *bss, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5765 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5766 | size_t req_ie_len, const u8 *resp_ie, |
| 5767 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 5768 | bool connect_timeout, |
| 5769 | tSirResultCodes timeout_reason) |
| 5770 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5771 | hdd_enter(); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5772 | if (!roam_info || !roam_info->is_fils_connection) |
| 5773 | return -EINVAL; |
| 5774 | |
| 5775 | hdd_connect_done(dev, bssid, bss, roam_info, req_ie, req_ie_len, |
| 5776 | resp_ie, resp_ie_len, status, gfp, connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5777 | timeout_reason); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5778 | return 0; |
| 5779 | } |
| 5780 | #else |
| 5781 | static inline int hdd_fils_update_connect_results(struct net_device *dev, |
| 5782 | const u8 *bssid, |
| 5783 | struct cfg80211_bss *bss, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5784 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5785 | size_t req_ie_len, const u8 *resp_ie, |
| 5786 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 5787 | bool connect_timeout, |
| 5788 | tSirResultCodes timeout_reason) |
| 5789 | { |
| 5790 | return -EINVAL; |
| 5791 | } |
| 5792 | #endif |
| 5793 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5794 | /** |
| 5795 | * hdd_connect_result() - API to send connection status to supplicant |
| 5796 | * @dev: network device |
| 5797 | * @bssid: bssid to which we want to associate |
| 5798 | * @roam_info: information about connected bss |
| 5799 | * @req_ie: Request Information Element |
| 5800 | * @req_ie_len: len of the req IE |
| 5801 | * @resp_ie: Response IE |
| 5802 | * @resp_ie_len: len of ht response IE |
| 5803 | * @status: status |
| 5804 | * @gfp: Kernel Flag |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5805 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5806 | * @timeout_reason: reason for connect timeout |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5807 | * |
| 5808 | * The API is a wrapper to send connection status to supplicant |
| 5809 | * and allow runtime suspend |
| 5810 | * |
| 5811 | * Return: Void |
| 5812 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5813 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5814 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5815 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5816 | size_t resp_ie_len, u16 status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5817 | bool connect_timeout, |
| 5818 | tSirResultCodes timeout_reason) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5819 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5820 | struct hdd_adapter *padapter = (struct hdd_adapter *) netdev_priv(dev); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5821 | struct cfg80211_bss *bss = NULL; |
Jingxiang Ge | 929c793 | 2018-01-24 14:01:12 +0800 | [diff] [blame] | 5822 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(padapter); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5823 | |
| 5824 | if (WLAN_STATUS_SUCCESS == status) { |
| 5825 | struct ieee80211_channel *chan; |
| 5826 | int freq; |
| 5827 | int chan_no = roam_info->pBssDesc->channelId; |
| 5828 | |
| 5829 | if (chan_no <= 14) |
| 5830 | freq = ieee80211_channel_to_frequency(chan_no, |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 5831 | HDD_NL80211_BAND_2GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5832 | else |
| 5833 | freq = ieee80211_channel_to_frequency(chan_no, |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 5834 | HDD_NL80211_BAND_5GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5835 | |
| 5836 | chan = ieee80211_get_channel(padapter->wdev.wiphy, freq); |
| 5837 | bss = hdd_cfg80211_get_bss(padapter->wdev.wiphy, chan, bssid, |
| 5838 | roam_info->u.pConnectedProfile->SSID.ssId, |
| 5839 | roam_info->u.pConnectedProfile->SSID.length); |
| 5840 | } |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 5841 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5842 | if (hdd_fils_update_connect_results(dev, bssid, bss, |
| 5843 | roam_info, req_ie, req_ie_len, resp_ie, |
| 5844 | resp_ie_len, status, gfp, connect_timeout, |
| 5845 | timeout_reason) != 0) { |
| 5846 | hdd_connect_bss(dev, bssid, bss, req_ie, |
| 5847 | req_ie_len, resp_ie, resp_ie_len, |
| 5848 | status, gfp, connect_timeout, timeout_reason); |
| 5849 | } |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 5850 | |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 5851 | qdf_runtime_pm_allow_suspend(&hdd_ctx->runtime_context.connect); |
Dustin Brown | ceed67e | 2017-05-26 11:57:31 -0700 | [diff] [blame] | 5852 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5853 | } |
| 5854 | #else |
| 5855 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5856 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5857 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5858 | size_t resp_ie_len, u16 status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5859 | bool connect_timeout, |
| 5860 | tSirResultCodes timeout_reason) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5861 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5862 | struct hdd_adapter *padapter = (struct hdd_adapter *) netdev_priv(dev); |
Jingxiang Ge | 929c793 | 2018-01-24 14:01:12 +0800 | [diff] [blame] | 5863 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(padapter); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 5864 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5865 | cfg80211_connect_result(dev, bssid, req_ie, req_ie_len, |
| 5866 | resp_ie, resp_ie_len, status, gfp); |
Prashanth Bhatta | 87b6dc0 | 2017-01-19 15:17:58 -0800 | [diff] [blame] | 5867 | |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 5868 | qdf_runtime_pm_allow_suspend(&hdd_ctx->runtime_context.connect); |
Dustin Brown | ceed67e | 2017-05-26 11:57:31 -0700 | [diff] [blame] | 5869 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5870 | } |
| 5871 | #endif |
| 5872 | |
| 5873 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5874 | QDF_STATUS hdd_start_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5875 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5876 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5877 | #ifndef MSM_PLATFORM |
Dustin Brown | ce5b3d3 | 2018-01-17 15:07:38 -0800 | [diff] [blame] | 5878 | struct qdf_mac_addr bcastMac = QDF_MAC_ADDR_BCAST_INIT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5879 | #endif |
| 5880 | eConnectionState connState; |
| 5881 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5882 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5883 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5884 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5885 | if (!hdd_is_interface_up(adapter)) |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5886 | continue; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5887 | |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5888 | hdd_debug("[SSR] start adapter with device mode %s(%d)", |
| 5889 | hdd_device_mode_to_string(adapter->device_mode), |
| 5890 | adapter->device_mode); |
| 5891 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5892 | hdd_wmm_init(adapter); |
| 5893 | |
| 5894 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5895 | case QDF_STA_MODE: |
| 5896 | case QDF_P2P_CLIENT_MODE: |
| 5897 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5898 | |
| 5899 | connState = (WLAN_HDD_GET_STATION_CTX_PTR(adapter)) |
| 5900 | ->conn_info.connState; |
| 5901 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5902 | hdd_start_station_adapter(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5903 | /* Open the gates for HDD to receive Wext commands */ |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 5904 | adapter->is_link_up_service_needed = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5905 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5906 | /* Indicate disconnect event to supplicant |
| 5907 | * if associated previously |
| 5908 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5909 | if (eConnectionState_Associated == connState || |
Yue Ma | cd96144 | 2015-10-20 16:15:31 -0700 | [diff] [blame] | 5910 | eConnectionState_IbssConnected == connState || |
| 5911 | eConnectionState_NotConnected == connState || |
| 5912 | eConnectionState_IbssDisconnected == connState || |
| 5913 | eConnectionState_Disconnecting == connState) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5914 | union iwreq_data wrqu; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5915 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5916 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 5917 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 5918 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 5919 | wireless_send_event(adapter->dev, SIOCGIWAP, |
| 5920 | &wrqu, NULL); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 5921 | adapter->session.station. |
Jeff Johnson | 690fe95 | 2017-10-25 11:48:39 -0700 | [diff] [blame] | 5922 | hdd_reassoc_scenario = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5923 | |
| 5924 | /* indicate disconnected event to nl80211 */ |
Mahesh A Saptasagar | c35e8bf | 2016-06-17 20:03:46 +0530 | [diff] [blame] | 5925 | wlan_hdd_cfg80211_indicate_disconnect( |
| 5926 | adapter->dev, false, |
| 5927 | WLAN_REASON_UNSPECIFIED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5928 | } else if (eConnectionState_Connecting == connState) { |
| 5929 | /* |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5930 | * Indicate connect failure to supplicant if we |
| 5931 | * were in the process of connecting |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5932 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5933 | hdd_connect_result(adapter->dev, NULL, NULL, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5934 | NULL, 0, NULL, 0, |
| 5935 | WLAN_STATUS_ASSOC_DENIED_UNSPEC, |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5936 | GFP_KERNEL, false, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5937 | } |
| 5938 | |
| 5939 | hdd_register_tx_flow_control(adapter, |
| 5940 | hdd_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 5941 | hdd_tx_resume_cb, |
| 5942 | hdd_tx_flow_control_is_pause); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5943 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5944 | hdd_nud_ignore_tracking(adapter, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5945 | break; |
| 5946 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5947 | case QDF_SAP_MODE: |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5948 | if (hdd_ctx->config->sap_internal_restart) |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5949 | hdd_start_ap_adapter(adapter); |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5950 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5951 | break; |
| 5952 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5953 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5954 | #ifdef MSM_PLATFORM |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5955 | hdd_debug("[SSR] send stop ap to supplicant"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5956 | cfg80211_ap_stopped(adapter->dev, GFP_KERNEL); |
| 5957 | #else |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5958 | hdd_debug("[SSR] send restart supplicant"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5959 | /* event supplicant to restart */ |
| 5960 | cfg80211_del_sta(adapter->dev, |
| 5961 | (const u8 *)&bcastMac.bytes[0], |
| 5962 | GFP_KERNEL); |
| 5963 | #endif |
| 5964 | break; |
Arunk Khandavalli | 062fb03 | 2017-10-04 12:18:15 +0530 | [diff] [blame] | 5965 | case QDF_MONITOR_MODE: |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5966 | hdd_start_station_adapter(adapter); |
Arunk Khandavalli | 062fb03 | 2017-10-04 12:18:15 +0530 | [diff] [blame] | 5967 | hdd_set_mon_rx_cb(adapter->dev); |
| 5968 | wlan_hdd_set_mon_chan(adapter, adapter->mon_chan, |
| 5969 | adapter->mon_bandwidth); |
| 5970 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5971 | default: |
| 5972 | break; |
| 5973 | } |
Krunal Soni | 9c2ee03 | 2017-07-18 13:49:54 -0700 | [diff] [blame] | 5974 | /* |
| 5975 | * Action frame registered in one adapter which will |
| 5976 | * applicable to all interfaces |
| 5977 | */ |
| 5978 | wlan_hdd_cfg80211_register_frames(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5979 | } |
| 5980 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5981 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5982 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5983 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5984 | } |
| 5985 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5986 | QDF_STATUS hdd_get_front_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5987 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5988 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5989 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5990 | qdf_list_node_t *node; |
| 5991 | |
| 5992 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5993 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5994 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5995 | status = qdf_list_peek_front(&hdd_ctx->hdd_adapters, &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5996 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5997 | |
| 5998 | if (QDF_IS_STATUS_ERROR(status)) |
| 5999 | return status; |
| 6000 | |
| 6001 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 6002 | |
| 6003 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6004 | } |
| 6005 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6006 | QDF_STATUS hdd_get_next_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6007 | struct hdd_adapter *current_adapter, |
| 6008 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6009 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6010 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6011 | qdf_list_node_t *node; |
| 6012 | |
| 6013 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6014 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6015 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 6016 | status = qdf_list_peek_next(&hdd_ctx->hdd_adapters, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6017 | ¤t_adapter->node, |
| 6018 | &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6019 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6020 | |
| 6021 | if (QDF_IS_STATUS_ERROR(status)) |
| 6022 | return status; |
| 6023 | |
| 6024 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 6025 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6026 | return status; |
| 6027 | } |
| 6028 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6029 | QDF_STATUS hdd_remove_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6030 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6031 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6032 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6033 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6034 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6035 | status = qdf_list_remove_node(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6036 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6037 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6038 | return status; |
| 6039 | } |
| 6040 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6041 | QDF_STATUS hdd_remove_front_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6042 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6043 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6044 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6045 | qdf_list_node_t *node; |
| 6046 | |
| 6047 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6048 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6049 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6050 | status = qdf_list_remove_front(&hdd_ctx->hdd_adapters, &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6051 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6052 | |
| 6053 | if (QDF_IS_STATUS_ERROR(status)) |
| 6054 | return status; |
| 6055 | |
| 6056 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 6057 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6058 | return status; |
| 6059 | } |
| 6060 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6061 | QDF_STATUS hdd_add_adapter_back(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6062 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6063 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6064 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6065 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6066 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6067 | status = qdf_list_insert_back(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6068 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6069 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6070 | return status; |
| 6071 | } |
| 6072 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6073 | QDF_STATUS hdd_add_adapter_front(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6074 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6075 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6076 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6077 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6078 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6079 | status = qdf_list_insert_front(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6080 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6081 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6082 | return status; |
| 6083 | } |
| 6084 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6085 | 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] | 6086 | tSirMacAddr macAddr) |
| 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 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6090 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6091 | if (!qdf_mem_cmp(adapter->mac_addr.bytes, |
| 6092 | macAddr, sizeof(tSirMacAddr))) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6093 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6094 | } |
| 6095 | |
| 6096 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6097 | } |
| 6098 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6099 | 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] | 6100 | uint32_t vdev_id) |
| 6101 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6102 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6103 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6104 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 6105 | if (adapter->session_id == vdev_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6106 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6107 | } |
| 6108 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6109 | return NULL; |
| 6110 | } |
| 6111 | |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6112 | /** |
| 6113 | * hdd_get_adapter_by_sme_session_id() - Return adapter with |
| 6114 | * the sessionid |
| 6115 | * @hdd_ctx: hdd context. |
| 6116 | * @sme_session_id: sme session is for the adapter to get. |
| 6117 | * |
| 6118 | * This function is used to get the adapter with provided session id |
| 6119 | * |
| 6120 | * Return: adapter pointer if found |
| 6121 | * |
| 6122 | */ |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 6123 | struct hdd_adapter * |
| 6124 | hdd_get_adapter_by_sme_session_id(struct hdd_context *hdd_ctx, |
| 6125 | uint32_t sme_session_id) |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6126 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6127 | struct hdd_adapter *adapter; |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6128 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6129 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6130 | if (adapter->session_id == sme_session_id) |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6131 | return adapter; |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6132 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6133 | |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6134 | return NULL; |
| 6135 | } |
| 6136 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6137 | 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] | 6138 | const char *iface_name) |
| 6139 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6140 | struct hdd_adapter *adapter; |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6141 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6142 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6143 | if (!qdf_str_cmp(adapter->dev->name, iface_name)) |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6144 | return adapter; |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6145 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6146 | |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6147 | return NULL; |
| 6148 | } |
| 6149 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6150 | /** |
| 6151 | * hdd_get_adapter() - to get adapter matching the mode |
| 6152 | * @hdd_ctx: hdd context |
| 6153 | * @mode: adapter mode |
| 6154 | * |
| 6155 | * This routine will return the pointer to adapter matching |
| 6156 | * with the passed mode. |
| 6157 | * |
| 6158 | * Return: pointer to adapter or null |
| 6159 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6160 | struct hdd_adapter *hdd_get_adapter(struct hdd_context *hdd_ctx, |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 6161 | enum QDF_OPMODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6162 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6163 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6164 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6165 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6166 | if (adapter->device_mode == mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6167 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6168 | } |
| 6169 | |
| 6170 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6171 | } |
| 6172 | |
Yeshwanth Sriram Guntuka | 469f957 | 2018-02-12 13:28:22 +0530 | [diff] [blame] | 6173 | enum tQDF_ADAPTER_MODE hdd_get_device_mode(uint32_t session_id) |
| 6174 | { |
| 6175 | struct hdd_context *hdd_ctx; |
| 6176 | struct hdd_adapter *adapter; |
| 6177 | |
| 6178 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 6179 | if (!hdd_ctx) { |
| 6180 | hdd_err("Invalid HDD context"); |
| 6181 | return QDF_MAX_NO_OF_MODE; |
| 6182 | } |
| 6183 | |
| 6184 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, session_id); |
| 6185 | if (!adapter) { |
| 6186 | hdd_err("Invalid HDD adapter"); |
| 6187 | return QDF_MAX_NO_OF_MODE; |
| 6188 | } |
| 6189 | |
| 6190 | return adapter->device_mode; |
| 6191 | } |
| 6192 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6193 | /** |
| 6194 | * hdd_get_operating_channel() - return operating channel of the device mode |
| 6195 | * @hdd_ctx: Pointer to the HDD context. |
| 6196 | * @mode: Device mode for which operating channel is required. |
| 6197 | * Suported modes: |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6198 | * QDF_STA_MODE, |
| 6199 | * QDF_P2P_CLIENT_MODE, |
| 6200 | * QDF_SAP_MODE, |
| 6201 | * QDF_P2P_GO_MODE. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6202 | * |
| 6203 | * This API returns the operating channel of the requested device mode |
| 6204 | * |
| 6205 | * Return: channel number. "0" id the requested device is not found OR it is |
| 6206 | * not connected. |
| 6207 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6208 | uint8_t hdd_get_operating_channel(struct hdd_context *hdd_ctx, |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 6209 | enum QDF_OPMODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6210 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6211 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6212 | uint8_t operatingChannel = 0; |
| 6213 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6214 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6215 | if (mode == adapter->device_mode) { |
| 6216 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6217 | case QDF_STA_MODE: |
| 6218 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6219 | if (hdd_conn_is_connected |
| 6220 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 6221 | (adapter))) { |
| 6222 | operatingChannel = |
| 6223 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 6224 | (adapter))->conn_info. |
| 6225 | operationChannel; |
| 6226 | } |
| 6227 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6228 | case QDF_SAP_MODE: |
| 6229 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6230 | /* softap connection info */ |
| 6231 | if (test_bit |
| 6232 | (SOFTAP_BSS_STARTED, |
| 6233 | &adapter->event_flags)) |
| 6234 | operatingChannel = |
| 6235 | (WLAN_HDD_GET_AP_CTX_PTR |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 6236 | (adapter))->operating_channel; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6237 | break; |
| 6238 | default: |
| 6239 | break; |
| 6240 | } |
| 6241 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6242 | /* Found the device of interest. break the loop */ |
| 6243 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6244 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6245 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6246 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6247 | return operatingChannel; |
| 6248 | } |
| 6249 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6250 | static inline QDF_STATUS hdd_unregister_wext_all_adapters(struct hdd_context * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6251 | hdd_ctx) |
| 6252 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6253 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6254 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6255 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6256 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6257 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6258 | if (adapter->device_mode == QDF_STA_MODE || |
| 6259 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 6260 | adapter->device_mode == QDF_IBSS_MODE || |
| 6261 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 6262 | adapter->device_mode == QDF_SAP_MODE || |
| 6263 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6264 | wlan_hdd_cfg80211_deregister_frames(adapter); |
| 6265 | hdd_unregister_wext(adapter->dev); |
| 6266 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6267 | } |
| 6268 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6269 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6270 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6271 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6272 | } |
| 6273 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6274 | 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] | 6275 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6276 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6277 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6278 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6279 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6280 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6281 | if (adapter->device_mode == QDF_STA_MODE || |
| 6282 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 6283 | adapter->device_mode == QDF_IBSS_MODE || |
| 6284 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 6285 | adapter->device_mode == QDF_SAP_MODE || |
| 6286 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 6287 | wlan_abort_scan(hdd_ctx->hdd_pdev, INVAL_PDEV_ID, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 6288 | adapter->session_id, INVALID_SCAN_ID, |
Vignesh Viswanathan | 19611c8 | 2018-01-16 16:20:40 +0530 | [diff] [blame] | 6289 | true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6290 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6291 | } |
| 6292 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6293 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6294 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6295 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6296 | } |
| 6297 | |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6298 | /** |
| 6299 | * hdd_abort_sched_scan_all_adapters() - stops scheduled (PNO) scans for all |
| 6300 | * adapters |
| 6301 | * @hdd_ctx: The HDD context containing the adapters to operate on |
| 6302 | * |
| 6303 | * return: QDF_STATUS_SUCCESS |
| 6304 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6305 | 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] | 6306 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6307 | struct hdd_adapter *adapter; |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6308 | int err; |
| 6309 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6310 | hdd_enter(); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6311 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6312 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6313 | if (adapter->device_mode == QDF_STA_MODE || |
| 6314 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 6315 | adapter->device_mode == QDF_IBSS_MODE || |
| 6316 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 6317 | adapter->device_mode == QDF_SAP_MODE || |
| 6318 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6319 | err = wlan_hdd_sched_scan_stop(adapter->dev); |
| 6320 | if (err) |
| 6321 | hdd_err("Unable to stop scheduled scan"); |
| 6322 | } |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6323 | } |
| 6324 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6325 | hdd_exit(); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6326 | |
| 6327 | return QDF_STATUS_SUCCESS; |
| 6328 | } |
| 6329 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6330 | #ifdef WLAN_NS_OFFLOAD |
| 6331 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6332 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6333 | * @hdd_ctx: Pointer to hdd context |
| 6334 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6335 | * Unregister for IPv6 address change notifications. |
| 6336 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6337 | * Return: None |
| 6338 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6339 | static void hdd_wlan_unregister_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6340 | { |
| 6341 | unregister_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6342 | } |
| 6343 | |
| 6344 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6345 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6346 | * @hdd_ctx: Pointer to hdd context |
| 6347 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6348 | * Register for IPv6 address change notifications. |
| 6349 | * |
| 6350 | * Return: 0 on success and errno on failure. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6351 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6352 | static int hdd_wlan_register_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6353 | { |
| 6354 | int ret; |
| 6355 | |
| 6356 | hdd_ctx->ipv6_notifier.notifier_call = wlan_hdd_ipv6_changed; |
| 6357 | ret = register_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6358 | if (ret) { |
| 6359 | hdd_err("Failed to register IPv6 notifier: %d", ret); |
| 6360 | goto out; |
| 6361 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6362 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6363 | hdd_debug("Registered IPv6 notifier"); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6364 | out: |
| 6365 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6366 | } |
| 6367 | #else |
| 6368 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6369 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6370 | * @hdd_ctx: Pointer to hdd context |
| 6371 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6372 | * Unregister for IPv6 address change notifications. |
| 6373 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6374 | * Return: None |
| 6375 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6376 | static void hdd_wlan_unregister_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6377 | { |
| 6378 | } |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6379 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6380 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6381 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6382 | * @hdd_ctx: Pointer to hdd context |
| 6383 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6384 | * Register for IPv6 address change notifications. |
| 6385 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6386 | * Return: None |
| 6387 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6388 | static int hdd_wlan_register_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6389 | { |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6390 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6391 | } |
| 6392 | #endif |
| 6393 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 6394 | void hdd_set_disconnect_status(struct hdd_adapter *adapter, bool status) |
| 6395 | { |
| 6396 | qdf_mutex_acquire(&adapter->disconnection_status_lock); |
| 6397 | adapter->disconnection_in_progress = status; |
| 6398 | qdf_mutex_release(&adapter->disconnection_status_lock); |
| 6399 | hdd_debug("setting disconnection status: %d", status); |
| 6400 | } |
| 6401 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6402 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6403 | * hdd_register_notifiers - Register netdev notifiers. |
| 6404 | * @hdd_ctx: HDD context |
| 6405 | * |
| 6406 | * Register netdev notifiers like IPv4 and IPv6. |
| 6407 | * |
| 6408 | * Return: 0 on success and errno on failure |
| 6409 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6410 | static int hdd_register_notifiers(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6411 | { |
| 6412 | int ret; |
| 6413 | |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6414 | ret = hdd_wlan_register_ip6_notifier(hdd_ctx); |
| 6415 | if (ret) |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 6416 | goto out; |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6417 | |
| 6418 | hdd_ctx->ipv4_notifier.notifier_call = wlan_hdd_ipv4_changed; |
| 6419 | ret = register_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
| 6420 | if (ret) { |
| 6421 | hdd_err("Failed to register IPv4 notifier: %d", ret); |
| 6422 | goto unregister_ip6_notifier; |
| 6423 | } |
| 6424 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 6425 | ret = hdd_nud_register_netevent_notifier(hdd_ctx); |
| 6426 | if (ret) { |
| 6427 | hdd_err("Failed to register netevent notifier: %d", |
| 6428 | ret); |
| 6429 | goto unregister_inetaddr_notifier; |
| 6430 | } |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6431 | return 0; |
| 6432 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 6433 | unregister_inetaddr_notifier: |
| 6434 | unregister_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6435 | unregister_ip6_notifier: |
| 6436 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6437 | out: |
| 6438 | return ret; |
| 6439 | |
| 6440 | } |
| 6441 | |
| 6442 | /** |
| 6443 | * hdd_unregister_notifiers - Unregister netdev notifiers. |
| 6444 | * @hdd_ctx: HDD context |
| 6445 | * |
| 6446 | * Unregister netdev notifiers like IPv4 and IPv6. |
| 6447 | * |
| 6448 | * Return: None. |
| 6449 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6450 | void hdd_unregister_notifiers(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6451 | { |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 6452 | hdd_nud_unregister_netevent_notifier(hdd_ctx); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6453 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
| 6454 | |
| 6455 | unregister_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6456 | } |
| 6457 | |
| 6458 | /** |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6459 | * hdd_exit_netlink_services - Exit netlink services |
| 6460 | * @hdd_ctx: HDD context |
| 6461 | * |
| 6462 | * Exit netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 6463 | * nl service. |
| 6464 | * |
| 6465 | * Return: None. |
| 6466 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6467 | static void hdd_exit_netlink_services(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6468 | { |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6469 | hdd_close_cesium_nl_sock(); |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 6470 | hdd_deactivate_wifi_pos(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6471 | ptt_sock_deactivate_svc(); |
| 6472 | |
| 6473 | nl_srv_exit(); |
| 6474 | } |
| 6475 | |
| 6476 | /** |
| 6477 | * hdd_init_netlink_services- Init netlink services |
| 6478 | * @hdd_ctx: HDD context |
| 6479 | * |
| 6480 | * Init netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 6481 | * nl service. |
| 6482 | * |
| 6483 | * Return: 0 on success and errno on failure. |
| 6484 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6485 | static int hdd_init_netlink_services(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6486 | { |
| 6487 | int ret; |
| 6488 | |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 6489 | ret = wlan_hdd_nl_init(hdd_ctx); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6490 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6491 | hdd_err("nl_srv_init failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6492 | goto out; |
| 6493 | } |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 6494 | cds_set_radio_index(hdd_ctx->radio_index); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6495 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 6496 | ret = hdd_activate_wifi_pos(hdd_ctx); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6497 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6498 | hdd_err("hdd_activate_wifi_pos failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6499 | goto err_nl_srv; |
| 6500 | } |
| 6501 | |
| 6502 | ret = ptt_sock_activate_svc(); |
| 6503 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6504 | hdd_err("ptt_sock_activate_svc failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6505 | goto err_nl_srv; |
| 6506 | } |
| 6507 | |
| 6508 | ret = hdd_open_cesium_nl_sock(); |
Ryan Hsu | 5e2e205 | 2016-04-28 10:19:38 -0700 | [diff] [blame] | 6509 | if (ret) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6510 | hdd_err("hdd_open_cesium_nl_sock failed ret: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6511 | |
| 6512 | ret = cnss_diag_activate_service(); |
| 6513 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6514 | hdd_err("cnss_diag_activate_service failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6515 | goto err_close_cesium; |
| 6516 | } |
| 6517 | |
Sandeep Puligilla | 019a1bd | 2018-02-04 22:57:44 -0800 | [diff] [blame] | 6518 | ret = spectral_scan_activate_service(); |
| 6519 | if (ret) { |
| 6520 | hdd_alert("spectral_scan_activate_service failed: %d", ret); |
| 6521 | goto err_close_cesium; |
| 6522 | } |
| 6523 | |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6524 | return 0; |
| 6525 | |
| 6526 | err_close_cesium: |
| 6527 | hdd_close_cesium_nl_sock(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6528 | ptt_sock_deactivate_svc(); |
| 6529 | err_nl_srv: |
| 6530 | nl_srv_exit(); |
| 6531 | out: |
| 6532 | return ret; |
| 6533 | } |
| 6534 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6535 | /** |
| 6536 | * hdd_rx_wake_lock_destroy() - Destroy RX wakelock |
| 6537 | * @hdd_ctx: HDD context. |
| 6538 | * |
| 6539 | * Destroy RX wakelock. |
| 6540 | * |
| 6541 | * Return: None. |
| 6542 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6543 | static void hdd_rx_wake_lock_destroy(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6544 | { |
| 6545 | qdf_wake_lock_destroy(&hdd_ctx->rx_wake_lock); |
| 6546 | } |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6547 | |
| 6548 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6549 | * hdd_rx_wake_lock_create() - Create RX wakelock |
| 6550 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6551 | * |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6552 | * Create RX wakelock. |
| 6553 | * |
| 6554 | * Return: None. |
| 6555 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6556 | static void hdd_rx_wake_lock_create(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6557 | { |
| 6558 | qdf_wake_lock_create(&hdd_ctx->rx_wake_lock, "qcom_rx_wakelock"); |
| 6559 | } |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6560 | |
| 6561 | /** |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6562 | * hdd_context_deinit() - Deinitialize HDD context |
| 6563 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6564 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6565 | * Deinitialize HDD context along with all the feature specific contexts but |
| 6566 | * do not free hdd context itself. Caller of this API is supposed to free |
| 6567 | * HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6568 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6569 | * return: 0 on success and errno on failure. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6570 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6571 | static int hdd_context_deinit(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6572 | { |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 6573 | qdf_wake_lock_destroy(&hdd_ctx->monitor_mode_wakelock); |
| 6574 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6575 | wlan_hdd_cfg80211_deinit(hdd_ctx->wiphy); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6576 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6577 | hdd_sap_context_destroy(hdd_ctx); |
| 6578 | |
| 6579 | hdd_rx_wake_lock_destroy(hdd_ctx); |
| 6580 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6581 | hdd_scan_context_destroy(hdd_ctx); |
| 6582 | |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 6583 | qdf_list_destroy(&hdd_ctx->hdd_adapters); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6584 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6585 | return 0; |
| 6586 | } |
| 6587 | |
| 6588 | /** |
| 6589 | * hdd_context_destroy() - Destroy HDD context |
| 6590 | * @hdd_ctx: HDD context to be destroyed. |
| 6591 | * |
| 6592 | * Free config and HDD context as well as destroy all the resources. |
| 6593 | * |
| 6594 | * Return: None |
| 6595 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6596 | static void hdd_context_destroy(struct hdd_context *hdd_ctx) |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6597 | { |
Rajeev Kumar | 493a31b | 2017-09-29 14:01:24 -0700 | [diff] [blame] | 6598 | cds_set_context(QDF_MODULE_ID_HDD, NULL); |
Arunk Khandavalli | 3d267b4 | 2017-05-02 18:58:59 +0530 | [diff] [blame] | 6599 | |
Hanumantha Reddy Pothula | 00c74f6 | 2016-11-24 20:13:32 +0530 | [diff] [blame] | 6600 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 6601 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6602 | hdd_context_deinit(hdd_ctx); |
| 6603 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6604 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6605 | hdd_ctx->config = NULL; |
| 6606 | |
| 6607 | wiphy_free(hdd_ctx->wiphy); |
| 6608 | } |
| 6609 | |
| 6610 | /** |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 6611 | * wlan_destroy_bug_report_lock() - Destroy bug report lock |
| 6612 | * |
| 6613 | * This function is used to destroy bug report lock |
| 6614 | * |
| 6615 | * Return: None |
| 6616 | */ |
| 6617 | static void wlan_destroy_bug_report_lock(void) |
| 6618 | { |
| 6619 | p_cds_contextType p_cds_context; |
| 6620 | |
| 6621 | p_cds_context = cds_get_global_context(); |
| 6622 | if (!p_cds_context) { |
| 6623 | hdd_err("cds context is NULL"); |
| 6624 | return; |
| 6625 | } |
| 6626 | |
| 6627 | qdf_spinlock_destroy(&p_cds_context->bug_report_lock); |
| 6628 | } |
| 6629 | |
| 6630 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6631 | * hdd_wlan_exit() - HDD WLAN exit function |
| 6632 | * @hdd_ctx: Pointer to the HDD Context |
| 6633 | * |
| 6634 | * This is the driver exit point (invoked during rmmod) |
| 6635 | * |
| 6636 | * Return: None |
| 6637 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6638 | static void hdd_wlan_exit(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6639 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6640 | struct wiphy *wiphy = hdd_ctx->wiphy; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6641 | int driver_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6642 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6643 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6644 | |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 6645 | qdf_cancel_delayed_work(&hdd_ctx->iface_idle_work); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6646 | |
| 6647 | hdd_unregister_notifiers(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6648 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6649 | hdd_bus_bandwidth_destroy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6650 | |
| 6651 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 6652 | if (QDF_TIMER_STATE_RUNNING == |
| 6653 | qdf_mc_timer_get_current_state(&hdd_ctx->skip_acs_scan_timer)) { |
| 6654 | qdf_mc_timer_stop(&hdd_ctx->skip_acs_scan_timer); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6655 | } |
| 6656 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6657 | if (!QDF_IS_STATUS_SUCCESS |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 6658 | (qdf_mc_timer_destroy(&hdd_ctx->skip_acs_scan_timer))) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 6659 | hdd_err("Cannot deallocate ACS Skip timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6660 | } |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 6661 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 6662 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 6663 | hdd_ctx->last_acs_channel_list = NULL; |
| 6664 | hdd_ctx->num_of_channels = 0; |
| 6665 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6666 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6667 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6668 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 6669 | driver_status = hdd_ctx->driver_status; |
| 6670 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 6671 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6672 | /* |
| 6673 | * Powersave Offload Case |
| 6674 | * Disable Idle Power Save Mode |
| 6675 | */ |
| 6676 | hdd_set_idle_ps_config(hdd_ctx, false); |
Sandeep Puligilla | 8fa28fd | 2017-11-02 12:19:33 -0700 | [diff] [blame] | 6677 | /* clear the scan queue in all the scenarios */ |
Sourav Mohapatra | 001cfaf | 2018-02-28 11:30:46 +0530 | [diff] [blame] | 6678 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->hdd_pdev, NULL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6679 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6680 | if (driver_status != DRIVER_MODULES_CLOSED) { |
| 6681 | hdd_unregister_wext_all_adapters(hdd_ctx); |
| 6682 | /* |
| 6683 | * Cancel any outstanding scan requests. We are about to close |
| 6684 | * all of our adapters, but an adapter structure is what SME |
| 6685 | * passes back to our callback function. Hence if there |
| 6686 | * are any outstanding scan requests then there is a |
| 6687 | * race condition between when the adapter is closed and |
| 6688 | * when the callback is invoked. We try to resolve that |
| 6689 | * race condition here by canceling any outstanding scans |
| 6690 | * before we close the adapters. |
| 6691 | * Note that the scans may be cancelled in an asynchronous |
| 6692 | * manner, so ideally there needs to be some kind of |
| 6693 | * synchronization. Rather than introduce a new |
| 6694 | * synchronization here, we will utilize the fact that we are |
| 6695 | * about to Request Full Power, and since that is synchronized, |
| 6696 | * the expectation is that by the time Request Full Power has |
| 6697 | * completed, all scans will be cancelled |
| 6698 | */ |
| 6699 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6700 | hdd_abort_sched_scan_all_adapters(hdd_ctx); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 6701 | hdd_stop_all_adapters(hdd_ctx); |
bings | 29c9986 | 2017-11-01 13:54:13 +0800 | [diff] [blame] | 6702 | hdd_deinit_all_adapters(hdd_ctx, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6703 | } |
| 6704 | |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 6705 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 6706 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 6707 | hdd_wlan_stop_modules(hdd_ctx, false); |
Hanumanth Reddy Pothula | 709a636 | 2016-10-18 18:19:44 +0530 | [diff] [blame] | 6708 | |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 6709 | hdd_driver_memdump_deinit(); |
| 6710 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 6711 | qdf_nbuf_deinit_replenish_timer(); |
| 6712 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 6713 | if (QDF_GLOBAL_MONITOR_MODE == hdd_get_conparam()) { |
| 6714 | hdd_info("Release wakelock for monitor mode!"); |
| 6715 | qdf_wake_lock_release(&hdd_ctx->monitor_mode_wakelock, |
| 6716 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 6717 | } |
| 6718 | |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 6719 | qdf_spinlock_destroy(&hdd_ctx->hdd_adapter_lock); |
| 6720 | qdf_spinlock_destroy(&hdd_ctx->sta_update_info_lock); |
| 6721 | qdf_spinlock_destroy(&hdd_ctx->connection_status_lock); |
| 6722 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6723 | /* |
| 6724 | * Close CDS |
| 6725 | * This frees pMac(HAL) context. There should not be any call |
| 6726 | * that requires pMac access after this. |
| 6727 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6728 | |
Jeff Johnson | ce0032c | 2017-01-20 07:18:27 -0800 | [diff] [blame] | 6729 | hdd_request_manager_deinit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6730 | |
Dustin Brown | d005ad8 | 2018-01-19 10:32:13 -0800 | [diff] [blame] | 6731 | hdd_close_all_adapters(hdd_ctx, false); |
| 6732 | |
Manishekar Chandrasekaran | f7a1dad | 2016-06-23 06:43:47 +0530 | [diff] [blame] | 6733 | wlansap_global_deinit(); |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 6734 | /* |
| 6735 | * If there is re_init failure wiphy would have already de-registered |
| 6736 | * check the wiphy status before un-registering again |
| 6737 | */ |
Ashish Kumar Dhanotiya | e16feb7 | 2017-03-31 19:39:37 +0530 | [diff] [blame] | 6738 | if (wiphy && wiphy->registered) { |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 6739 | wiphy_unregister(wiphy); |
| 6740 | wlan_hdd_cfg80211_deinit(wiphy); |
| 6741 | hdd_lpass_notify_stop(hdd_ctx); |
| 6742 | } |
Yuanyuan Liu | 3e918e5 | 2016-08-17 15:41:35 -0700 | [diff] [blame] | 6743 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6744 | hdd_exit_netlink_services(hdd_ctx); |
| 6745 | mutex_destroy(&hdd_ctx->iface_change_lock); |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 6746 | #ifdef FEATURE_WLAN_CH_AVOID |
| 6747 | mutex_destroy(&hdd_ctx->avoid_freq_lock); |
| 6748 | #endif |
Abhishek Singh | e9068f1 | 2017-03-31 14:14:52 +0530 | [diff] [blame] | 6749 | |
Abhishek Singh | e9068f1 | 2017-03-31 14:14:52 +0530 | [diff] [blame] | 6750 | driver_status = hdd_objmgr_release_and_destroy_psoc(hdd_ctx); |
| 6751 | if (driver_status) |
| 6752 | hdd_err("Psoc delete failed"); |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 6753 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6754 | hdd_context_destroy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6755 | } |
| 6756 | |
| 6757 | void __hdd_wlan_exit(void) |
| 6758 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6759 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6760 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6761 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6762 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 6763 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6764 | if (!hdd_ctx) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6765 | hdd_err("Invalid HDD Context"); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6766 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6767 | return; |
| 6768 | } |
| 6769 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6770 | /* Do all the cleanup before deregistering the driver */ |
| 6771 | hdd_wlan_exit(hdd_ctx); |
Mohit Khanna | ebf8a86 | 2016-04-28 17:53:59 -0700 | [diff] [blame] | 6772 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6773 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6774 | } |
| 6775 | |
| 6776 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 6777 | /** |
| 6778 | * hdd_skip_acs_scan_timer_handler() - skip ACS scan timer timeout handler |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6779 | * @data: pointer to struct hdd_context |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 6780 | * |
| 6781 | * This function will reset acs_scan_status to eSAP_DO_NEW_ACS_SCAN. |
| 6782 | * Then new ACS request will do a fresh scan without reusing the cached |
| 6783 | * scan information. |
| 6784 | * |
| 6785 | * Return: void |
| 6786 | */ |
Tang Yingying | 523322d | 2017-01-17 23:28:43 +0800 | [diff] [blame] | 6787 | static void hdd_skip_acs_scan_timer_handler(void *data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6788 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6789 | struct hdd_context *hdd_ctx = (struct hdd_context *) data; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6790 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6791 | hdd_debug("ACS Scan result expired. Reset ACS scan skip"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6792 | hdd_ctx->skip_acs_scan_status = eSAP_DO_NEW_ACS_SCAN; |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 6793 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 6794 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 6795 | hdd_ctx->last_acs_channel_list = NULL; |
| 6796 | hdd_ctx->num_of_channels = 0; |
| 6797 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6798 | |
| 6799 | if (!hdd_ctx->hHal) |
| 6800 | return; |
| 6801 | sme_scan_flush_result(hdd_ctx->hHal); |
| 6802 | } |
| 6803 | #endif |
| 6804 | |
| 6805 | #ifdef QCA_HT_2040_COEX |
Jeff Johnson | e7672e7 | 2017-10-21 15:10:04 -0700 | [diff] [blame] | 6806 | int hdd_wlan_set_ht2040_mode(struct hdd_adapter *adapter, uint16_t sta_id, |
| 6807 | struct qdf_mac_addr sta_mac, int channel_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6808 | { |
| 6809 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6810 | QDF_STATUS qdf_status; |
Jeff Johnson | e7672e7 | 2017-10-21 15:10:04 -0700 | [diff] [blame] | 6811 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6812 | |
| 6813 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 6814 | |
| 6815 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 6816 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6817 | return status; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 6818 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6819 | if (!hdd_ctx->hHal) |
| 6820 | return -EINVAL; |
| 6821 | |
Jeff Johnson | e7672e7 | 2017-10-21 15:10:04 -0700 | [diff] [blame] | 6822 | 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] | 6823 | adapter->session_id, channel_type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6824 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6825 | hdd_err("Fail to send notification with ht2040 mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6826 | return -EINVAL; |
| 6827 | } |
| 6828 | |
| 6829 | return 0; |
| 6830 | } |
| 6831 | #endif |
| 6832 | |
| 6833 | /** |
| 6834 | * hdd_wlan_notify_modem_power_state() - notify FW with modem power status |
| 6835 | * @state: state |
| 6836 | * |
| 6837 | * This function notifies FW with modem power status |
| 6838 | * |
| 6839 | * Return: 0 if successful, error number otherwise |
| 6840 | */ |
| 6841 | int hdd_wlan_notify_modem_power_state(int state) |
| 6842 | { |
| 6843 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6844 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6845 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6846 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 6847 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6848 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 6849 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6850 | return status; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 6851 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6852 | if (!hdd_ctx->hHal) |
| 6853 | return -EINVAL; |
| 6854 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6855 | qdf_status = sme_notify_modem_power_state(hdd_ctx->hHal, state); |
| 6856 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6857 | hdd_err("Fail to send notification with modem power state %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6858 | state); |
| 6859 | return -EINVAL; |
| 6860 | } |
| 6861 | return 0; |
| 6862 | } |
| 6863 | |
| 6864 | /** |
| 6865 | * |
| 6866 | * hdd_post_cds_enable_config() - HDD post cds start config helper |
| 6867 | * @adapter - Pointer to the HDD |
| 6868 | * |
| 6869 | * Return: None |
| 6870 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6871 | QDF_STATUS hdd_post_cds_enable_config(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6872 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 6873 | QDF_STATUS qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6874 | |
| 6875 | /* |
| 6876 | * Send ready indication to the HDD. This will kick off the MAC |
| 6877 | * into a 'running' state and should kick off an initial scan. |
| 6878 | */ |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 6879 | qdf_ret_status = sme_hdd_ready_ind(hdd_ctx->hHal); |
| 6880 | if (!QDF_IS_STATUS_SUCCESS(qdf_ret_status)) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6881 | hdd_err("sme_hdd_ready_ind() failed with status code %08d [x%08x]", |
| 6882 | qdf_ret_status, qdf_ret_status); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6883 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6884 | } |
| 6885 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6886 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6887 | } |
| 6888 | |
Sourav Mohapatra | 92ea8d6 | 2018-02-05 10:03:10 +0530 | [diff] [blame] | 6889 | struct hdd_adapter *hdd_get_first_valid_adapter(struct hdd_context *hdd_ctx) |
| 6890 | { |
| 6891 | struct hdd_adapter *adapter; |
| 6892 | |
| 6893 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6894 | if (adapter && adapter->magic == WLAN_HDD_ADAPTER_MAGIC) |
| 6895 | return adapter; |
| 6896 | } |
| 6897 | |
| 6898 | return NULL; |
| 6899 | } |
| 6900 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6901 | /* wake lock APIs for HDD */ |
| 6902 | void hdd_prevent_suspend(uint32_t reason) |
| 6903 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 6904 | qdf_wake_lock_acquire(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6905 | } |
| 6906 | |
| 6907 | void hdd_allow_suspend(uint32_t reason) |
| 6908 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 6909 | qdf_wake_lock_release(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6910 | } |
| 6911 | |
| 6912 | void hdd_prevent_suspend_timeout(uint32_t timeout, uint32_t reason) |
| 6913 | { |
Anurag Chouhan | 01cfa4e | 2016-09-04 15:10:49 +0530 | [diff] [blame] | 6914 | cds_host_diag_log_work(&wlan_wake_lock, timeout, reason); |
| 6915 | qdf_wake_lock_timeout_acquire(&wlan_wake_lock, timeout); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6916 | } |
| 6917 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6918 | /* Initialize channel list in sme based on the country code */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6919 | QDF_STATUS hdd_set_sme_chan_list(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6920 | { |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 6921 | |
Amar Singhal | 6f8592b | 2017-04-26 14:31:58 -0700 | [diff] [blame] | 6922 | return sme_init_chan_list(hdd_ctx->hHal, |
| 6923 | hdd_ctx->reg.alpha2, |
| 6924 | hdd_ctx->reg.cc_src); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6925 | } |
| 6926 | |
| 6927 | /** |
| 6928 | * hdd_is_5g_supported() - check if hardware supports 5GHz |
| 6929 | * @hdd_ctx: Pointer to the hdd context |
| 6930 | * |
| 6931 | * HDD function to know if hardware supports 5GHz |
| 6932 | * |
| 6933 | * Return: true if hardware supports 5GHz |
| 6934 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6935 | bool hdd_is_5g_supported(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6936 | { |
Amar Singhal | 58b45ef | 2017-08-01 13:43:54 -0700 | [diff] [blame] | 6937 | if (!hdd_ctx) |
zding | f54169a | 2016-10-12 17:08:45 +0800 | [diff] [blame] | 6938 | return true; |
| 6939 | |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 6940 | if (hdd_ctx->curr_band != BAND_2G) |
zding | f54169a | 2016-10-12 17:08:45 +0800 | [diff] [blame] | 6941 | return true; |
| 6942 | else |
| 6943 | return false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6944 | } |
| 6945 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6946 | static int hdd_wiphy_init(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6947 | { |
| 6948 | struct wiphy *wiphy; |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6949 | int ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6950 | |
| 6951 | wiphy = hdd_ctx->wiphy; |
| 6952 | |
| 6953 | /* |
| 6954 | * The channel information in |
| 6955 | * wiphy needs to be initialized before wiphy registration |
| 6956 | */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6957 | ret_val = hdd_regulatory_init(hdd_ctx, wiphy); |
| 6958 | if (ret_val) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6959 | hdd_err("regulatory init failed"); |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6960 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6961 | } |
| 6962 | |
| 6963 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 6964 | wiphy->wowlan = &wowlan_support_reg_init; |
| 6965 | #else |
| 6966 | wiphy->wowlan.flags = WIPHY_WOWLAN_ANY | |
| 6967 | WIPHY_WOWLAN_MAGIC_PKT | |
| 6968 | WIPHY_WOWLAN_DISCONNECT | |
| 6969 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 6970 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 6971 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 6972 | WIPHY_WOWLAN_4WAY_HANDSHAKE | |
| 6973 | WIPHY_WOWLAN_RFKILL_RELEASE; |
| 6974 | |
| 6975 | wiphy->wowlan.n_patterns = (WOW_MAX_FILTER_LISTS * |
| 6976 | WOW_MAX_FILTERS_PER_LIST); |
| 6977 | wiphy->wowlan.pattern_min_len = WOW_MIN_PATTERN_SIZE; |
| 6978 | wiphy->wowlan.pattern_max_len = WOW_MAX_PATTERN_SIZE; |
| 6979 | #endif |
| 6980 | |
| 6981 | /* registration of wiphy dev with cfg80211 */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6982 | ret_val = wlan_hdd_cfg80211_register(wiphy); |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 6983 | if (0 > ret_val) { |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6984 | hdd_err("wiphy registration failed"); |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 6985 | return ret_val; |
| 6986 | } |
| 6987 | |
Amar Singhal | 2d81201 | 2018-02-03 15:06:47 +0800 | [diff] [blame] | 6988 | pld_increment_driver_load_cnt(hdd_ctx->parent_dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6989 | |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6990 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6991 | } |
| 6992 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 6993 | #ifdef MSM_PLATFORM |
| 6994 | /** |
| 6995 | * hdd_display_periodic_stats() - Function to display periodic stats |
| 6996 | * @hdd_ctx - handle to hdd context |
| 6997 | * @bool data_in_interval - true, if data detected in bw time interval |
| 6998 | * |
| 6999 | * The periodicity is determined by hdd_ctx->config->periodic_stats_disp_time. |
| 7000 | * Stats show up in wlan driver logs. |
| 7001 | * |
| 7002 | * Returns: None |
| 7003 | */ |
| 7004 | static inline |
| 7005 | void hdd_display_periodic_stats(struct hdd_context *hdd_ctx, |
| 7006 | bool data_in_interval) |
| 7007 | { |
| 7008 | static u32 counter; |
| 7009 | static bool data_in_time_period; |
| 7010 | ol_txrx_pdev_handle pdev; |
| 7011 | |
| 7012 | if (hdd_ctx->config->periodic_stats_disp_time == 0) |
| 7013 | return; |
| 7014 | |
| 7015 | pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
| 7016 | if (!pdev) { |
| 7017 | hdd_err("pdev is NULL"); |
| 7018 | return; |
| 7019 | } |
| 7020 | |
| 7021 | counter++; |
| 7022 | if (data_in_interval) |
| 7023 | data_in_time_period = data_in_interval; |
| 7024 | |
| 7025 | if (counter * hdd_ctx->config->busBandwidthComputeInterval >= |
| 7026 | hdd_ctx->config->periodic_stats_disp_time * 1000) { |
| 7027 | if (data_in_time_period) { |
| 7028 | cdp_display_stats(cds_get_context(QDF_MODULE_ID_SOC), |
| 7029 | CDP_TXRX_PATH_STATS, |
| 7030 | QDF_STATS_VERBOSITY_LEVEL_LOW); |
| 7031 | wlan_hdd_display_netif_queue_history |
| 7032 | (hdd_ctx, QDF_STATS_VERBOSITY_LEVEL_LOW); |
| 7033 | qdf_dp_trace_dump_stats(); |
| 7034 | } |
| 7035 | counter = 0; |
| 7036 | data_in_time_period = false; |
| 7037 | } |
| 7038 | } |
| 7039 | |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7040 | /** |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7041 | * hdd_pld_request_bus_bandwidth() - Function to control bus bandwidth |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7042 | * @hdd_ctx - handle to hdd context |
| 7043 | * @tx_packets - transmit packet count |
| 7044 | * @rx_packets - receive packet count |
| 7045 | * |
| 7046 | * The function controls the bus bandwidth and dynamic control of |
| 7047 | * tcp delayed ack configuration |
| 7048 | * |
| 7049 | * Returns: None |
| 7050 | */ |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7051 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7052 | static void hdd_pld_request_bus_bandwidth(struct hdd_context *hdd_ctx, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 7053 | const uint64_t tx_packets, |
| 7054 | const uint64_t rx_packets) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7055 | { |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7056 | u64 total_pkts = tx_packets + rx_packets; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7057 | uint64_t temp_rx = 0; |
| 7058 | uint64_t temp_tx = 0; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7059 | enum pld_bus_width_type next_vote_level = PLD_BUS_WIDTH_NONE; |
Mohit Khanna | c3da706 | 2017-02-08 21:08:56 -0800 | [diff] [blame] | 7060 | static enum wlan_tp_level next_rx_level = WLAN_SVC_TP_NONE; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7061 | enum wlan_tp_level next_tx_level = WLAN_SVC_TP_NONE; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7062 | uint32_t delack_timer_cnt = hdd_ctx->config->tcp_delack_timer_count; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7063 | uint16_t index = 0; |
| 7064 | bool vote_level_change = false; |
| 7065 | bool rx_level_change = false; |
| 7066 | bool tx_level_change = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7067 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7068 | if (total_pkts > hdd_ctx->config->busBandwidthHighThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7069 | next_vote_level = PLD_BUS_WIDTH_HIGH; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7070 | else if (total_pkts > hdd_ctx->config->busBandwidthMediumThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7071 | next_vote_level = PLD_BUS_WIDTH_MEDIUM; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7072 | else if (total_pkts > hdd_ctx->config->busBandwidthLowThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7073 | next_vote_level = PLD_BUS_WIDTH_LOW; |
Yue Ma | d6478e4 | 2015-10-20 18:49:24 -0700 | [diff] [blame] | 7074 | else |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7075 | next_vote_level = PLD_BUS_WIDTH_NONE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7076 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7077 | if (hdd_ctx->cur_vote_level != next_vote_level) { |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7078 | hdd_debug("trigger level %d, tx_packets: %lld, rx_packets: %lld", |
| 7079 | next_vote_level, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7080 | hdd_ctx->cur_vote_level = next_vote_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7081 | vote_level_change = true; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7082 | pld_request_bus_bandwidth(hdd_ctx->parent_dev, next_vote_level); |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 7083 | if (next_vote_level == PLD_BUS_WIDTH_LOW) { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 7084 | if (hdd_ctx->hbw_requested) { |
| 7085 | pld_remove_pm_qos(hdd_ctx->parent_dev); |
| 7086 | hdd_ctx->hbw_requested = false; |
| 7087 | } |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 7088 | if (cds_sched_handle_throughput_req(false)) |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 7089 | hdd_warn("low bandwidth set rx affinity fail"); |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 7090 | } else { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 7091 | if (!hdd_ctx->hbw_requested) { |
| 7092 | pld_request_pm_qos(hdd_ctx->parent_dev, 1); |
| 7093 | hdd_ctx->hbw_requested = true; |
| 7094 | } |
| 7095 | |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 7096 | if (cds_sched_handle_throughput_req(true)) |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 7097 | hdd_warn("high bandwidth set rx affinity fail"); |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 7098 | } |
Orhan K AKYILDIZ | 1481aff | 2016-05-16 12:40:13 -0700 | [diff] [blame] | 7099 | hdd_napi_apply_throughput_policy(hdd_ctx, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7100 | } |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7101 | |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 7102 | qdf_dp_trace_throttle_live_mode( |
| 7103 | (next_vote_level > PLD_BUS_WIDTH_NONE) ? true : false); |
| 7104 | |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7105 | /* fine-tuning parameters for RX Flows */ |
| 7106 | temp_rx = (rx_packets + hdd_ctx->prev_rx) / 2; |
| 7107 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7108 | hdd_ctx->prev_rx = rx_packets; |
Mohit Khanna | b1dd1e8 | 2017-02-04 15:14:38 -0800 | [diff] [blame] | 7109 | |
Poddar, Siddarth | 47c2340 | 2017-10-25 12:17:39 +0530 | [diff] [blame] | 7110 | if (temp_rx < hdd_ctx->config->busBandwidthLowThreshold) |
| 7111 | hdd_disable_lro_for_low_tput(hdd_ctx, true); |
| 7112 | else |
| 7113 | hdd_disable_lro_for_low_tput(hdd_ctx, false); |
| 7114 | |
Ravi Joshi | fed8357 | 2016-10-07 16:20:37 -0700 | [diff] [blame] | 7115 | if (temp_rx > hdd_ctx->config->tcpDelackThresholdHigh) { |
| 7116 | if ((hdd_ctx->cur_rx_level != WLAN_SVC_TP_HIGH) && |
| 7117 | (++hdd_ctx->rx_high_ind_cnt == delack_timer_cnt)) { |
| 7118 | next_rx_level = WLAN_SVC_TP_HIGH; |
| 7119 | } |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7120 | } else { |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7121 | hdd_ctx->rx_high_ind_cnt = 0; |
Mohit Khanna | c3da706 | 2017-02-08 21:08:56 -0800 | [diff] [blame] | 7122 | next_rx_level = WLAN_SVC_TP_LOW; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7123 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7124 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7125 | if (hdd_ctx->cur_rx_level != next_rx_level) { |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 7126 | struct wlan_rx_tp_data rx_tp_data = {0}; |
| 7127 | |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7128 | hdd_debug("TCP DELACK trigger level %d, average_rx: %llu", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7129 | next_rx_level, temp_rx); |
| 7130 | hdd_ctx->cur_rx_level = next_rx_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7131 | rx_level_change = true; |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7132 | /* Send throughput indication only if it is enabled. |
| 7133 | * Disabling tcp_del_ack will revert the tcp stack behavior |
| 7134 | * to default delayed ack. Note that this will disable the |
| 7135 | * dynamic delayed ack mechanism across the system |
| 7136 | */ |
| 7137 | if (hdd_ctx->config->enable_tcp_delack) |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 7138 | rx_tp_data.rx_tp_flags |= TCP_DEL_ACK_IND; |
| 7139 | |
Mohit Khanna | 6272fb68 | 2017-04-13 09:34:36 -0700 | [diff] [blame] | 7140 | if (hdd_ctx->config->enable_tcp_adv_win_scale) |
| 7141 | rx_tp_data.rx_tp_flags |= TCP_ADV_WIN_SCL; |
| 7142 | |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 7143 | rx_tp_data.level = next_rx_level; |
| 7144 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 7145 | WLAN_SVC_WLAN_TP_IND, &rx_tp_data, |
| 7146 | sizeof(rx_tp_data)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7147 | } |
| 7148 | |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7149 | /* fine-tuning parameters for TX Flows */ |
| 7150 | temp_tx = (tx_packets + hdd_ctx->prev_tx) / 2; |
| 7151 | hdd_ctx->prev_tx = tx_packets; |
| 7152 | if (temp_tx > hdd_ctx->config->tcp_tx_high_tput_thres) |
| 7153 | next_tx_level = WLAN_SVC_TP_HIGH; |
| 7154 | else |
| 7155 | next_tx_level = WLAN_SVC_TP_LOW; |
| 7156 | |
Prakash Manjunathappa | e73e3b5 | 2018-02-27 18:56:22 -0800 | [diff] [blame] | 7157 | if ((hdd_ctx->config->enable_tcp_limit_output) && |
| 7158 | (hdd_ctx->cur_tx_level != next_tx_level)) { |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7159 | hdd_debug("change TCP TX trigger level %d, average_tx: %llu", |
| 7160 | next_tx_level, temp_tx); |
| 7161 | hdd_ctx->cur_tx_level = next_tx_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7162 | tx_level_change = true; |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 7163 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 7164 | WLAN_SVC_WLAN_TP_TX_IND, |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7165 | &next_tx_level, |
| 7166 | sizeof(next_tx_level)); |
| 7167 | } |
| 7168 | |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7169 | index = hdd_ctx->hdd_txrx_hist_idx; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7170 | if (vote_level_change || tx_level_change || rx_level_change) { |
| 7171 | hdd_ctx->hdd_txrx_hist[index].next_tx_level = next_tx_level; |
| 7172 | hdd_ctx->hdd_txrx_hist[index].next_rx_level = next_rx_level; |
| 7173 | hdd_ctx->hdd_txrx_hist[index].next_vote_level = next_vote_level; |
| 7174 | hdd_ctx->hdd_txrx_hist[index].interval_rx = rx_packets; |
| 7175 | hdd_ctx->hdd_txrx_hist[index].interval_tx = tx_packets; |
| 7176 | hdd_ctx->hdd_txrx_hist[index].qtime = qdf_get_log_timestamp(); |
| 7177 | hdd_ctx->hdd_txrx_hist_idx++; |
| 7178 | hdd_ctx->hdd_txrx_hist_idx &= NUM_TX_RX_HISTOGRAM_MASK; |
| 7179 | } |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7180 | |
| 7181 | hdd_display_periodic_stats(hdd_ctx, (total_pkts > 0) ? true : false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7182 | } |
| 7183 | |
| 7184 | #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] | 7185 | static void hdd_bus_bw_work_handler(struct work_struct *work) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7186 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7187 | struct hdd_context *hdd_ctx = container_of(work, struct hdd_context, |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7188 | bus_bw_work); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7189 | struct hdd_adapter *adapter = NULL; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7190 | uint64_t tx_packets = 0, rx_packets = 0; |
Himanshu Agarwal | a6cedee | 2016-06-08 14:50:00 +0530 | [diff] [blame] | 7191 | uint64_t fwd_tx_packets = 0, fwd_rx_packets = 0; |
| 7192 | uint64_t fwd_tx_packets_diff = 0, fwd_rx_packets_diff = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7193 | uint64_t total_tx = 0, total_rx = 0; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7194 | A_STATUS ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7195 | bool connected = false; |
| 7196 | uint32_t ipa_tx_packets = 0, ipa_rx_packets = 0; |
| 7197 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7198 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 7199 | return; |
| 7200 | |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 7201 | if (hdd_ctx->is_wiphy_suspended) |
Jingxiang Ge | c64e193 | 2017-08-22 14:38:59 +0800 | [diff] [blame] | 7202 | goto restart_timer; |
| 7203 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7204 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Manjeet Singh | 01327cc | 2016-09-03 12:14:25 +0530 | [diff] [blame] | 7205 | /* |
| 7206 | * Validate magic so we don't end up accessing |
| 7207 | * an invalid adapter. |
| 7208 | */ |
| 7209 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) |
| 7210 | continue; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7211 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 7212 | if ((adapter->device_mode == QDF_STA_MODE || |
| 7213 | adapter->device_mode == QDF_P2P_CLIENT_MODE) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7214 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)->conn_info.connState |
| 7215 | != eConnectionState_Associated) { |
| 7216 | |
| 7217 | continue; |
| 7218 | } |
| 7219 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 7220 | if ((adapter->device_mode == QDF_SAP_MODE || |
| 7221 | adapter->device_mode == QDF_P2P_GO_MODE) && |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 7222 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->ap_active == false) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7223 | |
| 7224 | continue; |
| 7225 | } |
| 7226 | |
| 7227 | tx_packets += HDD_BW_GET_DIFF(adapter->stats.tx_packets, |
| 7228 | adapter->prev_tx_packets); |
| 7229 | rx_packets += HDD_BW_GET_DIFF(adapter->stats.rx_packets, |
| 7230 | adapter->prev_rx_packets); |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7231 | |
| 7232 | if (adapter->device_mode == QDF_SAP_MODE || |
| 7233 | adapter->device_mode == QDF_P2P_GO_MODE || |
| 7234 | adapter->device_mode == QDF_IBSS_MODE) { |
| 7235 | |
Dhanashri Atre | a8f82f2 | 2017-01-23 12:58:24 -0800 | [diff] [blame] | 7236 | ret = cdp_get_intra_bss_fwd_pkts_count( |
| 7237 | cds_get_context(QDF_MODULE_ID_SOC), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 7238 | adapter->session_id, |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7239 | &fwd_tx_packets, &fwd_rx_packets); |
| 7240 | if (ret == A_OK) { |
| 7241 | fwd_tx_packets_diff += HDD_BW_GET_DIFF( |
| 7242 | fwd_tx_packets, |
| 7243 | adapter->prev_fwd_tx_packets); |
| 7244 | fwd_rx_packets_diff += HDD_BW_GET_DIFF( |
| 7245 | fwd_tx_packets, |
| 7246 | adapter->prev_fwd_rx_packets); |
| 7247 | } |
| 7248 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7249 | |
| 7250 | total_rx += adapter->stats.rx_packets; |
| 7251 | total_tx += adapter->stats.tx_packets; |
| 7252 | |
| 7253 | spin_lock_bh(&hdd_ctx->bus_bw_lock); |
| 7254 | adapter->prev_tx_packets = adapter->stats.tx_packets; |
| 7255 | adapter->prev_rx_packets = adapter->stats.rx_packets; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7256 | adapter->prev_fwd_tx_packets = fwd_tx_packets; |
| 7257 | adapter->prev_fwd_rx_packets = fwd_rx_packets; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7258 | spin_unlock_bh(&hdd_ctx->bus_bw_lock); |
| 7259 | connected = true; |
| 7260 | } |
| 7261 | |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7262 | /* add intra bss forwarded tx and rx packets */ |
| 7263 | tx_packets += fwd_tx_packets_diff; |
| 7264 | rx_packets += fwd_rx_packets_diff; |
| 7265 | |
Sravan Kumar Kairam | 271fab2 | 2018-03-07 18:57:41 +0530 | [diff] [blame] | 7266 | ucfg_ipa_uc_stat_query(hdd_ctx->hdd_pdev, &ipa_tx_packets, |
| 7267 | &ipa_rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7268 | tx_packets += (uint64_t)ipa_tx_packets; |
| 7269 | rx_packets += (uint64_t)ipa_rx_packets; |
| 7270 | |
| 7271 | if (!connected) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 7272 | hdd_err("bus bandwidth timer running in disconnected state"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7273 | return; |
| 7274 | } |
| 7275 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7276 | hdd_pld_request_bus_bandwidth(hdd_ctx, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7277 | |
Sravan Kumar Kairam | 9e99e9a | 2018-03-12 19:09:45 +0530 | [diff] [blame] | 7278 | 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] | 7279 | ucfg_ipa_uc_stat_request(hdd_ctx->hdd_pdev, 2); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7280 | |
Jingxiang Ge | c64e193 | 2017-08-22 14:38:59 +0800 | [diff] [blame] | 7281 | restart_timer: |
Dustin Brown | 2ed6036 | 2017-01-18 12:25:50 -0800 | [diff] [blame] | 7282 | /* ensure periodic timer should still be running before restarting it */ |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7283 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 2ed6036 | 2017-01-18 12:25:50 -0800 | [diff] [blame] | 7284 | if (hdd_ctx->bus_bw_timer_running) |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 7285 | qdf_timer_mod(&hdd_ctx->bus_bw_timer, |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7286 | hdd_ctx->config->busBandwidthComputeInterval); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7287 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7288 | } |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7289 | |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7290 | /** |
| 7291 | * __hdd_bus_bw_cbk() - Bus bandwidth data structure callback. |
| 7292 | * @arg: Argument of timer function |
| 7293 | * |
| 7294 | * Schedule a workqueue in this function where all the processing is done. |
| 7295 | * |
| 7296 | * Return: None. |
| 7297 | */ |
| 7298 | static void __hdd_bus_bw_cbk(void *arg) |
| 7299 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7300 | struct hdd_context *hdd_ctx = (struct hdd_context *) arg; |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7301 | |
| 7302 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 7303 | return; |
| 7304 | |
| 7305 | schedule_work(&hdd_ctx->bus_bw_work); |
| 7306 | } |
| 7307 | |
| 7308 | /** |
| 7309 | * hdd_bus_bw_cbk() - Wrapper for bus bw callback for SSR protection. |
| 7310 | * @arg: Argument of timer function |
| 7311 | * |
| 7312 | * Return: None. |
| 7313 | */ |
| 7314 | static void hdd_bus_bw_cbk(void *arg) |
| 7315 | { |
| 7316 | cds_ssr_protect(__func__); |
| 7317 | __hdd_bus_bw_cbk(arg); |
| 7318 | cds_ssr_unprotect(__func__); |
| 7319 | } |
| 7320 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7321 | int hdd_bus_bandwidth_init(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7322 | { |
| 7323 | spin_lock_init(&hdd_ctx->bus_bw_lock); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7324 | INIT_WORK(&hdd_ctx->bus_bw_work, |
| 7325 | hdd_bus_bw_work_handler); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7326 | hdd_ctx->bus_bw_timer_running = false; |
| 7327 | qdf_spinlock_create(&hdd_ctx->bus_bw_timer_lock); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7328 | qdf_timer_init(NULL, |
| 7329 | &hdd_ctx->bus_bw_timer, |
| 7330 | hdd_bus_bw_cbk, (void *)hdd_ctx, |
| 7331 | QDF_TIMER_TYPE_SW); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7332 | |
| 7333 | return 0; |
| 7334 | } |
| 7335 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7336 | void hdd_bus_bandwidth_destroy(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7337 | { |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7338 | if (hdd_ctx->bus_bw_timer_running) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7339 | hdd_reset_tcp_delack(hdd_ctx); |
| 7340 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7341 | hdd_debug("wait for bus bw work to flush"); |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 7342 | hdd_cancel_bus_bw_work(hdd_ctx); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7343 | qdf_timer_free(&hdd_ctx->bus_bw_timer); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7344 | hdd_ctx->bus_bw_timer_running = false; |
| 7345 | qdf_spinlock_destroy(&hdd_ctx->bus_bw_timer_lock); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7346 | } |
Lin Bai | c5c0688 | 2017-09-21 13:58:43 +0800 | [diff] [blame] | 7347 | |
| 7348 | void hdd_bus_bw_cancel_work(struct hdd_context *hdd_ctx) |
| 7349 | { |
| 7350 | if (hdd_ctx) |
| 7351 | cancel_work_sync(&hdd_ctx->bus_bw_work); |
| 7352 | } |
jiad | cdaf9bd | 2017-10-26 12:20:21 +0800 | [diff] [blame] | 7353 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7354 | #endif |
| 7355 | |
| 7356 | /** |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7357 | * wlan_hdd_init_tx_rx_histogram() - init tx/rx histogram stats |
| 7358 | * @hdd_ctx: hdd context |
| 7359 | * |
| 7360 | * Return: 0 for success or error code |
| 7361 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7362 | 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] | 7363 | { |
| 7364 | hdd_ctx->hdd_txrx_hist = qdf_mem_malloc( |
| 7365 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
| 7366 | if (hdd_ctx->hdd_txrx_hist == NULL) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 7367 | hdd_err("Failed malloc for hdd_txrx_hist"); |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7368 | return -ENOMEM; |
| 7369 | } |
| 7370 | return 0; |
| 7371 | } |
| 7372 | |
| 7373 | /** |
| 7374 | * wlan_hdd_deinit_tx_rx_histogram() - deinit tx/rx histogram stats |
| 7375 | * @hdd_ctx: hdd context |
| 7376 | * |
| 7377 | * Return: none |
| 7378 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7379 | void wlan_hdd_deinit_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7380 | { |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 7381 | if (!hdd_ctx || hdd_ctx->hdd_txrx_hist == NULL) |
| 7382 | return; |
| 7383 | |
| 7384 | qdf_mem_free(hdd_ctx->hdd_txrx_hist); |
| 7385 | hdd_ctx->hdd_txrx_hist = NULL; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7386 | } |
| 7387 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7388 | static uint8_t *convert_level_to_string(uint32_t level) |
| 7389 | { |
| 7390 | switch (level) { |
| 7391 | /* initialize the wlan sub system */ |
| 7392 | case WLAN_SVC_TP_NONE: |
| 7393 | return "NONE"; |
| 7394 | case WLAN_SVC_TP_LOW: |
| 7395 | return "LOW"; |
| 7396 | case WLAN_SVC_TP_MEDIUM: |
| 7397 | return "MED"; |
| 7398 | case WLAN_SVC_TP_HIGH: |
| 7399 | return "HIGH"; |
| 7400 | default: |
| 7401 | return "INVAL"; |
| 7402 | } |
| 7403 | } |
| 7404 | |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7405 | |
| 7406 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7407 | * wlan_hdd_display_tx_rx_histogram() - display tx rx histogram |
| 7408 | * @hdd_ctx: hdd context |
| 7409 | * |
| 7410 | * Return: none |
| 7411 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7412 | void wlan_hdd_display_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7413 | { |
| 7414 | int i; |
| 7415 | |
| 7416 | #ifdef MSM_PLATFORM |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7417 | hdd_debug("BW compute Interval: %dms", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7418 | hdd_ctx->config->busBandwidthComputeInterval); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7419 | 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] | 7420 | hdd_ctx->config->busBandwidthHighThreshold, |
| 7421 | hdd_ctx->config->busBandwidthMediumThreshold, |
| 7422 | hdd_ctx->config->busBandwidthLowThreshold); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7423 | hdd_debug("Enable TCP DEL ACK: %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7424 | hdd_ctx->config->enable_tcp_delack); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7425 | hdd_debug("TCP DEL High TH: %d TCP DEL Low TH: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7426 | hdd_ctx->config->tcpDelackThresholdHigh, |
| 7427 | hdd_ctx->config->tcpDelackThresholdLow); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7428 | 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] | 7429 | hdd_ctx->config->tcp_tx_high_tput_thres); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7430 | #endif |
| 7431 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7432 | hdd_debug("Total entries: %d Current index: %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7433 | NUM_TX_RX_HISTOGRAM, hdd_ctx->hdd_txrx_hist_idx); |
| 7434 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7435 | 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] | 7436 | |
| 7437 | for (i = 0; i < NUM_TX_RX_HISTOGRAM; i++) { |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7438 | /* using hdd_log to avoid printing function name */ |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7439 | if (hdd_ctx->hdd_txrx_hist[i].qtime > 0) |
Dustin Brown | 632af71 | 2018-03-14 15:03:55 -0700 | [diff] [blame] | 7440 | hdd_debug("[%3d][%15llu]: %6llu, %6llu, %s, %s, %s", |
| 7441 | i, hdd_ctx->hdd_txrx_hist[i].qtime, |
| 7442 | hdd_ctx->hdd_txrx_hist[i].interval_rx, |
| 7443 | hdd_ctx->hdd_txrx_hist[i].interval_tx, |
| 7444 | convert_level_to_string( |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7445 | hdd_ctx->hdd_txrx_hist[i]. |
| 7446 | next_vote_level), |
Dustin Brown | 632af71 | 2018-03-14 15:03:55 -0700 | [diff] [blame] | 7447 | convert_level_to_string( |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7448 | hdd_ctx->hdd_txrx_hist[i]. |
| 7449 | next_rx_level), |
Dustin Brown | 632af71 | 2018-03-14 15:03:55 -0700 | [diff] [blame] | 7450 | convert_level_to_string( |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7451 | hdd_ctx->hdd_txrx_hist[i]. |
| 7452 | next_tx_level)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7453 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7454 | } |
| 7455 | |
| 7456 | /** |
| 7457 | * wlan_hdd_clear_tx_rx_histogram() - clear tx rx histogram |
| 7458 | * @hdd_ctx: hdd context |
| 7459 | * |
| 7460 | * Return: none |
| 7461 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7462 | void wlan_hdd_clear_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7463 | { |
| 7464 | hdd_ctx->hdd_txrx_hist_idx = 0; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7465 | qdf_mem_zero(hdd_ctx->hdd_txrx_hist, |
| 7466 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7467 | } |
| 7468 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7469 | /* length of the netif queue log needed per adapter */ |
| 7470 | #define ADAP_NETIFQ_LOG_LEN ((20 * WLAN_REASON_TYPE_MAX) + 50) |
| 7471 | |
| 7472 | /** |
| 7473 | * |
| 7474 | * hdd_display_netif_queue_history_compact() - display compact netifq history |
| 7475 | * @hdd_ctx: hdd context |
| 7476 | * |
| 7477 | * Return: none |
| 7478 | */ |
| 7479 | static void |
| 7480 | hdd_display_netif_queue_history_compact(struct hdd_context *hdd_ctx) |
| 7481 | { |
| 7482 | int adapter_num = 0; |
| 7483 | int i; |
| 7484 | int bytes_written; |
| 7485 | u32 tbytes; |
| 7486 | qdf_time_t total, pause, unpause, curr_time, delta; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7487 | char temp_str[20 * WLAN_REASON_TYPE_MAX]; |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 7488 | char *comb_log_str; |
| 7489 | uint32_t comb_log_str_size; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7490 | struct hdd_adapter *adapter = NULL; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7491 | |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 7492 | comb_log_str_size = (ADAP_NETIFQ_LOG_LEN * MAX_NUMBER_OF_ADAPTERS) + 1; |
| 7493 | comb_log_str = qdf_mem_malloc(comb_log_str_size); |
| 7494 | if (!comb_log_str) { |
| 7495 | hdd_err("failed to alloc comb_log_str"); |
| 7496 | return; |
| 7497 | } |
| 7498 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7499 | bytes_written = 0; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7500 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7501 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7502 | curr_time = qdf_system_ticks(); |
| 7503 | total = curr_time - adapter->start_time; |
| 7504 | delta = curr_time - adapter->last_time; |
| 7505 | |
| 7506 | if (adapter->pause_map) { |
| 7507 | pause = adapter->total_pause_time + delta; |
| 7508 | unpause = adapter->total_unpause_time; |
| 7509 | } else { |
| 7510 | unpause = adapter->total_unpause_time + delta; |
| 7511 | pause = adapter->total_pause_time; |
| 7512 | } |
| 7513 | |
| 7514 | tbytes = 0; |
| 7515 | qdf_mem_set(temp_str, 0, sizeof(temp_str)); |
| 7516 | for (i = WLAN_CONTROL_PATH; i < WLAN_REASON_TYPE_MAX; i++) { |
| 7517 | if (adapter->queue_oper_stats[i].pause_count == 0) |
| 7518 | continue; |
| 7519 | tbytes += |
| 7520 | snprintf( |
| 7521 | &temp_str[tbytes], |
| 7522 | (tbytes >= sizeof(temp_str) ? |
| 7523 | 0 : sizeof(temp_str) - tbytes), |
| 7524 | "%d(%d,%d) ", |
| 7525 | i, |
| 7526 | adapter->queue_oper_stats[i]. |
| 7527 | pause_count, |
| 7528 | adapter->queue_oper_stats[i]. |
| 7529 | unpause_count); |
| 7530 | } |
| 7531 | if (tbytes >= sizeof(temp_str)) |
| 7532 | hdd_warn("log truncated"); |
| 7533 | |
| 7534 | bytes_written += snprintf(&comb_log_str[bytes_written], |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 7535 | bytes_written >= comb_log_str_size ? 0 : |
| 7536 | comb_log_str_size - bytes_written, |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7537 | "[%d %d] (%d) %u/%ums %s|", |
| 7538 | adapter->session_id, adapter->device_mode, |
| 7539 | adapter->pause_map, |
| 7540 | qdf_system_ticks_to_msecs(pause), |
| 7541 | qdf_system_ticks_to_msecs(total), |
| 7542 | temp_str); |
| 7543 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7544 | adapter_num++; |
| 7545 | } |
| 7546 | |
| 7547 | /* using QDF_TRACE to avoid printing function name */ |
| 7548 | QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_INFO_LOW, |
| 7549 | "STATS |%s", comb_log_str); |
| 7550 | |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 7551 | if (bytes_written >= comb_log_str_size) |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7552 | hdd_warn("log string truncated"); |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 7553 | |
| 7554 | qdf_mem_free(comb_log_str); |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7555 | } |
| 7556 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7557 | /** |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 7558 | * wlan_hdd_display_netif_queue_history() - display netif queue history |
Jeff Johnson | 58adbcf | 2017-09-03 08:53:31 -0700 | [diff] [blame] | 7559 | * @hdd_ctx: hdd context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7560 | * |
| 7561 | * Return: none |
| 7562 | */ |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7563 | void |
| 7564 | wlan_hdd_display_netif_queue_history(struct hdd_context *hdd_ctx, |
| 7565 | enum qdf_stats_verbosity_level verb_lvl) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7566 | { |
| 7567 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7568 | struct hdd_adapter *adapter = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7569 | int i; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7570 | qdf_time_t total, pause, unpause, curr_time, delta; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7571 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7572 | if (verb_lvl == QDF_STATS_VERBOSITY_LEVEL_LOW) { |
| 7573 | hdd_display_netif_queue_history_compact(hdd_ctx); |
| 7574 | return; |
| 7575 | } |
| 7576 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7577 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7578 | hdd_debug("Netif queue operation statistics:"); |
| 7579 | hdd_debug("Session_id %d device mode %d", |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 7580 | adapter->session_id, adapter->device_mode); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7581 | hdd_debug("Current pause_map value %x", adapter->pause_map); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7582 | curr_time = qdf_system_ticks(); |
| 7583 | total = curr_time - adapter->start_time; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7584 | delta = curr_time - adapter->last_time; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7585 | if (adapter->pause_map) { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7586 | pause = adapter->total_pause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7587 | unpause = adapter->total_unpause_time; |
| 7588 | } else { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7589 | unpause = adapter->total_unpause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7590 | pause = adapter->total_pause_time; |
| 7591 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7592 | hdd_debug("Total: %ums Pause: %ums Unpause: %ums", |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7593 | qdf_system_ticks_to_msecs(total), |
| 7594 | qdf_system_ticks_to_msecs(pause), |
| 7595 | qdf_system_ticks_to_msecs(unpause)); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7596 | hdd_debug("reason_type: pause_cnt: unpause_cnt: pause_time"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7597 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7598 | for (i = WLAN_CONTROL_PATH; i < WLAN_REASON_TYPE_MAX; i++) { |
| 7599 | qdf_time_t pause_delta = 0; |
| 7600 | |
| 7601 | if (adapter->pause_map & (1 << i)) |
| 7602 | pause_delta = delta; |
| 7603 | |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7604 | /* using hdd_log to avoid printing function name */ |
Dustin Brown | 632af71 | 2018-03-14 15:03:55 -0700 | [diff] [blame] | 7605 | hdd_debug("%s: %d: %d: %ums", |
| 7606 | hdd_reason_type_to_string(i), |
| 7607 | adapter->queue_oper_stats[i].pause_count, |
| 7608 | adapter->queue_oper_stats[i].unpause_count, |
| 7609 | qdf_system_ticks_to_msecs( |
| 7610 | adapter->queue_oper_stats[i].total_pause_time + |
| 7611 | pause_delta)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7612 | } |
| 7613 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7614 | hdd_debug("Netif queue operation history:"); |
| 7615 | hdd_debug("Total entries: %d current index %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7616 | WLAN_HDD_MAX_HISTORY_ENTRY, adapter->history_index); |
| 7617 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7618 | hdd_debug("index: time: action_type: reason_type: pause_map"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7619 | |
| 7620 | for (i = 0; i < WLAN_HDD_MAX_HISTORY_ENTRY; i++) { |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7621 | /* using hdd_log to avoid printing function name */ |
| 7622 | if (adapter->queue_oper_history[i].time == 0) |
| 7623 | continue; |
Dustin Brown | 632af71 | 2018-03-14 15:03:55 -0700 | [diff] [blame] | 7624 | hdd_debug("%d: %u: %s: %s: %x", |
| 7625 | i, qdf_system_ticks_to_msecs( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7626 | adapter->queue_oper_history[i].time), |
Dustin Brown | 632af71 | 2018-03-14 15:03:55 -0700 | [diff] [blame] | 7627 | hdd_action_type_to_string( |
| 7628 | adapter->queue_oper_history[i].netif_action), |
| 7629 | hdd_reason_type_to_string( |
| 7630 | adapter->queue_oper_history[i].netif_reason), |
| 7631 | adapter->queue_oper_history[i].pause_map); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7632 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7633 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7634 | } |
| 7635 | |
| 7636 | /** |
| 7637 | * wlan_hdd_clear_netif_queue_history() - clear netif queue operation history |
| 7638 | * @hdd_ctx: hdd context |
| 7639 | * |
| 7640 | * Return: none |
| 7641 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7642 | void wlan_hdd_clear_netif_queue_history(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7643 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7644 | struct hdd_adapter *adapter = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7645 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7646 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7647 | qdf_mem_zero(adapter->queue_oper_stats, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7648 | sizeof(adapter->queue_oper_stats)); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7649 | qdf_mem_zero(adapter->queue_oper_history, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7650 | sizeof(adapter->queue_oper_history)); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7651 | adapter->history_index = 0; |
| 7652 | adapter->start_time = adapter->last_time = qdf_system_ticks(); |
| 7653 | adapter->total_pause_time = 0; |
| 7654 | adapter->total_unpause_time = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7655 | } |
| 7656 | } |
| 7657 | |
| 7658 | /** |
| 7659 | * hdd_11d_scan_done() - callback for 11d scan completion of flushing results |
| 7660 | * @halHandle: Hal handle |
| 7661 | * @pContext: Pointer to the context |
| 7662 | * @sessionId: Session ID |
| 7663 | * @scanId: Scan ID |
| 7664 | * @status: Status |
| 7665 | * |
| 7666 | * This is the callback to be executed when 11d scan is completed to flush out |
| 7667 | * the scan results |
| 7668 | * |
| 7669 | * 11d scan is done during driver load and is a passive scan on all |
| 7670 | * channels supported by the device, 11d scans may find some APs on |
| 7671 | * frequencies which are forbidden to be used in the regulatory domain |
| 7672 | * the device is operating in. If these APs are notified to the supplicant |
| 7673 | * it may try to connect to these APs, thus flush out all the scan results |
| 7674 | * which are present in SME after 11d scan is done. |
| 7675 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7676 | * Return: QDF_STATUS_SUCCESS |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7677 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7678 | static QDF_STATUS hdd_11d_scan_done(tHalHandle halHandle, void *pContext, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7679 | uint8_t sessionId, uint32_t scanId, |
| 7680 | eCsrScanStatus status) |
| 7681 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 7682 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7683 | |
| 7684 | sme_scan_flush_result(halHandle); |
| 7685 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 7686 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7687 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7688 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7689 | } |
| 7690 | |
| 7691 | #ifdef WLAN_FEATURE_OFFLOAD_PACKETS |
| 7692 | /** |
| 7693 | * hdd_init_offloaded_packets_ctx() - Initialize offload packets context |
| 7694 | * @hdd_ctx: hdd global context |
| 7695 | * |
| 7696 | * Return: none |
| 7697 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7698 | static void hdd_init_offloaded_packets_ctx(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7699 | { |
| 7700 | uint8_t i; |
| 7701 | |
| 7702 | mutex_init(&hdd_ctx->op_ctx.op_lock); |
| 7703 | for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++) { |
| 7704 | hdd_ctx->op_ctx.op_table[i].request_id = MAX_REQUEST_ID; |
| 7705 | hdd_ctx->op_ctx.op_table[i].pattern_id = i; |
| 7706 | } |
| 7707 | } |
| 7708 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7709 | static void hdd_init_offloaded_packets_ctx(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7710 | { |
| 7711 | } |
| 7712 | #endif |
| 7713 | |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7714 | #ifdef WLAN_FEATURE_WOW_PULSE |
| 7715 | /** |
| 7716 | * 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] | 7717 | * @phddctx: struct hdd_context structure pointer |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7718 | * @enable: enable or disable this behaviour |
| 7719 | * |
| 7720 | * Return: int |
| 7721 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7722 | 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] | 7723 | { |
| 7724 | struct hdd_config *pcfg_ini = phddctx->config; |
| 7725 | struct wow_pulse_mode wow_pulse_set_info; |
| 7726 | QDF_STATUS status; |
| 7727 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7728 | hdd_debug("wow pulse enable flag is %d", enable); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7729 | |
| 7730 | if (false == phddctx->config->wow_pulse_support) |
| 7731 | return 0; |
| 7732 | |
| 7733 | /* prepare the request to send to SME */ |
| 7734 | if (enable == true) { |
| 7735 | wow_pulse_set_info.wow_pulse_enable = true; |
| 7736 | wow_pulse_set_info.wow_pulse_pin = |
| 7737 | pcfg_ini->wow_pulse_pin; |
| 7738 | wow_pulse_set_info.wow_pulse_interval_low = |
| 7739 | pcfg_ini->wow_pulse_interval_low; |
| 7740 | wow_pulse_set_info.wow_pulse_interval_high = |
| 7741 | pcfg_ini->wow_pulse_interval_high; |
| 7742 | } else { |
| 7743 | wow_pulse_set_info.wow_pulse_enable = false; |
| 7744 | wow_pulse_set_info.wow_pulse_pin = 0; |
| 7745 | wow_pulse_set_info.wow_pulse_interval_low = 0; |
| 7746 | wow_pulse_set_info.wow_pulse_interval_high = 0; |
| 7747 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7748 | hdd_debug("enable %d pin %d low %d high %d", |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7749 | wow_pulse_set_info.wow_pulse_enable, |
| 7750 | wow_pulse_set_info.wow_pulse_pin, |
| 7751 | wow_pulse_set_info.wow_pulse_interval_low, |
| 7752 | wow_pulse_set_info.wow_pulse_interval_high); |
| 7753 | |
| 7754 | status = sme_set_wow_pulse(&wow_pulse_set_info); |
| 7755 | if (QDF_STATUS_E_FAILURE == status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7756 | hdd_debug("sme_set_wow_pulse failure!"); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7757 | return -EIO; |
| 7758 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7759 | hdd_debug("sme_set_wow_pulse success!"); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7760 | return 0; |
| 7761 | } |
| 7762 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7763 | 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] | 7764 | { |
| 7765 | return 0; |
| 7766 | } |
| 7767 | #endif |
| 7768 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7769 | #ifdef WLAN_FEATURE_FASTPATH |
| 7770 | /** |
| 7771 | * hdd_enable_fastpath() - Enable fastpath if enabled in config INI |
| 7772 | * @hdd_cfg: hdd config |
| 7773 | * @context: lower layer context |
| 7774 | * |
| 7775 | * Return: none |
| 7776 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7777 | void hdd_enable_fastpath(struct hdd_config *hdd_cfg, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7778 | void *context) |
| 7779 | { |
| 7780 | if (hdd_cfg->fastpath_enable) |
| 7781 | hif_enable_fastpath(context); |
| 7782 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7783 | #endif |
| 7784 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7785 | #if defined(FEATURE_WLAN_CH_AVOID) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7786 | /** |
| 7787 | * hdd_set_thermal_level_cb() - set thermal level callback function |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7788 | * @context: hdd context pointer |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7789 | * @level: thermal level |
| 7790 | * |
| 7791 | * Change IPA data path to SW path when the thermal throttle level greater |
| 7792 | * than 0, and restore the original data path when throttle level is 0 |
| 7793 | * |
| 7794 | * Return: none |
| 7795 | */ |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7796 | 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] | 7797 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7798 | struct hdd_context *hdd_ctx = context; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7799 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7800 | /* Change IPA to SW path when throttle level greater than 0 */ |
| 7801 | if (level > THROTTLE_LEVEL_0) |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 7802 | ucfg_ipa_send_mcc_scc_msg(hdd_ctx->hdd_pdev, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7803 | else |
| 7804 | /* restore original concurrency mode */ |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 7805 | 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] | 7806 | } |
| 7807 | |
| 7808 | /** |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7809 | * hdd_get_safe_channel_from_pcl_and_acs_range() - Get safe channel for SAP |
| 7810 | * restart |
Manishekar Chandrasekaran | db9b867 | 2016-06-10 23:31:19 +0530 | [diff] [blame] | 7811 | * @adapter: AP adapter, which should be checked for NULL |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7812 | * |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7813 | * Get a safe channel to restart SAP. PCL already takes into account the |
| 7814 | * unsafe channels. So, the PCL is validated with the ACS range to provide |
| 7815 | * a safe channel for the SAP to restart. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7816 | * |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7817 | * Return: Channel number to restart SAP in case of success. In case of any |
| 7818 | * failure, the channel number returned is zero. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7819 | */ |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7820 | static uint8_t hdd_get_safe_channel_from_pcl_and_acs_range( |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7821 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7822 | { |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7823 | struct sir_pcl_list pcl; |
| 7824 | QDF_STATUS status; |
| 7825 | uint32_t i, j; |
| 7826 | tHalHandle *hal_handle; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7827 | struct hdd_context *hdd_ctx; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7828 | bool found = false; |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 7829 | int ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7830 | |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7831 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 7832 | if (!hdd_ctx) { |
| 7833 | hdd_err("invalid HDD context"); |
| 7834 | return INVALID_CHANNEL_ID; |
| 7835 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7836 | |
Manishekar Chandrasekaran | 79746ac | 2016-06-24 04:45:33 +0530 | [diff] [blame] | 7837 | hal_handle = WLAN_HDD_GET_HAL_CTX(adapter); |
| 7838 | if (!hal_handle) { |
| 7839 | hdd_err("invalid HAL handle"); |
| 7840 | return INVALID_CHANNEL_ID; |
| 7841 | } |
| 7842 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7843 | status = policy_mgr_get_pcl_for_existing_conn(hdd_ctx->hdd_psoc, |
| 7844 | PM_SAP_MODE, pcl.pcl_list, &pcl.pcl_len, |
bings | 37bd58f | 2017-07-20 16:49:26 +0800 | [diff] [blame] | 7845 | pcl.weight_list, QDF_ARRAY_SIZE(pcl.weight_list), |
| 7846 | false); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7847 | if (QDF_IS_STATUS_ERROR(status)) { |
| 7848 | hdd_err("Get PCL failed"); |
| 7849 | return INVALID_CHANNEL_ID; |
| 7850 | } |
| 7851 | |
Frank Liu | dc2cefb | 2017-06-21 15:38:18 +0800 | [diff] [blame] | 7852 | /* |
| 7853 | * In some scenarios, like hw dbs disabled, sap+sap case, if operating |
| 7854 | * channel is unsafe channel, the pcl may be empty, instead of return, |
| 7855 | * try to choose a safe channel from acs range. |
| 7856 | */ |
| 7857 | if (!pcl.pcl_len) |
| 7858 | hdd_debug("pcl length is zero!"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7859 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7860 | hdd_debug("start:%d end:%d", |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7861 | adapter->session.ap.sap_config.acs_cfg.start_ch, |
| 7862 | adapter->session.ap.sap_config.acs_cfg.end_ch); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7863 | |
| 7864 | /* PCL already takes unsafe channel into account */ |
| 7865 | for (i = 0; i < pcl.pcl_len; i++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7866 | hdd_debug("chan[%d]:%d", i, pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7867 | if ((pcl.pcl_list[i] >= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7868 | adapter->session.ap.sap_config.acs_cfg.start_ch) && |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7869 | (pcl.pcl_list[i] <= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7870 | adapter->session.ap.sap_config.acs_cfg.end_ch)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7871 | hdd_debug("found PCL safe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7872 | return pcl.pcl_list[i]; |
| 7873 | } |
| 7874 | } |
| 7875 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7876 | hdd_debug("no safe channel from PCL found in ACS range"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7877 | |
| 7878 | /* Try for safe channel from all valid channel */ |
| 7879 | pcl.pcl_len = MAX_NUM_CHAN; |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 7880 | ret = hdd_get_valid_chan(hdd_ctx, pcl.pcl_list, |
| 7881 | &pcl.pcl_len); |
| 7882 | if (ret) { |
| 7883 | hdd_err("error %d in getting valid channel list", ret); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7884 | return INVALID_CHANNEL_ID; |
| 7885 | } |
| 7886 | |
| 7887 | for (i = 0; i < pcl.pcl_len; i++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7888 | hdd_debug("chan[%d]:%d", i, pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7889 | found = false; |
| 7890 | for (j = 0; j < hdd_ctx->unsafe_channel_count; j++) { |
Krunal Soni | 15f0db1 | 2016-10-11 18:53:37 -0700 | [diff] [blame] | 7891 | if (pcl.pcl_list[i] == |
| 7892 | hdd_ctx->unsafe_channel_list[j]) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7893 | hdd_debug("unsafe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7894 | found = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7895 | break; |
| 7896 | } |
| 7897 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7898 | |
| 7899 | if (found) |
| 7900 | continue; |
| 7901 | |
| 7902 | if ((pcl.pcl_list[i] >= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7903 | adapter->session.ap.sap_config.acs_cfg.start_ch) && |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7904 | (pcl.pcl_list[i] <= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7905 | adapter->session.ap.sap_config.acs_cfg.end_ch)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7906 | hdd_debug("found safe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7907 | return pcl.pcl_list[i]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7908 | } |
| 7909 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7910 | |
| 7911 | return INVALID_CHANNEL_ID; |
| 7912 | } |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 7913 | #endif |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7914 | |
| 7915 | /** |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 7916 | * hdd_switch_sap_channel() - Move SAP to the given channel |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7917 | * @adapter: AP adapter |
| 7918 | * @channel: Channel |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 7919 | * @forced: Force to switch channel, ignore SCC/MCC check |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7920 | * |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 7921 | * Moves the SAP interface by invoking the function which |
| 7922 | * executes the callback to perform channel switch using (E)CSA. |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7923 | * |
| 7924 | * Return: None |
| 7925 | */ |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 7926 | void hdd_switch_sap_channel(struct hdd_adapter *adapter, uint8_t channel, |
| 7927 | bool forced) |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7928 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 7929 | struct hdd_ap_ctx *hdd_ap_ctx; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7930 | tHalHandle *hal_handle; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7931 | struct hdd_context *hdd_ctx; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7932 | |
| 7933 | if (!adapter) { |
| 7934 | hdd_err("invalid adapter"); |
| 7935 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7936 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7937 | |
| 7938 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 7939 | |
| 7940 | hal_handle = WLAN_HDD_GET_HAL_CTX(adapter); |
| 7941 | if (!hal_handle) { |
| 7942 | hdd_err("invalid HAL handle"); |
| 7943 | return; |
| 7944 | } |
| 7945 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7946 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 7947 | |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 7948 | hdd_ap_ctx->sap_config.channel = channel; |
| 7949 | hdd_ap_ctx->sap_config.ch_params.ch_width = |
| 7950 | hdd_ap_ctx->sap_config.ch_width_orig; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7951 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7952 | hdd_debug("chan:%d width:%d", |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 7953 | channel, hdd_ap_ctx->sap_config.ch_width_orig); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7954 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 7955 | wlan_reg_set_channel_params(hdd_ctx->hdd_pdev, |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 7956 | hdd_ap_ctx->sap_config.channel, |
| 7957 | hdd_ap_ctx->sap_config.sec_ch, |
| 7958 | &hdd_ap_ctx->sap_config.ch_params); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7959 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7960 | policy_mgr_change_sap_channel_with_csa(hdd_ctx->hdd_psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 7961 | adapter->session_id, channel, |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 7962 | hdd_ap_ctx->sap_config.ch_width_orig, forced); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7963 | } |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7964 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7965 | 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] | 7966 | { |
| 7967 | struct hdd_external_acs_timer_context *timer_context; |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 7968 | int status; |
| 7969 | QDF_STATUS qdf_status; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7970 | |
| 7971 | set_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
| 7972 | |
| 7973 | if (QDF_TIMER_STATE_RUNNING == |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7974 | qdf_mc_timer_get_current_state(&adapter->session. |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7975 | ap.vendor_acs_timer)) { |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7976 | qdf_mc_timer_stop(&adapter->session.ap.vendor_acs_timer); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7977 | } |
| 7978 | timer_context = (struct hdd_external_acs_timer_context *) |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7979 | adapter->session.ap.vendor_acs_timer.user_data; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7980 | timer_context->reason = reason; |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 7981 | qdf_status = |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7982 | qdf_mc_timer_start(&adapter->session.ap.vendor_acs_timer, |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 7983 | WLAN_VENDOR_ACS_WAIT_TIME); |
| 7984 | if (qdf_status != QDF_STATUS_SUCCESS) { |
| 7985 | hdd_err("failed to start external acs timer"); |
| 7986 | return -ENOSPC; |
| 7987 | } |
| 7988 | /* Update config to application */ |
| 7989 | status = hdd_cfg80211_update_acs_config(adapter, reason); |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 7990 | hdd_info("Updated ACS config to nl with reason %d", reason); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7991 | |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 7992 | return status; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7993 | } |
| 7994 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 7995 | #if defined(FEATURE_WLAN_CH_AVOID) |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7996 | /** |
| 7997 | * hdd_unsafe_channel_restart_sap() - restart sap if sap is on unsafe channel |
| 7998 | * @hdd_ctx: hdd context pointer |
| 7999 | * |
| 8000 | * hdd_unsafe_channel_restart_sap check all unsafe channel list |
| 8001 | * and if ACS is enabled, driver will ask userspace to restart the |
| 8002 | * sap. User space on LTE coex indication restart driver. |
| 8003 | * |
| 8004 | * Return - none |
| 8005 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8006 | void hdd_unsafe_channel_restart_sap(struct hdd_context *hdd_ctxt) |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8007 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8008 | struct hdd_adapter *adapter; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8009 | uint32_t i; |
| 8010 | bool found = false; |
| 8011 | uint8_t restart_chan; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8012 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8013 | hdd_for_each_adapter(hdd_ctxt, adapter) { |
| 8014 | if (!(adapter->device_mode == QDF_SAP_MODE && |
| 8015 | adapter->session.ap.sap_config.acs_cfg.acs_mode)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8016 | hdd_debug("skip device mode:%d acs:%d", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8017 | adapter->device_mode, |
| 8018 | adapter->session.ap.sap_config. |
| 8019 | acs_cfg.acs_mode); |
| 8020 | continue; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8021 | } |
| 8022 | |
| 8023 | found = false; |
| 8024 | for (i = 0; i < hdd_ctxt->unsafe_channel_count; i++) { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8025 | if (adapter->session.ap.operating_channel == |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8026 | hdd_ctxt->unsafe_channel_list[i]) { |
| 8027 | found = true; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8028 | hdd_debug("operating ch:%d is unsafe", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8029 | adapter->session.ap.operating_channel); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8030 | break; |
| 8031 | } |
| 8032 | } |
| 8033 | |
| 8034 | if (!found) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8035 | hdd_debug("ch:%d is safe. no need to change channel", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8036 | adapter->session.ap.operating_channel); |
| 8037 | continue; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8038 | } |
| 8039 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8040 | if (hdd_ctxt->config->vendor_acs_support && |
| 8041 | hdd_ctxt->config->acs_support_for_dfs_ltecoex) { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8042 | hdd_update_acs_timer_reason(adapter, |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8043 | QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8044 | continue; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8045 | } else |
| 8046 | restart_chan = |
| 8047 | hdd_get_safe_channel_from_pcl_and_acs_range( |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8048 | adapter); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8049 | if (!restart_chan) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8050 | hdd_err("fail to restart SAP"); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8051 | } else { |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 8052 | /* |
| 8053 | * SAP restart due to unsafe channel. While |
| 8054 | * restarting the SAP, make sure to clear |
| 8055 | * acs_channel, channel to reset to |
| 8056 | * 0. Otherwise these settings will override |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 8057 | * the ACS while restart. |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 8058 | */ |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 8059 | hdd_ctxt->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8060 | adapter->session.ap.sap_config.channel = |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 8061 | AUTO_CHANNEL_SELECT; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8062 | hdd_debug("sending coex indication"); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8063 | wlan_hdd_send_svc_nlink_msg(hdd_ctxt->radio_index, |
| 8064 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
Liangwei Dong | 6663d16 | 2017-07-10 03:29:36 -0400 | [diff] [blame] | 8065 | hdd_debug("driver to start sap: %d", |
| 8066 | hdd_ctxt->config->sap_internal_restart); |
| 8067 | if (hdd_ctxt->config->sap_internal_restart) |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8068 | hdd_switch_sap_channel(adapter, restart_chan, |
| 8069 | true); |
Liangwei Dong | 6663d16 | 2017-07-10 03:29:36 -0400 | [diff] [blame] | 8070 | else |
| 8071 | return; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8072 | } |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8073 | } |
| 8074 | } |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 8075 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8076 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8077 | * hdd_init_channel_avoidance() - Initialize channel avoidance |
| 8078 | * @hdd_ctx: HDD global context |
| 8079 | * |
| 8080 | * Initialize the channel avoidance logic by retrieving the unsafe |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8081 | * channel list from the platform driver and plumbing the data |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8082 | * down to the lower layers. Then subscribe to subsequent channel |
| 8083 | * avoidance events. |
| 8084 | * |
| 8085 | * Return: None |
| 8086 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8087 | static void hdd_init_channel_avoidance(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8088 | { |
| 8089 | uint16_t unsafe_channel_count; |
| 8090 | int index; |
| 8091 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8092 | pld_get_wlan_unsafe_channel(hdd_ctx->parent_dev, |
| 8093 | hdd_ctx->unsafe_channel_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8094 | &(hdd_ctx->unsafe_channel_count), |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 8095 | sizeof(uint16_t) * NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8096 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8097 | hdd_debug("num of unsafe channels is %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8098 | hdd_ctx->unsafe_channel_count); |
| 8099 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8100 | unsafe_channel_count = QDF_MIN((uint16_t)hdd_ctx->unsafe_channel_count, |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 8101 | (uint16_t)NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8102 | |
| 8103 | for (index = 0; index < unsafe_channel_count; index++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8104 | hdd_debug("channel %d is not safe", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8105 | hdd_ctx->unsafe_channel_list[index]); |
| 8106 | |
| 8107 | } |
| 8108 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8109 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8110 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8111 | static void hdd_lte_coex_restart_sap(struct hdd_adapter *adapter, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8112 | struct hdd_context *hdd_ctx) |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8113 | { |
| 8114 | uint8_t restart_chan; |
| 8115 | |
| 8116 | restart_chan = hdd_get_safe_channel_from_pcl_and_acs_range(adapter); |
| 8117 | if (!restart_chan) { |
| 8118 | hdd_alert("fail to restart SAP"); |
| 8119 | return; |
| 8120 | } |
| 8121 | |
| 8122 | /* SAP restart due to unsafe channel. While restarting |
| 8123 | * the SAP, make sure to clear acs_channel, channel to |
| 8124 | * reset to 0. Otherwise these settings will override |
| 8125 | * the ACS while restart. |
| 8126 | */ |
| 8127 | hdd_ctx->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8128 | adapter->session.ap.sap_config.channel = AUTO_CHANNEL_SELECT; |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8129 | |
| 8130 | hdd_debug("sending coex indication"); |
| 8131 | |
| 8132 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 8133 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8134 | hdd_switch_sap_channel(adapter, restart_chan, true); |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8135 | } |
Liangwei Dong | 6e1a209 | 2017-08-30 16:29:06 +0800 | [diff] [blame] | 8136 | |
| 8137 | int hdd_clone_local_unsafe_chan(struct hdd_context *hdd_ctx, |
| 8138 | uint16_t **local_unsafe_list, uint16_t *local_unsafe_list_count) |
| 8139 | { |
| 8140 | uint32_t size; |
| 8141 | uint16_t *unsafe_list; |
| 8142 | uint16_t chan_count; |
| 8143 | |
| 8144 | if (!hdd_ctx || !local_unsafe_list_count || !local_unsafe_list_count) |
| 8145 | return -EINVAL; |
| 8146 | |
| 8147 | chan_count = QDF_MIN(hdd_ctx->unsafe_channel_count, |
| 8148 | NUM_CHANNELS); |
| 8149 | if (chan_count) { |
| 8150 | size = chan_count * sizeof(hdd_ctx->unsafe_channel_list[0]); |
| 8151 | unsafe_list = qdf_mem_malloc(size); |
| 8152 | if (!unsafe_list) { |
| 8153 | hdd_err("No memory for unsafe chan list size%d", |
| 8154 | size); |
| 8155 | return -ENOMEM; |
| 8156 | } |
| 8157 | qdf_mem_copy(unsafe_list, hdd_ctx->unsafe_channel_list, size); |
| 8158 | } else { |
| 8159 | unsafe_list = NULL; |
| 8160 | } |
| 8161 | |
| 8162 | *local_unsafe_list = unsafe_list; |
| 8163 | *local_unsafe_list_count = chan_count; |
| 8164 | |
| 8165 | return 0; |
| 8166 | } |
| 8167 | |
| 8168 | bool hdd_local_unsafe_channel_updated(struct hdd_context *hdd_ctx, |
| 8169 | uint16_t *local_unsafe_list, uint16_t local_unsafe_list_count) |
| 8170 | { |
| 8171 | int i, j; |
| 8172 | |
| 8173 | if (local_unsafe_list_count != hdd_ctx->unsafe_channel_count) |
| 8174 | return true; |
| 8175 | if (local_unsafe_list_count == 0) |
| 8176 | return false; |
| 8177 | for (i = 0; i < local_unsafe_list_count; i++) { |
| 8178 | for (j = 0; j < local_unsafe_list_count; j++) |
| 8179 | if (local_unsafe_list[i] == |
| 8180 | hdd_ctx->unsafe_channel_list[j]) |
| 8181 | break; |
| 8182 | if (j >= local_unsafe_list_count) |
| 8183 | break; |
| 8184 | } |
| 8185 | if (i >= local_unsafe_list_count) { |
| 8186 | hdd_info("unsafe chan list same"); |
| 8187 | return false; |
| 8188 | } |
| 8189 | |
| 8190 | return true; |
| 8191 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8192 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8193 | static void hdd_init_channel_avoidance(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8194 | { |
| 8195 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8196 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8197 | 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] | 8198 | { |
| 8199 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8200 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8201 | static inline void hdd_lte_coex_restart_sap(struct hdd_adapter *adapter, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8202 | struct hdd_context *hdd_ctx) |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8203 | { |
| 8204 | hdd_debug("Channel avoidance is not enabled; Abort SAP restart"); |
| 8205 | } |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8206 | #endif /* defined(FEATURE_WLAN_CH_AVOID) */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8207 | |
| 8208 | /** |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8209 | * hdd_indicate_mgmt_frame() - Wrapper to indicate management frame to |
| 8210 | * user space |
| 8211 | * @frame_ind: Management frame data to be informed. |
| 8212 | * |
| 8213 | * This function is used to indicate management frame to |
| 8214 | * user space |
| 8215 | * |
| 8216 | * Return: None |
| 8217 | * |
| 8218 | */ |
| 8219 | void hdd_indicate_mgmt_frame(tSirSmeMgmtFrameInd *frame_ind) |
| 8220 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8221 | struct hdd_context *hdd_ctx = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8222 | struct hdd_adapter *adapter = NULL; |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8223 | int i; |
| 8224 | |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8225 | /* Get the HDD context.*/ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8226 | hdd_ctx = (struct hdd_context *)cds_get_context(QDF_MODULE_ID_HDD); |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8227 | |
| 8228 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
| 8229 | return; |
| 8230 | |
| 8231 | if (SME_SESSION_ID_ANY == frame_ind->sessionId) { |
| 8232 | for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) { |
| 8233 | adapter = |
| 8234 | hdd_get_adapter_by_sme_session_id(hdd_ctx, i); |
| 8235 | if (adapter) |
| 8236 | break; |
| 8237 | } |
Wu Gao | a0230a6 | 2018-01-04 20:56:57 +0800 | [diff] [blame] | 8238 | } else if (SME_SESSION_ID_BROADCAST == frame_ind->sessionId) { |
| 8239 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 8240 | if ((NULL != adapter) && |
| 8241 | (WLAN_HDD_ADAPTER_MAGIC == adapter->magic)) { |
| 8242 | __hdd_indicate_mgmt_frame(adapter, |
| 8243 | frame_ind->frame_len, |
| 8244 | frame_ind->frameBuf, |
| 8245 | frame_ind->frameType, |
| 8246 | frame_ind->rxChan, |
| 8247 | frame_ind->rxRssi); |
| 8248 | } |
| 8249 | } |
| 8250 | adapter = NULL; |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8251 | } else { |
| 8252 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, |
| 8253 | frame_ind->sessionId); |
| 8254 | } |
| 8255 | |
| 8256 | if ((NULL != adapter) && |
| 8257 | (WLAN_HDD_ADAPTER_MAGIC == adapter->magic)) |
| 8258 | __hdd_indicate_mgmt_frame(adapter, |
| 8259 | frame_ind->frame_len, |
| 8260 | frame_ind->frameBuf, |
| 8261 | frame_ind->frameType, |
| 8262 | frame_ind->rxChan, |
| 8263 | frame_ind->rxRssi); |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8264 | } |
| 8265 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8266 | void hdd_acs_response_timeout_handler(void *context) |
| 8267 | { |
| 8268 | struct hdd_external_acs_timer_context *timer_context = |
| 8269 | (struct hdd_external_acs_timer_context *)context; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8270 | struct hdd_adapter *adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8271 | struct hdd_context *hdd_ctx; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8272 | uint8_t reason; |
| 8273 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 8274 | hdd_enter(); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8275 | if (!timer_context) { |
| 8276 | hdd_err("invlaid timer context"); |
| 8277 | return; |
| 8278 | } |
| 8279 | adapter = timer_context->adapter; |
| 8280 | reason = timer_context->reason; |
| 8281 | |
| 8282 | |
| 8283 | if ((!adapter) || |
| 8284 | (adapter->magic != WLAN_HDD_ADAPTER_MAGIC)) { |
| 8285 | hdd_err("invalid adapter or adapter has invalid magic"); |
| 8286 | return; |
| 8287 | } |
| 8288 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 8289 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 8290 | return; |
| 8291 | |
| 8292 | if (test_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags)) |
| 8293 | clear_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
| 8294 | else |
| 8295 | return; |
| 8296 | |
| 8297 | hdd_err("ACS timeout happened for %s reason %d", |
| 8298 | adapter->dev->name, reason); |
| 8299 | switch (reason) { |
| 8300 | /* SAP init case */ |
| 8301 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_INIT: |
| 8302 | wlan_sap_set_vendor_acs(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 8303 | false); |
| 8304 | wlan_hdd_cfg80211_start_acs(adapter); |
| 8305 | break; |
| 8306 | /* DFS detected on current channel */ |
| 8307 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_DFS: |
| 8308 | wlan_sap_update_next_channel( |
| 8309 | WLAN_HDD_GET_SAP_CTX_PTR(adapter), 0, 0); |
| 8310 | sme_update_new_channel_event(WLAN_HDD_GET_HAL_CTX(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 8311 | adapter->session_id); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8312 | break; |
| 8313 | /* LTE coex event on current channel */ |
| 8314 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX: |
| 8315 | hdd_lte_coex_restart_sap(adapter, hdd_ctx); |
| 8316 | break; |
| 8317 | default: |
| 8318 | hdd_info("invalid reason for timer invoke"); |
| 8319 | |
| 8320 | } |
| 8321 | } |
| 8322 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8323 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8324 | * hdd_override_ini_config - Override INI config |
| 8325 | * @hdd_ctx: HDD context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8326 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8327 | * Override INI config based on module parameter. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8328 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8329 | * Return: None |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8330 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8331 | static void hdd_override_ini_config(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8332 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8333 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8334 | if (0 == enable_dfs_chan_scan || 1 == enable_dfs_chan_scan) { |
| 8335 | hdd_ctx->config->enableDFSChnlScan = enable_dfs_chan_scan; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8336 | hdd_debug("Module enable_dfs_chan_scan set to %d", |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8337 | enable_dfs_chan_scan); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8338 | } |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8339 | if (0 == enable_11d || 1 == enable_11d) { |
| 8340 | hdd_ctx->config->Is11dSupportEnabled = enable_11d; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8341 | hdd_debug("Module enable_11d set to %d", enable_11d); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8342 | } |
Leo Chang | 11545d6 | 2016-10-17 14:53:50 -0700 | [diff] [blame] | 8343 | |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 8344 | if (!ucfg_ipa_is_present()) { |
Leo Chang | 11545d6 | 2016-10-17 14:53:50 -0700 | [diff] [blame] | 8345 | hdd_ctx->config->IpaConfig = 0; |
Jingxiang Ge | 7a040dc | 2018-02-02 11:07:59 +0800 | [diff] [blame] | 8346 | hdd_debug("IpaConfig override to %d", |
| 8347 | hdd_ctx->config->IpaConfig); |
| 8348 | } |
Yeshwanth Sriram Guntuka | 2ba6fe9 | 2017-10-04 14:40:45 +0530 | [diff] [blame] | 8349 | |
| 8350 | if (!hdd_ctx->config->rssi_assoc_reject_enabled || |
| 8351 | !hdd_ctx->config->enable_bcast_probe_rsp) { |
| 8352 | hdd_debug("OCE disabled, rssi_assoc_reject_enabled: %d enable_bcast_probe_rsp: %d", |
| 8353 | hdd_ctx->config->rssi_assoc_reject_enabled, |
| 8354 | hdd_ctx->config->enable_bcast_probe_rsp); |
| 8355 | hdd_ctx->config->oce_sta_enabled = 0; |
| 8356 | } |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8357 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8358 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8359 | /** |
| 8360 | * hdd_set_trace_level_for_each - Set trace level for each INI config |
| 8361 | * @hdd_ctx - HDD context |
| 8362 | * |
| 8363 | * Set trace level for each module based on INI config. |
| 8364 | * |
| 8365 | * Return: None |
| 8366 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8367 | 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] | 8368 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 8369 | hdd_qdf_trace_enable(QDF_MODULE_ID_WMI, |
| 8370 | hdd_ctx->config->qdf_trace_enable_wdi); |
| 8371 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD, |
| 8372 | hdd_ctx->config->qdf_trace_enable_hdd); |
| 8373 | hdd_qdf_trace_enable(QDF_MODULE_ID_SME, |
| 8374 | hdd_ctx->config->qdf_trace_enable_sme); |
| 8375 | hdd_qdf_trace_enable(QDF_MODULE_ID_PE, |
| 8376 | hdd_ctx->config->qdf_trace_enable_pe); |
| 8377 | hdd_qdf_trace_enable(QDF_MODULE_ID_WMA, |
| 8378 | hdd_ctx->config->qdf_trace_enable_wma); |
| 8379 | hdd_qdf_trace_enable(QDF_MODULE_ID_SYS, |
| 8380 | hdd_ctx->config->qdf_trace_enable_sys); |
| 8381 | hdd_qdf_trace_enable(QDF_MODULE_ID_QDF, |
| 8382 | hdd_ctx->config->qdf_trace_enable_qdf); |
| 8383 | hdd_qdf_trace_enable(QDF_MODULE_ID_SAP, |
| 8384 | hdd_ctx->config->qdf_trace_enable_sap); |
| 8385 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_SOFTAP, |
| 8386 | hdd_ctx->config->qdf_trace_enable_hdd_sap); |
| 8387 | hdd_qdf_trace_enable(QDF_MODULE_ID_BMI, |
| 8388 | hdd_ctx->config->qdf_trace_enable_bmi); |
| 8389 | hdd_qdf_trace_enable(QDF_MODULE_ID_CFG, |
| 8390 | hdd_ctx->config->qdf_trace_enable_cfg); |
| 8391 | hdd_qdf_trace_enable(QDF_MODULE_ID_EPPING, |
| 8392 | hdd_ctx->config->qdf_trace_enable_epping); |
| 8393 | hdd_qdf_trace_enable(QDF_MODULE_ID_QDF_DEVICE, |
| 8394 | hdd_ctx->config->qdf_trace_enable_qdf_devices); |
| 8395 | hdd_qdf_trace_enable(QDF_MODULE_ID_TXRX, |
Houston Hoffman | fbf0510 | 2017-08-28 11:37:01 -0700 | [diff] [blame] | 8396 | hdd_ctx->config->qdf_trace_enable_txrx); |
| 8397 | hdd_qdf_trace_enable(QDF_MODULE_ID_DP, |
| 8398 | hdd_ctx->config->qdf_trace_enable_dp); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 8399 | hdd_qdf_trace_enable(QDF_MODULE_ID_HTC, |
| 8400 | hdd_ctx->config->qdf_trace_enable_htc); |
| 8401 | hdd_qdf_trace_enable(QDF_MODULE_ID_HIF, |
| 8402 | hdd_ctx->config->qdf_trace_enable_hif); |
| 8403 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_SAP_DATA, |
| 8404 | hdd_ctx->config->qdf_trace_enable_hdd_sap_data); |
| 8405 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_DATA, |
| 8406 | hdd_ctx->config->qdf_trace_enable_hdd_data); |
Naveen Rawat | 7df3186 | 2017-03-01 17:09:30 -0800 | [diff] [blame] | 8407 | hdd_qdf_trace_enable(QDF_MODULE_ID_WIFIPOS, |
| 8408 | hdd_ctx->config->qdf_trace_enable_wifi_pos); |
Naveen Rawat | f2b0dbd | 2017-03-27 10:00:15 -0700 | [diff] [blame] | 8409 | hdd_qdf_trace_enable(QDF_MODULE_ID_NAN, |
| 8410 | hdd_ctx->config->qdf_trace_enable_nan); |
Kiran Kumar Lokere | 798de7e | 2017-03-30 14:01:12 -0700 | [diff] [blame] | 8411 | hdd_qdf_trace_enable(QDF_MODULE_ID_REGULATORY, |
| 8412 | hdd_ctx->config->qdf_trace_enable_regulatory); |
| 8413 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8414 | hdd_cfg_print(hdd_ctx); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8415 | } |
| 8416 | |
| 8417 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8418 | * hdd_context_init() - Initialize HDD context |
| 8419 | * @hdd_ctx: HDD context. |
| 8420 | * |
| 8421 | * Initialize HDD context along with all the feature specific contexts. |
| 8422 | * |
| 8423 | * return: 0 on success and errno on failure. |
| 8424 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8425 | static int hdd_context_init(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8426 | { |
| 8427 | int ret; |
| 8428 | |
| 8429 | hdd_ctx->ioctl_scan_mode = eSIR_ACTIVE_SCAN; |
| 8430 | hdd_ctx->max_intf_count = CSR_ROAM_SESSION_MAX; |
| 8431 | |
| 8432 | hdd_init_ll_stats_ctx(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 8433 | hdd_init_nud_stats_ctx(hdd_ctx); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8434 | |
| 8435 | init_completion(&hdd_ctx->mc_sus_event_var); |
| 8436 | init_completion(&hdd_ctx->ready_to_suspend); |
| 8437 | |
| 8438 | qdf_spinlock_create(&hdd_ctx->connection_status_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 8439 | qdf_spinlock_create(&hdd_ctx->sta_update_info_lock); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8440 | qdf_spinlock_create(&hdd_ctx->hdd_adapter_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 8441 | |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 8442 | qdf_list_create(&hdd_ctx->hdd_adapters, MAX_NUMBER_OF_ADAPTERS); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8443 | |
| 8444 | init_completion(&hdd_ctx->set_antenna_mode_cmpl); |
| 8445 | |
| 8446 | ret = hdd_scan_context_init(hdd_ctx); |
| 8447 | if (ret) |
| 8448 | goto list_destroy; |
| 8449 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8450 | hdd_rx_wake_lock_create(hdd_ctx); |
| 8451 | |
| 8452 | ret = hdd_sap_context_init(hdd_ctx); |
| 8453 | if (ret) |
| 8454 | goto scan_destroy; |
| 8455 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8456 | wlan_hdd_cfg80211_extscan_init(hdd_ctx); |
| 8457 | |
| 8458 | hdd_init_offloaded_packets_ctx(hdd_ctx); |
| 8459 | |
| 8460 | ret = wlan_hdd_cfg80211_init(hdd_ctx->parent_dev, hdd_ctx->wiphy, |
| 8461 | hdd_ctx->config); |
| 8462 | if (ret) |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 8463 | goto sap_destroy; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8464 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 8465 | qdf_wake_lock_create(&hdd_ctx->monitor_mode_wakelock, |
| 8466 | "monitor_mode_wakelock"); |
| 8467 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8468 | return 0; |
| 8469 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8470 | sap_destroy: |
| 8471 | hdd_sap_context_destroy(hdd_ctx); |
| 8472 | |
| 8473 | scan_destroy: |
| 8474 | hdd_scan_context_destroy(hdd_ctx); |
| 8475 | hdd_rx_wake_lock_destroy(hdd_ctx); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8476 | list_destroy: |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 8477 | qdf_list_destroy(&hdd_ctx->hdd_adapters); |
Sandeep Puligilla | d000421 | 2017-02-26 18:34:56 -0800 | [diff] [blame] | 8478 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8479 | return ret; |
| 8480 | } |
| 8481 | |
| 8482 | /** |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 8483 | * ie_whitelist_attrs_init() - initialize ie whitelisting attributes |
| 8484 | * @hdd_ctx: pointer to hdd context |
| 8485 | * |
| 8486 | * Return: status of initialization |
| 8487 | * 0 - success |
| 8488 | * negative value - failure |
| 8489 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8490 | static int ie_whitelist_attrs_init(struct hdd_context *hdd_ctx) |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 8491 | { |
| 8492 | int ret; |
| 8493 | |
| 8494 | if (!hdd_ctx->config->probe_req_ie_whitelist) |
| 8495 | return 0; |
| 8496 | |
| 8497 | if (!hdd_validate_prb_req_ie_bitmap(hdd_ctx)) { |
| 8498 | hdd_err("invalid ie bitmap and ouis: disable ie whitelisting"); |
| 8499 | hdd_ctx->config->probe_req_ie_whitelist = false; |
| 8500 | return -EINVAL; |
| 8501 | } |
| 8502 | |
| 8503 | /* parse ini string probe req oui */ |
| 8504 | ret = hdd_parse_probe_req_ouis(hdd_ctx); |
| 8505 | if (ret) { |
| 8506 | hdd_err("parsing error: disable ie whitelisting"); |
| 8507 | hdd_ctx->config->probe_req_ie_whitelist = false; |
| 8508 | } |
| 8509 | |
| 8510 | return ret; |
| 8511 | } |
| 8512 | |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8513 | /** |
| 8514 | * hdd_iface_change_callback() - Function invoked when stop modules expires |
| 8515 | * @priv: pointer to hdd context |
| 8516 | * |
| 8517 | * This function is invoked when the timer waiting for the interface change |
| 8518 | * expires, it shall cut-down the power to wlan and stop all the modules. |
| 8519 | * |
| 8520 | * Return: void |
| 8521 | */ |
| 8522 | static void hdd_iface_change_callback(void *priv) |
| 8523 | { |
| 8524 | struct hdd_context *hdd_ctx = (struct hdd_context *) priv; |
| 8525 | int ret; |
| 8526 | int status = wlan_hdd_validate_context(hdd_ctx); |
| 8527 | |
| 8528 | if (status) |
| 8529 | return; |
| 8530 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 8531 | hdd_enter(); |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8532 | hdd_debug("Interface change timer expired close the modules!"); |
| 8533 | ret = hdd_wlan_stop_modules(hdd_ctx, false); |
| 8534 | if (ret) |
| 8535 | hdd_err("Failed to stop modules"); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 8536 | hdd_exit(); |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8537 | } |
| 8538 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 8539 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 8540 | static void hdd_set_wlan_logging(struct hdd_context *hdd_ctx) |
| 8541 | { |
| 8542 | wlan_logging_set_log_to_console(hdd_ctx->config-> |
| 8543 | wlan_logging_to_console); |
| 8544 | wlan_logging_set_active(hdd_ctx->config->wlan_logging_enable); |
| 8545 | } |
| 8546 | #else |
| 8547 | static void hdd_set_wlan_logging(struct hdd_context *hdd_ctx) |
| 8548 | { } |
| 8549 | #endif |
| 8550 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 8551 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8552 | * hdd_context_create() - Allocate and inialize HDD context. |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8553 | * @dev: Device Pointer to the underlying device |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8554 | * |
| 8555 | * Allocate and initialize HDD context. HDD context is allocated as part of |
| 8556 | * wiphy allocation and then context is initialized. |
| 8557 | * |
| 8558 | * Return: HDD context on success and ERR_PTR on failure |
| 8559 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8560 | static struct hdd_context *hdd_context_create(struct device *dev) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8561 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8562 | QDF_STATUS status; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8563 | int ret = 0; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8564 | struct hdd_context *hdd_ctx; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8565 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 8566 | hdd_enter(); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8567 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8568 | hdd_ctx = hdd_cfg80211_wiphy_alloc(sizeof(struct hdd_context)); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8569 | if (hdd_ctx == NULL) { |
| 8570 | ret = -ENOMEM; |
| 8571 | goto err_out; |
| 8572 | } |
| 8573 | |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 8574 | qdf_create_delayed_work(&hdd_ctx->iface_idle_work, |
| 8575 | hdd_iface_change_callback, |
| 8576 | (void *)hdd_ctx); |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8577 | |
| 8578 | mutex_init(&hdd_ctx->iface_change_lock); |
| 8579 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8580 | hdd_ctx->parent_dev = dev; |
Sreelakshmi Konamki | b53c629 | 2017-03-01 13:13:23 +0530 | [diff] [blame] | 8581 | hdd_ctx->last_scan_reject_session_id = 0xFF; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8582 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 8583 | hdd_ctx->config = qdf_mem_malloc(sizeof(struct hdd_config)); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8584 | if (hdd_ctx->config == NULL) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8585 | hdd_err("Failed to alloc memory for HDD config!"); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8586 | ret = -ENOMEM; |
| 8587 | goto err_free_hdd_context; |
| 8588 | } |
| 8589 | |
| 8590 | /* Read and parse the qcom_cfg.ini file */ |
| 8591 | status = hdd_parse_config_ini(hdd_ctx); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8592 | if (QDF_STATUS_SUCCESS != status) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8593 | hdd_err("Error (status: %d) parsing INI file: %s", status, |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8594 | WLAN_INI_FILE); |
| 8595 | ret = -EINVAL; |
| 8596 | goto err_free_config; |
| 8597 | } |
| 8598 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 8599 | ie_whitelist_attrs_init(hdd_ctx); |
| 8600 | |
Dustin Brown | 7f93993 | 2017-05-18 15:02:17 -0700 | [diff] [blame] | 8601 | hdd_debug("setting timer multiplier: %u", |
| 8602 | hdd_ctx->config->timer_multiplier); |
| 8603 | qdf_timer_set_multiplier(hdd_ctx->config->timer_multiplier); |
| 8604 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8605 | |
Sravan Kumar Kairam | fece87f | 2016-07-26 14:58:28 +0530 | [diff] [blame] | 8606 | if (hdd_ctx->config->fhostNSOffload) |
| 8607 | hdd_ctx->ns_offload_enable = true; |
| 8608 | |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 8609 | cds_set_fatal_event(hdd_ctx->config->enable_fatal_event); |
| 8610 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8611 | hdd_override_ini_config(hdd_ctx); |
| 8612 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8613 | ret = hdd_context_init(hdd_ctx); |
| 8614 | |
| 8615 | if (ret) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8616 | goto err_free_config; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8617 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8618 | /* Uses to enabled logging after SSR */ |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 8619 | hdd_ctx->fw_log_settings.enable = hdd_ctx->config->enable_fw_log; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8620 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8621 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8622 | goto skip_multicast_logging; |
| 8623 | |
| 8624 | cds_set_multicast_logging(hdd_ctx->config->multicast_host_fw_msgs); |
| 8625 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 8626 | ret = wlan_hdd_init_tx_rx_histogram(hdd_ctx); |
| 8627 | if (ret) |
| 8628 | goto err_deinit_hdd_context; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8629 | |
Houston Hoffman | b18dc6e | 2017-08-11 17:43:07 -0700 | [diff] [blame] | 8630 | ret = hdd_init_netlink_services(hdd_ctx); |
| 8631 | if (ret) |
| 8632 | goto err_deinit_txrx_histogram; |
| 8633 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 8634 | hdd_set_wlan_logging(hdd_ctx); |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8635 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8636 | skip_multicast_logging: |
| 8637 | hdd_set_trace_level_for_each(hdd_ctx); |
| 8638 | |
Rajeev Kumar | 493a31b | 2017-09-29 14:01:24 -0700 | [diff] [blame] | 8639 | cds_set_context(QDF_MODULE_ID_HDD, hdd_ctx); |
| 8640 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 8641 | hdd_exit(); |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 8642 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8643 | return hdd_ctx; |
| 8644 | |
Houston Hoffman | b18dc6e | 2017-08-11 17:43:07 -0700 | [diff] [blame] | 8645 | err_deinit_txrx_histogram: |
| 8646 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 8647 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 8648 | err_deinit_hdd_context: |
| 8649 | hdd_context_deinit(hdd_ctx); |
| 8650 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8651 | err_free_config: |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 8652 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8653 | |
| 8654 | err_free_hdd_context: |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8655 | mutex_destroy(&hdd_ctx->iface_change_lock); |
Rajeev Kumar | fa55a69 | 2018-01-09 14:12:41 -0800 | [diff] [blame] | 8656 | wiphy_free(hdd_ctx->wiphy); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8657 | |
| 8658 | err_out: |
| 8659 | return ERR_PTR(ret); |
| 8660 | } |
| 8661 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8662 | #ifdef WLAN_OPEN_P2P_INTERFACE |
| 8663 | /** |
| 8664 | * hdd_open_p2p_interface - Open P2P interface |
| 8665 | * @hdd_ctx: HDD context |
| 8666 | * @rtnl_held: True if RTNL lock held |
| 8667 | * |
| 8668 | * Open P2P interface during probe. This function called to open the P2P |
| 8669 | * interface at probe along with STA interface. |
| 8670 | * |
| 8671 | * Return: 0 on success and errno on failure |
| 8672 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8673 | 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] | 8674 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8675 | struct hdd_adapter *adapter; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8676 | uint8_t *p2p_dev_addr; |
| 8677 | |
| 8678 | if (hdd_ctx->config->isP2pDeviceAddrAdministrated && |
| 8679 | !(hdd_ctx->config->intfMacAddr[0].bytes[0] & 0x02)) { |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 8680 | qdf_mem_copy(hdd_ctx->p2p_device_address.bytes, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8681 | hdd_ctx->config->intfMacAddr[0].bytes, |
| 8682 | sizeof(tSirMacAddr)); |
| 8683 | |
| 8684 | /* |
| 8685 | * Generate the P2P Device Address. This consists of |
| 8686 | * the device's primary MAC address with the locally |
| 8687 | * administered bit set. |
| 8688 | */ |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 8689 | hdd_ctx->p2p_device_address.bytes[0] |= 0x02; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8690 | } else { |
| 8691 | p2p_dev_addr = wlan_hdd_get_intf_addr(hdd_ctx); |
| 8692 | if (p2p_dev_addr == NULL) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8693 | hdd_err("Failed to allocate mac_address for p2p_device"); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8694 | return -ENOSPC; |
| 8695 | } |
| 8696 | |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 8697 | qdf_mem_copy(&hdd_ctx->p2p_device_address.bytes[0], |
| 8698 | p2p_dev_addr, QDF_MAC_ADDR_SIZE); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8699 | } |
| 8700 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 8701 | adapter = hdd_open_adapter(hdd_ctx, QDF_P2P_DEVICE_MODE, "p2p%d", |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 8702 | &hdd_ctx->p2p_device_address.bytes[0], |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 8703 | NET_NAME_UNKNOWN, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8704 | |
| 8705 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8706 | hdd_err("Failed to do hdd_open_adapter for P2P Device Interface"); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8707 | return -ENOSPC; |
| 8708 | } |
| 8709 | |
| 8710 | return 0; |
| 8711 | } |
| 8712 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8713 | static inline int hdd_open_p2p_interface(struct hdd_context *hdd_ctx, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8714 | bool rtnl_held) |
| 8715 | { |
| 8716 | return 0; |
| 8717 | } |
| 8718 | #endif |
| 8719 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8720 | 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] | 8721 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8722 | struct hdd_adapter *adapter; |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8723 | int ret = 0; |
| 8724 | |
| 8725 | adapter = hdd_open_adapter(hdd_ctx, QDF_OCB_MODE, "wlanocb%d", |
| 8726 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 8727 | NET_NAME_UNKNOWN, rtnl_held); |
| 8728 | if (adapter == NULL) { |
| 8729 | hdd_err("Failed to open 802.11p interface"); |
| 8730 | ret = -ENOSPC; |
| 8731 | } |
| 8732 | |
| 8733 | return ret; |
| 8734 | } |
| 8735 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8736 | /** |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8737 | * hdd_start_station_adapter()- Start the Station Adapter |
| 8738 | * @adapter: HDD adapter |
| 8739 | * |
| 8740 | * This function initializes the adapter for the station mode. |
| 8741 | * |
| 8742 | * Return: 0 on success or errno on failure. |
| 8743 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8744 | int hdd_start_station_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8745 | { |
| 8746 | QDF_STATUS status; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8747 | int ret; |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8748 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 8749 | hdd_enter_dev(adapter->dev); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8750 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 8751 | hdd_err("session is already opened, %d", |
| 8752 | adapter->session_id); |
| 8753 | return qdf_status_to_os_return(QDF_STATUS_SUCCESS); |
| 8754 | } |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8755 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8756 | ret = hdd_vdev_create(adapter, hdd_sme_roam_callback, adapter); |
| 8757 | if (ret) { |
| 8758 | hdd_err("failed to create vdev: %d", ret); |
| 8759 | return ret; |
| 8760 | } |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8761 | status = hdd_init_station_mode(adapter); |
| 8762 | |
| 8763 | if (QDF_STATUS_SUCCESS != status) { |
| 8764 | hdd_err("Error Initializing station mode: %d", status); |
| 8765 | return qdf_status_to_os_return(status); |
| 8766 | } |
| 8767 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8768 | hdd_register_tx_flow_control(adapter, |
| 8769 | hdd_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 8770 | hdd_tx_resume_cb, |
| 8771 | hdd_tx_flow_control_is_pause); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8772 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 8773 | hdd_exit(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8774 | return 0; |
| 8775 | } |
| 8776 | |
| 8777 | /** |
| 8778 | * hdd_start_ap_adapter()- Start AP Adapter |
| 8779 | * @adapter: HDD adapter |
| 8780 | * |
| 8781 | * This function initializes the adapter for the AP mode. |
| 8782 | * |
| 8783 | * Return: 0 on success errno on failure. |
| 8784 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8785 | int hdd_start_ap_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8786 | { |
| 8787 | QDF_STATUS status; |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 8788 | bool is_ssr = false; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8789 | int ret; |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 8790 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8791 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 8792 | hdd_enter(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8793 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8794 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 8795 | hdd_err("session is already opened, %d", |
| 8796 | adapter->session_id); |
| 8797 | return qdf_status_to_os_return(QDF_STATUS_SUCCESS); |
| 8798 | } |
| 8799 | /* |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 8800 | * In SSR case no need to create new sap context. |
| 8801 | * Otherwise create sap context first and then create |
| 8802 | * vdev as while creating the vdev, driver needs to |
| 8803 | * register SAP callback and that callback uses sap context |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8804 | */ |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 8805 | if (adapter->session.ap.sap_context) { |
| 8806 | is_ssr = true; |
| 8807 | } else if (!hdd_sap_create_ctx(adapter)) { |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8808 | hdd_err("sap creation failed"); |
| 8809 | return qdf_status_to_os_return(QDF_STATUS_E_FAILURE); |
| 8810 | } |
| 8811 | |
| 8812 | ret = hdd_vdev_create(adapter, wlansap_roam_callback, |
| 8813 | adapter->session.ap.sap_context); |
| 8814 | if (ret) { |
| 8815 | hdd_err("failed to create vdev, status:%d", ret); |
| 8816 | hdd_sap_destroy_ctx(adapter); |
| 8817 | return ret; |
| 8818 | } |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 8819 | |
| 8820 | if (adapter->device_mode == QDF_SAP_MODE) |
| 8821 | sme_cli_set_command(adapter->session_id, |
| 8822 | WMI_VDEV_PARAM_ENABLE_DISABLE_RTT_RESPONDER_ROLE, |
| 8823 | (bool)(hdd_ctx->config->fine_time_meas_cap & |
| 8824 | WMI_FW_AP_RTT_RESPR), |
| 8825 | VDEV_CMD); |
| 8826 | |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 8827 | status = hdd_init_ap_mode(adapter, is_ssr); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8828 | |
| 8829 | if (QDF_STATUS_SUCCESS != status) { |
| 8830 | hdd_err("Error Initializing the AP mode: %d", status); |
| 8831 | return qdf_status_to_os_return(status); |
| 8832 | } |
| 8833 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8834 | hdd_register_tx_flow_control(adapter, |
| 8835 | hdd_softap_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 8836 | hdd_softap_tx_resume_cb, |
| 8837 | hdd_tx_flow_control_is_pause); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8838 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 8839 | hdd_exit(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8840 | return 0; |
| 8841 | } |
| 8842 | |
Sourav Mohapatra | 57006c7 | 2017-11-19 16:15:55 +0530 | [diff] [blame] | 8843 | static int hdd_open_concurrent_interface(struct hdd_context *hdd_ctx, |
| 8844 | bool rtnl_held) |
| 8845 | { |
| 8846 | struct hdd_adapter *adapter; |
| 8847 | |
| 8848 | adapter = hdd_open_adapter(hdd_ctx, QDF_STA_MODE, |
| 8849 | hdd_ctx->config->enableConcurrentSTA, |
| 8850 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 8851 | NET_NAME_UNKNOWN, rtnl_held); |
| 8852 | |
| 8853 | if (!adapter) |
| 8854 | return -ENOSPC; |
| 8855 | |
| 8856 | return 0; |
| 8857 | } |
| 8858 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8859 | /** |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8860 | * hdd_open_interfaces - Open all required interfaces |
| 8861 | * hdd_ctx: HDD context |
| 8862 | * rtnl_held: True if RTNL lock is held |
| 8863 | * |
| 8864 | * Open all the interfaces like STA, P2P and OCB based on the configuration. |
| 8865 | * |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8866 | * Return: 0 if all interfaces were created, otherwise negative errno |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8867 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8868 | 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] | 8869 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8870 | struct hdd_adapter *adapter; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8871 | int ret; |
| 8872 | |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 8873 | /* open monitor mode adapter if con_mode is monitor mode */ |
Lin Bai | 1c67848 | 2017-12-18 18:29:11 +0800 | [diff] [blame] | 8874 | if (con_mode == QDF_GLOBAL_MONITOR_MODE || |
| 8875 | con_mode == QDF_GLOBAL_FTM_MODE) { |
| 8876 | uint8_t session_type = (con_mode == QDF_GLOBAL_MONITOR_MODE) ? |
| 8877 | QDF_MONITOR_MODE : QDF_FTM_MODE; |
| 8878 | |
| 8879 | adapter = hdd_open_adapter(hdd_ctx, session_type, "wlan%d", |
| 8880 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 8881 | NET_NAME_UNKNOWN, rtnl_held); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 8882 | if (!adapter) { |
| 8883 | hdd_err("open adapter failed"); |
| 8884 | return -ENOSPC; |
| 8885 | } |
Lin Bai | 1c67848 | 2017-12-18 18:29:11 +0800 | [diff] [blame] | 8886 | |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 8887 | return 0; |
| 8888 | } |
| 8889 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8890 | if (hdd_ctx->config->dot11p_mode == WLAN_HDD_11P_STANDALONE) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8891 | /* Create only 802.11p interface */ |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8892 | return hdd_open_ocb_interface(hdd_ctx, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8893 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 8894 | adapter = hdd_open_adapter(hdd_ctx, QDF_STA_MODE, "wlan%d", |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8895 | wlan_hdd_get_intf_addr(hdd_ctx), |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 8896 | NET_NAME_UNKNOWN, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8897 | |
| 8898 | if (adapter == NULL) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8899 | return -ENOSPC; |
| 8900 | |
Sourav Mohapatra | 57006c7 | 2017-11-19 16:15:55 +0530 | [diff] [blame] | 8901 | if (strlen(hdd_ctx->config->enableConcurrentSTA) != 0) { |
| 8902 | ret = hdd_open_concurrent_interface(hdd_ctx, rtnl_held); |
| 8903 | if (ret) |
| 8904 | hdd_err("Cannot create concurrent STA interface"); |
| 8905 | } |
| 8906 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8907 | ret = hdd_open_p2p_interface(hdd_ctx, rtnl_held); |
| 8908 | if (ret) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8909 | goto err_close_adapters; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8910 | |
| 8911 | /* Open 802.11p Interface */ |
| 8912 | if (hdd_ctx->config->dot11p_mode == WLAN_HDD_11P_CONCURRENT) { |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8913 | ret = hdd_open_ocb_interface(hdd_ctx, rtnl_held); |
| 8914 | if (ret) |
| 8915 | goto err_close_adapters; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8916 | } |
| 8917 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8918 | return 0; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8919 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8920 | err_close_adapters: |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8921 | hdd_close_all_adapters(hdd_ctx, rtnl_held); |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8922 | return ret; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8923 | } |
| 8924 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8925 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8926 | #ifdef QCA_LL_TX_FLOW_CONTROL_V2 |
| 8927 | /** |
| 8928 | * hdd_txrx_populate_cds_config() - Populate txrx cds configuration |
| 8929 | * @cds_cfg: CDS Configuration |
| 8930 | * @hdd_ctx: Pointer to hdd context |
| 8931 | * |
| 8932 | * Return: none |
| 8933 | */ |
| 8934 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 8935 | *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8936 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8937 | { |
| 8938 | cds_cfg->tx_flow_stop_queue_th = |
| 8939 | hdd_ctx->config->TxFlowStopQueueThreshold; |
| 8940 | cds_cfg->tx_flow_start_queue_offset = |
| 8941 | hdd_ctx->config->TxFlowStartQueueOffset; |
| 8942 | } |
| 8943 | #else |
| 8944 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 8945 | *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8946 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8947 | { |
| 8948 | } |
| 8949 | #endif |
| 8950 | |
| 8951 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 8952 | /** |
| 8953 | * hdd_ra_populate_cds_config() - Populate RA filtering cds configuration |
| 8954 | * @cds_cfg: CDS Configuration |
| 8955 | * @hdd_ctx: Pointer to hdd context |
| 8956 | * |
| 8957 | * Return: none |
| 8958 | */ |
Anand Kumar | 3b92a91 | 2016-12-05 12:01:26 +0530 | [diff] [blame] | 8959 | 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] | 8960 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8961 | { |
| 8962 | cds_cfg->ra_ratelimit_interval = |
| 8963 | hdd_ctx->config->RArateLimitInterval; |
| 8964 | cds_cfg->is_ra_ratelimit_enabled = |
| 8965 | hdd_ctx->config->IsRArateLimitEnabled; |
| 8966 | } |
| 8967 | #else |
Anand Kumar | 3b92a91 | 2016-12-05 12:01:26 +0530 | [diff] [blame] | 8968 | 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] | 8969 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8970 | { |
| 8971 | } |
| 8972 | #endif |
| 8973 | |
| 8974 | /** |
| 8975 | * hdd_update_cds_config() - API to update cds configuration parameters |
| 8976 | * @hdd_ctx: HDD Context |
| 8977 | * |
| 8978 | * Return: 0 for Success, errno on failure |
| 8979 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8980 | static int hdd_update_cds_config(struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8981 | { |
| 8982 | struct cds_config_info *cds_cfg; |
| 8983 | |
| 8984 | cds_cfg = (struct cds_config_info *)qdf_mem_malloc(sizeof(*cds_cfg)); |
| 8985 | if (!cds_cfg) { |
| 8986 | hdd_err("failed to allocate cds config"); |
| 8987 | return -ENOMEM; |
| 8988 | } |
| 8989 | |
Srinivas Girigowda | 35b0031 | 2017-06-27 21:52:03 -0700 | [diff] [blame] | 8990 | cds_cfg->driver_type = QDF_DRIVER_TYPE_PRODUCTION; |
Kiran Kumar Lokere | 7006e0a | 2017-03-07 19:28:36 -0800 | [diff] [blame] | 8991 | if (!hdd_ctx->config->nMaxPsPoll || |
| 8992 | !hdd_ctx->config->enablePowersaveOffload) { |
| 8993 | cds_cfg->powersave_offload_enabled = |
| 8994 | hdd_ctx->config->enablePowersaveOffload; |
| 8995 | } else { |
| 8996 | if ((hdd_ctx->config->enablePowersaveOffload == |
| 8997 | PS_QPOWER_NODEEPSLEEP) || |
| 8998 | (hdd_ctx->config->enablePowersaveOffload == |
| 8999 | PS_LEGACY_NODEEPSLEEP)) |
| 9000 | cds_cfg->powersave_offload_enabled = |
| 9001 | PS_LEGACY_NODEEPSLEEP; |
| 9002 | else |
| 9003 | cds_cfg->powersave_offload_enabled = |
| 9004 | PS_LEGACY_DEEPSLEEP; |
| 9005 | hdd_info("Qpower disabled in cds config, %d", |
| 9006 | cds_cfg->powersave_offload_enabled); |
| 9007 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9008 | cds_cfg->sta_dynamic_dtim = hdd_ctx->config->enableDynamicDTIM; |
| 9009 | cds_cfg->sta_mod_dtim = hdd_ctx->config->enableModulatedDTIM; |
| 9010 | cds_cfg->sta_maxlimod_dtim = hdd_ctx->config->fMaxLIModulatedDTIM; |
| 9011 | cds_cfg->wow_enable = hdd_ctx->config->wowEnable; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9012 | |
| 9013 | /* |
| 9014 | * Copy the DFS Phyerr Filtering Offload status. |
| 9015 | * This parameter reflects the value of the |
| 9016 | * dfs_phyerr_filter_offload flag as set in the ini. |
| 9017 | */ |
| 9018 | cds_cfg->dfs_phyerr_filter_offload = |
| 9019 | hdd_ctx->config->fDfsPhyerrFilterOffload; |
| 9020 | if (hdd_ctx->config->ssdp) |
| 9021 | cds_cfg->ssdp = hdd_ctx->config->ssdp; |
| 9022 | |
SaidiReddy Yenuga | cc733af | 2016-11-09 17:45:42 +0530 | [diff] [blame] | 9023 | cds_cfg->force_target_assert_enabled = |
| 9024 | hdd_ctx->config->crash_inject_enabled; |
| 9025 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9026 | cds_cfg->enable_mc_list = hdd_ctx->config->fEnableMCAddrList; |
| 9027 | cds_cfg->ap_maxoffload_peers = hdd_ctx->config->apMaxOffloadPeers; |
| 9028 | |
| 9029 | cds_cfg->ap_maxoffload_reorderbuffs = |
| 9030 | hdd_ctx->config->apMaxOffloadReorderBuffs; |
| 9031 | |
| 9032 | cds_cfg->ap_disable_intrabss_fwd = |
| 9033 | hdd_ctx->config->apDisableIntraBssFwd; |
| 9034 | |
| 9035 | cds_cfg->dfs_pri_multiplier = |
| 9036 | hdd_ctx->config->dfsRadarPriMultiplier; |
| 9037 | cds_cfg->reorder_offload = |
| 9038 | hdd_ctx->config->reorderOffloadSupport; |
| 9039 | |
| 9040 | /* IPA micro controller data path offload resource config item */ |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 9041 | cds_cfg->uc_offload_enabled = ucfg_ipa_uc_is_enabled(); |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9042 | if (!is_power_of_2(hdd_ctx->config->IpaUcTxBufCount)) { |
| 9043 | /* IpaUcTxBufCount should be power of 2 */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9044 | hdd_debug("Round down IpaUcTxBufCount %d to nearest power of 2", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9045 | hdd_ctx->config->IpaUcTxBufCount); |
| 9046 | hdd_ctx->config->IpaUcTxBufCount = |
| 9047 | rounddown_pow_of_two( |
| 9048 | hdd_ctx->config->IpaUcTxBufCount); |
| 9049 | if (!hdd_ctx->config->IpaUcTxBufCount) { |
| 9050 | hdd_err("Failed to round down IpaUcTxBufCount"); |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 9051 | goto exit; |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9052 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9053 | hdd_debug("IpaUcTxBufCount rounded down to %d", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9054 | hdd_ctx->config->IpaUcTxBufCount); |
| 9055 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9056 | cds_cfg->uc_txbuf_count = hdd_ctx->config->IpaUcTxBufCount; |
| 9057 | cds_cfg->uc_txbuf_size = hdd_ctx->config->IpaUcTxBufSize; |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9058 | if (!is_power_of_2(hdd_ctx->config->IpaUcRxIndRingCount)) { |
| 9059 | /* IpaUcRxIndRingCount should be power of 2 */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9060 | hdd_debug("Round down IpaUcRxIndRingCount %d to nearest power of 2", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9061 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 9062 | hdd_ctx->config->IpaUcRxIndRingCount = |
| 9063 | rounddown_pow_of_two( |
| 9064 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 9065 | if (!hdd_ctx->config->IpaUcRxIndRingCount) { |
| 9066 | hdd_err("Failed to round down IpaUcRxIndRingCount"); |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 9067 | goto exit; |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9068 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9069 | hdd_debug("IpaUcRxIndRingCount rounded down to %d", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9070 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 9071 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9072 | cds_cfg->uc_rxind_ringcount = |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9073 | hdd_ctx->config->IpaUcRxIndRingCount; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9074 | cds_cfg->uc_tx_partition_base = |
| 9075 | hdd_ctx->config->IpaUcTxPartitionBase; |
| 9076 | cds_cfg->max_scan = hdd_ctx->config->max_scan_count; |
| 9077 | |
| 9078 | cds_cfg->ip_tcp_udp_checksum_offload = |
| 9079 | hdd_ctx->config->enable_ip_tcp_udp_checksum_offload; |
Jeff Johnson | e2ba3cd | 2017-10-30 20:02:09 -0700 | [diff] [blame] | 9080 | cds_cfg->enable_rxthread = hdd_ctx->enable_rxthread; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9081 | cds_cfg->ce_classify_enabled = |
| 9082 | hdd_ctx->config->ce_classify_enabled; |
Dustin Brown | d3fc9ee | 2016-09-14 13:57:27 -0700 | [diff] [blame] | 9083 | cds_cfg->bpf_packet_filter_enable = |
| 9084 | hdd_ctx->config->bpf_packet_filter_enable; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9085 | cds_cfg->tx_chain_mask_cck = hdd_ctx->config->tx_chain_mask_cck; |
| 9086 | cds_cfg->self_gen_frm_pwr = hdd_ctx->config->self_gen_frm_pwr; |
| 9087 | cds_cfg->max_station = hdd_ctx->config->maxNumberOfPeers; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 9088 | cds_cfg->sub_20_channel_width = WLAN_SUB_20_CH_WIDTH_NONE; |
Manjunathappa Prakash | fff753c | 2016-09-01 19:34:56 -0700 | [diff] [blame] | 9089 | cds_cfg->flow_steering_enabled = hdd_ctx->config->flow_steering_enable; |
Orhan K AKYILDIZ | 30e8cbc | 2017-08-11 18:00:28 -0700 | [diff] [blame] | 9090 | cds_cfg->max_msdus_per_rxinorderind = |
| 9091 | hdd_ctx->config->max_msdus_per_rxinorderind; |
Naveen Rawat | 91df30a | 2016-10-12 21:26:18 -0700 | [diff] [blame] | 9092 | cds_cfg->self_recovery_enabled = hdd_ctx->config->enableSelfRecovery; |
Sandeep Puligilla | afa5289 | 2016-10-26 19:03:16 -0700 | [diff] [blame] | 9093 | cds_cfg->fw_timeout_crash = hdd_ctx->config->fw_timeout_crash; |
Hanumanth Reddy Pothula | e87621b | 2017-04-12 20:53:35 +0530 | [diff] [blame] | 9094 | cds_cfg->active_uc_bpf_mode = hdd_ctx->config->active_uc_bpf_mode; |
| 9095 | 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] | 9096 | cds_cfg->auto_power_save_fail_mode = |
| 9097 | hdd_ctx->config->auto_pwr_save_fail_mode; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9098 | |
Ashish Kumar Dhanotiya | 9335d81 | 2017-06-30 16:57:20 +0530 | [diff] [blame] | 9099 | cds_cfg->ito_repeat_count = hdd_ctx->config->ito_repeat_count; |
Sandeep Puligilla | 819d94f | 2017-10-10 18:33:56 -0700 | [diff] [blame] | 9100 | cds_cfg->bandcapability = hdd_ctx->config->nBandCapability; |
Zhu Jianmin | a2f8e8d | 2018-02-11 16:37:10 +0800 | [diff] [blame] | 9101 | cds_cfg->delay_before_vdev_stop = |
| 9102 | hdd_ctx->config->delay_before_vdev_stop; |
Ashish Kumar Dhanotiya | 9335d81 | 2017-06-30 16:57:20 +0530 | [diff] [blame] | 9103 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9104 | hdd_ra_populate_cds_config(cds_cfg, hdd_ctx); |
| 9105 | hdd_txrx_populate_cds_config(cds_cfg, hdd_ctx); |
| 9106 | hdd_nan_populate_cds_config(cds_cfg, hdd_ctx); |
Jeff Johnson | 9078bdc | 2016-09-23 17:18:11 -0700 | [diff] [blame] | 9107 | hdd_lpass_populate_cds_config(cds_cfg, hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9108 | cds_init_ini_config(cds_cfg); |
| 9109 | return 0; |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 9110 | |
| 9111 | exit: |
| 9112 | qdf_mem_free(cds_cfg); |
| 9113 | return -EINVAL; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9114 | } |
| 9115 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9116 | /** |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9117 | * hdd_update_user_config() - API to update user configuration |
| 9118 | * parameters to obj mgr which are used by multiple components |
| 9119 | * @hdd_ctx: HDD Context |
| 9120 | * |
| 9121 | * Return: 0 for Success, errno on failure |
| 9122 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9123 | static int hdd_update_user_config(struct hdd_context *hdd_ctx) |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9124 | { |
| 9125 | struct wlan_objmgr_psoc_user_config *user_config; |
| 9126 | |
| 9127 | user_config = qdf_mem_malloc(sizeof(*user_config)); |
| 9128 | if (user_config == NULL) { |
| 9129 | hdd_alert("Failed to alloc memory for user_config!"); |
| 9130 | return -ENOMEM; |
| 9131 | } |
| 9132 | |
| 9133 | user_config->dot11_mode = hdd_ctx->config->dot11Mode; |
| 9134 | user_config->dual_mac_feature_disable = |
| 9135 | hdd_ctx->config->dual_mac_feature_disable; |
| 9136 | user_config->indoor_channel_support = |
| 9137 | hdd_ctx->config->indoor_channel_support; |
| 9138 | user_config->is_11d_support_enabled = |
| 9139 | hdd_ctx->config->Is11dSupportEnabled; |
| 9140 | user_config->is_11h_support_enabled = |
| 9141 | hdd_ctx->config->Is11hSupportEnabled; |
| 9142 | user_config->optimize_chan_avoid_event = |
| 9143 | hdd_ctx->config->goptimize_chan_avoid_event; |
| 9144 | user_config->skip_dfs_chnl_in_p2p_search = |
| 9145 | hdd_ctx->config->skipDfsChnlInP2pSearch; |
Naveen Rawat | 222b2e9 | 2017-03-16 09:52:21 -0700 | [diff] [blame] | 9146 | user_config->band_capability = hdd_ctx->config->nBandCapability; |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9147 | wlan_objmgr_psoc_set_user_config(hdd_ctx->hdd_psoc, user_config); |
| 9148 | |
| 9149 | qdf_mem_free(user_config); |
| 9150 | return 0; |
| 9151 | } |
| 9152 | |
| 9153 | /** |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9154 | * hdd_init_thermal_info - Initialize thermal level |
| 9155 | * @hdd_ctx: HDD context |
| 9156 | * |
| 9157 | * Initialize thermal level at SME layer and set the thermal level callback |
| 9158 | * which would be called when a configured thermal threshold is hit. |
| 9159 | * |
| 9160 | * Return: 0 on success and errno on failure |
| 9161 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9162 | static int hdd_init_thermal_info(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9163 | { |
| 9164 | tSmeThermalParams thermal_param; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9165 | QDF_STATUS status; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9166 | |
| 9167 | thermal_param.smeThermalMgmtEnabled = |
| 9168 | hdd_ctx->config->thermalMitigationEnable; |
| 9169 | thermal_param.smeThrottlePeriod = hdd_ctx->config->throttlePeriod; |
| 9170 | |
Poddar, Siddarth | 8390502 | 2016-04-16 17:56:08 -0700 | [diff] [blame] | 9171 | thermal_param.sme_throttle_duty_cycle_tbl[0] = |
| 9172 | hdd_ctx->config->throttle_dutycycle_level0; |
| 9173 | thermal_param.sme_throttle_duty_cycle_tbl[1] = |
| 9174 | hdd_ctx->config->throttle_dutycycle_level1; |
| 9175 | thermal_param.sme_throttle_duty_cycle_tbl[2] = |
| 9176 | hdd_ctx->config->throttle_dutycycle_level2; |
| 9177 | thermal_param.sme_throttle_duty_cycle_tbl[3] = |
| 9178 | hdd_ctx->config->throttle_dutycycle_level3; |
| 9179 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9180 | thermal_param.smeThermalLevels[0].smeMinTempThreshold = |
| 9181 | hdd_ctx->config->thermalTempMinLevel0; |
| 9182 | thermal_param.smeThermalLevels[0].smeMaxTempThreshold = |
| 9183 | hdd_ctx->config->thermalTempMaxLevel0; |
| 9184 | thermal_param.smeThermalLevels[1].smeMinTempThreshold = |
| 9185 | hdd_ctx->config->thermalTempMinLevel1; |
| 9186 | thermal_param.smeThermalLevels[1].smeMaxTempThreshold = |
| 9187 | hdd_ctx->config->thermalTempMaxLevel1; |
| 9188 | thermal_param.smeThermalLevels[2].smeMinTempThreshold = |
| 9189 | hdd_ctx->config->thermalTempMinLevel2; |
| 9190 | thermal_param.smeThermalLevels[2].smeMaxTempThreshold = |
| 9191 | hdd_ctx->config->thermalTempMaxLevel2; |
| 9192 | thermal_param.smeThermalLevels[3].smeMinTempThreshold = |
| 9193 | hdd_ctx->config->thermalTempMinLevel3; |
| 9194 | thermal_param.smeThermalLevels[3].smeMaxTempThreshold = |
| 9195 | hdd_ctx->config->thermalTempMaxLevel3; |
| 9196 | |
| 9197 | status = sme_init_thermal_info(hdd_ctx->hHal, thermal_param); |
| 9198 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9199 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 9200 | return qdf_status_to_os_return(status); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9201 | |
| 9202 | sme_add_set_thermal_level_callback(hdd_ctx->hHal, |
| 9203 | hdd_set_thermal_level_cb); |
| 9204 | |
| 9205 | return 0; |
| 9206 | |
| 9207 | } |
| 9208 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9209 | #if defined(CONFIG_HDD_INIT_WITH_RTNL_LOCK) |
| 9210 | /** |
| 9211 | * hdd_hold_rtnl_lock - Hold RTNL lock |
| 9212 | * |
| 9213 | * Hold RTNL lock |
| 9214 | * |
| 9215 | * Return: True if held and false otherwise |
| 9216 | */ |
| 9217 | static inline bool hdd_hold_rtnl_lock(void) |
| 9218 | { |
| 9219 | rtnl_lock(); |
| 9220 | return true; |
| 9221 | } |
| 9222 | |
| 9223 | /** |
| 9224 | * hdd_release_rtnl_lock - Release RTNL lock |
| 9225 | * |
| 9226 | * Release RTNL lock |
| 9227 | * |
| 9228 | * Return: None |
| 9229 | */ |
| 9230 | static inline void hdd_release_rtnl_lock(void) |
| 9231 | { |
| 9232 | rtnl_unlock(); |
| 9233 | } |
| 9234 | #else |
| 9235 | static inline bool hdd_hold_rtnl_lock(void) { return false; } |
| 9236 | static inline void hdd_release_rtnl_lock(void) { } |
| 9237 | #endif |
| 9238 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9239 | #if !defined(REMOVE_PKT_LOG) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9240 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9241 | /* MAX iwpriv command support */ |
| 9242 | #define PKTLOG_SET_BUFF_SIZE 3 |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9243 | #define PKTLOG_CLEAR_BUFF 4 |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9244 | #define MAX_PKTLOG_SIZE 16 |
| 9245 | |
| 9246 | /** |
| 9247 | * hdd_pktlog_set_buff_size() - set pktlog buffer size |
| 9248 | * @hdd_ctx: hdd context |
| 9249 | * @set_value2: pktlog buffer size value |
| 9250 | * |
| 9251 | * |
| 9252 | * Return: 0 for success or error. |
| 9253 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9254 | 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] | 9255 | { |
| 9256 | struct sir_wifi_start_log start_log = { 0 }; |
| 9257 | QDF_STATUS status; |
| 9258 | |
| 9259 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 9260 | start_log.verbose_level = WLAN_LOG_LEVEL_OFF; |
| 9261 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 9262 | start_log.user_triggered = 1; |
| 9263 | start_log.size = set_value2; |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9264 | start_log.is_pktlog_buff_clear = false; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9265 | |
| 9266 | status = sme_wifi_start_logger(hdd_ctx->hHal, start_log); |
| 9267 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9268 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9269 | hdd_exit(); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9270 | return -EINVAL; |
| 9271 | } |
| 9272 | |
| 9273 | return 0; |
| 9274 | } |
| 9275 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9276 | /** |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9277 | * hdd_pktlog_clear_buff() - clear pktlog buffer |
| 9278 | * @hdd_ctx: hdd context |
| 9279 | * |
| 9280 | * Return: 0 for success or error. |
| 9281 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9282 | static int hdd_pktlog_clear_buff(struct hdd_context *hdd_ctx) |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9283 | { |
| 9284 | struct sir_wifi_start_log start_log; |
| 9285 | QDF_STATUS status; |
| 9286 | |
| 9287 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 9288 | start_log.verbose_level = WLAN_LOG_LEVEL_OFF; |
| 9289 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 9290 | start_log.user_triggered = 1; |
| 9291 | start_log.size = 0; |
| 9292 | start_log.is_pktlog_buff_clear = true; |
| 9293 | |
| 9294 | status = sme_wifi_start_logger(hdd_ctx->hHal, start_log); |
| 9295 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9296 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9297 | hdd_exit(); |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9298 | return -EINVAL; |
| 9299 | } |
| 9300 | |
| 9301 | return 0; |
| 9302 | } |
| 9303 | |
| 9304 | |
| 9305 | /** |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9306 | * hdd_process_pktlog_command() - process pktlog command |
| 9307 | * @hdd_ctx: hdd context |
| 9308 | * @set_value: value set by user |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9309 | * @set_value2: pktlog buffer size value |
| 9310 | * |
| 9311 | * This function process pktlog command. |
| 9312 | * set_value2 only matters when set_value is 3 (set buff size) |
| 9313 | * otherwise we ignore it. |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9314 | * |
| 9315 | * Return: 0 for success or error. |
| 9316 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9317 | 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] | 9318 | int set_value2) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9319 | { |
| 9320 | int ret; |
| 9321 | bool enable; |
| 9322 | uint8_t user_triggered = 0; |
| 9323 | |
| 9324 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 9325 | if (0 != ret) |
| 9326 | return ret; |
| 9327 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9328 | hdd_debug("set pktlog %d, set size %d", set_value, set_value2); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9329 | |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9330 | if (set_value > PKTLOG_CLEAR_BUFF) { |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9331 | hdd_err("invalid pktlog value %d", set_value); |
| 9332 | return -EINVAL; |
| 9333 | } |
| 9334 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9335 | if (set_value == PKTLOG_SET_BUFF_SIZE) { |
| 9336 | if (set_value2 <= 0) { |
| 9337 | hdd_err("invalid pktlog size %d", set_value2); |
| 9338 | return -EINVAL; |
| 9339 | } else if (set_value2 > MAX_PKTLOG_SIZE) { |
| 9340 | hdd_err("Pktlog buff size is too large. max value is 16MB.\n"); |
| 9341 | return -EINVAL; |
| 9342 | } |
| 9343 | return hdd_pktlog_set_buff_size(hdd_ctx, set_value2); |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9344 | } else if (set_value == PKTLOG_CLEAR_BUFF) { |
| 9345 | return hdd_pktlog_clear_buff(hdd_ctx); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9346 | } |
| 9347 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9348 | /* |
| 9349 | * set_value = 0 then disable packetlog |
| 9350 | * set_value = 1 enable packetlog forcefully |
| 9351 | * set_vlaue = 2 then disable packetlog if disabled through ini or |
| 9352 | * enable packetlog with AUTO type. |
| 9353 | */ |
| 9354 | enable = ((set_value > 0) && cds_is_packet_log_enabled()) ? |
| 9355 | true : false; |
| 9356 | |
| 9357 | if (1 == set_value) { |
| 9358 | enable = true; |
| 9359 | user_triggered = 1; |
| 9360 | } |
| 9361 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9362 | return hdd_pktlog_enable_disable(hdd_ctx, enable, user_triggered, 0); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9363 | } |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 9364 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9365 | /** |
| 9366 | * hdd_pktlog_enable_disable() - Enable/Disable packet logging |
| 9367 | * @hdd_ctx: HDD context |
| 9368 | * @enable: Flag to enable/disable |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9369 | * @user_triggered: triggered through iwpriv |
| 9370 | * @size: buffer size to be used for packetlog |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9371 | * |
| 9372 | * Return: 0 on success; error number otherwise |
| 9373 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9374 | int hdd_pktlog_enable_disable(struct hdd_context *hdd_ctx, bool enable, |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9375 | uint8_t user_triggered, int size) |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9376 | { |
| 9377 | struct sir_wifi_start_log start_log; |
| 9378 | QDF_STATUS status; |
| 9379 | |
| 9380 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 9381 | start_log.verbose_level = |
| 9382 | enable ? WLAN_LOG_LEVEL_ACTIVE : WLAN_LOG_LEVEL_OFF; |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9383 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 9384 | start_log.user_triggered = user_triggered; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9385 | start_log.size = size; |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9386 | start_log.is_pktlog_buff_clear = false; |
Poddar, Siddarth | eefe348 | 2016-09-21 18:12:59 +0530 | [diff] [blame] | 9387 | /* |
| 9388 | * Use "is_iwpriv_command" flag to distinguish iwpriv command from other |
| 9389 | * commands. Host uses this flag to decide whether to send pktlog |
| 9390 | * disable command to fw without sending pktlog enable command |
| 9391 | * previously. For eg, If vendor sends pktlog disable command without |
| 9392 | * sending pktlog enable command, then host discards the packet |
| 9393 | * but for iwpriv command, host will send it to fw. |
| 9394 | */ |
| 9395 | start_log.is_iwpriv_command = 1; |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9396 | status = sme_wifi_start_logger(hdd_ctx->hHal, start_log); |
| 9397 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9398 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9399 | hdd_exit(); |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9400 | return -EINVAL; |
| 9401 | } |
| 9402 | |
Poddar, Siddarth | 61fbc93 | 2017-12-19 14:27:55 +0530 | [diff] [blame] | 9403 | if (enable == true) |
| 9404 | hdd_ctx->is_pktlog_enabled = 1; |
| 9405 | else |
| 9406 | hdd_ctx->is_pktlog_enabled = 0; |
| 9407 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9408 | return 0; |
| 9409 | } |
| 9410 | #endif /* REMOVE_PKT_LOG */ |
| 9411 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9412 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9413 | * hdd_get_platform_wlan_mac_buff() - API to query platform driver |
| 9414 | * for MAC address |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9415 | * @dev: Device Pointer |
| 9416 | * @num: Number of Valid Mac address |
| 9417 | * |
| 9418 | * Return: Pointer to MAC address buffer |
| 9419 | */ |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9420 | static uint8_t *hdd_get_platform_wlan_mac_buff(struct device *dev, |
| 9421 | uint32_t *num) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9422 | { |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9423 | return pld_get_wlan_mac_address(dev, num); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9424 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9425 | |
| 9426 | /** |
| 9427 | * hdd_populate_random_mac_addr() - API to populate random mac addresses |
| 9428 | * @hdd_ctx: HDD Context |
| 9429 | * @num: Number of random mac addresses needed |
| 9430 | * |
| 9431 | * Generate random addresses using bit manipulation on the base mac address |
| 9432 | * |
| 9433 | * Return: None |
| 9434 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9435 | 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] | 9436 | { |
| 9437 | uint32_t start_idx = QDF_MAX_CONCURRENCY_PERSONA - num; |
| 9438 | uint32_t iter; |
| 9439 | struct hdd_config *ini = hdd_ctx->config; |
| 9440 | uint8_t *buf = NULL; |
| 9441 | uint8_t macaddr_b3, tmp_br3; |
| 9442 | uint8_t *src = ini->intfMacAddr[0].bytes; |
| 9443 | |
| 9444 | for (iter = start_idx; iter < QDF_MAX_CONCURRENCY_PERSONA; ++iter) { |
| 9445 | buf = ini->intfMacAddr[iter].bytes; |
| 9446 | qdf_mem_copy(buf, src, QDF_MAC_ADDR_SIZE); |
| 9447 | macaddr_b3 = buf[3]; |
| 9448 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + iter) & |
| 9449 | INTF_MACADDR_MASK; |
| 9450 | macaddr_b3 += tmp_br3; |
| 9451 | macaddr_b3 ^= (1 << INTF_MACADDR_MASK); |
| 9452 | buf[0] |= 0x02; |
| 9453 | buf[3] = macaddr_b3; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9454 | hdd_debug(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(buf)); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9455 | } |
| 9456 | } |
| 9457 | |
| 9458 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9459 | * hdd_platform_wlan_mac() - API to get mac addresses from platform driver |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9460 | * @hdd_ctx: HDD Context |
| 9461 | * |
| 9462 | * API to get mac addresses from platform driver and update the driver |
| 9463 | * structures and configure FW with the base mac address. |
| 9464 | * Return: int |
| 9465 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9466 | static int hdd_platform_wlan_mac(struct hdd_context *hdd_ctx) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9467 | { |
| 9468 | uint32_t no_of_mac_addr, iter; |
| 9469 | uint32_t max_mac_addr = QDF_MAX_CONCURRENCY_PERSONA; |
| 9470 | uint32_t mac_addr_size = QDF_MAC_ADDR_SIZE; |
| 9471 | uint8_t *addr, *buf; |
| 9472 | struct device *dev = hdd_ctx->parent_dev; |
| 9473 | struct hdd_config *ini = hdd_ctx->config; |
| 9474 | tSirMacAddr mac_addr; |
| 9475 | QDF_STATUS status; |
| 9476 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9477 | addr = hdd_get_platform_wlan_mac_buff(dev, &no_of_mac_addr); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9478 | |
| 9479 | if (no_of_mac_addr == 0 || !addr) { |
| 9480 | hdd_warn("Platform Driver Doesn't have wlan mac addresses"); |
| 9481 | return -EINVAL; |
| 9482 | } |
| 9483 | |
| 9484 | if (no_of_mac_addr > max_mac_addr) |
| 9485 | no_of_mac_addr = max_mac_addr; |
| 9486 | |
| 9487 | qdf_mem_copy(&mac_addr, addr, mac_addr_size); |
| 9488 | |
| 9489 | for (iter = 0; iter < no_of_mac_addr; ++iter, addr += mac_addr_size) { |
| 9490 | buf = ini->intfMacAddr[iter].bytes; |
| 9491 | qdf_mem_copy(buf, addr, QDF_MAC_ADDR_SIZE); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9492 | hdd_debug(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(buf)); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9493 | } |
| 9494 | |
| 9495 | status = sme_set_custom_mac_addr(mac_addr); |
| 9496 | |
| 9497 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9498 | return -EAGAIN; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 9499 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9500 | if (no_of_mac_addr < max_mac_addr) |
| 9501 | hdd_populate_random_mac_addr(hdd_ctx, max_mac_addr - |
| 9502 | no_of_mac_addr); |
| 9503 | return 0; |
| 9504 | } |
| 9505 | |
| 9506 | /** |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9507 | * hdd_update_mac_addr_to_fw() - API to update wlan mac addresses to FW |
| 9508 | * @hdd_ctx: HDD Context |
| 9509 | * |
| 9510 | * Update MAC address to FW. If MAC address passed by FW is invalid, host |
| 9511 | * will generate its own MAC and update it to FW. |
| 9512 | * |
| 9513 | * Return: 0 for success |
| 9514 | * Non-zero error code for failure |
| 9515 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9516 | 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] | 9517 | { |
| 9518 | tSirMacAddr customMacAddr; |
| 9519 | QDF_STATUS status; |
| 9520 | |
| 9521 | qdf_mem_copy(&customMacAddr, |
| 9522 | &hdd_ctx->config->intfMacAddr[0].bytes[0], |
| 9523 | sizeof(tSirMacAddr)); |
| 9524 | status = sme_set_custom_mac_addr(customMacAddr); |
| 9525 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9526 | return -EAGAIN; |
| 9527 | return 0; |
| 9528 | } |
| 9529 | |
| 9530 | /** |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9531 | * hdd_initialize_mac_address() - API to get wlan mac addresses |
| 9532 | * @hdd_ctx: HDD Context |
| 9533 | * |
| 9534 | * Get MAC addresses from platform driver or wlan_mac.bin. If platform driver |
| 9535 | * is provisioned with mac addresses, driver uses it, else it will use |
| 9536 | * wlan_mac.bin to update HW MAC addresses. |
| 9537 | * |
| 9538 | * Return: None |
| 9539 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9540 | static void hdd_initialize_mac_address(struct hdd_context *hdd_ctx) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9541 | { |
| 9542 | QDF_STATUS status; |
| 9543 | int ret; |
| 9544 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9545 | ret = hdd_platform_wlan_mac(hdd_ctx); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9546 | if (ret == 0) |
| 9547 | return; |
| 9548 | |
Yuanyuan Liu | 3d62f6a | 2017-06-08 11:08:46 -0700 | [diff] [blame] | 9549 | hdd_info("MAC is not programmed in platform driver ret: %d, use wlan_mac.bin", |
| 9550 | ret); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9551 | |
| 9552 | status = hdd_update_mac_config(hdd_ctx); |
| 9553 | |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9554 | if (QDF_IS_STATUS_SUCCESS(status)) |
| 9555 | return; |
| 9556 | |
Yuanyuan Liu | 3d62f6a | 2017-06-08 11:08:46 -0700 | [diff] [blame] | 9557 | hdd_info("MAC is not programmed in wlan_mac.bin ret %d, use default MAC", |
| 9558 | status); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9559 | |
Yuanyuan Liu | 1c2caa3 | 2016-11-07 17:13:48 -0800 | [diff] [blame] | 9560 | if (hdd_ctx->update_mac_addr_to_fw) { |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9561 | ret = hdd_update_mac_addr_to_fw(hdd_ctx); |
Yuanyuan Liu | 1c2caa3 | 2016-11-07 17:13:48 -0800 | [diff] [blame] | 9562 | if (ret != 0) { |
| 9563 | hdd_err("MAC address out-of-sync, ret:%d", ret); |
| 9564 | QDF_ASSERT(ret); |
| 9565 | } |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9566 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9567 | } |
| 9568 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9569 | static int hdd_set_smart_chainmask_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9570 | { |
| 9571 | int vdev_id = 0; |
| 9572 | int param_id = WMI_PDEV_PARAM_SMART_CHAINMASK_SCHEME; |
| 9573 | int value = hdd_ctx->config->smart_chainmask_enabled; |
| 9574 | int vpdev = PDEV_CMD; |
| 9575 | int ret; |
| 9576 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9577 | ret = sme_cli_set_command(vdev_id, param_id, value, vpdev); |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9578 | if (ret) |
| 9579 | hdd_err("WMI_PDEV_PARAM_SMART_CHAINMASK_SCHEME failed %d", ret); |
| 9580 | |
| 9581 | return ret; |
| 9582 | } |
| 9583 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9584 | static int hdd_set_alternative_chainmask_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9585 | { |
| 9586 | int vdev_id = 0; |
| 9587 | int param_id = WMI_PDEV_PARAM_ALTERNATIVE_CHAINMASK_SCHEME; |
| 9588 | int value = hdd_ctx->config->alternative_chainmask_enabled; |
| 9589 | int vpdev = PDEV_CMD; |
| 9590 | int ret; |
| 9591 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9592 | ret = sme_cli_set_command(vdev_id, param_id, value, vpdev); |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9593 | if (ret) |
| 9594 | hdd_err("WMI_PDEV_PARAM_ALTERNATIVE_CHAINMASK_SCHEME failed %d", |
| 9595 | ret); |
| 9596 | |
| 9597 | return ret; |
| 9598 | } |
| 9599 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9600 | static int hdd_set_ani_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 9601 | { |
| 9602 | int vdev_id = 0; |
| 9603 | int param_id = WMI_PDEV_PARAM_ANI_ENABLE; |
| 9604 | int value = hdd_ctx->config->ani_enabled; |
| 9605 | int vpdev = PDEV_CMD; |
| 9606 | int ret; |
| 9607 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9608 | ret = sme_cli_set_command(vdev_id, param_id, value, vpdev); |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 9609 | if (ret) |
| 9610 | hdd_err("WMI_PDEV_PARAM_ANI_ENABLE failed %d", ret); |
| 9611 | |
| 9612 | return ret; |
| 9613 | } |
| 9614 | |
Jeff Johnson | 89c66ff | 2016-04-22 15:21:37 -0700 | [diff] [blame] | 9615 | /** |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9616 | * hdd_pre_enable_configure() - Configurations prior to cds_enable |
| 9617 | * @hdd_ctx: HDD context |
| 9618 | * |
| 9619 | * Pre configurations to be done at lower layer before calling cds enable. |
| 9620 | * |
| 9621 | * Return: 0 on success and errno on failure. |
| 9622 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9623 | static int hdd_pre_enable_configure(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9624 | { |
| 9625 | int ret; |
| 9626 | QDF_STATUS status; |
| 9627 | tSirRetStatus hal_status; |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 9628 | void *soc = cds_get_context(QDF_MODULE_ID_SOC); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9629 | |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 9630 | cdp_register_pause_cb(soc, wlan_hdd_txrx_pause_cb); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9631 | /* |
| 9632 | * Set 802.11p config |
| 9633 | * TODO-OCB: This has been temporarily added here to ensure this |
| 9634 | * parameter is set in CSR when we init the channel list. This should |
| 9635 | * be removed once the 5.9 GHz channels are added to the regulatory |
| 9636 | * domain. |
| 9637 | */ |
| 9638 | hdd_set_dot11p_config(hdd_ctx); |
| 9639 | |
| 9640 | /* |
| 9641 | * Note that the cds_pre_enable() sequence triggers the cfg download. |
| 9642 | * The cfg download must occur before we update the SME config |
| 9643 | * since the SME config operation must access the cfg database |
| 9644 | */ |
| 9645 | status = hdd_set_sme_config(hdd_ctx); |
| 9646 | |
| 9647 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9648 | hdd_err("Failed hdd_set_sme_config: %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9649 | ret = qdf_status_to_os_return(status); |
| 9650 | goto out; |
| 9651 | } |
| 9652 | |
Tushnim Bhattacharyya | ba8ee93 | 2017-03-23 09:27:40 -0700 | [diff] [blame] | 9653 | status = hdd_set_policy_mgr_user_cfg(hdd_ctx); |
| 9654 | if (QDF_STATUS_SUCCESS != status) { |
| 9655 | hdd_alert("Failed hdd_set_policy_mgr_user_cfg: %d", status); |
| 9656 | ret = qdf_status_to_os_return(status); |
| 9657 | goto out; |
| 9658 | } |
| 9659 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9660 | 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] | 9661 | hdd_ctx->config->tx_chain_mask_1ss, |
| 9662 | PDEV_CMD); |
| 9663 | if (0 != ret) { |
| 9664 | hdd_err("WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS failed %d", ret); |
| 9665 | goto out; |
| 9666 | } |
| 9667 | |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9668 | ret = hdd_set_smart_chainmask_enabled(hdd_ctx); |
| 9669 | if (ret) |
| 9670 | goto out; |
| 9671 | |
| 9672 | ret = hdd_set_alternative_chainmask_enabled(hdd_ctx); |
| 9673 | if (ret) |
| 9674 | goto out; |
| 9675 | |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 9676 | ret = hdd_set_ani_enabled(hdd_ctx); |
| 9677 | if (ret) |
| 9678 | goto out; |
| 9679 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9680 | ret = sme_cli_set_command(0, WMI_PDEV_PARAM_ARP_AC_OVERRIDE, |
Srinivas Girigowda | 70e169a | 2017-03-07 23:55:57 -0800 | [diff] [blame] | 9681 | hdd_ctx->config->arp_ac_category, |
| 9682 | PDEV_CMD); |
| 9683 | if (0 != ret) { |
| 9684 | hdd_err("WMI_PDEV_PARAM_ARP_AC_OVERRIDE ac: %d ret: %d", |
| 9685 | hdd_ctx->config->arp_ac_category, ret); |
| 9686 | goto out; |
| 9687 | } |
| 9688 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9689 | status = hdd_set_sme_chan_list(hdd_ctx); |
| 9690 | if (status != QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9691 | hdd_err("Failed to init channel list: %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9692 | ret = qdf_status_to_os_return(status); |
| 9693 | goto out; |
| 9694 | } |
| 9695 | |
| 9696 | /* Apply the cfg.ini to cfg.dat */ |
Krunal Soni | df0f874 | 2016-09-26 14:56:31 -0700 | [diff] [blame] | 9697 | if (!hdd_update_config_cfg(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9698 | hdd_err("config update failed"); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9699 | ret = -EINVAL; |
| 9700 | goto out; |
| 9701 | } |
| 9702 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9703 | /* |
| 9704 | * Set the MAC Address Currently this is used by HAL to add self sta. |
| 9705 | * Remove this once self sta is added as part of session open. |
| 9706 | */ |
| 9707 | hal_status = cfg_set_str(hdd_ctx->hHal, WNI_CFG_STA_ID, |
| 9708 | hdd_ctx->config->intfMacAddr[0].bytes, |
| 9709 | sizeof(hdd_ctx->config->intfMacAddr[0])); |
| 9710 | |
| 9711 | if (!IS_SIR_STATUS_SUCCESS(hal_status)) { |
| 9712 | hdd_err("Failed to set MAC Address. HALStatus is %08d [x%08x]", |
| 9713 | hal_status, hal_status); |
| 9714 | ret = -EINVAL; |
| 9715 | goto out; |
| 9716 | } |
| 9717 | |
| 9718 | hdd_init_channel_avoidance(hdd_ctx); |
| 9719 | |
Ganesh Kondabattini | 408fb8d | 2017-08-08 22:00:20 +0530 | [diff] [blame] | 9720 | /* update enable sap mandatory chan list */ |
| 9721 | policy_mgr_enable_disable_sap_mandatory_chan_list(hdd_ctx->hdd_psoc, |
| 9722 | hdd_ctx->config->enable_sap_mandatory_chan_list); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9723 | out: |
| 9724 | return ret; |
| 9725 | } |
| 9726 | |
| 9727 | /** |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9728 | * wlan_hdd_p2p_lo_event_callback - P2P listen offload stop event handler |
| 9729 | * @context_ptr - hdd context pointer |
| 9730 | * @event_ptr - event structure pointer |
| 9731 | * |
| 9732 | * This is the p2p listen offload stop event handler, it sends vendor |
| 9733 | * event back to supplicant to notify the stop reason. |
| 9734 | * |
| 9735 | * Return: None |
| 9736 | */ |
| 9737 | static void wlan_hdd_p2p_lo_event_callback(void *context_ptr, |
| 9738 | void *event_ptr) |
| 9739 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9740 | struct hdd_context *hdd_ctx = (struct hdd_context *)context_ptr; |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9741 | struct sir_p2p_lo_event *evt = event_ptr; |
| 9742 | struct sk_buff *vendor_event; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9743 | struct hdd_adapter *adapter; |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9744 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 9745 | hdd_enter(); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9746 | |
| 9747 | if (hdd_ctx == NULL) { |
| 9748 | hdd_err("Invalid HDD context pointer"); |
| 9749 | return; |
| 9750 | } |
| 9751 | |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 9752 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, evt->vdev_id); |
| 9753 | if (!adapter) { |
| 9754 | hdd_err("Cannot find adapter by vdev_id = %d", |
| 9755 | evt->vdev_id); |
| 9756 | return; |
| 9757 | } |
| 9758 | |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9759 | vendor_event = |
| 9760 | cfg80211_vendor_event_alloc(hdd_ctx->wiphy, |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 9761 | &(adapter->wdev), sizeof(uint32_t) + NLMSG_HDRLEN, |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9762 | QCA_NL80211_VENDOR_SUBCMD_P2P_LO_EVENT_INDEX, |
| 9763 | GFP_KERNEL); |
| 9764 | |
| 9765 | if (!vendor_event) { |
| 9766 | hdd_err("cfg80211_vendor_event_alloc failed"); |
| 9767 | return; |
| 9768 | } |
| 9769 | |
| 9770 | if (nla_put_u32(vendor_event, |
| 9771 | QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_STOP_REASON, |
| 9772 | evt->reason_code)) { |
| 9773 | hdd_err("nla put failed"); |
| 9774 | kfree_skb(vendor_event); |
| 9775 | return; |
| 9776 | } |
| 9777 | |
| 9778 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 9779 | hdd_debug("Sent P2P_LISTEN_OFFLOAD_STOP event for vdev_id = %d", |
| 9780 | evt->vdev_id); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9781 | } |
| 9782 | |
| 9783 | /** |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 9784 | * hdd_adaptive_dwelltime_init() - initialization for adaptive dwell time config |
| 9785 | * @hdd_ctx: HDD context |
| 9786 | * |
| 9787 | * This function sends the adaptive dwell time config configuration to the |
| 9788 | * firmware via WMA |
| 9789 | * |
| 9790 | * Return: 0 - success, < 0 - failure |
| 9791 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9792 | static int hdd_adaptive_dwelltime_init(struct hdd_context *hdd_ctx) |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 9793 | { |
| 9794 | QDF_STATUS status; |
| 9795 | struct adaptive_dwelltime_params dwelltime_params; |
| 9796 | |
| 9797 | dwelltime_params.is_enabled = |
| 9798 | hdd_ctx->config->adaptive_dwell_mode_enabled; |
| 9799 | dwelltime_params.dwelltime_mode = |
| 9800 | hdd_ctx->config->global_adapt_dwelltime_mode; |
| 9801 | dwelltime_params.lpf_weight = |
| 9802 | hdd_ctx->config->adapt_dwell_lpf_weight; |
| 9803 | dwelltime_params.passive_mon_intval = |
| 9804 | hdd_ctx->config->adapt_dwell_passive_mon_intval; |
| 9805 | dwelltime_params.wifi_act_threshold = |
| 9806 | hdd_ctx->config->adapt_dwell_wifi_act_threshold; |
| 9807 | |
| 9808 | status = sme_set_adaptive_dwelltime_config(hdd_ctx->hHal, |
| 9809 | &dwelltime_params); |
| 9810 | |
| 9811 | hdd_debug("Sending Adaptive Dwelltime Configuration to fw"); |
| 9812 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9813 | hdd_err("Failed to send Adaptive Dwelltime configuration!"); |
| 9814 | return -EAGAIN; |
| 9815 | } |
| 9816 | return 0; |
| 9817 | } |
| 9818 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9819 | int hdd_dbs_scan_selection_init(struct hdd_context *hdd_ctx) |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 9820 | { |
| 9821 | QDF_STATUS status; |
| 9822 | struct wmi_dbs_scan_sel_params dbs_scan_params; |
| 9823 | uint32_t i = 0; |
| 9824 | uint8_t count = 0, numentries = 0; |
| 9825 | uint8_t dbs_scan_config[CDS_DBS_SCAN_PARAM_PER_CLIENT |
| 9826 | * CDS_DBS_SCAN_CLIENTS_MAX]; |
| 9827 | |
| 9828 | /* check if DBS is enabled or supported */ |
Bala Venkatesh | c8236ca | 2018-03-09 12:38:29 +0530 | [diff] [blame] | 9829 | if ((hdd_ctx->config->dual_mac_feature_disable == |
| 9830 | DISABLE_DBS_CXN_AND_SCAN) || |
| 9831 | (hdd_ctx->config->dual_mac_feature_disable == |
| 9832 | ENABLE_DBS_CXN_AND_DISABLE_DBS_SCAN)) |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 9833 | return -EINVAL; |
| 9834 | |
| 9835 | hdd_string_to_u8_array(hdd_ctx->config->dbs_scan_selection, |
| 9836 | dbs_scan_config, &numentries, |
| 9837 | (CDS_DBS_SCAN_PARAM_PER_CLIENT |
| 9838 | * CDS_DBS_SCAN_CLIENTS_MAX)); |
| 9839 | |
| 9840 | hdd_info("numentries %hu", numentries); |
| 9841 | if (!numentries) { |
| 9842 | hdd_info("Donot send scan_selection_config"); |
| 9843 | return 0; |
| 9844 | } |
| 9845 | |
| 9846 | /* hdd_set_fw_log_params */ |
| 9847 | dbs_scan_params.num_clients = 0; |
| 9848 | while (count < (numentries - 2)) { |
| 9849 | dbs_scan_params.module_id[i] = dbs_scan_config[count]; |
| 9850 | dbs_scan_params.num_dbs_scans[i] = dbs_scan_config[count + 1]; |
| 9851 | dbs_scan_params.num_non_dbs_scans[i] = |
| 9852 | dbs_scan_config[count + 2]; |
| 9853 | dbs_scan_params.num_clients++; |
| 9854 | hdd_debug("module:%d NDS:%d NNDS:%d", |
| 9855 | dbs_scan_params.module_id[i], |
| 9856 | dbs_scan_params.num_dbs_scans[i], |
| 9857 | dbs_scan_params.num_non_dbs_scans[i]); |
| 9858 | count += CDS_DBS_SCAN_PARAM_PER_CLIENT; |
| 9859 | i++; |
| 9860 | } |
| 9861 | |
| 9862 | dbs_scan_params.pdev_id = 0; |
| 9863 | |
| 9864 | hdd_debug("clients:%d pdev:%d", |
| 9865 | dbs_scan_params.num_clients, dbs_scan_params.pdev_id); |
| 9866 | |
| 9867 | status = sme_set_dbs_scan_selection_config(hdd_ctx->hHal, |
| 9868 | &dbs_scan_params); |
| 9869 | hdd_debug("Sending DBS Scan Selection Configuration to fw"); |
| 9870 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9871 | hdd_err("Failed to send DBS Scan selection configuration!"); |
| 9872 | return -EAGAIN; |
| 9873 | } |
| 9874 | return 0; |
| 9875 | } |
| 9876 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9877 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 9878 | /** |
| 9879 | * hdd_set_auto_shutdown_cb() - Set auto shutdown callback |
| 9880 | * @hdd_ctx: HDD context |
| 9881 | * |
| 9882 | * Set auto shutdown callback to get indications from firmware to indicate |
| 9883 | * userspace to shutdown WLAN after a configured amount of inactivity. |
| 9884 | * |
| 9885 | * Return: 0 on success and errno on failure. |
| 9886 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9887 | static int hdd_set_auto_shutdown_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9888 | { |
| 9889 | QDF_STATUS status; |
| 9890 | |
| 9891 | if (!hdd_ctx->config->WlanAutoShutdown) |
| 9892 | return 0; |
| 9893 | |
| 9894 | status = sme_set_auto_shutdown_cb(hdd_ctx->hHal, |
| 9895 | wlan_hdd_auto_shutdown_cb); |
| 9896 | if (status != QDF_STATUS_SUCCESS) |
| 9897 | hdd_err("Auto shutdown feature could not be enabled: %d", |
| 9898 | status); |
| 9899 | |
| 9900 | return qdf_status_to_os_return(status); |
| 9901 | } |
| 9902 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9903 | static int hdd_set_auto_shutdown_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9904 | { |
| 9905 | return 0; |
| 9906 | } |
| 9907 | #endif |
| 9908 | |
| 9909 | /** |
| 9910 | * hdd_features_init() - Init features |
| 9911 | * @hdd_ctx: HDD context |
| 9912 | * @adapter: Primary adapter context |
| 9913 | * |
| 9914 | * Initialize features and their feature context after WLAN firmware is up. |
| 9915 | * |
| 9916 | * Return: 0 on success and errno on failure. |
| 9917 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9918 | 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] | 9919 | { |
| 9920 | tSirTxPowerLimit hddtxlimit; |
| 9921 | QDF_STATUS status; |
Manjeet Singh | a9cae43 | 2017-02-28 11:58:22 +0530 | [diff] [blame] | 9922 | struct sme_5g_band_pref_params band_pref_params; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9923 | int ret; |
| 9924 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 9925 | hdd_enter(); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9926 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9927 | /* FW capabilities received, Set the Dot11 mode */ |
| 9928 | sme_setdef_dot11mode(hdd_ctx->hHal); |
Kiran Kumar Lokere | 1aa9c9a | 2016-10-05 18:50:59 -0700 | [diff] [blame] | 9929 | sme_set_prefer_80MHz_over_160MHz(hdd_ctx->hHal, |
| 9930 | hdd_ctx->config->sta_prefer_80MHz_over_160MHz); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9931 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9932 | |
| 9933 | if (hdd_ctx->config->fIsImpsEnabled) |
| 9934 | hdd_set_idle_ps_config(hdd_ctx, true); |
| 9935 | else |
| 9936 | hdd_set_idle_ps_config(hdd_ctx, false); |
| 9937 | |
Poddar, Siddarth | 3703303 | 2017-10-11 15:47:40 +0530 | [diff] [blame] | 9938 | /* Send Enable/Disable data stall detection cmd to FW */ |
| 9939 | sme_cli_set_command(0, WMI_PDEV_PARAM_DATA_STALL_DETECT_ENABLE, |
| 9940 | hdd_ctx->config->enable_data_stall_det, PDEV_CMD); |
| 9941 | |
Agrawal Ashish | 642ec9b | 2017-02-22 14:45:30 +0530 | [diff] [blame] | 9942 | if (hdd_ctx->config->enable_go_cts2self_for_sta) |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 9943 | sme_set_cts2self_for_p2p_go(hdd_ctx->hHal); |
Agrawal Ashish | 642ec9b | 2017-02-22 14:45:30 +0530 | [diff] [blame] | 9944 | |
Nachiket Kukade | 8983cf6 | 2017-10-12 18:14:48 +0530 | [diff] [blame] | 9945 | if (sme_set_vc_mode_config(hdd_ctx->config->vc_mode_cfg_bitmap)) |
| 9946 | hdd_warn("Error in setting Voltage Corner mode config to FW"); |
| 9947 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9948 | if (hdd_lro_init(hdd_ctx)) |
| 9949 | hdd_err("Unable to initialize LRO in fw"); |
| 9950 | |
| 9951 | if (hdd_adaptive_dwelltime_init(hdd_ctx)) |
| 9952 | hdd_err("Unable to send adaptive dwelltime setting to FW"); |
| 9953 | |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 9954 | if (hdd_dbs_scan_selection_init(hdd_ctx)) |
| 9955 | hdd_err("Unable to send DBS scan selection setting to FW"); |
| 9956 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9957 | ret = hdd_init_thermal_info(hdd_ctx); |
| 9958 | if (ret) { |
| 9959 | hdd_err("Error while initializing thermal information"); |
| 9960 | goto deregister_frames; |
| 9961 | } |
| 9962 | |
Poddar, Siddarth | 61fbc93 | 2017-12-19 14:27:55 +0530 | [diff] [blame] | 9963 | /** |
| 9964 | * In case of SSR/PDR, if pktlog was enabled manually before |
| 9965 | * SSR/PDR, Then enabled it again automatically after Wlan |
| 9966 | * device up. |
| 9967 | */ |
| 9968 | if (cds_is_driver_recovering()) { |
| 9969 | if (hdd_ctx->is_pktlog_enabled) |
| 9970 | hdd_pktlog_enable_disable(hdd_ctx, true, 0, 0); |
Tiger Yu | f3d5d7f | 2018-03-15 14:48:11 +0800 | [diff] [blame] | 9971 | } |
Poddar, Siddarth | 66a4659 | 2017-02-22 11:44:44 +0530 | [diff] [blame] | 9972 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9973 | hddtxlimit.txPower2g = hdd_ctx->config->TxPower2g; |
| 9974 | hddtxlimit.txPower5g = hdd_ctx->config->TxPower5g; |
| 9975 | status = sme_txpower_limit(hdd_ctx->hHal, &hddtxlimit); |
| 9976 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9977 | hdd_err("Error setting txlimit in sme: %d", status); |
| 9978 | |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 9979 | wlan_hdd_tsf_init(hdd_ctx); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9980 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9981 | ret = hdd_register_cb(hdd_ctx); |
| 9982 | if (ret) { |
| 9983 | hdd_err("Failed to register HDD callbacks!"); |
| 9984 | goto deregister_frames; |
| 9985 | } |
| 9986 | |
Selvaraj, Sridhar | 371f55e | 2017-02-21 10:36:15 +0530 | [diff] [blame] | 9987 | if (hdd_ctx->config->goptimize_chan_avoid_event) { |
| 9988 | status = sme_enable_disable_chanavoidind_event( |
| 9989 | hdd_ctx->hHal, 0); |
| 9990 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9991 | hdd_err("Failed to disable Chan Avoidance Indication"); |
| 9992 | goto deregister_cb; |
| 9993 | } |
| 9994 | } |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9995 | |
Manjeet Singh | a9cae43 | 2017-02-28 11:58:22 +0530 | [diff] [blame] | 9996 | if (hdd_ctx->config->enable_5g_band_pref) { |
| 9997 | band_pref_params.rssi_boost_threshold_5g = |
| 9998 | hdd_ctx->config->rssi_boost_threshold_5g; |
| 9999 | band_pref_params.rssi_boost_factor_5g = |
| 10000 | hdd_ctx->config->rssi_boost_factor_5g; |
| 10001 | band_pref_params.max_rssi_boost_5g = |
| 10002 | hdd_ctx->config->max_rssi_boost_5g; |
| 10003 | band_pref_params.rssi_penalize_threshold_5g = |
| 10004 | hdd_ctx->config->rssi_penalize_threshold_5g; |
| 10005 | band_pref_params.rssi_penalize_factor_5g = |
| 10006 | hdd_ctx->config->rssi_penalize_factor_5g; |
| 10007 | band_pref_params.max_rssi_penalize_5g = |
| 10008 | hdd_ctx->config->max_rssi_penalize_5g; |
| 10009 | sme_set_5g_band_pref(hdd_ctx->hHal, &band_pref_params); |
| 10010 | } |
| 10011 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10012 | /* register P2P Listen Offload event callback */ |
| 10013 | if (wma_is_p2p_lo_capable()) |
| 10014 | sme_register_p2p_lo_event(hdd_ctx->hHal, hdd_ctx, |
| 10015 | wlan_hdd_p2p_lo_event_callback); |
| 10016 | |
| 10017 | ret = hdd_set_auto_shutdown_cb(hdd_ctx); |
| 10018 | |
| 10019 | if (ret) |
| 10020 | goto deregister_cb; |
| 10021 | |
Dustin Brown | 11638b7 | 2018-01-25 17:37:25 +0530 | [diff] [blame] | 10022 | wlan_hdd_init_chan_info(hdd_ctx); |
| 10023 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10024 | hdd_exit(); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10025 | return 0; |
| 10026 | |
| 10027 | deregister_cb: |
| 10028 | hdd_deregister_cb(hdd_ctx); |
| 10029 | deregister_frames: |
| 10030 | wlan_hdd_cfg80211_deregister_frames(adapter); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10031 | return -EINVAL; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10032 | } |
| 10033 | |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10034 | /** |
| 10035 | * hdd_features_deinit() - Deinit features |
| 10036 | * @hdd_ctx: HDD context |
| 10037 | * |
| 10038 | * De-Initialize features and their feature context. |
| 10039 | * |
| 10040 | * Return: none. |
| 10041 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10042 | static void hdd_features_deinit(struct hdd_context *hdd_ctx) |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10043 | { |
Dustin Brown | 11638b7 | 2018-01-25 17:37:25 +0530 | [diff] [blame] | 10044 | wlan_hdd_deinit_chan_info(hdd_ctx); |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10045 | wlan_hdd_tsf_deinit(hdd_ctx); |
| 10046 | } |
| 10047 | |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10048 | /** |
Sandeep Puligilla | 0a11f8d | 2017-06-23 15:53:29 -0700 | [diff] [blame] | 10049 | * hdd_register_bcn_cb() - register scan beacon callback |
| 10050 | * @hdd_ctx - Pointer to the HDD context |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10051 | * |
Sandeep Puligilla | 0a11f8d | 2017-06-23 15:53:29 -0700 | [diff] [blame] | 10052 | * Return: QDF_STATUS |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10053 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10054 | 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] | 10055 | { |
| 10056 | QDF_STATUS status; |
| 10057 | |
| 10058 | status = ucfg_scan_register_bcn_cb(hdd_ctx->hdd_psoc, |
| 10059 | wlan_cfg80211_inform_bss_frame, |
| 10060 | SCAN_CB_TYPE_INFORM_BCN); |
| 10061 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10062 | hdd_err("failed with status code %08d [x%08x]", |
| 10063 | status, status); |
| 10064 | return status; |
| 10065 | } |
| 10066 | |
| 10067 | return QDF_STATUS_SUCCESS; |
| 10068 | } |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10069 | |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 10070 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10071 | * hdd_configure_cds() - Configure cds modules |
| 10072 | * @hdd_ctx: HDD context |
| 10073 | * @adapter: Primary adapter context |
| 10074 | * |
| 10075 | * Enable Cds modules after WLAN firmware is up. |
| 10076 | * |
| 10077 | * Return: 0 on success and errno on failure. |
| 10078 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10079 | 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] | 10080 | { |
| 10081 | int ret; |
| 10082 | QDF_STATUS status; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 10083 | int set_value; |
| 10084 | uint32_t num_abg_tx_chains = 0; |
| 10085 | uint32_t num_11b_tx_chains = 0; |
| 10086 | uint32_t num_11ag_tx_chains = 0; |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 10087 | struct policy_mgr_dp_cbacks dp_cbs; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 10088 | |
| 10089 | if (hdd_ctx->config->sifs_burst_duration) { |
| 10090 | set_value = (SIFS_BURST_DUR_MULTIPLIER) * |
| 10091 | hdd_ctx->config->sifs_burst_duration; |
| 10092 | |
| 10093 | if ((set_value > 0) && (set_value <= SIFS_BURST_DUR_MAX)) |
| 10094 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_BURST_DUR, |
| 10095 | set_value, PDEV_CMD); |
| 10096 | } |
| 10097 | |
| 10098 | if (hdd_ctx->config->is_force_1x1) |
| 10099 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_SET_IOT_PATTERN, |
| 10100 | 1, PDEV_CMD); |
| 10101 | /* set chip power save failure detected callback */ |
| 10102 | sme_set_chip_pwr_save_fail_cb(hdd_ctx->hHal, |
| 10103 | hdd_chip_pwr_save_fail_detected_cb); |
| 10104 | |
| 10105 | if (hdd_ctx->config->max_mpdus_inampdu) { |
| 10106 | set_value = hdd_ctx->config->max_mpdus_inampdu; |
| 10107 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_MAX_MPDUS_IN_AMPDU, |
| 10108 | set_value, PDEV_CMD); |
| 10109 | } |
| 10110 | |
| 10111 | if (hdd_ctx->config->enable_rts_sifsbursting) { |
| 10112 | set_value = hdd_ctx->config->enable_rts_sifsbursting; |
| 10113 | sme_cli_set_command(0, |
| 10114 | (int)WMI_PDEV_PARAM_ENABLE_RTS_SIFS_BURSTING, |
| 10115 | set_value, PDEV_CMD); |
| 10116 | } |
| 10117 | |
| 10118 | if (hdd_ctx->config->sap_get_peer_info) { |
| 10119 | set_value = hdd_ctx->config->sap_get_peer_info; |
| 10120 | sme_cli_set_command(0, |
| 10121 | (int)WMI_PDEV_PARAM_PEER_STATS_INFO_ENABLE, |
| 10122 | set_value, PDEV_CMD); |
| 10123 | } |
| 10124 | |
| 10125 | num_11b_tx_chains = hdd_ctx->config->num_11b_tx_chains; |
| 10126 | num_11ag_tx_chains = hdd_ctx->config->num_11ag_tx_chains; |
| 10127 | if (!hdd_ctx->config->enable2x2) { |
| 10128 | if (num_11b_tx_chains > 1) |
| 10129 | num_11b_tx_chains = 1; |
| 10130 | if (num_11ag_tx_chains > 1) |
| 10131 | num_11ag_tx_chains = 1; |
| 10132 | } |
| 10133 | WMI_PDEV_PARAM_SET_11B_TX_CHAIN_NUM(num_abg_tx_chains, |
| 10134 | num_11b_tx_chains); |
| 10135 | WMI_PDEV_PARAM_SET_11AG_TX_CHAIN_NUM(num_abg_tx_chains, |
| 10136 | num_11ag_tx_chains); |
| 10137 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_ABG_MODE_TX_CHAIN_NUM, |
| 10138 | num_abg_tx_chains, PDEV_CMD); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10139 | |
| 10140 | ret = hdd_pre_enable_configure(hdd_ctx); |
| 10141 | if (ret) { |
| 10142 | hdd_err("Failed to pre-configure cds"); |
| 10143 | goto out; |
| 10144 | } |
| 10145 | |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 10146 | /* Always get latest IPA resources allocated from cds_open and configure |
| 10147 | * IPA module before configuring them to FW. Sequence required as crash |
| 10148 | * observed otherwise. |
| 10149 | */ |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 10150 | if (ucfg_ipa_uc_ol_init(hdd_ctx->hdd_pdev, |
| 10151 | cds_get_context(QDF_MODULE_ID_QDF_DEVICE))) { |
Manikandan Mohan | 2e803a0 | 2017-02-14 14:57:53 -0800 | [diff] [blame] | 10152 | hdd_err("Failed to setup pipes"); |
| 10153 | goto out; |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 10154 | } |
| 10155 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10156 | /* |
| 10157 | * Start CDS which starts up the SME/MAC/HAL modules and everything |
| 10158 | * else |
| 10159 | */ |
Jeff Johnson | 8f9dd5f | 2017-09-13 14:16:08 -0700 | [diff] [blame] | 10160 | status = cds_enable(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10161 | |
| 10162 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10163 | hdd_err("cds_enable failed"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10164 | goto out; |
| 10165 | } |
| 10166 | |
| 10167 | status = hdd_post_cds_enable_config(hdd_ctx); |
| 10168 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10169 | hdd_err("hdd_post_cds_enable_config failed"); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 10170 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10171 | } |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10172 | status = hdd_register_bcn_cb(hdd_ctx); |
| 10173 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Paul Zhang | e03cf4c | 2018-01-19 18:33:22 +0800 | [diff] [blame] | 10174 | hdd_err("hdd_register_bcn_cb failed"); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10175 | goto cds_disable; |
| 10176 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10177 | |
| 10178 | ret = hdd_features_init(hdd_ctx, adapter); |
| 10179 | if (ret) |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 10180 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10181 | |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 10182 | dp_cbs.hdd_disable_lro_in_concurrency = hdd_disable_lro_in_concurrency; |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 10183 | dp_cbs.hdd_set_rx_mode_rps_cb = hdd_set_rx_mode_rps; |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 10184 | status = policy_mgr_register_dp_cb(hdd_ctx->hdd_psoc, &dp_cbs); |
| 10185 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 10186 | hdd_debug("Failed to register DP cb with Policy Manager"); |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 10187 | goto cds_disable; |
| 10188 | } |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 10189 | status = policy_mgr_register_mode_change_cb(hdd_ctx->hdd_psoc, |
| 10190 | wlan_hdd_send_mode_change_event); |
| 10191 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10192 | hdd_debug("Failed to register mode change cb with Policy Manager"); |
| 10193 | goto cds_disable; |
| 10194 | } |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 10195 | |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 10196 | if (ucfg_green_ap_enable_egap(hdd_ctx->hdd_pdev)) |
Nachiket Kukade | fbd1afc | 2017-07-12 17:41:54 +0530 | [diff] [blame] | 10197 | hdd_debug("enhance green ap is not enabled"); |
| 10198 | |
Nachiket Kukade | dd30266 | 2017-07-13 17:31:44 +0530 | [diff] [blame] | 10199 | if (0 != wlan_hdd_set_wow_pulse(hdd_ctx, true)) |
| 10200 | hdd_debug("Failed to set wow pulse"); |
| 10201 | |
Ashish Kumar Dhanotiya | cb14b11 | 2018-01-19 19:26:44 +0530 | [diff] [blame] | 10202 | sme_cli_set_command(0, WMI_PDEV_PARAM_GCMP_SUPPORT_ENABLE, |
| 10203 | hdd_ctx->config->gcmp_enabled, PDEV_CMD); |
Hanumanth Reddy Pothula | ab39595 | 2017-09-05 19:12:26 +0530 | [diff] [blame] | 10204 | sme_cli_set_command(0, WMI_PDEV_AUTO_DETECT_POWER_FAILURE, |
| 10205 | hdd_ctx->config->auto_pwr_save_fail_mode, PDEV_CMD); |
| 10206 | |
Ravi Kumar Bokka | 990edcc | 2017-01-09 20:02:58 +0530 | [diff] [blame] | 10207 | |
| 10208 | if (hdd_ctx->config->enable_phy_reg_retention) |
| 10209 | wma_cli_set_command(0, WMI_PDEV_PARAM_FAST_PWR_TRANSITION, |
| 10210 | hdd_ctx->config->enable_phy_reg_retention, PDEV_CMD); |
| 10211 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10212 | return 0; |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 10213 | |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 10214 | cds_disable: |
Jeff Johnson | ea5c2aa1 | 2017-09-13 14:18:59 -0700 | [diff] [blame] | 10215 | cds_disable(hdd_ctx->hdd_psoc); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 10216 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10217 | out: |
| 10218 | return -EINVAL; |
| 10219 | } |
| 10220 | |
| 10221 | /** |
| 10222 | * hdd_deconfigure_cds() -De-Configure cds |
| 10223 | * @hdd_ctx: HDD context |
| 10224 | * |
| 10225 | * Deconfigure Cds modules before WLAN firmware is down. |
| 10226 | * |
| 10227 | * Return: 0 on success and errno on failure. |
| 10228 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10229 | static int hdd_deconfigure_cds(struct hdd_context *hdd_ctx) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10230 | { |
| 10231 | QDF_STATUS qdf_status; |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 10232 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10233 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10234 | hdd_enter(); |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10235 | |
| 10236 | /* De-init features */ |
| 10237 | hdd_features_deinit(hdd_ctx); |
| 10238 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10239 | /* De-register the SME callbacks */ |
| 10240 | hdd_deregister_cb(hdd_ctx); |
| 10241 | |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 10242 | qdf_status = policy_mgr_deregister_mode_change_cb(hdd_ctx->hdd_psoc); |
| 10243 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 10244 | hdd_debug("Failed to deregister mode change cb with Policy Manager"); |
| 10245 | } |
| 10246 | |
Jeff Johnson | ea5c2aa1 | 2017-09-13 14:18:59 -0700 | [diff] [blame] | 10247 | qdf_status = cds_disable(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10248 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 10249 | hdd_err("Failed to Disable the CDS Modules! :%d", |
| 10250 | qdf_status); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 10251 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10252 | } |
| 10253 | |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 10254 | 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] | 10255 | hdd_err("Failed to disconnect pipes"); |
| 10256 | ret = -EINVAL; |
| 10257 | } |
| 10258 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10259 | hdd_exit(); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 10260 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10261 | } |
| 10262 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 10263 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
| 10264 | static void hdd_deregister_policy_manager_callback( |
| 10265 | struct wlan_objmgr_psoc *psoc) |
| 10266 | { |
| 10267 | if (QDF_STATUS_SUCCESS != |
| 10268 | policy_mgr_deregister_hdd_cb(psoc)) { |
| 10269 | hdd_err("HDD callback deregister with policy manager failed"); |
| 10270 | } |
| 10271 | } |
| 10272 | #else |
| 10273 | static void hdd_deregister_policy_manager_callback( |
| 10274 | struct wlan_objmgr_psoc *psoc) |
| 10275 | { |
| 10276 | } |
| 10277 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10278 | |
| 10279 | /** |
| 10280 | * hdd_wlan_stop_modules - Single driver state machine for stoping modules |
| 10281 | * @hdd_ctx: HDD context |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 10282 | * @ftm_mode: ftm mode |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10283 | * |
| 10284 | * This function maintains the driver state machine it will be invoked from |
| 10285 | * exit, shutdown and con_mode change handler. Depending on the driver state |
| 10286 | * shall perform the stopping/closing of the modules. |
| 10287 | * |
| 10288 | * Return: 0 for success; non-zero for failure |
| 10289 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10290 | 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] | 10291 | { |
| 10292 | void *hif_ctx; |
| 10293 | qdf_device_t qdf_ctx; |
| 10294 | QDF_STATUS qdf_status; |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10295 | int ret = 0; |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 10296 | bool is_recovery_stop = cds_is_driver_recovering(); |
Liangwei Dong | a78cc1d | 2018-02-01 02:19:30 -0500 | [diff] [blame] | 10297 | bool is_idle_stop = !cds_is_driver_unloading() && !is_recovery_stop && |
| 10298 | !cds_is_driver_loading(); |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10299 | int active_threads; |
Arunk Khandavalli | a6305a3 | 2018-01-25 11:19:18 +0530 | [diff] [blame] | 10300 | struct target_psoc_info *tgt_hdl; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10301 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10302 | hdd_enter(); |
Yun Park | fec73dc | 2017-09-06 10:40:07 -0700 | [diff] [blame] | 10303 | hdd_alert("stop WLAN module: entering driver status=%d", |
| 10304 | hdd_ctx->driver_status); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10305 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 10306 | hdd_deregister_policy_manager_callback(hdd_ctx->hdd_psoc); |
| 10307 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10308 | qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 10309 | if (!qdf_ctx) { |
| 10310 | hdd_err("QDF device context NULL"); |
| 10311 | return -EINVAL; |
| 10312 | } |
| 10313 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10314 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 10315 | hdd_ctx->stop_modules_in_progress = true; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 10316 | cds_set_module_stop_in_progress(true); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10317 | |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10318 | active_threads = cds_return_external_threads_count(); |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 10319 | if (active_threads > 0 || hdd_ctx->is_wiphy_suspended) { |
Rajeev Kumar | 86177c2 | 2017-03-16 19:44:39 -0700 | [diff] [blame] | 10320 | hdd_warn("External threads %d wiphy suspend %d", |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 10321 | active_threads, hdd_ctx->is_wiphy_suspended); |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10322 | |
| 10323 | cds_print_external_threads(); |
| 10324 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 10325 | if (is_idle_stop && !ftm_mode) { |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10326 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 10327 | qdf_sched_delayed_work(&hdd_ctx->iface_idle_work, |
| 10328 | hdd_ctx->config->iface_change_wait_time); |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 10329 | hdd_prevent_suspend_timeout( |
| 10330 | hdd_ctx->config->iface_change_wait_time, |
| 10331 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER); |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 10332 | hdd_ctx->stop_modules_in_progress = false; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 10333 | cds_set_module_stop_in_progress(false); |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10334 | return 0; |
| 10335 | } |
Rajeev Kumar | 86177c2 | 2017-03-16 19:44:39 -0700 | [diff] [blame] | 10336 | } |
| 10337 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10338 | hdd_info("Present Driver Status: %d", hdd_ctx->driver_status); |
| 10339 | |
Kabilan Kannan | 6edafeb | 2017-11-16 16:34:34 -0800 | [diff] [blame] | 10340 | /* free user wowl patterns */ |
| 10341 | hdd_free_user_wowl_ptrns(); |
| 10342 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10343 | switch (hdd_ctx->driver_status) { |
| 10344 | case DRIVER_MODULES_UNINITIALIZED: |
| 10345 | hdd_info("Modules not initialized just return"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10346 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10347 | case DRIVER_MODULES_CLOSED: |
| 10348 | hdd_info("Modules already closed"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10349 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10350 | case DRIVER_MODULES_ENABLED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10351 | hdd_info("Wlan transitioning (OPENED <- ENABLED)"); |
| 10352 | |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 10353 | hdd_disable_power_management(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10354 | if (hdd_deconfigure_cds(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10355 | hdd_err("Failed to de-configure CDS"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10356 | QDF_ASSERT(0); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10357 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10358 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10359 | hdd_debug("successfully Disabled the CDS modules!"); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10360 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10361 | hdd_ctx->driver_status = DRIVER_MODULES_OPENED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10362 | hdd_info("Wlan transitioned (now OPENED)"); |
| 10363 | |
| 10364 | /* fall through */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10365 | case DRIVER_MODULES_OPENED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10366 | hdd_info("Wlan transitioning (CLOSED <- OPENED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10367 | break; |
| 10368 | default: |
| 10369 | hdd_err("Trying to stop wlan in a wrong state: %d", |
| 10370 | hdd_ctx->driver_status); |
| 10371 | QDF_ASSERT(0); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10372 | ret = -EINVAL; |
| 10373 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10374 | } |
| 10375 | |
Amar Singhal | 1808164 | 2018-01-26 16:04:13 -0800 | [diff] [blame] | 10376 | hdd_sysfs_destroy_version_interface(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10377 | hdd_debug("Closing CDS modules!"); |
Amar Singhal | 1808164 | 2018-01-26 16:04:13 -0800 | [diff] [blame] | 10378 | |
Rajeev Kumar | be02124 | 2017-02-16 16:12:23 -0800 | [diff] [blame] | 10379 | qdf_status = cds_post_disable(); |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 10380 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 10381 | hdd_err("Failed to process post CDS disable Modules! :%d", |
| 10382 | qdf_status); |
| 10383 | ret = -EINVAL; |
| 10384 | QDF_ASSERT(0); |
| 10385 | } |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 10386 | |
psimha | deea0a1 | 2017-12-18 14:50:02 -0800 | [diff] [blame] | 10387 | hdd_runtime_suspend_context_deinit(hdd_ctx); |
| 10388 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 10389 | qdf_status = cds_dp_close(hdd_ctx->hdd_psoc); |
| 10390 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 10391 | hdd_warn("Failed to stop CDS DP: %d", qdf_status); |
| 10392 | ret = -EINVAL; |
| 10393 | QDF_ASSERT(0); |
| 10394 | } |
| 10395 | |
Jeff Johnson | e4b1459 | 2017-09-13 14:23:33 -0700 | [diff] [blame] | 10396 | qdf_status = cds_close(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10397 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10398 | hdd_warn("Failed to stop CDS: %d", qdf_status); |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 10399 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10400 | QDF_ASSERT(0); |
| 10401 | } |
Krunal Soni | d32c6bc | 2016-10-18 18:00:21 -0700 | [diff] [blame] | 10402 | |
Amar Singhal | 410675c | 2018-01-10 12:14:21 -0800 | [diff] [blame] | 10403 | dispatcher_pdev_close(hdd_ctx->hdd_pdev); |
Liangwei Dong | 50a64a7 | 2018-01-11 01:17:00 -0500 | [diff] [blame] | 10404 | ret = hdd_objmgr_release_and_destroy_pdev(hdd_ctx); |
| 10405 | if (ret) { |
| 10406 | hdd_err("Failed to destroy pdev; errno:%d", ret); |
| 10407 | QDF_ASSERT(0); |
| 10408 | } |
| 10409 | |
| 10410 | /* |
| 10411 | * Reset total mac phy during module stop such that during |
| 10412 | * next module start same psoc is used to populate new service |
| 10413 | * ready data |
| 10414 | */ |
Arunk Khandavalli | a6305a3 | 2018-01-25 11:19:18 +0530 | [diff] [blame] | 10415 | tgt_hdl = wlan_psoc_get_tgt_if_handle(hdd_ctx->hdd_psoc); |
| 10416 | if (tgt_hdl) |
| 10417 | target_psoc_set_total_mac_phy_cnt(tgt_hdl, 0); |
| 10418 | |
Liangwei Dong | 50a64a7 | 2018-01-11 01:17:00 -0500 | [diff] [blame] | 10419 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10420 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 10421 | if (!hif_ctx) { |
| 10422 | hdd_err("Hif context is Null"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10423 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10424 | } |
| 10425 | |
Arunk Khandavalli | 4b40433 | 2017-09-26 12:46:00 +0530 | [diff] [blame] | 10426 | if (hdd_ctx->target_hw_name) { |
| 10427 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 10428 | hdd_ctx->target_hw_name = NULL; |
| 10429 | } |
| 10430 | |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 10431 | hdd_hif_close(hdd_ctx, hif_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10432 | |
| 10433 | ol_cds_free(); |
| 10434 | |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10435 | if (is_idle_stop) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10436 | ret = pld_power_off(qdf_ctx->dev); |
| 10437 | if (ret) |
| 10438 | hdd_err("CNSS power down failed put device into Low power mode:%d", |
| 10439 | ret); |
| 10440 | } |
Arunk Khandavalli | 847969d | 2017-09-25 15:15:36 +0530 | [diff] [blame] | 10441 | |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 10442 | /* many adapter resources are not freed by design in SSR case */ |
| 10443 | if (!is_recovery_stop) |
| 10444 | hdd_check_for_leaks(); |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 10445 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_INIT); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 10446 | |
Arunk Khandavalli | 847969d | 2017-09-25 15:15:36 +0530 | [diff] [blame] | 10447 | /* Once the firmware sequence is completed reset this flag */ |
| 10448 | hdd_ctx->imps_enabled = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10449 | hdd_ctx->driver_status = DRIVER_MODULES_CLOSED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10450 | hdd_info("Wlan transitioned (now CLOSED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10451 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10452 | done: |
| 10453 | hdd_ctx->stop_modules_in_progress = false; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 10454 | cds_set_module_stop_in_progress(false); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10455 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Yun Park | fec73dc | 2017-09-06 10:40:07 -0700 | [diff] [blame] | 10456 | hdd_alert("stop WLAN module: exit driver status=%d", |
| 10457 | hdd_ctx->driver_status); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 10458 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10459 | hdd_exit(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10460 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10461 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10462 | } |
| 10463 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10464 | |
| 10465 | /** |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10466 | * hdd_state_info_dump() - prints state information of hdd layer |
| 10467 | * @buf: buffer pointer |
| 10468 | * @size: size of buffer to be filled |
| 10469 | * |
| 10470 | * This function is used to dump state information of hdd layer |
| 10471 | * |
| 10472 | * Return: None |
| 10473 | */ |
| 10474 | static void hdd_state_info_dump(char **buf_ptr, uint16_t *size) |
| 10475 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10476 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 10477 | struct hdd_station_ctx *hdd_sta_ctx; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10478 | struct hdd_adapter *adapter; |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10479 | uint16_t len = 0; |
| 10480 | char *buf = *buf_ptr; |
| 10481 | |
| 10482 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 10483 | if (!hdd_ctx) { |
| 10484 | hdd_err("Failed to get hdd context "); |
| 10485 | return; |
| 10486 | } |
| 10487 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10488 | hdd_debug("size of buffer: %d", *size); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10489 | |
| 10490 | len += scnprintf(buf + len, *size - len, |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 10491 | "\n is_wiphy_suspended %d", hdd_ctx->is_wiphy_suspended); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10492 | len += scnprintf(buf + len, *size - len, |
Rajeev Kumar | eada0d0 | 2016-12-08 17:44:17 -0800 | [diff] [blame] | 10493 | "\n is_scheduler_suspended %d", |
| 10494 | hdd_ctx->is_scheduler_suspended); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10495 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 10496 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10497 | if (adapter->dev) |
| 10498 | len += scnprintf(buf + len, *size - len, |
| 10499 | "\n device name: %s", adapter->dev->name); |
wadesong | 42968e9 | 2017-06-08 14:11:21 +0800 | [diff] [blame] | 10500 | len += scnprintf(buf + len, *size - len, |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10501 | "\n device_mode: %d", adapter->device_mode); |
| 10502 | switch (adapter->device_mode) { |
| 10503 | case QDF_STA_MODE: |
| 10504 | case QDF_P2P_CLIENT_MODE: |
| 10505 | hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 10506 | len += scnprintf(buf + len, *size - len, |
| 10507 | "\n connState: %d", |
| 10508 | hdd_sta_ctx->conn_info.connState); |
| 10509 | break; |
| 10510 | |
| 10511 | default: |
| 10512 | break; |
| 10513 | } |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10514 | } |
| 10515 | |
| 10516 | *size -= len; |
| 10517 | *buf_ptr += len; |
| 10518 | } |
| 10519 | |
| 10520 | /** |
| 10521 | * hdd_register_debug_callback() - registration function for hdd layer |
| 10522 | * to print hdd state information |
| 10523 | * |
| 10524 | * Return: None |
| 10525 | */ |
| 10526 | static void hdd_register_debug_callback(void) |
| 10527 | { |
| 10528 | qdf_register_debug_callback(QDF_MODULE_ID_HDD, &hdd_state_info_dump); |
| 10529 | } |
| 10530 | |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 10531 | /* |
| 10532 | * wlan_init_bug_report_lock() - Initialize bug report lock |
| 10533 | * |
| 10534 | * This function is used to create bug report lock |
| 10535 | * |
| 10536 | * Return: None |
| 10537 | */ |
| 10538 | static void wlan_init_bug_report_lock(void) |
| 10539 | { |
| 10540 | p_cds_contextType p_cds_context; |
| 10541 | |
| 10542 | p_cds_context = cds_get_global_context(); |
| 10543 | if (!p_cds_context) { |
| 10544 | hdd_err("cds context is NULL"); |
| 10545 | return; |
| 10546 | } |
| 10547 | |
| 10548 | qdf_spinlock_create(&p_cds_context->bug_report_lock); |
| 10549 | } |
| 10550 | |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10551 | void hdd_dp_trace_init(struct hdd_config *config) |
| 10552 | { |
| 10553 | |
| 10554 | bool live_mode = DP_TRACE_CONFIG_DEFAULT_LIVE_MODE; |
| 10555 | uint8_t thresh = DP_TRACE_CONFIG_DEFAULT_THRESH; |
| 10556 | uint16_t thresh_time_limit = DP_TRACE_CONFIG_DEFAULT_THRESH_TIME_LIMIT; |
| 10557 | uint8_t verbosity = DP_TRACE_CONFIG_DEFAULT_VERBOSTY; |
| 10558 | uint8_t proto_bitmap = DP_TRACE_CONFIG_DEFAULT_BITMAP; |
| 10559 | uint8_t config_params[DP_TRACE_CONFIG_NUM_PARAMS]; |
| 10560 | uint8_t num_entries = 0; |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 10561 | uint32_t bw_compute_interval; |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10562 | |
| 10563 | hdd_string_to_u8_array(config->dp_trace_config, config_params, |
| 10564 | &num_entries, sizeof(config_params)); |
| 10565 | |
| 10566 | /* calculating, num bw timer intervals in a second (1000ms) */ |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 10567 | bw_compute_interval = GET_BW_COMPUTE_INTV(config); |
Jiachao Wu | 1b00ecb | 2017-07-05 19:13:41 +0800 | [diff] [blame] | 10568 | if (bw_compute_interval <= 1000 && bw_compute_interval > 0) |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 10569 | thresh_time_limit = 1000 / bw_compute_interval; |
Jiachao Wu | 1b00ecb | 2017-07-05 19:13:41 +0800 | [diff] [blame] | 10570 | else if (bw_compute_interval > 1000) { |
| 10571 | hdd_err("busBandwidthComputeInterval > 1000, using 1000"); |
| 10572 | thresh_time_limit = 1; |
| 10573 | } else |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10574 | hdd_err("busBandwidthComputeInterval is 0, using defaults"); |
| 10575 | |
| 10576 | switch (num_entries) { |
| 10577 | case 4: |
| 10578 | proto_bitmap = config_params[3]; |
| 10579 | case 3: |
| 10580 | verbosity = config_params[2]; |
| 10581 | case 2: |
| 10582 | thresh = config_params[1]; |
| 10583 | case 1: |
| 10584 | live_mode = config_params[0]; |
| 10585 | default: |
Rajeev Kumar | 3887f9b | 2018-01-10 11:24:01 -0800 | [diff] [blame] | 10586 | 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] | 10587 | live_mode, thresh, thresh_time_limit, |
| 10588 | verbosity, proto_bitmap); |
| 10589 | }; |
| 10590 | |
| 10591 | qdf_dp_trace_init(live_mode, thresh, thresh_time_limit, |
| 10592 | verbosity, proto_bitmap); |
| 10593 | |
| 10594 | } |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10595 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10596 | * hdd_wlan_startup() - HDD init function |
| 10597 | * @dev: Pointer to the underlying device |
| 10598 | * |
| 10599 | * This is the driver startup code executed once a WLAN device has been detected |
| 10600 | * |
| 10601 | * Return: 0 for success, < 0 for failure |
| 10602 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10603 | int hdd_wlan_startup(struct device *dev) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10604 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10605 | QDF_STATUS status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10606 | struct hdd_context *hdd_ctx; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10607 | int ret; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 10608 | bool rtnl_held; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10609 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10610 | hdd_enter(); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10611 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10612 | hdd_ctx = hdd_context_create(dev); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10613 | |
| 10614 | if (IS_ERR(hdd_ctx)) |
| 10615 | return PTR_ERR(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10616 | |
Abhishek Singh | e9068f1 | 2017-03-31 14:14:52 +0530 | [diff] [blame] | 10617 | ret = hdd_objmgr_create_and_store_psoc(hdd_ctx, |
| 10618 | DEFAULT_PSOC_ID); |
| 10619 | if (ret) { |
| 10620 | hdd_err("Psoc creation fails!"); |
| 10621 | QDF_BUG(0); |
| 10622 | goto err_hdd_free_context; |
| 10623 | } |
| 10624 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 10625 | qdf_nbuf_init_replenish_timer(); |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 10626 | #ifdef FEATURE_WLAN_CH_AVOID |
| 10627 | mutex_init(&hdd_ctx->avoid_freq_lock); |
| 10628 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10629 | |
Jeff Johnson | ce0032c | 2017-01-20 07:18:27 -0800 | [diff] [blame] | 10630 | hdd_request_manager_init(); |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 10631 | qdf_atomic_init(&hdd_ctx->con_mode_flag); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10632 | |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 10633 | hdd_driver_memdump_init(); |
| 10634 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 10635 | ret = hdd_wlan_start_modules(hdd_ctx, NULL, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10636 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10637 | hdd_err("Failed to start modules: %d", ret); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 10638 | goto err_memdump_deinit; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10639 | } |
| 10640 | |
Yingying Tang | 80e15f3 | 2016-09-27 18:23:01 +0800 | [diff] [blame] | 10641 | wlan_hdd_update_wiphy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10642 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 10643 | hdd_ctx->hHal = cds_get_context(QDF_MODULE_ID_SME); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10644 | |
| 10645 | if (NULL == hdd_ctx->hHal) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10646 | hdd_err("HAL context is null"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10647 | goto err_stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10648 | } |
| 10649 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10650 | ret = hdd_wiphy_init(hdd_ctx); |
| 10651 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10652 | hdd_err("Failed to initialize wiphy: %d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10653 | goto err_stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10654 | } |
| 10655 | |
Nirav Shah | cc1f1ae | 2016-04-26 11:41:29 +0530 | [diff] [blame] | 10656 | if (hdd_ctx->config->enable_dp_trace) |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10657 | hdd_dp_trace_init(hdd_ctx->config); |
Nirav Shah | cc1f1ae | 2016-04-26 11:41:29 +0530 | [diff] [blame] | 10658 | |
Yuanyuan Liu | c98370e | 2016-10-13 11:22:13 -0700 | [diff] [blame] | 10659 | hdd_initialize_mac_address(hdd_ctx); |
Prashanth Bhatta | 75fa9a1 | 2016-01-11 18:30:08 -0800 | [diff] [blame] | 10660 | |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 10661 | ret = register_netdevice_notifier(&hdd_netdev_notifier); |
| 10662 | if (ret) { |
| 10663 | hdd_err("register_netdevice_notifier failed: %d", ret); |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 10664 | goto err_wiphy_unregister; |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 10665 | } |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 10666 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 10667 | rtnl_held = hdd_hold_rtnl_lock(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10668 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 10669 | ret = hdd_open_interfaces(hdd_ctx, rtnl_held); |
| 10670 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10671 | hdd_err("Failed to open interfaces: %d", ret); |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 10672 | goto err_release_rtnl_lock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10673 | } |
| 10674 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 10675 | hdd_release_rtnl_lock(); |
| 10676 | rtnl_held = false; |
| 10677 | |
Yingying Tang | 3ba3dbc | 2016-09-27 16:36:58 +0800 | [diff] [blame] | 10678 | wlan_hdd_update_11n_mode(hdd_ctx->config); |
| 10679 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10680 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 10681 | status = qdf_mc_timer_init(&hdd_ctx->skip_acs_scan_timer, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 10682 | QDF_TIMER_TYPE_SW, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10683 | hdd_skip_acs_scan_timer_handler, |
| 10684 | (void *)hdd_ctx); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10685 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 10686 | hdd_err("Failed to init ACS Skip timer"); |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 10687 | qdf_spinlock_create(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10688 | #endif |
| 10689 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 10690 | hdd_bus_bandwidth_init(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10691 | |
Jeff Johnson | 9afc501 | 2016-09-23 13:56:27 -0700 | [diff] [blame] | 10692 | hdd_lpass_notify_start(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10693 | |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 10694 | if (hdd_ctx->rps) |
| 10695 | hdd_set_rps_cpu_mask(hdd_ctx); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10696 | |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 10697 | ret = hdd_register_notifiers(hdd_ctx); |
| 10698 | if (ret) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 10699 | goto err_close_adapters; |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 10700 | |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 10701 | status = wlansap_global_init(); |
| 10702 | if (QDF_IS_STATUS_ERROR(status)) { |
| 10703 | hdd_unregister_notifiers(hdd_ctx); |
| 10704 | goto err_close_adapters; |
| 10705 | } |
| 10706 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10707 | if (hdd_ctx->config->fIsImpsEnabled) |
| 10708 | hdd_set_idle_ps_config(hdd_ctx, true); |
Kiran Kumar Lokere | b0f19c3 | 2017-10-13 12:23:26 -0700 | [diff] [blame] | 10709 | else |
| 10710 | hdd_set_idle_ps_config(hdd_ctx, false); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10711 | |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 10712 | if (QDF_GLOBAL_FTM_MODE != hdd_get_conparam()) { |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 10713 | qdf_sched_delayed_work(&hdd_ctx->iface_idle_work, |
| 10714 | hdd_ctx->config->iface_change_wait_time); |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 10715 | hdd_prevent_suspend_timeout( |
| 10716 | hdd_ctx->config->iface_change_wait_time, |
| 10717 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER); |
| 10718 | } |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 10719 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10720 | goto success; |
| 10721 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 10722 | err_close_adapters: |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 10723 | hdd_close_all_adapters(hdd_ctx, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10724 | |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 10725 | err_release_rtnl_lock: |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10726 | if (rtnl_held) |
| 10727 | hdd_release_rtnl_lock(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10728 | |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 10729 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 10730 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10731 | err_wiphy_unregister: |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10732 | wiphy_unregister(hdd_ctx->wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10733 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10734 | err_stop_modules: |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 10735 | hdd_wlan_stop_modules(hdd_ctx, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10736 | |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 10737 | err_memdump_deinit: |
| 10738 | hdd_driver_memdump_deinit(); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 10739 | |
Jeff Johnson | ce0032c | 2017-01-20 07:18:27 -0800 | [diff] [blame] | 10740 | hdd_request_manager_deinit(); |
Ryan Hsu | cfef0ae | 2016-04-28 10:20:46 -0700 | [diff] [blame] | 10741 | hdd_exit_netlink_services(hdd_ctx); |
| 10742 | |
Dustin Brown | 2091246 | 2017-06-07 13:48:25 -0700 | [diff] [blame] | 10743 | hdd_objmgr_release_and_destroy_psoc(hdd_ctx); |
| 10744 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10745 | err_hdd_free_context: |
Nachiket Kukade | 8003d25 | 2017-03-30 15:55:58 +0530 | [diff] [blame] | 10746 | if (cds_is_fw_down()) |
| 10747 | hdd_err("Not setting the complete event as fw is down"); |
| 10748 | else |
| 10749 | hdd_start_complete(ret); |
| 10750 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 10751 | qdf_nbuf_deinit_replenish_timer(); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 10752 | hdd_context_destroy(hdd_ctx); |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 10753 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10754 | |
| 10755 | success: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10756 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10757 | return 0; |
| 10758 | } |
| 10759 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10760 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10761 | * hdd_wlan_update_target_info() - update target type info |
| 10762 | * @hdd_ctx: HDD context |
| 10763 | * @context: hif context |
| 10764 | * |
| 10765 | * Update target info received from firmware in hdd context |
| 10766 | * Return:None |
| 10767 | */ |
| 10768 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10769 | 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] | 10770 | { |
| 10771 | struct hif_target_info *tgt_info = hif_get_target_info_handle(context); |
| 10772 | |
| 10773 | if (!tgt_info) { |
| 10774 | hdd_err("Target info is Null"); |
| 10775 | return; |
| 10776 | } |
| 10777 | |
| 10778 | hdd_ctx->target_type = tgt_info->target_type; |
| 10779 | } |
| 10780 | |
| 10781 | /** |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10782 | * hdd_get_nud_stats_cb() - callback api to update the stats |
| 10783 | * received from the firmware |
| 10784 | * @data: pointer to adapter. |
| 10785 | * @rsp: pointer to data received from FW. |
| 10786 | * |
| 10787 | * This is called when wlan driver received response event for |
| 10788 | * get arp stats to firmware. |
| 10789 | * |
| 10790 | * Return: None |
| 10791 | */ |
| 10792 | static void hdd_get_nud_stats_cb(void *data, struct rsp_stats *rsp) |
| 10793 | { |
| 10794 | struct hdd_context *hdd_ctx = (struct hdd_context *)data; |
| 10795 | struct hdd_nud_stats_context *context; |
| 10796 | int status; |
| 10797 | struct hdd_adapter *adapter = NULL; |
| 10798 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10799 | hdd_enter(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10800 | |
| 10801 | if (!rsp) { |
| 10802 | hdd_err("data is null"); |
| 10803 | return; |
| 10804 | } |
| 10805 | |
| 10806 | status = wlan_hdd_validate_context(hdd_ctx); |
| 10807 | if (0 != status) |
| 10808 | return; |
| 10809 | |
| 10810 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, rsp->vdev_id); |
| 10811 | if ((NULL == adapter) || (WLAN_HDD_ADAPTER_MAGIC != adapter->magic)) { |
| 10812 | hdd_err("Invalid adapter or adapter has invalid magic"); |
| 10813 | return; |
| 10814 | } |
| 10815 | |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 10816 | hdd_info("rsp->arp_req_enqueue :%x", rsp->arp_req_enqueue); |
| 10817 | hdd_info("rsp->arp_req_tx_success :%x", rsp->arp_req_tx_success); |
| 10818 | hdd_info("rsp->arp_req_tx_failure :%x", rsp->arp_req_tx_failure); |
| 10819 | hdd_info("rsp->arp_rsp_recvd :%x", rsp->arp_rsp_recvd); |
| 10820 | hdd_info("rsp->out_of_order_arp_rsp_drop_cnt :%x", |
| 10821 | rsp->out_of_order_arp_rsp_drop_cnt); |
| 10822 | hdd_info("rsp->dad_detected :%x", rsp->dad_detected); |
| 10823 | hdd_info("rsp->connect_status :%x", rsp->connect_status); |
| 10824 | hdd_info("rsp->ba_session_establishment_status :%x", |
| 10825 | rsp->ba_session_establishment_status); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10826 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10827 | 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] | 10828 | adapter->dad |= rsp->dad_detected; |
| 10829 | adapter->con_status = rsp->connect_status; |
| 10830 | |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 10831 | /* Flag true indicates connectivity check stats present. */ |
| 10832 | if (rsp->connect_stats_present) { |
| 10833 | hdd_info("rsp->tcp_ack_recvd :%x", rsp->tcp_ack_recvd); |
| 10834 | hdd_info("rsp->icmpv4_rsp_recvd :%x", rsp->icmpv4_rsp_recvd); |
| 10835 | adapter->hdd_stats.hdd_tcp_stats.rx_fw_cnt = rsp->tcp_ack_recvd; |
| 10836 | adapter->hdd_stats.hdd_icmpv4_stats.rx_fw_cnt = |
| 10837 | rsp->icmpv4_rsp_recvd; |
| 10838 | } |
| 10839 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10840 | spin_lock(&hdd_context_lock); |
| 10841 | context = &hdd_ctx->nud_stats_context; |
| 10842 | complete(&context->response_event); |
| 10843 | spin_unlock(&hdd_context_lock); |
| 10844 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10845 | hdd_exit(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10846 | } |
| 10847 | |
| 10848 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10849 | * hdd_register_cb - Register HDD callbacks. |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10850 | * @hdd_ctx: HDD context |
| 10851 | * |
| 10852 | * Register the HDD callbacks to CDS/SME. |
| 10853 | * |
| 10854 | * Return: 0 for success or Error code for failure |
| 10855 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10856 | int hdd_register_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10857 | { |
| 10858 | QDF_STATUS status; |
| 10859 | int ret = 0; |
| 10860 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10861 | hdd_enter(); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10862 | |
| 10863 | sme_register11d_scan_done_callback(hdd_ctx->hHal, hdd_11d_scan_done); |
| 10864 | |
| 10865 | sme_register_oem_data_rsp_callback(hdd_ctx->hHal, |
| 10866 | hdd_send_oem_data_rsp_msg); |
| 10867 | |
Deepthi Gowri | d5a58fe | 2016-09-03 16:01:28 +0530 | [diff] [blame] | 10868 | sme_register_mgmt_frame_ind_callback(hdd_ctx->hHal, |
| 10869 | hdd_indicate_mgmt_frame); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10870 | sme_set_tsfcb(hdd_ctx->hHal, hdd_get_tsf_cb, hdd_ctx); |
| 10871 | sme_nan_register_callback(hdd_ctx->hHal, |
| 10872 | wlan_hdd_cfg80211_nan_callback); |
| 10873 | sme_stats_ext_register_callback(hdd_ctx->hHal, |
| 10874 | wlan_hdd_cfg80211_stats_ext_callback); |
| 10875 | |
| 10876 | sme_ext_scan_register_callback(hdd_ctx->hHal, |
| 10877 | wlan_hdd_cfg80211_extscan_callback); |
lifeng | 6683166 | 2017-05-19 16:01:35 +0800 | [diff] [blame] | 10878 | sme_stats_ext2_register_callback(hdd_ctx->hHal, |
| 10879 | wlan_hdd_cfg80211_stats_ext2_callback); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10880 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10881 | sme_set_rssi_threshold_breached_cb(hdd_ctx->hHal, |
| 10882 | hdd_rssi_threshold_breached); |
| 10883 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10884 | sme_set_nud_debug_stats_cb(hdd_ctx->hHal, hdd_get_nud_stats_cb); |
| 10885 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10886 | sme_set_link_layer_stats_ind_cb(hdd_ctx->hHal, |
| 10887 | wlan_hdd_cfg80211_link_layer_stats_callback); |
| 10888 | |
Sreelakshmi Konamki | 88a2a41 | 2017-04-14 15:11:55 +0530 | [diff] [blame] | 10889 | sme_rso_cmd_status_cb(hdd_ctx->hHal, wlan_hdd_rso_cmd_status_cb); |
| 10890 | |
Zhang Qian | ca38fb1 | 2016-12-23 11:10:48 +0800 | [diff] [blame] | 10891 | sme_set_link_layer_ext_cb(hdd_ctx->hHal, |
| 10892 | wlan_hdd_cfg80211_link_layer_stats_ext_callback); |
| 10893 | |
Sreelakshmi Konamki | 58c7243 | 2016-11-09 17:06:44 +0530 | [diff] [blame] | 10894 | status = sme_set_lost_link_info_cb(hdd_ctx->hHal, |
| 10895 | hdd_lost_link_info_cb); |
| 10896 | /* print error and not block the startup process */ |
| 10897 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10898 | hdd_err("set lost link info callback failed"); |
| 10899 | |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 10900 | ret = hdd_register_data_stall_detect_cb(); |
| 10901 | if (ret) { |
| 10902 | hdd_err("Register data stall detect detect callback failed."); |
| 10903 | return ret; |
| 10904 | } |
| 10905 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10906 | wlan_hdd_dcc_register_for_dcc_stats_event(hdd_ctx); |
| 10907 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 10908 | sme_register_set_connection_info_cb(hdd_ctx->hHal, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 10909 | hdd_set_connection_in_progress, |
| 10910 | hdd_is_connection_in_progress); |
Padma, Santhosh Kumar | 16dacfb | 2017-03-21 19:05:40 +0530 | [diff] [blame] | 10911 | |
| 10912 | status = sme_congestion_register_callback(hdd_ctx->hHal, |
| 10913 | hdd_update_cca_info_cb); |
| 10914 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10915 | hdd_err("set congestion callback failed"); |
| 10916 | |
Vidyullatha Kanchanapally | be0ebb3 | 2017-03-23 14:36:21 +0530 | [diff] [blame] | 10917 | status = sme_set_bt_activity_info_cb(hdd_ctx->hHal, |
| 10918 | hdd_bt_activity_cb); |
| 10919 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10920 | hdd_err("set bt activity info callback failed"); |
| 10921 | |
Varun Reddy Yeturu | 076eaa8 | 2018-01-16 12:16:14 -0800 | [diff] [blame] | 10922 | status = sme_register_tx_queue_cb(hdd_ctx->hHal, |
| 10923 | hdd_tx_queue_cb); |
| 10924 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10925 | hdd_err("Register tx queue callback failed"); |
| 10926 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10927 | hdd_exit(); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10928 | |
| 10929 | return ret; |
| 10930 | } |
| 10931 | |
| 10932 | /** |
| 10933 | * hdd_deregister_cb() - De-Register HDD callbacks. |
| 10934 | * @hdd_ctx: HDD context |
| 10935 | * |
| 10936 | * De-Register the HDD callbacks to CDS/SME. |
| 10937 | * |
| 10938 | * Return: void |
| 10939 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10940 | void hdd_deregister_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10941 | { |
| 10942 | QDF_STATUS status; |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 10943 | int ret; |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10944 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10945 | hdd_enter(); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10946 | |
Varun Reddy Yeturu | 076eaa8 | 2018-01-16 12:16:14 -0800 | [diff] [blame] | 10947 | sme_deregister_tx_queue_cb(hdd_ctx->hHal); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10948 | status = sme_deregister_for_dcc_stats_event(hdd_ctx->hHal); |
| 10949 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10950 | hdd_err("De-register of dcc stats callback failed: %d", |
| 10951 | status); |
| 10952 | |
| 10953 | sme_reset_link_layer_stats_ind_cb(hdd_ctx->hHal); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10954 | sme_reset_rssi_threshold_breached_cb(hdd_ctx->hHal); |
| 10955 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10956 | sme_stats_ext_register_callback(hdd_ctx->hHal, |
| 10957 | wlan_hdd_cfg80211_stats_ext_callback); |
| 10958 | |
| 10959 | sme_nan_deregister_callback(hdd_ctx->hHal); |
| 10960 | status = sme_reset_tsfcb(hdd_ctx->hHal); |
| 10961 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10962 | hdd_err("Failed to de-register tsfcb the callback:%d", |
| 10963 | status); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10964 | |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 10965 | ret = hdd_deregister_data_stall_detect_cb(); |
| 10966 | if (ret) |
| 10967 | hdd_err("Failed to de-register data stall detect event callback"); |
| 10968 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10969 | sme_deregister_oem_data_rsp_callback(hdd_ctx->hHal); |
| 10970 | sme_deregister11d_scan_done_callback(hdd_ctx->hHal); |
| 10971 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10972 | hdd_exit(); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10973 | } |
| 10974 | |
| 10975 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10976 | * hdd_softap_sta_deauth() - handle deauth req from HDD |
| 10977 | * @adapter: Pointer to the HDD |
| 10978 | * @enable: bool value |
| 10979 | * |
| 10980 | * This to take counter measure to handle deauth req from HDD |
| 10981 | * |
| 10982 | * Return: None |
| 10983 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10984 | QDF_STATUS hdd_softap_sta_deauth(struct hdd_adapter *adapter, |
Jeff Johnson | e6bf719 | 2017-11-07 15:16:09 -0800 | [diff] [blame] | 10985 | struct csr_del_sta_params *pDelStaParams) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10986 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10987 | QDF_STATUS qdf_status = QDF_STATUS_E_FAULT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10988 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10989 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10990 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10991 | /* Ignore request to deauth bcmc station */ |
| 10992 | if (pDelStaParams->peerMacAddr.bytes[0] & 0x1) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10993 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10994 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10995 | qdf_status = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10996 | wlansap_deauth_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 10997 | pDelStaParams); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10998 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10999 | hdd_exit(); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11000 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11001 | } |
| 11002 | |
| 11003 | /** |
| 11004 | * hdd_softap_sta_disassoc() - take counter measure to handle deauth req from HDD |
| 11005 | * @adapter: Pointer to the HDD |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 11006 | * @p_del_sta_params: pointer to station deletion parameters |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11007 | * |
| 11008 | * This to take counter measure to handle deauth req from HDD |
| 11009 | * |
| 11010 | * Return: None |
| 11011 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11012 | void hdd_softap_sta_disassoc(struct hdd_adapter *adapter, |
Jeff Johnson | e6bf719 | 2017-11-07 15:16:09 -0800 | [diff] [blame] | 11013 | struct csr_del_sta_params *pDelStaParams) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11014 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11015 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11016 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11017 | /* Ignore request to disassoc bcmc station */ |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 11018 | if (pDelStaParams->peerMacAddr.bytes[0] & 0x1) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11019 | return; |
| 11020 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11021 | wlansap_disassoc_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 11022 | pDelStaParams); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11023 | } |
| 11024 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11025 | /** |
| 11026 | * hdd_issta_p2p_clientconnected() - check if sta or p2p client is connected |
| 11027 | * @hdd_ctx: HDD Context |
| 11028 | * |
| 11029 | * API to find if there is any STA or P2P-Client is connected |
| 11030 | * |
| 11031 | * Return: true if connected; false otherwise |
| 11032 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11033 | QDF_STATUS hdd_issta_p2p_clientconnected(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11034 | { |
| 11035 | return sme_is_sta_p2p_client_connected(hdd_ctx->hHal); |
| 11036 | } |
| 11037 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11038 | /** |
| 11039 | * wlan_hdd_disable_roaming() - disable roaming on all STAs except the input one |
| 11040 | * @adapter: HDD adapter pointer |
| 11041 | * |
| 11042 | * This function loop through each adapter and disable roaming on each STA |
| 11043 | * device mode except the input adapter. |
| 11044 | * |
| 11045 | * Note: On the input adapter roaming is not enabled yet hence no need to |
| 11046 | * disable. |
| 11047 | * |
| 11048 | * Return: None |
| 11049 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11050 | void wlan_hdd_disable_roaming(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11051 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11052 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11053 | struct hdd_adapter *adapterIdx = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11054 | |
| 11055 | if (hdd_ctx->config->isFastRoamIniFeatureEnabled && |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 11056 | hdd_ctx->config->isRoamOffloadScanEnabled && |
| 11057 | QDF_STA_MODE == adapter->device_mode && |
| 11058 | policy_mgr_is_sta_active_connection_exists( |
| 11059 | hdd_ctx->hdd_psoc)) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11060 | hdd_debug("Connect received on STA session Id(%d)", |
| 11061 | adapter->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11062 | /* |
| 11063 | * Loop through adapter and disable roaming for each STA device |
| 11064 | * mode except the input adapter. |
| 11065 | */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11066 | hdd_for_each_adapter(hdd_ctx, adapterIdx) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11067 | if (QDF_STA_MODE == adapterIdx->device_mode && |
| 11068 | adapter->session_id != adapterIdx->session_id) { |
| 11069 | hdd_debug("Disable Roaming on session Id(%d)", |
| 11070 | adapterIdx->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11071 | sme_stop_roaming(WLAN_HDD_GET_HAL_CTX |
| 11072 | (adapterIdx), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11073 | adapterIdx->session_id, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11074 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11075 | } |
| 11076 | } |
| 11077 | } |
| 11078 | |
| 11079 | /** |
| 11080 | * wlan_hdd_enable_roaming() - enable roaming on all STAs except the input one |
| 11081 | * @adapter: HDD adapter pointer |
| 11082 | * |
| 11083 | * This function loop through each adapter and enable roaming on each STA |
| 11084 | * device mode except the input adapter. |
| 11085 | * Note: On the input adapter no need to enable roaming because link got |
| 11086 | * disconnected on this. |
| 11087 | * |
| 11088 | * Return: None |
| 11089 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11090 | void wlan_hdd_enable_roaming(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11091 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11092 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11093 | struct hdd_adapter *adapterIdx = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11094 | |
| 11095 | if (hdd_ctx->config->isFastRoamIniFeatureEnabled && |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 11096 | hdd_ctx->config->isRoamOffloadScanEnabled && |
| 11097 | QDF_STA_MODE == adapter->device_mode && |
| 11098 | policy_mgr_is_sta_active_connection_exists( |
| 11099 | hdd_ctx->hdd_psoc)) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11100 | hdd_debug("Disconnect received on STA session Id(%d)", |
| 11101 | adapter->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11102 | /* |
| 11103 | * Loop through adapter and enable roaming for each STA device |
| 11104 | * mode except the input adapter. |
| 11105 | */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11106 | hdd_for_each_adapter(hdd_ctx, adapterIdx) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11107 | if (QDF_STA_MODE == adapterIdx->device_mode && |
| 11108 | adapter->session_id != adapterIdx->session_id) { |
| 11109 | hdd_debug("Enabling Roaming on session Id(%d)", |
| 11110 | adapterIdx->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11111 | sme_start_roaming(WLAN_HDD_GET_HAL_CTX |
| 11112 | (adapterIdx), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11113 | adapterIdx->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11114 | REASON_CONNECT); |
| 11115 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11116 | } |
| 11117 | } |
| 11118 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11119 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 11120 | /** |
| 11121 | * nl_srv_bcast_svc() - Wrapper function to send bcast msgs to SVC mcast group |
| 11122 | * @skb: sk buffer pointer |
| 11123 | * |
| 11124 | * Sends the bcast message to SVC multicast group with generic nl socket |
| 11125 | * if CNSS_GENL is enabled. Else, use the legacy netlink socket to send. |
| 11126 | * |
| 11127 | * Return: None |
| 11128 | */ |
| 11129 | static void nl_srv_bcast_svc(struct sk_buff *skb) |
| 11130 | { |
| 11131 | #ifdef CNSS_GENL |
| 11132 | nl_srv_bcast(skb, CLD80211_MCGRP_SVC_MSGS, WLAN_NL_MSG_SVC); |
| 11133 | #else |
| 11134 | nl_srv_bcast(skb); |
| 11135 | #endif |
| 11136 | } |
| 11137 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11138 | 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] | 11139 | { |
| 11140 | struct sk_buff *skb; |
| 11141 | struct nlmsghdr *nlh; |
| 11142 | tAniMsgHdr *ani_hdr; |
| 11143 | void *nl_data = NULL; |
| 11144 | int flags = GFP_KERNEL; |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11145 | struct radio_index_tlv *radio_info; |
| 11146 | int tlv_len; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11147 | |
| 11148 | if (in_interrupt() || irqs_disabled() || in_atomic()) |
| 11149 | flags = GFP_ATOMIC; |
| 11150 | |
| 11151 | skb = alloc_skb(NLMSG_SPACE(WLAN_NL_MAX_PAYLOAD), flags); |
| 11152 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 11153 | if (skb == NULL) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11154 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11155 | |
| 11156 | nlh = (struct nlmsghdr *)skb->data; |
| 11157 | nlh->nlmsg_pid = 0; /* from kernel */ |
| 11158 | nlh->nlmsg_flags = 0; |
| 11159 | nlh->nlmsg_seq = 0; |
| 11160 | nlh->nlmsg_type = WLAN_NL_MSG_SVC; |
| 11161 | |
| 11162 | ani_hdr = NLMSG_DATA(nlh); |
| 11163 | ani_hdr->type = type; |
| 11164 | |
| 11165 | switch (type) { |
| 11166 | case WLAN_SVC_FW_CRASHED_IND: |
Komal Seelam | 78ff65a | 2016-08-18 15:25:24 +0530 | [diff] [blame] | 11167 | case WLAN_SVC_FW_SHUTDOWN_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11168 | case WLAN_SVC_LTE_COEX_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11169 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND: |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 11170 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11171 | ani_hdr->length = 0; |
| 11172 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr))); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11173 | break; |
| 11174 | case WLAN_SVC_WLAN_STATUS_IND: |
| 11175 | case WLAN_SVC_WLAN_VERSION_IND: |
| 11176 | case WLAN_SVC_DFS_CAC_START_IND: |
| 11177 | case WLAN_SVC_DFS_CAC_END_IND: |
| 11178 | case WLAN_SVC_DFS_RADAR_DETECT_IND: |
| 11179 | case WLAN_SVC_DFS_ALL_CHANNEL_UNAVAIL_IND: |
| 11180 | case WLAN_SVC_WLAN_TP_IND: |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 11181 | case WLAN_SVC_WLAN_TP_TX_IND: |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 11182 | case WLAN_SVC_RPS_ENABLE_IND: |
Orhan K AKYILDIZ | e7445a2 | 2017-01-19 21:21:47 -0800 | [diff] [blame] | 11183 | case WLAN_SVC_CORE_MINFREQ: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11184 | ani_hdr->length = len; |
| 11185 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr) + len)); |
| 11186 | nl_data = (char *)ani_hdr + sizeof(tAniMsgHdr); |
| 11187 | memcpy(nl_data, data, len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11188 | break; |
| 11189 | |
| 11190 | default: |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 11191 | hdd_err("WLAN SVC: Attempt to send unknown nlink message %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11192 | type); |
| 11193 | kfree_skb(skb); |
| 11194 | return; |
| 11195 | } |
| 11196 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11197 | /* |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 11198 | * Add radio index at the end of the svc event in TLV format |
| 11199 | * to maintain the backward compatibility with userspace |
| 11200 | * applications. |
| 11201 | */ |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11202 | |
| 11203 | tlv_len = 0; |
| 11204 | |
| 11205 | if ((sizeof(*ani_hdr) + len + sizeof(struct radio_index_tlv)) |
| 11206 | < WLAN_NL_MAX_PAYLOAD) { |
| 11207 | radio_info = (struct radio_index_tlv *)((char *) ani_hdr + |
| 11208 | sizeof(*ani_hdr) + len); |
| 11209 | radio_info->type = (unsigned short) WLAN_SVC_WLAN_RADIO_INDEX; |
| 11210 | radio_info->length = (unsigned short) sizeof(radio_info->radio); |
| 11211 | radio_info->radio = radio; |
| 11212 | tlv_len = sizeof(*radio_info); |
Dustin Brown | a286862 | 2018-03-20 11:38:14 -0700 | [diff] [blame] | 11213 | hdd_debug("Added radio index tlv - radio index %d", |
| 11214 | radio_info->radio); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11215 | } |
| 11216 | |
| 11217 | nlh->nlmsg_len += tlv_len; |
| 11218 | skb_put(skb, NLMSG_SPACE(sizeof(tAniMsgHdr) + len + tlv_len)); |
| 11219 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 11220 | nl_srv_bcast_svc(skb); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11221 | } |
| 11222 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11223 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 11224 | void wlan_hdd_auto_shutdown_cb(void) |
| 11225 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11226 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11227 | |
| 11228 | if (!hdd_ctx) |
| 11229 | return; |
| 11230 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11231 | hdd_debug("Wlan Idle. Sending Shutdown event.."); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11232 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 11233 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11234 | } |
| 11235 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11236 | 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] | 11237 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11238 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11239 | bool ap_connected = false, sta_connected = false; |
| 11240 | tHalHandle hal_handle; |
| 11241 | |
| 11242 | hal_handle = hdd_ctx->hHal; |
| 11243 | if (hal_handle == NULL) |
| 11244 | return; |
| 11245 | |
| 11246 | if (hdd_ctx->config->WlanAutoShutdown == 0) |
| 11247 | return; |
| 11248 | |
| 11249 | if (enable == false) { |
| 11250 | if (sme_set_auto_shutdown_timer(hal_handle, 0) != |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11251 | QDF_STATUS_SUCCESS) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11252 | hdd_err("Failed to stop wlan auto shutdown timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11253 | } |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11254 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 11255 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11256 | return; |
| 11257 | } |
| 11258 | |
| 11259 | /* To enable shutdown timer check conncurrency */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11260 | if (policy_mgr_concurrent_open_sessions_running(hdd_ctx->hdd_psoc)) { |
| 11261 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 11262 | if (adapter->device_mode == QDF_STA_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11263 | if (WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
| 11264 | conn_info.connState == |
| 11265 | eConnectionState_Associated) { |
| 11266 | sta_connected = true; |
| 11267 | break; |
| 11268 | } |
| 11269 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11270 | |
| 11271 | if (adapter->device_mode == QDF_SAP_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11272 | if (WLAN_HDD_GET_AP_CTX_PTR(adapter)-> |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 11273 | ap_active == true) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11274 | ap_connected = true; |
| 11275 | break; |
| 11276 | } |
| 11277 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11278 | } |
| 11279 | } |
| 11280 | |
| 11281 | if (ap_connected == true || sta_connected == true) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11282 | hdd_debug("CC Session active. Shutdown timer not enabled"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11283 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11284 | } |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 11285 | |
| 11286 | if (sme_set_auto_shutdown_timer(hal_handle, |
| 11287 | hdd_ctx->config->WlanAutoShutdown) |
| 11288 | != QDF_STATUS_SUCCESS) |
| 11289 | hdd_err("Failed to start wlan auto shutdown timer"); |
| 11290 | else |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 11291 | hdd_info("Auto Shutdown timer for %d seconds enabled", |
| 11292 | hdd_ctx->config->WlanAutoShutdown); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11293 | } |
| 11294 | #endif |
| 11295 | |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 11296 | struct hdd_adapter * |
| 11297 | hdd_get_con_sap_adapter(struct hdd_adapter *this_sap_adapter, |
| 11298 | bool check_start_bss) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11299 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11300 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(this_sap_adapter); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11301 | struct hdd_adapter *adapter, *con_sap_adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11302 | |
| 11303 | con_sap_adapter = NULL; |
| 11304 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11305 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 11306 | if (adapter && ((adapter->device_mode == QDF_SAP_MODE) || |
| 11307 | (adapter->device_mode == QDF_P2P_GO_MODE)) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11308 | adapter != this_sap_adapter) { |
| 11309 | if (check_start_bss) { |
| 11310 | if (test_bit(SOFTAP_BSS_STARTED, |
| 11311 | &adapter->event_flags)) { |
| 11312 | con_sap_adapter = adapter; |
| 11313 | break; |
| 11314 | } |
| 11315 | } else { |
| 11316 | con_sap_adapter = adapter; |
| 11317 | break; |
| 11318 | } |
| 11319 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11320 | } |
| 11321 | |
| 11322 | return con_sap_adapter; |
| 11323 | } |
| 11324 | |
| 11325 | #ifdef MSM_PLATFORM |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11326 | static inline bool hdd_adapter_is_sta(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11327 | { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11328 | return adapter->device_mode == QDF_STA_MODE || |
| 11329 | adapter->device_mode == QDF_P2P_CLIENT_MODE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11330 | } |
| 11331 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11332 | static inline bool hdd_adapter_is_ap(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11333 | { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11334 | return adapter->device_mode == QDF_SAP_MODE || |
| 11335 | adapter->device_mode == QDF_P2P_GO_MODE; |
| 11336 | } |
| 11337 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11338 | static bool hdd_any_adapter_is_assoc(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11339 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11340 | struct hdd_adapter *adapter; |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11341 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11342 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 11343 | if (hdd_adapter_is_sta(adapter) && |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11344 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
| 11345 | conn_info.connState == eConnectionState_Associated) { |
| 11346 | return true; |
| 11347 | } |
| 11348 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11349 | if (hdd_adapter_is_ap(adapter) && |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 11350 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->ap_active) { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11351 | return true; |
| 11352 | } |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11353 | } |
| 11354 | |
| 11355 | return false; |
| 11356 | } |
| 11357 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11358 | 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] | 11359 | { |
| 11360 | bool is_running; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11361 | |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 11362 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11363 | is_running = hdd_ctx->bus_bw_timer_running; |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 11364 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11365 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11366 | return is_running; |
| 11367 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11368 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11369 | 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] | 11370 | { |
| 11371 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
| 11372 | hdd_ctx->bus_bw_timer_running = true; |
| 11373 | qdf_timer_start(&hdd_ctx->bus_bw_timer, |
| 11374 | hdd_ctx->config->busBandwidthComputeInterval); |
| 11375 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
| 11376 | } |
| 11377 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11378 | void hdd_bus_bw_compute_timer_start(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11379 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11380 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11381 | |
| 11382 | if (hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 11383 | hdd_debug("Bandwidth compute timer already started"); |
| 11384 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11385 | } |
| 11386 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11387 | __hdd_bus_bw_compute_timer_start(hdd_ctx); |
| 11388 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11389 | hdd_exit(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11390 | } |
| 11391 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11392 | 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] | 11393 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11394 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11395 | |
| 11396 | if (hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 11397 | hdd_debug("Bandwidth compute timer already started"); |
| 11398 | return; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 11399 | } |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11400 | |
| 11401 | if (hdd_any_adapter_is_assoc(hdd_ctx)) |
| 11402 | __hdd_bus_bw_compute_timer_start(hdd_ctx); |
| 11403 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11404 | hdd_exit(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11405 | } |
| 11406 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11407 | 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] | 11408 | { |
Sravan Kumar Kairam | 9e99e9a | 2018-03-12 19:09:45 +0530 | [diff] [blame] | 11409 | ucfg_ipa_set_perf_level(hdd_ctx->hdd_pdev, 0, 0); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11410 | |
| 11411 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
| 11412 | qdf_timer_stop(&hdd_ctx->bus_bw_timer); |
| 11413 | hdd_ctx->bus_bw_timer_running = false; |
| 11414 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
| 11415 | |
| 11416 | hdd_reset_tcp_delack(hdd_ctx); |
| 11417 | } |
| 11418 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11419 | void hdd_bus_bw_compute_timer_stop(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11420 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11421 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11422 | |
| 11423 | if (!hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 11424 | hdd_debug("Bandwidth compute timer already stopped"); |
| 11425 | return; |
| 11426 | } |
| 11427 | |
| 11428 | __hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 11429 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11430 | hdd_exit(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11431 | } |
| 11432 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11433 | 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] | 11434 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11435 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11436 | |
| 11437 | if (!hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 11438 | hdd_debug("Bandwidth compute timer already stopped"); |
| 11439 | return; |
| 11440 | } |
| 11441 | |
| 11442 | if (!hdd_any_adapter_is_assoc(hdd_ctx)) |
| 11443 | __hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 11444 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11445 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11446 | } |
| 11447 | #endif |
| 11448 | |
| 11449 | /** |
| 11450 | * wlan_hdd_check_custom_con_channel_rules() - This function checks the sap's |
| 11451 | * and sta's operating channel. |
| 11452 | * @sta_adapter: Describe the first argument to foobar. |
| 11453 | * @ap_adapter: Describe the second argument to foobar. |
| 11454 | * @roam_profile: Roam profile of AP to which STA wants to connect. |
| 11455 | * @concurrent_chnl_same: If both SAP and STA channels are same then |
| 11456 | * set this flag to true else false. |
| 11457 | * |
| 11458 | * This function checks the sap's operating channel and sta's operating channel. |
| 11459 | * if both are same then it will return false else it will restart the sap in |
| 11460 | * sta's channel and return true. |
| 11461 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11462 | * Return: QDF_STATUS_SUCCESS or QDF_STATUS_E_FAILURE. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11463 | */ |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 11464 | QDF_STATUS |
| 11465 | wlan_hdd_check_custom_con_channel_rules(struct hdd_adapter *sta_adapter, |
| 11466 | struct hdd_adapter *ap_adapter, |
Jeff Johnson | 61b5e98 | 2018-03-15 11:33:31 -0700 | [diff] [blame] | 11467 | struct csr_roam_profile *roam_profile, |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 11468 | tScanResultHandle *scan_cache, |
| 11469 | bool *concurrent_chnl_same) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11470 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 11471 | struct hdd_ap_ctx *hdd_ap_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11472 | uint8_t channel_id; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11473 | QDF_STATUS status; |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 11474 | enum QDF_OPMODE device_mode = ap_adapter->device_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11475 | *concurrent_chnl_same = true; |
| 11476 | |
| 11477 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 11478 | status = |
Archana Ramachandran | 2eb7a61 | 2017-03-23 22:58:42 -0700 | [diff] [blame] | 11479 | sme_get_ap_channel_from_scan_cache(roam_profile, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11480 | scan_cache, |
| 11481 | &channel_id); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 11482 | if (QDF_STATUS_SUCCESS == status) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 11483 | if ((QDF_SAP_MODE == device_mode) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11484 | (channel_id < SIR_11A_CHANNEL_BEGIN)) { |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 11485 | if (hdd_ap_ctx->operating_channel != channel_id) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11486 | *concurrent_chnl_same = false; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11487 | hdd_debug("channels are different"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11488 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 11489 | } else if ((QDF_P2P_GO_MODE == device_mode) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11490 | (channel_id >= SIR_11A_CHANNEL_BEGIN)) { |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 11491 | if (hdd_ap_ctx->operating_channel != channel_id) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11492 | *concurrent_chnl_same = false; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11493 | hdd_debug("channels are different"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11494 | } |
| 11495 | } |
| 11496 | } else { |
| 11497 | /* |
| 11498 | * Lets handle worst case scenario here, Scan cache lookup is |
| 11499 | * failed so we have to stop the SAP to avoid any channel |
| 11500 | * discrepancy between SAP's channel and STA's channel. |
| 11501 | * Return the status as failure so caller function could know |
| 11502 | * that scan look up is failed. |
| 11503 | */ |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11504 | hdd_err("Finding AP from scan cache failed"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11505 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11506 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11507 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11508 | } |
| 11509 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11510 | /** |
| 11511 | * wlan_hdd_stop_sap() - This function stops bss of SAP. |
| 11512 | * @ap_adapter: SAP adapter |
| 11513 | * |
| 11514 | * This function will process the stopping of sap adapter. |
| 11515 | * |
| 11516 | * Return: None |
| 11517 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11518 | void wlan_hdd_stop_sap(struct hdd_adapter *ap_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11519 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 11520 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 11521 | struct hdd_hostapd_state *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 11522 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11523 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11524 | |
| 11525 | if (NULL == ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11526 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11527 | return; |
| 11528 | } |
| 11529 | |
| 11530 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 11531 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 11532 | if (wlan_hdd_validate_context(hdd_ctx)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11533 | return; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 11534 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11535 | mutex_lock(&hdd_ctx->sap_lock); |
| 11536 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
Ryan Hsu | 8ecb0fa | 2016-01-18 15:40:55 -0800 | [diff] [blame] | 11537 | wlan_hdd_del_station(ap_adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11538 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11539 | hdd_debug("Now doing SAP STOPBSS"); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 11540 | qdf_event_reset(&hostapd_state->qdf_stop_bss_event); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11541 | if (QDF_STATUS_SUCCESS == wlansap_stop_bss(hdd_ap_ctx-> |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 11542 | sap_context)) { |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 11543 | qdf_status = qdf_wait_for_event_completion(&hostapd_state-> |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 11544 | qdf_stop_bss_event, |
| 11545 | SME_CMD_TIMEOUT_VALUE); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 11546 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11547 | mutex_unlock(&hdd_ctx->sap_lock); |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11548 | hdd_err("SAP Stop Failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11549 | return; |
| 11550 | } |
| 11551 | } |
| 11552 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 11553 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
| 11554 | ap_adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11555 | ap_adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 11556 | hdd_green_ap_start_state_mc(hdd_ctx, ap_adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 11557 | false); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11558 | hdd_debug("SAP Stop Success"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11559 | } else { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11560 | hdd_err("Can't stop ap because its not started"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11561 | } |
| 11562 | mutex_unlock(&hdd_ctx->sap_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11563 | } |
| 11564 | |
| 11565 | /** |
| 11566 | * wlan_hdd_start_sap() - this function starts bss of SAP. |
| 11567 | * @ap_adapter: SAP adapter |
| 11568 | * |
| 11569 | * This function will process the starting of sap adapter. |
| 11570 | * |
| 11571 | * Return: None |
| 11572 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11573 | void wlan_hdd_start_sap(struct hdd_adapter *ap_adapter, bool reinit) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11574 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 11575 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 11576 | struct hdd_hostapd_state *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 11577 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11578 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11579 | tsap_Config_t *sap_config; |
| 11580 | |
| 11581 | if (NULL == ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11582 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11583 | return; |
| 11584 | } |
| 11585 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 11586 | if (QDF_SAP_MODE != ap_adapter->device_mode) { |
Peng Xu | f5d60c8 | 2015-10-02 17:17:03 -0700 | [diff] [blame] | 11587 | hdd_err("SoftAp role has not been enabled"); |
| 11588 | return; |
| 11589 | } |
| 11590 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11591 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
| 11592 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 11593 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 11594 | sap_config = &ap_adapter->session.ap.sap_config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11595 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11596 | mutex_lock(&hdd_ctx->sap_lock); |
| 11597 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) |
| 11598 | goto end; |
| 11599 | |
| 11600 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11601 | hdd_err("SAP Not able to set AP IEs"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11602 | goto end; |
| 11603 | } |
| 11604 | |
Wei Song | 2f76f64 | 2016-11-18 16:32:53 +0800 | [diff] [blame] | 11605 | qdf_event_reset(&hostapd_state->qdf_event); |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 11606 | 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] | 11607 | &hdd_ap_ctx->sap_config, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11608 | ap_adapter->dev) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11609 | != QDF_STATUS_SUCCESS) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11610 | goto end; |
| 11611 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11612 | hdd_debug("Waiting for SAP to start"); |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 11613 | qdf_status = qdf_wait_for_event_completion(&hostapd_state->qdf_event, |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 11614 | SME_CMD_TIMEOUT_VALUE); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 11615 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11616 | hdd_err("SAP Start failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11617 | goto end; |
| 11618 | } |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11619 | hdd_info("SAP Start Success"); |
Vignesh Viswanathan | 85b455e | 2018-01-17 19:54:33 +0530 | [diff] [blame] | 11620 | wlansap_reset_sap_config_add_ie(sap_config, eUPDATE_IE_ALL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11621 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 11622 | if (hostapd_state->bss_state == BSS_START) { |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 11623 | policy_mgr_incr_active_session(hdd_ctx->hdd_psoc, |
| 11624 | ap_adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11625 | ap_adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 11626 | hdd_green_ap_start_state_mc(hdd_ctx, ap_adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 11627 | true); |
| 11628 | } |
Sourav Mohapatra | 9bc6711 | 2017-11-08 09:36:11 +0530 | [diff] [blame] | 11629 | mutex_unlock(&hdd_ctx->sap_lock); |
| 11630 | |
| 11631 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11632 | end: |
Vignesh Viswanathan | 85b455e | 2018-01-17 19:54:33 +0530 | [diff] [blame] | 11633 | wlansap_reset_sap_config_add_ie(sap_config, eUPDATE_IE_ALL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11634 | mutex_unlock(&hdd_ctx->sap_lock); |
Manikandan Mohan | 3dad1a4 | 2017-06-14 10:50:18 -0700 | [diff] [blame] | 11635 | /* SAP context and beacon cleanup will happen during driver unload |
| 11636 | * in hdd_stop_adapter |
| 11637 | */ |
| 11638 | hdd_err("SAP restart after SSR failed! Reload WLAN and try SAP again"); |
| 11639 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11640 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11641 | |
| 11642 | /** |
Archana Ramachandran | a20ef81 | 2015-11-13 16:12:13 -0800 | [diff] [blame] | 11643 | * wlan_hdd_soc_set_antenna_mode_cb() - Callback for set dual |
| 11644 | * mac scan config |
| 11645 | * @status: Status of set antenna mode |
| 11646 | * |
| 11647 | * Callback on setting the dual mac configuration |
| 11648 | * |
| 11649 | * Return: None |
| 11650 | */ |
| 11651 | void wlan_hdd_soc_set_antenna_mode_cb( |
| 11652 | enum set_antenna_mode_status status) |
| 11653 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11654 | struct hdd_context *hdd_ctx; |
Archana Ramachandran | a20ef81 | 2015-11-13 16:12:13 -0800 | [diff] [blame] | 11655 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11656 | hdd_debug("Status: %d", status); |
Archana Ramachandran | a20ef81 | 2015-11-13 16:12:13 -0800 | [diff] [blame] | 11657 | |
| 11658 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 11659 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
| 11660 | return; |
| 11661 | |
| 11662 | /* Signal the completion of set dual mac config */ |
| 11663 | complete(&hdd_ctx->set_antenna_mode_cmpl); |
| 11664 | } |
| 11665 | |
| 11666 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11667 | * hdd_get_fw_version() - Get FW version |
| 11668 | * @hdd_ctx: pointer to HDD context. |
| 11669 | * @major_spid: FW version - major spid. |
| 11670 | * @minor_spid: FW version - minor spid |
| 11671 | * @ssid: FW version - ssid |
| 11672 | * @crmid: FW version - crmid |
| 11673 | * |
| 11674 | * This function is called to get the firmware build version stored |
| 11675 | * as part of the HDD context |
| 11676 | * |
| 11677 | * Return: None |
| 11678 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11679 | void hdd_get_fw_version(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11680 | uint32_t *major_spid, uint32_t *minor_spid, |
| 11681 | uint32_t *siid, uint32_t *crmid) |
| 11682 | { |
| 11683 | *major_spid = (hdd_ctx->target_fw_version & 0xf0000000) >> 28; |
| 11684 | *minor_spid = (hdd_ctx->target_fw_version & 0xf000000) >> 24; |
| 11685 | *siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20; |
| 11686 | *crmid = hdd_ctx->target_fw_version & 0x7fff; |
| 11687 | } |
| 11688 | |
| 11689 | #ifdef QCA_CONFIG_SMP |
| 11690 | /** |
| 11691 | * wlan_hdd_get_cpu() - get cpu_index |
| 11692 | * |
| 11693 | * Return: cpu_index |
| 11694 | */ |
| 11695 | int wlan_hdd_get_cpu(void) |
| 11696 | { |
| 11697 | int cpu_index = get_cpu(); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 11698 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11699 | put_cpu(); |
| 11700 | return cpu_index; |
| 11701 | } |
| 11702 | #endif |
| 11703 | |
| 11704 | /** |
| 11705 | * hdd_get_fwpath() - get framework path |
| 11706 | * |
| 11707 | * This function is used to get the string written by |
| 11708 | * userspace to start the wlan driver |
| 11709 | * |
| 11710 | * Return: string |
| 11711 | */ |
| 11712 | const char *hdd_get_fwpath(void) |
| 11713 | { |
| 11714 | return fwpath.string; |
| 11715 | } |
| 11716 | |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 11717 | static int hdd_qdf_print_init(void) |
| 11718 | { |
| 11719 | int qdf_print_idx; |
| 11720 | QDF_STATUS status; |
| 11721 | |
| 11722 | status = qdf_print_setup(); |
| 11723 | if (status != QDF_STATUS_SUCCESS) { |
| 11724 | pr_err("qdf_print_setup failed\n"); |
| 11725 | return -EINVAL; |
| 11726 | } |
| 11727 | |
| 11728 | qdf_print_idx = qdf_print_ctrl_register(cinfo, NULL, NULL, "MCL_WLAN"); |
| 11729 | |
| 11730 | if (qdf_print_idx < 0) { |
| 11731 | pr_err("qdf_print_ctrl_register failed, ret = %d\n", |
| 11732 | qdf_print_idx); |
| 11733 | return -EINVAL; |
| 11734 | } |
| 11735 | |
| 11736 | qdf_set_pidx(qdf_print_idx); |
| 11737 | |
| 11738 | return 0; |
| 11739 | } |
| 11740 | |
| 11741 | static void hdd_qdf_print_deinit(void) |
| 11742 | { |
| 11743 | int qdf_print_idx; |
| 11744 | |
| 11745 | qdf_print_idx = qdf_get_pidx(); |
| 11746 | qdf_print_ctrl_cleanup(qdf_print_idx); |
| 11747 | } |
| 11748 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11749 | /** |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11750 | * hdd_init() - Initialize Driver |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11751 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11752 | * This function initilizes CDS global context with the help of cds_init. This |
| 11753 | * has to be the first function called after probe to get a valid global |
| 11754 | * context. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11755 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11756 | * Return: 0 for success, errno on failure |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11757 | */ |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11758 | int hdd_init(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11759 | { |
Jeff Johnson | 7aaeeea | 2017-09-26 13:16:24 -0700 | [diff] [blame] | 11760 | QDF_STATUS status; |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11761 | int ret = 0; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11762 | |
Jeff Johnson | 7aaeeea | 2017-09-26 13:16:24 -0700 | [diff] [blame] | 11763 | status = cds_init(); |
wadesong | ae4ffd1 | 2017-10-24 16:45:54 +0800 | [diff] [blame] | 11764 | if (QDF_IS_STATUS_ERROR(status)) { |
| 11765 | hdd_err("Failed to allocate CDS context"); |
| 11766 | ret = -ENOMEM; |
| 11767 | goto err_out; |
| 11768 | } |
Hanumanth Reddy Pothula | 788a37e | 2017-08-17 18:40:11 +0530 | [diff] [blame] | 11769 | |
| 11770 | wlan_init_bug_report_lock(); |
| 11771 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11772 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 11773 | wlan_logging_sock_init_svc(); |
| 11774 | #endif |
| 11775 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 11776 | qdf_timer_init(NULL, &hdd_drv_ops_inactivity_timer, |
| 11777 | (void *)hdd_drv_ops_inactivity_handler, NULL, |
| 11778 | QDF_TIMER_TYPE_SW); |
| 11779 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11780 | hdd_trace_init(); |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 11781 | hdd_qdf_print_init(); |
| 11782 | |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11783 | hdd_register_debug_callback(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11784 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11785 | err_out: |
| 11786 | return ret; |
| 11787 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11788 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11789 | /** |
| 11790 | * hdd_deinit() - Deinitialize Driver |
| 11791 | * |
| 11792 | * This function frees CDS global context with the help of cds_deinit. This |
| 11793 | * has to be the last function call in remove callback to free the global |
| 11794 | * context. |
| 11795 | */ |
| 11796 | void hdd_deinit(void) |
| 11797 | { |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 11798 | qdf_timer_free(&hdd_drv_ops_inactivity_timer); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11799 | |
Rajeev Kumar | 2d0f219 | 2017-10-18 19:48:21 -0700 | [diff] [blame] | 11800 | wlan_destroy_bug_report_lock(); |
| 11801 | cds_deinit(); |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 11802 | |
Rajeev Kumar | 2d0f219 | 2017-10-18 19:48:21 -0700 | [diff] [blame] | 11803 | hdd_qdf_print_deinit(); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11804 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 11805 | wlan_logging_sock_deinit_svc(); |
| 11806 | #endif |
| 11807 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11808 | |
Yue Ma | 6e7b1a0 | 2017-04-03 14:17:46 -0700 | [diff] [blame] | 11809 | #ifdef QCA_WIFI_NAPIER_EMULATION |
| 11810 | #define HDD_WLAN_START_WAIT_TIME ((CDS_WMA_TIMEOUT + 5000) * 100) |
| 11811 | #else |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11812 | #define HDD_WLAN_START_WAIT_TIME (CDS_WMA_TIMEOUT + 5000) |
Yue Ma | 6e7b1a0 | 2017-04-03 14:17:46 -0700 | [diff] [blame] | 11813 | #endif |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11814 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11815 | static int wlan_hdd_state_ctrl_param_open(struct inode *inode, |
| 11816 | struct file *file) |
| 11817 | { |
| 11818 | return 0; |
| 11819 | } |
| 11820 | |
| 11821 | static ssize_t wlan_hdd_state_ctrl_param_write(struct file *filp, |
| 11822 | const char __user *user_buf, |
| 11823 | size_t count, |
| 11824 | loff_t *f_pos) |
| 11825 | { |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 11826 | char buf[3]; |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11827 | static const char wlan_off_str[] = "OFF"; |
| 11828 | static const char wlan_on_str[] = "ON"; |
| 11829 | int ret; |
| 11830 | unsigned long rc; |
| 11831 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 11832 | if (copy_from_user(buf, user_buf, 3)) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11833 | pr_err("Failed to read buffer\n"); |
| 11834 | return -EINVAL; |
| 11835 | } |
| 11836 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 11837 | if (strncmp(buf, wlan_off_str, strlen(wlan_off_str)) == 0) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11838 | pr_debug("Wifi turning off from UI\n"); |
| 11839 | goto exit; |
| 11840 | } |
| 11841 | |
Sachin Ahuja | 16904db | 2017-12-13 19:56:57 +0530 | [diff] [blame] | 11842 | if (strncmp(buf, wlan_on_str, strlen(wlan_on_str)) == 0) { |
| 11843 | pr_info("Wifi Turning On from UI\n"); |
| 11844 | } |
| 11845 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 11846 | if (strncmp(buf, wlan_on_str, strlen(wlan_on_str)) != 0) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11847 | pr_err("Invalid value received from framework"); |
| 11848 | goto exit; |
| 11849 | } |
| 11850 | |
| 11851 | if (!cds_is_driver_loaded()) { |
Sachin Ahuja | ee62b54 | 2017-04-21 14:14:16 +0530 | [diff] [blame] | 11852 | init_completion(&wlan_start_comp); |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11853 | rc = wait_for_completion_timeout(&wlan_start_comp, |
| 11854 | msecs_to_jiffies(HDD_WLAN_START_WAIT_TIME)); |
| 11855 | if (!rc) { |
| 11856 | hdd_alert("Timed-out waiting in wlan_hdd_state_ctrl_param_write"); |
| 11857 | ret = -EINVAL; |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11858 | return ret; |
| 11859 | } |
| 11860 | |
| 11861 | hdd_start_complete(0); |
| 11862 | } |
| 11863 | |
| 11864 | exit: |
| 11865 | return count; |
| 11866 | } |
| 11867 | |
| 11868 | |
| 11869 | const struct file_operations wlan_hdd_state_fops = { |
| 11870 | .owner = THIS_MODULE, |
| 11871 | .open = wlan_hdd_state_ctrl_param_open, |
| 11872 | .write = wlan_hdd_state_ctrl_param_write, |
| 11873 | }; |
| 11874 | |
| 11875 | static int wlan_hdd_state_ctrl_param_create(void) |
| 11876 | { |
| 11877 | unsigned int wlan_hdd_state_major = 0; |
| 11878 | int ret; |
| 11879 | struct device *dev; |
| 11880 | |
| 11881 | device = MKDEV(wlan_hdd_state_major, 0); |
| 11882 | |
| 11883 | ret = alloc_chrdev_region(&device, 0, dev_num, "qcwlanstate"); |
| 11884 | if (ret) { |
| 11885 | pr_err("Failed to register qcwlanstate"); |
| 11886 | goto dev_alloc_err; |
| 11887 | } |
| 11888 | wlan_hdd_state_major = MAJOR(device); |
| 11889 | |
| 11890 | class = class_create(THIS_MODULE, WLAN_MODULE_NAME); |
| 11891 | if (IS_ERR(class)) { |
| 11892 | pr_err("wlan_hdd_state class_create error"); |
| 11893 | goto class_err; |
| 11894 | } |
| 11895 | |
| 11896 | dev = device_create(class, NULL, device, NULL, WLAN_MODULE_NAME); |
| 11897 | if (IS_ERR(dev)) { |
| 11898 | pr_err("wlan_hdd_statedevice_create error"); |
| 11899 | goto err_class_destroy; |
| 11900 | } |
| 11901 | |
| 11902 | cdev_init(&wlan_hdd_state_cdev, &wlan_hdd_state_fops); |
| 11903 | ret = cdev_add(&wlan_hdd_state_cdev, device, dev_num); |
| 11904 | if (ret) { |
| 11905 | pr_err("Failed to add cdev error"); |
| 11906 | goto cdev_add_err; |
| 11907 | } |
| 11908 | |
| 11909 | pr_info("wlan_hdd_state %s major(%d) initialized", |
| 11910 | WLAN_MODULE_NAME, wlan_hdd_state_major); |
| 11911 | |
| 11912 | return 0; |
| 11913 | |
| 11914 | cdev_add_err: |
| 11915 | device_destroy(class, device); |
| 11916 | err_class_destroy: |
| 11917 | class_destroy(class); |
| 11918 | class_err: |
| 11919 | unregister_chrdev_region(device, dev_num); |
| 11920 | dev_alloc_err: |
| 11921 | return -ENODEV; |
| 11922 | } |
| 11923 | |
| 11924 | static void wlan_hdd_state_ctrl_param_destroy(void) |
| 11925 | { |
| 11926 | cdev_del(&wlan_hdd_state_cdev); |
| 11927 | device_destroy(class, device); |
| 11928 | class_destroy(class); |
| 11929 | unregister_chrdev_region(device, dev_num); |
| 11930 | |
| 11931 | pr_info("Device node unregistered"); |
| 11932 | } |
| 11933 | |
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 | * component_init - API to init cld component's |
| 11936 | * |
| 11937 | * Return: None |
| 11938 | */ |
| 11939 | static void component_init(void) |
| 11940 | { |
| 11941 | pmo_init(); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 11942 | disa_init(); |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 11943 | ucfg_ocb_init(); |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 11944 | ipa_init(); |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 11945 | } |
| 11946 | |
| 11947 | /** |
| 11948 | * component_deinit - API to deinit cld component's |
| 11949 | * |
| 11950 | * Return: None |
| 11951 | */ |
| 11952 | static void component_deinit(void) |
| 11953 | { |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 11954 | ipa_deinit(); |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 11955 | ucfg_ocb_deinit(); |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 11956 | pmo_deinit(); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 11957 | disa_deinit(); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 11958 | } |
| 11959 | |
| 11960 | void hdd_component_psoc_enable(struct wlan_objmgr_psoc *psoc) |
| 11961 | { |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 11962 | ocb_psoc_enable(psoc); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 11963 | disa_psoc_enable(psoc); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 11964 | } |
| 11965 | |
| 11966 | void hdd_component_psoc_disable(struct wlan_objmgr_psoc *psoc) |
| 11967 | { |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 11968 | disa_psoc_disable(psoc); |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 11969 | ocb_psoc_disable(psoc); |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 11970 | } |
| 11971 | |
| 11972 | /** |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11973 | * __hdd_module_init - Module init helper |
| 11974 | * |
| 11975 | * Module init helper function used by both module and static driver. |
| 11976 | * |
| 11977 | * Return: 0 for success, errno on failure |
| 11978 | */ |
| 11979 | static int __hdd_module_init(void) |
| 11980 | { |
| 11981 | int ret = 0; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11982 | |
Dustin Brown | 96cd963 | 2017-11-13 12:45:04 -0800 | [diff] [blame] | 11983 | pr_err("%s: Loading driver v%s (%s)\n", |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 11984 | WLAN_MODULE_NAME, |
Dustin Brown | 96cd963 | 2017-11-13 12:45:04 -0800 | [diff] [blame] | 11985 | g_wlan_driver_version, |
Dustin Brown | c1034df | 2018-02-07 14:51:32 -0800 | [diff] [blame] | 11986 | TIMER_MANAGER_STR MEMORY_DEBUG_STR PANIC_ON_BUG_STR); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11987 | |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 11988 | pld_init(); |
| 11989 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 11990 | ret = hdd_init(); |
| 11991 | if (ret) { |
| 11992 | pr_err("hdd_init failed %x\n", ret); |
| 11993 | goto err_hdd_init; |
| 11994 | } |
| 11995 | |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 11996 | dispatcher_init(); |
| 11997 | |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 11998 | /* Ensure to call post objmgr init */ |
| 11999 | component_init(); |
| 12000 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 12001 | qdf_wake_lock_create(&wlan_wake_lock, "wlan"); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12002 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12003 | hdd_set_conparam((uint32_t) con_mode); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12004 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12005 | ret = wlan_hdd_register_driver(); |
| 12006 | if (ret) { |
Mohit Khanna | fa99aea | 2016-05-12 21:43:13 -0700 | [diff] [blame] | 12007 | pr_err("%s: driver load failure, err %d\n", WLAN_MODULE_NAME, |
| 12008 | ret); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12009 | goto out; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12010 | } |
| 12011 | |
Sachin Ahuja | 16904db | 2017-12-13 19:56:57 +0530 | [diff] [blame] | 12012 | ret = wlan_hdd_state_ctrl_param_create(); |
| 12013 | if (ret) { |
| 12014 | pr_err("wlan_hdd_state_create:%x\n", ret); |
| 12015 | goto out; |
| 12016 | } |
| 12017 | |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 12018 | pr_info("%s: driver loaded\n", WLAN_MODULE_NAME); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12019 | |
| 12020 | return 0; |
| 12021 | out: |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 12022 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Liangwei Dong | 9fcc721 | 2017-10-24 13:43:52 +0800 | [diff] [blame] | 12023 | component_deinit(); |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 12024 | dispatcher_deinit(); |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12025 | hdd_deinit(); |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 12026 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12027 | err_hdd_init: |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 12028 | pld_deinit(); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12029 | return ret; |
| 12030 | } |
| 12031 | |
| 12032 | /** |
| 12033 | * __hdd_module_exit - Module exit helper |
| 12034 | * |
| 12035 | * Module exit helper function used by both module and static driver. |
| 12036 | */ |
| 12037 | static void __hdd_module_exit(void) |
| 12038 | { |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 12039 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12040 | pr_info("%s: Unloading driver v%s\n", WLAN_MODULE_NAME, |
| 12041 | QWLAN_VERSIONSTR); |
| 12042 | |
Arunk Khandavalli | 07ec8f6 | 2016-09-27 21:51:01 +0530 | [diff] [blame] | 12043 | hdd_wait_for_recovery_completion(); |
| 12044 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12045 | wlan_hdd_unregister_driver(); |
| 12046 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 12047 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12048 | |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 12049 | /* Ensure to call prior to objmgr deinit */ |
| 12050 | component_deinit(); |
| 12051 | |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 12052 | dispatcher_deinit(); |
Amar Singhal | 0928b19 | 2017-12-01 10:50:54 -0800 | [diff] [blame] | 12053 | |
| 12054 | hdd_sysfs_destroy_version_interface(); |
| 12055 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12056 | hdd_deinit(); |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 12057 | pld_deinit(); |
| 12058 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12059 | wlan_hdd_state_ctrl_param_destroy(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12060 | } |
| 12061 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12062 | #ifndef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12063 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12064 | * wlan_boot_cb() - Wlan boot callback |
| 12065 | * @kobj: object whose directory we're creating the link in. |
| 12066 | * @attr: attribute the user is interacting with |
| 12067 | * @buff: the buffer containing the user data |
| 12068 | * @count: number of bytes in the buffer |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12069 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12070 | * This callback is invoked when the fs is ready to start the |
| 12071 | * wlan driver initialization. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12072 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12073 | * 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] | 12074 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12075 | static ssize_t wlan_boot_cb(struct kobject *kobj, |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12076 | struct kobj_attribute *attr, |
| 12077 | const char *buf, |
| 12078 | size_t count) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12079 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12080 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12081 | if (wlan_loader->loaded_state) { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12082 | pr_err("%s: wlan driver already initialized\n", __func__); |
| 12083 | return -EALREADY; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12084 | } |
| 12085 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12086 | if (__hdd_module_init()) { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12087 | pr_err("%s: wlan driver initialization failed\n", __func__); |
| 12088 | return -EIO; |
| 12089 | } |
| 12090 | |
| 12091 | wlan_loader->loaded_state = MODULE_INITIALIZED; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12092 | |
| 12093 | return count; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12094 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12095 | |
| 12096 | /** |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12097 | * hdd_sysfs_cleanup() - cleanup sysfs |
| 12098 | * |
| 12099 | * Return: None |
| 12100 | * |
| 12101 | */ |
| 12102 | static void hdd_sysfs_cleanup(void) |
| 12103 | { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12104 | /* remove from group */ |
| 12105 | if (wlan_loader->boot_wlan_obj && wlan_loader->attr_group) |
| 12106 | sysfs_remove_group(wlan_loader->boot_wlan_obj, |
| 12107 | wlan_loader->attr_group); |
| 12108 | |
| 12109 | /* unlink the object from parent */ |
| 12110 | kobject_del(wlan_loader->boot_wlan_obj); |
| 12111 | |
| 12112 | /* free the object */ |
| 12113 | kobject_put(wlan_loader->boot_wlan_obj); |
| 12114 | |
| 12115 | kfree(wlan_loader->attr_group); |
| 12116 | kfree(wlan_loader); |
| 12117 | |
| 12118 | wlan_loader = NULL; |
| 12119 | } |
| 12120 | |
| 12121 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12122 | * wlan_init_sysfs() - Creates the sysfs to be invoked when the fs is |
| 12123 | * ready |
| 12124 | * |
| 12125 | * This is creates the syfs entry boot_wlan. Which shall be invoked |
| 12126 | * when the filesystem is ready. |
| 12127 | * |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12128 | * QDF API cannot be used here since this function is called even before |
| 12129 | * initializing WLAN driver. |
| 12130 | * |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 12131 | * Return: 0 for success, errno on failure |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12132 | */ |
| 12133 | static int wlan_init_sysfs(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12134 | { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12135 | int ret = -ENOMEM; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12136 | |
| 12137 | wlan_loader = kzalloc(sizeof(*wlan_loader), GFP_KERNEL); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 12138 | if (!wlan_loader) |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12139 | return -ENOMEM; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12140 | |
| 12141 | wlan_loader->boot_wlan_obj = NULL; |
| 12142 | wlan_loader->attr_group = kzalloc(sizeof(*(wlan_loader->attr_group)), |
| 12143 | GFP_KERNEL); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 12144 | if (!wlan_loader->attr_group) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12145 | goto error_return; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12146 | |
| 12147 | wlan_loader->loaded_state = 0; |
| 12148 | wlan_loader->attr_group->attrs = attrs; |
| 12149 | |
| 12150 | wlan_loader->boot_wlan_obj = kobject_create_and_add("boot_wlan", |
| 12151 | kernel_kobj); |
| 12152 | if (!wlan_loader->boot_wlan_obj) { |
| 12153 | pr_err("%s: sysfs create and add failed\n", __func__); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12154 | goto error_return; |
| 12155 | } |
| 12156 | |
| 12157 | ret = sysfs_create_group(wlan_loader->boot_wlan_obj, |
| 12158 | wlan_loader->attr_group); |
| 12159 | if (ret) { |
| 12160 | pr_err("%s: sysfs create group failed %d\n", __func__, ret); |
| 12161 | goto error_return; |
| 12162 | } |
| 12163 | |
| 12164 | return 0; |
| 12165 | |
| 12166 | error_return: |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12167 | hdd_sysfs_cleanup(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12168 | |
| 12169 | return ret; |
| 12170 | } |
| 12171 | |
| 12172 | /** |
| 12173 | * wlan_deinit_sysfs() - Removes the sysfs created to initialize the wlan |
| 12174 | * |
| 12175 | * Return: 0 on success or errno on failure |
| 12176 | */ |
| 12177 | static int wlan_deinit_sysfs(void) |
| 12178 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12179 | if (!wlan_loader) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12180 | hdd_err("wlan loader context is Null!"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12181 | return -EINVAL; |
| 12182 | } |
| 12183 | |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12184 | hdd_sysfs_cleanup(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12185 | return 0; |
| 12186 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12187 | |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12188 | #endif /* MODULE */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12189 | |
| 12190 | #ifdef MODULE |
| 12191 | /** |
| 12192 | * __hdd_module_init - Module init helper |
| 12193 | * |
| 12194 | * Module init helper function used by both module and static driver. |
| 12195 | * |
| 12196 | * Return: 0 for success, errno on failure |
| 12197 | */ |
| 12198 | static int hdd_module_init(void) |
| 12199 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12200 | if (__hdd_module_init()) { |
| 12201 | pr_err("%s: Failed to register handler\n", __func__); |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 12202 | return -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12203 | } |
| 12204 | |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 12205 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12206 | } |
| 12207 | #else |
| 12208 | static int __init hdd_module_init(void) |
| 12209 | { |
| 12210 | int ret = -EINVAL; |
| 12211 | |
| 12212 | ret = wlan_init_sysfs(); |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 12213 | if (ret) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12214 | pr_err("Failed to create sysfs entry for loading wlan"); |
| 12215 | |
| 12216 | return ret; |
| 12217 | } |
| 12218 | #endif |
| 12219 | |
| 12220 | |
| 12221 | #ifdef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12222 | /** |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12223 | * hdd_module_exit() - Exit function |
| 12224 | * |
| 12225 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 12226 | * |
| 12227 | * Return: None |
| 12228 | */ |
| 12229 | static void __exit hdd_module_exit(void) |
| 12230 | { |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12231 | __hdd_module_exit(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12232 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12233 | #else |
| 12234 | static void __exit hdd_module_exit(void) |
| 12235 | { |
| 12236 | __hdd_module_exit(); |
| 12237 | wlan_deinit_sysfs(); |
| 12238 | } |
| 12239 | #endif |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12240 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12241 | static int fwpath_changed_handler(const char *kmessage, struct kernel_param *kp) |
| 12242 | { |
| 12243 | return param_set_copystring(kmessage, kp); |
| 12244 | } |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12245 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12246 | /** |
| 12247 | * is_con_mode_valid() check con mode is valid or not |
| 12248 | * @mode: global con mode |
| 12249 | * |
| 12250 | * Return: TRUE on success FALSE on failure |
| 12251 | */ |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12252 | static bool is_con_mode_valid(enum QDF_GLOBAL_MODE mode) |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12253 | { |
| 12254 | switch (mode) { |
| 12255 | case QDF_GLOBAL_MONITOR_MODE: |
| 12256 | case QDF_GLOBAL_FTM_MODE: |
| 12257 | case QDF_GLOBAL_EPPING_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12258 | case QDF_GLOBAL_MISSION_MODE: |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12259 | return true; |
| 12260 | default: |
| 12261 | return false; |
| 12262 | } |
| 12263 | } |
| 12264 | |
| 12265 | /** |
| 12266 | * hdd_get_adpter_mode() - returns adapter mode based on global con mode |
| 12267 | * @mode: global con mode |
| 12268 | * |
| 12269 | * Return: adapter mode |
| 12270 | */ |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 12271 | static enum QDF_OPMODE hdd_get_adpter_mode( |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12272 | enum QDF_GLOBAL_MODE mode) |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12273 | { |
| 12274 | |
| 12275 | switch (mode) { |
| 12276 | case QDF_GLOBAL_MISSION_MODE: |
| 12277 | return QDF_STA_MODE; |
| 12278 | case QDF_GLOBAL_MONITOR_MODE: |
| 12279 | return QDF_MONITOR_MODE; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12280 | case QDF_GLOBAL_EPPING_MODE: |
| 12281 | return QDF_EPPING_MODE; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12282 | case QDF_GLOBAL_FTM_MODE: |
| 12283 | return QDF_FTM_MODE; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12284 | case QDF_GLOBAL_QVIT_MODE: |
| 12285 | return QDF_QVIT_MODE; |
| 12286 | default: |
| 12287 | return QDF_MAX_NO_OF_MODE; |
| 12288 | } |
| 12289 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12290 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12291 | static void hdd_stop_present_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12292 | enum QDF_GLOBAL_MODE curr_mode) |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12293 | { |
| 12294 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) |
| 12295 | return; |
| 12296 | |
| 12297 | switch (curr_mode) { |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12298 | case QDF_GLOBAL_MONITOR_MODE: |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 12299 | hdd_info("Release wakelock for monitor mode!"); |
| 12300 | qdf_wake_lock_release(&hdd_ctx->monitor_mode_wakelock, |
| 12301 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 12302 | case QDF_GLOBAL_MISSION_MODE: |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12303 | case QDF_GLOBAL_FTM_MODE: |
| 12304 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
Sourav Mohapatra | 001cfaf | 2018-02-28 11:30:46 +0530 | [diff] [blame] | 12305 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->hdd_pdev, NULL); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 12306 | hdd_stop_all_adapters(hdd_ctx); |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12307 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12308 | break; |
| 12309 | default: |
| 12310 | break; |
| 12311 | } |
| 12312 | } |
| 12313 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12314 | static void hdd_cleanup_present_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12315 | enum QDF_GLOBAL_MODE curr_mode) |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12316 | { |
Ashish Kumar Dhanotiya | 0024313 | 2017-01-24 16:37:34 +0530 | [diff] [blame] | 12317 | int driver_status; |
| 12318 | |
| 12319 | driver_status = hdd_ctx->driver_status; |
| 12320 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12321 | switch (curr_mode) { |
| 12322 | case QDF_GLOBAL_MISSION_MODE: |
| 12323 | case QDF_GLOBAL_MONITOR_MODE: |
| 12324 | case QDF_GLOBAL_FTM_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12325 | hdd_deinit_all_adapters(hdd_ctx, false); |
| 12326 | hdd_close_all_adapters(hdd_ctx, false); |
| 12327 | break; |
| 12328 | case QDF_GLOBAL_EPPING_MODE: |
| 12329 | epping_disable(); |
| 12330 | epping_close(); |
| 12331 | break; |
| 12332 | default: |
| 12333 | return; |
| 12334 | } |
| 12335 | } |
| 12336 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12337 | static int hdd_register_req_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12338 | enum QDF_GLOBAL_MODE mode) |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12339 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12340 | struct hdd_adapter *adapter; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12341 | int ret = 0; |
| 12342 | bool rtnl_held; |
| 12343 | qdf_device_t qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 12344 | QDF_STATUS status; |
| 12345 | |
| 12346 | if (!qdf_dev) { |
| 12347 | hdd_err("qdf device context is Null return!"); |
| 12348 | return -EINVAL; |
| 12349 | } |
| 12350 | |
| 12351 | rtnl_held = hdd_hold_rtnl_lock(); |
| 12352 | switch (mode) { |
| 12353 | case QDF_GLOBAL_MISSION_MODE: |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 12354 | ret = hdd_open_interfaces(hdd_ctx, rtnl_held); |
| 12355 | if (ret) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12356 | hdd_err("Failed to open interfaces: %d", ret); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12357 | break; |
| 12358 | case QDF_GLOBAL_FTM_MODE: |
| 12359 | adapter = hdd_open_adapter(hdd_ctx, QDF_FTM_MODE, "wlan%d", |
| 12360 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 12361 | NET_NAME_UNKNOWN, rtnl_held); |
| 12362 | if (adapter == NULL) |
| 12363 | ret = -EINVAL; |
| 12364 | break; |
| 12365 | case QDF_GLOBAL_MONITOR_MODE: |
| 12366 | adapter = hdd_open_adapter(hdd_ctx, QDF_MONITOR_MODE, "wlan%d", |
| 12367 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 12368 | NET_NAME_UNKNOWN, rtnl_held); |
| 12369 | if (adapter == NULL) |
| 12370 | ret = -EINVAL; |
| 12371 | break; |
| 12372 | case QDF_GLOBAL_EPPING_MODE: |
| 12373 | status = epping_open(); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 12374 | if (status != QDF_STATUS_SUCCESS) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12375 | hdd_err("Failed to open in eeping mode: %d", status); |
| 12376 | ret = -EINVAL; |
| 12377 | break; |
| 12378 | } |
| 12379 | ret = epping_enable(qdf_dev->dev); |
| 12380 | if (ret) { |
| 12381 | hdd_err("Failed to enable in epping mode : %d", ret); |
| 12382 | epping_close(); |
| 12383 | } |
| 12384 | break; |
| 12385 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12386 | hdd_err("Mode not supported"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12387 | ret = -ENOTSUPP; |
| 12388 | break; |
| 12389 | } |
| 12390 | hdd_release_rtnl_lock(); |
| 12391 | rtnl_held = false; |
| 12392 | return ret; |
| 12393 | } |
| 12394 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12395 | /** |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12396 | * __con_mode_handler() - Handles module param con_mode change |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12397 | * @kmessage: con mode name on which driver to be bring up |
| 12398 | * @kp: The associated kernel parameter |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12399 | * @hdd_ctx: Pointer to the global HDD context |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12400 | * |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12401 | * This function is invoked when user updates con mode using sys entry, |
| 12402 | * to initialize and bring-up driver in that specific mode. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12403 | * |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12404 | * Return - 0 on success and failure code on failure |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12405 | */ |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12406 | static int __con_mode_handler(const char *kmessage, struct kernel_param *kp, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12407 | struct hdd_context *hdd_ctx) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12408 | { |
| 12409 | int ret; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12410 | struct hdd_adapter *adapter; |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12411 | enum QDF_GLOBAL_MODE curr_mode; |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 12412 | enum QDF_OPMODE adapter_mode; |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12413 | int new_con_mode; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12414 | |
Dustin Brown | ab6029b | 2017-05-24 13:04:19 -0700 | [diff] [blame] | 12415 | hdd_info("con_mode handler: %s", kmessage); |
| 12416 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12417 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 12418 | if (ret) |
| 12419 | return ret; |
| 12420 | |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 12421 | qdf_atomic_set(&hdd_ctx->con_mode_flag, 1); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12422 | cds_set_load_in_progress(true); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12423 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12424 | ret = kstrtoint(kmessage, 0, &new_con_mode); |
| 12425 | if (ret) { |
| 12426 | hdd_err("Failed to parse con_mode '%s'", kmessage); |
| 12427 | goto reset_flags; |
| 12428 | } |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 12429 | mutex_lock(&hdd_init_deinit_lock); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12430 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12431 | if (!is_con_mode_valid(new_con_mode)) { |
| 12432 | hdd_err("invalid con_mode %d", new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12433 | ret = -EINVAL; |
| 12434 | goto reset_flags; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12435 | } |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12436 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12437 | curr_mode = hdd_get_conparam(); |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12438 | if (curr_mode == new_con_mode) { |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12439 | hdd_err("curr mode: %d is same as user triggered mode %d", |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12440 | curr_mode, new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12441 | ret = 0; |
| 12442 | goto reset_flags; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12443 | } |
| 12444 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12445 | /* ensure adapters are stopped */ |
| 12446 | hdd_stop_present_mode(hdd_ctx, curr_mode); |
| 12447 | |
Frank Liu | 6666f83 | 2018-01-04 10:06:05 +0800 | [diff] [blame] | 12448 | /* Cleanup present mode before switching to new mode */ |
| 12449 | hdd_cleanup_present_mode(hdd_ctx, curr_mode); |
| 12450 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 12451 | ret = hdd_wlan_stop_modules(hdd_ctx, true); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12452 | if (ret) { |
| 12453 | hdd_err("Stop wlan modules failed"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12454 | goto reset_flags; |
| 12455 | } |
| 12456 | |
Ashish Kumar Dhanotiya | cda5766 | 2017-08-14 14:45:25 +0530 | [diff] [blame] | 12457 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12458 | hdd_set_conparam(new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12459 | |
Frank Liu | 6666f83 | 2018-01-04 10:06:05 +0800 | [diff] [blame] | 12460 | /* |
| 12461 | * Set ACTIVE domain before adapters created, otherwise check domain |
| 12462 | * match will fail when cleanup adapters. |
| 12463 | */ |
| 12464 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_ACTIVE); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12465 | /* Register for new con_mode & then kick_start modules again */ |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12466 | ret = hdd_register_req_mode(hdd_ctx, new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12467 | if (ret) { |
| 12468 | hdd_err("Failed to register for new mode"); |
| 12469 | goto reset_flags; |
| 12470 | } |
| 12471 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12472 | adapter_mode = hdd_get_adpter_mode(new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12473 | if (adapter_mode == QDF_MAX_NO_OF_MODE) { |
| 12474 | hdd_err("invalid adapter"); |
| 12475 | ret = -EINVAL; |
| 12476 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12477 | } |
| 12478 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12479 | adapter = hdd_get_adapter(hdd_ctx, adapter_mode); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12480 | if (!adapter) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12481 | hdd_err("Failed to get adapter:%d", adapter_mode); |
| 12482 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12483 | } |
| 12484 | |
| 12485 | ret = hdd_wlan_start_modules(hdd_ctx, adapter, false); |
| 12486 | if (ret) { |
| 12487 | hdd_err("Start wlan modules failed: %d", ret); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12488 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12489 | } |
| 12490 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12491 | if (new_con_mode == QDF_GLOBAL_MONITOR_MODE) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12492 | if (hdd_start_adapter(adapter)) { |
| 12493 | hdd_err("Failed to start %s adapter", kmessage); |
| 12494 | ret = -EINVAL; |
| 12495 | goto reset_flags; |
| 12496 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12497 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 12498 | hdd_info("Acquire wakelock for monitor mode!"); |
| 12499 | qdf_wake_lock_acquire(&hdd_ctx->monitor_mode_wakelock, |
| 12500 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 12501 | } |
| 12502 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12503 | /* con_mode is a global module parameter */ |
| 12504 | con_mode = new_con_mode; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12505 | hdd_info("Mode successfully changed to %s", kmessage); |
| 12506 | ret = 0; |
| 12507 | |
| 12508 | reset_flags: |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 12509 | mutex_unlock(&hdd_init_deinit_lock); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12510 | cds_set_load_in_progress(false); |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 12511 | qdf_atomic_set(&hdd_ctx->con_mode_flag, 0); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12512 | return ret; |
| 12513 | } |
| 12514 | |
| 12515 | |
| 12516 | static int con_mode_handler(const char *kmessage, struct kernel_param *kp) |
| 12517 | { |
| 12518 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12519 | struct hdd_context *hdd_ctx; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12520 | |
| 12521 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 12522 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 12523 | if (ret) |
| 12524 | return ret; |
| 12525 | |
| 12526 | cds_ssr_protect(__func__); |
| 12527 | ret = __con_mode_handler(kmessage, kp, hdd_ctx); |
| 12528 | cds_ssr_unprotect(__func__); |
| 12529 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12530 | return ret; |
| 12531 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12532 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 12533 | static int con_mode_handler_ftm(const char *kmessage, |
| 12534 | struct kernel_param *kp) |
| 12535 | { |
| 12536 | int ret; |
| 12537 | |
| 12538 | ret = param_set_int(kmessage, kp); |
| 12539 | |
| 12540 | if (con_mode_ftm != QDF_GLOBAL_FTM_MODE) { |
| 12541 | pr_err("Only FTM mode supported!"); |
| 12542 | return -ENOTSUPP; |
| 12543 | } |
| 12544 | |
| 12545 | hdd_set_conparam(con_mode_ftm); |
| 12546 | con_mode = con_mode_ftm; |
| 12547 | |
| 12548 | return ret; |
| 12549 | } |
| 12550 | |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 12551 | static int con_mode_handler_monitor(const char *kmessage, |
| 12552 | struct kernel_param *kp) |
| 12553 | { |
| 12554 | int ret; |
| 12555 | |
| 12556 | ret = param_set_int(kmessage, kp); |
| 12557 | |
| 12558 | if (con_mode_monitor != QDF_GLOBAL_MONITOR_MODE) { |
| 12559 | pr_err("Only Monitor mode supported!"); |
| 12560 | return -ENOTSUPP; |
| 12561 | } |
| 12562 | |
| 12563 | hdd_set_conparam(con_mode_monitor); |
| 12564 | con_mode = con_mode_monitor; |
| 12565 | |
| 12566 | return ret; |
| 12567 | } |
| 12568 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12569 | /** |
| 12570 | * hdd_get_conparam() - driver exit point |
| 12571 | * |
| 12572 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 12573 | * |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12574 | * Return: enum QDF_GLOBAL_MODE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12575 | */ |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12576 | enum QDF_GLOBAL_MODE hdd_get_conparam(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12577 | { |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12578 | return (enum QDF_GLOBAL_MODE) curr_con_mode; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12579 | } |
| 12580 | |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 12581 | void hdd_set_conparam(uint32_t con_param) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12582 | { |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 12583 | curr_con_mode = con_param; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12584 | } |
| 12585 | |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12586 | /** |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 12587 | * hdd_clean_up_pre_cac_interface() - Clean up the pre cac interface |
| 12588 | * @hdd_ctx: HDD context |
| 12589 | * |
| 12590 | * Cleans up the pre cac interface, if it exists |
| 12591 | * |
| 12592 | * Return: None |
| 12593 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12594 | void hdd_clean_up_pre_cac_interface(struct hdd_context *hdd_ctx) |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 12595 | { |
| 12596 | uint8_t session_id; |
| 12597 | QDF_STATUS status; |
Jeff Johnson | 85b5c11 | 2017-08-11 15:15:23 -0700 | [diff] [blame] | 12598 | struct hdd_adapter *precac_adapter; |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 12599 | |
| 12600 | status = wlan_sap_get_pre_cac_vdev_id(hdd_ctx->hHal, &session_id); |
| 12601 | if (QDF_IS_STATUS_ERROR(status)) { |
| 12602 | hdd_err("failed to get pre cac vdev id"); |
| 12603 | return; |
| 12604 | } |
| 12605 | |
| 12606 | precac_adapter = hdd_get_adapter_by_vdev(hdd_ctx, session_id); |
| 12607 | if (!precac_adapter) { |
| 12608 | hdd_err("invalid pre cac adapater"); |
| 12609 | return; |
| 12610 | } |
| 12611 | |
| 12612 | qdf_create_work(0, &hdd_ctx->sap_pre_cac_work, |
| 12613 | wlan_hdd_sap_pre_cac_failure, |
| 12614 | (void *)precac_adapter); |
| 12615 | qdf_sched_work(0, &hdd_ctx->sap_pre_cac_work); |
| 12616 | |
| 12617 | } |
| 12618 | |
| 12619 | /** |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12620 | * hdd_update_ol_config - API to update ol configuration parameters |
| 12621 | * @hdd_ctx: HDD context |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12622 | * |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12623 | * Return: void |
| 12624 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12625 | static void hdd_update_ol_config(struct hdd_context *hdd_ctx) |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12626 | { |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12627 | struct ol_config_info cfg; |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 12628 | struct ol_context *ol_ctx = cds_get_context(QDF_MODULE_ID_BMI); |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12629 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12630 | if (!ol_ctx) |
| 12631 | return; |
| 12632 | |
| 12633 | cfg.enable_self_recovery = hdd_ctx->config->enableSelfRecovery; |
| 12634 | cfg.enable_uart_print = hdd_ctx->config->enablefwprint; |
| 12635 | cfg.enable_fw_log = hdd_ctx->config->enable_fw_log; |
| 12636 | cfg.enable_ramdump_collection = hdd_ctx->config->is_ramdump_enabled; |
Jeff Johnson | b8bf907 | 2016-09-23 17:39:27 -0700 | [diff] [blame] | 12637 | cfg.enable_lpass_support = hdd_lpass_is_supported(hdd_ctx); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12638 | |
| 12639 | ol_init_ini_config(ol_ctx, &cfg); |
| 12640 | } |
| 12641 | |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 12642 | #ifdef FEATURE_RUNTIME_PM |
| 12643 | /** |
| 12644 | * hdd_populate_runtime_cfg() - populate runtime configuration |
| 12645 | * @hdd_ctx: hdd context |
| 12646 | * @cfg: pointer to the configuration memory being populated |
| 12647 | * |
| 12648 | * Return: void |
| 12649 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12650 | static void hdd_populate_runtime_cfg(struct hdd_context *hdd_ctx, |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 12651 | struct hif_config_info *cfg) |
| 12652 | { |
| 12653 | cfg->enable_runtime_pm = hdd_ctx->config->runtime_pm; |
| 12654 | cfg->runtime_pm_delay = hdd_ctx->config->runtime_pm_delay; |
| 12655 | } |
| 12656 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12657 | static void hdd_populate_runtime_cfg(struct hdd_context *hdd_ctx, |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 12658 | struct hif_config_info *cfg) |
| 12659 | { |
| 12660 | } |
| 12661 | #endif |
| 12662 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12663 | /** |
| 12664 | * hdd_update_hif_config - API to update HIF configuration parameters |
| 12665 | * @hdd_ctx: HDD Context |
| 12666 | * |
| 12667 | * Return: void |
| 12668 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12669 | static void hdd_update_hif_config(struct hdd_context *hdd_ctx) |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12670 | { |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 12671 | struct hif_opaque_softc *scn = cds_get_context(QDF_MODULE_ID_HIF); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12672 | struct hif_config_info cfg; |
| 12673 | |
| 12674 | if (!scn) |
| 12675 | return; |
| 12676 | |
| 12677 | cfg.enable_self_recovery = hdd_ctx->config->enableSelfRecovery; |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 12678 | hdd_populate_runtime_cfg(hdd_ctx, &cfg); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12679 | hif_init_ini_config(scn, &cfg); |
Dustin Brown | ee3e059 | 2017-09-07 13:50:11 -0700 | [diff] [blame] | 12680 | |
| 12681 | if (hdd_ctx->config->prevent_link_down) |
| 12682 | hif_vote_link_up(scn); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12683 | } |
| 12684 | |
| 12685 | /** |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 12686 | * hdd_update_dp_config() - Propagate config parameters to Lithium |
| 12687 | * datapath |
| 12688 | * @hdd_ctx: HDD Context |
| 12689 | * |
| 12690 | * Return: 0 for success/errno for failure |
| 12691 | */ |
| 12692 | static int hdd_update_dp_config(struct hdd_context *hdd_ctx) |
| 12693 | { |
| 12694 | struct cdp_config_params params; |
| 12695 | QDF_STATUS status; |
| 12696 | |
| 12697 | params.tso_enable = hdd_ctx->config->tso_enable; |
| 12698 | params.lro_enable = hdd_ctx->config->lro_enable; |
| 12699 | #ifdef QCA_LL_TX_FLOW_CONTROL_V2 |
| 12700 | params.tx_flow_stop_queue_threshold = |
| 12701 | hdd_ctx->config->TxFlowStopQueueThreshold; |
| 12702 | params.tx_flow_start_queue_offset = |
| 12703 | hdd_ctx->config->TxFlowStartQueueOffset; |
| 12704 | #endif |
| 12705 | params.flow_steering_enable = hdd_ctx->config->flow_steering_enable; |
| 12706 | params.napi_enable = hdd_ctx->napi_enable; |
| 12707 | params.tcp_udp_checksumoffload = |
| 12708 | hdd_ctx->config->enable_ip_tcp_udp_checksum_offload; |
| 12709 | |
| 12710 | status = cdp_update_config_parameters( |
| 12711 | cds_get_context(QDF_MODULE_ID_SOC), |
| 12712 | ¶ms); |
| 12713 | if (status) { |
Dustin Brown | a286862 | 2018-03-20 11:38:14 -0700 | [diff] [blame] | 12714 | hdd_err("Failed to attach config parameters"); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 12715 | return status; |
| 12716 | } |
| 12717 | |
| 12718 | return 0; |
| 12719 | } |
| 12720 | |
| 12721 | /** |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12722 | * hdd_update_config() - Initialize driver per module ini parameters |
| 12723 | * @hdd_ctx: HDD Context |
| 12724 | * |
| 12725 | * API is used to initialize all driver per module configuration parameters |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 12726 | * Return: 0 for success, errno for failure |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12727 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12728 | int hdd_update_config(struct hdd_context *hdd_ctx) |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12729 | { |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 12730 | int ret; |
| 12731 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12732 | hdd_update_ol_config(hdd_ctx); |
| 12733 | hdd_update_hif_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 12734 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
| 12735 | ret = hdd_update_cds_config_ftm(hdd_ctx); |
| 12736 | else |
| 12737 | ret = hdd_update_cds_config(hdd_ctx); |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 12738 | ret = hdd_update_user_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 12739 | |
| 12740 | return ret; |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12741 | } |
| 12742 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12743 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 12744 | /** |
| 12745 | * hdd_ra_populate_cds_config() - Populate RA filtering cds configuration |
| 12746 | * @psoc_cfg: pmo psoc Configuration |
| 12747 | * @hdd_ctx: Pointer to hdd context |
| 12748 | * |
| 12749 | * Return: none |
| 12750 | */ |
| 12751 | static inline void hdd_ra_populate_pmo_config( |
| 12752 | struct pmo_psoc_cfg *psoc_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12753 | struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12754 | { |
| 12755 | psoc_cfg->ra_ratelimit_interval = |
| 12756 | hdd_ctx->config->RArateLimitInterval; |
| 12757 | psoc_cfg->ra_ratelimit_enable = |
| 12758 | hdd_ctx->config->IsRArateLimitEnabled; |
| 12759 | } |
| 12760 | #else |
| 12761 | static inline void hdd_ra_populate_pmo_config( |
| 12762 | struct cds_config_info *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12763 | struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12764 | { |
| 12765 | } |
| 12766 | #endif |
Will Huang | 3cd2b7c | 2017-11-17 13:16:56 +0800 | [diff] [blame] | 12767 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12768 | /** |
| 12769 | * hdd_update_pmo_config - API to update pmo configuration parameters |
| 12770 | * @hdd_ctx: HDD context |
| 12771 | * |
| 12772 | * Return: void |
| 12773 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12774 | static int hdd_update_pmo_config(struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12775 | { |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12776 | struct pmo_psoc_cfg psoc_cfg; |
| 12777 | QDF_STATUS status; |
| 12778 | |
| 12779 | /* |
| 12780 | * Value of hdd_ctx->wowEnable can be, |
| 12781 | * 0 - Disable both magic pattern match and pattern byte match. |
| 12782 | * 1 - Enable magic pattern match on all interfaces. |
| 12783 | * 2 - Enable pattern byte match on all interfaces. |
| 12784 | * 3 - Enable both magic patter and pattern byte match on |
| 12785 | * all interfaces. |
| 12786 | */ |
| 12787 | psoc_cfg.magic_ptrn_enable = |
| 12788 | (hdd_ctx->config->wowEnable & 0x01) ? true : false; |
| 12789 | psoc_cfg.ptrn_match_enable_all_vdev = |
| 12790 | (hdd_ctx->config->wowEnable & 0x02) ? true : false; |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 12791 | psoc_cfg.ptrn_id_per_vdev = |
| 12792 | wma_is_service_enabled(wmi_service_unified_wow_capability); |
| 12793 | psoc_cfg.apf_enable = hdd_ctx->config->bpf_packet_filter_enable; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12794 | psoc_cfg.arp_offload_enable = hdd_ctx->config->fhostArpOffload; |
Dustin Brown | 1224e21 | 2017-05-12 14:02:12 -0700 | [diff] [blame] | 12795 | psoc_cfg.hw_filter_mode = hdd_ctx->config->hw_filter_mode; |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 12796 | psoc_cfg.ns_offload_enable_dynamic = hdd_ctx->config->fhostNSOffload; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12797 | psoc_cfg.ns_offload_enable_static = hdd_ctx->config->fhostNSOffload; |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 12798 | psoc_cfg.packet_filter_enabled = !hdd_ctx->config->disablePacketFilter; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12799 | psoc_cfg.ssdp = hdd_ctx->config->ssdp; |
| 12800 | psoc_cfg.enable_mc_list = hdd_ctx->config->fEnableMCAddrList; |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 12801 | psoc_cfg.active_mode_offload = hdd_ctx->config->active_mode_offload; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12802 | psoc_cfg.ap_arpns_support = hdd_ctx->ap_arpns_support; |
Will Huang | 3cd2b7c | 2017-11-17 13:16:56 +0800 | [diff] [blame] | 12803 | psoc_cfg.d0_wow_supported = wma_d0_wow_is_supported(); |
Mukul Sharma | 9223f23 | 2017-03-08 18:42:27 +0530 | [diff] [blame] | 12804 | psoc_cfg.sta_dynamic_dtim = hdd_ctx->config->enableDynamicDTIM; |
| 12805 | psoc_cfg.sta_mod_dtim = hdd_ctx->config->enableModulatedDTIM; |
| 12806 | psoc_cfg.sta_max_li_mod_dtim = hdd_ctx->config->fMaxLIModulatedDTIM; |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 12807 | psoc_cfg.power_save_mode = hdd_ctx->config->enablePowersaveOffload; |
Ravi Kumar Bokka | 05c14e5 | 2017-03-27 14:48:23 +0530 | [diff] [blame] | 12808 | psoc_cfg.auto_power_save_fail_mode = |
| 12809 | hdd_ctx->config->auto_pwr_save_fail_mode; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12810 | |
| 12811 | hdd_ra_populate_pmo_config(&psoc_cfg, hdd_ctx); |
Mukul Sharma | 9223f23 | 2017-03-08 18:42:27 +0530 | [diff] [blame] | 12812 | hdd_nan_populate_pmo_config(&psoc_cfg, hdd_ctx); |
| 12813 | hdd_lpass_populate_pmo_config(&psoc_cfg, hdd_ctx); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12814 | |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 12815 | status = ucfg_pmo_update_psoc_config(hdd_ctx->hdd_psoc, &psoc_cfg); |
| 12816 | if (QDF_IS_STATUS_ERROR(status)) |
| 12817 | hdd_err("failed pmo psoc configuration; status:%d", status); |
| 12818 | |
| 12819 | return qdf_status_to_os_return(status); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12820 | } |
| 12821 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12822 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 12823 | static inline void hdd_update_pno_config(struct pno_user_cfg *pno_cfg, |
| 12824 | struct hdd_config *cfg) |
| 12825 | { |
Varun Reddy Yeturu | bba32e9 | 2017-09-06 13:31:40 -0700 | [diff] [blame] | 12826 | struct nlo_mawc_params *mawc_cfg = &pno_cfg->mawc_params; |
| 12827 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12828 | pno_cfg->channel_prediction = cfg->pno_channel_prediction; |
| 12829 | pno_cfg->top_k_num_of_channels = cfg->top_k_num_of_channels; |
| 12830 | pno_cfg->stationary_thresh = cfg->stationary_thresh; |
| 12831 | pno_cfg->adaptive_dwell_mode = cfg->adaptive_dwell_mode_enabled; |
| 12832 | pno_cfg->channel_prediction_full_scan = |
| 12833 | cfg->channel_prediction_full_scan; |
Varun Reddy Yeturu | bba32e9 | 2017-09-06 13:31:40 -0700 | [diff] [blame] | 12834 | mawc_cfg->enable = cfg->MAWCEnabled && cfg->mawc_nlo_enabled; |
| 12835 | mawc_cfg->exp_backoff_ratio = cfg->mawc_nlo_exp_backoff_ratio; |
| 12836 | mawc_cfg->init_scan_interval = cfg->mawc_nlo_init_scan_interval; |
| 12837 | mawc_cfg->max_scan_interval = cfg->mawc_nlo_max_scan_interval; |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12838 | } |
| 12839 | #else |
| 12840 | static inline void |
| 12841 | hdd_update_pno_config(struct pno_user_cfg *pno_cfg, |
Jeff Johnson | 33a0792 | 2017-10-05 09:08:46 -0700 | [diff] [blame] | 12842 | struct hdd_config *cfg) |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12843 | { |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12844 | } |
| 12845 | #endif |
| 12846 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 12847 | void hdd_update_ie_whitelist_attr(struct probe_req_whitelist_attr *ie_whitelist, |
| 12848 | struct hdd_config *cfg) |
| 12849 | { |
| 12850 | uint8_t i = 0; |
| 12851 | |
| 12852 | ie_whitelist->white_list = cfg->probe_req_ie_whitelist; |
| 12853 | if (!ie_whitelist->white_list) |
| 12854 | return; |
| 12855 | |
| 12856 | ie_whitelist->ie_bitmap[0] = cfg->probe_req_ie_bitmap_0; |
| 12857 | ie_whitelist->ie_bitmap[1] = cfg->probe_req_ie_bitmap_1; |
| 12858 | ie_whitelist->ie_bitmap[2] = cfg->probe_req_ie_bitmap_2; |
| 12859 | ie_whitelist->ie_bitmap[3] = cfg->probe_req_ie_bitmap_3; |
| 12860 | ie_whitelist->ie_bitmap[4] = cfg->probe_req_ie_bitmap_4; |
| 12861 | ie_whitelist->ie_bitmap[5] = cfg->probe_req_ie_bitmap_5; |
| 12862 | ie_whitelist->ie_bitmap[6] = cfg->probe_req_ie_bitmap_6; |
| 12863 | ie_whitelist->ie_bitmap[7] = cfg->probe_req_ie_bitmap_7; |
| 12864 | |
| 12865 | ie_whitelist->num_vendor_oui = cfg->no_of_probe_req_ouis; |
| 12866 | for (i = 0; i < ie_whitelist->num_vendor_oui; i++) |
| 12867 | ie_whitelist->voui[i] = cfg->probe_req_voui[i]; |
| 12868 | } |
| 12869 | |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 12870 | uint32_t hdd_limit_max_per_index_score(uint32_t per_index_score) |
| 12871 | { |
| 12872 | uint8_t i, score; |
| 12873 | |
| 12874 | for (i = 0; i < MAX_INDEX_PER_INI; i++) { |
| 12875 | score = WLAN_GET_SCORE_PERCENTAGE(per_index_score, i); |
| 12876 | if (score > MAX_INDEX_SCORE) |
| 12877 | WLAN_SET_SCORE_PERCENTAGE(per_index_score, |
| 12878 | MAX_INDEX_SCORE, i); |
| 12879 | } |
| 12880 | |
| 12881 | return per_index_score; |
| 12882 | } |
| 12883 | |
| 12884 | /** |
| 12885 | * hdd_update_score_config - API to update candidate scoring related params |
| 12886 | * configuration parameters |
| 12887 | * @score_config: score config to update |
| 12888 | * @cfg: config params |
| 12889 | * |
| 12890 | * Return: 0 if success else err |
| 12891 | */ |
| 12892 | static void hdd_update_score_config( |
| 12893 | struct scoring_config *score_config, struct hdd_config *cfg) |
| 12894 | { |
| 12895 | int total_weight; |
| 12896 | |
| 12897 | score_config->weight_cfg.rssi_weightage = cfg->rssi_weightage; |
| 12898 | score_config->weight_cfg.ht_caps_weightage = cfg->ht_caps_weightage; |
| 12899 | score_config->weight_cfg.vht_caps_weightage = |
| 12900 | cfg->vht_caps_weightage; |
| 12901 | score_config->weight_cfg.he_caps_weightage = |
| 12902 | cfg->he_caps_weightage; |
| 12903 | score_config->weight_cfg.chan_width_weightage = |
| 12904 | cfg->chan_width_weightage; |
| 12905 | score_config->weight_cfg.chan_band_weightage = |
| 12906 | cfg->chan_band_weightage; |
| 12907 | score_config->weight_cfg.nss_weightage = cfg->nss_weightage; |
| 12908 | score_config->weight_cfg.beamforming_cap_weightage = |
| 12909 | cfg->beamforming_cap_weightage; |
| 12910 | score_config->weight_cfg.pcl_weightage = cfg->pcl_weightage; |
| 12911 | score_config->weight_cfg.channel_congestion_weightage = |
| 12912 | cfg->channel_congestion_weightage; |
| 12913 | score_config->weight_cfg.oce_wan_weightage = cfg->oce_wan_weightage; |
| 12914 | |
| 12915 | total_weight = score_config->weight_cfg.rssi_weightage + |
| 12916 | score_config->weight_cfg.ht_caps_weightage + |
| 12917 | score_config->weight_cfg.vht_caps_weightage + |
| 12918 | score_config->weight_cfg.he_caps_weightage + |
| 12919 | score_config->weight_cfg.chan_width_weightage + |
| 12920 | score_config->weight_cfg.chan_band_weightage + |
| 12921 | score_config->weight_cfg.nss_weightage + |
| 12922 | score_config->weight_cfg.beamforming_cap_weightage + |
| 12923 | score_config->weight_cfg.pcl_weightage + |
| 12924 | score_config->weight_cfg.channel_congestion_weightage + |
| 12925 | score_config->weight_cfg.oce_wan_weightage; |
| 12926 | |
| 12927 | if (total_weight > BEST_CANDIDATE_MAX_WEIGHT) { |
| 12928 | hdd_err("total weight is greater than %d fallback to default values", |
| 12929 | BEST_CANDIDATE_MAX_WEIGHT); |
| 12930 | |
| 12931 | score_config->weight_cfg.rssi_weightage = RSSI_WEIGHTAGE; |
| 12932 | score_config->weight_cfg.ht_caps_weightage = |
| 12933 | HT_CAPABILITY_WEIGHTAGE; |
| 12934 | score_config->weight_cfg.vht_caps_weightage = VHT_CAP_WEIGHTAGE; |
| 12935 | score_config->weight_cfg.he_caps_weightage = HE_CAP_WEIGHTAGE; |
| 12936 | score_config->weight_cfg.chan_width_weightage = |
| 12937 | CHAN_WIDTH_WEIGHTAGE; |
| 12938 | score_config->weight_cfg.chan_band_weightage = |
| 12939 | CHAN_BAND_WEIGHTAGE; |
| 12940 | score_config->weight_cfg.nss_weightage = NSS_WEIGHTAGE; |
| 12941 | score_config->weight_cfg.beamforming_cap_weightage = |
| 12942 | BEAMFORMING_CAP_WEIGHTAGE; |
| 12943 | score_config->weight_cfg.pcl_weightage = PCL_WEIGHT; |
| 12944 | score_config->weight_cfg.channel_congestion_weightage = |
| 12945 | CHANNEL_CONGESTION_WEIGHTAGE; |
| 12946 | score_config->weight_cfg.oce_wan_weightage = OCE_WAN_WEIGHTAGE; |
| 12947 | } |
| 12948 | |
| 12949 | score_config->bandwidth_weight_per_index = |
| 12950 | hdd_limit_max_per_index_score( |
| 12951 | cfg->bandwidth_weight_per_index); |
| 12952 | score_config->nss_weight_per_index = |
| 12953 | hdd_limit_max_per_index_score(cfg->nss_weight_per_index); |
| 12954 | score_config->band_weight_per_index = |
| 12955 | hdd_limit_max_per_index_score(cfg->band_weight_per_index); |
| 12956 | |
| 12957 | score_config->rssi_score.best_rssi_threshold = |
| 12958 | cfg->best_rssi_threshold; |
| 12959 | score_config->rssi_score.good_rssi_threshold = |
| 12960 | cfg->good_rssi_threshold; |
| 12961 | score_config->rssi_score.bad_rssi_threshold = |
| 12962 | cfg->bad_rssi_threshold; |
| 12963 | score_config->rssi_score.good_rssi_pcnt = cfg->good_rssi_pcnt; |
| 12964 | score_config->rssi_score.bad_rssi_pcnt = cfg->bad_rssi_pcnt; |
| 12965 | score_config->rssi_score.good_rssi_bucket_size = |
| 12966 | cfg->good_rssi_bucket_size; |
| 12967 | score_config->rssi_score.bad_rssi_bucket_size = |
| 12968 | cfg->bad_rssi_bucket_size; |
| 12969 | score_config->rssi_score.rssi_pref_5g_rssi_thresh = |
| 12970 | cfg->rssi_pref_5g_rssi_thresh; |
| 12971 | |
| 12972 | score_config->esp_qbss_scoring.num_slot = cfg->num_esp_qbss_slots; |
| 12973 | score_config->esp_qbss_scoring.score_pcnt3_to_0 = |
| 12974 | hdd_limit_max_per_index_score( |
| 12975 | cfg->esp_qbss_score_slots3_to_0); |
| 12976 | score_config->esp_qbss_scoring.score_pcnt7_to_4 = |
| 12977 | hdd_limit_max_per_index_score( |
| 12978 | cfg->esp_qbss_score_slots7_to_4); |
| 12979 | score_config->esp_qbss_scoring.score_pcnt11_to_8 = |
| 12980 | hdd_limit_max_per_index_score( |
| 12981 | cfg->esp_qbss_score_slots11_to_8); |
| 12982 | score_config->esp_qbss_scoring.score_pcnt15_to_12 = |
| 12983 | hdd_limit_max_per_index_score( |
| 12984 | cfg->esp_qbss_score_slots15_to_12); |
| 12985 | |
| 12986 | score_config->oce_wan_scoring.num_slot = cfg->num_oce_wan_slots; |
| 12987 | score_config->oce_wan_scoring.score_pcnt3_to_0 = |
| 12988 | hdd_limit_max_per_index_score( |
| 12989 | cfg->oce_wan_score_slots3_to_0); |
| 12990 | score_config->oce_wan_scoring.score_pcnt7_to_4 = |
| 12991 | hdd_limit_max_per_index_score( |
| 12992 | cfg->oce_wan_score_slots7_to_4); |
| 12993 | score_config->oce_wan_scoring.score_pcnt11_to_8 = |
| 12994 | hdd_limit_max_per_index_score( |
| 12995 | cfg->oce_wan_score_slots11_to_8); |
| 12996 | score_config->oce_wan_scoring.score_pcnt15_to_12 = |
| 12997 | hdd_limit_max_per_index_score( |
| 12998 | cfg->oce_wan_score_slots15_to_12); |
| 12999 | |
| 13000 | |
| 13001 | score_config->cb_mode_24G = cfg->nChannelBondingMode24GHz; |
| 13002 | score_config->cb_mode_5G = cfg->nChannelBondingMode5GHz; |
| 13003 | score_config->nss = cfg->enable2x2 ? 2 : 1; |
| 13004 | |
| 13005 | if (cfg->dot11Mode == eHDD_DOT11_MODE_AUTO || |
| 13006 | cfg->dot11Mode == eHDD_DOT11_MODE_11ax || |
| 13007 | cfg->dot11Mode == eHDD_DOT11_MODE_11ax_ONLY) |
| 13008 | score_config->he_cap = 1; |
| 13009 | |
| 13010 | if (score_config->he_cap || |
| 13011 | cfg->dot11Mode == eHDD_DOT11_MODE_11ac || |
| 13012 | cfg->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY) |
| 13013 | score_config->vht_cap = 1; |
| 13014 | |
| 13015 | if (score_config->vht_cap || cfg->dot11Mode == eHDD_DOT11_MODE_11n || |
| 13016 | cfg->dot11Mode == eHDD_DOT11_MODE_11n_ONLY) |
| 13017 | score_config->ht_cap = 1; |
| 13018 | |
| 13019 | if (score_config->vht_cap && cfg->enableVhtFor24GHzBand) |
| 13020 | score_config->vht_24G_cap = 1; |
| 13021 | |
| 13022 | if (cfg->enableTxBF) |
| 13023 | score_config->beamformee_cap = 1; |
| 13024 | |
| 13025 | } |
| 13026 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13027 | /** |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 13028 | * hdd_update_dfs_config() - API to update dfs configuration parameters. |
| 13029 | * @hdd_ctx: HDD context |
| 13030 | * |
| 13031 | * Return: 0 if success else err |
| 13032 | */ |
| 13033 | static int hdd_update_dfs_config(struct hdd_context *hdd_ctx) |
| 13034 | { |
| 13035 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 13036 | struct hdd_config *cfg = hdd_ctx->config; |
| 13037 | struct dfs_user_config dfs_cfg; |
| 13038 | QDF_STATUS status; |
| 13039 | |
| 13040 | dfs_cfg.dfs_is_phyerr_filter_offload = !!cfg->fDfsPhyerrFilterOffload; |
| 13041 | status = ucfg_dfs_update_config(psoc, &dfs_cfg); |
| 13042 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13043 | hdd_err("failed dfs psoc configuration"); |
| 13044 | return -EINVAL; |
| 13045 | } |
| 13046 | |
| 13047 | return 0; |
| 13048 | } |
| 13049 | |
| 13050 | /** |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13051 | * hdd_update_scan_config - API to update scan configuration parameters |
| 13052 | * @hdd_ctx: HDD context |
| 13053 | * |
| 13054 | * Return: 0 if success else err |
| 13055 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13056 | static int hdd_update_scan_config(struct hdd_context *hdd_ctx) |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13057 | { |
| 13058 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 13059 | struct scan_user_cfg scan_cfg; |
| 13060 | struct hdd_config *cfg = hdd_ctx->config; |
| 13061 | QDF_STATUS status; |
| 13062 | |
| 13063 | scan_cfg.active_dwell = cfg->nActiveMaxChnTime; |
| 13064 | scan_cfg.passive_dwell = cfg->nPassiveMaxChnTime; |
| 13065 | scan_cfg.conc_active_dwell = cfg->nActiveMaxChnTimeConc; |
| 13066 | scan_cfg.conc_passive_dwell = cfg->nPassiveMaxChnTimeConc; |
| 13067 | scan_cfg.conc_max_rest_time = cfg->nRestTimeConc; |
| 13068 | scan_cfg.conc_min_rest_time = cfg->min_rest_time_conc; |
| 13069 | scan_cfg.conc_idle_time = cfg->idle_time_conc; |
Abhishek Singh | 158fe25 | 2017-03-23 11:09:34 +0530 | [diff] [blame] | 13070 | /* convert to ms */ |
| 13071 | scan_cfg.scan_cache_aging_time = |
| 13072 | cfg->scanAgingTimeout * 1000; |
| 13073 | scan_cfg.prefer_5ghz = cfg->nRoamPrefer5GHz; |
| 13074 | scan_cfg.select_5ghz_margin = cfg->nSelect5GHzMargin; |
| 13075 | scan_cfg.scan_bucket_threshold = cfg->first_scan_bucket_threshold; |
| 13076 | scan_cfg.rssi_cat_gap = cfg->nRssiCatGap; |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13077 | scan_cfg.scan_dwell_time_mode = cfg->scan_adaptive_dwell_mode; |
Kapil Gupta | fa9a8c6 | 2017-04-10 15:25:40 +0530 | [diff] [blame] | 13078 | scan_cfg.is_snr_monitoring_enabled = cfg->fEnableSNRMonitoring; |
Jeff Johnson | 81c00d0 | 2017-11-07 12:34:36 -0800 | [diff] [blame] | 13079 | scan_cfg.usr_cfg_probe_rpt_time = cfg->scan_probe_repeat_time; |
| 13080 | scan_cfg.usr_cfg_num_probes = cfg->scan_num_probes; |
Abhishek Singh | b58164a | 2017-07-19 18:47:23 +0530 | [diff] [blame] | 13081 | scan_cfg.is_bssid_hint_priority = cfg->is_bssid_hint_priority; |
Kiran Kumar Lokere | d547fdd | 2017-09-13 17:20:55 -0700 | [diff] [blame] | 13082 | scan_cfg.enable_mac_spoofing = cfg->enable_mac_spoofing; |
Abhishek Singh | c87bb04 | 2018-01-30 17:10:42 +0530 | [diff] [blame] | 13083 | scan_cfg.sta_miracast_mcc_rest_time = |
| 13084 | cfg->sta_miracast_mcc_rest_time_val; |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13085 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 13086 | hdd_update_pno_config(&scan_cfg.pno_cfg, cfg); |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 13087 | hdd_update_ie_whitelist_attr(&scan_cfg.ie_whitelist, cfg); |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 13088 | hdd_update_score_config(&scan_cfg.score_config, cfg); |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 13089 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13090 | status = ucfg_scan_update_user_config(psoc, &scan_cfg); |
| 13091 | if (status != QDF_STATUS_SUCCESS) { |
| 13092 | hdd_err("failed pmo psoc configuration"); |
| 13093 | return -EINVAL; |
| 13094 | } |
| 13095 | |
| 13096 | return 0; |
| 13097 | } |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13098 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13099 | int hdd_update_components_config(struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13100 | { |
| 13101 | int ret; |
| 13102 | |
| 13103 | ret = hdd_update_pmo_config(hdd_ctx); |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13104 | if (ret) |
| 13105 | return ret; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 13106 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13107 | ret = hdd_update_scan_config(hdd_ctx); |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 13108 | if (ret) |
| 13109 | return ret; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 13110 | |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 13111 | ret = hdd_update_tdls_config(hdd_ctx); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 13112 | if (ret) |
| 13113 | return ret; |
| 13114 | |
| 13115 | ret = hdd_update_dp_config(hdd_ctx); |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 13116 | if (ret) |
| 13117 | return ret; |
| 13118 | |
| 13119 | ret = hdd_update_dfs_config(hdd_ctx); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13120 | |
| 13121 | return ret; |
| 13122 | } |
| 13123 | |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 13124 | /** |
| 13125 | * wlan_hdd_get_dfs_mode() - get ACS DFS mode |
| 13126 | * @mode : cfg80211 DFS mode |
| 13127 | * |
| 13128 | * Return: return SAP ACS DFS mode else return ACS_DFS_MODE_NONE |
| 13129 | */ |
| 13130 | enum sap_acs_dfs_mode wlan_hdd_get_dfs_mode(enum dfs_mode mode) |
| 13131 | { |
| 13132 | switch (mode) { |
| 13133 | case DFS_MODE_ENABLE: |
| 13134 | return ACS_DFS_MODE_ENABLE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 13135 | case DFS_MODE_DISABLE: |
| 13136 | return ACS_DFS_MODE_DISABLE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 13137 | case DFS_MODE_DEPRIORITIZE: |
| 13138 | return ACS_DFS_MODE_DEPRIORITIZE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 13139 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 13140 | hdd_debug("ACS dfs mode is NONE"); |
| 13141 | return ACS_DFS_MODE_NONE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 13142 | } |
| 13143 | } |
| 13144 | |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 13145 | /** |
| 13146 | * hdd_enable_disable_ca_event() - enable/disable channel avoidance event |
| 13147 | * @hddctx: pointer to hdd context |
| 13148 | * @set_value: enable/disable |
| 13149 | * |
| 13150 | * When Host sends vendor command enable, FW will send *ONE* CA ind to |
| 13151 | * Host(even though it is duplicate). When Host send vendor command |
| 13152 | * disable,FW doesn't perform any action. Whenever any change in |
| 13153 | * CA *and* WLAN is in SAP/P2P-GO mode, FW sends CA ind to host. |
| 13154 | * |
| 13155 | * return - 0 on success, appropriate error values on failure. |
| 13156 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13157 | 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] | 13158 | { |
| 13159 | QDF_STATUS status; |
| 13160 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 13161 | if (0 != wlan_hdd_validate_context(hddctx)) |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 13162 | return -EAGAIN; |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 13163 | |
| 13164 | if (!hddctx->config->goptimize_chan_avoid_event) { |
| 13165 | hdd_warn("goptimize_chan_avoid_event ini param disabled"); |
| 13166 | return -EINVAL; |
| 13167 | } |
| 13168 | |
| 13169 | status = sme_enable_disable_chanavoidind_event(hddctx->hHal, set_value); |
| 13170 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 13171 | hdd_err("Failed to send chan avoid command to SME"); |
| 13172 | return -EINVAL; |
| 13173 | } |
| 13174 | return 0; |
| 13175 | } |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 13176 | |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13177 | /** |
| 13178 | * hdd_set_roaming_in_progress() - to set the roaming in progress flag |
| 13179 | * @value: value to set |
| 13180 | * |
| 13181 | * This function will set the passed value to roaming in progress flag. |
| 13182 | * |
| 13183 | * Return: None |
| 13184 | */ |
| 13185 | void hdd_set_roaming_in_progress(bool value) |
| 13186 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13187 | struct hdd_context *hdd_ctx; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13188 | |
| 13189 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13190 | if (!hdd_ctx) { |
| 13191 | hdd_err("HDD context is NULL"); |
| 13192 | return; |
| 13193 | } |
| 13194 | |
| 13195 | hdd_ctx->roaming_in_progress = value; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 13196 | hdd_debug("Roaming in Progress set to %d", value); |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13197 | } |
| 13198 | |
| 13199 | /** |
| 13200 | * hdd_is_roaming_in_progress() - check if roaming is in progress |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 13201 | * @adapter - HDD adapter |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13202 | * |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 13203 | * 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] | 13204 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13205 | bool hdd_is_roaming_in_progress(struct hdd_adapter *adapter) |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13206 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13207 | struct hdd_context *hdd_ctx; |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 13208 | bool ret_status = false; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13209 | |
| 13210 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13211 | if (!hdd_ctx) { |
| 13212 | hdd_err("HDD context is NULL"); |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 13213 | return ret_status; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13214 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 13215 | hdd_debug("dev mode = %d, roaming_in_progress = %d", |
| 13216 | adapter->device_mode, hdd_ctx->roaming_in_progress); |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 13217 | ret_status = ((adapter->device_mode == QDF_STA_MODE) && |
| 13218 | hdd_ctx->roaming_in_progress); |
| 13219 | |
| 13220 | return ret_status; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13221 | } |
| 13222 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13223 | /** |
| 13224 | * hdd_is_connection_in_progress() - check if connection is in |
| 13225 | * progress |
| 13226 | * @session_id: session id |
| 13227 | * @reason: scan reject reason |
| 13228 | * |
| 13229 | * Go through each adapter and check if Connection is in progress |
| 13230 | * |
| 13231 | * Return: true if connection is in progress else false |
| 13232 | */ |
| 13233 | bool hdd_is_connection_in_progress(uint8_t *session_id, |
| 13234 | enum scan_reject_states *reason) |
| 13235 | { |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 13236 | struct hdd_station_ctx *hdd_sta_ctx = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13237 | struct hdd_adapter *adapter = NULL; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13238 | uint8_t sta_id = 0; |
| 13239 | uint8_t *sta_mac = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13240 | struct hdd_context *hdd_ctx; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13241 | |
| 13242 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13243 | if (!hdd_ctx) { |
| 13244 | hdd_err("HDD context is NULL"); |
| 13245 | return false; |
| 13246 | } |
| 13247 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 13248 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13249 | hdd_info("Adapter with device mode %s(%d) exists", |
| 13250 | hdd_device_mode_to_string(adapter->device_mode), |
| 13251 | adapter->device_mode); |
| 13252 | if (((QDF_STA_MODE == adapter->device_mode) |
| 13253 | || (QDF_P2P_CLIENT_MODE == adapter->device_mode) |
| 13254 | || (QDF_P2P_DEVICE_MODE == adapter->device_mode)) |
| 13255 | && (eConnectionState_Connecting == |
| 13256 | (WLAN_HDD_GET_STATION_CTX_PTR(adapter))-> |
| 13257 | conn_info.connState)) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 13258 | hdd_debug("%pK(%d) Connection is in progress", |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13259 | WLAN_HDD_GET_STATION_CTX_PTR(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13260 | adapter->session_id); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13261 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13262 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13263 | *reason = CONNECTION_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13264 | } |
| 13265 | return true; |
| 13266 | } |
Archana Ramachandran | 62886ce | 2017-03-24 14:46:32 -0700 | [diff] [blame] | 13267 | /* |
| 13268 | * sme_neighbor_middle_of_roaming is for LFR2 |
| 13269 | * hdd_is_roaming_in_progress is for LFR3 |
| 13270 | */ |
| 13271 | if (((QDF_STA_MODE == adapter->device_mode) && |
| 13272 | sme_neighbor_middle_of_roaming( |
| 13273 | WLAN_HDD_GET_HAL_CTX(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13274 | adapter->session_id)) || |
Archana Ramachandran | 62886ce | 2017-03-24 14:46:32 -0700 | [diff] [blame] | 13275 | hdd_is_roaming_in_progress(adapter)) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 13276 | hdd_debug("%pK(%d) Reassociation in progress", |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13277 | WLAN_HDD_GET_STATION_CTX_PTR(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13278 | adapter->session_id); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13279 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13280 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13281 | *reason = REASSOC_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13282 | } |
| 13283 | return true; |
| 13284 | } |
| 13285 | if ((QDF_STA_MODE == adapter->device_mode) || |
| 13286 | (QDF_P2P_CLIENT_MODE == adapter->device_mode) || |
| 13287 | (QDF_P2P_DEVICE_MODE == adapter->device_mode)) { |
| 13288 | hdd_sta_ctx = |
| 13289 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 13290 | if ((eConnectionState_Associated == |
Vignesh Viswanathan | 0a56929 | 2018-02-14 15:34:47 +0530 | [diff] [blame] | 13291 | hdd_sta_ctx->conn_info.connState) |
| 13292 | && sme_is_sta_key_exchange_in_progress( |
| 13293 | hdd_ctx->hHal, adapter->session_id)) { |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13294 | sta_mac = (uint8_t *) |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 13295 | &(adapter->mac_addr.bytes[0]); |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 13296 | hdd_debug("client " MAC_ADDRESS_STR |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13297 | " is in middle of WPS/EAPOL exchange.", |
| 13298 | MAC_ADDR_ARRAY(sta_mac)); |
| 13299 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13300 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13301 | *reason = EAPOL_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13302 | } |
| 13303 | return true; |
| 13304 | } |
| 13305 | } else if ((QDF_SAP_MODE == adapter->device_mode) || |
| 13306 | (QDF_P2P_GO_MODE == adapter->device_mode)) { |
| 13307 | for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; |
| 13308 | sta_id++) { |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 13309 | if (!((adapter->sta_info[sta_id].in_use) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13310 | && (OL_TXRX_PEER_STATE_CONN == |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 13311 | adapter->sta_info[sta_id].peer_state))) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13312 | continue; |
| 13313 | |
| 13314 | sta_mac = (uint8_t *) |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 13315 | &(adapter->sta_info[sta_id]. |
Jeff Johnson | f235651 | 2017-10-21 16:04:12 -0700 | [diff] [blame] | 13316 | sta_mac.bytes[0]); |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 13317 | hdd_debug("client " MAC_ADDRESS_STR |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13318 | " of SAP/GO is in middle of WPS/EAPOL exchange", |
| 13319 | MAC_ADDR_ARRAY(sta_mac)); |
| 13320 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13321 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13322 | *reason = SAP_EAPOL_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13323 | } |
| 13324 | return true; |
| 13325 | } |
| 13326 | if (hdd_ctx->connection_in_progress) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 13327 | hdd_debug("AP/GO: connection is in progress"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13328 | return true; |
| 13329 | } |
| 13330 | } |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13331 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 13332 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13333 | return false; |
| 13334 | } |
| 13335 | |
| 13336 | /** |
| 13337 | * hdd_restart_sap() - to restart SAP in driver internally |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13338 | * @ap_adapter: Pointer to SAP struct hdd_adapter structure |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13339 | * |
| 13340 | * Return: None |
| 13341 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13342 | void hdd_restart_sap(struct hdd_adapter *ap_adapter) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13343 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 13344 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 13345 | struct hdd_hostapd_state *hostapd_state; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13346 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13347 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13348 | tsap_Config_t *sap_config; |
| 13349 | void *sap_ctx; |
| 13350 | |
| 13351 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 13352 | sap_config = &hdd_ap_ctx->sap_config; |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 13353 | sap_ctx = hdd_ap_ctx->sap_context; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13354 | |
| 13355 | mutex_lock(&hdd_ctx->sap_lock); |
| 13356 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
| 13357 | wlan_hdd_del_station(ap_adapter); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13358 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
| 13359 | qdf_event_reset(&hostapd_state->qdf_stop_bss_event); |
| 13360 | if (QDF_STATUS_SUCCESS == wlansap_stop_bss(sap_ctx)) { |
| 13361 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 13362 | qdf_wait_for_event_completion(&hostapd_state-> |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13363 | qdf_stop_bss_event, |
| 13364 | SME_CMD_TIMEOUT_VALUE); |
| 13365 | |
| 13366 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13367 | hdd_err("SAP Stop Failed"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13368 | goto end; |
| 13369 | } |
| 13370 | } |
| 13371 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13372 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13373 | ap_adapter->device_mode, ap_adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 13374 | hdd_green_ap_start_state_mc(hdd_ctx, ap_adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 13375 | false); |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13376 | hdd_err("SAP Stop Success"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13377 | |
| 13378 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13379 | hdd_err("SAP Not able to set AP IEs"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13380 | wlansap_reset_sap_config_add_ie(sap_config, |
| 13381 | eUPDATE_IE_ALL); |
| 13382 | goto end; |
| 13383 | } |
| 13384 | |
| 13385 | qdf_event_reset(&hostapd_state->qdf_event); |
| 13386 | if (wlansap_start_bss(sap_ctx, hdd_hostapd_sap_event_cb, |
| 13387 | sap_config, |
| 13388 | ap_adapter->dev) != QDF_STATUS_SUCCESS) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13389 | hdd_err("SAP Start Bss fail"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13390 | wlansap_reset_sap_config_add_ie(sap_config, |
| 13391 | eUPDATE_IE_ALL); |
| 13392 | goto end; |
| 13393 | } |
| 13394 | |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13395 | hdd_info("Waiting for SAP to start"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13396 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 13397 | qdf_wait_for_event_completion(&hostapd_state->qdf_event, |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13398 | SME_CMD_TIMEOUT_VALUE); |
| 13399 | wlansap_reset_sap_config_add_ie(sap_config, |
| 13400 | eUPDATE_IE_ALL); |
| 13401 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13402 | hdd_err("SAP Start failed"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13403 | goto end; |
| 13404 | } |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13405 | hdd_err("SAP Start Success"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13406 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 13407 | if (hostapd_state->bss_state == BSS_START) { |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13408 | policy_mgr_incr_active_session(hdd_ctx->hdd_psoc, |
| 13409 | ap_adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13410 | ap_adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 13411 | hdd_green_ap_start_state_mc(hdd_ctx, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 13412 | ap_adapter->device_mode, |
| 13413 | true); |
| 13414 | } |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13415 | } |
| 13416 | end: |
| 13417 | mutex_unlock(&hdd_ctx->sap_lock); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13418 | } |
| 13419 | |
| 13420 | /** |
| 13421 | * hdd_check_and_restart_sap_with_non_dfs_acs() - Restart SAP |
| 13422 | * with non dfs acs |
| 13423 | * |
| 13424 | * Restarts SAP in non-DFS ACS mode when STA-AP mode DFS is not supported |
| 13425 | * |
| 13426 | * Return: None |
| 13427 | */ |
| 13428 | void hdd_check_and_restart_sap_with_non_dfs_acs(void) |
| 13429 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13430 | struct hdd_adapter *ap_adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13431 | struct hdd_context *hdd_ctx; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13432 | cds_context_type *cds_ctx; |
| 13433 | |
| 13434 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13435 | if (!hdd_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13436 | hdd_err("HDD context is NULL"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13437 | return; |
| 13438 | } |
| 13439 | |
| 13440 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 13441 | if (!cds_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13442 | hdd_err("Invalid CDS Context"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13443 | return; |
| 13444 | } |
| 13445 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13446 | if (policy_mgr_get_concurrency_mode(hdd_ctx->hdd_psoc) |
| 13447 | != (QDF_STA_MASK | QDF_SAP_MASK)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13448 | hdd_info("Concurrency mode is not SAP"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13449 | return; |
| 13450 | } |
| 13451 | |
| 13452 | ap_adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE); |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 13453 | if (ap_adapter != NULL && test_bit(SOFTAP_BSS_STARTED, |
| 13454 | &ap_adapter->event_flags) && |
| 13455 | wlan_reg_is_dfs_ch(hdd_ctx->hdd_pdev, |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 13456 | ap_adapter->session.ap.operating_channel)) { |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13457 | |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13458 | 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] | 13459 | ap_adapter->session.ap.sap_config.channel = |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13460 | AUTO_CHANNEL_SELECT; |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 13461 | ap_adapter->session.ap.sap_config. |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13462 | acs_cfg.acs_mode = true; |
| 13463 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13464 | hdd_restart_sap(ap_adapter); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13465 | } |
| 13466 | } |
| 13467 | |
| 13468 | /** |
| 13469 | * hdd_set_connection_in_progress() - to set the connection in |
| 13470 | * progress flag |
| 13471 | * @value: value to set |
| 13472 | * |
| 13473 | * This function will set the passed value to connection in progress flag. |
| 13474 | * If value is previously being set to true then no need to set it again. |
| 13475 | * |
| 13476 | * Return: true if value is being set correctly and false otherwise. |
| 13477 | */ |
| 13478 | bool hdd_set_connection_in_progress(bool value) |
| 13479 | { |
| 13480 | bool status = true; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13481 | struct hdd_context *hdd_ctx; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13482 | |
| 13483 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13484 | if (!hdd_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13485 | hdd_err("HDD context is NULL"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13486 | return false; |
| 13487 | } |
| 13488 | |
| 13489 | qdf_spin_lock(&hdd_ctx->connection_status_lock); |
| 13490 | /* |
| 13491 | * if the value is set to true previously and if someone is |
| 13492 | * trying to make it true again then it could be some race |
| 13493 | * condition being triggered. Avoid this situation by returning |
| 13494 | * false |
| 13495 | */ |
| 13496 | if (hdd_ctx->connection_in_progress && value) |
| 13497 | status = false; |
| 13498 | else |
| 13499 | hdd_ctx->connection_in_progress = value; |
| 13500 | qdf_spin_unlock(&hdd_ctx->connection_status_lock); |
| 13501 | return status; |
| 13502 | } |
| 13503 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13504 | 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] | 13505 | { |
| 13506 | if (!adapter) { |
| 13507 | hdd_err("Invalid adapter"); |
| 13508 | return -EINVAL; |
| 13509 | } |
| 13510 | hdd_info("Send MCC P2P QUOTA to WMA: %d", set_value); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13511 | sme_cli_set_command(adapter->session_id, |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 13512 | WMA_VDEV_MCC_SET_TIME_QUOTA, |
| 13513 | set_value, VDEV_CMD); |
| 13514 | return 0; |
| 13515 | |
| 13516 | } |
| 13517 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13518 | 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] | 13519 | { |
| 13520 | if (!adapter) { |
| 13521 | hdd_err("Invalid adapter"); |
| 13522 | return -EINVAL; |
| 13523 | } |
| 13524 | |
| 13525 | hdd_info("Send MCC latency WMA: %d", set_value); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13526 | sme_cli_set_command(adapter->session_id, |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 13527 | WMA_VDEV_MCC_SET_TIME_LATENCY, |
| 13528 | set_value, VDEV_CMD); |
| 13529 | return 0; |
| 13530 | } |
| 13531 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13532 | 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] | 13533 | *psoc, uint8_t vdev_id) |
| 13534 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13535 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13536 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 13537 | |
| 13538 | /* |
| 13539 | * Currently PSOC is not being used. But this logic will |
| 13540 | * change once we have the converged implementation of |
| 13541 | * HDD context per PSOC in place. This would break if |
| 13542 | * multiple vdev objects reuse the vdev id. |
| 13543 | */ |
| 13544 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 13545 | if (!adapter) |
| 13546 | hdd_err("Get adapter by vdev id failed"); |
| 13547 | |
| 13548 | return adapter; |
| 13549 | } |
| 13550 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13551 | 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] | 13552 | int8_t *rssi, int8_t *snr) |
| 13553 | { |
| 13554 | QDF_STATUS status; |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 13555 | struct csr_roam_profile *roam_profile; |
Hanumanth Reddy Pothula | 9005178 | 2017-05-04 22:14:43 +0530 | [diff] [blame] | 13556 | |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 13557 | roam_profile = hdd_roam_profile(adapter); |
Hanumanth Reddy Pothula | 9005178 | 2017-05-04 22:14:43 +0530 | [diff] [blame] | 13558 | 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] | 13559 | roam_profile, bssid, rssi, snr); |
Hanumanth Reddy Pothula | 9005178 | 2017-05-04 22:14:43 +0530 | [diff] [blame] | 13560 | if (QDF_STATUS_SUCCESS != status) { |
| 13561 | hdd_warn("sme_get_rssi_snr_by_bssid failed"); |
| 13562 | return -EINVAL; |
| 13563 | } |
| 13564 | |
| 13565 | return 0; |
| 13566 | } |
| 13567 | |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13568 | /** |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13569 | * hdd_set_limit_off_chan_for_tos() - set limit off-channel command parameters |
| 13570 | * @adapter - HDD adapter |
| 13571 | * @tos - type of service |
| 13572 | * @status - status of the traffic |
| 13573 | * |
| 13574 | * Return: 0 on success and non zero value on failure |
| 13575 | */ |
| 13576 | |
| 13577 | int hdd_set_limit_off_chan_for_tos(struct hdd_adapter *adapter, enum tos tos, |
| 13578 | bool is_tos_active) |
| 13579 | { |
| 13580 | int ac_bit; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13581 | struct hdd_context *hdd_ctx; |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13582 | uint32_t max_off_chan_time = 0; |
| 13583 | QDF_STATUS status; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13584 | int ret; |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13585 | tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter); |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13586 | |
| 13587 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 13588 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 13589 | |
| 13590 | if (ret < 0) { |
| 13591 | hdd_err("failed to set limit off chan params"); |
| 13592 | return ret; |
| 13593 | } |
| 13594 | |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13595 | ac_bit = limit_off_chan_tbl[tos][HDD_AC_BIT_INDX]; |
| 13596 | |
| 13597 | if (is_tos_active) |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 13598 | adapter->active_ac |= ac_bit; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13599 | else |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 13600 | adapter->active_ac &= ~ac_bit; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13601 | |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 13602 | if (adapter->active_ac) { |
| 13603 | if (adapter->active_ac & HDD_AC_VO_BIT) { |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13604 | max_off_chan_time = |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13605 | limit_off_chan_tbl[TOS_VO][HDD_DWELL_TIME_INDX]; |
| 13606 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13607 | PM_LATENCY); |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 13608 | } else if (adapter->active_ac & HDD_AC_VI_BIT) { |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13609 | max_off_chan_time = |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13610 | limit_off_chan_tbl[TOS_VI][HDD_DWELL_TIME_INDX]; |
| 13611 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13612 | PM_LATENCY); |
| 13613 | } else { |
| 13614 | /*ignore this command if only BE/BK is active */ |
| 13615 | is_tos_active = false; |
| 13616 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13617 | hdd_ctx->config->conc_system_pref); |
| 13618 | } |
| 13619 | } else { |
| 13620 | /* No active tos */ |
| 13621 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13622 | hdd_ctx->config->conc_system_pref); |
| 13623 | } |
| 13624 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13625 | status = sme_send_limit_off_channel_params(hal, adapter->session_id, |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13626 | is_tos_active, max_off_chan_time, |
| 13627 | hdd_ctx->config->nRestTimeConc, true); |
| 13628 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 13629 | hdd_err("failed to set limit off chan params"); |
| 13630 | ret = -EINVAL; |
| 13631 | } |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13632 | |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13633 | return ret; |
| 13634 | } |
| 13635 | |
| 13636 | /** |
| 13637 | * hdd_reset_limit_off_chan() - reset limit off-channel command parameters |
| 13638 | * @adapter - HDD adapter |
| 13639 | * |
| 13640 | * Return: 0 on success and non zero value on failure |
| 13641 | */ |
| 13642 | int hdd_reset_limit_off_chan(struct hdd_adapter *adapter) |
| 13643 | { |
| 13644 | struct hdd_context *hdd_ctx; |
| 13645 | int ret; |
| 13646 | QDF_STATUS status; |
| 13647 | tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter); |
| 13648 | |
| 13649 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 13650 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 13651 | if (ret < 0) |
| 13652 | return ret; |
| 13653 | |
| 13654 | /* set the system preferece to default */ |
| 13655 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13656 | hdd_ctx->config->conc_system_pref); |
| 13657 | |
| 13658 | /* clear the bitmap */ |
| 13659 | adapter->active_ac = 0; |
| 13660 | |
| 13661 | hdd_debug("reset ac_bitmap for session %hu active_ac %0x", |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13662 | adapter->session_id, adapter->active_ac); |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13663 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13664 | status = sme_send_limit_off_channel_params(hal, adapter->session_id, |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13665 | false, 0, 0, false); |
| 13666 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 13667 | hdd_err("failed to reset limit off chan params"); |
| 13668 | ret = -EINVAL; |
| 13669 | } |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13670 | |
| 13671 | return ret; |
| 13672 | } |
| 13673 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13674 | /** |
| 13675 | * hdd_start_driver_ops_timer() - Starts driver ops inactivity timer |
| 13676 | * @drv_op: Enum indicating driver op |
| 13677 | * |
| 13678 | * Return: none |
| 13679 | */ |
| 13680 | void hdd_start_driver_ops_timer(int drv_op) |
| 13681 | { |
| 13682 | memset(drv_ops_string, 0, MAX_OPS_NAME_STRING_SIZE); |
| 13683 | switch (drv_op) { |
| 13684 | case eHDD_DRV_OP_PROBE: |
| 13685 | memcpy(drv_ops_string, "probe", sizeof("probe")); |
| 13686 | break; |
| 13687 | case eHDD_DRV_OP_REMOVE: |
| 13688 | memcpy(drv_ops_string, "remove", sizeof("remove")); |
| 13689 | break; |
| 13690 | case eHDD_DRV_OP_SHUTDOWN: |
| 13691 | memcpy(drv_ops_string, "shutdown", sizeof("shutdown")); |
| 13692 | break; |
| 13693 | case eHDD_DRV_OP_REINIT: |
| 13694 | memcpy(drv_ops_string, "reinit", sizeof("reinit")); |
| 13695 | break; |
Arunk Khandavalli | e9ef42a | 2017-10-04 14:49:51 +0530 | [diff] [blame] | 13696 | case eHDD_DRV_OP_IFF_UP: |
| 13697 | memcpy(drv_ops_string, "iff_up", sizeof("iff_up")); |
| 13698 | break; |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13699 | } |
| 13700 | |
Dustin Brown | 45ed4bb | 2017-12-18 12:00:13 -0800 | [diff] [blame] | 13701 | hdd_drv_ops_task = current; |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13702 | qdf_timer_start(&hdd_drv_ops_inactivity_timer, |
| 13703 | HDD_OPS_INACTIVITY_TIMEOUT); |
| 13704 | } |
| 13705 | |
| 13706 | /** |
| 13707 | * hdd_stop_driver_ops_timer() - Stops driver ops inactivity timer |
| 13708 | * |
| 13709 | * Return: none |
| 13710 | */ |
| 13711 | void hdd_stop_driver_ops_timer(void) |
| 13712 | { |
| 13713 | qdf_timer_sync_cancel(&hdd_drv_ops_inactivity_timer); |
| 13714 | } |
| 13715 | |
| 13716 | /** |
| 13717 | * hdd_drv_ops_inactivity_handler() - Timeout handler for driver ops |
| 13718 | * inactivity timer |
| 13719 | * |
| 13720 | * Return: None |
| 13721 | */ |
| 13722 | void hdd_drv_ops_inactivity_handler(void) |
| 13723 | { |
| 13724 | hdd_err("%s: %d Sec timer expired while in .%s", |
| 13725 | __func__, HDD_OPS_INACTIVITY_TIMEOUT/1000, drv_ops_string); |
| 13726 | |
Dustin Brown | 45ed4bb | 2017-12-18 12:00:13 -0800 | [diff] [blame] | 13727 | if (hdd_drv_ops_task) { |
| 13728 | printk("Call stack for \"%s\"\n", hdd_drv_ops_task->comm); |
| 13729 | qdf_print_thread_trace(hdd_drv_ops_task); |
| 13730 | } else { |
| 13731 | hdd_err("hdd_drv_ops_task is null"); |
| 13732 | } |
| 13733 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13734 | /* Driver shutdown is stuck, no recovery possible at this point */ |
| 13735 | if (0 == qdf_mem_cmp(&drv_ops_string[0], "shutdown", |
| 13736 | sizeof("shutdown"))) |
| 13737 | QDF_BUG(0); |
| 13738 | |
Rajeev Kumar | 1e57b9c | 2018-01-04 16:17:10 -0800 | [diff] [blame] | 13739 | if (cds_is_fw_down()) { |
| 13740 | hdd_err("FW is down"); |
| 13741 | return; |
| 13742 | } |
| 13743 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13744 | if (cds_is_self_recovery_enabled()) |
Anurag Chouhan | 4085ff7 | 2017-10-05 18:09:56 +0530 | [diff] [blame] | 13745 | cds_trigger_recovery(QDF_REASON_UNSPECIFIED); |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13746 | else |
| 13747 | QDF_BUG(0); |
| 13748 | } |
| 13749 | |
Sravan Kumar Kairam | d80c766 | 2017-10-03 16:11:05 +0530 | [diff] [blame] | 13750 | void hdd_pld_ipa_uc_shutdown_pipes(void) |
| 13751 | { |
| 13752 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13753 | |
| 13754 | if (!hdd_ctx) |
| 13755 | return; |
| 13756 | |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 13757 | ucfg_ipa_uc_force_pipe_shutdown(hdd_ctx->hdd_pdev); |
Sravan Kumar Kairam | d80c766 | 2017-10-03 16:11:05 +0530 | [diff] [blame] | 13758 | } |
| 13759 | |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 13760 | /** |
| 13761 | * hdd_set_rx_mode_rps() - Enable/disable RPS in SAP mode |
| 13762 | * @struct hdd_context *hdd_ctx |
| 13763 | * @struct hdd_adapter *padapter |
| 13764 | * @bool enble |
| 13765 | * |
| 13766 | * Return: none |
| 13767 | */ |
| 13768 | void hdd_set_rx_mode_rps(bool enable) |
| 13769 | { |
| 13770 | struct cds_config_info *cds_cfg = cds_get_ini_config(); |
| 13771 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13772 | struct hdd_adapter *adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE); |
| 13773 | |
| 13774 | if (adapter && hdd_ctx && |
| 13775 | !hdd_ctx->rps && cds_cfg->uc_offload_enabled) { |
| 13776 | if (enable && !cds_cfg->rps_enabled) |
| 13777 | hdd_send_rps_ind(adapter); |
| 13778 | else if (!enable && cds_cfg->rps_enabled) |
| 13779 | hdd_send_rps_disable_ind(adapter); |
| 13780 | } |
| 13781 | } |
| 13782 | |
Hanumanth Reddy Pothula | 3862ca9 | 2018-01-12 16:44:10 +0530 | [diff] [blame] | 13783 | bool hdd_is_cli_iface_up(struct hdd_context *hdd_ctx) |
| 13784 | { |
| 13785 | struct hdd_adapter *adapter = NULL; |
| 13786 | |
| 13787 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 13788 | if ((adapter->device_mode == QDF_STA_MODE || |
| 13789 | adapter->device_mode == QDF_P2P_CLIENT_MODE) && |
| 13790 | qdf_atomic_test_bit(DEVICE_IFACE_OPENED, |
| 13791 | &adapter->event_flags)){ |
| 13792 | return true; |
| 13793 | } |
| 13794 | } |
| 13795 | |
| 13796 | return false; |
| 13797 | } |
| 13798 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13799 | /* Register the module init/exit functions */ |
| 13800 | module_init(hdd_module_init); |
| 13801 | module_exit(hdd_module_exit); |
| 13802 | |
| 13803 | MODULE_LICENSE("Dual BSD/GPL"); |
| 13804 | MODULE_AUTHOR("Qualcomm Atheros, Inc."); |
| 13805 | MODULE_DESCRIPTION("WLAN HOST DEVICE DRIVER"); |
| 13806 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13807 | module_param_call(con_mode, con_mode_handler, param_get_int, &con_mode, |
| 13808 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13809 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 13810 | module_param_call(con_mode_ftm, con_mode_handler_ftm, param_get_int, |
| 13811 | &con_mode_ftm, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 13812 | |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 13813 | module_param_call(con_mode_monitor, con_mode_handler_monitor, param_get_int, |
| 13814 | &con_mode_monitor, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 13815 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13816 | module_param_call(fwpath, fwpath_changed_handler, param_get_string, &fwpath, |
| 13817 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 13818 | |
| 13819 | module_param(enable_dfs_chan_scan, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 13820 | |
| 13821 | module_param(enable_11d, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 13822 | |
| 13823 | module_param(country_code, charp, S_IRUSR | S_IRGRP | S_IROTH); |